Professional Documents
Culture Documents
8 29 13 PDF
8 29 13 PDF
1
High-level vs. Assembly language
1. a=x+y–z
2. if x > y
then x:= x + y
else x:= x - y
“directly” understands.
2
3
Understanding Assembly Language
represent
• Signed integers
• Fractions
• Pictures?
Memory
01001011
11011010
1 00 1 1 0 0 0 Can you read
0o00 the contents
of these
memory
cells?
4
Visualizing instruction execution
registers
Memory
0 500 x r0
1 24 y r1 ALU
-32
2 z r2
0
3 a r3
Address data processor
load y into r2
a = x + y - z load z into r0
r3 ← r1 + r2
r0 ← r3 – r0
store r0 into a
5
Assembly language instructions for a
Load x, r1
Load y, r2
Load z, r0
Add r3, r1, r2
Sub r0, r3, r0
Store r0, a
completely different.
6
Binary or Machine Language program
0 31
010100 11001100…000
0
Load address of x
Operation
code
0 31
110010 11 01 10
Add r3 r1 r2 unused
7
Can we distinguish program from data?
Program
Both are bit strings.
Data Indistinguishable.
MEMORY
crash.
8
Bits, bytes, words
Bit: 0, 1
0 01010000
1 11110000 word 0
0000000
2
11111111
3
00001111
4
10111011
5 word 1
00111100
6
00000111
7
9
0 Word 0
Word 1
4
Word 2
8
12 Word 3
10
Registers vs. memory
approximately 1 ns or less).
MIPS registers
11
register assembly name Comment
r0 $zero Always 0
12
Example assembly language programs
Example 1 f=g+h–i
Example 2. g = h + A[8]
13
Machine language representations
0 18 8 17 0 32
6 5 5 5 5 6
14