Created
November 2, 2012 15:24
-
-
Save b-adams/4001975 to your computer and use it in GitHub Desktop.
CS225 Global index addressing with non-byte sized data values
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
BR main | |
foo: .block 12 ;blah #2d6a | |
;bar: .block 12 ;blah #1c12a | |
;baz: .block 6 ;blah #2h3a | |
;bat: .block 6 ;blah #2d3a | |
;on cheat sheet, index would be blue | |
index: .equate 0 ;local variable #2d for loop control | |
;on cheat sheet, frame would be green | |
frame: .equate 2 ;size of main's local frame | |
;index: .block 2 ;global variable #2d | |
times: .equate 6 ;how many times to do something | |
prompt: .ascii "Enter a number:\x00" | |
main: NOP0 | |
SUBSP frame,i ;allocate #index | |
;index = 0 | |
LDA 0,i | |
STA index,s | |
forloop: NOP0 | |
;index<times ? | |
LDA index,s | |
CPA times,i | |
BRGE doneloop,i ;if index>=times finish looping | |
BR loopbody,i ;if index<times do the loop body | |
loopbody: NOP0 | |
STRO prompt,d | |
LDX index,s ;offset would currently be 1 byte more, want two more | |
ASLX ;double index to convert from "number of spaces" to "number of bytes" | |
DECI foo,x ;won't work quite right, never advanced | |
;index++ | |
ADDX 1,i | |
STX index,s | |
BR forloop,i | |
doneloop: NOP0 | |
charo ':',i | |
charo ')',i | |
ADDSP frame,i ;deallocate #index | |
STOP | |
.end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment