I everyone, i post this simply code written by myself. It contains some comments.
I wish someone can appreciate it.
P.S. : sorry for my bad english 😭
I wish someone can appreciate it.
P.S. : sorry for my bad english 😭
Code
START:
main: sub.l #8, a7 #we must reserve some space in the stack for the recursive call;we'll reserve 32 bit
move.l num, d0 #we move the num from the memory to register d0
move.l #1, d2 #we copy 1 in d2
bra Fatt #branch to the label Fatt
Fatt_recursive: sub.l #4, a7 #reserving 32 bit in the stack(a7)
move.l d0, (a7) #we move d0 in the stack zone pointed by register a7
sub.l #1, d0 #we decrease d0
bsr fatt #branch subroutine
move.l (a7)+,d1 #this two lines are the most important we move the content of the stack in position a7 (with post increase) and we
mulu d1, d2 #put it in d1 and we mul (unsigned) d1 and d2, the result at last we'll be written in d1 register
rts
Fatt: cmp #1, d0 #we compare d0 with 1 if d0 become 1 we'll start with the recursive call
bgt Fatt_recursive #d0 is greater than 1 so we branch to the label fatt_recursive
rts
SIMHALT ; halt simulator
num: dc.l 6
ris: dc.l 0
END START ; last line of source
