mirror of
https://gitlab.com/camelot/kickc.git
synced 2025-02-27 16:30:14 +00:00
Added fragment for subtracting unsigned byte from signed word.
This commit is contained in:
parent
8e2de5f79b
commit
4ad601ce72
7
src/main/fragment/vwsz1=vwsz2_minus_vbuc1.asm
Normal file
7
src/main/fragment/vwsz1=vwsz2_minus_vbuc1.asm
Normal file
@ -0,0 +1,7 @@
|
||||
sec
|
||||
lda {z2}
|
||||
sbc #{c1}
|
||||
sta {z1}
|
||||
lda {z2}+1
|
||||
sbc #0
|
||||
sta {z1}+1
|
@ -32,6 +32,16 @@ public class TestPrograms {
|
||||
public TestPrograms() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSignedWordMinusByte() throws IOException, URISyntaxException {
|
||||
compileAndCompare("test-signed-word-minus-byte");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIrqIdxProblem() throws IOException, URISyntaxException {
|
||||
compileAndCompare("irq-idx-problem");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDoubleIndexingArrays() throws IOException, URISyntaxException {
|
||||
compileAndCompare("double-indexing-arrays");
|
||||
|
48
src/test/kc/irq-idx-problem.kc
Normal file
48
src/test/kc/irq-idx-problem.kc
Normal file
@ -0,0 +1,48 @@
|
||||
// Test interrupt routine using a variable between calls (irq_idx)
|
||||
import "c64"
|
||||
|
||||
const byte* SCREEN = $0400;
|
||||
|
||||
void main() {
|
||||
asm { sei }
|
||||
// Disable CIA 1 Timer IRQ
|
||||
*CIA1_INTERRUPT = CIA_INTERRUPT_CLEAR;
|
||||
// Set raster line to $60
|
||||
*VIC_CONTROL &=$7f;
|
||||
*RASTER = $60;
|
||||
// Enable Raster Interrupt
|
||||
*IRQ_ENABLE = IRQ_RASTER;
|
||||
// Acknowledge any IRQ
|
||||
*IRQ_STATUS = IRQ_RASTER;
|
||||
// Setup the table driven IRQ routine
|
||||
*KERNEL_IRQ = &table_driven_irq;
|
||||
asm { cli }
|
||||
}
|
||||
|
||||
const byte *VIC_BASE = $D000;
|
||||
const byte VIC_SIZE = 48;
|
||||
const byte IRQ_CHANGE_NEXT = $7f;
|
||||
|
||||
byte[] IRQ_CHANGE_IDX = { $20, $21, IRQ_CHANGE_NEXT, $20, $21, IRQ_CHANGE_NEXT, $20, $21, IRQ_CHANGE_NEXT, $20, $21, IRQ_CHANGE_NEXT };
|
||||
byte[] IRQ_CHANGE_VAL = { $0b, $0b, $63, $00, $00, $80, $07, $07, $83, $00, $00, $60 };
|
||||
|
||||
volatile byte irq_idx = 0;
|
||||
|
||||
interrupt(kernel_min) void table_driven_irq() {
|
||||
do {
|
||||
byte idx = IRQ_CHANGE_IDX[irq_idx];
|
||||
byte val = IRQ_CHANGE_VAL[irq_idx];
|
||||
irq_idx++;
|
||||
if (idx < VIC_SIZE) {
|
||||
VIC_BASE[idx] = val;
|
||||
} else if (idx < VIC_SIZE + 8) {
|
||||
SCREEN[idx + $3f8 - VIC_SIZE] = val;
|
||||
} else {
|
||||
*IRQ_STATUS = IRQ_RASTER;
|
||||
*RASTER = val;
|
||||
if (val < *RASTER)
|
||||
irq_idx = 0;
|
||||
return;
|
||||
}
|
||||
} while (true);
|
||||
}
|
19
src/test/kc/test-signed-word-minus-byte.kc
Normal file
19
src/test/kc/test-signed-word-minus-byte.kc
Normal file
@ -0,0 +1,19 @@
|
||||
// Tests subtracting bytes from signed words
|
||||
|
||||
import "print"
|
||||
|
||||
void main() {
|
||||
signed word w1 = 1234;
|
||||
|
||||
print_cls();
|
||||
for( byte i: 0..10 ) {
|
||||
signed word w2 = w1 - 91;
|
||||
w1 = w2 - 41;
|
||||
print_sword(w1);
|
||||
print_char(' ');
|
||||
print_sword(w2);
|
||||
print_ln();
|
||||
}
|
||||
|
||||
|
||||
}
|
86
src/test/ref/irq-idx-problem.asm
Normal file
86
src/test/ref/irq-idx-problem.asm
Normal file
@ -0,0 +1,86 @@
|
||||
// Test interrupt routine using a variable between calls (irq_idx)
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(bbegin)
|
||||
.pc = $80d "Program"
|
||||
.label RASTER = $d012
|
||||
.label VIC_CONTROL = $d011
|
||||
// VIC II IRQ Status Register
|
||||
.label IRQ_STATUS = $d019
|
||||
// VIC II IRQ Enable Register
|
||||
.label IRQ_ENABLE = $d01a
|
||||
// Bits for the IRQ Status/Enable Registers
|
||||
.const IRQ_RASTER = 1
|
||||
// CIA#1 Interrupt Status & Control Register
|
||||
.label CIA1_INTERRUPT = $dc0d
|
||||
// Value that disables all CIA interrupts when stored to the CIA Interrupt registers
|
||||
.const CIA_INTERRUPT_CLEAR = $7f
|
||||
// The vector used when the KERNAL serves IRQ interrupts
|
||||
.label KERNEL_IRQ = $314
|
||||
.label SCREEN = $400
|
||||
.label VIC_BASE = $d000
|
||||
.const VIC_SIZE = $30
|
||||
.const IRQ_CHANGE_NEXT = $7f
|
||||
.label irq_idx = 2
|
||||
bbegin:
|
||||
lda #0
|
||||
sta irq_idx
|
||||
jsr main
|
||||
main: {
|
||||
sei
|
||||
// Disable CIA 1 Timer IRQ
|
||||
lda #CIA_INTERRUPT_CLEAR
|
||||
sta CIA1_INTERRUPT
|
||||
// Set raster line to $60
|
||||
lda VIC_CONTROL
|
||||
and #$7f
|
||||
sta VIC_CONTROL
|
||||
lda #$60
|
||||
sta RASTER
|
||||
// Enable Raster Interrupt
|
||||
lda #IRQ_RASTER
|
||||
sta IRQ_ENABLE
|
||||
// Acknowledge any IRQ
|
||||
sta IRQ_STATUS
|
||||
// Setup the table driven IRQ routine
|
||||
lda #<table_driven_irq
|
||||
sta KERNEL_IRQ
|
||||
lda #>table_driven_irq
|
||||
sta KERNEL_IRQ+1
|
||||
cli
|
||||
rts
|
||||
}
|
||||
table_driven_irq: {
|
||||
b1:
|
||||
ldy irq_idx
|
||||
lda IRQ_CHANGE_IDX,y
|
||||
ldx IRQ_CHANGE_VAL,y
|
||||
inc irq_idx
|
||||
cmp #VIC_SIZE
|
||||
bcc b2
|
||||
cmp #VIC_SIZE+8
|
||||
bcc b3
|
||||
lda #IRQ_RASTER
|
||||
sta IRQ_STATUS
|
||||
stx RASTER
|
||||
ldy RASTER
|
||||
sty $ff
|
||||
cpx $ff
|
||||
bcc !_ea81+
|
||||
jmp $ea81
|
||||
!_ea81:
|
||||
lda #0
|
||||
sta irq_idx
|
||||
jmp $ea81
|
||||
b3:
|
||||
tay
|
||||
txa
|
||||
sta SCREEN+-VIC_SIZE+$3f8,y
|
||||
jmp b1
|
||||
b2:
|
||||
tay
|
||||
txa
|
||||
sta VIC_BASE,y
|
||||
jmp b1
|
||||
}
|
||||
IRQ_CHANGE_VAL: .byte $b, $b, $63, 0, 0, $80, 7, 7, $83, 0, 0, $60
|
||||
IRQ_CHANGE_IDX: .byte $20, $21, IRQ_CHANGE_NEXT, $20, $21, IRQ_CHANGE_NEXT, $20, $21, IRQ_CHANGE_NEXT, $20, $21, IRQ_CHANGE_NEXT
|
55
src/test/ref/irq-idx-problem.cfg
Normal file
55
src/test/ref/irq-idx-problem.cfg
Normal file
@ -0,0 +1,55 @@
|
||||
@begin: scope:[] from
|
||||
[0] phi()
|
||||
to:@5
|
||||
@5: scope:[] from @begin
|
||||
[1] (byte) irq_idx#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0
|
||||
to:@6
|
||||
@6: scope:[] from @5
|
||||
[2] phi()
|
||||
[3] call main
|
||||
to:@end
|
||||
@end: scope:[] from @6
|
||||
[4] phi()
|
||||
main: scope:[main] from @6
|
||||
asm { sei }
|
||||
[6] *((const byte*) CIA1_INTERRUPT#0) ← (const byte) CIA_INTERRUPT_CLEAR#0
|
||||
[7] *((const byte*) VIC_CONTROL#0) ← *((const byte*) VIC_CONTROL#0) & (byte/signed byte/word/signed word/dword/signed dword) $7f
|
||||
[8] *((const byte*) RASTER#0) ← (byte/signed byte/word/signed word/dword/signed dword) $60
|
||||
[9] *((const byte*) IRQ_ENABLE#0) ← (const byte) IRQ_RASTER#0
|
||||
[10] *((const byte*) IRQ_STATUS#0) ← (const byte) IRQ_RASTER#0
|
||||
[11] *((const void()**) KERNEL_IRQ#0) ← &interrupt(KERNEL_MIN)(void()) table_driven_irq()
|
||||
asm { cli }
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main
|
||||
[13] return
|
||||
to:@return
|
||||
table_driven_irq: scope:[table_driven_irq] from
|
||||
[14] phi()
|
||||
to:table_driven_irq::@1
|
||||
table_driven_irq::@1: scope:[table_driven_irq] from table_driven_irq table_driven_irq::@2 table_driven_irq::@3
|
||||
[15] (byte) irq_idx#4 ← phi( table_driven_irq/(byte) irq_idx#0 table_driven_irq::@2/(byte) irq_idx#1 table_driven_irq::@3/(byte) irq_idx#1 )
|
||||
[16] (byte) table_driven_irq::idx#0 ← *((const byte[]) IRQ_CHANGE_IDX#0 + (byte) irq_idx#4)
|
||||
[17] (byte) table_driven_irq::val#0 ← *((const byte[]) IRQ_CHANGE_VAL#0 + (byte) irq_idx#4)
|
||||
[18] (byte) irq_idx#1 ← ++ (byte) irq_idx#4
|
||||
[19] if((byte) table_driven_irq::idx#0<(const byte) VIC_SIZE#0) goto table_driven_irq::@2
|
||||
to:table_driven_irq::@7
|
||||
table_driven_irq::@7: scope:[table_driven_irq] from table_driven_irq::@1
|
||||
[20] if((byte) table_driven_irq::idx#0<(const byte) VIC_SIZE#0+(byte/signed byte/word/signed word/dword/signed dword) 8) goto table_driven_irq::@3
|
||||
to:table_driven_irq::@8
|
||||
table_driven_irq::@8: scope:[table_driven_irq] from table_driven_irq::@7
|
||||
[21] *((const byte*) IRQ_STATUS#0) ← (const byte) IRQ_RASTER#0
|
||||
[22] *((const byte*) RASTER#0) ← (byte) table_driven_irq::val#0
|
||||
[23] if((byte) table_driven_irq::val#0>=*((const byte*) RASTER#0)) goto table_driven_irq::@return
|
||||
to:table_driven_irq::@9
|
||||
table_driven_irq::@9: scope:[table_driven_irq] from table_driven_irq::@8
|
||||
[24] (byte) irq_idx#2 ← (byte/signed byte/word/signed word/dword/signed dword) 0
|
||||
to:table_driven_irq::@return
|
||||
table_driven_irq::@return: scope:[table_driven_irq] from table_driven_irq::@8 table_driven_irq::@9
|
||||
[25] return
|
||||
to:@return
|
||||
table_driven_irq::@3: scope:[table_driven_irq] from table_driven_irq::@7
|
||||
[26] *((const byte*) SCREEN#0+-(const byte) VIC_SIZE#0+(word/signed word/dword/signed dword) $3f8 + (byte) table_driven_irq::idx#0) ← (byte) table_driven_irq::val#0
|
||||
to:table_driven_irq::@1
|
||||
table_driven_irq::@2: scope:[table_driven_irq] from table_driven_irq::@1
|
||||
[27] *((const byte*) VIC_BASE#0 + (byte) table_driven_irq::idx#0) ← (byte) table_driven_irq::val#0
|
||||
to:table_driven_irq::@1
|
1380
src/test/ref/irq-idx-problem.log
Normal file
1380
src/test/ref/irq-idx-problem.log
Normal file
File diff suppressed because it is too large
Load Diff
126
src/test/ref/irq-idx-problem.sym
Normal file
126
src/test/ref/irq-idx-problem.sym
Normal file
@ -0,0 +1,126 @@
|
||||
(label) @5
|
||||
(label) @6
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(byte*) BGCOL
|
||||
(byte*) BGCOL1
|
||||
(byte*) BGCOL2
|
||||
(byte*) BGCOL3
|
||||
(byte*) BGCOL4
|
||||
(byte) BLACK
|
||||
(byte) BLUE
|
||||
(byte*) BORDERCOL
|
||||
(byte) BROWN
|
||||
(byte*) CHARGEN
|
||||
(byte*) CIA1_INTERRUPT
|
||||
(const byte*) CIA1_INTERRUPT#0 CIA1_INTERRUPT = ((byte*))(word/dword/signed dword) $dc0d
|
||||
(byte*) CIA1_PORT_A
|
||||
(byte*) CIA1_PORT_A_DDR
|
||||
(byte*) CIA1_PORT_B
|
||||
(byte*) CIA1_PORT_B_DDR
|
||||
(byte*) CIA2_INTERRUPT
|
||||
(byte*) CIA2_PORT_A
|
||||
(byte*) CIA2_PORT_A_DDR
|
||||
(byte*) CIA2_PORT_B
|
||||
(byte*) CIA2_PORT_B_DDR
|
||||
(byte) CIA_INTERRUPT_CLEAR
|
||||
(const byte) CIA_INTERRUPT_CLEAR#0 CIA_INTERRUPT_CLEAR = (byte/signed byte/word/signed word/dword/signed dword) $7f
|
||||
(byte*) COLS
|
||||
(byte) CYAN
|
||||
(byte*) D011
|
||||
(byte*) D016
|
||||
(byte*) D018
|
||||
(byte) DARK_GREY
|
||||
(byte) GREEN
|
||||
(byte) GREY
|
||||
(void()**) HARDWARE_IRQ
|
||||
(byte[]) IRQ_CHANGE_IDX
|
||||
(const byte[]) IRQ_CHANGE_IDX#0 IRQ_CHANGE_IDX = { (byte/signed byte/word/signed word/dword/signed dword) $20, (byte/signed byte/word/signed word/dword/signed dword) $21, (const byte) IRQ_CHANGE_NEXT#0, (byte/signed byte/word/signed word/dword/signed dword) $20, (byte/signed byte/word/signed word/dword/signed dword) $21, (const byte) IRQ_CHANGE_NEXT#0, (byte/signed byte/word/signed word/dword/signed dword) $20, (byte/signed byte/word/signed word/dword/signed dword) $21, (const byte) IRQ_CHANGE_NEXT#0, (byte/signed byte/word/signed word/dword/signed dword) $20, (byte/signed byte/word/signed word/dword/signed dword) $21, (const byte) IRQ_CHANGE_NEXT#0 }
|
||||
(byte) IRQ_CHANGE_NEXT
|
||||
(const byte) IRQ_CHANGE_NEXT#0 IRQ_CHANGE_NEXT = (byte/signed byte/word/signed word/dword/signed dword) $7f
|
||||
(byte[]) IRQ_CHANGE_VAL
|
||||
(const byte[]) IRQ_CHANGE_VAL#0 IRQ_CHANGE_VAL = { (byte/signed byte/word/signed word/dword/signed dword) $b, (byte/signed byte/word/signed word/dword/signed dword) $b, (byte/signed byte/word/signed word/dword/signed dword) $63, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/word/signed word/dword/signed dword) $80, (byte/signed byte/word/signed word/dword/signed dword) 7, (byte/signed byte/word/signed word/dword/signed dword) 7, (byte/word/signed word/dword/signed dword) $83, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) $60 }
|
||||
(byte) IRQ_COLLISION_BG
|
||||
(byte) IRQ_COLLISION_SPRITE
|
||||
(byte*) IRQ_ENABLE
|
||||
(const byte*) IRQ_ENABLE#0 IRQ_ENABLE = ((byte*))(word/dword/signed dword) $d01a
|
||||
(byte) IRQ_LIGHTPEN
|
||||
(byte) IRQ_RASTER
|
||||
(const byte) IRQ_RASTER#0 IRQ_RASTER = (byte/signed byte/word/signed word/dword/signed dword) 1
|
||||
(byte*) IRQ_STATUS
|
||||
(const byte*) IRQ_STATUS#0 IRQ_STATUS = ((byte*))(word/dword/signed dword) $d019
|
||||
(void()**) KERNEL_IRQ
|
||||
(const void()**) KERNEL_IRQ#0 KERNEL_IRQ = ((void()**))(word/signed word/dword/signed dword) $314
|
||||
(byte*) LIGHTPEN_X
|
||||
(byte*) LIGHTPEN_Y
|
||||
(byte) LIGHT_BLUE
|
||||
(byte) LIGHT_GREEN
|
||||
(byte) LIGHT_GREY
|
||||
(byte) ORANGE
|
||||
(byte) PINK
|
||||
(byte*) PROCPORT
|
||||
(byte) PROCPORT_BASIC_KERNEL_IO
|
||||
(byte*) PROCPORT_DDR
|
||||
(byte) PROCPORT_DDR_MEMORY_MASK
|
||||
(byte) PROCPORT_KERNEL_IO
|
||||
(byte) PROCPORT_RAM_ALL
|
||||
(byte) PROCPORT_RAM_CHARROM
|
||||
(byte) PROCPORT_RAM_IO
|
||||
(byte) PURPLE
|
||||
(byte*) RASTER
|
||||
(const byte*) RASTER#0 RASTER = ((byte*))(word/dword/signed dword) $d012
|
||||
(byte) RED
|
||||
(byte*) SCREEN
|
||||
(const byte*) SCREEN#0 SCREEN = ((byte*))(word/signed word/dword/signed dword) $400
|
||||
(byte*) SPRITES_COLS
|
||||
(byte*) SPRITES_ENABLE
|
||||
(byte*) SPRITES_EXPAND_X
|
||||
(byte*) SPRITES_EXPAND_Y
|
||||
(byte*) SPRITES_MC
|
||||
(byte*) SPRITES_MC1
|
||||
(byte*) SPRITES_MC2
|
||||
(byte*) SPRITES_PRIORITY
|
||||
(byte*) SPRITES_XMSB
|
||||
(byte*) SPRITES_XPOS
|
||||
(byte*) SPRITES_YPOS
|
||||
(word) SPRITE_PTRS
|
||||
(byte*) VIC_BASE
|
||||
(const byte*) VIC_BASE#0 VIC_BASE = ((byte*))(word/dword/signed dword) $d000
|
||||
(byte) VIC_BMM
|
||||
(byte*) VIC_CONTROL
|
||||
(const byte*) VIC_CONTROL#0 VIC_CONTROL = ((byte*))(word/dword/signed dword) $d011
|
||||
(byte*) VIC_CONTROL2
|
||||
(byte) VIC_CSEL
|
||||
(byte) VIC_DEN
|
||||
(byte) VIC_ECM
|
||||
(byte) VIC_MCM
|
||||
(byte*) VIC_MEMORY
|
||||
(byte) VIC_RSEL
|
||||
(byte) VIC_RST8
|
||||
(byte) VIC_SIZE
|
||||
(const byte) VIC_SIZE#0 VIC_SIZE = (byte/signed byte/word/signed word/dword/signed dword) $30
|
||||
(byte) WHITE
|
||||
(byte) YELLOW
|
||||
(byte) irq_idx
|
||||
(byte) irq_idx#0 irq_idx zp ZP_BYTE:2 4.0
|
||||
(byte) irq_idx#1 irq_idx zp ZP_BYTE:2 6.6000000000000005
|
||||
(byte) irq_idx#2 irq_idx zp ZP_BYTE:2 20.0
|
||||
(byte) irq_idx#4 irq_idx zp ZP_BYTE:2 19.0
|
||||
(void()) main()
|
||||
(label) main::@return
|
||||
interrupt(KERNEL_MIN)(void()) table_driven_irq()
|
||||
(label) table_driven_irq::@1
|
||||
(label) table_driven_irq::@2
|
||||
(label) table_driven_irq::@3
|
||||
(label) table_driven_irq::@7
|
||||
(label) table_driven_irq::@8
|
||||
(label) table_driven_irq::@9
|
||||
(label) table_driven_irq::@return
|
||||
(byte) table_driven_irq::idx
|
||||
(byte) table_driven_irq::idx#0 reg byte a 11.0
|
||||
(byte) table_driven_irq::val
|
||||
(byte) table_driven_irq::val#0 reg byte x 6.166666666666666
|
||||
|
||||
zp ZP_BYTE:2 [ irq_idx#4 irq_idx#0 irq_idx#1 irq_idx#2 ]
|
||||
reg byte a [ table_driven_irq::idx#0 ]
|
||||
reg byte x [ table_driven_irq::val#0 ]
|
167
src/test/ref/test-signed-word-minus-byte.asm
Normal file
167
src/test/ref/test-signed-word-minus-byte.asm
Normal file
@ -0,0 +1,167 @@
|
||||
// Tests subtracting bytes from signed words
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(main)
|
||||
.pc = $80d "Program"
|
||||
.label print_line_cursor = 4
|
||||
.label print_char_cursor = 9
|
||||
main: {
|
||||
.label w2 = $b
|
||||
.label w1 = 2
|
||||
jsr print_cls
|
||||
ldx #0
|
||||
lda #<$400
|
||||
sta print_line_cursor
|
||||
lda #>$400
|
||||
sta print_line_cursor+1
|
||||
lda #<$400
|
||||
sta print_char_cursor
|
||||
lda #>$400
|
||||
sta print_char_cursor+1
|
||||
lda #<$4d2
|
||||
sta w1
|
||||
lda #>$4d2
|
||||
sta w1+1
|
||||
b1:
|
||||
sec
|
||||
lda w1
|
||||
sbc #$5b
|
||||
sta w2
|
||||
lda w1+1
|
||||
sbc #0
|
||||
sta w2+1
|
||||
sec
|
||||
lda w2
|
||||
sbc #$29
|
||||
sta w1
|
||||
lda w2+1
|
||||
sbc #0
|
||||
sta w1+1
|
||||
lda w1
|
||||
sta print_sword.w
|
||||
lda w1+1
|
||||
sta print_sword.w+1
|
||||
jsr print_sword
|
||||
lda #' '
|
||||
jsr print_char
|
||||
lda w2
|
||||
sta print_sword.w
|
||||
lda w2+1
|
||||
sta print_sword.w+1
|
||||
jsr print_sword
|
||||
jsr print_ln
|
||||
inx
|
||||
cpx #$b
|
||||
bne b8
|
||||
rts
|
||||
b8:
|
||||
lda print_line_cursor
|
||||
sta print_char_cursor
|
||||
lda print_line_cursor+1
|
||||
sta print_char_cursor+1
|
||||
jmp b1
|
||||
}
|
||||
// Print a newline
|
||||
print_ln: {
|
||||
b1:
|
||||
lda #$28
|
||||
clc
|
||||
adc print_line_cursor
|
||||
sta print_line_cursor
|
||||
bcc !+
|
||||
inc print_line_cursor+1
|
||||
!:
|
||||
lda print_line_cursor+1
|
||||
cmp print_char_cursor+1
|
||||
bcc b1
|
||||
bne !+
|
||||
lda print_line_cursor
|
||||
cmp print_char_cursor
|
||||
bcc b1
|
||||
!:
|
||||
rts
|
||||
}
|
||||
// Print a signed word as HEX
|
||||
// print_sword(signed word zeropage(6) w)
|
||||
print_sword: {
|
||||
.label w = 6
|
||||
lda w+1
|
||||
bpl b1
|
||||
lda #'-'
|
||||
jsr print_char
|
||||
sec
|
||||
lda w
|
||||
eor #$ff
|
||||
adc #0
|
||||
sta w
|
||||
lda w+1
|
||||
eor #$ff
|
||||
adc #0
|
||||
sta w+1
|
||||
b1:
|
||||
jsr print_word
|
||||
rts
|
||||
}
|
||||
// Print a word as HEX
|
||||
print_word: {
|
||||
lda print_sword.w+1
|
||||
sta print_byte.b
|
||||
jsr print_byte
|
||||
lda print_sword.w
|
||||
sta print_byte.b
|
||||
jsr print_byte
|
||||
rts
|
||||
}
|
||||
// Print a byte as HEX
|
||||
// print_byte(byte zeropage(8) b)
|
||||
print_byte: {
|
||||
.label b = 8
|
||||
lda b
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
tay
|
||||
lda print_hextab,y
|
||||
jsr print_char
|
||||
lda #$f
|
||||
and b
|
||||
tay
|
||||
lda print_hextab,y
|
||||
jsr print_char
|
||||
rts
|
||||
}
|
||||
// Print a single char
|
||||
// print_char(byte register(A) ch)
|
||||
print_char: {
|
||||
ldy #0
|
||||
sta (print_char_cursor),y
|
||||
inc print_char_cursor
|
||||
bne !+
|
||||
inc print_char_cursor+1
|
||||
!:
|
||||
rts
|
||||
}
|
||||
// Clear the screen. Also resets current line/char cursor.
|
||||
print_cls: {
|
||||
.label sc = 2
|
||||
lda #<$400
|
||||
sta sc
|
||||
lda #>$400
|
||||
sta sc+1
|
||||
b1:
|
||||
lda #' '
|
||||
ldy #0
|
||||
sta (sc),y
|
||||
inc sc
|
||||
bne !+
|
||||
inc sc+1
|
||||
!:
|
||||
lda sc+1
|
||||
cmp #>$400+$3e8
|
||||
bne b1
|
||||
lda sc
|
||||
cmp #<$400+$3e8
|
||||
bne b1
|
||||
rts
|
||||
}
|
||||
print_hextab: .text "0123456789abcdef"
|
123
src/test/ref/test-signed-word-minus-byte.cfg
Normal file
123
src/test/ref/test-signed-word-minus-byte.cfg
Normal file
@ -0,0 +1,123 @@
|
||||
@begin: scope:[] from
|
||||
[0] phi()
|
||||
to:@20
|
||||
@20: scope:[] from @begin
|
||||
[1] phi()
|
||||
[2] call main
|
||||
to:@end
|
||||
@end: scope:[] from @20
|
||||
[3] phi()
|
||||
main: scope:[main] from @20
|
||||
[4] phi()
|
||||
[5] call print_cls
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@8
|
||||
[6] (byte) main::i#2 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 0 main::@8/(byte) main::i#1 )
|
||||
[6] (byte*) print_line_cursor#19 ← phi( main/((byte*))(word/signed word/dword/signed dword) $400 main::@8/(byte*) print_line_cursor#1 )
|
||||
[6] (byte*) print_char_cursor#50 ← phi( main/((byte*))(word/signed word/dword/signed dword) $400 main::@8/(byte*~) print_char_cursor#54 )
|
||||
[6] (signed word) main::w1#2 ← phi( main/(word/signed word/dword/signed dword) $4d2 main::@8/(signed word) main::w1#1 )
|
||||
[7] (signed word) main::w2#0 ← (signed word) main::w1#2 - (byte/signed byte/word/signed word/dword/signed dword) $5b
|
||||
[8] (signed word) main::w1#1 ← (signed word) main::w2#0 - (byte/signed byte/word/signed word/dword/signed dword) $29
|
||||
[9] (signed word) print_sword::w#1 ← (signed word) main::w1#1
|
||||
[10] call print_sword
|
||||
to:main::@4
|
||||
main::@4: scope:[main] from main::@1
|
||||
[11] phi()
|
||||
[12] call print_char
|
||||
to:main::@5
|
||||
main::@5: scope:[main] from main::@4
|
||||
[13] (signed word) print_sword::w#2 ← (signed word) main::w2#0
|
||||
[14] call print_sword
|
||||
to:main::@6
|
||||
main::@6: scope:[main] from main::@5
|
||||
[15] phi()
|
||||
[16] call print_ln
|
||||
to:main::@7
|
||||
main::@7: scope:[main] from main::@6
|
||||
[17] (byte) main::i#1 ← ++ (byte) main::i#2
|
||||
[18] if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) $b) goto main::@8
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@7
|
||||
[19] return
|
||||
to:@return
|
||||
main::@8: scope:[main] from main::@7
|
||||
[20] (byte*~) print_char_cursor#54 ← (byte*) print_line_cursor#1
|
||||
to:main::@1
|
||||
print_ln: scope:[print_ln] from main::@6
|
||||
[21] phi()
|
||||
to:print_ln::@1
|
||||
print_ln::@1: scope:[print_ln] from print_ln print_ln::@1
|
||||
[22] (byte*) print_line_cursor#9 ← phi( print_ln/(byte*) print_line_cursor#19 print_ln::@1/(byte*) print_line_cursor#1 )
|
||||
[23] (byte*) print_line_cursor#1 ← (byte*) print_line_cursor#9 + (byte/signed byte/word/signed word/dword/signed dword) $28
|
||||
[24] if((byte*) print_line_cursor#1<(byte*) print_char_cursor#12) goto print_ln::@1
|
||||
to:print_ln::@return
|
||||
print_ln::@return: scope:[print_ln] from print_ln::@1
|
||||
[25] return
|
||||
to:@return
|
||||
print_sword: scope:[print_sword] from main::@1 main::@5
|
||||
[26] (byte*) print_char_cursor#46 ← phi( main::@1/(byte*) print_char_cursor#50 main::@5/(byte*) print_char_cursor#12 )
|
||||
[26] (signed word) print_sword::w#3 ← phi( main::@1/(signed word) print_sword::w#1 main::@5/(signed word) print_sword::w#2 )
|
||||
[27] if((signed word) print_sword::w#3>=(byte/signed byte/word/signed word/dword/signed dword) 0) goto print_sword::@1
|
||||
to:print_sword::@2
|
||||
print_sword::@2: scope:[print_sword] from print_sword
|
||||
[28] phi()
|
||||
[29] call print_char
|
||||
to:print_sword::@4
|
||||
print_sword::@4: scope:[print_sword] from print_sword::@2
|
||||
[30] (signed word) print_sword::w#0 ← - (signed word) print_sword::w#3
|
||||
to:print_sword::@1
|
||||
print_sword::@1: scope:[print_sword] from print_sword print_sword::@4
|
||||
[31] (byte*) print_char_cursor#45 ← phi( print_sword/(byte*) print_char_cursor#46 print_sword::@4/(byte*) print_char_cursor#12 )
|
||||
[31] (signed word) print_sword::w#4 ← phi( print_sword/(signed word) print_sword::w#3 print_sword::@4/(signed word) print_sword::w#0 )
|
||||
[32] call print_word
|
||||
to:print_sword::@return
|
||||
print_sword::@return: scope:[print_sword] from print_sword::@1
|
||||
[33] return
|
||||
to:@return
|
||||
print_word: scope:[print_word] from print_sword::@1
|
||||
[34] (byte) print_byte::b#0 ← > (word)(signed word) print_sword::w#4
|
||||
[35] call print_byte
|
||||
to:print_word::@1
|
||||
print_word::@1: scope:[print_word] from print_word
|
||||
[36] (byte) print_byte::b#1 ← < (word)(signed word) print_sword::w#4
|
||||
[37] call print_byte
|
||||
to:print_word::@return
|
||||
print_word::@return: scope:[print_word] from print_word::@1
|
||||
[38] return
|
||||
to:@return
|
||||
print_byte: scope:[print_byte] from print_word print_word::@1
|
||||
[39] (byte*) print_char_cursor#48 ← phi( print_word/(byte*) print_char_cursor#45 print_word::@1/(byte*) print_char_cursor#12 )
|
||||
[39] (byte) print_byte::b#2 ← phi( print_word/(byte) print_byte::b#0 print_word::@1/(byte) print_byte::b#1 )
|
||||
[40] (byte~) print_byte::$0 ← (byte) print_byte::b#2 >> (byte/signed byte/word/signed word/dword/signed dword) 4
|
||||
[41] (byte) print_char::ch#1 ← *((const byte[]) print_hextab#0 + (byte~) print_byte::$0)
|
||||
[42] call print_char
|
||||
to:print_byte::@1
|
||||
print_byte::@1: scope:[print_byte] from print_byte
|
||||
[43] (byte~) print_byte::$2 ← (byte) print_byte::b#2 & (byte/signed byte/word/signed word/dword/signed dword) $f
|
||||
[44] (byte) print_char::ch#2 ← *((const byte[]) print_hextab#0 + (byte~) print_byte::$2)
|
||||
[45] call print_char
|
||||
to:print_byte::@return
|
||||
print_byte::@return: scope:[print_byte] from print_byte::@1
|
||||
[46] return
|
||||
to:@return
|
||||
print_char: scope:[print_char] from main::@4 print_byte print_byte::@1 print_sword::@2
|
||||
[47] (byte*) print_char_cursor#34 ← phi( main::@4/(byte*) print_char_cursor#12 print_byte/(byte*) print_char_cursor#48 print_byte::@1/(byte*) print_char_cursor#12 print_sword::@2/(byte*) print_char_cursor#46 )
|
||||
[47] (byte) print_char::ch#4 ← phi( main::@4/(byte) ' ' print_byte/(byte) print_char::ch#1 print_byte::@1/(byte) print_char::ch#2 print_sword::@2/(byte) '-' )
|
||||
[48] *((byte*) print_char_cursor#34) ← (byte) print_char::ch#4
|
||||
[49] (byte*) print_char_cursor#12 ← ++ (byte*) print_char_cursor#34
|
||||
to:print_char::@return
|
||||
print_char::@return: scope:[print_char] from print_char
|
||||
[50] return
|
||||
to:@return
|
||||
print_cls: scope:[print_cls] from main
|
||||
[51] phi()
|
||||
to:print_cls::@1
|
||||
print_cls::@1: scope:[print_cls] from print_cls print_cls::@1
|
||||
[52] (byte*) print_cls::sc#2 ← phi( print_cls/((byte*))(word/signed word/dword/signed dword) $400 print_cls::@1/(byte*) print_cls::sc#1 )
|
||||
[53] *((byte*) print_cls::sc#2) ← (byte) ' '
|
||||
[54] (byte*) print_cls::sc#1 ← ++ (byte*) print_cls::sc#2
|
||||
[55] if((byte*) print_cls::sc#1!=((byte*))(word/signed word/dword/signed dword) $400+(word/signed word/dword/signed dword) $3e8) goto print_cls::@1
|
||||
to:print_cls::@return
|
||||
print_cls::@return: scope:[print_cls] from print_cls::@1
|
||||
[56] return
|
||||
to:@return
|
2083
src/test/ref/test-signed-word-minus-byte.log
Normal file
2083
src/test/ref/test-signed-word-minus-byte.log
Normal file
File diff suppressed because it is too large
Load Diff
84
src/test/ref/test-signed-word-minus-byte.sym
Normal file
84
src/test/ref/test-signed-word-minus-byte.sym
Normal file
@ -0,0 +1,84 @@
|
||||
(label) @20
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(void()) main()
|
||||
(label) main::@1
|
||||
(label) main::@4
|
||||
(label) main::@5
|
||||
(label) main::@6
|
||||
(label) main::@7
|
||||
(label) main::@8
|
||||
(label) main::@return
|
||||
(byte) main::i
|
||||
(byte) main::i#1 reg byte x 11.0
|
||||
(byte) main::i#2 reg byte x 2.0
|
||||
(signed word) main::w1
|
||||
(signed word) main::w1#1 w1 zp ZP_WORD:2 2.75
|
||||
(signed word) main::w1#2 w1 zp ZP_WORD:2 22.0
|
||||
(signed word) main::w2
|
||||
(signed word) main::w2#0 w2 zp ZP_WORD:11 5.5
|
||||
(void()) print_byte((byte) print_byte::b)
|
||||
(byte~) print_byte::$0 reg byte a 4.0
|
||||
(byte~) print_byte::$2 reg byte a 4.0
|
||||
(label) print_byte::@1
|
||||
(label) print_byte::@return
|
||||
(byte) print_byte::b
|
||||
(byte) print_byte::b#0 b zp ZP_BYTE:8 4.0
|
||||
(byte) print_byte::b#1 b zp ZP_BYTE:8 4.0
|
||||
(byte) print_byte::b#2 b zp ZP_BYTE:8 2.0
|
||||
(void()) print_char((byte) print_char::ch)
|
||||
(label) print_char::@return
|
||||
(byte) print_char::ch
|
||||
(byte) print_char::ch#1 reg byte a 4.0
|
||||
(byte) print_char::ch#2 reg byte a 4.0
|
||||
(byte) print_char::ch#4 reg byte a 6.0
|
||||
(byte*) print_char_cursor
|
||||
(byte*) print_char_cursor#12 print_char_cursor zp ZP_WORD:9 5.240000000000001
|
||||
(byte*) print_char_cursor#34 print_char_cursor zp ZP_WORD:9 10.5
|
||||
(byte*) print_char_cursor#45 print_char_cursor zp ZP_WORD:9 3.0
|
||||
(byte*) print_char_cursor#46 print_char_cursor zp ZP_WORD:9 8.666666666666666
|
||||
(byte*) print_char_cursor#48 print_char_cursor zp ZP_WORD:9 2.0
|
||||
(byte*) print_char_cursor#50 print_char_cursor zp ZP_WORD:9 5.5
|
||||
(byte*~) print_char_cursor#54 print_char_cursor zp ZP_WORD:9 22.0
|
||||
(void()) print_cls()
|
||||
(label) print_cls::@1
|
||||
(label) print_cls::@return
|
||||
(byte*) print_cls::sc
|
||||
(byte*) print_cls::sc#1 sc zp ZP_WORD:2 16.5
|
||||
(byte*) print_cls::sc#2 sc zp ZP_WORD:2 16.5
|
||||
(byte[]) print_hextab
|
||||
(const byte[]) print_hextab#0 print_hextab = (string) "0123456789abcdef"
|
||||
(byte*) print_line_cursor
|
||||
(byte*) print_line_cursor#1 print_line_cursor zp ZP_WORD:4 46.42857142857143
|
||||
(byte*) print_line_cursor#19 print_line_cursor zp ZP_WORD:4 1.1818181818181819
|
||||
(byte*) print_line_cursor#9 print_line_cursor zp ZP_WORD:4 204.0
|
||||
(void()) print_ln()
|
||||
(label) print_ln::@1
|
||||
(label) print_ln::@return
|
||||
(byte*) print_screen
|
||||
(void()) print_sword((signed word) print_sword::w)
|
||||
(label) print_sword::@1
|
||||
(label) print_sword::@2
|
||||
(label) print_sword::@4
|
||||
(label) print_sword::@return
|
||||
(signed word) print_sword::w
|
||||
(signed word) print_sword::w#0 w zp ZP_WORD:6 4.0
|
||||
(signed word) print_sword::w#1 w zp ZP_WORD:6 22.0
|
||||
(signed word) print_sword::w#2 w zp ZP_WORD:6 22.0
|
||||
(signed word) print_sword::w#3 w zp ZP_WORD:6 7.0
|
||||
(signed word) print_sword::w#4 w zp ZP_WORD:6 1.3333333333333333
|
||||
(void()) print_word((word) print_word::w)
|
||||
(label) print_word::@1
|
||||
(label) print_word::@return
|
||||
(word) print_word::w
|
||||
|
||||
zp ZP_WORD:2 [ main::w1#2 main::w1#1 print_cls::sc#2 print_cls::sc#1 ]
|
||||
reg byte x [ main::i#2 main::i#1 ]
|
||||
zp ZP_WORD:4 [ print_line_cursor#9 print_line_cursor#19 print_line_cursor#1 ]
|
||||
zp ZP_WORD:6 [ print_sword::w#4 print_sword::w#3 print_sword::w#1 print_sword::w#2 print_sword::w#0 ]
|
||||
zp ZP_BYTE:8 [ print_byte::b#2 print_byte::b#0 print_byte::b#1 ]
|
||||
reg byte a [ print_char::ch#4 print_char::ch#1 print_char::ch#2 ]
|
||||
zp ZP_WORD:9 [ print_char_cursor#34 print_char_cursor#48 print_char_cursor#45 print_char_cursor#46 print_char_cursor#50 print_char_cursor#54 print_char_cursor#12 ]
|
||||
zp ZP_WORD:11 [ main::w2#0 ]
|
||||
reg byte a [ print_byte::$0 ]
|
||||
reg byte a [ print_byte::$2 ]
|
Loading…
x
Reference in New Issue
Block a user