SuperCPU Tutorial Listings - Part 2
Listing 2.1 ; From here on Flash 8 AssBlaster Source Code Format is used. ; Make sure to get F8-AssBlaster V1.2 ! ; Subtraction 16 Bit ; 6510-Version £ba $c000 lda value1 sec sbc value2 sta result lda value1+1 sbc value2+1 sta result+1 rts value1: £by $7a,$10 value2: £by $5d,$02 result: £by $00,$00
Listing 2.2 ; Subtraction 16 Bit ; 65816-Version £ba $c000 sei clc ; clear xce ; e-flag ; go native! rep #%00100000 ; Akku 16 Bit lda value1 sec sbc value2 sta result sep #%00100000 ; Akku 8 Bit sec ; back to xce ; emulation-mode cli rts value1: £by $7a,$10 value2: £by $5d,$02 result: £by $00,$00
Listing 2.3 ; Addition 16 Bit ; 65816-Version £ba $c000 sei clc ; clear xce ; e-flag ; go native! rep #%00100000 ; Akku 16 Bit lda value1 clc adc value2 sta result sep #%00100000 ; Akku 8 Bit sec ; back to xce ; emulation-mode cli rts value1: £by $31,$6a value2: £by $4b,$13 result: £by $00,$00
Listing 2.4 ; Multiplication 16 Bit * 16 Bit = 16 Bit ; 6510-Version £ba $c000 ldx #0 ; initialize ldy #0 ; registers for result mult1: lda value1 ; operator 1 (lo) ora value1+1 ; operator 1 (hi) beq done ; 0? ready lsr value1+1 ; right bit ror value1 ; of operator bcc mult2 ; no addition! clc tya adc value2 tay txa adc value2+1 tax mult2: asl value2 ; shift operator 2 rol value2+1 ; for next loop jmp mult1 done: sty result stx result+1 rts value1: £by $32,$04 value2: £by $4b,$13 result: £by $00,$00
Listing 2.5 ; Multiplication 16 Bit * 16 Bit = 16 Bit ; 65816-Version £ba $c000 sei clc ; native xce ; mode rep #%01100000 ; accu & index ; 16 bit £al ; tell assembler £rl ; about 16bit a®. lda #$0000 ; init. result mult1: ldx value1 ; operator 1 beq done ; 0? ready lsr value1 ; right bit oper.1 bcc mult2 ; clear? no add. clc adc value2 mult2: asl value2 jmp mult1 done: sta result sep #%00110000 ; 8 bit for accu&x/y £as ; tell assembler £rs sec ; switch to xce ; emulation mode cli rts value1: £by $32,$04 value2: £by $4b,$13 result: £by $00,$00
Listing 2.6 ; Example 16 Bit Indexregisters ; 65816 £ba $c000 sei clc ; clear xce ; e-flag, go native rep #%00010000 ; 16 bit indexregisters £rl ; tell assembler ldx #$5000 loop: lda $1000,x sta $2000,x dex bne loop lda #$00 sta $fc sta $fe lda #$20 sta $fd lda #$40 sta $ff ldy #$0000 loop2: lda ($fc),y sta ($fe),y iny cpy #$3000 bne loop2 sep #%00010000 ; back to 8 bit £rs ; tell assembler sec ; back to xce ; emulation-mode cli rts
Assembler Code © by Malte Mundt
Partial translation and cosmetical changes by Count Zero/SCS*TRC
[ Listings Part 1 ][
Tutorial Part 2 ][ Index ][ Listings
Part 3 ]