Presentation is loading. Please wait.

Presentation is loading. Please wait.

ZONG Wen Department of Computer Science and Engineering The Chinese University of Hong Kong

Similar presentations


Presentation on theme: "ZONG Wen Department of Computer Science and Engineering The Chinese University of Hong Kong"— Presentation transcript:

1 ZONG Wen Department of Computer Science and Engineering The Chinese University of Hong Kong wzong@cse.cuhk.edu.hk

2 1. Write an assembly program with given instruction 2. Two’s complement operation 3. Ordering of bytes in data

3 Basic component of a computer

4 There are only 6 machine instructions on a single- accumulator processor, namely: Load [Memory]{to ACC}e.g. Load [2872] Store [Memory]{from ACC}e.g. Store [1536] Add Constant{to ACC}e.g. Add -95 Add [Memory]{to ACC}e.g. Add [2132] Multiply Constant{to ACC}e.g. Multiply 23 Multiply [Memory]{to ACC}e.g. Multiply [298]

5 Variable x and y are stored in address 1000 and 1004, try to implement x 2 + y 2, store the result in 1008. Load [1000]; load data to register Multiply [1000]; perform memory + register operation Store [1008]; store temporary result to memory Load[1004]; Multiply[1004]; Add[1008]; Store[1008]; store result

6 Example: (–6) + 8 * 3 – 1 Step 1  11111010 + (00001000 * 00000011) – 00000001 Step 2  (11111010 + 00011000) – 00000001 Step 3  00010010 – 00000001 Step 4  00010001 Step 5  17 (decimal answer without overflow)

7 Example: (–6) + 8 * 3 – 1 Step 1  11111010 + (00001000 * 00000011) – 00000001 Step 2  (11111010 + 00011000) – 00000001 Step 3  00010010 – 00000001 Step 4  00010001 Step 5  17 (decimal answer without overflow)

8 In big endian, you store the most significant byte in the smallest address In little endian, you store the least significant byte in the smallest address

9 For a data of 4 bytes: 90AB12CD Big endian:

10 For a data of 4 bytes: 90AB12CD Little endian:

11

12


Download ppt "ZONG Wen Department of Computer Science and Engineering The Chinese University of Hong Kong"

Similar presentations


Ads by Google