Assignment #1 by Wang Lin

Assembly Language Department of Computer Science

Instructor: 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:

  1. 4ABC + 4ABC
  2. 4ABC16 = 0100 1010 1011 11002

    +4ABC16 = +0100 1010 1011 11002

    957816 1001 0101 0111 10002

    Since the signed bit is changed, the calculation is overflowed.

  3. A123 + A321
  4. A12316 = 1010 0001 0010 00112

    +A32116 = +1010 0011 0010 00012

    444416 0100 0100 0100 01002

    Since the signed bit is changed, the calculation is overflowed.

  5. 0101 + 0101
  6. 010116 = 0000 0001 0000 00012

    +010116 = +0000 0001 0000 00012

    020216 = 0000 0010 0000 00102

  7. 0101 – 0101
  8. 010116 = 0000 0001 0000 00012

    -010116 = 0000 0001 0000 00012 +1111 1110 1111 11112 (2`S complement)

    000016 = 0000 0000 0000 00002

  9. CEBC – FBDD

CEBC16 = 1100 1110 1011 11002

-FBDD16 = 1111 1011 1101 11012 +0000 0100 0010 00112 (2`S complement)

D2DF16 = 1101 0010 1101 11112

Question 2. Show the respective 2’s complement 8-bit representation of the following decimal numbers:

Answer:

  1. 23 = 16+4+2+1 = 0001 01112
  2. –68 = -(64+4) = -(0100 01002) = 1011 11002
  3. 150 cannot be represented because the largest decimal number represented by 8-bit signed binary is 127.
  4. –128 = 1000 00002
  5. 128 cannot be represented because the largest decimal number represented by 8-bit signed binary is 127.
  6. 1126 cannot be represented because the largest decimal number represented by 8-bit signed binary is 127.

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 = ACU = 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