Assignment #1 by Wang Lin
Assembly Language
Department of Computer ScienceInstructor: Fady SAID Date Due: 1 Week.
Question 1. Add the following Hexadecimal values while considering that they are in 2’s complement 16-bit representation:
Answer:
4ABC16 = 0100 1010 1011 11002
+4ABC16
957816
1001 0101 0111 10002Since the signed bit is changed, the calculation is overflowed.
A12316 = 1010 0001 0010 00112
+A32116
= +1010 0011 0010 00012444416
0100 0100 0100 01002Since the signed bit is changed, the calculation is overflowed.
010116 = 0000 0001 0000 00012
+010116
= +0000 0001 0000 00012020216
= 0000 0010 0000 00102010116
= 0000 0001 0000 00012-010116
= 0000 0001 0000 00012 +1111 1110 1111 11112 (2`S complement)000016
= 0000 0000 0000 00002CEBC16
-FBDD16
= 1111 1011 1101 11012 +0000 0100 0010 00112 (2`S complement)D2DF16
= 1101 0010 1101 11112Question 2. Show the respective 2’s complement 8-bit representation of the following decimal numbers:
Answer:
Question 4. Considering having a hypothetical machine, show the fetch and execute cycles of the following machine instructions, as shown in memory. Assume that the initial value of your PC is at memory location 400, and that it increments by 2.
Mem-Addr---> Mem-content
400 ---> 1902
402 ---> 5904
404 ---> 5906
406 ---> 6908
408 ---> 290A
40A ---> 1904
40C ---> 7904
40E ---> 2904
….
902 ---> 00A0
904 ---> 0100
906 ---> 0101
908 ---> 0002
90A ---> 0234
Recall that:
h: load from memory location to AC
2h: store from AC to memory location
5h: add from memory location to AC
6h: subtract memory location from AC
7h: multiply memory location by AC
Considering that X, Y, Z, U, and V are stored at memory locations: 902, 904, 906, 908, and 90A respectively, derive the formula(s) that this machine code is calculating.
Answer:
Add.---> Content |
Explanation |
Equivalent |
400 ---> 1902 |
AC = (902)=00A0 |
AC = X |
402 ---> 5904 |
AC = AC+(904) = 00A0+0100 = 01A0 |
AC = AC+Y= X + Y |
404 ---> 5906 |
AC = AC+(906) = 01A0+0101 = 02A1 |
AC = AC+Z = X+Y+Z |
406 ---> 6908 |
AC = AC –(908)= 02A1-0002 = 029F |
AC = AC –U = X+Y+Z-U |
408 ---> 290A |
(90A) = AC |
V = AC =X+Y+Z-U |
40A ---> 1904 |
AC = (904)= 0100 |
AC = Y |
40C ---> 7904 |
AC = AC*(904) =0100*0100 OVERFLOW |
AC = Y * Y |
40E ---> 2904 |
(904)= AC |
|
… … |
|
|
902 ---> 00A0 X |
|
|
904 ---> 0100 Y |
|
|
906 ---> 0101 Z |
|
|
908 ---> 0002 U |
|
|
90A ---> 0234 V |
|
|