1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-06-20 03:29:32 +00:00

Added tests for different reported problems & fixes.

This commit is contained in:
jespergravgaard 2019-09-18 21:53:32 +02:00
parent caf8ac6421
commit 70435aec30
21 changed files with 13942 additions and 0 deletions

View File

@ -35,6 +35,26 @@ public class TestPrograms {
public TestPrograms() {
}
@Test
public void testSignedCharComparison() throws IOException, URISyntaxException {
compileAndCompare("signed-char-comparison");
}
@Test
public void testBitmapLineAnim2() throws IOException, URISyntaxException {
compileAndCompare("bitmap-line-anim-2");
}
@Test
public void testBitmapLineAnim1() throws IOException, URISyntaxException {
compileAndCompare("bitmap-line-anim-1");
}
@Test
public void testStackRelativeAddressing() throws IOException, URISyntaxException {
compileAndCompare("stack-relative-addressing");
}
/*
@Test
public void testProcedureCallingConventionStack1() throws IOException, URISyntaxException {

View File

@ -0,0 +1,30 @@
// Illustrates problem with bitmap-draw.kc line()
// Reported by Janne Johansson
import "c64.kc"
import "bitmap-draw.kc"
const byte* SCREEN = $400;
const byte* BITMAP = $2000;
byte next=0;
void main() {
*BORDERCOL = 0;
*BGCOL = 0;
*D011 = VIC_BMM|VIC_DEN|VIC_RSEL|3;
*VIC_MEMORY = (byte)((((word)SCREEN&$3fff)/$40)|(((word)BITMAP&$3fff)/$400));
bitmap_init(BITMAP);
bitmap_clear();
init_screen();
do {
bitmap_line(0,next,0,100);
next++;
} while (true);
}
void init_screen() {
for(byte* c = SCREEN; c!=SCREEN+$400;c++) {
*c = $14;
}
}

View File

@ -0,0 +1,24 @@
// Shows that bitmap2.kc line() does not have the same problem as bitmap-draw.kc
// See bitmap-line-anim-1.kc
import "c64.kc"
import "bitmap2.kc"
const byte* SCREEN = $400;
const byte* BITMAP = $2000;
word next=0;
void main() {
*BORDERCOL = 0;
*BGCOL = 0;
*D011 = VIC_BMM|VIC_DEN|VIC_RSEL|3;
*VIC_MEMORY = (byte)((((word)SCREEN&$3fff)/$40)|(((word)BITMAP&$3fff)/$400));
bitmap_init(BITMAP, SCREEN);
bitmap_clear(PURPLE, WHITE);
do {
bitmap_line(0,0,next,100);
next++;
if(next==320) next=0;
} while (true);
}

View File

@ -0,0 +1,16 @@
// Illustrates problem with > comparison of signed chars.
// Reported by Danny Spijksma
void main() {
for(signed char dy:-128..127)
debug(dy);
}
char *SCREEN = 0x0400;
void debug(signed char dy) {
char i = (char)dy;
if (dy > -120) {
SCREEN[i] = 10;
}
}

View File

@ -0,0 +1,42 @@
// Test stack-relative addressing (for passing parameters through the stack)
/** The hardware stack. The offset 3 is to skip the return address and the fact that the pointer is to the next free position. */
const char* STACK = 0x0103;
void main() {
// Push a few values to the stack
asm {
lda #'1'
pha
lda #'2'
pha
lda #'3'
pha
}
// Then call a function
peek_stack();
// Clean up the stack
asm {
pla
pla
pla
}
}
/** The screen. */
const char* SCREEN = 0x0400;
// Peek values from the stack using stack-relative addressing
void peek_stack() {
asm {
tsx
lda STACK,x // The last byte pushed
sta SCREEN
lda STACK+1,x // The 2nd last byte pushed
sta SCREEN+1
lda STACK+2,x // The 3rd last byte pushed
sta SCREEN+2
}
}

View File

@ -0,0 +1,347 @@
// Illustrates problem with bitmap-draw.kc line()
// Reported by Janne Johansson
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
.label BORDERCOL = $d020
.label BGCOL = $d021
.label D011 = $d011
.const VIC_BMM = $20
.const VIC_DEN = $10
.const VIC_RSEL = 8
.label VIC_MEMORY = $d018
.label SCREEN = $400
.label BITMAP = $2000
.label next = 5
main: {
lda #0
sta BORDERCOL
sta BGCOL
lda #VIC_BMM|VIC_DEN|VIC_RSEL|3
sta D011
lda #(SCREEN&$3fff)/$40|(BITMAP&$3fff)/$400
sta VIC_MEMORY
jsr bitmap_init
jsr bitmap_clear
jsr init_screen
lda #0
sta.z next
b1:
ldx.z next
jsr bitmap_line
inc.z next
jmp b1
}
// Draw a line on the bitmap
// bitmap_line(byte register(X) x1)
bitmap_line: {
.label x0 = 0
.label y0 = 0
.label y1 = $64
cpx #x0
beq !+
bcs b1
!:
txa
cmp #y1
beq !+
bcs b4
!:
sta.z bitmap_line_ydxd.xd
jsr bitmap_line_ydxd
rts
b4:
stx.z bitmap_line_xdyd.x
sta.z bitmap_line_xdyd.xd
jsr bitmap_line_xdyd
rts
b1:
txa
cmp #y1
beq !+
bcs b7
!:
sta.z bitmap_line_ydxi.xd
jsr bitmap_line_ydxi
rts
b7:
stx.z bitmap_line_xdyi.x1
sta.z bitmap_line_xdyi.xd
jsr bitmap_line_xdyi
rts
}
// bitmap_line_xdyi(byte zeropage(2) x, byte zeropage(3) y, byte zeropage(6) x1, byte zeropage($b) xd)
bitmap_line_xdyi: {
.label x1 = 6
.label xd = $b
.label x = 2
.label e = 4
.label y = 3
lda #bitmap_line.y1>>1
sta.z e
lda #bitmap_line.y0
sta.z y
lda #bitmap_line.x0
sta.z x
b1:
ldx.z x
ldy.z y
jsr bitmap_plot
inc.z x
lax.z e
axs #-[bitmap_line.y1]
stx.z e
lda.z xd
cmp.z e
bcs b2
inc.z y
txa
sec
sbc.z xd
sta.z e
b2:
ldx.z x1
inx
cpx.z x
bne b1
rts
}
// bitmap_plot(byte register(X) x, byte register(Y) y)
bitmap_plot: {
.label plotter_x = 7
.label plotter_y = 9
.label plotter = 7
lda bitmap_plot_xhi,x
sta.z plotter_x+1
lda bitmap_plot_xlo,x
sta.z plotter_x
lda bitmap_plot_yhi,y
sta.z plotter_y+1
lda bitmap_plot_ylo,y
sta.z plotter_y
lda.z plotter
clc
adc.z plotter_y
sta.z plotter
lda.z plotter+1
adc.z plotter_y+1
sta.z plotter+1
lda bitmap_plot_bit,x
ldy #0
ora (plotter),y
sta (plotter),y
rts
}
// bitmap_line_ydxi(byte zeropage(3) y, byte zeropage(2) x, byte zeropage(6) xd)
bitmap_line_ydxi: {
.label xd = 6
.label e = 4
.label y = 3
.label x = 2
lda.z xd
lsr
sta.z e
lda #bitmap_line.y0
sta.z y
lda #bitmap_line.x0
sta.z x
b1:
ldx.z x
ldy.z y
jsr bitmap_plot
inc.z y
lda.z e
clc
adc.z xd
sta.z e
lda #bitmap_line.y1
cmp.z e
bcs b2
inc.z x
lax.z e
axs #bitmap_line.y1
stx.z e
b2:
lda #bitmap_line.y1+1
cmp.z y
bne b1
rts
}
// bitmap_line_xdyd(byte zeropage(2) x, byte zeropage(3) y, byte zeropage(6) xd)
bitmap_line_xdyd: {
.label x = 2
.label xd = 6
.label e = 4
.label y = 3
lda #bitmap_line.y1>>1
sta.z e
lda #bitmap_line.y1
sta.z y
b1:
ldx.z x
ldy.z y
jsr bitmap_plot
inc.z x
lax.z e
axs #-[bitmap_line.y1]
stx.z e
lda.z xd
cmp.z e
bcs b2
dec.z y
txa
sec
sbc.z xd
sta.z e
b2:
lda #1
cmp.z x
bne b1
rts
}
// bitmap_line_ydxd(byte zeropage(3) y, byte zeropage(2) x, byte zeropage(6) xd)
bitmap_line_ydxd: {
.label xd = 6
.label e = 4
.label y = 3
.label x = 2
lda.z xd
lsr
sta.z e
lda #bitmap_line.y0
sta.z y
lda #bitmap_line.x0
sta.z x
b1:
ldx.z x
ldy.z y
jsr bitmap_plot
inc.z y
lda.z e
clc
adc.z xd
sta.z e
lda #bitmap_line.y1
cmp.z e
bcs b2
dec.z x
lax.z e
axs #bitmap_line.y1
stx.z e
b2:
lda #bitmap_line.y1+1
cmp.z y
bne b1
rts
}
init_screen: {
.label c = 7
lda #<SCREEN
sta.z c
lda #>SCREEN
sta.z c+1
b1:
lda.z c+1
cmp #>SCREEN+$400
bne b2
lda.z c
cmp #<SCREEN+$400
bne b2
rts
b2:
lda #$14
ldy #0
sta (c),y
inc.z c
bne !+
inc.z c+1
!:
jmp b1
}
// Clear all graphics on the bitmap
bitmap_clear: {
.label bitmap = 7
.label y = 5
lda bitmap_plot_xlo
sta.z bitmap
lda bitmap_plot_xhi
sta.z bitmap+1
lda #0
sta.z y
b1:
ldx #0
b2:
lda #0
tay
sta (bitmap),y
inc.z bitmap
bne !+
inc.z bitmap+1
!:
inx
cpx #$c8
bne b2
inc.z y
lda #$28
cmp.z y
bne b1
rts
}
// Initialize the bitmap plotter tables for a specific bitmap
bitmap_init: {
.label _10 = $b
.label yoffs = 7
ldy #$80
ldx #0
b1:
txa
and #$f8
sta bitmap_plot_xlo,x
lda #>BITMAP
sta bitmap_plot_xhi,x
tya
sta bitmap_plot_bit,x
tya
lsr
tay
cpy #0
bne b2
ldy #$80
b2:
inx
cpx #0
bne b1
lda #<0
sta.z yoffs
sta.z yoffs+1
tax
b3:
lda #7
sax.z _10
lda.z yoffs
ora.z _10
sta bitmap_plot_ylo,x
lda.z yoffs+1
sta bitmap_plot_yhi,x
lda #7
cmp.z _10
bne b4
clc
lda.z yoffs
adc #<$28*8
sta.z yoffs
lda.z yoffs+1
adc #>$28*8
sta.z yoffs+1
b4:
inx
cpx #0
bne b3
rts
}
// Tables for the plotter - initialized by calling bitmap_draw_init();
bitmap_plot_xlo: .fill $100, 0
bitmap_plot_xhi: .fill $100, 0
bitmap_plot_ylo: .fill $100, 0
bitmap_plot_yhi: .fill $100, 0
bitmap_plot_bit: .fill $100, 0

View File

@ -0,0 +1,273 @@
@begin: scope:[] from
[0] phi()
to:@1
@1: scope:[] from @begin
[1] phi()
[2] call main
to:@end
@end: scope:[] from @1
[3] phi()
main: scope:[main] from @1
[4] *((const byte*) BORDERCOL#0) ← (byte) 0
[5] *((const byte*) BGCOL#0) ← (byte) 0
[6] *((const byte*) D011#0) ← (const byte) VIC_BMM#0|(const byte) VIC_DEN#0|(const byte) VIC_RSEL#0|(byte) 3
[7] *((const byte*) VIC_MEMORY#0) ← (byte)(word)(const byte*) SCREEN#0&(word) $3fff/(byte) $40|(word)(const byte*) BITMAP#0&(word) $3fff/(word) $400
[8] call bitmap_init
to:main::@2
main::@2: scope:[main] from main
[9] phi()
[10] call bitmap_clear
to:main::@3
main::@3: scope:[main] from main::@2
[11] phi()
[12] call init_screen
to:main::@1
main::@1: scope:[main] from main::@3 main::@4
[13] (byte) next#4 ← phi( main::@3/(byte) 0 main::@4/(byte) next#1 )
[14] (byte) bitmap_line::x1#0 ← (byte) next#4
[15] call bitmap_line
to:main::@4
main::@4: scope:[main] from main::@1
[16] (byte) next#1 ← ++ (byte) next#4
to:main::@1
bitmap_line: scope:[bitmap_line] from main::@1
[17] if((const byte) bitmap_line::x0#0<(byte) bitmap_line::x1#0) goto bitmap_line::@1
to:bitmap_line::@2
bitmap_line::@2: scope:[bitmap_line] from bitmap_line
[18] (byte) bitmap_line::xd#2 ← (byte) bitmap_line::x1#0
to:bitmap_line::@3
bitmap_line::@3: scope:[bitmap_line] from bitmap_line::@2
[19] if((const byte) bitmap_line::y1#0<(byte) bitmap_line::xd#2) goto bitmap_line::@4
to:bitmap_line::@5
bitmap_line::@5: scope:[bitmap_line] from bitmap_line::@3
[20] (byte) bitmap_line_ydxd::xd#0 ← (byte) bitmap_line::xd#2
[21] call bitmap_line_ydxd
to:bitmap_line::@return
bitmap_line::@return: scope:[bitmap_line] from bitmap_line::@4 bitmap_line::@5 bitmap_line::@7 bitmap_line::@8
[22] return
to:@return
bitmap_line::@4: scope:[bitmap_line] from bitmap_line::@3
[23] (byte) bitmap_line_xdyd::x#0 ← (byte) bitmap_line::x1#0
[24] (byte) bitmap_line_xdyd::xd#0 ← (byte) bitmap_line::xd#2
[25] call bitmap_line_xdyd
to:bitmap_line::@return
bitmap_line::@1: scope:[bitmap_line] from bitmap_line
[26] (byte) bitmap_line::xd#1 ← (byte) bitmap_line::x1#0
to:bitmap_line::@6
bitmap_line::@6: scope:[bitmap_line] from bitmap_line::@1
[27] if((const byte) bitmap_line::y1#0<(byte) bitmap_line::xd#1) goto bitmap_line::@7
to:bitmap_line::@8
bitmap_line::@8: scope:[bitmap_line] from bitmap_line::@6
[28] (byte) bitmap_line_ydxi::xd#1 ← (byte) bitmap_line::xd#1
[29] call bitmap_line_ydxi
to:bitmap_line::@return
bitmap_line::@7: scope:[bitmap_line] from bitmap_line::@6
[30] (byte) bitmap_line_xdyi::x1#1 ← (byte) bitmap_line::x1#0
[31] (byte) bitmap_line_xdyi::xd#1 ← (byte) bitmap_line::xd#1
[32] call bitmap_line_xdyi
to:bitmap_line::@return
bitmap_line_xdyi: scope:[bitmap_line_xdyi] from bitmap_line::@7
[33] phi()
to:bitmap_line_xdyi::@1
bitmap_line_xdyi::@1: scope:[bitmap_line_xdyi] from bitmap_line_xdyi bitmap_line_xdyi::@2
[34] (byte) bitmap_line_xdyi::e#3 ← phi( bitmap_line_xdyi/(const byte) bitmap_line::y1#0>>(byte) 1 bitmap_line_xdyi::@2/(byte) bitmap_line_xdyi::e#6 )
[34] (byte) bitmap_line_xdyi::y#3 ← phi( bitmap_line_xdyi/(const byte) bitmap_line::y0#0 bitmap_line_xdyi::@2/(byte) bitmap_line_xdyi::y#6 )
[34] (byte) bitmap_line_xdyi::x#3 ← phi( bitmap_line_xdyi/(const byte) bitmap_line::x0#0 bitmap_line_xdyi::@2/(byte) bitmap_line_xdyi::x#2 )
[35] (byte) bitmap_plot::x#0 ← (byte) bitmap_line_xdyi::x#3
[36] (byte) bitmap_plot::y#0 ← (byte) bitmap_line_xdyi::y#3
[37] call bitmap_plot
to:bitmap_line_xdyi::@4
bitmap_line_xdyi::@4: scope:[bitmap_line_xdyi] from bitmap_line_xdyi::@1
[38] (byte) bitmap_line_xdyi::x#2 ← ++ (byte) bitmap_line_xdyi::x#3
[39] (byte) bitmap_line_xdyi::e#1 ← (byte) bitmap_line_xdyi::e#3 + (const byte) bitmap_line::y1#0
[40] if((byte) bitmap_line_xdyi::xd#1>=(byte) bitmap_line_xdyi::e#1) goto bitmap_line_xdyi::@2
to:bitmap_line_xdyi::@3
bitmap_line_xdyi::@3: scope:[bitmap_line_xdyi] from bitmap_line_xdyi::@4
[41] (byte) bitmap_line_xdyi::y#2 ← ++ (byte) bitmap_line_xdyi::y#3
[42] (byte) bitmap_line_xdyi::e#2 ← (byte) bitmap_line_xdyi::e#1 - (byte) bitmap_line_xdyi::xd#1
to:bitmap_line_xdyi::@2
bitmap_line_xdyi::@2: scope:[bitmap_line_xdyi] from bitmap_line_xdyi::@3 bitmap_line_xdyi::@4
[43] (byte) bitmap_line_xdyi::e#6 ← phi( bitmap_line_xdyi::@3/(byte) bitmap_line_xdyi::e#2 bitmap_line_xdyi::@4/(byte) bitmap_line_xdyi::e#1 )
[43] (byte) bitmap_line_xdyi::y#6 ← phi( bitmap_line_xdyi::@3/(byte) bitmap_line_xdyi::y#2 bitmap_line_xdyi::@4/(byte) bitmap_line_xdyi::y#3 )
[44] (byte~) bitmap_line_xdyi::$6 ← (byte) bitmap_line_xdyi::x1#1 + (byte) 1
[45] if((byte) bitmap_line_xdyi::x#2!=(byte~) bitmap_line_xdyi::$6) goto bitmap_line_xdyi::@1
to:bitmap_line_xdyi::@return
bitmap_line_xdyi::@return: scope:[bitmap_line_xdyi] from bitmap_line_xdyi::@2
[46] return
to:@return
bitmap_plot: scope:[bitmap_plot] from bitmap_line_xdyd::@1 bitmap_line_xdyi::@1 bitmap_line_ydxd::@1 bitmap_line_ydxi::@1
[47] (byte) bitmap_plot::y#4 ← phi( bitmap_line_xdyd::@1/(byte) bitmap_plot::y#1 bitmap_line_xdyi::@1/(byte) bitmap_plot::y#0 bitmap_line_ydxd::@1/(byte) bitmap_plot::y#3 bitmap_line_ydxi::@1/(byte) bitmap_plot::y#2 )
[47] (byte) bitmap_plot::x#4 ← phi( bitmap_line_xdyd::@1/(byte) bitmap_plot::x#1 bitmap_line_xdyi::@1/(byte) bitmap_plot::x#0 bitmap_line_ydxd::@1/(byte) bitmap_plot::x#3 bitmap_line_ydxi::@1/(byte) bitmap_plot::x#2 )
[48] (word) bitmap_plot::plotter_x#0 ← *((const byte[$100]) bitmap_plot_xhi#0 + (byte) bitmap_plot::x#4) w= *((const byte[$100]) bitmap_plot_xlo#0 + (byte) bitmap_plot::x#4)
[49] (word) bitmap_plot::plotter_y#0 ← *((const byte[$100]) bitmap_plot_yhi#0 + (byte) bitmap_plot::y#4) w= *((const byte[$100]) bitmap_plot_ylo#0 + (byte) bitmap_plot::y#4)
[50] (word) bitmap_plot::plotter#0 ← (word) bitmap_plot::plotter_x#0 + (word) bitmap_plot::plotter_y#0
[51] (byte~) bitmap_plot::$1 ← *((byte*)(word) bitmap_plot::plotter#0) | *((const byte[$100]) bitmap_plot_bit#0 + (byte) bitmap_plot::x#4)
[52] *((byte*)(word) bitmap_plot::plotter#0) ← (byte~) bitmap_plot::$1
to:bitmap_plot::@return
bitmap_plot::@return: scope:[bitmap_plot] from bitmap_plot
[53] return
to:@return
bitmap_line_ydxi: scope:[bitmap_line_ydxi] from bitmap_line::@8
[54] (byte) bitmap_line_ydxi::e#0 ← (byte) bitmap_line_ydxi::xd#1 >> (byte) 1
to:bitmap_line_ydxi::@1
bitmap_line_ydxi::@1: scope:[bitmap_line_ydxi] from bitmap_line_ydxi bitmap_line_ydxi::@2
[55] (byte) bitmap_line_ydxi::e#3 ← phi( bitmap_line_ydxi/(byte) bitmap_line_ydxi::e#0 bitmap_line_ydxi::@2/(byte) bitmap_line_ydxi::e#6 )
[55] (byte) bitmap_line_ydxi::y#3 ← phi( bitmap_line_ydxi/(const byte) bitmap_line::y0#0 bitmap_line_ydxi::@2/(byte) bitmap_line_ydxi::y#2 )
[55] (byte) bitmap_line_ydxi::x#3 ← phi( bitmap_line_ydxi/(const byte) bitmap_line::x0#0 bitmap_line_ydxi::@2/(byte) bitmap_line_ydxi::x#6 )
[56] (byte) bitmap_plot::x#2 ← (byte) bitmap_line_ydxi::x#3
[57] (byte) bitmap_plot::y#2 ← (byte) bitmap_line_ydxi::y#3
[58] call bitmap_plot
to:bitmap_line_ydxi::@4
bitmap_line_ydxi::@4: scope:[bitmap_line_ydxi] from bitmap_line_ydxi::@1
[59] (byte) bitmap_line_ydxi::y#2 ← ++ (byte) bitmap_line_ydxi::y#3
[60] (byte) bitmap_line_ydxi::e#1 ← (byte) bitmap_line_ydxi::e#3 + (byte) bitmap_line_ydxi::xd#1
[61] if((const byte) bitmap_line::y1#0>=(byte) bitmap_line_ydxi::e#1) goto bitmap_line_ydxi::@2
to:bitmap_line_ydxi::@3
bitmap_line_ydxi::@3: scope:[bitmap_line_ydxi] from bitmap_line_ydxi::@4
[62] (byte) bitmap_line_ydxi::x#2 ← ++ (byte) bitmap_line_ydxi::x#3
[63] (byte) bitmap_line_ydxi::e#2 ← (byte) bitmap_line_ydxi::e#1 - (const byte) bitmap_line::y1#0
to:bitmap_line_ydxi::@2
bitmap_line_ydxi::@2: scope:[bitmap_line_ydxi] from bitmap_line_ydxi::@3 bitmap_line_ydxi::@4
[64] (byte) bitmap_line_ydxi::e#6 ← phi( bitmap_line_ydxi::@3/(byte) bitmap_line_ydxi::e#2 bitmap_line_ydxi::@4/(byte) bitmap_line_ydxi::e#1 )
[64] (byte) bitmap_line_ydxi::x#6 ← phi( bitmap_line_ydxi::@3/(byte) bitmap_line_ydxi::x#2 bitmap_line_ydxi::@4/(byte) bitmap_line_ydxi::x#3 )
[65] if((byte) bitmap_line_ydxi::y#2!=(const byte) bitmap_line::y1#0+(byte) 1) goto bitmap_line_ydxi::@1
to:bitmap_line_ydxi::@return
bitmap_line_ydxi::@return: scope:[bitmap_line_ydxi] from bitmap_line_ydxi::@2
[66] return
to:@return
bitmap_line_xdyd: scope:[bitmap_line_xdyd] from bitmap_line::@4
[67] phi()
to:bitmap_line_xdyd::@1
bitmap_line_xdyd::@1: scope:[bitmap_line_xdyd] from bitmap_line_xdyd bitmap_line_xdyd::@2
[68] (byte) bitmap_line_xdyd::e#3 ← phi( bitmap_line_xdyd/(const byte) bitmap_line::y1#0>>(byte) 1 bitmap_line_xdyd::@2/(byte) bitmap_line_xdyd::e#6 )
[68] (byte) bitmap_line_xdyd::y#3 ← phi( bitmap_line_xdyd/(const byte) bitmap_line::y1#0 bitmap_line_xdyd::@2/(byte) bitmap_line_xdyd::y#6 )
[68] (byte) bitmap_line_xdyd::x#3 ← phi( bitmap_line_xdyd/(byte) bitmap_line_xdyd::x#0 bitmap_line_xdyd::@2/(byte) bitmap_line_xdyd::x#2 )
[69] (byte) bitmap_plot::x#1 ← (byte) bitmap_line_xdyd::x#3
[70] (byte) bitmap_plot::y#1 ← (byte) bitmap_line_xdyd::y#3
[71] call bitmap_plot
to:bitmap_line_xdyd::@4
bitmap_line_xdyd::@4: scope:[bitmap_line_xdyd] from bitmap_line_xdyd::@1
[72] (byte) bitmap_line_xdyd::x#2 ← ++ (byte) bitmap_line_xdyd::x#3
[73] (byte) bitmap_line_xdyd::e#1 ← (byte) bitmap_line_xdyd::e#3 + (const byte) bitmap_line::y1#0
[74] if((byte) bitmap_line_xdyd::xd#0>=(byte) bitmap_line_xdyd::e#1) goto bitmap_line_xdyd::@2
to:bitmap_line_xdyd::@3
bitmap_line_xdyd::@3: scope:[bitmap_line_xdyd] from bitmap_line_xdyd::@4
[75] (byte) bitmap_line_xdyd::y#2 ← -- (byte) bitmap_line_xdyd::y#3
[76] (byte) bitmap_line_xdyd::e#2 ← (byte) bitmap_line_xdyd::e#1 - (byte) bitmap_line_xdyd::xd#0
to:bitmap_line_xdyd::@2
bitmap_line_xdyd::@2: scope:[bitmap_line_xdyd] from bitmap_line_xdyd::@3 bitmap_line_xdyd::@4
[77] (byte) bitmap_line_xdyd::e#6 ← phi( bitmap_line_xdyd::@3/(byte) bitmap_line_xdyd::e#2 bitmap_line_xdyd::@4/(byte) bitmap_line_xdyd::e#1 )
[77] (byte) bitmap_line_xdyd::y#6 ← phi( bitmap_line_xdyd::@3/(byte) bitmap_line_xdyd::y#2 bitmap_line_xdyd::@4/(byte) bitmap_line_xdyd::y#3 )
[78] if((byte) bitmap_line_xdyd::x#2!=(byte) 1) goto bitmap_line_xdyd::@1
to:bitmap_line_xdyd::@return
bitmap_line_xdyd::@return: scope:[bitmap_line_xdyd] from bitmap_line_xdyd::@2
[79] return
to:@return
bitmap_line_ydxd: scope:[bitmap_line_ydxd] from bitmap_line::@5
[80] (byte) bitmap_line_ydxd::e#0 ← (byte) bitmap_line_ydxd::xd#0 >> (byte) 1
to:bitmap_line_ydxd::@1
bitmap_line_ydxd::@1: scope:[bitmap_line_ydxd] from bitmap_line_ydxd bitmap_line_ydxd::@2
[81] (byte) bitmap_line_ydxd::e#3 ← phi( bitmap_line_ydxd/(byte) bitmap_line_ydxd::e#0 bitmap_line_ydxd::@2/(byte) bitmap_line_ydxd::e#6 )
[81] (byte) bitmap_line_ydxd::y#2 ← phi( bitmap_line_ydxd/(const byte) bitmap_line::y0#0 bitmap_line_ydxd::@2/(byte) bitmap_line_ydxd::y#3 )
[81] (byte) bitmap_line_ydxd::x#3 ← phi( bitmap_line_ydxd/(const byte) bitmap_line::x0#0 bitmap_line_ydxd::@2/(byte) bitmap_line_ydxd::x#6 )
[82] (byte) bitmap_plot::x#3 ← (byte) bitmap_line_ydxd::x#3
[83] (byte) bitmap_plot::y#3 ← (byte) bitmap_line_ydxd::y#2
[84] call bitmap_plot
to:bitmap_line_ydxd::@4
bitmap_line_ydxd::@4: scope:[bitmap_line_ydxd] from bitmap_line_ydxd::@1
[85] (byte) bitmap_line_ydxd::y#3 ← ++ (byte) bitmap_line_ydxd::y#2
[86] (byte) bitmap_line_ydxd::e#1 ← (byte) bitmap_line_ydxd::e#3 + (byte) bitmap_line_ydxd::xd#0
[87] if((const byte) bitmap_line::y1#0>=(byte) bitmap_line_ydxd::e#1) goto bitmap_line_ydxd::@2
to:bitmap_line_ydxd::@3
bitmap_line_ydxd::@3: scope:[bitmap_line_ydxd] from bitmap_line_ydxd::@4
[88] (byte) bitmap_line_ydxd::x#2 ← -- (byte) bitmap_line_ydxd::x#3
[89] (byte) bitmap_line_ydxd::e#2 ← (byte) bitmap_line_ydxd::e#1 - (const byte) bitmap_line::y1#0
to:bitmap_line_ydxd::@2
bitmap_line_ydxd::@2: scope:[bitmap_line_ydxd] from bitmap_line_ydxd::@3 bitmap_line_ydxd::@4
[90] (byte) bitmap_line_ydxd::e#6 ← phi( bitmap_line_ydxd::@3/(byte) bitmap_line_ydxd::e#2 bitmap_line_ydxd::@4/(byte) bitmap_line_ydxd::e#1 )
[90] (byte) bitmap_line_ydxd::x#6 ← phi( bitmap_line_ydxd::@3/(byte) bitmap_line_ydxd::x#2 bitmap_line_ydxd::@4/(byte) bitmap_line_ydxd::x#3 )
[91] if((byte) bitmap_line_ydxd::y#3!=(const byte) bitmap_line::y1#0+(byte) 1) goto bitmap_line_ydxd::@1
to:bitmap_line_ydxd::@return
bitmap_line_ydxd::@return: scope:[bitmap_line_ydxd] from bitmap_line_ydxd::@2
[92] return
to:@return
init_screen: scope:[init_screen] from main::@3
[93] phi()
to:init_screen::@1
init_screen::@1: scope:[init_screen] from init_screen init_screen::@2
[94] (byte*) init_screen::c#2 ← phi( init_screen/(const byte*) SCREEN#0 init_screen::@2/(byte*) init_screen::c#1 )
[95] if((byte*) init_screen::c#2!=(const byte*) SCREEN#0+(word) $400) goto init_screen::@2
to:init_screen::@return
init_screen::@return: scope:[init_screen] from init_screen::@1
[96] return
to:@return
init_screen::@2: scope:[init_screen] from init_screen::@1
[97] *((byte*) init_screen::c#2) ← (byte) $14
[98] (byte*) init_screen::c#1 ← ++ (byte*) init_screen::c#2
to:init_screen::@1
bitmap_clear: scope:[bitmap_clear] from main::@2
[99] (word) bitmap_clear::bitmap#0 ← *((const byte[$100]) bitmap_plot_xhi#0) w= *((const byte[$100]) bitmap_plot_xlo#0)
[100] (byte*~) bitmap_clear::bitmap#5 ← (byte*)(word) bitmap_clear::bitmap#0
to:bitmap_clear::@1
bitmap_clear::@1: scope:[bitmap_clear] from bitmap_clear bitmap_clear::@3
[101] (byte) bitmap_clear::y#4 ← phi( bitmap_clear/(byte) 0 bitmap_clear::@3/(byte) bitmap_clear::y#1 )
[101] (byte*) bitmap_clear::bitmap#3 ← phi( bitmap_clear/(byte*~) bitmap_clear::bitmap#5 bitmap_clear::@3/(byte*) bitmap_clear::bitmap#1 )
to:bitmap_clear::@2
bitmap_clear::@2: scope:[bitmap_clear] from bitmap_clear::@1 bitmap_clear::@2
[102] (byte) bitmap_clear::x#2 ← phi( bitmap_clear::@1/(byte) 0 bitmap_clear::@2/(byte) bitmap_clear::x#1 )
[102] (byte*) bitmap_clear::bitmap#2 ← phi( bitmap_clear::@1/(byte*) bitmap_clear::bitmap#3 bitmap_clear::@2/(byte*) bitmap_clear::bitmap#1 )
[103] *((byte*) bitmap_clear::bitmap#2) ← (byte) 0
[104] (byte*) bitmap_clear::bitmap#1 ← ++ (byte*) bitmap_clear::bitmap#2
[105] (byte) bitmap_clear::x#1 ← ++ (byte) bitmap_clear::x#2
[106] if((byte) bitmap_clear::x#1!=(byte) $c8) goto bitmap_clear::@2
to:bitmap_clear::@3
bitmap_clear::@3: scope:[bitmap_clear] from bitmap_clear::@2
[107] (byte) bitmap_clear::y#1 ← ++ (byte) bitmap_clear::y#4
[108] if((byte) bitmap_clear::y#1!=(byte) $28) goto bitmap_clear::@1
to:bitmap_clear::@return
bitmap_clear::@return: scope:[bitmap_clear] from bitmap_clear::@3
[109] return
to:@return
bitmap_init: scope:[bitmap_init] from main
[110] phi()
to:bitmap_init::@1
bitmap_init::@1: scope:[bitmap_init] from bitmap_init bitmap_init::@2
[111] (byte) bitmap_init::bits#3 ← phi( bitmap_init/(byte) $80 bitmap_init::@2/(byte) bitmap_init::bits#4 )
[111] (byte) bitmap_init::x#2 ← phi( bitmap_init/(byte) 0 bitmap_init::@2/(byte) bitmap_init::x#1 )
[112] (byte~) bitmap_init::$0 ← (byte) bitmap_init::x#2 & (byte) $f8
[113] *((const byte[$100]) bitmap_plot_xlo#0 + (byte) bitmap_init::x#2) ← (byte~) bitmap_init::$0
[114] *((const byte[$100]) bitmap_plot_xhi#0 + (byte) bitmap_init::x#2) ← >(const byte*) BITMAP#0
[115] *((const byte[$100]) bitmap_plot_bit#0 + (byte) bitmap_init::x#2) ← (byte) bitmap_init::bits#3
[116] (byte) bitmap_init::bits#1 ← (byte) bitmap_init::bits#3 >> (byte) 1
[117] if((byte) bitmap_init::bits#1!=(byte) 0) goto bitmap_init::@6
to:bitmap_init::@2
bitmap_init::@6: scope:[bitmap_init] from bitmap_init::@1
[118] phi()
to:bitmap_init::@2
bitmap_init::@2: scope:[bitmap_init] from bitmap_init::@1 bitmap_init::@6
[119] (byte) bitmap_init::bits#4 ← phi( bitmap_init::@6/(byte) bitmap_init::bits#1 bitmap_init::@1/(byte) $80 )
[120] (byte) bitmap_init::x#1 ← ++ (byte) bitmap_init::x#2
[121] if((byte) bitmap_init::x#1!=(byte) 0) goto bitmap_init::@1
to:bitmap_init::@3
bitmap_init::@3: scope:[bitmap_init] from bitmap_init::@2 bitmap_init::@4
[122] (byte*) bitmap_init::yoffs#2 ← phi( bitmap_init::@2/(byte*) 0 bitmap_init::@4/(byte*) bitmap_init::yoffs#4 )
[122] (byte) bitmap_init::y#2 ← phi( bitmap_init::@2/(byte) 0 bitmap_init::@4/(byte) bitmap_init::y#1 )
[123] (byte~) bitmap_init::$10 ← (byte) bitmap_init::y#2 & (byte) 7
[124] (byte~) bitmap_init::$7 ← < (byte*) bitmap_init::yoffs#2
[125] (byte~) bitmap_init::$8 ← (byte~) bitmap_init::$10 | (byte~) bitmap_init::$7
[126] *((const byte[$100]) bitmap_plot_ylo#0 + (byte) bitmap_init::y#2) ← (byte~) bitmap_init::$8
[127] (byte~) bitmap_init::$9 ← > (byte*) bitmap_init::yoffs#2
[128] *((const byte[$100]) bitmap_plot_yhi#0 + (byte) bitmap_init::y#2) ← (byte~) bitmap_init::$9
[129] if((byte~) bitmap_init::$10!=(byte) 7) goto bitmap_init::@4
to:bitmap_init::@5
bitmap_init::@5: scope:[bitmap_init] from bitmap_init::@3
[130] (byte*) bitmap_init::yoffs#1 ← (byte*) bitmap_init::yoffs#2 + (word)(number) $28*(number) 8
to:bitmap_init::@4
bitmap_init::@4: scope:[bitmap_init] from bitmap_init::@3 bitmap_init::@5
[131] (byte*) bitmap_init::yoffs#4 ← phi( bitmap_init::@3/(byte*) bitmap_init::yoffs#2 bitmap_init::@5/(byte*) bitmap_init::yoffs#1 )
[132] (byte) bitmap_init::y#1 ← ++ (byte) bitmap_init::y#2
[133] if((byte) bitmap_init::y#1!=(byte) 0) goto bitmap_init::@3
to:bitmap_init::@return
bitmap_init::@return: scope:[bitmap_init] from bitmap_init::@4
[134] return
to:@return

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,251 @@
(label) @1
(label) @begin
(label) @end
(byte*) BGCOL
(const byte*) BGCOL#0 BGCOL = (byte*) 53281
(byte*) BITMAP
(const byte*) BITMAP#0 BITMAP = (byte*) 8192
(byte*) BORDERCOL
(const byte*) BORDERCOL#0 BORDERCOL = (byte*) 53280
(byte*) D011
(const byte*) D011#0 D011 = (byte*) 53265
(byte*) SCREEN
(const byte*) SCREEN#0 SCREEN = (byte*) 1024
(byte) VIC_BMM
(const byte) VIC_BMM#0 VIC_BMM = (byte) $20
(byte) VIC_DEN
(const byte) VIC_DEN#0 VIC_DEN = (byte) $10
(byte*) VIC_MEMORY
(const byte*) VIC_MEMORY#0 VIC_MEMORY = (byte*) 53272
(byte) VIC_RSEL
(const byte) VIC_RSEL#0 VIC_RSEL = (byte) 8
(void()) bitmap_clear()
(label) bitmap_clear::@1
(label) bitmap_clear::@2
(label) bitmap_clear::@3
(label) bitmap_clear::@return
(byte*) bitmap_clear::bitmap
(word) bitmap_clear::bitmap#0 bitmap zp ZP_WORD:7 2.0
(byte*) bitmap_clear::bitmap#1 bitmap zp ZP_WORD:7 42.599999999999994
(byte*) bitmap_clear::bitmap#2 bitmap zp ZP_WORD:7 157.0
(byte*) bitmap_clear::bitmap#3 bitmap zp ZP_WORD:7 24.0
(byte*~) bitmap_clear::bitmap#5 bitmap zp ZP_WORD:7 4.0
(byte) bitmap_clear::x
(byte) bitmap_clear::x#1 reg byte x 151.5
(byte) bitmap_clear::x#2 reg byte x 67.33333333333333
(byte) bitmap_clear::y
(byte) bitmap_clear::y#1 y zp ZP_BYTE:5 16.5
(byte) bitmap_clear::y#4 y zp ZP_BYTE:5 3.6666666666666665
(void()) bitmap_init((byte*) bitmap_init::bitmap)
(byte~) bitmap_init::$0 reg byte a 22.0
(byte~) bitmap_init::$10 $10 zp ZP_BYTE:11 5.5
(byte~) bitmap_init::$7 reg byte a 22.0
(byte~) bitmap_init::$8 reg byte a 22.0
(byte~) bitmap_init::$9 reg byte a 22.0
(label) bitmap_init::@1
(label) bitmap_init::@2
(label) bitmap_init::@3
(label) bitmap_init::@4
(label) bitmap_init::@5
(label) bitmap_init::@6
(label) bitmap_init::@return
(byte*) bitmap_init::bitmap
(byte) bitmap_init::bits
(byte) bitmap_init::bits#1 reg byte y 11.0
(byte) bitmap_init::bits#3 reg byte y 6.6000000000000005
(byte) bitmap_init::bits#4 reg byte y 7.333333333333333
(byte) bitmap_init::x
(byte) bitmap_init::x#1 reg byte x 16.5
(byte) bitmap_init::x#2 reg byte x 7.333333333333334
(byte) bitmap_init::y
(byte) bitmap_init::y#1 reg byte x 16.5
(byte) bitmap_init::y#2 reg byte x 5.5
(byte*) bitmap_init::yoffs
(byte*) bitmap_init::yoffs#1 yoffs zp ZP_WORD:7 22.0
(byte*) bitmap_init::yoffs#2 yoffs zp ZP_WORD:7 6.875
(byte*) bitmap_init::yoffs#4 yoffs zp ZP_WORD:7 11.0
(void()) bitmap_line((byte) bitmap_line::x0 , (byte) bitmap_line::x1 , (byte) bitmap_line::y0 , (byte) bitmap_line::y1)
(label) bitmap_line::@1
(label) bitmap_line::@2
(label) bitmap_line::@3
(label) bitmap_line::@4
(label) bitmap_line::@5
(label) bitmap_line::@6
(label) bitmap_line::@7
(label) bitmap_line::@8
(label) bitmap_line::@return
(byte) bitmap_line::x0
(const byte) bitmap_line::x0#0 x0 = (byte) 0
(byte) bitmap_line::x1
(byte) bitmap_line::x1#0 reg byte x 3.5000000000000004
(byte) bitmap_line::xd
(byte) bitmap_line::xd#1 reg byte a 2.6666666666666665
(byte) bitmap_line::xd#2 reg byte a 2.6666666666666665
(byte) bitmap_line::y0
(const byte) bitmap_line::y0#0 y0 = (byte) 0
(byte) bitmap_line::y1
(const byte) bitmap_line::y1#0 y1 = (byte) $64
(byte) bitmap_line::yd
(void()) bitmap_line_xdyd((byte) bitmap_line_xdyd::x , (byte) bitmap_line_xdyd::y , (byte) bitmap_line_xdyd::x1 , (byte) bitmap_line_xdyd::xd , (byte) bitmap_line_xdyd::yd)
(label) bitmap_line_xdyd::@1
(label) bitmap_line_xdyd::@2
(label) bitmap_line_xdyd::@3
(label) bitmap_line_xdyd::@4
(label) bitmap_line_xdyd::@return
(byte) bitmap_line_xdyd::e
(byte) bitmap_line_xdyd::e#1 e zp ZP_BYTE:4 134.66666666666666
(byte) bitmap_line_xdyd::e#2 e zp ZP_BYTE:4 202.0
(byte) bitmap_line_xdyd::e#3 e zp ZP_BYTE:4 40.4
(byte) bitmap_line_xdyd::e#6 e zp ZP_BYTE:4 151.5
(byte) bitmap_line_xdyd::x
(byte) bitmap_line_xdyd::x#0 x zp ZP_BYTE:2 1.3333333333333333
(byte) bitmap_line_xdyd::x#2 x zp ZP_BYTE:2 43.285714285714285
(byte) bitmap_line_xdyd::x#3 x zp ZP_BYTE:2 76.25
(byte) bitmap_line_xdyd::x1
(byte) bitmap_line_xdyd::xd
(byte) bitmap_line_xdyd::xd#0 xd zp ZP_BYTE:6 15.692307692307693
(byte) bitmap_line_xdyd::y
(byte) bitmap_line_xdyd::y#2 y zp ZP_BYTE:3 101.0
(byte) bitmap_line_xdyd::y#3 y zp ZP_BYTE:3 57.714285714285715
(byte) bitmap_line_xdyd::y#6 y zp ZP_BYTE:3 151.5
(byte) bitmap_line_xdyd::yd
(void()) bitmap_line_xdyi((byte) bitmap_line_xdyi::x , (byte) bitmap_line_xdyi::y , (byte) bitmap_line_xdyi::x1 , (byte) bitmap_line_xdyi::xd , (byte) bitmap_line_xdyi::yd)
(byte~) bitmap_line_xdyi::$6 reg byte x 202.0
(label) bitmap_line_xdyi::@1
(label) bitmap_line_xdyi::@2
(label) bitmap_line_xdyi::@3
(label) bitmap_line_xdyi::@4
(label) bitmap_line_xdyi::@return
(byte) bitmap_line_xdyi::e
(byte) bitmap_line_xdyi::e#1 e zp ZP_BYTE:4 134.66666666666666
(byte) bitmap_line_xdyi::e#2 e zp ZP_BYTE:4 202.0
(byte) bitmap_line_xdyi::e#3 e zp ZP_BYTE:4 40.4
(byte) bitmap_line_xdyi::e#6 e zp ZP_BYTE:4 101.0
(byte) bitmap_line_xdyi::x
(byte) bitmap_line_xdyi::x#2 x zp ZP_BYTE:2 37.875
(byte) bitmap_line_xdyi::x#3 x zp ZP_BYTE:2 75.75
(byte) bitmap_line_xdyi::x1
(byte) bitmap_line_xdyi::x1#1 x1 zp ZP_BYTE:6 6.866666666666667
(byte) bitmap_line_xdyi::xd
(byte) bitmap_line_xdyi::xd#1 xd zp ZP_BYTE:11 14.571428571428573
(byte) bitmap_line_xdyi::y
(byte) bitmap_line_xdyi::y#2 y zp ZP_BYTE:3 101.0
(byte) bitmap_line_xdyi::y#3 y zp ZP_BYTE:3 57.714285714285715
(byte) bitmap_line_xdyi::y#6 y zp ZP_BYTE:3 101.0
(byte) bitmap_line_xdyi::yd
(void()) bitmap_line_ydxd((byte) bitmap_line_ydxd::y , (byte) bitmap_line_ydxd::x , (byte) bitmap_line_ydxd::y1 , (byte) bitmap_line_ydxd::yd , (byte) bitmap_line_ydxd::xd)
(label) bitmap_line_ydxd::@1
(label) bitmap_line_ydxd::@2
(label) bitmap_line_ydxd::@3
(label) bitmap_line_ydxd::@4
(label) bitmap_line_ydxd::@return
(byte) bitmap_line_ydxd::e
(byte) bitmap_line_ydxd::e#0 e zp ZP_BYTE:4 4.0
(byte) bitmap_line_ydxd::e#1 e zp ZP_BYTE:4 134.66666666666666
(byte) bitmap_line_ydxd::e#2 e zp ZP_BYTE:4 202.0
(byte) bitmap_line_ydxd::e#3 e zp ZP_BYTE:4 40.8
(byte) bitmap_line_ydxd::e#6 e zp ZP_BYTE:4 151.5
(byte) bitmap_line_ydxd::x
(byte) bitmap_line_ydxd::x#2 x zp ZP_BYTE:2 101.0
(byte) bitmap_line_ydxd::x#3 x zp ZP_BYTE:2 57.714285714285715
(byte) bitmap_line_ydxd::x#6 x zp ZP_BYTE:2 151.5
(byte) bitmap_line_ydxd::xd
(byte) bitmap_line_ydxd::xd#0 xd zp ZP_BYTE:6 8.076923076923077
(byte) bitmap_line_ydxd::y
(byte) bitmap_line_ydxd::y#2 y zp ZP_BYTE:3 75.75
(byte) bitmap_line_ydxd::y#3 y zp ZP_BYTE:3 43.285714285714285
(byte) bitmap_line_ydxd::y1
(byte) bitmap_line_ydxd::yd
(void()) bitmap_line_ydxi((byte) bitmap_line_ydxi::y , (byte) bitmap_line_ydxi::x , (byte) bitmap_line_ydxi::y1 , (byte) bitmap_line_ydxi::yd , (byte) bitmap_line_ydxi::xd)
(label) bitmap_line_ydxi::@1
(label) bitmap_line_ydxi::@2
(label) bitmap_line_ydxi::@3
(label) bitmap_line_ydxi::@4
(label) bitmap_line_ydxi::@return
(byte) bitmap_line_ydxi::e
(byte) bitmap_line_ydxi::e#0 e zp ZP_BYTE:4 4.0
(byte) bitmap_line_ydxi::e#1 e zp ZP_BYTE:4 134.66666666666666
(byte) bitmap_line_ydxi::e#2 e zp ZP_BYTE:4 202.0
(byte) bitmap_line_ydxi::e#3 e zp ZP_BYTE:4 40.8
(byte) bitmap_line_ydxi::e#6 e zp ZP_BYTE:4 151.5
(byte) bitmap_line_ydxi::x
(byte) bitmap_line_ydxi::x#2 x zp ZP_BYTE:2 101.0
(byte) bitmap_line_ydxi::x#3 x zp ZP_BYTE:2 57.714285714285715
(byte) bitmap_line_ydxi::x#6 x zp ZP_BYTE:2 151.5
(byte) bitmap_line_ydxi::xd
(byte) bitmap_line_ydxi::xd#1 xd zp ZP_BYTE:6 8.076923076923077
(byte) bitmap_line_ydxi::y
(byte) bitmap_line_ydxi::y#2 y zp ZP_BYTE:3 43.285714285714285
(byte) bitmap_line_ydxi::y#3 y zp ZP_BYTE:3 75.75
(byte) bitmap_line_ydxi::y1
(byte) bitmap_line_ydxi::yd
(void()) bitmap_plot((byte) bitmap_plot::x , (byte) bitmap_plot::y)
(byte~) bitmap_plot::$1 reg byte a 4.0
(label) bitmap_plot::@return
(byte*) bitmap_plot::plotter
(word) bitmap_plot::plotter#0 plotter zp ZP_WORD:7 1.0
(word) bitmap_plot::plotter_x
(word) bitmap_plot::plotter_x#0 plotter_x zp ZP_WORD:7 2.0
(word) bitmap_plot::plotter_y
(word) bitmap_plot::plotter_y#0 plotter_y zp ZP_WORD:9 4.0
(byte) bitmap_plot::x
(byte) bitmap_plot::x#0 reg byte x 101.0
(byte) bitmap_plot::x#1 reg byte x 101.0
(byte) bitmap_plot::x#2 reg byte x 101.0
(byte) bitmap_plot::x#3 reg byte x 101.0
(byte) bitmap_plot::x#4 reg byte x 102.5
(byte) bitmap_plot::y
(byte) bitmap_plot::y#0 reg byte y 202.0
(byte) bitmap_plot::y#1 reg byte y 202.0
(byte) bitmap_plot::y#2 reg byte y 202.0
(byte) bitmap_plot::y#3 reg byte y 202.0
(byte) bitmap_plot::y#4 reg byte y 204.0
(byte[$100]) bitmap_plot_bit
(const byte[$100]) bitmap_plot_bit#0 bitmap_plot_bit = { fill( $100, 0) }
(byte[$100]) bitmap_plot_xhi
(const byte[$100]) bitmap_plot_xhi#0 bitmap_plot_xhi = { fill( $100, 0) }
(byte[$100]) bitmap_plot_xlo
(const byte[$100]) bitmap_plot_xlo#0 bitmap_plot_xlo = { fill( $100, 0) }
(byte[$100]) bitmap_plot_yhi
(const byte[$100]) bitmap_plot_yhi#0 bitmap_plot_yhi = { fill( $100, 0) }
(byte[$100]) bitmap_plot_ylo
(const byte[$100]) bitmap_plot_ylo#0 bitmap_plot_ylo = { fill( $100, 0) }
(void()) init_screen()
(label) init_screen::@1
(label) init_screen::@2
(label) init_screen::@return
(byte*) init_screen::c
(byte*) init_screen::c#1 c zp ZP_WORD:7 22.0
(byte*) init_screen::c#2 c zp ZP_WORD:7 14.666666666666666
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@4
(byte) next
(byte) next#1 next zp ZP_BYTE:5 22.0
(byte) next#4 next zp ZP_BYTE:5 11.0
reg byte x [ bitmap_plot::x#4 bitmap_plot::x#1 bitmap_plot::x#0 bitmap_plot::x#3 bitmap_plot::x#2 ]
reg byte y [ bitmap_plot::y#4 bitmap_plot::y#1 bitmap_plot::y#0 bitmap_plot::y#3 bitmap_plot::y#2 ]
zp ZP_BYTE:2 [ bitmap_line_ydxd::x#3 bitmap_line_ydxd::x#6 bitmap_line_ydxd::x#2 bitmap_line_xdyd::x#3 bitmap_line_xdyd::x#0 bitmap_line_xdyd::x#2 bitmap_line_ydxi::x#3 bitmap_line_ydxi::x#6 bitmap_line_ydxi::x#2 bitmap_line_xdyi::x#3 bitmap_line_xdyi::x#2 ]
zp ZP_BYTE:3 [ bitmap_line_ydxd::y#2 bitmap_line_ydxd::y#3 bitmap_line_xdyd::y#3 bitmap_line_xdyd::y#6 bitmap_line_xdyd::y#2 bitmap_line_ydxi::y#3 bitmap_line_ydxi::y#2 bitmap_line_xdyi::y#3 bitmap_line_xdyi::y#6 bitmap_line_xdyi::y#2 ]
zp ZP_BYTE:4 [ bitmap_line_ydxd::e#3 bitmap_line_ydxd::e#0 bitmap_line_ydxd::e#6 bitmap_line_ydxd::e#2 bitmap_line_ydxd::e#1 bitmap_line_xdyd::e#3 bitmap_line_xdyd::e#6 bitmap_line_xdyd::e#2 bitmap_line_xdyd::e#1 bitmap_line_ydxi::e#3 bitmap_line_ydxi::e#0 bitmap_line_ydxi::e#6 bitmap_line_ydxi::e#2 bitmap_line_ydxi::e#1 bitmap_line_xdyi::e#3 bitmap_line_xdyi::e#6 bitmap_line_xdyi::e#2 bitmap_line_xdyi::e#1 ]
zp ZP_BYTE:5 [ bitmap_clear::y#4 bitmap_clear::y#1 next#4 next#1 ]
reg byte x [ bitmap_clear::x#2 bitmap_clear::x#1 ]
reg byte x [ bitmap_init::x#2 bitmap_init::x#1 ]
reg byte y [ bitmap_init::bits#3 bitmap_init::bits#4 bitmap_init::bits#1 ]
reg byte x [ bitmap_init::y#2 bitmap_init::y#1 ]
reg byte x [ bitmap_line::x1#0 ]
reg byte a [ bitmap_line::xd#2 ]
reg byte a [ bitmap_line::xd#1 ]
zp ZP_BYTE:6 [ bitmap_line_xdyi::x1#1 bitmap_line_ydxi::xd#1 bitmap_line_xdyd::xd#0 bitmap_line_ydxd::xd#0 ]
reg byte x [ bitmap_line_xdyi::$6 ]
zp ZP_WORD:7 [ bitmap_plot::plotter_x#0 bitmap_plot::plotter#0 bitmap_init::yoffs#2 bitmap_init::yoffs#4 bitmap_init::yoffs#1 bitmap_clear::bitmap#2 bitmap_clear::bitmap#3 bitmap_clear::bitmap#5 bitmap_clear::bitmap#1 bitmap_clear::bitmap#0 init_screen::c#2 init_screen::c#1 ]
zp ZP_WORD:9 [ bitmap_plot::plotter_y#0 ]
reg byte a [ bitmap_plot::$1 ]
reg byte a [ bitmap_init::$0 ]
zp ZP_BYTE:11 [ bitmap_init::$10 bitmap_line_xdyi::xd#1 ]
reg byte a [ bitmap_init::$7 ]
reg byte a [ bitmap_init::$8 ]
reg byte a [ bitmap_init::$9 ]

View File

@ -0,0 +1,433 @@
// Shows that bitmap2.kc line() does not have the same problem as bitmap-draw.kc
// See bitmap-line-anim-1.kc
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
.label BORDERCOL = $d020
.label BGCOL = $d021
.label D011 = $d011
.const VIC_BMM = $20
.const VIC_DEN = $10
.const VIC_RSEL = 8
.label VIC_MEMORY = $d018
.const WHITE = 1
.const PURPLE = 4
.label SCREEN = $400
.label BITMAP = $2000
.label next = $a
main: {
lda #0
sta BORDERCOL
sta BGCOL
lda #VIC_BMM|VIC_DEN|VIC_RSEL|3
sta D011
lda #(SCREEN&$3fff)/$40|(BITMAP&$3fff)/$400
sta VIC_MEMORY
jsr bitmap_init
jsr bitmap_clear
lda #<0
sta.z next
sta.z next+1
b1:
jsr bitmap_line
inc.z next
bne !+
inc.z next+1
!:
lda.z next+1
cmp #>$140
bne b1
lda.z next
cmp #<$140
bne b1
lda #<0
sta.z next
sta.z next+1
jmp b1
}
// Draw a line on the bitmap using bresenhams algorithm
// bitmap_line(word zeropage($a) x2)
bitmap_line: {
.const x1 = 0
.const y1 = 0
.const y2 = $64
.label dx = $10
.label dy = 8
.label sx = $12
.label sy = 6
.label e1 = 2
.label e = 4
.label y = $c
.label x = $e
.label x2 = $a
lda.z x2
sta.z abs_u16.w
lda.z x2+1
sta.z abs_u16.w+1
jsr abs_u16
lda.z abs_u16.return
sta.z dx
lda.z abs_u16.return+1
sta.z dx+1
lda #<y2
sta.z abs_u16.w
lda #>y2
sta.z abs_u16.w+1
jsr abs_u16
lda.z dx
bne b1
lda.z dx+1
bne b1
lda.z dy
bne !+
lda.z dy+1
bne !b4+
jmp b4
!b4:
!:
b1:
lda.z x2
sta.z sgn_u16.w
lda.z x2+1
sta.z sgn_u16.w+1
jsr sgn_u16
lda.z sgn_u16.return
sta.z sx
lda.z sgn_u16.return+1
sta.z sx+1
lda #<y2
sta.z sgn_u16.w
lda #>y2
sta.z sgn_u16.w+1
jsr sgn_u16
lda.z dy+1
cmp.z dx+1
bcc b2
bne !+
lda.z dy
cmp.z dx
bcc b2
!:
lda.z dx+1
lsr
sta.z e+1
lda.z dx
ror
sta.z e
lda #<x1
sta.z x
lda #>x1
sta.z x+1
lda #<y1
sta.z y
lda #>y1
sta.z y+1
b6:
lda.z y
tax
jsr bitmap_plot
lda.z y
clc
adc.z sy
sta.z y
lda.z y+1
adc.z sy+1
sta.z y+1
lda.z e
clc
adc.z dx
sta.z e
lda.z e+1
adc.z dx+1
sta.z e+1
cmp.z dy+1
bne !+
lda.z e
cmp.z dy
beq b7
!:
bcc b7
lda.z x
clc
adc.z sx
sta.z x
lda.z x+1
adc.z sx+1
sta.z x+1
lda.z e
sec
sbc.z dy
sta.z e
lda.z e+1
sbc.z dy+1
sta.z e+1
b7:
lda.z y+1
cmp #>y2
bne b6
lda.z y
cmp #<y2
bne b6
b3:
lda.z y
tax
jsr bitmap_plot
rts
b2:
lda.z dy+1
lsr
sta.z e1+1
lda.z dy
ror
sta.z e1
lda #<x1
sta.z x
lda #>x1
sta.z x+1
lda #<y1
sta.z y
lda #>y1
sta.z y+1
b9:
lda.z y
tax
jsr bitmap_plot
lda.z x
clc
adc.z sx
sta.z x
lda.z x+1
adc.z sx+1
sta.z x+1
lda.z e1
clc
adc.z dy
sta.z e1
lda.z e1+1
adc.z dy+1
sta.z e1+1
cmp.z dx+1
bne !+
lda.z e1
cmp.z dx
beq b10
!:
bcc b10
lda.z y
clc
adc.z sy
sta.z y
lda.z y+1
adc.z sy+1
sta.z y+1
lda.z e1
sec
sbc.z dx
sta.z e1
lda.z e1+1
sbc.z dx+1
sta.z e1+1
b10:
lda.z x+1
cmp.z x2+1
bne b9
lda.z x
cmp.z x2
bne b9
jmp b3
b4:
lda #<x1
sta.z bitmap_plot.x
lda #>x1
sta.z bitmap_plot.x+1
ldx #0
jsr bitmap_plot
rts
}
// Plot a single dot in the bitmap
// bitmap_plot(word zeropage($e) x, byte register(X) y)
bitmap_plot: {
.label _1 = $16
.label plotter = $14
.label x = $e
lda bitmap_plot_yhi,x
sta.z plotter+1
lda bitmap_plot_ylo,x
sta.z plotter
lda.z x
and #<$fff8
sta.z _1
lda.z x+1
and #>$fff8
sta.z _1+1
lda.z plotter
clc
adc.z _1
sta.z plotter
lda.z plotter+1
adc.z _1+1
sta.z plotter+1
lda.z x
tay
lda bitmap_plot_bit,y
ldy #0
ora (plotter),y
sta (plotter),y
rts
}
// Get the sign of a 16-bit unsigned number treated as a signed number.
// Returns unsigned -1 if the number is
// sgn_u16(word zeropage(4) w)
sgn_u16: {
.label w = 4
.label return = 6
lda.z w+1
and #$80
cmp #0
bne b1
lda #<1
sta.z return
lda #>1
sta.z return+1
rts
b1:
lda #<-1
sta.z return
lda #>-1
sta.z return+1
rts
}
// Get the absolute value of a 16-bit unsigned number treated as a signed number.
// abs_u16(word zeropage(8) w)
abs_u16: {
.label w = 8
.label return = 8
lda.z w+1
and #$80
cmp #0
bne b1
rts
b1:
sec
lda #0
sbc.z return
sta.z return
lda #0
sbc.z return+1
sta.z return+1
rts
}
// Clear all graphics on the bitmap
// bgcol - the background color to fill the screen with
// fgcol - the foreground color to fill the screen with
bitmap_clear: {
.const col = WHITE*$10+PURPLE
ldx #col
lda #<SCREEN
sta.z memset.str
lda #>SCREEN
sta.z memset.str+1
lda #<$3e8
sta.z memset.num
lda #>$3e8
sta.z memset.num+1
jsr memset
ldx #0
lda #<BITMAP
sta.z memset.str
lda #>BITMAP
sta.z memset.str+1
lda #<$1f40
sta.z memset.num
lda #>$1f40
sta.z memset.num+1
jsr memset
rts
}
// Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
// memset(void* zeropage($c) str, byte register(X) c, word zeropage($a) num)
memset: {
.label end = $a
.label dst = $c
.label num = $a
.label str = $c
lda.z num
bne !+
lda.z num+1
beq breturn
!:
lda.z end
clc
adc.z str
sta.z end
lda.z end+1
adc.z str+1
sta.z end+1
b2:
lda.z dst+1
cmp.z end+1
bne b3
lda.z dst
cmp.z end
bne b3
breturn:
rts
b3:
txa
ldy #0
sta (dst),y
inc.z dst
bne !+
inc.z dst+1
!:
jmp b2
}
// Initialize bitmap plotting tables
bitmap_init: {
.label _7 = $18
.label yoffs = $e
ldx #0
lda #$80
b1:
sta bitmap_plot_bit,x
lsr
cmp #0
bne b2
lda #$80
b2:
inx
cpx #0
bne b1
lda #<BITMAP
sta.z yoffs
lda #>BITMAP
sta.z yoffs+1
ldx #0
b3:
lda #7
sax.z _7
lda.z yoffs
ora.z _7
sta bitmap_plot_ylo,x
lda.z yoffs+1
sta bitmap_plot_yhi,x
lda #7
cmp.z _7
bne b4
clc
lda.z yoffs
adc #<$28*8
sta.z yoffs
lda.z yoffs+1
adc #>$28*8
sta.z yoffs+1
b4:
inx
cpx #0
bne b3
rts
}
// Tables for the plotter - initialized by calling bitmap_init();
bitmap_plot_ylo: .fill $100, 0
bitmap_plot_yhi: .fill $100, 0
bitmap_plot_bit: .fill $100, 0

View File

@ -0,0 +1,240 @@
@begin: scope:[] from
[0] phi()
to:@1
@1: scope:[] from @begin
[1] phi()
[2] call main
to:@end
@end: scope:[] from @1
[3] phi()
main: scope:[main] from @1
[4] *((const byte*) BORDERCOL#0) ← (byte) 0
[5] *((const byte*) BGCOL#0) ← (byte) 0
[6] *((const byte*) D011#0) ← (const byte) VIC_BMM#0|(const byte) VIC_DEN#0|(const byte) VIC_RSEL#0|(byte) 3
[7] *((const byte*) VIC_MEMORY#0) ← (byte)(word)(const byte*) SCREEN#0&(word) $3fff/(byte) $40|(word)(const byte*) BITMAP#0&(word) $3fff/(word) $400
[8] call bitmap_init
to:main::@3
main::@3: scope:[main] from main
[9] phi()
[10] call bitmap_clear
to:main::@1
main::@1: scope:[main] from main::@2 main::@3
[11] (word) next#5 ← phi( main::@2/(word) next#3 main::@3/(byte) 0 )
[12] (word) bitmap_line::x2#0 ← (word) next#5
[13] call bitmap_line
to:main::@4
main::@4: scope:[main] from main::@1
[14] (word) next#1 ← ++ (word) next#5
[15] if((word) next#1!=(word) $140) goto main::@5
to:main::@2
main::@5: scope:[main] from main::@4
[16] phi()
to:main::@2
main::@2: scope:[main] from main::@4 main::@5
[17] (word) next#3 ← phi( main::@4/(byte) 0 main::@5/(word) next#1 )
to:main::@1
bitmap_line: scope:[bitmap_line] from main::@1
[18] (word) abs_u16::w#0 ← (word) bitmap_line::x2#0
[19] call abs_u16
[20] (word) abs_u16::return#0 ← (word) abs_u16::return#4
to:bitmap_line::@12
bitmap_line::@12: scope:[bitmap_line] from bitmap_line
[21] (word) bitmap_line::dx#0 ← (word) abs_u16::return#0
[22] call abs_u16
[23] (word) abs_u16::return#1 ← (word) abs_u16::return#4
to:bitmap_line::@13
bitmap_line::@13: scope:[bitmap_line] from bitmap_line::@12
[24] (word) bitmap_line::dy#0 ← (word) abs_u16::return#1
[25] if((word) bitmap_line::dx#0!=(byte) 0) goto bitmap_line::@1
to:bitmap_line::@18
bitmap_line::@18: scope:[bitmap_line] from bitmap_line::@13
[26] if((word) bitmap_line::dy#0==(byte) 0) goto bitmap_line::@4
to:bitmap_line::@1
bitmap_line::@1: scope:[bitmap_line] from bitmap_line::@13 bitmap_line::@18
[27] (word) sgn_u16::w#0 ← (word) bitmap_line::x2#0
[28] call sgn_u16
[29] (word) sgn_u16::return#0 ← (word) sgn_u16::return#4
to:bitmap_line::@14
bitmap_line::@14: scope:[bitmap_line] from bitmap_line::@1
[30] (word) bitmap_line::sx#0 ← (word) sgn_u16::return#0
[31] call sgn_u16
[32] (word) sgn_u16::return#1 ← (word) sgn_u16::return#4
to:bitmap_line::@15
bitmap_line::@15: scope:[bitmap_line] from bitmap_line::@14
[33] (word) bitmap_line::sy#0 ← (word) sgn_u16::return#1
[34] if((word) bitmap_line::dx#0>(word) bitmap_line::dy#0) goto bitmap_line::@2
to:bitmap_line::@5
bitmap_line::@5: scope:[bitmap_line] from bitmap_line::@15
[35] (word) bitmap_line::e#0 ← (word) bitmap_line::dx#0 >> (byte) 1
to:bitmap_line::@6
bitmap_line::@6: scope:[bitmap_line] from bitmap_line::@5 bitmap_line::@7
[36] (word) bitmap_line::e#3 ← phi( bitmap_line::@5/(word) bitmap_line::e#0 bitmap_line::@7/(word) bitmap_line::e#6 )
[36] (word) bitmap_line::x#13 ← phi( bitmap_line::@5/(const word) bitmap_line::x1#0 bitmap_line::@7/(word) bitmap_line::x#12 )
[36] (word) bitmap_line::y#4 ← phi( bitmap_line::@5/(const word) bitmap_line::y1#0 bitmap_line::@7/(word) bitmap_line::y#1 )
[37] (byte) bitmap_plot::y#1 ← (byte)(word) bitmap_line::y#4
[38] (word) bitmap_plot::x#1 ← (word) bitmap_line::x#13
[39] call bitmap_plot
to:bitmap_line::@16
bitmap_line::@16: scope:[bitmap_line] from bitmap_line::@6
[40] (word) bitmap_line::y#1 ← (word) bitmap_line::y#4 + (word) bitmap_line::sy#0
[41] (word) bitmap_line::e#1 ← (word) bitmap_line::e#3 + (word) bitmap_line::dx#0
[42] if((word) bitmap_line::dy#0>=(word) bitmap_line::e#1) goto bitmap_line::@7
to:bitmap_line::@8
bitmap_line::@8: scope:[bitmap_line] from bitmap_line::@16
[43] (word) bitmap_line::x#1 ← (word) bitmap_line::x#13 + (word) bitmap_line::sx#0
[44] (word) bitmap_line::e#2 ← (word) bitmap_line::e#1 - (word) bitmap_line::dy#0
to:bitmap_line::@7
bitmap_line::@7: scope:[bitmap_line] from bitmap_line::@16 bitmap_line::@8
[45] (word) bitmap_line::e#6 ← phi( bitmap_line::@16/(word) bitmap_line::e#1 bitmap_line::@8/(word) bitmap_line::e#2 )
[45] (word) bitmap_line::x#12 ← phi( bitmap_line::@16/(word) bitmap_line::x#13 bitmap_line::@8/(word) bitmap_line::x#1 )
[46] if((word) bitmap_line::y#1!=(const word) bitmap_line::y2#0) goto bitmap_line::@6
to:bitmap_line::@3
bitmap_line::@3: scope:[bitmap_line] from bitmap_line::@10 bitmap_line::@7
[47] (word) bitmap_line::x#6 ← phi( bitmap_line::@10/(word) bitmap_line::x#15 bitmap_line::@7/(word) bitmap_line::x#12 )
[47] (word) bitmap_line::y#7 ← phi( bitmap_line::@10/(word) bitmap_line::y#13 bitmap_line::@7/(word) bitmap_line::y#1 )
[48] (byte) bitmap_plot::y#2 ← (byte)(word) bitmap_line::y#7
[49] (word) bitmap_plot::x#2 ← (word) bitmap_line::x#6
[50] call bitmap_plot
to:bitmap_line::@return
bitmap_line::@return: scope:[bitmap_line] from bitmap_line::@3 bitmap_line::@4
[51] return
to:@return
bitmap_line::@2: scope:[bitmap_line] from bitmap_line::@15
[52] (word) bitmap_line::e1#0 ← (word) bitmap_line::dy#0 >> (byte) 1
to:bitmap_line::@9
bitmap_line::@9: scope:[bitmap_line] from bitmap_line::@10 bitmap_line::@2
[53] (word) bitmap_line::e1#3 ← phi( bitmap_line::@10/(word) bitmap_line::e1#6 bitmap_line::@2/(word) bitmap_line::e1#0 )
[53] (word) bitmap_line::x#7 ← phi( bitmap_line::@10/(word) bitmap_line::x#15 bitmap_line::@2/(const word) bitmap_line::x1#0 )
[53] (word) bitmap_line::y#15 ← phi( bitmap_line::@10/(word) bitmap_line::y#13 bitmap_line::@2/(const word) bitmap_line::y1#0 )
[54] (byte) bitmap_plot::y#3 ← (byte)(word) bitmap_line::y#15
[55] (word) bitmap_plot::x#3 ← (word) bitmap_line::x#7
[56] call bitmap_plot
to:bitmap_line::@17
bitmap_line::@17: scope:[bitmap_line] from bitmap_line::@9
[57] (word) bitmap_line::x#15 ← (word) bitmap_line::x#7 + (word) bitmap_line::sx#0
[58] (word) bitmap_line::e1#1 ← (word) bitmap_line::e1#3 + (word) bitmap_line::dy#0
[59] if((word) bitmap_line::dx#0>=(word) bitmap_line::e1#1) goto bitmap_line::@10
to:bitmap_line::@11
bitmap_line::@11: scope:[bitmap_line] from bitmap_line::@17
[60] (word) bitmap_line::y#2 ← (word) bitmap_line::y#15 + (word) bitmap_line::sy#0
[61] (word) bitmap_line::e1#2 ← (word) bitmap_line::e1#1 - (word) bitmap_line::dx#0
to:bitmap_line::@10
bitmap_line::@10: scope:[bitmap_line] from bitmap_line::@11 bitmap_line::@17
[62] (word) bitmap_line::e1#6 ← phi( bitmap_line::@11/(word) bitmap_line::e1#2 bitmap_line::@17/(word) bitmap_line::e1#1 )
[62] (word) bitmap_line::y#13 ← phi( bitmap_line::@11/(word) bitmap_line::y#2 bitmap_line::@17/(word) bitmap_line::y#15 )
[63] if((word) bitmap_line::x#15!=(word) bitmap_line::x2#0) goto bitmap_line::@9
to:bitmap_line::@3
bitmap_line::@4: scope:[bitmap_line] from bitmap_line::@18
[64] phi()
[65] call bitmap_plot
to:bitmap_line::@return
bitmap_plot: scope:[bitmap_plot] from bitmap_line::@3 bitmap_line::@4 bitmap_line::@6 bitmap_line::@9
[66] (word) bitmap_plot::x#4 ← phi( bitmap_line::@9/(word) bitmap_plot::x#3 bitmap_line::@3/(word) bitmap_plot::x#2 bitmap_line::@4/(const word) bitmap_line::x1#0 bitmap_line::@6/(word) bitmap_plot::x#1 )
[66] (byte) bitmap_plot::y#4 ← phi( bitmap_line::@9/(byte) bitmap_plot::y#3 bitmap_line::@3/(byte) bitmap_plot::y#2 bitmap_line::@4/(byte) 0 bitmap_line::@6/(byte) bitmap_plot::y#1 )
[67] (word) bitmap_plot::plotter#0 ← *((const byte[$100]) bitmap_plot_yhi#0 + (byte) bitmap_plot::y#4) w= *((const byte[$100]) bitmap_plot_ylo#0 + (byte) bitmap_plot::y#4)
[68] (word~) bitmap_plot::$1 ← (word) bitmap_plot::x#4 & (word) $fff8
[69] (byte*) bitmap_plot::plotter#1 ← (byte*)(word) bitmap_plot::plotter#0 + (word~) bitmap_plot::$1
[70] (byte~) bitmap_plot::$2 ← < (word) bitmap_plot::x#4
[71] *((byte*) bitmap_plot::plotter#1) ← *((byte*) bitmap_plot::plotter#1) | *((const byte[$100]) bitmap_plot_bit#0 + (byte~) bitmap_plot::$2)
to:bitmap_plot::@return
bitmap_plot::@return: scope:[bitmap_plot] from bitmap_plot
[72] return
to:@return
sgn_u16: scope:[sgn_u16] from bitmap_line::@1 bitmap_line::@14
[73] (word) sgn_u16::w#2 ← phi( bitmap_line::@1/(word) sgn_u16::w#0 bitmap_line::@14/(const word) bitmap_line::y2#0 )
[74] (byte~) sgn_u16::$0 ← > (word) sgn_u16::w#2
[75] (byte~) sgn_u16::$1 ← (byte~) sgn_u16::$0 & (byte) $80
[76] if((byte) 0!=(byte~) sgn_u16::$1) goto sgn_u16::@1
to:sgn_u16::@return
sgn_u16::@1: scope:[sgn_u16] from sgn_u16
[77] phi()
to:sgn_u16::@return
sgn_u16::@return: scope:[sgn_u16] from sgn_u16 sgn_u16::@1
[78] (word) sgn_u16::return#4 ← phi( sgn_u16::@1/(byte) -1 sgn_u16/(byte) 1 )
[79] return
to:@return
abs_u16: scope:[abs_u16] from bitmap_line bitmap_line::@12
[80] (word) abs_u16::w#2 ← phi( bitmap_line/(word) abs_u16::w#0 bitmap_line::@12/(const word) bitmap_line::y2#0 )
[81] (byte~) abs_u16::$0 ← > (word) abs_u16::w#2
[82] (byte~) abs_u16::$1 ← (byte~) abs_u16::$0 & (byte) $80
[83] if((byte) 0!=(byte~) abs_u16::$1) goto abs_u16::@1
to:abs_u16::@return
abs_u16::@1: scope:[abs_u16] from abs_u16
[84] (word) abs_u16::return#2 ← - (word) abs_u16::w#2
to:abs_u16::@return
abs_u16::@return: scope:[abs_u16] from abs_u16 abs_u16::@1
[85] (word) abs_u16::return#4 ← phi( abs_u16::@1/(word) abs_u16::return#2 abs_u16/(word) abs_u16::w#2 )
[86] return
to:@return
bitmap_clear: scope:[bitmap_clear] from main::@3
[87] phi()
[88] call memset
to:bitmap_clear::@1
bitmap_clear::@1: scope:[bitmap_clear] from bitmap_clear
[89] phi()
[90] call memset
to:bitmap_clear::@return
bitmap_clear::@return: scope:[bitmap_clear] from bitmap_clear::@1
[91] return
to:@return
memset: scope:[memset] from bitmap_clear bitmap_clear::@1
[92] (byte) memset::c#4 ← phi( bitmap_clear/(const byte) bitmap_clear::col#0 bitmap_clear::@1/(byte) 0 )
[92] (void*) memset::str#3 ← phi( bitmap_clear/(void*)(const byte*) SCREEN#0 bitmap_clear::@1/(void*)(const byte*) BITMAP#0 )
[92] (word) memset::num#2 ← phi( bitmap_clear/(word) $3e8 bitmap_clear::@1/(word) $1f40 )
[93] if((word) memset::num#2<=(byte) 0) goto memset::@return
to:memset::@1
memset::@1: scope:[memset] from memset
[94] (byte*) memset::end#0 ← (byte*)(void*) memset::str#3 + (word) memset::num#2
[95] (byte*~) memset::dst#4 ← (byte*)(void*) memset::str#3
to:memset::@2
memset::@2: scope:[memset] from memset::@1 memset::@3
[96] (byte*) memset::dst#2 ← phi( memset::@1/(byte*~) memset::dst#4 memset::@3/(byte*) memset::dst#1 )
[97] if((byte*) memset::dst#2!=(byte*) memset::end#0) goto memset::@3
to:memset::@return
memset::@return: scope:[memset] from memset memset::@2
[98] return
to:@return
memset::@3: scope:[memset] from memset::@2
[99] *((byte*) memset::dst#2) ← (byte) memset::c#4
[100] (byte*) memset::dst#1 ← ++ (byte*) memset::dst#2
to:memset::@2
bitmap_init: scope:[bitmap_init] from main
[101] phi()
to:bitmap_init::@1
bitmap_init::@1: scope:[bitmap_init] from bitmap_init bitmap_init::@2
[102] (byte) bitmap_init::x#2 ← phi( bitmap_init/(byte) 0 bitmap_init::@2/(byte) bitmap_init::x#1 )
[102] (byte) bitmap_init::bits#3 ← phi( bitmap_init/(byte) $80 bitmap_init::@2/(byte) bitmap_init::bits#4 )
[103] *((const byte[$100]) bitmap_plot_bit#0 + (byte) bitmap_init::x#2) ← (byte) bitmap_init::bits#3
[104] (byte) bitmap_init::bits#1 ← (byte) bitmap_init::bits#3 >> (byte) 1
[105] if((byte) bitmap_init::bits#1!=(byte) 0) goto bitmap_init::@6
to:bitmap_init::@2
bitmap_init::@6: scope:[bitmap_init] from bitmap_init::@1
[106] phi()
to:bitmap_init::@2
bitmap_init::@2: scope:[bitmap_init] from bitmap_init::@1 bitmap_init::@6
[107] (byte) bitmap_init::bits#4 ← phi( bitmap_init::@6/(byte) bitmap_init::bits#1 bitmap_init::@1/(byte) $80 )
[108] (byte) bitmap_init::x#1 ← ++ (byte) bitmap_init::x#2
[109] if((byte) bitmap_init::x#1!=(byte) 0) goto bitmap_init::@1
to:bitmap_init::@3
bitmap_init::@3: scope:[bitmap_init] from bitmap_init::@2 bitmap_init::@4
[110] (byte*) bitmap_init::yoffs#2 ← phi( bitmap_init::@2/(const byte*) BITMAP#0 bitmap_init::@4/(byte*) bitmap_init::yoffs#4 )
[110] (byte) bitmap_init::y#2 ← phi( bitmap_init::@2/(byte) 0 bitmap_init::@4/(byte) bitmap_init::y#1 )
[111] (byte~) bitmap_init::$7 ← (byte) bitmap_init::y#2 & (byte) 7
[112] (byte~) bitmap_init::$4 ← < (byte*) bitmap_init::yoffs#2
[113] (byte~) bitmap_init::$5 ← (byte~) bitmap_init::$7 | (byte~) bitmap_init::$4
[114] *((const byte[$100]) bitmap_plot_ylo#0 + (byte) bitmap_init::y#2) ← (byte~) bitmap_init::$5
[115] (byte~) bitmap_init::$6 ← > (byte*) bitmap_init::yoffs#2
[116] *((const byte[$100]) bitmap_plot_yhi#0 + (byte) bitmap_init::y#2) ← (byte~) bitmap_init::$6
[117] if((byte~) bitmap_init::$7!=(byte) 7) goto bitmap_init::@4
to:bitmap_init::@5
bitmap_init::@5: scope:[bitmap_init] from bitmap_init::@3
[118] (byte*) bitmap_init::yoffs#1 ← (byte*) bitmap_init::yoffs#2 + (word)(number) $28*(number) 8
to:bitmap_init::@4
bitmap_init::@4: scope:[bitmap_init] from bitmap_init::@3 bitmap_init::@5
[119] (byte*) bitmap_init::yoffs#4 ← phi( bitmap_init::@3/(byte*) bitmap_init::yoffs#2 bitmap_init::@5/(byte*) bitmap_init::yoffs#1 )
[120] (byte) bitmap_init::y#1 ← ++ (byte) bitmap_init::y#2
[121] if((byte) bitmap_init::y#1!=(byte) 0) goto bitmap_init::@3
to:bitmap_init::@return
bitmap_init::@return: scope:[bitmap_init] from bitmap_init::@4
[122] return
to:@return

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,226 @@
(label) @1
(label) @begin
(label) @end
(byte*) BGCOL
(const byte*) BGCOL#0 BGCOL = (byte*) 53281
(byte*) BITMAP
(const byte*) BITMAP#0 BITMAP = (byte*) 8192
(byte*) BORDERCOL
(const byte*) BORDERCOL#0 BORDERCOL = (byte*) 53280
(byte*) D011
(const byte*) D011#0 D011 = (byte*) 53265
(byte) PURPLE
(const byte) PURPLE#0 PURPLE = (byte) 4
(byte*) SCREEN
(const byte*) SCREEN#0 SCREEN = (byte*) 1024
(byte) VIC_BMM
(const byte) VIC_BMM#0 VIC_BMM = (byte) $20
(byte) VIC_DEN
(const byte) VIC_DEN#0 VIC_DEN = (byte) $10
(byte*) VIC_MEMORY
(const byte*) VIC_MEMORY#0 VIC_MEMORY = (byte*) 53272
(byte) VIC_RSEL
(const byte) VIC_RSEL#0 VIC_RSEL = (byte) 8
(byte) WHITE
(const byte) WHITE#0 WHITE = (byte) 1
(word()) abs_u16((word) abs_u16::w)
(byte~) abs_u16::$0 reg byte a 4.0
(byte~) abs_u16::$1 reg byte a 4.0
(label) abs_u16::@1
(label) abs_u16::@return
(word) abs_u16::return
(word) abs_u16::return#0 return zp ZP_WORD:8 4.0
(word) abs_u16::return#1 return zp ZP_WORD:8 4.0
(word) abs_u16::return#2 return zp ZP_WORD:8 4.0
(word) abs_u16::return#4 return zp ZP_WORD:8 2.0
(word) abs_u16::w
(word) abs_u16::w#0 w zp ZP_WORD:8 4.0
(word) abs_u16::w#2 w zp ZP_WORD:8 2.0
(void()) bitmap_clear((byte) bitmap_clear::bgcol , (byte) bitmap_clear::fgcol)
(label) bitmap_clear::@1
(label) bitmap_clear::@return
(byte) bitmap_clear::bgcol
(byte) bitmap_clear::col
(const byte) bitmap_clear::col#0 col = (const byte) WHITE#0*(byte) $10+(const byte) PURPLE#0
(byte) bitmap_clear::fgcol
(byte*) bitmap_gfx
(void()) bitmap_init((byte*) bitmap_init::gfx , (byte*) bitmap_init::screen)
(byte~) bitmap_init::$4 reg byte a 22.0
(byte~) bitmap_init::$5 reg byte a 22.0
(byte~) bitmap_init::$6 reg byte a 22.0
(byte~) bitmap_init::$7 $7 zp ZP_BYTE:24 5.5
(label) bitmap_init::@1
(label) bitmap_init::@2
(label) bitmap_init::@3
(label) bitmap_init::@4
(label) bitmap_init::@5
(label) bitmap_init::@6
(label) bitmap_init::@return
(byte) bitmap_init::bits
(byte) bitmap_init::bits#1 reg byte a 11.0
(byte) bitmap_init::bits#3 reg byte a 16.5
(byte) bitmap_init::bits#4 reg byte a 7.333333333333333
(byte*) bitmap_init::gfx
(byte*) bitmap_init::screen
(byte) bitmap_init::x
(byte) bitmap_init::x#1 reg byte x 16.5
(byte) bitmap_init::x#2 reg byte x 5.5
(byte) bitmap_init::y
(byte) bitmap_init::y#1 reg byte x 16.5
(byte) bitmap_init::y#2 reg byte x 5.5
(byte*) bitmap_init::yoffs
(byte*) bitmap_init::yoffs#1 yoffs zp ZP_WORD:14 22.0
(byte*) bitmap_init::yoffs#2 yoffs zp ZP_WORD:14 6.875
(byte*) bitmap_init::yoffs#4 yoffs zp ZP_WORD:14 11.0
(void()) bitmap_line((word) bitmap_line::x1 , (word) bitmap_line::y1 , (word) bitmap_line::x2 , (word) bitmap_line::y2)
(label) bitmap_line::@1
(label) bitmap_line::@10
(label) bitmap_line::@11
(label) bitmap_line::@12
(label) bitmap_line::@13
(label) bitmap_line::@14
(label) bitmap_line::@15
(label) bitmap_line::@16
(label) bitmap_line::@17
(label) bitmap_line::@18
(label) bitmap_line::@2
(label) bitmap_line::@3
(label) bitmap_line::@4
(label) bitmap_line::@5
(label) bitmap_line::@6
(label) bitmap_line::@7
(label) bitmap_line::@8
(label) bitmap_line::@9
(label) bitmap_line::@return
(word) bitmap_line::dx
(word) bitmap_line::dx#0 dx zp ZP_WORD:16 8.18421052631579
(word) bitmap_line::dy
(word) bitmap_line::dy#0 dy zp ZP_WORD:8 8.885714285714286
(word) bitmap_line::e
(word) bitmap_line::e#0 e zp ZP_WORD:4 4.0
(word) bitmap_line::e#1 e zp ZP_WORD:4 134.66666666666666
(word) bitmap_line::e#2 e zp ZP_WORD:4 202.0
(word) bitmap_line::e#3 e zp ZP_WORD:4 40.8
(word) bitmap_line::e#6 e zp ZP_WORD:4 151.5
(word) bitmap_line::e1
(word) bitmap_line::e1#0 e1 zp ZP_WORD:2 4.0
(word) bitmap_line::e1#1 e1 zp ZP_WORD:2 134.66666666666666
(word) bitmap_line::e1#2 e1 zp ZP_WORD:2 202.0
(word) bitmap_line::e1#3 e1 zp ZP_WORD:2 40.8
(word) bitmap_line::e1#6 e1 zp ZP_WORD:2 151.5
(word) bitmap_line::sx
(word) bitmap_line::sx#0 sx zp ZP_WORD:18 7.03448275862069
(word) bitmap_line::sy
(word) bitmap_line::sy#0 sy zp ZP_WORD:6 7.846153846153847
(word) bitmap_line::x
(word) bitmap_line::x#1 x zp ZP_WORD:14 101.0
(word) bitmap_line::x#12 x zp ZP_WORD:14 202.0
(word) bitmap_line::x#13 x zp ZP_WORD:14 57.714285714285715
(word) bitmap_line::x#15 x zp ZP_WORD:14 57.714285714285715
(word) bitmap_line::x#6 x zp ZP_WORD:14 102.0
(word) bitmap_line::x#7 x zp ZP_WORD:14 75.75
(word) bitmap_line::x1
(const word) bitmap_line::x1#0 x1 = (byte) 0
(word) bitmap_line::x2
(word) bitmap_line::x2#0 x2 zp ZP_WORD:10 3.8666666666666667
(word) bitmap_line::y
(word) bitmap_line::y#1 y zp ZP_WORD:12 57.714285714285715
(word) bitmap_line::y#13 y zp ZP_WORD:12 202.0
(word) bitmap_line::y#15 y zp ZP_WORD:12 43.285714285714285
(word) bitmap_line::y#2 y zp ZP_WORD:12 101.0
(word) bitmap_line::y#4 y zp ZP_WORD:12 50.5
(word) bitmap_line::y#7 y zp ZP_WORD:12 202.0
(word) bitmap_line::y1
(const word) bitmap_line::y1#0 y1 = (byte) 0
(word) bitmap_line::y2
(const word) bitmap_line::y2#0 y2 = (byte) $64
(void()) bitmap_plot((word) bitmap_plot::x , (byte) bitmap_plot::y)
(word~) bitmap_plot::$1 $1 zp ZP_WORD:22 4.0
(byte~) bitmap_plot::$2 reg byte a 4.0
(label) bitmap_plot::@return
(byte*) bitmap_plot::plotter
(word) bitmap_plot::plotter#0 plotter zp ZP_WORD:20 1.0
(byte*) bitmap_plot::plotter#1 plotter zp ZP_WORD:20 3.0
(word) bitmap_plot::x
(word) bitmap_plot::x#1 x zp ZP_WORD:14 202.0
(word) bitmap_plot::x#2 x zp ZP_WORD:14 4.0
(word) bitmap_plot::x#3 x zp ZP_WORD:14 202.0
(word) bitmap_plot::x#4 x zp ZP_WORD:14 52.0
(byte) bitmap_plot::y
(byte) bitmap_plot::y#1 reg byte x 101.0
(byte) bitmap_plot::y#2 reg byte x 2.0
(byte) bitmap_plot::y#3 reg byte x 101.0
(byte) bitmap_plot::y#4 reg byte x 208.0
(byte[$100]) bitmap_plot_bit
(const byte[$100]) bitmap_plot_bit#0 bitmap_plot_bit = { fill( $100, 0) }
(byte[$100]) bitmap_plot_yhi
(const byte[$100]) bitmap_plot_yhi#0 bitmap_plot_yhi = { fill( $100, 0) }
(byte[$100]) bitmap_plot_ylo
(const byte[$100]) bitmap_plot_ylo#0 bitmap_plot_ylo = { fill( $100, 0) }
(byte*) bitmap_screen
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@4
(label) main::@5
(void*()) memset((void*) memset::str , (byte) memset::c , (word) memset::num)
(label) memset::@1
(label) memset::@2
(label) memset::@3
(label) memset::@return
(byte) memset::c
(byte) memset::c#4 reg byte x 1.375
(byte*) memset::dst
(byte*) memset::dst#1 dst zp ZP_WORD:12 22.0
(byte*) memset::dst#2 dst zp ZP_WORD:12 15.333333333333332
(byte*~) memset::dst#4 dst zp ZP_WORD:12 4.0
(byte*) memset::end
(byte*) memset::end#0 end zp ZP_WORD:10 2.1666666666666665
(word) memset::num
(word) memset::num#2 num zp ZP_WORD:10 2.0
(void*) memset::return
(void*) memset::str
(void*) memset::str#3 str zp ZP_WORD:12
(word) next
(word) next#1 next zp ZP_WORD:10 11.0
(word) next#3 next zp ZP_WORD:10 22.0
(word) next#5 next zp ZP_WORD:10 11.0
(word()) sgn_u16((word) sgn_u16::w)
(byte~) sgn_u16::$0 reg byte a 4.0
(byte~) sgn_u16::$1 reg byte a 4.0
(label) sgn_u16::@1
(label) sgn_u16::@return
(word) sgn_u16::return
(word) sgn_u16::return#0 return zp ZP_WORD:6 4.0
(word) sgn_u16::return#1 return zp ZP_WORD:6 4.0
(word) sgn_u16::return#4 return zp ZP_WORD:6 1.0
(word) sgn_u16::w
(word) sgn_u16::w#0 w zp ZP_WORD:4 4.0
(word) sgn_u16::w#2 w zp ZP_WORD:4 4.0
zp ZP_WORD:2 [ bitmap_line::e1#3 bitmap_line::e1#6 bitmap_line::e1#0 bitmap_line::e1#2 bitmap_line::e1#1 ]
reg byte x [ bitmap_plot::y#4 bitmap_plot::y#3 bitmap_plot::y#2 bitmap_plot::y#1 ]
zp ZP_WORD:4 [ sgn_u16::w#2 sgn_u16::w#0 bitmap_line::e#3 bitmap_line::e#0 bitmap_line::e#6 bitmap_line::e#1 bitmap_line::e#2 ]
zp ZP_WORD:6 [ sgn_u16::return#4 sgn_u16::return#0 sgn_u16::return#1 bitmap_line::sy#0 ]
zp ZP_WORD:8 [ abs_u16::return#4 abs_u16::return#2 abs_u16::w#2 abs_u16::w#0 abs_u16::return#0 abs_u16::return#1 bitmap_line::dy#0 ]
zp ZP_WORD:10 [ memset::num#2 memset::end#0 next#5 next#3 next#1 bitmap_line::x2#0 ]
zp ZP_WORD:12 [ memset::str#3 memset::dst#2 memset::dst#4 memset::dst#1 bitmap_line::y#15 bitmap_line::y#7 bitmap_line::y#13 bitmap_line::y#4 bitmap_line::y#1 bitmap_line::y#2 ]
reg byte x [ memset::c#4 ]
reg byte a [ bitmap_init::bits#3 bitmap_init::bits#4 bitmap_init::bits#1 ]
reg byte x [ bitmap_init::x#2 bitmap_init::x#1 ]
reg byte x [ bitmap_init::y#2 bitmap_init::y#1 ]
zp ZP_WORD:14 [ bitmap_init::yoffs#2 bitmap_init::yoffs#4 bitmap_init::yoffs#1 bitmap_line::x#7 bitmap_line::x#6 bitmap_line::x#15 bitmap_line::x#13 bitmap_line::x#12 bitmap_line::x#1 bitmap_plot::x#4 bitmap_plot::x#3 bitmap_plot::x#2 bitmap_plot::x#1 ]
zp ZP_WORD:16 [ bitmap_line::dx#0 ]
zp ZP_WORD:18 [ bitmap_line::sx#0 ]
zp ZP_WORD:20 [ bitmap_plot::plotter#0 bitmap_plot::plotter#1 ]
zp ZP_WORD:22 [ bitmap_plot::$1 ]
reg byte a [ bitmap_plot::$2 ]
reg byte a [ sgn_u16::$0 ]
reg byte a [ sgn_u16::$1 ]
reg byte a [ abs_u16::$0 ]
reg byte a [ abs_u16::$1 ]
zp ZP_BYTE:24 [ bitmap_init::$7 ]
reg byte a [ bitmap_init::$4 ]
reg byte a [ bitmap_init::$5 ]
reg byte a [ bitmap_init::$6 ]

View File

@ -0,0 +1,30 @@
// Illustrates problem with > comparison of signed chars.
// Reported by Danny Spijksma
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
.label SCREEN = $400
main: {
ldx #-$80
b1:
jsr debug
inx
cpx #-$80
bne b1
rts
}
// debug(signed byte register(X) dy)
debug: {
txa
sec
sbc #-$78
beq breturn
bvc !+
eor #$80
!:
bmi breturn
lda #$a
sta SCREEN,x
breturn:
rts
}

View File

@ -0,0 +1,33 @@
@begin: scope:[] from
[0] phi()
to:@1
@1: scope:[] from @begin
[1] phi()
[2] call main
to:@end
@end: scope:[] from @1
[3] phi()
main: scope:[main] from @1
[4] phi()
to:main::@1
main::@1: scope:[main] from main main::@2
[5] (signed byte) main::dy#2 ← phi( main/(signed byte) -$80 main::@2/(signed byte) main::dy#1 )
[6] (signed byte) debug::dy#0 ← (signed byte) main::dy#2
[7] call debug
to:main::@2
main::@2: scope:[main] from main::@1
[8] (signed byte) main::dy#1 ← ++ (signed byte) main::dy#2
[9] if((signed byte) main::dy#1!=(signed byte) -$80) goto main::@1
to:main::@return
main::@return: scope:[main] from main::@2
[10] return
to:@return
debug: scope:[debug] from main::@1
[11] if((signed byte) debug::dy#0<=(signed byte) -$78) goto debug::@return
to:debug::@1
debug::@1: scope:[debug] from debug
[12] *((const byte*) SCREEN#0 + (byte)(signed byte) debug::dy#0) ← (byte) $a
to:debug::@return
debug::@return: scope:[debug] from debug debug::@1
[13] return
to:@return

View File

@ -0,0 +1,515 @@
Identified constant variable (byte*) SCREEN
Culled Empty Block (label) main::@2
Culled Empty Block (label) debug::@1
CONTROL FLOW GRAPH SSA
@begin: scope:[] from
to:@1
main: scope:[main] from @2
(signed byte) main::dy#0 ← (signed byte) -$80
to:main::@1
main::@1: scope:[main] from main main::@3
(signed byte) main::dy#2 ← phi( main/(signed byte) main::dy#0 main::@3/(signed byte) main::dy#1 )
(signed byte) debug::dy#0 ← (signed byte) main::dy#2
call debug
to:main::@3
main::@3: scope:[main] from main::@1
(signed byte) main::dy#3 ← phi( main::@1/(signed byte) main::dy#2 )
(signed byte) main::dy#1 ← (signed byte) main::dy#3 + rangenext(-$80,$7f)
(bool~) main::$1 ← (signed byte) main::dy#1 != rangelast(-$80,$7f)
if((bool~) main::$1) goto main::@1
to:main::@return
main::@return: scope:[main] from main::@3
return
to:@return
@1: scope:[] from @begin
(byte*) SCREEN#0 ← ((byte*)) (number) $400
to:@2
debug: scope:[debug] from main::@1
(signed byte) debug::dy#1 ← phi( main::@1/(signed byte) debug::dy#0 )
(byte~) debug::$0 ← ((byte)) (signed byte) debug::dy#1
(byte) debug::i#0 ← (byte~) debug::$0
(bool~) debug::$1 ← (signed byte) debug::dy#1 > (number) -$78
(bool~) debug::$2 ← ! (bool~) debug::$1
if((bool~) debug::$2) goto debug::@return
to:debug::@2
debug::@2: scope:[debug] from debug
(byte) debug::i#1 ← phi( debug/(byte) debug::i#0 )
*((byte*) SCREEN#0 + (byte) debug::i#1) ← (number) $a
to:debug::@return
debug::@return: scope:[debug] from debug debug::@2
return
to:@return
@2: scope:[] from @1
call main
to:@3
@3: scope:[] from @2
to:@end
@end: scope:[] from @3
SYMBOL TABLE SSA
(label) @1
(label) @2
(label) @3
(label) @begin
(label) @end
(byte*) SCREEN
(byte*) SCREEN#0
(void()) debug((signed byte) debug::dy)
(byte~) debug::$0
(bool~) debug::$1
(bool~) debug::$2
(label) debug::@2
(label) debug::@return
(signed byte) debug::dy
(signed byte) debug::dy#0
(signed byte) debug::dy#1
(byte) debug::i
(byte) debug::i#0
(byte) debug::i#1
(void()) main()
(bool~) main::$1
(label) main::@1
(label) main::@3
(label) main::@return
(signed byte) main::dy
(signed byte) main::dy#0
(signed byte) main::dy#1
(signed byte) main::dy#2
(signed byte) main::dy#3
Adding number conversion cast (snumber) -$78 in (bool~) debug::$1 ← (signed byte) debug::dy#1 > (number) -$78
Adding number conversion cast (unumber) $a in *((byte*) SCREEN#0 + (byte) debug::i#1) ← (number) $a
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte*) SCREEN#0 ← (byte*)(number) $400
Inlining cast (byte~) debug::$0 ← (byte)(signed byte) debug::dy#1
Inlining cast *((byte*) SCREEN#0 + (byte) debug::i#1) ← (unumber)(number) $a
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast -$78
Simplifying constant integer cast $a
Successful SSA optimization PassNCastSimplification
Finalized signed number type (signed byte) -$78
Finalized unsigned number type (byte) $a
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inversing boolean not [14] (bool~) debug::$2 ← (signed byte) debug::dy#1 <= (signed byte) -$78 from [13] (bool~) debug::$1 ← (signed byte) debug::dy#1 > (signed byte) -$78
Successful SSA optimization Pass2UnaryNotSimplification
Alias (signed byte) main::dy#2 = (signed byte) main::dy#3
Alias (byte) debug::i#0 = (byte~) debug::$0 (byte) debug::i#1
Successful SSA optimization Pass2AliasElimination
Identical Phi Values (signed byte) debug::dy#1 (signed byte) debug::dy#0
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition (bool~) main::$1 [7] if((signed byte) main::dy#1!=rangelast(-$80,$7f)) goto main::@1
Simple Condition (bool~) debug::$2 [15] if((signed byte) debug::dy#0<=(signed byte) -$78) goto debug::@return
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const signed byte) main::dy#0 = -$80
Constant (const byte*) SCREEN#0 = (byte*) 1024
Successful SSA optimization Pass2ConstantIdentification
Resolved ranged next value [5] main::dy#1 ← ++ main::dy#2 to ++
Resolved ranged comparison value [7] if(main::dy#1!=rangelast(-$80,$7f)) goto main::@1 to (number) -$80
Adding number conversion cast (snumber) -$80 in if((signed byte) main::dy#1!=(number) -$80) goto main::@1
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast -$80
Successful SSA optimization PassNCastSimplification
Finalized signed number type (signed byte) -$80
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inlining Noop Cast [6] (byte) debug::i#0 ← (byte)(signed byte) debug::dy#0 keeping debug::dy#0
Successful SSA optimization Pass2NopCastInlining
Inlining constant with var siblings (const signed byte) main::dy#0
Constant inlined main::dy#0 = (signed byte) -$80
Successful SSA optimization Pass2ConstantInlining
Added new block during phi lifting main::@4(between main::@3 and main::@1)
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
Adding NOP phi() at start of @2
Adding NOP phi() at start of @3
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
CALL GRAPH
Calls in [] to main:3
Calls in [main] to debug:9
Created 1 initial phi equivalence classes
Coalesced [13] main::dy#4 ← main::dy#1
Coalesced down to 1 phi equivalence classes
Culled Empty Block (label) @1
Culled Empty Block (label) @3
Culled Empty Block (label) main::@4
Renumbering block @2 to @1
Renumbering block main::@3 to main::@2
Renumbering block debug::@2 to debug::@1
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
FINAL CONTROL FLOW GRAPH
@begin: scope:[] from
[0] phi()
to:@1
@1: scope:[] from @begin
[1] phi()
[2] call main
to:@end
@end: scope:[] from @1
[3] phi()
main: scope:[main] from @1
[4] phi()
to:main::@1
main::@1: scope:[main] from main main::@2
[5] (signed byte) main::dy#2 ← phi( main/(signed byte) -$80 main::@2/(signed byte) main::dy#1 )
[6] (signed byte) debug::dy#0 ← (signed byte) main::dy#2
[7] call debug
to:main::@2
main::@2: scope:[main] from main::@1
[8] (signed byte) main::dy#1 ← ++ (signed byte) main::dy#2
[9] if((signed byte) main::dy#1!=(signed byte) -$80) goto main::@1
to:main::@return
main::@return: scope:[main] from main::@2
[10] return
to:@return
debug: scope:[debug] from main::@1
[11] if((signed byte) debug::dy#0<=(signed byte) -$78) goto debug::@return
to:debug::@1
debug::@1: scope:[debug] from debug
[12] *((const byte*) SCREEN#0 + (byte)(signed byte) debug::dy#0) ← (byte) $a
to:debug::@return
debug::@return: scope:[debug] from debug debug::@1
[13] return
to:@return
VARIABLE REGISTER WEIGHTS
(byte*) SCREEN
(void()) debug((signed byte) debug::dy)
(signed byte) debug::dy
(signed byte) debug::dy#0 6.5
(byte) debug::i
(void()) main()
(signed byte) main::dy
(signed byte) main::dy#1 16.5
(signed byte) main::dy#2 11.0
Initial phi equivalence classes
[ main::dy#2 main::dy#1 ]
Added variable debug::dy#0 to zero page equivalence class [ debug::dy#0 ]
Complete equivalence classes
[ main::dy#2 main::dy#1 ]
[ debug::dy#0 ]
Allocated zp ZP_BYTE:2 [ main::dy#2 main::dy#1 ]
Allocated zp ZP_BYTE:3 [ debug::dy#0 ]
INITIAL ASM
Target platform is c64basic / MOS6502X
// File Comments
// Illustrates problem with > comparison of signed chars.
// Reported by Danny Spijksma
// Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
// Global Constants & labels
.label SCREEN = $400
// @begin
bbegin:
// [1] phi from @begin to @1 [phi:@begin->@1]
b1_from_bbegin:
jmp b1
// @1
b1:
// [2] call main
// [4] phi from @1 to main [phi:@1->main]
main_from_b1:
jsr main
// [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
jmp bend
// @end
bend:
// main
main: {
.label dy = 2
// [5] phi from main to main::@1 [phi:main->main::@1]
b1_from_main:
// [5] phi (signed byte) main::dy#2 = (signed byte) -$80 [phi:main->main::@1#0] -- vbsz1=vbsc1
lda #-$80
sta.z dy
jmp b1
// [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
b1_from_b2:
// [5] phi (signed byte) main::dy#2 = (signed byte) main::dy#1 [phi:main::@2->main::@1#0] -- register_copy
jmp b1
// main::@1
b1:
// [6] (signed byte) debug::dy#0 ← (signed byte) main::dy#2 -- vbsz1=vbsz2
lda.z dy
sta.z debug.dy
// [7] call debug
jsr debug
jmp b2
// main::@2
b2:
// [8] (signed byte) main::dy#1 ← ++ (signed byte) main::dy#2 -- vbsz1=_inc_vbsz1
inc.z dy
// [9] if((signed byte) main::dy#1!=(signed byte) -$80) goto main::@1 -- vbsz1_neq_vbsc1_then_la1
lda #-$80
cmp.z dy
bne b1_from_b2
jmp breturn
// main::@return
breturn:
// [10] return
rts
}
// debug
// debug(signed byte zeropage(3) dy)
debug: {
.label dy = 3
// [11] if((signed byte) debug::dy#0<=(signed byte) -$78) goto debug::@return -- vbsz1_le_vbsc1_then_la1
lda #-$78
sec
sbc.z dy
bvc !+
eor #$80
!:
bpl breturn
jmp b1
// debug::@1
b1:
// [12] *((const byte*) SCREEN#0 + (byte)(signed byte) debug::dy#0) ← (byte) $a -- pbuc1_derefidx_vbuz1=vbuc2
lda #$a
ldy.z dy
sta SCREEN,y
jmp breturn
// debug::@return
breturn:
// [13] return
rts
}
// File Data
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [11] if((signed byte) debug::dy#0<=(signed byte) -$78) goto debug::@return [ debug::dy#0 ] ( main:2::debug:7 [ main::dy#2 debug::dy#0 ] ) always clobbers reg byte a
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:2 [ main::dy#2 main::dy#1 ]
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:3 [ debug::dy#0 ]
Statement [12] *((const byte*) SCREEN#0 + (byte)(signed byte) debug::dy#0) ← (byte) $a [ ] ( main:2::debug:7 [ main::dy#2 ] ) always clobbers reg byte a
Statement [11] if((signed byte) debug::dy#0<=(signed byte) -$78) goto debug::@return [ debug::dy#0 ] ( main:2::debug:7 [ main::dy#2 debug::dy#0 ] ) always clobbers reg byte a
Statement [12] *((const byte*) SCREEN#0 + (byte)(signed byte) debug::dy#0) ← (byte) $a [ ] ( main:2::debug:7 [ main::dy#2 ] ) always clobbers reg byte a
Potential registers zp ZP_BYTE:2 [ main::dy#2 main::dy#1 ] : zp ZP_BYTE:2 , reg byte x , reg byte y ,
Potential registers zp ZP_BYTE:3 [ debug::dy#0 ] : zp ZP_BYTE:3 , reg byte x , reg byte y ,
REGISTER UPLIFT SCOPES
Uplift Scope [main] 27.5: zp ZP_BYTE:2 [ main::dy#2 main::dy#1 ]
Uplift Scope [debug] 6.5: zp ZP_BYTE:3 [ debug::dy#0 ]
Uplift Scope []
Uplifting [main] best 349 combination reg byte x [ main::dy#2 main::dy#1 ]
Uplifting [debug] best 317 combination reg byte x [ debug::dy#0 ]
Uplifting [] best 317 combination
ASSEMBLER BEFORE OPTIMIZATION
// File Comments
// Illustrates problem with > comparison of signed chars.
// Reported by Danny Spijksma
// Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
// Global Constants & labels
.label SCREEN = $400
// @begin
bbegin:
// [1] phi from @begin to @1 [phi:@begin->@1]
b1_from_bbegin:
jmp b1
// @1
b1:
// [2] call main
// [4] phi from @1 to main [phi:@1->main]
main_from_b1:
jsr main
// [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
jmp bend
// @end
bend:
// main
main: {
// [5] phi from main to main::@1 [phi:main->main::@1]
b1_from_main:
// [5] phi (signed byte) main::dy#2 = (signed byte) -$80 [phi:main->main::@1#0] -- vbsxx=vbsc1
ldx #-$80
jmp b1
// [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
b1_from_b2:
// [5] phi (signed byte) main::dy#2 = (signed byte) main::dy#1 [phi:main::@2->main::@1#0] -- register_copy
jmp b1
// main::@1
b1:
// [6] (signed byte) debug::dy#0 ← (signed byte) main::dy#2
// [7] call debug
jsr debug
jmp b2
// main::@2
b2:
// [8] (signed byte) main::dy#1 ← ++ (signed byte) main::dy#2 -- vbsxx=_inc_vbsxx
inx
// [9] if((signed byte) main::dy#1!=(signed byte) -$80) goto main::@1 -- vbsxx_neq_vbsc1_then_la1
cpx #-$80
bne b1_from_b2
jmp breturn
// main::@return
breturn:
// [10] return
rts
}
// debug
// debug(signed byte register(X) dy)
debug: {
// [11] if((signed byte) debug::dy#0<=(signed byte) -$78) goto debug::@return -- vbsxx_le_vbsc1_then_la1
txa
sec
sbc #-$78
beq breturn
bvc !+
eor #$80
!:
bmi breturn
jmp b1
// debug::@1
b1:
// [12] *((const byte*) SCREEN#0 + (byte)(signed byte) debug::dy#0) ← (byte) $a -- pbuc1_derefidx_vbuxx=vbuc2
lda #$a
sta SCREEN,x
jmp breturn
// debug::@return
breturn:
// [13] return
rts
}
// File Data
ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b1
Removing instruction jmp bend
Removing instruction jmp b1
Removing instruction jmp b2
Removing instruction jmp breturn
Removing instruction jmp b1
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label b1_from_b2 with b1
Removing instruction b1_from_bbegin:
Removing instruction b1:
Removing instruction main_from_b1:
Removing instruction bend_from_b1:
Removing instruction b1_from_b2:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction bend:
Removing instruction b1_from_main:
Removing instruction b2:
Removing instruction breturn:
Removing instruction b1:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Removing instruction jmp b1
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction bbegin:
Succesful ASM optimization Pass5UnusedLabelElimination
FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(byte*) SCREEN
(const byte*) SCREEN#0 SCREEN = (byte*) 1024
(void()) debug((signed byte) debug::dy)
(label) debug::@1
(label) debug::@return
(signed byte) debug::dy
(signed byte) debug::dy#0 reg byte x 6.5
(byte) debug::i
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@return
(signed byte) main::dy
(signed byte) main::dy#1 reg byte x 16.5
(signed byte) main::dy#2 reg byte x 11.0
reg byte x [ main::dy#2 main::dy#1 ]
reg byte x [ debug::dy#0 ]
FINAL ASSEMBLER
Score: 179
// File Comments
// Illustrates problem with > comparison of signed chars.
// Reported by Danny Spijksma
// Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
// Global Constants & labels
.label SCREEN = $400
// @begin
// [1] phi from @begin to @1 [phi:@begin->@1]
// @1
// [2] call main
// [4] phi from @1 to main [phi:@1->main]
// [3] phi from @1 to @end [phi:@1->@end]
// @end
// main
main: {
// [5] phi from main to main::@1 [phi:main->main::@1]
// [5] phi (signed byte) main::dy#2 = (signed byte) -$80 [phi:main->main::@1#0] -- vbsxx=vbsc1
ldx #-$80
// [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
// [5] phi (signed byte) main::dy#2 = (signed byte) main::dy#1 [phi:main::@2->main::@1#0] -- register_copy
// main::@1
b1:
// debug(dy)
// [6] (signed byte) debug::dy#0 ← (signed byte) main::dy#2
// [7] call debug
jsr debug
// main::@2
// for(signed char dy:-128..127)
// [8] (signed byte) main::dy#1 ← ++ (signed byte) main::dy#2 -- vbsxx=_inc_vbsxx
inx
// [9] if((signed byte) main::dy#1!=(signed byte) -$80) goto main::@1 -- vbsxx_neq_vbsc1_then_la1
cpx #-$80
bne b1
// main::@return
// }
// [10] return
rts
}
// debug
// debug(signed byte register(X) dy)
debug: {
// if (dy > -120)
// [11] if((signed byte) debug::dy#0<=(signed byte) -$78) goto debug::@return -- vbsxx_le_vbsc1_then_la1
txa
sec
sbc #-$78
beq breturn
bvc !+
eor #$80
!:
bmi breturn
// debug::@1
// SCREEN[i] = 10
// [12] *((const byte*) SCREEN#0 + (byte)(signed byte) debug::dy#0) ← (byte) $a -- pbuc1_derefidx_vbuxx=vbuc2
lda #$a
sta SCREEN,x
// debug::@return
breturn:
// }
// [13] return
rts
}
// File Data

View File

@ -0,0 +1,21 @@
(label) @1
(label) @begin
(label) @end
(byte*) SCREEN
(const byte*) SCREEN#0 SCREEN = (byte*) 1024
(void()) debug((signed byte) debug::dy)
(label) debug::@1
(label) debug::@return
(signed byte) debug::dy
(signed byte) debug::dy#0 reg byte x 6.5
(byte) debug::i
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@return
(signed byte) main::dy
(signed byte) main::dy#1 reg byte x 16.5
(signed byte) main::dy#2 reg byte x 11.0
reg byte x [ main::dy#2 main::dy#1 ]
reg byte x [ debug::dy#0 ]

View File

@ -0,0 +1,34 @@
// Test stack-relative addressing (for passing parameters through the stack)
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
/** The hardware stack. The offset 3 is to skip the return address and the fact that the pointer is to the next free position. */
.label STACK = $103
/** The screen. */
.label SCREEN = $400
main: {
// Push a few values to the stack
lda #'1'
pha
lda #'2'
pha
lda #'3'
pha
jsr peek_stack
// Clean up the stack
pla
pla
pla
rts
}
// Peek values from the stack using stack-relative addressing
peek_stack: {
tsx
lda STACK,x
sta SCREEN
lda STACK+1,x
sta SCREEN+1
lda STACK+2,x
sta SCREEN+2
rts
}

View File

@ -0,0 +1,25 @@
@begin: scope:[] from
[0] phi()
to:@1
@1: scope:[] from @begin
[1] phi()
[2] call main
to:@end
@end: scope:[] from @1
[3] phi()
main: scope:[main] from @1
asm { lda#'1' pha lda#'2' pha lda#'3' pha }
[5] call peek_stack
to:main::@1
main::@1: scope:[main] from main
asm { pla pla pla }
to:main::@return
main::@return: scope:[main] from main::@1
[7] return
to:@return
peek_stack: scope:[peek_stack] from main
asm { tsx ldaSTACK,x staSCREEN ldaSTACK+1,x staSCREEN+1 ldaSTACK+2,x staSCREEN+2 }
to:peek_stack::@return
peek_stack::@return: scope:[peek_stack] from peek_stack
[9] return
to:@return

View File

@ -0,0 +1,371 @@
CONTROL FLOW GRAPH SSA
@begin: scope:[] from
(byte*) STACK#0 ← ((byte*)) (number) $103
to:@1
main: scope:[main] from @2
asm { lda#'1' pha lda#'2' pha lda#'3' pha }
call peek_stack
to:main::@1
main::@1: scope:[main] from main
asm { pla pla pla }
to:main::@return
main::@return: scope:[main] from main::@1
return
to:@return
@1: scope:[] from @begin
(byte*) SCREEN#0 ← ((byte*)) (number) $400
to:@2
peek_stack: scope:[peek_stack] from main
asm { tsx ldaSTACK,x staSCREEN ldaSTACK+1,x staSCREEN+1 ldaSTACK+2,x staSCREEN+2 }
to:peek_stack::@return
peek_stack::@return: scope:[peek_stack] from peek_stack
return
to:@return
@2: scope:[] from @1
call main
to:@3
@3: scope:[] from @2
to:@end
@end: scope:[] from @3
SYMBOL TABLE SSA
(label) @1
(label) @2
(label) @3
(label) @begin
(label) @end
(byte*) SCREEN
(byte*) SCREEN#0
(byte*) STACK
(byte*) STACK#0
(void()) main()
(label) main::@1
(label) main::@return
(void()) peek_stack()
(label) peek_stack::@return
Inlining cast (byte*) STACK#0 ← (byte*)(number) $103
Inlining cast (byte*) SCREEN#0 ← (byte*)(number) $400
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 259
Simplifying constant pointer cast (byte*) 1024
Successful SSA optimization PassNCastSimplification
Constant (const byte*) STACK#0 = (byte*) 259
Constant (const byte*) SCREEN#0 = (byte*) 1024
Successful SSA optimization Pass2ConstantIdentification
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
Adding NOP phi() at start of @2
Adding NOP phi() at start of @3
Adding NOP phi() at start of @end
CALL GRAPH
Calls in [] to main:3
Calls in [main] to peek_stack:7
Created 0 initial phi equivalence classes
Coalesced down to 0 phi equivalence classes
Culled Empty Block (label) @1
Culled Empty Block (label) @3
Renumbering block @2 to @1
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
Adding NOP phi() at start of @end
FINAL CONTROL FLOW GRAPH
@begin: scope:[] from
[0] phi()
to:@1
@1: scope:[] from @begin
[1] phi()
[2] call main
to:@end
@end: scope:[] from @1
[3] phi()
main: scope:[main] from @1
asm { lda#'1' pha lda#'2' pha lda#'3' pha }
[5] call peek_stack
to:main::@1
main::@1: scope:[main] from main
asm { pla pla pla }
to:main::@return
main::@return: scope:[main] from main::@1
[7] return
to:@return
peek_stack: scope:[peek_stack] from main
asm { tsx ldaSTACK,x staSCREEN ldaSTACK+1,x staSCREEN+1 ldaSTACK+2,x staSCREEN+2 }
to:peek_stack::@return
peek_stack::@return: scope:[peek_stack] from peek_stack
[9] return
to:@return
VARIABLE REGISTER WEIGHTS
(byte*) SCREEN
(byte*) STACK
(void()) main()
(void()) peek_stack()
Initial phi equivalence classes
Complete equivalence classes
INITIAL ASM
Target platform is c64basic / MOS6502X
// File Comments
// Test stack-relative addressing (for passing parameters through the stack)
// Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
// Global Constants & labels
/** The hardware stack. The offset 3 is to skip the return address and the fact that the pointer is to the next free position. */
.label STACK = $103
/** The screen. */
.label SCREEN = $400
// @begin
bbegin:
// [1] phi from @begin to @1 [phi:@begin->@1]
b1_from_bbegin:
jmp b1
// @1
b1:
// [2] call main
jsr main
// [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
jmp bend
// @end
bend:
// main
main: {
// asm { lda#'1' pha lda#'2' pha lda#'3' pha }
// Push a few values to the stack
lda #'1'
pha
lda #'2'
pha
lda #'3'
pha
// [5] call peek_stack
jsr peek_stack
jmp b1
// main::@1
b1:
// asm { pla pla pla }
// Clean up the stack
pla
pla
pla
jmp breturn
// main::@return
breturn:
// [7] return
rts
}
// peek_stack
// Peek values from the stack using stack-relative addressing
peek_stack: {
// asm { tsx ldaSTACK,x staSCREEN ldaSTACK+1,x staSCREEN+1 ldaSTACK+2,x staSCREEN+2 }
tsx
lda STACK,x
sta SCREEN
lda STACK+1,x
sta SCREEN+1
lda STACK+2,x
sta SCREEN+2
jmp breturn
// peek_stack::@return
breturn:
// [9] return
rts
}
// File Data
REGISTER UPLIFT POTENTIAL REGISTERS
Statement asm { lda#'1' pha lda#'2' pha lda#'3' pha } always clobbers reg byte a
Statement asm { pla pla pla } always clobbers reg byte a
Statement asm { tsx ldaSTACK,x staSCREEN ldaSTACK+1,x staSCREEN+1 ldaSTACK+2,x staSCREEN+2 } always clobbers reg byte a reg byte x
REGISTER UPLIFT SCOPES
Uplift Scope [main]
Uplift Scope [peek_stack]
Uplift Scope []
Uplifting [main] best 93 combination
Uplifting [peek_stack] best 93 combination
Uplifting [] best 93 combination
ASSEMBLER BEFORE OPTIMIZATION
// File Comments
// Test stack-relative addressing (for passing parameters through the stack)
// Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
// Global Constants & labels
/** The hardware stack. The offset 3 is to skip the return address and the fact that the pointer is to the next free position. */
.label STACK = $103
/** The screen. */
.label SCREEN = $400
// @begin
bbegin:
// [1] phi from @begin to @1 [phi:@begin->@1]
b1_from_bbegin:
jmp b1
// @1
b1:
// [2] call main
jsr main
// [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
jmp bend
// @end
bend:
// main
main: {
// asm { lda#'1' pha lda#'2' pha lda#'3' pha }
// Push a few values to the stack
lda #'1'
pha
lda #'2'
pha
lda #'3'
pha
// [5] call peek_stack
jsr peek_stack
jmp b1
// main::@1
b1:
// asm { pla pla pla }
// Clean up the stack
pla
pla
pla
jmp breturn
// main::@return
breturn:
// [7] return
rts
}
// peek_stack
// Peek values from the stack using stack-relative addressing
peek_stack: {
// asm { tsx ldaSTACK,x staSCREEN ldaSTACK+1,x staSCREEN+1 ldaSTACK+2,x staSCREEN+2 }
tsx
lda STACK,x
sta SCREEN
lda STACK+1,x
sta SCREEN+1
lda STACK+2,x
sta SCREEN+2
jmp breturn
// peek_stack::@return
breturn:
// [9] return
rts
}
// File Data
ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b1
Removing instruction jmp bend
Removing instruction jmp b1
Removing instruction jmp breturn
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction b1_from_bbegin:
Removing instruction b1:
Removing instruction bend_from_b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction bend:
Removing instruction b1:
Removing instruction breturn:
Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Removing instruction bbegin:
Succesful ASM optimization Pass5UnusedLabelElimination
FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(byte*) SCREEN
(const byte*) SCREEN#0 SCREEN = (byte*) 1024
(byte*) STACK
(const byte*) STACK#0 STACK = (byte*) 259
(void()) main()
(label) main::@1
(label) main::@return
(void()) peek_stack()
(label) peek_stack::@return
FINAL ASSEMBLER
Score: 72
// File Comments
// Test stack-relative addressing (for passing parameters through the stack)
// Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
// Global Constants & labels
/** The hardware stack. The offset 3 is to skip the return address and the fact that the pointer is to the next free position. */
.label STACK = $103
/** The screen. */
.label SCREEN = $400
// @begin
// [1] phi from @begin to @1 [phi:@begin->@1]
// @1
// [2] call main
// [3] phi from @1 to @end [phi:@1->@end]
// @end
// main
main: {
// asm
// asm { lda#'1' pha lda#'2' pha lda#'3' pha }
// Push a few values to the stack
lda #'1'
pha
lda #'2'
pha
lda #'3'
pha
// peek_stack()
// [5] call peek_stack
jsr peek_stack
// main::@1
// asm
// asm { pla pla pla }
// Clean up the stack
pla
pla
pla
// main::@return
// }
// [7] return
rts
}
// peek_stack
// Peek values from the stack using stack-relative addressing
peek_stack: {
// asm
// asm { tsx ldaSTACK,x staSCREEN ldaSTACK+1,x staSCREEN+1 ldaSTACK+2,x staSCREEN+2 }
tsx
lda STACK,x
sta SCREEN
lda STACK+1,x
sta SCREEN+1
lda STACK+2,x
sta SCREEN+2
// peek_stack::@return
// }
// [9] return
rts
}
// File Data

View File

@ -0,0 +1,13 @@
(label) @1
(label) @begin
(label) @end
(byte*) SCREEN
(const byte*) SCREEN#0 SCREEN = (byte*) 1024
(byte*) STACK
(const byte*) STACK#0 STACK = (byte*) 259
(void()) main()
(label) main::@1
(label) main::@return
(void()) peek_stack()
(label) peek_stack::@return