1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-10-21 17:24:39 +00:00

Added conio.h support for PLUS4. Fixed problem where anonymous structs failed because scopes were mixed up.

This commit is contained in:
jespergravgaard 2020-05-16 12:40:01 +02:00
parent 1b9f523f8f
commit d9fdaca1b0
21 changed files with 992 additions and 173 deletions

View File

@ -1739,7 +1739,7 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
if(ctx.NAME() != null) {
structDefName = ctx.NAME().getText();
} else {
structDefName = getCurrentScope().allocateIntermediateVariableName();
structDefName = program.getScope().allocateIntermediateVariableName();
}
StructDefinition structDefinition = program.getScope().addStructDefinition(structDefName);
scopeStack.push(structDefinition);

View File

@ -376,7 +376,7 @@ public class CPreprocessor implements TokenSource {
}
/**
* #ifdef checks if a macro is _NOT_ defined.
* #ifndef checks if a macro is _NOT_ defined.
*
* @param cTokenSource The token source used to get the macro name
*/

View File

@ -2,7 +2,7 @@
// Implements similar functions as conio.h from CC65 for compatibility
// See https://github.com/cc65/cc65/blob/master/include/conio.h
//
// Currently only the C64 platform is supported
// Currently only the C64 and PLUS4 platform is supported
// clears the screen and moves the cursor to the upper left-hand corner of the screen.

View File

@ -29,7 +29,7 @@ struct MOS7360_TED {
unsigned char CONTROL2;
// Keyboard input latch. Giving a strobe - writing to the register, the latch stores the values of the input-lines.
// Then, we can read them from this register.
unsigned char KEYBOARD_INPUT;
volatile unsigned char KEYBOARD_INPUT;
// Interrupt request register. When a counter sends want to send an IRQ, it's bit will appear as a 0; then, if the
// IRQ was caused then highmost bit is set.
// Bit 0 : Unused

View File

@ -2,32 +2,76 @@
// Implements similar functions as conio.h from CC65 for compatibility
// See https://github.com/cc65/cc65/blob/master/include/conio.h
//
// Currently only the C64 platform is supported
#include <string.h>
// Currently only the C64/PLUS4 platforms are supported
#include <conio.h>
#include <string.h>
// The screen width
#define CONIO_WIDTH 40
// The screen height
#define CONIO_HEIGHT 25
// The screen bytes
#define CONIO_BYTES CONIO_HEIGHT*CONIO_WIDTH
#if defined(__C64__)
// The text screen address
char * const CONIO_SCREEN_TEXT = 0x0400;
// The color screen address
char * const CONIO_SCREEN_COLORS = 0xd800;
// The background color register address
char * const CONIO_BGCOLOR = 0xd021;
// The border color register address
char * const CONIO_BORDERCOLOR = 0xd020;
// CIA#1 Port A: keyboard matrix columns and joystick #2
char* const CONIO_CIA1_PORT_A = 0xdc00;
// CIA#1 Port B: keyboard matrix rows and joystick #1.
char* const CONIO_CIA1_PORT_B = 0xdc01;
// The screen width
#define CONIO_WIDTH 40
// The screen height
#define CONIO_HEIGHT 25
// The screen bytes
#define CONIO_BYTES CONIO_HEIGHT*CONIO_WIDTH
// The text screen address
char * const CONIO_SCREEN_TEXT = 0x0400;
// The color screen address
char * const CONIO_SCREEN_COLORS = 0xd800;
// The background color register address
char * const CONIO_BGCOLOR = 0xd021;
// The border color register address
char * const CONIO_BORDERCOLOR = 0xd020;
// The default text color
const char CONIO_TEXTCOLOR_DEFAULT = 0xe;
// The default text color
const char CONIO_TEXTCOLOR_DEFAULT = 0xe;
// Return true if there's a key waiting, return false if not
unsigned char kbhit (void) {
// CIA#1 Port A: keyboard matrix columns and joystick #2
char* const CONIO_CIA1_PORT_A = 0xdc00;
// CIA#1 Port B: keyboard matrix rows and joystick #1.
char* const CONIO_CIA1_PORT_B = 0xdc01;
*CONIO_CIA1_PORT_A = 0;
return ~*CONIO_CIA1_PORT_B;
}
#elif defined(__PLUS4__)
#include <plus4.h>
// The screen width
#define CONIO_WIDTH 40
// The screen height
#define CONIO_HEIGHT 25
// The screen bytes
#define CONIO_BYTES CONIO_HEIGHT*CONIO_WIDTH
// The text screen address
char * const CONIO_SCREEN_TEXT = DEFAULT_SCREEN;
// The color screen address
char * const CONIO_SCREEN_COLORS = DEFAULT_COLORRAM;
// The background color register address
char * const CONIO_BGCOLOR = &TED->BG_COLOR;
// The border color register address
char * const CONIO_BORDERCOLOR = &TED->BORDER_COLOR;
// The default text color
const char CONIO_TEXTCOLOR_DEFAULT = 0;
// Return true if there's a key waiting, return false if not
unsigned char kbhit (void) {
// Read all keyboard matrix rows
KEYBOARD_PORT->PORT = 0x00;
// Write to the keyboard input to latch the matrix column values
// TODO: Currently inline ASM is used to prevent the ASM optimizer from removing the load of the KEYBOARD_INPUT.
// TED->KEYBOARD_INPUT = 0;
asm { sta $ff08 }
// Read the keyboard input
return ~TED->KEYBOARD_INPUT;
}
#else
// #error "Target platform does not support conio.h"
#endif
// The current cursor x-position
__ma char conio_cursor_x = 0;
@ -210,12 +254,6 @@ unsigned char bordercolor(unsigned char color) {
return old;
}
// Return true if there's a key waiting, return false if not
unsigned char kbhit (void) {
*CONIO_CIA1_PORT_A = 0;
return ~*CONIO_CIA1_PORT_B;
}
// If onoff is 1, a cursor is displayed when waiting for keyboard input.
// If onoff is 0, the cursor is hidden when waiting for keyboard input.
// The function returns the old cursor setting.
@ -232,4 +270,4 @@ unsigned char scroll(unsigned char onoff) {
char old = conio_scroll_enable;
conio_scroll_enable = onoff;
return old;
}
}

View File

@ -44,6 +44,11 @@ public class TestPrograms {
public TestPrograms() {
}
@Test
public void testPlus4Kbhit() throws IOException, URISyntaxException {
compileAndCompare("plus4-kbhit.c");
}
@Test
public void testPlatformPlus4Define() throws IOException, URISyntaxException {
compileAndCompare("platform-plus4-define.c");

17
src/test/kc/plus4-kbhit.c Normal file
View File

@ -0,0 +1,17 @@
// Test implementation of kbhit() for Plus/4
#pragma target(plus4basic)
#include <plus4.h>
void main() {
while(!kbhit()) {}
}
// Return true if there's a key waiting, return false if not
unsigned char kbhit (void) {
// Read all keyboard matrix rows
KEYBOARD_PORT->PORT = 0x00;
// Write to the keyboard input to latch the matrix column values
TED->KEYBOARD_INPUT = 0;
// Read the keyboard input
return ~TED->KEYBOARD_INPUT;
}

View File

@ -44,10 +44,6 @@
.label CIA2_TIMER_AB = $dd04
// The vector used when the KERNAL serves IRQ interrupts
.label KERNEL_IRQ = $314
// CIA#1 Port A: keyboard matrix columns and joystick #2
.label CONIO_CIA1_PORT_A = $dc00
// CIA#1 Port B: keyboard matrix rows and joystick #1.
.label CONIO_CIA1_PORT_B = $dc01
// The line buffer
.label LINE_BUFFER = $2000
// The two charsets used as screen buffers
@ -885,6 +881,10 @@ irq_bottom_2: {
}
// Return true if there's a key waiting, return false if not
kbhit: {
// CIA#1 Port A: keyboard matrix columns and joystick #2
.label CONIO_CIA1_PORT_A = $dc00
// CIA#1 Port B: keyboard matrix rows and joystick #1.
.label CONIO_CIA1_PORT_B = $dc01
// *CONIO_CIA1_PORT_A = 0
lda #0
sta CONIO_CIA1_PORT_A

View File

@ -448,8 +448,8 @@ irq_bottom_2::@1: scope:[irq_bottom_2] from irq_bottom_2::@4
(byte()) kbhit()
kbhit: scope:[kbhit] from irq_bottom_2
[219] *((const nomodify byte*) CONIO_CIA1_PORT_A) ← (byte) 0
[220] (byte) kbhit::return#0 ← ~ *((const nomodify byte*) CONIO_CIA1_PORT_B)
[219] *((const nomodify byte*) kbhit::CONIO_CIA1_PORT_A) ← (byte) 0
[220] (byte) kbhit::return#0 ← ~ *((const nomodify byte*) kbhit::CONIO_CIA1_PORT_B)
to:kbhit::@return
kbhit::@return: scope:[kbhit] from kbhit
[221] return

View File

@ -88,6 +88,18 @@ clock_start: scope:[clock_start] from main::@8
clock_start::@return: scope:[clock_start] from clock_start
return
to:@return
$$
(byte()) kbhit()
kbhit: scope:[kbhit] from irq_bottom_2
*((const nomodify byte*) kbhit::CONIO_CIA1_PORT_A) ← (number) 0
(byte~) kbhit::$0 ← ~ *((const nomodify byte*) kbhit::CONIO_CIA1_PORT_B)
(byte) kbhit::return#0 ← (byte~) kbhit::$0
to:kbhit::@return
kbhit::@return: scope:[kbhit] from kbhit
(byte) kbhit::return#3 ← phi( kbhit/(byte) kbhit::return#0 )
(byte) kbhit::return#1 ← (byte) kbhit::return#3
return
to:@return
@1: scope:[] from @begin
(byte) conio_textcolor ← (const nomodify byte) CONIO_TEXTCOLOR_DEFAULT
to:@2
@ -104,18 +116,6 @@ textcolor::@return: scope:[textcolor] from textcolor
(byte) textcolor::return#1 ← (byte) textcolor::return#3
return
to:@return
(byte()) kbhit()
kbhit: scope:[kbhit] from irq_bottom_2
*((const nomodify byte*) CONIO_CIA1_PORT_A) ← (number) 0
(byte~) kbhit::$0 ← ~ *((const nomodify byte*) CONIO_CIA1_PORT_B)
(byte) kbhit::return#0 ← (byte~) kbhit::$0
to:kbhit::@return
kbhit::@return: scope:[kbhit] from kbhit
(byte) kbhit::return#3 ← phi( kbhit/(byte) kbhit::return#0 )
(byte) kbhit::return#1 ← (byte) kbhit::return#3
return
to:@return
@2: scope:[] from @1
(byte*) toD0181_screen#0 ← (const nomodify byte*) SCREEN
(byte*) toD0181_gfx#0 ← (const nomodify byte*) CANVAS2
@ -1064,8 +1064,6 @@ SYMBOL TABLE SSA
(const nomodify byte) CIA_TIMER_CONTROL_START = (byte) 1
(const nomodify byte) CIA_TIMER_CONTROL_STOP = (byte) 0
(const nomodify byte*) COLS = (byte*)(number) $d800
(const nomodify byte*) CONIO_CIA1_PORT_A = (byte*)(number) $dc00
(const nomodify byte*) CONIO_CIA1_PORT_B = (byte*)(number) $dc01
(const nomodify byte) CONIO_TEXTCOLOR_DEFAULT = (byte) $e
(const nomodify byte*) CONSOLE = (byte*)(number) $400
(const byte*) COSTAB = (const byte*) SINTAB+(number) $40
@ -1323,6 +1321,8 @@ interrupt(KERNEL_KEYBOARD)(void()) irq_bottom_2()
(byte()) kbhit()
(byte~) kbhit::$0
(label) kbhit::@return
(const nomodify byte*) kbhit::CONIO_CIA1_PORT_A = (byte*)(number) $dc00
(const nomodify byte*) kbhit::CONIO_CIA1_PORT_B = (byte*)(number) $dc01
(byte) kbhit::return
(byte) kbhit::return#0
(byte) kbhit::return#1
@ -2073,7 +2073,7 @@ Adding number conversion cast (unumber) 0 in (bool~) memset::$0 ← (word) memse
Adding number conversion cast (unumber) $ffffffff in (number~) clock::$0 ← (number) $ffffffff - *((const nomodify dword*) CIA2_TIMER_AB)
Adding number conversion cast (unumber) clock::$0 in (number~) clock::$0 ← (unumber)(number) $ffffffff - *((const nomodify dword*) CIA2_TIMER_AB)
Adding number conversion cast (unumber) $ffffffff in *((const nomodify dword*) CIA2_TIMER_AB) ← (number) $ffffffff
Adding number conversion cast (unumber) 0 in *((const nomodify byte*) CONIO_CIA1_PORT_A) ← (number) 0
Adding number conversion cast (unumber) 0 in *((const nomodify byte*) kbhit::CONIO_CIA1_PORT_A) ← (number) 0
Adding number conversion cast (unumber) $3fff in (number~) toD0181_$0 ← (word~) toD0181_$7 & (number) $3fff
Adding number conversion cast (unumber) toD0181_$0 in (number~) toD0181_$0 ← (word~) toD0181_$7 & (unumber)(number) $3fff
Adding number conversion cast (unumber) 4 in (number~) toD0181_$1 ← (unumber~) toD0181_$0 * (number) 4
@ -2205,7 +2205,7 @@ Adding number conversion cast (unumber) 1 in (byte) sgn_u8::return#3 ← (number
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte*) memset::dst#0 ← (byte*)(void*) memset::str#5
Inlining cast *((const nomodify dword*) CIA2_TIMER_AB) ← (unumber)(number) $ffffffff
Inlining cast *((const nomodify byte*) CONIO_CIA1_PORT_A) ← (unumber)(number) 0
Inlining cast *((const nomodify byte*) kbhit::CONIO_CIA1_PORT_A) ← (unumber)(number) 0
Inlining cast (word) memset::num#0 ← (unumber)(number) $28*(number) $19
Inlining cast (byte) memset::c#1 ← (unumber)(number) 0
Inlining cast (word) memset::num#1 ← (unumber)(number) $28*(number) $19
@ -2454,8 +2454,8 @@ Alias memset::dst#2 = memset::dst#3
Alias memset::end#1 = memset::end#2
Alias memset::str#7 = memset::str#8
Alias clock::return#0 = clock::$0 clock::return#3 clock::return#1
Alias textcolor::return#0 = textcolor::old#0 textcolor::return#3 textcolor::return#1
Alias kbhit::return#0 = kbhit::$0 kbhit::return#3 kbhit::return#1
Alias textcolor::return#0 = textcolor::old#0 textcolor::return#3 textcolor::return#1
Alias toD0181_screen#0 = toD0181_screen#1
Alias toD0181_gfx#0 = toD0181_gfx#1
Alias main::y#2 = main::y#3 main::c#0
@ -2732,10 +2732,10 @@ Eliminating unused constant (const byte*) line::canvas#1
Eliminating unused constant (const byte*) line::canvas#2
Successful SSA optimization PassNEliminateUnusedVars
Eliminating unused variable (dword) clock::return#0 and assignment [10] (dword) clock::return#0 ← (dword) $ffffffff - *((const nomodify dword*) CIA2_TIMER_AB)
Eliminating unused variable (byte) textcolor::return#0 and assignment [19] (byte) textcolor::return#0 ← (byte) conio_textcolor
Eliminating unused variable (byte) textcolor::return#0 and assignment [22] (byte) textcolor::return#0 ← (byte) conio_textcolor
Successful SSA optimization PassNEliminateUnusedVars
Eliminating unused variable (byte) conio_textcolor and assignment [17] (byte) conio_textcolor ← (const nomodify byte) CONIO_TEXTCOLOR_DEFAULT
Eliminating unused variable conio_textcolor(null) and assignment [18] conio_textcolor(null) ← (const byte) textcolor::color#0
Eliminating unused variable (byte) conio_textcolor and assignment [20] (byte) conio_textcolor ← (const nomodify byte) CONIO_TEXTCOLOR_DEFAULT
Eliminating unused variable conio_textcolor(null) and assignment [21] conio_textcolor(null) ← (const byte) textcolor::color#0
Successful SSA optimization PassNEliminateUnusedVars
Eliminating unused constant (const nomodify byte) CONIO_TEXTCOLOR_DEFAULT
Eliminating unused constant (const byte) textcolor::color#0
@ -3608,8 +3608,8 @@ irq_bottom_2::@1: scope:[irq_bottom_2] from irq_bottom_2::@4
(byte()) kbhit()
kbhit: scope:[kbhit] from irq_bottom_2
[219] *((const nomodify byte*) CONIO_CIA1_PORT_A) ← (byte) 0
[220] (byte) kbhit::return#0 ← ~ *((const nomodify byte*) CONIO_CIA1_PORT_B)
[219] *((const nomodify byte*) kbhit::CONIO_CIA1_PORT_A) ← (byte) 0
[220] (byte) kbhit::return#0 ← ~ *((const nomodify byte*) kbhit::CONIO_CIA1_PORT_B)
to:kbhit::@return
kbhit::@return: scope:[kbhit] from kbhit
[221] return
@ -4249,10 +4249,6 @@ Target platform is c64basic / MOS6502X
.label CIA2_TIMER_AB = $dd04
// The vector used when the KERNAL serves IRQ interrupts
.label KERNEL_IRQ = $314
// CIA#1 Port A: keyboard matrix columns and joystick #2
.label CONIO_CIA1_PORT_A = $dc00
// CIA#1 Port B: keyboard matrix rows and joystick #1.
.label CONIO_CIA1_PORT_B = $dc01
// The line buffer
.label LINE_BUFFER = $2000
// The two charsets used as screen buffers
@ -5641,12 +5637,16 @@ irq_bottom_2: {
// kbhit
// Return true if there's a key waiting, return false if not
kbhit: {
// CIA#1 Port A: keyboard matrix columns and joystick #2
.label CONIO_CIA1_PORT_A = $dc00
// CIA#1 Port B: keyboard matrix rows and joystick #1.
.label CONIO_CIA1_PORT_B = $dc01
.label return = $5d
.label return_1 = $5b
// [219] *((const nomodify byte*) CONIO_CIA1_PORT_A) ← (byte) 0 -- _deref_pbuc1=vbuc2
// [219] *((const nomodify byte*) kbhit::CONIO_CIA1_PORT_A) ← (byte) 0 -- _deref_pbuc1=vbuc2
lda #0
sta CONIO_CIA1_PORT_A
// [220] (byte) kbhit::return#0 ← ~ *((const nomodify byte*) CONIO_CIA1_PORT_B) -- vbuz1=_bnot__deref_pbuc1
// [220] (byte) kbhit::return#0 ← ~ *((const nomodify byte*) kbhit::CONIO_CIA1_PORT_B) -- vbuz1=_bnot__deref_pbuc1
lda CONIO_CIA1_PORT_B
eor #$ff
sta.z return
@ -5853,8 +5853,8 @@ Statement [214] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byt
Statement [215] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER) ← (const nomodify byte) BORDER_YPOS_BOTTOM-(byte) 8 [ ] ( [ ] { } ) always clobbers reg byte a
Statement [216] *((const nomodify void()**) KERNEL_IRQ) ← &interrupt(KERNEL_MIN)(void()) irq_bottom_1() [ ] ( [ ] { } ) always clobbers reg byte a
Statement [218] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_MEMORY) ← (volatile byte) canvas_show_memory [ ] ( [ ] { } ) always clobbers reg byte a
Statement [219] *((const nomodify byte*) CONIO_CIA1_PORT_A) ← (byte) 0 [ ] ( kbhit:207 [ canvas_show_memory ] { { kbhit::return#0 = kbhit::return#2 } } ) always clobbers reg byte a
Statement [220] (byte) kbhit::return#0 ← ~ *((const nomodify byte*) CONIO_CIA1_PORT_B) [ kbhit::return#0 ] ( kbhit:207 [ canvas_show_memory kbhit::return#0 ] { { kbhit::return#0 = kbhit::return#2 } } ) always clobbers reg byte a
Statement [219] *((const nomodify byte*) kbhit::CONIO_CIA1_PORT_A) ← (byte) 0 [ ] ( kbhit:207 [ canvas_show_memory ] { { kbhit::return#0 = kbhit::return#2 } } ) always clobbers reg byte a
Statement [220] (byte) kbhit::return#0 ← ~ *((const nomodify byte*) kbhit::CONIO_CIA1_PORT_B) [ kbhit::return#0 ] ( kbhit:207 [ canvas_show_memory kbhit::return#0 ] { { kbhit::return#0 = kbhit::return#2 } } ) always clobbers reg byte a
Statement [222] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) ← (const nomodify byte) DARK_GREY [ ] ( [ ] { } ) always clobbers reg byte a
Statement [224] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_MEMORY) ← (const byte) irq_bottom_1::toD0181_return#0 [ ] ( [ ] { } ) always clobbers reg byte a
Statement [225] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS) ← (const nomodify byte) IRQ_RASTER [ ] ( [ ] { } ) always clobbers reg byte a
@ -5955,8 +5955,8 @@ Statement [214] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byt
Statement [215] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER) ← (const nomodify byte) BORDER_YPOS_BOTTOM-(byte) 8 [ ] ( [ ] { } ) always clobbers reg byte a
Statement [216] *((const nomodify void()**) KERNEL_IRQ) ← &interrupt(KERNEL_MIN)(void()) irq_bottom_1() [ ] ( [ ] { } ) always clobbers reg byte a
Statement [218] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_MEMORY) ← (volatile byte) canvas_show_memory [ ] ( [ ] { } ) always clobbers reg byte a
Statement [219] *((const nomodify byte*) CONIO_CIA1_PORT_A) ← (byte) 0 [ ] ( kbhit:207 [ canvas_show_memory ] { { kbhit::return#0 = kbhit::return#2 } } ) always clobbers reg byte a
Statement [220] (byte) kbhit::return#0 ← ~ *((const nomodify byte*) CONIO_CIA1_PORT_B) [ kbhit::return#0 ] ( kbhit:207 [ canvas_show_memory kbhit::return#0 ] { { kbhit::return#0 = kbhit::return#2 } } ) always clobbers reg byte a
Statement [219] *((const nomodify byte*) kbhit::CONIO_CIA1_PORT_A) ← (byte) 0 [ ] ( kbhit:207 [ canvas_show_memory ] { { kbhit::return#0 = kbhit::return#2 } } ) always clobbers reg byte a
Statement [220] (byte) kbhit::return#0 ← ~ *((const nomodify byte*) kbhit::CONIO_CIA1_PORT_B) [ kbhit::return#0 ] ( kbhit:207 [ canvas_show_memory kbhit::return#0 ] { { kbhit::return#0 = kbhit::return#2 } } ) always clobbers reg byte a
Statement [222] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) ← (const nomodify byte) DARK_GREY [ ] ( [ ] { } ) always clobbers reg byte a
Statement [224] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_MEMORY) ← (const byte) irq_bottom_1::toD0181_return#0 [ ] ( [ ] { } ) always clobbers reg byte a
Statement [225] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS) ← (const nomodify byte) IRQ_RASTER [ ] ( [ ] { } ) always clobbers reg byte a
@ -6255,10 +6255,6 @@ ASSEMBLER BEFORE OPTIMIZATION
.label CIA2_TIMER_AB = $dd04
// The vector used when the KERNAL serves IRQ interrupts
.label KERNEL_IRQ = $314
// CIA#1 Port A: keyboard matrix columns and joystick #2
.label CONIO_CIA1_PORT_A = $dc00
// CIA#1 Port B: keyboard matrix rows and joystick #1.
.label CONIO_CIA1_PORT_B = $dc01
// The line buffer
.label LINE_BUFFER = $2000
// The two charsets used as screen buffers
@ -7527,10 +7523,14 @@ irq_bottom_2: {
// kbhit
// Return true if there's a key waiting, return false if not
kbhit: {
// [219] *((const nomodify byte*) CONIO_CIA1_PORT_A) ← (byte) 0 -- _deref_pbuc1=vbuc2
// CIA#1 Port A: keyboard matrix columns and joystick #2
.label CONIO_CIA1_PORT_A = $dc00
// CIA#1 Port B: keyboard matrix rows and joystick #1.
.label CONIO_CIA1_PORT_B = $dc01
// [219] *((const nomodify byte*) kbhit::CONIO_CIA1_PORT_A) ← (byte) 0 -- _deref_pbuc1=vbuc2
lda #0
sta CONIO_CIA1_PORT_A
// [220] (byte) kbhit::return#0 ← ~ *((const nomodify byte*) CONIO_CIA1_PORT_B) -- vbuaa=_bnot__deref_pbuc1
// [220] (byte) kbhit::return#0 ← ~ *((const nomodify byte*) kbhit::CONIO_CIA1_PORT_B) -- vbuaa=_bnot__deref_pbuc1
lda CONIO_CIA1_PORT_B
eor #$ff
jmp __breturn
@ -7819,8 +7819,8 @@ Removing instruction __breturn:
Removing instruction __b2:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Fixing long branch [137] bcc __b2 to bcs
Fixing long branch [377] bcc __b2 to bcs
Fixing long branch [133] bcc __b2 to bcs
Fixing long branch [373] bcc __b2 to bcs
FINAL SYMBOL TABLE
(label) @1
@ -7838,8 +7838,6 @@ FINAL SYMBOL TABLE
(const nomodify byte) CIA_TIMER_CONTROL_B_COUNT_UNDERFLOW_A = (byte) $40
(const nomodify byte) CIA_TIMER_CONTROL_START = (byte) 1
(const nomodify byte*) COLS = (byte*) 55296
(const nomodify byte*) CONIO_CIA1_PORT_A = (byte*) 56320
(const nomodify byte*) CONIO_CIA1_PORT_B = (byte*) 56321
(const nomodify byte*) CONSOLE = (byte*) 1024
(const byte*) COSTAB = (const byte*) SINTAB+(byte) $40
(const nomodify byte) DARK_GREY = (byte) $b
@ -8019,6 +8017,8 @@ interrupt(KERNEL_KEYBOARD)(void()) irq_bottom_2()
(byte*) irq_bottom_2::toD0181_screen
(byte()) kbhit()
(label) kbhit::@return
(const nomodify byte*) kbhit::CONIO_CIA1_PORT_A = (byte*) 56320
(const nomodify byte*) kbhit::CONIO_CIA1_PORT_B = (byte*) 56321
(byte) kbhit::return
(byte) kbhit::return#0 reg byte a 4.333333333333333
(byte) kbhit::return#2 reg byte a 4.0
@ -8410,10 +8410,6 @@ Score: 106699
.label CIA2_TIMER_AB = $dd04
// The vector used when the KERNAL serves IRQ interrupts
.label KERNEL_IRQ = $314
// CIA#1 Port A: keyboard matrix columns and joystick #2
.label CONIO_CIA1_PORT_A = $dc00
// CIA#1 Port B: keyboard matrix rows and joystick #1.
.label CONIO_CIA1_PORT_B = $dc01
// The line buffer
.label LINE_BUFFER = $2000
// The two charsets used as screen buffers
@ -9651,12 +9647,16 @@ irq_bottom_2: {
// kbhit
// Return true if there's a key waiting, return false if not
kbhit: {
// CIA#1 Port A: keyboard matrix columns and joystick #2
.label CONIO_CIA1_PORT_A = $dc00
// CIA#1 Port B: keyboard matrix rows and joystick #1.
.label CONIO_CIA1_PORT_B = $dc01
// *CONIO_CIA1_PORT_A = 0
// [219] *((const nomodify byte*) CONIO_CIA1_PORT_A) ← (byte) 0 -- _deref_pbuc1=vbuc2
// [219] *((const nomodify byte*) kbhit::CONIO_CIA1_PORT_A) ← (byte) 0 -- _deref_pbuc1=vbuc2
lda #0
sta CONIO_CIA1_PORT_A
// ~*CONIO_CIA1_PORT_B
// [220] (byte) kbhit::return#0 ← ~ *((const nomodify byte*) CONIO_CIA1_PORT_B) -- vbuaa=_bnot__deref_pbuc1
// [220] (byte) kbhit::return#0 ← ~ *((const nomodify byte*) kbhit::CONIO_CIA1_PORT_B) -- vbuaa=_bnot__deref_pbuc1
lda CONIO_CIA1_PORT_B
eor #$ff
// kbhit::@return

View File

@ -13,8 +13,6 @@
(const nomodify byte) CIA_TIMER_CONTROL_B_COUNT_UNDERFLOW_A = (byte) $40
(const nomodify byte) CIA_TIMER_CONTROL_START = (byte) 1
(const nomodify byte*) COLS = (byte*) 55296
(const nomodify byte*) CONIO_CIA1_PORT_A = (byte*) 56320
(const nomodify byte*) CONIO_CIA1_PORT_B = (byte*) 56321
(const nomodify byte*) CONSOLE = (byte*) 1024
(const byte*) COSTAB = (const byte*) SINTAB+(byte) $40
(const nomodify byte) DARK_GREY = (byte) $b
@ -194,6 +192,8 @@ interrupt(KERNEL_KEYBOARD)(void()) irq_bottom_2()
(byte*) irq_bottom_2::toD0181_screen
(byte()) kbhit()
(label) kbhit::@return
(const nomodify byte*) kbhit::CONIO_CIA1_PORT_A = (byte*) 56320
(const nomodify byte*) kbhit::CONIO_CIA1_PORT_B = (byte*) 56321
(byte) kbhit::return
(byte) kbhit::return#0 reg byte a 4.333333333333333
(byte) kbhit::return#2 reg byte a 4.0

View File

@ -35,10 +35,6 @@
.label CONIO_BGCOLOR = $d021
// The border color register address
.label CONIO_BORDERCOLOR = $d020
// CIA#1 Port A: keyboard matrix columns and joystick #2
.label CONIO_CIA1_PORT_A = $dc00
// CIA#1 Port B: keyboard matrix rows and joystick #1.
.label CONIO_CIA1_PORT_B = $dc01
.label VIC_MEMORY = $d018
.label conio_cursor_x = 9
.label conio_cursor_y = $a
@ -175,6 +171,10 @@ clrscr: {
}
// Return true if there's a key waiting, return false if not
kbhit: {
// CIA#1 Port A: keyboard matrix columns and joystick #2
.label CONIO_CIA1_PORT_A = $dc00
// CIA#1 Port B: keyboard matrix rows and joystick #1.
.label CONIO_CIA1_PORT_B = $dc01
// *CONIO_CIA1_PORT_A = 0
lda #0
sta CONIO_CIA1_PORT_A

View File

@ -82,8 +82,8 @@ clrscr::@4: scope:[clrscr] from clrscr::@3
(byte()) kbhit()
kbhit: scope:[kbhit] from main::@1
[40] *((const nomodify byte*) CONIO_CIA1_PORT_A) ← (byte) 0
[41] (byte) kbhit::return#0 ← ~ *((const nomodify byte*) CONIO_CIA1_PORT_B)
[40] *((const nomodify byte*) kbhit::CONIO_CIA1_PORT_A) ← (byte) 0
[41] (byte) kbhit::return#0 ← ~ *((const nomodify byte*) kbhit::CONIO_CIA1_PORT_B)
to:kbhit::@return
kbhit::@return: scope:[kbhit] from kbhit
[42] return

View File

@ -116,6 +116,18 @@ strlen::@return: scope:[strlen] from strlen::@3
(word) strlen::return#1 ← (word) strlen::return#3
return
to:@return
(byte()) kbhit()
kbhit: scope:[kbhit] from main::@1
*((const nomodify byte*) kbhit::CONIO_CIA1_PORT_A) ← (number) 0
(byte~) kbhit::$0 ← ~ *((const nomodify byte*) kbhit::CONIO_CIA1_PORT_B)
(byte) kbhit::return#0 ← (byte~) kbhit::$0
to:kbhit::@return
kbhit::@return: scope:[kbhit] from kbhit
(byte) kbhit::return#3 ← phi( kbhit/(byte) kbhit::return#0 )
(byte) kbhit::return#1 ← (byte) kbhit::return#3
return
to:@return
@1: scope:[] from @begin
(byte) conio_cursor_x ← (byte) 0
(byte) conio_cursor_y ← (byte) 0
@ -534,18 +546,6 @@ bordercolor::@return: scope:[bordercolor] from bordercolor
return
to:@return
(byte()) kbhit()
kbhit: scope:[kbhit] from main::@1
*((const nomodify byte*) CONIO_CIA1_PORT_A) ← (number) 0
(byte~) kbhit::$0 ← ~ *((const nomodify byte*) CONIO_CIA1_PORT_B)
(byte) kbhit::return#0 ← (byte~) kbhit::$0
to:kbhit::@return
kbhit::@return: scope:[kbhit] from kbhit
(byte) kbhit::return#3 ← phi( kbhit/(byte) kbhit::return#0 )
(byte) kbhit::return#1 ← (byte) kbhit::return#3
return
to:@return
(byte()) cursor((byte) cursor::onoff)
cursor: scope:[cursor] from MakeNiceScreen::@7
(byte) cursor::onoff#1 ← phi( MakeNiceScreen::@7/(byte) cursor::onoff#0 )
@ -788,8 +788,6 @@ SYMBOL TABLE SSA
(const nomodify byte) COLOR_GRAY3 = (byte) $f
(const nomodify byte*) CONIO_BGCOLOR = (byte*)(number) $d021
(const nomodify byte*) CONIO_BORDERCOLOR = (byte*)(number) $d020
(const nomodify byte*) CONIO_CIA1_PORT_A = (byte*)(number) $dc00
(const nomodify byte*) CONIO_CIA1_PORT_B = (byte*)(number) $dc01
(const nomodify byte*) CONIO_SCREEN_COLORS = (byte*)(number) $d800
(const nomodify byte*) CONIO_SCREEN_TEXT = (byte*)(number) $400
(const nomodify byte) CONIO_TEXTCOLOR_DEFAULT = (byte) $e
@ -1154,6 +1152,8 @@ SYMBOL TABLE SSA
(byte()) kbhit()
(byte~) kbhit::$0
(label) kbhit::@return
(const nomodify byte*) kbhit::CONIO_CIA1_PORT_A = (byte*)(number) $dc00
(const nomodify byte*) kbhit::CONIO_CIA1_PORT_B = (byte*)(number) $dc01
(byte) kbhit::return
(byte) kbhit::return#0
(byte) kbhit::return#1
@ -1319,6 +1319,7 @@ SYMBOL TABLE SSA
Adding number conversion cast (unumber) 0 in (bool~) memset::$0 ← (word) memset::num#2 > (number) 0
Adding number conversion cast (unumber) 0 in (bool~) strlen::$0 ← (number) 0 != *((byte*) strlen::str#2)
Adding number conversion cast (unumber) 0 in *((const nomodify byte*) kbhit::CONIO_CIA1_PORT_A) ← (number) 0
Adding number conversion cast (unumber) $19 in (bool~) clrscr::$0 ← (byte) clrscr::l#2 < (number) $19
Adding number conversion cast (unumber) 0 in (byte) conio_cursor_x ← (number) 0
Adding number conversion cast (unumber) 0 in (byte) conio_cursor_y ← (number) 0
@ -1356,7 +1357,6 @@ Adding number conversion cast (unumber) $28 in (byte*~) cscroll::$8 ← (byte*)
Adding number conversion cast (unumber) 0 in (byte) gotoxy::x#1 ← (number) 0
Adding number conversion cast (unumber) 0 in (byte) gotoxy::y#1 ← (number) 0
Adding number conversion cast (unumber) 0 in (bool~) cputs::$1 ← (number) 0 != (byte) cputs::c#1
Adding number conversion cast (unumber) 0 in *((const nomodify byte*) CONIO_CIA1_PORT_A) ← (number) 0
Adding number conversion cast (unumber) $17 in *((const nomodify byte*) VIC_MEMORY) ← (number) $17
Adding number conversion cast (unumber) 0 in (bool~) main::$5 ← (number) 0 != (byte~) main::$3
Adding number conversion cast (unumber) 0 in (byte) cputcxy::x#0 ← (number) 0
@ -1385,6 +1385,7 @@ Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte*) memcpy::src#0 ← (byte*)(void*) memcpy::source#2
Inlining cast (byte*) memcpy::dst#0 ← (byte*)(void*) memcpy::destination#2
Inlining cast (byte*) memset::dst#0 ← (byte*)(void*) memset::str#3
Inlining cast *((const nomodify byte*) kbhit::CONIO_CIA1_PORT_A) ← (unumber)(number) 0
Inlining cast (byte) conio_cursor_x ← (unumber)(number) 0
Inlining cast (byte) conio_cursor_y ← (unumber)(number) 0
Inlining cast (byte) gotoxy::y#0 ← (unumber)(number) 0
@ -1399,7 +1400,6 @@ Inlining cast (word) memset::num#0 ← (unumber)(number) $28
Inlining cast (word) memset::num#1 ← (unumber)(number) $28
Inlining cast (byte) gotoxy::x#1 ← (unumber)(number) 0
Inlining cast (byte) gotoxy::y#1 ← (unumber)(number) 0
Inlining cast *((const nomodify byte*) CONIO_CIA1_PORT_A) ← (unumber)(number) 0
Inlining cast *((const nomodify byte*) VIC_MEMORY) ← (unumber)(number) $17
Inlining cast (byte) cputcxy::x#0 ← (unumber)(number) 0
Inlining cast (byte) scroll::onoff#0 ← (unumber)(number) 0
@ -1424,6 +1424,7 @@ Simplifying constant pointer cast (byte*) 56321
Simplifying constant pointer cast (byte*) 53272
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Simplifying constant integer cast $19
Simplifying constant integer cast 0
Simplifying constant integer cast 0
@ -1454,7 +1455,6 @@ Simplifying constant integer cast $28
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Simplifying constant integer cast $17
Simplifying constant integer cast 0
Simplifying constant integer cast 0
@ -1478,6 +1478,7 @@ Simplifying constant integer cast 1
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) $19
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 0
@ -1508,7 +1509,6 @@ Finalized unsigned number type (byte) $28
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) $17
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 0
@ -1538,10 +1538,10 @@ Inferred type updated to byte in (unumber~) MakeNiceScreen::$7 ← (volatile byt
Inferred type updated to byte in (unumber~) MakeNiceScreen::$12 ← (volatile byte) XSize - (byte) 2
Inferred type updated to byte in (unumber~) MakeNiceScreen::$15 ← (volatile byte) XSize - (byte) 1
Inversing boolean not [20] (bool~) memset::$1 ← (word) memset::num#2 <= (byte) 0 from [19] (bool~) memset::$0 ← (word) memset::num#2 > (byte) 0
Inversing boolean not [84] (bool~) gotoxy::$1 ← (byte) gotoxy::y#6 <= (byte) $19 from [83] (bool~) gotoxy::$0 ← (byte) gotoxy::y#6 > (byte) $19
Inversing boolean not [88] (bool~) gotoxy::$3 ← (byte) gotoxy::x#6 < (byte) $28 from [87] (bool~) gotoxy::$2 ← (byte) gotoxy::x#6 >= (byte) $28
Inversing boolean not [121] (bool~) cputc::$2 ← (byte) conio_cursor_x != (byte) $28 from [120] (bool~) cputc::$1 ← (byte) conio_cursor_x == (byte) $28
Inversing boolean not [138] (bool~) cscroll::$1 ← (byte) conio_cursor_y != (byte) $19 from [137] (bool~) cscroll::$0 ← (byte) conio_cursor_y == (byte) $19
Inversing boolean not [90] (bool~) gotoxy::$1 ← (byte) gotoxy::y#6 <= (byte) $19 from [89] (bool~) gotoxy::$0 ← (byte) gotoxy::y#6 > (byte) $19
Inversing boolean not [94] (bool~) gotoxy::$3 ← (byte) gotoxy::x#6 < (byte) $28 from [93] (bool~) gotoxy::$2 ← (byte) gotoxy::x#6 >= (byte) $28
Inversing boolean not [127] (bool~) cputc::$2 ← (byte) conio_cursor_x != (byte) $28 from [126] (bool~) cputc::$1 ← (byte) conio_cursor_x == (byte) $28
Inversing boolean not [144] (bool~) cscroll::$1 ← (byte) conio_cursor_y != (byte) $19 from [143] (bool~) cscroll::$0 ← (byte) conio_cursor_y == (byte) $19
Inversing boolean not [289] (bool~) main::$4 ← (byte) 0 == (byte~) main::$3 from [288] (bool~) main::$5 ← (byte) 0 != (byte~) main::$3
Successful SSA optimization Pass2UnaryNotSimplification
Alias candidate removed (volatile)conio_cursor_text = gotoxy::$6 cputln::$1 cscroll::$7
@ -1562,6 +1562,7 @@ Alias memset::end#1 = memset::end#2
Alias memset::str#5 = memset::str#6
Alias strlen::len#2 = strlen::len#4 strlen::len#3 strlen::return#0 strlen::return#3 strlen::return#1
Alias strlen::str#2 = strlen::str#3
Alias kbhit::return#0 = kbhit::$0 kbhit::return#3 kbhit::return#1
Alias clrscr::line_text#5 = clrscr::line_text#6
Alias clrscr::line_cols#5 = clrscr::line_cols#6
Alias clrscr::l#2 = clrscr::l#5
@ -1589,7 +1590,6 @@ Alias cvlinexy::length#2 = cvlinexy::length#3
Alias textcolor::return#0 = textcolor::old#0 textcolor::return#3 textcolor::return#1
Alias bgcolor::return#0 = bgcolor::old#0 bgcolor::return#3 bgcolor::return#1
Alias bordercolor::return#0 = bordercolor::old#0 bordercolor::return#3 bordercolor::return#1
Alias kbhit::return#0 = kbhit::$0 kbhit::return#3 kbhit::return#1
Alias cursor::return#0 = cursor::old#0 cursor::return#3 cursor::return#1
Alias scroll::return#0 = scroll::old#0 scroll::return#3 scroll::return#1
Alias kbhit::return#2 = kbhit::return#4
@ -1642,23 +1642,23 @@ Simple Condition (bool~) memcpy::$1 [7] if((byte*) memcpy::src#2!=(byte*) memcpy
Simple Condition (bool~) memset::$1 [14] if((word) memset::num#2<=(byte) 0) goto memset::@1
Simple Condition (bool~) memset::$3 [21] if((byte*) memset::dst#2!=(byte*) memset::end#0) goto memset::@4
Simple Condition (bool~) strlen::$0 [29] if((byte) 0!=*((byte*) strlen::str#2)) goto strlen::@2
Simple Condition (bool~) clrscr::$0 [45] if((byte) clrscr::l#2<(byte) $19) goto clrscr::@2
Simple Condition (bool~) clrscr::$1 [53] if((byte) clrscr::c#2<(byte) $28) goto clrscr::@5
Simple Condition (bool~) gotoxy::$1 [63] if((byte) gotoxy::y#6<=(byte) $19) goto gotoxy::@1
Simple Condition (bool~) gotoxy::$3 [66] if((byte) gotoxy::x#6<(byte) $28) goto gotoxy::@2
Simple Condition (bool~) cputc::$0 [86] if((byte) cputc::c#8==(byte) '
Simple Condition (bool~) clrscr::$0 [48] if((byte) clrscr::l#2<(byte) $19) goto clrscr::@2
Simple Condition (bool~) clrscr::$1 [56] if((byte) clrscr::c#2<(byte) $28) goto clrscr::@5
Simple Condition (bool~) gotoxy::$1 [66] if((byte) gotoxy::y#6<=(byte) $19) goto gotoxy::@1
Simple Condition (bool~) gotoxy::$3 [69] if((byte) gotoxy::x#6<(byte) $28) goto gotoxy::@2
Simple Condition (bool~) cputc::$0 [89] if((byte) cputc::c#8==(byte) '
') goto cputc::@1
Simple Condition (bool~) cputc::$2 [94] if((byte) conio_cursor_x!=(byte) $28) goto cputc::@return
Simple Condition (bool~) cscroll::$1 [109] if((byte) conio_cursor_y!=(byte) $19) goto cscroll::@return
Simple Condition (bool~) cscroll::$9 [111] if((byte) 0!=(byte) conio_scroll_enable) goto cscroll::@3
Simple Condition (bool~) cputs::$1 [147] if((byte) 0!=(byte) cputs::c#1) goto cputs::@2
Simple Condition (bool~) chline::$0 [169] if((byte) chline::i#2<(byte) chline::length#4) goto chline::@2
Simple Condition (bool~) cvline::$0 [180] if((byte) cvline::i#2<(byte) cvline::length#0) goto cvline::@2
Simple Condition (bool~) cputc::$2 [97] if((byte) conio_cursor_x!=(byte) $28) goto cputc::@return
Simple Condition (bool~) cscroll::$1 [112] if((byte) conio_cursor_y!=(byte) $19) goto cscroll::@return
Simple Condition (bool~) cscroll::$9 [114] if((byte) 0!=(byte) conio_scroll_enable) goto cscroll::@3
Simple Condition (bool~) cputs::$1 [150] if((byte) 0!=(byte) cputs::c#1) goto cputs::@2
Simple Condition (bool~) chline::$0 [172] if((byte) chline::i#2<(byte) chline::length#4) goto chline::@2
Simple Condition (bool~) cvline::$0 [183] if((byte) cvline::i#2<(byte) cvline::length#0) goto cvline::@2
Simple Condition (bool~) main::$4 [230] if((byte) 0==(byte~) main::$3) goto main::@1
Simple Condition (bool~) MakeNiceScreen::$21 [294] if((byte) MakeNiceScreen::I#3<(byte~) MakeNiceScreen::$20) goto MakeNiceScreen::@2
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant right-side identified [114] (word) memcpy::num#0 ← (unumber)(number) $19*(number) $28-(number) $28
Constant right-side identified [119] (word) memcpy::num#1 ← (unumber)(number) $19*(number) $28-(number) $28
Constant right-side identified [117] (word) memcpy::num#0 ← (unumber)(number) $19*(number) $28-(number) $28
Constant right-side identified [122] (word) memcpy::num#1 ← (unumber)(number) $19*(number) $28-(number) $28
Constant right-side identified [291] (byte~) MakeNiceScreen::$19 ← sizeof (const struct $0*) MakeNiceScreen::Text
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const word) strlen::len#0 = 0
@ -1716,16 +1716,16 @@ Constant (const byte) MakeNiceScreen::I#1 = 0
Constant (const to_nomodify struct $0*) MakeNiceScreen::T#1 = MakeNiceScreen::Text
Constant (const byte) MakeNiceScreen::$19 = sizeof MakeNiceScreen::Text
Successful SSA optimization Pass2ConstantIdentification
Rewriting conditional comparison [63] if((byte) gotoxy::y#6<=(byte) $19) goto gotoxy::@1
Rewriting conditional comparison [66] if((byte) gotoxy::y#6<=(byte) $19) goto gotoxy::@1
Converting *(pointer+n) to pointer[n] [308] (byte) cputsxy::y#0 ← *((byte*~) MakeNiceScreen::$30) -- *(MakeNiceScreen::$37 + OFFSET_STRUCT_$0_Y)
Successful SSA optimization Pass2InlineDerefIdx
Simplifying expression containing zero MakeNiceScreen::$37 in [304] (byte*~) MakeNiceScreen::$30 ← (byte*~) MakeNiceScreen::$37 + (const byte) OFFSET_STRUCT_$0_Y
Simplifying expression containing zero MakeNiceScreen::$37 in [308] (byte) cputsxy::y#0 ← *((byte*~) MakeNiceScreen::$37 + (const byte) OFFSET_STRUCT_$0_Y)
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused variable (void*) memcpy::return#2 and assignment [91] (void*) memcpy::return#2 ← (void*) memcpy::destination#2
Eliminating unused variable (void*) memcpy::return#3 and assignment [93] (void*) memcpy::return#3 ← (void*) memcpy::destination#2
Eliminating unused variable (void*) memset::return#2 and assignment [95] (void*) memset::return#2 ← (void*) memset::str#3
Eliminating unused variable (void*) memset::return#3 and assignment [98] (void*) memset::return#3 ← (void*) memset::str#3
Eliminating unused variable (void*) memcpy::return#2 and assignment [94] (void*) memcpy::return#2 ← (void*) memcpy::destination#2
Eliminating unused variable (void*) memcpy::return#3 and assignment [96] (void*) memcpy::return#3 ← (void*) memcpy::destination#2
Eliminating unused variable (void*) memset::return#2 and assignment [98] (void*) memset::return#2 ← (void*) memset::str#3
Eliminating unused variable (void*) memset::return#3 and assignment [101] (void*) memset::return#3 ← (void*) memset::str#3
Eliminating unused variable (byte) scroll::return#2 and assignment [187] (byte) scroll::return#2 ← (byte) scroll::return#0
Eliminating unused variable (byte) textcolor::return#2 and assignment [189] (byte) textcolor::return#2 ← (byte) textcolor::return#0
Eliminating unused variable (byte) bordercolor::return#2 and assignment [191] (byte) bordercolor::return#2 ← (byte) bordercolor::return#0
@ -1738,13 +1738,13 @@ Eliminating unused constant (const byte) MakeNiceScreen::I#0
Eliminating unused constant (const byte) MakeNiceScreen::X#0
Eliminating unused constant (const byte) OFFSET_STRUCT_$0_Y
Successful SSA optimization PassNEliminateUnusedVars
Eliminating unused variable (byte) textcolor::return#0 and assignment [146] (byte) textcolor::return#0 ← (byte) conio_textcolor
Eliminating unused variable (byte) bgcolor::return#0 and assignment [149] (byte) bgcolor::return#0 ← *((const nomodify byte*) CONIO_BGCOLOR)
Eliminating unused variable (byte) bordercolor::return#0 and assignment [152] (byte) bordercolor::return#0 ← *((const nomodify byte*) CONIO_BORDERCOLOR)
Eliminating unused variable (byte) textcolor::return#0 and assignment [149] (byte) textcolor::return#0 ← (byte) conio_textcolor
Eliminating unused variable (byte) bgcolor::return#0 and assignment [152] (byte) bgcolor::return#0 ← *((const nomodify byte*) CONIO_BGCOLOR)
Eliminating unused variable (byte) bordercolor::return#0 and assignment [155] (byte) bordercolor::return#0 ← *((const nomodify byte*) CONIO_BORDERCOLOR)
Eliminating unused variable (byte) cursor::return#0 and assignment [158] (byte) cursor::return#0 ← (byte) conio_display_cursor
Eliminating unused variable (byte) scroll::return#0 and assignment [161] (byte) scroll::return#0 ← (byte) conio_scroll_enable
Successful SSA optimization PassNEliminateUnusedVars
Eliminating unused variable (byte) conio_display_cursor and assignment [31] (byte) conio_display_cursor ← (byte) 0
Eliminating unused variable (byte) conio_display_cursor and assignment [34] (byte) conio_display_cursor ← (byte) 0
Eliminating unused variable conio_display_cursor(null) and assignment [155] conio_display_cursor(null) ← (const byte) cursor::onoff#0
Successful SSA optimization PassNEliminateUnusedVars
Eliminating unused constant (const byte) cursor::onoff#0
@ -1784,7 +1784,7 @@ Inlining Noop Cast [196] (byte*~) MakeNiceScreen::$33 ← (byte*)(to_nomodify st
Inlining Noop Cast [204] (byte*~) MakeNiceScreen::$37 ← (byte*)(to_nomodify struct $0*) MakeNiceScreen::T#3 keeping MakeNiceScreen::T#3
Inlining Noop Cast [205] (byte*~) MakeNiceScreen::$38 ← (byte*)(to_nomodify struct $0*) MakeNiceScreen::T#3 keeping MakeNiceScreen::T#3
Successful SSA optimization Pass2NopCastInlining
Rewriting multiplication to use shift and addition[55] (word~) gotoxy::$4 ← (word~) gotoxy::$8 * (byte) $28
Rewriting multiplication to use shift and addition[58] (word~) gotoxy::$4 ← (word~) gotoxy::$8 * (byte) $28
Inlining constant with var siblings (const void*) memcpy::destination#0
Inlining constant with var siblings (const void*) memcpy::source#0
Inlining constant with var siblings (const word) memcpy::num#0
@ -2156,8 +2156,8 @@ clrscr::@4: scope:[clrscr] from clrscr::@3
(byte()) kbhit()
kbhit: scope:[kbhit] from main::@1
[40] *((const nomodify byte*) CONIO_CIA1_PORT_A) ← (byte) 0
[41] (byte) kbhit::return#0 ← ~ *((const nomodify byte*) CONIO_CIA1_PORT_B)
[40] *((const nomodify byte*) kbhit::CONIO_CIA1_PORT_A) ← (byte) 0
[41] (byte) kbhit::return#0 ← ~ *((const nomodify byte*) kbhit::CONIO_CIA1_PORT_B)
to:kbhit::@return
kbhit::@return: scope:[kbhit] from kbhit
[42] return
@ -3039,10 +3039,6 @@ Target platform is c64basic / MOS6502X
.label CONIO_BGCOLOR = $d021
// The border color register address
.label CONIO_BORDERCOLOR = $d020
// CIA#1 Port A: keyboard matrix columns and joystick #2
.label CONIO_CIA1_PORT_A = $dc00
// CIA#1 Port B: keyboard matrix rows and joystick #1.
.label CONIO_CIA1_PORT_B = $dc01
.label VIC_MEMORY = $d018
.label conio_cursor_x = $29
.label conio_cursor_y = $2a
@ -3272,12 +3268,16 @@ clrscr: {
// kbhit
// Return true if there's a key waiting, return false if not
kbhit: {
// CIA#1 Port A: keyboard matrix columns and joystick #2
.label CONIO_CIA1_PORT_A = $dc00
// CIA#1 Port B: keyboard matrix rows and joystick #1.
.label CONIO_CIA1_PORT_B = $dc01
.label return = $35
.label return_1 = $33
// [40] *((const nomodify byte*) CONIO_CIA1_PORT_A) ← (byte) 0 -- _deref_pbuc1=vbuc2
// [40] *((const nomodify byte*) kbhit::CONIO_CIA1_PORT_A) ← (byte) 0 -- _deref_pbuc1=vbuc2
lda #0
sta CONIO_CIA1_PORT_A
// [41] (byte) kbhit::return#0 ← ~ *((const nomodify byte*) CONIO_CIA1_PORT_B) -- vbuz1=_bnot__deref_pbuc1
// [41] (byte) kbhit::return#0 ← ~ *((const nomodify byte*) kbhit::CONIO_CIA1_PORT_B) -- vbuz1=_bnot__deref_pbuc1
lda CONIO_CIA1_PORT_B
eor #$ff
sta.z return
@ -4580,8 +4580,8 @@ Statement [35] (byte*) clrscr::line_cols#1 ← (byte*) clrscr::line_cols#5 + (by
Statement [37] *((byte*) clrscr::line_text#5 + (byte) clrscr::c#2) ← (byte) ' ' [ conio_textcolor clrscr::l#2 clrscr::line_text#5 clrscr::line_cols#5 clrscr::c#2 ] ( main:10::clrscr:22 [ conio_textcolor clrscr::l#2 clrscr::line_text#5 clrscr::line_cols#5 clrscr::c#2 ] { } main:10::MakeNiceScreen:15::clrscr:52 [ conio_scroll_enable XSize conio_textcolor clrscr::l#2 clrscr::line_text#5 clrscr::line_cols#5 clrscr::c#2 ] { } ) always clobbers reg byte a
Removing always clobbered register reg byte a as potential for zp[1]:7 [ clrscr::c#2 clrscr::c#1 ]
Statement [38] *((byte*) clrscr::line_cols#5 + (byte) clrscr::c#2) ← (byte) conio_textcolor [ conio_textcolor clrscr::l#2 clrscr::line_text#5 clrscr::line_cols#5 clrscr::c#2 ] ( main:10::clrscr:22 [ conio_textcolor clrscr::l#2 clrscr::line_text#5 clrscr::line_cols#5 clrscr::c#2 ] { } main:10::MakeNiceScreen:15::clrscr:52 [ conio_scroll_enable XSize conio_textcolor clrscr::l#2 clrscr::line_text#5 clrscr::line_cols#5 clrscr::c#2 ] { } ) always clobbers reg byte a
Statement [40] *((const nomodify byte*) CONIO_CIA1_PORT_A) ← (byte) 0 [ ] ( main:10::kbhit:17 [ conio_textcolor ] { { kbhit::return#0 = kbhit::return#2 } } ) always clobbers reg byte a
Statement [41] (byte) kbhit::return#0 ← ~ *((const nomodify byte*) CONIO_CIA1_PORT_B) [ kbhit::return#0 ] ( main:10::kbhit:17 [ conio_textcolor kbhit::return#0 ] { { kbhit::return#0 = kbhit::return#2 } } ) always clobbers reg byte a
Statement [40] *((const nomodify byte*) kbhit::CONIO_CIA1_PORT_A) ← (byte) 0 [ ] ( main:10::kbhit:17 [ conio_textcolor ] { { kbhit::return#0 = kbhit::return#2 } } ) always clobbers reg byte a
Statement [41] (byte) kbhit::return#0 ← ~ *((const nomodify byte*) kbhit::CONIO_CIA1_PORT_B) [ kbhit::return#0 ] ( main:10::kbhit:17 [ conio_textcolor kbhit::return#0 ] { { kbhit::return#0 = kbhit::return#2 } } ) always clobbers reg byte a
Statement [78] (byte*) strlen::str#1 ← (byte*)(to_nomodify struct $0*) MakeNiceScreen::T#3 + (byte) 1 [ conio_textcolor conio_scroll_enable XSize MakeNiceScreen::I#3 MakeNiceScreen::T#3 strlen::str#1 ] ( main:10::MakeNiceScreen:15 [ conio_textcolor conio_scroll_enable XSize MakeNiceScreen::I#3 MakeNiceScreen::T#3 strlen::str#1 ] { { strlen::return#2 = strlen::len#2 } } ) always clobbers reg byte a
Removing always clobbered register reg byte a as potential for zp[1]:8 [ MakeNiceScreen::I#3 MakeNiceScreen::I#2 ]
Statement [80] (word) strlen::return#2 ← (word) strlen::len#2 [ conio_textcolor conio_scroll_enable XSize MakeNiceScreen::I#3 MakeNiceScreen::T#3 strlen::return#2 ] ( main:10::MakeNiceScreen:15 [ conio_textcolor conio_scroll_enable XSize MakeNiceScreen::I#3 MakeNiceScreen::T#3 strlen::return#2 ] { { strlen::return#2 = strlen::len#2 } } ) always clobbers reg byte a
@ -4670,8 +4670,8 @@ Statement [34] (byte*) clrscr::line_text#1 ← (byte*) clrscr::line_text#5 + (by
Statement [35] (byte*) clrscr::line_cols#1 ← (byte*) clrscr::line_cols#5 + (byte) $28 [ conio_textcolor clrscr::l#2 clrscr::line_text#1 clrscr::line_cols#1 ] ( main:10::clrscr:22 [ conio_textcolor clrscr::l#2 clrscr::line_text#1 clrscr::line_cols#1 ] { } main:10::MakeNiceScreen:15::clrscr:52 [ conio_scroll_enable XSize conio_textcolor clrscr::l#2 clrscr::line_text#1 clrscr::line_cols#1 ] { } ) always clobbers reg byte a
Statement [37] *((byte*) clrscr::line_text#5 + (byte) clrscr::c#2) ← (byte) ' ' [ conio_textcolor clrscr::l#2 clrscr::line_text#5 clrscr::line_cols#5 clrscr::c#2 ] ( main:10::clrscr:22 [ conio_textcolor clrscr::l#2 clrscr::line_text#5 clrscr::line_cols#5 clrscr::c#2 ] { } main:10::MakeNiceScreen:15::clrscr:52 [ conio_scroll_enable XSize conio_textcolor clrscr::l#2 clrscr::line_text#5 clrscr::line_cols#5 clrscr::c#2 ] { } ) always clobbers reg byte a
Statement [38] *((byte*) clrscr::line_cols#5 + (byte) clrscr::c#2) ← (byte) conio_textcolor [ conio_textcolor clrscr::l#2 clrscr::line_text#5 clrscr::line_cols#5 clrscr::c#2 ] ( main:10::clrscr:22 [ conio_textcolor clrscr::l#2 clrscr::line_text#5 clrscr::line_cols#5 clrscr::c#2 ] { } main:10::MakeNiceScreen:15::clrscr:52 [ conio_scroll_enable XSize conio_textcolor clrscr::l#2 clrscr::line_text#5 clrscr::line_cols#5 clrscr::c#2 ] { } ) always clobbers reg byte a
Statement [40] *((const nomodify byte*) CONIO_CIA1_PORT_A) ← (byte) 0 [ ] ( main:10::kbhit:17 [ conio_textcolor ] { { kbhit::return#0 = kbhit::return#2 } } ) always clobbers reg byte a
Statement [41] (byte) kbhit::return#0 ← ~ *((const nomodify byte*) CONIO_CIA1_PORT_B) [ kbhit::return#0 ] ( main:10::kbhit:17 [ conio_textcolor kbhit::return#0 ] { { kbhit::return#0 = kbhit::return#2 } } ) always clobbers reg byte a
Statement [40] *((const nomodify byte*) kbhit::CONIO_CIA1_PORT_A) ← (byte) 0 [ ] ( main:10::kbhit:17 [ conio_textcolor ] { { kbhit::return#0 = kbhit::return#2 } } ) always clobbers reg byte a
Statement [41] (byte) kbhit::return#0 ← ~ *((const nomodify byte*) kbhit::CONIO_CIA1_PORT_B) [ kbhit::return#0 ] ( main:10::kbhit:17 [ conio_textcolor kbhit::return#0 ] { { kbhit::return#0 = kbhit::return#2 } } ) always clobbers reg byte a
Statement [78] (byte*) strlen::str#1 ← (byte*)(to_nomodify struct $0*) MakeNiceScreen::T#3 + (byte) 1 [ conio_textcolor conio_scroll_enable XSize MakeNiceScreen::I#3 MakeNiceScreen::T#3 strlen::str#1 ] ( main:10::MakeNiceScreen:15 [ conio_textcolor conio_scroll_enable XSize MakeNiceScreen::I#3 MakeNiceScreen::T#3 strlen::str#1 ] { { strlen::return#2 = strlen::len#2 } } ) always clobbers reg byte a
Statement [80] (word) strlen::return#2 ← (word) strlen::len#2 [ conio_textcolor conio_scroll_enable XSize MakeNiceScreen::I#3 MakeNiceScreen::T#3 strlen::return#2 ] ( main:10::MakeNiceScreen:15 [ conio_textcolor conio_scroll_enable XSize MakeNiceScreen::I#3 MakeNiceScreen::T#3 strlen::return#2 ] { { strlen::return#2 = strlen::len#2 } } ) always clobbers reg byte a
Statement [81] (word~) MakeNiceScreen::$22 ← (word) strlen::return#2 [ conio_textcolor conio_scroll_enable XSize MakeNiceScreen::I#3 MakeNiceScreen::T#3 MakeNiceScreen::$22 ] ( main:10::MakeNiceScreen:15 [ conio_textcolor conio_scroll_enable XSize MakeNiceScreen::I#3 MakeNiceScreen::T#3 MakeNiceScreen::$22 ] { { cputsxy::x#0 = MakeNiceScreen::X#1 } } ) always clobbers reg byte a
@ -4950,10 +4950,6 @@ ASSEMBLER BEFORE OPTIMIZATION
.label CONIO_BGCOLOR = $d021
// The border color register address
.label CONIO_BORDERCOLOR = $d020
// CIA#1 Port A: keyboard matrix columns and joystick #2
.label CONIO_CIA1_PORT_A = $dc00
// CIA#1 Port B: keyboard matrix rows and joystick #1.
.label CONIO_CIA1_PORT_B = $dc01
.label VIC_MEMORY = $d018
.label conio_cursor_x = 9
.label conio_cursor_y = $a
@ -5169,10 +5165,14 @@ clrscr: {
// kbhit
// Return true if there's a key waiting, return false if not
kbhit: {
// [40] *((const nomodify byte*) CONIO_CIA1_PORT_A) ← (byte) 0 -- _deref_pbuc1=vbuc2
// CIA#1 Port A: keyboard matrix columns and joystick #2
.label CONIO_CIA1_PORT_A = $dc00
// CIA#1 Port B: keyboard matrix rows and joystick #1.
.label CONIO_CIA1_PORT_B = $dc01
// [40] *((const nomodify byte*) kbhit::CONIO_CIA1_PORT_A) ← (byte) 0 -- _deref_pbuc1=vbuc2
lda #0
sta CONIO_CIA1_PORT_A
// [41] (byte) kbhit::return#0 ← ~ *((const nomodify byte*) CONIO_CIA1_PORT_B) -- vbuaa=_bnot__deref_pbuc1
// [41] (byte) kbhit::return#0 ← ~ *((const nomodify byte*) kbhit::CONIO_CIA1_PORT_B) -- vbuaa=_bnot__deref_pbuc1
lda CONIO_CIA1_PORT_B
eor #$ff
jmp __breturn
@ -6624,8 +6624,6 @@ FINAL SYMBOL TABLE
(const nomodify byte) COLOR_GRAY3 = (byte) $f
(const nomodify byte*) CONIO_BGCOLOR = (byte*) 53281
(const nomodify byte*) CONIO_BORDERCOLOR = (byte*) 53280
(const nomodify byte*) CONIO_CIA1_PORT_A = (byte*) 56320
(const nomodify byte*) CONIO_CIA1_PORT_B = (byte*) 56321
(const nomodify byte*) CONIO_SCREEN_COLORS = (byte*) 55296
(const nomodify byte*) CONIO_SCREEN_TEXT = (byte*) 1024
(const nomodify byte) CONIO_TEXTCOLOR_DEFAULT = (byte) $e
@ -6831,6 +6829,8 @@ FINAL SYMBOL TABLE
(byte) gotoxy::y#7 reg byte a 3.3333333333666668E10
(byte()) kbhit()
(label) kbhit::@return
(const nomodify byte*) kbhit::CONIO_CIA1_PORT_A = (byte*) 56320
(const nomodify byte*) kbhit::CONIO_CIA1_PORT_B = (byte*) 56321
(byte) kbhit::return
(byte) kbhit::return#0 reg byte a 367.33333333333337
(byte) kbhit::return#2 reg byte a 202.0
@ -6991,10 +6991,6 @@ Score: 114584
.label CONIO_BGCOLOR = $d021
// The border color register address
.label CONIO_BORDERCOLOR = $d020
// CIA#1 Port A: keyboard matrix columns and joystick #2
.label CONIO_CIA1_PORT_A = $dc00
// CIA#1 Port B: keyboard matrix rows and joystick #1.
.label CONIO_CIA1_PORT_B = $dc01
.label VIC_MEMORY = $d018
.label conio_cursor_x = 9
.label conio_cursor_y = $a
@ -7200,12 +7196,16 @@ clrscr: {
// kbhit
// Return true if there's a key waiting, return false if not
kbhit: {
// CIA#1 Port A: keyboard matrix columns and joystick #2
.label CONIO_CIA1_PORT_A = $dc00
// CIA#1 Port B: keyboard matrix rows and joystick #1.
.label CONIO_CIA1_PORT_B = $dc01
// *CONIO_CIA1_PORT_A = 0
// [40] *((const nomodify byte*) CONIO_CIA1_PORT_A) ← (byte) 0 -- _deref_pbuc1=vbuc2
// [40] *((const nomodify byte*) kbhit::CONIO_CIA1_PORT_A) ← (byte) 0 -- _deref_pbuc1=vbuc2
lda #0
sta CONIO_CIA1_PORT_A
// ~*CONIO_CIA1_PORT_B
// [41] (byte) kbhit::return#0 ← ~ *((const nomodify byte*) CONIO_CIA1_PORT_B) -- vbuaa=_bnot__deref_pbuc1
// [41] (byte) kbhit::return#0 ← ~ *((const nomodify byte*) kbhit::CONIO_CIA1_PORT_B) -- vbuaa=_bnot__deref_pbuc1
lda CONIO_CIA1_PORT_B
eor #$ff
// kbhit::@return

View File

@ -17,8 +17,6 @@
(const nomodify byte) COLOR_GRAY3 = (byte) $f
(const nomodify byte*) CONIO_BGCOLOR = (byte*) 53281
(const nomodify byte*) CONIO_BORDERCOLOR = (byte*) 53280
(const nomodify byte*) CONIO_CIA1_PORT_A = (byte*) 56320
(const nomodify byte*) CONIO_CIA1_PORT_B = (byte*) 56321
(const nomodify byte*) CONIO_SCREEN_COLORS = (byte*) 55296
(const nomodify byte*) CONIO_SCREEN_TEXT = (byte*) 1024
(const nomodify byte) CONIO_TEXTCOLOR_DEFAULT = (byte) $e
@ -224,6 +222,8 @@
(byte) gotoxy::y#7 reg byte a 3.3333333333666668E10
(byte()) kbhit()
(label) kbhit::@return
(const nomodify byte*) kbhit::CONIO_CIA1_PORT_A = (byte*) 56320
(const nomodify byte*) kbhit::CONIO_CIA1_PORT_B = (byte*) 56321
(byte) kbhit::return
(byte) kbhit::return#0 reg byte a 367.33333333333337
(byte) kbhit::return#2 reg byte a 202.0

View File

@ -279,7 +279,7 @@ SYMBOL TABLE SSA
(byte) MOS7360_TED::HSCAN_POS
(byte) MOS7360_TED::IRQ_MASK
(byte) MOS7360_TED::IRQ_REQUEST
(byte) MOS7360_TED::KEYBOARD_INPUT
(volatile byte) MOS7360_TED::KEYBOARD_INPUT loadstore
(byte) MOS7360_TED::MEMORY1
(byte) MOS7360_TED::MEMORY2
(byte) MOS7360_TED::MEMORY3
@ -964,7 +964,7 @@ VARIABLE REGISTER WEIGHTS
(byte) MOS7360_TED::HSCAN_POS
(byte) MOS7360_TED::IRQ_MASK
(byte) MOS7360_TED::IRQ_REQUEST
(byte) MOS7360_TED::KEYBOARD_INPUT
(volatile byte) MOS7360_TED::KEYBOARD_INPUT loadstore
(byte) MOS7360_TED::MEMORY1
(byte) MOS7360_TED::MEMORY2
(byte) MOS7360_TED::MEMORY3
@ -2369,7 +2369,7 @@ FINAL SYMBOL TABLE
(byte) MOS7360_TED::HSCAN_POS
(byte) MOS7360_TED::IRQ_MASK
(byte) MOS7360_TED::IRQ_REQUEST
(byte) MOS7360_TED::KEYBOARD_INPUT
(volatile byte) MOS7360_TED::KEYBOARD_INPUT loadstore
(byte) MOS7360_TED::MEMORY1
(byte) MOS7360_TED::MEMORY2
(byte) MOS7360_TED::MEMORY3

View File

@ -36,7 +36,7 @@
(byte) MOS7360_TED::HSCAN_POS
(byte) MOS7360_TED::IRQ_MASK
(byte) MOS7360_TED::IRQ_REQUEST
(byte) MOS7360_TED::KEYBOARD_INPUT
(volatile byte) MOS7360_TED::KEYBOARD_INPUT loadstore
(byte) MOS7360_TED::MEMORY1
(byte) MOS7360_TED::MEMORY2
(byte) MOS7360_TED::MEMORY3

View File

@ -0,0 +1,35 @@
// Test implementation of kbhit() for Plus/4
.pc = $1001 "Basic"
:BasicUpstart(main)
.pc = $100d "Program"
.const OFFSET_STRUCT_MOS7360_TED_KEYBOARD_INPUT = 8
// Keyboard Port PIO (P0-P7)
// The input latch is part of the TED.
.label KEYBOARD_PORT = $fd30
// The TED chip controlling video and sound on the Plus/4 and Commodore 16
.label TED = $ff00
main: {
__b1:
// kbhit()
jsr kbhit
// while(!kbhit())
cmp #0
beq __b1
// }
rts
}
// Return true if there's a key waiting, return false if not
kbhit: {
// KEYBOARD_PORT->PORT = 0x00
// Read all keyboard matrix rows
lda #0
sta KEYBOARD_PORT
// TED->KEYBOARD_INPUT = 0
// Write to the keyboard input to latch the matrix column values
sta TED+OFFSET_STRUCT_MOS7360_TED_KEYBOARD_INPUT
// ~TED->KEYBOARD_INPUT
eor #$ff
// }
rts
}

View File

@ -0,0 +1,36 @@
@begin: scope:[] from
[0] phi()
to:@1
@1: scope:[] from @begin
[1] phi()
[2] call main
to:@end
@end: scope:[] from @1
[3] phi()
(void()) main()
main: scope:[main] from @1
[4] phi()
to:main::@1
main::@1: scope:[main] from main main::@2
[5] phi()
[6] call kbhit
[7] (byte) kbhit::return#0 ← (byte) kbhit::return#1
to:main::@2
main::@2: scope:[main] from main::@1
[8] (byte~) main::$0 ← (byte) kbhit::return#0
[9] if((byte) 0==(byte~) main::$0) goto main::@1
to:main::@return
main::@return: scope:[main] from main::@2
[10] return
to:@return
(byte()) kbhit()
kbhit: scope:[kbhit] from main::@1
[11] *((byte*)(const nomodify struct MOS6529_PIO*) KEYBOARD_PORT) ← (byte) 0
[12] *((byte*)(const nomodify struct MOS7360_TED*) TED+(const byte) OFFSET_STRUCT_MOS7360_TED_KEYBOARD_INPUT) ← (byte) 0
[13] (byte) kbhit::return#1 ← ~ *((byte*)(const nomodify struct MOS7360_TED*) TED+(const byte) OFFSET_STRUCT_MOS7360_TED_KEYBOARD_INPUT)
to:kbhit::@return
kbhit::@return: scope:[kbhit] from kbhit
[14] return
to:@return

View File

@ -0,0 +1,622 @@
Fixing struct type size struct MOS7360_TED to 63
Fixing struct type SIZE_OF struct MOS7360_TED to 63
Fixing struct type SIZE_OF struct MOS7360_TED to 63
CONTROL FLOW GRAPH SSA
@begin: scope:[] from
to:@1
(void()) main()
main: scope:[main] from @1
to:main::@1
main::@1: scope:[main] from main main::@2
call kbhit
(byte) kbhit::return#0 ← (byte) kbhit::return#2
to:main::@2
main::@2: scope:[main] from main::@1
(byte) kbhit::return#3 ← phi( main::@1/(byte) kbhit::return#0 )
(byte~) main::$0 ← (byte) kbhit::return#3
(bool~) main::$2 ← (number) 0 != (byte~) main::$0
(bool~) main::$1 ← ! (bool~) main::$2
if((bool~) main::$1) goto main::@1
to:main::@return
main::@return: scope:[main] from main::@2
return
to:@return
(byte()) kbhit()
kbhit: scope:[kbhit] from main::@1
*((byte*)(const nomodify struct MOS6529_PIO*) KEYBOARD_PORT+(const byte) OFFSET_STRUCT_MOS6529_PIO_PORT) ← (number) 0
*((byte*)(const nomodify struct MOS7360_TED*) TED+(const byte) OFFSET_STRUCT_MOS7360_TED_KEYBOARD_INPUT) ← (number) 0
(byte~) kbhit::$0 ← ~ *((byte*)(const nomodify struct MOS7360_TED*) TED+(const byte) OFFSET_STRUCT_MOS7360_TED_KEYBOARD_INPUT)
(byte) kbhit::return#1 ← (byte~) kbhit::$0
to:kbhit::@return
kbhit::@return: scope:[kbhit] from kbhit
(byte) kbhit::return#4 ← phi( kbhit/(byte) kbhit::return#1 )
(byte) kbhit::return#2 ← (byte) kbhit::return#4
return
to:@return
@1: scope:[] from @begin
call main
to:@2
@2: scope:[] from @1
to:@end
@end: scope:[] from @2
SYMBOL TABLE SSA
(byte) $0::BASIC
(byte) $0::CARTRIDGE_HIGH
(byte) $0::CARTRIDGE_LOW
(byte) $0::FUNCTION_HIGH
(byte) $0::FUNCTION_LOW
(byte) $0::KERNAL
(byte) $0::UNUSED
(label) @1
(label) @2
(label) @begin
(label) @end
(const nomodify struct MOS6529_PIO*) KEYBOARD_PORT = (struct MOS6529_PIO*)(number) $fd30
(byte) MOS6529_PIO::PORT
(byte) MOS6551_ACIA::COMMAND
(byte) MOS6551_ACIA::CONTROL
(byte) MOS6551_ACIA::DATA
(byte) MOS6551_ACIA::STATUS
(byte) MOS7360_TED::BG_COLOR
(byte) MOS7360_TED::BG_COLOR1
(byte) MOS7360_TED::BG_COLOR2
(byte) MOS7360_TED::BG_COLOR3
(byte) MOS7360_TED::BORDER_COLOR
(byte) MOS7360_TED::CH1_FREQ_HI
(byte) MOS7360_TED::CH1_FREQ_LO
(byte) MOS7360_TED::CH2_FREQ_LO
(byte) MOS7360_TED::CHARPOS_HI
(byte) MOS7360_TED::CHARPOS_LO
(byte) MOS7360_TED::CONTROL1
(byte) MOS7360_TED::CONTROL2
(word) MOS7360_TED::COUNTER1
(word) MOS7360_TED::COUNTER2
(word) MOS7360_TED::COUNTER3
(byte) MOS7360_TED::CURSOR_HI
(byte) MOS7360_TED::CURSOR_LO
(byte) MOS7360_TED::HSCAN_POS
(byte) MOS7360_TED::IRQ_MASK
(byte) MOS7360_TED::IRQ_REQUEST
(volatile byte) MOS7360_TED::KEYBOARD_INPUT loadstore
(byte) MOS7360_TED::MEMORY1
(byte) MOS7360_TED::MEMORY2
(byte) MOS7360_TED::MEMORY3
(byte) MOS7360_TED::RAM_SWITCH
(byte) MOS7360_TED::RASTER_HI
(byte) MOS7360_TED::RASTER_IRQ
(byte) MOS7360_TED::RASTER_LO
(byte) MOS7360_TED::ROM_SWITCH
(byte) MOS7360_TED::SOUND_CONTROL
(const byte*) MOS7360_TED::UNUSED[(number) $1d] = { fill( $1d, 0) }
(byte) MOS7360_TED::VSCAN_POS
(byte) MOS7501_PORT::DDR
(byte) MOS7501_PORT::PORT
(const byte) OFFSET_STRUCT_MOS6529_PIO_PORT = (byte) 0
(const byte) OFFSET_STRUCT_MOS7360_TED_KEYBOARD_INPUT = (byte) 8
(const nomodify struct MOS7360_TED*) TED = (struct MOS7360_TED*)(number) $ff00
(byte()) kbhit()
(byte~) kbhit::$0
(label) kbhit::@return
(byte) kbhit::return
(byte) kbhit::return#0
(byte) kbhit::return#1
(byte) kbhit::return#2
(byte) kbhit::return#3
(byte) kbhit::return#4
(void()) main()
(byte~) main::$0
(bool~) main::$1
(bool~) main::$2
(label) main::@1
(label) main::@2
(label) main::@return
Adding number conversion cast (unumber) 0 in (bool~) main::$2 ← (number) 0 != (byte~) main::$0
Adding number conversion cast (unumber) 0 in *((byte*)(const nomodify struct MOS6529_PIO*) KEYBOARD_PORT+(const byte) OFFSET_STRUCT_MOS6529_PIO_PORT) ← (number) 0
Adding number conversion cast (unumber) 0 in *((byte*)(const nomodify struct MOS7360_TED*) TED+(const byte) OFFSET_STRUCT_MOS7360_TED_KEYBOARD_INPUT) ← (number) 0
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast *((byte*)(const nomodify struct MOS6529_PIO*) KEYBOARD_PORT+(const byte) OFFSET_STRUCT_MOS6529_PIO_PORT) ← (unumber)(number) 0
Inlining cast *((byte*)(const nomodify struct MOS7360_TED*) TED+(const byte) OFFSET_STRUCT_MOS7360_TED_KEYBOARD_INPUT) ← (unumber)(number) 0
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (struct MOS6529_PIO*) 64816
Simplifying constant pointer cast (struct MOS7360_TED*) 65280
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inversing boolean not [5] (bool~) main::$1 ← (byte) 0 == (byte~) main::$0 from [4] (bool~) main::$2 ← (byte) 0 != (byte~) main::$0
Successful SSA optimization Pass2UnaryNotSimplification
Alias kbhit::return#0 = kbhit::return#3
Alias kbhit::return#1 = kbhit::$0 kbhit::return#4 kbhit::return#2
Successful SSA optimization Pass2AliasElimination
Simple Condition (bool~) main::$1 [4] if((byte) 0==(byte~) main::$0) goto main::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Simplifying expression containing zero (byte*)KEYBOARD_PORT in [6] *((byte*)(const nomodify struct MOS6529_PIO*) KEYBOARD_PORT+(const byte) OFFSET_STRUCT_MOS6529_PIO_PORT) ← (byte) 0
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused constant (const byte) OFFSET_STRUCT_MOS6529_PIO_PORT
Successful SSA optimization PassNEliminateUnusedVars
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 @end
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@1
CALL GRAPH
Calls in [] to main:2
Calls in [main] to kbhit:7
Created 0 initial phi equivalence classes
Coalesced down to 0 phi equivalence classes
Culled Empty Block (label) @2
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
Adding NOP phi() at start of main::@1
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()
(void()) main()
main: scope:[main] from @1
[4] phi()
to:main::@1
main::@1: scope:[main] from main main::@2
[5] phi()
[6] call kbhit
[7] (byte) kbhit::return#0 ← (byte) kbhit::return#1
to:main::@2
main::@2: scope:[main] from main::@1
[8] (byte~) main::$0 ← (byte) kbhit::return#0
[9] if((byte) 0==(byte~) main::$0) goto main::@1
to:main::@return
main::@return: scope:[main] from main::@2
[10] return
to:@return
(byte()) kbhit()
kbhit: scope:[kbhit] from main::@1
[11] *((byte*)(const nomodify struct MOS6529_PIO*) KEYBOARD_PORT) ← (byte) 0
[12] *((byte*)(const nomodify struct MOS7360_TED*) TED+(const byte) OFFSET_STRUCT_MOS7360_TED_KEYBOARD_INPUT) ← (byte) 0
[13] (byte) kbhit::return#1 ← ~ *((byte*)(const nomodify struct MOS7360_TED*) TED+(const byte) OFFSET_STRUCT_MOS7360_TED_KEYBOARD_INPUT)
to:kbhit::@return
kbhit::@return: scope:[kbhit] from kbhit
[14] return
to:@return
VARIABLE REGISTER WEIGHTS
(byte) $0::BASIC
(byte) $0::CARTRIDGE_HIGH
(byte) $0::CARTRIDGE_LOW
(byte) $0::FUNCTION_HIGH
(byte) $0::FUNCTION_LOW
(byte) $0::KERNAL
(byte) $0::UNUSED
(byte) MOS6529_PIO::PORT
(byte) MOS6551_ACIA::COMMAND
(byte) MOS6551_ACIA::CONTROL
(byte) MOS6551_ACIA::DATA
(byte) MOS6551_ACIA::STATUS
(byte) MOS7360_TED::BG_COLOR
(byte) MOS7360_TED::BG_COLOR1
(byte) MOS7360_TED::BG_COLOR2
(byte) MOS7360_TED::BG_COLOR3
(byte) MOS7360_TED::BORDER_COLOR
(byte) MOS7360_TED::CH1_FREQ_HI
(byte) MOS7360_TED::CH1_FREQ_LO
(byte) MOS7360_TED::CH2_FREQ_LO
(byte) MOS7360_TED::CHARPOS_HI
(byte) MOS7360_TED::CHARPOS_LO
(byte) MOS7360_TED::CONTROL1
(byte) MOS7360_TED::CONTROL2
(word) MOS7360_TED::COUNTER1
(word) MOS7360_TED::COUNTER2
(word) MOS7360_TED::COUNTER3
(byte) MOS7360_TED::CURSOR_HI
(byte) MOS7360_TED::CURSOR_LO
(byte) MOS7360_TED::HSCAN_POS
(byte) MOS7360_TED::IRQ_MASK
(byte) MOS7360_TED::IRQ_REQUEST
(volatile byte) MOS7360_TED::KEYBOARD_INPUT loadstore
(byte) MOS7360_TED::MEMORY1
(byte) MOS7360_TED::MEMORY2
(byte) MOS7360_TED::MEMORY3
(byte) MOS7360_TED::RAM_SWITCH
(byte) MOS7360_TED::RASTER_HI
(byte) MOS7360_TED::RASTER_IRQ
(byte) MOS7360_TED::RASTER_LO
(byte) MOS7360_TED::ROM_SWITCH
(byte) MOS7360_TED::SOUND_CONTROL
(byte) MOS7360_TED::VSCAN_POS
(byte) MOS7501_PORT::DDR
(byte) MOS7501_PORT::PORT
(byte()) kbhit()
(byte) kbhit::return
(byte) kbhit::return#0 202.0
(byte) kbhit::return#1 367.33333333333337
(void()) main()
(byte~) main::$0 202.0
Initial phi equivalence classes
Added variable kbhit::return#0 to live range equivalence class [ kbhit::return#0 ]
Added variable main::$0 to live range equivalence class [ main::$0 ]
Added variable kbhit::return#1 to live range equivalence class [ kbhit::return#1 ]
Complete equivalence classes
[ kbhit::return#0 ]
[ main::$0 ]
[ kbhit::return#1 ]
Allocated zp[1]:2 [ kbhit::return#0 ]
Allocated zp[1]:3 [ main::$0 ]
Allocated zp[1]:4 [ kbhit::return#1 ]
INITIAL ASM
Target platform is plus4basic / MOS6502X
// File Comments
// Test implementation of kbhit() for Plus/4
// Upstart
.pc = $1001 "Basic"
:BasicUpstart(main)
.pc = $100d "Program"
// Global Constants & labels
.const OFFSET_STRUCT_MOS7360_TED_KEYBOARD_INPUT = 8
// Keyboard Port PIO (P0-P7)
// The input latch is part of the TED.
.label KEYBOARD_PORT = $fd30
// The TED chip controlling video and sound on the Plus/4 and Commodore 16
.label TED = $ff00
// @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 __0 = 3
// [5] phi from main main::@2 to main::@1 [phi:main/main::@2->main::@1]
__b1_from_main:
__b1_from___b2:
jmp __b1
// main::@1
__b1:
// [6] call kbhit
jsr kbhit
// [7] (byte) kbhit::return#0 ← (byte) kbhit::return#1 -- vbuz1=vbuz2
lda.z kbhit.return_1
sta.z kbhit.return
jmp __b2
// main::@2
__b2:
// [8] (byte~) main::$0 ← (byte) kbhit::return#0 -- vbuz1=vbuz2
lda.z kbhit.return
sta.z __0
// [9] if((byte) 0==(byte~) main::$0) goto main::@1 -- vbuc1_eq_vbuz1_then_la1
lda #0
cmp.z __0
beq __b1_from___b2
jmp __breturn
// main::@return
__breturn:
// [10] return
rts
}
// kbhit
// Return true if there's a key waiting, return false if not
kbhit: {
.label return = 2
.label return_1 = 4
// [11] *((byte*)(const nomodify struct MOS6529_PIO*) KEYBOARD_PORT) ← (byte) 0 -- _deref_pbuc1=vbuc2
// Read all keyboard matrix rows
lda #0
sta KEYBOARD_PORT
// [12] *((byte*)(const nomodify struct MOS7360_TED*) TED+(const byte) OFFSET_STRUCT_MOS7360_TED_KEYBOARD_INPUT) ← (byte) 0 -- _deref_pbuc1=vbuc2
// Write to the keyboard input to latch the matrix column values
lda #0
sta TED+OFFSET_STRUCT_MOS7360_TED_KEYBOARD_INPUT
// [13] (byte) kbhit::return#1 ← ~ *((byte*)(const nomodify struct MOS7360_TED*) TED+(const byte) OFFSET_STRUCT_MOS7360_TED_KEYBOARD_INPUT) -- vbuz1=_bnot__deref_pbuc1
lda TED+OFFSET_STRUCT_MOS7360_TED_KEYBOARD_INPUT
eor #$ff
sta.z return_1
jmp __breturn
// kbhit::@return
__breturn:
// [14] return
rts
}
// File Data
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [11] *((byte*)(const nomodify struct MOS6529_PIO*) KEYBOARD_PORT) ← (byte) 0 [ ] ( main:2::kbhit:6 [ ] { { kbhit::return#0 = kbhit::return#1 } } ) always clobbers reg byte a
Statement [12] *((byte*)(const nomodify struct MOS7360_TED*) TED+(const byte) OFFSET_STRUCT_MOS7360_TED_KEYBOARD_INPUT) ← (byte) 0 [ ] ( main:2::kbhit:6 [ ] { { kbhit::return#0 = kbhit::return#1 } } ) always clobbers reg byte a
Statement [13] (byte) kbhit::return#1 ← ~ *((byte*)(const nomodify struct MOS7360_TED*) TED+(const byte) OFFSET_STRUCT_MOS7360_TED_KEYBOARD_INPUT) [ kbhit::return#1 ] ( main:2::kbhit:6 [ kbhit::return#1 ] { { kbhit::return#0 = kbhit::return#1 } } ) always clobbers reg byte a
Potential registers zp[1]:2 [ kbhit::return#0 ] : zp[1]:2 , reg byte a , reg byte x , reg byte y ,
Potential registers zp[1]:3 [ main::$0 ] : zp[1]:3 , reg byte a , reg byte x , reg byte y ,
Potential registers zp[1]:4 [ kbhit::return#1 ] : zp[1]:4 , reg byte a , reg byte x , reg byte y ,
REGISTER UPLIFT SCOPES
Uplift Scope [kbhit] 367.33: zp[1]:4 [ kbhit::return#1 ] 202: zp[1]:2 [ kbhit::return#0 ]
Uplift Scope [main] 202: zp[1]:3 [ main::$0 ]
Uplift Scope [MOS7360_TED]
Uplift Scope [MOS6551_ACIA]
Uplift Scope [MOS6529_PIO]
Uplift Scope [MOS7501_PORT]
Uplift Scope [$0]
Uplift Scope []
Uplifting [kbhit] best 300 combination reg byte a [ kbhit::return#1 ] reg byte a [ kbhit::return#0 ]
Uplifting [main] best 240 combination reg byte a [ main::$0 ]
Uplifting [MOS7360_TED] best 240 combination
Uplifting [MOS6551_ACIA] best 240 combination
Uplifting [MOS6529_PIO] best 240 combination
Uplifting [MOS7501_PORT] best 240 combination
Uplifting [$0] best 240 combination
Uplifting [] best 240 combination
ASSEMBLER BEFORE OPTIMIZATION
// File Comments
// Test implementation of kbhit() for Plus/4
// Upstart
.pc = $1001 "Basic"
:BasicUpstart(main)
.pc = $100d "Program"
// Global Constants & labels
.const OFFSET_STRUCT_MOS7360_TED_KEYBOARD_INPUT = 8
// Keyboard Port PIO (P0-P7)
// The input latch is part of the TED.
.label KEYBOARD_PORT = $fd30
// The TED chip controlling video and sound on the Plus/4 and Commodore 16
.label TED = $ff00
// @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 main::@2 to main::@1 [phi:main/main::@2->main::@1]
__b1_from_main:
__b1_from___b2:
jmp __b1
// main::@1
__b1:
// [6] call kbhit
jsr kbhit
// [7] (byte) kbhit::return#0 ← (byte) kbhit::return#1
jmp __b2
// main::@2
__b2:
// [8] (byte~) main::$0 ← (byte) kbhit::return#0
// [9] if((byte) 0==(byte~) main::$0) goto main::@1 -- vbuc1_eq_vbuaa_then_la1
cmp #0
beq __b1_from___b2
jmp __breturn
// main::@return
__breturn:
// [10] return
rts
}
// kbhit
// Return true if there's a key waiting, return false if not
kbhit: {
// [11] *((byte*)(const nomodify struct MOS6529_PIO*) KEYBOARD_PORT) ← (byte) 0 -- _deref_pbuc1=vbuc2
// Read all keyboard matrix rows
lda #0
sta KEYBOARD_PORT
// [12] *((byte*)(const nomodify struct MOS7360_TED*) TED+(const byte) OFFSET_STRUCT_MOS7360_TED_KEYBOARD_INPUT) ← (byte) 0 -- _deref_pbuc1=vbuc2
// Write to the keyboard input to latch the matrix column values
lda #0
sta TED+OFFSET_STRUCT_MOS7360_TED_KEYBOARD_INPUT
// [13] (byte) kbhit::return#1 ← ~ *((byte*)(const nomodify struct MOS7360_TED*) TED+(const byte) OFFSET_STRUCT_MOS7360_TED_KEYBOARD_INPUT) -- vbuaa=_bnot__deref_pbuc1
lda TED+OFFSET_STRUCT_MOS7360_TED_KEYBOARD_INPUT
eor #$ff
jmp __breturn
// kbhit::@return
__breturn:
// [14] 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 __breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction lda #0
Removing instruction lda TED+OFFSET_STRUCT_MOS7360_TED_KEYBOARD_INPUT
Succesful ASM optimization Pass5UnnecesaryLoadElimination
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_main:
Removing instruction __b1_from___b2:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __bbegin:
Removing instruction __bend:
Removing instruction __b2:
Removing instruction __breturn:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
FINAL SYMBOL TABLE
(byte) $0::BASIC
(byte) $0::CARTRIDGE_HIGH
(byte) $0::CARTRIDGE_LOW
(byte) $0::FUNCTION_HIGH
(byte) $0::FUNCTION_LOW
(byte) $0::KERNAL
(byte) $0::UNUSED
(label) @1
(label) @begin
(label) @end
(const nomodify struct MOS6529_PIO*) KEYBOARD_PORT = (struct MOS6529_PIO*) 64816
(byte) MOS6529_PIO::PORT
(byte) MOS6551_ACIA::COMMAND
(byte) MOS6551_ACIA::CONTROL
(byte) MOS6551_ACIA::DATA
(byte) MOS6551_ACIA::STATUS
(byte) MOS7360_TED::BG_COLOR
(byte) MOS7360_TED::BG_COLOR1
(byte) MOS7360_TED::BG_COLOR2
(byte) MOS7360_TED::BG_COLOR3
(byte) MOS7360_TED::BORDER_COLOR
(byte) MOS7360_TED::CH1_FREQ_HI
(byte) MOS7360_TED::CH1_FREQ_LO
(byte) MOS7360_TED::CH2_FREQ_LO
(byte) MOS7360_TED::CHARPOS_HI
(byte) MOS7360_TED::CHARPOS_LO
(byte) MOS7360_TED::CONTROL1
(byte) MOS7360_TED::CONTROL2
(word) MOS7360_TED::COUNTER1
(word) MOS7360_TED::COUNTER2
(word) MOS7360_TED::COUNTER3
(byte) MOS7360_TED::CURSOR_HI
(byte) MOS7360_TED::CURSOR_LO
(byte) MOS7360_TED::HSCAN_POS
(byte) MOS7360_TED::IRQ_MASK
(byte) MOS7360_TED::IRQ_REQUEST
(volatile byte) MOS7360_TED::KEYBOARD_INPUT loadstore
(byte) MOS7360_TED::MEMORY1
(byte) MOS7360_TED::MEMORY2
(byte) MOS7360_TED::MEMORY3
(byte) MOS7360_TED::RAM_SWITCH
(byte) MOS7360_TED::RASTER_HI
(byte) MOS7360_TED::RASTER_IRQ
(byte) MOS7360_TED::RASTER_LO
(byte) MOS7360_TED::ROM_SWITCH
(byte) MOS7360_TED::SOUND_CONTROL
(const byte*) MOS7360_TED::UNUSED[(number) $1d] = { fill( $1d, 0) }
(byte) MOS7360_TED::VSCAN_POS
(byte) MOS7501_PORT::DDR
(byte) MOS7501_PORT::PORT
(const byte) OFFSET_STRUCT_MOS7360_TED_KEYBOARD_INPUT = (byte) 8
(const nomodify struct MOS7360_TED*) TED = (struct MOS7360_TED*) 65280
(byte()) kbhit()
(label) kbhit::@return
(byte) kbhit::return
(byte) kbhit::return#0 reg byte a 202.0
(byte) kbhit::return#1 reg byte a 367.33333333333337
(void()) main()
(byte~) main::$0 reg byte a 202.0
(label) main::@1
(label) main::@2
(label) main::@return
reg byte a [ kbhit::return#0 ]
reg byte a [ main::$0 ]
reg byte a [ kbhit::return#1 ]
FINAL ASSEMBLER
Score: 129
// File Comments
// Test implementation of kbhit() for Plus/4
// Upstart
.pc = $1001 "Basic"
:BasicUpstart(main)
.pc = $100d "Program"
// Global Constants & labels
.const OFFSET_STRUCT_MOS7360_TED_KEYBOARD_INPUT = 8
// Keyboard Port PIO (P0-P7)
// The input latch is part of the TED.
.label KEYBOARD_PORT = $fd30
// The TED chip controlling video and sound on the Plus/4 and Commodore 16
.label TED = $ff00
// @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 main::@2 to main::@1 [phi:main/main::@2->main::@1]
// main::@1
__b1:
// kbhit()
// [6] call kbhit
jsr kbhit
// [7] (byte) kbhit::return#0 ← (byte) kbhit::return#1
// main::@2
// [8] (byte~) main::$0 ← (byte) kbhit::return#0
// while(!kbhit())
// [9] if((byte) 0==(byte~) main::$0) goto main::@1 -- vbuc1_eq_vbuaa_then_la1
cmp #0
beq __b1
// main::@return
// }
// [10] return
rts
}
// kbhit
// Return true if there's a key waiting, return false if not
kbhit: {
// KEYBOARD_PORT->PORT = 0x00
// [11] *((byte*)(const nomodify struct MOS6529_PIO*) KEYBOARD_PORT) ← (byte) 0 -- _deref_pbuc1=vbuc2
// Read all keyboard matrix rows
lda #0
sta KEYBOARD_PORT
// TED->KEYBOARD_INPUT = 0
// [12] *((byte*)(const nomodify struct MOS7360_TED*) TED+(const byte) OFFSET_STRUCT_MOS7360_TED_KEYBOARD_INPUT) ← (byte) 0 -- _deref_pbuc1=vbuc2
// Write to the keyboard input to latch the matrix column values
sta TED+OFFSET_STRUCT_MOS7360_TED_KEYBOARD_INPUT
// ~TED->KEYBOARD_INPUT
// [13] (byte) kbhit::return#1 ← ~ *((byte*)(const nomodify struct MOS7360_TED*) TED+(const byte) OFFSET_STRUCT_MOS7360_TED_KEYBOARD_INPUT) -- vbuaa=_bnot__deref_pbuc1
eor #$ff
// kbhit::@return
// }
// [14] return
rts
}
// File Data

View File

@ -0,0 +1,66 @@
(byte) $0::BASIC
(byte) $0::CARTRIDGE_HIGH
(byte) $0::CARTRIDGE_LOW
(byte) $0::FUNCTION_HIGH
(byte) $0::FUNCTION_LOW
(byte) $0::KERNAL
(byte) $0::UNUSED
(label) @1
(label) @begin
(label) @end
(const nomodify struct MOS6529_PIO*) KEYBOARD_PORT = (struct MOS6529_PIO*) 64816
(byte) MOS6529_PIO::PORT
(byte) MOS6551_ACIA::COMMAND
(byte) MOS6551_ACIA::CONTROL
(byte) MOS6551_ACIA::DATA
(byte) MOS6551_ACIA::STATUS
(byte) MOS7360_TED::BG_COLOR
(byte) MOS7360_TED::BG_COLOR1
(byte) MOS7360_TED::BG_COLOR2
(byte) MOS7360_TED::BG_COLOR3
(byte) MOS7360_TED::BORDER_COLOR
(byte) MOS7360_TED::CH1_FREQ_HI
(byte) MOS7360_TED::CH1_FREQ_LO
(byte) MOS7360_TED::CH2_FREQ_LO
(byte) MOS7360_TED::CHARPOS_HI
(byte) MOS7360_TED::CHARPOS_LO
(byte) MOS7360_TED::CONTROL1
(byte) MOS7360_TED::CONTROL2
(word) MOS7360_TED::COUNTER1
(word) MOS7360_TED::COUNTER2
(word) MOS7360_TED::COUNTER3
(byte) MOS7360_TED::CURSOR_HI
(byte) MOS7360_TED::CURSOR_LO
(byte) MOS7360_TED::HSCAN_POS
(byte) MOS7360_TED::IRQ_MASK
(byte) MOS7360_TED::IRQ_REQUEST
(volatile byte) MOS7360_TED::KEYBOARD_INPUT loadstore
(byte) MOS7360_TED::MEMORY1
(byte) MOS7360_TED::MEMORY2
(byte) MOS7360_TED::MEMORY3
(byte) MOS7360_TED::RAM_SWITCH
(byte) MOS7360_TED::RASTER_HI
(byte) MOS7360_TED::RASTER_IRQ
(byte) MOS7360_TED::RASTER_LO
(byte) MOS7360_TED::ROM_SWITCH
(byte) MOS7360_TED::SOUND_CONTROL
(const byte*) MOS7360_TED::UNUSED[(number) $1d] = { fill( $1d, 0) }
(byte) MOS7360_TED::VSCAN_POS
(byte) MOS7501_PORT::DDR
(byte) MOS7501_PORT::PORT
(const byte) OFFSET_STRUCT_MOS7360_TED_KEYBOARD_INPUT = (byte) 8
(const nomodify struct MOS7360_TED*) TED = (struct MOS7360_TED*) 65280
(byte()) kbhit()
(label) kbhit::@return
(byte) kbhit::return
(byte) kbhit::return#0 reg byte a 202.0
(byte) kbhit::return#1 reg byte a 367.33333333333337
(void()) main()
(byte~) main::$0 reg byte a 202.0
(label) main::@1
(label) main::@2
(label) main::@return
reg byte a [ kbhit::return#0 ]
reg byte a [ main::$0 ]
reg byte a [ kbhit::return#1 ]