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

Rewrote printf() to use a putc() function pointer. Working on #698

This commit is contained in:
jespergravgaard 2021-08-13 09:19:33 +02:00
parent 728a5ae7e3
commit 72471bbcd0
56 changed files with 21310 additions and 19463 deletions

View File

@ -2457,3 +2457,40 @@ sta {z1}+3
NO_SYNTHESIS
//FRAGMENT vduz1=vwsc1
NO_SYNTHESIS
//FRAGMENT vbuz1=_stackidxbyte_vbuc1
tsx
lda STACK_BASE+{c1},x
sta {z1}
//FRAGMENT _stackpushbyte_=vbuz1
lda {z1}
pha
//FRAGMENT call_vprc1
jsr {c1}
//FRAGMENT _stackpullbyte_1
pla
//FRAGMENT vbuaa=_stackidxbyte_vbuc1
tsx
lda STACK_BASE+{c1},x
//FRAGMENT vbuxx=_stackidxbyte_vbuc1
tsx
lda STACK_BASE+{c1},x
tax
//FRAGMENT vbuyy=_stackidxbyte_vbuc1
tsx
lda STACK_BASE+{c1},x
tay
//FRAGMENT vbuzz=_stackidxbyte_vbuc1
tsx
lda STACK_BASE+{c1},x
taz
//FRAGMENT _stackpushbyte_=vbuaa
pha
//FRAGMENT _stackpushbyte_=vbuxx
txa
pha
//FRAGMENT _stackpushbyte_=vbuyy
tya
pha
//FRAGMENT _stackpushbyte_=vbuzz
tza
pha

View File

@ -7,8 +7,10 @@ import dk.camelot64.kickc.model.Program;
import dk.camelot64.kickc.model.statements.Statement;
import dk.camelot64.kickc.model.statements.StatementCall;
import dk.camelot64.kickc.model.symbols.Procedure;
import dk.camelot64.kickc.model.symbols.Symbol;
import dk.camelot64.kickc.model.types.SymbolType;
import dk.camelot64.kickc.model.types.SymbolTypeInference;
import dk.camelot64.kickc.model.types.SymbolTypeProcedure;
import dk.camelot64.kickc.model.values.*;
import java.util.Arrays;
@ -24,10 +26,12 @@ public class Pass1PrintfIntrinsicRewrite extends Pass2SsaOptimization {
/** The printf procedure name. */
public static final String INTRINSIC_PRINTF_NAME = "printf";
/** The printf routine used to print a raw char */
private static final String PRINTF_CHAR = "cputc";
private static final String CPUTC = "cputc";
/** The printf routine used to print a raw string */
private static final String PRINTF_STR = "cputs";
private static final String PRINTF_STR = "printf_str";
/** The printf routine used to print formatted strings. */
private static final String PRINTF_STRING = "printf_string";
/** The printf routine used to print signed chars. */
@ -42,6 +46,7 @@ public class Pass1PrintfIntrinsicRewrite extends Pass2SsaOptimization {
private static final String PRINTF_SLONG = "printf_slong";
/** The printf routine used to print unsigned long integers. */
private static final String PRINTF_ULONG = "printf_ulong";
/** Hexadecimal Radix name. */
public static final String HEXADECIMAL = "HEXADECIMAL";
/** Decimal Radix name. */
@ -55,6 +60,8 @@ public class Pass1PrintfIntrinsicRewrite extends Pass2SsaOptimization {
@Override
public boolean step() {
for(ControlFlowBlock block : getGraph().getAllBlocks()) {
final ListIterator<Statement> stmtIt = block.getStatements().listIterator();
while(stmtIt.hasNext()) {
@ -71,6 +78,13 @@ public class Pass1PrintfIntrinsicRewrite extends Pass2SsaOptimization {
final String formatString = ((ConstantString) formatLiteral).getString();
final StringEncoding formatEncoding = ((ConstantString) formatLiteral).getEncoding();
Symbol cputcSymbol = getScope().getGlobalSymbol(CPUTC);
ConstantValue CPUTC_REF;
if(cputcSymbol!=null)
CPUTC_REF = new ConstantSymbolPointer(cputcSymbol.getRef());
else
CPUTC_REF = new ConstantPointer(0L, new SymbolTypeProcedure(SymbolType.VOID, Arrays.asList(SymbolType.BYTE)));
// Remove the call to printf()
stmtIt.remove();
@ -121,12 +135,13 @@ public class Pass1PrintfIntrinsicRewrite extends Pass2SsaOptimization {
// First output the non-matching part before the pattern
String prefix = formatString.substring(formatIdx, start);
if(prefix.length() > 0)
addPrintfCall(PRINTF_STR, Arrays.asList(new ConstantString(prefix, formatEncoding, true)), stmtIt, printfCall);
if(prefix.length() > 0) {
addPrintfCall(PRINTF_STR, Arrays.asList(CPUTC_REF, new ConstantString(prefix, formatEncoding, true)), stmtIt, printfCall);
}
formatIdx = end;
if(typeField.equals("%")) {
addPrintfCall(PRINTF_CHAR, Arrays.asList(new ConstantChar('%', formatEncoding)), stmtIt, printfCall);
addPrintfCall(CPUTC, Arrays.asList(new ConstantChar('%', formatEncoding)), stmtIt, printfCall);
} else if(typeField.equals("s")) {
// A formatted string
//struct printf_format_string {
@ -138,7 +153,7 @@ public class Pass1PrintfIntrinsicRewrite extends Pass2SsaOptimization {
new ConstantInteger(width, SymbolType.BYTE),
new ConstantInteger(leftJustify, SymbolType.BYTE)
));
addPrintfCall(PRINTF_STRING, Arrays.asList(getParameterValue(parameters, paramIdx, printfCall), format_string_struct), stmtIt, printfCall);
addPrintfCall(PRINTF_STRING, Arrays.asList(CPUTC_REF, getParameterValue(parameters, paramIdx, printfCall), format_string_struct), stmtIt, printfCall);
paramIdx++;
} else if("diuxXo".contains(typeField)) {
// A formatted integer
@ -214,11 +229,11 @@ public class Pass1PrintfIntrinsicRewrite extends Pass2SsaOptimization {
new ConstantInteger(upperCase, SymbolType.BYTE),
radix
));
addPrintfCall(printf_number_procedure, Arrays.asList(getParameterValue(parameters, paramIdx, printfCall), format_number_struct), stmtIt, printfCall);
addPrintfCall(printf_number_procedure, Arrays.asList(CPUTC_REF, getParameterValue(parameters, paramIdx, printfCall), format_number_struct), stmtIt, printfCall);
paramIdx++;
} else if(typeField.equals("c")) {
// Print char
addPrintfCall(PRINTF_CHAR, Arrays.asList(getParameterValue(parameters, paramIdx, printfCall)), stmtIt, printfCall);
addPrintfCall(CPUTC, Arrays.asList(getParameterValue(parameters, paramIdx, printfCall)), stmtIt, printfCall);
paramIdx++;
} else if(typeField.equals("p")) {
// Print a pointer
@ -231,14 +246,14 @@ public class Pass1PrintfIntrinsicRewrite extends Pass2SsaOptimization {
new ConstantInteger(upperCase, SymbolType.BYTE),
getScope().getLocalConstant(HEXADECIMAL).getRef()
));
addPrintfCall(PRINTF_UINT, Arrays.asList(new CastValue(SymbolType.WORD, getParameterValue(parameters, paramIdx, printfCall)), format_number_struct), stmtIt, printfCall);
addPrintfCall(PRINTF_UINT, Arrays.asList(CPUTC_REF, new CastValue(SymbolType.WORD, getParameterValue(parameters, paramIdx, printfCall)), format_number_struct), stmtIt, printfCall);
paramIdx++;
}
}
// Grab the rest
String suffix = formatString.substring(formatIdx);
if(suffix.length() > 0)
addPrintfCall(PRINTF_STR, Arrays.asList(new ConstantString(suffix, formatEncoding, true)), stmtIt, printfCall);
addPrintfCall(PRINTF_STR, Arrays.asList(CPUTC_REF, new ConstantString(suffix, formatEncoding, true)), stmtIt, printfCall);
}
}
}

View File

@ -8,8 +8,11 @@
/// This implementation supports decimal, octal and hexadecimal radix. It supports min length, left/right justify, zero-padding and always-sign.
void printf(char* format, ...);
/// Print a NUL-terminated string
void printf_str(void (*putc)(char), const char* s);
/// Print a padding char a number of times
void printf_padding(char pad, char length);
void printf_padding(void (*putc)(char), char pad, char length);
/// Format specifying how to format a printed number
struct printf_format_number {
@ -36,26 +39,26 @@ struct printf_buffer_number {
};
/// Print a signed long using a specific format
void printf_slong(signed long value, struct printf_format_number format);
void printf_slong(void (*putc)(char), signed long value, struct printf_format_number format);
/// Print an unsigned int using a specific format
void printf_ulong(unsigned long uvalue, struct printf_format_number format);
void printf_ulong(void (*putc)(char), unsigned long uvalue, struct printf_format_number format);
/// Print a signed integer using a specific format
void printf_sint(signed int value, struct printf_format_number format);
void printf_sint(void (*putc)(char), signed int value, struct printf_format_number format);
/// Print an unsigned int using a specific format
void printf_uint(unsigned int uvalue, struct printf_format_number format);
void printf_uint(void (*putc)(char), unsigned int uvalue, struct printf_format_number format);
/// Print a signed char using a specific format
void printf_schar(signed char value, struct printf_format_number format);
void printf_schar(void (*putc)(char), signed char value, struct printf_format_number format);
/// Print an unsigned char using a specific format
void printf_uchar(unsigned char uvalue, struct printf_format_number format);
void printf_uchar(void (*putc)(char), unsigned char uvalue, struct printf_format_number format);
/// Print the contents of the number buffer using a specific format.
/// This handles minimum length, zero-filling, and left/right justification from the format
void printf_number_buffer(struct printf_buffer_number buffer, struct printf_format_number format);
void printf_number_buffer(void (*putc)(char), struct printf_buffer_number buffer, struct printf_format_number format);
/// Format specifying how to format a printed string
struct printf_format_string {
@ -67,4 +70,4 @@ struct printf_format_string {
/// Print a string value using a specific format
/// Handles justification and min length
void printf_string(char* str, struct printf_format_string format);
void printf_string(void (*putc)(char), char* str, struct printf_format_string format);

View File

@ -11,14 +11,21 @@ struct printf_buffer_number printf_buffer;
// This implementation supports decimal, octal and hexadecimal radix. It supports min length, left/right justify, zero-padding and always-sign.
__intrinsic void printf(char* format, ...);
/// Print a NUL-terminated string
void printf_str(void (*putc)(char), const char* s) {
char c;
while(c=*s++)
putc(c);
}
// Print a padding char a number of times
void printf_padding(char pad, char length) {
void printf_padding(void (*putc)(char), char pad, char length) {
for(char i=0;i<length; i++)
cputc(pad);
putc(pad);
}
// Print a signed long using a specific format
void printf_slong(signed long value, struct printf_format_number format) {
void printf_slong(void (*putc)(char), signed long value, struct printf_format_number format) {
// Handle any sign
printf_buffer.sign = 0;
if(value<0) {
@ -34,21 +41,21 @@ void printf_slong(signed long value, struct printf_format_number format) {
unsigned long uvalue = (unsigned long)value;
ultoa(uvalue, printf_buffer.digits, format.radix);
// Print using format
printf_number_buffer(printf_buffer, format);
printf_number_buffer(putc, printf_buffer, format);
}
// Print an unsigned int using a specific format
void printf_ulong(unsigned long uvalue, struct printf_format_number format) {
void printf_ulong(void (*putc)(char), unsigned long uvalue, struct printf_format_number format) {
// Handle any sign
printf_buffer.sign = format.sign_always?'+':0;
// Format number into buffer
ultoa(uvalue, printf_buffer.digits, format.radix);
// Print using format
printf_number_buffer(printf_buffer, format);
printf_number_buffer(putc, printf_buffer, format);
}
// Print a signed integer using a specific format
void printf_sint(signed int value, struct printf_format_number format) {
void printf_sint(void (*putc)(char), signed int value, struct printf_format_number format) {
// Handle any sign
printf_buffer.sign = 0;
if(value<0) {
@ -64,21 +71,21 @@ void printf_sint(signed int value, struct printf_format_number format) {
unsigned int uvalue = (unsigned int)value;
utoa(uvalue, printf_buffer.digits, format.radix);
// Print using format
printf_number_buffer(printf_buffer, format);
printf_number_buffer(putc, printf_buffer, format);
}
// Print an unsigned int using a specific format
void printf_uint(unsigned int uvalue, struct printf_format_number format) {
void printf_uint(void (*putc)(char), unsigned int uvalue, struct printf_format_number format) {
// Handle any sign
printf_buffer.sign = format.sign_always?'+':0;
// Format number into buffer
utoa(uvalue, printf_buffer.digits, format.radix);
// Print using format
printf_number_buffer(printf_buffer, format);
printf_number_buffer(putc, printf_buffer, format);
}
// Print a signed char using a specific format
void printf_schar(signed char value, struct printf_format_number format) {
void printf_schar(void (*putc)(char), signed char value, struct printf_format_number format) {
// Handle any sign
printf_buffer.sign = 0;
if(value<0) {
@ -94,22 +101,22 @@ void printf_schar(signed char value, struct printf_format_number format) {
unsigned char uvalue = (unsigned char)value;
uctoa(uvalue, printf_buffer.digits, format.radix);
// Print using format
printf_number_buffer(printf_buffer, format);
printf_number_buffer(putc, printf_buffer, format);
}
// Print an unsigned char using a specific format
void printf_uchar(unsigned char uvalue, struct printf_format_number format) {
void printf_uchar(void (*putc)(char), unsigned char uvalue, struct printf_format_number format) {
// Handle any sign
printf_buffer.sign = format.sign_always?'+':0;
// Format number into buffer
uctoa(uvalue, printf_buffer.digits, format.radix);
// Print using format
printf_number_buffer(printf_buffer, format);
printf_number_buffer(putc, printf_buffer, format);
}
// Print the contents of the number buffer using a specific format.
// This handles minimum length, zero-filling, and left/right justification from the format
void printf_number_buffer(struct printf_buffer_number buffer, struct printf_format_number format) {
void printf_number_buffer(void (*putc)(char), struct printf_buffer_number buffer, struct printf_format_number format) {
signed char padding = 0;
if(format.min_length) {
// There is a minimum length - work out the padding
@ -119,22 +126,22 @@ void printf_number_buffer(struct printf_buffer_number buffer, struct printf_form
if(padding<0) padding = 0;
}
if(!format.justify_left && !format.zero_padding && padding)
printf_padding(' ',(char)padding);
printf_padding(putc, ' ',(char)padding);
if(buffer.sign)
cputc(buffer.sign);
putc(buffer.sign);
if(format.zero_padding && padding)
printf_padding('0',(char)padding);
printf_padding(putc, '0',(char)padding);
if(format.upper_case) {
strupr(buffer.digits);
}
cputs(buffer.digits);
printf_str(putc, buffer.digits);
if(format.justify_left && !format.zero_padding && padding)
printf_padding(' ',(char)padding);
printf_padding(putc, ' ',(char)padding);
}
// Print a string value using a specific format
// Handles justification and min length
void printf_string(char* str, struct printf_format_string format) {
void printf_string(void (*putc)(char), char* str, struct printf_format_string format) {
signed char padding = 0;
if(format.min_length) {
signed char len = (signed char)strlen(str);
@ -142,9 +149,8 @@ void printf_string(char* str, struct printf_format_string format) {
if(padding<0) padding = 0;
}
if(!format.justify_left && padding)
printf_padding(' ',(char)padding);
cputs(str);
printf_padding(putc, ' ',(char)padding);
printf_str(putc, str);
if(format.justify_left && padding)
printf_padding(' ',(char)padding);
printf_padding(putc, ' ',(char)padding);
}

View File

@ -7,12 +7,13 @@ void main() {
clrscr();
printf_string( "cml", { 10, 0 } );
printf_string(&cputc, "cml", { 10, 0 } );
cputln();
printf_string( "rules", { 10, 0 } );
printf_string(&cputc, "rules", { 10, 0 } );
cputln();
printf_string( "cml", { 10, 1 } );
printf_string(&cputc, "cml", { 10, 1 } );
cputln();
printf_string( "rules", { 10, 1 } );
printf_string(&cputc, "rules", { 10, 1 } );
}

View File

@ -1,12 +1,12 @@
// Tests printf function call rewriting
// A simple string - with the printf-sub cuntions in the same file.
// A simple string - with the printf-sub funtions in the same file.
__intrinsic void printf(char* format, ...);
char * screen = (char*)0x0400;
char idx = 0;
void cputs(char* str) {
void printf_str(void (*putc)(char), char* str) {
while(*str) {
*screen++ = *str++;
}
@ -22,8 +22,8 @@ struct printf_format_string {
// Print a string value using a specific format
// Handles justification and min length
void printf_string(char* str, struct printf_format_string format) {
cputs(str);
void printf_string(void (*putc)(char), char* str, struct printf_format_string format) {
printf_str(putc, str);
}

View File

@ -6,7 +6,7 @@ __intrinsic void printf(char* format, ...);
char * screen = (char*)0x0400;
char idx = 0;
void cputs(char* str) {
void printf_str(void (*putc)(char), char* str) {
while(*str) {
*screen++ = *str++;
}
@ -35,7 +35,7 @@ const char printf_hextab[] = "0123456789abcdef"z;
// Print an unsigned int using a specific format
// Always prints hexadecimals - ignores min_length and flags
void printf_uint(unsigned int uvalue, struct printf_format_number format) {
void printf_uint(void (*putc)(char), unsigned int uvalue, struct printf_format_number format) {
*screen++ = printf_hextab[BYTE1(uvalue)>>4];
*screen++ = printf_hextab[BYTE1(uvalue)&0xf];
*screen++ = printf_hextab[BYTE0(uvalue)>>4];

View File

@ -7,13 +7,13 @@ void main() {
clrscr();
printf_schar(-77, { 6, 0, 0, 0, 0, DECIMAL});
printf_schar(cputc, -77, { 6, 0, 0, 0, 0, DECIMAL});
cputln();
printf_schar(99, {6, 0, 1, 1, 0, OCTAL});
printf_schar(cputc, 99, {6, 0, 1, 1, 0, OCTAL});
cputln();
printf_uint(3456, {10, 1, 0, 0, 1, HEXADECIMAL});
printf_uint(cputc, 3456, {10, 1, 0, 0, 1, HEXADECIMAL});
cputln();
}

View File

@ -10,6 +10,7 @@
:BasicUpstart(__start)
.const LIGHT_BLUE = $e
.const OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS = 1
.const STACK_BASE = $103
.const SIZEOF_STRUCT_PRINTF_BUFFER_NUMBER = $c
/// Color Ram
.label COLORRAM = $d800
@ -62,6 +63,37 @@ conio_c64_init: {
// }
rts
}
// Output one character at the current cursor position
// Moves the cursor forward. Scrolls the entire screen if needed
// void cputc(__register(A) char c)
cputc: {
.const OFFSET_STACK_C = 0
tsx
lda STACK_BASE+OFFSET_STACK_C,x
// if(c=='\n')
cmp #'\n'
beq __b1
// conio_line_text[conio_cursor_x] = c
ldy.z conio_cursor_x
sta (conio_line_text),y
// conio_line_color[conio_cursor_x] = conio_textcolor
lda #LIGHT_BLUE
sta (conio_line_color),y
// if(++conio_cursor_x==CONIO_WIDTH)
inc.z conio_cursor_x
lda #$28
cmp.z conio_cursor_x
bne __breturn
// cputln()
jsr cputln
__breturn:
// }
rts
__b1:
// cputln()
jsr cputln
rts
}
main: {
.label signed_char_value = 2
// clrscr()
@ -164,10 +196,38 @@ gotoxy: {
// }
rts
}
// Print a newline
cputln: {
// conio_line_text += CONIO_WIDTH
lda #$28
clc
adc.z conio_line_text
sta.z conio_line_text
bcc !+
inc.z conio_line_text+1
!:
// conio_line_color += CONIO_WIDTH
lda #$28
clc
adc.z conio_line_color
sta.z conio_line_color
bcc !+
inc.z conio_line_color+1
!:
// conio_cursor_x = 0
lda #0
sta.z conio_cursor_x
// conio_cursor_y++;
inc.z conio_cursor_y
// cscroll()
jsr cscroll
// }
rts
}
// clears the screen and moves the cursor to the upper left-hand corner of the screen.
clrscr: {
.label line_text = 3
.label line_cols = 5
.label line_cols = $1a
lda #<COLORRAM
sta.z line_cols
lda #>COLORRAM
@ -240,11 +300,15 @@ test_casting: {
// printf("%d\n", signed_short_value)
jsr printf_sint
// printf("%d\n", signed_short_value)
lda #<cputc
sta.z printf_str.putc
lda #>cputc
sta.z printf_str.putc+1
lda #<s
sta.z cputs.s
sta.z printf_str.s
lda #>s
sta.z cputs.s+1
jsr cputs
sta.z printf_str.s+1
jsr printf_str
// }
rts
.segment Data
@ -252,9 +316,72 @@ test_casting: {
.byte 0
}
.segment Code
// Scroll the entire screen if the cursor is beyond the last line
cscroll: {
// if(conio_cursor_y==CONIO_HEIGHT)
lda #$19
cmp.z conio_cursor_y
bne __breturn
// memcpy(CONIO_SCREEN_TEXT, CONIO_SCREEN_TEXT+CONIO_WIDTH, CONIO_BYTES-CONIO_WIDTH)
lda #<DEFAULT_SCREEN
sta.z memcpy.destination
lda #>DEFAULT_SCREEN
sta.z memcpy.destination+1
lda #<DEFAULT_SCREEN+$28
sta.z memcpy.source
lda #>DEFAULT_SCREEN+$28
sta.z memcpy.source+1
jsr memcpy
// memcpy(CONIO_SCREEN_COLORS, CONIO_SCREEN_COLORS+CONIO_WIDTH, CONIO_BYTES-CONIO_WIDTH)
lda #<COLORRAM
sta.z memcpy.destination
lda #>COLORRAM
sta.z memcpy.destination+1
lda #<COLORRAM+$28
sta.z memcpy.source
lda #>COLORRAM+$28
sta.z memcpy.source+1
jsr memcpy
// memset(CONIO_SCREEN_TEXT+CONIO_BYTES-CONIO_WIDTH, ' ', CONIO_WIDTH)
ldx #' '
lda #<DEFAULT_SCREEN+$19*$28-$28
sta.z memset.str
lda #>DEFAULT_SCREEN+$19*$28-$28
sta.z memset.str+1
jsr memset
// memset(CONIO_SCREEN_COLORS+CONIO_BYTES-CONIO_WIDTH, conio_textcolor, CONIO_WIDTH)
ldx #LIGHT_BLUE
lda #<COLORRAM+$19*$28-$28
sta.z memset.str
lda #>COLORRAM+$19*$28-$28
sta.z memset.str+1
jsr memset
// conio_line_text -= CONIO_WIDTH
sec
lda.z conio_line_text
sbc #$28
sta.z conio_line_text
lda.z conio_line_text+1
sbc #0
sta.z conio_line_text+1
// conio_line_color -= CONIO_WIDTH
sec
lda.z conio_line_color
sbc #$28
sta.z conio_line_color
lda.z conio_line_color+1
sbc #0
sta.z conio_line_color+1
// conio_cursor_y--;
dec.z conio_cursor_y
__breturn:
// }
rts
}
// Print a signed integer using a specific format
// void printf_sint(__zp(3) int value, char format_min_length, char format_justify_left, char format_sign_always, char format_zero_padding, char format_upper_case, char format_radix)
// void printf_sint(void (*putc)(char), __zp(3) int value, char format_min_length, char format_justify_left, char format_sign_always, char format_zero_padding, char format_upper_case, char format_radix)
printf_sint: {
.label putc = cputc
.label value = 3
// printf_buffer.sign = 0
// Handle any sign
@ -279,17 +406,18 @@ printf_sint: {
__b2:
// utoa(uvalue, printf_buffer.digits, format.radix)
jsr utoa
// printf_number_buffer(printf_buffer, format)
// printf_number_buffer(putc, printf_buffer, format)
lda printf_buffer
// Print using format
jsr printf_number_buffer
// }
rts
}
// Output a NUL-terminated string at the current cursor position
// void cputs(__zp(5) const char *s)
cputs: {
.label s = 5
/// Print a NUL-terminated string
// void printf_str(__zp($1a) void (*putc)(char), __zp(8) const char *s)
printf_str: {
.label s = 8
.label putc = $1a
__b1:
// while(c=*s++)
ldy #0
@ -303,20 +431,103 @@ cputs: {
// }
rts
__b2:
// cputc(c)
jsr cputc
// putc(c)
pha
jsr icall1
pla
jmp __b1
icall1:
jmp (putc)
}
// Copy block of memory (forwards)
// Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
// void * memcpy(__zp($18) void *destination, __zp(5) void *source, unsigned int num)
memcpy: {
.label src_end = $16
.label dst = $18
.label src = 5
.label source = 5
.label destination = $18
// char* src_end = (char*)source+num
lda.z source
clc
adc #<$19*$28-$28
sta.z src_end
lda.z source+1
adc #>$19*$28-$28
sta.z src_end+1
__b1:
// while(src!=src_end)
lda.z src+1
cmp.z src_end+1
bne __b2
lda.z src
cmp.z src_end
bne __b2
// }
rts
__b2:
// *dst++ = *src++
ldy #0
lda (src),y
sta (dst),y
// *dst++ = *src++;
inc.z dst
bne !+
inc.z dst+1
!:
inc.z src
bne !+
inc.z src+1
!:
jmp __b1
}
// Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
// void * memset(__zp(5) void *str, __register(X) char c, unsigned int num)
memset: {
.label end = $18
.label dst = 5
.label str = 5
// char* end = (char*)str + num
lda #$28
clc
adc.z str
sta.z end
lda #0
adc.z str+1
sta.z end+1
__b2:
// for(char* dst = str; dst!=end; dst++)
lda.z dst+1
cmp.z end+1
bne __b3
lda.z dst
cmp.z end
bne __b3
// }
rts
__b3:
// *dst = c
txa
ldy #0
sta (dst),y
// for(char* dst = str; dst!=end; dst++)
inc.z dst
bne !+
inc.z dst+1
!:
jmp __b2
}
// Converts unsigned number value to a string representing it in RADIX format.
// If the leading digits are zero they are not included in the string.
// - value : The number to be converted to RADIX
// - buffer : receives the string representing the number and zero-termination.
// - radix : The radix to convert the number to (from the enum RADIX)
// void utoa(__zp(3) unsigned int value, __zp($18) char *buffer, char radix)
// void utoa(__zp(3) unsigned int value, __zp(8) char *buffer, char radix)
utoa: {
.const max_digits = 5
.label digit_value = $16
.label buffer = $18
.label digit_value = $1a
.label buffer = 8
.label digit = 7
.label value = 3
lda #<printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
@ -385,52 +596,30 @@ utoa: {
}
// Print the contents of the number buffer using a specific format.
// This handles minimum length, zero-filling, and left/right justification from the format
// void printf_number_buffer(__register(A) char buffer_sign, char *buffer_digits, char format_min_length, char format_justify_left, char format_sign_always, char format_zero_padding, char format_upper_case, char format_radix)
// void printf_number_buffer(void (*putc)(char), __register(A) char buffer_sign, char *buffer_digits, char format_min_length, char format_justify_left, char format_sign_always, char format_zero_padding, char format_upper_case, char format_radix)
printf_number_buffer: {
.label buffer_digits = printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
// if(buffer.sign)
cmp #0
beq __b2
// cputc(buffer.sign)
// putc(buffer.sign)
pha
jsr cputc
pla
__b2:
// cputs(buffer.digits)
// printf_str(putc, buffer.digits)
lda #<printf_sint.putc
sta.z printf_str.putc
lda #>printf_sint.putc
sta.z printf_str.putc+1
lda #<buffer_digits
sta.z cputs.s
sta.z printf_str.s
lda #>buffer_digits
sta.z cputs.s+1
jsr cputs
sta.z printf_str.s+1
jsr printf_str
// }
rts
}
// Output one character at the current cursor position
// Moves the cursor forward. Scrolls the entire screen if needed
// void cputc(__register(A) char c)
cputc: {
// if(c=='\n')
cmp #'\n'
beq __b1
// conio_line_text[conio_cursor_x] = c
ldy.z conio_cursor_x
sta (conio_line_text),y
// conio_line_color[conio_cursor_x] = conio_textcolor
lda #LIGHT_BLUE
sta (conio_line_color),y
// if(++conio_cursor_x==CONIO_WIDTH)
inc.z conio_cursor_x
lda #$28
cmp.z conio_cursor_x
bne __breturn
// cputln()
jsr cputln
__breturn:
// }
rts
__b1:
// cputln()
jsr cputln
rts
}
// Used to convert a single digit of an unsigned number value to a string representation
// Counts a single digit up from '0' as long as the value is larger than sub.
// Each time the digit is increased sub is subtracted from value.
@ -439,11 +628,11 @@ cputc: {
// - sub : the value of a '1' in the digit. Subtracted continually while the digit is increased.
// (For decimal the subs used are 10000, 1000, 100, 10, 1)
// returns : the value reduced by sub * digit so that it is less than sub.
// __zp(3) unsigned int utoa_append(__zp($18) char *buffer, __zp(3) unsigned int value, __zp($16) unsigned int sub)
// __zp(3) unsigned int utoa_append(__zp(8) char *buffer, __zp(3) unsigned int value, __zp($1a) unsigned int sub)
utoa_append: {
.label buffer = $18
.label buffer = 8
.label value = 3
.label sub = $16
.label sub = $1a
.label return = 3
ldx #0
__b1:
@ -475,175 +664,6 @@ utoa_append: {
sta.z value+1
jmp __b1
}
// Print a newline
cputln: {
// conio_line_text += CONIO_WIDTH
lda #$28
clc
adc.z conio_line_text
sta.z conio_line_text
bcc !+
inc.z conio_line_text+1
!:
// conio_line_color += CONIO_WIDTH
lda #$28
clc
adc.z conio_line_color
sta.z conio_line_color
bcc !+
inc.z conio_line_color+1
!:
// conio_cursor_x = 0
lda #0
sta.z conio_cursor_x
// conio_cursor_y++;
inc.z conio_cursor_y
// cscroll()
jsr cscroll
// }
rts
}
// Scroll the entire screen if the cursor is beyond the last line
cscroll: {
// if(conio_cursor_y==CONIO_HEIGHT)
lda #$19
cmp.z conio_cursor_y
bne __breturn
// memcpy(CONIO_SCREEN_TEXT, CONIO_SCREEN_TEXT+CONIO_WIDTH, CONIO_BYTES-CONIO_WIDTH)
lda #<DEFAULT_SCREEN
sta.z memcpy.destination
lda #>DEFAULT_SCREEN
sta.z memcpy.destination+1
lda #<DEFAULT_SCREEN+$28
sta.z memcpy.source
lda #>DEFAULT_SCREEN+$28
sta.z memcpy.source+1
jsr memcpy
// memcpy(CONIO_SCREEN_COLORS, CONIO_SCREEN_COLORS+CONIO_WIDTH, CONIO_BYTES-CONIO_WIDTH)
lda #<COLORRAM
sta.z memcpy.destination
lda #>COLORRAM
sta.z memcpy.destination+1
lda #<COLORRAM+$28
sta.z memcpy.source
lda #>COLORRAM+$28
sta.z memcpy.source+1
jsr memcpy
// memset(CONIO_SCREEN_TEXT+CONIO_BYTES-CONIO_WIDTH, ' ', CONIO_WIDTH)
ldx #' '
lda #<DEFAULT_SCREEN+$19*$28-$28
sta.z memset.str
lda #>DEFAULT_SCREEN+$19*$28-$28
sta.z memset.str+1
jsr memset
// memset(CONIO_SCREEN_COLORS+CONIO_BYTES-CONIO_WIDTH, conio_textcolor, CONIO_WIDTH)
ldx #LIGHT_BLUE
lda #<COLORRAM+$19*$28-$28
sta.z memset.str
lda #>COLORRAM+$19*$28-$28
sta.z memset.str+1
jsr memset
// conio_line_text -= CONIO_WIDTH
sec
lda.z conio_line_text
sbc #$28
sta.z conio_line_text
lda.z conio_line_text+1
sbc #0
sta.z conio_line_text+1
// conio_line_color -= CONIO_WIDTH
sec
lda.z conio_line_color
sbc #$28
sta.z conio_line_color
lda.z conio_line_color+1
sbc #0
sta.z conio_line_color+1
// conio_cursor_y--;
dec.z conio_cursor_y
__breturn:
// }
rts
}
// Copy block of memory (forwards)
// Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
// void * memcpy(__zp(8) void *destination, __zp($18) void *source, unsigned int num)
memcpy: {
.label src_end = $16
.label dst = 8
.label src = $18
.label source = $18
.label destination = 8
// char* src_end = (char*)source+num
lda.z source
clc
adc #<$19*$28-$28
sta.z src_end
lda.z source+1
adc #>$19*$28-$28
sta.z src_end+1
__b1:
// while(src!=src_end)
lda.z src+1
cmp.z src_end+1
bne __b2
lda.z src
cmp.z src_end
bne __b2
// }
rts
__b2:
// *dst++ = *src++
ldy #0
lda (src),y
sta (dst),y
// *dst++ = *src++;
inc.z dst
bne !+
inc.z dst+1
!:
inc.z src
bne !+
inc.z src+1
!:
jmp __b1
}
// Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
// void * memset(__zp(8) void *str, __register(X) char c, unsigned int num)
memset: {
.label end = $18
.label dst = 8
.label str = 8
// char* end = (char*)str + num
lda #$28
clc
adc.z str
sta.z end
lda #0
adc.z str+1
sta.z end+1
__b2:
// for(char* dst = str; dst!=end; dst++)
lda.z dst+1
cmp.z end+1
bne __b3
lda.z dst
cmp.z end
bne __b3
// }
rts
__b3:
// *dst = c
txa
ldy #0
sta (dst),y
// for(char* dst = str; dst!=end; dst++)
inc.z dst
bne !+
inc.z dst+1
!:
jmp __b2
}
.segment Data
// The digits used for numbers
DIGITS: .text "0123456789abcdef"

View File

@ -35,326 +35,329 @@ conio_c64_init::@return: scope:[conio_c64_init] from conio_c64_init::@1
[15] return
to:@return
__stackcall void cputc(char c)
cputc: scope:[cputc] from printf_number_buffer::@3
[16] cputc::c#0 = stackidx(char,cputc::OFFSET_STACK_C)
[17] if(cputc::c#0=='
') goto cputc::@1
to:cputc::@2
cputc::@2: scope:[cputc] from cputc
[18] conio_line_text[conio_cursor_x] = cputc::c#0
[19] conio_line_color[conio_cursor_x] = LIGHT_BLUE
[20] conio_cursor_x = ++ conio_cursor_x
[21] if(conio_cursor_x!=$28) goto cputc::@return
to:cputc::@3
cputc::@3: scope:[cputc] from cputc::@2
[22] phi()
[23] call cputln
to:cputc::@return
cputc::@return: scope:[cputc] from cputc::@1 cputc::@2 cputc::@3
[24] return
to:@return
cputc::@1: scope:[cputc] from cputc
[25] phi()
[26] call cputln
to:cputc::@return
void main()
main: scope:[main] from __start::@1
[16] phi()
[17] call clrscr
[27] phi()
[28] call clrscr
to:main::@1
main::@1: scope:[main] from main main::@2
[18] main::signed_char_value#2 = phi( main/-5, main::@2/main::signed_char_value#1 )
[19] if(main::signed_char_value#2!=0) goto main::@2
[29] main::signed_char_value#2 = phi( main/-5, main::@2/main::signed_char_value#1 )
[30] if(main::signed_char_value#2!=0) goto main::@2
to:main::@return
main::@return: scope:[main] from main::@1
[20] return
[31] return
to:@return
main::@2: scope:[main] from main::@1
[21] main::signed_char_value#1 = ++ main::signed_char_value#2
[22] test_casting::signed_short_value#0 = main::signed_char_value#1
[23] call test_casting
[32] main::signed_char_value#1 = ++ main::signed_char_value#2
[33] test_casting::signed_short_value#0 = main::signed_char_value#1
[34] call test_casting
to:main::@1
void gotoxy(char x , char y)
gotoxy: scope:[gotoxy] from conio_c64_init::@1
[24] if(gotoxy::y#2<$19+1) goto gotoxy::@3
[35] if(gotoxy::y#2<$19+1) goto gotoxy::@3
to:gotoxy::@1
gotoxy::@3: scope:[gotoxy] from gotoxy
[25] phi()
[36] phi()
to:gotoxy::@1
gotoxy::@1: scope:[gotoxy] from gotoxy gotoxy::@3
[26] gotoxy::y#4 = phi( gotoxy::@3/gotoxy::y#2, gotoxy/0 )
[37] gotoxy::y#4 = phi( gotoxy::@3/gotoxy::y#2, gotoxy/0 )
to:gotoxy::@2
gotoxy::@2: scope:[gotoxy] from gotoxy::@1
[27] conio_cursor_x = gotoxy::x#2
[28] conio_cursor_y = gotoxy::y#4
[29] gotoxy::$7 = (unsigned int)gotoxy::y#4
[30] gotoxy::$8 = gotoxy::$7 << 2
[31] gotoxy::$9 = gotoxy::$8 + gotoxy::$7
[32] gotoxy::line_offset#0 = gotoxy::$9 << 3
[33] gotoxy::$5 = DEFAULT_SCREEN + gotoxy::line_offset#0
[34] conio_line_text = gotoxy::$5
[35] gotoxy::$6 = COLORRAM + gotoxy::line_offset#0
[36] conio_line_color = gotoxy::$6
[38] conio_cursor_x = gotoxy::x#2
[39] conio_cursor_y = gotoxy::y#4
[40] gotoxy::$7 = (unsigned int)gotoxy::y#4
[41] gotoxy::$8 = gotoxy::$7 << 2
[42] gotoxy::$9 = gotoxy::$8 + gotoxy::$7
[43] gotoxy::line_offset#0 = gotoxy::$9 << 3
[44] gotoxy::$5 = DEFAULT_SCREEN + gotoxy::line_offset#0
[45] conio_line_text = gotoxy::$5
[46] gotoxy::$6 = COLORRAM + gotoxy::line_offset#0
[47] conio_line_color = gotoxy::$6
to:gotoxy::@return
gotoxy::@return: scope:[gotoxy] from gotoxy::@2
[37] return
[48] return
to:@return
void cputln()
cputln: scope:[cputln] from cputc::@1 cputc::@3
[49] conio_line_text = conio_line_text + $28
[50] conio_line_color = conio_line_color + $28
[51] conio_cursor_x = 0
[52] conio_cursor_y = ++ conio_cursor_y
[53] call cscroll
to:cputln::@return
cputln::@return: scope:[cputln] from cputln
[54] return
to:@return
void clrscr()
clrscr: scope:[clrscr] from main
[38] phi()
[55] phi()
to:clrscr::@1
clrscr::@1: scope:[clrscr] from clrscr clrscr::@5
[39] clrscr::line_cols#5 = phi( clrscr/COLORRAM, clrscr::@5/clrscr::line_cols#1 )
[39] clrscr::line_text#5 = phi( clrscr/DEFAULT_SCREEN, clrscr::@5/clrscr::line_text#1 )
[39] clrscr::l#2 = phi( clrscr/0, clrscr::@5/clrscr::l#1 )
[40] if(clrscr::l#2<$19) goto clrscr::@3
[56] clrscr::line_cols#5 = phi( clrscr/COLORRAM, clrscr::@5/clrscr::line_cols#1 )
[56] clrscr::line_text#5 = phi( clrscr/DEFAULT_SCREEN, clrscr::@5/clrscr::line_text#1 )
[56] clrscr::l#2 = phi( clrscr/0, clrscr::@5/clrscr::l#1 )
[57] if(clrscr::l#2<$19) goto clrscr::@3
to:clrscr::@2
clrscr::@2: scope:[clrscr] from clrscr::@1
[41] conio_cursor_x = 0
[42] conio_cursor_y = 0
[43] conio_line_text = DEFAULT_SCREEN
[44] conio_line_color = COLORRAM
[58] conio_cursor_x = 0
[59] conio_cursor_y = 0
[60] conio_line_text = DEFAULT_SCREEN
[61] conio_line_color = COLORRAM
to:clrscr::@return
clrscr::@return: scope:[clrscr] from clrscr::@2
[45] return
[62] return
to:@return
clrscr::@3: scope:[clrscr] from clrscr::@1 clrscr::@4
[46] clrscr::c#2 = phi( clrscr::@1/0, clrscr::@4/clrscr::c#1 )
[47] if(clrscr::c#2<$28) goto clrscr::@4
[63] clrscr::c#2 = phi( clrscr::@1/0, clrscr::@4/clrscr::c#1 )
[64] if(clrscr::c#2<$28) goto clrscr::@4
to:clrscr::@5
clrscr::@5: scope:[clrscr] from clrscr::@3
[48] clrscr::line_text#1 = clrscr::line_text#5 + $28
[49] clrscr::line_cols#1 = clrscr::line_cols#5 + $28
[50] clrscr::l#1 = ++ clrscr::l#2
[65] clrscr::line_text#1 = clrscr::line_text#5 + $28
[66] clrscr::line_cols#1 = clrscr::line_cols#5 + $28
[67] clrscr::l#1 = ++ clrscr::l#2
to:clrscr::@1
clrscr::@4: scope:[clrscr] from clrscr::@3
[51] clrscr::line_text#5[clrscr::c#2] = ' '
[52] clrscr::line_cols#5[clrscr::c#2] = LIGHT_BLUE
[53] clrscr::c#1 = ++ clrscr::c#2
[68] clrscr::line_text#5[clrscr::c#2] = ' '
[69] clrscr::line_cols#5[clrscr::c#2] = LIGHT_BLUE
[70] clrscr::c#1 = ++ clrscr::c#2
to:clrscr::@3
void test_casting(int signed_short_value)
test_casting: scope:[test_casting] from main::@2
[54] printf_sint::value#1 = test_casting::signed_short_value#0
[55] call printf_sint
[71] printf_sint::value#1 = test_casting::signed_short_value#0
[72] call printf_sint
to:test_casting::@1
test_casting::@1: scope:[test_casting] from test_casting
[56] phi()
[57] call cputs
[73] phi()
[74] call printf_str
to:test_casting::@return
test_casting::@return: scope:[test_casting] from test_casting::@1
[58] return
to:@return
void printf_sint(int value , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
printf_sint: scope:[printf_sint] from test_casting
[59] *((char *)&printf_buffer) = 0
[60] if(printf_sint::value#1<0) goto printf_sint::@1
to:printf_sint::@2
printf_sint::@1: scope:[printf_sint] from printf_sint
[61] printf_sint::value#0 = - printf_sint::value#1
[62] *((char *)&printf_buffer) = '-'
to:printf_sint::@2
printf_sint::@2: scope:[printf_sint] from printf_sint printf_sint::@1
[63] printf_sint::value#4 = phi( printf_sint::@1/printf_sint::value#0, printf_sint/printf_sint::value#1 )
[64] utoa::value#1 = (unsigned int)printf_sint::value#4
[65] call utoa
to:printf_sint::@3
printf_sint::@3: scope:[printf_sint] from printf_sint::@2
[66] printf_number_buffer::buffer_sign#0 = *((char *)&printf_buffer)
[67] call printf_number_buffer
to:printf_sint::@return
printf_sint::@return: scope:[printf_sint] from printf_sint::@3
[68] return
to:@return
void cputs(const char *s)
cputs: scope:[cputs] from printf_number_buffer::@2 test_casting::@1
[69] cputs::s#4 = phi( printf_number_buffer::@2/printf_number_buffer::buffer_digits#0, test_casting::@1/test_casting::s )
to:cputs::@1
cputs::@1: scope:[cputs] from cputs cputs::@2
[70] cputs::s#3 = phi( cputs/cputs::s#4, cputs::@2/cputs::s#0 )
[71] cputs::c#1 = *cputs::s#3
[72] cputs::s#0 = ++ cputs::s#3
[73] if(0!=cputs::c#1) goto cputs::@2
to:cputs::@return
cputs::@return: scope:[cputs] from cputs::@1
[74] return
to:@return
cputs::@2: scope:[cputs] from cputs::@1
[75] cputc::c#0 = cputs::c#1
[76] call cputc
to:cputs::@1
void utoa(unsigned int value , char *buffer , char radix)
utoa: scope:[utoa] from printf_sint::@2
[77] phi()
to:utoa::@1
utoa::@1: scope:[utoa] from utoa utoa::@4
[78] utoa::buffer#11 = phi( utoa::@4/utoa::buffer#14, utoa/(char *)&printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS )
[78] utoa::started#2 = phi( utoa::@4/utoa::started#4, utoa/0 )
[78] utoa::value#2 = phi( utoa::@4/utoa::value#6, utoa/utoa::value#1 )
[78] utoa::digit#2 = phi( utoa::@4/utoa::digit#1, utoa/0 )
[79] if(utoa::digit#2<utoa::max_digits#1-1) goto utoa::@2
to:utoa::@3
utoa::@3: scope:[utoa] from utoa::@1
[80] utoa::$11 = (char)utoa::value#2
[81] *utoa::buffer#11 = DIGITS[utoa::$11]
[82] utoa::buffer#3 = ++ utoa::buffer#11
[83] *utoa::buffer#3 = 0
to:utoa::@return
utoa::@return: scope:[utoa] from utoa::@3
[84] return
to:@return
utoa::@2: scope:[utoa] from utoa::@1
[85] utoa::$10 = utoa::digit#2 << 1
[86] utoa::digit_value#0 = RADIX_DECIMAL_VALUES[utoa::$10]
[87] if(0!=utoa::started#2) goto utoa::@5
to:utoa::@7
utoa::@7: scope:[utoa] from utoa::@2
[88] if(utoa::value#2>=utoa::digit_value#0) goto utoa::@5
to:utoa::@4
utoa::@4: scope:[utoa] from utoa::@6 utoa::@7
[89] utoa::buffer#14 = phi( utoa::@7/utoa::buffer#11, utoa::@6/utoa::buffer#4 )
[89] utoa::started#4 = phi( utoa::@7/utoa::started#2, utoa::@6/1 )
[89] utoa::value#6 = phi( utoa::@7/utoa::value#2, utoa::@6/utoa::value#0 )
[90] utoa::digit#1 = ++ utoa::digit#2
to:utoa::@1
utoa::@5: scope:[utoa] from utoa::@2 utoa::@7
[91] utoa_append::buffer#0 = utoa::buffer#11
[92] utoa_append::value#0 = utoa::value#2
[93] utoa_append::sub#0 = utoa::digit_value#0
[94] call utoa_append
[95] utoa_append::return#0 = utoa_append::value#2
to:utoa::@6
utoa::@6: scope:[utoa] from utoa::@5
[96] utoa::value#0 = utoa_append::return#0
[97] utoa::buffer#4 = ++ utoa::buffer#11
to:utoa::@4
void printf_number_buffer(char buffer_sign , char *buffer_digits , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
printf_number_buffer: scope:[printf_number_buffer] from printf_sint::@3
[98] phi()
to:printf_number_buffer::@1
printf_number_buffer::@1: scope:[printf_number_buffer] from printf_number_buffer
[99] if(0==printf_number_buffer::buffer_sign#0) goto printf_number_buffer::@2
to:printf_number_buffer::@3
printf_number_buffer::@3: scope:[printf_number_buffer] from printf_number_buffer::@1
[100] cputc::c#2 = printf_number_buffer::buffer_sign#0
[101] call cputc
to:printf_number_buffer::@2
printf_number_buffer::@2: scope:[printf_number_buffer] from printf_number_buffer::@1 printf_number_buffer::@3
[102] phi()
[103] call cputs
to:printf_number_buffer::@return
printf_number_buffer::@return: scope:[printf_number_buffer] from printf_number_buffer::@2
[104] return
to:@return
void cputc(char c)
cputc: scope:[cputc] from cputs::@2 printf_number_buffer::@3
[105] cputc::c#3 = phi( cputs::@2/cputc::c#0, printf_number_buffer::@3/cputc::c#2 )
[106] if(cputc::c#3=='
') goto cputc::@1
to:cputc::@2
cputc::@2: scope:[cputc] from cputc
[107] conio_line_text[conio_cursor_x] = cputc::c#3
[108] conio_line_color[conio_cursor_x] = LIGHT_BLUE
[109] conio_cursor_x = ++ conio_cursor_x
[110] if(conio_cursor_x!=$28) goto cputc::@return
to:cputc::@3
cputc::@3: scope:[cputc] from cputc::@2
[111] phi()
[112] call cputln
to:cputc::@return
cputc::@return: scope:[cputc] from cputc::@1 cputc::@2 cputc::@3
[113] return
to:@return
cputc::@1: scope:[cputc] from cputc
[114] phi()
[115] call cputln
to:cputc::@return
unsigned int utoa_append(char *buffer , unsigned int value , unsigned int sub)
utoa_append: scope:[utoa_append] from utoa::@5
[116] phi()
to:utoa_append::@1
utoa_append::@1: scope:[utoa_append] from utoa_append utoa_append::@2
[117] utoa_append::digit#2 = phi( utoa_append/0, utoa_append::@2/utoa_append::digit#1 )
[117] utoa_append::value#2 = phi( utoa_append/utoa_append::value#0, utoa_append::@2/utoa_append::value#1 )
[118] if(utoa_append::value#2>=utoa_append::sub#0) goto utoa_append::@2
to:utoa_append::@3
utoa_append::@3: scope:[utoa_append] from utoa_append::@1
[119] *utoa_append::buffer#0 = DIGITS[utoa_append::digit#2]
to:utoa_append::@return
utoa_append::@return: scope:[utoa_append] from utoa_append::@3
[120] return
to:@return
utoa_append::@2: scope:[utoa_append] from utoa_append::@1
[121] utoa_append::digit#1 = ++ utoa_append::digit#2
[122] utoa_append::value#1 = utoa_append::value#2 - utoa_append::sub#0
to:utoa_append::@1
void cputln()
cputln: scope:[cputln] from cputc::@1 cputc::@3
[123] conio_line_text = conio_line_text + $28
[124] conio_line_color = conio_line_color + $28
[125] conio_cursor_x = 0
[126] conio_cursor_y = ++ conio_cursor_y
[127] call cscroll
to:cputln::@return
cputln::@return: scope:[cputln] from cputln
[128] return
[75] return
to:@return
void cscroll()
cscroll: scope:[cscroll] from cputln
[129] if(conio_cursor_y!=$19) goto cscroll::@return
[76] if(conio_cursor_y!=$19) goto cscroll::@return
to:cscroll::@1
cscroll::@1: scope:[cscroll] from cscroll
[130] phi()
[131] call memcpy
[77] phi()
[78] call memcpy
to:cscroll::@2
cscroll::@2: scope:[cscroll] from cscroll::@1
[132] phi()
[133] call memcpy
[79] phi()
[80] call memcpy
to:cscroll::@3
cscroll::@3: scope:[cscroll] from cscroll::@2
[134] phi()
[135] call memset
[81] phi()
[82] call memset
to:cscroll::@4
cscroll::@4: scope:[cscroll] from cscroll::@3
[136] phi()
[137] call memset
[83] phi()
[84] call memset
to:cscroll::@5
cscroll::@5: scope:[cscroll] from cscroll::@4
[138] conio_line_text = conio_line_text - $28
[139] conio_line_color = conio_line_color - $28
[140] conio_cursor_y = -- conio_cursor_y
[85] conio_line_text = conio_line_text - $28
[86] conio_line_color = conio_line_color - $28
[87] conio_cursor_y = -- conio_cursor_y
to:cscroll::@return
cscroll::@return: scope:[cscroll] from cscroll cscroll::@5
[141] return
[88] return
to:@return
void printf_sint(void (*putc)(char) , int value , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
printf_sint: scope:[printf_sint] from test_casting
[89] *((char *)&printf_buffer) = 0
[90] if(printf_sint::value#1<0) goto printf_sint::@1
to:printf_sint::@2
printf_sint::@1: scope:[printf_sint] from printf_sint
[91] printf_sint::value#0 = - printf_sint::value#1
[92] *((char *)&printf_buffer) = '-'
to:printf_sint::@2
printf_sint::@2: scope:[printf_sint] from printf_sint printf_sint::@1
[93] printf_sint::value#4 = phi( printf_sint::@1/printf_sint::value#0, printf_sint/printf_sint::value#1 )
[94] utoa::value#1 = (unsigned int)printf_sint::value#4
[95] call utoa
to:printf_sint::@3
printf_sint::@3: scope:[printf_sint] from printf_sint::@2
[96] printf_number_buffer::buffer_sign#0 = *((char *)&printf_buffer)
[97] call printf_number_buffer
to:printf_sint::@return
printf_sint::@return: scope:[printf_sint] from printf_sint::@3
[98] return
to:@return
void printf_str(void (*putc)(char) , const char *s)
printf_str: scope:[printf_str] from printf_number_buffer::@2 test_casting::@1
[99] printf_str::putc#4 = phi( printf_number_buffer::@2/printf_sint::putc#0, test_casting::@1/&cputc )
[99] printf_str::s#4 = phi( printf_number_buffer::@2/printf_number_buffer::buffer_digits#0, test_casting::@1/test_casting::s )
to:printf_str::@1
printf_str::@1: scope:[printf_str] from printf_str printf_str::@2
[100] printf_str::s#3 = phi( printf_str/printf_str::s#4, printf_str::@2/printf_str::s#0 )
[101] printf_str::c#1 = *printf_str::s#3
[102] printf_str::s#0 = ++ printf_str::s#3
[103] if(0!=printf_str::c#1) goto printf_str::@2
to:printf_str::@return
printf_str::@return: scope:[printf_str] from printf_str::@1
[104] return
to:@return
printf_str::@2: scope:[printf_str] from printf_str::@1
[105] stackpush(char) = printf_str::c#1
[106] callexecute *printf_str::putc#4
sideeffect stackpullbytes(1)
to:printf_str::@1
void * memcpy(void *destination , void *source , unsigned int num)
memcpy: scope:[memcpy] from cscroll::@1 cscroll::@2
[142] memcpy::destination#2 = phi( cscroll::@1/(void *)DEFAULT_SCREEN, cscroll::@2/(void *)COLORRAM )
[142] memcpy::source#2 = phi( cscroll::@1/(void *)DEFAULT_SCREEN+$28, cscroll::@2/(void *)COLORRAM+$28 )
[143] memcpy::src_end#0 = (char *)memcpy::source#2 + (unsigned int)$19*$28-$28
[144] memcpy::src#4 = (char *)memcpy::source#2
[145] memcpy::dst#4 = (char *)memcpy::destination#2
[108] memcpy::destination#2 = phi( cscroll::@1/(void *)DEFAULT_SCREEN, cscroll::@2/(void *)COLORRAM )
[108] memcpy::source#2 = phi( cscroll::@1/(void *)DEFAULT_SCREEN+$28, cscroll::@2/(void *)COLORRAM+$28 )
[109] memcpy::src_end#0 = (char *)memcpy::source#2 + (unsigned int)$19*$28-$28
[110] memcpy::src#4 = (char *)memcpy::source#2
[111] memcpy::dst#4 = (char *)memcpy::destination#2
to:memcpy::@1
memcpy::@1: scope:[memcpy] from memcpy memcpy::@2
[146] memcpy::dst#2 = phi( memcpy/memcpy::dst#4, memcpy::@2/memcpy::dst#1 )
[146] memcpy::src#2 = phi( memcpy/memcpy::src#4, memcpy::@2/memcpy::src#1 )
[147] if(memcpy::src#2!=memcpy::src_end#0) goto memcpy::@2
[112] memcpy::dst#2 = phi( memcpy/memcpy::dst#4, memcpy::@2/memcpy::dst#1 )
[112] memcpy::src#2 = phi( memcpy/memcpy::src#4, memcpy::@2/memcpy::src#1 )
[113] if(memcpy::src#2!=memcpy::src_end#0) goto memcpy::@2
to:memcpy::@return
memcpy::@return: scope:[memcpy] from memcpy::@1
[148] return
[114] return
to:@return
memcpy::@2: scope:[memcpy] from memcpy::@1
[149] *memcpy::dst#2 = *memcpy::src#2
[150] memcpy::dst#1 = ++ memcpy::dst#2
[151] memcpy::src#1 = ++ memcpy::src#2
[115] *memcpy::dst#2 = *memcpy::src#2
[116] memcpy::dst#1 = ++ memcpy::dst#2
[117] memcpy::src#1 = ++ memcpy::src#2
to:memcpy::@1
void * memset(void *str , char c , unsigned int num)
memset: scope:[memset] from cscroll::@3 cscroll::@4
[152] memset::c#4 = phi( cscroll::@3/' ', cscroll::@4/LIGHT_BLUE )
[152] memset::str#3 = phi( cscroll::@3/(void *)DEFAULT_SCREEN+(unsigned int)$19*$28-$28, cscroll::@4/(void *)COLORRAM+(unsigned int)$19*$28-$28 )
[118] memset::c#4 = phi( cscroll::@3/' ', cscroll::@4/LIGHT_BLUE )
[118] memset::str#3 = phi( cscroll::@3/(void *)DEFAULT_SCREEN+(unsigned int)$19*$28-$28, cscroll::@4/(void *)COLORRAM+(unsigned int)$19*$28-$28 )
to:memset::@1
memset::@1: scope:[memset] from memset
[153] memset::end#0 = (char *)memset::str#3 + $28
[154] memset::dst#4 = (char *)memset::str#3
[119] memset::end#0 = (char *)memset::str#3 + $28
[120] memset::dst#4 = (char *)memset::str#3
to:memset::@2
memset::@2: scope:[memset] from memset::@1 memset::@3
[155] memset::dst#2 = phi( memset::@1/memset::dst#4, memset::@3/memset::dst#1 )
[156] if(memset::dst#2!=memset::end#0) goto memset::@3
[121] memset::dst#2 = phi( memset::@1/memset::dst#4, memset::@3/memset::dst#1 )
[122] if(memset::dst#2!=memset::end#0) goto memset::@3
to:memset::@return
memset::@return: scope:[memset] from memset::@2
[157] return
[123] return
to:@return
memset::@3: scope:[memset] from memset::@2
[158] *memset::dst#2 = memset::c#4
[159] memset::dst#1 = ++ memset::dst#2
[124] *memset::dst#2 = memset::c#4
[125] memset::dst#1 = ++ memset::dst#2
to:memset::@2
void utoa(unsigned int value , char *buffer , char radix)
utoa: scope:[utoa] from printf_sint::@2
[126] phi()
to:utoa::@1
utoa::@1: scope:[utoa] from utoa utoa::@4
[127] utoa::buffer#11 = phi( utoa::@4/utoa::buffer#14, utoa/(char *)&printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS )
[127] utoa::started#2 = phi( utoa::@4/utoa::started#4, utoa/0 )
[127] utoa::value#2 = phi( utoa::@4/utoa::value#6, utoa/utoa::value#1 )
[127] utoa::digit#2 = phi( utoa::@4/utoa::digit#1, utoa/0 )
[128] if(utoa::digit#2<utoa::max_digits#1-1) goto utoa::@2
to:utoa::@3
utoa::@3: scope:[utoa] from utoa::@1
[129] utoa::$11 = (char)utoa::value#2
[130] *utoa::buffer#11 = DIGITS[utoa::$11]
[131] utoa::buffer#3 = ++ utoa::buffer#11
[132] *utoa::buffer#3 = 0
to:utoa::@return
utoa::@return: scope:[utoa] from utoa::@3
[133] return
to:@return
utoa::@2: scope:[utoa] from utoa::@1
[134] utoa::$10 = utoa::digit#2 << 1
[135] utoa::digit_value#0 = RADIX_DECIMAL_VALUES[utoa::$10]
[136] if(0!=utoa::started#2) goto utoa::@5
to:utoa::@7
utoa::@7: scope:[utoa] from utoa::@2
[137] if(utoa::value#2>=utoa::digit_value#0) goto utoa::@5
to:utoa::@4
utoa::@4: scope:[utoa] from utoa::@6 utoa::@7
[138] utoa::buffer#14 = phi( utoa::@7/utoa::buffer#11, utoa::@6/utoa::buffer#4 )
[138] utoa::started#4 = phi( utoa::@7/utoa::started#2, utoa::@6/1 )
[138] utoa::value#6 = phi( utoa::@7/utoa::value#2, utoa::@6/utoa::value#0 )
[139] utoa::digit#1 = ++ utoa::digit#2
to:utoa::@1
utoa::@5: scope:[utoa] from utoa::@2 utoa::@7
[140] utoa_append::buffer#0 = utoa::buffer#11
[141] utoa_append::value#0 = utoa::value#2
[142] utoa_append::sub#0 = utoa::digit_value#0
[143] call utoa_append
[144] utoa_append::return#0 = utoa_append::value#2
to:utoa::@6
utoa::@6: scope:[utoa] from utoa::@5
[145] utoa::value#0 = utoa_append::return#0
[146] utoa::buffer#4 = ++ utoa::buffer#11
to:utoa::@4
void printf_number_buffer(void (*putc)(char) , char buffer_sign , char *buffer_digits , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
printf_number_buffer: scope:[printf_number_buffer] from printf_sint::@3
[147] phi()
to:printf_number_buffer::@1
printf_number_buffer::@1: scope:[printf_number_buffer] from printf_number_buffer
[148] if(0==printf_number_buffer::buffer_sign#0) goto printf_number_buffer::@2
to:printf_number_buffer::@3
printf_number_buffer::@3: scope:[printf_number_buffer] from printf_number_buffer::@1
[149] stackpush(char) = printf_number_buffer::buffer_sign#0
[150] callexecute cputc
sideeffect stackpullbytes(1)
to:printf_number_buffer::@2
printf_number_buffer::@2: scope:[printf_number_buffer] from printf_number_buffer::@1 printf_number_buffer::@3
[152] phi()
[153] call printf_str
to:printf_number_buffer::@return
printf_number_buffer::@return: scope:[printf_number_buffer] from printf_number_buffer::@2
[154] return
to:@return
unsigned int utoa_append(char *buffer , unsigned int value , unsigned int sub)
utoa_append: scope:[utoa_append] from utoa::@5
[155] phi()
to:utoa_append::@1
utoa_append::@1: scope:[utoa_append] from utoa_append utoa_append::@2
[156] utoa_append::digit#2 = phi( utoa_append/0, utoa_append::@2/utoa_append::digit#1 )
[156] utoa_append::value#2 = phi( utoa_append/utoa_append::value#0, utoa_append::@2/utoa_append::value#1 )
[157] if(utoa_append::value#2>=utoa_append::sub#0) goto utoa_append::@2
to:utoa_append::@3
utoa_append::@3: scope:[utoa_append] from utoa_append::@1
[158] *utoa_append::buffer#0 = DIGITS[utoa_append::digit#2]
to:utoa_append::@return
utoa_append::@return: scope:[utoa_append] from utoa_append::@3
[159] return
to:@return
utoa_append::@2: scope:[utoa_append] from utoa_append::@1
[160] utoa_append::digit#1 = ++ utoa_append::digit#2
[161] utoa_append::value#1 = utoa_append::value#2 - utoa_append::sub#0
to:utoa_append::@1

File diff suppressed because one or more lines are too long

View File

@ -9,6 +9,7 @@ __constant char RADIX::HEXADECIMAL = $10
__constant char RADIX::OCTAL = 8
__constant unsigned int RADIX_DECIMAL_VALUES[] = { $2710, $3e8, $64, $a }
__constant char SIZEOF_STRUCT_PRINTF_BUFFER_NUMBER = $c
__constant unsigned int STACK_BASE = $103
void __start()
void clrscr()
char clrscr::c
@ -18,8 +19,8 @@ char clrscr::l
char clrscr::l#1 // reg byte x 2002.0
char clrscr::l#2 // reg byte x 333.6666666666667
char *clrscr::line_cols
char *clrscr::line_cols#1 // line_cols zp[2]:5 1001.0
char *clrscr::line_cols#5 // line_cols zp[2]:5 1500.375
char *clrscr::line_cols#1 // line_cols zp[2]:26 1001.0
char *clrscr::line_cols#5 // line_cols zp[2]:26 1500.375
char *clrscr::line_text
char *clrscr::line_text#1 // line_text zp[2]:3 667.3333333333334
char *clrscr::line_text#5 // line_text zp[2]:3 1714.7142857142858
@ -28,23 +29,15 @@ __constant char * const conio_c64_init::BASIC_CURSOR_LINE = (char *) 214
char conio_c64_init::line
char conio_c64_init::line#0 // reg byte x 11.0
char conio_c64_init::line#2 // reg byte x 22.0
__loadstore char conio_cursor_x // zp[1]:10 2.777777816666666E8
__loadstore char conio_cursor_y // zp[1]:11 4.571428574414286E9
__loadstore char *conio_line_color // zp[2]:14 3.2500000030735292E9
__loadstore char *conio_line_text // zp[2]:12 3.202898553753623E9
void cputc(char c)
__loadstore char conio_cursor_x // zp[1]:10 319153.40425531915
__loadstore char conio_cursor_y // zp[1]:11 5079368.396825396
__loadstore char *conio_line_color // zp[2]:14 3622954.2459016396
__loadstore char *conio_line_text // zp[2]:12 3564519.5
__stackcall void cputc(char c)
__constant char cputc::OFFSET_STACK_C = 0
char cputc::c
char cputc::c#0 // reg byte a 2.00000002E8
char cputc::c#2 // reg byte a 200002.0
char cputc::c#3 // reg byte a 1.050050002E9
char cputc::c#0 // reg byte a 1500001.5
void cputln()
void cputs(const char *s)
char cputs::c
char cputs::c#1 // reg byte a 1.00000001E8
const char *cputs::s
const char *cputs::s#0 // s zp[2]:5 5.00000005E7
const char *cputs::s#3 // s zp[2]:5 1.50500002E8
const char *cputs::s#4 // s zp[2]:5 1000001.0
void cscroll()
void gotoxy(char x , char y)
char *gotoxy::$5 // zp[2]:20 202.0
@ -65,36 +58,36 @@ signed char main::signed_char_value#1 // signed_char_value zp[1]:2 101.0
signed char main::signed_char_value#2 // signed_char_value zp[1]:2 151.5
void * memcpy(void *destination , void *source , unsigned int num)
void *memcpy::destination
void *memcpy::destination#2 // destination zp[2]:8
void *memcpy::destination#2 // destination zp[2]:24
char *memcpy::dst
char *memcpy::dst#1 // dst zp[2]:8 1.000000000000001E15
char *memcpy::dst#2 // dst zp[2]:8 1.0003333333333348E15
char *memcpy::dst#4 // dst zp[2]:8 2.000000000002E12
char *memcpy::dst#1 // dst zp[2]:24 1.00000000001E11
char *memcpy::dst#2 // dst zp[2]:24 1.0033333333466667E11
char *memcpy::dst#4 // dst zp[2]:24 2.000000002E9
unsigned int memcpy::num
void *memcpy::return
void *memcpy::source
void *memcpy::source#2 // source zp[2]:24
void *memcpy::source#2 // source zp[2]:5
char *memcpy::src
char *memcpy::src#1 // src zp[2]:24 2.000000000000002E15
char *memcpy::src#2 // src zp[2]:24 1.0002500000000012E15
char *memcpy::src#4 // src zp[2]:24 1.000000000001E12
char *memcpy::src#1 // src zp[2]:5 2.00000000002E11
char *memcpy::src#2 // src zp[2]:5 1.0025000000125E11
char *memcpy::src#4 // src zp[2]:5 1.000000001E9
char *memcpy::src_end
char *memcpy::src_end#0 // src_end zp[2]:22 1.2512500000000025E14
char *memcpy::src_end#0 // src_end zp[2]:22 1.262500000025E10
void * memset(void *str , char c , unsigned int num)
char memset::c
char memset::c#4 // reg byte x 1.42857142857143E14
char memset::c#4 // reg byte x 1.4285714285857143E10
char *memset::dst
char *memset::dst#1 // dst zp[2]:8 2.000000000000002E15
char *memset::dst#2 // dst zp[2]:8 1.3336666666666685E15
char *memset::dst#4 // dst zp[2]:8 2.000000000002E12
char *memset::dst#1 // dst zp[2]:5 2.00000000002E11
char *memset::dst#2 // dst zp[2]:5 1.3366666666833334E11
char *memset::dst#4 // dst zp[2]:5 2.000000002E9
char *memset::end
char *memset::end#0 // end zp[2]:24 1.668333333333337E14
char *memset::end#0 // end zp[2]:24 1.6833333333666668E10
unsigned int memset::num
void *memset::return
void *memset::str
void *memset::str#3 // str zp[2]:8
void *memset::str#3 // str zp[2]:5
__loadstore struct printf_buffer_number printf_buffer = {} // mem[12]
void printf_number_buffer(char buffer_sign , char *buffer_digits , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
void printf_number_buffer(void (*putc)(char) , char buffer_sign , char *buffer_digits , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
struct printf_buffer_number printf_number_buffer::buffer
char *printf_number_buffer::buffer_digits
__constant char *printf_number_buffer::buffer_digits#0 = (char *)&printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS // buffer_digits
@ -109,7 +102,8 @@ char printf_number_buffer::format_upper_case
char printf_number_buffer::format_zero_padding
signed char printf_number_buffer::len
signed char printf_number_buffer::padding
void printf_sint(int value , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
void (*printf_number_buffer::putc)(char)
void printf_sint(void (*putc)(char) , int value , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
struct printf_format_number printf_sint::format
char printf_sint::format_justify_left
char printf_sint::format_min_length
@ -117,11 +111,22 @@ char printf_sint::format_radix
char printf_sint::format_sign_always
char printf_sint::format_upper_case
char printf_sint::format_zero_padding
void (*printf_sint::putc)(char)
__constant void (*printf_sint::putc#0)(char) = &cputc // putc
unsigned int printf_sint::uvalue
int printf_sint::value
int printf_sint::value#0 // value zp[2]:3 10001.0
int printf_sint::value#1 // value zp[2]:3 10334.666666666666
int printf_sint::value#4 // value zp[2]:3 20002.0
void printf_str(void (*putc)(char) , const char *s)
char printf_str::c
char printf_str::c#1 // reg byte a 1.00000001E8
void (*printf_str::putc)(char)
void (*printf_str::putc#4)(char) // putc zp[2]:26
const char *printf_str::s
const char *printf_str::s#0 // s zp[2]:8 1.00000001E8
const char *printf_str::s#3 // s zp[2]:8 1.50500002E8
const char *printf_str::s#4 // s zp[2]:8 1000001.0
void test_casting(int signed_short_value)
__constant char test_casting::s[2] = "
"
@ -131,15 +136,15 @@ void utoa(unsigned int value , char *buffer , char radix)
char utoa::$10 // reg byte a 2.0000002E7
char utoa::$11 // reg byte x 200002.0
char *utoa::buffer
char *utoa::buffer#11 // buffer zp[2]:24 2871429.0
char *utoa::buffer#14 // buffer zp[2]:24 1.50000015E7
char *utoa::buffer#3 // buffer zp[2]:24 200002.0
char *utoa::buffer#4 // buffer zp[2]:24 2.0000002E7
char *utoa::buffer#11 // buffer zp[2]:8 2871429.0
char *utoa::buffer#14 // buffer zp[2]:8 1.50000015E7
char *utoa::buffer#3 // buffer zp[2]:8 200002.0
char *utoa::buffer#4 // buffer zp[2]:8 2.0000002E7
char utoa::digit
char utoa::digit#1 // digit zp[1]:7 2.0000002E7
char utoa::digit#2 // digit zp[1]:7 2857143.1428571427
unsigned int utoa::digit_value
unsigned int utoa::digit_value#0 // digit_value zp[2]:22 6000000.6
unsigned int utoa::digit_value#0 // digit_value zp[2]:26 6000000.6
unsigned int *utoa::digit_values
char utoa::max_digits
__constant char utoa::max_digits#1 = 5 // max_digits
@ -154,14 +159,14 @@ unsigned int utoa::value#2 // value zp[2]:3 5728572.142857142
unsigned int utoa::value#6 // value zp[2]:3 1.50000015E7
unsigned int utoa_append(char *buffer , unsigned int value , unsigned int sub)
char *utoa_append::buffer
char *utoa_append::buffer#0 // buffer zp[2]:24 1.375000025E7
char *utoa_append::buffer#0 // buffer zp[2]:8 1.375000025E7
char utoa_append::digit
char utoa_append::digit#1 // reg byte x 1.00000000001E11
char utoa_append::digit#2 // reg byte x 1.000500000015E11
unsigned int utoa_append::return
unsigned int utoa_append::return#0 // return zp[2]:3 2.0000002E7
unsigned int utoa_append::sub
unsigned int utoa_append::sub#0 // sub zp[2]:22 3.33350000005E10
unsigned int utoa_append::sub#0 // sub zp[2]:26 3.33350000005E10
unsigned int utoa_append::value
unsigned int utoa_append::value#0 // value zp[2]:3 3.6666667333333336E7
unsigned int utoa_append::value#1 // value zp[2]:3 2.00000000002E11
@ -173,24 +178,25 @@ reg byte x [ gotoxy::y#4 gotoxy::y#2 ]
reg byte x [ clrscr::l#2 clrscr::l#1 ]
reg byte y [ clrscr::c#2 clrscr::c#1 ]
zp[2]:3 [ printf_sint::value#4 printf_sint::value#0 printf_sint::value#1 utoa::value#2 utoa::value#6 utoa::value#1 utoa::value#0 test_casting::signed_short_value#0 utoa_append::value#2 utoa_append::value#0 utoa_append::value#1 utoa_append::return#0 clrscr::line_text#5 clrscr::line_text#1 ]
zp[2]:5 [ cputs::s#3 cputs::s#4 cputs::s#0 clrscr::line_cols#5 clrscr::line_cols#1 ]
zp[2]:5 [ memset::str#3 memset::dst#2 memset::dst#4 memset::dst#1 memcpy::source#2 memcpy::src#2 memcpy::src#4 memcpy::src#1 ]
reg byte x [ memset::c#4 ]
zp[1]:7 [ utoa::digit#2 utoa::digit#1 ]
reg byte x [ utoa::started#2 utoa::started#4 ]
reg byte a [ cputc::c#3 cputc::c#0 cputc::c#2 ]
zp[2]:8 [ utoa::buffer#11 utoa::buffer#14 utoa::buffer#4 utoa::buffer#3 utoa_append::buffer#0 printf_str::s#3 printf_str::s#4 printf_str::s#0 ]
reg byte x [ utoa_append::digit#2 utoa_append::digit#1 ]
zp[2]:8 [ memset::str#3 memset::dst#2 memset::dst#4 memset::dst#1 memcpy::destination#2 memcpy::dst#2 memcpy::dst#4 memcpy::dst#1 ]
reg byte x [ memset::c#4 ]
zp[1]:10 [ conio_cursor_x ]
zp[1]:11 [ conio_cursor_y ]
zp[2]:12 [ conio_line_text ]
zp[2]:14 [ conio_line_color ]
reg byte a [ cputc::c#0 ]
zp[2]:16 [ gotoxy::$7 gotoxy::$9 gotoxy::line_offset#0 gotoxy::$6 ]
zp[2]:18 [ gotoxy::$8 ]
zp[2]:20 [ gotoxy::$5 ]
reg byte a [ printf_number_buffer::buffer_sign#0 ]
reg byte a [ cputs::c#1 ]
reg byte a [ printf_str::c#1 ]
zp[2]:22 [ memcpy::src_end#0 ]
zp[2]:24 [ memset::end#0 memcpy::destination#2 memcpy::dst#2 memcpy::dst#4 memcpy::dst#1 ]
reg byte x [ utoa::$11 ]
reg byte a [ utoa::$10 ]
zp[2]:22 [ memcpy::src_end#0 utoa::digit_value#0 utoa_append::sub#0 ]
zp[2]:24 [ memset::end#0 memcpy::source#2 memcpy::src#2 memcpy::src#4 memcpy::src#1 utoa::buffer#11 utoa::buffer#14 utoa::buffer#4 utoa::buffer#3 utoa_append::buffer#0 ]
zp[2]:26 [ utoa::digit_value#0 utoa_append::sub#0 printf_str::putc#4 clrscr::line_cols#5 clrscr::line_cols#1 ]
mem[12] [ printf_buffer ]

View File

@ -9,6 +9,7 @@
.segment Basic
:BasicUpstart(__start)
.const LIGHT_BLUE = $e
.const STACK_BASE = $103
/// Color Ram
.label COLORRAM = $d800
/// Default address of screen character matrix
@ -60,9 +61,40 @@ conio_c64_init: {
// }
rts
}
// Output one character at the current cursor position
// Moves the cursor forward. Scrolls the entire screen if needed
// void cputc(__register(A) char c)
cputc: {
.const OFFSET_STACK_C = 0
tsx
lda STACK_BASE+OFFSET_STACK_C,x
// if(c=='\n')
cmp #'\n'
beq __b1
// conio_line_text[conio_cursor_x] = c
ldy.z conio_cursor_x
sta (conio_line_text),y
// conio_line_color[conio_cursor_x] = conio_textcolor
lda #LIGHT_BLUE
sta (conio_line_color),y
// if(++conio_cursor_x==CONIO_WIDTH)
inc.z conio_cursor_x
lda #$28
cmp.z conio_cursor_x
bne __breturn
// cputln()
jsr cputln
__breturn:
// }
rts
__b1:
// cputln()
jsr cputln
rts
}
main: {
// printf("hello world!\n")
jsr cputs
jsr printf_str
// }
rts
.segment Data
@ -145,59 +177,6 @@ gotoxy: {
// }
rts
}
// Output a NUL-terminated string at the current cursor position
// void cputs(__zp(2) const char *s)
cputs: {
.label s = 2
lda #<main.s
sta.z s
lda #>main.s
sta.z s+1
__b1:
// while(c=*s++)
ldy #0
lda (s),y
inc.z s
bne !+
inc.z s+1
!:
cmp #0
bne __b2
// }
rts
__b2:
// cputc(c)
jsr cputc
jmp __b1
}
// Output one character at the current cursor position
// Moves the cursor forward. Scrolls the entire screen if needed
// void cputc(__register(A) char c)
cputc: {
// if(c=='\n')
cmp #'\n'
beq __b1
// conio_line_text[conio_cursor_x] = c
ldy.z conio_cursor_x
sta (conio_line_text),y
// conio_line_color[conio_cursor_x] = conio_textcolor
lda #LIGHT_BLUE
sta (conio_line_color),y
// if(++conio_cursor_x==CONIO_WIDTH)
inc.z conio_cursor_x
lda #$28
cmp.z conio_cursor_x
bne __breturn
// cputln()
jsr cputln
__breturn:
// }
rts
__b1:
// cputln()
jsr cputln
rts
}
// Print a newline
cputln: {
// conio_line_text += CONIO_WIDTH
@ -226,6 +205,33 @@ cputln: {
// }
rts
}
/// Print a NUL-terminated string
// void printf_str(void (*putc)(char), __zp(2) const char *s)
printf_str: {
.label s = 2
lda #<main.s
sta.z s
lda #>main.s
sta.z s+1
__b1:
// while(c=*s++)
ldy #0
lda (s),y
inc.z s
bne !+
inc.z s+1
!:
cmp #0
bne __b2
// }
rts
__b2:
// putc(c)
pha
jsr cputc
pla
jmp __b1
}
// Scroll the entire screen if the cursor is beyond the last line
cscroll: {
// if(conio_cursor_y==CONIO_HEIGHT)

View File

@ -35,162 +35,164 @@ conio_c64_init::@return: scope:[conio_c64_init] from conio_c64_init::@1
[15] return
to:@return
__stackcall void cputc(char c)
cputc: scope:[cputc] from printf_str::@2
[16] cputc::c#0 = stackidx(char,cputc::OFFSET_STACK_C)
[17] if(cputc::c#0=='
') goto cputc::@1
to:cputc::@2
cputc::@2: scope:[cputc] from cputc
[18] conio_line_text[conio_cursor_x] = cputc::c#0
[19] conio_line_color[conio_cursor_x] = LIGHT_BLUE
[20] conio_cursor_x = ++ conio_cursor_x
[21] if(conio_cursor_x!=$28) goto cputc::@return
to:cputc::@3
cputc::@3: scope:[cputc] from cputc::@2
[22] phi()
[23] call cputln
to:cputc::@return
cputc::@return: scope:[cputc] from cputc::@1 cputc::@2 cputc::@3
[24] return
to:@return
cputc::@1: scope:[cputc] from cputc
[25] phi()
[26] call cputln
to:cputc::@return
void main()
main: scope:[main] from __start::@1
[16] phi()
[17] call cputs
[27] phi()
[28] call printf_str
to:main::@return
main::@return: scope:[main] from main
[18] return
[29] return
to:@return
void gotoxy(char x , char y)
gotoxy: scope:[gotoxy] from conio_c64_init::@1
[19] if(gotoxy::y#2<$19+1) goto gotoxy::@3
[30] if(gotoxy::y#2<$19+1) goto gotoxy::@3
to:gotoxy::@1
gotoxy::@3: scope:[gotoxy] from gotoxy
[20] phi()
[31] phi()
to:gotoxy::@1
gotoxy::@1: scope:[gotoxy] from gotoxy gotoxy::@3
[21] gotoxy::y#4 = phi( gotoxy::@3/gotoxy::y#2, gotoxy/0 )
[32] gotoxy::y#4 = phi( gotoxy::@3/gotoxy::y#2, gotoxy/0 )
to:gotoxy::@2
gotoxy::@2: scope:[gotoxy] from gotoxy::@1
[22] conio_cursor_x = gotoxy::x#2
[23] conio_cursor_y = gotoxy::y#4
[24] gotoxy::$7 = (unsigned int)gotoxy::y#4
[25] gotoxy::$8 = gotoxy::$7 << 2
[26] gotoxy::$9 = gotoxy::$8 + gotoxy::$7
[27] gotoxy::line_offset#0 = gotoxy::$9 << 3
[28] gotoxy::$5 = DEFAULT_SCREEN + gotoxy::line_offset#0
[29] conio_line_text = gotoxy::$5
[30] gotoxy::$6 = COLORRAM + gotoxy::line_offset#0
[31] conio_line_color = gotoxy::$6
[33] conio_cursor_x = gotoxy::x#2
[34] conio_cursor_y = gotoxy::y#4
[35] gotoxy::$7 = (unsigned int)gotoxy::y#4
[36] gotoxy::$8 = gotoxy::$7 << 2
[37] gotoxy::$9 = gotoxy::$8 + gotoxy::$7
[38] gotoxy::line_offset#0 = gotoxy::$9 << 3
[39] gotoxy::$5 = DEFAULT_SCREEN + gotoxy::line_offset#0
[40] conio_line_text = gotoxy::$5
[41] gotoxy::$6 = COLORRAM + gotoxy::line_offset#0
[42] conio_line_color = gotoxy::$6
to:gotoxy::@return
gotoxy::@return: scope:[gotoxy] from gotoxy::@2
[32] return
[43] return
to:@return
void cputs(const char *s)
cputs: scope:[cputs] from main
[33] phi()
to:cputs::@1
cputs::@1: scope:[cputs] from cputs cputs::@2
[34] cputs::s#2 = phi( cputs/main::s, cputs::@2/cputs::s#0 )
[35] cputs::c#1 = *cputs::s#2
[36] cputs::s#0 = ++ cputs::s#2
[37] if(0!=cputs::c#1) goto cputs::@2
to:cputs::@return
cputs::@return: scope:[cputs] from cputs::@1
[38] return
to:@return
cputs::@2: scope:[cputs] from cputs::@1
[39] cputc::c#0 = cputs::c#1
[40] call cputc
to:cputs::@1
void cputc(char c)
cputc: scope:[cputc] from cputs::@2
[41] if(cputc::c#0=='
') goto cputc::@1
to:cputc::@2
cputc::@2: scope:[cputc] from cputc
[42] conio_line_text[conio_cursor_x] = cputc::c#0
[43] conio_line_color[conio_cursor_x] = LIGHT_BLUE
[44] conio_cursor_x = ++ conio_cursor_x
[45] if(conio_cursor_x!=$28) goto cputc::@return
to:cputc::@3
cputc::@3: scope:[cputc] from cputc::@2
[46] phi()
[47] call cputln
to:cputc::@return
cputc::@return: scope:[cputc] from cputc::@1 cputc::@2 cputc::@3
[48] return
to:@return
cputc::@1: scope:[cputc] from cputc
[49] phi()
[50] call cputln
to:cputc::@return
void cputln()
cputln: scope:[cputln] from cputc::@1 cputc::@3
[51] conio_line_text = conio_line_text + $28
[52] conio_line_color = conio_line_color + $28
[53] conio_cursor_x = 0
[54] conio_cursor_y = ++ conio_cursor_y
[55] call cscroll
[44] conio_line_text = conio_line_text + $28
[45] conio_line_color = conio_line_color + $28
[46] conio_cursor_x = 0
[47] conio_cursor_y = ++ conio_cursor_y
[48] call cscroll
to:cputln::@return
cputln::@return: scope:[cputln] from cputln
[56] return
[49] return
to:@return
void printf_str(void (*putc)(char) , const char *s)
printf_str: scope:[printf_str] from main
[50] phi()
to:printf_str::@1
printf_str::@1: scope:[printf_str] from printf_str printf_str::@2
[51] printf_str::s#2 = phi( printf_str/main::s, printf_str::@2/printf_str::s#0 )
[52] printf_str::c#1 = *printf_str::s#2
[53] printf_str::s#0 = ++ printf_str::s#2
[54] if(0!=printf_str::c#1) goto printf_str::@2
to:printf_str::@return
printf_str::@return: scope:[printf_str] from printf_str::@1
[55] return
to:@return
printf_str::@2: scope:[printf_str] from printf_str::@1
[56] stackpush(char) = printf_str::c#1
[57] callexecute cputc
sideeffect stackpullbytes(1)
to:printf_str::@1
void cscroll()
cscroll: scope:[cscroll] from cputln
[57] if(conio_cursor_y!=$19) goto cscroll::@return
[59] if(conio_cursor_y!=$19) goto cscroll::@return
to:cscroll::@1
cscroll::@1: scope:[cscroll] from cscroll
[58] phi()
[59] call memcpy
to:cscroll::@2
cscroll::@2: scope:[cscroll] from cscroll::@1
[60] phi()
[61] call memcpy
to:cscroll::@2
cscroll::@2: scope:[cscroll] from cscroll::@1
[62] phi()
[63] call memcpy
to:cscroll::@3
cscroll::@3: scope:[cscroll] from cscroll::@2
[62] phi()
[63] call memset
to:cscroll::@4
cscroll::@4: scope:[cscroll] from cscroll::@3
[64] phi()
[65] call memset
to:cscroll::@4
cscroll::@4: scope:[cscroll] from cscroll::@3
[66] phi()
[67] call memset
to:cscroll::@5
cscroll::@5: scope:[cscroll] from cscroll::@4
[66] conio_line_text = conio_line_text - $28
[67] conio_line_color = conio_line_color - $28
[68] conio_cursor_y = -- conio_cursor_y
[68] conio_line_text = conio_line_text - $28
[69] conio_line_color = conio_line_color - $28
[70] conio_cursor_y = -- conio_cursor_y
to:cscroll::@return
cscroll::@return: scope:[cscroll] from cscroll cscroll::@5
[69] return
[71] return
to:@return
void * memcpy(void *destination , void *source , unsigned int num)
memcpy: scope:[memcpy] from cscroll::@1 cscroll::@2
[70] memcpy::destination#2 = phi( cscroll::@1/(void *)DEFAULT_SCREEN, cscroll::@2/(void *)COLORRAM )
[70] memcpy::source#2 = phi( cscroll::@1/(void *)DEFAULT_SCREEN+$28, cscroll::@2/(void *)COLORRAM+$28 )
[71] memcpy::src_end#0 = (char *)memcpy::source#2 + (unsigned int)$19*$28-$28
[72] memcpy::src#4 = (char *)memcpy::source#2
[73] memcpy::dst#4 = (char *)memcpy::destination#2
[72] memcpy::destination#2 = phi( cscroll::@1/(void *)DEFAULT_SCREEN, cscroll::@2/(void *)COLORRAM )
[72] memcpy::source#2 = phi( cscroll::@1/(void *)DEFAULT_SCREEN+$28, cscroll::@2/(void *)COLORRAM+$28 )
[73] memcpy::src_end#0 = (char *)memcpy::source#2 + (unsigned int)$19*$28-$28
[74] memcpy::src#4 = (char *)memcpy::source#2
[75] memcpy::dst#4 = (char *)memcpy::destination#2
to:memcpy::@1
memcpy::@1: scope:[memcpy] from memcpy memcpy::@2
[74] memcpy::dst#2 = phi( memcpy/memcpy::dst#4, memcpy::@2/memcpy::dst#1 )
[74] memcpy::src#2 = phi( memcpy/memcpy::src#4, memcpy::@2/memcpy::src#1 )
[75] if(memcpy::src#2!=memcpy::src_end#0) goto memcpy::@2
[76] memcpy::dst#2 = phi( memcpy/memcpy::dst#4, memcpy::@2/memcpy::dst#1 )
[76] memcpy::src#2 = phi( memcpy/memcpy::src#4, memcpy::@2/memcpy::src#1 )
[77] if(memcpy::src#2!=memcpy::src_end#0) goto memcpy::@2
to:memcpy::@return
memcpy::@return: scope:[memcpy] from memcpy::@1
[76] return
[78] return
to:@return
memcpy::@2: scope:[memcpy] from memcpy::@1
[77] *memcpy::dst#2 = *memcpy::src#2
[78] memcpy::dst#1 = ++ memcpy::dst#2
[79] memcpy::src#1 = ++ memcpy::src#2
[79] *memcpy::dst#2 = *memcpy::src#2
[80] memcpy::dst#1 = ++ memcpy::dst#2
[81] memcpy::src#1 = ++ memcpy::src#2
to:memcpy::@1
void * memset(void *str , char c , unsigned int num)
memset: scope:[memset] from cscroll::@3 cscroll::@4
[80] memset::c#4 = phi( cscroll::@3/' ', cscroll::@4/LIGHT_BLUE )
[80] memset::str#3 = phi( cscroll::@3/(void *)DEFAULT_SCREEN+(unsigned int)$19*$28-$28, cscroll::@4/(void *)COLORRAM+(unsigned int)$19*$28-$28 )
[82] memset::c#4 = phi( cscroll::@3/' ', cscroll::@4/LIGHT_BLUE )
[82] memset::str#3 = phi( cscroll::@3/(void *)DEFAULT_SCREEN+(unsigned int)$19*$28-$28, cscroll::@4/(void *)COLORRAM+(unsigned int)$19*$28-$28 )
to:memset::@1
memset::@1: scope:[memset] from memset
[81] memset::end#0 = (char *)memset::str#3 + $28
[82] memset::dst#4 = (char *)memset::str#3
[83] memset::end#0 = (char *)memset::str#3 + $28
[84] memset::dst#4 = (char *)memset::str#3
to:memset::@2
memset::@2: scope:[memset] from memset::@1 memset::@3
[83] memset::dst#2 = phi( memset::@1/memset::dst#4, memset::@3/memset::dst#1 )
[84] if(memset::dst#2!=memset::end#0) goto memset::@3
[85] memset::dst#2 = phi( memset::@1/memset::dst#4, memset::@3/memset::dst#1 )
[86] if(memset::dst#2!=memset::end#0) goto memset::@3
to:memset::@return
memset::@return: scope:[memset] from memset::@2
[85] return
[87] return
to:@return
memset::@3: scope:[memset] from memset::@2
[86] *memset::dst#2 = memset::c#4
[87] memset::dst#1 = ++ memset::dst#2
[88] *memset::dst#2 = memset::c#4
[89] memset::dst#1 = ++ memset::dst#2
to:memset::@2

File diff suppressed because it is too large Load Diff

View File

@ -5,26 +5,22 @@ __constant char RADIX::BINARY = 2
__constant char RADIX::DECIMAL = $a
__constant char RADIX::HEXADECIMAL = $10
__constant char RADIX::OCTAL = 8
__constant unsigned int STACK_BASE = $103
void __start()
void conio_c64_init()
__constant char * const conio_c64_init::BASIC_CURSOR_LINE = (char *) 214
char conio_c64_init::line
char conio_c64_init::line#0 // reg byte x 11.0
char conio_c64_init::line#2 // reg byte x 22.0
__loadstore char conio_cursor_x // zp[1]:6 4288.828571428571
__loadstore char conio_cursor_y // zp[1]:7 62747.2156862745
__loadstore char *conio_line_color // zp[2]:10 51397.860465116275
__loadstore char *conio_line_text // zp[2]:8 49113.51111111111
void cputc(char c)
__loadstore char conio_cursor_x // zp[1]:6 4057.0
__loadstore char conio_cursor_y // zp[1]:7 60379.3962264151
__loadstore char *conio_line_color // zp[2]:10 49113.51111111111
__loadstore char *conio_line_text // zp[2]:8 47023.574468085106
__stackcall void cputc(char c)
__constant char cputc::OFFSET_STACK_C = 0
char cputc::c
char cputc::c#0 // reg byte a 10501.5
char cputc::c#0 // reg byte a 15001.5
void cputln()
void cputs(const char *s)
char cputs::c
char cputs::c#1 // reg byte a 1001.0
const char *cputs::s
const char *cputs::s#0 // s zp[2]:2 500.5
const char *cputs::s#2 // s zp[2]:2 1501.5
void cscroll()
void gotoxy(char x , char y)
char *gotoxy::$5 // zp[2]:16 202.0
@ -72,20 +68,27 @@ unsigned int memset::num
void *memset::return
void *memset::str
void *memset::str#3 // str zp[2]:4
void printf_str(void (*putc)(char) , const char *s)
char printf_str::c
char printf_str::c#1 // reg byte a 1001.0
void (*printf_str::putc)(char)
const char *printf_str::s
const char *printf_str::s#0 // s zp[2]:2 400.4
const char *printf_str::s#2 // s zp[2]:2 1501.5
reg byte x [ conio_c64_init::line#2 conio_c64_init::line#0 ]
reg byte x [ gotoxy::y#4 gotoxy::y#2 ]
zp[2]:2 [ cputs::s#2 cputs::s#0 ]
zp[2]:2 [ printf_str::s#2 printf_str::s#0 ]
zp[2]:4 [ memset::str#3 memset::dst#2 memset::dst#4 memset::dst#1 memcpy::source#2 memcpy::src#2 memcpy::src#4 memcpy::src#1 ]
reg byte x [ memset::c#4 ]
zp[1]:6 [ conio_cursor_x ]
zp[1]:7 [ conio_cursor_y ]
zp[2]:8 [ conio_line_text ]
zp[2]:10 [ conio_line_color ]
reg byte a [ cputc::c#0 ]
zp[2]:12 [ gotoxy::$7 gotoxy::$9 gotoxy::line_offset#0 gotoxy::$6 ]
zp[2]:14 [ gotoxy::$8 ]
zp[2]:16 [ gotoxy::$5 ]
reg byte a [ cputs::c#1 ]
reg byte a [ cputc::c#0 ]
reg byte a [ printf_str::c#1 ]
zp[2]:18 [ memcpy::src_end#0 ]
zp[2]:20 [ memset::end#0 memcpy::destination#2 memcpy::dst#2 memcpy::dst#4 memcpy::dst#1 ]

View File

@ -16,6 +16,7 @@
/// Map 2nd KB of colour RAM $DC00-$DFFF (hiding CIA's)
.const CRAM2K = 1
.const LIGHT_BLUE = $e
.const STACK_BASE = $103
/// I/O Personality selection
.label IO_KEY = $d02f
/// C65 Banking Register
@ -89,9 +90,41 @@ conio_mega65_init: {
// }
rts
}
// Output one character at the current cursor position
// Moves the cursor forward. Scrolls the entire screen if needed
// void cputc(__register(A) char c)
cputc: {
.const OFFSET_STACK_C = 0
tsx
lda STACK_BASE+OFFSET_STACK_C,x
// if(c=='\n')
cmp #'\n'
beq __b1
// conio_line_text[conio_cursor_x] = c
ldz conio_cursor_x
sta.z (conio_line_text),z
// conio_line_color[conio_cursor_x] = conio_textcolor
lda #LIGHT_BLUE
ldz conio_cursor_x
sta.z (conio_line_color),z
// if(++conio_cursor_x==CONIO_WIDTH)
inc.z conio_cursor_x
lda #$50
cmp.z conio_cursor_x
bne __breturn
// cputln()
jsr cputln
__breturn:
// }
rts
__b1:
// cputln()
jsr cputln
rts
}
main: {
// printf("hello world!")
jsr cputs
jsr printf_str
// }
rts
.segment Data
@ -225,57 +258,6 @@ gotoxy: {
// }
rts
}
// Output a NUL-terminated string at the current cursor position
// void cputs(__zp(2) const char *s)
cputs: {
.label s = 2
lda #<main.s
sta.z s
lda #>main.s
sta.z s+1
__b1:
// while(c=*s++)
ldy #0
lda (s),y
inw.z s
cmp #0
bne __b2
// }
rts
__b2:
// cputc(c)
jsr cputc
jmp __b1
}
// Output one character at the current cursor position
// Moves the cursor forward. Scrolls the entire screen if needed
// void cputc(__register(A) char c)
cputc: {
// if(c=='\n')
cmp #'\n'
beq __b1
// conio_line_text[conio_cursor_x] = c
ldz conio_cursor_x
sta.z (conio_line_text),z
// conio_line_color[conio_cursor_x] = conio_textcolor
lda #LIGHT_BLUE
ldz conio_cursor_x
sta.z (conio_line_color),z
// if(++conio_cursor_x==CONIO_WIDTH)
inc.z conio_cursor_x
lda #$50
cmp.z conio_cursor_x
bne __breturn
// cputln()
jsr cputln
__breturn:
// }
rts
__b1:
// cputln()
jsr cputln
rts
}
// Print a newline
cputln: {
// conio_line_text += CONIO_WIDTH
@ -304,6 +286,30 @@ cputln: {
// }
rts
}
/// Print a NUL-terminated string
// void printf_str(void (*putc)(char), __zp(2) const char *s)
printf_str: {
.label s = 2
lda #<main.s
sta.z s
lda #>main.s
sta.z s+1
__b1:
// while(c=*s++)
ldy #0
lda (s),y
inw.z s
cmp #0
bne __b2
// }
rts
__b2:
// putc(c)
pha
jsr cputc
pla
jmp __b1
}
// Scroll the entire screen if the cursor is beyond the last line
cscroll: {
// if(conio_cursor_y==CONIO_HEIGHT)

View File

@ -48,174 +48,176 @@ conio_mega65_init::@return: scope:[conio_mega65_init] from conio_mega65_init::@
[22] return
to:@return
__stackcall void cputc(char c)
cputc: scope:[cputc] from printf_str::@2
[23] cputc::c#0 = stackidx(char,cputc::OFFSET_STACK_C)
[24] if(cputc::c#0=='
') goto cputc::@1
to:cputc::@2
cputc::@2: scope:[cputc] from cputc
[25] conio_line_text[conio_cursor_x] = cputc::c#0
[26] conio_line_color[conio_cursor_x] = LIGHT_BLUE
[27] conio_cursor_x = ++ conio_cursor_x
[28] if(conio_cursor_x!=$50) goto cputc::@return
to:cputc::@3
cputc::@3: scope:[cputc] from cputc::@2
[29] phi()
[30] call cputln
to:cputc::@return
cputc::@return: scope:[cputc] from cputc::@1 cputc::@2 cputc::@3
[31] return
to:@return
cputc::@1: scope:[cputc] from cputc
[32] phi()
[33] call cputln
to:cputc::@return
void main()
main: scope:[main] from __start::@1
[23] phi()
[24] call cputs
[34] phi()
[35] call printf_str
to:main::@return
main::@return: scope:[main] from main
[25] return
[36] return
to:@return
void memoryRemap(char remapBlocks , unsigned int lowerPageOffset , unsigned int upperPageOffset)
memoryRemap: scope:[memoryRemap] from conio_mega65_init::@2
[26] memoryRemap::aVal = 0
[27] memoryRemap::xVal = 0
[28] memoryRemap::yVal = 0
[29] memoryRemap::zVal = 0
[37] memoryRemap::aVal = 0
[38] memoryRemap::xVal = 0
[39] memoryRemap::yVal = 0
[40] memoryRemap::zVal = 0
asm { ldaaVal ldxxVal ldyyVal ldzzVal map eom }
to:memoryRemap::@return
memoryRemap::@return: scope:[memoryRemap] from memoryRemap
[31] return
[42] return
to:@return
void gotoxy(char x , char y)
gotoxy: scope:[gotoxy] from conio_mega65_init::@1
[32] if(gotoxy::y#2<$19+1) goto gotoxy::@3
[43] if(gotoxy::y#2<$19+1) goto gotoxy::@3
to:gotoxy::@1
gotoxy::@3: scope:[gotoxy] from gotoxy
[33] phi()
[44] phi()
to:gotoxy::@1
gotoxy::@1: scope:[gotoxy] from gotoxy gotoxy::@3
[34] gotoxy::y#4 = phi( gotoxy::@3/gotoxy::y#2, gotoxy/0 )
[45] gotoxy::y#4 = phi( gotoxy::@3/gotoxy::y#2, gotoxy/0 )
to:gotoxy::@2
gotoxy::@2: scope:[gotoxy] from gotoxy::@1
[35] conio_cursor_x = gotoxy::x#2
[36] conio_cursor_y = gotoxy::y#4
[37] gotoxy::$7 = (unsigned int)gotoxy::y#4
[38] gotoxy::$8 = gotoxy::$7 << 2
[39] gotoxy::$9 = gotoxy::$8 + gotoxy::$7
[40] gotoxy::line_offset#0 = gotoxy::$9 << 4
[41] gotoxy::$5 = DEFAULT_SCREEN + gotoxy::line_offset#0
[42] conio_line_text = gotoxy::$5
[43] gotoxy::$6 = COLORRAM + gotoxy::line_offset#0
[44] conio_line_color = gotoxy::$6
[46] conio_cursor_x = gotoxy::x#2
[47] conio_cursor_y = gotoxy::y#4
[48] gotoxy::$7 = (unsigned int)gotoxy::y#4
[49] gotoxy::$8 = gotoxy::$7 << 2
[50] gotoxy::$9 = gotoxy::$8 + gotoxy::$7
[51] gotoxy::line_offset#0 = gotoxy::$9 << 4
[52] gotoxy::$5 = DEFAULT_SCREEN + gotoxy::line_offset#0
[53] conio_line_text = gotoxy::$5
[54] gotoxy::$6 = COLORRAM + gotoxy::line_offset#0
[55] conio_line_color = gotoxy::$6
to:gotoxy::@return
gotoxy::@return: scope:[gotoxy] from gotoxy::@2
[45] return
[56] return
to:@return
void cputs(const char *s)
cputs: scope:[cputs] from main
[46] phi()
to:cputs::@1
cputs::@1: scope:[cputs] from cputs cputs::@2
[47] cputs::s#2 = phi( cputs/main::s, cputs::@2/cputs::s#0 )
[48] cputs::c#1 = *cputs::s#2
[49] cputs::s#0 = ++ cputs::s#2
[50] if(0!=cputs::c#1) goto cputs::@2
to:cputs::@return
cputs::@return: scope:[cputs] from cputs::@1
[51] return
to:@return
cputs::@2: scope:[cputs] from cputs::@1
[52] cputc::c#0 = cputs::c#1
[53] call cputc
to:cputs::@1
void cputc(char c)
cputc: scope:[cputc] from cputs::@2
[54] if(cputc::c#0=='
') goto cputc::@1
to:cputc::@2
cputc::@2: scope:[cputc] from cputc
[55] conio_line_text[conio_cursor_x] = cputc::c#0
[56] conio_line_color[conio_cursor_x] = LIGHT_BLUE
[57] conio_cursor_x = ++ conio_cursor_x
[58] if(conio_cursor_x!=$50) goto cputc::@return
to:cputc::@3
cputc::@3: scope:[cputc] from cputc::@2
[59] phi()
[60] call cputln
to:cputc::@return
cputc::@return: scope:[cputc] from cputc::@1 cputc::@2 cputc::@3
[61] return
to:@return
cputc::@1: scope:[cputc] from cputc
[62] phi()
[63] call cputln
to:cputc::@return
void cputln()
cputln: scope:[cputln] from cputc::@1 cputc::@3
[64] conio_line_text = conio_line_text + $50
[65] conio_line_color = conio_line_color + $50
[66] conio_cursor_x = 0
[67] conio_cursor_y = ++ conio_cursor_y
[68] call cscroll
[57] conio_line_text = conio_line_text + $50
[58] conio_line_color = conio_line_color + $50
[59] conio_cursor_x = 0
[60] conio_cursor_y = ++ conio_cursor_y
[61] call cscroll
to:cputln::@return
cputln::@return: scope:[cputln] from cputln
[69] return
[62] return
to:@return
void printf_str(void (*putc)(char) , const char *s)
printf_str: scope:[printf_str] from main
[63] phi()
to:printf_str::@1
printf_str::@1: scope:[printf_str] from printf_str printf_str::@2
[64] printf_str::s#2 = phi( printf_str/main::s, printf_str::@2/printf_str::s#0 )
[65] printf_str::c#1 = *printf_str::s#2
[66] printf_str::s#0 = ++ printf_str::s#2
[67] if(0!=printf_str::c#1) goto printf_str::@2
to:printf_str::@return
printf_str::@return: scope:[printf_str] from printf_str::@1
[68] return
to:@return
printf_str::@2: scope:[printf_str] from printf_str::@1
[69] stackpush(char) = printf_str::c#1
[70] callexecute cputc
sideeffect stackpullbytes(1)
to:printf_str::@1
void cscroll()
cscroll: scope:[cscroll] from cputln
[70] if(conio_cursor_y!=$19) goto cscroll::@return
[72] if(conio_cursor_y!=$19) goto cscroll::@return
to:cscroll::@1
cscroll::@1: scope:[cscroll] from cscroll
[71] phi()
[72] call memcpy
to:cscroll::@2
cscroll::@2: scope:[cscroll] from cscroll::@1
[73] phi()
[74] call memcpy
to:cscroll::@2
cscroll::@2: scope:[cscroll] from cscroll::@1
[75] phi()
[76] call memcpy
to:cscroll::@3
cscroll::@3: scope:[cscroll] from cscroll::@2
[75] phi()
[76] call memset
to:cscroll::@4
cscroll::@4: scope:[cscroll] from cscroll::@3
[77] phi()
[78] call memset
to:cscroll::@4
cscroll::@4: scope:[cscroll] from cscroll::@3
[79] phi()
[80] call memset
to:cscroll::@5
cscroll::@5: scope:[cscroll] from cscroll::@4
[79] conio_line_text = conio_line_text - $50
[80] conio_line_color = conio_line_color - $50
[81] conio_cursor_y = -- conio_cursor_y
[81] conio_line_text = conio_line_text - $50
[82] conio_line_color = conio_line_color - $50
[83] conio_cursor_y = -- conio_cursor_y
to:cscroll::@return
cscroll::@return: scope:[cscroll] from cscroll cscroll::@5
[82] return
[84] return
to:@return
void * memcpy(void *destination , void *source , unsigned int num)
memcpy: scope:[memcpy] from cscroll::@1 cscroll::@2
[83] memcpy::destination#2 = phi( cscroll::@1/(void *)DEFAULT_SCREEN, cscroll::@2/(void *)COLORRAM )
[83] memcpy::source#2 = phi( cscroll::@1/(void *)DEFAULT_SCREEN+$50, cscroll::@2/(void *)COLORRAM+$50 )
[84] memcpy::src_end#0 = (char *)memcpy::source#2 + (unsigned int)$19*$50-$50
[85] memcpy::src#4 = (char *)memcpy::source#2
[86] memcpy::dst#4 = (char *)memcpy::destination#2
[85] memcpy::destination#2 = phi( cscroll::@1/(void *)DEFAULT_SCREEN, cscroll::@2/(void *)COLORRAM )
[85] memcpy::source#2 = phi( cscroll::@1/(void *)DEFAULT_SCREEN+$50, cscroll::@2/(void *)COLORRAM+$50 )
[86] memcpy::src_end#0 = (char *)memcpy::source#2 + (unsigned int)$19*$50-$50
[87] memcpy::src#4 = (char *)memcpy::source#2
[88] memcpy::dst#4 = (char *)memcpy::destination#2
to:memcpy::@1
memcpy::@1: scope:[memcpy] from memcpy memcpy::@2
[87] memcpy::dst#2 = phi( memcpy/memcpy::dst#4, memcpy::@2/memcpy::dst#1 )
[87] memcpy::src#2 = phi( memcpy/memcpy::src#4, memcpy::@2/memcpy::src#1 )
[88] if(memcpy::src#2!=memcpy::src_end#0) goto memcpy::@2
[89] memcpy::dst#2 = phi( memcpy/memcpy::dst#4, memcpy::@2/memcpy::dst#1 )
[89] memcpy::src#2 = phi( memcpy/memcpy::src#4, memcpy::@2/memcpy::src#1 )
[90] if(memcpy::src#2!=memcpy::src_end#0) goto memcpy::@2
to:memcpy::@return
memcpy::@return: scope:[memcpy] from memcpy::@1
[89] return
[91] return
to:@return
memcpy::@2: scope:[memcpy] from memcpy::@1
[90] *memcpy::dst#2 = *memcpy::src#2
[91] memcpy::dst#1 = ++ memcpy::dst#2
[92] memcpy::src#1 = ++ memcpy::src#2
[92] *memcpy::dst#2 = *memcpy::src#2
[93] memcpy::dst#1 = ++ memcpy::dst#2
[94] memcpy::src#1 = ++ memcpy::src#2
to:memcpy::@1
void * memset(void *str , char c , unsigned int num)
memset: scope:[memset] from cscroll::@3 cscroll::@4
[93] memset::c#4 = phi( cscroll::@3/' ', cscroll::@4/LIGHT_BLUE )
[93] memset::str#3 = phi( cscroll::@3/(void *)DEFAULT_SCREEN+(unsigned int)$19*$50-$50, cscroll::@4/(void *)COLORRAM+(unsigned int)$19*$50-$50 )
[95] memset::c#4 = phi( cscroll::@3/' ', cscroll::@4/LIGHT_BLUE )
[95] memset::str#3 = phi( cscroll::@3/(void *)DEFAULT_SCREEN+(unsigned int)$19*$50-$50, cscroll::@4/(void *)COLORRAM+(unsigned int)$19*$50-$50 )
to:memset::@1
memset::@1: scope:[memset] from memset
[94] memset::end#0 = (char *)memset::str#3 + $50
[95] memset::dst#4 = (char *)memset::str#3
[96] memset::end#0 = (char *)memset::str#3 + $50
[97] memset::dst#4 = (char *)memset::str#3
to:memset::@2
memset::@2: scope:[memset] from memset::@1 memset::@3
[96] memset::dst#2 = phi( memset::@1/memset::dst#4, memset::@3/memset::dst#1 )
[97] if(memset::dst#2!=memset::end#0) goto memset::@3
[98] memset::dst#2 = phi( memset::@1/memset::dst#4, memset::@3/memset::dst#1 )
[99] if(memset::dst#2!=memset::end#0) goto memset::@3
to:memset::@return
memset::@return: scope:[memset] from memset::@2
[98] return
[100] return
to:@return
memset::@3: scope:[memset] from memset::@2
[99] *memset::dst#2 = memset::c#4
[100] memset::dst#1 = ++ memset::dst#2
[101] *memset::dst#2 = memset::c#4
[102] memset::dst#1 = ++ memset::dst#2
to:memset::@2

File diff suppressed because it is too large Load Diff

View File

@ -8,26 +8,22 @@ __constant char RADIX::BINARY = 2
__constant char RADIX::DECIMAL = $a
__constant char RADIX::HEXADECIMAL = $10
__constant char RADIX::OCTAL = 8
__constant unsigned int STACK_BASE = $103
void __start()
__loadstore char conio_cursor_x // zp[1]:6 4288.828571428571
__loadstore char conio_cursor_y // zp[1]:7 62747.2156862745
__loadstore char *conio_line_color // zp[2]:10 51397.860465116275
__loadstore char *conio_line_text // zp[2]:8 49113.51111111111
__loadstore char conio_cursor_x // zp[1]:6 4057.0
__loadstore char conio_cursor_y // zp[1]:7 60379.3962264151
__loadstore char *conio_line_color // zp[2]:10 49113.51111111111
__loadstore char *conio_line_text // zp[2]:8 47023.574468085106
void conio_mega65_init()
__constant char * const conio_mega65_init::BASIC_CURSOR_LINE = (char *) 235
char conio_mega65_init::line
char conio_mega65_init::line#0 // reg byte x 11.0
char conio_mega65_init::line#2 // reg byte x 22.0
void cputc(char c)
__stackcall void cputc(char c)
__constant char cputc::OFFSET_STACK_C = 0
char cputc::c
char cputc::c#0 // reg byte a 10501.5
char cputc::c#0 // reg byte a 15001.5
void cputln()
void cputs(const char *s)
char cputs::c
char cputs::c#1 // reg byte a 1001.0
const char *cputs::s
const char *cputs::s#0 // s zp[2]:2 500.5
const char *cputs::s#2 // s zp[2]:2 1501.5
void cscroll()
void gotoxy(char x , char y)
char *gotoxy::$5 // zp[2]:20 202.0
@ -82,16 +78,24 @@ unsigned int memset::num
void *memset::return
void *memset::str
void *memset::str#3 // str zp[2]:4
void printf_str(void (*putc)(char) , const char *s)
char printf_str::c
char printf_str::c#1 // reg byte a 1001.0
void (*printf_str::putc)(char)
const char *printf_str::s
const char *printf_str::s#0 // s zp[2]:2 400.4
const char *printf_str::s#2 // s zp[2]:2 1501.5
reg byte x [ conio_mega65_init::line#2 conio_mega65_init::line#0 ]
reg byte x [ gotoxy::y#4 gotoxy::y#2 ]
zp[2]:2 [ cputs::s#2 cputs::s#0 ]
zp[2]:2 [ printf_str::s#2 printf_str::s#0 ]
zp[2]:4 [ memset::str#3 memset::dst#2 memset::dst#4 memset::dst#1 memcpy::source#2 memcpy::src#2 memcpy::src#4 memcpy::src#1 ]
reg byte z [ memset::c#4 ]
zp[1]:6 [ conio_cursor_x ]
zp[1]:7 [ conio_cursor_y ]
zp[2]:8 [ conio_line_text ]
zp[2]:10 [ conio_line_color ]
reg byte a [ cputc::c#0 ]
zp[1]:12 [ memoryRemap::aVal ]
zp[1]:13 [ memoryRemap::xVal ]
zp[1]:14 [ memoryRemap::yVal ]
@ -99,7 +103,6 @@ zp[1]:15 [ memoryRemap::zVal ]
zp[2]:16 [ gotoxy::$7 gotoxy::$9 gotoxy::line_offset#0 gotoxy::$6 ]
zp[2]:18 [ gotoxy::$8 ]
zp[2]:20 [ gotoxy::$5 ]
reg byte a [ cputs::c#1 ]
reg byte a [ cputc::c#0 ]
reg byte a [ printf_str::c#1 ]
zp[2]:22 [ memcpy::src_end#0 ]
zp[2]:24 [ memset::end#0 memcpy::destination#2 memcpy::dst#2 memcpy::dst#4 memcpy::dst#1 ]

View File

@ -8,6 +8,7 @@
.segment Basic
:BasicUpstart(__start)
.const LIGHT_BLUE = $e
.const STACK_BASE = $103
/// Color Ram
.label COLORRAM = $d800
/// Default address of screen character matrix
@ -46,10 +47,10 @@ __start: {
world: {
// printf("world!")
lda #<s
sta.z cputs.s
sta.z printf_str.s
lda #>s
sta.z cputs.s+1
jsr cputs
sta.z printf_str.s+1
jsr printf_str
// }
rts
.segment Data
@ -60,10 +61,10 @@ world: {
hello: {
// printf("hello ")
lda #<s
sta.z cputs.s
sta.z printf_str.s
lda #>s
sta.z cputs.s+1
jsr cputs
sta.z printf_str.s+1
jsr printf_str
// }
rts
.segment Data
@ -87,6 +88,37 @@ conio_c64_init: {
// }
rts
}
// Output one character at the current cursor position
// Moves the cursor forward. Scrolls the entire screen if needed
// void cputc(__register(A) char c)
cputc: {
.const OFFSET_STACK_C = 0
tsx
lda STACK_BASE+OFFSET_STACK_C,x
// if(c=='\n')
cmp #'\n'
beq __b1
// conio_line_text[conio_cursor_x] = c
ldy.z conio_cursor_x
sta (conio_line_text),y
// conio_line_color[conio_cursor_x] = conio_textcolor
lda #LIGHT_BLUE
sta (conio_line_color),y
// if(++conio_cursor_x==CONIO_WIDTH)
inc.z conio_cursor_x
lda #$28
cmp.z conio_cursor_x
bne __breturn
// cputln()
jsr cputln
__breturn:
// }
rts
__b1:
// cputln()
jsr cputln
rts
}
main: {
// f1(&hello)
lda #<hello
@ -103,9 +135,9 @@ main: {
// }
rts
}
// Output a NUL-terminated string at the current cursor position
// void cputs(__zp(2) const char *s)
cputs: {
/// Print a NUL-terminated string
// void printf_str(void (*putc)(char), __zp(2) const char *s)
printf_str: {
.label s = 2
__b1:
// while(c=*s++)
@ -120,8 +152,10 @@ cputs: {
// }
rts
__b2:
// cputc(c)
// putc(c)
pha
jsr cputc
pla
jmp __b1
}
// Set the cursor to the specified position
@ -199,44 +233,6 @@ gotoxy: {
// }
rts
}
// void f1(__zp(4) void (*fn)())
f1: {
.label fn = 4
// (*fn)()
jsr icall1
// }
rts
icall1:
jmp (fn)
}
// Output one character at the current cursor position
// Moves the cursor forward. Scrolls the entire screen if needed
// void cputc(__register(A) char c)
cputc: {
// if(c=='\n')
cmp #'\n'
beq __b1
// conio_line_text[conio_cursor_x] = c
ldy.z conio_cursor_x
sta (conio_line_text),y
// conio_line_color[conio_cursor_x] = conio_textcolor
lda #LIGHT_BLUE
sta (conio_line_color),y
// if(++conio_cursor_x==CONIO_WIDTH)
inc.z conio_cursor_x
lda #$28
cmp.z conio_cursor_x
bne __breturn
// cputln()
jsr cputln
__breturn:
// }
rts
__b1:
// cputln()
jsr cputln
rts
}
// Print a newline
cputln: {
// conio_line_text += CONIO_WIDTH
@ -265,6 +261,16 @@ cputln: {
// }
rts
}
// void f1(__zp(4) void (*fn)())
f1: {
.label fn = 4
// (*fn)()
jsr icall2
// }
rts
icall2:
jmp (fn)
}
// Scroll the entire screen if the cursor is beyond the last line
cscroll: {
// if(conio_cursor_y==CONIO_HEIGHT)

View File

@ -21,7 +21,7 @@ __start::@return: scope:[__start] from __start::@1
void world()
world: scope:[world] from
[9] phi()
[10] call cputs
[10] call printf_str
to:world::@return
world::@return: scope:[world] from world
[11] return
@ -30,7 +30,7 @@ world::@return: scope:[world] from world
void hello()
hello: scope:[hello] from
[12] phi()
[13] call cputs
[13] call printf_str
to:hello::@return
hello::@return: scope:[hello] from hello
[14] return
@ -53,175 +53,177 @@ conio_c64_init::@return: scope:[conio_c64_init] from conio_c64_init::@1
[21] return
to:@return
__stackcall void cputc(char c)
cputc: scope:[cputc] from printf_str::@2
[22] cputc::c#0 = stackidx(char,cputc::OFFSET_STACK_C)
[23] if(cputc::c#0=='
') goto cputc::@1
to:cputc::@2
cputc::@2: scope:[cputc] from cputc
[24] conio_line_text[conio_cursor_x] = cputc::c#0
[25] conio_line_color[conio_cursor_x] = LIGHT_BLUE
[26] conio_cursor_x = ++ conio_cursor_x
[27] if(conio_cursor_x!=$28) goto cputc::@return
to:cputc::@3
cputc::@3: scope:[cputc] from cputc::@2
[28] phi()
[29] call cputln
to:cputc::@return
cputc::@return: scope:[cputc] from cputc::@1 cputc::@2 cputc::@3
[30] return
to:@return
cputc::@1: scope:[cputc] from cputc
[31] phi()
[32] call cputln
to:cputc::@return
void main()
main: scope:[main] from __start::@1
[22] phi()
[23] call f1
[33] phi()
[34] call f1
to:main::@1
main::@1: scope:[main] from main
[24] phi()
[25] call f1
[35] phi()
[36] call f1
to:main::@return
main::@return: scope:[main] from main::@1
[26] return
[37] return
to:@return
void cputs(const char *s)
cputs: scope:[cputs] from hello world
[27] cputs::s#4 = phi( hello/hello::s, world/world::s )
to:cputs::@1
cputs::@1: scope:[cputs] from cputs cputs::@2
[28] cputs::s#3 = phi( cputs/cputs::s#4, cputs::@2/cputs::s#0 )
[29] cputs::c#1 = *cputs::s#3
[30] cputs::s#0 = ++ cputs::s#3
[31] if(0!=cputs::c#1) goto cputs::@2
to:cputs::@return
cputs::@return: scope:[cputs] from cputs::@1
[32] return
void printf_str(void (*putc)(char) , const char *s)
printf_str: scope:[printf_str] from hello world
[38] printf_str::s#4 = phi( hello/hello::s, world/world::s )
to:printf_str::@1
printf_str::@1: scope:[printf_str] from printf_str printf_str::@2
[39] printf_str::s#3 = phi( printf_str/printf_str::s#4, printf_str::@2/printf_str::s#0 )
[40] printf_str::c#1 = *printf_str::s#3
[41] printf_str::s#0 = ++ printf_str::s#3
[42] if(0!=printf_str::c#1) goto printf_str::@2
to:printf_str::@return
printf_str::@return: scope:[printf_str] from printf_str::@1
[43] return
to:@return
cputs::@2: scope:[cputs] from cputs::@1
[33] cputc::c#0 = cputs::c#1
[34] call cputc
to:cputs::@1
printf_str::@2: scope:[printf_str] from printf_str::@1
[44] stackpush(char) = printf_str::c#1
[45] callexecute cputc
sideeffect stackpullbytes(1)
to:printf_str::@1
void gotoxy(char x , char y)
gotoxy: scope:[gotoxy] from conio_c64_init::@1
[35] if(gotoxy::y#2<$19+1) goto gotoxy::@3
[47] if(gotoxy::y#2<$19+1) goto gotoxy::@3
to:gotoxy::@1
gotoxy::@3: scope:[gotoxy] from gotoxy
[36] phi()
[48] phi()
to:gotoxy::@1
gotoxy::@1: scope:[gotoxy] from gotoxy gotoxy::@3
[37] gotoxy::y#4 = phi( gotoxy::@3/gotoxy::y#2, gotoxy/0 )
[49] gotoxy::y#4 = phi( gotoxy::@3/gotoxy::y#2, gotoxy/0 )
to:gotoxy::@2
gotoxy::@2: scope:[gotoxy] from gotoxy::@1
[38] conio_cursor_x = gotoxy::x#2
[39] conio_cursor_y = gotoxy::y#4
[40] gotoxy::$7 = (unsigned int)gotoxy::y#4
[41] gotoxy::$8 = gotoxy::$7 << 2
[42] gotoxy::$9 = gotoxy::$8 + gotoxy::$7
[43] gotoxy::line_offset#0 = gotoxy::$9 << 3
[44] gotoxy::$5 = DEFAULT_SCREEN + gotoxy::line_offset#0
[45] conio_line_text = gotoxy::$5
[46] gotoxy::$6 = COLORRAM + gotoxy::line_offset#0
[47] conio_line_color = gotoxy::$6
[50] conio_cursor_x = gotoxy::x#2
[51] conio_cursor_y = gotoxy::y#4
[52] gotoxy::$7 = (unsigned int)gotoxy::y#4
[53] gotoxy::$8 = gotoxy::$7 << 2
[54] gotoxy::$9 = gotoxy::$8 + gotoxy::$7
[55] gotoxy::line_offset#0 = gotoxy::$9 << 3
[56] gotoxy::$5 = DEFAULT_SCREEN + gotoxy::line_offset#0
[57] conio_line_text = gotoxy::$5
[58] gotoxy::$6 = COLORRAM + gotoxy::line_offset#0
[59] conio_line_color = gotoxy::$6
to:gotoxy::@return
gotoxy::@return: scope:[gotoxy] from gotoxy::@2
[48] return
[60] return
to:@return
void cputln()
cputln: scope:[cputln] from cputc::@1 cputc::@3
[61] conio_line_text = conio_line_text + $28
[62] conio_line_color = conio_line_color + $28
[63] conio_cursor_x = 0
[64] conio_cursor_y = ++ conio_cursor_y
[65] call cscroll
to:cputln::@return
cputln::@return: scope:[cputln] from cputln
[66] return
to:@return
void f1(void (*fn)())
f1: scope:[f1] from main main::@1
[49] f1::fn#2 = phi( main/&hello, main::@1/&world )
[50] callexecute *f1::fn#2
[67] f1::fn#2 = phi( main/&hello, main::@1/&world )
[68] callexecute *f1::fn#2
to:f1::@return
f1::@return: scope:[f1] from f1
[51] return
to:@return
void cputc(char c)
cputc: scope:[cputc] from cputs::@2
[52] if(cputc::c#0=='
') goto cputc::@1
to:cputc::@2
cputc::@2: scope:[cputc] from cputc
[53] conio_line_text[conio_cursor_x] = cputc::c#0
[54] conio_line_color[conio_cursor_x] = LIGHT_BLUE
[55] conio_cursor_x = ++ conio_cursor_x
[56] if(conio_cursor_x!=$28) goto cputc::@return
to:cputc::@3
cputc::@3: scope:[cputc] from cputc::@2
[57] phi()
[58] call cputln
to:cputc::@return
cputc::@return: scope:[cputc] from cputc::@1 cputc::@2 cputc::@3
[59] return
to:@return
cputc::@1: scope:[cputc] from cputc
[60] phi()
[61] call cputln
to:cputc::@return
void cputln()
cputln: scope:[cputln] from cputc::@1 cputc::@3
[62] conio_line_text = conio_line_text + $28
[63] conio_line_color = conio_line_color + $28
[64] conio_cursor_x = 0
[65] conio_cursor_y = ++ conio_cursor_y
[66] call cscroll
to:cputln::@return
cputln::@return: scope:[cputln] from cputln
[67] return
[69] return
to:@return
void cscroll()
cscroll: scope:[cscroll] from cputln
[68] if(conio_cursor_y!=$19) goto cscroll::@return
[70] if(conio_cursor_y!=$19) goto cscroll::@return
to:cscroll::@1
cscroll::@1: scope:[cscroll] from cscroll
[69] phi()
[70] call memcpy
to:cscroll::@2
cscroll::@2: scope:[cscroll] from cscroll::@1
[71] phi()
[72] call memcpy
to:cscroll::@2
cscroll::@2: scope:[cscroll] from cscroll::@1
[73] phi()
[74] call memcpy
to:cscroll::@3
cscroll::@3: scope:[cscroll] from cscroll::@2
[73] phi()
[74] call memset
to:cscroll::@4
cscroll::@4: scope:[cscroll] from cscroll::@3
[75] phi()
[76] call memset
to:cscroll::@4
cscroll::@4: scope:[cscroll] from cscroll::@3
[77] phi()
[78] call memset
to:cscroll::@5
cscroll::@5: scope:[cscroll] from cscroll::@4
[77] conio_line_text = conio_line_text - $28
[78] conio_line_color = conio_line_color - $28
[79] conio_cursor_y = -- conio_cursor_y
[79] conio_line_text = conio_line_text - $28
[80] conio_line_color = conio_line_color - $28
[81] conio_cursor_y = -- conio_cursor_y
to:cscroll::@return
cscroll::@return: scope:[cscroll] from cscroll cscroll::@5
[80] return
[82] return
to:@return
void * memcpy(void *destination , void *source , unsigned int num)
memcpy: scope:[memcpy] from cscroll::@1 cscroll::@2
[81] memcpy::destination#2 = phi( cscroll::@1/(void *)DEFAULT_SCREEN, cscroll::@2/(void *)COLORRAM )
[81] memcpy::source#2 = phi( cscroll::@1/(void *)DEFAULT_SCREEN+$28, cscroll::@2/(void *)COLORRAM+$28 )
[82] memcpy::src_end#0 = (char *)memcpy::source#2 + (unsigned int)$19*$28-$28
[83] memcpy::src#4 = (char *)memcpy::source#2
[84] memcpy::dst#4 = (char *)memcpy::destination#2
[83] memcpy::destination#2 = phi( cscroll::@1/(void *)DEFAULT_SCREEN, cscroll::@2/(void *)COLORRAM )
[83] memcpy::source#2 = phi( cscroll::@1/(void *)DEFAULT_SCREEN+$28, cscroll::@2/(void *)COLORRAM+$28 )
[84] memcpy::src_end#0 = (char *)memcpy::source#2 + (unsigned int)$19*$28-$28
[85] memcpy::src#4 = (char *)memcpy::source#2
[86] memcpy::dst#4 = (char *)memcpy::destination#2
to:memcpy::@1
memcpy::@1: scope:[memcpy] from memcpy memcpy::@2
[85] memcpy::dst#2 = phi( memcpy/memcpy::dst#4, memcpy::@2/memcpy::dst#1 )
[85] memcpy::src#2 = phi( memcpy/memcpy::src#4, memcpy::@2/memcpy::src#1 )
[86] if(memcpy::src#2!=memcpy::src_end#0) goto memcpy::@2
[87] memcpy::dst#2 = phi( memcpy/memcpy::dst#4, memcpy::@2/memcpy::dst#1 )
[87] memcpy::src#2 = phi( memcpy/memcpy::src#4, memcpy::@2/memcpy::src#1 )
[88] if(memcpy::src#2!=memcpy::src_end#0) goto memcpy::@2
to:memcpy::@return
memcpy::@return: scope:[memcpy] from memcpy::@1
[87] return
[89] return
to:@return
memcpy::@2: scope:[memcpy] from memcpy::@1
[88] *memcpy::dst#2 = *memcpy::src#2
[89] memcpy::dst#1 = ++ memcpy::dst#2
[90] memcpy::src#1 = ++ memcpy::src#2
[90] *memcpy::dst#2 = *memcpy::src#2
[91] memcpy::dst#1 = ++ memcpy::dst#2
[92] memcpy::src#1 = ++ memcpy::src#2
to:memcpy::@1
void * memset(void *str , char c , unsigned int num)
memset: scope:[memset] from cscroll::@3 cscroll::@4
[91] memset::c#4 = phi( cscroll::@3/' ', cscroll::@4/LIGHT_BLUE )
[91] memset::str#3 = phi( cscroll::@3/(void *)DEFAULT_SCREEN+(unsigned int)$19*$28-$28, cscroll::@4/(void *)COLORRAM+(unsigned int)$19*$28-$28 )
[93] memset::c#4 = phi( cscroll::@3/' ', cscroll::@4/LIGHT_BLUE )
[93] memset::str#3 = phi( cscroll::@3/(void *)DEFAULT_SCREEN+(unsigned int)$19*$28-$28, cscroll::@4/(void *)COLORRAM+(unsigned int)$19*$28-$28 )
to:memset::@1
memset::@1: scope:[memset] from memset
[92] memset::end#0 = (char *)memset::str#3 + $28
[93] memset::dst#4 = (char *)memset::str#3
[94] memset::end#0 = (char *)memset::str#3 + $28
[95] memset::dst#4 = (char *)memset::str#3
to:memset::@2
memset::@2: scope:[memset] from memset::@1 memset::@3
[94] memset::dst#2 = phi( memset::@1/memset::dst#4, memset::@3/memset::dst#1 )
[95] if(memset::dst#2!=memset::end#0) goto memset::@3
[96] memset::dst#2 = phi( memset::@1/memset::dst#4, memset::@3/memset::dst#1 )
[97] if(memset::dst#2!=memset::end#0) goto memset::@3
to:memset::@return
memset::@return: scope:[memset] from memset::@2
[96] return
[98] return
to:@return
memset::@3: scope:[memset] from memset::@2
[97] *memset::dst#2 = memset::c#4
[98] memset::dst#1 = ++ memset::dst#2
[99] *memset::dst#2 = memset::c#4
[100] memset::dst#1 = ++ memset::dst#2
to:memset::@2

File diff suppressed because it is too large Load Diff

View File

@ -5,27 +5,22 @@ __constant char RADIX::BINARY = 2
__constant char RADIX::DECIMAL = $a
__constant char RADIX::HEXADECIMAL = $10
__constant char RADIX::OCTAL = 8
__constant unsigned int STACK_BASE = $103
void __start()
void conio_c64_init()
__constant char * const conio_c64_init::BASIC_CURSOR_LINE = (char *) 214
char conio_c64_init::line
char conio_c64_init::line#0 // reg byte x 11.0
char conio_c64_init::line#2 // reg byte x 22.0
__loadstore char conio_cursor_x // zp[1]:8 719.4761904761905
__loadstore char conio_cursor_y // zp[1]:9 8423.894736842105
__loadstore char *conio_line_color // zp[2]:12 5818.631578947368
__loadstore char *conio_line_text // zp[2]:10 5818.631578947368
void cputc(char c)
__loadstore char conio_cursor_x // zp[1]:8 656.9130434782609
__loadstore char conio_cursor_y // zp[1]:9 8002.700000000001
__loadstore char *conio_line_color // zp[2]:12 5527.700000000001
__loadstore char *conio_line_text // zp[2]:10 5527.700000000001
__stackcall void cputc(char c)
__constant char cputc::OFFSET_STACK_C = 0
char cputc::c
char cputc::c#0 // reg byte a 1051.5
char cputc::c#0 // reg byte a 1501.5
void cputln()
void cputs(const char *s)
char cputs::c
char cputs::c#1 // reg byte a 101.0
const char *cputs::s
const char *cputs::s#0 // s zp[2]:2 50.5
const char *cputs::s#3 // s zp[2]:2 157.0
const char *cputs::s#4 // s zp[2]:2 11.0
void cscroll()
void f1(void (*fn)())
void (*f1::fn)()
@ -76,11 +71,19 @@ unsigned int memset::num
void *memset::return
void *memset::str
void *memset::str#3 // str zp[2]:6
void printf_str(void (*putc)(char) , const char *s)
char printf_str::c
char printf_str::c#1 // reg byte a 101.0
void (*printf_str::putc)(char)
const char *printf_str::s
const char *printf_str::s#0 // s zp[2]:2 40.4
const char *printf_str::s#3 // s zp[2]:2 157.0
const char *printf_str::s#4 // s zp[2]:2 11.0
void world()
__constant char world::s[7] = "world!"
reg byte x [ conio_c64_init::line#2 conio_c64_init::line#0 ]
zp[2]:2 [ cputs::s#3 cputs::s#4 cputs::s#0 ]
zp[2]:2 [ printf_str::s#3 printf_str::s#4 printf_str::s#0 ]
reg byte x [ gotoxy::y#4 gotoxy::y#2 ]
zp[2]:4 [ f1::fn#2 ]
zp[2]:6 [ memset::str#3 memset::dst#2 memset::dst#4 memset::dst#1 memcpy::source#2 memcpy::src#2 memcpy::src#4 memcpy::src#1 ]
@ -89,8 +92,8 @@ zp[1]:8 [ conio_cursor_x ]
zp[1]:9 [ conio_cursor_y ]
zp[2]:10 [ conio_line_text ]
zp[2]:12 [ conio_line_color ]
reg byte a [ cputs::c#1 ]
reg byte a [ cputc::c#0 ]
reg byte a [ printf_str::c#1 ]
zp[2]:14 [ gotoxy::$7 gotoxy::$9 gotoxy::line_offset#0 gotoxy::$6 ]
zp[2]:16 [ gotoxy::$8 ]
zp[2]:18 [ gotoxy::$5 ]

View File

@ -9,6 +9,7 @@
.segment Basic
:BasicUpstart(__start)
.const LIGHT_BLUE = $e
.const STACK_BASE = $103
/// Color Ram
.label COLORRAM = $d800
/// Default address of screen character matrix
@ -60,10 +61,41 @@ conio_c64_init: {
// }
rts
}
// Output one character at the current cursor position
// Moves the cursor forward. Scrolls the entire screen if needed
// void cputc(__register(A) char c)
cputc: {
.const OFFSET_STACK_C = 0
tsx
lda STACK_BASE+OFFSET_STACK_C,x
// if(c=='\n')
cmp #'\n'
beq __b1
// conio_line_text[conio_cursor_x] = c
ldy.z conio_cursor_x
sta (conio_line_text),y
// conio_line_color[conio_cursor_x] = conio_textcolor
lda #LIGHT_BLUE
sta (conio_line_color),y
// if(++conio_cursor_x==CONIO_WIDTH)
inc.z conio_cursor_x
lda #$28
cmp.z conio_cursor_x
bne __breturn
// cputln()
jsr cputln
__breturn:
// }
rts
__b1:
// cputln()
jsr cputln
rts
}
main: {
// clrscr()
jsr clrscr
// printf_string( "cml", { 10, 0 } )
// printf_string(&cputc, "cml", { 10, 0 } )
lda #<str
sta.z printf_string.str
lda #>str
@ -73,7 +105,7 @@ main: {
jsr printf_string
// cputln()
jsr cputln
// printf_string( "rules", { 10, 0 } )
// printf_string(&cputc, "rules", { 10, 0 } )
lda #<str1
sta.z printf_string.str
lda #>str1
@ -83,7 +115,7 @@ main: {
jsr printf_string
// cputln()
jsr cputln
// printf_string( "cml", { 10, 1 } )
// printf_string(&cputc, "cml", { 10, 1 } )
lda #<str
sta.z printf_string.str
lda #>str
@ -93,7 +125,7 @@ main: {
jsr printf_string
// cputln()
jsr cputln
// printf_string( "rules", { 10, 1 } )
// printf_string(&cputc, "rules", { 10, 1 } )
lda #<str1
sta.z printf_string.str
lda #>str1
@ -185,6 +217,34 @@ gotoxy: {
// }
rts
}
// Print a newline
cputln: {
// conio_line_text += CONIO_WIDTH
lda #$28
clc
adc.z conio_line_text
sta.z conio_line_text
bcc !+
inc.z conio_line_text+1
!:
// conio_line_color += CONIO_WIDTH
lda #$28
clc
adc.z conio_line_color
sta.z conio_line_color
bcc !+
inc.z conio_line_color+1
!:
// conio_cursor_x = 0
lda #0
sta.z conio_cursor_x
// conio_cursor_y++;
inc.z conio_cursor_y
// cscroll()
jsr cscroll
// }
rts
}
// clears the screen and moves the cursor to the upper left-hand corner of the screen.
clrscr: {
.label line_text = 3
@ -257,7 +317,7 @@ clrscr: {
}
// Print a string value using a specific format
// Handles justification and min length
// void printf_string(__zp(3) char *str, char format_min_length, __zp(2) char format_justify_left)
// void printf_string(void (*putc)(char), __zp(3) char *str, char format_min_length, __zp(2) char format_justify_left)
printf_string: {
.label __9 = 6
.label padding = 5
@ -291,15 +351,15 @@ printf_string: {
bne __b4
jmp __b2
__b4:
// printf_padding(' ',(char)padding)
// printf_padding(putc, ' ',(char)padding)
lda.z padding
sta.z printf_padding.length
lda #' '
sta.z printf_padding.pad
jsr printf_padding
__b2:
// cputs(str)
jsr cputs
// printf_str(putc, str)
jsr printf_str
// if(format.justify_left && padding)
lda.z format_justify_left
beq __breturn
@ -308,7 +368,7 @@ printf_string: {
bne __b5
rts
__b5:
// printf_padding(' ',(char)padding)
// printf_padding(putc, ' ',(char)padding)
lda.z padding
sta.z printf_padding.length
lda #' '
@ -318,108 +378,6 @@ printf_string: {
// }
rts
}
// Print a newline
cputln: {
// conio_line_text += CONIO_WIDTH
lda #$28
clc
adc.z conio_line_text
sta.z conio_line_text
bcc !+
inc.z conio_line_text+1
!:
// conio_line_color += CONIO_WIDTH
lda #$28
clc
adc.z conio_line_color
sta.z conio_line_color
bcc !+
inc.z conio_line_color+1
!:
// conio_cursor_x = 0
lda #0
sta.z conio_cursor_x
// conio_cursor_y++;
inc.z conio_cursor_y
// cscroll()
jsr cscroll
// }
rts
}
// Computes the length of the string str up to but not including the terminating null character.
// __zp(6) unsigned int strlen(__zp($b) char *str)
strlen: {
.label len = 6
.label str = $b
.label return = 6
lda #<0
sta.z len
sta.z len+1
__b1:
// while(*str)
ldy #0
lda (str),y
cmp #0
bne __b2
// }
rts
__b2:
// len++;
inc.z len
bne !+
inc.z len+1
!:
// str++;
inc.z str
bne !+
inc.z str+1
!:
jmp __b1
}
// Print a padding char a number of times
// void printf_padding(__zp(9) char pad, __zp(8) char length)
printf_padding: {
.label i = $a
.label length = 8
.label pad = 9
lda #0
sta.z i
__b1:
// for(char i=0;i<length; i++)
lda.z i
cmp.z length
bcc __b2
// }
rts
__b2:
// cputc(pad)
lda.z pad
jsr cputc
// for(char i=0;i<length; i++)
inc.z i
jmp __b1
}
// Output a NUL-terminated string at the current cursor position
// void cputs(__zp(3) const char *s)
cputs: {
.label s = 3
__b1:
// while(c=*s++)
ldy #0
lda (s),y
inc.z s
bne !+
inc.z s+1
!:
cmp #0
bne __b2
// }
rts
__b2:
// cputc(c)
jsr cputc
jmp __b1
}
// Scroll the entire screen if the cursor is beyond the last line
cscroll: {
// if(conio_cursor_y==CONIO_HEIGHT)
@ -482,33 +440,83 @@ cscroll: {
// }
rts
}
// Output one character at the current cursor position
// Moves the cursor forward. Scrolls the entire screen if needed
// void cputc(__register(A) char c)
cputc: {
// if(c=='\n')
cmp #'\n'
beq __b1
// conio_line_text[conio_cursor_x] = c
ldy.z conio_cursor_x
sta (conio_line_text),y
// conio_line_color[conio_cursor_x] = conio_textcolor
lda #LIGHT_BLUE
sta (conio_line_color),y
// if(++conio_cursor_x==CONIO_WIDTH)
inc.z conio_cursor_x
lda #$28
cmp.z conio_cursor_x
bne __breturn
// cputln()
jsr cputln
__breturn:
// Computes the length of the string str up to but not including the terminating null character.
// __zp(6) unsigned int strlen(__zp($b) char *str)
strlen: {
.label len = 6
.label str = $b
.label return = 6
lda #<0
sta.z len
sta.z len+1
__b1:
// while(*str)
ldy #0
lda (str),y
cmp #0
bne __b2
// }
rts
__b2:
// len++;
inc.z len
bne !+
inc.z len+1
!:
// str++;
inc.z str
bne !+
inc.z str+1
!:
jmp __b1
}
// Print a padding char a number of times
// void printf_padding(void (*putc)(char), __zp(9) char pad, __zp(8) char length)
printf_padding: {
.label i = $a
.label length = 8
.label pad = 9
lda #0
sta.z i
__b1:
// cputln()
jsr cputln
// for(char i=0;i<length; i++)
lda.z i
cmp.z length
bcc __b2
// }
rts
__b2:
// putc(pad)
lda.z pad
pha
jsr cputc
pla
// for(char i=0;i<length; i++)
inc.z i
jmp __b1
}
/// Print a NUL-terminated string
// void printf_str(void (*putc)(char), __zp(3) const char *s)
printf_str: {
.label s = 3
__b1:
// while(c=*s++)
ldy #0
lda (s),y
inc.z s
bne !+
inc.z s+1
!:
cmp #0
bne __b2
// }
rts
__b2:
// putc(c)
pha
jsr cputc
pla
jmp __b1
}
// Copy block of memory (forwards)
// Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.

View File

@ -35,310 +35,312 @@ conio_c64_init::@return: scope:[conio_c64_init] from conio_c64_init::@1
[15] return
to:@return
__stackcall void cputc(char c)
cputc: scope:[cputc] from printf_padding::@2 printf_str::@2
[16] cputc::c#0 = stackidx(char,cputc::OFFSET_STACK_C)
[17] if(cputc::c#0=='
') goto cputc::@1
to:cputc::@2
cputc::@2: scope:[cputc] from cputc
[18] conio_line_text[conio_cursor_x] = cputc::c#0
[19] conio_line_color[conio_cursor_x] = LIGHT_BLUE
[20] conio_cursor_x = ++ conio_cursor_x
[21] if(conio_cursor_x!=$28) goto cputc::@return
to:cputc::@3
cputc::@3: scope:[cputc] from cputc::@2
[22] phi()
[23] call cputln
to:cputc::@return
cputc::@return: scope:[cputc] from cputc::@1 cputc::@2 cputc::@3
[24] return
to:@return
cputc::@1: scope:[cputc] from cputc
[25] phi()
[26] call cputln
to:cputc::@return
void main()
main: scope:[main] from __start::@1
[16] phi()
[17] call clrscr
[27] phi()
[28] call clrscr
to:main::@1
main::@1: scope:[main] from main
[18] phi()
[19] call printf_string
[29] phi()
[30] call printf_string
to:main::@2
main::@2: scope:[main] from main::@1
[20] phi()
[21] call cputln
[31] phi()
[32] call cputln
to:main::@3
main::@3: scope:[main] from main::@2
[22] phi()
[23] call printf_string
[33] phi()
[34] call printf_string
to:main::@4
main::@4: scope:[main] from main::@3
[24] phi()
[25] call cputln
[35] phi()
[36] call cputln
to:main::@5
main::@5: scope:[main] from main::@4
[26] phi()
[27] call printf_string
[37] phi()
[38] call printf_string
to:main::@6
main::@6: scope:[main] from main::@5
[28] phi()
[29] call cputln
[39] phi()
[40] call cputln
to:main::@7
main::@7: scope:[main] from main::@6
[30] phi()
[31] call printf_string
[41] phi()
[42] call printf_string
to:main::@return
main::@return: scope:[main] from main::@7
[32] return
[43] return
to:@return
void gotoxy(char x , char y)
gotoxy: scope:[gotoxy] from conio_c64_init::@1
[33] if(gotoxy::y#2<$19+1) goto gotoxy::@3
[44] if(gotoxy::y#2<$19+1) goto gotoxy::@3
to:gotoxy::@1
gotoxy::@3: scope:[gotoxy] from gotoxy
[34] phi()
[45] phi()
to:gotoxy::@1
gotoxy::@1: scope:[gotoxy] from gotoxy gotoxy::@3
[35] gotoxy::y#4 = phi( gotoxy::@3/gotoxy::y#2, gotoxy/0 )
[46] gotoxy::y#4 = phi( gotoxy::@3/gotoxy::y#2, gotoxy/0 )
to:gotoxy::@2
gotoxy::@2: scope:[gotoxy] from gotoxy::@1
[36] conio_cursor_x = gotoxy::x#2
[37] conio_cursor_y = gotoxy::y#4
[38] gotoxy::$7 = (unsigned int)gotoxy::y#4
[39] gotoxy::$8 = gotoxy::$7 << 2
[40] gotoxy::$9 = gotoxy::$8 + gotoxy::$7
[41] gotoxy::line_offset#0 = gotoxy::$9 << 3
[42] gotoxy::$5 = DEFAULT_SCREEN + gotoxy::line_offset#0
[43] conio_line_text = gotoxy::$5
[44] gotoxy::$6 = COLORRAM + gotoxy::line_offset#0
[45] conio_line_color = gotoxy::$6
[47] conio_cursor_x = gotoxy::x#2
[48] conio_cursor_y = gotoxy::y#4
[49] gotoxy::$7 = (unsigned int)gotoxy::y#4
[50] gotoxy::$8 = gotoxy::$7 << 2
[51] gotoxy::$9 = gotoxy::$8 + gotoxy::$7
[52] gotoxy::line_offset#0 = gotoxy::$9 << 3
[53] gotoxy::$5 = DEFAULT_SCREEN + gotoxy::line_offset#0
[54] conio_line_text = gotoxy::$5
[55] gotoxy::$6 = COLORRAM + gotoxy::line_offset#0
[56] conio_line_color = gotoxy::$6
to:gotoxy::@return
gotoxy::@return: scope:[gotoxy] from gotoxy::@2
[46] return
to:@return
void clrscr()
clrscr: scope:[clrscr] from main
[47] phi()
to:clrscr::@1
clrscr::@1: scope:[clrscr] from clrscr clrscr::@5
[48] clrscr::line_cols#5 = phi( clrscr/COLORRAM, clrscr::@5/clrscr::line_cols#1 )
[48] clrscr::line_text#5 = phi( clrscr/DEFAULT_SCREEN, clrscr::@5/clrscr::line_text#1 )
[48] clrscr::l#2 = phi( clrscr/0, clrscr::@5/clrscr::l#1 )
[49] if(clrscr::l#2<$19) goto clrscr::@3
to:clrscr::@2
clrscr::@2: scope:[clrscr] from clrscr::@1
[50] conio_cursor_x = 0
[51] conio_cursor_y = 0
[52] conio_line_text = DEFAULT_SCREEN
[53] conio_line_color = COLORRAM
to:clrscr::@return
clrscr::@return: scope:[clrscr] from clrscr::@2
[54] return
to:@return
clrscr::@3: scope:[clrscr] from clrscr::@1 clrscr::@4
[55] clrscr::c#2 = phi( clrscr::@1/0, clrscr::@4/clrscr::c#1 )
[56] if(clrscr::c#2<$28) goto clrscr::@4
to:clrscr::@5
clrscr::@5: scope:[clrscr] from clrscr::@3
[57] clrscr::line_text#1 = clrscr::line_text#5 + $28
[58] clrscr::line_cols#1 = clrscr::line_cols#5 + $28
[59] clrscr::l#1 = ++ clrscr::l#2
to:clrscr::@1
clrscr::@4: scope:[clrscr] from clrscr::@3
[60] clrscr::line_text#5[clrscr::c#2] = ' '
[61] clrscr::line_cols#5[clrscr::c#2] = LIGHT_BLUE
[62] clrscr::c#1 = ++ clrscr::c#2
to:clrscr::@3
void printf_string(char *str , char format_min_length , char format_justify_left)
printf_string: scope:[printf_string] from main::@1 main::@3 main::@5 main::@7
[63] printf_string::str#10 = phi( main::@1/main::str, main::@3/main::str1, main::@5/main::str, main::@7/main::str1 )
[63] printf_string::format_justify_left#10 = phi( main::@1/0, main::@3/0, main::@5/1, main::@7/1 )
to:printf_string::@3
printf_string::@3: scope:[printf_string] from printf_string
[64] strlen::str#1 = printf_string::str#10
[65] call strlen
[66] strlen::return#2 = strlen::len#2
to:printf_string::@6
printf_string::@6: scope:[printf_string] from printf_string::@3
[67] printf_string::$9 = strlen::return#2
[68] printf_string::len#0 = (signed char)printf_string::$9
[69] printf_string::padding#1 = $a - printf_string::len#0
[70] if(printf_string::padding#1>=0) goto printf_string::@10
to:printf_string::@1
printf_string::@10: scope:[printf_string] from printf_string::@6
[71] phi()
to:printf_string::@1
printf_string::@1: scope:[printf_string] from printf_string::@10 printf_string::@6
[72] printf_string::padding#3 = phi( printf_string::@6/0, printf_string::@10/printf_string::padding#1 )
[73] if(0!=printf_string::format_justify_left#10) goto printf_string::@2
to:printf_string::@8
printf_string::@8: scope:[printf_string] from printf_string::@1
[74] if(0!=printf_string::padding#3) goto printf_string::@4
to:printf_string::@2
printf_string::@4: scope:[printf_string] from printf_string::@8
[75] printf_padding::length#0 = (char)printf_string::padding#3
[76] call printf_padding
to:printf_string::@2
printf_string::@2: scope:[printf_string] from printf_string::@1 printf_string::@4 printf_string::@8
[77] cputs::s#1 = printf_string::str#10
[78] call cputs
to:printf_string::@7
printf_string::@7: scope:[printf_string] from printf_string::@2
[79] if(0==printf_string::format_justify_left#10) goto printf_string::@return
to:printf_string::@9
printf_string::@9: scope:[printf_string] from printf_string::@7
[80] if(0!=printf_string::padding#3) goto printf_string::@5
to:printf_string::@return
printf_string::@5: scope:[printf_string] from printf_string::@9
[81] printf_padding::length#1 = (char)printf_string::padding#3
[82] call printf_padding
to:printf_string::@return
printf_string::@return: scope:[printf_string] from printf_string::@5 printf_string::@7 printf_string::@9
[83] return
[57] return
to:@return
void cputln()
cputln: scope:[cputln] from cputc::@1 cputc::@3 main::@2 main::@4 main::@6
[84] conio_line_text = conio_line_text + $28
[85] conio_line_color = conio_line_color + $28
[86] conio_cursor_x = 0
[87] conio_cursor_y = ++ conio_cursor_y
[88] call cscroll
[58] conio_line_text = conio_line_text + $28
[59] conio_line_color = conio_line_color + $28
[60] conio_cursor_x = 0
[61] conio_cursor_y = ++ conio_cursor_y
[62] call cscroll
to:cputln::@return
cputln::@return: scope:[cputln] from cputln
[89] return
[63] return
to:@return
void clrscr()
clrscr: scope:[clrscr] from main
[64] phi()
to:clrscr::@1
clrscr::@1: scope:[clrscr] from clrscr clrscr::@5
[65] clrscr::line_cols#5 = phi( clrscr/COLORRAM, clrscr::@5/clrscr::line_cols#1 )
[65] clrscr::line_text#5 = phi( clrscr/DEFAULT_SCREEN, clrscr::@5/clrscr::line_text#1 )
[65] clrscr::l#2 = phi( clrscr/0, clrscr::@5/clrscr::l#1 )
[66] if(clrscr::l#2<$19) goto clrscr::@3
to:clrscr::@2
clrscr::@2: scope:[clrscr] from clrscr::@1
[67] conio_cursor_x = 0
[68] conio_cursor_y = 0
[69] conio_line_text = DEFAULT_SCREEN
[70] conio_line_color = COLORRAM
to:clrscr::@return
clrscr::@return: scope:[clrscr] from clrscr::@2
[71] return
to:@return
clrscr::@3: scope:[clrscr] from clrscr::@1 clrscr::@4
[72] clrscr::c#2 = phi( clrscr::@1/0, clrscr::@4/clrscr::c#1 )
[73] if(clrscr::c#2<$28) goto clrscr::@4
to:clrscr::@5
clrscr::@5: scope:[clrscr] from clrscr::@3
[74] clrscr::line_text#1 = clrscr::line_text#5 + $28
[75] clrscr::line_cols#1 = clrscr::line_cols#5 + $28
[76] clrscr::l#1 = ++ clrscr::l#2
to:clrscr::@1
clrscr::@4: scope:[clrscr] from clrscr::@3
[77] clrscr::line_text#5[clrscr::c#2] = ' '
[78] clrscr::line_cols#5[clrscr::c#2] = LIGHT_BLUE
[79] clrscr::c#1 = ++ clrscr::c#2
to:clrscr::@3
void printf_string(void (*putc)(char) , char *str , char format_min_length , char format_justify_left)
printf_string: scope:[printf_string] from main::@1 main::@3 main::@5 main::@7
[80] printf_string::str#10 = phi( main::@1/main::str, main::@3/main::str1, main::@5/main::str, main::@7/main::str1 )
[80] printf_string::format_justify_left#10 = phi( main::@1/0, main::@3/0, main::@5/1, main::@7/1 )
to:printf_string::@3
printf_string::@3: scope:[printf_string] from printf_string
[81] strlen::str#1 = printf_string::str#10
[82] call strlen
[83] strlen::return#2 = strlen::len#2
to:printf_string::@6
printf_string::@6: scope:[printf_string] from printf_string::@3
[84] printf_string::$9 = strlen::return#2
[85] printf_string::len#0 = (signed char)printf_string::$9
[86] printf_string::padding#1 = $a - printf_string::len#0
[87] if(printf_string::padding#1>=0) goto printf_string::@10
to:printf_string::@1
printf_string::@10: scope:[printf_string] from printf_string::@6
[88] phi()
to:printf_string::@1
printf_string::@1: scope:[printf_string] from printf_string::@10 printf_string::@6
[89] printf_string::padding#3 = phi( printf_string::@6/0, printf_string::@10/printf_string::padding#1 )
[90] if(0!=printf_string::format_justify_left#10) goto printf_string::@2
to:printf_string::@8
printf_string::@8: scope:[printf_string] from printf_string::@1
[91] if(0!=printf_string::padding#3) goto printf_string::@4
to:printf_string::@2
printf_string::@4: scope:[printf_string] from printf_string::@8
[92] printf_padding::length#0 = (char)printf_string::padding#3
[93] call printf_padding
to:printf_string::@2
printf_string::@2: scope:[printf_string] from printf_string::@1 printf_string::@4 printf_string::@8
[94] printf_str::s#1 = printf_string::str#10
[95] call printf_str
to:printf_string::@7
printf_string::@7: scope:[printf_string] from printf_string::@2
[96] if(0==printf_string::format_justify_left#10) goto printf_string::@return
to:printf_string::@9
printf_string::@9: scope:[printf_string] from printf_string::@7
[97] if(0!=printf_string::padding#3) goto printf_string::@5
to:printf_string::@return
printf_string::@5: scope:[printf_string] from printf_string::@9
[98] printf_padding::length#1 = (char)printf_string::padding#3
[99] call printf_padding
to:printf_string::@return
printf_string::@return: scope:[printf_string] from printf_string::@5 printf_string::@7 printf_string::@9
[100] return
to:@return
void cscroll()
cscroll: scope:[cscroll] from cputln
[101] if(conio_cursor_y!=$19) goto cscroll::@return
to:cscroll::@1
cscroll::@1: scope:[cscroll] from cscroll
[102] phi()
[103] call memcpy
to:cscroll::@2
cscroll::@2: scope:[cscroll] from cscroll::@1
[104] phi()
[105] call memcpy
to:cscroll::@3
cscroll::@3: scope:[cscroll] from cscroll::@2
[106] phi()
[107] call memset
to:cscroll::@4
cscroll::@4: scope:[cscroll] from cscroll::@3
[108] phi()
[109] call memset
to:cscroll::@5
cscroll::@5: scope:[cscroll] from cscroll::@4
[110] conio_line_text = conio_line_text - $28
[111] conio_line_color = conio_line_color - $28
[112] conio_cursor_y = -- conio_cursor_y
to:cscroll::@return
cscroll::@return: scope:[cscroll] from cscroll cscroll::@5
[113] return
to:@return
unsigned int strlen(char *str)
strlen: scope:[strlen] from printf_string::@3
[90] phi()
[114] phi()
to:strlen::@1
strlen::@1: scope:[strlen] from strlen strlen::@2
[91] strlen::len#2 = phi( strlen/0, strlen::@2/strlen::len#1 )
[91] strlen::str#2 = phi( strlen/strlen::str#1, strlen::@2/strlen::str#0 )
[92] if(0!=*strlen::str#2) goto strlen::@2
[115] strlen::len#2 = phi( strlen/0, strlen::@2/strlen::len#1 )
[115] strlen::str#2 = phi( strlen/strlen::str#1, strlen::@2/strlen::str#0 )
[116] if(0!=*strlen::str#2) goto strlen::@2
to:strlen::@return
strlen::@return: scope:[strlen] from strlen::@1
[93] return
[117] return
to:@return
strlen::@2: scope:[strlen] from strlen::@1
[94] strlen::len#1 = ++ strlen::len#2
[95] strlen::str#0 = ++ strlen::str#2
[118] strlen::len#1 = ++ strlen::len#2
[119] strlen::str#0 = ++ strlen::str#2
to:strlen::@1
void printf_padding(char pad , char length)
void printf_padding(void (*putc)(char) , char pad , char length)
printf_padding: scope:[printf_padding] from printf_string::@4 printf_string::@5
[96] printf_padding::pad#4 = phi( printf_string::@4/' ', printf_string::@5/' ' )
[96] printf_padding::length#3 = phi( printf_string::@4/printf_padding::length#0, printf_string::@5/printf_padding::length#1 )
[120] printf_padding::pad#4 = phi( printf_string::@4/' ', printf_string::@5/' ' )
[120] printf_padding::length#3 = phi( printf_string::@4/printf_padding::length#0, printf_string::@5/printf_padding::length#1 )
to:printf_padding::@1
printf_padding::@1: scope:[printf_padding] from printf_padding printf_padding::@3
[97] printf_padding::i#2 = phi( printf_padding/0, printf_padding::@3/printf_padding::i#1 )
[98] if(printf_padding::i#2<printf_padding::length#3) goto printf_padding::@2
[121] printf_padding::i#2 = phi( printf_padding/0, printf_padding::@3/printf_padding::i#1 )
[122] if(printf_padding::i#2<printf_padding::length#3) goto printf_padding::@2
to:printf_padding::@return
printf_padding::@return: scope:[printf_padding] from printf_padding::@1
[99] return
to:@return
printf_padding::@2: scope:[printf_padding] from printf_padding::@1
[100] cputc::c#1 = printf_padding::pad#4
[101] call cputc
to:printf_padding::@3
printf_padding::@3: scope:[printf_padding] from printf_padding::@2
[102] printf_padding::i#1 = ++ printf_padding::i#2
to:printf_padding::@1
void cputs(const char *s)
cputs: scope:[cputs] from printf_string::@2
[103] phi()
to:cputs::@1
cputs::@1: scope:[cputs] from cputs cputs::@2
[104] cputs::s#2 = phi( cputs/cputs::s#1, cputs::@2/cputs::s#0 )
[105] cputs::c#1 = *cputs::s#2
[106] cputs::s#0 = ++ cputs::s#2
[107] if(0!=cputs::c#1) goto cputs::@2
to:cputs::@return
cputs::@return: scope:[cputs] from cputs::@1
[108] return
to:@return
cputs::@2: scope:[cputs] from cputs::@1
[109] cputc::c#0 = cputs::c#1
[110] call cputc
to:cputs::@1
void cscroll()
cscroll: scope:[cscroll] from cputln
[111] if(conio_cursor_y!=$19) goto cscroll::@return
to:cscroll::@1
cscroll::@1: scope:[cscroll] from cscroll
[112] phi()
[113] call memcpy
to:cscroll::@2
cscroll::@2: scope:[cscroll] from cscroll::@1
[114] phi()
[115] call memcpy
to:cscroll::@3
cscroll::@3: scope:[cscroll] from cscroll::@2
[116] phi()
[117] call memset
to:cscroll::@4
cscroll::@4: scope:[cscroll] from cscroll::@3
[118] phi()
[119] call memset
to:cscroll::@5
cscroll::@5: scope:[cscroll] from cscroll::@4
[120] conio_line_text = conio_line_text - $28
[121] conio_line_color = conio_line_color - $28
[122] conio_cursor_y = -- conio_cursor_y
to:cscroll::@return
cscroll::@return: scope:[cscroll] from cscroll cscroll::@5
[123] return
to:@return
printf_padding::@2: scope:[printf_padding] from printf_padding::@1
[124] stackpush(char) = printf_padding::pad#4
[125] callexecute cputc
sideeffect stackpullbytes(1)
to:printf_padding::@3
printf_padding::@3: scope:[printf_padding] from printf_padding::@2
[127] printf_padding::i#1 = ++ printf_padding::i#2
to:printf_padding::@1
void cputc(char c)
cputc: scope:[cputc] from cputs::@2 printf_padding::@2
[124] cputc::c#2 = phi( cputs::@2/cputc::c#0, printf_padding::@2/cputc::c#1 )
[125] if(cputc::c#2=='
') goto cputc::@1
to:cputc::@2
cputc::@2: scope:[cputc] from cputc
[126] conio_line_text[conio_cursor_x] = cputc::c#2
[127] conio_line_color[conio_cursor_x] = LIGHT_BLUE
[128] conio_cursor_x = ++ conio_cursor_x
[129] if(conio_cursor_x!=$28) goto cputc::@return
to:cputc::@3
cputc::@3: scope:[cputc] from cputc::@2
[130] phi()
[131] call cputln
to:cputc::@return
cputc::@return: scope:[cputc] from cputc::@1 cputc::@2 cputc::@3
[132] return
void printf_str(void (*putc)(char) , const char *s)
printf_str: scope:[printf_str] from printf_string::@2
[128] phi()
to:printf_str::@1
printf_str::@1: scope:[printf_str] from printf_str printf_str::@2
[129] printf_str::s#2 = phi( printf_str/printf_str::s#1, printf_str::@2/printf_str::s#0 )
[130] printf_str::c#1 = *printf_str::s#2
[131] printf_str::s#0 = ++ printf_str::s#2
[132] if(0!=printf_str::c#1) goto printf_str::@2
to:printf_str::@return
printf_str::@return: scope:[printf_str] from printf_str::@1
[133] return
to:@return
cputc::@1: scope:[cputc] from cputc
[133] phi()
[134] call cputln
to:cputc::@return
printf_str::@2: scope:[printf_str] from printf_str::@1
[134] stackpush(char) = printf_str::c#1
[135] callexecute cputc
sideeffect stackpullbytes(1)
to:printf_str::@1
void * memcpy(void *destination , void *source , unsigned int num)
memcpy: scope:[memcpy] from cscroll::@1 cscroll::@2
[135] memcpy::destination#2 = phi( cscroll::@1/(void *)DEFAULT_SCREEN, cscroll::@2/(void *)COLORRAM )
[135] memcpy::source#2 = phi( cscroll::@1/(void *)DEFAULT_SCREEN+$28, cscroll::@2/(void *)COLORRAM+$28 )
[136] memcpy::src_end#0 = (char *)memcpy::source#2 + (unsigned int)$19*$28-$28
[137] memcpy::src#4 = (char *)memcpy::source#2
[138] memcpy::dst#4 = (char *)memcpy::destination#2
[137] memcpy::destination#2 = phi( cscroll::@1/(void *)DEFAULT_SCREEN, cscroll::@2/(void *)COLORRAM )
[137] memcpy::source#2 = phi( cscroll::@1/(void *)DEFAULT_SCREEN+$28, cscroll::@2/(void *)COLORRAM+$28 )
[138] memcpy::src_end#0 = (char *)memcpy::source#2 + (unsigned int)$19*$28-$28
[139] memcpy::src#4 = (char *)memcpy::source#2
[140] memcpy::dst#4 = (char *)memcpy::destination#2
to:memcpy::@1
memcpy::@1: scope:[memcpy] from memcpy memcpy::@2
[139] memcpy::dst#2 = phi( memcpy/memcpy::dst#4, memcpy::@2/memcpy::dst#1 )
[139] memcpy::src#2 = phi( memcpy/memcpy::src#4, memcpy::@2/memcpy::src#1 )
[140] if(memcpy::src#2!=memcpy::src_end#0) goto memcpy::@2
[141] memcpy::dst#2 = phi( memcpy/memcpy::dst#4, memcpy::@2/memcpy::dst#1 )
[141] memcpy::src#2 = phi( memcpy/memcpy::src#4, memcpy::@2/memcpy::src#1 )
[142] if(memcpy::src#2!=memcpy::src_end#0) goto memcpy::@2
to:memcpy::@return
memcpy::@return: scope:[memcpy] from memcpy::@1
[141] return
[143] return
to:@return
memcpy::@2: scope:[memcpy] from memcpy::@1
[142] *memcpy::dst#2 = *memcpy::src#2
[143] memcpy::dst#1 = ++ memcpy::dst#2
[144] memcpy::src#1 = ++ memcpy::src#2
[144] *memcpy::dst#2 = *memcpy::src#2
[145] memcpy::dst#1 = ++ memcpy::dst#2
[146] memcpy::src#1 = ++ memcpy::src#2
to:memcpy::@1
void * memset(void *str , char c , unsigned int num)
memset: scope:[memset] from cscroll::@3 cscroll::@4
[145] memset::c#4 = phi( cscroll::@3/' ', cscroll::@4/LIGHT_BLUE )
[145] memset::str#3 = phi( cscroll::@3/(void *)DEFAULT_SCREEN+(unsigned int)$19*$28-$28, cscroll::@4/(void *)COLORRAM+(unsigned int)$19*$28-$28 )
[147] memset::c#4 = phi( cscroll::@3/' ', cscroll::@4/LIGHT_BLUE )
[147] memset::str#3 = phi( cscroll::@3/(void *)DEFAULT_SCREEN+(unsigned int)$19*$28-$28, cscroll::@4/(void *)COLORRAM+(unsigned int)$19*$28-$28 )
to:memset::@1
memset::@1: scope:[memset] from memset
[146] memset::end#0 = (char *)memset::str#3 + $28
[147] memset::dst#4 = (char *)memset::str#3
[148] memset::end#0 = (char *)memset::str#3 + $28
[149] memset::dst#4 = (char *)memset::str#3
to:memset::@2
memset::@2: scope:[memset] from memset::@1 memset::@3
[148] memset::dst#2 = phi( memset::@1/memset::dst#4, memset::@3/memset::dst#1 )
[149] if(memset::dst#2!=memset::end#0) goto memset::@3
[150] memset::dst#2 = phi( memset::@1/memset::dst#4, memset::@3/memset::dst#1 )
[151] if(memset::dst#2!=memset::end#0) goto memset::@3
to:memset::@return
memset::@return: scope:[memset] from memset::@2
[150] return
[152] return
to:@return
memset::@3: scope:[memset] from memset::@2
[151] *memset::dst#2 = memset::c#4
[152] memset::dst#1 = ++ memset::dst#2
[153] *memset::dst#2 = memset::c#4
[154] memset::dst#1 = ++ memset::dst#2
to:memset::@2

File diff suppressed because one or more lines are too long

View File

@ -5,6 +5,7 @@ __constant char RADIX::BINARY = 2
__constant char RADIX::DECIMAL = $a
__constant char RADIX::HEXADECIMAL = $10
__constant char RADIX::OCTAL = 8
__constant unsigned int STACK_BASE = $103
void __start()
void clrscr()
char clrscr::c
@ -24,23 +25,15 @@ __constant char * const conio_c64_init::BASIC_CURSOR_LINE = (char *) 214
char conio_c64_init::line
char conio_c64_init::line#0 // reg byte x 11.0
char conio_c64_init::line#2 // reg byte x 22.0
__loadstore char conio_cursor_x // zp[1]:13 25003.500000000007
__loadstore char conio_cursor_y // zp[1]:14 380954.86904761905
__loadstore char *conio_line_color // zp[2]:17 269514.743902439
__loadstore char *conio_line_text // zp[2]:15 266267.578313253
void cputc(char c)
__loadstore char conio_cursor_x // zp[1]:13 24196.93548387097
__loadstore char conio_cursor_y // zp[1]:14 372095.4534883721
__loadstore char *conio_line_color // zp[2]:17 263097.7261904762
__loadstore char *conio_line_text // zp[2]:15 260002.45882352942
__stackcall void cputc(char c)
__constant char cputc::OFFSET_STACK_C = 0
char cputc::c
char cputc::c#0 // reg byte a 20002.0
char cputc::c#1 // reg byte a 20002.0
char cputc::c#2 // reg byte a 110002.0
char cputc::c#0 // reg byte a 150001.5
void cputln()
void cputs(const char *s)
char cputs::c
char cputs::c#1 // reg byte a 10001.0
const char *cputs::s
const char *cputs::s#0 // s zp[2]:3 5000.5
const char *cputs::s#1 // s zp[2]:3 551.0
const char *cputs::s#2 // s zp[2]:3 15502.0
void cscroll()
void gotoxy(char x , char y)
char *gotoxy::$5 // zp[2]:23 202.0
@ -88,17 +81,26 @@ unsigned int memset::num
void *memset::return
void *memset::str
void *memset::str#3 // str zp[2]:11
void printf_padding(char pad , char length)
void printf_padding(void (*putc)(char) , char pad , char length)
char printf_padding::i
char printf_padding::i#1 // i zp[1]:10 20002.0
char printf_padding::i#2 // i zp[1]:10 7500.75
char printf_padding::i#2 // i zp[1]:10 6000.6
char printf_padding::length
char printf_padding::length#0 // length zp[1]:8 202.0
char printf_padding::length#1 // length zp[1]:8 202.0
char printf_padding::length#3 // length zp[1]:8 1700.5
char printf_padding::length#3 // length zp[1]:8 1457.5714285714287
char printf_padding::pad
char printf_padding::pad#4 // pad zp[1]:9 1666.8333333333333
void printf_string(char *str , char format_min_length , char format_justify_left)
char printf_padding::pad#4 // pad zp[1]:9 1428.7142857142858
void (*printf_padding::putc)(char)
void printf_str(void (*putc)(char) , const char *s)
char printf_str::c
char printf_str::c#1 // reg byte a 10001.0
void (*printf_str::putc)(char)
const char *printf_str::s
const char *printf_str::s#0 // s zp[2]:3 4000.4
const char *printf_str::s#1 // s zp[2]:3 551.0
const char *printf_str::s#2 // s zp[2]:3 15502.0
void printf_string(void (*putc)(char) , char *str , char format_min_length , char format_justify_left)
unsigned int printf_string::$9 // zp[2]:6 101.0
struct printf_format_string printf_string::format
char printf_string::format_justify_left
@ -109,6 +111,7 @@ signed char printf_string::len#0 // reg byte a 202.0
signed char printf_string::padding
signed char printf_string::padding#1 // padding zp[1]:5 101.0
signed char printf_string::padding#3 // padding zp[1]:5 33.666666666666664
void (*printf_string::putc)(char)
char *printf_string::str
char *printf_string::str#10 // str zp[2]:3 14.428571428571429
unsigned int strlen(char *str)
@ -127,23 +130,23 @@ reg byte x [ gotoxy::y#4 gotoxy::y#2 ]
reg byte x [ clrscr::l#2 clrscr::l#1 ]
reg byte y [ clrscr::c#2 clrscr::c#1 ]
zp[1]:2 [ printf_string::format_justify_left#10 ]
zp[2]:3 [ printf_string::str#10 cputs::s#2 cputs::s#1 cputs::s#0 clrscr::line_text#5 clrscr::line_text#1 ]
zp[2]:3 [ printf_string::str#10 printf_str::s#2 printf_str::s#1 printf_str::s#0 clrscr::line_text#5 clrscr::line_text#1 ]
zp[1]:5 [ printf_string::padding#3 printf_string::padding#1 ]
zp[2]:6 [ strlen::len#2 strlen::len#1 strlen::return#2 printf_string::$9 ]
zp[1]:8 [ printf_padding::length#3 printf_padding::length#0 printf_padding::length#1 ]
zp[1]:9 [ printf_padding::pad#4 ]
zp[1]:10 [ printf_padding::i#2 printf_padding::i#1 ]
reg byte a [ cputc::c#2 cputc::c#0 cputc::c#1 ]
zp[2]:11 [ memset::str#3 memset::dst#2 memset::dst#4 memset::dst#1 memcpy::source#2 memcpy::src#2 memcpy::src#4 memcpy::src#1 strlen::str#2 strlen::str#1 strlen::str#0 clrscr::line_cols#5 clrscr::line_cols#1 ]
reg byte x [ memset::c#4 ]
zp[1]:13 [ conio_cursor_x ]
zp[1]:14 [ conio_cursor_y ]
zp[2]:15 [ conio_line_text ]
zp[2]:17 [ conio_line_color ]
reg byte a [ cputc::c#0 ]
zp[2]:19 [ gotoxy::$7 gotoxy::$9 gotoxy::line_offset#0 gotoxy::$6 ]
zp[2]:21 [ gotoxy::$8 ]
zp[2]:23 [ gotoxy::$5 ]
reg byte a [ printf_string::len#0 ]
reg byte a [ cputs::c#1 ]
reg byte a [ printf_str::c#1 ]
zp[2]:25 [ memcpy::src_end#0 ]
zp[2]:27 [ memset::end#0 memcpy::destination#2 memcpy::dst#2 memcpy::dst#4 memcpy::dst#1 ]

View File

@ -1,5 +1,5 @@
// Tests printf function call rewriting
// A simple string - with the printf-sub cuntions in the same file.
// A simple string - with the printf-sub funtions in the same file.
// Commodore 64 PRG executable file
.file [name="printf-10.prg", type="prg", segments="Program"]
.segmentdef Program [segments="Basic, Code, Data"]
@ -17,18 +17,18 @@ main: {
lda #>$400
sta.z screen+1
lda #<str
sta.z cputs.str
sta.z printf_str.str
lda #>str
sta.z cputs.str+1
jsr cputs
sta.z printf_str.str+1
jsr printf_str
// printf("Hello, I am %s. who are you?", name)
jsr printf_string
// printf("Hello, I am %s. who are you?", name)
lda #<str1
sta.z cputs.str
sta.z printf_str.str
lda #>str1
sta.z cputs.str+1
jsr cputs
sta.z printf_str.str+1
jsr printf_str
// }
rts
.segment Data
@ -40,8 +40,8 @@ main: {
.byte 0
}
.segment Code
// void cputs(__zp(4) char *str)
cputs: {
// void printf_str(void (*putc)(char), __zp(4) char *str)
printf_str: {
.label str = 4
__b1:
// while(*str)
@ -69,14 +69,14 @@ cputs: {
}
// Print a string value using a specific format
// Handles justification and min length
// void printf_string(char *str, char format_min_length, char format_justify_left)
// void printf_string(void (*putc)(char), char *str, char format_min_length, char format_justify_left)
printf_string: {
// cputs(str)
// printf_str(putc, str)
lda #<main.name
sta.z cputs.str
sta.z printf_str.str
lda #>main.name
sta.z cputs.str+1
jsr cputs
sta.z printf_str.str+1
jsr printf_str
// }
rts
}

View File

@ -2,7 +2,7 @@
void main()
main: scope:[main] from
[0] phi()
[1] call cputs
[1] call printf_str
to:main::@1
main::@1: scope:[main] from main
[2] phi()
@ -10,35 +10,35 @@ main::@1: scope:[main] from main
to:main::@2
main::@2: scope:[main] from main::@1
[4] phi()
[5] call cputs
[5] call printf_str
to:main::@return
main::@return: scope:[main] from main::@2
[6] return
to:@return
void cputs(char *str)
cputs: scope:[cputs] from main main::@2 printf_string
void printf_str(void (*putc)(char) , char *str)
printf_str: scope:[printf_str] from main main::@2 printf_string
[7] screen#25 = phi( main/(char *) 1024, main::@2/screen#1, printf_string/screen#1 )
[7] cputs::str#6 = phi( main/main::str, main::@2/main::str1, printf_string/main::name )
to:cputs::@1
cputs::@1: scope:[cputs] from cputs cputs::@2
[8] screen#1 = phi( cputs/screen#25, cputs::@2/screen#0 )
[8] cputs::str#4 = phi( cputs/cputs::str#6, cputs::@2/cputs::str#0 )
[9] if(0!=*cputs::str#4) goto cputs::@2
to:cputs::@return
cputs::@return: scope:[cputs] from cputs::@1
[7] printf_str::str#6 = phi( main/main::str, main::@2/main::str1, printf_string/main::name )
to:printf_str::@1
printf_str::@1: scope:[printf_str] from printf_str printf_str::@2
[8] screen#1 = phi( printf_str/screen#25, printf_str::@2/screen#0 )
[8] printf_str::str#4 = phi( printf_str/printf_str::str#6, printf_str::@2/printf_str::str#0 )
[9] if(0!=*printf_str::str#4) goto printf_str::@2
to:printf_str::@return
printf_str::@return: scope:[printf_str] from printf_str::@1
[10] return
to:@return
cputs::@2: scope:[cputs] from cputs::@1
[11] *screen#1 = *cputs::str#4
printf_str::@2: scope:[printf_str] from printf_str::@1
[11] *screen#1 = *printf_str::str#4
[12] screen#0 = ++ screen#1
[13] cputs::str#0 = ++ cputs::str#4
to:cputs::@1
[13] printf_str::str#0 = ++ printf_str::str#4
to:printf_str::@1
void printf_string(char *str , char format_min_length , char format_justify_left)
void printf_string(void (*putc)(char) , char *str , char format_min_length , char format_justify_left)
printf_string: scope:[printf_string] from main::@1
[14] phi()
[15] call cputs
[15] call printf_str
to:printf_string::@return
printf_string::@return: scope:[printf_string] from printf_string
[16] return

View File

@ -1,39 +1,41 @@
Added struct type cast to parameter value list call printf_string(main::name, (struct printf_format_string){ 0, 0 })
Added struct type cast to parameter value list call printf_string((void (*)(char)) 0, main::name, (struct printf_format_string){ 0, 0 })
Inlined call call __init
Eliminating unused variable with no statement main::$0
CONTROL FLOW GRAPH SSA
void cputs(char *str)
cputs: scope:[cputs] from main main::@2 printf_string
void printf_str(void (*putc)(char) , char *str)
printf_str: scope:[printf_str] from main main::@2 printf_string
screen#25 = phi( main/screen#23, main::@2/screen#5, printf_string/screen#22 )
cputs::str#6 = phi( main/cputs::str#2, main::@2/cputs::str#3, printf_string/cputs::str#1 )
to:cputs::@1
cputs::@1: scope:[cputs] from cputs cputs::@2
screen#21 = phi( cputs/screen#25, cputs::@2/screen#0 )
cputs::str#4 = phi( cputs/cputs::str#6, cputs::@2/cputs::str#0 )
cputs::$0 = 0 != *cputs::str#4
if(cputs::$0) goto cputs::@2
to:cputs::@return
cputs::@2: scope:[cputs] from cputs::@1
screen#11 = phi( cputs::@1/screen#21 )
cputs::str#5 = phi( cputs::@1/cputs::str#4 )
*screen#11 = *cputs::str#5
printf_str::str#6 = phi( main/printf_str::str#2, main::@2/printf_str::str#3, printf_string/printf_str::str#1 )
to:printf_str::@1
printf_str::@1: scope:[printf_str] from printf_str printf_str::@2
screen#21 = phi( printf_str/screen#25, printf_str::@2/screen#0 )
printf_str::str#4 = phi( printf_str/printf_str::str#6, printf_str::@2/printf_str::str#0 )
printf_str::$0 = 0 != *printf_str::str#4
if(printf_str::$0) goto printf_str::@2
to:printf_str::@return
printf_str::@2: scope:[printf_str] from printf_str::@1
screen#11 = phi( printf_str::@1/screen#21 )
printf_str::str#5 = phi( printf_str::@1/printf_str::str#4 )
*screen#11 = *printf_str::str#5
screen#0 = ++ screen#11
cputs::str#0 = ++ cputs::str#5
to:cputs::@1
cputs::@return: scope:[cputs] from cputs::@1
screen#12 = phi( cputs::@1/screen#21 )
printf_str::str#0 = ++ printf_str::str#5
to:printf_str::@1
printf_str::@return: scope:[printf_str] from printf_str::@1
screen#12 = phi( printf_str::@1/screen#21 )
screen#1 = screen#12
return
to:@return
void printf_string(char *str , char format_min_length , char format_justify_left)
void printf_string(void (*putc)(char) , char *str , char format_min_length , char format_justify_left)
printf_string: scope:[printf_string] from main::@1
screen#22 = phi( main::@1/screen#4 )
printf_string::str#1 = phi( main::@1/printf_string::str#0 )
cputs::str#1 = printf_string::str#1
call cputs
printf_string::putc#1 = phi( main::@1/printf_string::putc#0 )
printf_str::putc#0 = printf_string::putc#1
printf_str::str#1 = printf_string::str#1
call printf_str
to:printf_string::@1
printf_string::@1: scope:[printf_string] from printf_string
screen#13 = phi( printf_string/screen#1 )
@ -48,12 +50,14 @@ printf_string::@return: scope:[printf_string] from printf_string::@1
void main()
main: scope:[main] from __start::@1
screen#23 = phi( __start::@1/screen#24 )
cputs::str#2 = main::str
call cputs
printf_str::putc#1 = (void (*)(char)) 0
printf_str::str#2 = main::str
call printf_str
to:main::@1
main::@1: scope:[main] from main
screen#15 = phi( main/screen#1 )
screen#4 = screen#15
printf_string::putc#0 = (void (*)(char)) 0
printf_string::str#0 = main::name
printf_string::format_min_length#0 = 0
printf_string::format_justify_left#0 = 0
@ -62,8 +66,9 @@ main::@1: scope:[main] from main
main::@2: scope:[main] from main::@1
screen#16 = phi( main::@1/screen#3 )
screen#5 = screen#16
cputs::str#3 = main::str1
call cputs
printf_str::putc#2 = (void (*)(char)) 0
printf_str::str#3 = main::str1
call printf_str
to:main::@3
main::@3: scope:[main] from main::@2
screen#17 = phi( main::@2/screen#1 )
@ -97,26 +102,33 @@ __start::@return: scope:[__start] from __start::@2
SYMBOL TABLE SSA
void __start()
void cputs(char *str)
bool cputs::$0
char *cputs::str
char *cputs::str#0
char *cputs::str#1
char *cputs::str#2
char *cputs::str#3
char *cputs::str#4
char *cputs::str#5
char *cputs::str#6
void main()
__constant char *main::name = "Jesper"
__constant char main::str[$d] = "Hello, I am "
__constant char main::str1[$f] = ". who are you?"
void printf_string(char *str , char format_min_length , char format_justify_left)
void printf_str(void (*putc)(char) , char *str)
bool printf_str::$0
void (*printf_str::putc)(char)
void (*printf_str::putc#0)(char)
void (*printf_str::putc#1)(char)
void (*printf_str::putc#2)(char)
char *printf_str::str
char *printf_str::str#0
char *printf_str::str#1
char *printf_str::str#2
char *printf_str::str#3
char *printf_str::str#4
char *printf_str::str#5
char *printf_str::str#6
void printf_string(void (*putc)(char) , char *str , char format_min_length , char format_justify_left)
struct printf_format_string printf_string::format
char printf_string::format_justify_left
char printf_string::format_justify_left#0
char printf_string::format_min_length
char printf_string::format_min_length#0
void (*printf_string::putc)(char)
void (*printf_string::putc#0)(char)
void (*printf_string::putc#1)(char)
char *printf_string::str
char *printf_string::str#0
char *printf_string::str#1
@ -148,14 +160,14 @@ char *screen#7
char *screen#8
char *screen#9
Adding number conversion cast (unumber) 0 in cputs::$0 = 0 != *cputs::str#4
Adding number conversion cast (unumber) 0 in printf_str::$0 = 0 != *printf_str::str#4
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast 0
Simplifying constant pointer cast (char *) 1024
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias cputs::str#4 = cputs::str#5
Alias printf_str::str#4 = printf_str::str#5
Alias screen#1 = screen#11 screen#21 screen#12
Alias screen#13 = screen#2 screen#14 screen#3
Alias screen#15 = screen#4
@ -164,6 +176,7 @@ Alias screen#17 = screen#6 screen#18 screen#7
Alias screen#24 = screen#8
Alias screen#10 = screen#9 screen#19 screen#20
Successful SSA optimization Pass2AliasElimination
Identical Phi Values printf_string::putc#1 printf_string::putc#0
Identical Phi Values printf_string::str#1 printf_string::str#0
Identical Phi Values screen#22 screen#15
Identical Phi Values screen#13 screen#1
@ -173,20 +186,29 @@ Identical Phi Values screen#16 screen#13
Identical Phi Values screen#17 screen#1
Identical Phi Values screen#10 screen#17
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition cputs::$0 [3] if(0!=*cputs::str#4) goto cputs::@2
Simple Condition printf_str::$0 [3] if(0!=*printf_str::str#4) goto printf_str::@2
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant cputs::str#2 = main::str
Constant printf_str::putc#1 = (void (*)(char)) 0
Constant printf_str::str#2 = main::str
Constant printf_string::putc#0 = (void (*)(char)) 0
Constant printf_string::str#0 = main::name
Constant printf_string::format_min_length#0 = 0
Constant printf_string::format_justify_left#0 = 0
Constant cputs::str#3 = main::str1
Constant printf_str::putc#2 = (void (*)(char)) 0
Constant printf_str::str#3 = main::str1
Constant screen#24 = (char *) 1024
Successful SSA optimization Pass2ConstantIdentification
Constant cputs::str#1 = printf_string::str#0
Constant printf_str::putc#0 = printf_string::putc#0
Constant printf_str::str#1 = printf_string::str#0
Successful SSA optimization Pass2ConstantIdentification
Eliminating unused constant printf_str::putc#1
Eliminating unused constant printf_str::putc#2
Eliminating unused constant printf_str::putc#0
Eliminating unused constant printf_string::format_min_length#0
Eliminating unused constant printf_string::format_justify_left#0
Successful SSA optimization PassNEliminateUnusedVars
Eliminating unused constant printf_string::putc#0
Successful SSA optimization PassNEliminateUnusedVars
Removing unused procedure __start
Removing unused procedure block __start
Removing unused procedure block __start::__init1
@ -194,29 +216,29 @@ Removing unused procedure block __start::@1
Removing unused procedure block __start::@2
Removing unused procedure block __start::@return
Successful SSA optimization PassNEliminateEmptyStart
Inlining constant with var siblings cputs::str#2
Inlining constant with var siblings cputs::str#3
Inlining constant with var siblings cputs::str#1
Inlining constant with var siblings printf_str::str#2
Inlining constant with var siblings printf_str::str#3
Inlining constant with var siblings printf_str::str#1
Inlining constant with var siblings screen#24
Constant inlined cputs::str#1 = main::name
Constant inlined cputs::str#2 = main::str
Constant inlined cputs::str#3 = main::str1
Constant inlined screen#24 = (char *) 1024
Constant inlined printf_string::str#0 = main::name
Constant inlined printf_str::str#2 = main::str
Constant inlined printf_str::str#1 = main::name
Constant inlined printf_str::str#3 = main::str1
Successful SSA optimization Pass2ConstantInlining
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@1
Adding NOP phi() at start of main::@3
Adding NOP phi() at start of printf_string::@1
CALL GRAPH
Calls in [main] to cputs:1 printf_string:3 cputs:5
Calls in [printf_string] to cputs:20
Calls in [main] to printf_str:1 printf_string:3 printf_str:5
Calls in [printf_string] to printf_str:20
Created 4 initial phi equivalence classes
Coalesced [4] screen#26 = screen#1
Coalesced [9] cputs::str#7 = cputs::str#6
Coalesced [9] printf_str::str#7 = printf_str::str#6
Coalesced (already) [10] screen#28 = screen#25
Coalesced [17] cputs::str#8 = cputs::str#0
Coalesced [17] printf_str::str#8 = printf_str::str#0
Coalesced [18] screen#29 = screen#0
Coalesced (already) [19] screen#27 = screen#1
Coalesced down to 2 phi equivalence classes
@ -232,7 +254,7 @@ FINAL CONTROL FLOW GRAPH
void main()
main: scope:[main] from
[0] phi()
[1] call cputs
[1] call printf_str
to:main::@1
main::@1: scope:[main] from main
[2] phi()
@ -240,35 +262,35 @@ main::@1: scope:[main] from main
to:main::@2
main::@2: scope:[main] from main::@1
[4] phi()
[5] call cputs
[5] call printf_str
to:main::@return
main::@return: scope:[main] from main::@2
[6] return
to:@return
void cputs(char *str)
cputs: scope:[cputs] from main main::@2 printf_string
void printf_str(void (*putc)(char) , char *str)
printf_str: scope:[printf_str] from main main::@2 printf_string
[7] screen#25 = phi( main/(char *) 1024, main::@2/screen#1, printf_string/screen#1 )
[7] cputs::str#6 = phi( main/main::str, main::@2/main::str1, printf_string/main::name )
to:cputs::@1
cputs::@1: scope:[cputs] from cputs cputs::@2
[8] screen#1 = phi( cputs/screen#25, cputs::@2/screen#0 )
[8] cputs::str#4 = phi( cputs/cputs::str#6, cputs::@2/cputs::str#0 )
[9] if(0!=*cputs::str#4) goto cputs::@2
to:cputs::@return
cputs::@return: scope:[cputs] from cputs::@1
[7] printf_str::str#6 = phi( main/main::str, main::@2/main::str1, printf_string/main::name )
to:printf_str::@1
printf_str::@1: scope:[printf_str] from printf_str printf_str::@2
[8] screen#1 = phi( printf_str/screen#25, printf_str::@2/screen#0 )
[8] printf_str::str#4 = phi( printf_str/printf_str::str#6, printf_str::@2/printf_str::str#0 )
[9] if(0!=*printf_str::str#4) goto printf_str::@2
to:printf_str::@return
printf_str::@return: scope:[printf_str] from printf_str::@1
[10] return
to:@return
cputs::@2: scope:[cputs] from cputs::@1
[11] *screen#1 = *cputs::str#4
printf_str::@2: scope:[printf_str] from printf_str::@1
[11] *screen#1 = *printf_str::str#4
[12] screen#0 = ++ screen#1
[13] cputs::str#0 = ++ cputs::str#4
to:cputs::@1
[13] printf_str::str#0 = ++ printf_str::str#4
to:printf_str::@1
void printf_string(char *str , char format_min_length , char format_justify_left)
void printf_string(void (*putc)(char) , char *str , char format_min_length , char format_justify_left)
printf_string: scope:[printf_string] from main::@1
[14] phi()
[15] call cputs
[15] call printf_str
to:printf_string::@return
printf_string::@return: scope:[printf_string] from printf_string
[16] return
@ -276,16 +298,18 @@ printf_string::@return: scope:[printf_string] from printf_string
VARIABLE REGISTER WEIGHTS
void cputs(char *str)
char *cputs::str
char *cputs::str#0 // 2002.0
char *cputs::str#4 // 1026.25
char *cputs::str#6 // 101.0
void main()
void printf_string(char *str , char format_min_length , char format_justify_left)
void printf_str(void (*putc)(char) , char *str)
void (*printf_str::putc)(char)
char *printf_str::str
char *printf_str::str#0 // 2002.0
char *printf_str::str#4 // 1026.25
char *printf_str::str#6 // 101.0
void printf_string(void (*putc)(char) , char *str , char format_min_length , char format_justify_left)
struct printf_format_string printf_string::format
char printf_string::format_justify_left
char printf_string::format_min_length
void (*printf_string::putc)(char)
char *printf_string::str
char *screen
char *screen#0 // 1001.0
@ -294,26 +318,26 @@ char *screen#25 // 114.0
Initial phi equivalence classes
[ screen#25 screen#1 screen#0 ]
[ cputs::str#4 cputs::str#6 cputs::str#0 ]
[ printf_str::str#4 printf_str::str#6 printf_str::str#0 ]
Complete equivalence classes
[ screen#25 screen#1 screen#0 ]
[ cputs::str#4 cputs::str#6 cputs::str#0 ]
[ printf_str::str#4 printf_str::str#6 printf_str::str#0 ]
Allocated zp[2]:2 [ screen#25 screen#1 screen#0 ]
Allocated zp[2]:4 [ cputs::str#4 cputs::str#6 cputs::str#0 ]
Allocated zp[2]:4 [ printf_str::str#4 printf_str::str#6 printf_str::str#0 ]
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [9] if(0!=*cputs::str#4) goto cputs::@2 [ screen#1 cputs::str#4 ] ( cputs:1 [ screen#1 cputs::str#4 ] { } cputs:5 [ screen#1 cputs::str#4 ] { { screen#1 = screen#25 } } printf_string:3::cputs:15 [ screen#1 cputs::str#4 ] { { screen#1 = screen#25 } } ) always clobbers reg byte a reg byte y
Statement [11] *screen#1 = *cputs::str#4 [ screen#1 cputs::str#4 ] ( cputs:1 [ screen#1 cputs::str#4 ] { } cputs:5 [ screen#1 cputs::str#4 ] { { screen#1 = screen#25 } } printf_string:3::cputs:15 [ screen#1 cputs::str#4 ] { { screen#1 = screen#25 } } ) always clobbers reg byte a reg byte y
Statement [9] if(0!=*printf_str::str#4) goto printf_str::@2 [ screen#1 printf_str::str#4 ] ( printf_str:1 [ screen#1 printf_str::str#4 ] { } printf_str:5 [ screen#1 printf_str::str#4 ] { { screen#1 = screen#25 } } printf_string:3::printf_str:15 [ screen#1 printf_str::str#4 ] { { screen#1 = screen#25 } } ) always clobbers reg byte a reg byte y
Statement [11] *screen#1 = *printf_str::str#4 [ screen#1 printf_str::str#4 ] ( printf_str:1 [ screen#1 printf_str::str#4 ] { } printf_str:5 [ screen#1 printf_str::str#4 ] { { screen#1 = screen#25 } } printf_string:3::printf_str:15 [ screen#1 printf_str::str#4 ] { { screen#1 = screen#25 } } ) always clobbers reg byte a reg byte y
Potential registers zp[2]:2 [ screen#25 screen#1 screen#0 ] : zp[2]:2 ,
Potential registers zp[2]:4 [ cputs::str#4 cputs::str#6 cputs::str#0 ] : zp[2]:4 ,
Potential registers zp[2]:4 [ printf_str::str#4 printf_str::str#6 printf_str::str#0 ] : zp[2]:4 ,
REGISTER UPLIFT SCOPES
Uplift Scope [cputs] 3,129.25: zp[2]:4 [ cputs::str#4 cputs::str#6 cputs::str#0 ]
Uplift Scope [printf_str] 3,129.25: zp[2]:4 [ printf_str::str#4 printf_str::str#6 printf_str::str#0 ]
Uplift Scope [] 1,398.36: zp[2]:2 [ screen#25 screen#1 screen#0 ]
Uplift Scope [printf_format_string]
Uplift Scope [printf_string]
Uplift Scope [main]
Uplifting [cputs] best 709 combination zp[2]:4 [ cputs::str#4 cputs::str#6 cputs::str#0 ]
Uplifting [printf_str] best 709 combination zp[2]:4 [ printf_str::str#4 printf_str::str#6 printf_str::str#0 ]
Uplifting [] best 709 combination zp[2]:2 [ screen#25 screen#1 screen#0 ]
Uplifting [printf_format_string] best 709 combination
Uplifting [printf_string] best 709 combination
@ -322,7 +346,7 @@ Uplifting [main] best 709 combination
ASSEMBLER BEFORE OPTIMIZATION
// File Comments
// Tests printf function call rewriting
// A simple string - with the printf-sub cuntions in the same file.
// A simple string - with the printf-sub funtions in the same file.
// Upstart
// Commodore 64 PRG executable file
.file [name="printf-10.prg", type="prg", segments="Program"]
@ -337,20 +361,20 @@ ASSEMBLER BEFORE OPTIMIZATION
.segment Code
// main
main: {
// [1] call cputs
// [7] phi from main to cputs [phi:main->cputs]
cputs_from_main:
// [7] phi screen#25 = (char *) 1024 [phi:main->cputs#0] -- pbuz1=pbuc1
// [1] call printf_str
// [7] phi from main to printf_str [phi:main->printf_str]
printf_str_from_main:
// [7] phi screen#25 = (char *) 1024 [phi:main->printf_str#0] -- pbuz1=pbuc1
lda #<$400
sta.z screen
lda #>$400
sta.z screen+1
// [7] phi cputs::str#6 = main::str [phi:main->cputs#1] -- pbuz1=pbuc1
// [7] phi printf_str::str#6 = main::str [phi:main->printf_str#1] -- pbuz1=pbuc1
lda #<str
sta.z cputs.str
sta.z printf_str.str
lda #>str
sta.z cputs.str+1
jsr cputs
sta.z printf_str.str+1
jsr printf_str
// [2] phi from main to main::@1 [phi:main->main::@1]
__b1_from_main:
jmp __b1
@ -365,16 +389,16 @@ main: {
jmp __b2
// main::@2
__b2:
// [5] call cputs
// [7] phi from main::@2 to cputs [phi:main::@2->cputs]
cputs_from___b2:
// [7] phi screen#25 = screen#1 [phi:main::@2->cputs#0] -- register_copy
// [7] phi cputs::str#6 = main::str1 [phi:main::@2->cputs#1] -- pbuz1=pbuc1
// [5] call printf_str
// [7] phi from main::@2 to printf_str [phi:main::@2->printf_str]
printf_str_from___b2:
// [7] phi screen#25 = screen#1 [phi:main::@2->printf_str#0] -- register_copy
// [7] phi printf_str::str#6 = main::str1 [phi:main::@2->printf_str#1] -- pbuz1=pbuc1
lda #<str1
sta.z cputs.str
sta.z printf_str.str
lda #>str1
sta.z cputs.str+1
jsr cputs
sta.z printf_str.str+1
jsr printf_str
jmp __breturn
// main::@return
__breturn:
@ -389,31 +413,31 @@ main: {
.byte 0
}
.segment Code
// cputs
// void cputs(__zp(4) char *str)
cputs: {
// printf_str
// void printf_str(void (*putc)(char), __zp(4) char *str)
printf_str: {
.label str = 4
// [8] phi from cputs cputs::@2 to cputs::@1 [phi:cputs/cputs::@2->cputs::@1]
__b1_from_cputs:
// [8] phi from printf_str printf_str::@2 to printf_str::@1 [phi:printf_str/printf_str::@2->printf_str::@1]
__b1_from_printf_str:
__b1_from___b2:
// [8] phi screen#1 = screen#25 [phi:cputs/cputs::@2->cputs::@1#0] -- register_copy
// [8] phi cputs::str#4 = cputs::str#6 [phi:cputs/cputs::@2->cputs::@1#1] -- register_copy
// [8] phi screen#1 = screen#25 [phi:printf_str/printf_str::@2->printf_str::@1#0] -- register_copy
// [8] phi printf_str::str#4 = printf_str::str#6 [phi:printf_str/printf_str::@2->printf_str::@1#1] -- register_copy
jmp __b1
// cputs::@1
// printf_str::@1
__b1:
// [9] if(0!=*cputs::str#4) goto cputs::@2 -- 0_neq__deref_pbuz1_then_la1
// [9] if(0!=*printf_str::str#4) goto printf_str::@2 -- 0_neq__deref_pbuz1_then_la1
ldy #0
lda (str),y
cmp #0
bne __b2
jmp __breturn
// cputs::@return
// printf_str::@return
__breturn:
// [10] return
rts
// cputs::@2
// printf_str::@2
__b2:
// [11] *screen#1 = *cputs::str#4 -- _deref_pbuz1=_deref_pbuz2
// [11] *screen#1 = *printf_str::str#4 -- _deref_pbuz1=_deref_pbuz2
ldy #0
lda (str),y
ldy #0
@ -423,7 +447,7 @@ cputs: {
bne !+
inc.z screen+1
!:
// [13] cputs::str#0 = ++ cputs::str#4 -- pbuz1=_inc_pbuz1
// [13] printf_str::str#0 = ++ printf_str::str#4 -- pbuz1=_inc_pbuz1
inc.z str
bne !+
inc.z str+1
@ -433,18 +457,18 @@ cputs: {
// printf_string
// Print a string value using a specific format
// Handles justification and min length
// void printf_string(char *str, char format_min_length, char format_justify_left)
// void printf_string(void (*putc)(char), char *str, char format_min_length, char format_justify_left)
printf_string: {
// [15] call cputs
// [7] phi from printf_string to cputs [phi:printf_string->cputs]
cputs_from_printf_string:
// [7] phi screen#25 = screen#1 [phi:printf_string->cputs#0] -- register_copy
// [7] phi cputs::str#6 = main::name [phi:printf_string->cputs#1] -- pbuz1=pbuc1
// [15] call printf_str
// [7] phi from printf_string to printf_str [phi:printf_string->printf_str]
printf_str_from_printf_string:
// [7] phi screen#25 = screen#1 [phi:printf_string->printf_str#0] -- register_copy
// [7] phi printf_str::str#6 = main::name [phi:printf_string->printf_str#1] -- pbuz1=pbuc1
lda #<main.name
sta.z cputs.str
sta.z printf_str.str
lda #>main.name
sta.z cputs.str+1
jsr cputs
sta.z printf_str.str+1
jsr printf_str
jmp __breturn
// printf_string::@return
__breturn:
@ -467,33 +491,35 @@ Replacing label __b1_from___b2 with __b1
Removing instruction __b1_from_main:
Removing instruction printf_string_from___b1:
Removing instruction __b2_from___b1:
Removing instruction cputs_from___b2:
Removing instruction __b1_from_cputs:
Removing instruction printf_str_from___b2:
Removing instruction __b1_from_printf_str:
Removing instruction __b1_from___b2:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction cputs_from_main:
Removing instruction printf_str_from_main:
Removing instruction __b1:
Removing instruction __b2:
Removing instruction __breturn:
Removing instruction __breturn:
Removing instruction cputs_from_printf_string:
Removing instruction printf_str_from_printf_string:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
FINAL SYMBOL TABLE
void cputs(char *str)
char *cputs::str
char *cputs::str#0 // str zp[2]:4 2002.0
char *cputs::str#4 // str zp[2]:4 1026.25
char *cputs::str#6 // str zp[2]:4 101.0
void main()
__constant char *main::name = "Jesper"
__constant char main::str[$d] = "Hello, I am "
__constant char main::str1[$f] = ". who are you?"
void printf_string(char *str , char format_min_length , char format_justify_left)
void printf_str(void (*putc)(char) , char *str)
void (*printf_str::putc)(char)
char *printf_str::str
char *printf_str::str#0 // str zp[2]:4 2002.0
char *printf_str::str#4 // str zp[2]:4 1026.25
char *printf_str::str#6 // str zp[2]:4 101.0
void printf_string(void (*putc)(char) , char *str , char format_min_length , char format_justify_left)
struct printf_format_string printf_string::format
char printf_string::format_justify_left
char printf_string::format_min_length
void (*printf_string::putc)(char)
char *printf_string::str
char *screen
char *screen#0 // screen zp[2]:2 1001.0
@ -501,7 +527,7 @@ char *screen#1 // screen zp[2]:2 283.3636363636364
char *screen#25 // screen zp[2]:2 114.0
zp[2]:2 [ screen#25 screen#1 screen#0 ]
zp[2]:4 [ cputs::str#4 cputs::str#6 cputs::str#0 ]
zp[2]:4 [ printf_str::str#4 printf_str::str#6 printf_str::str#0 ]
FINAL ASSEMBLER
@ -509,7 +535,7 @@ Score: 617
// File Comments
// Tests printf function call rewriting
// A simple string - with the printf-sub cuntions in the same file.
// A simple string - with the printf-sub funtions in the same file.
// Upstart
// Commodore 64 PRG executable file
.file [name="printf-10.prg", type="prg", segments="Program"]
@ -525,19 +551,19 @@ Score: 617
// main
main: {
// printf("Hello, I am %s. who are you?", name)
// [1] call cputs
// [7] phi from main to cputs [phi:main->cputs]
// [7] phi screen#25 = (char *) 1024 [phi:main->cputs#0] -- pbuz1=pbuc1
// [1] call printf_str
// [7] phi from main to printf_str [phi:main->printf_str]
// [7] phi screen#25 = (char *) 1024 [phi:main->printf_str#0] -- pbuz1=pbuc1
lda #<$400
sta.z screen
lda #>$400
sta.z screen+1
// [7] phi cputs::str#6 = main::str [phi:main->cputs#1] -- pbuz1=pbuc1
// [7] phi printf_str::str#6 = main::str [phi:main->printf_str#1] -- pbuz1=pbuc1
lda #<str
sta.z cputs.str
sta.z printf_str.str
lda #>str
sta.z cputs.str+1
jsr cputs
sta.z printf_str.str+1
jsr printf_str
// [2] phi from main to main::@1 [phi:main->main::@1]
// main::@1
// printf("Hello, I am %s. who are you?", name)
@ -547,15 +573,15 @@ main: {
// [4] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
// main::@2
// printf("Hello, I am %s. who are you?", name)
// [5] call cputs
// [7] phi from main::@2 to cputs [phi:main::@2->cputs]
// [7] phi screen#25 = screen#1 [phi:main::@2->cputs#0] -- register_copy
// [7] phi cputs::str#6 = main::str1 [phi:main::@2->cputs#1] -- pbuz1=pbuc1
// [5] call printf_str
// [7] phi from main::@2 to printf_str [phi:main::@2->printf_str]
// [7] phi screen#25 = screen#1 [phi:main::@2->printf_str#0] -- register_copy
// [7] phi printf_str::str#6 = main::str1 [phi:main::@2->printf_str#1] -- pbuz1=pbuc1
lda #<str1
sta.z cputs.str
sta.z printf_str.str
lda #>str1
sta.z cputs.str+1
jsr cputs
sta.z printf_str.str+1
jsr printf_str
// main::@return
// }
// [6] return
@ -569,29 +595,29 @@ main: {
.byte 0
}
.segment Code
// cputs
// void cputs(__zp(4) char *str)
cputs: {
// printf_str
// void printf_str(void (*putc)(char), __zp(4) char *str)
printf_str: {
.label str = 4
// [8] phi from cputs cputs::@2 to cputs::@1 [phi:cputs/cputs::@2->cputs::@1]
// [8] phi screen#1 = screen#25 [phi:cputs/cputs::@2->cputs::@1#0] -- register_copy
// [8] phi cputs::str#4 = cputs::str#6 [phi:cputs/cputs::@2->cputs::@1#1] -- register_copy
// cputs::@1
// [8] phi from printf_str printf_str::@2 to printf_str::@1 [phi:printf_str/printf_str::@2->printf_str::@1]
// [8] phi screen#1 = screen#25 [phi:printf_str/printf_str::@2->printf_str::@1#0] -- register_copy
// [8] phi printf_str::str#4 = printf_str::str#6 [phi:printf_str/printf_str::@2->printf_str::@1#1] -- register_copy
// printf_str::@1
__b1:
// while(*str)
// [9] if(0!=*cputs::str#4) goto cputs::@2 -- 0_neq__deref_pbuz1_then_la1
// [9] if(0!=*printf_str::str#4) goto printf_str::@2 -- 0_neq__deref_pbuz1_then_la1
ldy #0
lda (str),y
cmp #0
bne __b2
// cputs::@return
// printf_str::@return
// }
// [10] return
rts
// cputs::@2
// printf_str::@2
__b2:
// *screen++ = *str++
// [11] *screen#1 = *cputs::str#4 -- _deref_pbuz1=_deref_pbuz2
// [11] *screen#1 = *printf_str::str#4 -- _deref_pbuz1=_deref_pbuz2
ldy #0
lda (str),y
sta (screen),y
@ -601,7 +627,7 @@ cputs: {
bne !+
inc.z screen+1
!:
// [13] cputs::str#0 = ++ cputs::str#4 -- pbuz1=_inc_pbuz1
// [13] printf_str::str#0 = ++ printf_str::str#4 -- pbuz1=_inc_pbuz1
inc.z str
bne !+
inc.z str+1
@ -611,18 +637,18 @@ cputs: {
// printf_string
// Print a string value using a specific format
// Handles justification and min length
// void printf_string(char *str, char format_min_length, char format_justify_left)
// void printf_string(void (*putc)(char), char *str, char format_min_length, char format_justify_left)
printf_string: {
// cputs(str)
// [15] call cputs
// [7] phi from printf_string to cputs [phi:printf_string->cputs]
// [7] phi screen#25 = screen#1 [phi:printf_string->cputs#0] -- register_copy
// [7] phi cputs::str#6 = main::name [phi:printf_string->cputs#1] -- pbuz1=pbuc1
// printf_str(putc, str)
// [15] call printf_str
// [7] phi from printf_string to printf_str [phi:printf_string->printf_str]
// [7] phi screen#25 = screen#1 [phi:printf_string->printf_str#0] -- register_copy
// [7] phi printf_str::str#6 = main::name [phi:printf_string->printf_str#1] -- pbuz1=pbuc1
lda #<main.name
sta.z cputs.str
sta.z printf_str.str
lda #>main.name
sta.z cputs.str+1
jsr cputs
sta.z printf_str.str+1
jsr printf_str
// printf_string::@return
// }
// [16] return

View File

@ -1,16 +1,18 @@
void cputs(char *str)
char *cputs::str
char *cputs::str#0 // str zp[2]:4 2002.0
char *cputs::str#4 // str zp[2]:4 1026.25
char *cputs::str#6 // str zp[2]:4 101.0
void main()
__constant char *main::name = "Jesper"
__constant char main::str[$d] = "Hello, I am "
__constant char main::str1[$f] = ". who are you?"
void printf_string(char *str , char format_min_length , char format_justify_left)
void printf_str(void (*putc)(char) , char *str)
void (*printf_str::putc)(char)
char *printf_str::str
char *printf_str::str#0 // str zp[2]:4 2002.0
char *printf_str::str#4 // str zp[2]:4 1026.25
char *printf_str::str#6 // str zp[2]:4 101.0
void printf_string(void (*putc)(char) , char *str , char format_min_length , char format_justify_left)
struct printf_format_string printf_string::format
char printf_string::format_justify_left
char printf_string::format_min_length
void (*printf_string::putc)(char)
char *printf_string::str
char *screen
char *screen#0 // screen zp[2]:2 1001.0
@ -18,4 +20,4 @@ char *screen#1 // screen zp[2]:2 283.3636363636364
char *screen#25 // screen zp[2]:2 114.0
zp[2]:2 [ screen#25 screen#1 screen#0 ]
zp[2]:4 [ cputs::str#4 cputs::str#6 cputs::str#0 ]
zp[2]:4 [ printf_str::str#4 printf_str::str#6 printf_str::str#0 ]

View File

@ -18,18 +18,18 @@ main: {
lda #>$400
sta.z screen+1
lda #<str
sta.z cputs.str
sta.z printf_str.str
lda #>str
sta.z cputs.str+1
jsr cputs
sta.z printf_str.str+1
jsr printf_str
// printf("Commodore is %x cool", pct)
jsr printf_uint
// printf("Commodore is %x cool", pct)
lda #<str1
sta.z cputs.str
sta.z printf_str.str
lda #>str1
sta.z cputs.str+1
jsr cputs
sta.z printf_str.str+1
jsr printf_str
// }
rts
.segment Data
@ -39,8 +39,8 @@ main: {
.byte 0
}
.segment Code
// void cputs(__zp(2) char *str)
cputs: {
// void printf_str(void (*putc)(char), __zp(2) char *str)
printf_str: {
.label str = 2
__b1:
// while(*str)
@ -68,7 +68,7 @@ cputs: {
}
// Print an unsigned int using a specific format
// Always prints hexadecimals - ignores min_length and flags
// void printf_uint(unsigned int uvalue, char format_min_length, char format_justify_left, char format_sign_always, char format_zero_padding, char format_upper_case, char format_radix)
// void printf_uint(void (*putc)(char), unsigned int uvalue, char format_min_length, char format_justify_left, char format_sign_always, char format_zero_padding, char format_upper_case, char format_radix)
printf_uint: {
// *screen++ = printf_hextab[BYTE1(uvalue)>>4]
lda printf_hextab

View File

@ -2,7 +2,7 @@
void main()
main: scope:[main] from
[0] phi()
[1] call cputs
[1] call printf_str
to:main::@1
main::@1: scope:[main] from main
[2] phi()
@ -10,32 +10,32 @@ main::@1: scope:[main] from main
to:main::@2
main::@2: scope:[main] from main::@1
[4] phi()
[5] call cputs
[5] call printf_str
to:main::@return
main::@return: scope:[main] from main::@2
[6] return
to:@return
void cputs(char *str)
cputs: scope:[cputs] from main main::@2
void printf_str(void (*putc)(char) , char *str)
printf_str: scope:[printf_str] from main main::@2
[7] screen#27 = phi( main/(char *) 1024, main::@2/screen#17 )
[7] cputs::str#5 = phi( main/main::str, main::@2/main::str1 )
to:cputs::@1
cputs::@1: scope:[cputs] from cputs cputs::@2
[8] screen#1 = phi( cputs/screen#27, cputs::@2/screen#0 )
[8] cputs::str#3 = phi( cputs/cputs::str#5, cputs::@2/cputs::str#0 )
[9] if(0!=*cputs::str#3) goto cputs::@2
to:cputs::@return
cputs::@return: scope:[cputs] from cputs::@1
[7] printf_str::str#5 = phi( main/main::str, main::@2/main::str1 )
to:printf_str::@1
printf_str::@1: scope:[printf_str] from printf_str printf_str::@2
[8] screen#1 = phi( printf_str/screen#27, printf_str::@2/screen#0 )
[8] printf_str::str#3 = phi( printf_str/printf_str::str#5, printf_str::@2/printf_str::str#0 )
[9] if(0!=*printf_str::str#3) goto printf_str::@2
to:printf_str::@return
printf_str::@return: scope:[printf_str] from printf_str::@1
[10] return
to:@return
cputs::@2: scope:[cputs] from cputs::@1
[11] *screen#1 = *cputs::str#3
printf_str::@2: scope:[printf_str] from printf_str::@1
[11] *screen#1 = *printf_str::str#3
[12] screen#0 = ++ screen#1
[13] cputs::str#0 = ++ cputs::str#3
to:cputs::@1
[13] printf_str::str#0 = ++ printf_str::str#3
to:printf_str::@1
void printf_uint(unsigned int uvalue , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
void printf_uint(void (*putc)(char) , unsigned int uvalue , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
printf_uint: scope:[printf_uint] from main::@1
[14] *screen#1 = *printf_hextab
[15] screen#2 = ++ screen#1

View File

@ -1,34 +1,34 @@
Added struct type cast to parameter value list call printf_uint(main::pct, (struct printf_format_number){ 0, 0, 0, 0, 0, HEXADECIMAL })
Added struct type cast to parameter value list call printf_uint((void (*)(char)) 0, main::pct, (struct printf_format_number){ 0, 0, 0, 0, 0, HEXADECIMAL })
Inlined call call __init
Eliminating unused variable with no statement main::$0
CONTROL FLOW GRAPH SSA
void cputs(char *str)
cputs: scope:[cputs] from main main::@2
void printf_str(void (*putc)(char) , char *str)
printf_str: scope:[printf_str] from main main::@2
screen#27 = phi( main/screen#25, main::@2/screen#8 )
cputs::str#5 = phi( main/cputs::str#1, main::@2/cputs::str#2 )
to:cputs::@1
cputs::@1: scope:[cputs] from cputs cputs::@2
screen#24 = phi( cputs/screen#27, cputs::@2/screen#0 )
cputs::str#3 = phi( cputs/cputs::str#5, cputs::@2/cputs::str#0 )
cputs::$0 = 0 != *cputs::str#3
if(cputs::$0) goto cputs::@2
to:cputs::@return
cputs::@2: scope:[cputs] from cputs::@1
screen#14 = phi( cputs::@1/screen#24 )
cputs::str#4 = phi( cputs::@1/cputs::str#3 )
*screen#14 = *cputs::str#4
printf_str::str#5 = phi( main/printf_str::str#1, main::@2/printf_str::str#2 )
to:printf_str::@1
printf_str::@1: scope:[printf_str] from printf_str printf_str::@2
screen#24 = phi( printf_str/screen#27, printf_str::@2/screen#0 )
printf_str::str#3 = phi( printf_str/printf_str::str#5, printf_str::@2/printf_str::str#0 )
printf_str::$0 = 0 != *printf_str::str#3
if(printf_str::$0) goto printf_str::@2
to:printf_str::@return
printf_str::@2: scope:[printf_str] from printf_str::@1
screen#14 = phi( printf_str::@1/screen#24 )
printf_str::str#4 = phi( printf_str::@1/printf_str::str#3 )
*screen#14 = *printf_str::str#4
screen#0 = ++ screen#14
cputs::str#0 = ++ cputs::str#4
to:cputs::@1
cputs::@return: scope:[cputs] from cputs::@1
screen#15 = phi( cputs::@1/screen#24 )
printf_str::str#0 = ++ printf_str::str#4
to:printf_str::@1
printf_str::@return: scope:[printf_str] from printf_str::@1
screen#15 = phi( printf_str::@1/screen#24 )
screen#1 = screen#15
return
to:@return
void printf_uint(unsigned int uvalue , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
void printf_uint(void (*putc)(char) , unsigned int uvalue , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
printf_uint: scope:[printf_uint] from main::@1
screen#16 = phi( main::@1/screen#7 )
printf_uint::uvalue#1 = phi( main::@1/printf_uint::uvalue#0 )
@ -58,12 +58,14 @@ printf_uint::@return: scope:[printf_uint] from printf_uint
void main()
main: scope:[main] from __start::@1
screen#25 = phi( __start::@1/screen#26 )
cputs::str#1 = main::str
call cputs
printf_str::putc#0 = (void (*)(char)) 0
printf_str::str#1 = main::str
call printf_str
to:main::@1
main::@1: scope:[main] from main
screen#18 = phi( main/screen#1 )
screen#7 = screen#18
printf_uint::putc#0 = (void (*)(char)) 0
printf_uint::uvalue#0 = main::pct
printf_uint::format_min_length#0 = 0
printf_uint::format_justify_left#0 = 0
@ -76,8 +78,9 @@ main::@1: scope:[main] from main
main::@2: scope:[main] from main::@1
screen#19 = phi( main::@1/screen#6 )
screen#8 = screen#19
cputs::str#2 = main::str1
call cputs
printf_str::putc#1 = (void (*)(char)) 0
printf_str::str#2 = main::str1
call printf_str
to:main::@3
main::@3: scope:[main] from main::@2
screen#20 = phi( main::@2/screen#1 )
@ -116,21 +119,24 @@ __constant char RADIX::DECIMAL = $a
__constant char RADIX::HEXADECIMAL = $10
__constant char RADIX::OCTAL = 8
void __start()
void cputs(char *str)
bool cputs::$0
char *cputs::str
char *cputs::str#0
char *cputs::str#1
char *cputs::str#2
char *cputs::str#3
char *cputs::str#4
char *cputs::str#5
void main()
__constant unsigned int main::pct = $156
__constant char main::str[$e] = "Commodore is "
__constant char main::str1[6] = " cool"
__constant const char printf_hextab[] = "0123456789abcdef"z
void printf_uint(unsigned int uvalue , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
void printf_str(void (*putc)(char) , char *str)
bool printf_str::$0
void (*printf_str::putc)(char)
void (*printf_str::putc#0)(char)
void (*printf_str::putc#1)(char)
char *printf_str::str
char *printf_str::str#0
char *printf_str::str#1
char *printf_str::str#2
char *printf_str::str#3
char *printf_str::str#4
char *printf_str::str#5
void printf_uint(void (*putc)(char) , unsigned int uvalue , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
char printf_uint::$0
char printf_uint::$1
char printf_uint::$2
@ -152,6 +158,8 @@ char printf_uint::format_upper_case
char printf_uint::format_upper_case#0
char printf_uint::format_zero_padding
char printf_uint::format_zero_padding#0
void (*printf_uint::putc)(char)
void (*printf_uint::putc#0)(char)
unsigned int printf_uint::uvalue
unsigned int printf_uint::uvalue#0
unsigned int printf_uint::uvalue#1
@ -185,7 +193,7 @@ char *screen#7
char *screen#8
char *screen#9
Adding number conversion cast (unumber) 0 in cputs::$0 = 0 != *cputs::str#3
Adding number conversion cast (unumber) 0 in printf_str::$0 = 0 != *printf_str::str#3
Adding number conversion cast (unumber) 4 in printf_uint::$1 = printf_uint::$0 >> 4
Adding number conversion cast (unumber) $f in printf_uint::$3 = printf_uint::$2 & $f
Adding number conversion cast (unumber) printf_uint::$3 in printf_uint::$3 = printf_uint::$2 & (unumber)$f
@ -208,7 +216,7 @@ Finalized unsigned number type (char) $f
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to char in printf_uint::$3 = printf_uint::$2 & $f
Inferred type updated to char in printf_uint::$7 = printf_uint::$6 & $f
Alias cputs::str#3 = cputs::str#4
Alias printf_str::str#3 = printf_str::str#4
Alias screen#1 = screen#14 screen#24 screen#15
Alias screen#17 = screen#5 screen#6
Alias screen#18 = screen#7
@ -225,9 +233,11 @@ Identical Phi Values screen#19 screen#17
Identical Phi Values screen#10 screen#1
Identical Phi Values screen#12 screen#10
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition cputs::$0 [3] if(0!=*cputs::str#3) goto cputs::@2
Simple Condition printf_str::$0 [3] if(0!=*printf_str::str#3) goto printf_str::@2
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant cputs::str#1 = main::str
Constant printf_str::putc#0 = (void (*)(char)) 0
Constant printf_str::str#1 = main::str
Constant printf_uint::putc#0 = (void (*)(char)) 0
Constant printf_uint::uvalue#0 = main::pct
Constant printf_uint::format_min_length#0 = 0
Constant printf_uint::format_justify_left#0 = 0
@ -235,9 +245,13 @@ Constant printf_uint::format_sign_always#0 = 0
Constant printf_uint::format_zero_padding#0 = 0
Constant printf_uint::format_upper_case#0 = 0
Constant printf_uint::format_radix#0 = HEXADECIMAL
Constant cputs::str#2 = main::str1
Constant printf_str::putc#1 = (void (*)(char)) 0
Constant printf_str::str#2 = main::str1
Constant screen#11 = (char *) 1024
Successful SSA optimization Pass2ConstantIdentification
Eliminating unused constant printf_str::putc#0
Eliminating unused constant printf_str::putc#1
Eliminating unused constant printf_uint::putc#0
Eliminating unused constant printf_uint::format_min_length#0
Eliminating unused constant printf_uint::format_justify_left#0
Eliminating unused constant printf_uint::format_sign_always#0
@ -281,11 +295,9 @@ Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused constant printf_uint::$0
Eliminating unused constant printf_uint::$1
Successful SSA optimization PassNEliminateUnusedVars
Inlining constant with var siblings cputs::str#1
Inlining constant with var siblings cputs::str#2
Inlining constant with var siblings printf_str::str#1
Inlining constant with var siblings printf_str::str#2
Inlining constant with var siblings screen#11
Constant inlined cputs::str#1 = main::str
Constant inlined cputs::str#2 = main::str1
Constant inlined screen#11 = (char *) 1024
Constant inlined printf_uint::$3 = byte1 main::pct&$f
Constant inlined printf_uint::uvalue#0 = main::pct
@ -294,6 +306,8 @@ Constant inlined printf_uint::$5 = byte0 main::pct>>4
Constant inlined printf_uint::$4 = byte0 main::pct
Constant inlined printf_uint::$7 = byte0 main::pct&$f
Constant inlined printf_uint::$6 = byte0 main::pct
Constant inlined printf_str::str#2 = main::str1
Constant inlined printf_str::str#1 = main::str
Successful SSA optimization Pass2ConstantInlining
Consolidated array index constant in *(printf_hextab+byte1 main::pct&$f)
Consolidated array index constant in *(printf_hextab+byte0 main::pct>>4)
@ -308,13 +322,13 @@ Adding NOP phi() at start of main
Adding NOP phi() at start of main::@1
Adding NOP phi() at start of main::@3
CALL GRAPH
Calls in [main] to cputs:1 printf_uint:3 cputs:5
Calls in [main] to printf_str:1 printf_uint:3 printf_str:5
Created 4 initial phi equivalence classes
Coalesced [4] screen#28 = screen#17
Coalesced [9] cputs::str#6 = cputs::str#5
Coalesced [9] printf_str::str#6 = printf_str::str#5
Coalesced [10] screen#29 = screen#27
Coalesced [17] cputs::str#7 = cputs::str#0
Coalesced [17] printf_str::str#7 = printf_str::str#0
Coalesced [18] screen#30 = screen#0
Coalesced down to 2 phi equivalence classes
Culled Empty Block label main::@3
@ -327,7 +341,7 @@ FINAL CONTROL FLOW GRAPH
void main()
main: scope:[main] from
[0] phi()
[1] call cputs
[1] call printf_str
to:main::@1
main::@1: scope:[main] from main
[2] phi()
@ -335,32 +349,32 @@ main::@1: scope:[main] from main
to:main::@2
main::@2: scope:[main] from main::@1
[4] phi()
[5] call cputs
[5] call printf_str
to:main::@return
main::@return: scope:[main] from main::@2
[6] return
to:@return
void cputs(char *str)
cputs: scope:[cputs] from main main::@2
void printf_str(void (*putc)(char) , char *str)
printf_str: scope:[printf_str] from main main::@2
[7] screen#27 = phi( main/(char *) 1024, main::@2/screen#17 )
[7] cputs::str#5 = phi( main/main::str, main::@2/main::str1 )
to:cputs::@1
cputs::@1: scope:[cputs] from cputs cputs::@2
[8] screen#1 = phi( cputs/screen#27, cputs::@2/screen#0 )
[8] cputs::str#3 = phi( cputs/cputs::str#5, cputs::@2/cputs::str#0 )
[9] if(0!=*cputs::str#3) goto cputs::@2
to:cputs::@return
cputs::@return: scope:[cputs] from cputs::@1
[7] printf_str::str#5 = phi( main/main::str, main::@2/main::str1 )
to:printf_str::@1
printf_str::@1: scope:[printf_str] from printf_str printf_str::@2
[8] screen#1 = phi( printf_str/screen#27, printf_str::@2/screen#0 )
[8] printf_str::str#3 = phi( printf_str/printf_str::str#5, printf_str::@2/printf_str::str#0 )
[9] if(0!=*printf_str::str#3) goto printf_str::@2
to:printf_str::@return
printf_str::@return: scope:[printf_str] from printf_str::@1
[10] return
to:@return
cputs::@2: scope:[cputs] from cputs::@1
[11] *screen#1 = *cputs::str#3
printf_str::@2: scope:[printf_str] from printf_str::@1
[11] *screen#1 = *printf_str::str#3
[12] screen#0 = ++ screen#1
[13] cputs::str#0 = ++ cputs::str#3
to:cputs::@1
[13] printf_str::str#0 = ++ printf_str::str#3
to:printf_str::@1
void printf_uint(unsigned int uvalue , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
void printf_uint(void (*putc)(char) , unsigned int uvalue , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
printf_uint: scope:[printf_uint] from main::@1
[14] *screen#1 = *printf_hextab
[15] screen#2 = ++ screen#1
@ -377,13 +391,14 @@ printf_uint::@return: scope:[printf_uint] from printf_uint
VARIABLE REGISTER WEIGHTS
void cputs(char *str)
char *cputs::str
char *cputs::str#0 // 202.0
char *cputs::str#3 // 103.75
char *cputs::str#5 // 11.0
void main()
void printf_uint(unsigned int uvalue , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
void printf_str(void (*putc)(char) , char *str)
void (*printf_str::putc)(char)
char *printf_str::str
char *printf_str::str#0 // 202.0
char *printf_str::str#3 // 103.75
char *printf_str::str#5 // 11.0
void printf_uint(void (*putc)(char) , unsigned int uvalue , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
struct printf_format_number printf_uint::format
char printf_uint::format_justify_left
char printf_uint::format_min_length
@ -391,6 +406,7 @@ char printf_uint::format_radix
char printf_uint::format_sign_always
char printf_uint::format_upper_case
char printf_uint::format_zero_padding
void (*printf_uint::putc)(char)
unsigned int printf_uint::uvalue
char *screen
char *screen#0 // 101.0
@ -402,25 +418,25 @@ char *screen#3 // 16.5
char *screen#4 // 16.5
Initial phi equivalence classes
[ cputs::str#3 cputs::str#5 cputs::str#0 ]
[ printf_str::str#3 printf_str::str#5 printf_str::str#0 ]
[ screen#1 screen#27 screen#17 screen#0 ]
Added variable screen#2 to live range equivalence class [ screen#2 ]
Added variable screen#3 to live range equivalence class [ screen#3 ]
Added variable screen#4 to live range equivalence class [ screen#4 ]
Complete equivalence classes
[ cputs::str#3 cputs::str#5 cputs::str#0 ]
[ printf_str::str#3 printf_str::str#5 printf_str::str#0 ]
[ screen#1 screen#27 screen#17 screen#0 ]
[ screen#2 ]
[ screen#3 ]
[ screen#4 ]
Allocated zp[2]:2 [ cputs::str#3 cputs::str#5 cputs::str#0 ]
Allocated zp[2]:2 [ printf_str::str#3 printf_str::str#5 printf_str::str#0 ]
Allocated zp[2]:4 [ screen#1 screen#27 screen#17 screen#0 ]
Allocated zp[2]:6 [ screen#2 ]
Allocated zp[2]:8 [ screen#3 ]
Allocated zp[2]:10 [ screen#4 ]
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [9] if(0!=*cputs::str#3) goto cputs::@2 [ cputs::str#3 screen#1 ] ( cputs:1 [ cputs::str#3 screen#1 ] { } cputs:5 [ cputs::str#3 screen#1 ] { { screen#17 = screen#27 } } ) always clobbers reg byte a reg byte y
Statement [11] *screen#1 = *cputs::str#3 [ cputs::str#3 screen#1 ] ( cputs:1 [ cputs::str#3 screen#1 ] { } cputs:5 [ cputs::str#3 screen#1 ] { { screen#17 = screen#27 } } ) always clobbers reg byte a reg byte y
Statement [9] if(0!=*printf_str::str#3) goto printf_str::@2 [ printf_str::str#3 screen#1 ] ( printf_str:1 [ printf_str::str#3 screen#1 ] { } printf_str:5 [ printf_str::str#3 screen#1 ] { { screen#17 = screen#27 } } ) always clobbers reg byte a reg byte y
Statement [11] *screen#1 = *printf_str::str#3 [ printf_str::str#3 screen#1 ] ( printf_str:1 [ printf_str::str#3 screen#1 ] { } printf_str:5 [ printf_str::str#3 screen#1 ] { { screen#17 = screen#27 } } ) always clobbers reg byte a reg byte y
Statement [14] *screen#1 = *printf_hextab [ screen#1 ] ( printf_uint:3 [ screen#1 ] { } ) always clobbers reg byte a reg byte y
Statement [15] screen#2 = ++ screen#1 [ screen#2 ] ( printf_uint:3 [ screen#2 ] { } ) always clobbers reg byte a
Statement [16] *screen#2 = *(printf_hextab+byte1 main::pct&$f) [ screen#2 ] ( printf_uint:3 [ screen#2 ] { } ) always clobbers reg byte a reg byte y
@ -429,21 +445,21 @@ Statement [18] *screen#3 = *(printf_hextab+byte0 main::pct>>4) [ screen#3 ] ( pr
Statement [19] screen#4 = ++ screen#3 [ screen#4 ] ( printf_uint:3 [ screen#4 ] { } ) always clobbers reg byte a
Statement [20] *screen#4 = *(printf_hextab+byte0 main::pct&$f) [ screen#4 ] ( printf_uint:3 [ screen#4 ] { } ) always clobbers reg byte a reg byte y
Statement [21] screen#17 = ++ screen#4 [ screen#17 ] ( printf_uint:3 [ screen#17 ] { } ) always clobbers reg byte a
Potential registers zp[2]:2 [ cputs::str#3 cputs::str#5 cputs::str#0 ] : zp[2]:2 ,
Potential registers zp[2]:2 [ printf_str::str#3 printf_str::str#5 printf_str::str#0 ] : zp[2]:2 ,
Potential registers zp[2]:4 [ screen#1 screen#27 screen#17 screen#0 ] : zp[2]:4 ,
Potential registers zp[2]:6 [ screen#2 ] : zp[2]:6 ,
Potential registers zp[2]:8 [ screen#3 ] : zp[2]:8 ,
Potential registers zp[2]:10 [ screen#4 ] : zp[2]:10 ,
REGISTER UPLIFT SCOPES
Uplift Scope [cputs] 316.75: zp[2]:2 [ cputs::str#3 cputs::str#5 cputs::str#0 ]
Uplift Scope [printf_str] 316.75: zp[2]:2 [ printf_str::str#3 printf_str::str#5 printf_str::str#0 ]
Uplift Scope [] 165.25: zp[2]:4 [ screen#1 screen#27 screen#17 screen#0 ] 16.5: zp[2]:6 [ screen#2 ] 16.5: zp[2]:8 [ screen#3 ] 16.5: zp[2]:10 [ screen#4 ]
Uplift Scope [RADIX]
Uplift Scope [printf_format_number]
Uplift Scope [printf_uint]
Uplift Scope [main]
Uplifting [cputs] best 813 combination zp[2]:2 [ cputs::str#3 cputs::str#5 cputs::str#0 ]
Uplifting [printf_str] best 813 combination zp[2]:2 [ printf_str::str#3 printf_str::str#5 printf_str::str#0 ]
Uplifting [] best 813 combination zp[2]:4 [ screen#1 screen#27 screen#17 screen#0 ] zp[2]:6 [ screen#2 ] zp[2]:8 [ screen#3 ] zp[2]:10 [ screen#4 ]
Uplifting [RADIX] best 813 combination
Uplifting [printf_format_number] best 813 combination
@ -472,20 +488,20 @@ ASSEMBLER BEFORE OPTIMIZATION
// main
main: {
.label pct = $156
// [1] call cputs
// [7] phi from main to cputs [phi:main->cputs]
cputs_from_main:
// [7] phi screen#27 = (char *) 1024 [phi:main->cputs#0] -- pbuz1=pbuc1
// [1] call printf_str
// [7] phi from main to printf_str [phi:main->printf_str]
printf_str_from_main:
// [7] phi screen#27 = (char *) 1024 [phi:main->printf_str#0] -- pbuz1=pbuc1
lda #<$400
sta.z screen
lda #>$400
sta.z screen+1
// [7] phi cputs::str#5 = main::str [phi:main->cputs#1] -- pbuz1=pbuc1
// [7] phi printf_str::str#5 = main::str [phi:main->printf_str#1] -- pbuz1=pbuc1
lda #<str
sta.z cputs.str
sta.z printf_str.str
lda #>str
sta.z cputs.str+1
jsr cputs
sta.z printf_str.str+1
jsr printf_str
// [2] phi from main to main::@1 [phi:main->main::@1]
__b1_from_main:
jmp __b1
@ -498,16 +514,16 @@ main: {
jmp __b2
// main::@2
__b2:
// [5] call cputs
// [7] phi from main::@2 to cputs [phi:main::@2->cputs]
cputs_from___b2:
// [7] phi screen#27 = screen#17 [phi:main::@2->cputs#0] -- register_copy
// [7] phi cputs::str#5 = main::str1 [phi:main::@2->cputs#1] -- pbuz1=pbuc1
// [5] call printf_str
// [7] phi from main::@2 to printf_str [phi:main::@2->printf_str]
printf_str_from___b2:
// [7] phi screen#27 = screen#17 [phi:main::@2->printf_str#0] -- register_copy
// [7] phi printf_str::str#5 = main::str1 [phi:main::@2->printf_str#1] -- pbuz1=pbuc1
lda #<str1
sta.z cputs.str
sta.z printf_str.str
lda #>str1
sta.z cputs.str+1
jsr cputs
sta.z printf_str.str+1
jsr printf_str
jmp __breturn
// main::@return
__breturn:
@ -520,31 +536,31 @@ main: {
.byte 0
}
.segment Code
// cputs
// void cputs(__zp(2) char *str)
cputs: {
// printf_str
// void printf_str(void (*putc)(char), __zp(2) char *str)
printf_str: {
.label str = 2
// [8] phi from cputs cputs::@2 to cputs::@1 [phi:cputs/cputs::@2->cputs::@1]
__b1_from_cputs:
// [8] phi from printf_str printf_str::@2 to printf_str::@1 [phi:printf_str/printf_str::@2->printf_str::@1]
__b1_from_printf_str:
__b1_from___b2:
// [8] phi screen#1 = screen#27 [phi:cputs/cputs::@2->cputs::@1#0] -- register_copy
// [8] phi cputs::str#3 = cputs::str#5 [phi:cputs/cputs::@2->cputs::@1#1] -- register_copy
// [8] phi screen#1 = screen#27 [phi:printf_str/printf_str::@2->printf_str::@1#0] -- register_copy
// [8] phi printf_str::str#3 = printf_str::str#5 [phi:printf_str/printf_str::@2->printf_str::@1#1] -- register_copy
jmp __b1
// cputs::@1
// printf_str::@1
__b1:
// [9] if(0!=*cputs::str#3) goto cputs::@2 -- 0_neq__deref_pbuz1_then_la1
// [9] if(0!=*printf_str::str#3) goto printf_str::@2 -- 0_neq__deref_pbuz1_then_la1
ldy #0
lda (str),y
cmp #0
bne __b2
jmp __breturn
// cputs::@return
// printf_str::@return
__breturn:
// [10] return
rts
// cputs::@2
// printf_str::@2
__b2:
// [11] *screen#1 = *cputs::str#3 -- _deref_pbuz1=_deref_pbuz2
// [11] *screen#1 = *printf_str::str#3 -- _deref_pbuz1=_deref_pbuz2
ldy #0
lda (str),y
ldy #0
@ -554,7 +570,7 @@ cputs: {
bne !+
inc.z screen+1
!:
// [13] cputs::str#0 = ++ cputs::str#3 -- pbuz1=_inc_pbuz1
// [13] printf_str::str#0 = ++ printf_str::str#3 -- pbuz1=_inc_pbuz1
inc.z str
bne !+
inc.z str+1
@ -564,7 +580,7 @@ cputs: {
// printf_uint
// Print an unsigned int using a specific format
// Always prints hexadecimals - ignores min_length and flags
// void printf_uint(unsigned int uvalue, char format_min_length, char format_justify_left, char format_sign_always, char format_zero_padding, char format_upper_case, char format_radix)
// void printf_uint(void (*putc)(char), unsigned int uvalue, char format_min_length, char format_justify_left, char format_sign_always, char format_zero_padding, char format_upper_case, char format_radix)
printf_uint: {
// [14] *screen#1 = *printf_hextab -- _deref_pbuz1=_deref_pbuc1
lda printf_hextab
@ -625,11 +641,11 @@ Succesful ASM optimization Pass5UnnecesaryLoadElimination
Replacing label __b1_from___b2 with __b1
Removing instruction __b1_from_main:
Removing instruction __b2_from___b1:
Removing instruction cputs_from___b2:
Removing instruction __b1_from_cputs:
Removing instruction printf_str_from___b2:
Removing instruction __b1_from_printf_str:
Removing instruction __b1_from___b2:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction cputs_from_main:
Removing instruction printf_str_from_main:
Removing instruction __b1:
Removing instruction __b2:
Removing instruction __breturn:
@ -642,17 +658,18 @@ __constant char RADIX::BINARY = 2
__constant char RADIX::DECIMAL = $a
__constant char RADIX::HEXADECIMAL = $10
__constant char RADIX::OCTAL = 8
void cputs(char *str)
char *cputs::str
char *cputs::str#0 // str zp[2]:2 202.0
char *cputs::str#3 // str zp[2]:2 103.75
char *cputs::str#5 // str zp[2]:2 11.0
void main()
__constant unsigned int main::pct = $156
__constant char main::str[$e] = "Commodore is "
__constant char main::str1[6] = " cool"
__constant const char printf_hextab[] = "0123456789abcdef"z
void printf_uint(unsigned int uvalue , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
void printf_str(void (*putc)(char) , char *str)
void (*printf_str::putc)(char)
char *printf_str::str
char *printf_str::str#0 // str zp[2]:2 202.0
char *printf_str::str#3 // str zp[2]:2 103.75
char *printf_str::str#5 // str zp[2]:2 11.0
void printf_uint(void (*putc)(char) , unsigned int uvalue , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
struct printf_format_number printf_uint::format
char printf_uint::format_justify_left
char printf_uint::format_min_length
@ -660,6 +677,7 @@ char printf_uint::format_radix
char printf_uint::format_sign_always
char printf_uint::format_upper_case
char printf_uint::format_zero_padding
void (*printf_uint::putc)(char)
unsigned int printf_uint::uvalue
char *screen
char *screen#0 // screen zp[2]:4 101.0
@ -670,7 +688,7 @@ char *screen#27 // screen zp[2]:4 13.0
char *screen#3 // screen zp[2]:4 16.5
char *screen#4 // screen zp[2]:4 16.5
zp[2]:2 [ cputs::str#3 cputs::str#5 cputs::str#0 ]
zp[2]:2 [ printf_str::str#3 printf_str::str#5 printf_str::str#0 ]
zp[2]:4 [ screen#1 screen#27 screen#17 screen#0 screen#2 screen#4 screen#3 ]
@ -696,19 +714,19 @@ Score: 697
main: {
.label pct = $156
// printf("Commodore is %x cool", pct)
// [1] call cputs
// [7] phi from main to cputs [phi:main->cputs]
// [7] phi screen#27 = (char *) 1024 [phi:main->cputs#0] -- pbuz1=pbuc1
// [1] call printf_str
// [7] phi from main to printf_str [phi:main->printf_str]
// [7] phi screen#27 = (char *) 1024 [phi:main->printf_str#0] -- pbuz1=pbuc1
lda #<$400
sta.z screen
lda #>$400
sta.z screen+1
// [7] phi cputs::str#5 = main::str [phi:main->cputs#1] -- pbuz1=pbuc1
// [7] phi printf_str::str#5 = main::str [phi:main->printf_str#1] -- pbuz1=pbuc1
lda #<str
sta.z cputs.str
sta.z printf_str.str
lda #>str
sta.z cputs.str+1
jsr cputs
sta.z printf_str.str+1
jsr printf_str
// [2] phi from main to main::@1 [phi:main->main::@1]
// main::@1
// printf("Commodore is %x cool", pct)
@ -717,15 +735,15 @@ main: {
// [4] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
// main::@2
// printf("Commodore is %x cool", pct)
// [5] call cputs
// [7] phi from main::@2 to cputs [phi:main::@2->cputs]
// [7] phi screen#27 = screen#17 [phi:main::@2->cputs#0] -- register_copy
// [7] phi cputs::str#5 = main::str1 [phi:main::@2->cputs#1] -- pbuz1=pbuc1
// [5] call printf_str
// [7] phi from main::@2 to printf_str [phi:main::@2->printf_str]
// [7] phi screen#27 = screen#17 [phi:main::@2->printf_str#0] -- register_copy
// [7] phi printf_str::str#5 = main::str1 [phi:main::@2->printf_str#1] -- pbuz1=pbuc1
lda #<str1
sta.z cputs.str
sta.z printf_str.str
lda #>str1
sta.z cputs.str+1
jsr cputs
sta.z printf_str.str+1
jsr printf_str
// main::@return
// }
// [6] return
@ -737,29 +755,29 @@ main: {
.byte 0
}
.segment Code
// cputs
// void cputs(__zp(2) char *str)
cputs: {
// printf_str
// void printf_str(void (*putc)(char), __zp(2) char *str)
printf_str: {
.label str = 2
// [8] phi from cputs cputs::@2 to cputs::@1 [phi:cputs/cputs::@2->cputs::@1]
// [8] phi screen#1 = screen#27 [phi:cputs/cputs::@2->cputs::@1#0] -- register_copy
// [8] phi cputs::str#3 = cputs::str#5 [phi:cputs/cputs::@2->cputs::@1#1] -- register_copy
// cputs::@1
// [8] phi from printf_str printf_str::@2 to printf_str::@1 [phi:printf_str/printf_str::@2->printf_str::@1]
// [8] phi screen#1 = screen#27 [phi:printf_str/printf_str::@2->printf_str::@1#0] -- register_copy
// [8] phi printf_str::str#3 = printf_str::str#5 [phi:printf_str/printf_str::@2->printf_str::@1#1] -- register_copy
// printf_str::@1
__b1:
// while(*str)
// [9] if(0!=*cputs::str#3) goto cputs::@2 -- 0_neq__deref_pbuz1_then_la1
// [9] if(0!=*printf_str::str#3) goto printf_str::@2 -- 0_neq__deref_pbuz1_then_la1
ldy #0
lda (str),y
cmp #0
bne __b2
// cputs::@return
// printf_str::@return
// }
// [10] return
rts
// cputs::@2
// printf_str::@2
__b2:
// *screen++ = *str++
// [11] *screen#1 = *cputs::str#3 -- _deref_pbuz1=_deref_pbuz2
// [11] *screen#1 = *printf_str::str#3 -- _deref_pbuz1=_deref_pbuz2
ldy #0
lda (str),y
sta (screen),y
@ -769,7 +787,7 @@ cputs: {
bne !+
inc.z screen+1
!:
// [13] cputs::str#0 = ++ cputs::str#3 -- pbuz1=_inc_pbuz1
// [13] printf_str::str#0 = ++ printf_str::str#3 -- pbuz1=_inc_pbuz1
inc.z str
bne !+
inc.z str+1
@ -779,7 +797,7 @@ cputs: {
// printf_uint
// Print an unsigned int using a specific format
// Always prints hexadecimals - ignores min_length and flags
// void printf_uint(unsigned int uvalue, char format_min_length, char format_justify_left, char format_sign_always, char format_zero_padding, char format_upper_case, char format_radix)
// void printf_uint(void (*putc)(char), unsigned int uvalue, char format_min_length, char format_justify_left, char format_sign_always, char format_zero_padding, char format_upper_case, char format_radix)
printf_uint: {
// *screen++ = printf_hextab[BYTE1(uvalue)>>4]
// [14] *screen#1 = *printf_hextab -- _deref_pbuz1=_deref_pbuc1

View File

@ -2,17 +2,18 @@ __constant char RADIX::BINARY = 2
__constant char RADIX::DECIMAL = $a
__constant char RADIX::HEXADECIMAL = $10
__constant char RADIX::OCTAL = 8
void cputs(char *str)
char *cputs::str
char *cputs::str#0 // str zp[2]:2 202.0
char *cputs::str#3 // str zp[2]:2 103.75
char *cputs::str#5 // str zp[2]:2 11.0
void main()
__constant unsigned int main::pct = $156
__constant char main::str[$e] = "Commodore is "
__constant char main::str1[6] = " cool"
__constant const char printf_hextab[] = "0123456789abcdef"z
void printf_uint(unsigned int uvalue , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
void printf_str(void (*putc)(char) , char *str)
void (*printf_str::putc)(char)
char *printf_str::str
char *printf_str::str#0 // str zp[2]:2 202.0
char *printf_str::str#3 // str zp[2]:2 103.75
char *printf_str::str#5 // str zp[2]:2 11.0
void printf_uint(void (*putc)(char) , unsigned int uvalue , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
struct printf_format_number printf_uint::format
char printf_uint::format_justify_left
char printf_uint::format_min_length
@ -20,6 +21,7 @@ char printf_uint::format_radix
char printf_uint::format_sign_always
char printf_uint::format_upper_case
char printf_uint::format_zero_padding
void (*printf_uint::putc)(char)
unsigned int printf_uint::uvalue
char *screen
char *screen#0 // screen zp[2]:4 101.0
@ -30,5 +32,5 @@ char *screen#27 // screen zp[2]:4 13.0
char *screen#3 // screen zp[2]:4 16.5
char *screen#4 // screen zp[2]:4 16.5
zp[2]:2 [ cputs::str#3 cputs::str#5 cputs::str#0 ]
zp[2]:2 [ printf_str::str#3 printf_str::str#5 printf_str::str#0 ]
zp[2]:4 [ screen#1 screen#27 screen#17 screen#0 screen#2 screen#4 screen#3 ]

View File

@ -10,6 +10,7 @@
:BasicUpstart(__start)
.const LIGHT_BLUE = $e
.const OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS = 1
.const STACK_BASE = $103
.const SIZEOF_STRUCT_PRINTF_BUFFER_NUMBER = $c
/// Color Ram
.label COLORRAM = $d800
@ -17,13 +18,13 @@
.label DEFAULT_SCREEN = $400
// The number of bytes on the screen
// The current cursor x-position
.label conio_cursor_x = 8
.label conio_cursor_x = $a
// The current cursor y-position
.label conio_cursor_y = 9
.label conio_cursor_y = $b
// The current text cursor line start
.label conio_line_text = $a
.label conio_line_text = $c
// The current color cursor line start
.label conio_line_color = $c
.label conio_line_color = $e
.segment Code
__start: {
// __ma char conio_cursor_x = 0
@ -62,6 +63,37 @@ conio_c64_init: {
// }
rts
}
// Output one character at the current cursor position
// Moves the cursor forward. Scrolls the entire screen if needed
// void cputc(__register(A) char c)
cputc: {
.const OFFSET_STACK_C = 0
tsx
lda STACK_BASE+OFFSET_STACK_C,x
// if(c=='\n')
cmp #'\n'
beq __b1
// conio_line_text[conio_cursor_x] = c
ldy.z conio_cursor_x
sta (conio_line_text),y
// conio_line_color[conio_cursor_x] = conio_textcolor
lda #LIGHT_BLUE
sta (conio_line_color),y
// if(++conio_cursor_x==CONIO_WIDTH)
inc.z conio_cursor_x
lda #$28
cmp.z conio_cursor_x
bne __breturn
// cputln()
jsr cputln
__breturn:
// }
rts
__b1:
// cputln()
jsr cputln
rts
}
main: {
.label c = 7
// clrscr()
@ -75,12 +107,12 @@ main: {
// void gotoxy(char x, __register(X) char y)
gotoxy: {
.const x = 0
.label __5 = $12
.label __6 = $e
.label __7 = $e
.label line_offset = $e
.label __8 = $10
.label __9 = $e
.label __5 = $14
.label __6 = $10
.label __7 = $10
.label line_offset = $10
.label __8 = $12
.label __9 = $10
// if(y>CONIO_HEIGHT)
cpx #$19+1
bcc __b2
@ -146,6 +178,34 @@ gotoxy: {
// }
rts
}
// Print a newline
cputln: {
// conio_line_text += CONIO_WIDTH
lda #$28
clc
adc.z conio_line_text
sta.z conio_line_text
bcc !+
inc.z conio_line_text+1
!:
// conio_line_color += CONIO_WIDTH
lda #$28
clc
adc.z conio_line_color
sta.z conio_line_color
bcc !+
inc.z conio_line_color+1
!:
// conio_cursor_x = 0
lda #0
sta.z conio_cursor_x
// conio_cursor_y++;
inc.z conio_cursor_y
// cscroll()
jsr cscroll
// }
rts
}
// clears the screen and moves the cursor to the upper left-hand corner of the screen.
clrscr: {
.label line_text = 6
@ -217,7 +277,7 @@ clrscr: {
jmp __b3
}
// Print an unsigned char using a specific format
// void printf_uchar(char uvalue, char format_min_length, char format_justify_left, char format_sign_always, char format_zero_padding, char format_upper_case, char format_radix)
// void printf_uchar(void (*putc)(char), char uvalue, char format_min_length, char format_justify_left, char format_sign_always, char format_zero_padding, char format_upper_case, char format_radix)
printf_uchar: {
// printf_buffer.sign = format.sign_always?'+':0
// Handle any sign
@ -226,211 +286,13 @@ printf_uchar: {
// uctoa(uvalue, printf_buffer.digits, format.radix)
// Format number into buffer
jsr uctoa
// printf_number_buffer(printf_buffer, format)
// printf_number_buffer(putc, printf_buffer, format)
lda printf_buffer
// Print using format
jsr printf_number_buffer
// }
rts
}
// Converts unsigned number value to a string representing it in RADIX format.
// If the leading digits are zero they are not included in the string.
// - value : The number to be converted to RADIX
// - buffer : receives the string representing the number and zero-termination.
// - radix : The radix to convert the number to (from the enum RADIX)
// void uctoa(__register(X) char value, __zp(6) char *buffer, char radix)
uctoa: {
.const max_digits = 3
.label digit_value = $14
.label buffer = 6
.label digit = 2
.label started = 3
lda #<printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
sta.z buffer
lda #>printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
sta.z buffer+1
lda #0
sta.z started
ldx #main.c
sta.z digit
__b1:
// for( char digit=0; digit<max_digits-1; digit++ )
lda.z digit
cmp #max_digits-1
bcc __b2
// *buffer++ = DIGITS[(char)value]
lda DIGITS,x
ldy #0
sta (buffer),y
// *buffer++ = DIGITS[(char)value];
inc.z buffer
bne !+
inc.z buffer+1
!:
// *buffer = 0
lda #0
tay
sta (buffer),y
// }
rts
__b2:
// unsigned char digit_value = digit_values[digit]
ldy.z digit
lda RADIX_DECIMAL_VALUES_CHAR,y
sta.z digit_value
// if (started || value >= digit_value)
lda.z started
bne __b5
cpx.z digit_value
bcs __b5
__b4:
// for( char digit=0; digit<max_digits-1; digit++ )
inc.z digit
jmp __b1
__b5:
// uctoa_append(buffer++, value, digit_value)
jsr uctoa_append
// uctoa_append(buffer++, value, digit_value)
// value = uctoa_append(buffer++, value, digit_value)
// value = uctoa_append(buffer++, value, digit_value);
inc.z buffer
bne !+
inc.z buffer+1
!:
lda #1
sta.z started
jmp __b4
}
// Print the contents of the number buffer using a specific format.
// This handles minimum length, zero-filling, and left/right justification from the format
// void printf_number_buffer(__register(A) char buffer_sign, char *buffer_digits, char format_min_length, char format_justify_left, char format_sign_always, char format_zero_padding, char format_upper_case, char format_radix)
printf_number_buffer: {
.label buffer_digits = printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
// if(buffer.sign)
cmp #0
beq __b2
// cputc(buffer.sign)
jsr cputc
__b2:
// cputs(buffer.digits)
jsr cputs
// }
rts
}
// Used to convert a single digit of an unsigned number value to a string representation
// Counts a single digit up from '0' as long as the value is larger than sub.
// Each time the digit is increased sub is subtracted from value.
// - buffer : pointer to the char that receives the digit
// - value : The value where the digit will be derived from
// - sub : the value of a '1' in the digit. Subtracted continually while the digit is increased.
// (For decimal the subs used are 10000, 1000, 100, 10, 1)
// returns : the value reduced by sub * digit so that it is less than sub.
// __register(X) char uctoa_append(__zp(6) char *buffer, __register(X) char value, __zp($14) char sub)
uctoa_append: {
.label buffer = 6
.label sub = $14
ldy #0
__b1:
// while (value >= sub)
cpx.z sub
bcs __b2
// *buffer = DIGITS[digit]
lda DIGITS,y
ldy #0
sta (buffer),y
// }
rts
__b2:
// digit++;
iny
// value -= sub
txa
sec
sbc.z sub
tax
jmp __b1
}
// Output one character at the current cursor position
// Moves the cursor forward. Scrolls the entire screen if needed
// void cputc(__register(A) char c)
cputc: {
// if(c=='\n')
cmp #'\n'
beq __b1
// conio_line_text[conio_cursor_x] = c
ldy.z conio_cursor_x
sta (conio_line_text),y
// conio_line_color[conio_cursor_x] = conio_textcolor
lda #LIGHT_BLUE
sta (conio_line_color),y
// if(++conio_cursor_x==CONIO_WIDTH)
inc.z conio_cursor_x
lda #$28
cmp.z conio_cursor_x
bne __breturn
// cputln()
jsr cputln
__breturn:
// }
rts
__b1:
// cputln()
jsr cputln
rts
}
// Output a NUL-terminated string at the current cursor position
// void cputs(__zp(4) const char *s)
cputs: {
.label s = 4
lda #<printf_number_buffer.buffer_digits
sta.z s
lda #>printf_number_buffer.buffer_digits
sta.z s+1
__b1:
// while(c=*s++)
ldy #0
lda (s),y
inc.z s
bne !+
inc.z s+1
!:
cmp #0
bne __b2
// }
rts
__b2:
// cputc(c)
jsr cputc
jmp __b1
}
// Print a newline
cputln: {
// conio_line_text += CONIO_WIDTH
lda #$28
clc
adc.z conio_line_text
sta.z conio_line_text
bcc !+
inc.z conio_line_text+1
!:
// conio_line_color += CONIO_WIDTH
lda #$28
clc
adc.z conio_line_color
sta.z conio_line_color
bcc !+
inc.z conio_line_color+1
!:
// conio_cursor_x = 0
lda #0
sta.z conio_cursor_x
// conio_cursor_y++;
inc.z conio_cursor_y
// cscroll()
jsr cscroll
// }
rts
}
// Scroll the entire screen if the cursor is beyond the last line
cscroll: {
// if(conio_cursor_y==CONIO_HEIGHT)
@ -493,15 +355,101 @@ cscroll: {
// }
rts
}
// Converts unsigned number value to a string representing it in RADIX format.
// If the leading digits are zero they are not included in the string.
// - value : The number to be converted to RADIX
// - buffer : receives the string representing the number and zero-termination.
// - radix : The radix to convert the number to (from the enum RADIX)
// void uctoa(__register(X) char value, __zp(6) char *buffer, char radix)
uctoa: {
.const max_digits = 3
.label digit_value = $16
.label buffer = 6
.label digit = 2
.label started = 3
lda #<printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
sta.z buffer
lda #>printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
sta.z buffer+1
lda #0
sta.z started
ldx #main.c
sta.z digit
__b1:
// for( char digit=0; digit<max_digits-1; digit++ )
lda.z digit
cmp #max_digits-1
bcc __b2
// *buffer++ = DIGITS[(char)value]
lda DIGITS,x
ldy #0
sta (buffer),y
// *buffer++ = DIGITS[(char)value];
inc.z buffer
bne !+
inc.z buffer+1
!:
// *buffer = 0
lda #0
tay
sta (buffer),y
// }
rts
__b2:
// unsigned char digit_value = digit_values[digit]
ldy.z digit
lda RADIX_DECIMAL_VALUES_CHAR,y
sta.z digit_value
// if (started || value >= digit_value)
lda.z started
bne __b5
cpx.z digit_value
bcs __b5
__b4:
// for( char digit=0; digit<max_digits-1; digit++ )
inc.z digit
jmp __b1
__b5:
// uctoa_append(buffer++, value, digit_value)
jsr uctoa_append
// uctoa_append(buffer++, value, digit_value)
// value = uctoa_append(buffer++, value, digit_value)
// value = uctoa_append(buffer++, value, digit_value);
inc.z buffer
bne !+
inc.z buffer+1
!:
lda #1
sta.z started
jmp __b4
}
// Print the contents of the number buffer using a specific format.
// This handles minimum length, zero-filling, and left/right justification from the format
// void printf_number_buffer(void (*putc)(char), __register(A) char buffer_sign, char *buffer_digits, char format_min_length, char format_justify_left, char format_sign_always, char format_zero_padding, char format_upper_case, char format_radix)
printf_number_buffer: {
.label buffer_digits = printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
// if(buffer.sign)
cmp #0
beq __b2
// putc(buffer.sign)
pha
jsr cputc
pla
__b2:
// printf_str(putc, buffer.digits)
jsr printf_str
// }
rts
}
// Copy block of memory (forwards)
// Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
// void * memcpy(__zp($17) void *destination, __zp(6) void *source, unsigned int num)
// void * memcpy(__zp(6) void *destination, __zp(4) void *source, unsigned int num)
memcpy: {
.label src_end = $15
.label dst = $17
.label src = 6
.label source = 6
.label destination = $17
.label src_end = $17
.label dst = 6
.label src = 4
.label source = 4
.label destination = 6
// char* src_end = (char*)source+num
lda.z source
clc
@ -572,6 +520,66 @@ memset: {
!:
jmp __b2
}
// Used to convert a single digit of an unsigned number value to a string representation
// Counts a single digit up from '0' as long as the value is larger than sub.
// Each time the digit is increased sub is subtracted from value.
// - buffer : pointer to the char that receives the digit
// - value : The value where the digit will be derived from
// - sub : the value of a '1' in the digit. Subtracted continually while the digit is increased.
// (For decimal the subs used are 10000, 1000, 100, 10, 1)
// returns : the value reduced by sub * digit so that it is less than sub.
// __register(X) char uctoa_append(__zp(6) char *buffer, __register(X) char value, __zp($16) char sub)
uctoa_append: {
.label buffer = 6
.label sub = $16
ldy #0
__b1:
// while (value >= sub)
cpx.z sub
bcs __b2
// *buffer = DIGITS[digit]
lda DIGITS,y
ldy #0
sta (buffer),y
// }
rts
__b2:
// digit++;
iny
// value -= sub
txa
sec
sbc.z sub
tax
jmp __b1
}
/// Print a NUL-terminated string
// void printf_str(void (*putc)(char), __zp(8) const char *s)
printf_str: {
.label s = 8
lda #<printf_number_buffer.buffer_digits
sta.z s
lda #>printf_number_buffer.buffer_digits
sta.z s+1
__b1:
// while(c=*s++)
ldy #0
lda (s),y
inc.z s
bne !+
inc.z s+1
!:
cmp #0
bne __b2
// }
rts
__b2:
// putc(c)
pha
jsr cputc
pla
jmp __b1
}
.segment Data
// The digits used for numbers
DIGITS: .text "0123456789abcdef"

View File

@ -35,300 +35,302 @@ conio_c64_init::@return: scope:[conio_c64_init] from conio_c64_init::@1
[15] return
to:@return
__stackcall void cputc(char c)
cputc: scope:[cputc] from printf_number_buffer::@3 printf_str::@2
[16] cputc::c#0 = stackidx(char,cputc::OFFSET_STACK_C)
[17] if(cputc::c#0=='
') goto cputc::@1
to:cputc::@2
cputc::@2: scope:[cputc] from cputc
[18] conio_line_text[conio_cursor_x] = cputc::c#0
[19] conio_line_color[conio_cursor_x] = LIGHT_BLUE
[20] conio_cursor_x = ++ conio_cursor_x
[21] if(conio_cursor_x!=$28) goto cputc::@return
to:cputc::@3
cputc::@3: scope:[cputc] from cputc::@2
[22] phi()
[23] call cputln
to:cputc::@return
cputc::@return: scope:[cputc] from cputc::@1 cputc::@2 cputc::@3
[24] return
to:@return
cputc::@1: scope:[cputc] from cputc
[25] phi()
[26] call cputln
to:cputc::@return
void main()
main: scope:[main] from __start::@1
[16] phi()
[17] call clrscr
[27] phi()
[28] call clrscr
to:main::@1
main::@1: scope:[main] from main
[18] phi()
[19] call printf_uchar
[29] phi()
[30] call printf_uchar
to:main::@return
main::@return: scope:[main] from main::@1
[20] return
[31] return
to:@return
void gotoxy(char x , char y)
gotoxy: scope:[gotoxy] from conio_c64_init::@1
[21] if(gotoxy::y#2<$19+1) goto gotoxy::@3
[32] if(gotoxy::y#2<$19+1) goto gotoxy::@3
to:gotoxy::@1
gotoxy::@3: scope:[gotoxy] from gotoxy
[22] phi()
[33] phi()
to:gotoxy::@1
gotoxy::@1: scope:[gotoxy] from gotoxy gotoxy::@3
[23] gotoxy::y#4 = phi( gotoxy::@3/gotoxy::y#2, gotoxy/0 )
[34] gotoxy::y#4 = phi( gotoxy::@3/gotoxy::y#2, gotoxy/0 )
to:gotoxy::@2
gotoxy::@2: scope:[gotoxy] from gotoxy::@1
[24] conio_cursor_x = gotoxy::x#2
[25] conio_cursor_y = gotoxy::y#4
[26] gotoxy::$7 = (unsigned int)gotoxy::y#4
[27] gotoxy::$8 = gotoxy::$7 << 2
[28] gotoxy::$9 = gotoxy::$8 + gotoxy::$7
[29] gotoxy::line_offset#0 = gotoxy::$9 << 3
[30] gotoxy::$5 = DEFAULT_SCREEN + gotoxy::line_offset#0
[31] conio_line_text = gotoxy::$5
[32] gotoxy::$6 = COLORRAM + gotoxy::line_offset#0
[33] conio_line_color = gotoxy::$6
[35] conio_cursor_x = gotoxy::x#2
[36] conio_cursor_y = gotoxy::y#4
[37] gotoxy::$7 = (unsigned int)gotoxy::y#4
[38] gotoxy::$8 = gotoxy::$7 << 2
[39] gotoxy::$9 = gotoxy::$8 + gotoxy::$7
[40] gotoxy::line_offset#0 = gotoxy::$9 << 3
[41] gotoxy::$5 = DEFAULT_SCREEN + gotoxy::line_offset#0
[42] conio_line_text = gotoxy::$5
[43] gotoxy::$6 = COLORRAM + gotoxy::line_offset#0
[44] conio_line_color = gotoxy::$6
to:gotoxy::@return
gotoxy::@return: scope:[gotoxy] from gotoxy::@2
[34] return
[45] return
to:@return
void cputln()
cputln: scope:[cputln] from cputc::@1 cputc::@3
[46] conio_line_text = conio_line_text + $28
[47] conio_line_color = conio_line_color + $28
[48] conio_cursor_x = 0
[49] conio_cursor_y = ++ conio_cursor_y
[50] call cscroll
to:cputln::@return
cputln::@return: scope:[cputln] from cputln
[51] return
to:@return
void clrscr()
clrscr: scope:[clrscr] from main
[35] phi()
[52] phi()
to:clrscr::@1
clrscr::@1: scope:[clrscr] from clrscr clrscr::@5
[36] clrscr::line_cols#5 = phi( clrscr/COLORRAM, clrscr::@5/clrscr::line_cols#1 )
[36] clrscr::line_text#5 = phi( clrscr/DEFAULT_SCREEN, clrscr::@5/clrscr::line_text#1 )
[36] clrscr::l#2 = phi( clrscr/0, clrscr::@5/clrscr::l#1 )
[37] if(clrscr::l#2<$19) goto clrscr::@3
[53] clrscr::line_cols#5 = phi( clrscr/COLORRAM, clrscr::@5/clrscr::line_cols#1 )
[53] clrscr::line_text#5 = phi( clrscr/DEFAULT_SCREEN, clrscr::@5/clrscr::line_text#1 )
[53] clrscr::l#2 = phi( clrscr/0, clrscr::@5/clrscr::l#1 )
[54] if(clrscr::l#2<$19) goto clrscr::@3
to:clrscr::@2
clrscr::@2: scope:[clrscr] from clrscr::@1
[38] conio_cursor_x = 0
[39] conio_cursor_y = 0
[40] conio_line_text = DEFAULT_SCREEN
[41] conio_line_color = COLORRAM
[55] conio_cursor_x = 0
[56] conio_cursor_y = 0
[57] conio_line_text = DEFAULT_SCREEN
[58] conio_line_color = COLORRAM
to:clrscr::@return
clrscr::@return: scope:[clrscr] from clrscr::@2
[42] return
[59] return
to:@return
clrscr::@3: scope:[clrscr] from clrscr::@1 clrscr::@4
[43] clrscr::c#2 = phi( clrscr::@1/0, clrscr::@4/clrscr::c#1 )
[44] if(clrscr::c#2<$28) goto clrscr::@4
[60] clrscr::c#2 = phi( clrscr::@1/0, clrscr::@4/clrscr::c#1 )
[61] if(clrscr::c#2<$28) goto clrscr::@4
to:clrscr::@5
clrscr::@5: scope:[clrscr] from clrscr::@3
[45] clrscr::line_text#1 = clrscr::line_text#5 + $28
[46] clrscr::line_cols#1 = clrscr::line_cols#5 + $28
[47] clrscr::l#1 = ++ clrscr::l#2
[62] clrscr::line_text#1 = clrscr::line_text#5 + $28
[63] clrscr::line_cols#1 = clrscr::line_cols#5 + $28
[64] clrscr::l#1 = ++ clrscr::l#2
to:clrscr::@1
clrscr::@4: scope:[clrscr] from clrscr::@3
[48] clrscr::line_text#5[clrscr::c#2] = ' '
[49] clrscr::line_cols#5[clrscr::c#2] = LIGHT_BLUE
[50] clrscr::c#1 = ++ clrscr::c#2
[65] clrscr::line_text#5[clrscr::c#2] = ' '
[66] clrscr::line_cols#5[clrscr::c#2] = LIGHT_BLUE
[67] clrscr::c#1 = ++ clrscr::c#2
to:clrscr::@3
void printf_uchar(char uvalue , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
void printf_uchar(void (*putc)(char) , char uvalue , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
printf_uchar: scope:[printf_uchar] from main::@1
[51] phi()
[68] phi()
to:printf_uchar::@1
printf_uchar::@1: scope:[printf_uchar] from printf_uchar
[52] *((char *)&printf_buffer) = 0
[53] call uctoa
[69] *((char *)&printf_buffer) = 0
[70] call uctoa
to:printf_uchar::@2
printf_uchar::@2: scope:[printf_uchar] from printf_uchar::@1
[54] printf_number_buffer::buffer_sign#0 = *((char *)&printf_buffer)
[55] call printf_number_buffer
[71] printf_number_buffer::buffer_sign#0 = *((char *)&printf_buffer)
[72] call printf_number_buffer
to:printf_uchar::@return
printf_uchar::@return: scope:[printf_uchar] from printf_uchar::@2
[56] return
to:@return
void uctoa(char value , char *buffer , char radix)
uctoa: scope:[uctoa] from printf_uchar::@1
[57] phi()
to:uctoa::@1
uctoa::@1: scope:[uctoa] from uctoa uctoa::@4
[58] uctoa::buffer#11 = phi( uctoa::@4/uctoa::buffer#14, uctoa/(char *)&printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS )
[58] uctoa::started#2 = phi( uctoa::@4/uctoa::started#4, uctoa/0 )
[58] uctoa::value#2 = phi( uctoa::@4/uctoa::value#6, uctoa/main::c )
[58] uctoa::digit#2 = phi( uctoa::@4/uctoa::digit#1, uctoa/0 )
[59] if(uctoa::digit#2<uctoa::max_digits#1-1) goto uctoa::@2
to:uctoa::@3
uctoa::@3: scope:[uctoa] from uctoa::@1
[60] *uctoa::buffer#11 = DIGITS[uctoa::value#2]
[61] uctoa::buffer#3 = ++ uctoa::buffer#11
[62] *uctoa::buffer#3 = 0
to:uctoa::@return
uctoa::@return: scope:[uctoa] from uctoa::@3
[63] return
to:@return
uctoa::@2: scope:[uctoa] from uctoa::@1
[64] uctoa::digit_value#0 = RADIX_DECIMAL_VALUES_CHAR[uctoa::digit#2]
[65] if(0!=uctoa::started#2) goto uctoa::@5
to:uctoa::@7
uctoa::@7: scope:[uctoa] from uctoa::@2
[66] if(uctoa::value#2>=uctoa::digit_value#0) goto uctoa::@5
to:uctoa::@4
uctoa::@4: scope:[uctoa] from uctoa::@6 uctoa::@7
[67] uctoa::buffer#14 = phi( uctoa::@7/uctoa::buffer#11, uctoa::@6/uctoa::buffer#4 )
[67] uctoa::started#4 = phi( uctoa::@7/uctoa::started#2, uctoa::@6/1 )
[67] uctoa::value#6 = phi( uctoa::@7/uctoa::value#2, uctoa::@6/uctoa::value#0 )
[68] uctoa::digit#1 = ++ uctoa::digit#2
to:uctoa::@1
uctoa::@5: scope:[uctoa] from uctoa::@2 uctoa::@7
[69] uctoa_append::buffer#0 = uctoa::buffer#11
[70] uctoa_append::value#0 = uctoa::value#2
[71] uctoa_append::sub#0 = uctoa::digit_value#0
[72] call uctoa_append
[73] uctoa_append::return#0 = uctoa_append::value#2
to:uctoa::@6
uctoa::@6: scope:[uctoa] from uctoa::@5
[74] uctoa::value#0 = uctoa_append::return#0
[75] uctoa::buffer#4 = ++ uctoa::buffer#11
to:uctoa::@4
void printf_number_buffer(char buffer_sign , char *buffer_digits , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
printf_number_buffer: scope:[printf_number_buffer] from printf_uchar::@2
[76] phi()
to:printf_number_buffer::@1
printf_number_buffer::@1: scope:[printf_number_buffer] from printf_number_buffer
[77] if(0==printf_number_buffer::buffer_sign#0) goto printf_number_buffer::@2
to:printf_number_buffer::@3
printf_number_buffer::@3: scope:[printf_number_buffer] from printf_number_buffer::@1
[78] cputc::c#2 = printf_number_buffer::buffer_sign#0
[79] call cputc
to:printf_number_buffer::@2
printf_number_buffer::@2: scope:[printf_number_buffer] from printf_number_buffer::@1 printf_number_buffer::@3
[80] phi()
[81] call cputs
to:printf_number_buffer::@return
printf_number_buffer::@return: scope:[printf_number_buffer] from printf_number_buffer::@2
[82] return
to:@return
char uctoa_append(char *buffer , char value , char sub)
uctoa_append: scope:[uctoa_append] from uctoa::@5
[83] phi()
to:uctoa_append::@1
uctoa_append::@1: scope:[uctoa_append] from uctoa_append uctoa_append::@2
[84] uctoa_append::digit#2 = phi( uctoa_append/0, uctoa_append::@2/uctoa_append::digit#1 )
[84] uctoa_append::value#2 = phi( uctoa_append/uctoa_append::value#0, uctoa_append::@2/uctoa_append::value#1 )
[85] if(uctoa_append::value#2>=uctoa_append::sub#0) goto uctoa_append::@2
to:uctoa_append::@3
uctoa_append::@3: scope:[uctoa_append] from uctoa_append::@1
[86] *uctoa_append::buffer#0 = DIGITS[uctoa_append::digit#2]
to:uctoa_append::@return
uctoa_append::@return: scope:[uctoa_append] from uctoa_append::@3
[87] return
to:@return
uctoa_append::@2: scope:[uctoa_append] from uctoa_append::@1
[88] uctoa_append::digit#1 = ++ uctoa_append::digit#2
[89] uctoa_append::value#1 = uctoa_append::value#2 - uctoa_append::sub#0
to:uctoa_append::@1
void cputc(char c)
cputc: scope:[cputc] from cputs::@2 printf_number_buffer::@3
[90] cputc::c#3 = phi( cputs::@2/cputc::c#0, printf_number_buffer::@3/cputc::c#2 )
[91] if(cputc::c#3=='
') goto cputc::@1
to:cputc::@2
cputc::@2: scope:[cputc] from cputc
[92] conio_line_text[conio_cursor_x] = cputc::c#3
[93] conio_line_color[conio_cursor_x] = LIGHT_BLUE
[94] conio_cursor_x = ++ conio_cursor_x
[95] if(conio_cursor_x!=$28) goto cputc::@return
to:cputc::@3
cputc::@3: scope:[cputc] from cputc::@2
[96] phi()
[97] call cputln
to:cputc::@return
cputc::@return: scope:[cputc] from cputc::@1 cputc::@2 cputc::@3
[98] return
to:@return
cputc::@1: scope:[cputc] from cputc
[99] phi()
[100] call cputln
to:cputc::@return
void cputs(const char *s)
cputs: scope:[cputs] from printf_number_buffer::@2
[101] phi()
to:cputs::@1
cputs::@1: scope:[cputs] from cputs cputs::@2
[102] cputs::s#2 = phi( cputs/printf_number_buffer::buffer_digits#0, cputs::@2/cputs::s#0 )
[103] cputs::c#1 = *cputs::s#2
[104] cputs::s#0 = ++ cputs::s#2
[105] if(0!=cputs::c#1) goto cputs::@2
to:cputs::@return
cputs::@return: scope:[cputs] from cputs::@1
[106] return
to:@return
cputs::@2: scope:[cputs] from cputs::@1
[107] cputc::c#0 = cputs::c#1
[108] call cputc
to:cputs::@1
void cputln()
cputln: scope:[cputln] from cputc::@1 cputc::@3
[109] conio_line_text = conio_line_text + $28
[110] conio_line_color = conio_line_color + $28
[111] conio_cursor_x = 0
[112] conio_cursor_y = ++ conio_cursor_y
[113] call cscroll
to:cputln::@return
cputln::@return: scope:[cputln] from cputln
[114] return
[73] return
to:@return
void cscroll()
cscroll: scope:[cscroll] from cputln
[115] if(conio_cursor_y!=$19) goto cscroll::@return
[74] if(conio_cursor_y!=$19) goto cscroll::@return
to:cscroll::@1
cscroll::@1: scope:[cscroll] from cscroll
[116] phi()
[117] call memcpy
[75] phi()
[76] call memcpy
to:cscroll::@2
cscroll::@2: scope:[cscroll] from cscroll::@1
[118] phi()
[119] call memcpy
[77] phi()
[78] call memcpy
to:cscroll::@3
cscroll::@3: scope:[cscroll] from cscroll::@2
[120] phi()
[121] call memset
[79] phi()
[80] call memset
to:cscroll::@4
cscroll::@4: scope:[cscroll] from cscroll::@3
[122] phi()
[123] call memset
[81] phi()
[82] call memset
to:cscroll::@5
cscroll::@5: scope:[cscroll] from cscroll::@4
[124] conio_line_text = conio_line_text - $28
[125] conio_line_color = conio_line_color - $28
[126] conio_cursor_y = -- conio_cursor_y
[83] conio_line_text = conio_line_text - $28
[84] conio_line_color = conio_line_color - $28
[85] conio_cursor_y = -- conio_cursor_y
to:cscroll::@return
cscroll::@return: scope:[cscroll] from cscroll cscroll::@5
[127] return
[86] return
to:@return
void uctoa(char value , char *buffer , char radix)
uctoa: scope:[uctoa] from printf_uchar::@1
[87] phi()
to:uctoa::@1
uctoa::@1: scope:[uctoa] from uctoa uctoa::@4
[88] uctoa::buffer#11 = phi( uctoa::@4/uctoa::buffer#14, uctoa/(char *)&printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS )
[88] uctoa::started#2 = phi( uctoa::@4/uctoa::started#4, uctoa/0 )
[88] uctoa::value#2 = phi( uctoa::@4/uctoa::value#6, uctoa/main::c )
[88] uctoa::digit#2 = phi( uctoa::@4/uctoa::digit#1, uctoa/0 )
[89] if(uctoa::digit#2<uctoa::max_digits#1-1) goto uctoa::@2
to:uctoa::@3
uctoa::@3: scope:[uctoa] from uctoa::@1
[90] *uctoa::buffer#11 = DIGITS[uctoa::value#2]
[91] uctoa::buffer#3 = ++ uctoa::buffer#11
[92] *uctoa::buffer#3 = 0
to:uctoa::@return
uctoa::@return: scope:[uctoa] from uctoa::@3
[93] return
to:@return
uctoa::@2: scope:[uctoa] from uctoa::@1
[94] uctoa::digit_value#0 = RADIX_DECIMAL_VALUES_CHAR[uctoa::digit#2]
[95] if(0!=uctoa::started#2) goto uctoa::@5
to:uctoa::@7
uctoa::@7: scope:[uctoa] from uctoa::@2
[96] if(uctoa::value#2>=uctoa::digit_value#0) goto uctoa::@5
to:uctoa::@4
uctoa::@4: scope:[uctoa] from uctoa::@6 uctoa::@7
[97] uctoa::buffer#14 = phi( uctoa::@7/uctoa::buffer#11, uctoa::@6/uctoa::buffer#4 )
[97] uctoa::started#4 = phi( uctoa::@7/uctoa::started#2, uctoa::@6/1 )
[97] uctoa::value#6 = phi( uctoa::@7/uctoa::value#2, uctoa::@6/uctoa::value#0 )
[98] uctoa::digit#1 = ++ uctoa::digit#2
to:uctoa::@1
uctoa::@5: scope:[uctoa] from uctoa::@2 uctoa::@7
[99] uctoa_append::buffer#0 = uctoa::buffer#11
[100] uctoa_append::value#0 = uctoa::value#2
[101] uctoa_append::sub#0 = uctoa::digit_value#0
[102] call uctoa_append
[103] uctoa_append::return#0 = uctoa_append::value#2
to:uctoa::@6
uctoa::@6: scope:[uctoa] from uctoa::@5
[104] uctoa::value#0 = uctoa_append::return#0
[105] uctoa::buffer#4 = ++ uctoa::buffer#11
to:uctoa::@4
void printf_number_buffer(void (*putc)(char) , char buffer_sign , char *buffer_digits , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
printf_number_buffer: scope:[printf_number_buffer] from printf_uchar::@2
[106] phi()
to:printf_number_buffer::@1
printf_number_buffer::@1: scope:[printf_number_buffer] from printf_number_buffer
[107] if(0==printf_number_buffer::buffer_sign#0) goto printf_number_buffer::@2
to:printf_number_buffer::@3
printf_number_buffer::@3: scope:[printf_number_buffer] from printf_number_buffer::@1
[108] stackpush(char) = printf_number_buffer::buffer_sign#0
[109] callexecute cputc
sideeffect stackpullbytes(1)
to:printf_number_buffer::@2
printf_number_buffer::@2: scope:[printf_number_buffer] from printf_number_buffer::@1 printf_number_buffer::@3
[111] phi()
[112] call printf_str
to:printf_number_buffer::@return
printf_number_buffer::@return: scope:[printf_number_buffer] from printf_number_buffer::@2
[113] return
to:@return
void * memcpy(void *destination , void *source , unsigned int num)
memcpy: scope:[memcpy] from cscroll::@1 cscroll::@2
[128] memcpy::destination#2 = phi( cscroll::@1/(void *)DEFAULT_SCREEN, cscroll::@2/(void *)COLORRAM )
[128] memcpy::source#2 = phi( cscroll::@1/(void *)DEFAULT_SCREEN+$28, cscroll::@2/(void *)COLORRAM+$28 )
[129] memcpy::src_end#0 = (char *)memcpy::source#2 + (unsigned int)$19*$28-$28
[130] memcpy::src#4 = (char *)memcpy::source#2
[131] memcpy::dst#4 = (char *)memcpy::destination#2
[114] memcpy::destination#2 = phi( cscroll::@1/(void *)DEFAULT_SCREEN, cscroll::@2/(void *)COLORRAM )
[114] memcpy::source#2 = phi( cscroll::@1/(void *)DEFAULT_SCREEN+$28, cscroll::@2/(void *)COLORRAM+$28 )
[115] memcpy::src_end#0 = (char *)memcpy::source#2 + (unsigned int)$19*$28-$28
[116] memcpy::src#4 = (char *)memcpy::source#2
[117] memcpy::dst#4 = (char *)memcpy::destination#2
to:memcpy::@1
memcpy::@1: scope:[memcpy] from memcpy memcpy::@2
[132] memcpy::dst#2 = phi( memcpy/memcpy::dst#4, memcpy::@2/memcpy::dst#1 )
[132] memcpy::src#2 = phi( memcpy/memcpy::src#4, memcpy::@2/memcpy::src#1 )
[133] if(memcpy::src#2!=memcpy::src_end#0) goto memcpy::@2
[118] memcpy::dst#2 = phi( memcpy/memcpy::dst#4, memcpy::@2/memcpy::dst#1 )
[118] memcpy::src#2 = phi( memcpy/memcpy::src#4, memcpy::@2/memcpy::src#1 )
[119] if(memcpy::src#2!=memcpy::src_end#0) goto memcpy::@2
to:memcpy::@return
memcpy::@return: scope:[memcpy] from memcpy::@1
[134] return
[120] return
to:@return
memcpy::@2: scope:[memcpy] from memcpy::@1
[135] *memcpy::dst#2 = *memcpy::src#2
[136] memcpy::dst#1 = ++ memcpy::dst#2
[137] memcpy::src#1 = ++ memcpy::src#2
[121] *memcpy::dst#2 = *memcpy::src#2
[122] memcpy::dst#1 = ++ memcpy::dst#2
[123] memcpy::src#1 = ++ memcpy::src#2
to:memcpy::@1
void * memset(void *str , char c , unsigned int num)
memset: scope:[memset] from cscroll::@3 cscroll::@4
[138] memset::c#4 = phi( cscroll::@3/' ', cscroll::@4/LIGHT_BLUE )
[138] memset::str#3 = phi( cscroll::@3/(void *)DEFAULT_SCREEN+(unsigned int)$19*$28-$28, cscroll::@4/(void *)COLORRAM+(unsigned int)$19*$28-$28 )
[124] memset::c#4 = phi( cscroll::@3/' ', cscroll::@4/LIGHT_BLUE )
[124] memset::str#3 = phi( cscroll::@3/(void *)DEFAULT_SCREEN+(unsigned int)$19*$28-$28, cscroll::@4/(void *)COLORRAM+(unsigned int)$19*$28-$28 )
to:memset::@1
memset::@1: scope:[memset] from memset
[139] memset::end#0 = (char *)memset::str#3 + $28
[140] memset::dst#4 = (char *)memset::str#3
[125] memset::end#0 = (char *)memset::str#3 + $28
[126] memset::dst#4 = (char *)memset::str#3
to:memset::@2
memset::@2: scope:[memset] from memset::@1 memset::@3
[141] memset::dst#2 = phi( memset::@1/memset::dst#4, memset::@3/memset::dst#1 )
[142] if(memset::dst#2!=memset::end#0) goto memset::@3
[127] memset::dst#2 = phi( memset::@1/memset::dst#4, memset::@3/memset::dst#1 )
[128] if(memset::dst#2!=memset::end#0) goto memset::@3
to:memset::@return
memset::@return: scope:[memset] from memset::@2
[143] return
[129] return
to:@return
memset::@3: scope:[memset] from memset::@2
[144] *memset::dst#2 = memset::c#4
[145] memset::dst#1 = ++ memset::dst#2
[130] *memset::dst#2 = memset::c#4
[131] memset::dst#1 = ++ memset::dst#2
to:memset::@2
char uctoa_append(char *buffer , char value , char sub)
uctoa_append: scope:[uctoa_append] from uctoa::@5
[132] phi()
to:uctoa_append::@1
uctoa_append::@1: scope:[uctoa_append] from uctoa_append uctoa_append::@2
[133] uctoa_append::digit#2 = phi( uctoa_append/0, uctoa_append::@2/uctoa_append::digit#1 )
[133] uctoa_append::value#2 = phi( uctoa_append/uctoa_append::value#0, uctoa_append::@2/uctoa_append::value#1 )
[134] if(uctoa_append::value#2>=uctoa_append::sub#0) goto uctoa_append::@2
to:uctoa_append::@3
uctoa_append::@3: scope:[uctoa_append] from uctoa_append::@1
[135] *uctoa_append::buffer#0 = DIGITS[uctoa_append::digit#2]
to:uctoa_append::@return
uctoa_append::@return: scope:[uctoa_append] from uctoa_append::@3
[136] return
to:@return
uctoa_append::@2: scope:[uctoa_append] from uctoa_append::@1
[137] uctoa_append::digit#1 = ++ uctoa_append::digit#2
[138] uctoa_append::value#1 = uctoa_append::value#2 - uctoa_append::sub#0
to:uctoa_append::@1
void printf_str(void (*putc)(char) , const char *s)
printf_str: scope:[printf_str] from printf_number_buffer::@2
[139] phi()
to:printf_str::@1
printf_str::@1: scope:[printf_str] from printf_str printf_str::@2
[140] printf_str::s#2 = phi( printf_str/printf_number_buffer::buffer_digits#0, printf_str::@2/printf_str::s#0 )
[141] printf_str::c#1 = *printf_str::s#2
[142] printf_str::s#0 = ++ printf_str::s#2
[143] if(0!=printf_str::c#1) goto printf_str::@2
to:printf_str::@return
printf_str::@return: scope:[printf_str] from printf_str::@1
[144] return
to:@return
printf_str::@2: scope:[printf_str] from printf_str::@1
[145] stackpush(char) = printf_str::c#1
[146] callexecute cputc
sideeffect stackpullbytes(1)
to:printf_str::@1

File diff suppressed because it is too large Load Diff

View File

@ -9,6 +9,7 @@ __constant char RADIX::HEXADECIMAL = $10
__constant char RADIX::OCTAL = 8
__constant char RADIX_DECIMAL_VALUES_CHAR[] = { $64, $a }
__constant char SIZEOF_STRUCT_PRINTF_BUFFER_NUMBER = $c
__constant unsigned int STACK_BASE = $103
void __start()
void clrscr()
char clrscr::c
@ -28,31 +29,24 @@ __constant char * const conio_c64_init::BASIC_CURSOR_LINE = (char *) 214
char conio_c64_init::line
char conio_c64_init::line#0 // reg byte x 11.0
char conio_c64_init::line#2 // reg byte x 22.0
__loadstore char conio_cursor_x // zp[1]:8 416672.5
__loadstore char conio_cursor_y // zp[1]:9 6153850.173076923
__loadstore char *conio_line_color // zp[2]:12 4420004.18
__loadstore char *conio_line_text // zp[2]:10 4333337.431372548
void cputc(char c)
__loadstore char conio_cursor_x // zp[1]:10 394742.36842105264
__loadstore char conio_cursor_y // zp[1]:11 5925929.796296297
__loadstore char *conio_line_color // zp[2]:14 4250004.019230769
__loadstore char *conio_line_text // zp[2]:12 4169815.2641509436
__stackcall void cputc(char c)
__constant char cputc::OFFSET_STACK_C = 0
char cputc::c
char cputc::c#0 // reg byte a 200002.0
char cputc::c#2 // reg byte a 2002.0
char cputc::c#3 // reg byte a 1050502.0
char cputc::c#0 // reg byte a 1500001.5
void cputln()
void cputs(const char *s)
char cputs::c
char cputs::c#1 // reg byte a 100001.0
const char *cputs::s
const char *cputs::s#0 // s zp[2]:4 50000.5
const char *cputs::s#2 // s zp[2]:4 150001.5
void cscroll()
void gotoxy(char x , char y)
char *gotoxy::$5 // zp[2]:18 202.0
char *gotoxy::$6 // zp[2]:14 202.0
unsigned int gotoxy::$7 // zp[2]:14 151.5
unsigned int gotoxy::$8 // zp[2]:16 202.0
unsigned int gotoxy::$9 // zp[2]:14 202.0
char *gotoxy::$5 // zp[2]:20 202.0
char *gotoxy::$6 // zp[2]:16 202.0
unsigned int gotoxy::$7 // zp[2]:16 151.5
unsigned int gotoxy::$8 // zp[2]:18 202.0
unsigned int gotoxy::$9 // zp[2]:16 202.0
unsigned int gotoxy::line_offset
unsigned int gotoxy::line_offset#0 // line_offset zp[2]:14 101.0
unsigned int gotoxy::line_offset#0 // line_offset zp[2]:16 101.0
char gotoxy::x
__constant char gotoxy::x#2 = 0 // x
char gotoxy::y
@ -62,36 +56,36 @@ void main()
__constant char main::c = 7
void * memcpy(void *destination , void *source , unsigned int num)
void *memcpy::destination
void *memcpy::destination#2 // destination zp[2]:23
void *memcpy::destination#2 // destination zp[2]:6
char *memcpy::dst
char *memcpy::dst#1 // dst zp[2]:23 1.00000000001E11
char *memcpy::dst#2 // dst zp[2]:23 1.0033333333466667E11
char *memcpy::dst#4 // dst zp[2]:23 2.000000002E9
char *memcpy::dst#1 // dst zp[2]:6 1.0000000001E10
char *memcpy::dst#2 // dst zp[2]:6 1.0333333334666666E10
char *memcpy::dst#4 // dst zp[2]:6 2.000000002E9
unsigned int memcpy::num
void *memcpy::return
void *memcpy::source
void *memcpy::source#2 // source zp[2]:6
void *memcpy::source#2 // source zp[2]:4
char *memcpy::src
char *memcpy::src#1 // src zp[2]:6 2.00000000002E11
char *memcpy::src#2 // src zp[2]:6 1.0025000000125E11
char *memcpy::src#4 // src zp[2]:6 1.000000001E9
char *memcpy::src#1 // src zp[2]:4 2.0000000002E10
char *memcpy::src#2 // src zp[2]:4 1.025000000125E10
char *memcpy::src#4 // src zp[2]:4 1.000000001E9
char *memcpy::src_end
char *memcpy::src_end#0 // src_end zp[2]:21 1.262500000025E10
char *memcpy::src_end#0 // src_end zp[2]:23 1.37500000025E9
void * memset(void *str , char c , unsigned int num)
char memset::c
char memset::c#4 // reg byte x 1.4285714285857143E10
char memset::c#4 // reg byte x 1.4285714287142856E9
char *memset::dst
char *memset::dst#1 // dst zp[2]:6 2.00000000002E11
char *memset::dst#2 // dst zp[2]:6 1.3366666666833334E11
char *memset::dst#1 // dst zp[2]:6 2.0000000002E10
char *memset::dst#2 // dst zp[2]:6 1.3666666668333332E10
char *memset::dst#4 // dst zp[2]:6 2.000000002E9
char *memset::end
char *memset::end#0 // end zp[2]:23 1.6833333333666668E10
char *memset::end#0 // end zp[2]:23 1.8333333336666665E9
unsigned int memset::num
void *memset::return
void *memset::str
void *memset::str#3 // str zp[2]:6
__loadstore struct printf_buffer_number printf_buffer = {} // mem[12]
void printf_number_buffer(char buffer_sign , char *buffer_digits , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
void printf_number_buffer(void (*putc)(char) , char buffer_sign , char *buffer_digits , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
struct printf_buffer_number printf_number_buffer::buffer
char *printf_number_buffer::buffer_digits
__constant char *printf_number_buffer::buffer_digits#0 = (char *)&printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS // buffer_digits
@ -106,7 +100,15 @@ char printf_number_buffer::format_upper_case
char printf_number_buffer::format_zero_padding
signed char printf_number_buffer::len
signed char printf_number_buffer::padding
void printf_uchar(char uvalue , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
void (*printf_number_buffer::putc)(char)
void printf_str(void (*putc)(char) , const char *s)
char printf_str::c
char printf_str::c#1 // reg byte a 100001.0
void (*printf_str::putc)(char)
const char *printf_str::s
const char *printf_str::s#0 // s zp[2]:8 40000.4
const char *printf_str::s#2 // s zp[2]:8 150001.5
void printf_uchar(void (*putc)(char) , char uvalue , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
struct printf_format_number printf_uchar::format
char printf_uchar::format_justify_left
char printf_uchar::format_min_length
@ -114,6 +116,7 @@ char printf_uchar::format_radix
char printf_uchar::format_sign_always
char printf_uchar::format_upper_case
char printf_uchar::format_zero_padding
void (*printf_uchar::putc)(char)
char printf_uchar::uvalue
void uctoa(char value , char *buffer , char radix)
char *uctoa::buffer
@ -125,7 +128,7 @@ char uctoa::digit
char uctoa::digit#1 // digit zp[1]:2 20002.0
char uctoa::digit#2 // digit zp[1]:2 3077.230769230769
char uctoa::digit_value
char uctoa::digit_value#0 // digit_value zp[1]:20 6000.6
char uctoa::digit_value#0 // digit_value zp[1]:22 6000.6
char *uctoa::digit_values
char uctoa::max_digits
__constant char uctoa::max_digits#1 = 3 // max_digits
@ -146,7 +149,7 @@ char uctoa_append::digit#2 // reg byte y 1.00500015E7
char uctoa_append::return
char uctoa_append::return#0 // reg byte x 20002.0
char uctoa_append::sub
char uctoa_append::sub#0 // sub zp[1]:20 3335000.5
char uctoa_append::sub#0 // sub zp[1]:22 3335000.5
char uctoa_append::value
char uctoa_append::value#0 // reg byte x 36667.33333333333
char uctoa_append::value#1 // reg byte x 2.0000002E7
@ -159,23 +162,23 @@ reg byte y [ clrscr::c#2 clrscr::c#1 ]
zp[1]:2 [ uctoa::digit#2 uctoa::digit#1 ]
reg byte x [ uctoa::value#2 uctoa::value#6 uctoa::value#0 ]
zp[1]:3 [ uctoa::started#2 uctoa::started#4 ]
zp[2]:4 [ memcpy::source#2 memcpy::src#2 memcpy::src#4 memcpy::src#1 clrscr::line_cols#5 clrscr::line_cols#1 ]
zp[2]:6 [ memset::str#3 memset::dst#2 memset::dst#4 memset::dst#1 memcpy::destination#2 memcpy::dst#2 memcpy::dst#4 memcpy::dst#1 uctoa::buffer#11 uctoa::buffer#14 uctoa::buffer#4 uctoa::buffer#3 uctoa_append::buffer#0 clrscr::line_text#5 clrscr::line_text#1 ]
reg byte x [ memset::c#4 ]
reg byte x [ uctoa_append::value#2 uctoa_append::value#0 uctoa_append::value#1 ]
reg byte y [ uctoa_append::digit#2 uctoa_append::digit#1 ]
reg byte a [ cputc::c#3 cputc::c#0 cputc::c#2 ]
zp[2]:4 [ cputs::s#2 cputs::s#0 clrscr::line_cols#5 clrscr::line_cols#1 ]
zp[2]:6 [ memset::str#3 memset::dst#2 memset::dst#4 memset::dst#1 memcpy::source#2 memcpy::src#2 memcpy::src#4 memcpy::src#1 uctoa::buffer#11 uctoa::buffer#14 uctoa::buffer#4 uctoa::buffer#3 uctoa_append::buffer#0 clrscr::line_text#5 clrscr::line_text#1 ]
reg byte x [ memset::c#4 ]
zp[1]:8 [ conio_cursor_x ]
zp[1]:9 [ conio_cursor_y ]
zp[2]:10 [ conio_line_text ]
zp[2]:12 [ conio_line_color ]
zp[2]:14 [ gotoxy::$7 gotoxy::$9 gotoxy::line_offset#0 gotoxy::$6 ]
zp[2]:16 [ gotoxy::$8 ]
zp[2]:18 [ gotoxy::$5 ]
zp[2]:8 [ printf_str::s#2 printf_str::s#0 ]
zp[1]:10 [ conio_cursor_x ]
zp[1]:11 [ conio_cursor_y ]
zp[2]:12 [ conio_line_text ]
zp[2]:14 [ conio_line_color ]
reg byte a [ cputc::c#0 ]
zp[2]:16 [ gotoxy::$7 gotoxy::$9 gotoxy::line_offset#0 gotoxy::$6 ]
zp[2]:18 [ gotoxy::$8 ]
zp[2]:20 [ gotoxy::$5 ]
reg byte a [ printf_number_buffer::buffer_sign#0 ]
zp[1]:20 [ uctoa::digit_value#0 uctoa_append::sub#0 ]
zp[1]:22 [ uctoa::digit_value#0 uctoa_append::sub#0 ]
reg byte x [ uctoa_append::return#0 ]
reg byte a [ cputs::c#1 ]
zp[2]:21 [ memcpy::src_end#0 ]
zp[2]:23 [ memset::end#0 memcpy::destination#2 memcpy::dst#2 memcpy::dst#4 memcpy::dst#1 ]
zp[2]:23 [ memset::end#0 memcpy::src_end#0 ]
reg byte a [ printf_str::c#1 ]
mem[12] [ printf_buffer ]

View File

@ -9,6 +9,7 @@
.segment Basic
:BasicUpstart(__start)
.const LIGHT_BLUE = $e
.const STACK_BASE = $103
/// Color Ram
.label COLORRAM = $d800
/// Default address of screen character matrix
@ -60,21 +61,52 @@ conio_c64_init: {
// }
rts
}
// Output one character at the current cursor position
// Moves the cursor forward. Scrolls the entire screen if needed
// void cputc(__register(A) char c)
cputc: {
.const OFFSET_STACK_C = 0
tsx
lda STACK_BASE+OFFSET_STACK_C,x
// if(c=='\n')
cmp #'\n'
beq __b1
// conio_line_text[conio_cursor_x] = c
ldy.z conio_cursor_x
sta (conio_line_text),y
// conio_line_color[conio_cursor_x] = conio_textcolor
lda #LIGHT_BLUE
sta (conio_line_color),y
// if(++conio_cursor_x==CONIO_WIDTH)
inc.z conio_cursor_x
lda #$28
cmp.z conio_cursor_x
bne __breturn
// cputln()
jsr cputln
__breturn:
// }
rts
__b1:
// cputln()
jsr cputln
rts
}
main: {
// clrscr()
jsr clrscr
// printf("Lone 1\n")
lda #<s
sta.z cputs.s
sta.z printf_str.s
lda #>s
sta.z cputs.s+1
jsr cputs
sta.z printf_str.s+1
jsr printf_str
// printf("Lone 2\n")
lda #<s1
sta.z cputs.s
sta.z printf_str.s
lda #>s1
sta.z cputs.s+1
jsr cputs
sta.z printf_str.s+1
jsr printf_str
// }
rts
.segment Data
@ -159,6 +191,34 @@ gotoxy: {
// }
rts
}
// Print a newline
cputln: {
// conio_line_text += CONIO_WIDTH
lda #$28
clc
adc.z conio_line_text
sta.z conio_line_text
bcc !+
inc.z conio_line_text+1
!:
// conio_line_color += CONIO_WIDTH
lda #$28
clc
adc.z conio_line_color
sta.z conio_line_color
bcc !+
inc.z conio_line_color+1
!:
// conio_cursor_x = 0
lda #0
sta.z conio_cursor_x
// conio_cursor_y++;
inc.z conio_cursor_y
// cscroll()
jsr cscroll
// }
rts
}
// clears the screen and moves the cursor to the upper left-hand corner of the screen.
clrscr: {
.label line_text = 2
@ -229,9 +289,9 @@ clrscr: {
iny
jmp __b3
}
// Output a NUL-terminated string at the current cursor position
// void cputs(__zp(2) const char *s)
cputs: {
/// Print a NUL-terminated string
// void printf_str(void (*putc)(char), __zp(2) const char *s)
printf_str: {
.label s = 2
__b1:
// while(c=*s++)
@ -246,66 +306,12 @@ cputs: {
// }
rts
__b2:
// cputc(c)
// putc(c)
pha
jsr cputc
pla
jmp __b1
}
// Output one character at the current cursor position
// Moves the cursor forward. Scrolls the entire screen if needed
// void cputc(__register(A) char c)
cputc: {
// if(c=='\n')
cmp #'\n'
beq __b1
// conio_line_text[conio_cursor_x] = c
ldy.z conio_cursor_x
sta (conio_line_text),y
// conio_line_color[conio_cursor_x] = conio_textcolor
lda #LIGHT_BLUE
sta (conio_line_color),y
// if(++conio_cursor_x==CONIO_WIDTH)
inc.z conio_cursor_x
lda #$28
cmp.z conio_cursor_x
bne __breturn
// cputln()
jsr cputln
__breturn:
// }
rts
__b1:
// cputln()
jsr cputln
rts
}
// Print a newline
cputln: {
// conio_line_text += CONIO_WIDTH
lda #$28
clc
adc.z conio_line_text
sta.z conio_line_text
bcc !+
inc.z conio_line_text+1
!:
// conio_line_color += CONIO_WIDTH
lda #$28
clc
adc.z conio_line_color
sta.z conio_line_color
bcc !+
inc.z conio_line_color+1
!:
// conio_cursor_x = 0
lda #0
sta.z conio_cursor_x
// conio_cursor_y++;
inc.z conio_cursor_y
// cscroll()
jsr cscroll
// }
rts
}
// Scroll the entire screen if the cursor is beyond the last line
cscroll: {
// if(conio_cursor_y==CONIO_HEIGHT)

View File

@ -35,204 +35,206 @@ conio_c64_init::@return: scope:[conio_c64_init] from conio_c64_init::@1
[15] return
to:@return
__stackcall void cputc(char c)
cputc: scope:[cputc] from printf_str::@2
[16] cputc::c#0 = stackidx(char,cputc::OFFSET_STACK_C)
[17] if(cputc::c#0=='
') goto cputc::@1
to:cputc::@2
cputc::@2: scope:[cputc] from cputc
[18] conio_line_text[conio_cursor_x] = cputc::c#0
[19] conio_line_color[conio_cursor_x] = LIGHT_BLUE
[20] conio_cursor_x = ++ conio_cursor_x
[21] if(conio_cursor_x!=$28) goto cputc::@return
to:cputc::@3
cputc::@3: scope:[cputc] from cputc::@2
[22] phi()
[23] call cputln
to:cputc::@return
cputc::@return: scope:[cputc] from cputc::@1 cputc::@2 cputc::@3
[24] return
to:@return
cputc::@1: scope:[cputc] from cputc
[25] phi()
[26] call cputln
to:cputc::@return
void main()
main: scope:[main] from __start::@1
[16] phi()
[17] call clrscr
[27] phi()
[28] call clrscr
to:main::@1
main::@1: scope:[main] from main
[18] phi()
[19] call cputs
[29] phi()
[30] call printf_str
to:main::@2
main::@2: scope:[main] from main::@1
[20] phi()
[21] call cputs
[31] phi()
[32] call printf_str
to:main::@return
main::@return: scope:[main] from main::@2
[22] return
[33] return
to:@return
void gotoxy(char x , char y)
gotoxy: scope:[gotoxy] from conio_c64_init::@1
[23] if(gotoxy::y#2<$19+1) goto gotoxy::@3
[34] if(gotoxy::y#2<$19+1) goto gotoxy::@3
to:gotoxy::@1
gotoxy::@3: scope:[gotoxy] from gotoxy
[24] phi()
[35] phi()
to:gotoxy::@1
gotoxy::@1: scope:[gotoxy] from gotoxy gotoxy::@3
[25] gotoxy::y#4 = phi( gotoxy::@3/gotoxy::y#2, gotoxy/0 )
[36] gotoxy::y#4 = phi( gotoxy::@3/gotoxy::y#2, gotoxy/0 )
to:gotoxy::@2
gotoxy::@2: scope:[gotoxy] from gotoxy::@1
[26] conio_cursor_x = gotoxy::x#2
[27] conio_cursor_y = gotoxy::y#4
[28] gotoxy::$7 = (unsigned int)gotoxy::y#4
[29] gotoxy::$8 = gotoxy::$7 << 2
[30] gotoxy::$9 = gotoxy::$8 + gotoxy::$7
[31] gotoxy::line_offset#0 = gotoxy::$9 << 3
[32] gotoxy::$5 = DEFAULT_SCREEN + gotoxy::line_offset#0
[33] conio_line_text = gotoxy::$5
[34] gotoxy::$6 = COLORRAM + gotoxy::line_offset#0
[35] conio_line_color = gotoxy::$6
[37] conio_cursor_x = gotoxy::x#2
[38] conio_cursor_y = gotoxy::y#4
[39] gotoxy::$7 = (unsigned int)gotoxy::y#4
[40] gotoxy::$8 = gotoxy::$7 << 2
[41] gotoxy::$9 = gotoxy::$8 + gotoxy::$7
[42] gotoxy::line_offset#0 = gotoxy::$9 << 3
[43] gotoxy::$5 = DEFAULT_SCREEN + gotoxy::line_offset#0
[44] conio_line_text = gotoxy::$5
[45] gotoxy::$6 = COLORRAM + gotoxy::line_offset#0
[46] conio_line_color = gotoxy::$6
to:gotoxy::@return
gotoxy::@return: scope:[gotoxy] from gotoxy::@2
[36] return
[47] return
to:@return
void cputln()
cputln: scope:[cputln] from cputc::@1 cputc::@3
[48] conio_line_text = conio_line_text + $28
[49] conio_line_color = conio_line_color + $28
[50] conio_cursor_x = 0
[51] conio_cursor_y = ++ conio_cursor_y
[52] call cscroll
to:cputln::@return
cputln::@return: scope:[cputln] from cputln
[53] return
to:@return
void clrscr()
clrscr: scope:[clrscr] from main
[37] phi()
[54] phi()
to:clrscr::@1
clrscr::@1: scope:[clrscr] from clrscr clrscr::@5
[38] clrscr::line_cols#5 = phi( clrscr/COLORRAM, clrscr::@5/clrscr::line_cols#1 )
[38] clrscr::line_text#5 = phi( clrscr/DEFAULT_SCREEN, clrscr::@5/clrscr::line_text#1 )
[38] clrscr::l#2 = phi( clrscr/0, clrscr::@5/clrscr::l#1 )
[39] if(clrscr::l#2<$19) goto clrscr::@3
[55] clrscr::line_cols#5 = phi( clrscr/COLORRAM, clrscr::@5/clrscr::line_cols#1 )
[55] clrscr::line_text#5 = phi( clrscr/DEFAULT_SCREEN, clrscr::@5/clrscr::line_text#1 )
[55] clrscr::l#2 = phi( clrscr/0, clrscr::@5/clrscr::l#1 )
[56] if(clrscr::l#2<$19) goto clrscr::@3
to:clrscr::@2
clrscr::@2: scope:[clrscr] from clrscr::@1
[40] conio_cursor_x = 0
[41] conio_cursor_y = 0
[42] conio_line_text = DEFAULT_SCREEN
[43] conio_line_color = COLORRAM
[57] conio_cursor_x = 0
[58] conio_cursor_y = 0
[59] conio_line_text = DEFAULT_SCREEN
[60] conio_line_color = COLORRAM
to:clrscr::@return
clrscr::@return: scope:[clrscr] from clrscr::@2
[44] return
[61] return
to:@return
clrscr::@3: scope:[clrscr] from clrscr::@1 clrscr::@4
[45] clrscr::c#2 = phi( clrscr::@1/0, clrscr::@4/clrscr::c#1 )
[46] if(clrscr::c#2<$28) goto clrscr::@4
[62] clrscr::c#2 = phi( clrscr::@1/0, clrscr::@4/clrscr::c#1 )
[63] if(clrscr::c#2<$28) goto clrscr::@4
to:clrscr::@5
clrscr::@5: scope:[clrscr] from clrscr::@3
[47] clrscr::line_text#1 = clrscr::line_text#5 + $28
[48] clrscr::line_cols#1 = clrscr::line_cols#5 + $28
[49] clrscr::l#1 = ++ clrscr::l#2
[64] clrscr::line_text#1 = clrscr::line_text#5 + $28
[65] clrscr::line_cols#1 = clrscr::line_cols#5 + $28
[66] clrscr::l#1 = ++ clrscr::l#2
to:clrscr::@1
clrscr::@4: scope:[clrscr] from clrscr::@3
[50] clrscr::line_text#5[clrscr::c#2] = ' '
[51] clrscr::line_cols#5[clrscr::c#2] = LIGHT_BLUE
[52] clrscr::c#1 = ++ clrscr::c#2
[67] clrscr::line_text#5[clrscr::c#2] = ' '
[68] clrscr::line_cols#5[clrscr::c#2] = LIGHT_BLUE
[69] clrscr::c#1 = ++ clrscr::c#2
to:clrscr::@3
void cputs(const char *s)
cputs: scope:[cputs] from main::@1 main::@2
[53] cputs::s#4 = phi( main::@1/main::s, main::@2/main::s1 )
to:cputs::@1
cputs::@1: scope:[cputs] from cputs cputs::@2
[54] cputs::s#3 = phi( cputs/cputs::s#4, cputs::@2/cputs::s#0 )
[55] cputs::c#1 = *cputs::s#3
[56] cputs::s#0 = ++ cputs::s#3
[57] if(0!=cputs::c#1) goto cputs::@2
to:cputs::@return
cputs::@return: scope:[cputs] from cputs::@1
[58] return
to:@return
cputs::@2: scope:[cputs] from cputs::@1
[59] cputc::c#0 = cputs::c#1
[60] call cputc
to:cputs::@1
void cputc(char c)
cputc: scope:[cputc] from cputs::@2
[61] if(cputc::c#0=='
') goto cputc::@1
to:cputc::@2
cputc::@2: scope:[cputc] from cputc
[62] conio_line_text[conio_cursor_x] = cputc::c#0
[63] conio_line_color[conio_cursor_x] = LIGHT_BLUE
[64] conio_cursor_x = ++ conio_cursor_x
[65] if(conio_cursor_x!=$28) goto cputc::@return
to:cputc::@3
cputc::@3: scope:[cputc] from cputc::@2
[66] phi()
[67] call cputln
to:cputc::@return
cputc::@return: scope:[cputc] from cputc::@1 cputc::@2 cputc::@3
[68] return
to:@return
cputc::@1: scope:[cputc] from cputc
[69] phi()
[70] call cputln
to:cputc::@return
void cputln()
cputln: scope:[cputln] from cputc::@1 cputc::@3
[71] conio_line_text = conio_line_text + $28
[72] conio_line_color = conio_line_color + $28
[73] conio_cursor_x = 0
[74] conio_cursor_y = ++ conio_cursor_y
[75] call cscroll
to:cputln::@return
cputln::@return: scope:[cputln] from cputln
[76] return
void printf_str(void (*putc)(char) , const char *s)
printf_str: scope:[printf_str] from main::@1 main::@2
[70] printf_str::s#4 = phi( main::@1/main::s, main::@2/main::s1 )
to:printf_str::@1
printf_str::@1: scope:[printf_str] from printf_str printf_str::@2
[71] printf_str::s#3 = phi( printf_str/printf_str::s#4, printf_str::@2/printf_str::s#0 )
[72] printf_str::c#1 = *printf_str::s#3
[73] printf_str::s#0 = ++ printf_str::s#3
[74] if(0!=printf_str::c#1) goto printf_str::@2
to:printf_str::@return
printf_str::@return: scope:[printf_str] from printf_str::@1
[75] return
to:@return
printf_str::@2: scope:[printf_str] from printf_str::@1
[76] stackpush(char) = printf_str::c#1
[77] callexecute cputc
sideeffect stackpullbytes(1)
to:printf_str::@1
void cscroll()
cscroll: scope:[cscroll] from cputln
[77] if(conio_cursor_y!=$19) goto cscroll::@return
[79] if(conio_cursor_y!=$19) goto cscroll::@return
to:cscroll::@1
cscroll::@1: scope:[cscroll] from cscroll
[78] phi()
[79] call memcpy
to:cscroll::@2
cscroll::@2: scope:[cscroll] from cscroll::@1
[80] phi()
[81] call memcpy
to:cscroll::@2
cscroll::@2: scope:[cscroll] from cscroll::@1
[82] phi()
[83] call memcpy
to:cscroll::@3
cscroll::@3: scope:[cscroll] from cscroll::@2
[82] phi()
[83] call memset
to:cscroll::@4
cscroll::@4: scope:[cscroll] from cscroll::@3
[84] phi()
[85] call memset
to:cscroll::@4
cscroll::@4: scope:[cscroll] from cscroll::@3
[86] phi()
[87] call memset
to:cscroll::@5
cscroll::@5: scope:[cscroll] from cscroll::@4
[86] conio_line_text = conio_line_text - $28
[87] conio_line_color = conio_line_color - $28
[88] conio_cursor_y = -- conio_cursor_y
[88] conio_line_text = conio_line_text - $28
[89] conio_line_color = conio_line_color - $28
[90] conio_cursor_y = -- conio_cursor_y
to:cscroll::@return
cscroll::@return: scope:[cscroll] from cscroll cscroll::@5
[89] return
[91] return
to:@return
void * memcpy(void *destination , void *source , unsigned int num)
memcpy: scope:[memcpy] from cscroll::@1 cscroll::@2
[90] memcpy::destination#2 = phi( cscroll::@1/(void *)DEFAULT_SCREEN, cscroll::@2/(void *)COLORRAM )
[90] memcpy::source#2 = phi( cscroll::@1/(void *)DEFAULT_SCREEN+$28, cscroll::@2/(void *)COLORRAM+$28 )
[91] memcpy::src_end#0 = (char *)memcpy::source#2 + (unsigned int)$19*$28-$28
[92] memcpy::src#4 = (char *)memcpy::source#2
[93] memcpy::dst#4 = (char *)memcpy::destination#2
[92] memcpy::destination#2 = phi( cscroll::@1/(void *)DEFAULT_SCREEN, cscroll::@2/(void *)COLORRAM )
[92] memcpy::source#2 = phi( cscroll::@1/(void *)DEFAULT_SCREEN+$28, cscroll::@2/(void *)COLORRAM+$28 )
[93] memcpy::src_end#0 = (char *)memcpy::source#2 + (unsigned int)$19*$28-$28
[94] memcpy::src#4 = (char *)memcpy::source#2
[95] memcpy::dst#4 = (char *)memcpy::destination#2
to:memcpy::@1
memcpy::@1: scope:[memcpy] from memcpy memcpy::@2
[94] memcpy::dst#2 = phi( memcpy/memcpy::dst#4, memcpy::@2/memcpy::dst#1 )
[94] memcpy::src#2 = phi( memcpy/memcpy::src#4, memcpy::@2/memcpy::src#1 )
[95] if(memcpy::src#2!=memcpy::src_end#0) goto memcpy::@2
[96] memcpy::dst#2 = phi( memcpy/memcpy::dst#4, memcpy::@2/memcpy::dst#1 )
[96] memcpy::src#2 = phi( memcpy/memcpy::src#4, memcpy::@2/memcpy::src#1 )
[97] if(memcpy::src#2!=memcpy::src_end#0) goto memcpy::@2
to:memcpy::@return
memcpy::@return: scope:[memcpy] from memcpy::@1
[96] return
[98] return
to:@return
memcpy::@2: scope:[memcpy] from memcpy::@1
[97] *memcpy::dst#2 = *memcpy::src#2
[98] memcpy::dst#1 = ++ memcpy::dst#2
[99] memcpy::src#1 = ++ memcpy::src#2
[99] *memcpy::dst#2 = *memcpy::src#2
[100] memcpy::dst#1 = ++ memcpy::dst#2
[101] memcpy::src#1 = ++ memcpy::src#2
to:memcpy::@1
void * memset(void *str , char c , unsigned int num)
memset: scope:[memset] from cscroll::@3 cscroll::@4
[100] memset::c#4 = phi( cscroll::@3/' ', cscroll::@4/LIGHT_BLUE )
[100] memset::str#3 = phi( cscroll::@3/(void *)DEFAULT_SCREEN+(unsigned int)$19*$28-$28, cscroll::@4/(void *)COLORRAM+(unsigned int)$19*$28-$28 )
[102] memset::c#4 = phi( cscroll::@3/' ', cscroll::@4/LIGHT_BLUE )
[102] memset::str#3 = phi( cscroll::@3/(void *)DEFAULT_SCREEN+(unsigned int)$19*$28-$28, cscroll::@4/(void *)COLORRAM+(unsigned int)$19*$28-$28 )
to:memset::@1
memset::@1: scope:[memset] from memset
[101] memset::end#0 = (char *)memset::str#3 + $28
[102] memset::dst#4 = (char *)memset::str#3
[103] memset::end#0 = (char *)memset::str#3 + $28
[104] memset::dst#4 = (char *)memset::str#3
to:memset::@2
memset::@2: scope:[memset] from memset::@1 memset::@3
[103] memset::dst#2 = phi( memset::@1/memset::dst#4, memset::@3/memset::dst#1 )
[104] if(memset::dst#2!=memset::end#0) goto memset::@3
[105] memset::dst#2 = phi( memset::@1/memset::dst#4, memset::@3/memset::dst#1 )
[106] if(memset::dst#2!=memset::end#0) goto memset::@3
to:memset::@return
memset::@return: scope:[memset] from memset::@2
[105] return
[107] return
to:@return
memset::@3: scope:[memset] from memset::@2
[106] *memset::dst#2 = memset::c#4
[107] memset::dst#1 = ++ memset::dst#2
[108] *memset::dst#2 = memset::c#4
[109] memset::dst#1 = ++ memset::dst#2
to:memset::@2

File diff suppressed because it is too large Load Diff

View File

@ -5,6 +5,7 @@ __constant char RADIX::BINARY = 2
__constant char RADIX::DECIMAL = $a
__constant char RADIX::HEXADECIMAL = $10
__constant char RADIX::OCTAL = 8
__constant unsigned int STACK_BASE = $103
void __start()
void clrscr()
char clrscr::c
@ -24,21 +25,15 @@ __constant char * const conio_c64_init::BASIC_CURSOR_LINE = (char *) 214
char conio_c64_init::line
char conio_c64_init::line#0 // reg byte x 11.0
char conio_c64_init::line#2 // reg byte x 22.0
__loadstore char conio_cursor_x // zp[1]:8 5179.6551724137935
__loadstore char conio_cursor_y // zp[1]:9 71115.75555555556
__loadstore char *conio_line_color // zp[2]:12 51400.20930232557
__loadstore char *conio_line_text // zp[2]:10 50232.02272727273
void cputc(char c)
__loadstore char conio_cursor_x // zp[1]:8 4845.4838709677415
__loadstore char conio_cursor_y // zp[1]:9 68089.55319148937
__loadstore char *conio_line_color // zp[2]:12 49115.75555555556
__loadstore char *conio_line_text // zp[2]:10 48048.02173913043
__stackcall void cputc(char c)
__constant char cputc::OFFSET_STACK_C = 0
char cputc::c
char cputc::c#0 // reg byte a 10501.5
char cputc::c#0 // reg byte a 15001.5
void cputln()
void cputs(const char *s)
char cputs::c
char cputs::c#1 // reg byte a 1001.0
const char *cputs::s
const char *cputs::s#0 // s zp[2]:2 500.5
const char *cputs::s#3 // s zp[2]:2 1552.0
const char *cputs::s#4 // s zp[2]:2 101.0
void cscroll()
void gotoxy(char x , char y)
char *gotoxy::$5 // zp[2]:18 202.0
@ -88,12 +83,20 @@ unsigned int memset::num
void *memset::return
void *memset::str
void *memset::str#3 // str zp[2]:6
void printf_str(void (*putc)(char) , const char *s)
char printf_str::c
char printf_str::c#1 // reg byte a 1001.0
void (*printf_str::putc)(char)
const char *printf_str::s
const char *printf_str::s#0 // s zp[2]:2 400.4
const char *printf_str::s#3 // s zp[2]:2 1552.0
const char *printf_str::s#4 // s zp[2]:2 101.0
reg byte x [ conio_c64_init::line#2 conio_c64_init::line#0 ]
reg byte x [ gotoxy::y#4 gotoxy::y#2 ]
reg byte x [ clrscr::l#2 clrscr::l#1 ]
reg byte y [ clrscr::c#2 clrscr::c#1 ]
zp[2]:2 [ cputs::s#3 cputs::s#4 cputs::s#0 clrscr::line_text#5 clrscr::line_text#1 ]
zp[2]:2 [ printf_str::s#3 printf_str::s#4 printf_str::s#0 clrscr::line_text#5 clrscr::line_text#1 ]
zp[2]:4 [ memcpy::source#2 memcpy::src#2 memcpy::src#4 memcpy::src#1 clrscr::line_cols#5 clrscr::line_cols#1 ]
zp[2]:6 [ memset::str#3 memset::dst#2 memset::dst#4 memset::dst#1 memcpy::destination#2 memcpy::dst#2 memcpy::dst#4 memcpy::dst#1 ]
reg byte x [ memset::c#4 ]
@ -101,9 +104,9 @@ zp[1]:8 [ conio_cursor_x ]
zp[1]:9 [ conio_cursor_y ]
zp[2]:10 [ conio_line_text ]
zp[2]:12 [ conio_line_color ]
reg byte a [ cputc::c#0 ]
zp[2]:14 [ gotoxy::$7 gotoxy::$9 gotoxy::line_offset#0 gotoxy::$6 ]
zp[2]:16 [ gotoxy::$8 ]
zp[2]:18 [ gotoxy::$5 ]
reg byte a [ cputs::c#1 ]
reg byte a [ cputc::c#0 ]
reg byte a [ printf_str::c#1 ]
zp[2]:20 [ memset::end#0 memcpy::src_end#0 ]

View File

@ -11,6 +11,7 @@
:BasicUpstart(__start)
.const LIGHT_BLUE = $e
.const OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS = 1
.const STACK_BASE = $103
.const SIZEOF_STRUCT_PRINTF_BUFFER_NUMBER = $c
/// Color Ram
.label COLORRAM = $d800
@ -18,13 +19,13 @@
.label DEFAULT_SCREEN = $400
// The number of bytes on the screen
// The current cursor x-position
.label conio_cursor_x = 9
.label conio_cursor_x = $b
// The current cursor y-position
.label conio_cursor_y = $a
.label conio_cursor_y = $c
// The current text cursor line start
.label conio_line_text = $b
.label conio_line_text = $d
// The current color cursor line start
.label conio_line_color = $d
.label conio_line_color = $f
.segment Code
__start: {
// __ma char conio_cursor_x = 0
@ -63,6 +64,37 @@ conio_c64_init: {
// }
rts
}
// Output one character at the current cursor position
// Moves the cursor forward. Scrolls the entire screen if needed
// void cputc(__register(A) char c)
cputc: {
.const OFFSET_STACK_C = 0
tsx
lda STACK_BASE+OFFSET_STACK_C,x
// if(c=='\n')
cmp #'\n'
beq __b1
// conio_line_text[conio_cursor_x] = c
ldy.z conio_cursor_x
sta (conio_line_text),y
// conio_line_color[conio_cursor_x] = conio_textcolor
lda #LIGHT_BLUE
sta (conio_line_color),y
// if(++conio_cursor_x==CONIO_WIDTH)
inc.z conio_cursor_x
lda #$28
cmp.z conio_cursor_x
bne __breturn
// cputln()
jsr cputln
__breturn:
// }
rts
__b1:
// cputln()
jsr cputln
rts
}
main: {
.label i = 2
// clrscr()
@ -82,21 +114,29 @@ main: {
ldx stars,y
jsr printf_uchar
// printf("%u %u\n", stars.star_x[i], stars.star_y[i])
lda #<cputc
sta.z printf_str.putc
lda #>cputc
sta.z printf_str.putc+1
lda #<s
sta.z cputs.s
sta.z printf_str.s
lda #>s
sta.z cputs.s+1
jsr cputs
sta.z printf_str.s+1
jsr printf_str
// printf("%u %u\n", stars.star_x[i], stars.star_y[i])
ldy.z i
ldx stars+5,y
jsr printf_uchar
// printf("%u %u\n", stars.star_x[i], stars.star_y[i])
lda #<cputc
sta.z printf_str.putc
lda #>cputc
sta.z printf_str.putc+1
lda #<s1
sta.z cputs.s
sta.z printf_str.s
lda #>s1
sta.z cputs.s+1
jsr cputs
sta.z printf_str.s+1
jsr printf_str
// for(char i=0;i<5;i++)
inc.z i
jmp __b1
@ -111,12 +151,12 @@ main: {
// void gotoxy(char x, __register(X) char y)
gotoxy: {
.const x = 0
.label __5 = $13
.label __6 = $f
.label __7 = $f
.label line_offset = $f
.label __8 = $11
.label __9 = $f
.label __5 = $15
.label __6 = $11
.label __7 = $11
.label line_offset = $11
.label __8 = $13
.label __9 = $11
// if(y>CONIO_HEIGHT)
cpx #$19+1
bcc __b2
@ -182,10 +222,38 @@ gotoxy: {
// }
rts
}
// Print a newline
cputln: {
// conio_line_text += CONIO_WIDTH
lda #$28
clc
adc.z conio_line_text
sta.z conio_line_text
bcc !+
inc.z conio_line_text+1
!:
// conio_line_color += CONIO_WIDTH
lda #$28
clc
adc.z conio_line_color
sta.z conio_line_color
bcc !+
inc.z conio_line_color+1
!:
// conio_cursor_x = 0
lda #0
sta.z conio_cursor_x
// conio_cursor_y++;
inc.z conio_cursor_y
// cscroll()
jsr cscroll
// }
rts
}
// clears the screen and moves the cursor to the upper left-hand corner of the screen.
clrscr: {
.label line_text = 3
.label line_cols = 7
.label line_text = 7
.label line_cols = 3
lda #<COLORRAM
sta.z line_cols
lda #>COLORRAM
@ -253,7 +321,7 @@ clrscr: {
jmp __b3
}
// Print an unsigned char using a specific format
// void printf_uchar(__register(X) char uvalue, char format_min_length, char format_justify_left, char format_sign_always, char format_zero_padding, char format_upper_case, char format_radix)
// void printf_uchar(void (*putc)(char), __register(X) char uvalue, char format_min_length, char format_justify_left, char format_sign_always, char format_zero_padding, char format_upper_case, char format_radix)
printf_uchar: {
// printf_buffer.sign = format.sign_always?'+':0
// Handle any sign
@ -262,17 +330,18 @@ printf_uchar: {
// uctoa(uvalue, printf_buffer.digits, format.radix)
// Format number into buffer
jsr uctoa
// printf_number_buffer(printf_buffer, format)
// printf_number_buffer(putc, printf_buffer, format)
lda printf_buffer
// Print using format
jsr printf_number_buffer
// }
rts
}
// Output a NUL-terminated string at the current cursor position
// void cputs(__zp(3) const char *s)
cputs: {
/// Print a NUL-terminated string
// void printf_str(__zp(7) void (*putc)(char), __zp(3) const char *s)
printf_str: {
.label s = 3
.label putc = 7
__b1:
// while(c=*s++)
ldy #0
@ -286,184 +355,13 @@ cputs: {
// }
rts
__b2:
// cputc(c)
jsr cputc
// putc(c)
pha
jsr icall1
pla
jmp __b1
}
// Converts unsigned number value to a string representing it in RADIX format.
// If the leading digits are zero they are not included in the string.
// - value : The number to be converted to RADIX
// - buffer : receives the string representing the number and zero-termination.
// - radix : The radix to convert the number to (from the enum RADIX)
// void uctoa(__register(X) char value, __zp(7) char *buffer, char radix)
uctoa: {
.label digit_value = $15
.label buffer = 7
.label digit = 5
.label started = 6
lda #<printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
sta.z buffer
lda #>printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
sta.z buffer+1
lda #0
sta.z started
sta.z digit
__b1:
// for( char digit=0; digit<max_digits-1; digit++ )
lda.z digit
cmp #3-1
bcc __b2
// *buffer++ = DIGITS[(char)value]
lda DIGITS,x
ldy #0
sta (buffer),y
// *buffer++ = DIGITS[(char)value];
inc.z buffer
bne !+
inc.z buffer+1
!:
// *buffer = 0
lda #0
tay
sta (buffer),y
// }
rts
__b2:
// unsigned char digit_value = digit_values[digit]
ldy.z digit
lda RADIX_DECIMAL_VALUES_CHAR,y
sta.z digit_value
// if (started || value >= digit_value)
lda.z started
bne __b5
cpx.z digit_value
bcs __b5
__b4:
// for( char digit=0; digit<max_digits-1; digit++ )
inc.z digit
jmp __b1
__b5:
// uctoa_append(buffer++, value, digit_value)
jsr uctoa_append
// uctoa_append(buffer++, value, digit_value)
// value = uctoa_append(buffer++, value, digit_value)
// value = uctoa_append(buffer++, value, digit_value);
inc.z buffer
bne !+
inc.z buffer+1
!:
lda #1
sta.z started
jmp __b4
}
// Print the contents of the number buffer using a specific format.
// This handles minimum length, zero-filling, and left/right justification from the format
// void printf_number_buffer(__register(A) char buffer_sign, char *buffer_digits, char format_min_length, char format_justify_left, char format_sign_always, char format_zero_padding, char format_upper_case, char format_radix)
printf_number_buffer: {
.label buffer_digits = printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
// if(buffer.sign)
cmp #0
beq __b2
// cputc(buffer.sign)
jsr cputc
__b2:
// cputs(buffer.digits)
lda #<buffer_digits
sta.z cputs.s
lda #>buffer_digits
sta.z cputs.s+1
jsr cputs
// }
rts
}
// Output one character at the current cursor position
// Moves the cursor forward. Scrolls the entire screen if needed
// void cputc(__register(A) char c)
cputc: {
// if(c=='\n')
cmp #'\n'
beq __b1
// conio_line_text[conio_cursor_x] = c
ldy.z conio_cursor_x
sta (conio_line_text),y
// conio_line_color[conio_cursor_x] = conio_textcolor
lda #LIGHT_BLUE
sta (conio_line_color),y
// if(++conio_cursor_x==CONIO_WIDTH)
inc.z conio_cursor_x
lda #$28
cmp.z conio_cursor_x
bne __breturn
// cputln()
jsr cputln
__breturn:
// }
rts
__b1:
// cputln()
jsr cputln
rts
}
// Used to convert a single digit of an unsigned number value to a string representation
// Counts a single digit up from '0' as long as the value is larger than sub.
// Each time the digit is increased sub is subtracted from value.
// - buffer : pointer to the char that receives the digit
// - value : The value where the digit will be derived from
// - sub : the value of a '1' in the digit. Subtracted continually while the digit is increased.
// (For decimal the subs used are 10000, 1000, 100, 10, 1)
// returns : the value reduced by sub * digit so that it is less than sub.
// __register(X) char uctoa_append(__zp(7) char *buffer, __register(X) char value, __zp($15) char sub)
uctoa_append: {
.label buffer = 7
.label sub = $15
ldy #0
__b1:
// while (value >= sub)
cpx.z sub
bcs __b2
// *buffer = DIGITS[digit]
lda DIGITS,y
ldy #0
sta (buffer),y
// }
rts
__b2:
// digit++;
iny
// value -= sub
txa
sec
sbc.z sub
tax
jmp __b1
}
// Print a newline
cputln: {
// conio_line_text += CONIO_WIDTH
lda #$28
clc
adc.z conio_line_text
sta.z conio_line_text
bcc !+
inc.z conio_line_text+1
!:
// conio_line_color += CONIO_WIDTH
lda #$28
clc
adc.z conio_line_color
sta.z conio_line_color
bcc !+
inc.z conio_line_color+1
!:
// conio_cursor_x = 0
lda #0
sta.z conio_cursor_x
// conio_cursor_y++;
inc.z conio_cursor_y
// cscroll()
jsr cscroll
// }
rts
icall1:
jmp (putc)
}
// Scroll the entire screen if the cursor is beyond the last line
cscroll: {
@ -527,15 +425,108 @@ cscroll: {
// }
rts
}
// Converts unsigned number value to a string representing it in RADIX format.
// If the leading digits are zero they are not included in the string.
// - value : The number to be converted to RADIX
// - buffer : receives the string representing the number and zero-termination.
// - radix : The radix to convert the number to (from the enum RADIX)
// void uctoa(__register(X) char value, __zp(7) char *buffer, char radix)
uctoa: {
.label digit_value = $17
.label buffer = 7
.label digit = 5
.label started = 6
lda #<printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
sta.z buffer
lda #>printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
sta.z buffer+1
lda #0
sta.z started
sta.z digit
__b1:
// for( char digit=0; digit<max_digits-1; digit++ )
lda.z digit
cmp #3-1
bcc __b2
// *buffer++ = DIGITS[(char)value]
lda DIGITS,x
ldy #0
sta (buffer),y
// *buffer++ = DIGITS[(char)value];
inc.z buffer
bne !+
inc.z buffer+1
!:
// *buffer = 0
lda #0
tay
sta (buffer),y
// }
rts
__b2:
// unsigned char digit_value = digit_values[digit]
ldy.z digit
lda RADIX_DECIMAL_VALUES_CHAR,y
sta.z digit_value
// if (started || value >= digit_value)
lda.z started
bne __b5
cpx.z digit_value
bcs __b5
__b4:
// for( char digit=0; digit<max_digits-1; digit++ )
inc.z digit
jmp __b1
__b5:
// uctoa_append(buffer++, value, digit_value)
jsr uctoa_append
// uctoa_append(buffer++, value, digit_value)
// value = uctoa_append(buffer++, value, digit_value)
// value = uctoa_append(buffer++, value, digit_value);
inc.z buffer
bne !+
inc.z buffer+1
!:
lda #1
sta.z started
jmp __b4
}
// Print the contents of the number buffer using a specific format.
// This handles minimum length, zero-filling, and left/right justification from the format
// void printf_number_buffer(void (*putc)(char), __register(A) char buffer_sign, char *buffer_digits, char format_min_length, char format_justify_left, char format_sign_always, char format_zero_padding, char format_upper_case, char format_radix)
printf_number_buffer: {
.label buffer_digits = printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
.label putc = cputc
// if(buffer.sign)
cmp #0
beq __b2
// putc(buffer.sign)
pha
jsr cputc
pla
__b2:
// printf_str(putc, buffer.digits)
lda #<putc
sta.z printf_str.putc
lda #>putc
sta.z printf_str.putc+1
lda #<buffer_digits
sta.z printf_str.s
lda #>buffer_digits
sta.z printf_str.s+1
jsr printf_str
// }
rts
}
// Copy block of memory (forwards)
// Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
// void * memcpy(__zp($18) void *destination, __zp(7) void *source, unsigned int num)
// void * memcpy(__zp($1a) void *destination, __zp(9) void *source, unsigned int num)
memcpy: {
.label src_end = $16
.label dst = $18
.label src = 7
.label source = 7
.label destination = $18
.label src_end = $18
.label dst = $1a
.label src = 9
.label source = 9
.label destination = $1a
// char* src_end = (char*)source+num
lda.z source
clc
@ -571,11 +562,11 @@ memcpy: {
jmp __b1
}
// Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
// void * memset(__zp(7) void *str, __register(X) char c, unsigned int num)
// void * memset(__zp(9) void *str, __register(X) char c, unsigned int num)
memset: {
.label end = $18
.label dst = 7
.label str = 7
.label end = $1a
.label dst = 9
.label str = 9
// char* end = (char*)str + num
lda #$28
clc
@ -606,6 +597,39 @@ memset: {
!:
jmp __b2
}
// Used to convert a single digit of an unsigned number value to a string representation
// Counts a single digit up from '0' as long as the value is larger than sub.
// Each time the digit is increased sub is subtracted from value.
// - buffer : pointer to the char that receives the digit
// - value : The value where the digit will be derived from
// - sub : the value of a '1' in the digit. Subtracted continually while the digit is increased.
// (For decimal the subs used are 10000, 1000, 100, 10, 1)
// returns : the value reduced by sub * digit so that it is less than sub.
// __register(X) char uctoa_append(__zp(7) char *buffer, __register(X) char value, __zp($17) char sub)
uctoa_append: {
.label buffer = 7
.label sub = $17
ldy #0
__b1:
// while (value >= sub)
cpx.z sub
bcs __b2
// *buffer = DIGITS[digit]
lda DIGITS,y
ldy #0
sta (buffer),y
// }
rts
__b2:
// digit++;
iny
// value -= sub
txa
sec
sbc.z sub
tax
jmp __b1
}
.segment Data
// The digits used for numbers
DIGITS: .text "0123456789abcdef"

View File

@ -35,320 +35,323 @@ conio_c64_init::@return: scope:[conio_c64_init] from conio_c64_init::@1
[15] return
to:@return
__stackcall void cputc(char c)
cputc: scope:[cputc] from printf_number_buffer::@3
[16] cputc::c#0 = stackidx(char,cputc::OFFSET_STACK_C)
[17] if(cputc::c#0=='
') goto cputc::@1
to:cputc::@2
cputc::@2: scope:[cputc] from cputc
[18] conio_line_text[conio_cursor_x] = cputc::c#0
[19] conio_line_color[conio_cursor_x] = LIGHT_BLUE
[20] conio_cursor_x = ++ conio_cursor_x
[21] if(conio_cursor_x!=$28) goto cputc::@return
to:cputc::@3
cputc::@3: scope:[cputc] from cputc::@2
[22] phi()
[23] call cputln
to:cputc::@return
cputc::@return: scope:[cputc] from cputc::@1 cputc::@2 cputc::@3
[24] return
to:@return
cputc::@1: scope:[cputc] from cputc
[25] phi()
[26] call cputln
to:cputc::@return
void main()
main: scope:[main] from __start::@1
[16] phi()
[17] call clrscr
[27] phi()
[28] call clrscr
to:main::@1
main::@1: scope:[main] from main main::@6
[18] main::i#2 = phi( main/0, main::@6/main::i#1 )
[19] if(main::i#2<5) goto main::@2
[29] main::i#2 = phi( main/0, main::@6/main::i#1 )
[30] if(main::i#2<5) goto main::@2
to:main::@return
main::@return: scope:[main] from main::@1
[20] return
[31] return
to:@return
main::@2: scope:[main] from main::@1
[21] printf_uchar::uvalue#0 = ((char *)&stars)[main::i#2]
[22] call printf_uchar
[32] printf_uchar::uvalue#0 = ((char *)&stars)[main::i#2]
[33] call printf_uchar
to:main::@3
main::@3: scope:[main] from main::@2
[23] phi()
[24] call cputs
[34] phi()
[35] call printf_str
to:main::@4
main::@4: scope:[main] from main::@3
[25] printf_uchar::uvalue#1 = ((char *)&stars+5)[main::i#2]
[26] call printf_uchar
[36] printf_uchar::uvalue#1 = ((char *)&stars+5)[main::i#2]
[37] call printf_uchar
to:main::@5
main::@5: scope:[main] from main::@4
[27] phi()
[28] call cputs
[38] phi()
[39] call printf_str
to:main::@6
main::@6: scope:[main] from main::@5
[29] main::i#1 = ++ main::i#2
[40] main::i#1 = ++ main::i#2
to:main::@1
void gotoxy(char x , char y)
gotoxy: scope:[gotoxy] from conio_c64_init::@1
[30] if(gotoxy::y#2<$19+1) goto gotoxy::@3
[41] if(gotoxy::y#2<$19+1) goto gotoxy::@3
to:gotoxy::@1
gotoxy::@3: scope:[gotoxy] from gotoxy
[31] phi()
[42] phi()
to:gotoxy::@1
gotoxy::@1: scope:[gotoxy] from gotoxy gotoxy::@3
[32] gotoxy::y#4 = phi( gotoxy::@3/gotoxy::y#2, gotoxy/0 )
[43] gotoxy::y#4 = phi( gotoxy::@3/gotoxy::y#2, gotoxy/0 )
to:gotoxy::@2
gotoxy::@2: scope:[gotoxy] from gotoxy::@1
[33] conio_cursor_x = gotoxy::x#2
[34] conio_cursor_y = gotoxy::y#4
[35] gotoxy::$7 = (unsigned int)gotoxy::y#4
[36] gotoxy::$8 = gotoxy::$7 << 2
[37] gotoxy::$9 = gotoxy::$8 + gotoxy::$7
[38] gotoxy::line_offset#0 = gotoxy::$9 << 3
[39] gotoxy::$5 = DEFAULT_SCREEN + gotoxy::line_offset#0
[40] conio_line_text = gotoxy::$5
[41] gotoxy::$6 = COLORRAM + gotoxy::line_offset#0
[42] conio_line_color = gotoxy::$6
[44] conio_cursor_x = gotoxy::x#2
[45] conio_cursor_y = gotoxy::y#4
[46] gotoxy::$7 = (unsigned int)gotoxy::y#4
[47] gotoxy::$8 = gotoxy::$7 << 2
[48] gotoxy::$9 = gotoxy::$8 + gotoxy::$7
[49] gotoxy::line_offset#0 = gotoxy::$9 << 3
[50] gotoxy::$5 = DEFAULT_SCREEN + gotoxy::line_offset#0
[51] conio_line_text = gotoxy::$5
[52] gotoxy::$6 = COLORRAM + gotoxy::line_offset#0
[53] conio_line_color = gotoxy::$6
to:gotoxy::@return
gotoxy::@return: scope:[gotoxy] from gotoxy::@2
[43] return
[54] return
to:@return
void cputln()
cputln: scope:[cputln] from cputc::@1 cputc::@3
[55] conio_line_text = conio_line_text + $28
[56] conio_line_color = conio_line_color + $28
[57] conio_cursor_x = 0
[58] conio_cursor_y = ++ conio_cursor_y
[59] call cscroll
to:cputln::@return
cputln::@return: scope:[cputln] from cputln
[60] return
to:@return
void clrscr()
clrscr: scope:[clrscr] from main
[44] phi()
[61] phi()
to:clrscr::@1
clrscr::@1: scope:[clrscr] from clrscr clrscr::@5
[45] clrscr::line_cols#5 = phi( clrscr/COLORRAM, clrscr::@5/clrscr::line_cols#1 )
[45] clrscr::line_text#5 = phi( clrscr/DEFAULT_SCREEN, clrscr::@5/clrscr::line_text#1 )
[45] clrscr::l#2 = phi( clrscr/0, clrscr::@5/clrscr::l#1 )
[46] if(clrscr::l#2<$19) goto clrscr::@3
[62] clrscr::line_cols#5 = phi( clrscr/COLORRAM, clrscr::@5/clrscr::line_cols#1 )
[62] clrscr::line_text#5 = phi( clrscr/DEFAULT_SCREEN, clrscr::@5/clrscr::line_text#1 )
[62] clrscr::l#2 = phi( clrscr/0, clrscr::@5/clrscr::l#1 )
[63] if(clrscr::l#2<$19) goto clrscr::@3
to:clrscr::@2
clrscr::@2: scope:[clrscr] from clrscr::@1
[47] conio_cursor_x = 0
[48] conio_cursor_y = 0
[49] conio_line_text = DEFAULT_SCREEN
[50] conio_line_color = COLORRAM
[64] conio_cursor_x = 0
[65] conio_cursor_y = 0
[66] conio_line_text = DEFAULT_SCREEN
[67] conio_line_color = COLORRAM
to:clrscr::@return
clrscr::@return: scope:[clrscr] from clrscr::@2
[51] return
[68] return
to:@return
clrscr::@3: scope:[clrscr] from clrscr::@1 clrscr::@4
[52] clrscr::c#2 = phi( clrscr::@1/0, clrscr::@4/clrscr::c#1 )
[53] if(clrscr::c#2<$28) goto clrscr::@4
[69] clrscr::c#2 = phi( clrscr::@1/0, clrscr::@4/clrscr::c#1 )
[70] if(clrscr::c#2<$28) goto clrscr::@4
to:clrscr::@5
clrscr::@5: scope:[clrscr] from clrscr::@3
[54] clrscr::line_text#1 = clrscr::line_text#5 + $28
[55] clrscr::line_cols#1 = clrscr::line_cols#5 + $28
[56] clrscr::l#1 = ++ clrscr::l#2
[71] clrscr::line_text#1 = clrscr::line_text#5 + $28
[72] clrscr::line_cols#1 = clrscr::line_cols#5 + $28
[73] clrscr::l#1 = ++ clrscr::l#2
to:clrscr::@1
clrscr::@4: scope:[clrscr] from clrscr::@3
[57] clrscr::line_text#5[clrscr::c#2] = ' '
[58] clrscr::line_cols#5[clrscr::c#2] = LIGHT_BLUE
[59] clrscr::c#1 = ++ clrscr::c#2
[74] clrscr::line_text#5[clrscr::c#2] = ' '
[75] clrscr::line_cols#5[clrscr::c#2] = LIGHT_BLUE
[76] clrscr::c#1 = ++ clrscr::c#2
to:clrscr::@3
void printf_uchar(char uvalue , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
void printf_uchar(void (*putc)(char) , char uvalue , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
printf_uchar: scope:[printf_uchar] from main::@2 main::@4
[60] printf_uchar::uvalue#2 = phi( main::@2/printf_uchar::uvalue#0, main::@4/printf_uchar::uvalue#1 )
[77] printf_uchar::uvalue#2 = phi( main::@2/printf_uchar::uvalue#0, main::@4/printf_uchar::uvalue#1 )
to:printf_uchar::@1
printf_uchar::@1: scope:[printf_uchar] from printf_uchar
[61] *((char *)&printf_buffer) = 0
[62] uctoa::value#1 = printf_uchar::uvalue#2
[63] call uctoa
[78] *((char *)&printf_buffer) = 0
[79] uctoa::value#1 = printf_uchar::uvalue#2
[80] call uctoa
to:printf_uchar::@2
printf_uchar::@2: scope:[printf_uchar] from printf_uchar::@1
[64] printf_number_buffer::buffer_sign#0 = *((char *)&printf_buffer)
[65] call printf_number_buffer
[81] printf_number_buffer::buffer_sign#0 = *((char *)&printf_buffer)
[82] call printf_number_buffer
to:printf_uchar::@return
printf_uchar::@return: scope:[printf_uchar] from printf_uchar::@2
[66] return
[83] return
to:@return
void cputs(const char *s)
cputs: scope:[cputs] from main::@3 main::@5 printf_number_buffer::@2
[67] cputs::s#5 = phi( main::@3/main::s, main::@5/main::s1, printf_number_buffer::@2/printf_number_buffer::buffer_digits#0 )
to:cputs::@1
cputs::@1: scope:[cputs] from cputs cputs::@2
[68] cputs::s#4 = phi( cputs/cputs::s#5, cputs::@2/cputs::s#0 )
[69] cputs::c#1 = *cputs::s#4
[70] cputs::s#0 = ++ cputs::s#4
[71] if(0!=cputs::c#1) goto cputs::@2
to:cputs::@return
cputs::@return: scope:[cputs] from cputs::@1
[72] return
to:@return
cputs::@2: scope:[cputs] from cputs::@1
[73] cputc::c#0 = cputs::c#1
[74] call cputc
to:cputs::@1
void uctoa(char value , char *buffer , char radix)
uctoa: scope:[uctoa] from printf_uchar::@1
[75] phi()
to:uctoa::@1
uctoa::@1: scope:[uctoa] from uctoa uctoa::@4
[76] uctoa::buffer#11 = phi( uctoa::@4/uctoa::buffer#14, uctoa/(char *)&printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS )
[76] uctoa::started#2 = phi( uctoa::@4/uctoa::started#4, uctoa/0 )
[76] uctoa::value#2 = phi( uctoa::@4/uctoa::value#6, uctoa/uctoa::value#1 )
[76] uctoa::digit#2 = phi( uctoa::@4/uctoa::digit#1, uctoa/0 )
[77] if(uctoa::digit#2<3-1) goto uctoa::@2
to:uctoa::@3
uctoa::@3: scope:[uctoa] from uctoa::@1
[78] *uctoa::buffer#11 = DIGITS[uctoa::value#2]
[79] uctoa::buffer#3 = ++ uctoa::buffer#11
[80] *uctoa::buffer#3 = 0
to:uctoa::@return
uctoa::@return: scope:[uctoa] from uctoa::@3
[81] return
to:@return
uctoa::@2: scope:[uctoa] from uctoa::@1
[82] uctoa::digit_value#0 = RADIX_DECIMAL_VALUES_CHAR[uctoa::digit#2]
[83] if(0!=uctoa::started#2) goto uctoa::@5
to:uctoa::@7
uctoa::@7: scope:[uctoa] from uctoa::@2
[84] if(uctoa::value#2>=uctoa::digit_value#0) goto uctoa::@5
to:uctoa::@4
uctoa::@4: scope:[uctoa] from uctoa::@6 uctoa::@7
[85] uctoa::buffer#14 = phi( uctoa::@7/uctoa::buffer#11, uctoa::@6/uctoa::buffer#4 )
[85] uctoa::started#4 = phi( uctoa::@7/uctoa::started#2, uctoa::@6/1 )
[85] uctoa::value#6 = phi( uctoa::@7/uctoa::value#2, uctoa::@6/uctoa::value#0 )
[86] uctoa::digit#1 = ++ uctoa::digit#2
to:uctoa::@1
uctoa::@5: scope:[uctoa] from uctoa::@2 uctoa::@7
[87] uctoa_append::buffer#0 = uctoa::buffer#11
[88] uctoa_append::value#0 = uctoa::value#2
[89] uctoa_append::sub#0 = uctoa::digit_value#0
[90] call uctoa_append
[91] uctoa_append::return#0 = uctoa_append::value#2
to:uctoa::@6
uctoa::@6: scope:[uctoa] from uctoa::@5
[92] uctoa::value#0 = uctoa_append::return#0
[93] uctoa::buffer#4 = ++ uctoa::buffer#11
to:uctoa::@4
void printf_number_buffer(char buffer_sign , char *buffer_digits , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
printf_number_buffer: scope:[printf_number_buffer] from printf_uchar::@2
[94] phi()
to:printf_number_buffer::@1
printf_number_buffer::@1: scope:[printf_number_buffer] from printf_number_buffer
[95] if(0==printf_number_buffer::buffer_sign#0) goto printf_number_buffer::@2
to:printf_number_buffer::@3
printf_number_buffer::@3: scope:[printf_number_buffer] from printf_number_buffer::@1
[96] cputc::c#2 = printf_number_buffer::buffer_sign#0
[97] call cputc
to:printf_number_buffer::@2
printf_number_buffer::@2: scope:[printf_number_buffer] from printf_number_buffer::@1 printf_number_buffer::@3
[98] phi()
[99] call cputs
to:printf_number_buffer::@return
printf_number_buffer::@return: scope:[printf_number_buffer] from printf_number_buffer::@2
[100] return
to:@return
void cputc(char c)
cputc: scope:[cputc] from cputs::@2 printf_number_buffer::@3
[101] cputc::c#3 = phi( cputs::@2/cputc::c#0, printf_number_buffer::@3/cputc::c#2 )
[102] if(cputc::c#3=='
') goto cputc::@1
to:cputc::@2
cputc::@2: scope:[cputc] from cputc
[103] conio_line_text[conio_cursor_x] = cputc::c#3
[104] conio_line_color[conio_cursor_x] = LIGHT_BLUE
[105] conio_cursor_x = ++ conio_cursor_x
[106] if(conio_cursor_x!=$28) goto cputc::@return
to:cputc::@3
cputc::@3: scope:[cputc] from cputc::@2
[107] phi()
[108] call cputln
to:cputc::@return
cputc::@return: scope:[cputc] from cputc::@1 cputc::@2 cputc::@3
[109] return
to:@return
cputc::@1: scope:[cputc] from cputc
[110] phi()
[111] call cputln
to:cputc::@return
char uctoa_append(char *buffer , char value , char sub)
uctoa_append: scope:[uctoa_append] from uctoa::@5
[112] phi()
to:uctoa_append::@1
uctoa_append::@1: scope:[uctoa_append] from uctoa_append uctoa_append::@2
[113] uctoa_append::digit#2 = phi( uctoa_append/0, uctoa_append::@2/uctoa_append::digit#1 )
[113] uctoa_append::value#2 = phi( uctoa_append/uctoa_append::value#0, uctoa_append::@2/uctoa_append::value#1 )
[114] if(uctoa_append::value#2>=uctoa_append::sub#0) goto uctoa_append::@2
to:uctoa_append::@3
uctoa_append::@3: scope:[uctoa_append] from uctoa_append::@1
[115] *uctoa_append::buffer#0 = DIGITS[uctoa_append::digit#2]
to:uctoa_append::@return
uctoa_append::@return: scope:[uctoa_append] from uctoa_append::@3
[116] return
to:@return
uctoa_append::@2: scope:[uctoa_append] from uctoa_append::@1
[117] uctoa_append::digit#1 = ++ uctoa_append::digit#2
[118] uctoa_append::value#1 = uctoa_append::value#2 - uctoa_append::sub#0
to:uctoa_append::@1
void cputln()
cputln: scope:[cputln] from cputc::@1 cputc::@3
[119] conio_line_text = conio_line_text + $28
[120] conio_line_color = conio_line_color + $28
[121] conio_cursor_x = 0
[122] conio_cursor_y = ++ conio_cursor_y
[123] call cscroll
to:cputln::@return
cputln::@return: scope:[cputln] from cputln
[124] return
void printf_str(void (*putc)(char) , const char *s)
printf_str: scope:[printf_str] from main::@3 main::@5 printf_number_buffer::@2
[84] printf_str::putc#5 = phi( main::@3/&cputc, main::@5/&cputc, printf_number_buffer::@2/printf_number_buffer::putc#0 )
[84] printf_str::s#5 = phi( main::@3/main::s, main::@5/main::s1, printf_number_buffer::@2/printf_number_buffer::buffer_digits#0 )
to:printf_str::@1
printf_str::@1: scope:[printf_str] from printf_str printf_str::@2
[85] printf_str::s#4 = phi( printf_str/printf_str::s#5, printf_str::@2/printf_str::s#0 )
[86] printf_str::c#1 = *printf_str::s#4
[87] printf_str::s#0 = ++ printf_str::s#4
[88] if(0!=printf_str::c#1) goto printf_str::@2
to:printf_str::@return
printf_str::@return: scope:[printf_str] from printf_str::@1
[89] return
to:@return
printf_str::@2: scope:[printf_str] from printf_str::@1
[90] stackpush(char) = printf_str::c#1
[91] callexecute *printf_str::putc#5
sideeffect stackpullbytes(1)
to:printf_str::@1
void cscroll()
cscroll: scope:[cscroll] from cputln
[125] if(conio_cursor_y!=$19) goto cscroll::@return
[93] if(conio_cursor_y!=$19) goto cscroll::@return
to:cscroll::@1
cscroll::@1: scope:[cscroll] from cscroll
[126] phi()
[127] call memcpy
[94] phi()
[95] call memcpy
to:cscroll::@2
cscroll::@2: scope:[cscroll] from cscroll::@1
[128] phi()
[129] call memcpy
[96] phi()
[97] call memcpy
to:cscroll::@3
cscroll::@3: scope:[cscroll] from cscroll::@2
[130] phi()
[131] call memset
[98] phi()
[99] call memset
to:cscroll::@4
cscroll::@4: scope:[cscroll] from cscroll::@3
[132] phi()
[133] call memset
[100] phi()
[101] call memset
to:cscroll::@5
cscroll::@5: scope:[cscroll] from cscroll::@4
[134] conio_line_text = conio_line_text - $28
[135] conio_line_color = conio_line_color - $28
[136] conio_cursor_y = -- conio_cursor_y
[102] conio_line_text = conio_line_text - $28
[103] conio_line_color = conio_line_color - $28
[104] conio_cursor_y = -- conio_cursor_y
to:cscroll::@return
cscroll::@return: scope:[cscroll] from cscroll cscroll::@5
[137] return
[105] return
to:@return
void uctoa(char value , char *buffer , char radix)
uctoa: scope:[uctoa] from printf_uchar::@1
[106] phi()
to:uctoa::@1
uctoa::@1: scope:[uctoa] from uctoa uctoa::@4
[107] uctoa::buffer#11 = phi( uctoa::@4/uctoa::buffer#14, uctoa/(char *)&printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS )
[107] uctoa::started#2 = phi( uctoa::@4/uctoa::started#4, uctoa/0 )
[107] uctoa::value#2 = phi( uctoa::@4/uctoa::value#6, uctoa/uctoa::value#1 )
[107] uctoa::digit#2 = phi( uctoa::@4/uctoa::digit#1, uctoa/0 )
[108] if(uctoa::digit#2<3-1) goto uctoa::@2
to:uctoa::@3
uctoa::@3: scope:[uctoa] from uctoa::@1
[109] *uctoa::buffer#11 = DIGITS[uctoa::value#2]
[110] uctoa::buffer#3 = ++ uctoa::buffer#11
[111] *uctoa::buffer#3 = 0
to:uctoa::@return
uctoa::@return: scope:[uctoa] from uctoa::@3
[112] return
to:@return
uctoa::@2: scope:[uctoa] from uctoa::@1
[113] uctoa::digit_value#0 = RADIX_DECIMAL_VALUES_CHAR[uctoa::digit#2]
[114] if(0!=uctoa::started#2) goto uctoa::@5
to:uctoa::@7
uctoa::@7: scope:[uctoa] from uctoa::@2
[115] if(uctoa::value#2>=uctoa::digit_value#0) goto uctoa::@5
to:uctoa::@4
uctoa::@4: scope:[uctoa] from uctoa::@6 uctoa::@7
[116] uctoa::buffer#14 = phi( uctoa::@7/uctoa::buffer#11, uctoa::@6/uctoa::buffer#4 )
[116] uctoa::started#4 = phi( uctoa::@7/uctoa::started#2, uctoa::@6/1 )
[116] uctoa::value#6 = phi( uctoa::@7/uctoa::value#2, uctoa::@6/uctoa::value#0 )
[117] uctoa::digit#1 = ++ uctoa::digit#2
to:uctoa::@1
uctoa::@5: scope:[uctoa] from uctoa::@2 uctoa::@7
[118] uctoa_append::buffer#0 = uctoa::buffer#11
[119] uctoa_append::value#0 = uctoa::value#2
[120] uctoa_append::sub#0 = uctoa::digit_value#0
[121] call uctoa_append
[122] uctoa_append::return#0 = uctoa_append::value#2
to:uctoa::@6
uctoa::@6: scope:[uctoa] from uctoa::@5
[123] uctoa::value#0 = uctoa_append::return#0
[124] uctoa::buffer#4 = ++ uctoa::buffer#11
to:uctoa::@4
void printf_number_buffer(void (*putc)(char) , char buffer_sign , char *buffer_digits , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
printf_number_buffer: scope:[printf_number_buffer] from printf_uchar::@2
[125] phi()
to:printf_number_buffer::@1
printf_number_buffer::@1: scope:[printf_number_buffer] from printf_number_buffer
[126] if(0==printf_number_buffer::buffer_sign#0) goto printf_number_buffer::@2
to:printf_number_buffer::@3
printf_number_buffer::@3: scope:[printf_number_buffer] from printf_number_buffer::@1
[127] stackpush(char) = printf_number_buffer::buffer_sign#0
[128] callexecute cputc
sideeffect stackpullbytes(1)
to:printf_number_buffer::@2
printf_number_buffer::@2: scope:[printf_number_buffer] from printf_number_buffer::@1 printf_number_buffer::@3
[130] phi()
[131] call printf_str
to:printf_number_buffer::@return
printf_number_buffer::@return: scope:[printf_number_buffer] from printf_number_buffer::@2
[132] return
to:@return
void * memcpy(void *destination , void *source , unsigned int num)
memcpy: scope:[memcpy] from cscroll::@1 cscroll::@2
[138] memcpy::destination#2 = phi( cscroll::@1/(void *)DEFAULT_SCREEN, cscroll::@2/(void *)COLORRAM )
[138] memcpy::source#2 = phi( cscroll::@1/(void *)DEFAULT_SCREEN+$28, cscroll::@2/(void *)COLORRAM+$28 )
[139] memcpy::src_end#0 = (char *)memcpy::source#2 + (unsigned int)$19*$28-$28
[140] memcpy::src#4 = (char *)memcpy::source#2
[141] memcpy::dst#4 = (char *)memcpy::destination#2
[133] memcpy::destination#2 = phi( cscroll::@1/(void *)DEFAULT_SCREEN, cscroll::@2/(void *)COLORRAM )
[133] memcpy::source#2 = phi( cscroll::@1/(void *)DEFAULT_SCREEN+$28, cscroll::@2/(void *)COLORRAM+$28 )
[134] memcpy::src_end#0 = (char *)memcpy::source#2 + (unsigned int)$19*$28-$28
[135] memcpy::src#4 = (char *)memcpy::source#2
[136] memcpy::dst#4 = (char *)memcpy::destination#2
to:memcpy::@1
memcpy::@1: scope:[memcpy] from memcpy memcpy::@2
[142] memcpy::dst#2 = phi( memcpy/memcpy::dst#4, memcpy::@2/memcpy::dst#1 )
[142] memcpy::src#2 = phi( memcpy/memcpy::src#4, memcpy::@2/memcpy::src#1 )
[143] if(memcpy::src#2!=memcpy::src_end#0) goto memcpy::@2
[137] memcpy::dst#2 = phi( memcpy/memcpy::dst#4, memcpy::@2/memcpy::dst#1 )
[137] memcpy::src#2 = phi( memcpy/memcpy::src#4, memcpy::@2/memcpy::src#1 )
[138] if(memcpy::src#2!=memcpy::src_end#0) goto memcpy::@2
to:memcpy::@return
memcpy::@return: scope:[memcpy] from memcpy::@1
[144] return
[139] return
to:@return
memcpy::@2: scope:[memcpy] from memcpy::@1
[145] *memcpy::dst#2 = *memcpy::src#2
[146] memcpy::dst#1 = ++ memcpy::dst#2
[147] memcpy::src#1 = ++ memcpy::src#2
[140] *memcpy::dst#2 = *memcpy::src#2
[141] memcpy::dst#1 = ++ memcpy::dst#2
[142] memcpy::src#1 = ++ memcpy::src#2
to:memcpy::@1
void * memset(void *str , char c , unsigned int num)
memset: scope:[memset] from cscroll::@3 cscroll::@4
[148] memset::c#4 = phi( cscroll::@3/' ', cscroll::@4/LIGHT_BLUE )
[148] memset::str#3 = phi( cscroll::@3/(void *)DEFAULT_SCREEN+(unsigned int)$19*$28-$28, cscroll::@4/(void *)COLORRAM+(unsigned int)$19*$28-$28 )
[143] memset::c#4 = phi( cscroll::@3/' ', cscroll::@4/LIGHT_BLUE )
[143] memset::str#3 = phi( cscroll::@3/(void *)DEFAULT_SCREEN+(unsigned int)$19*$28-$28, cscroll::@4/(void *)COLORRAM+(unsigned int)$19*$28-$28 )
to:memset::@1
memset::@1: scope:[memset] from memset
[149] memset::end#0 = (char *)memset::str#3 + $28
[150] memset::dst#4 = (char *)memset::str#3
[144] memset::end#0 = (char *)memset::str#3 + $28
[145] memset::dst#4 = (char *)memset::str#3
to:memset::@2
memset::@2: scope:[memset] from memset::@1 memset::@3
[151] memset::dst#2 = phi( memset::@1/memset::dst#4, memset::@3/memset::dst#1 )
[152] if(memset::dst#2!=memset::end#0) goto memset::@3
[146] memset::dst#2 = phi( memset::@1/memset::dst#4, memset::@3/memset::dst#1 )
[147] if(memset::dst#2!=memset::end#0) goto memset::@3
to:memset::@return
memset::@return: scope:[memset] from memset::@2
[153] return
[148] return
to:@return
memset::@3: scope:[memset] from memset::@2
[154] *memset::dst#2 = memset::c#4
[155] memset::dst#1 = ++ memset::dst#2
[149] *memset::dst#2 = memset::c#4
[150] memset::dst#1 = ++ memset::dst#2
to:memset::@2
char uctoa_append(char *buffer , char value , char sub)
uctoa_append: scope:[uctoa_append] from uctoa::@5
[151] phi()
to:uctoa_append::@1
uctoa_append::@1: scope:[uctoa_append] from uctoa_append uctoa_append::@2
[152] uctoa_append::digit#2 = phi( uctoa_append/0, uctoa_append::@2/uctoa_append::digit#1 )
[152] uctoa_append::value#2 = phi( uctoa_append/uctoa_append::value#0, uctoa_append::@2/uctoa_append::value#1 )
[153] if(uctoa_append::value#2>=uctoa_append::sub#0) goto uctoa_append::@2
to:uctoa_append::@3
uctoa_append::@3: scope:[uctoa_append] from uctoa_append::@1
[154] *uctoa_append::buffer#0 = DIGITS[uctoa_append::digit#2]
to:uctoa_append::@return
uctoa_append::@return: scope:[uctoa_append] from uctoa_append::@3
[155] return
to:@return
uctoa_append::@2: scope:[uctoa_append] from uctoa_append::@1
[156] uctoa_append::digit#1 = ++ uctoa_append::digit#2
[157] uctoa_append::value#1 = uctoa_append::value#2 - uctoa_append::sub#0
to:uctoa_append::@1

File diff suppressed because one or more lines are too long

View File

@ -9,6 +9,7 @@ __constant char RADIX::HEXADECIMAL = $10
__constant char RADIX::OCTAL = 8
__constant char RADIX_DECIMAL_VALUES_CHAR[] = { $64, $a }
__constant char SIZEOF_STRUCT_PRINTF_BUFFER_NUMBER = $c
__constant unsigned int STACK_BASE = $103
void __start()
void clrscr()
char clrscr::c
@ -18,42 +19,34 @@ char clrscr::l
char clrscr::l#1 // reg byte x 2002.0
char clrscr::l#2 // reg byte x 333.6666666666667
char *clrscr::line_cols
char *clrscr::line_cols#1 // line_cols zp[2]:7 1001.0
char *clrscr::line_cols#5 // line_cols zp[2]:7 1500.375
char *clrscr::line_cols#1 // line_cols zp[2]:3 1001.0
char *clrscr::line_cols#5 // line_cols zp[2]:3 1500.375
char *clrscr::line_text
char *clrscr::line_text#1 // line_text zp[2]:3 667.3333333333334
char *clrscr::line_text#5 // line_text zp[2]:3 1714.7142857142858
char *clrscr::line_text#1 // line_text zp[2]:7 667.3333333333334
char *clrscr::line_text#5 // line_text zp[2]:7 1714.7142857142858
void conio_c64_init()
__constant char * const conio_c64_init::BASIC_CURSOR_LINE = (char *) 214
char conio_c64_init::line
char conio_c64_init::line#0 // reg byte x 11.0
char conio_c64_init::line#2 // reg byte x 22.0
__loadstore char conio_cursor_x // zp[1]:9 2.8846157884615384E7
__loadstore char conio_cursor_y // zp[1]:10 4.705882383676472E8
__loadstore char *conio_line_color // zp[2]:13 3.348484880151515E8
__loadstore char *conio_line_text // zp[2]:11 3.2985074938805974E8
void cputc(char c)
__loadstore char conio_cursor_x // zp[1]:11 33338.0
__loadstore char conio_cursor_y // zp[1]:12 524593.5901639345
__loadstore char *conio_line_color // zp[2]:15 374579.81355932204
__loadstore char *conio_line_text // zp[2]:13 368336.81666666665
__stackcall void cputc(char c)
__constant char cputc::OFFSET_STACK_C = 0
char cputc::c
char cputc::c#0 // reg byte a 2.0000002E7
char cputc::c#2 // reg byte a 20002.0
char cputc::c#3 // reg byte a 1.05005002E8
char cputc::c#0 // reg byte a 150001.5
void cputln()
void cputs(const char *s)
char cputs::c
char cputs::c#1 // reg byte a 1.0000001E7
const char *cputs::s
const char *cputs::s#0 // s zp[2]:3 5000000.5
const char *cputs::s#4 // s zp[2]:3 1.5050002E7
const char *cputs::s#5 // s zp[2]:3 100001.0
void cscroll()
void gotoxy(char x , char y)
char *gotoxy::$5 // zp[2]:19 202.0
char *gotoxy::$6 // zp[2]:15 202.0
unsigned int gotoxy::$7 // zp[2]:15 151.5
unsigned int gotoxy::$8 // zp[2]:17 202.0
unsigned int gotoxy::$9 // zp[2]:15 202.0
char *gotoxy::$5 // zp[2]:21 202.0
char *gotoxy::$6 // zp[2]:17 202.0
unsigned int gotoxy::$7 // zp[2]:17 151.5
unsigned int gotoxy::$8 // zp[2]:19 202.0
unsigned int gotoxy::$9 // zp[2]:17 202.0
unsigned int gotoxy::line_offset
unsigned int gotoxy::line_offset#0 // line_offset zp[2]:15 101.0
unsigned int gotoxy::line_offset#0 // line_offset zp[2]:17 101.0
char gotoxy::x
__constant char gotoxy::x#2 = 0 // x
char gotoxy::y
@ -68,36 +61,36 @@ __constant char main::s1[2] = "
"
void * memcpy(void *destination , void *source , unsigned int num)
void *memcpy::destination
void *memcpy::destination#2 // destination zp[2]:24
void *memcpy::destination#2 // destination zp[2]:26
char *memcpy::dst
char *memcpy::dst#1 // dst zp[2]:24 1.00000000000001E14
char *memcpy::dst#2 // dst zp[2]:24 1.0003333333333467E14
char *memcpy::dst#4 // dst zp[2]:24 2.00000000002E11
char *memcpy::dst#1 // dst zp[2]:26 1.0000000001E10
char *memcpy::dst#2 // dst zp[2]:26 1.0033333334666666E10
char *memcpy::dst#4 // dst zp[2]:26 2.00000002E8
unsigned int memcpy::num
void *memcpy::return
void *memcpy::source
void *memcpy::source#2 // source zp[2]:7
void *memcpy::source#2 // source zp[2]:9
char *memcpy::src
char *memcpy::src#1 // src zp[2]:7 2.00000000000002E14
char *memcpy::src#2 // src zp[2]:7 1.0002500000000125E14
char *memcpy::src#4 // src zp[2]:7 1.00000000001E11
char *memcpy::src#1 // src zp[2]:9 2.0000000002E10
char *memcpy::src#2 // src zp[2]:9 1.002500000125E10
char *memcpy::src#4 // src zp[2]:9 1.00000001E8
char *memcpy::src_end
char *memcpy::src_end#0 // src_end zp[2]:22 1.251250000000025E13
char *memcpy::src_end#0 // src_end zp[2]:24 1.26250000025E9
void * memset(void *str , char c , unsigned int num)
char memset::c
char memset::c#4 // reg byte x 1.4285714285714428E13
char memset::c#4 // reg byte x 1.4285714287142856E9
char *memset::dst
char *memset::dst#1 // dst zp[2]:7 2.00000000000002E14
char *memset::dst#2 // dst zp[2]:7 1.3336666666666834E14
char *memset::dst#4 // dst zp[2]:7 2.00000000002E11
char *memset::dst#1 // dst zp[2]:9 2.0000000002E10
char *memset::dst#2 // dst zp[2]:9 1.3366666668333332E10
char *memset::dst#4 // dst zp[2]:9 2.00000002E8
char *memset::end
char *memset::end#0 // end zp[2]:24 1.6683333333333668E13
char *memset::end#0 // end zp[2]:26 1.6833333336666665E9
unsigned int memset::num
void *memset::return
void *memset::str
void *memset::str#3 // str zp[2]:7
void *memset::str#3 // str zp[2]:9
__loadstore struct printf_buffer_number printf_buffer = {} // mem[12]
void printf_number_buffer(char buffer_sign , char *buffer_digits , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
void printf_number_buffer(void (*putc)(char) , char buffer_sign , char *buffer_digits , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
struct printf_buffer_number printf_number_buffer::buffer
char *printf_number_buffer::buffer_digits
__constant char *printf_number_buffer::buffer_digits#0 = (char *)&printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS // buffer_digits
@ -112,7 +105,18 @@ char printf_number_buffer::format_upper_case
char printf_number_buffer::format_zero_padding
signed char printf_number_buffer::len
signed char printf_number_buffer::padding
void printf_uchar(char uvalue , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
void (*printf_number_buffer::putc)(char)
__constant void (*printf_number_buffer::putc#0)(char) = &cputc // putc
void printf_str(void (*putc)(char) , const char *s)
char printf_str::c
char printf_str::c#1 // reg byte a 1.0000001E7
void (*printf_str::putc)(char)
void (*printf_str::putc#5)(char) // putc zp[2]:7
const char *printf_str::s
const char *printf_str::s#0 // s zp[2]:3 1.0000001E7
const char *printf_str::s#4 // s zp[2]:3 1.5050002E7
const char *printf_str::s#5 // s zp[2]:3 100001.0
void printf_uchar(void (*putc)(char) , char uvalue , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
struct printf_format_number printf_uchar::format
char printf_uchar::format_justify_left
char printf_uchar::format_min_length
@ -120,6 +124,7 @@ char printf_uchar::format_radix
char printf_uchar::format_sign_always
char printf_uchar::format_upper_case
char printf_uchar::format_zero_padding
void (*printf_uchar::putc)(char)
char printf_uchar::uvalue
char printf_uchar::uvalue#0 // reg byte x 202.0
char printf_uchar::uvalue#1 // reg byte x 202.0
@ -135,7 +140,7 @@ char uctoa::digit
char uctoa::digit#1 // digit zp[1]:5 2000002.0
char uctoa::digit#2 // digit zp[1]:5 307692.6153846154
char uctoa::digit_value
char uctoa::digit_value#0 // digit_value zp[1]:21 600000.6000000001
char uctoa::digit_value#0 // digit_value zp[1]:23 600000.6000000001
char *uctoa::digit_values
char uctoa::max_digits
char uctoa::radix
@ -156,7 +161,7 @@ char uctoa_append::digit#2 // reg byte y 1.00050000015E10
char uctoa_append::return
char uctoa_append::return#0 // reg byte x 2000002.0
char uctoa_append::sub
char uctoa_append::sub#0 // sub zp[1]:21 3.3335000005E9
char uctoa_append::sub#0 // sub zp[1]:23 3.3335000005E9
char uctoa_append::value
char uctoa_append::value#0 // reg byte x 3666667.333333333
char uctoa_append::value#1 // reg byte x 2.0000000002E10
@ -168,27 +173,28 @@ reg byte x [ gotoxy::y#4 gotoxy::y#2 ]
reg byte x [ clrscr::l#2 clrscr::l#1 ]
reg byte y [ clrscr::c#2 clrscr::c#1 ]
reg byte x [ printf_uchar::uvalue#2 printf_uchar::uvalue#0 printf_uchar::uvalue#1 ]
zp[2]:3 [ cputs::s#4 cputs::s#5 cputs::s#0 clrscr::line_text#5 clrscr::line_text#1 ]
zp[2]:3 [ printf_str::s#4 printf_str::s#5 printf_str::s#0 clrscr::line_cols#5 clrscr::line_cols#1 ]
zp[1]:5 [ uctoa::digit#2 uctoa::digit#1 ]
reg byte x [ uctoa::value#2 uctoa::value#6 uctoa::value#1 uctoa::value#0 ]
zp[1]:6 [ uctoa::started#2 uctoa::started#4 ]
reg byte a [ cputc::c#3 cputc::c#0 cputc::c#2 ]
zp[2]:7 [ uctoa::buffer#11 uctoa::buffer#14 uctoa::buffer#4 uctoa::buffer#3 uctoa_append::buffer#0 printf_str::putc#5 clrscr::line_text#5 clrscr::line_text#1 ]
zp[2]:9 [ memset::str#3 memset::dst#2 memset::dst#4 memset::dst#1 memcpy::source#2 memcpy::src#2 memcpy::src#4 memcpy::src#1 ]
reg byte x [ memset::c#4 ]
reg byte x [ uctoa_append::value#2 uctoa_append::value#0 uctoa_append::value#1 ]
reg byte y [ uctoa_append::digit#2 uctoa_append::digit#1 ]
zp[2]:7 [ memset::str#3 memset::dst#2 memset::dst#4 memset::dst#1 memcpy::source#2 memcpy::src#2 memcpy::src#4 memcpy::src#1 uctoa::buffer#11 uctoa::buffer#14 uctoa::buffer#4 uctoa::buffer#3 uctoa_append::buffer#0 clrscr::line_cols#5 clrscr::line_cols#1 ]
reg byte x [ memset::c#4 ]
zp[1]:9 [ conio_cursor_x ]
zp[1]:10 [ conio_cursor_y ]
zp[2]:11 [ conio_line_text ]
zp[2]:13 [ conio_line_color ]
zp[2]:15 [ gotoxy::$7 gotoxy::$9 gotoxy::line_offset#0 gotoxy::$6 ]
zp[2]:17 [ gotoxy::$8 ]
zp[2]:19 [ gotoxy::$5 ]
zp[1]:11 [ conio_cursor_x ]
zp[1]:12 [ conio_cursor_y ]
zp[2]:13 [ conio_line_text ]
zp[2]:15 [ conio_line_color ]
reg byte a [ cputc::c#0 ]
zp[2]:17 [ gotoxy::$7 gotoxy::$9 gotoxy::line_offset#0 gotoxy::$6 ]
zp[2]:19 [ gotoxy::$8 ]
zp[2]:21 [ gotoxy::$5 ]
reg byte a [ printf_number_buffer::buffer_sign#0 ]
reg byte a [ cputs::c#1 ]
zp[1]:21 [ uctoa::digit_value#0 uctoa_append::sub#0 ]
reg byte a [ printf_str::c#1 ]
zp[1]:23 [ uctoa::digit_value#0 uctoa_append::sub#0 ]
reg byte x [ uctoa_append::return#0 ]
zp[2]:22 [ memcpy::src_end#0 ]
zp[2]:24 [ memset::end#0 memcpy::destination#2 memcpy::dst#2 memcpy::dst#4 memcpy::dst#1 ]
zp[2]:24 [ memcpy::src_end#0 ]
zp[2]:26 [ memset::end#0 memcpy::destination#2 memcpy::dst#2 memcpy::dst#4 memcpy::dst#1 ]
mem[12] [ printf_buffer ]
mem[20] [ stars ]

View File

@ -11,6 +11,7 @@
.const GREEN = 5
.const LIGHT_BLUE = $e
.const OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS = 1
.const STACK_BASE = $103
.const SIZEOF_STRUCT_PRINTF_BUFFER_NUMBER = $c
/// Color Ram
.label COLORRAM = $d800
@ -18,15 +19,15 @@
.label DEFAULT_SCREEN = $400
// The number of bytes on the screen
// The current cursor x-position
.label conio_cursor_x = $c
.label conio_cursor_x = $10
// The current cursor y-position
.label conio_cursor_y = $d
.label conio_cursor_y = $11
// The current text cursor line start
.label conio_line_text = $e
.label conio_line_text = $12
// The current color cursor line start
.label conio_line_color = $10
.label conio_line_color = $14
// The current text color
.label conio_textcolor = $12
.label conio_textcolor = $16
.segment Code
__start: {
// __ma char conio_cursor_x = 0
@ -68,6 +69,37 @@ conio_c64_init: {
// }
rts
}
// Output one character at the current cursor position
// Moves the cursor forward. Scrolls the entire screen if needed
// void cputc(__register(A) char c)
cputc: {
.const OFFSET_STACK_C = 0
tsx
lda STACK_BASE+OFFSET_STACK_C,x
// if(c=='\n')
cmp #'\n'
beq __b1
// conio_line_text[conio_cursor_x] = c
ldy.z conio_cursor_x
sta (conio_line_text),y
// conio_line_color[conio_cursor_x] = conio_textcolor
lda.z conio_textcolor
sta (conio_line_color),y
// if(++conio_cursor_x==CONIO_WIDTH)
inc.z conio_cursor_x
lda #$28
cmp.z conio_cursor_x
bne __breturn
// cputln()
jsr cputln
__breturn:
// }
rts
__b1:
// cputln()
jsr cputln
rts
}
main: {
// strcmp("a","b")
lda #<str2
@ -551,12 +583,12 @@ main: {
// void gotoxy(char x, __register(X) char y)
gotoxy: {
.const x = 0
.label __5 = $17
.label __6 = $13
.label __7 = $13
.label line_offset = $13
.label __8 = $15
.label __9 = $13
.label __5 = $1b
.label __6 = $17
.label __7 = $17
.label line_offset = $17
.label __8 = $19
.label __9 = $17
// if(y>CONIO_HEIGHT)
cpx #$19+1
bcc __b2
@ -622,17 +654,45 @@ gotoxy: {
// }
rts
}
// Print a newline
cputln: {
// conio_line_text += CONIO_WIDTH
lda #$28
clc
adc.z conio_line_text
sta.z conio_line_text
bcc !+
inc.z conio_line_text+1
!:
// conio_line_color += CONIO_WIDTH
lda #$28
clc
adc.z conio_line_color
sta.z conio_line_color
bcc !+
inc.z conio_line_color+1
!:
// conio_cursor_x = 0
lda #0
sta.z conio_cursor_x
// conio_cursor_y++;
inc.z conio_cursor_y
// cscroll()
jsr cscroll
// }
rts
}
/// compares the string pointed to, by str1 to the string pointed to by str2.
/// @param str1 This is the first string to be compared.
/// @param str2 This is the second string to be compared.
/// @return if Return value < 0 then it indicates str1 is less than str2.
/// if Return value > 0 then it indicates str2 is less than str1.
/// if Return value = 0 then it indicates str1 is equal to str2.
// __zp($1a) int strcmp(const char *str1, const char *str2)
// __zp(8) int strcmp(const char *str1, const char *str2)
strcmp: {
.label s1 = 4
.label s2 = 6
.label return = $1a
.label return = 8
__b1:
// while(*s1==*s2)
ldy #0
@ -693,7 +753,9 @@ assert_cmp: {
// break;
lda.z expect
cmp #0
beq __b5
bne !__b5+
jmp __b5
!__b5:
// case GREATER_THAN:
// ok = (char)(actual>0);
// break;
@ -724,37 +786,53 @@ assert_cmp: {
lda #RED
jsr textcolor
// printf("Assert failed. expected:%d actual:%d. %s\n", expect, actual, message)
lda #<cputc
sta.z printf_str.putc
lda #>cputc
sta.z printf_str.putc+1
lda #<s2
sta.z cputs.s
sta.z printf_str.s
lda #>s2
sta.z cputs.s+1
jsr cputs
sta.z printf_str.s+1
jsr printf_str
// printf("Assert failed. expected:%d actual:%d. %s\n", expect, actual, message)
ldx.z expect
jsr printf_schar
// printf("Assert failed. expected:%d actual:%d. %s\n", expect, actual, message)
lda #<cputc
sta.z printf_str.putc
lda #>cputc
sta.z printf_str.putc+1
lda #<s3
sta.z cputs.s
sta.z printf_str.s
lda #>s3
sta.z cputs.s+1
jsr cputs
sta.z printf_str.s+1
jsr printf_str
// printf("Assert failed. expected:%d actual:%d. %s\n", expect, actual, message)
ldx.z actual
jsr printf_schar
// printf("Assert failed. expected:%d actual:%d. %s\n", expect, actual, message)
lda #<cputc
sta.z printf_str.putc
lda #>cputc
sta.z printf_str.putc+1
lda #<s4
sta.z cputs.s
sta.z printf_str.s
lda #>s4
sta.z cputs.s+1
jsr cputs
sta.z printf_str.s+1
jsr printf_str
// printf("Assert failed. expected:%d actual:%d. %s\n", expect, actual, message)
jsr printf_string
// printf("Assert failed. expected:%d actual:%d. %s\n", expect, actual, message)
lda #<cputc
sta.z printf_str.putc
lda #>cputc
sta.z printf_str.putc+1
lda #<s1
sta.z cputs.s
sta.z printf_str.s
lda #>s1
sta.z cputs.s+1
jsr cputs
sta.z printf_str.s+1
jsr printf_str
// }
rts
__b1:
@ -762,19 +840,27 @@ assert_cmp: {
lda #GREEN
jsr textcolor
// printf("ok! %s\n", message)
lda #<cputc
sta.z printf_str.putc
lda #>cputc
sta.z printf_str.putc+1
lda #<s
sta.z cputs.s
sta.z printf_str.s
lda #>s
sta.z cputs.s+1
jsr cputs
sta.z printf_str.s+1
jsr printf_str
// printf("ok! %s\n", message)
jsr printf_string
// printf("ok! %s\n", message)
lda #<cputc
sta.z printf_str.putc
lda #>cputc
sta.z printf_str.putc+1
lda #<s1
sta.z cputs.s
sta.z printf_str.s
lda #>s1
sta.z cputs.s+1
jsr cputs
sta.z printf_str.s+1
jsr printf_str
rts
__b5:
// actual==0
@ -819,12 +905,12 @@ assert_cmp: {
/// @return if Return value < 0 then it indicates str1 is less than str2.
/// if Return value > 0 then it indicates str2 is less than str1.
/// if Return value = 0 then it indicates str1 is equal to str2.
// __zp($a) int strncmp(const char *str1, const char *str2, __zp(4) unsigned int n)
// __zp($e) int strncmp(const char *str1, const char *str2, __zp(4) unsigned int n)
strncmp: {
.label s1 = 6
.label s2 = $1a
.label s2 = 8
.label n = 4
.label return = $a
.label return = $e
__b1:
// while(*s1==*s2)
ldy #0
@ -883,14 +969,14 @@ strncmp: {
/// @return if Return value < 0 then it indicates str1 is less than str2.
/// if Return value > 0 then it indicates str2 is less than str1.
/// if Return value = 0 then it indicates str1 is equal to str2.
// __zp($1a) int memcmp(__zp(4) const void *str1, __zp($a) const void *str2, __zp(6) unsigned int n)
// __zp(8) int memcmp(__zp(4) const void *str1, __zp($e) const void *str2, __zp(6) unsigned int n)
memcmp: {
.label n = 6
.label s1 = 4
.label s2 = $a
.label return = $1a
.label s2 = $e
.label return = 8
.label str1 = 4
.label str2 = $a
.label str2 = $e
__b1:
// for(char *s1 = str1, *s2 = str2; n!=0; n--,s1++,s2++)
lda.z n
@ -936,255 +1022,6 @@ memcmp: {
!:
jmp __b1
}
// Set the color for text output. The old color setting is returned.
// char textcolor(__register(A) char color)
textcolor: {
// conio_textcolor = color
sta.z conio_textcolor
// }
rts
}
// Output a NUL-terminated string at the current cursor position
// void cputs(__zp(6) const char *s)
cputs: {
.label s = 6
__b1:
// while(c=*s++)
ldy #0
lda (s),y
inc.z s
bne !+
inc.z s+1
!:
cmp #0
bne __b2
// }
rts
__b2:
// cputc(c)
jsr cputc
jmp __b1
}
// Print a signed char using a specific format
// void printf_schar(__register(X) signed char value, char format_min_length, char format_justify_left, char format_sign_always, char format_zero_padding, char format_upper_case, char format_radix)
printf_schar: {
// printf_buffer.sign = 0
// Handle any sign
lda #0
sta printf_buffer
// if(value<0)
cpx #0
bmi __b1
jmp __b2
__b1:
// value = -value
txa
eor #$ff
clc
adc #1
tax
// printf_buffer.sign = '-'
lda #'-'
sta printf_buffer
__b2:
// uctoa(uvalue, printf_buffer.digits, format.radix)
jsr uctoa
// printf_number_buffer(printf_buffer, format)
lda printf_buffer
// Print using format
jsr printf_number_buffer
// }
rts
}
// Print a string value using a specific format
// Handles justification and min length
// void printf_string(__zp(4) char *str, char format_min_length, char format_justify_left)
printf_string: {
.label str = 4
// cputs(str)
lda.z str
sta.z cputs.s
lda.z str+1
sta.z cputs.s+1
jsr cputs
// }
rts
}
// Output one character at the current cursor position
// Moves the cursor forward. Scrolls the entire screen if needed
// void cputc(__register(A) char c)
cputc: {
// if(c=='\n')
cmp #'\n'
beq __b1
// conio_line_text[conio_cursor_x] = c
ldy.z conio_cursor_x
sta (conio_line_text),y
// conio_line_color[conio_cursor_x] = conio_textcolor
lda.z conio_textcolor
sta (conio_line_color),y
// if(++conio_cursor_x==CONIO_WIDTH)
inc.z conio_cursor_x
lda #$28
cmp.z conio_cursor_x
bne __breturn
// cputln()
jsr cputln
__breturn:
// }
rts
__b1:
// cputln()
jsr cputln
rts
}
// Converts unsigned number value to a string representing it in RADIX format.
// If the leading digits are zero they are not included in the string.
// - value : The number to be converted to RADIX
// - buffer : receives the string representing the number and zero-termination.
// - radix : The radix to convert the number to (from the enum RADIX)
// void uctoa(__register(X) char value, __zp($1a) char *buffer, char radix)
uctoa: {
.label digit_value = $19
.label buffer = $1a
.label digit = 8
.label started = 9
lda #<printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
sta.z buffer
lda #>printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
sta.z buffer+1
lda #0
sta.z started
sta.z digit
__b1:
// for( char digit=0; digit<max_digits-1; digit++ )
lda.z digit
cmp #3-1
bcc __b2
// *buffer++ = DIGITS[(char)value]
lda DIGITS,x
ldy #0
sta (buffer),y
// *buffer++ = DIGITS[(char)value];
inc.z buffer
bne !+
inc.z buffer+1
!:
// *buffer = 0
lda #0
tay
sta (buffer),y
// }
rts
__b2:
// unsigned char digit_value = digit_values[digit]
ldy.z digit
lda RADIX_DECIMAL_VALUES_CHAR,y
sta.z digit_value
// if (started || value >= digit_value)
lda.z started
bne __b5
cpx.z digit_value
bcs __b5
__b4:
// for( char digit=0; digit<max_digits-1; digit++ )
inc.z digit
jmp __b1
__b5:
// uctoa_append(buffer++, value, digit_value)
jsr uctoa_append
// uctoa_append(buffer++, value, digit_value)
// value = uctoa_append(buffer++, value, digit_value)
// value = uctoa_append(buffer++, value, digit_value);
inc.z buffer
bne !+
inc.z buffer+1
!:
lda #1
sta.z started
jmp __b4
}
// Print the contents of the number buffer using a specific format.
// This handles minimum length, zero-filling, and left/right justification from the format
// void printf_number_buffer(__register(A) char buffer_sign, char *buffer_digits, char format_min_length, char format_justify_left, char format_sign_always, char format_zero_padding, char format_upper_case, char format_radix)
printf_number_buffer: {
.label buffer_digits = printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
// if(buffer.sign)
cmp #0
beq __b2
// cputc(buffer.sign)
jsr cputc
__b2:
// cputs(buffer.digits)
lda #<buffer_digits
sta.z cputs.s
lda #>buffer_digits
sta.z cputs.s+1
jsr cputs
// }
rts
}
// Print a newline
cputln: {
// conio_line_text += CONIO_WIDTH
lda #$28
clc
adc.z conio_line_text
sta.z conio_line_text
bcc !+
inc.z conio_line_text+1
!:
// conio_line_color += CONIO_WIDTH
lda #$28
clc
adc.z conio_line_color
sta.z conio_line_color
bcc !+
inc.z conio_line_color+1
!:
// conio_cursor_x = 0
lda #0
sta.z conio_cursor_x
// conio_cursor_y++;
inc.z conio_cursor_y
// cscroll()
jsr cscroll
// }
rts
}
// Used to convert a single digit of an unsigned number value to a string representation
// Counts a single digit up from '0' as long as the value is larger than sub.
// Each time the digit is increased sub is subtracted from value.
// - buffer : pointer to the char that receives the digit
// - value : The value where the digit will be derived from
// - sub : the value of a '1' in the digit. Subtracted continually while the digit is increased.
// (For decimal the subs used are 10000, 1000, 100, 10, 1)
// returns : the value reduced by sub * digit so that it is less than sub.
// __register(X) char uctoa_append(__zp($1a) char *buffer, __register(X) char value, __zp($19) char sub)
uctoa_append: {
.label buffer = $1a
.label sub = $19
ldy #0
__b1:
// while (value >= sub)
cpx.z sub
bcs __b2
// *buffer = DIGITS[digit]
lda DIGITS,y
ldy #0
sta (buffer),y
// }
rts
__b2:
// digit++;
iny
// value -= sub
txa
sec
sbc.z sub
tax
jmp __b1
}
// Scroll the entire screen if the cursor is beyond the last line
cscroll: {
// if(conio_cursor_y==CONIO_HEIGHT)
@ -1247,15 +1084,98 @@ cscroll: {
// }
rts
}
// Set the color for text output. The old color setting is returned.
// char textcolor(__register(A) char color)
textcolor: {
// conio_textcolor = color
sta.z conio_textcolor
// }
rts
}
/// Print a NUL-terminated string
// void printf_str(__zp(6) void (*putc)(char), __zp(8) const char *s)
printf_str: {
.label s = 8
.label putc = 6
__b1:
// while(c=*s++)
ldy #0
lda (s),y
inc.z s
bne !+
inc.z s+1
!:
cmp #0
bne __b2
// }
rts
__b2:
// putc(c)
pha
jsr icall1
pla
jmp __b1
icall1:
jmp (putc)
}
// Print a signed char using a specific format
// void printf_schar(void (*putc)(char), __register(X) signed char value, char format_min_length, char format_justify_left, char format_sign_always, char format_zero_padding, char format_upper_case, char format_radix)
printf_schar: {
// printf_buffer.sign = 0
// Handle any sign
lda #0
sta printf_buffer
// if(value<0)
cpx #0
bmi __b1
jmp __b2
__b1:
// value = -value
txa
eor #$ff
clc
adc #1
tax
// printf_buffer.sign = '-'
lda #'-'
sta printf_buffer
__b2:
// uctoa(uvalue, printf_buffer.digits, format.radix)
jsr uctoa
// printf_number_buffer(putc, printf_buffer, format)
lda printf_buffer
// Print using format
jsr printf_number_buffer
// }
rts
}
// Print a string value using a specific format
// Handles justification and min length
// void printf_string(void (*putc)(char), __zp(4) char *str, char format_min_length, char format_justify_left)
printf_string: {
.label str = 4
// printf_str(putc, str)
lda.z str
sta.z printf_str.s
lda.z str+1
sta.z printf_str.s+1
lda #<cputc
sta.z printf_str.putc
lda #>cputc
sta.z printf_str.putc+1
jsr printf_str
// }
rts
}
// Copy block of memory (forwards)
// Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
// void * memcpy(__zp($1c) void *destination, __zp($a) void *source, unsigned int num)
// void * memcpy(__zp($1f) void *destination, __zp($a) void *source, unsigned int num)
memcpy: {
.label src_end = $1a
.label dst = $1c
.label src_end = $1d
.label dst = $1f
.label src = $a
.label source = $a
.label destination = $1c
.label destination = $1f
// char* src_end = (char*)source+num
lda.z source
clc
@ -1293,7 +1213,7 @@ memcpy: {
// Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
// void * memset(__zp($a) void *str, __register(X) char c, unsigned int num)
memset: {
.label end = $1c
.label end = $1f
.label dst = $a
.label str = $a
// char* end = (char*)str + num
@ -1326,6 +1246,132 @@ memset: {
!:
jmp __b2
}
// Converts unsigned number value to a string representing it in RADIX format.
// If the leading digits are zero they are not included in the string.
// - value : The number to be converted to RADIX
// - buffer : receives the string representing the number and zero-termination.
// - radix : The radix to convert the number to (from the enum RADIX)
// void uctoa(__register(X) char value, __zp($e) char *buffer, char radix)
uctoa: {
.label digit_value = $21
.label buffer = $e
.label digit = $c
.label started = $d
lda #<printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
sta.z buffer
lda #>printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
sta.z buffer+1
lda #0
sta.z started
sta.z digit
__b1:
// for( char digit=0; digit<max_digits-1; digit++ )
lda.z digit
cmp #3-1
bcc __b2
// *buffer++ = DIGITS[(char)value]
lda DIGITS,x
ldy #0
sta (buffer),y
// *buffer++ = DIGITS[(char)value];
inc.z buffer
bne !+
inc.z buffer+1
!:
// *buffer = 0
lda #0
tay
sta (buffer),y
// }
rts
__b2:
// unsigned char digit_value = digit_values[digit]
ldy.z digit
lda RADIX_DECIMAL_VALUES_CHAR,y
sta.z digit_value
// if (started || value >= digit_value)
lda.z started
bne __b5
cpx.z digit_value
bcs __b5
__b4:
// for( char digit=0; digit<max_digits-1; digit++ )
inc.z digit
jmp __b1
__b5:
// uctoa_append(buffer++, value, digit_value)
jsr uctoa_append
// uctoa_append(buffer++, value, digit_value)
// value = uctoa_append(buffer++, value, digit_value)
// value = uctoa_append(buffer++, value, digit_value);
inc.z buffer
bne !+
inc.z buffer+1
!:
lda #1
sta.z started
jmp __b4
}
// Print the contents of the number buffer using a specific format.
// This handles minimum length, zero-filling, and left/right justification from the format
// void printf_number_buffer(void (*putc)(char), __register(A) char buffer_sign, char *buffer_digits, char format_min_length, char format_justify_left, char format_sign_always, char format_zero_padding, char format_upper_case, char format_radix)
printf_number_buffer: {
.label buffer_digits = printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
.label putc = cputc
// if(buffer.sign)
cmp #0
beq __b2
// putc(buffer.sign)
pha
jsr cputc
pla
__b2:
// printf_str(putc, buffer.digits)
lda #<putc
sta.z printf_str.putc
lda #>putc
sta.z printf_str.putc+1
lda #<buffer_digits
sta.z printf_str.s
lda #>buffer_digits
sta.z printf_str.s+1
jsr printf_str
// }
rts
}
// Used to convert a single digit of an unsigned number value to a string representation
// Counts a single digit up from '0' as long as the value is larger than sub.
// Each time the digit is increased sub is subtracted from value.
// - buffer : pointer to the char that receives the digit
// - value : The value where the digit will be derived from
// - sub : the value of a '1' in the digit. Subtracted continually while the digit is increased.
// (For decimal the subs used are 10000, 1000, 100, 10, 1)
// returns : the value reduced by sub * digit so that it is less than sub.
// __register(X) char uctoa_append(__zp($e) char *buffer, __register(X) char value, __zp($21) char sub)
uctoa_append: {
.label buffer = $e
.label sub = $21
ldy #0
__b1:
// while (value >= sub)
cpx.z sub
bcs __b2
// *buffer = DIGITS[digit]
lda DIGITS,y
ldy #0
sta (buffer),y
// }
rts
__b2:
// digit++;
iny
// value -= sub
txa
sec
sbc.z sub
tax
jmp __b1
}
.segment Data
// The digits used for numbers
DIGITS: .text "0123456789abcdef"

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -11,6 +11,7 @@ __constant char RADIX::OCTAL = 8
__constant char RADIX_DECIMAL_VALUES_CHAR[] = { $64, $a }
__constant const char RED = 2
__constant char SIZEOF_STRUCT_PRINTF_BUFFER_NUMBER = $c
__constant unsigned int STACK_BASE = $103
void __start()
void assert_cmp(signed char expect , signed char actual , char *message)
bool assert_cmp::$0 // reg byte a 101.0
@ -55,34 +56,25 @@ __constant char * const conio_c64_init::BASIC_CURSOR_LINE = (char *) 214
char conio_c64_init::line
char conio_c64_init::line#0 // reg byte x 11.0
char conio_c64_init::line#2 // reg byte x 22.0
__loadstore char conio_cursor_x // zp[1]:12 837989.43575419
__loadstore char conio_cursor_y // zp[1]:13 1.6410256964102566E7
__loadstore char *conio_line_color // zp[2]:16 1.1818182395721925E7
__loadstore char *conio_line_text // zp[2]:14 1.1693122264550265E7
__loadstore char conio_textcolor // zp[1]:18 1.2317085426829267E7
void cputc(char c)
__loadstore char conio_cursor_x // zp[1]:16 8929.220238095239
__loadstore char conio_cursor_y // zp[1]:17 173913.6304347826
__loadstore char *conio_line_color // zp[2]:20 125568.79545454546
__loadstore char *conio_line_text // zp[2]:18 124157.91011235955
__loadstore char conio_textcolor // zp[1]:22 171203.47457627117
__stackcall void cputc(char c)
__constant char cputc::OFFSET_STACK_C = 0
char cputc::c
char cputc::c#0 // reg byte a 2000002.0
char cputc::c#2 // reg byte a 20002.0
char cputc::c#3 // reg byte a 1.0505002E7
char cputc::c#0 // reg byte a 150001.5
void cputln()
void cputs(const char *s)
char cputs::c
char cputs::c#1 // reg byte a 1000001.0
const char *cputs::s
const char *cputs::s#0 // s zp[2]:6 500000.5
const char *cputs::s#10 // s zp[2]:6 101002.0
const char *cputs::s#2 // s zp[2]:6 2002.0
const char *cputs::s#9 // s zp[2]:6 1550002.0
void cscroll()
void gotoxy(char x , char y)
char *gotoxy::$5 // zp[2]:23 202.0
char *gotoxy::$6 // zp[2]:19 202.0
unsigned int gotoxy::$7 // zp[2]:19 151.5
unsigned int gotoxy::$8 // zp[2]:21 202.0
unsigned int gotoxy::$9 // zp[2]:19 202.0
char *gotoxy::$5 // zp[2]:27 202.0
char *gotoxy::$6 // zp[2]:23 202.0
unsigned int gotoxy::$7 // zp[2]:23 151.5
unsigned int gotoxy::$8 // zp[2]:25 202.0
unsigned int gotoxy::$9 // zp[2]:23 202.0
unsigned int gotoxy::line_offset
unsigned int gotoxy::line_offset#0 // line_offset zp[2]:19 101.0
unsigned int gotoxy::line_offset#0 // line_offset zp[2]:23 101.0
char gotoxy::x
__constant char gotoxy::x#2 = 0 // x
char gotoxy::y
@ -136,57 +128,57 @@ unsigned int memcmp::n#0 // n zp[2]:6 667.3333333333334
unsigned int memcmp::n#5 // n zp[2]:6 1034.6666666666667
unsigned int memcmp::n#7 // n zp[2]:6 33.666666666666664
int memcmp::return
int memcmp::return#1 // return zp[2]:26 202.0
int memcmp::return#10 // return zp[2]:26 22.0
int memcmp::return#11 // return zp[2]:26 22.0
int memcmp::return#2 // return zp[2]:26 24.166666666666664
int memcmp::return#3 // return zp[2]:26 22.0
int memcmp::return#4 // return zp[2]:26 22.0
int memcmp::return#1 // return zp[2]:8 202.0
int memcmp::return#10 // return zp[2]:8 22.0
int memcmp::return#11 // return zp[2]:8 22.0
int memcmp::return#2 // return zp[2]:8 24.166666666666664
int memcmp::return#3 // return zp[2]:8 22.0
int memcmp::return#4 // return zp[2]:8 22.0
char *memcmp::s1
char *memcmp::s1#1 // s1 zp[2]:4 1001.0
char *memcmp::s1#2 // s1 zp[2]:4 801.25
char *memcmp::s1#6 // s1 zp[2]:4 101.0
char *memcmp::s2
char *memcmp::s2#1 // s2 zp[2]:10 2002.0
char *memcmp::s2#2 // s2 zp[2]:10 641.0
char *memcmp::s2#6 // s2 zp[2]:10 202.0
char *memcmp::s2#1 // s2 zp[2]:14 2002.0
char *memcmp::s2#2 // s2 zp[2]:14 641.0
char *memcmp::s2#6 // s2 zp[2]:14 202.0
const void *memcmp::str1
const void *memcmp::str1#4 // str1 zp[2]:4
const void *memcmp::str2
const void *memcmp::str2#4 // str2 zp[2]:10
const void *memcmp::str2#4 // str2 zp[2]:14
void * memcpy(void *destination , void *source , unsigned int num)
void *memcpy::destination
void *memcpy::destination#2 // destination zp[2]:28
void *memcpy::destination#2 // destination zp[2]:31
char *memcpy::dst
char *memcpy::dst#1 // dst zp[2]:28 1.000000000001E12
char *memcpy::dst#2 // dst zp[2]:28 1.0033333333346667E12
char *memcpy::dst#4 // dst zp[2]:28 2.0000000002E10
char *memcpy::dst#1 // dst zp[2]:31 1.000000001E9
char *memcpy::dst#2 // dst zp[2]:31 1.0333333346666667E9
char *memcpy::dst#4 // dst zp[2]:31 2.00000002E8
unsigned int memcpy::num
void *memcpy::return
void *memcpy::source
void *memcpy::source#2 // source zp[2]:10
char *memcpy::src
char *memcpy::src#1 // src zp[2]:10 2.000000000002E12
char *memcpy::src#2 // src zp[2]:10 1.00250000000125E12
char *memcpy::src#4 // src zp[2]:10 1.0000000001E10
char *memcpy::src#1 // src zp[2]:10 2.000000002E9
char *memcpy::src#2 // src zp[2]:10 1.02500000125E9
char *memcpy::src#4 // src zp[2]:10 1.00000001E8
char *memcpy::src_end
char *memcpy::src_end#0 // src_end zp[2]:26 1.2625000000025E11
char *memcpy::src_end#0 // src_end zp[2]:29 1.3750000025E8
void * memset(void *str , char c , unsigned int num)
char memset::c
char memset::c#1 // reg byte x 2.000000002E9
char memset::c#4 // reg byte x 1.430000000002857E11
char memset::c#1 // reg byte x 2.0000002E7
char memset::c#4 // reg byte x 1.4428571457142857E8
char *memset::dst
char *memset::dst#1 // dst zp[2]:10 2.000000000002E12
char *memset::dst#2 // dst zp[2]:10 1.3366666666683335E12
char *memset::dst#4 // dst zp[2]:10 2.0000000002E10
char *memset::dst#1 // dst zp[2]:10 2.000000002E9
char *memset::dst#2 // dst zp[2]:10 1.3666666683333335E9
char *memset::dst#4 // dst zp[2]:10 2.00000002E8
char *memset::end
char *memset::end#0 // end zp[2]:28 1.683333333336667E11
char *memset::end#0 // end zp[2]:31 1.833333336666667E8
unsigned int memset::num
void *memset::return
void *memset::str
void *memset::str#3 // str zp[2]:10
__loadstore struct printf_buffer_number printf_buffer = {} // mem[12]
void printf_number_buffer(char buffer_sign , char *buffer_digits , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
void printf_number_buffer(void (*putc)(char) , char buffer_sign , char *buffer_digits , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
struct printf_buffer_number printf_number_buffer::buffer
char *printf_number_buffer::buffer_digits
__constant char *printf_number_buffer::buffer_digits#0 = (char *)&printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS // buffer_digits
@ -201,7 +193,9 @@ char printf_number_buffer::format_upper_case
char printf_number_buffer::format_zero_padding
signed char printf_number_buffer::len
signed char printf_number_buffer::padding
void printf_schar(signed char value , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
void (*printf_number_buffer::putc)(char)
__constant void (*printf_number_buffer::putc#0)(char) = &cputc // putc
void printf_schar(void (*putc)(char) , signed char value , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
struct printf_format_number printf_schar::format
char printf_schar::format_justify_left
char printf_schar::format_min_length
@ -209,6 +203,7 @@ char printf_schar::format_radix
char printf_schar::format_sign_always
char printf_schar::format_upper_case
char printf_schar::format_zero_padding
void (*printf_schar::putc)(char)
char printf_schar::uvalue
signed char printf_schar::value
signed char printf_schar::value#0 // reg byte x 1001.0
@ -216,12 +211,23 @@ signed char printf_schar::value#1 // reg byte x 202.0
signed char printf_schar::value#2 // reg byte x 202.0
signed char printf_schar::value#3 // reg byte x 1068.3333333333335
signed char printf_schar::value#5 // reg byte x 2002.0
void printf_string(char *str , char format_min_length , char format_justify_left)
void printf_str(void (*putc)(char) , const char *s)
char printf_str::c
char printf_str::c#1 // reg byte a 1000001.0
void (*printf_str::putc)(char)
void (*printf_str::putc#10)(char) // putc zp[2]:6
const char *printf_str::s
const char *printf_str::s#0 // s zp[2]:8 1000001.0
const char *printf_str::s#10 // s zp[2]:8 101002.0
const char *printf_str::s#2 // s zp[2]:8 2002.0
const char *printf_str::s#9 // s zp[2]:8 1550002.0
void printf_string(void (*putc)(char) , char *str , char format_min_length , char format_justify_left)
struct printf_format_string printf_string::format
char printf_string::format_justify_left
char printf_string::format_min_length
signed char printf_string::len
signed char printf_string::padding
void (*printf_string::putc)(char)
char *printf_string::str
char *printf_string::str#0 // str zp[2]:4 202.0
char *printf_string::str#1 // str zp[2]:4 202.0
@ -229,16 +235,16 @@ char *printf_string::str#2 // str zp[2]:4 1203.0
int strcmp(const char *str1 , const char *str2)
char strcmp::$0 // reg byte a 101.0
int strcmp::return
int strcmp::return#0 // return zp[2]:26 202.0
int strcmp::return#10 // return zp[2]:26 22.0
int strcmp::return#11 // return zp[2]:26 18.9
int strcmp::return#12 // return zp[2]:26 22.0
int strcmp::return#13 // return zp[2]:26 22.0
int strcmp::return#14 // return zp[2]:26 22.0
int strcmp::return#15 // return zp[2]:26 22.0
int strcmp::return#16 // return zp[2]:26 22.0
int strcmp::return#17 // return zp[2]:26 22.0
int strcmp::return#18 // return zp[2]:26 22.0
int strcmp::return#0 // return zp[2]:8 202.0
int strcmp::return#10 // return zp[2]:8 22.0
int strcmp::return#11 // return zp[2]:8 18.9
int strcmp::return#12 // return zp[2]:8 22.0
int strcmp::return#13 // return zp[2]:8 22.0
int strcmp::return#14 // return zp[2]:8 22.0
int strcmp::return#15 // return zp[2]:8 22.0
int strcmp::return#16 // return zp[2]:8 22.0
int strcmp::return#17 // return zp[2]:8 22.0
int strcmp::return#18 // return zp[2]:8 22.0
char *strcmp::s1
char *strcmp::s1#0 // s1 zp[2]:4 101.0
char *strcmp::s1#1 // s1 zp[2]:4 1001.0
@ -256,21 +262,21 @@ unsigned int strncmp::n#0 // n zp[2]:4 600.5999999999999
unsigned int strncmp::n#6 // n zp[2]:4 1051.5
unsigned int strncmp::n#8 // n zp[2]:4 101.0
int strncmp::return
int strncmp::return#0 // return zp[2]:10 202.0
int strncmp::return#10 // return zp[2]:10 22.0
int strncmp::return#11 // return zp[2]:10 22.0
int strncmp::return#12 // return zp[2]:10 22.0
int strncmp::return#13 // return zp[2]:10 22.0
int strncmp::return#2 // return zp[2]:10 22.285714285714285
int strncmp::return#3 // return zp[2]:10 22.0
int strncmp::return#0 // return zp[2]:14 202.0
int strncmp::return#10 // return zp[2]:14 22.0
int strncmp::return#11 // return zp[2]:14 22.0
int strncmp::return#12 // return zp[2]:14 22.0
int strncmp::return#13 // return zp[2]:14 22.0
int strncmp::return#2 // return zp[2]:14 22.285714285714285
int strncmp::return#3 // return zp[2]:14 22.0
char *strncmp::s1
char *strncmp::s1#0 // s1 zp[2]:6 101.0
char *strncmp::s1#1 // s1 zp[2]:6 1001.0
char *strncmp::s1#2 // s1 zp[2]:6 841.2
char *strncmp::s2
char *strncmp::s2#0 // s2 zp[2]:26 101.0
char *strncmp::s2#1 // s2 zp[2]:26 2002.0
char *strncmp::s2#2 // s2 zp[2]:26 534.1666666666666
char *strncmp::s2#0 // s2 zp[2]:8 101.0
char *strncmp::s2#1 // s2 zp[2]:8 2002.0
char *strncmp::s2#2 // s2 zp[2]:8 534.1666666666666
const char *strncmp::str1
const char *strncmp::str2
char textcolor(char color)
@ -280,21 +286,21 @@ char textcolor::old
char textcolor::return
void uctoa(char value , char *buffer , char radix)
char *uctoa::buffer
char *uctoa::buffer#11 // buffer zp[2]:26 35000.49999999999
char *uctoa::buffer#14 // buffer zp[2]:26 150001.5
char *uctoa::buffer#3 // buffer zp[2]:26 20002.0
char *uctoa::buffer#4 // buffer zp[2]:26 200002.0
char *uctoa::buffer#11 // buffer zp[2]:14 35000.49999999999
char *uctoa::buffer#14 // buffer zp[2]:14 150001.5
char *uctoa::buffer#3 // buffer zp[2]:14 20002.0
char *uctoa::buffer#4 // buffer zp[2]:14 200002.0
char uctoa::digit
char uctoa::digit#1 // digit zp[1]:8 200002.0
char uctoa::digit#2 // digit zp[1]:8 30769.53846153846
char uctoa::digit#1 // digit zp[1]:12 200002.0
char uctoa::digit#2 // digit zp[1]:12 30769.53846153846
char uctoa::digit_value
char uctoa::digit_value#0 // digit_value zp[1]:25 60000.600000000006
char uctoa::digit_value#0 // digit_value zp[1]:33 60000.600000000006
char *uctoa::digit_values
char uctoa::max_digits
char uctoa::radix
char uctoa::started
char uctoa::started#2 // started zp[1]:9 60000.600000000006
char uctoa::started#4 // started zp[1]:9 100001.0
char uctoa::started#2 // started zp[1]:13 60000.600000000006
char uctoa::started#4 // started zp[1]:13 100001.0
char uctoa::value
char uctoa::value#0 // reg byte x 100001.0
char uctoa::value#1 // reg byte x 5501.0
@ -302,14 +308,14 @@ char uctoa::value#2 // reg byte x 70000.99999999999
char uctoa::value#6 // reg byte x 150001.5
char uctoa_append(char *buffer , char value , char sub)
char *uctoa_append::buffer
char *uctoa_append::buffer#0 // buffer zp[2]:26 137500.25
char *uctoa_append::buffer#0 // buffer zp[2]:14 137500.25
char uctoa_append::digit
char uctoa_append::digit#1 // reg byte y 1.00000001E8
char uctoa_append::digit#2 // reg byte y 1.005000015E8
char uctoa_append::return
char uctoa_append::return#0 // reg byte x 200002.0
char uctoa_append::sub
char uctoa_append::sub#0 // sub zp[1]:25 3.33500005E7
char uctoa_append::sub#0 // sub zp[1]:33 3.33500005E7
char uctoa_append::value
char uctoa_append::value#0 // reg byte x 366667.3333333334
char uctoa_append::value#1 // reg byte x 2.00000002E8
@ -322,34 +328,36 @@ zp[1]:3 [ assert_cmp::actual#17 assert_cmp::actual#4 assert_cmp::actual#5 assert
reg byte a [ assert_cmp::ok#4 assert_cmp::ok#1 assert_cmp::ok#2 assert_cmp::ok#3 ]
zp[2]:4 [ memcmp::str1#4 memcmp::s1#2 memcmp::s1#6 memcmp::s1#1 strncmp::n#6 strncmp::n#8 strncmp::n#0 assert_cmp::message#17 printf_string::str#2 printf_string::str#0 printf_string::str#1 strcmp::s1#2 strcmp::s1#0 strcmp::s1#1 ]
reg byte a [ textcolor::color#2 ]
zp[2]:6 [ cputs::s#9 cputs::s#10 cputs::s#2 cputs::s#0 memcmp::n#5 memcmp::n#7 memcmp::n#0 strncmp::s1#2 strncmp::s1#0 strncmp::s1#1 strcmp::s2#2 strcmp::s2#0 strcmp::s2#1 ]
zp[2]:6 [ printf_str::putc#10 memcmp::n#5 memcmp::n#7 memcmp::n#0 strncmp::s1#2 strncmp::s1#0 strncmp::s1#1 strcmp::s2#2 strcmp::s2#0 strcmp::s2#1 ]
zp[2]:8 [ printf_str::s#9 printf_str::s#10 printf_str::s#2 printf_str::s#0 memcmp::return#2 memcmp::return#1 memcmp::return#3 memcmp::return#4 memcmp::return#10 memcmp::return#11 strncmp::s2#2 strncmp::s2#0 strncmp::s2#1 strcmp::return#11 strcmp::return#0 strcmp::return#12 strcmp::return#13 strcmp::return#14 strcmp::return#15 strcmp::return#16 strcmp::return#17 strcmp::return#18 strcmp::return#10 ]
reg byte x [ printf_schar::value#5 printf_schar::value#0 printf_schar::value#3 printf_schar::value#1 printf_schar::value#2 ]
reg byte a [ cputc::c#3 cputc::c#0 cputc::c#2 ]
zp[1]:8 [ uctoa::digit#2 uctoa::digit#1 ]
zp[2]:10 [ memset::str#3 memset::dst#2 memset::dst#4 memset::dst#1 memcpy::source#2 memcpy::src#2 memcpy::src#4 memcpy::src#1 ]
reg byte x [ memset::c#4 memset::c#1 ]
zp[1]:12 [ uctoa::digit#2 uctoa::digit#1 ]
reg byte x [ uctoa::value#2 uctoa::value#6 uctoa::value#1 uctoa::value#0 ]
zp[1]:9 [ uctoa::started#2 uctoa::started#4 ]
zp[1]:13 [ uctoa::started#2 uctoa::started#4 ]
zp[2]:14 [ uctoa::buffer#11 uctoa::buffer#14 uctoa::buffer#4 uctoa::buffer#3 uctoa_append::buffer#0 memcmp::str2#4 memcmp::s2#2 memcmp::s2#6 memcmp::s2#1 strncmp::return#2 strncmp::return#0 strncmp::return#3 strncmp::return#10 strncmp::return#11 strncmp::return#12 strncmp::return#13 ]
reg byte x [ uctoa_append::value#2 uctoa_append::value#0 uctoa_append::value#1 ]
reg byte y [ uctoa_append::digit#2 uctoa_append::digit#1 ]
zp[2]:10 [ memset::str#3 memset::dst#2 memset::dst#4 memset::dst#1 memcpy::source#2 memcpy::src#2 memcpy::src#4 memcpy::src#1 memcmp::str2#4 memcmp::s2#2 memcmp::s2#6 memcmp::s2#1 strncmp::return#2 strncmp::return#0 strncmp::return#3 strncmp::return#10 strncmp::return#11 strncmp::return#12 strncmp::return#13 ]
reg byte x [ memset::c#4 memset::c#1 ]
zp[1]:12 [ conio_cursor_x ]
zp[1]:13 [ conio_cursor_y ]
zp[2]:14 [ conio_line_text ]
zp[2]:16 [ conio_line_color ]
zp[1]:18 [ conio_textcolor ]
zp[2]:19 [ gotoxy::$7 gotoxy::$9 gotoxy::line_offset#0 gotoxy::$6 ]
zp[2]:21 [ gotoxy::$8 ]
zp[2]:23 [ gotoxy::$5 ]
zp[1]:16 [ conio_cursor_x ]
zp[1]:17 [ conio_cursor_y ]
zp[2]:18 [ conio_line_text ]
zp[2]:20 [ conio_line_color ]
zp[1]:22 [ conio_textcolor ]
reg byte a [ cputc::c#0 ]
zp[2]:23 [ gotoxy::$7 gotoxy::$9 gotoxy::line_offset#0 gotoxy::$6 ]
zp[2]:25 [ gotoxy::$8 ]
zp[2]:27 [ gotoxy::$5 ]
reg byte a [ strcmp::$0 ]
reg byte a [ assert_cmp::$2 ]
reg byte a [ assert_cmp::$1 ]
reg byte a [ assert_cmp::$0 ]
reg byte a [ strncmp::$0 ]
reg byte a [ memcmp::$3 ]
reg byte a [ cputs::c#1 ]
reg byte a [ printf_str::c#1 ]
reg byte a [ printf_number_buffer::buffer_sign#0 ]
zp[1]:25 [ uctoa::digit_value#0 uctoa_append::sub#0 ]
zp[2]:29 [ memcpy::src_end#0 ]
zp[2]:31 [ memset::end#0 memcpy::destination#2 memcpy::dst#2 memcpy::dst#4 memcpy::dst#1 ]
zp[1]:33 [ uctoa::digit_value#0 uctoa_append::sub#0 ]
reg byte x [ uctoa_append::return#0 ]
zp[2]:26 [ memcpy::src_end#0 uctoa::buffer#11 uctoa::buffer#14 uctoa::buffer#4 uctoa::buffer#3 uctoa_append::buffer#0 memcmp::return#2 memcmp::return#1 memcmp::return#3 memcmp::return#4 memcmp::return#10 memcmp::return#11 strncmp::s2#2 strncmp::s2#0 strncmp::s2#1 strcmp::return#11 strcmp::return#0 strcmp::return#12 strcmp::return#13 strcmp::return#14 strcmp::return#15 strcmp::return#16 strcmp::return#17 strcmp::return#18 strcmp::return#10 ]
zp[2]:28 [ memset::end#0 memcpy::destination#2 memcpy::dst#2 memcpy::dst#4 memcpy::dst#1 ]
mem[12] [ printf_buffer ]

View File

@ -13,6 +13,7 @@
.const OFFSET_STRUCT_MOS6569_VICII_MEMORY = $18
.const OFFSET_STRUCT_BBS_HOST_NAME = 2
.const OFFSET_STRUCT_BBS_PORT_NUMBER = 4
.const STACK_BASE = $103
.const SIZEOF_STRUCT_PRINTF_BUFFER_NUMBER = $c
/// The VIC-II MOS 6567/6569
.label VICII = $d000
@ -22,13 +23,13 @@
.label DEFAULT_SCREEN = $400
// The number of bytes on the screen
// The current cursor x-position
.label conio_cursor_x = 9
.label conio_cursor_x = $b
// The current cursor y-position
.label conio_cursor_y = $a
.label conio_cursor_y = $c
// The current text cursor line start
.label conio_line_text = $b
.label conio_line_text = $d
// The current color cursor line start
.label conio_line_color = $d
.label conio_line_color = $f
.segment Code
__start: {
// __ma char conio_cursor_x = 0
@ -67,6 +68,37 @@ conio_c64_init: {
// }
rts
}
// Output one character at the current cursor position
// Moves the cursor forward. Scrolls the entire screen if needed
// void cputc(__register(A) char c)
cputc: {
.const OFFSET_STACK_C = 0
tsx
lda STACK_BASE+OFFSET_STACK_C,x
// if(c=='\n')
cmp #'\n'
beq __b1
// conio_line_text[conio_cursor_x] = c
ldy.z conio_cursor_x
sta (conio_line_text),y
// conio_line_color[conio_cursor_x] = conio_textcolor
lda #LIGHT_BLUE
sta (conio_line_color),y
// if(++conio_cursor_x==CONIO_WIDTH)
inc.z conio_cursor_x
lda #$28
cmp.z conio_cursor_x
bne __breturn
// cputln()
jsr cputln
__breturn:
// }
rts
__b1:
// cputln()
jsr cputln
rts
}
main: {
.label bbs = 2
// VICII->MEMORY = 0x17
@ -97,11 +129,15 @@ main: {
sta.z printf_string.str+1
jsr printf_string
// printf("%s %s %u\n", bbs->name, bbs->host_name, bbs->port_number)
lda #<cputc
sta.z printf_str.putc
lda #>cputc
sta.z printf_str.putc+1
lda #<s
sta.z cputs.s
sta.z printf_str.s
lda #>s
sta.z cputs.s+1
jsr cputs
sta.z printf_str.s+1
jsr printf_str
// printf("%s %s %u\n", bbs->name, bbs->host_name, bbs->port_number)
ldy #OFFSET_STRUCT_BBS_HOST_NAME
lda (bbs),y
@ -111,11 +147,15 @@ main: {
sta.z printf_string.str+1
jsr printf_string
// printf("%s %s %u\n", bbs->name, bbs->host_name, bbs->port_number)
lda #<cputc
sta.z printf_str.putc
lda #>cputc
sta.z printf_str.putc+1
lda #<s
sta.z cputs.s
sta.z printf_str.s
lda #>s
sta.z cputs.s+1
jsr cputs
sta.z printf_str.s+1
jsr printf_str
// printf("%s %s %u\n", bbs->name, bbs->host_name, bbs->port_number)
ldy #OFFSET_STRUCT_BBS_PORT_NUMBER
lda (bbs),y
@ -125,11 +165,15 @@ main: {
sta.z printf_uint.uvalue+1
jsr printf_uint
// printf("%s %s %u\n", bbs->name, bbs->host_name, bbs->port_number)
lda #<cputc
sta.z printf_str.putc
lda #>cputc
sta.z printf_str.putc+1
lda #<s2
sta.z cputs.s
sta.z printf_str.s
lda #>s2
sta.z cputs.s+1
jsr cputs
sta.z printf_str.s+1
jsr printf_str
// for(struct bbs * bbs = bbs_list; bbs->name; bbs++)
lda #SIZEOF_STRUCT_BBS
clc
@ -150,12 +194,12 @@ main: {
// void gotoxy(char x, __register(X) char y)
gotoxy: {
.const x = 0
.label __5 = $13
.label __6 = $f
.label __7 = $f
.label line_offset = $f
.label __8 = $11
.label __9 = $f
.label __5 = $15
.label __6 = $11
.label __7 = $11
.label line_offset = $11
.label __8 = $13
.label __9 = $11
// if(y>CONIO_HEIGHT)
cpx #$19+1
bcc __b2
@ -221,20 +265,53 @@ gotoxy: {
// }
rts
}
// Print a string value using a specific format
// Handles justification and min length
// void printf_string(__zp(5) char *str, char format_min_length, char format_justify_left)
printf_string: {
.label str = 5
// cputs(str)
jsr cputs
// Print a newline
cputln: {
// conio_line_text += CONIO_WIDTH
lda #$28
clc
adc.z conio_line_text
sta.z conio_line_text
bcc !+
inc.z conio_line_text+1
!:
// conio_line_color += CONIO_WIDTH
lda #$28
clc
adc.z conio_line_color
sta.z conio_line_color
bcc !+
inc.z conio_line_color+1
!:
// conio_cursor_x = 0
lda #0
sta.z conio_cursor_x
// conio_cursor_y++;
inc.z conio_cursor_y
// cscroll()
jsr cscroll
// }
rts
}
// Output a NUL-terminated string at the current cursor position
// void cputs(__zp(5) const char *s)
cputs: {
// Print a string value using a specific format
// Handles justification and min length
// void printf_string(void (*putc)(char), __zp(5) char *str, char format_min_length, char format_justify_left)
printf_string: {
.label str = 5
// printf_str(putc, str)
lda #<cputc
sta.z printf_str.putc
lda #>cputc
sta.z printf_str.putc+1
jsr printf_str
// }
rts
}
/// Print a NUL-terminated string
// void printf_str(__zp(7) void (*putc)(char), __zp(5) const char *s)
printf_str: {
.label s = 5
.label putc = 7
__b1:
// while(c=*s++)
ldy #0
@ -248,13 +325,18 @@ cputs: {
// }
rts
__b2:
// cputc(c)
jsr cputc
// putc(c)
pha
jsr icall1
pla
jmp __b1
icall1:
jmp (putc)
}
// Print an unsigned int using a specific format
// void printf_uint(__zp(5) unsigned int uvalue, char format_min_length, char format_justify_left, char format_sign_always, char format_zero_padding, char format_upper_case, char format_radix)
// void printf_uint(void (*putc)(char), __zp(5) unsigned int uvalue, char format_min_length, char format_justify_left, char format_sign_always, char format_zero_padding, char format_upper_case, char format_radix)
printf_uint: {
.label putc = cputc
.label uvalue = 5
// printf_buffer.sign = format.sign_always?'+':0
// Handle any sign
@ -263,51 +345,85 @@ printf_uint: {
// utoa(uvalue, printf_buffer.digits, format.radix)
// Format number into buffer
jsr utoa
// printf_number_buffer(printf_buffer, format)
// printf_number_buffer(putc, printf_buffer, format)
lda printf_buffer
// Print using format
jsr printf_number_buffer
// }
rts
}
// Output one character at the current cursor position
// Moves the cursor forward. Scrolls the entire screen if needed
// void cputc(__register(A) char c)
cputc: {
// if(c=='\n')
cmp #'\n'
beq __b1
// conio_line_text[conio_cursor_x] = c
ldy.z conio_cursor_x
sta (conio_line_text),y
// conio_line_color[conio_cursor_x] = conio_textcolor
lda #LIGHT_BLUE
sta (conio_line_color),y
// if(++conio_cursor_x==CONIO_WIDTH)
inc.z conio_cursor_x
lda #$28
cmp.z conio_cursor_x
// Scroll the entire screen if the cursor is beyond the last line
cscroll: {
// if(conio_cursor_y==CONIO_HEIGHT)
lda #$19
cmp.z conio_cursor_y
bne __breturn
// cputln()
jsr cputln
// memcpy(CONIO_SCREEN_TEXT, CONIO_SCREEN_TEXT+CONIO_WIDTH, CONIO_BYTES-CONIO_WIDTH)
lda #<DEFAULT_SCREEN
sta.z memcpy.destination
lda #>DEFAULT_SCREEN
sta.z memcpy.destination+1
lda #<DEFAULT_SCREEN+$28
sta.z memcpy.source
lda #>DEFAULT_SCREEN+$28
sta.z memcpy.source+1
jsr memcpy
// memcpy(CONIO_SCREEN_COLORS, CONIO_SCREEN_COLORS+CONIO_WIDTH, CONIO_BYTES-CONIO_WIDTH)
lda #<COLORRAM
sta.z memcpy.destination
lda #>COLORRAM
sta.z memcpy.destination+1
lda #<COLORRAM+$28
sta.z memcpy.source
lda #>COLORRAM+$28
sta.z memcpy.source+1
jsr memcpy
// memset(CONIO_SCREEN_TEXT+CONIO_BYTES-CONIO_WIDTH, ' ', CONIO_WIDTH)
ldx #' '
lda #<DEFAULT_SCREEN+$19*$28-$28
sta.z memset.str
lda #>DEFAULT_SCREEN+$19*$28-$28
sta.z memset.str+1
jsr memset
// memset(CONIO_SCREEN_COLORS+CONIO_BYTES-CONIO_WIDTH, conio_textcolor, CONIO_WIDTH)
ldx #LIGHT_BLUE
lda #<COLORRAM+$19*$28-$28
sta.z memset.str
lda #>COLORRAM+$19*$28-$28
sta.z memset.str+1
jsr memset
// conio_line_text -= CONIO_WIDTH
sec
lda.z conio_line_text
sbc #$28
sta.z conio_line_text
lda.z conio_line_text+1
sbc #0
sta.z conio_line_text+1
// conio_line_color -= CONIO_WIDTH
sec
lda.z conio_line_color
sbc #$28
sta.z conio_line_color
lda.z conio_line_color+1
sbc #0
sta.z conio_line_color+1
// conio_cursor_y--;
dec.z conio_cursor_y
__breturn:
// }
rts
__b1:
// cputln()
jsr cputln
rts
}
// Converts unsigned number value to a string representing it in RADIX format.
// If the leading digits are zero they are not included in the string.
// - value : The number to be converted to RADIX
// - buffer : receives the string representing the number and zero-termination.
// - radix : The radix to convert the number to (from the enum RADIX)
// void utoa(__zp(5) unsigned int value, __zp($17) char *buffer, char radix)
// void utoa(__zp(5) unsigned int value, __zp(7) char *buffer, char radix)
utoa: {
.const max_digits = 5
.label digit_value = $15
.label buffer = $17
.label digit_value = $17
.label buffer = 7
.label digit = 4
.label value = 5
lda #<printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
@ -376,167 +492,39 @@ utoa: {
}
// Print the contents of the number buffer using a specific format.
// This handles minimum length, zero-filling, and left/right justification from the format
// void printf_number_buffer(__register(A) char buffer_sign, char *buffer_digits, char format_min_length, char format_justify_left, char format_sign_always, char format_zero_padding, char format_upper_case, char format_radix)
// void printf_number_buffer(void (*putc)(char), __register(A) char buffer_sign, char *buffer_digits, char format_min_length, char format_justify_left, char format_sign_always, char format_zero_padding, char format_upper_case, char format_radix)
printf_number_buffer: {
.label buffer_digits = printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
// if(buffer.sign)
cmp #0
beq __b2
// cputc(buffer.sign)
// putc(buffer.sign)
pha
jsr cputc
pla
__b2:
// cputs(buffer.digits)
// printf_str(putc, buffer.digits)
lda #<printf_uint.putc
sta.z printf_str.putc
lda #>printf_uint.putc
sta.z printf_str.putc+1
lda #<buffer_digits
sta.z cputs.s
sta.z printf_str.s
lda #>buffer_digits
sta.z cputs.s+1
jsr cputs
// }
rts
}
// Print a newline
cputln: {
// conio_line_text += CONIO_WIDTH
lda #$28
clc
adc.z conio_line_text
sta.z conio_line_text
bcc !+
inc.z conio_line_text+1
!:
// conio_line_color += CONIO_WIDTH
lda #$28
clc
adc.z conio_line_color
sta.z conio_line_color
bcc !+
inc.z conio_line_color+1
!:
// conio_cursor_x = 0
lda #0
sta.z conio_cursor_x
// conio_cursor_y++;
inc.z conio_cursor_y
// cscroll()
jsr cscroll
// }
rts
}
// Used to convert a single digit of an unsigned number value to a string representation
// Counts a single digit up from '0' as long as the value is larger than sub.
// Each time the digit is increased sub is subtracted from value.
// - buffer : pointer to the char that receives the digit
// - value : The value where the digit will be derived from
// - sub : the value of a '1' in the digit. Subtracted continually while the digit is increased.
// (For decimal the subs used are 10000, 1000, 100, 10, 1)
// returns : the value reduced by sub * digit so that it is less than sub.
// __zp(5) unsigned int utoa_append(__zp($17) char *buffer, __zp(5) unsigned int value, __zp($15) unsigned int sub)
utoa_append: {
.label buffer = $17
.label value = 5
.label sub = $15
.label return = 5
ldx #0
__b1:
// while (value >= sub)
lda.z sub+1
cmp.z value+1
bne !+
lda.z sub
cmp.z value
beq __b2
!:
bcc __b2
// *buffer = DIGITS[digit]
lda DIGITS,x
ldy #0
sta (buffer),y
// }
rts
__b2:
// digit++;
inx
// value -= sub
lda.z value
sec
sbc.z sub
sta.z value
lda.z value+1
sbc.z sub+1
sta.z value+1
jmp __b1
}
// Scroll the entire screen if the cursor is beyond the last line
cscroll: {
// if(conio_cursor_y==CONIO_HEIGHT)
lda #$19
cmp.z conio_cursor_y
bne __breturn
// memcpy(CONIO_SCREEN_TEXT, CONIO_SCREEN_TEXT+CONIO_WIDTH, CONIO_BYTES-CONIO_WIDTH)
lda #<DEFAULT_SCREEN
sta.z memcpy.destination
lda #>DEFAULT_SCREEN
sta.z memcpy.destination+1
lda #<DEFAULT_SCREEN+$28
sta.z memcpy.source
lda #>DEFAULT_SCREEN+$28
sta.z memcpy.source+1
jsr memcpy
// memcpy(CONIO_SCREEN_COLORS, CONIO_SCREEN_COLORS+CONIO_WIDTH, CONIO_BYTES-CONIO_WIDTH)
lda #<COLORRAM
sta.z memcpy.destination
lda #>COLORRAM
sta.z memcpy.destination+1
lda #<COLORRAM+$28
sta.z memcpy.source
lda #>COLORRAM+$28
sta.z memcpy.source+1
jsr memcpy
// memset(CONIO_SCREEN_TEXT+CONIO_BYTES-CONIO_WIDTH, ' ', CONIO_WIDTH)
ldx #' '
lda #<DEFAULT_SCREEN+$19*$28-$28
sta.z memset.str
lda #>DEFAULT_SCREEN+$19*$28-$28
sta.z memset.str+1
jsr memset
// memset(CONIO_SCREEN_COLORS+CONIO_BYTES-CONIO_WIDTH, conio_textcolor, CONIO_WIDTH)
ldx #LIGHT_BLUE
lda #<COLORRAM+$19*$28-$28
sta.z memset.str
lda #>COLORRAM+$19*$28-$28
sta.z memset.str+1
jsr memset
// conio_line_text -= CONIO_WIDTH
sec
lda.z conio_line_text
sbc #$28
sta.z conio_line_text
lda.z conio_line_text+1
sbc #0
sta.z conio_line_text+1
// conio_line_color -= CONIO_WIDTH
sec
lda.z conio_line_color
sbc #$28
sta.z conio_line_color
lda.z conio_line_color+1
sbc #0
sta.z conio_line_color+1
// conio_cursor_y--;
dec.z conio_cursor_y
__breturn:
sta.z printf_str.s+1
jsr printf_str
// }
rts
}
// Copy block of memory (forwards)
// Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
// void * memcpy(__zp(7) void *destination, __zp($17) void *source, unsigned int num)
// void * memcpy(__zp($1b) void *destination, __zp(9) void *source, unsigned int num)
memcpy: {
.label src_end = $15
.label dst = 7
.label src = $17
.label source = $17
.label destination = 7
.label src_end = $19
.label dst = $1b
.label src = 9
.label source = 9
.label destination = $1b
// char* src_end = (char*)source+num
lda.z source
clc
@ -572,11 +560,11 @@ memcpy: {
jmp __b1
}
// Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
// void * memset(__zp(7) void *str, __register(X) char c, unsigned int num)
// void * memset(__zp(9) void *str, __register(X) char c, unsigned int num)
memset: {
.label end = $17
.label dst = 7
.label str = 7
.label end = $1b
.label dst = 9
.label str = 9
// char* end = (char*)str + num
lda #$28
clc
@ -607,6 +595,50 @@ memset: {
!:
jmp __b2
}
// Used to convert a single digit of an unsigned number value to a string representation
// Counts a single digit up from '0' as long as the value is larger than sub.
// Each time the digit is increased sub is subtracted from value.
// - buffer : pointer to the char that receives the digit
// - value : The value where the digit will be derived from
// - sub : the value of a '1' in the digit. Subtracted continually while the digit is increased.
// (For decimal the subs used are 10000, 1000, 100, 10, 1)
// returns : the value reduced by sub * digit so that it is less than sub.
// __zp(5) unsigned int utoa_append(__zp(7) char *buffer, __zp(5) unsigned int value, __zp($17) unsigned int sub)
utoa_append: {
.label buffer = 7
.label value = 5
.label sub = $17
.label return = 5
ldx #0
__b1:
// while (value >= sub)
lda.z sub+1
cmp.z value+1
bne !+
lda.z sub
cmp.z value
beq __b2
!:
bcc __b2
// *buffer = DIGITS[digit]
lda DIGITS,x
ldy #0
sta (buffer),y
// }
rts
__b2:
// digit++;
inx
// value -= sub
lda.z value
sec
sbc.z sub
sta.z value
lda.z value+1
sbc.z sub+1
sta.z value+1
jmp __b1
}
.segment Data
// The digits used for numbers
DIGITS: .text "0123456789abcdef"

View File

@ -35,307 +35,310 @@ conio_c64_init::@return: scope:[conio_c64_init] from conio_c64_init::@1
[15] return
to:@return
__stackcall void cputc(char c)
cputc: scope:[cputc] from printf_number_buffer::@3
[16] cputc::c#0 = stackidx(char,cputc::OFFSET_STACK_C)
[17] if(cputc::c#0=='
') goto cputc::@1
to:cputc::@2
cputc::@2: scope:[cputc] from cputc
[18] conio_line_text[conio_cursor_x] = cputc::c#0
[19] conio_line_color[conio_cursor_x] = LIGHT_BLUE
[20] conio_cursor_x = ++ conio_cursor_x
[21] if(conio_cursor_x!=$28) goto cputc::@return
to:cputc::@3
cputc::@3: scope:[cputc] from cputc::@2
[22] phi()
[23] call cputln
to:cputc::@return
cputc::@return: scope:[cputc] from cputc::@1 cputc::@2 cputc::@3
[24] return
to:@return
cputc::@1: scope:[cputc] from cputc
[25] phi()
[26] call cputln
to:cputc::@return
void main()
main: scope:[main] from __start::@1
[16] *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_MEMORY) = $17
[27] *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_MEMORY) = $17
to:main::@1
main::@1: scope:[main] from main main::@8
[17] main::bbs#2 = phi( main/bbs_list, main::@8/main::bbs#1 )
[18] if((char *)0!=*((char **)main::bbs#2)) goto main::@2
[28] main::bbs#2 = phi( main/bbs_list, main::@8/main::bbs#1 )
[29] if((char *)0!=*((char **)main::bbs#2)) goto main::@2
to:main::@return
main::@return: scope:[main] from main::@1
[19] return
[30] return
to:@return
main::@2: scope:[main] from main::@1
[20] printf_string::str#0 = *((char **)main::bbs#2)
[21] call printf_string
[31] printf_string::str#0 = *((char **)main::bbs#2)
[32] call printf_string
to:main::@3
main::@3: scope:[main] from main::@2
[22] phi()
[23] call cputs
[33] phi()
[34] call printf_str
to:main::@4
main::@4: scope:[main] from main::@3
[24] printf_string::str#1 = ((char **)main::bbs#2)[OFFSET_STRUCT_BBS_HOST_NAME]
[25] call printf_string
[35] printf_string::str#1 = ((char **)main::bbs#2)[OFFSET_STRUCT_BBS_HOST_NAME]
[36] call printf_string
to:main::@5
main::@5: scope:[main] from main::@4
[26] phi()
[27] call cputs
[37] phi()
[38] call printf_str
to:main::@6
main::@6: scope:[main] from main::@5
[28] printf_uint::uvalue#0 = ((unsigned int *)main::bbs#2)[OFFSET_STRUCT_BBS_PORT_NUMBER]
[29] call printf_uint
[39] printf_uint::uvalue#0 = ((unsigned int *)main::bbs#2)[OFFSET_STRUCT_BBS_PORT_NUMBER]
[40] call printf_uint
to:main::@7
main::@7: scope:[main] from main::@6
[30] phi()
[31] call cputs
[41] phi()
[42] call printf_str
to:main::@8
main::@8: scope:[main] from main::@7
[32] main::bbs#1 = main::bbs#2 + SIZEOF_STRUCT_BBS
[43] main::bbs#1 = main::bbs#2 + SIZEOF_STRUCT_BBS
to:main::@1
void gotoxy(char x , char y)
gotoxy: scope:[gotoxy] from conio_c64_init::@1
[33] if(gotoxy::y#2<$19+1) goto gotoxy::@3
[44] if(gotoxy::y#2<$19+1) goto gotoxy::@3
to:gotoxy::@1
gotoxy::@3: scope:[gotoxy] from gotoxy
[34] phi()
[45] phi()
to:gotoxy::@1
gotoxy::@1: scope:[gotoxy] from gotoxy gotoxy::@3
[35] gotoxy::y#4 = phi( gotoxy::@3/gotoxy::y#2, gotoxy/0 )
[46] gotoxy::y#4 = phi( gotoxy::@3/gotoxy::y#2, gotoxy/0 )
to:gotoxy::@2
gotoxy::@2: scope:[gotoxy] from gotoxy::@1
[36] conio_cursor_x = gotoxy::x#2
[37] conio_cursor_y = gotoxy::y#4
[38] gotoxy::$7 = (unsigned int)gotoxy::y#4
[39] gotoxy::$8 = gotoxy::$7 << 2
[40] gotoxy::$9 = gotoxy::$8 + gotoxy::$7
[41] gotoxy::line_offset#0 = gotoxy::$9 << 3
[42] gotoxy::$5 = DEFAULT_SCREEN + gotoxy::line_offset#0
[43] conio_line_text = gotoxy::$5
[44] gotoxy::$6 = COLORRAM + gotoxy::line_offset#0
[45] conio_line_color = gotoxy::$6
[47] conio_cursor_x = gotoxy::x#2
[48] conio_cursor_y = gotoxy::y#4
[49] gotoxy::$7 = (unsigned int)gotoxy::y#4
[50] gotoxy::$8 = gotoxy::$7 << 2
[51] gotoxy::$9 = gotoxy::$8 + gotoxy::$7
[52] gotoxy::line_offset#0 = gotoxy::$9 << 3
[53] gotoxy::$5 = DEFAULT_SCREEN + gotoxy::line_offset#0
[54] conio_line_text = gotoxy::$5
[55] gotoxy::$6 = COLORRAM + gotoxy::line_offset#0
[56] conio_line_color = gotoxy::$6
to:gotoxy::@return
gotoxy::@return: scope:[gotoxy] from gotoxy::@2
[46] return
to:@return
void printf_string(char *str , char format_min_length , char format_justify_left)
printf_string: scope:[printf_string] from main::@2 main::@4
[47] printf_string::str#2 = phi( main::@2/printf_string::str#0, main::@4/printf_string::str#1 )
to:printf_string::@1
printf_string::@1: scope:[printf_string] from printf_string
[48] cputs::s#2 = printf_string::str#2
[49] call cputs
to:printf_string::@return
printf_string::@return: scope:[printf_string] from printf_string::@1
[50] return
to:@return
void cputs(const char *s)
cputs: scope:[cputs] from main::@3 main::@5 main::@7 printf_number_buffer::@2 printf_string::@1
[51] cputs::s#7 = phi( main::@3/main::s, main::@5/main::s, main::@7/main::s2, printf_number_buffer::@2/printf_number_buffer::buffer_digits#0, printf_string::@1/cputs::s#2 )
to:cputs::@1
cputs::@1: scope:[cputs] from cputs cputs::@2
[52] cputs::s#6 = phi( cputs/cputs::s#7, cputs::@2/cputs::s#0 )
[53] cputs::c#1 = *cputs::s#6
[54] cputs::s#0 = ++ cputs::s#6
[55] if(0!=cputs::c#1) goto cputs::@2
to:cputs::@return
cputs::@return: scope:[cputs] from cputs::@1
[56] return
to:@return
cputs::@2: scope:[cputs] from cputs::@1
[57] cputc::c#0 = cputs::c#1
[58] call cputc
to:cputs::@1
void printf_uint(unsigned int uvalue , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
printf_uint: scope:[printf_uint] from main::@6
[59] phi()
to:printf_uint::@1
printf_uint::@1: scope:[printf_uint] from printf_uint
[60] *((char *)&printf_buffer) = 0
[61] utoa::value#1 = printf_uint::uvalue#0
[62] call utoa
to:printf_uint::@2
printf_uint::@2: scope:[printf_uint] from printf_uint::@1
[63] printf_number_buffer::buffer_sign#0 = *((char *)&printf_buffer)
[64] call printf_number_buffer
to:printf_uint::@return
printf_uint::@return: scope:[printf_uint] from printf_uint::@2
[65] return
to:@return
void cputc(char c)
cputc: scope:[cputc] from cputs::@2 printf_number_buffer::@3
[66] cputc::c#3 = phi( cputs::@2/cputc::c#0, printf_number_buffer::@3/cputc::c#2 )
[67] if(cputc::c#3=='
') goto cputc::@1
to:cputc::@2
cputc::@2: scope:[cputc] from cputc
[68] conio_line_text[conio_cursor_x] = cputc::c#3
[69] conio_line_color[conio_cursor_x] = LIGHT_BLUE
[70] conio_cursor_x = ++ conio_cursor_x
[71] if(conio_cursor_x!=$28) goto cputc::@return
to:cputc::@3
cputc::@3: scope:[cputc] from cputc::@2
[72] phi()
[73] call cputln
to:cputc::@return
cputc::@return: scope:[cputc] from cputc::@1 cputc::@2 cputc::@3
[74] return
to:@return
cputc::@1: scope:[cputc] from cputc
[75] phi()
[76] call cputln
to:cputc::@return
void utoa(unsigned int value , char *buffer , char radix)
utoa: scope:[utoa] from printf_uint::@1
[77] phi()
to:utoa::@1
utoa::@1: scope:[utoa] from utoa utoa::@4
[78] utoa::buffer#11 = phi( utoa::@4/utoa::buffer#14, utoa/(char *)&printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS )
[78] utoa::started#2 = phi( utoa::@4/utoa::started#4, utoa/0 )
[78] utoa::value#2 = phi( utoa::@4/utoa::value#6, utoa/utoa::value#1 )
[78] utoa::digit#2 = phi( utoa::@4/utoa::digit#1, utoa/0 )
[79] if(utoa::digit#2<utoa::max_digits#1-1) goto utoa::@2
to:utoa::@3
utoa::@3: scope:[utoa] from utoa::@1
[80] utoa::$11 = (char)utoa::value#2
[81] *utoa::buffer#11 = DIGITS[utoa::$11]
[82] utoa::buffer#3 = ++ utoa::buffer#11
[83] *utoa::buffer#3 = 0
to:utoa::@return
utoa::@return: scope:[utoa] from utoa::@3
[84] return
to:@return
utoa::@2: scope:[utoa] from utoa::@1
[85] utoa::$10 = utoa::digit#2 << 1
[86] utoa::digit_value#0 = RADIX_DECIMAL_VALUES[utoa::$10]
[87] if(0!=utoa::started#2) goto utoa::@5
to:utoa::@7
utoa::@7: scope:[utoa] from utoa::@2
[88] if(utoa::value#2>=utoa::digit_value#0) goto utoa::@5
to:utoa::@4
utoa::@4: scope:[utoa] from utoa::@6 utoa::@7
[89] utoa::buffer#14 = phi( utoa::@7/utoa::buffer#11, utoa::@6/utoa::buffer#4 )
[89] utoa::started#4 = phi( utoa::@7/utoa::started#2, utoa::@6/1 )
[89] utoa::value#6 = phi( utoa::@7/utoa::value#2, utoa::@6/utoa::value#0 )
[90] utoa::digit#1 = ++ utoa::digit#2
to:utoa::@1
utoa::@5: scope:[utoa] from utoa::@2 utoa::@7
[91] utoa_append::buffer#0 = utoa::buffer#11
[92] utoa_append::value#0 = utoa::value#2
[93] utoa_append::sub#0 = utoa::digit_value#0
[94] call utoa_append
[95] utoa_append::return#0 = utoa_append::value#2
to:utoa::@6
utoa::@6: scope:[utoa] from utoa::@5
[96] utoa::value#0 = utoa_append::return#0
[97] utoa::buffer#4 = ++ utoa::buffer#11
to:utoa::@4
void printf_number_buffer(char buffer_sign , char *buffer_digits , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
printf_number_buffer: scope:[printf_number_buffer] from printf_uint::@2
[98] phi()
to:printf_number_buffer::@1
printf_number_buffer::@1: scope:[printf_number_buffer] from printf_number_buffer
[99] if(0==printf_number_buffer::buffer_sign#0) goto printf_number_buffer::@2
to:printf_number_buffer::@3
printf_number_buffer::@3: scope:[printf_number_buffer] from printf_number_buffer::@1
[100] cputc::c#2 = printf_number_buffer::buffer_sign#0
[101] call cputc
to:printf_number_buffer::@2
printf_number_buffer::@2: scope:[printf_number_buffer] from printf_number_buffer::@1 printf_number_buffer::@3
[102] phi()
[103] call cputs
to:printf_number_buffer::@return
printf_number_buffer::@return: scope:[printf_number_buffer] from printf_number_buffer::@2
[104] return
[57] return
to:@return
void cputln()
cputln: scope:[cputln] from cputc::@1 cputc::@3
[105] conio_line_text = conio_line_text + $28
[106] conio_line_color = conio_line_color + $28
[107] conio_cursor_x = 0
[108] conio_cursor_y = ++ conio_cursor_y
[109] call cscroll
[58] conio_line_text = conio_line_text + $28
[59] conio_line_color = conio_line_color + $28
[60] conio_cursor_x = 0
[61] conio_cursor_y = ++ conio_cursor_y
[62] call cscroll
to:cputln::@return
cputln::@return: scope:[cputln] from cputln
[110] return
[63] return
to:@return
unsigned int utoa_append(char *buffer , unsigned int value , unsigned int sub)
utoa_append: scope:[utoa_append] from utoa::@5
[111] phi()
to:utoa_append::@1
utoa_append::@1: scope:[utoa_append] from utoa_append utoa_append::@2
[112] utoa_append::digit#2 = phi( utoa_append/0, utoa_append::@2/utoa_append::digit#1 )
[112] utoa_append::value#2 = phi( utoa_append/utoa_append::value#0, utoa_append::@2/utoa_append::value#1 )
[113] if(utoa_append::value#2>=utoa_append::sub#0) goto utoa_append::@2
to:utoa_append::@3
utoa_append::@3: scope:[utoa_append] from utoa_append::@1
[114] *utoa_append::buffer#0 = DIGITS[utoa_append::digit#2]
to:utoa_append::@return
utoa_append::@return: scope:[utoa_append] from utoa_append::@3
[115] return
void printf_string(void (*putc)(char) , char *str , char format_min_length , char format_justify_left)
printf_string: scope:[printf_string] from main::@2 main::@4
[64] printf_string::str#2 = phi( main::@2/printf_string::str#0, main::@4/printf_string::str#1 )
to:printf_string::@1
printf_string::@1: scope:[printf_string] from printf_string
[65] printf_str::s#2 = printf_string::str#2
[66] call printf_str
to:printf_string::@return
printf_string::@return: scope:[printf_string] from printf_string::@1
[67] return
to:@return
void printf_str(void (*putc)(char) , const char *s)
printf_str: scope:[printf_str] from main::@3 main::@5 main::@7 printf_number_buffer::@2 printf_string::@1
[68] printf_str::putc#7 = phi( main::@3/&cputc, main::@5/&cputc, main::@7/&cputc, printf_number_buffer::@2/printf_uint::putc#0, printf_string::@1/&cputc )
[68] printf_str::s#7 = phi( main::@3/main::s, main::@5/main::s, main::@7/main::s2, printf_number_buffer::@2/printf_number_buffer::buffer_digits#0, printf_string::@1/printf_str::s#2 )
to:printf_str::@1
printf_str::@1: scope:[printf_str] from printf_str printf_str::@2
[69] printf_str::s#6 = phi( printf_str/printf_str::s#7, printf_str::@2/printf_str::s#0 )
[70] printf_str::c#1 = *printf_str::s#6
[71] printf_str::s#0 = ++ printf_str::s#6
[72] if(0!=printf_str::c#1) goto printf_str::@2
to:printf_str::@return
printf_str::@return: scope:[printf_str] from printf_str::@1
[73] return
to:@return
printf_str::@2: scope:[printf_str] from printf_str::@1
[74] stackpush(char) = printf_str::c#1
[75] callexecute *printf_str::putc#7
sideeffect stackpullbytes(1)
to:printf_str::@1
void printf_uint(void (*putc)(char) , unsigned int uvalue , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
printf_uint: scope:[printf_uint] from main::@6
[77] phi()
to:printf_uint::@1
printf_uint::@1: scope:[printf_uint] from printf_uint
[78] *((char *)&printf_buffer) = 0
[79] utoa::value#1 = printf_uint::uvalue#0
[80] call utoa
to:printf_uint::@2
printf_uint::@2: scope:[printf_uint] from printf_uint::@1
[81] printf_number_buffer::buffer_sign#0 = *((char *)&printf_buffer)
[82] call printf_number_buffer
to:printf_uint::@return
printf_uint::@return: scope:[printf_uint] from printf_uint::@2
[83] return
to:@return
utoa_append::@2: scope:[utoa_append] from utoa_append::@1
[116] utoa_append::digit#1 = ++ utoa_append::digit#2
[117] utoa_append::value#1 = utoa_append::value#2 - utoa_append::sub#0
to:utoa_append::@1
void cscroll()
cscroll: scope:[cscroll] from cputln
[118] if(conio_cursor_y!=$19) goto cscroll::@return
[84] if(conio_cursor_y!=$19) goto cscroll::@return
to:cscroll::@1
cscroll::@1: scope:[cscroll] from cscroll
[119] phi()
[120] call memcpy
[85] phi()
[86] call memcpy
to:cscroll::@2
cscroll::@2: scope:[cscroll] from cscroll::@1
[121] phi()
[122] call memcpy
[87] phi()
[88] call memcpy
to:cscroll::@3
cscroll::@3: scope:[cscroll] from cscroll::@2
[123] phi()
[124] call memset
[89] phi()
[90] call memset
to:cscroll::@4
cscroll::@4: scope:[cscroll] from cscroll::@3
[125] phi()
[126] call memset
[91] phi()
[92] call memset
to:cscroll::@5
cscroll::@5: scope:[cscroll] from cscroll::@4
[127] conio_line_text = conio_line_text - $28
[128] conio_line_color = conio_line_color - $28
[129] conio_cursor_y = -- conio_cursor_y
[93] conio_line_text = conio_line_text - $28
[94] conio_line_color = conio_line_color - $28
[95] conio_cursor_y = -- conio_cursor_y
to:cscroll::@return
cscroll::@return: scope:[cscroll] from cscroll cscroll::@5
[130] return
[96] return
to:@return
void utoa(unsigned int value , char *buffer , char radix)
utoa: scope:[utoa] from printf_uint::@1
[97] phi()
to:utoa::@1
utoa::@1: scope:[utoa] from utoa utoa::@4
[98] utoa::buffer#11 = phi( utoa::@4/utoa::buffer#14, utoa/(char *)&printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS )
[98] utoa::started#2 = phi( utoa::@4/utoa::started#4, utoa/0 )
[98] utoa::value#2 = phi( utoa::@4/utoa::value#6, utoa/utoa::value#1 )
[98] utoa::digit#2 = phi( utoa::@4/utoa::digit#1, utoa/0 )
[99] if(utoa::digit#2<utoa::max_digits#1-1) goto utoa::@2
to:utoa::@3
utoa::@3: scope:[utoa] from utoa::@1
[100] utoa::$11 = (char)utoa::value#2
[101] *utoa::buffer#11 = DIGITS[utoa::$11]
[102] utoa::buffer#3 = ++ utoa::buffer#11
[103] *utoa::buffer#3 = 0
to:utoa::@return
utoa::@return: scope:[utoa] from utoa::@3
[104] return
to:@return
utoa::@2: scope:[utoa] from utoa::@1
[105] utoa::$10 = utoa::digit#2 << 1
[106] utoa::digit_value#0 = RADIX_DECIMAL_VALUES[utoa::$10]
[107] if(0!=utoa::started#2) goto utoa::@5
to:utoa::@7
utoa::@7: scope:[utoa] from utoa::@2
[108] if(utoa::value#2>=utoa::digit_value#0) goto utoa::@5
to:utoa::@4
utoa::@4: scope:[utoa] from utoa::@6 utoa::@7
[109] utoa::buffer#14 = phi( utoa::@7/utoa::buffer#11, utoa::@6/utoa::buffer#4 )
[109] utoa::started#4 = phi( utoa::@7/utoa::started#2, utoa::@6/1 )
[109] utoa::value#6 = phi( utoa::@7/utoa::value#2, utoa::@6/utoa::value#0 )
[110] utoa::digit#1 = ++ utoa::digit#2
to:utoa::@1
utoa::@5: scope:[utoa] from utoa::@2 utoa::@7
[111] utoa_append::buffer#0 = utoa::buffer#11
[112] utoa_append::value#0 = utoa::value#2
[113] utoa_append::sub#0 = utoa::digit_value#0
[114] call utoa_append
[115] utoa_append::return#0 = utoa_append::value#2
to:utoa::@6
utoa::@6: scope:[utoa] from utoa::@5
[116] utoa::value#0 = utoa_append::return#0
[117] utoa::buffer#4 = ++ utoa::buffer#11
to:utoa::@4
void printf_number_buffer(void (*putc)(char) , char buffer_sign , char *buffer_digits , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
printf_number_buffer: scope:[printf_number_buffer] from printf_uint::@2
[118] phi()
to:printf_number_buffer::@1
printf_number_buffer::@1: scope:[printf_number_buffer] from printf_number_buffer
[119] if(0==printf_number_buffer::buffer_sign#0) goto printf_number_buffer::@2
to:printf_number_buffer::@3
printf_number_buffer::@3: scope:[printf_number_buffer] from printf_number_buffer::@1
[120] stackpush(char) = printf_number_buffer::buffer_sign#0
[121] callexecute cputc
sideeffect stackpullbytes(1)
to:printf_number_buffer::@2
printf_number_buffer::@2: scope:[printf_number_buffer] from printf_number_buffer::@1 printf_number_buffer::@3
[123] phi()
[124] call printf_str
to:printf_number_buffer::@return
printf_number_buffer::@return: scope:[printf_number_buffer] from printf_number_buffer::@2
[125] return
to:@return
void * memcpy(void *destination , void *source , unsigned int num)
memcpy: scope:[memcpy] from cscroll::@1 cscroll::@2
[131] memcpy::destination#2 = phi( cscroll::@1/(void *)DEFAULT_SCREEN, cscroll::@2/(void *)COLORRAM )
[131] memcpy::source#2 = phi( cscroll::@1/(void *)DEFAULT_SCREEN+$28, cscroll::@2/(void *)COLORRAM+$28 )
[132] memcpy::src_end#0 = (char *)memcpy::source#2 + (unsigned int)$19*$28-$28
[133] memcpy::src#4 = (char *)memcpy::source#2
[134] memcpy::dst#4 = (char *)memcpy::destination#2
[126] memcpy::destination#2 = phi( cscroll::@1/(void *)DEFAULT_SCREEN, cscroll::@2/(void *)COLORRAM )
[126] memcpy::source#2 = phi( cscroll::@1/(void *)DEFAULT_SCREEN+$28, cscroll::@2/(void *)COLORRAM+$28 )
[127] memcpy::src_end#0 = (char *)memcpy::source#2 + (unsigned int)$19*$28-$28
[128] memcpy::src#4 = (char *)memcpy::source#2
[129] memcpy::dst#4 = (char *)memcpy::destination#2
to:memcpy::@1
memcpy::@1: scope:[memcpy] from memcpy memcpy::@2
[135] memcpy::dst#2 = phi( memcpy/memcpy::dst#4, memcpy::@2/memcpy::dst#1 )
[135] memcpy::src#2 = phi( memcpy/memcpy::src#4, memcpy::@2/memcpy::src#1 )
[136] if(memcpy::src#2!=memcpy::src_end#0) goto memcpy::@2
[130] memcpy::dst#2 = phi( memcpy/memcpy::dst#4, memcpy::@2/memcpy::dst#1 )
[130] memcpy::src#2 = phi( memcpy/memcpy::src#4, memcpy::@2/memcpy::src#1 )
[131] if(memcpy::src#2!=memcpy::src_end#0) goto memcpy::@2
to:memcpy::@return
memcpy::@return: scope:[memcpy] from memcpy::@1
[137] return
[132] return
to:@return
memcpy::@2: scope:[memcpy] from memcpy::@1
[138] *memcpy::dst#2 = *memcpy::src#2
[139] memcpy::dst#1 = ++ memcpy::dst#2
[140] memcpy::src#1 = ++ memcpy::src#2
[133] *memcpy::dst#2 = *memcpy::src#2
[134] memcpy::dst#1 = ++ memcpy::dst#2
[135] memcpy::src#1 = ++ memcpy::src#2
to:memcpy::@1
void * memset(void *str , char c , unsigned int num)
memset: scope:[memset] from cscroll::@3 cscroll::@4
[141] memset::c#4 = phi( cscroll::@3/' ', cscroll::@4/LIGHT_BLUE )
[141] memset::str#3 = phi( cscroll::@3/(void *)DEFAULT_SCREEN+(unsigned int)$19*$28-$28, cscroll::@4/(void *)COLORRAM+(unsigned int)$19*$28-$28 )
[136] memset::c#4 = phi( cscroll::@3/' ', cscroll::@4/LIGHT_BLUE )
[136] memset::str#3 = phi( cscroll::@3/(void *)DEFAULT_SCREEN+(unsigned int)$19*$28-$28, cscroll::@4/(void *)COLORRAM+(unsigned int)$19*$28-$28 )
to:memset::@1
memset::@1: scope:[memset] from memset
[142] memset::end#0 = (char *)memset::str#3 + $28
[143] memset::dst#4 = (char *)memset::str#3
[137] memset::end#0 = (char *)memset::str#3 + $28
[138] memset::dst#4 = (char *)memset::str#3
to:memset::@2
memset::@2: scope:[memset] from memset::@1 memset::@3
[144] memset::dst#2 = phi( memset::@1/memset::dst#4, memset::@3/memset::dst#1 )
[145] if(memset::dst#2!=memset::end#0) goto memset::@3
[139] memset::dst#2 = phi( memset::@1/memset::dst#4, memset::@3/memset::dst#1 )
[140] if(memset::dst#2!=memset::end#0) goto memset::@3
to:memset::@return
memset::@return: scope:[memset] from memset::@2
[146] return
[141] return
to:@return
memset::@3: scope:[memset] from memset::@2
[147] *memset::dst#2 = memset::c#4
[148] memset::dst#1 = ++ memset::dst#2
[142] *memset::dst#2 = memset::c#4
[143] memset::dst#1 = ++ memset::dst#2
to:memset::@2
unsigned int utoa_append(char *buffer , unsigned int value , unsigned int sub)
utoa_append: scope:[utoa_append] from utoa::@5
[144] phi()
to:utoa_append::@1
utoa_append::@1: scope:[utoa_append] from utoa_append utoa_append::@2
[145] utoa_append::digit#2 = phi( utoa_append/0, utoa_append::@2/utoa_append::digit#1 )
[145] utoa_append::value#2 = phi( utoa_append/utoa_append::value#0, utoa_append::@2/utoa_append::value#1 )
[146] if(utoa_append::value#2>=utoa_append::sub#0) goto utoa_append::@2
to:utoa_append::@3
utoa_append::@3: scope:[utoa_append] from utoa_append::@1
[147] *utoa_append::buffer#0 = DIGITS[utoa_append::digit#2]
to:utoa_append::@return
utoa_append::@return: scope:[utoa_append] from utoa_append::@3
[148] return
to:@return
utoa_append::@2: scope:[utoa_append] from utoa_append::@1
[149] utoa_append::digit#1 = ++ utoa_append::digit#2
[150] utoa_append::value#1 = utoa_append::value#2 - utoa_append::sub#0
to:utoa_append::@1

File diff suppressed because one or more lines are too long

View File

@ -13,6 +13,7 @@ __constant char RADIX::OCTAL = 8
__constant unsigned int RADIX_DECIMAL_VALUES[] = { $2710, $3e8, $64, $a }
__constant char SIZEOF_STRUCT_BBS = 6
__constant char SIZEOF_STRUCT_PRINTF_BUFFER_NUMBER = $c
__constant unsigned int STACK_BASE = $103
__constant struct MOS6569_VICII * const VICII = (struct MOS6569_VICII *) 53248
void __start()
__constant char bbs_host_name[$f] = "byob.hopto.org"
@ -71,33 +72,24 @@ __constant char * const conio_c64_init::BASIC_CURSOR_LINE = (char *) 214
char conio_c64_init::line
char conio_c64_init::line#0 // reg byte x 11.0
char conio_c64_init::line#2 // reg byte x 22.0
__loadstore char conio_cursor_x // zp[1]:9 2.1428572985714287E7
__loadstore char conio_cursor_y // zp[1]:10 3.720930245116279E8
__loadstore char *conio_line_color // zp[2]:13 2.8333333471794873E8
__loadstore char *conio_line_text // zp[2]:11 2.7625000135E8
void cputc(char c)
__loadstore char conio_cursor_x // zp[1]:11 25425.576271186437
__loadstore char conio_cursor_y // zp[1]:12 426668.1066666667
__loadstore char *conio_line_color // zp[2]:15 329852.35820895527
__loadstore char *conio_line_text // zp[2]:13 320291.4202898551
__stackcall void cputc(char c)
__constant char cputc::OFFSET_STACK_C = 0
char cputc::c
char cputc::c#0 // reg byte a 2.0000002E7
char cputc::c#2 // reg byte a 20002.0
char cputc::c#3 // reg byte a 1.05005002E8
char cputc::c#0 // reg byte a 150001.5
void cputln()
void cputs(const char *s)
char cputs::c
char cputs::c#1 // reg byte a 1.0000001E7
const char *cputs::s
const char *cputs::s#0 // s zp[2]:5 5000000.5
const char *cputs::s#2 // s zp[2]:5 2002.0
const char *cputs::s#6 // s zp[2]:5 1.5050002E7
const char *cputs::s#7 // s zp[2]:5 101002.0
void cscroll()
void gotoxy(char x , char y)
char *gotoxy::$5 // zp[2]:19 202.0
char *gotoxy::$6 // zp[2]:15 202.0
unsigned int gotoxy::$7 // zp[2]:15 151.5
unsigned int gotoxy::$8 // zp[2]:17 202.0
unsigned int gotoxy::$9 // zp[2]:15 202.0
char *gotoxy::$5 // zp[2]:21 202.0
char *gotoxy::$6 // zp[2]:17 202.0
unsigned int gotoxy::$7 // zp[2]:17 151.5
unsigned int gotoxy::$8 // zp[2]:19 202.0
unsigned int gotoxy::$9 // zp[2]:17 202.0
unsigned int gotoxy::line_offset
unsigned int gotoxy::line_offset#0 // line_offset zp[2]:15 101.0
unsigned int gotoxy::line_offset#0 // line_offset zp[2]:17 101.0
char gotoxy::x
__constant char gotoxy::x#2 = 0 // x
char gotoxy::y
@ -112,36 +104,36 @@ __constant char main::s2[2] = "
"
void * memcpy(void *destination , void *source , unsigned int num)
void *memcpy::destination
void *memcpy::destination#2 // destination zp[2]:7
void *memcpy::destination#2 // destination zp[2]:27
char *memcpy::dst
char *memcpy::dst#1 // dst zp[2]:7 1.00000000000001E14
char *memcpy::dst#2 // dst zp[2]:7 1.0003333333333467E14
char *memcpy::dst#4 // dst zp[2]:7 2.00000000002E11
char *memcpy::dst#1 // dst zp[2]:27 1.0000000001E10
char *memcpy::dst#2 // dst zp[2]:27 1.0033333334666666E10
char *memcpy::dst#4 // dst zp[2]:27 2.00000002E8
unsigned int memcpy::num
void *memcpy::return
void *memcpy::source
void *memcpy::source#2 // source zp[2]:23
void *memcpy::source#2 // source zp[2]:9
char *memcpy::src
char *memcpy::src#1 // src zp[2]:23 2.00000000000002E14
char *memcpy::src#2 // src zp[2]:23 1.0002500000000125E14
char *memcpy::src#4 // src zp[2]:23 1.00000000001E11
char *memcpy::src#1 // src zp[2]:9 2.0000000002E10
char *memcpy::src#2 // src zp[2]:9 1.002500000125E10
char *memcpy::src#4 // src zp[2]:9 1.00000001E8
char *memcpy::src_end
char *memcpy::src_end#0 // src_end zp[2]:21 1.251250000000025E13
char *memcpy::src_end#0 // src_end zp[2]:25 1.26250000025E9
void * memset(void *str , char c , unsigned int num)
char memset::c
char memset::c#4 // reg byte x 1.4285714285714428E13
char memset::c#4 // reg byte x 1.4285714287142856E9
char *memset::dst
char *memset::dst#1 // dst zp[2]:7 2.00000000000002E14
char *memset::dst#2 // dst zp[2]:7 1.3336666666666834E14
char *memset::dst#4 // dst zp[2]:7 2.00000000002E11
char *memset::dst#1 // dst zp[2]:9 2.0000000002E10
char *memset::dst#2 // dst zp[2]:9 1.3366666668333332E10
char *memset::dst#4 // dst zp[2]:9 2.00000002E8
char *memset::end
char *memset::end#0 // end zp[2]:23 1.6683333333333668E13
char *memset::end#0 // end zp[2]:27 1.6833333336666665E9
unsigned int memset::num
void *memset::return
void *memset::str
void *memset::str#3 // str zp[2]:7
void *memset::str#3 // str zp[2]:9
__loadstore struct printf_buffer_number printf_buffer = {} // mem[12]
void printf_number_buffer(char buffer_sign , char *buffer_digits , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
void printf_number_buffer(void (*putc)(char) , char buffer_sign , char *buffer_digits , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
struct printf_buffer_number printf_number_buffer::buffer
char *printf_number_buffer::buffer_digits
__constant char *printf_number_buffer::buffer_digits#0 = (char *)&printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS // buffer_digits
@ -156,17 +148,29 @@ char printf_number_buffer::format_upper_case
char printf_number_buffer::format_zero_padding
signed char printf_number_buffer::len
signed char printf_number_buffer::padding
void printf_string(char *str , char format_min_length , char format_justify_left)
void (*printf_number_buffer::putc)(char)
void printf_str(void (*putc)(char) , const char *s)
char printf_str::c
char printf_str::c#1 // reg byte a 1.0000001E7
void (*printf_str::putc)(char)
void (*printf_str::putc#7)(char) // putc zp[2]:7
const char *printf_str::s
const char *printf_str::s#0 // s zp[2]:5 1.0000001E7
const char *printf_str::s#2 // s zp[2]:5 2002.0
const char *printf_str::s#6 // s zp[2]:5 1.5050002E7
const char *printf_str::s#7 // s zp[2]:5 101002.0
void printf_string(void (*putc)(char) , char *str , char format_min_length , char format_justify_left)
struct printf_format_string printf_string::format
char printf_string::format_justify_left
char printf_string::format_min_length
signed char printf_string::len
signed char printf_string::padding
void (*printf_string::putc)(char)
char *printf_string::str
char *printf_string::str#0 // str zp[2]:5 202.0
char *printf_string::str#1 // str zp[2]:5 202.0
char *printf_string::str#2 // str zp[2]:5 1203.0
void printf_uint(unsigned int uvalue , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
void printf_uint(void (*putc)(char) , unsigned int uvalue , char format_min_length , char format_justify_left , char format_sign_always , char format_zero_padding , char format_upper_case , char format_radix)
struct printf_format_number printf_uint::format
char printf_uint::format_justify_left
char printf_uint::format_min_length
@ -174,21 +178,23 @@ char printf_uint::format_radix
char printf_uint::format_sign_always
char printf_uint::format_upper_case
char printf_uint::format_zero_padding
void (*printf_uint::putc)(char)
__constant void (*printf_uint::putc#0)(char) = &cputc // putc
unsigned int printf_uint::uvalue
unsigned int printf_uint::uvalue#0 // uvalue zp[2]:5 367.33333333333337
void utoa(unsigned int value , char *buffer , char radix)
char utoa::$10 // reg byte a 2000002.0
char utoa::$11 // reg byte x 20002.0
char *utoa::buffer
char *utoa::buffer#11 // buffer zp[2]:23 287143.2857142857
char *utoa::buffer#14 // buffer zp[2]:23 1500001.5
char *utoa::buffer#3 // buffer zp[2]:23 20002.0
char *utoa::buffer#4 // buffer zp[2]:23 2000002.0
char *utoa::buffer#11 // buffer zp[2]:7 287143.2857142857
char *utoa::buffer#14 // buffer zp[2]:7 1500001.5
char *utoa::buffer#3 // buffer zp[2]:7 20002.0
char *utoa::buffer#4 // buffer zp[2]:7 2000002.0
char utoa::digit
char utoa::digit#1 // digit zp[1]:4 2000002.0
char utoa::digit#2 // digit zp[1]:4 285714.5714285714
unsigned int utoa::digit_value
unsigned int utoa::digit_value#0 // digit_value zp[2]:21 600000.6000000001
unsigned int utoa::digit_value#0 // digit_value zp[2]:23 600000.6000000001
unsigned int *utoa::digit_values
char utoa::max_digits
__constant char utoa::max_digits#1 = 5 // max_digits
@ -203,14 +209,14 @@ unsigned int utoa::value#2 // value zp[2]:5 572857.857142857
unsigned int utoa::value#6 // value zp[2]:5 1500001.5
unsigned int utoa_append(char *buffer , unsigned int value , unsigned int sub)
char *utoa_append::buffer
char *utoa_append::buffer#0 // buffer zp[2]:23 1375000.25
char *utoa_append::buffer#0 // buffer zp[2]:7 1375000.25
char utoa_append::digit
char utoa_append::digit#1 // reg byte x 1.0000000001E10
char utoa_append::digit#2 // reg byte x 1.00050000015E10
unsigned int utoa_append::return
unsigned int utoa_append::return#0 // return zp[2]:5 2000002.0
unsigned int utoa_append::sub
unsigned int utoa_append::sub#0 // sub zp[2]:21 3.3335000005E9
unsigned int utoa_append::sub#0 // sub zp[2]:23 3.3335000005E9
unsigned int utoa_append::value
unsigned int utoa_append::value#0 // value zp[2]:5 3666667.333333333
unsigned int utoa_append::value#1 // value zp[2]:5 2.0000000002E10
@ -219,24 +225,26 @@ unsigned int utoa_append::value#2 // value zp[2]:5 5.001833334166666E9
reg byte x [ conio_c64_init::line#2 conio_c64_init::line#0 ]
zp[2]:2 [ main::bbs#2 main::bbs#1 ]
reg byte x [ gotoxy::y#4 gotoxy::y#2 ]
reg byte a [ cputc::c#3 cputc::c#0 cputc::c#2 ]
zp[1]:4 [ utoa::digit#2 utoa::digit#1 ]
zp[2]:5 [ utoa::value#2 utoa::value#6 utoa::value#1 utoa::value#0 utoa_append::value#2 utoa_append::value#0 utoa_append::value#1 printf_uint::uvalue#0 utoa_append::return#0 printf_string::str#2 printf_string::str#0 printf_string::str#1 cputs::s#6 cputs::s#7 cputs::s#2 cputs::s#0 ]
zp[2]:5 [ utoa::value#2 utoa::value#6 utoa::value#1 utoa::value#0 utoa_append::value#2 utoa_append::value#0 utoa_append::value#1 printf_uint::uvalue#0 utoa_append::return#0 printf_string::str#2 printf_string::str#0 printf_string::str#1 printf_str::s#6 printf_str::s#7 printf_str::s#2 printf_str::s#0 ]
reg byte x [ utoa::started#2 utoa::started#4 ]
reg byte x [ utoa_append::digit#2 utoa_append::digit#1 ]
zp[2]:7 [ memset::str#3 memset::dst#2 memset::dst#4 memset::dst#1 memcpy::destination#2 memcpy::dst#2 memcpy::dst#4 memcpy::dst#1 ]
zp[2]:7 [ utoa::buffer#11 utoa::buffer#14 utoa::buffer#4 utoa::buffer#3 utoa_append::buffer#0 printf_str::putc#7 ]
zp[2]:9 [ memset::str#3 memset::dst#2 memset::dst#4 memset::dst#1 memcpy::source#2 memcpy::src#2 memcpy::src#4 memcpy::src#1 ]
reg byte x [ memset::c#4 ]
zp[1]:9 [ conio_cursor_x ]
zp[1]:10 [ conio_cursor_y ]
zp[2]:11 [ conio_line_text ]
zp[2]:13 [ conio_line_color ]
zp[2]:15 [ gotoxy::$7 gotoxy::$9 gotoxy::line_offset#0 gotoxy::$6 ]
zp[2]:17 [ gotoxy::$8 ]
zp[2]:19 [ gotoxy::$5 ]
reg byte a [ cputs::c#1 ]
reg byte x [ utoa_append::digit#2 utoa_append::digit#1 ]
zp[1]:11 [ conio_cursor_x ]
zp[1]:12 [ conio_cursor_y ]
zp[2]:13 [ conio_line_text ]
zp[2]:15 [ conio_line_color ]
reg byte a [ cputc::c#0 ]
zp[2]:17 [ gotoxy::$7 gotoxy::$9 gotoxy::line_offset#0 gotoxy::$6 ]
zp[2]:19 [ gotoxy::$8 ]
zp[2]:21 [ gotoxy::$5 ]
reg byte a [ printf_str::c#1 ]
reg byte a [ printf_number_buffer::buffer_sign#0 ]
reg byte x [ utoa::$11 ]
reg byte a [ utoa::$10 ]
zp[2]:21 [ memcpy::src_end#0 utoa::digit_value#0 utoa_append::sub#0 ]
zp[2]:23 [ memset::end#0 memcpy::source#2 memcpy::src#2 memcpy::src#4 memcpy::src#1 utoa::buffer#11 utoa::buffer#14 utoa::buffer#4 utoa::buffer#3 utoa_append::buffer#0 ]
zp[2]:23 [ utoa::digit_value#0 utoa_append::sub#0 ]
zp[2]:25 [ memcpy::src_end#0 ]
zp[2]:27 [ memset::end#0 memcpy::destination#2 memcpy::dst#2 memcpy::dst#4 memcpy::dst#1 ]
mem[12] [ printf_buffer ]