You are on page 1of 7

Thamilarasan Ramalingam

Lab:CO2 STUDY OF CPU USING A SIMULATOR Objectives The main objectives in this lab is to study the CPU using a simulator program.Besides that, to understand the mechanisms involved in program execution in a microprocessor unit. EMU8086 In this lab emu8086 version 2.4 is used to run the source code.This program is extremely helpful for those who just begin to study assembly language. It compiles the source code and executes it on emulator step by step. Emulator runs programs on a Virtual PC, this completely blocks your program from accessing real hardware, such as hard-drives and memory, since your assembly code runs on a virtual machine, this makes debugging much easier. Results Exercise 2: Load first program and study the operations (MMU.asm)

AX 0000 0000 0000 0900 0900 0924 0924 4C24 4C24

BX 0000 0000 0000 0000 0000 0000 0000 0000 0000

CX 0039 0039 0039 0039 0039 0039 0039 0039 0039

DX 0000 0000 0102 0102 0102 0102 0102 0102 0102

CS 0B56 0B56 0B56 0B56 F400 F400 0B56 0B56 F400

IP 0100 012E 0131 0133 0200 0204 0135 0137 0200

SP FFFE FFFE FFFE FFFE FFF8 FFF8 FFFE FFFE FFF8

Instructions JUMP START START: LEA DX, msg MOV AH,9 INT 21h INT 21h INT 21h MOV AH, 4Ch INT 21h INT 21h

Thamilarasan Ramalingam

Step to step explanation for Hello World Program : When the instruction JMP START is executed the Ip points to Instruction START: When this instruction is executed the address of msg
DB 'Hello, MMU DB 'Please Register. DB 'Thank you! LEA DX, msg

Is loaded into register DX. After that the IP will move to instructions MOV AH, 9 and also INT 21h Where this will prompt print using dos interrupt. Finally the IP will go to MOV AH, 4Ch And also INT 21h which means the program is terminated. Exercise 3: Traffic Lights program :Unimproved program AX 0000 0001 0001 0002 0002 0002 0004 0004 0004 0008 0008 0008 0010 0010 0010 0020 0020 0020 0040 0040 0040 0080 0080 0080 0100 0100 0100 IP 0000 0003 0005 0007 0003 0005 0007 0003 0005 0007 0003 0005 0007 0003 0005 0007 0003 0005 0007 0003 0005 0007 0003 0005 0007 0003 0005 Instructions MOV AX,1 OUT 4,AX ROL AX,1 JMP NEXT_SITUATION OUT 4,AX ROL AX,1 JMP NEXT_SITUATION OUT 4,AX ROL AX,2 JMP NEXT_SITUATION OUT 4,AX ROL AX,2 JMP NEXT_SITUATION OUT 4,AX ROL AX,3 JMP NEXT_SITUATION OUT 4,AX ROL AX,3 JMP NEXT_SITUATION OUT 4,AX ROL AX,4 JMP NEXT_SITUATION OUT 4,AX ROL AX,4 JMP NEXT_SITUATION OUT 4,AX ROL AX,5

Thamilarasan Ramalingam

0200 0200 0200 0400 0400 0400 0800 0800 0800 1000 1000 1000 2000 2000 2000 4000 4000 4000 8000 8000 8000

0007 0003 0005 0007 0003 0005 0007 0003 0005 0007 0003 0005 0007 0003 0005 0007 0003 0005 0007 0003 0005

JMP NEXT_SITUATION OUT 4,AX ROL AX,5 JMP NEXT_SITUATION OUT 4,AX ROL AX,6 JMP NEXT_SITUATION OUT 4,AX ROL AX,6 JMP NEXT_SITUATION OUT 4,AX ROL AX,7 JMP NEXT_SITUATION OUT 4,AX ROL AX,7 JMP NEXT_SITUATION OUT 4,AX ROL AX,8 JMP NEXT_SITUATION OUT 4,AX ROL AX,8

Thamilarasan Ramalingam

Improved program(optional) #MAKE_BIN# #CS = 500# #IP = 0# next_situation: MOV AX, 100100100001b OUT 4, AX MOV AX, 100100100010b OUT 4, AX MOV AX, 100100100100b OUT 4, AX MOV AX, 100100001100b OUT 4, AX MOV AX, 100100010100b OUT 4, AX MOV AX, 100100100100b OUT 4, AX MOV AX, 100001100100b OUT 4, AX MOV AX, 100010100100b OUT 4, AX MOV AX, 100100100100b OUT 4, AX MOV AX, 001100100100b OUT 4, AX MOV AX, 010100100100b OUT 4, AX MOV AX, 100100100100b OUT 4, AX JMP next_situation

AX 0000 0921 0921 0922 0922 0924 0924 090C 090C 0914 0914 0924 0924 0864 0864 08A4 08A4 0924 0924 0324 0324 0524 0524 0924 0924

IP 0000 0003 0005 0008 000A 000D 000F 0012 0014 0017 0019 001C 001E 0021 0023 0026 0028 002B 002D 0030 0032 0035 0037 003A 003C

Exercise 4: Add/Subtract program.

Thamilarasan Ramalingam

AX 0000 0005 0005 000F 000E

BX 0000 0000 000A 000A 000A

IP 0000 0003 0006 0008 000B

Instructions MOV AX,5 MOV BX,10 ADD AX,BX SUB AX.1 HLT

Step to step explanation for Add/Subtract program : When the instruction JMP START is executed the Ip points to Instruction mov ax,5 . When this instruction is executed the accumulator x is loaded with 5, then the Ip will go to instruction
DB 'Hello, MMU DB 'Please Register. DB 'Thank you!

Is loaded into register DX. After that the IP will move to instructions MOV AH, 9 and also INT 21h Where this will prompt print using dos interrupt. Finally the IP will go to MOV AH, 4Ch And also INT 21h which means the program is terminated.

Thamilarasan Ramalingam

Exercise 5: Arithmetic program. The last four digit of my id is 5546.

#make_COM# ; COM file is loaded at CS:0100h ORG 100h MOV AX, 5 MOV BX, 55 ADD AX, BX MOV BX,55 ADD BX,46 MUL BX MOV BX,2 MUL BX SUB AX,5 HLT

Thamilarasan Ramalingam

AX 0000 0005 0005 003C 003C 003C 17AC 17AC 2F58 2F53

BX 0000 0000 0037 0037 0037 0065 0065 0002 0002 0002

IP 0100 0103 0106 0700 0108 010E 0110 0113 0115 0118

Instructions MOV AX, 00005H MOV BX,00037H ADD AX,BX MOV BX,00037H ADD BX,02EH MUL BX MOV BX,00002H MUL BX SUB AX , 00005H HLT

Conclusion From this lab , I have gained a lot knowledge and skills, firstly on assembly programming. Moreover, I have learned , how does each registers in the microprocessor works and in problem solving and in each situation. Besides that, I have also learned about the assembly software such as EMU 8086 emulator .

You might also like