l02 - Assembly Language And Machine Code C Statement: int...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Assembly Language And Machine Code C Statement: int foo; foo = 15; foo = foo + 7; MIPS Assembly Language: ori $1,$0,15 # set foo to 15 addiu $1,$1,7 # add 7 to foo (register 1 holds the value of foo) MIPS Machine Instructions: 00110100000000010000000000001111 00100100001000010000000000000111 A Simple Computer r1 00110100000000010000000000001111 00100100001000010000000000000111 fetch ins at pc decode ... ... Memory pc execute update pc function units rN r0 22 control Number Representation Decimal: base 10, digits: '0', '1', ..., '9' (683) 10 = 6 10 2 + 8 10 1 + 3 10 Binary: base 2, digits: '0', '1' (1101) 2 = 1 2 3 + 1 2 2 + 0 2 1 + 1 2 = 8 + 4 + + 1 = (13) 10 Hexadecimal: base 16, digits: '0' .. '9', 'a' .. 'f' 'a' = 10, 'b' = 11, 'c' = 12, 'd' = 13, 'e' = 14, 'f' = 15 ( a 6) 16 = 10 16 1 + 6 16 = (166) 10 Often write 0xa6 instead of ( a 6) 16 . Number Representation A Useful Trick: Converting between hexadecimal (hex) and binary. 0xe3f8 = 14 16 3 + 3 16 2 + 15 16 1 + 8 16 = 14 (2 4 ) 3 + 3 (2 4 ) 2 + 15 (2 4 ) 1 + 8 (2 4 ) = (1110) 2 (2 4 ) 3 + (0011) 2 (2 4 ) 2 + (1111) 2 (2 4 ) 1 + (1000) 2 (2 4 ) = (1110 | {z } 0xe 0011 | {z } 0x3 1111 | {z } 0xf 1000 | {z } 0x8 ) 2 1 hex digit = 4 bits Negative Numbers Various representations possible for signed binary arithmetic. Sign-Magnitude: reserve left-most bit for the sign + Easy to negate a number- Multiple zeros- Arithmetic is more complicated Example: 4-bit numbers (+5) 10 is given by 101 (- 5) 10 is given by 1 101 Negative Numbers...
View Full Document

Page1 / 22

l02 - Assembly Language And Machine Code C Statement: int...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online