Answer to Question #262375 in Assembler for Bluwhale98

Question #262375

Write a NEAR subroutine using 8086 assembly Language (with proper comments) that

returns the smallest byte value in a byte array of length 5-bytes. The array is declared in the

calling program and the base address of the array is passed to the subroutine in the stack. You

should write both the calling program and subroutine.


1
Expert's answer
2021-11-07T10:13:04-0500
 

data segment

   array    db 10,2,3,4,7

ends

 

code segment

start:

; set segment registers:

    mov ax, data

    mov ds, ax

 

    lea si, array

            push si                         ; stack = address of array

            call minArray

   

    mov ax, 4c00h ; exit to operating system.

    int 21h   

ends

 

; subroutine minArray

; to returns the smallest byte value in a byte array of length 5-bytes

; input parameters:

;                       stack = address of array

; output:          al = the smallest byte      

minArray proc near

            push bp

            mov bp,sp

            add sp,4

    pop si

            mov al, [si]      ; begining min

            inc si

            mov cx, 4                     ; counter

loopMin:

            mov ah, [si]

            cmp al, ah

            jc next

            mov al, ah

next:   

            inc si

            loop loopMin

           

            mov sp,bp

            pop bp

            ret

minArray endp

end start ; set entry point and stop the assembler.

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
New on Blog
APPROVED BY CLIENTS