Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

LAB 9 (22k-4136)

Task 1:
INCLUDE Irvine32.inc

.data

prompt BYTE "50 x 21 = ",0

.code
main PROC

mov eax,50
shl eax,4
mov ebx,50
shl ebx,2
add eax,ebx
mov ebx,50
shl ebx,0
add eax,ebx
mov edx,OFFSET prompt
call writeString
call writeDec

exit
main ENDP
END main

Task 2:
INCLUDE Irvine32.inc

.data

.code
main PROC

mov eax,0
mov ax,-128
call dumpregs

rol eax,16
sar eax,16
call crlf
call crlf
call dumpregs

exit
main ENDP
END main

Task 3:
INCLUDE Irvine32.inc

.data

bMinutes BYTE ?
prompt BYTE "The minutes are: ",0

.code
main PROC

mov ax,101010011101010b
shr ax,5
and al,00111111b
mov bMinutes,al
mov eax,0
mov al,bMinutes
mov edx,OFFSET prompt
call writeString
call writeDec
call crlf

exit
main ENDP
END main

Task 4:
INCLUDE Irvine32.inc

.data

prompt BYTE "AX: ",0


prompt2 BYTE "The lower bit is moved into highest bit of BX so it became 8",0
prompt3 BYTE "BX: ",0

.code
main PROC
mov eax,0
mov ebx,0
mov ax,10010001b

mov edx,OFFSET prompt


call writeString

call writeBin
clc
rcr eax,1
rcl bx,1
shl bx,3
mov eax,0
mov ax,bx
call crlf
call crlf
mov edx,OFFSET prompt2
call writeString
call crlf
call crlf

mov edx,OFFSET prompt3


call writeString

call writebin
mov edx,OFFSET prompt
call crlf

mov ax,325Bh
mov dx,7931h
shrd ax,dx,4

exit
main ENDP
END main

Task 5:
INCLUDE Irvine32.inc

.data

prompt BYTE "val1 = (100/25) * (500/100) = ",0


val1 SDWORD 500
val2 SDWORD 100
val3 SDWORD 25

.code
main PROC

mov eax,val2
cdq
idiv val3
mov ebx, eax
mov eax,val1
cdq
idiv val2

imul eax,ebx
mov edx,OFFSET prompt
call writeString
call writeDEC

exit
main ENDP
END main

Task 6:
INCLUDE Irvine32.inc

.data

val1 DWORD 43214512h,12345678h


val2 DWORD 85421098h,97654321h

.code
main PROC

call Extended_Add

exit
main ENDP

Extended_Add PROC
mov eax,0
mov edx,0
mov esi,OFFSET val1
add eax,[esi+ TYPE val1]
mov edi,OFFSET val2
add eax,[edi+ TYPE val2]
adc edx,0

mov ebx,0
add ebx,[esi]
add ebx,[edi]
add eax,ebx
adc edx,0

call dumpregs

ret
Extended_Add ENDP
END main

You might also like