Docsity

Assembler Instructions and Data Representation - Prof. Edward Bosworth, Assignments of Programming Languages

Toggle sidebar
bg1
1. (10 points) What is the range of values that can be represented as 12–bit
unsigned integers?
ANSWER: The range of unsigned N–bit integers is 0 through 2N – 1.
For 12–bit unsigned integers, the range is 0 through 212 – 1,
or 0 through 4,095.
COMMENT: This is the range of integer values useable as a
displacement in the base register/displacement
addressing scheme.
GRADES:83, 83, 80, 77, 73,
67, 66, 66, 65, 65, 60
59, 58, 57, 55, 55, 43, 40, 31
Average = 62.3, Median = 65.
pf3
pf4
pf5
pf8

Partial preview of the text

Download Assembler Instructions and Data Representation - Prof. Edward Bosworth and more Assignments Programming Languages in PDF only on Docsity!

  1. (10 points) What is the range of values that can be represented as 12–bit unsigned integers? ANSWER: The range of unsigned N–bit integers is 0 through 2 N - 1. For 12–bit unsigned integers, the range is 0 through 2 12
  • 1, or 0 through 4,095. COMMENT: This is the range of integer values useable as a displacement in the base register/displacement addressing scheme.

GRADES :83, 83, 80, 77, 73,

Average = 62.3, Median = 65.

  1. (10 points) What is the packed decimal representation of the following numbers? a) The negative number –45. b) The positive number 1. c) 0 (the number zero) ANSWER: a) 04 56 7D b) 01 87 6C c) 0C COMMENT: A zero is always stored as 0C or some variant of that. It is never stored as 0D.
  1. (10 points) Register 10 contains the value 0x0000 1300. Register 11 contains the value 0x0000 2400. What is the address referenced by the object code address reference B12A? HINT: This is easy to do in hexadecimal, but can also be done in decimal. Answer : The reference is to an address in Base Register | Offset format. The base register is specified by the hexadecimal digit B, so it is R11 with contents X‘2400’. The offset is the three digit number X‘ 12A’. The address is X‘252A’.
  1. (10 points) Use the values of the registers given above to answer this question. The op code for the load register from full–word instruction is X‘58’. Consider the object code 58 C0 A2 3B. a) What register is being loaded? b) What is the address of the full–word that is being loaded into the register? Answer : This is a type RX instruction. Its format is as follows: Source code: L R1,D2(X2,B2) Object code: OP R 1 X 2 B 2 D 2 D 2 D 2 Look at the object code in question: 58 C 0 A2 3B a) The register being loaded is represented by X‘C’. It is register 12. b) The reference is to an address in Base Register | Offset format. X 2 = 0 indicates that indexed addressing is not used. The base register is specified by the hexadecimal digit A so it is R10; its contents are X‘1300’. The offset is the three digit number X‘ 23B’. The address is X‘153B’.
  1. (15 points) Prior to a division operation, the values in three registers are as follows: R7 contains the value 13, R8 contains the value 0, and R9 contains the value 62. The operation DR 8,7 is performed. After the operation, what value is in each register? DR 8,7 causes the number in the register pair (R8, R9) to be divided by R7. Before the division R8 contains the high–order 32 bits of the dividend R9 contains the low–order 32 bits of the dividend R7 contains the 32–bit divisor After the division R8 contains the remainder R9 contains the quotient The 64–bit number in register pair (R8,R9) has decimal value equal to 62. Actually it is 0 2 32 + 621. 62 / 13 = 4 with a remainder of 10. After the division R7 contains a 13. This is unchanged. R8 contains a 10. This is the remainder. R9 contains a 4 This is the quotient. 62 = 134 + 10 = 52 + 10
  1. (15 points) You are given an array of ten 16–bit half–words, beginning at address HW. Use the BXLE instruction to write a loop that sums these ten values and returns the value in register R6. In a high–level language, this is HW[0] + HW[1] + … + HW[9]. Answer : Here is one version of the code. There are equivalent answers. BXLE uses an even–odd register pair as follows: The even register contains the increment. Here I use R8. The odd register contains the limit. Here I use R9. LA R6,0 SET THE SUM TO ZERO LA R7,0 I USE REGISTER R7 AS THE INDEX LA R8,2 THIS IS THE INCREMENT. LA R9,18 THIS IS THE LIMIT. ADDLOOP AH R6,HW(R7) ADD THE ELEMENT BXLE R7,R8,ADDLOOP LOOP BACK Recall that the index register must contain the byte offset of the array element, not just an index, which is an artifact of higher level languages. The ten elements in array HW are found at addresses HW, HW+2, HW+4, HW+6, … HW+18. Element HW[K] is at byte offset K2 from HW[0].