QUESTION 1
include irvine32.inc
.data
prompt BYTE 'Enter an integer : ',0
array dword 4 DUP(?)
res BYTE 'These are equal',0
res1 BYTE 'These are not equal',0
.code
main proc
mov ecx,4
mov esi,0
L1:
mov edx,offset prompt
call writestring
call readint
mov array[esi],eax
add esi,4
loop L1
mov eax,[array]
cmp eax,[array+4]
je EQ1
Jmp notEqual
EQ1:
cmp eax,[array+8]
je EQ2
jmp notEqual
EQ2:
cmp eax,[array+12]
je EQ3
jmp notEqual
EQ3:
mov edx,offset res
call writestring
call crlf
jmp final
notEqual:
mov edx,offset res1
call writestring
final:
exit
main endp
end main
OUTPUT
QUESTION 2
include irvine32.inc
.data
intarr Sword 0, 0, 0, 150, 120, 35, -12, 66, 4, 0
res BYTE 'The first non zero value is :',0
.code
main proc
mov esi,0
NonZero:
movzx eax,[intarr+esi]
cmp eax,0
jne EQUAL
add esi,2
jmp NonZero
EQUAL:
mov edx,offset res
call writestring
call writeint
exit
main endp
end main
OUTPUT
QUESTION 3
include irvine32.inc
.data
intarr Sword 0, 0, 0, 150, 120, 35, -12, 66, 4, 0
var dword 5
counter dword lengthof intarr
x dword 0
.code
main proc
mov edx,var+1
mov ecx,counter
cmp var,ecx
jl L1
jmp notequal
L1:
cmp ecx,edx
jge L2
L2:
mov x,0
mov eax,x
call writedec
call crlf
jmp final
notequal:
mov x,1
mov eax,x
call writedec
final:
exit
main endp
end main
OUTPUT
QUESTION 4
include irvine32.inc
.data
hello BYTE 'HELLO!',0
world BYTE 'WORLD',0
var dword 0
.code
main proc
top:cmp var,10
ja next
cmp var,5
jae wor
mov edx,offset hello
call writestring
call crlf
jmp nochange
wor:
mov edx,offset world
call writestring
call crlf
nochange:
add var,1
jmp top
next:
exit
main endp
end main
OUTPUT
QUESTION 5
include irvine32.inc
.data
arr WORD 10, 4, 7, 14, 299, 156, 3, 19, 29, 300, 20
prompt byte 'Enter a number to search: ',0
res byte 'Number found',0
not_found byte 'Number not found',0
num dword 0
.code
main proc
mov edx, offset prompt
call writestring
call readdec
mov num, eax
mov esi, 0
mov ecx, lengthof arr
loop1:
movzx eax, [arr + esi]
cmp num, eax
je equal
add esi, 2
loop loop1
mov edx, offset not_found
call writestring
jmp final
equal:
mov edx, offset res
call writestring
final:
exit
main endp
end main
OUTPUT
QUESTION 7
include irvine32.inc
.data
prompt byte 'Enter a number (1-7) for the day of the week: ', 0
sunday_msg byte 'Sunday', 0
monday_msg byte 'Monday', 0
tuesday_msg byte 'Tuesday', 0
wednesday_msg byte 'Wednesday', 0
thursday_msg byte 'Thursday', 0
friday_msg byte 'Friday', 0
saturday_msg byte 'Saturday', 0
invalid_msg byte 'Invalid input. Please enter a number between 1 and 7.', 0
.code
main proc
mov edx, offset prompt
call writestring
call readdec
mov eax, eax
cmp eax, 1
jb invalid
cmp eax, 7
ja invalid
cmp eax, 1
je print_sunday
cmp eax, 2
je print_monday
cmp eax, 3
je print_tuesday
cmp eax, 4
je print_wednesday
cmp eax, 5
je print_thursday
cmp eax, 6
je print_friday
cmp eax, 7
je print_saturday
print_sunday:
mov edx, offset sunday_msg
call writestring
jmp next
print_monday:
mov edx, offset monday_msg
call writestring
jmp next
print_tuesday:
mov edx, offset tuesday_msg
call writestring
jmp next
print_wednesday:
mov edx, offset wednesday_msg
call writestring
jmp next
print_thursday:
mov edx, offset thursday_msg
call writestring
jmp next
print_friday:
mov edx, offset friday_msg
call writestring
jmp next
print_saturday:
mov edx, offset saturday_msg
call writestring
jmp next
invalid:
mov edx, offset invalid_msg
call writestring
next:
exit
main endp
end main
OUTPUT
QUESTION 8
include irvine32.inc
.data
lowercase_arr byte
'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','
u','v','w','x','y','z'
uppercase_arr byte
'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','
U','V','W','X','Y','Z'
prompt byte 'Enter a character: ',0
res byte 'Character is an alphabet',0
not_found byte 'Character is not an alphabet',0
num byte ?
.code
main proc
mov edx, offset prompt
call writestring
call readchar
call writechar
call crlf
mov num, al
mov esi, 0
mov ecx, lengthof lowercase_arr
check_lowercase:
mov al, [lowercase_arr + esi]
cmp num, al
je equal
inc esi
loop check_lowercase
mov esi, 0
mov ecx, lengthof uppercase_arr
check_uppercase:
mov al, [uppercase_arr + esi]
cmp num, al
je equal
inc esi
loop check_uppercase
mov edx, offset not_found
call writestring
jmp final
equal:
mov edx, offset res
call writestring
final:
exit
main endp
end main
OUTPUT