ZONG Wen Department of Computer Science and Engineering The Chinese University of Hong Kong...
-
Upload
annice-hawkins -
Category
Documents
-
view
215 -
download
0
Transcript of ZONG Wen Department of Computer Science and Engineering The Chinese University of Hong Kong...
![Page 1: ZONG Wen Department of Computer Science and Engineering The Chinese University of Hong Kong wzong@cse.cuhk.edu.hk.](https://reader035.fdocuments.in/reader035/viewer/2022062517/56649e7e5503460f94b82047/html5/thumbnails/1.jpg)
CSCI 2510 Tutorial 1Basic Assembly and Data Representation
ZONG Wen
Department of Computer Science and EngineeringThe Chinese University of Hong Kong
![Page 2: ZONG Wen Department of Computer Science and Engineering The Chinese University of Hong Kong wzong@cse.cuhk.edu.hk.](https://reader035.fdocuments.in/reader035/viewer/2022062517/56649e7e5503460f94b82047/html5/thumbnails/2.jpg)
Main topic:
1. Write an assembly program with given instruction
2. Two’s complement operation
3. Ordering of bytes in data
![Page 3: ZONG Wen Department of Computer Science and Engineering The Chinese University of Hong Kong wzong@cse.cuhk.edu.hk.](https://reader035.fdocuments.in/reader035/viewer/2022062517/56649e7e5503460f94b82047/html5/thumbnails/3.jpg)
Write a machine program with given instruction
Basic component of a computer
![Page 4: ZONG Wen Department of Computer Science and Engineering The Chinese University of Hong Kong wzong@cse.cuhk.edu.hk.](https://reader035.fdocuments.in/reader035/viewer/2022062517/56649e7e5503460f94b82047/html5/thumbnails/4.jpg)
Write a machine program with given instruction
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 -95Add [Memory] {to ACC} e.g. Add [2132]Multiply Constant {to ACC} e.g. Multiply 23Multiply [Memory]{to ACC} e.g. Multiply [298]
![Page 5: ZONG Wen Department of Computer Science and Engineering The Chinese University of Hong Kong wzong@cse.cuhk.edu.hk.](https://reader035.fdocuments.in/reader035/viewer/2022062517/56649e7e5503460f94b82047/html5/thumbnails/5.jpg)
Write a machine program with given instruction
Variable x and y are stored in address 1000 and 1004, try to implement x2 + y2, store the result in 1008.
Load [1000]; load data to registerMultiply [1000]; perform memory + register operationStore [1008]; store temporary result to memoryLoad[1004]; Multiply[1004];Add[1008];Store[1008]; store result
![Page 6: ZONG Wen Department of Computer Science and Engineering The Chinese University of Hong Kong wzong@cse.cuhk.edu.hk.](https://reader035.fdocuments.in/reader035/viewer/2022062517/56649e7e5503460f94b82047/html5/thumbnails/6.jpg)
Operation on two’s complement
Example: (–6) + 8 * 3 – 1 Step 1 11111010 + (00001000 * 00000011) – 00000001Step 2 (11111010 + 00011000) – 00000001Step 3 00010010 – 00000001Step 4 00010001Step 5 17 (decimal answer without overflow)
![Page 7: ZONG Wen Department of Computer Science and Engineering The Chinese University of Hong Kong wzong@cse.cuhk.edu.hk.](https://reader035.fdocuments.in/reader035/viewer/2022062517/56649e7e5503460f94b82047/html5/thumbnails/7.jpg)
Operation on two’s complement
Example: (–6) + 8 * 3 – 1 Step 1 11111010 + (00001000 * 00000011) – 00000001Step 2 (11111010 + 00011000) – 00000001Step 3 00010010 – 00000001Step 4 00010001Step 5 17 (decimal answer without overflow)
![Page 8: ZONG Wen Department of Computer Science and Engineering The Chinese University of Hong Kong wzong@cse.cuhk.edu.hk.](https://reader035.fdocuments.in/reader035/viewer/2022062517/56649e7e5503460f94b82047/html5/thumbnails/8.jpg)
Big endian and little endian
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
![Page 9: ZONG Wen Department of Computer Science and Engineering The Chinese University of Hong Kong wzong@cse.cuhk.edu.hk.](https://reader035.fdocuments.in/reader035/viewer/2022062517/56649e7e5503460f94b82047/html5/thumbnails/9.jpg)
Big endian and little endian
For a data of 4 bytes: 90AB12CD
Big endian:
![Page 10: ZONG Wen Department of Computer Science and Engineering The Chinese University of Hong Kong wzong@cse.cuhk.edu.hk.](https://reader035.fdocuments.in/reader035/viewer/2022062517/56649e7e5503460f94b82047/html5/thumbnails/10.jpg)
Big endian and little endian
For a data of 4 bytes: 90AB12CD
Little endian:
![Page 11: ZONG Wen Department of Computer Science and Engineering The Chinese University of Hong Kong wzong@cse.cuhk.edu.hk.](https://reader035.fdocuments.in/reader035/viewer/2022062517/56649e7e5503460f94b82047/html5/thumbnails/11.jpg)
Float point representation
![Page 12: ZONG Wen Department of Computer Science and Engineering The Chinese University of Hong Kong wzong@cse.cuhk.edu.hk.](https://reader035.fdocuments.in/reader035/viewer/2022062517/56649e7e5503460f94b82047/html5/thumbnails/12.jpg)
Q&A