Ad Code

Which instruction are to call a subroutine?

Which instructions are to call a subroutine and to get back to the same point where the function
was called? Explain these instruction with help of an Examples.


CALL is used to call a subroutine and to get back RET is used. CALL takes a label as argument and execution starts from that label, until the RET instruction is encountered and it takes execution back to the instruction following the CALL.

FOR EXAMPLE:
[org 0x0100]
jmp start
num: dw 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
sum: add dx, [num+bx]
add bx,2
cmp bx,40
jne sum
ret
start: mov dx,0
mov bx,0
call sum
mov ax,0x4c00
int 0x21
Reactions

Post a Comment

0 Comments