SuperCPU Tutorial Listings - Part 6
Listing 6.1 ; 65816 ; relocatable Code by Stack-relative ; indirect-indexed Adressing [ Oh My :) ] ; Using the PER-command ; written in 1997 by Malte Mundt ; for GO64! £ba $c000 ; PER pushes the difference between program ; counter and label to the stack ; and therefore works memory independent. per data0 ldy #0 ; 1,S means: Stackpointer +1 (You need +1 to get the label right) ; ,Y adds the value of Y-Register ; The processor calculates the adress of the pointer ; and gets the byte to the accu using it. lda (1,S),y ; get data0 sta $0400 ; write to screen iny lda (1,S),y ; now get data1 sta $d020 ; write to border color iny lda (1,S),y ; get data2 sta $d021 ; write to background iny lda (1,S),y ; get data3 sta $d800 ; write to color-ram pla ; clean up stack pla rts data0: £by $21 data1: £by $00 data2: £by $07 data3: £by $01 ; This might look confusing at first sight, but with a cool ; macro assembler, great code is possible :) /cz
Listing 6.2 ; 65816 ; relocatible Code by using stack-relative ; adressing and the ; PER-command ; written in 1997 by Malte Mundt ; for GO64! £ba $c000 ; PER pushes the difference between program ; counter and label to the stack ; and therefore works memory independent. per text ; start of text is moved ; to stack while prog is running lda 2,S ; get highbyte tay lda 1,S ; get lowbyte jsr $ab1e ; print text pla ; clean up stack pla rts text: £tx "the quick brown fox jumps" £by $0d £tx "over the lazy dog ..." £by 0
Assembler Code © by Malte Mundt
Partial translation and cosmetical changes by Count Zero/SCS*TRC
[ Listings Part 5 ][
Tutorial Part 6 ][ Index ][ Listings
Part 7 ]