Coal Lab 3
Coal Lab 3
1|Page
Task1:
Write assembly language program that will move some data into registers and
visualize this data using DumpRegs function (with screen shots)?
Code:
;Shawal Nasir F21605003(Task#1)
.686
.MODEL flat, stdcall
.STACK
INCLUDE Irvine32.inc
.code
main PROC ; Main procedure
call DumpRegs ; displaying all registers before moving data in registers
mov eax, 80000h ; EAX = 80000h
mov ebx, 20000h ; EBX = 20000h
mov ecx, 0c0000h ; ECX = c0000h
mov edx, 40000h ; EDX = 40000H
call DumpRegs ; displaying all registers after moving data in registers
exit
main ENDP
END main
Explanation:
In this task we move some data in the registers and display the values by using the DumpRegs
command.
2|Page
Task2
Write assembly language program that will Add and Sub two numbers and display
the result using DumpRegs function (with screen shots)?
Code:
;Shawal Nasir F21605003 (Task#2)
.686
.MODEL flat, stdcall
.STACK
INCLUDE Irvine32.inc
.code
main PROC ; Main procedure
call DumpRegs ; displaying all registers before add and sub
mov eax, 30000h ; EAX = 40000h
add eax, 60000h ; EAX = EAX + 80000h
call DumpRegs ; displaying all registers after add operations
sub eax, 20000h ; EAX = EAX - 30000h
call DumpRegs ; displaying all registers after subtract operations
exit
main ENDP
END main
Explanation:
This task add and sub two numbers and display the value using the DumpRegs. We see the
value in the EAX register will change after perform the add and sub operations.
3|Page
Task3
Using the addsub program as a reference, write a program that moves four integers
into the EAX, EBX, ECX, and EDX registers and then accumulates their sum into
the EAX register. Trace the execution of the program and view the registers using
the windows debugger.
Code:
;Shawal Nasir F21605003 (Task 3)
.686
.MODEL flat, stdcall
.STACK
INCLUDE Irvine32.inc
.code
main PROC ; Main procedure
call DumpRegs ; displaying all registers before arithmetic operations
mov eax, 40000h ; EAX = 40000h
mov ebx, 90000h ; EBX = 90000h
mov ecx, 0c0000h ; ECX = c0000h
mov edx, 70000h ; EDX = 70000H
add eax, ebx ; EAX = EAX + EBX
add eax, ecx ; EAX = EAX + ECX
add eax, edx ; EAX = EAX + EDX
call DumpRegs ; displaying all registers after arithmetic operations
exit
main ENDP
END main
4|Page
Explanation:
This task includes two operations first is move four values in the register EAX, EBX, ECX, EDX
After moving the values then accumulates the sum and move the value into the EAX register.
To display the values in the registers we first press F7 key at the main Proc we will see that the
garbage values will be appear in EAX register.
5|Page
Then press F10 to show the actual value in the registers.
6|Page
7|Page
We can see that after the add and sub operation the value of the EAX register change.
8|Page