Académique Documents
Professionnel Documents
Culture Documents
Write an assembly program that takes two WORD sized arrays of first 20 even and
first 20 odd numbers (arrayE and arrayO) from the user and display them on the
screen. Place the arrayO in stack. Now write two proceduresarraySum and
arraySub that add (arrayO[stack]+arrayE[mem]) and subtract(arrayO[stack]-
arrayE[mem]) the two arrays. Display your results on screen using the strings
"sum of two arrays" and "difference of two arrays".
[10 marks]
include irvine32.inc
.data
arrayO WORD 20 DUP(?)
arrayE WORD 20 DUP(?)
l1:
mov ax,0
EE- 222: Microprocessor Systems Page 2
National University of Sciences & Technology (NUST)
School of Electrical Engineering and Computer Science (SEECS)
Department of Electrical Engineering
call readint
mov [ebx],ax
add ebx,2
loop l1
l2:
mov eax,0
call readint
mov [ebx],eax
add ebx,2
loop l2
l4:
mov ax,[edx]
call writeint
add edx,2
loop l4
call arrayS
mov ecx,20
call arraySb
exit
main endp
arrayS PROC
mov edx,offset prompt3
call writestring
call crlf
mov ecx,20
add esi,19*2
Pushloop1:
mov ax,[esi]
push eax
sub esi,2
loop pushloop1
mov cl,20
additionLoop:
pop eax
add ax, [edi]
call writeDec
call crlf
add edi, 2
loop additionLoop
ret
arrayS ENDP
arraySb PROC
mov edx,offset prompt4
call writestring
call crlf
add esi,19*2
mov cl,20
Pushloop2:
mov ax,[esi]
push eax
sub esi,2
loop pushloop2
mov cl,20
subLoop:
pop eax
sub ax, [edi]
call writeDec
call crlf
add edi, 2
loop subLoop
ret
arraySb ENDP
end main
OUTPUT:
CONCLUSION
The purpose of the lab was to learn how to make and use procedures as well
as reinforce the concepts of array manipulation. Learning to use Stack
memory and push/pop was also part of the lab. We have learned how
procedures are made and implemented in this lab, as well as how to use the
stack based commands.