Created
September 27, 2012 18:00
-
-
Save b-adams/3795428 to your computer and use it in GitHub Desktop.
Local variables
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
;CONSTANTS | |
; * local variable stack offsets (with trace tags) [s addressing] | |
; * local variable stack sizes [i addressing] | |
msgLtr1: .EQUATE 0 ;local variable #1c | |
msgLtr2: .EQUATE 1 ;local variable #1c | |
msgLtr3: .EQUATE 2 ;local variable #1c | |
frameMai: .equate 3 | |
addr1: .EQUATE 0 ;local variable #2h | |
addr2: .EQUATE 2 ;local variable #2h | |
frameSec: .equate 4 | |
inst1: .EQUATE 0 ;local variable #1h | |
opcode1: .EQUATE 1 ;local variable #2h | |
inst2: .EQUATE 3 ;local variable #1h | |
frameThi: .equate 4 | |
BR main ;To enable stack trace to start properly | |
;GLOBAL VARIABLES | |
; * (with trace tags, see p223) [d addressing] | |
globVar1: .BLOCK 2 ;global variable #2d | |
globVar2: .BLOCK 2 ;global variable #2h | |
globVar3: .BLOCK 1 ;global variable #1c | |
;PROGRAM | |
; * (with alloc/dealloc trace tags) | |
main: SUBSP frameMai,i ;allocate #msgLtr3 #msgLtr2 #msgLtr1 | |
LDA "Hi",i | |
STA msgLtr1,s | |
LDA "\x00",i | |
STBYTEA msgLtr3,s | |
second: SUBSP frameSec,i ;allocate #addr2 #addr1 | |
LDA second,i | |
STA addr1,s | |
STA globVar2,d | |
LDA third,i | |
STA addr2,s | |
cleanup2:ADDSP frameSec,i ;deallocate #addr1 #addr2 | |
third: SUBSP frameThi,i ;allocate #inst2 #opcode1 #inst1 | |
LDBYTEA second,d | |
STBYTEA inst1,s ;get the instruction specifier of instruction at 'third' | |
LDA 0x0022,d ;Inelegant way to get the operand of instruction at 'third' | |
STA opcode1,s | |
LDBYTEA 0x0024,d ;getting the instruction specifier of instruction after 'third' | |
STBYTEA inst2,s | |
cleanup3:ADDSP frameThi,i ;deallocate #inst1 #opcode1 #inst2 | |
cleanup1:ADDSP frameMai,i ;deallocate #msgLtr1 #msgLtr2 #msgLtr3 | |
.END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment