NASM: program to find largest number from an array of 32-bit numbers(hard-coded)
; Find largest number from the array of 32-bit numbers. ; Program search for largest number and display the same. 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 lu
Comments
Post a Comment