|
Introduction:BackgroundThe task of this lab consists of assembling instructions in a memory that stores instructions along with memory that stores data and reads it from or writes it to registers. The inputs are entered using debug commands to change register and memory values. Some of the debug commands are indicated as follows:
The address inputs are indicated with brackets representing the address to access memory. The addresses are indicated as follows:
The registers are eight bits representing the byte, sixteen bits representing the word up to 32 bits representing the double word to memory. The eight bit registers are indicated as follows: The sixteen bit registers are indicated as follows: AX, BX, CX, DX. Problem DescriptionThis lab will use the real mode instruction set. Instructions are stored in the CS register and accessed using an offset called the IP (Instruction Pointer). Every time a new instruction or set of instructions is entered the IP will have to be set to the same memory location where the instructions are being assembled. One of the things that has to be remembered is that the least significant part of a number has to be located at the lowest addressed byte of a word or double word. Instructions or data will be written to memory and registers by using debug commands which will set up each problem. Assembly language uses registers to load for data, instructions, or advance the counter for the address of the memory. The instruction register will point to the next instruction. Some of the assembly language instructions will be to demonstrate arithmetic and logic functions, others will change the flag register bits and demonstrate how jumps work. The assembly language instructions are to be carried out with the T debug command. Also, the result of which will be sent to the registers. Goals and Specifications
Final Results1. We are instructed to type DEBUG at the command prompt in order to be able to perform other instructions. 2. As we typed R at the command, we got values of certain registers.
3. Typing R AX at the prompt allowed us to change the value of the contents of the AX register. So, we input the new value of AX, which was 55AAH. The value of AL was taken from the lower byte of AX, which was AAH. Typing R AL gives an error (br error to be exact). 4. The code for the parity flag is given as:
The code shown on our screen is PE, which stands for Even Parity. 5. Typing UP changed the value of the direction flag to UP. We changed the value of DS register to 0E00 as well as ES register to 1000. 6. We changed the value of the DS register to 0E00 as well as the ES register to 1000.
DS = OEOO DS overlap ES the answer is: overlapping 7. The physical address of the first memory location displayed was 0E00:0200. PA = 0E200, the offset of 200H relative to the DS. Also to display the content of memory at an offset 300H for the code segment we typed the command D CS:300 8. The ASCII character stored at addresses DS:2C0 through DS2C4 were ABCD%. The command to store A1B2C3 at DS:200 is E 200 "A1B2C3". 9. The memory locations were five and the placed value in the memory location ES:105 was 12. 10. The command is: M DS:20 2F ES:10 11. The assembly language instruction that is represented by machine code C3H is RET 12. BL is the destination. 13. The machine code is 00D3. 14. The value of the offset is EA = 0432 that was used by the MOV command. There were three bytes because we had the machine code 8A5002 * 4 = 24 / 8 = 3.
15. The value of the DL register: 55h
16. After resetting the instruction pointer, we entered the multiple instructions:
17. Table for running the instructions from problem 16.
18.
The value of the parity flag is PE Even Parity. FC is equivalent in binary to 1111 1100 which contains 6 ones that made it even.
19. The addressing mode was register indirect addressing mode.
20. The addressing mode was Direct Addressing Mode.
21. The physical address corresponding to the logical address DS:31B:
The physical address corresponding to the logical address DS:30B:
22.
23. The values in BX and CX registers were swapped. After the instruction: 24. The SP changed from FFFE to FFEC. Second, the top of stack address decreases as items are pushed. 25. The value of the SP register went from FFEE to FFFO (SP increased by two) the CX register went from FFFF to 0000. In other words, it was popped out. 26. The new value of the BX register after the instruction executed was FFFB. The value of the sign flag was ( SF = NG ). 27. When the command ADD AX, BX was executed, the value in the BX register was added to the AX register and the result was put in AX. AX went from 0002 t0 0005.
28. The new byte values in memory address DS:300 and DS:301 before and after the instruction was executed were:
06FF DEC BYTE PTR [301] We cannot tell if byte, word or double word.
29.
30. Assemble the instruction IMUL BL into CS:100
31. Assemble the instruction IMUL BX into CS:100
32. Assemble the instruction CBW into CS:100
33. Assemble the instruction AND AL,[500] into CS:100
34. Assemble the instruction SHL AL, 1 into CS:100
35. Assemble the instruction SHL AL, CL into CS:100
36. Try to assemble the instruction SAL AL,1 into CS:100
37. Assemble the instruction SAR AL,1 into CS:100
38. Assemble the instructions SAR AL,1 and SHR AL,1 into CS:100
39. Assemble the instructions STC and ADC AX, 2 into CS:100
40. Assemble the instruction CMP CL, BL into CS:100
41. Assemble the instruction SUB CL, BL into CS:100
42. Assemble the instructions DEC CL and JMP 100 into CS:100
43. Assemble the instruction JMP 800 into CS:100
44. Assemble the instruction JMP CF00:200 into CS:100
45. Assemble the instruction JMP BX into CS:100
46. Assemble the instruction JMP WORD PTR [500] into CS:100
47. Assemble the instruction JMP FAR [500] into CS:100
48. Assemble the instruction CALL 400 into CS:100
Conclusion and SummaryA total of forty-eight problems were performed in this lab. Some of the problems were using debug commands especially at the beginning. Most of the problems involved carrying out assembly language instructions, in some cases multiple instructions as in the case with the jumps or call. One of the problems we had was with the IP ( Instruction Pointer ). This was noticed around problem number 22 which involved using the XCHG command. The registers would not exchange after the command was executed. This was because the IP was not placed back at 0100. When the IP was set at 0100 prior to every instruction, they all ran correctly. All types of instructions were implemented; one CALL, two stack instructions: PUSH and POP, many MOV and shift instructions, quite a few multiplication and addition instructions. It was observed that the CMP and SUB instructions are nearly the same except the CMP doesn't return a result. In the case of this instruction what matters is how the flags are set after the instruction is executed. There were some problems that involved setting and resetting the flags. Another thing that was noticed was that not all of the shift instructions work. This was because the SAL and SHL instruction are equivalent and the assembler will only accept SHL. As a result, much was learned in this lab about the processor and assembly language. We were able to complete the work correctly for all problems. The answers came out as intended and there were no incorrect results. All objectives were accomplished. References Walter Tribel, "The 80386, 80486, and Pentium Processors: Hardware, Software, and Interfacing", Prentice Hall, 1998, ISBN #0-13-533225-7 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||