Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BRA main
- main INP R0 //n
- INP R1 //m
- MOV R5, R1 //start
- JMS readArr
- MOV R1, R5
- JMS printArr
- HLT
- readArr MOV R2, #0 //i
- loopRead CMP R2, R0
- BEQ doneRead
- INP R4
- STR R4, [R1]
- ADD R1, #1
- ADD R2, #1
- BRA loopRead
- doneRead RET
- printArr PSH {LR} // Save link register
- MOV R2, #0
- MOV R3, R1 // Store the start of the array in R3
- loopPrint CMP R2, R0
- BEQ donePrint
- LDR R4, [R3]
- JMS doFact
- OUT R4
- ADD R3, #1 // Move to the next element in the array
- ADD R2, #1
- BRA loopPrint
- donePrint POP {PC}
- doFact MOV R6, #1
- MOV R7, R4
- loopFact CMP R6, R4
- BEQ doneFact
- MUL R7, R6
- ADD R6, #1
- BRA loopFact
- doneFact MOV R4, R7
- RET
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement