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

Name Umair Waseem

Reg No #4702

Assingment No #3:

Q no 1:
INCLUDE C:\IRVINE\IRVINE32.INC
.386
.STACK 4096
EXITPROCESS PROTO,DWEXITCODE:DWORD
.DATA

array dword 3,66,5,444,2,4,5


max dword ?
min dword ?
string1 BYTE "the largest num in array is : ",0
string2 BYTE "the smallest num in array is : ",0
.CODE
MAIN PROC
mov edx,OFFSET array
mov ecx,LENGTHOF array
mov esi,0

mov eax,array[esi]
mov max,eax
mov ebx, array[esi]
mov min,ebx
l1::
cmp ecx,0
je Bye

cmp eax,array[esi]
ja minn
mov eax,array[esi]
add esi ,4
loop l1

jmp Bye
minn:
cmp ebx,array[esi]
jb again

mov ebx,array[esi]
add esi,4
dec ecx
jmp l1

again:
add esi,4
dec ecx
jmp l1

Bye:
mov max,eax
mov edx,OFFSET string1
call WriteString
call WriteInt
call crlf

mov edx,OFFSET string2


call WriteString
mov eax,ebx
call WriteInt
INVOKE EXITPROCESS,0
MAIN ENDP
END MAIN

Q no #2:
INCLUDE C:\IRVINE\IRVINE32.INC
.386
.STACK 4096
EXITPROCESS PROTO,DWEXITCODE:DWORD
.DATA

SIDE DWORD ?
stringg BYTE "if Zf is 0 then number is odd and if ZF is 1 then number
is even",0
.CODE
MAIN PROC

call ReadInt
AND eax,1
call Dumpregs

mov edx,OFFSET stringg


call WriteString

INVOKE EXITPROCESS,0
MAIN ENDP
END MAIN

Q no #3:
INCLUDE C:\IRVINE\IRVINE32.INC

.386

.STACK 4096

EXITPROCESS PROTO,DWEXITCODE:DWORD

.DATA

v1 word 12

v2 word 4

v4 word ?

str1 byte "the value of V4 is : ",0

.CODE

MAIN PROC

mov eax,0

mov ax,v2

shl ax,4

mov ebx,0

mov bl,al

mov ax,v1

shr ax,1

add ax,bx

mov v4,ax

mov edx,OFFSET str1

call WriteString

call WriteInt

INVOKE EXITPROCESS,0

MAIN ENDP

END MAIN
Q no #4:
INCLUDE C:\IRVINE\IRVINE32.INC

.386

.STACK 4096

EXITPROCESS PROTO,DWEXITCODE:DWORD

.DATA

v1 dword 12

v2 dword 24

v3 dword 7

str1 byte "the value of V5 is : ",0

.CODE

MAIN PROC

mov edx,0

mov eax,v2
mov ebx,8

div ebx

mov ebx,v1

add eax,ebx

mov ebx,eax

mov eax,v3

mov ecx,5

mul ecx

add eax,ebx

mov edx,OFFSET str1

call WriteString

call WriteInt

INVOKE EXITPROCESS,0

MAIN ENDP

END MAIN

You might also like