EXERCISE 9. Determine the mod bits from Figure 7-24 and write them in Table 7-7. MODE (mod) FIELD CODES mod 00 01 10 DESCRIPTION MEMORY MODE: NO DISPLACEMENT FOLLOWS MEMORY MODE: 8-BIT DISPLACEMENT MEMORY MODE: 16- OR 32- BIT DISPLACEMENT REGISTER MODE NOTE: WHEN r/m EQUALS 110. THERE IS A 1 6-BIT DISPLACEMENT. Figure 7-24 10. Determine the reg bits from Figure 7-25 and write them in Table 7-7. REGISTERS SPECIFIED BY REG (reg) FIELD reg 000 001 0 10 01 1 100 101 11 1 16- OR 32- BIT DATA OPERATION AL CL DL AH CH BH 16- BIT DATA OPERATION w = l AX CX SP BP I 32- BIT DATA OPERATION w = l o r n o w f i e l d ECX EDX EBX ESP ESI Figure 7-25 11. You now have the binary value for the first nibble of the second byte. Write the hex value below the binary value in Table 7-7. 12. Determine the r/m bit from Figure 7-26 and write it in Table 7-7. 16-BIT ADDRESSING EFFECTIVE ADDRESSES SPECIFIED BY r/m AND mod FIELDS r/m 0 0 0 001 0 1 0 = [Bx [BX SI - 100 110 111 6 d8] Figure 7-26 [SI d 1 [Bx d 1 6 ] 13. You now have the binary value for the second nibble of the second byte. Write the hex value below the binary value in Table 7-7.
Instruction Formats - II 14. What is the hex displacement value in the instruction MOV CX,[BX SI 0060H]? 15. For the displacement 0060H, what hex code follows the first two bytes 8B 88? 16. What is the complete instruction code for the mnemonic MOV CX,[BX SI 0060H]? 17. To test the instruction code for the mnemonic MOV CX,[BX SI 0060H], do the following on the 32-BIT MICROPROCESSOR circuit board. 1. Turn the SINGLE CYCLE switch to OFF and press RESET. 2. Enter "0200" in the CS register. 3. Enter "1000" in the IP register. 4. Enter "01 00" in the DS register. 5. Enter a base value "3000" in the BX register. 6. Enter an index value "0004" in the SI register. With a base value of 3000, an index value of 0004, and a displacement of 0060, what is the EA? 18. Continue by entering the memory operand and instruction code. 1. Press <EXIT> and then press <READ>. 2. Enter the logical address "0100 3064" for the memory operand. 3. Starting at address 04064, enter "88 77" for the operand, which is 7788. 4. Press <READ> and enter the logical address "0200 1000" for the instruction code. 5. Starting at address 03000, enter the instruction code "8B88 60 00". 6. Press <STEP> to execute the instruction code.
EXERCISE 29. You now have the binary value for the second nibble of the second byte. Write the hex value below the binary value in Table 7-8. 30. Determine the mod bits from Figure 7-28 and write it in Table 7-8. MODE (mod) FIELD CODES mod 00 01 10 1 1 DESCRIPTION MEMORY MODE: NO DISPLACEMENT FOLLOWS * MEMORY MODE: 8-BIT DISPLACEMENT MEMORY MODE: 16- OR 32-BIT DISPLACEMENT REGISTER MODE * NOTE: WHEN r/m EQUALS 110. THERE IS A 16-BIT DISPLACEMENT. Figure 7-28 Determine the reg bits from Figure 7-29 and write it in Table 7-8. REGISTERS SPECIFIED BY REG (reg) FIELD 16- OR 32- BIT DATA OPERATION w = O AL CL DL BL AH CH DH BH 16-BIT DATA OPERATION w = l or no w field AX CX DX BX SP BP SI Dl 32-BIT DATA OPERATION w = l or no w field EAX ECX EDX EBX ESP EBP ESI EDI Figure 7-29 32. You now have the binary value for the first nibble of the third byte. Write the hex value below the binary value in Table 7-8. 33. Determine the r/m bits from Figure 7-30 and write it in Table 7-8. 32-BIT ADDRESSING EFFECTIVE ADDRESSES SPECIFIED BY r/m AND mod FIELDS Figure 7-30 34. You now have the binary value for the second nibble of the third byte. Write the hex value below the binary value in Table 7-8.
InstructionFormats- II 35. The scaled index (EDI*2)is given in the mnemonic. Determine the ss bits from Figure 7-31 and write them in Table 7-8. SS FIELD IN S-I-B BYTE ss 00 0 1 10 1 1 SCALE FACTOR 1 2 4 8 Figure 7-31 36. Determine the index bits from Figure 7-32 and write them in Table 7-8. INDEX (index) FIELD IN S-1-B BYTE SPECIFIED BY INDEX REGISTER index 000 001 010 01 1 100 101 110 1 1 1 *NOTE: WHEN THE INDEX FIELD IS 100. THEN THE SS FIELD MUST EQUAL 00. Figure 7-32 INDEX REGISTER EAX ECX EDX EBX NO INDEX REG* EBP ESI EDI Determine the base bits from Figure 7-33 and write them in Table 7-8. BASE (base) FIELD IN S-1-B BYTE SPECIFIED BY EFFECTIVE ADDRESS base mod = 01 mod = 10 000 001 010 01 1 100 101 110 11 1 [EDX d8] [ECX [EDX d8] [ESP d8] [EBP d8] [EAX (S*l) [ECX [EDX [EBX [ESP [EBP NOTE: S*l EQUALS THE SCALING FACTOR TIMES THE INDEX VALUE. Figure 7-33 38. You now have the binary value for the last instruction byte. Write the hex value below the binary value in Table 7-8. 39. What is the complete instruction code for the mnemonic MOV [ECX (ED l*2)], BX?
EXERCISE 7- For the instruction MOV EBX,[ECX (EDI*4) 0520F8AB], what are the r/m field bits? 32- BIT ADDRESSING EFFECTIVE ADDRESSES SPECIFIED BY r/m AND mod FIELDS r /m mod = 00 mod = 01 mod = 10 000 001 010 011 100 101 110 111 [EAX] [ E C X ] [ E D X ] [ E B X ] s- i- b present d32 [ E S I ] [ EDI] [EAX d8] [ECX d 8 ] [EDX d 8 ] [EBX d 8 ] s-i-b present [EBP db] [ESI db] [EDI d8] [EAX d32] [ECX d32] [EDX d32] [EBX d32] s- i- b present [EBP d32] [ESI d32] [EDI d32] Figure 7-36 For the instruction MOV EBX,[ECX (EDI*4) 0520F8AB], what are the index field bits? INDEX (index) FIELD IN S-1-B BYTE SPECIFIED BY INDCX REGISTER index 000 001 010 01 1 100 101 110 1 1 1 INDEX REGISTER EAX ECX EDX EBX NO INDEX REG* EBP ESI ED1 *NOTE: WHEN THE INDEX FIELD IS 100. THEN THE SS FIELD MUST EQUAL 00. Figure 7-37
Instruction Formats- II BASE (base) FIELD IN 5-1-0 BYTE SPECIFIED BY EFFECTIVE ADDRESS base m o d = 00 m o d = 01 mod = 10 000 [EAX (S*I)] [EAX (S*l) db] [EAX (S*l) d32] 001 [ECX (S*I)] [ECX (S*I) db] [ECX (S*l) d 3 2 ] 010 [EDx (S*I)] [EDX (S*I) d8] [EDX ( S * I ) d32] 011 [EBx (S*l)] [EBX (S*I) d8] [EBX (S*I) d32] 100 101 110 [ESP (S*l)] [d32 (S*I)] [ESl (S*I)] [ESP (S*I) d8] [EBP (S*I) d8] [ESI (S*I) d8] [ESP (S*I) d32] [EBP (S*I) t d32] [ESl (S*I) d32] 1 1 1 [ED1 (S*l)] [ED1 (S*I) d8] [ED1 (S*I) d32] NOTE: S'I EQUALS THE SCALING FACTOR TIMES THE INDEX VALUE. Figure 7-38 5. For the instruction MOV [ESl (EDX*8)],EAX, what are the base field bits?