Created
October 10, 2012 15:21
-
-
Save b-adams/3866306 to your computer and use it in GitHub Desktop.
CS225 IF example
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
;program for if(x>2) 1; else 0; | |
BR main,i | |
x: .BLOCK 2 ;global variable #2d | |
main: NOP0 | |
charo 'm',i | |
deci x,d | |
lda x,d ;A is now x | |
cpa 2,i ;accumulator-preserving subtraction, flags reflect x-2 | |
;now that flags are set, branch RIGHT AWAY!!!!!!1!111!!! | |
BRGT yes,i ;branch if flags for (x-2) indicate > 0 | |
no: NOP0 | |
charo 'n',i | |
LDA 0,i | |
STA x,d | |
BR fi,i | |
yes: NOP0 | |
charo 'y',i | |
LDA 1,i | |
STA x,d | |
BR fi,i | |
fi: NOP0 | |
charo 'f',i | |
DECO x,d | |
STOP | |
.END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment