Created
December 14, 2021 08:04
-
-
Save ascpial/2aefbd1f5040d5e5b35daa09c5aa6508 to your computer and use it in GitHub Desktop.
This program do a factorial in assembler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MOV R12, #1 //resultat | |
MOV R0, #0 //iteration | |
INP R2, 2 | |
boucle1: | |
CMP R0, R2 //max | |
BEQ finboucle1 | |
MOV R1, R0 //iteration mutliplication | |
MOV R11, R12 | |
boucle2: | |
CMP R1, #0 | |
BEQ finboucle2 | |
ADD R12, R12, R11 | |
SUB R1, R1, #1 | |
B boucle2 | |
finboucle2: | |
ADD R0, R0, #1 | |
B boucle1 | |
finboucle1: | |
OUT R12, 4 | |
HALT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment