Last active
November 3, 2022 16:30
-
-
Save ProfAndreaPollini/777d1d93bbf55be7813265dbba349b7a to your computer and use it in GitHub Desktop.
https://schweigi.github.io/assembler-simulator/ assembler sign function
This file contains hidden or 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
| JMP start | |
| R0: DB 140 | |
| R1: DB 255 | |
| start: | |
| CALL sign | |
| HLT | |
| sign: | |
| PUSH A | |
| MOV A, [R0] | |
| CMP A,128 | |
| JAE .positivo | |
| JMP .negativo | |
| .positivo: | |
| MOV [R1], 1 | |
| JMP .end | |
| .negativo: | |
| MOV [R1], 0 | |
| .end: | |
| POP A | |
| RET |
This file contains hidden or 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
| ; somma dei numeri da 1 a 5 (risultato in s) | |
| JMP start | |
| R0: DB 5 | |
| s: DB 0 | |
| start: | |
| CALL sum | |
| HLT | |
| sum: | |
| PUSH A | |
| PUSH B | |
| PUSH C | |
| MOV A, [R0] | |
| MOV B, 0 | |
| MOV C,1 | |
| .loop: | |
| CMP A, C | |
| JB .end | |
| ADD B, C | |
| INC C | |
| JMP .loop | |
| .end: | |
| MOV [s], B | |
| POP C | |
| POP B | |
| POP A | |
| RET |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment