Skip to content

Instantly share code, notes, and snippets.

@ascpial
Created December 14, 2021 08:04
Show Gist options
  • Save ascpial/2aefbd1f5040d5e5b35daa09c5aa6508 to your computer and use it in GitHub Desktop.
Save ascpial/2aefbd1f5040d5e5b35daa09c5aa6508 to your computer and use it in GitHub Desktop.
This program do a factorial in assembler
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