Micro Lab 2
Micro Lab 2
Micro Lab 2
LAB-2
Objective: Students will learn Assembly programming pneumonic, and explore
simple Assembly Language Instructions in assembly and run them.
Lab Work:
As the first example we will see the Moves. Each student should run the program
and should try to trace it as well.
.386
.model flat,stdcall
.stack 4096
ExitProcess PROTO, dwExitCode:dword
.data
val1 WORD 1000h
val2 WORD 2000h
.code
main proc
; MOVZX
mov bx,0A69Bh
movzx eax,bx ; EAX = 0000A69Bh
movzx edx,bl ; EDX = 0000009Bh
movzx cx,bl ; CX = 009Bh
; MOVSX
mov bx,0A69Bh
movsx eax,bx ; EAX = FFFFA69Bh
movsx edx,bl ; EDX = FFFFFF9Bh
mov bl,7Bh
movsx cx,bl ; CX = 007Bh
; Memory-to-memory exchange:
mov ax,val1 ; AX = 1000h
xchg ax,val2 ; AX = 2000h, val2 = 1000h
mov val1,ax ; val1 = 2000h
Invoke ExitProcess,0
main endp
end main
Lab Work -2 :
As the second example we will see the TYPE, LENGTHOF, and SIZEOF
operators. Each student should run the program and should try to trace it as well.
; Operators (Operator.asm)
.386
.model flat,stdcall
.stack 4096
ExitProcess PROTO, dwExitCode:dword
.data
byte1 BYTE 10,20,30
array1 WORD 30 DUP(?),0,0
array2 WORD 5 DUP(3 DUP(?))
array3 DWORD 1,2,3,4
digitStr BYTE '12345678',0
myArray BYTE 10,20,30,40,50,
60,70,80,90,100
.code
main PROC
invoke ExitProcess,0
main ENDP
END main
Lab Work -3:
As the second example we will see the pointers and TYPEDEF operators. Each
student should run the program and should try to trace it as well.
; Pointers (Pointers.asm)
.386
.model flat,stdcall
.stack 4096
ExitProcess PROTO, dwExitCode:dword
.data
arrayB BYTE 10h,20h,30h
arrayW WORD 1,2,3
arrayD DWORD 4,5,6
.code
main PROC
invoke ExitProcess,0
main ENDP
END main
Lab Work -4:
As the second example we will see the sum of array. Each student should run the
program and should try to trace it as well.
.386
.model flat,stdcall
.stack 4096
ExitProcess PROTO, dwExitCode:dword
.data
intarray DWORD 10000h,20000h,30000h,40000h
.code
main proc
invoke ExitProcess,0
main endp
end main