Microprocessor and Microcontroller Lab 4 | Read Now

Microprocessor and Microcontroller Lab 4

4] Develop an assembly language program to compute nCr using the recursive procedure. Assume that ‘n’ and ‘r’ are non-negative integers.


4] Program Code(lab4.asm)

.model small
.stack 10
.data
n dw 4
r dw 2
org 10h
ncr dw ?
res dw ?

.code
mov ax,@data
mov ds,ax
mov ax,r
call fact
mov bx,res

mov ax,n
sub ax,r
call fact
mov ax,res
mul bx
mov bx,ax

mov ax,n
call fact
mov ax,res
div bx
mov ncr,ax
int 3

fact proc
cmp ax,0h
je exit
push ax
dec ax
call fact

pop ax
mul res
mov res,ax
ret

exit:mov res,1h
ret
fact endp
end

Leave a Reply

Your email address will not be published. Required fields are marked *

WhatsApp Icon Join For Job Alerts