Assembly Language For this program you will find the largest
Assembly Language
For this program you will find the largest element in an array of DWORDs. The output of your program will be: The Largest Integer In the Array is: +6 where, for the example I used, the largest element in the array is 6. You will make up your own array of integers with at least 6 integers, and including some duplicate values. You will do all of your work using registers, i.e. NO variables appear in your code except to initialize registers once. You code must include: meaningful simultaneous use of EAX, EBX, ECX, EDX at least three jump instructions at least two compare instructions at least one meaningful use of LENGTHOF at least one meaningful use of TYPE at least one meaningful use of OFFSET at least one meaningful use of indirect addressing use of WriteString and WriteInt from the Irvine librarySolution
Assembly Language code to find largest number in the array: (output details also included below)
section .data
     larg_msg db \'Largest Number is::\'
     larg_len: equ $-larg_msg
nwline db 10
    array dd 0fa100001h,0b2000002h,0ffffffffh,0d400004h, 0500005h        ;array elements
     arrcnt dd 05h
section .bss
     dnum_buff resb 8
     large resd 1
%macro dispmsg 2
     mov eax,4    ;System call for write
     mov ebx,1    ;standard output stream
     mov ecx,%1    ;message start address
     mov edx,%2    ;message length
     int 80h
 %endmacro
section .text
     global _start
         global break
 _start:
     mov esi,0
     mov ecx,[arrcnt]
 break1:    mov eax,0
lup1:    cmp eax,[array+esi*4]    ;Compare accumulator with array element
     ja lskip1        ;If accumulator is greater go to skip
     mov eax,[array+esi*4]    ;Else move array element in accumulator
 lskip1:    inc esi            ;Point to next element
     loop lup1
mov [large],eax
    dispmsg larg_msg,larg_len
     mov ebx,[large]
     call disp_num
dispmsg nwline,1
exit:    mov eax,01
     mov ebx,0
     int 80h
disp_num:
     mov edi,dnum_buff    ;point esi to buffer
    mov ecx,8        ;load number of digits to display
 dispup1:
     rol ebx,4        ;rotate number left by four bits
     mov dl,bl        ;move lower byte in dl
     and dl,0fh        ;mask upper digit of byte in dl
     add dl,30h        ;add 30h to calculate ASCII code
     cmp dl,39h        ;compare with 39h
     jbe dispskip1        ;if less than 39h akip adding 07 more
     add dl,07h        ;else add 07
 dispskip1:
     mov [edi],dl        ;store ASCII code in buffer
     inc edi            ;point to next byte
     loop dispup1        ;decrement the count of digits to display
                 ;if not zero jump to repeat
     dispmsg dnum_buff,8
    
     ret
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
;Output
 ;[apcoer@localhost ~]$ nasm -f elf64 32h.asm
 ;[apcoer@localhost ~]$ ld -o 32h 32h.o
 ;[apcoer@localhost ~]$ ./32h
 ;Largest Number is::FFFFFFFF


