Answer to Question #282041 in Assembler for Ahsan

Question #282041

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


1
Expert's answer
2021-12-22T08:07:14-0500
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

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS