Q. Write an assembly language program to perform the following tasks:
Task 1 - Find the largest digit in your VUID.
Task 2 - Add the largest value to each index value and write it back at the respective index of the VUID. For example, if the numbers in VUID are 030400789, then after the task 2, the VUID should become 91291399161718.
Task 3 - Find the arithmetic series of the largest digit found in task 1 and store it in the “dx” register as shown in the sample screenshot.
My student id is ..Bc200203355
TITLE Assignment
; Find the largest digit in your VUID.
INCLUDE Irvine32.inc
.data
VUID DWORD 2, 0, 0, 2, 0, 3, 3, 3, 5
VUID_len DWORD ?
.code
main PROC
mov VUID_len, LENGTHOF VUID ; put length of array into memory
mov esi, offset VUID ; array address
mov ecx, VUID_len ; array size
Array_print1:
mov eax, [esi] ; VUID[i]
call WriteDec
mov eax, ' '
call WriteChar
add esi, 4 ; next address in array VUID
loop Array_print1 ; next loop
call crlf
mov esi, offset VUID ; array address VUID
mov ecx, VUID_len ; array VUID size
mov eax, [esi] ; read VUID[0]. Lagest.
dec ecx
Array_test:
add esi, 4 ; next address in array VUID
mov ebx, [esi] ; next elemet in array VUID
cmp ebx, eax ; curent element <= next element
JLE Not_Largerst ; if not go to it is not lagest
mov eax, ebx ; else eax = new lagest element
Not_Largerst:
loop Array_test ; next loop
mov edx, eax ; SAVE IN DX
call WriteDec
call crlf
;
mov esi, offset VUID ; array VUID address
mov ecx, VUID_len ; array VUID size
Array_add:
add [esi], edx ; VUID[i]+lagest
add esi, 4 ; next address in array VUID
loop Array_add ; next loop
call crlf
mov esi, offset VUID ; array address VUID
mov ecx, VUID_len ; array VUID size
Array_print2:
mov eax, [esi] ; VUID[i]
call WriteDec
mov eax, ' '
call WriteChar
add esi, 4 ; next address in array VUID
loop Array_print2 ; next loop
call crlf
call WaitMsg
exit
main ENDP
end main
Comments
Leave a comment