1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-11-26 12:49:21 +00:00

changed printf() cursor to be x,y-based.

This commit is contained in:
jespergravgaard 2020-04-22 00:14:30 +02:00
parent 64660c626a
commit d160e45c8a
31 changed files with 15510 additions and 11954 deletions

View File

@ -0,0 +1,7 @@
sec
lda {m1}
sbc {m2}
sta {m1}
bcs !+
dec {m1}+1
!:

View File

@ -0,0 +1,7 @@
sec
lda {m2}
sbc {m3}
sta {m1}
lda {m2}+1
sbc #0
sta {m1}+1

View File

@ -7,9 +7,13 @@
#define PRINTF_SCREEN_HEIGHT 25
#define PRINTF_SCREEN_BYTES PRINTF_SCREEN_WIDTH*PRINTF_SCREEN_HEIGHT
__ma char* printf_screen = PRINTF_SCREEN_ADDRESS;
__ma char* printf_line_cursor = PRINTF_SCREEN_ADDRESS;
__ma char* printf_char_cursor = PRINTF_SCREEN_ADDRESS;
// X-position of cursor
__ma char printf_cursor_x = 0;
// Y-position of cursor
__ma char printf_cursor_y = 0;
// Pointer to cursor address
__ma char* printf_cursor_ptr = PRINTF_SCREEN_ADDRESS;
// Buffer used for stringified number being printed
struct printf_buffer_number printf_buffer;
@ -20,30 +24,33 @@ __intrinsic void printf(char* format, ...);
// Clear the screen. Also resets current line/char cursor.
void printf_cls() {
memset(printf_screen, ' ', PRINTF_SCREEN_BYTES);
printf_line_cursor = printf_screen;
printf_char_cursor = printf_line_cursor;
memset(PRINTF_SCREEN_ADDRESS, ' ', PRINTF_SCREEN_BYTES);
printf_cursor_ptr = PRINTF_SCREEN_ADDRESS;
printf_cursor_x = 0;
printf_cursor_y = 0;
}
// Print a single char
// If the end of the screen is reached scroll it up one char and place the cursor at the
void printf_char(char ch) {
*(printf_char_cursor++) = ch;
// Scroll the screen if the cursor has moved past the end of the screen
if(printf_char_cursor>=(printf_screen+PRINTF_SCREEN_BYTES)) {
memcpy(printf_screen, printf_screen+PRINTF_SCREEN_WIDTH, PRINTF_SCREEN_BYTES-PRINTF_SCREEN_WIDTH);
memset(printf_screen+PRINTF_SCREEN_BYTES-PRINTF_SCREEN_WIDTH, ' ', PRINTF_SCREEN_WIDTH);
printf_char_cursor = printf_char_cursor-PRINTF_SCREEN_WIDTH;
printf_line_cursor = printf_char_cursor;
*(printf_cursor_ptr++) = ch;
if(++printf_cursor_x==PRINTF_SCREEN_WIDTH) {
printf_cursor_x = 0;
++printf_cursor_y;
if(printf_cursor_y==PRINTF_SCREEN_HEIGHT) {
memcpy(PRINTF_SCREEN_ADDRESS, PRINTF_SCREEN_ADDRESS+PRINTF_SCREEN_WIDTH, PRINTF_SCREEN_BYTES-PRINTF_SCREEN_WIDTH);
memset(PRINTF_SCREEN_ADDRESS+PRINTF_SCREEN_BYTES-PRINTF_SCREEN_WIDTH, ' ', PRINTF_SCREEN_WIDTH);
printf_cursor_ptr = printf_cursor_ptr-PRINTF_SCREEN_WIDTH;
printf_cursor_y--;
}
}
}
// Print a newline
void printf_ln() {
do {
printf_line_cursor += PRINTF_SCREEN_WIDTH;
} while (printf_line_cursor<printf_char_cursor);
printf_char_cursor = printf_line_cursor;
printf_cursor_ptr = printf_cursor_ptr - printf_cursor_x + PRINTF_SCREEN_WIDTH;
printf_cursor_x = 0;
printf_cursor_y++;
}
// Print a padding char a number of times

View File

@ -45,6 +45,11 @@ public class TestPrograms {
assertError("printf-error-1.c", "Needed printf sub-procedure not found");
}
@Test
public void testPrintf15() throws IOException, URISyntaxException {
compileAndCompare("printf-15.c");
}
@Test
public void testPrintf14() throws IOException, URISyntaxException {
compileAndCompare("printf-14.c");

View File

@ -125,6 +125,7 @@
"windows": {
"command": "c:/c64/kickc_local/bin/kickc.bat",
"args": [
"-Sc",
"-odir",
"c:/c64/tmp/",
"-e",
@ -133,6 +134,7 @@
"osx": {
"command": "~/c64/kickc_local/bin/kickc.sh",
"args": [
"-Sc",
"-odir",
"~/c64/tmp/",
"-e",

View File

@ -1,5 +1,5 @@
// Tests printf function call rewriting
// Print a char using %d
// Print a char using %u
#include <printf.h>
@ -7,7 +7,7 @@ void main() {
printf_cls();
char c = 7;
printf("%hhu", c);
printf("%u", c);
}

11
src/test/kc/printf-15.c Normal file
View File

@ -0,0 +1,11 @@
// Tests printf function call rewriting
// A few strings with newlines
#include <printf.h>
void main() {
printf_cls();
printf("Lone 1\n");
printf("Lone 2\n");
}

View File

@ -3,20 +3,23 @@
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
.label printf_screen = $400
.label printf_line_cursor = $d
.label printf_char_cursor = $f
.label printf_cursor_x = $d
.label printf_cursor_y = $e
.label printf_cursor_ptr = $f
__bbegin:
// printf_line_cursor = PRINTF_SCREEN_ADDRESS
// printf_cursor_x = 0
// X-position of cursor
lda #0
sta.z printf_cursor_x
// printf_cursor_y = 0
// Y-position of cursor
sta.z printf_cursor_y
// printf_cursor_ptr = PRINTF_SCREEN_ADDRESS
// Pointer to cursor address
lda #<$400
sta.z printf_line_cursor
sta.z printf_cursor_ptr
lda #>$400
sta.z printf_line_cursor+1
// printf_char_cursor = PRINTF_SCREEN_ADDRESS
lda #<$400
sta.z printf_char_cursor
lda #>$400
sta.z printf_char_cursor+1
sta.z printf_cursor_ptr+1
jsr main
rts
main: {
@ -157,51 +160,53 @@ printf_padding: {
// If the end of the screen is reached scroll it up one char and place the cursor at the
// printf_char(byte register(A) ch)
printf_char: {
.label __8 = $f
// *(printf_char_cursor++) = ch
.label __6 = $f
// *(printf_cursor_ptr++) = ch
ldy #0
sta (printf_char_cursor),y
// *(printf_char_cursor++) = ch;
inc.z printf_char_cursor
sta (printf_cursor_ptr),y
// *(printf_cursor_ptr++) = ch;
inc.z printf_cursor_ptr
bne !+
inc.z printf_char_cursor+1
inc.z printf_cursor_ptr+1
!:
// if(printf_char_cursor>=(printf_screen+PRINTF_SCREEN_BYTES))
lda.z printf_char_cursor+1
cmp #>printf_screen+$28*$19
bcc __breturn
bne !+
lda.z printf_char_cursor
cmp #<printf_screen+$28*$19
bcc __breturn
!:
// memcpy(printf_screen, printf_screen+PRINTF_SCREEN_WIDTH, PRINTF_SCREEN_BYTES-PRINTF_SCREEN_WIDTH)
// if(++printf_cursor_x==PRINTF_SCREEN_WIDTH)
inc.z printf_cursor_x
lda #$28
cmp.z printf_cursor_x
bne __breturn
// printf_cursor_x = 0
lda #0
sta.z printf_cursor_x
// ++printf_cursor_y;
inc.z printf_cursor_y
// if(printf_cursor_y==PRINTF_SCREEN_HEIGHT)
lda #$19
cmp.z printf_cursor_y
bne __breturn
// memcpy(PRINTF_SCREEN_ADDRESS, PRINTF_SCREEN_ADDRESS+PRINTF_SCREEN_WIDTH, PRINTF_SCREEN_BYTES-PRINTF_SCREEN_WIDTH)
jsr memcpy
// memset(printf_screen+PRINTF_SCREEN_BYTES-PRINTF_SCREEN_WIDTH, ' ', PRINTF_SCREEN_WIDTH)
// memset(PRINTF_SCREEN_ADDRESS+PRINTF_SCREEN_BYTES-PRINTF_SCREEN_WIDTH, ' ', PRINTF_SCREEN_WIDTH)
ldx #' '
lda #<printf_screen+$28*$19-$28
lda #<$400+$28*$19-$28
sta.z memset.str
lda #>printf_screen+$28*$19-$28
lda #>$400+$28*$19-$28
sta.z memset.str+1
lda #<$28
sta.z memset.num
lda #>$28
sta.z memset.num+1
jsr memset
// printf_char_cursor-PRINTF_SCREEN_WIDTH
lda.z __8
// printf_cursor_ptr-PRINTF_SCREEN_WIDTH
lda.z __6
sec
sbc #<$28
sta.z __8
lda.z __8+1
sta.z __6
lda.z __6+1
sbc #>$28
sta.z __8+1
// printf_char_cursor = printf_char_cursor-PRINTF_SCREEN_WIDTH
// printf_line_cursor = printf_char_cursor
lda.z printf_char_cursor
sta.z printf_line_cursor
lda.z printf_char_cursor+1
sta.z printf_line_cursor+1
sta.z __6+1
// printf_cursor_ptr = printf_cursor_ptr-PRINTF_SCREEN_WIDTH
// printf_cursor_y--;
dec.z printf_cursor_y
__breturn:
// }
rts
@ -253,9 +258,9 @@ memset: {
// 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.
memcpy: {
.label destination = printf_screen
.label destination = $400
.label source = $400+$28
.const num = $28*$19-$28
.label source = printf_screen+$28
.label src_end = source+num
.label dst = $b
.label src = 9
@ -325,29 +330,30 @@ printf_str: {
}
// Print a newline
printf_ln: {
__b1:
// printf_line_cursor += PRINTF_SCREEN_WIDTH
.label __0 = $f
.label __1 = $f
// printf_cursor_ptr - printf_cursor_x
sec
lda.z __0
sbc.z printf_cursor_x
sta.z __0
bcs !+
dec.z __0+1
!:
// printf_cursor_ptr - printf_cursor_x + PRINTF_SCREEN_WIDTH
lda #$28
clc
adc.z printf_line_cursor
sta.z printf_line_cursor
adc.z __1
sta.z __1
bcc !+
inc.z printf_line_cursor+1
inc.z __1+1
!:
// while (printf_line_cursor<printf_char_cursor)
lda.z printf_line_cursor+1
cmp.z printf_char_cursor+1
bcc __b1
bne !+
lda.z printf_line_cursor
cmp.z printf_char_cursor
bcc __b1
!:
// printf_char_cursor = printf_line_cursor
lda.z printf_line_cursor
sta.z printf_char_cursor
lda.z printf_line_cursor+1
sta.z printf_char_cursor+1
// printf_cursor_ptr = printf_cursor_ptr - printf_cursor_x + PRINTF_SCREEN_WIDTH
// printf_cursor_x = 0
lda #0
sta.z printf_cursor_x
// printf_cursor_y++;
inc.z printf_cursor_y
// }
rts
}
@ -383,27 +389,27 @@ strlen: {
}
// Clear the screen. Also resets current line/char cursor.
printf_cls: {
// memset(printf_screen, ' ', PRINTF_SCREEN_BYTES)
// memset(PRINTF_SCREEN_ADDRESS, ' ', PRINTF_SCREEN_BYTES)
ldx #' '
lda #<printf_screen
lda #<$400
sta.z memset.str
lda #>printf_screen
lda #>$400
sta.z memset.str+1
lda #<$28*$19
sta.z memset.num
lda #>$28*$19
sta.z memset.num+1
jsr memset
// printf_line_cursor = printf_screen
lda #<printf_screen
sta.z printf_line_cursor
lda #>printf_screen
sta.z printf_line_cursor+1
// printf_char_cursor = printf_line_cursor
lda.z printf_line_cursor
sta.z printf_char_cursor
lda.z printf_line_cursor+1
sta.z printf_char_cursor+1
// printf_cursor_ptr = PRINTF_SCREEN_ADDRESS
lda #<$400
sta.z printf_cursor_ptr
lda #>$400
sta.z printf_cursor_ptr+1
// printf_cursor_x = 0
lda #0
sta.z printf_cursor_x
// printf_cursor_y = 0
sta.z printf_cursor_y
// }
rts
}

View File

@ -2,255 +2,260 @@
[0] phi()
to:@1
@1: scope:[] from @begin
[1] (byte*) printf_line_cursor ← (byte*) 1024
[2] (byte*) printf_char_cursor ← (byte*) 1024
[1] (byte) printf_cursor_x ← (byte) 0
[2] (byte) printf_cursor_y ← (byte) 0
[3] (byte*) printf_cursor_ptr ← (byte*) 1024
to:@2
@2: scope:[] from @1
[3] phi()
[4] call main
[4] phi()
[5] call main
to:@end
@end: scope:[] from @2
[5] phi()
[6] phi()
(void()) main()
main: scope:[main] from @2
[6] phi()
[7] call printf_cls
[7] phi()
[8] call printf_cls
to:main::@1
main::@1: scope:[main] from main
[8] phi()
[9] call printf_string
[9] phi()
[10] call printf_string
to:main::@2
main::@2: scope:[main] from main::@1
[10] phi()
[11] call printf_ln
[11] phi()
[12] call printf_ln
to:main::@3
main::@3: scope:[main] from main::@2
[12] phi()
[13] call printf_string
[13] phi()
[14] call printf_string
to:main::@4
main::@4: scope:[main] from main::@3
[14] phi()
[15] call printf_ln
[15] phi()
[16] call printf_ln
to:main::@5
main::@5: scope:[main] from main::@4
[16] phi()
[17] call printf_string
[17] phi()
[18] call printf_string
to:main::@6
main::@6: scope:[main] from main::@5
[18] phi()
[19] call printf_ln
[19] phi()
[20] call printf_ln
to:main::@7
main::@7: scope:[main] from main::@6
[20] phi()
[21] call printf_string
[21] phi()
[22] call printf_string
to:main::@return
main::@return: scope:[main] from main::@7
[22] return
[23] return
to:@return
(void()) printf_string((byte*) printf_string::str , (byte) printf_string::format_min_length , (byte) printf_string::format_justify_left)
printf_string: scope:[printf_string] from main::@1 main::@3 main::@5 main::@7
[23] (byte*) printf_string::str#10 ← phi( main::@1/(const byte*) main::str main::@3/(const byte*) main::str1 main::@5/(const byte*) main::str main::@7/(const byte*) main::str1 )
[23] (byte) printf_string::format_justify_left#10 ← phi( main::@1/(byte) 0 main::@3/(byte) 0 main::@5/(byte) 1 main::@7/(byte) 1 )
[24] (byte*) printf_string::str#10 ← phi( main::@1/(const byte*) main::str main::@3/(const byte*) main::str1 main::@5/(const byte*) main::str main::@7/(const byte*) main::str1 )
[24] (byte) printf_string::format_justify_left#10 ← phi( main::@1/(byte) 0 main::@3/(byte) 0 main::@5/(byte) 1 main::@7/(byte) 1 )
to:printf_string::@3
printf_string::@3: scope:[printf_string] from printf_string
[24] (byte*) strlen::str#1 ← (byte*) printf_string::str#10
[25] call strlen
[26] (word) strlen::return#2 ← (word) strlen::len#2
[25] (byte*) strlen::str#1 ← (byte*) printf_string::str#10
[26] call strlen
[27] (word) strlen::return#2 ← (word) strlen::len#2
to:printf_string::@6
printf_string::@6: scope:[printf_string] from printf_string::@3
[27] (word~) printf_string::$9 ← (word) strlen::return#2
[28] (signed byte) printf_string::len#0 ← (signed byte)(word~) printf_string::$9
[29] (signed byte) printf_string::padding#1 ← (signed byte) $a - (signed byte) printf_string::len#0
[30] if((signed byte) printf_string::padding#1>=(signed byte) 0) goto printf_string::@10
[28] (word~) printf_string::$9 ← (word) strlen::return#2
[29] (signed byte) printf_string::len#0 ← (signed byte)(word~) printf_string::$9
[30] (signed byte) printf_string::padding#1 ← (signed byte) $a - (signed byte) printf_string::len#0
[31] if((signed byte) printf_string::padding#1>=(signed byte) 0) goto printf_string::@10
to:printf_string::@1
printf_string::@10: scope:[printf_string] from printf_string::@6
[31] phi()
[32] phi()
to:printf_string::@1
printf_string::@1: scope:[printf_string] from printf_string::@10 printf_string::@6
[32] (signed byte) printf_string::padding#3 ← phi( printf_string::@6/(signed byte) 0 printf_string::@10/(signed byte) printf_string::padding#1 )
[33] if((byte) 0!=(byte) printf_string::format_justify_left#10) goto printf_string::@2
[33] (signed byte) printf_string::padding#3 ← phi( printf_string::@6/(signed byte) 0 printf_string::@10/(signed byte) printf_string::padding#1 )
[34] if((byte) 0!=(byte) printf_string::format_justify_left#10) goto printf_string::@2
to:printf_string::@8
printf_string::@8: scope:[printf_string] from printf_string::@1
[34] if((signed byte) 0!=(signed byte) printf_string::padding#3) goto printf_string::@4
[35] if((signed byte) 0!=(signed byte) printf_string::padding#3) goto printf_string::@4
to:printf_string::@2
printf_string::@4: scope:[printf_string] from printf_string::@8
[35] (byte) printf_padding::length#0 ← (byte)(signed byte) printf_string::padding#3
[36] call printf_padding
[36] (byte) printf_padding::length#0 ← (byte)(signed byte) printf_string::padding#3
[37] call printf_padding
to:printf_string::@2
printf_string::@2: scope:[printf_string] from printf_string::@1 printf_string::@4 printf_string::@8
[37] (byte*) printf_str::str#1 ← (byte*) printf_string::str#10
[38] call printf_str
[38] (byte*) printf_str::str#1 ← (byte*) printf_string::str#10
[39] call printf_str
to:printf_string::@7
printf_string::@7: scope:[printf_string] from printf_string::@2
[39] if((byte) 0==(byte) printf_string::format_justify_left#10) goto printf_string::@return
[40] if((byte) 0==(byte) printf_string::format_justify_left#10) goto printf_string::@return
to:printf_string::@9
printf_string::@9: scope:[printf_string] from printf_string::@7
[40] if((signed byte) 0!=(signed byte) printf_string::padding#3) goto printf_string::@5
[41] if((signed byte) 0!=(signed byte) printf_string::padding#3) goto printf_string::@5
to:printf_string::@return
printf_string::@5: scope:[printf_string] from printf_string::@9
[41] (byte) printf_padding::length#1 ← (byte)(signed byte) printf_string::padding#3
[42] call printf_padding
[42] (byte) printf_padding::length#1 ← (byte)(signed byte) printf_string::padding#3
[43] call printf_padding
to:printf_string::@return
printf_string::@return: scope:[printf_string] from printf_string::@5 printf_string::@7 printf_string::@9
[43] return
[44] return
to:@return
(void()) printf_padding((byte) printf_padding::pad , (byte) printf_padding::length)
printf_padding: scope:[printf_padding] from printf_string::@4 printf_string::@5
[44] (byte) printf_padding::pad#4 ← phi( printf_string::@4/(byte) ' ' printf_string::@5/(byte) ' ' )
[44] (byte) printf_padding::length#3 ← phi( printf_string::@4/(byte) printf_padding::length#0 printf_string::@5/(byte) printf_padding::length#1 )
[45] (byte) printf_padding::pad#4 ← phi( printf_string::@4/(byte) ' ' printf_string::@5/(byte) ' ' )
[45] (byte) printf_padding::length#3 ← phi( printf_string::@4/(byte) printf_padding::length#0 printf_string::@5/(byte) printf_padding::length#1 )
to:printf_padding::@1
printf_padding::@1: scope:[printf_padding] from printf_padding printf_padding::@3
[45] (byte) printf_padding::i#2 ← phi( printf_padding/(byte) 0 printf_padding::@3/(byte) printf_padding::i#1 )
[46] if((byte) printf_padding::i#2<(byte) printf_padding::length#3) goto printf_padding::@2
[46] (byte) printf_padding::i#2 ← phi( printf_padding/(byte) 0 printf_padding::@3/(byte) printf_padding::i#1 )
[47] if((byte) printf_padding::i#2<(byte) printf_padding::length#3) goto printf_padding::@2
to:printf_padding::@return
printf_padding::@return: scope:[printf_padding] from printf_padding::@1
[47] return
[48] return
to:@return
printf_padding::@2: scope:[printf_padding] from printf_padding::@1
[48] (byte) printf_char::ch#0 ← (byte) printf_padding::pad#4
[49] call printf_char
[49] (byte) printf_char::ch#0 ← (byte) printf_padding::pad#4
[50] call printf_char
to:printf_padding::@3
printf_padding::@3: scope:[printf_padding] from printf_padding::@2
[50] (byte) printf_padding::i#1 ← ++ (byte) printf_padding::i#2
[51] (byte) printf_padding::i#1 ← ++ (byte) printf_padding::i#2
to:printf_padding::@1
(void()) printf_char((byte) printf_char::ch)
printf_char: scope:[printf_char] from printf_padding::@2 printf_str::@5
[51] (byte) printf_char::ch#2 ← phi( printf_padding::@2/(byte) printf_char::ch#0 printf_str::@5/(byte) printf_char::ch#1 )
[52] *((byte*) printf_char_cursor) ← (byte) printf_char::ch#2
[53] (byte*) printf_char_cursor ← ++ (byte*) printf_char_cursor
[54] if((byte*) printf_char_cursor<(const byte*) printf_screen+(word)(number) $28*(number) $19) goto printf_char::@return
[52] (byte) printf_char::ch#2 ← phi( printf_padding::@2/(byte) printf_char::ch#0 printf_str::@5/(byte) printf_char::ch#1 )
[53] *((byte*) printf_cursor_ptr) ← (byte) printf_char::ch#2
[54] (byte*) printf_cursor_ptr ← ++ (byte*) printf_cursor_ptr
[55] (byte) printf_cursor_x ← ++ (byte) printf_cursor_x
[56] if((byte) printf_cursor_x!=(byte) $28) goto printf_char::@return
to:printf_char::@1
printf_char::@1: scope:[printf_char] from printf_char
[55] phi()
[56] call memcpy
[57] (byte) printf_cursor_x ← (byte) 0
[58] (byte) printf_cursor_y ← ++ (byte) printf_cursor_y
[59] if((byte) printf_cursor_y!=(byte) $19) goto printf_char::@return
to:printf_char::@2
printf_char::@2: scope:[printf_char] from printf_char::@1
[57] phi()
[58] call memset
[60] phi()
[61] call memcpy
to:printf_char::@3
printf_char::@3: scope:[printf_char] from printf_char::@2
[59] (byte*~) printf_char::$8 ← (byte*) printf_char_cursor - (byte) $28
[60] (byte*) printf_char_cursor ← (byte*~) printf_char::$8
[61] (byte*) printf_line_cursor ← (byte*) printf_char_cursor
[62] phi()
[63] call memset
to:printf_char::@4
printf_char::@4: scope:[printf_char] from printf_char::@3
[64] (byte*~) printf_char::$6 ← (byte*) printf_cursor_ptr - (byte) $28
[65] (byte*) printf_cursor_ptr ← (byte*~) printf_char::$6
[66] (byte) printf_cursor_y ← -- (byte) printf_cursor_y
to:printf_char::@return
printf_char::@return: scope:[printf_char] from printf_char printf_char::@3
[62] return
printf_char::@return: scope:[printf_char] from printf_char printf_char::@1 printf_char::@4
[67] return
to:@return
(void*()) memset((void*) memset::str , (byte) memset::c , (word) memset::num)
memset: scope:[memset] from printf_char::@2 printf_cls
[63] (byte) memset::c#4 ← phi( printf_char::@2/(byte) ' ' printf_cls/(byte) ' ' )
[63] (void*) memset::str#3 ← phi( printf_char::@2/(void*)(const byte*) printf_screen+(word)(number) $28*(number) $19-(byte) $28 printf_cls/(void*)(const byte*) printf_screen )
[63] (word) memset::num#2 ← phi( printf_char::@2/(byte) $28 printf_cls/(word)(number) $28*(number) $19 )
[64] if((word) memset::num#2<=(byte) 0) goto memset::@return
memset: scope:[memset] from printf_char::@3 printf_cls
[68] (byte) memset::c#4 ← phi( printf_char::@3/(byte) ' ' printf_cls/(byte) ' ' )
[68] (void*) memset::str#3 ← phi( printf_char::@3/(void*)(number) $400+(number) $28*(number) $19-(number) $28 printf_cls/(void*) 1024 )
[68] (word) memset::num#2 ← phi( printf_char::@3/(byte) $28 printf_cls/(word)(number) $28*(number) $19 )
[69] if((word) memset::num#2<=(byte) 0) goto memset::@return
to:memset::@1
memset::@1: scope:[memset] from memset
[65] (byte*) memset::end#0 ← (byte*)(void*) memset::str#3 + (word) memset::num#2
[66] (byte*) memset::dst#4 ← (byte*)(void*) memset::str#3
[70] (byte*) memset::end#0 ← (byte*)(void*) memset::str#3 + (word) memset::num#2
[71] (byte*) memset::dst#4 ← (byte*)(void*) memset::str#3
to:memset::@2
memset::@2: scope:[memset] from memset::@1 memset::@3
[67] (byte*) memset::dst#2 ← phi( memset::@1/(byte*) memset::dst#4 memset::@3/(byte*) memset::dst#1 )
[68] if((byte*) memset::dst#2!=(byte*) memset::end#0) goto memset::@3
[72] (byte*) memset::dst#2 ← phi( memset::@1/(byte*) memset::dst#4 memset::@3/(byte*) memset::dst#1 )
[73] if((byte*) memset::dst#2!=(byte*) memset::end#0) goto memset::@3
to:memset::@return
memset::@return: scope:[memset] from memset memset::@2
[69] return
[74] return
to:@return
memset::@3: scope:[memset] from memset::@2
[70] *((byte*) memset::dst#2) ← (byte) memset::c#4
[71] (byte*) memset::dst#1 ← ++ (byte*) memset::dst#2
[75] *((byte*) memset::dst#2) ← (byte) memset::c#4
[76] (byte*) memset::dst#1 ← ++ (byte*) memset::dst#2
to:memset::@2
(void*()) memcpy((void*) memcpy::destination , (void*) memcpy::source , (word) memcpy::num)
memcpy: scope:[memcpy] from printf_char::@1
[72] phi()
memcpy: scope:[memcpy] from printf_char::@2
[77] phi()
to:memcpy::@1
memcpy::@1: scope:[memcpy] from memcpy memcpy::@2
[73] (byte*) memcpy::dst#2 ← phi( memcpy/(byte*)(const void*) memcpy::destination#0 memcpy::@2/(byte*) memcpy::dst#1 )
[73] (byte*) memcpy::src#2 ← phi( memcpy/(byte*)(const void*) memcpy::source#0 memcpy::@2/(byte*) memcpy::src#1 )
[74] if((byte*) memcpy::src#2!=(const byte*) memcpy::src_end#0) goto memcpy::@2
[78] (byte*) memcpy::dst#2 ← phi( memcpy/(byte*)(const void*) memcpy::destination#0 memcpy::@2/(byte*) memcpy::dst#1 )
[78] (byte*) memcpy::src#2 ← phi( memcpy/(byte*)(const void*) memcpy::source#0 memcpy::@2/(byte*) memcpy::src#1 )
[79] if((byte*) memcpy::src#2!=(const byte*) memcpy::src_end#0) goto memcpy::@2
to:memcpy::@return
memcpy::@return: scope:[memcpy] from memcpy::@1
[75] return
[80] return
to:@return
memcpy::@2: scope:[memcpy] from memcpy::@1
[76] *((byte*) memcpy::dst#2) ← *((byte*) memcpy::src#2)
[77] (byte*) memcpy::dst#1 ← ++ (byte*) memcpy::dst#2
[78] (byte*) memcpy::src#1 ← ++ (byte*) memcpy::src#2
[81] *((byte*) memcpy::dst#2) ← *((byte*) memcpy::src#2)
[82] (byte*) memcpy::dst#1 ← ++ (byte*) memcpy::dst#2
[83] (byte*) memcpy::src#1 ← ++ (byte*) memcpy::src#2
to:memcpy::@1
(void()) printf_str((byte*) printf_str::str)
printf_str: scope:[printf_str] from printf_string::@2
[79] phi()
[84] phi()
to:printf_str::@1
printf_str::@1: scope:[printf_str] from printf_str printf_str::@4 printf_str::@5
[80] (byte*) printf_str::str#2 ← phi( printf_str/(byte*) printf_str::str#1 printf_str::@4/(byte*) printf_str::str#0 printf_str::@5/(byte*) printf_str::str#0 )
[85] (byte*) printf_str::str#2 ← phi( printf_str/(byte*) printf_str::str#1 printf_str::@4/(byte*) printf_str::str#0 printf_str::@5/(byte*) printf_str::str#0 )
to:printf_str::@2
printf_str::@2: scope:[printf_str] from printf_str::@1
[81] (byte) printf_str::ch#0 ← *((byte*) printf_str::str#2)
[82] (byte*) printf_str::str#0 ← ++ (byte*) printf_str::str#2
[83] if((byte) printf_str::ch#0!=(byte) 0) goto printf_str::@3
[86] (byte) printf_str::ch#0 ← *((byte*) printf_str::str#2)
[87] (byte*) printf_str::str#0 ← ++ (byte*) printf_str::str#2
[88] if((byte) printf_str::ch#0!=(byte) 0) goto printf_str::@3
to:printf_str::@return
printf_str::@return: scope:[printf_str] from printf_str::@2
[84] return
[89] return
to:@return
printf_str::@3: scope:[printf_str] from printf_str::@2
[85] if((byte) printf_str::ch#0==(byte) '
[90] if((byte) printf_str::ch#0==(byte) '
') goto printf_str::@4
to:printf_str::@5
printf_str::@5: scope:[printf_str] from printf_str::@3
[86] (byte) printf_char::ch#1 ← (byte) printf_str::ch#0
[87] call printf_char
[91] (byte) printf_char::ch#1 ← (byte) printf_str::ch#0
[92] call printf_char
to:printf_str::@1
printf_str::@4: scope:[printf_str] from printf_str::@3
[88] phi()
[89] call printf_ln
[93] phi()
[94] call printf_ln
to:printf_str::@1
(void()) printf_ln()
printf_ln: scope:[printf_ln] from main::@2 main::@4 main::@6 printf_str::@4
[90] phi()
to:printf_ln::@1
printf_ln::@1: scope:[printf_ln] from printf_ln printf_ln::@1
[91] (byte*) printf_line_cursor ← (byte*) printf_line_cursor + (byte) $28
[92] if((byte*) printf_line_cursor<(byte*) printf_char_cursor) goto printf_ln::@1
to:printf_ln::@2
printf_ln::@2: scope:[printf_ln] from printf_ln::@1
[93] (byte*) printf_char_cursor ← (byte*) printf_line_cursor
[95] (byte*~) printf_ln::$0 ← (byte*) printf_cursor_ptr - (byte) printf_cursor_x
[96] (byte*~) printf_ln::$1 ← (byte*~) printf_ln::$0 + (byte) $28
[97] (byte*) printf_cursor_ptr ← (byte*~) printf_ln::$1
[98] (byte) printf_cursor_x ← (byte) 0
[99] (byte) printf_cursor_y ← ++ (byte) printf_cursor_y
to:printf_ln::@return
printf_ln::@return: scope:[printf_ln] from printf_ln::@2
[94] return
printf_ln::@return: scope:[printf_ln] from printf_ln
[100] return
to:@return
(word()) strlen((byte*) strlen::str)
strlen: scope:[strlen] from printf_string::@3
[95] phi()
[101] phi()
to:strlen::@1
strlen::@1: scope:[strlen] from strlen strlen::@2
[96] (word) strlen::len#2 ← phi( strlen/(word) 0 strlen::@2/(word) strlen::len#1 )
[96] (byte*) strlen::str#2 ← phi( strlen/(byte*) strlen::str#1 strlen::@2/(byte*) strlen::str#0 )
[97] if((byte) 0!=*((byte*) strlen::str#2)) goto strlen::@2
[102] (word) strlen::len#2 ← phi( strlen/(word) 0 strlen::@2/(word) strlen::len#1 )
[102] (byte*) strlen::str#2 ← phi( strlen/(byte*) strlen::str#1 strlen::@2/(byte*) strlen::str#0 )
[103] if((byte) 0!=*((byte*) strlen::str#2)) goto strlen::@2
to:strlen::@return
strlen::@return: scope:[strlen] from strlen::@1
[98] return
[104] return
to:@return
strlen::@2: scope:[strlen] from strlen::@1
[99] (word) strlen::len#1 ← ++ (word) strlen::len#2
[100] (byte*) strlen::str#0 ← ++ (byte*) strlen::str#2
[105] (word) strlen::len#1 ← ++ (word) strlen::len#2
[106] (byte*) strlen::str#0 ← ++ (byte*) strlen::str#2
to:strlen::@1
(void()) printf_cls()
printf_cls: scope:[printf_cls] from main
[101] phi()
[102] call memset
[107] phi()
[108] call memset
to:printf_cls::@1
printf_cls::@1: scope:[printf_cls] from printf_cls
[103] (byte*) printf_line_cursor ← (const byte*) printf_screen
[104] (byte*) printf_char_cursor ← (byte*) printf_line_cursor
[109] (byte*) printf_cursor_ptr ← (byte*) 1024
[110] (byte) printf_cursor_x ← (byte) 0
[111] (byte) printf_cursor_y ← (byte) 0
to:printf_cls::@return
printf_cls::@return: scope:[printf_cls] from printf_cls::@1
[105] return
[112] return
to:@return

File diff suppressed because it is too large Load Diff

View File

@ -22,7 +22,7 @@
(label) memcpy::@2
(label) memcpy::@return
(void*) memcpy::destination
(const void*) memcpy::destination#0 destination = (void*)(const byte*) printf_screen
(const void*) memcpy::destination#0 destination = (void*) 1024
(byte*) memcpy::dst
(byte*) memcpy::dst#1 dst zp[2]:11 1.00000001E8
(byte*) memcpy::dst#2 dst zp[2]:11 1.00000001E8
@ -30,7 +30,7 @@
(const word) memcpy::num#0 num = (word)(number) $28*(number) $19-(number) $28
(void*) memcpy::return
(void*) memcpy::source
(const void*) memcpy::source#0 source = (void*)(const byte*) printf_screen+(byte) $28
(const void*) memcpy::source#0 source = (void*)(number) $400+(number) $28
(byte*) memcpy::src
(byte*) memcpy::src#1 src zp[2]:9 2.00000002E8
(byte*) memcpy::src#2 src zp[2]:9 1.00000001E8
@ -57,19 +57,22 @@
(const byte*) printf_buffer_number::digits[(number) $b] = { fill( $b, 0) }
(byte) printf_buffer_number::sign
(void()) printf_char((byte) printf_char::ch)
(byte*~) printf_char::$8 zp[2]:15 200002.0
(byte*~) printf_char::$6 zp[2]:15 200002.0
(label) printf_char::@1
(label) printf_char::@2
(label) printf_char::@3
(label) printf_char::@4
(label) printf_char::@return
(byte) printf_char::ch
(byte) printf_char::ch#0 reg byte a 20002.0
(byte) printf_char::ch#1 reg byte a 20002.0
(byte) printf_char::ch#2 reg byte a 120003.0
(byte*) printf_char_cursor loadstore zp[2]:15 25353.69014084507
(void()) printf_cls()
(label) printf_cls::@1
(label) printf_cls::@return
(byte*) printf_cursor_ptr loadstore zp[2]:15 9211.973684210527
(byte) printf_cursor_x loadstore zp[1]:13 8001.453333333332
(byte) printf_cursor_y loadstore zp[1]:14 9092.337662337664
(byte) printf_format_number::justify_left
(byte) printf_format_number::min_length
(byte) printf_format_number::radix
@ -77,10 +80,9 @@
(byte) printf_format_number::zero_padding
(byte) printf_format_string::justify_left
(byte) printf_format_string::min_length
(byte*) printf_line_cursor loadstore zp[2]:13 47764.31343283582
(void()) printf_ln()
(label) printf_ln::@1
(label) printf_ln::@2
(byte*~) printf_ln::$0 zp[2]:15 200002.0
(byte*~) printf_ln::$1 zp[2]:15 200002.0
(label) printf_ln::@return
(void()) printf_padding((byte) printf_padding::pad , (byte) printf_padding::length)
(label) printf_padding::@1
@ -96,7 +98,6 @@
(byte) printf_padding::length#3 length zp[1]:6 1700.5
(byte) printf_padding::pad
(byte) printf_padding::pad#4 pad zp[1]:7 1666.8333333333333
(const byte*) printf_screen = (byte*) 1024
(void()) printf_str((byte*) printf_str::str)
(label) printf_str::@1
(label) printf_str::@2
@ -158,7 +159,8 @@ reg byte a [ printf_char::ch#2 printf_char::ch#0 printf_char::ch#1 ]
reg byte x [ memset::c#4 ]
zp[2]:9 [ strlen::str#2 strlen::str#1 strlen::str#0 memcpy::src#2 memcpy::src#1 memset::num#2 memset::end#0 ]
zp[2]:11 [ strlen::len#2 strlen::len#1 strlen::return#2 printf_string::$9 memcpy::dst#2 memcpy::dst#1 memset::str#3 memset::dst#2 memset::dst#4 memset::dst#1 ]
zp[2]:13 [ printf_line_cursor ]
zp[2]:15 [ printf_char_cursor printf_char::$8 ]
zp[1]:13 [ printf_cursor_x ]
zp[1]:14 [ printf_cursor_y ]
zp[2]:15 [ printf_cursor_ptr printf_char::$6 printf_ln::$0 printf_ln::$1 ]
reg byte a [ printf_string::len#0 ]
reg byte a [ printf_str::ch#0 ]

View File

@ -8,21 +8,24 @@
.const DECIMAL = $a
.const HEXADECIMAL = $10
.const OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS = 1
.label printf_screen = $400
.const SIZEOF_STRUCT_PRINTF_BUFFER_NUMBER = $c
.label printf_line_cursor = $12
.label printf_char_cursor = $14
.label printf_cursor_x = $12
.label printf_cursor_y = $13
.label printf_cursor_ptr = $14
__bbegin:
// printf_line_cursor = PRINTF_SCREEN_ADDRESS
// printf_cursor_x = 0
// X-position of cursor
lda #0
sta.z printf_cursor_x
// printf_cursor_y = 0
// Y-position of cursor
sta.z printf_cursor_y
// printf_cursor_ptr = PRINTF_SCREEN_ADDRESS
// Pointer to cursor address
lda #<$400
sta.z printf_line_cursor
sta.z printf_cursor_ptr
lda #>$400
sta.z printf_line_cursor+1
// printf_char_cursor = PRINTF_SCREEN_ADDRESS
lda #<$400
sta.z printf_char_cursor
lda #>$400
sta.z printf_char_cursor+1
sta.z printf_cursor_ptr+1
jsr main
rts
main: {
@ -231,29 +234,30 @@ printf_str: {
}
// Print a newline
printf_ln: {
__b1:
// printf_line_cursor += PRINTF_SCREEN_WIDTH
.label __0 = $14
.label __1 = $14
// printf_cursor_ptr - printf_cursor_x
sec
lda.z __0
sbc.z printf_cursor_x
sta.z __0
bcs !+
dec.z __0+1
!:
// printf_cursor_ptr - printf_cursor_x + PRINTF_SCREEN_WIDTH
lda #$28
clc
adc.z printf_line_cursor
sta.z printf_line_cursor
adc.z __1
sta.z __1
bcc !+
inc.z printf_line_cursor+1
inc.z __1+1
!:
// while (printf_line_cursor<printf_char_cursor)
lda.z printf_line_cursor+1
cmp.z printf_char_cursor+1
bcc __b1
bne !+
lda.z printf_line_cursor
cmp.z printf_char_cursor
bcc __b1
!:
// printf_char_cursor = printf_line_cursor
lda.z printf_line_cursor
sta.z printf_char_cursor
lda.z printf_line_cursor+1
sta.z printf_char_cursor+1
// printf_cursor_ptr = printf_cursor_ptr - printf_cursor_x + PRINTF_SCREEN_WIDTH
// printf_cursor_x = 0
lda #0
sta.z printf_cursor_x
// printf_cursor_y++;
inc.z printf_cursor_y
// }
rts
}
@ -261,51 +265,53 @@ printf_ln: {
// If the end of the screen is reached scroll it up one char and place the cursor at the
// printf_char(byte register(A) ch)
printf_char: {
.label __8 = $14
// *(printf_char_cursor++) = ch
.label __6 = $14
// *(printf_cursor_ptr++) = ch
ldy #0
sta (printf_char_cursor),y
// *(printf_char_cursor++) = ch;
inc.z printf_char_cursor
sta (printf_cursor_ptr),y
// *(printf_cursor_ptr++) = ch;
inc.z printf_cursor_ptr
bne !+
inc.z printf_char_cursor+1
inc.z printf_cursor_ptr+1
!:
// if(printf_char_cursor>=(printf_screen+PRINTF_SCREEN_BYTES))
lda.z printf_char_cursor+1
cmp #>printf_screen+$28*$19
bcc __breturn
bne !+
lda.z printf_char_cursor
cmp #<printf_screen+$28*$19
bcc __breturn
!:
// memcpy(printf_screen, printf_screen+PRINTF_SCREEN_WIDTH, PRINTF_SCREEN_BYTES-PRINTF_SCREEN_WIDTH)
// if(++printf_cursor_x==PRINTF_SCREEN_WIDTH)
inc.z printf_cursor_x
lda #$28
cmp.z printf_cursor_x
bne __breturn
// printf_cursor_x = 0
lda #0
sta.z printf_cursor_x
// ++printf_cursor_y;
inc.z printf_cursor_y
// if(printf_cursor_y==PRINTF_SCREEN_HEIGHT)
lda #$19
cmp.z printf_cursor_y
bne __breturn
// memcpy(PRINTF_SCREEN_ADDRESS, PRINTF_SCREEN_ADDRESS+PRINTF_SCREEN_WIDTH, PRINTF_SCREEN_BYTES-PRINTF_SCREEN_WIDTH)
jsr memcpy
// memset(printf_screen+PRINTF_SCREEN_BYTES-PRINTF_SCREEN_WIDTH, ' ', PRINTF_SCREEN_WIDTH)
// memset(PRINTF_SCREEN_ADDRESS+PRINTF_SCREEN_BYTES-PRINTF_SCREEN_WIDTH, ' ', PRINTF_SCREEN_WIDTH)
ldx #' '
lda #<printf_screen+$28*$19-$28
lda #<$400+$28*$19-$28
sta.z memset.str
lda #>printf_screen+$28*$19-$28
lda #>$400+$28*$19-$28
sta.z memset.str+1
lda #<$28
sta.z memset.num
lda #>$28
sta.z memset.num+1
jsr memset
// printf_char_cursor-PRINTF_SCREEN_WIDTH
lda.z __8
// printf_cursor_ptr-PRINTF_SCREEN_WIDTH
lda.z __6
sec
sbc #<$28
sta.z __8
lda.z __8+1
sta.z __6
lda.z __6+1
sbc #>$28
sta.z __8+1
// printf_char_cursor = printf_char_cursor-PRINTF_SCREEN_WIDTH
// printf_line_cursor = printf_char_cursor
lda.z printf_char_cursor
sta.z printf_line_cursor
lda.z printf_char_cursor+1
sta.z printf_line_cursor+1
sta.z __6+1
// printf_cursor_ptr = printf_cursor_ptr-PRINTF_SCREEN_WIDTH
// printf_cursor_y--;
dec.z printf_cursor_y
__breturn:
// }
rts
@ -357,9 +363,9 @@ memset: {
// 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.
memcpy: {
.label destination = printf_screen
.label destination = $400
.label source = $400+$28
.const num = $28*$19-$28
.label source = printf_screen+$28
.label src_end = source+num
.label dst = $b
.label src = 8
@ -1233,27 +1239,27 @@ printf_schar: {
}
// Clear the screen. Also resets current line/char cursor.
printf_cls: {
// memset(printf_screen, ' ', PRINTF_SCREEN_BYTES)
// memset(PRINTF_SCREEN_ADDRESS, ' ', PRINTF_SCREEN_BYTES)
ldx #' '
lda #<printf_screen
lda #<$400
sta.z memset.str
lda #>printf_screen
lda #>$400
sta.z memset.str+1
lda #<$28*$19
sta.z memset.num
lda #>$28*$19
sta.z memset.num+1
jsr memset
// printf_line_cursor = printf_screen
lda #<printf_screen
sta.z printf_line_cursor
lda #>printf_screen
sta.z printf_line_cursor+1
// printf_char_cursor = printf_line_cursor
lda.z printf_line_cursor
sta.z printf_char_cursor
lda.z printf_line_cursor+1
sta.z printf_char_cursor+1
// printf_cursor_ptr = PRINTF_SCREEN_ADDRESS
lda #<$400
sta.z printf_cursor_ptr
lda #>$400
sta.z printf_cursor_ptr+1
// printf_cursor_x = 0
lda #0
sta.z printf_cursor_x
// printf_cursor_y = 0
sta.z printf_cursor_y
// }
rts
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -71,7 +71,7 @@
(label) memcpy::@2
(label) memcpy::@return
(void*) memcpy::destination
(const void*) memcpy::destination#0 destination = (void*)(const byte*) printf_screen
(const void*) memcpy::destination#0 destination = (void*) 1024
(byte*) memcpy::dst
(byte*) memcpy::dst#1 dst zp[2]:11 1.000000001E9
(byte*) memcpy::dst#2 dst zp[2]:11 1.000000001E9
@ -79,7 +79,7 @@
(const word) memcpy::num#0 num = (word)(number) $28*(number) $19-(number) $28
(void*) memcpy::return
(void*) memcpy::source
(const void*) memcpy::source#0 source = (void*)(const byte*) printf_screen+(byte) $28
(const void*) memcpy::source#0 source = (void*)(number) $400+(number) $28
(byte*) memcpy::src
(byte*) memcpy::src#1 src zp[2]:8 2.000000002E9
(byte*) memcpy::src#2 src zp[2]:8 1.000000001E9
@ -107,10 +107,11 @@
(const byte*) printf_buffer_number::digits[(number) $b] = { fill( $b, 0) }
(byte) printf_buffer_number::sign
(void()) printf_char((byte) printf_char::ch)
(byte*~) printf_char::$8 zp[2]:20 2000002.0
(byte*~) printf_char::$6 zp[2]:20 2000002.0
(label) printf_char::@1
(label) printf_char::@2
(label) printf_char::@3
(label) printf_char::@4
(label) printf_char::@return
(byte) printf_char::ch
(byte) printf_char::ch#0 reg byte a 200002.0
@ -118,10 +119,12 @@
(byte) printf_char::ch#2 reg byte a 2002.0
(byte) printf_char::ch#3 reg byte a 22.0
(byte) printf_char::ch#5 reg byte a 1201015.0
(byte*) printf_char_cursor loadstore zp[2]:20 654546.1333333328
(void()) printf_cls()
(label) printf_cls::@1
(label) printf_cls::@return
(byte*) printf_cursor_ptr loadstore zp[2]:20 41177.11764705883
(byte) printf_cursor_x loadstore zp[1]:18 35503.603550295855
(byte) printf_cursor_y loadstore zp[1]:19 40936.31578947368
(byte) printf_format_number::justify_left
(byte) printf_format_number::min_length
(byte) printf_format_number::radix
@ -129,10 +132,9 @@
(byte) printf_format_number::zero_padding
(byte) printf_format_string::justify_left
(byte) printf_format_string::min_length
(byte*) printf_line_cursor loadstore zp[2]:18 1875777.6956521738
(void()) printf_ln()
(label) printf_ln::@1
(label) printf_ln::@2
(byte*~) printf_ln::$0 zp[2]:20 2000002.0
(byte*~) printf_ln::$1 zp[2]:20 2000002.0
(label) printf_ln::@return
(void()) printf_number_buffer((byte) printf_number_buffer::buffer_sign , (byte*) printf_number_buffer::buffer_digits , (byte) printf_number_buffer::format_min_length , (byte) printf_number_buffer::format_justify_left , (byte) printf_number_buffer::format_sign_always , (byte) printf_number_buffer::format_zero_padding , (byte) printf_number_buffer::format_radix)
(word~) printf_number_buffer::$18 zp[2]:11 1001.0
@ -216,7 +218,6 @@
(const byte) printf_schar::uvalue#0 uvalue = (byte)(const signed byte) printf_schar::value#0
(signed byte) printf_schar::value
(const signed byte) printf_schar::value#0 value = -(const signed byte) main::sc
(const byte*) printf_screen = (byte*) 1024
(void()) printf_sint((signed word) printf_sint::value , (byte) printf_sint::format_min_length , (byte) printf_sint::format_justify_left , (byte) printf_sint::format_sign_always , (byte) printf_sint::format_zero_padding , (byte) printf_sint::format_radix)
(label) printf_sint::@1
(label) printf_sint::@2
@ -510,8 +511,9 @@ zp[1]:15 [ uctoa::started#2 uctoa::started#4 printf_padding::length#4 printf_pad
zp[2]:16 [ uctoa::buffer#10 uctoa::buffer#15 uctoa::buffer#11 uctoa::buffer#4 uctoa::buffer#3 uctoa_append::buffer#0 utoa::buffer#10 utoa::buffer#15 utoa::buffer#11 utoa::buffer#4 utoa::buffer#0 utoa::buffer#3 utoa_append::buffer#0 utoa::buffer#1 utoa::buffer#2 ultoa::buffer#10 ultoa::buffer#15 ultoa::buffer#11 ultoa::buffer#4 ultoa::buffer#3 ultoa_append::buffer#0 printf_str::str#20 printf_str::str#22 printf_str::str#1 printf_str::str#0 printf_number_buffer::buffer_digits#10 ]
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]:18 [ printf_line_cursor ]
zp[2]:20 [ printf_char_cursor printf_char::$8 ]
zp[1]:18 [ printf_cursor_x ]
zp[1]:19 [ printf_cursor_y ]
zp[2]:20 [ printf_cursor_ptr printf_char::$6 printf_ln::$0 printf_ln::$1 ]
zp[1]:22 [ main::c ]
reg byte a [ printf_str::ch#0 ]
reg byte a [ ultoa::$11 ]

View File

@ -8,21 +8,24 @@
.const DECIMAL = $a
.const HEXADECIMAL = $10
.const OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS = 1
.label printf_screen = $400
.const SIZEOF_STRUCT_PRINTF_BUFFER_NUMBER = $c
.label printf_line_cursor = $f
.label printf_char_cursor = $11
.label printf_cursor_x = $f
.label printf_cursor_y = $10
.label printf_cursor_ptr = $11
__bbegin:
// printf_line_cursor = PRINTF_SCREEN_ADDRESS
// printf_cursor_x = 0
// X-position of cursor
lda #0
sta.z printf_cursor_x
// printf_cursor_y = 0
// Y-position of cursor
sta.z printf_cursor_y
// printf_cursor_ptr = PRINTF_SCREEN_ADDRESS
// Pointer to cursor address
lda #<$400
sta.z printf_line_cursor
sta.z printf_cursor_ptr
lda #>$400
sta.z printf_line_cursor+1
// printf_char_cursor = PRINTF_SCREEN_ADDRESS
lda #<$400
sta.z printf_char_cursor
lda #>$400
sta.z printf_char_cursor+1
sta.z printf_cursor_ptr+1
jsr main
rts
main: {
@ -692,29 +695,30 @@ printf_str: {
}
// Print a newline
printf_ln: {
__b1:
// printf_line_cursor += PRINTF_SCREEN_WIDTH
.label __0 = $11
.label __1 = $11
// printf_cursor_ptr - printf_cursor_x
sec
lda.z __0
sbc.z printf_cursor_x
sta.z __0
bcs !+
dec.z __0+1
!:
// printf_cursor_ptr - printf_cursor_x + PRINTF_SCREEN_WIDTH
lda #$28
clc
adc.z printf_line_cursor
sta.z printf_line_cursor
adc.z __1
sta.z __1
bcc !+
inc.z printf_line_cursor+1
inc.z __1+1
!:
// while (printf_line_cursor<printf_char_cursor)
lda.z printf_line_cursor+1
cmp.z printf_char_cursor+1
bcc __b1
bne !+
lda.z printf_line_cursor
cmp.z printf_char_cursor
bcc __b1
!:
// printf_char_cursor = printf_line_cursor
lda.z printf_line_cursor
sta.z printf_char_cursor
lda.z printf_line_cursor+1
sta.z printf_char_cursor+1
// printf_cursor_ptr = printf_cursor_ptr - printf_cursor_x + PRINTF_SCREEN_WIDTH
// printf_cursor_x = 0
lda #0
sta.z printf_cursor_x
// printf_cursor_y++;
inc.z printf_cursor_y
// }
rts
}
@ -722,51 +726,53 @@ printf_ln: {
// If the end of the screen is reached scroll it up one char and place the cursor at the
// printf_char(byte register(A) ch)
printf_char: {
.label __8 = $11
// *(printf_char_cursor++) = ch
.label __6 = $11
// *(printf_cursor_ptr++) = ch
ldy #0
sta (printf_char_cursor),y
// *(printf_char_cursor++) = ch;
inc.z printf_char_cursor
sta (printf_cursor_ptr),y
// *(printf_cursor_ptr++) = ch;
inc.z printf_cursor_ptr
bne !+
inc.z printf_char_cursor+1
inc.z printf_cursor_ptr+1
!:
// if(printf_char_cursor>=(printf_screen+PRINTF_SCREEN_BYTES))
lda.z printf_char_cursor+1
cmp #>printf_screen+$28*$19
bcc __breturn
bne !+
lda.z printf_char_cursor
cmp #<printf_screen+$28*$19
bcc __breturn
!:
// memcpy(printf_screen, printf_screen+PRINTF_SCREEN_WIDTH, PRINTF_SCREEN_BYTES-PRINTF_SCREEN_WIDTH)
// if(++printf_cursor_x==PRINTF_SCREEN_WIDTH)
inc.z printf_cursor_x
lda #$28
cmp.z printf_cursor_x
bne __breturn
// printf_cursor_x = 0
lda #0
sta.z printf_cursor_x
// ++printf_cursor_y;
inc.z printf_cursor_y
// if(printf_cursor_y==PRINTF_SCREEN_HEIGHT)
lda #$19
cmp.z printf_cursor_y
bne __breturn
// memcpy(PRINTF_SCREEN_ADDRESS, PRINTF_SCREEN_ADDRESS+PRINTF_SCREEN_WIDTH, PRINTF_SCREEN_BYTES-PRINTF_SCREEN_WIDTH)
jsr memcpy
// memset(printf_screen+PRINTF_SCREEN_BYTES-PRINTF_SCREEN_WIDTH, ' ', PRINTF_SCREEN_WIDTH)
// memset(PRINTF_SCREEN_ADDRESS+PRINTF_SCREEN_BYTES-PRINTF_SCREEN_WIDTH, ' ', PRINTF_SCREEN_WIDTH)
ldx #' '
lda #<printf_screen+$28*$19-$28
lda #<$400+$28*$19-$28
sta.z memset.str
lda #>printf_screen+$28*$19-$28
lda #>$400+$28*$19-$28
sta.z memset.str+1
lda #<$28
sta.z memset.num
lda #>$28
sta.z memset.num+1
jsr memset
// printf_char_cursor-PRINTF_SCREEN_WIDTH
lda.z __8
// printf_cursor_ptr-PRINTF_SCREEN_WIDTH
lda.z __6
sec
sbc #<$28
sta.z __8
lda.z __8+1
sta.z __6
lda.z __6+1
sbc #>$28
sta.z __8+1
// printf_char_cursor = printf_char_cursor-PRINTF_SCREEN_WIDTH
// printf_line_cursor = printf_char_cursor
lda.z printf_char_cursor
sta.z printf_line_cursor
lda.z printf_char_cursor+1
sta.z printf_line_cursor+1
sta.z __6+1
// printf_cursor_ptr = printf_cursor_ptr-PRINTF_SCREEN_WIDTH
// printf_cursor_y--;
dec.z printf_cursor_y
__breturn:
// }
rts
@ -818,9 +824,9 @@ memset: {
// 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.
memcpy: {
.label destination = printf_screen
.label destination = $400
.label source = $400+$28
.const num = $28*$19-$28
.label source = printf_screen+$28
.label src_end = source+num
.label dst = $b
.label src = 8
@ -1367,27 +1373,27 @@ printf_string: {
}
// Clear the screen. Also resets current line/char cursor.
printf_cls: {
// memset(printf_screen, ' ', PRINTF_SCREEN_BYTES)
// memset(PRINTF_SCREEN_ADDRESS, ' ', PRINTF_SCREEN_BYTES)
ldx #' '
lda #<printf_screen
lda #<$400
sta.z memset.str
lda #>printf_screen
lda #>$400
sta.z memset.str+1
lda #<$28*$19
sta.z memset.num
lda #>$28*$19
sta.z memset.num+1
jsr memset
// printf_line_cursor = printf_screen
lda #<printf_screen
sta.z printf_line_cursor
lda #>printf_screen
sta.z printf_line_cursor+1
// printf_char_cursor = printf_line_cursor
lda.z printf_line_cursor
sta.z printf_char_cursor
lda.z printf_line_cursor+1
sta.z printf_char_cursor+1
// printf_cursor_ptr = PRINTF_SCREEN_ADDRESS
lda #<$400
sta.z printf_cursor_ptr
lda #>$400
sta.z printf_cursor_ptr+1
// printf_cursor_x = 0
lda #0
sta.z printf_cursor_x
// printf_cursor_y = 0
sta.z printf_cursor_y
// }
rts
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -128,7 +128,7 @@
(label) memcpy::@2
(label) memcpy::@return
(void*) memcpy::destination
(const void*) memcpy::destination#0 destination = (void*)(const byte*) printf_screen
(const void*) memcpy::destination#0 destination = (void*) 1024
(byte*) memcpy::dst
(byte*) memcpy::dst#1 dst zp[2]:11 1.000000001E9
(byte*) memcpy::dst#2 dst zp[2]:11 1.000000001E9
@ -136,7 +136,7 @@
(const word) memcpy::num#0 num = (word)(number) $28*(number) $19-(number) $28
(void*) memcpy::return
(void*) memcpy::source
(const void*) memcpy::source#0 source = (void*)(const byte*) printf_screen+(byte) $28
(const void*) memcpy::source#0 source = (void*)(number) $400+(number) $28
(byte*) memcpy::src
(byte*) memcpy::src#1 src zp[2]:8 2.000000002E9
(byte*) memcpy::src#2 src zp[2]:8 1.000000001E9
@ -164,20 +164,23 @@
(const byte*) printf_buffer_number::digits[(number) $b] = { fill( $b, 0) }
(byte) printf_buffer_number::sign
(void()) printf_char((byte) printf_char::ch)
(byte*~) printf_char::$8 zp[2]:17 2000002.0
(byte*~) printf_char::$6 zp[2]:17 2000002.0
(label) printf_char::@1
(label) printf_char::@2
(label) printf_char::@3
(label) printf_char::@4
(label) printf_char::@return
(byte) printf_char::ch
(byte) printf_char::ch#0 reg byte a 200002.0
(byte) printf_char::ch#1 reg byte a 200002.0
(byte) printf_char::ch#11 reg byte a 1201004.0
(byte) printf_char::ch#2 reg byte a 2002.0
(byte*) printf_char_cursor loadstore zp[2]:17 372414.17931034486
(void()) printf_cls()
(label) printf_cls::@1
(label) printf_cls::@return
(byte*) printf_cursor_ptr loadstore zp[2]:17 23729.18644067797
(byte) printf_cursor_x loadstore zp[1]:15 20408.534013605447
(byte) printf_cursor_y loadstore zp[1]:16 23649.02027027027
(byte) printf_format_number::justify_left
(byte) printf_format_number::min_length
(byte) printf_format_number::radix
@ -185,10 +188,9 @@
(byte) printf_format_number::zero_padding
(byte) printf_format_string::justify_left
(byte) printf_format_string::min_length
(byte*) printf_line_cursor loadstore zp[2]:15 1055944.7867132865
(void()) printf_ln()
(label) printf_ln::@1
(label) printf_ln::@2
(byte*~) printf_ln::$0 zp[2]:17 2000002.0
(byte*~) printf_ln::$1 zp[2]:17 2000002.0
(label) printf_ln::@return
(void()) printf_number_buffer((byte) printf_number_buffer::buffer_sign , (byte*) printf_number_buffer::buffer_digits , (byte) printf_number_buffer::format_min_length , (byte) printf_number_buffer::format_justify_left , (byte) printf_number_buffer::format_sign_always , (byte) printf_number_buffer::format_zero_padding , (byte) printf_number_buffer::format_radix)
(word~) printf_number_buffer::$18 zp[2]:11 1001.0
@ -254,7 +256,6 @@
(byte) printf_padding::length#6 length zp[1]:4 17201.0
(byte) printf_padding::pad
(byte) printf_padding::pad#7 pad zp[1]:5 16666.833333333332
(const byte*) printf_screen = (byte*) 1024
(void()) printf_sint((signed word) printf_sint::value , (byte) printf_sint::format_min_length , (byte) printf_sint::format_justify_left , (byte) printf_sint::format_sign_always , (byte) printf_sint::format_zero_padding , (byte) printf_sint::format_radix)
(label) printf_sint::@1
(label) printf_sint::@2
@ -430,8 +431,9 @@ reg byte x [ utoa_append::digit#2 utoa_append::digit#1 ]
reg byte x [ printf_sint::format_sign_always#16 ]
zp[1]:13 [ printf_string::format_justify_left#10 printf_number_buffer::format_justify_left#10 printf_number_buffer::format_justify_left#0 printf_sint::format_justify_left#16 ]
zp[1]:14 [ printf_string::padding#3 printf_string::padding#1 printf_number_buffer::format_zero_padding#10 printf_number_buffer::format_zero_padding#0 printf_sint::format_zero_padding#16 ]
zp[2]:15 [ printf_line_cursor ]
zp[2]:17 [ printf_char_cursor printf_char::$8 ]
zp[1]:15 [ printf_cursor_x ]
zp[1]:16 [ printf_cursor_y ]
zp[2]:17 [ printf_cursor_ptr printf_char::$6 printf_ln::$0 printf_ln::$1 ]
reg byte a [ printf_str::ch#0 ]
reg byte a [ utoa::$4 ]
reg byte a [ utoa::$11 ]

View File

@ -1,39 +1,42 @@
// Tests printf function call rewriting
// Print a char using %d
// Print a char using %u
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
.const OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS = 1
.label printf_screen = $400
.const SIZEOF_STRUCT_PRINTF_BUFFER_NUMBER = $c
.label printf_line_cursor = 8
.label printf_char_cursor = $a
.label printf_cursor_x = $a
.label printf_cursor_y = $b
.label printf_cursor_ptr = $c
__bbegin:
// printf_line_cursor = PRINTF_SCREEN_ADDRESS
// printf_cursor_x = 0
// X-position of cursor
lda #0
sta.z printf_cursor_x
// printf_cursor_y = 0
// Y-position of cursor
sta.z printf_cursor_y
// printf_cursor_ptr = PRINTF_SCREEN_ADDRESS
// Pointer to cursor address
lda #<$400
sta.z printf_line_cursor
sta.z printf_cursor_ptr
lda #>$400
sta.z printf_line_cursor+1
// printf_char_cursor = PRINTF_SCREEN_ADDRESS
lda #<$400
sta.z printf_char_cursor
lda #>$400
sta.z printf_char_cursor+1
sta.z printf_cursor_ptr+1
jsr main
rts
main: {
.label c = 7
// printf_cls()
jsr printf_cls
// printf("%hhu", c)
// printf("%u", c)
lda #<str
sta.z printf_str.str
lda #>str
sta.z printf_str.str+1
jsr printf_str
// printf("%hhu", c)
// printf("%u", c)
jsr printf_uchar
// printf("%hhu", c)
// printf("%u", c)
lda #<str
sta.z printf_str.str
lda #>str
@ -46,9 +49,9 @@ main: {
}
// Print a zero-terminated string
// Handles escape codes such as newline
// printf_str(byte* zp(6) str)
// printf_str(byte* zp(8) str)
printf_str: {
.label str = 6
.label str = 8
__b2:
// ch = *str++
ldy #0
@ -76,29 +79,30 @@ printf_str: {
}
// Print a newline
printf_ln: {
__b1:
// printf_line_cursor += PRINTF_SCREEN_WIDTH
.label __0 = $c
.label __1 = $c
// printf_cursor_ptr - printf_cursor_x
sec
lda.z __0
sbc.z printf_cursor_x
sta.z __0
bcs !+
dec.z __0+1
!:
// printf_cursor_ptr - printf_cursor_x + PRINTF_SCREEN_WIDTH
lda #$28
clc
adc.z printf_line_cursor
sta.z printf_line_cursor
adc.z __1
sta.z __1
bcc !+
inc.z printf_line_cursor+1
inc.z __1+1
!:
// while (printf_line_cursor<printf_char_cursor)
lda.z printf_line_cursor+1
cmp.z printf_char_cursor+1
bcc __b1
bne !+
lda.z printf_line_cursor
cmp.z printf_char_cursor
bcc __b1
!:
// printf_char_cursor = printf_line_cursor
lda.z printf_line_cursor
sta.z printf_char_cursor
lda.z printf_line_cursor+1
sta.z printf_char_cursor+1
// printf_cursor_ptr = printf_cursor_ptr - printf_cursor_x + PRINTF_SCREEN_WIDTH
// printf_cursor_x = 0
lda #0
sta.z printf_cursor_x
// printf_cursor_y++;
inc.z printf_cursor_y
// }
rts
}
@ -106,62 +110,64 @@ printf_ln: {
// If the end of the screen is reached scroll it up one char and place the cursor at the
// printf_char(byte register(A) ch)
printf_char: {
.label __8 = $a
// *(printf_char_cursor++) = ch
.label __6 = $c
// *(printf_cursor_ptr++) = ch
ldy #0
sta (printf_char_cursor),y
// *(printf_char_cursor++) = ch;
inc.z printf_char_cursor
sta (printf_cursor_ptr),y
// *(printf_cursor_ptr++) = ch;
inc.z printf_cursor_ptr
bne !+
inc.z printf_char_cursor+1
inc.z printf_cursor_ptr+1
!:
// if(printf_char_cursor>=(printf_screen+PRINTF_SCREEN_BYTES))
lda.z printf_char_cursor+1
cmp #>printf_screen+$28*$19
bcc __breturn
bne !+
lda.z printf_char_cursor
cmp #<printf_screen+$28*$19
bcc __breturn
!:
// memcpy(printf_screen, printf_screen+PRINTF_SCREEN_WIDTH, PRINTF_SCREEN_BYTES-PRINTF_SCREEN_WIDTH)
// if(++printf_cursor_x==PRINTF_SCREEN_WIDTH)
inc.z printf_cursor_x
lda #$28
cmp.z printf_cursor_x
bne __breturn
// printf_cursor_x = 0
lda #0
sta.z printf_cursor_x
// ++printf_cursor_y;
inc.z printf_cursor_y
// if(printf_cursor_y==PRINTF_SCREEN_HEIGHT)
lda #$19
cmp.z printf_cursor_y
bne __breturn
// memcpy(PRINTF_SCREEN_ADDRESS, PRINTF_SCREEN_ADDRESS+PRINTF_SCREEN_WIDTH, PRINTF_SCREEN_BYTES-PRINTF_SCREEN_WIDTH)
jsr memcpy
// memset(printf_screen+PRINTF_SCREEN_BYTES-PRINTF_SCREEN_WIDTH, ' ', PRINTF_SCREEN_WIDTH)
// memset(PRINTF_SCREEN_ADDRESS+PRINTF_SCREEN_BYTES-PRINTF_SCREEN_WIDTH, ' ', PRINTF_SCREEN_WIDTH)
ldx #' '
lda #<printf_screen+$28*$19-$28
lda #<$400+$28*$19-$28
sta.z memset.str
lda #>printf_screen+$28*$19-$28
lda #>$400+$28*$19-$28
sta.z memset.str+1
lda #<$28
sta.z memset.num
lda #>$28
sta.z memset.num+1
jsr memset
// printf_char_cursor-PRINTF_SCREEN_WIDTH
lda.z __8
// printf_cursor_ptr-PRINTF_SCREEN_WIDTH
lda.z __6
sec
sbc #<$28
sta.z __8
lda.z __8+1
sta.z __6
lda.z __6+1
sbc #>$28
sta.z __8+1
// printf_char_cursor = printf_char_cursor-PRINTF_SCREEN_WIDTH
// printf_line_cursor = printf_char_cursor
lda.z printf_char_cursor
sta.z printf_line_cursor
lda.z printf_char_cursor+1
sta.z printf_line_cursor+1
sta.z __6+1
// printf_cursor_ptr = printf_cursor_ptr-PRINTF_SCREEN_WIDTH
// printf_cursor_y--;
dec.z printf_cursor_y
__breturn:
// }
rts
}
// Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
// memset(void* zp(2) str, byte register(X) c, word zp(8) num)
// memset(void* zp(4) str, byte register(X) c, word zp(2) num)
memset: {
.label end = 8
.label dst = 2
.label num = 8
.label str = 2
.label end = 2
.label dst = 4
.label num = 2
.label str = 4
// if(num>0)
lda.z num
bne !+
@ -202,12 +208,12 @@ memset: {
// 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.
memcpy: {
.label destination = printf_screen
.label destination = $400
.label source = $400+$28
.const num = $28*$19-$28
.label source = printf_screen+$28
.label src_end = source+num
.label dst = 2
.label src = 8
.label dst = 4
.label src = 2
lda #<destination
sta.z dst
lda #>destination
@ -283,13 +289,13 @@ printf_number_buffer: {
// - 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)
// uctoa(byte register(X) value, byte* zp(6) buffer)
// uctoa(byte register(X) value, byte* zp(8) buffer)
uctoa: {
.const max_digits = 3
.label digit_value = $c
.label buffer = 6
.label digit = 4
.label started = 5
.label digit_value = $e
.label buffer = 8
.label digit = 6
.label started = 7
lda #<printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
sta.z buffer
lda #>printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
@ -355,10 +361,10 @@ uctoa: {
// - 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.
// uctoa_append(byte* zp(6) buffer, byte register(X) value, byte zp($c) sub)
// uctoa_append(byte* zp(8) buffer, byte register(X) value, byte zp($e) sub)
uctoa_append: {
.label buffer = 6
.label sub = $c
.label buffer = 8
.label sub = $e
ldy #0
__b1:
// while (value >= sub)
@ -382,27 +388,27 @@ uctoa_append: {
}
// Clear the screen. Also resets current line/char cursor.
printf_cls: {
// memset(printf_screen, ' ', PRINTF_SCREEN_BYTES)
// memset(PRINTF_SCREEN_ADDRESS, ' ', PRINTF_SCREEN_BYTES)
ldx #' '
lda #<printf_screen
lda #<$400
sta.z memset.str
lda #>printf_screen
lda #>$400
sta.z memset.str+1
lda #<$28*$19
sta.z memset.num
lda #>$28*$19
sta.z memset.num+1
jsr memset
// printf_line_cursor = printf_screen
lda #<printf_screen
sta.z printf_line_cursor
lda #>printf_screen
sta.z printf_line_cursor+1
// printf_char_cursor = printf_line_cursor
lda.z printf_line_cursor
sta.z printf_char_cursor
lda.z printf_line_cursor+1
sta.z printf_char_cursor+1
// printf_cursor_ptr = PRINTF_SCREEN_ADDRESS
lda #<$400
sta.z printf_cursor_ptr
lda #>$400
sta.z printf_cursor_ptr+1
// printf_cursor_x = 0
lda #0
sta.z printf_cursor_x
// printf_cursor_y = 0
sta.z printf_cursor_y
// }
rts
}

View File

@ -2,253 +2,258 @@
[0] phi()
to:@1
@1: scope:[] from @begin
[1] (byte*) printf_line_cursor ← (byte*) 1024
[2] (byte*) printf_char_cursor ← (byte*) 1024
[1] (byte) printf_cursor_x ← (byte) 0
[2] (byte) printf_cursor_y ← (byte) 0
[3] (byte*) printf_cursor_ptr ← (byte*) 1024
to:@2
@2: scope:[] from @1
[3] phi()
[4] call main
[4] phi()
[5] call main
to:@end
@end: scope:[] from @2
[5] phi()
[6] phi()
(void()) main()
main: scope:[main] from @2
[6] phi()
[7] call printf_cls
[7] phi()
[8] call printf_cls
to:main::@1
main::@1: scope:[main] from main
[8] phi()
[9] call printf_str
[9] phi()
[10] call printf_str
to:main::@2
main::@2: scope:[main] from main::@1
[10] phi()
[11] call printf_uchar
[11] phi()
[12] call printf_uchar
to:main::@3
main::@3: scope:[main] from main::@2
[12] phi()
[13] call printf_str
[13] phi()
[14] call printf_str
to:main::@return
main::@return: scope:[main] from main::@3
[14] return
[15] return
to:@return
(void()) printf_str((byte*) printf_str::str)
printf_str: scope:[printf_str] from main::@1 main::@3 printf_number_buffer::@2
[15] (byte*) printf_str::str#6 ← phi( main::@1/(const byte*) main::str main::@3/(const byte*) main::str printf_number_buffer::@2/(const byte*) printf_number_buffer::buffer_digits#0 )
[16] (byte*) printf_str::str#6 ← phi( main::@1/(const byte*) main::str main::@3/(const byte*) main::str printf_number_buffer::@2/(const byte*) printf_number_buffer::buffer_digits#0 )
to:printf_str::@1
printf_str::@1: scope:[printf_str] from printf_str printf_str::@4 printf_str::@5
[16] (byte*) printf_str::str#4 ← phi( printf_str/(byte*) printf_str::str#6 printf_str::@4/(byte*) printf_str::str#0 printf_str::@5/(byte*) printf_str::str#0 )
[17] (byte*) printf_str::str#4 ← phi( printf_str/(byte*) printf_str::str#6 printf_str::@4/(byte*) printf_str::str#0 printf_str::@5/(byte*) printf_str::str#0 )
to:printf_str::@2
printf_str::@2: scope:[printf_str] from printf_str::@1
[17] (byte) printf_str::ch#0 ← *((byte*) printf_str::str#4)
[18] (byte*) printf_str::str#0 ← ++ (byte*) printf_str::str#4
[19] if((byte) printf_str::ch#0!=(byte) 0) goto printf_str::@3
[18] (byte) printf_str::ch#0 ← *((byte*) printf_str::str#4)
[19] (byte*) printf_str::str#0 ← ++ (byte*) printf_str::str#4
[20] if((byte) printf_str::ch#0!=(byte) 0) goto printf_str::@3
to:printf_str::@return
printf_str::@return: scope:[printf_str] from printf_str::@2
[20] return
[21] return
to:@return
printf_str::@3: scope:[printf_str] from printf_str::@2
[21] if((byte) printf_str::ch#0==(byte) '
[22] if((byte) printf_str::ch#0==(byte) '
') goto printf_str::@4
to:printf_str::@5
printf_str::@5: scope:[printf_str] from printf_str::@3
[22] (byte) printf_char::ch#1 ← (byte) printf_str::ch#0
[23] call printf_char
[23] (byte) printf_char::ch#1 ← (byte) printf_str::ch#0
[24] call printf_char
to:printf_str::@1
printf_str::@4: scope:[printf_str] from printf_str::@3
[24] phi()
[25] call printf_ln
[25] phi()
[26] call printf_ln
to:printf_str::@1
(void()) printf_ln()
printf_ln: scope:[printf_ln] from printf_str::@4
[26] phi()
to:printf_ln::@1
printf_ln::@1: scope:[printf_ln] from printf_ln printf_ln::@1
[27] (byte*) printf_line_cursor ← (byte*) printf_line_cursor + (byte) $28
[28] if((byte*) printf_line_cursor<(byte*) printf_char_cursor) goto printf_ln::@1
to:printf_ln::@2
printf_ln::@2: scope:[printf_ln] from printf_ln::@1
[29] (byte*) printf_char_cursor ← (byte*) printf_line_cursor
[27] (byte*~) printf_ln::$0 ← (byte*) printf_cursor_ptr - (byte) printf_cursor_x
[28] (byte*~) printf_ln::$1 ← (byte*~) printf_ln::$0 + (byte) $28
[29] (byte*) printf_cursor_ptr ← (byte*~) printf_ln::$1
[30] (byte) printf_cursor_x ← (byte) 0
[31] (byte) printf_cursor_y ← ++ (byte) printf_cursor_y
to:printf_ln::@return
printf_ln::@return: scope:[printf_ln] from printf_ln::@2
[30] return
printf_ln::@return: scope:[printf_ln] from printf_ln
[32] return
to:@return
(void()) printf_char((byte) printf_char::ch)
printf_char: scope:[printf_char] from printf_number_buffer::@3 printf_str::@5
[31] (byte) printf_char::ch#3 ← phi( printf_number_buffer::@3/(byte) printf_char::ch#2 printf_str::@5/(byte) printf_char::ch#1 )
[32] *((byte*) printf_char_cursor) ← (byte) printf_char::ch#3
[33] (byte*) printf_char_cursor ← ++ (byte*) printf_char_cursor
[34] if((byte*) printf_char_cursor<(const byte*) printf_screen+(word)(number) $28*(number) $19) goto printf_char::@return
[33] (byte) printf_char::ch#3 ← phi( printf_number_buffer::@3/(byte) printf_char::ch#2 printf_str::@5/(byte) printf_char::ch#1 )
[34] *((byte*) printf_cursor_ptr) ← (byte) printf_char::ch#3
[35] (byte*) printf_cursor_ptr ← ++ (byte*) printf_cursor_ptr
[36] (byte) printf_cursor_x ← ++ (byte) printf_cursor_x
[37] if((byte) printf_cursor_x!=(byte) $28) goto printf_char::@return
to:printf_char::@1
printf_char::@1: scope:[printf_char] from printf_char
[35] phi()
[36] call memcpy
[38] (byte) printf_cursor_x ← (byte) 0
[39] (byte) printf_cursor_y ← ++ (byte) printf_cursor_y
[40] if((byte) printf_cursor_y!=(byte) $19) goto printf_char::@return
to:printf_char::@2
printf_char::@2: scope:[printf_char] from printf_char::@1
[37] phi()
[38] call memset
[41] phi()
[42] call memcpy
to:printf_char::@3
printf_char::@3: scope:[printf_char] from printf_char::@2
[39] (byte*~) printf_char::$8 ← (byte*) printf_char_cursor - (byte) $28
[40] (byte*) printf_char_cursor ← (byte*~) printf_char::$8
[41] (byte*) printf_line_cursor ← (byte*) printf_char_cursor
[43] phi()
[44] call memset
to:printf_char::@4
printf_char::@4: scope:[printf_char] from printf_char::@3
[45] (byte*~) printf_char::$6 ← (byte*) printf_cursor_ptr - (byte) $28
[46] (byte*) printf_cursor_ptr ← (byte*~) printf_char::$6
[47] (byte) printf_cursor_y ← -- (byte) printf_cursor_y
to:printf_char::@return
printf_char::@return: scope:[printf_char] from printf_char printf_char::@3
[42] return
printf_char::@return: scope:[printf_char] from printf_char printf_char::@1 printf_char::@4
[48] return
to:@return
(void*()) memset((void*) memset::str , (byte) memset::c , (word) memset::num)
memset: scope:[memset] from printf_char::@2 printf_cls
[43] (byte) memset::c#4 ← phi( printf_char::@2/(byte) ' ' printf_cls/(byte) ' ' )
[43] (void*) memset::str#3 ← phi( printf_char::@2/(void*)(const byte*) printf_screen+(word)(number) $28*(number) $19-(byte) $28 printf_cls/(void*)(const byte*) printf_screen )
[43] (word) memset::num#2 ← phi( printf_char::@2/(byte) $28 printf_cls/(word)(number) $28*(number) $19 )
[44] if((word) memset::num#2<=(byte) 0) goto memset::@return
memset: scope:[memset] from printf_char::@3 printf_cls
[49] (byte) memset::c#4 ← phi( printf_char::@3/(byte) ' ' printf_cls/(byte) ' ' )
[49] (void*) memset::str#3 ← phi( printf_char::@3/(void*)(number) $400+(number) $28*(number) $19-(number) $28 printf_cls/(void*) 1024 )
[49] (word) memset::num#2 ← phi( printf_char::@3/(byte) $28 printf_cls/(word)(number) $28*(number) $19 )
[50] if((word) memset::num#2<=(byte) 0) goto memset::@return
to:memset::@1
memset::@1: scope:[memset] from memset
[45] (byte*) memset::end#0 ← (byte*)(void*) memset::str#3 + (word) memset::num#2
[46] (byte*) memset::dst#4 ← (byte*)(void*) memset::str#3
[51] (byte*) memset::end#0 ← (byte*)(void*) memset::str#3 + (word) memset::num#2
[52] (byte*) memset::dst#4 ← (byte*)(void*) memset::str#3
to:memset::@2
memset::@2: scope:[memset] from memset::@1 memset::@3
[47] (byte*) memset::dst#2 ← phi( memset::@1/(byte*) memset::dst#4 memset::@3/(byte*) memset::dst#1 )
[48] if((byte*) memset::dst#2!=(byte*) memset::end#0) goto memset::@3
[53] (byte*) memset::dst#2 ← phi( memset::@1/(byte*) memset::dst#4 memset::@3/(byte*) memset::dst#1 )
[54] if((byte*) memset::dst#2!=(byte*) memset::end#0) goto memset::@3
to:memset::@return
memset::@return: scope:[memset] from memset memset::@2
[49] return
[55] return
to:@return
memset::@3: scope:[memset] from memset::@2
[50] *((byte*) memset::dst#2) ← (byte) memset::c#4
[51] (byte*) memset::dst#1 ← ++ (byte*) memset::dst#2
[56] *((byte*) memset::dst#2) ← (byte) memset::c#4
[57] (byte*) memset::dst#1 ← ++ (byte*) memset::dst#2
to:memset::@2
(void*()) memcpy((void*) memcpy::destination , (void*) memcpy::source , (word) memcpy::num)
memcpy: scope:[memcpy] from printf_char::@1
[52] phi()
memcpy: scope:[memcpy] from printf_char::@2
[58] phi()
to:memcpy::@1
memcpy::@1: scope:[memcpy] from memcpy memcpy::@2
[53] (byte*) memcpy::dst#2 ← phi( memcpy/(byte*)(const void*) memcpy::destination#0 memcpy::@2/(byte*) memcpy::dst#1 )
[53] (byte*) memcpy::src#2 ← phi( memcpy/(byte*)(const void*) memcpy::source#0 memcpy::@2/(byte*) memcpy::src#1 )
[54] if((byte*) memcpy::src#2!=(const byte*) memcpy::src_end#0) goto memcpy::@2
[59] (byte*) memcpy::dst#2 ← phi( memcpy/(byte*)(const void*) memcpy::destination#0 memcpy::@2/(byte*) memcpy::dst#1 )
[59] (byte*) memcpy::src#2 ← phi( memcpy/(byte*)(const void*) memcpy::source#0 memcpy::@2/(byte*) memcpy::src#1 )
[60] if((byte*) memcpy::src#2!=(const byte*) memcpy::src_end#0) goto memcpy::@2
to:memcpy::@return
memcpy::@return: scope:[memcpy] from memcpy::@1
[55] return
[61] return
to:@return
memcpy::@2: scope:[memcpy] from memcpy::@1
[56] *((byte*) memcpy::dst#2) ← *((byte*) memcpy::src#2)
[57] (byte*) memcpy::dst#1 ← ++ (byte*) memcpy::dst#2
[58] (byte*) memcpy::src#1 ← ++ (byte*) memcpy::src#2
[62] *((byte*) memcpy::dst#2) ← *((byte*) memcpy::src#2)
[63] (byte*) memcpy::dst#1 ← ++ (byte*) memcpy::dst#2
[64] (byte*) memcpy::src#1 ← ++ (byte*) memcpy::src#2
to:memcpy::@1
(void()) printf_uchar((byte) printf_uchar::uvalue , (byte) printf_uchar::format_min_length , (byte) printf_uchar::format_justify_left , (byte) printf_uchar::format_sign_always , (byte) printf_uchar::format_zero_padding , (byte) printf_uchar::format_radix)
printf_uchar: scope:[printf_uchar] from main::@2
[59] phi()
[65] phi()
to:printf_uchar::@1
printf_uchar::@1: scope:[printf_uchar] from printf_uchar
[60] *((byte*)&(struct printf_buffer_number) printf_buffer) ← (byte) 0
[61] call uctoa
[66] *((byte*)&(struct printf_buffer_number) printf_buffer) ← (byte) 0
[67] call uctoa
to:printf_uchar::@2
printf_uchar::@2: scope:[printf_uchar] from printf_uchar::@1
[62] (byte) printf_number_buffer::buffer_sign#0 ← *((byte*)&(struct printf_buffer_number) printf_buffer)
[63] call printf_number_buffer
[68] (byte) printf_number_buffer::buffer_sign#0 ← *((byte*)&(struct printf_buffer_number) printf_buffer)
[69] call printf_number_buffer
to:printf_uchar::@return
printf_uchar::@return: scope:[printf_uchar] from printf_uchar::@2
[64] return
[70] return
to:@return
(void()) printf_number_buffer((byte) printf_number_buffer::buffer_sign , (byte*) printf_number_buffer::buffer_digits , (byte) printf_number_buffer::format_min_length , (byte) printf_number_buffer::format_justify_left , (byte) printf_number_buffer::format_sign_always , (byte) printf_number_buffer::format_zero_padding , (byte) printf_number_buffer::format_radix)
printf_number_buffer: scope:[printf_number_buffer] from printf_uchar::@2
[65] phi()
[71] phi()
to:printf_number_buffer::@1
printf_number_buffer::@1: scope:[printf_number_buffer] from printf_number_buffer
[66] if((byte) 0==(byte) printf_number_buffer::buffer_sign#0) goto printf_number_buffer::@2
[72] if((byte) 0==(byte) 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
[67] (byte) printf_char::ch#2 ← (byte) printf_number_buffer::buffer_sign#0
[68] call printf_char
[73] (byte) printf_char::ch#2 ← (byte) printf_number_buffer::buffer_sign#0
[74] call printf_char
to:printf_number_buffer::@2
printf_number_buffer::@2: scope:[printf_number_buffer] from printf_number_buffer::@1 printf_number_buffer::@3
[69] phi()
[70] call printf_str
[75] phi()
[76] call printf_str
to:printf_number_buffer::@return
printf_number_buffer::@return: scope:[printf_number_buffer] from printf_number_buffer::@2
[71] return
[77] return
to:@return
(void()) uctoa((byte) uctoa::value , (byte*) uctoa::buffer , (byte) uctoa::radix)
uctoa: scope:[uctoa] from printf_uchar::@1
[72] phi()
[78] phi()
to:uctoa::@1
uctoa::@1: scope:[uctoa] from uctoa uctoa::@4
[73] (byte*) uctoa::buffer#11 ← phi( uctoa::@4/(byte*) uctoa::buffer#14 uctoa/(byte*)&(struct printf_buffer_number) printf_buffer+(const byte) OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS )
[73] (byte) uctoa::started#2 ← phi( uctoa::@4/(byte) uctoa::started#4 uctoa/(byte) 0 )
[73] (byte) uctoa::value#2 ← phi( uctoa::@4/(byte) uctoa::value#6 uctoa/(const byte) main::c )
[73] (byte) uctoa::digit#2 ← phi( uctoa::@4/(byte) uctoa::digit#1 uctoa/(byte) 0 )
[74] if((byte) uctoa::digit#2<(const byte) uctoa::max_digits#1-(byte) 1) goto uctoa::@2
[79] (byte*) uctoa::buffer#11 ← phi( uctoa::@4/(byte*) uctoa::buffer#14 uctoa/(byte*)&(struct printf_buffer_number) printf_buffer+(const byte) OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS )
[79] (byte) uctoa::started#2 ← phi( uctoa::@4/(byte) uctoa::started#4 uctoa/(byte) 0 )
[79] (byte) uctoa::value#2 ← phi( uctoa::@4/(byte) uctoa::value#6 uctoa/(const byte) main::c )
[79] (byte) uctoa::digit#2 ← phi( uctoa::@4/(byte) uctoa::digit#1 uctoa/(byte) 0 )
[80] if((byte) uctoa::digit#2<(const byte) uctoa::max_digits#1-(byte) 1) goto uctoa::@2
to:uctoa::@3
uctoa::@3: scope:[uctoa] from uctoa::@1
[75] *((byte*) uctoa::buffer#11) ← *((const byte*) DIGITS + (byte) uctoa::value#2)
[76] (byte*) uctoa::buffer#3 ← ++ (byte*) uctoa::buffer#11
[77] *((byte*) uctoa::buffer#3) ← (byte) 0
[81] *((byte*) uctoa::buffer#11) ← *((const byte*) DIGITS + (byte) uctoa::value#2)
[82] (byte*) uctoa::buffer#3 ← ++ (byte*) uctoa::buffer#11
[83] *((byte*) uctoa::buffer#3) ← (byte) 0
to:uctoa::@return
uctoa::@return: scope:[uctoa] from uctoa::@3
[78] return
[84] return
to:@return
uctoa::@2: scope:[uctoa] from uctoa::@1
[79] (byte) uctoa::digit_value#0 ← *((const byte*) RADIX_DECIMAL_VALUES_CHAR + (byte) uctoa::digit#2)
[80] if((byte) 0!=(byte) uctoa::started#2) goto uctoa::@5
[85] (byte) uctoa::digit_value#0 ← *((const byte*) RADIX_DECIMAL_VALUES_CHAR + (byte) uctoa::digit#2)
[86] if((byte) 0!=(byte) uctoa::started#2) goto uctoa::@5
to:uctoa::@7
uctoa::@7: scope:[uctoa] from uctoa::@2
[81] if((byte) uctoa::value#2>=(byte) uctoa::digit_value#0) goto uctoa::@5
[87] if((byte) uctoa::value#2>=(byte) uctoa::digit_value#0) goto uctoa::@5
to:uctoa::@4
uctoa::@4: scope:[uctoa] from uctoa::@6 uctoa::@7
[82] (byte*) uctoa::buffer#14 ← phi( uctoa::@7/(byte*) uctoa::buffer#11 uctoa::@6/(byte*) uctoa::buffer#4 )
[82] (byte) uctoa::started#4 ← phi( uctoa::@7/(byte) uctoa::started#2 uctoa::@6/(byte) 1 )
[82] (byte) uctoa::value#6 ← phi( uctoa::@7/(byte) uctoa::value#2 uctoa::@6/(byte) uctoa::value#0 )
[83] (byte) uctoa::digit#1 ← ++ (byte) uctoa::digit#2
[88] (byte*) uctoa::buffer#14 ← phi( uctoa::@7/(byte*) uctoa::buffer#11 uctoa::@6/(byte*) uctoa::buffer#4 )
[88] (byte) uctoa::started#4 ← phi( uctoa::@7/(byte) uctoa::started#2 uctoa::@6/(byte) 1 )
[88] (byte) uctoa::value#6 ← phi( uctoa::@7/(byte) uctoa::value#2 uctoa::@6/(byte) uctoa::value#0 )
[89] (byte) uctoa::digit#1 ← ++ (byte) uctoa::digit#2
to:uctoa::@1
uctoa::@5: scope:[uctoa] from uctoa::@2 uctoa::@7
[84] (byte*) uctoa_append::buffer#0 ← (byte*) uctoa::buffer#11
[85] (byte) uctoa_append::value#0 ← (byte) uctoa::value#2
[86] (byte) uctoa_append::sub#0 ← (byte) uctoa::digit_value#0
[87] call uctoa_append
[88] (byte) uctoa_append::return#0 ← (byte) uctoa_append::value#2
[90] (byte*) uctoa_append::buffer#0 ← (byte*) uctoa::buffer#11
[91] (byte) uctoa_append::value#0 ← (byte) uctoa::value#2
[92] (byte) uctoa_append::sub#0 ← (byte) uctoa::digit_value#0
[93] call uctoa_append
[94] (byte) uctoa_append::return#0 ← (byte) uctoa_append::value#2
to:uctoa::@6
uctoa::@6: scope:[uctoa] from uctoa::@5
[89] (byte) uctoa::value#0 ← (byte) uctoa_append::return#0
[90] (byte*) uctoa::buffer#4 ← ++ (byte*) uctoa::buffer#11
[95] (byte) uctoa::value#0 ← (byte) uctoa_append::return#0
[96] (byte*) uctoa::buffer#4 ← ++ (byte*) uctoa::buffer#11
to:uctoa::@4
(byte()) uctoa_append((byte*) uctoa_append::buffer , (byte) uctoa_append::value , (byte) uctoa_append::sub)
uctoa_append: scope:[uctoa_append] from uctoa::@5
[91] phi()
[97] phi()
to:uctoa_append::@1
uctoa_append::@1: scope:[uctoa_append] from uctoa_append uctoa_append::@2
[92] (byte) uctoa_append::digit#2 ← phi( uctoa_append/(byte) 0 uctoa_append::@2/(byte) uctoa_append::digit#1 )
[92] (byte) uctoa_append::value#2 ← phi( uctoa_append/(byte) uctoa_append::value#0 uctoa_append::@2/(byte) uctoa_append::value#1 )
[93] if((byte) uctoa_append::value#2>=(byte) uctoa_append::sub#0) goto uctoa_append::@2
[98] (byte) uctoa_append::digit#2 ← phi( uctoa_append/(byte) 0 uctoa_append::@2/(byte) uctoa_append::digit#1 )
[98] (byte) uctoa_append::value#2 ← phi( uctoa_append/(byte) uctoa_append::value#0 uctoa_append::@2/(byte) uctoa_append::value#1 )
[99] if((byte) uctoa_append::value#2>=(byte) uctoa_append::sub#0) goto uctoa_append::@2
to:uctoa_append::@3
uctoa_append::@3: scope:[uctoa_append] from uctoa_append::@1
[94] *((byte*) uctoa_append::buffer#0) ← *((const byte*) DIGITS + (byte) uctoa_append::digit#2)
[100] *((byte*) uctoa_append::buffer#0) ← *((const byte*) DIGITS + (byte) uctoa_append::digit#2)
to:uctoa_append::@return
uctoa_append::@return: scope:[uctoa_append] from uctoa_append::@3
[95] return
[101] return
to:@return
uctoa_append::@2: scope:[uctoa_append] from uctoa_append::@1
[96] (byte) uctoa_append::digit#1 ← ++ (byte) uctoa_append::digit#2
[97] (byte) uctoa_append::value#1 ← (byte) uctoa_append::value#2 - (byte) uctoa_append::sub#0
[102] (byte) uctoa_append::digit#1 ← ++ (byte) uctoa_append::digit#2
[103] (byte) uctoa_append::value#1 ← (byte) uctoa_append::value#2 - (byte) uctoa_append::sub#0
to:uctoa_append::@1
(void()) printf_cls()
printf_cls: scope:[printf_cls] from main
[98] phi()
[99] call memset
[104] phi()
[105] call memset
to:printf_cls::@1
printf_cls::@1: scope:[printf_cls] from printf_cls
[100] (byte*) printf_line_cursor ← (const byte*) printf_screen
[101] (byte*) printf_char_cursor ← (byte*) printf_line_cursor
[106] (byte*) printf_cursor_ptr ← (byte*) 1024
[107] (byte) printf_cursor_x ← (byte) 0
[108] (byte) printf_cursor_y ← (byte) 0
to:printf_cls::@return
printf_cls::@return: scope:[printf_cls] from printf_cls::@1
[102] return
[109] return
to:@return

File diff suppressed because it is too large Load Diff

View File

@ -22,18 +22,18 @@
(label) memcpy::@2
(label) memcpy::@return
(void*) memcpy::destination
(const void*) memcpy::destination#0 destination = (void*)(const byte*) printf_screen
(const void*) memcpy::destination#0 destination = (void*) 1024
(byte*) memcpy::dst
(byte*) memcpy::dst#1 dst zp[2]:2 1.000000001E9
(byte*) memcpy::dst#2 dst zp[2]:2 1.000000001E9
(byte*) memcpy::dst#1 dst zp[2]:4 1.000000001E9
(byte*) memcpy::dst#2 dst zp[2]:4 1.000000001E9
(word) memcpy::num
(const word) memcpy::num#0 num = (word)(number) $28*(number) $19-(number) $28
(void*) memcpy::return
(void*) memcpy::source
(const void*) memcpy::source#0 source = (void*)(const byte*) printf_screen+(byte) $28
(const void*) memcpy::source#0 source = (void*)(number) $400+(number) $28
(byte*) memcpy::src
(byte*) memcpy::src#1 src zp[2]:8 2.000000002E9
(byte*) memcpy::src#2 src zp[2]:8 1.000000001E9
(byte*) memcpy::src#1 src zp[2]:2 2.000000002E9
(byte*) memcpy::src#2 src zp[2]:2 1.000000001E9
(byte*) memcpy::src_end
(const byte*) memcpy::src_end#0 src_end = (byte*)(const void*) memcpy::source#0+(const word) memcpy::num#0
(void*()) memset((void*) memset::str , (byte) memset::c , (word) memset::num)
@ -44,33 +44,36 @@
(byte) memset::c
(byte) memset::c#4 reg byte x 1.25000000125E8
(byte*) memset::dst
(byte*) memset::dst#1 dst zp[2]:2 2.000000002E9
(byte*) memset::dst#2 dst zp[2]:2 1.3366666683333335E9
(byte*) memset::dst#4 dst zp[2]:2 2.0000002E7
(byte*) memset::dst#1 dst zp[2]:4 2.000000002E9
(byte*) memset::dst#2 dst zp[2]:4 1.3366666683333335E9
(byte*) memset::dst#4 dst zp[2]:4 2.0000002E7
(byte*) memset::end
(byte*) memset::end#0 end zp[2]:8 1.683333336666667E8
(byte*) memset::end#0 end zp[2]:2 1.683333336666667E8
(word) memset::num
(word) memset::num#2 num zp[2]:8 1.0000001E7
(word) memset::num#2 num zp[2]:2 1.0000001E7
(void*) memset::return
(void*) memset::str
(void*) memset::str#3 str zp[2]:2
(void*) memset::str#3 str zp[2]:4
(struct printf_buffer_number) printf_buffer loadstore mem[12] = {}
(const byte*) printf_buffer_number::digits[(number) $b] = { fill( $b, 0) }
(byte) printf_buffer_number::sign
(void()) printf_char((byte) printf_char::ch)
(byte*~) printf_char::$8 zp[2]:10 2000002.0
(byte*~) printf_char::$6 zp[2]:12 2000002.0
(label) printf_char::@1
(label) printf_char::@2
(label) printf_char::@3
(label) printf_char::@4
(label) printf_char::@return
(byte) printf_char::ch
(byte) printf_char::ch#1 reg byte a 200002.0
(byte) printf_char::ch#2 reg byte a 2002.0
(byte) printf_char::ch#3 reg byte a 1101003.0
(byte*) printf_char_cursor loadstore zp[2]:10 2250002.333333332
(void()) printf_cls()
(label) printf_cls::@1
(label) printf_cls::@return
(byte*) printf_cursor_ptr loadstore zp[2]:12 132077.54716981133
(byte) printf_cursor_x loadstore zp[1]:10 115386.71153846156
(byte) printf_cursor_y loadstore zp[1]:11 129631.66666666666
(byte) printf_format_number::justify_left
(byte) printf_format_number::min_length
(byte) printf_format_number::radix
@ -78,10 +81,9 @@
(byte) printf_format_number::zero_padding
(byte) printf_format_string::justify_left
(byte) printf_format_string::min_length
(byte*) printf_line_cursor loadstore zp[2]:8 6863641.113636365
(void()) printf_ln()
(label) printf_ln::@1
(label) printf_ln::@2
(byte*~) printf_ln::$0 zp[2]:12 2000002.0
(byte*~) printf_ln::$1 zp[2]:12 2000002.0
(label) printf_ln::@return
(void()) printf_number_buffer((byte) printf_number_buffer::buffer_sign , (byte*) printf_number_buffer::buffer_digits , (byte) printf_number_buffer::format_min_length , (byte) printf_number_buffer::format_justify_left , (byte) printf_number_buffer::format_sign_always , (byte) printf_number_buffer::format_zero_padding , (byte) printf_number_buffer::format_radix)
(label) printf_number_buffer::@1
@ -101,7 +103,6 @@
(byte) printf_number_buffer::format_zero_padding
(signed byte) printf_number_buffer::len
(signed byte) printf_number_buffer::padding
(const byte*) printf_screen = (byte*) 1024
(void()) printf_str((byte*) printf_str::str)
(label) printf_str::@1
(label) printf_str::@2
@ -112,9 +113,9 @@
(byte) printf_str::ch
(byte) printf_str::ch#0 reg byte a 100001.0
(byte*) printf_str::str
(byte*) printf_str::str#0 str zp[2]:6 42857.57142857143
(byte*) printf_str::str#4 str zp[2]:6 205002.5
(byte*) printf_str::str#6 str zp[2]:6 10001.0
(byte*) printf_str::str#0 str zp[2]:8 42857.57142857143
(byte*) printf_str::str#4 str zp[2]:8 205002.5
(byte*) printf_str::str#6 str zp[2]:8 10001.0
(void()) printf_uchar((byte) printf_uchar::uvalue , (byte) printf_uchar::format_min_length , (byte) printf_uchar::format_justify_left , (byte) printf_uchar::format_sign_always , (byte) printf_uchar::format_zero_padding , (byte) printf_uchar::format_radix)
(label) printf_uchar::@1
(label) printf_uchar::@2
@ -136,22 +137,22 @@
(label) uctoa::@7
(label) uctoa::@return
(byte*) uctoa::buffer
(byte*) uctoa::buffer#11 buffer zp[2]:6 3500.4999999999995
(byte*) uctoa::buffer#14 buffer zp[2]:6 15001.5
(byte*) uctoa::buffer#3 buffer zp[2]:6 2002.0
(byte*) uctoa::buffer#4 buffer zp[2]:6 20002.0
(byte*) uctoa::buffer#11 buffer zp[2]:8 3500.4999999999995
(byte*) uctoa::buffer#14 buffer zp[2]:8 15001.5
(byte*) uctoa::buffer#3 buffer zp[2]:8 2002.0
(byte*) uctoa::buffer#4 buffer zp[2]:8 20002.0
(byte) uctoa::digit
(byte) uctoa::digit#1 digit zp[1]:4 20002.0
(byte) uctoa::digit#2 digit zp[1]:4 3077.230769230769
(byte) uctoa::digit#1 digit zp[1]:6 20002.0
(byte) uctoa::digit#2 digit zp[1]:6 3077.230769230769
(byte) uctoa::digit_value
(byte) uctoa::digit_value#0 digit_value zp[1]:12 6000.6
(byte) uctoa::digit_value#0 digit_value zp[1]:14 6000.6
(byte*) uctoa::digit_values
(byte) uctoa::max_digits
(const byte) uctoa::max_digits#1 max_digits = (byte) 3
(byte) uctoa::radix
(byte) uctoa::started
(byte) uctoa::started#2 started zp[1]:5 6000.6
(byte) uctoa::started#4 started zp[1]:5 10001.0
(byte) uctoa::started#2 started zp[1]:7 6000.6
(byte) uctoa::started#4 started zp[1]:7 10001.0
(byte) uctoa::value
(byte) uctoa::value#0 reg byte x 10001.0
(byte) uctoa::value#2 reg byte x 6834.166666666666
@ -162,14 +163,14 @@
(label) uctoa_append::@3
(label) uctoa_append::@return
(byte*) uctoa_append::buffer
(byte*) uctoa_append::buffer#0 buffer zp[2]:6 13750.25
(byte*) uctoa_append::buffer#0 buffer zp[2]:8 13750.25
(byte) uctoa_append::digit
(byte) uctoa_append::digit#1 reg byte y 1.0000001E7
(byte) uctoa_append::digit#2 reg byte y 1.00500015E7
(byte) uctoa_append::return
(byte) uctoa_append::return#0 reg byte x 20002.0
(byte) uctoa_append::sub
(byte) uctoa_append::sub#0 sub zp[1]:12 3335000.5
(byte) uctoa_append::sub#0 sub zp[1]:14 3335000.5
(byte) uctoa_append::value
(byte) uctoa_append::value#0 reg byte x 36667.33333333333
(byte) uctoa_append::value#1 reg byte x 2.0000002E7
@ -177,17 +178,19 @@
reg byte a [ printf_char::ch#3 printf_char::ch#2 printf_char::ch#1 ]
reg byte x [ memset::c#4 ]
zp[2]:2 [ memcpy::dst#2 memcpy::dst#1 memset::str#3 memset::dst#2 memset::dst#4 memset::dst#1 ]
zp[1]:4 [ uctoa::digit#2 uctoa::digit#1 ]
zp[2]:2 [ memcpy::src#2 memcpy::src#1 memset::num#2 memset::end#0 ]
zp[2]:4 [ memcpy::dst#2 memcpy::dst#1 memset::str#3 memset::dst#2 memset::dst#4 memset::dst#1 ]
zp[1]:6 [ uctoa::digit#2 uctoa::digit#1 ]
reg byte x [ uctoa::value#2 uctoa::value#6 uctoa::value#0 ]
zp[1]:5 [ uctoa::started#2 uctoa::started#4 ]
zp[2]:6 [ uctoa::buffer#11 uctoa::buffer#14 uctoa::buffer#4 uctoa::buffer#3 uctoa_append::buffer#0 printf_str::str#4 printf_str::str#6 printf_str::str#0 ]
zp[1]:7 [ uctoa::started#2 uctoa::started#4 ]
zp[2]:8 [ uctoa::buffer#11 uctoa::buffer#14 uctoa::buffer#4 uctoa::buffer#3 uctoa_append::buffer#0 printf_str::str#4 printf_str::str#6 printf_str::str#0 ]
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]:8 [ printf_line_cursor memcpy::src#2 memcpy::src#1 memset::num#2 memset::end#0 ]
zp[2]:10 [ printf_char_cursor printf_char::$8 ]
zp[1]:10 [ printf_cursor_x ]
zp[1]:11 [ printf_cursor_y ]
zp[2]:12 [ printf_cursor_ptr printf_char::$6 printf_ln::$0 printf_ln::$1 ]
reg byte a [ printf_str::ch#0 ]
reg byte a [ printf_number_buffer::buffer_sign#0 ]
zp[1]:12 [ uctoa::digit_value#0 uctoa_append::sub#0 ]
zp[1]:14 [ uctoa::digit_value#0 uctoa_append::sub#0 ]
reg byte x [ uctoa_append::return#0 ]
mem[12] [ printf_buffer ]

273
src/test/ref/printf-15.asm Normal file
View File

@ -0,0 +1,273 @@
// Tests printf function call rewriting
// A few strings with newlines
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
.label printf_cursor_x = 8
.label printf_cursor_y = 9
.label printf_cursor_ptr = $a
__bbegin:
// printf_cursor_x = 0
// X-position of cursor
lda #0
sta.z printf_cursor_x
// printf_cursor_y = 0
// Y-position of cursor
sta.z printf_cursor_y
// printf_cursor_ptr = PRINTF_SCREEN_ADDRESS
// Pointer to cursor address
lda #<$400
sta.z printf_cursor_ptr
lda #>$400
sta.z printf_cursor_ptr+1
jsr main
rts
main: {
// printf_cls()
jsr printf_cls
// printf("Lone 1\n")
lda #<str
sta.z printf_str.str
lda #>str
sta.z printf_str.str+1
jsr printf_str
// printf("Lone 2\n")
lda #<str1
sta.z printf_str.str
lda #>str1
sta.z printf_str.str+1
jsr printf_str
// }
rts
str: .text @"Lone 1\n"
.byte 0
str1: .text @"Lone 2\n"
.byte 0
}
// Print a zero-terminated string
// Handles escape codes such as newline
// printf_str(byte* zp(2) str)
printf_str: {
.label str = 2
__b2:
// ch = *str++
ldy #0
lda (str),y
inc.z str
bne !+
inc.z str+1
!:
// if(ch==0)
cmp #0
bne __b3
// }
rts
__b3:
// if(ch=='\n')
cmp #'\n'
beq __b4
// printf_char(ch)
jsr printf_char
jmp __b2
__b4:
// printf_ln()
jsr printf_ln
jmp __b2
}
// Print a newline
printf_ln: {
.label __0 = $a
.label __1 = $a
// printf_cursor_ptr - printf_cursor_x
sec
lda.z __0
sbc.z printf_cursor_x
sta.z __0
bcs !+
dec.z __0+1
!:
// printf_cursor_ptr - printf_cursor_x + PRINTF_SCREEN_WIDTH
lda #$28
clc
adc.z __1
sta.z __1
bcc !+
inc.z __1+1
!:
// printf_cursor_ptr = printf_cursor_ptr - printf_cursor_x + PRINTF_SCREEN_WIDTH
// printf_cursor_x = 0
lda #0
sta.z printf_cursor_x
// printf_cursor_y++;
inc.z printf_cursor_y
// }
rts
}
// Print a single char
// If the end of the screen is reached scroll it up one char and place the cursor at the
// printf_char(byte register(A) ch)
printf_char: {
.label __6 = $a
// *(printf_cursor_ptr++) = ch
ldy #0
sta (printf_cursor_ptr),y
// *(printf_cursor_ptr++) = ch;
inc.z printf_cursor_ptr
bne !+
inc.z printf_cursor_ptr+1
!:
// if(++printf_cursor_x==PRINTF_SCREEN_WIDTH)
inc.z printf_cursor_x
lda #$28
cmp.z printf_cursor_x
bne __breturn
// printf_cursor_x = 0
lda #0
sta.z printf_cursor_x
// ++printf_cursor_y;
inc.z printf_cursor_y
// if(printf_cursor_y==PRINTF_SCREEN_HEIGHT)
lda #$19
cmp.z printf_cursor_y
bne __breturn
// memcpy(PRINTF_SCREEN_ADDRESS, PRINTF_SCREEN_ADDRESS+PRINTF_SCREEN_WIDTH, PRINTF_SCREEN_BYTES-PRINTF_SCREEN_WIDTH)
jsr memcpy
// memset(PRINTF_SCREEN_ADDRESS+PRINTF_SCREEN_BYTES-PRINTF_SCREEN_WIDTH, ' ', PRINTF_SCREEN_WIDTH)
ldx #' '
lda #<$400+$28*$19-$28
sta.z memset.str
lda #>$400+$28*$19-$28
sta.z memset.str+1
lda #<$28
sta.z memset.num
lda #>$28
sta.z memset.num+1
jsr memset
// printf_cursor_ptr-PRINTF_SCREEN_WIDTH
lda.z __6
sec
sbc #<$28
sta.z __6
lda.z __6+1
sbc #>$28
sta.z __6+1
// printf_cursor_ptr = printf_cursor_ptr-PRINTF_SCREEN_WIDTH
// printf_cursor_y--;
dec.z printf_cursor_y
__breturn:
// }
rts
}
// Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
// memset(void* zp(6) str, byte register(X) c, word zp(4) num)
memset: {
.label end = 4
.label dst = 6
.label num = 4
.label str = 6
// if(num>0)
lda.z num
bne !+
lda.z num+1
beq __breturn
!:
// end = (char*)str + num
lda.z end
clc
adc.z str
sta.z end
lda.z end+1
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
__breturn:
// }
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
}
// 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.
memcpy: {
.label destination = $400
.label source = $400+$28
.const num = $28*$19-$28
.label src_end = source+num
.label dst = 6
.label src = 4
lda #<destination
sta.z dst
lda #>destination
sta.z dst+1
lda #<source
sta.z src
lda #>source
sta.z src+1
__b1:
// while(src!=src_end)
lda.z src+1
cmp #>src_end
bne __b2
lda.z src
cmp #<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
}
// Clear the screen. Also resets current line/char cursor.
printf_cls: {
// memset(PRINTF_SCREEN_ADDRESS, ' ', PRINTF_SCREEN_BYTES)
ldx #' '
lda #<$400
sta.z memset.str
lda #>$400
sta.z memset.str+1
lda #<$28*$19
sta.z memset.num
lda #>$28*$19
sta.z memset.num+1
jsr memset
// printf_cursor_ptr = PRINTF_SCREEN_ADDRESS
lda #<$400
sta.z printf_cursor_ptr
lda #>$400
sta.z printf_cursor_ptr+1
// printf_cursor_x = 0
lda #0
sta.z printf_cursor_x
// printf_cursor_y = 0
sta.z printf_cursor_y
// }
rts
}

155
src/test/ref/printf-15.cfg Normal file
View File

@ -0,0 +1,155 @@
@begin: scope:[] from
[0] phi()
to:@1
@1: scope:[] from @begin
[1] (byte) printf_cursor_x ← (byte) 0
[2] (byte) printf_cursor_y ← (byte) 0
[3] (byte*) printf_cursor_ptr ← (byte*) 1024
to:@2
@2: scope:[] from @1
[4] phi()
[5] call main
to:@end
@end: scope:[] from @2
[6] phi()
(void()) main()
main: scope:[main] from @2
[7] phi()
[8] call printf_cls
to:main::@1
main::@1: scope:[main] from main
[9] phi()
[10] call printf_str
to:main::@2
main::@2: scope:[main] from main::@1
[11] phi()
[12] call printf_str
to:main::@return
main::@return: scope:[main] from main::@2
[13] return
to:@return
(void()) printf_str((byte*) printf_str::str)
printf_str: scope:[printf_str] from main::@1 main::@2
[14] (byte*) printf_str::str#5 ← phi( main::@1/(const byte*) main::str main::@2/(const byte*) main::str1 )
to:printf_str::@1
printf_str::@1: scope:[printf_str] from printf_str printf_str::@4 printf_str::@5
[15] (byte*) printf_str::str#3 ← phi( printf_str/(byte*) printf_str::str#5 printf_str::@4/(byte*) printf_str::str#0 printf_str::@5/(byte*) printf_str::str#0 )
to:printf_str::@2
printf_str::@2: scope:[printf_str] from printf_str::@1
[16] (byte) printf_str::ch#0 ← *((byte*) printf_str::str#3)
[17] (byte*) printf_str::str#0 ← ++ (byte*) printf_str::str#3
[18] if((byte) printf_str::ch#0!=(byte) 0) goto printf_str::@3
to:printf_str::@return
printf_str::@return: scope:[printf_str] from printf_str::@2
[19] return
to:@return
printf_str::@3: scope:[printf_str] from printf_str::@2
[20] if((byte) printf_str::ch#0==(byte) '
') goto printf_str::@4
to:printf_str::@5
printf_str::@5: scope:[printf_str] from printf_str::@3
[21] (byte) printf_char::ch#0 ← (byte) printf_str::ch#0
[22] call printf_char
to:printf_str::@1
printf_str::@4: scope:[printf_str] from printf_str::@3
[23] phi()
[24] call printf_ln
to:printf_str::@1
(void()) printf_ln()
printf_ln: scope:[printf_ln] from printf_str::@4
[25] (byte*~) printf_ln::$0 ← (byte*) printf_cursor_ptr - (byte) printf_cursor_x
[26] (byte*~) printf_ln::$1 ← (byte*~) printf_ln::$0 + (byte) $28
[27] (byte*) printf_cursor_ptr ← (byte*~) printf_ln::$1
[28] (byte) printf_cursor_x ← (byte) 0
[29] (byte) printf_cursor_y ← ++ (byte) printf_cursor_y
to:printf_ln::@return
printf_ln::@return: scope:[printf_ln] from printf_ln
[30] return
to:@return
(void()) printf_char((byte) printf_char::ch)
printf_char: scope:[printf_char] from printf_str::@5
[31] *((byte*) printf_cursor_ptr) ← (byte) printf_char::ch#0
[32] (byte*) printf_cursor_ptr ← ++ (byte*) printf_cursor_ptr
[33] (byte) printf_cursor_x ← ++ (byte) printf_cursor_x
[34] if((byte) printf_cursor_x!=(byte) $28) goto printf_char::@return
to:printf_char::@1
printf_char::@1: scope:[printf_char] from printf_char
[35] (byte) printf_cursor_x ← (byte) 0
[36] (byte) printf_cursor_y ← ++ (byte) printf_cursor_y
[37] if((byte) printf_cursor_y!=(byte) $19) goto printf_char::@return
to:printf_char::@2
printf_char::@2: scope:[printf_char] from printf_char::@1
[38] phi()
[39] call memcpy
to:printf_char::@3
printf_char::@3: scope:[printf_char] from printf_char::@2
[40] phi()
[41] call memset
to:printf_char::@4
printf_char::@4: scope:[printf_char] from printf_char::@3
[42] (byte*~) printf_char::$6 ← (byte*) printf_cursor_ptr - (byte) $28
[43] (byte*) printf_cursor_ptr ← (byte*~) printf_char::$6
[44] (byte) printf_cursor_y ← -- (byte) printf_cursor_y
to:printf_char::@return
printf_char::@return: scope:[printf_char] from printf_char printf_char::@1 printf_char::@4
[45] return
to:@return
(void*()) memset((void*) memset::str , (byte) memset::c , (word) memset::num)
memset: scope:[memset] from printf_char::@3 printf_cls
[46] (byte) memset::c#4 ← phi( printf_char::@3/(byte) ' ' printf_cls/(byte) ' ' )
[46] (void*) memset::str#3 ← phi( printf_char::@3/(void*)(number) $400+(number) $28*(number) $19-(number) $28 printf_cls/(void*) 1024 )
[46] (word) memset::num#2 ← phi( printf_char::@3/(byte) $28 printf_cls/(word)(number) $28*(number) $19 )
[47] if((word) memset::num#2<=(byte) 0) goto memset::@return
to:memset::@1
memset::@1: scope:[memset] from memset
[48] (byte*) memset::end#0 ← (byte*)(void*) memset::str#3 + (word) memset::num#2
[49] (byte*) memset::dst#4 ← (byte*)(void*) memset::str#3
to:memset::@2
memset::@2: scope:[memset] from memset::@1 memset::@3
[50] (byte*) memset::dst#2 ← phi( memset::@1/(byte*) memset::dst#4 memset::@3/(byte*) memset::dst#1 )
[51] if((byte*) memset::dst#2!=(byte*) memset::end#0) goto memset::@3
to:memset::@return
memset::@return: scope:[memset] from memset memset::@2
[52] return
to:@return
memset::@3: scope:[memset] from memset::@2
[53] *((byte*) memset::dst#2) ← (byte) memset::c#4
[54] (byte*) memset::dst#1 ← ++ (byte*) memset::dst#2
to:memset::@2
(void*()) memcpy((void*) memcpy::destination , (void*) memcpy::source , (word) memcpy::num)
memcpy: scope:[memcpy] from printf_char::@2
[55] phi()
to:memcpy::@1
memcpy::@1: scope:[memcpy] from memcpy memcpy::@2
[56] (byte*) memcpy::dst#2 ← phi( memcpy/(byte*)(const void*) memcpy::destination#0 memcpy::@2/(byte*) memcpy::dst#1 )
[56] (byte*) memcpy::src#2 ← phi( memcpy/(byte*)(const void*) memcpy::source#0 memcpy::@2/(byte*) memcpy::src#1 )
[57] if((byte*) memcpy::src#2!=(const byte*) memcpy::src_end#0) goto memcpy::@2
to:memcpy::@return
memcpy::@return: scope:[memcpy] from memcpy::@1
[58] return
to:@return
memcpy::@2: scope:[memcpy] from memcpy::@1
[59] *((byte*) memcpy::dst#2) ← *((byte*) memcpy::src#2)
[60] (byte*) memcpy::dst#1 ← ++ (byte*) memcpy::dst#2
[61] (byte*) memcpy::src#1 ← ++ (byte*) memcpy::src#2
to:memcpy::@1
(void()) printf_cls()
printf_cls: scope:[printf_cls] from main
[62] phi()
[63] call memset
to:printf_cls::@1
printf_cls::@1: scope:[printf_cls] from printf_cls
[64] (byte*) printf_cursor_ptr ← (byte*) 1024
[65] (byte) printf_cursor_x ← (byte) 0
[66] (byte) printf_cursor_y ← (byte) 0
to:printf_cls::@return
printf_cls::@return: scope:[printf_cls] from printf_cls::@1
[67] return
to:@return

2628
src/test/ref/printf-15.log Normal file

File diff suppressed because it is too large Load Diff

104
src/test/ref/printf-15.sym Normal file
View File

@ -0,0 +1,104 @@
(label) @1
(label) @2
(label) @begin
(label) @end
(const byte) RADIX::BINARY = (number) 2
(const byte) RADIX::DECIMAL = (number) $a
(const byte) RADIX::HEXADECIMAL = (number) $10
(const byte) RADIX::OCTAL = (number) 8
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@return
(const byte*) main::str[(byte) 8] = (byte*) "Lone 1
"
(const byte*) main::str1[(byte) 8] = (byte*) "Lone 2
"
(void*()) memcpy((void*) memcpy::destination , (void*) memcpy::source , (word) memcpy::num)
(label) memcpy::@1
(label) memcpy::@2
(label) memcpy::@return
(void*) memcpy::destination
(const void*) memcpy::destination#0 destination = (void*) 1024
(byte*) memcpy::dst
(byte*) memcpy::dst#1 dst zp[2]:6 1.0000001E7
(byte*) memcpy::dst#2 dst zp[2]:6 1.0000001E7
(word) memcpy::num
(const word) memcpy::num#0 num = (word)(number) $28*(number) $19-(number) $28
(void*) memcpy::return
(void*) memcpy::source
(const void*) memcpy::source#0 source = (void*)(number) $400+(number) $28
(byte*) memcpy::src
(byte*) memcpy::src#1 src zp[2]:4 2.0000002E7
(byte*) memcpy::src#2 src zp[2]:4 1.0000001E7
(byte*) memcpy::src_end
(const byte*) memcpy::src_end#0 src_end = (byte*)(const void*) memcpy::source#0+(const word) memcpy::num#0
(void*()) memset((void*) memset::str , (byte) memset::c , (word) memset::num)
(label) memset::@1
(label) memset::@2
(label) memset::@3
(label) memset::@return
(byte) memset::c
(byte) memset::c#4 reg byte x 1250000.125
(byte*) memset::dst
(byte*) memset::dst#1 dst zp[2]:6 2.0000002E7
(byte*) memset::dst#2 dst zp[2]:6 1.3366668333333332E7
(byte*) memset::dst#4 dst zp[2]:6 200002.0
(byte*) memset::end
(byte*) memset::end#0 end zp[2]:4 1683333.6666666665
(word) memset::num
(word) memset::num#2 num zp[2]:4 100001.0
(void*) memset::return
(void*) memset::str
(void*) memset::str#3 str zp[2]:6
(const byte*) printf_buffer_number::digits[(number) $b] = { fill( $b, 0) }
(byte) printf_buffer_number::sign
(void()) printf_char((byte) printf_char::ch)
(byte*~) printf_char::$6 zp[2]:10 20002.0
(label) printf_char::@1
(label) printf_char::@2
(label) printf_char::@3
(label) printf_char::@4
(label) printf_char::@return
(byte) printf_char::ch
(byte) printf_char::ch#0 reg byte a 11002.0
(void()) printf_cls()
(label) printf_cls::@1
(label) printf_cls::@return
(byte*) printf_cursor_ptr loadstore zp[2]:10 1894.864864864865
(byte) printf_cursor_x loadstore zp[1]:8 1669.6944444444448
(byte) printf_cursor_y loadstore zp[1]:9 1845.0000000000002
(byte) printf_format_number::justify_left
(byte) printf_format_number::min_length
(byte) printf_format_number::radix
(byte) printf_format_number::sign_always
(byte) printf_format_number::zero_padding
(byte) printf_format_string::justify_left
(byte) printf_format_string::min_length
(void()) printf_ln()
(byte*~) printf_ln::$0 zp[2]:10 20002.0
(byte*~) printf_ln::$1 zp[2]:10 20002.0
(label) printf_ln::@return
(void()) printf_str((byte*) printf_str::str)
(label) printf_str::@1
(label) printf_str::@2
(label) printf_str::@3
(label) printf_str::@4
(label) printf_str::@5
(label) printf_str::@return
(byte) printf_str::ch
(byte) printf_str::ch#0 reg byte a 1001.0
(byte*) printf_str::str
(byte*) printf_str::str#0 str zp[2]:2 429.0
(byte*) printf_str::str#3 str zp[2]:2 2052.5
(byte*) printf_str::str#5 str zp[2]:2 101.0
zp[2]:2 [ printf_str::str#3 printf_str::str#5 printf_str::str#0 ]
reg byte x [ memset::c#4 ]
zp[2]:4 [ memcpy::src#2 memcpy::src#1 memset::num#2 memset::end#0 ]
zp[2]:6 [ memcpy::dst#2 memcpy::dst#1 memset::str#3 memset::dst#2 memset::dst#4 memset::dst#1 ]
zp[1]:8 [ printf_cursor_x ]
zp[1]:9 [ printf_cursor_y ]
zp[2]:10 [ printf_cursor_ptr printf_char::$6 printf_ln::$0 printf_ln::$1 ]
reg byte a [ printf_str::ch#0 ]
reg byte a [ printf_char::ch#0 ]

View File

@ -8,21 +8,24 @@
.const DECIMAL = $a
.const HEXADECIMAL = $10
.const OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS = 1
.label printf_screen = $400
.const SIZEOF_STRUCT_PRINTF_BUFFER_NUMBER = $c
.label printf_line_cursor = $e
.label printf_char_cursor = $10
.label printf_cursor_x = $e
.label printf_cursor_y = $f
.label printf_cursor_ptr = $10
__bbegin:
// printf_line_cursor = PRINTF_SCREEN_ADDRESS
// printf_cursor_x = 0
// X-position of cursor
lda #0
sta.z printf_cursor_x
// printf_cursor_y = 0
// Y-position of cursor
sta.z printf_cursor_y
// printf_cursor_ptr = PRINTF_SCREEN_ADDRESS
// Pointer to cursor address
lda #<$400
sta.z printf_line_cursor
sta.z printf_cursor_ptr
lda #>$400
sta.z printf_line_cursor+1
// printf_char_cursor = PRINTF_SCREEN_ADDRESS
lda #<$400
sta.z printf_char_cursor
lda #>$400
sta.z printf_char_cursor+1
sta.z printf_cursor_ptr+1
jsr main
rts
main: {
@ -57,29 +60,30 @@ main: {
}
// Print a newline
printf_ln: {
__b1:
// printf_line_cursor += PRINTF_SCREEN_WIDTH
.label __0 = $10
.label __1 = $10
// printf_cursor_ptr - printf_cursor_x
sec
lda.z __0
sbc.z printf_cursor_x
sta.z __0
bcs !+
dec.z __0+1
!:
// printf_cursor_ptr - printf_cursor_x + PRINTF_SCREEN_WIDTH
lda #$28
clc
adc.z printf_line_cursor
sta.z printf_line_cursor
adc.z __1
sta.z __1
bcc !+
inc.z printf_line_cursor+1
inc.z __1+1
!:
// while (printf_line_cursor<printf_char_cursor)
lda.z printf_line_cursor+1
cmp.z printf_char_cursor+1
bcc __b1
bne !+
lda.z printf_line_cursor
cmp.z printf_char_cursor
bcc __b1
!:
// printf_char_cursor = printf_line_cursor
lda.z printf_line_cursor
sta.z printf_char_cursor
lda.z printf_line_cursor+1
sta.z printf_char_cursor+1
// printf_cursor_ptr = printf_cursor_ptr - printf_cursor_x + PRINTF_SCREEN_WIDTH
// printf_cursor_x = 0
lda #0
sta.z printf_cursor_x
// printf_cursor_y++;
inc.z printf_cursor_y
// }
rts
}
@ -246,51 +250,53 @@ printf_padding: {
// If the end of the screen is reached scroll it up one char and place the cursor at the
// printf_char(byte register(A) ch)
printf_char: {
.label __8 = $10
// *(printf_char_cursor++) = ch
.label __6 = $10
// *(printf_cursor_ptr++) = ch
ldy #0
sta (printf_char_cursor),y
// *(printf_char_cursor++) = ch;
inc.z printf_char_cursor
sta (printf_cursor_ptr),y
// *(printf_cursor_ptr++) = ch;
inc.z printf_cursor_ptr
bne !+
inc.z printf_char_cursor+1
inc.z printf_cursor_ptr+1
!:
// if(printf_char_cursor>=(printf_screen+PRINTF_SCREEN_BYTES))
lda.z printf_char_cursor+1
cmp #>printf_screen+$28*$19
bcc __breturn
bne !+
lda.z printf_char_cursor
cmp #<printf_screen+$28*$19
bcc __breturn
!:
// memcpy(printf_screen, printf_screen+PRINTF_SCREEN_WIDTH, PRINTF_SCREEN_BYTES-PRINTF_SCREEN_WIDTH)
// if(++printf_cursor_x==PRINTF_SCREEN_WIDTH)
inc.z printf_cursor_x
lda #$28
cmp.z printf_cursor_x
bne __breturn
// printf_cursor_x = 0
lda #0
sta.z printf_cursor_x
// ++printf_cursor_y;
inc.z printf_cursor_y
// if(printf_cursor_y==PRINTF_SCREEN_HEIGHT)
lda #$19
cmp.z printf_cursor_y
bne __breturn
// memcpy(PRINTF_SCREEN_ADDRESS, PRINTF_SCREEN_ADDRESS+PRINTF_SCREEN_WIDTH, PRINTF_SCREEN_BYTES-PRINTF_SCREEN_WIDTH)
jsr memcpy
// memset(printf_screen+PRINTF_SCREEN_BYTES-PRINTF_SCREEN_WIDTH, ' ', PRINTF_SCREEN_WIDTH)
// memset(PRINTF_SCREEN_ADDRESS+PRINTF_SCREEN_BYTES-PRINTF_SCREEN_WIDTH, ' ', PRINTF_SCREEN_WIDTH)
ldx #' '
lda #<printf_screen+$28*$19-$28
lda #<$400+$28*$19-$28
sta.z memset.str
lda #>printf_screen+$28*$19-$28
lda #>$400+$28*$19-$28
sta.z memset.str+1
lda #<$28
sta.z memset.num
lda #>$28
sta.z memset.num+1
jsr memset
// printf_char_cursor-PRINTF_SCREEN_WIDTH
lda.z __8
// printf_cursor_ptr-PRINTF_SCREEN_WIDTH
lda.z __6
sec
sbc #<$28
sta.z __8
lda.z __8+1
sta.z __6
lda.z __6+1
sbc #>$28
sta.z __8+1
// printf_char_cursor = printf_char_cursor-PRINTF_SCREEN_WIDTH
// printf_line_cursor = printf_char_cursor
lda.z printf_char_cursor
sta.z printf_line_cursor
lda.z printf_char_cursor+1
sta.z printf_line_cursor+1
sta.z __6+1
// printf_cursor_ptr = printf_cursor_ptr-PRINTF_SCREEN_WIDTH
// printf_cursor_y--;
dec.z printf_cursor_y
__breturn:
// }
rts
@ -342,9 +348,9 @@ memset: {
// 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.
memcpy: {
.label destination = printf_screen
.label destination = $400
.label source = $400+$28
.const num = $28*$19-$28
.label source = printf_screen+$28
.label src_end = source+num
.label dst = $a
.label src = 6
@ -781,27 +787,27 @@ uctoa_append: {
}
// Clear the screen. Also resets current line/char cursor.
printf_cls: {
// memset(printf_screen, ' ', PRINTF_SCREEN_BYTES)
// memset(PRINTF_SCREEN_ADDRESS, ' ', PRINTF_SCREEN_BYTES)
ldx #' '
lda #<printf_screen
lda #<$400
sta.z memset.str
lda #>printf_screen
lda #>$400
sta.z memset.str+1
lda #<$28*$19
sta.z memset.num
lda #>$28*$19
sta.z memset.num+1
jsr memset
// printf_line_cursor = printf_screen
lda #<printf_screen
sta.z printf_line_cursor
lda #>printf_screen
sta.z printf_line_cursor+1
// printf_char_cursor = printf_line_cursor
lda.z printf_line_cursor
sta.z printf_char_cursor
lda.z printf_line_cursor+1
sta.z printf_char_cursor+1
// printf_cursor_ptr = PRINTF_SCREEN_ADDRESS
lda #<$400
sta.z printf_cursor_ptr
lda #>$400
sta.z printf_cursor_ptr+1
// printf_cursor_x = 0
lda #0
sta.z printf_cursor_x
// printf_cursor_y = 0
sta.z printf_cursor_y
// }
rts
}

View File

@ -2,485 +2,490 @@
[0] phi()
to:@1
@1: scope:[] from @begin
[1] (byte*) printf_line_cursor ← (byte*) 1024
[2] (byte*) printf_char_cursor ← (byte*) 1024
[1] (byte) printf_cursor_x ← (byte) 0
[2] (byte) printf_cursor_y ← (byte) 0
[3] (byte*) printf_cursor_ptr ← (byte*) 1024
to:@2
@2: scope:[] from @1
[3] phi()
[4] call main
[4] phi()
[5] call main
to:@end
@end: scope:[] from @2
[5] phi()
[6] phi()
(void()) main()
main: scope:[main] from @2
[6] phi()
[7] call printf_cls
[7] phi()
[8] call printf_cls
to:main::@1
main::@1: scope:[main] from main
[8] phi()
[9] call printf_schar
[9] phi()
[10] call printf_schar
to:main::@2
main::@2: scope:[main] from main::@1
[10] phi()
[11] call printf_ln
[11] phi()
[12] call printf_ln
to:main::@3
main::@3: scope:[main] from main::@2
[12] phi()
[13] call printf_schar
[13] phi()
[14] call printf_schar
to:main::@4
main::@4: scope:[main] from main::@3
[14] phi()
[15] call printf_ln
[15] phi()
[16] call printf_ln
to:main::@5
main::@5: scope:[main] from main::@4
[16] phi()
[17] call printf_uint
[17] phi()
[18] call printf_uint
to:main::@6
main::@6: scope:[main] from main::@5
[18] phi()
[19] call printf_ln
[19] phi()
[20] call printf_ln
to:main::@return
main::@return: scope:[main] from main::@6
[20] return
[21] return
to:@return
(void()) printf_ln()
printf_ln: scope:[printf_ln] from main::@2 main::@4 main::@6 printf_str::@4
[21] phi()
to:printf_ln::@1
printf_ln::@1: scope:[printf_ln] from printf_ln printf_ln::@1
[22] (byte*) printf_line_cursor ← (byte*) printf_line_cursor + (byte) $28
[23] if((byte*) printf_line_cursor<(byte*) printf_char_cursor) goto printf_ln::@1
to:printf_ln::@2
printf_ln::@2: scope:[printf_ln] from printf_ln::@1
[24] (byte*) printf_char_cursor ← (byte*) printf_line_cursor
[22] (byte*~) printf_ln::$0 ← (byte*) printf_cursor_ptr - (byte) printf_cursor_x
[23] (byte*~) printf_ln::$1 ← (byte*~) printf_ln::$0 + (byte) $28
[24] (byte*) printf_cursor_ptr ← (byte*~) printf_ln::$1
[25] (byte) printf_cursor_x ← (byte) 0
[26] (byte) printf_cursor_y ← ++ (byte) printf_cursor_y
to:printf_ln::@return
printf_ln::@return: scope:[printf_ln] from printf_ln::@2
[25] return
printf_ln::@return: scope:[printf_ln] from printf_ln
[27] return
to:@return
(void()) printf_uint((word) printf_uint::uvalue , (byte) printf_uint::format_min_length , (byte) printf_uint::format_justify_left , (byte) printf_uint::format_sign_always , (byte) printf_uint::format_zero_padding , (byte) printf_uint::format_radix)
printf_uint: scope:[printf_uint] from main::@5
[26] phi()
[28] phi()
to:printf_uint::@1
printf_uint::@1: scope:[printf_uint] from printf_uint
[27] *((byte*)&(struct printf_buffer_number) printf_buffer) ← (byte) 0
[28] call utoa
[29] *((byte*)&(struct printf_buffer_number) printf_buffer) ← (byte) 0
[30] call utoa
to:printf_uint::@2
printf_uint::@2: scope:[printf_uint] from printf_uint::@1
[29] (byte) printf_number_buffer::buffer_sign#0 ← *((byte*)&(struct printf_buffer_number) printf_buffer)
[30] call printf_number_buffer
[31] (byte) printf_number_buffer::buffer_sign#0 ← *((byte*)&(struct printf_buffer_number) printf_buffer)
[32] call printf_number_buffer
to:printf_uint::@return
printf_uint::@return: scope:[printf_uint] from printf_uint::@2
[31] return
[33] return
to:@return
(void()) printf_number_buffer((byte) printf_number_buffer::buffer_sign , (byte*) printf_number_buffer::buffer_digits , (byte) printf_number_buffer::format_min_length , (byte) printf_number_buffer::format_justify_left , (byte) printf_number_buffer::format_sign_always , (byte) printf_number_buffer::format_zero_padding , (byte) printf_number_buffer::format_radix)
printf_number_buffer: scope:[printf_number_buffer] from printf_schar::@5 printf_uint::@2
[32] (byte) printf_number_buffer::buffer_sign#10 ← phi( printf_schar::@5/(byte) printf_number_buffer::buffer_sign#1 printf_uint::@2/(byte) printf_number_buffer::buffer_sign#0 )
[32] (byte*) printf_number_buffer::buffer_digits#10 ← phi( printf_schar::@5/(byte*)&(struct printf_buffer_number) printf_buffer+(const byte) OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS printf_uint::@2/(byte*)&(struct printf_buffer_number) printf_buffer+(const byte) OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS )
[32] (byte) printf_number_buffer::format_zero_padding#10 ← phi( printf_schar::@5/(byte) printf_number_buffer::format_zero_padding#1 printf_uint::@2/(const byte) printf_uint::format_zero_padding#0 )
[32] (byte) printf_number_buffer::format_justify_left#10 ← phi( printf_schar::@5/(byte) 0 printf_uint::@2/(const byte) printf_uint::format_justify_left#0 )
[32] (byte) printf_number_buffer::format_min_length#2 ← phi( printf_schar::@5/(byte) 6 printf_uint::@2/(const byte) printf_uint::format_min_length#0 )
[33] if((byte) 0==(byte) printf_number_buffer::format_min_length#2) goto printf_number_buffer::@1
[34] (byte) printf_number_buffer::buffer_sign#10 ← phi( printf_schar::@5/(byte) printf_number_buffer::buffer_sign#1 printf_uint::@2/(byte) printf_number_buffer::buffer_sign#0 )
[34] (byte*) printf_number_buffer::buffer_digits#10 ← phi( printf_schar::@5/(byte*)&(struct printf_buffer_number) printf_buffer+(const byte) OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS printf_uint::@2/(byte*)&(struct printf_buffer_number) printf_buffer+(const byte) OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS )
[34] (byte) printf_number_buffer::format_zero_padding#10 ← phi( printf_schar::@5/(byte) printf_number_buffer::format_zero_padding#1 printf_uint::@2/(const byte) printf_uint::format_zero_padding#0 )
[34] (byte) printf_number_buffer::format_justify_left#10 ← phi( printf_schar::@5/(byte) 0 printf_uint::@2/(const byte) printf_uint::format_justify_left#0 )
[34] (byte) printf_number_buffer::format_min_length#2 ← phi( printf_schar::@5/(byte) 6 printf_uint::@2/(const byte) printf_uint::format_min_length#0 )
[35] if((byte) 0==(byte) printf_number_buffer::format_min_length#2) goto printf_number_buffer::@1
to:printf_number_buffer::@5
printf_number_buffer::@5: scope:[printf_number_buffer] from printf_number_buffer
[34] (byte*) strlen::str#1 ← (byte*) printf_number_buffer::buffer_digits#10
[35] call strlen
[36] (word) strlen::return#2 ← (word) strlen::len#2
[36] (byte*) strlen::str#1 ← (byte*) printf_number_buffer::buffer_digits#10
[37] call strlen
[38] (word) strlen::return#2 ← (word) strlen::len#2
to:printf_number_buffer::@12
printf_number_buffer::@12: scope:[printf_number_buffer] from printf_number_buffer::@5
[37] (word~) printf_number_buffer::$18 ← (word) strlen::return#2
[38] (signed byte) printf_number_buffer::len#0 ← (signed byte)(word~) printf_number_buffer::$18
[39] if((byte) 0==(byte) printf_number_buffer::buffer_sign#10) goto printf_number_buffer::@11
[39] (word~) printf_number_buffer::$18 ← (word) strlen::return#2
[40] (signed byte) printf_number_buffer::len#0 ← (signed byte)(word~) printf_number_buffer::$18
[41] if((byte) 0==(byte) printf_number_buffer::buffer_sign#10) goto printf_number_buffer::@11
to:printf_number_buffer::@6
printf_number_buffer::@6: scope:[printf_number_buffer] from printf_number_buffer::@12
[40] (signed byte) printf_number_buffer::len#1 ← ++ (signed byte) printf_number_buffer::len#0
[42] (signed byte) printf_number_buffer::len#1 ← ++ (signed byte) printf_number_buffer::len#0
to:printf_number_buffer::@11
printf_number_buffer::@11: scope:[printf_number_buffer] from printf_number_buffer::@12 printf_number_buffer::@6
[41] (signed byte) printf_number_buffer::len#2 ← phi( printf_number_buffer::@12/(signed byte) printf_number_buffer::len#0 printf_number_buffer::@6/(signed byte) printf_number_buffer::len#1 )
[42] (signed byte) printf_number_buffer::padding#1 ← (signed byte)(byte) printf_number_buffer::format_min_length#2 - (signed byte) printf_number_buffer::len#2
[43] if((signed byte) printf_number_buffer::padding#1>=(signed byte) 0) goto printf_number_buffer::@19
[43] (signed byte) printf_number_buffer::len#2 ← phi( printf_number_buffer::@12/(signed byte) printf_number_buffer::len#0 printf_number_buffer::@6/(signed byte) printf_number_buffer::len#1 )
[44] (signed byte) printf_number_buffer::padding#1 ← (signed byte)(byte) printf_number_buffer::format_min_length#2 - (signed byte) printf_number_buffer::len#2
[45] if((signed byte) printf_number_buffer::padding#1>=(signed byte) 0) goto printf_number_buffer::@19
to:printf_number_buffer::@1
printf_number_buffer::@19: scope:[printf_number_buffer] from printf_number_buffer::@11
[44] phi()
[46] phi()
to:printf_number_buffer::@1
printf_number_buffer::@1: scope:[printf_number_buffer] from printf_number_buffer printf_number_buffer::@11 printf_number_buffer::@19
[45] (signed byte) printf_number_buffer::padding#10 ← phi( printf_number_buffer/(signed byte) 0 printf_number_buffer::@19/(signed byte) printf_number_buffer::padding#1 printf_number_buffer::@11/(signed byte) 0 )
[46] if((byte) 0!=(byte) printf_number_buffer::format_justify_left#10) goto printf_number_buffer::@2
[47] (signed byte) printf_number_buffer::padding#10 ← phi( printf_number_buffer/(signed byte) 0 printf_number_buffer::@19/(signed byte) printf_number_buffer::padding#1 printf_number_buffer::@11/(signed byte) 0 )
[48] if((byte) 0!=(byte) printf_number_buffer::format_justify_left#10) goto printf_number_buffer::@2
to:printf_number_buffer::@15
printf_number_buffer::@15: scope:[printf_number_buffer] from printf_number_buffer::@1
[47] if((byte) 0!=(byte) printf_number_buffer::format_zero_padding#10) goto printf_number_buffer::@2
[49] if((byte) 0!=(byte) printf_number_buffer::format_zero_padding#10) goto printf_number_buffer::@2
to:printf_number_buffer::@14
printf_number_buffer::@14: scope:[printf_number_buffer] from printf_number_buffer::@15
[48] if((signed byte) 0!=(signed byte) printf_number_buffer::padding#10) goto printf_number_buffer::@7
[50] if((signed byte) 0!=(signed byte) printf_number_buffer::padding#10) goto printf_number_buffer::@7
to:printf_number_buffer::@2
printf_number_buffer::@7: scope:[printf_number_buffer] from printf_number_buffer::@14
[49] (byte) printf_padding::length#0 ← (byte)(signed byte) printf_number_buffer::padding#10
[50] call printf_padding
[51] (byte) printf_padding::length#0 ← (byte)(signed byte) printf_number_buffer::padding#10
[52] call printf_padding
to:printf_number_buffer::@2
printf_number_buffer::@2: scope:[printf_number_buffer] from printf_number_buffer::@1 printf_number_buffer::@14 printf_number_buffer::@15 printf_number_buffer::@7
[51] if((byte) 0==(byte) printf_number_buffer::buffer_sign#10) goto printf_number_buffer::@3
[53] if((byte) 0==(byte) printf_number_buffer::buffer_sign#10) goto printf_number_buffer::@3
to:printf_number_buffer::@8
printf_number_buffer::@8: scope:[printf_number_buffer] from printf_number_buffer::@2
[52] (byte) printf_char::ch#2 ← (byte) printf_number_buffer::buffer_sign#10
[53] call printf_char
[54] (byte) printf_char::ch#2 ← (byte) printf_number_buffer::buffer_sign#10
[55] call printf_char
to:printf_number_buffer::@3
printf_number_buffer::@3: scope:[printf_number_buffer] from printf_number_buffer::@2 printf_number_buffer::@8
[54] if((byte) 0==(byte) printf_number_buffer::format_zero_padding#10) goto printf_number_buffer::@4
[56] if((byte) 0==(byte) printf_number_buffer::format_zero_padding#10) goto printf_number_buffer::@4
to:printf_number_buffer::@16
printf_number_buffer::@16: scope:[printf_number_buffer] from printf_number_buffer::@3
[55] if((signed byte) 0!=(signed byte) printf_number_buffer::padding#10) goto printf_number_buffer::@9
[57] if((signed byte) 0!=(signed byte) printf_number_buffer::padding#10) goto printf_number_buffer::@9
to:printf_number_buffer::@4
printf_number_buffer::@9: scope:[printf_number_buffer] from printf_number_buffer::@16
[56] (byte) printf_padding::length#1 ← (byte)(signed byte) printf_number_buffer::padding#10
[57] call printf_padding
[58] (byte) printf_padding::length#1 ← (byte)(signed byte) printf_number_buffer::padding#10
[59] call printf_padding
to:printf_number_buffer::@4
printf_number_buffer::@4: scope:[printf_number_buffer] from printf_number_buffer::@16 printf_number_buffer::@3 printf_number_buffer::@9
[58] (byte*) printf_str::str#1 ← (byte*) printf_number_buffer::buffer_digits#10
[59] call printf_str
[60] (byte*) printf_str::str#1 ← (byte*) printf_number_buffer::buffer_digits#10
[61] call printf_str
to:printf_number_buffer::@13
printf_number_buffer::@13: scope:[printf_number_buffer] from printf_number_buffer::@4
[60] if((byte) 0==(byte) printf_number_buffer::format_justify_left#10) goto printf_number_buffer::@return
[62] if((byte) 0==(byte) printf_number_buffer::format_justify_left#10) goto printf_number_buffer::@return
to:printf_number_buffer::@18
printf_number_buffer::@18: scope:[printf_number_buffer] from printf_number_buffer::@13
[61] if((byte) 0!=(byte) printf_number_buffer::format_zero_padding#10) goto printf_number_buffer::@return
[63] if((byte) 0!=(byte) printf_number_buffer::format_zero_padding#10) goto printf_number_buffer::@return
to:printf_number_buffer::@17
printf_number_buffer::@17: scope:[printf_number_buffer] from printf_number_buffer::@18
[62] if((signed byte) 0!=(signed byte) printf_number_buffer::padding#10) goto printf_number_buffer::@10
[64] if((signed byte) 0!=(signed byte) printf_number_buffer::padding#10) goto printf_number_buffer::@10
to:printf_number_buffer::@return
printf_number_buffer::@10: scope:[printf_number_buffer] from printf_number_buffer::@17
[63] (byte) printf_padding::length#2 ← (byte)(signed byte) printf_number_buffer::padding#10
[64] call printf_padding
[65] (byte) printf_padding::length#2 ← (byte)(signed byte) printf_number_buffer::padding#10
[66] call printf_padding
to:printf_number_buffer::@return
printf_number_buffer::@return: scope:[printf_number_buffer] from printf_number_buffer::@10 printf_number_buffer::@13 printf_number_buffer::@17 printf_number_buffer::@18
[65] return
[67] return
to:@return
(void()) printf_padding((byte) printf_padding::pad , (byte) printf_padding::length)
printf_padding: scope:[printf_padding] from printf_number_buffer::@10 printf_number_buffer::@7 printf_number_buffer::@9
[66] (byte) printf_padding::pad#5 ← phi( printf_number_buffer::@9/(byte) '0' printf_number_buffer::@10/(byte) ' ' printf_number_buffer::@7/(byte) ' ' )
[66] (byte) printf_padding::length#4 ← phi( printf_number_buffer::@9/(byte) printf_padding::length#1 printf_number_buffer::@10/(byte) printf_padding::length#2 printf_number_buffer::@7/(byte) printf_padding::length#0 )
[68] (byte) printf_padding::pad#5 ← phi( printf_number_buffer::@9/(byte) '0' printf_number_buffer::@10/(byte) ' ' printf_number_buffer::@7/(byte) ' ' )
[68] (byte) printf_padding::length#4 ← phi( printf_number_buffer::@9/(byte) printf_padding::length#1 printf_number_buffer::@10/(byte) printf_padding::length#2 printf_number_buffer::@7/(byte) printf_padding::length#0 )
to:printf_padding::@1
printf_padding::@1: scope:[printf_padding] from printf_padding printf_padding::@3
[67] (byte) printf_padding::i#2 ← phi( printf_padding/(byte) 0 printf_padding::@3/(byte) printf_padding::i#1 )
[68] if((byte) printf_padding::i#2<(byte) printf_padding::length#4) goto printf_padding::@2
[69] (byte) printf_padding::i#2 ← phi( printf_padding/(byte) 0 printf_padding::@3/(byte) printf_padding::i#1 )
[70] if((byte) printf_padding::i#2<(byte) printf_padding::length#4) goto printf_padding::@2
to:printf_padding::@return
printf_padding::@return: scope:[printf_padding] from printf_padding::@1
[69] return
[71] return
to:@return
printf_padding::@2: scope:[printf_padding] from printf_padding::@1
[70] (byte) printf_char::ch#0 ← (byte) printf_padding::pad#5
[71] call printf_char
[72] (byte) printf_char::ch#0 ← (byte) printf_padding::pad#5
[73] call printf_char
to:printf_padding::@3
printf_padding::@3: scope:[printf_padding] from printf_padding::@2
[72] (byte) printf_padding::i#1 ← ++ (byte) printf_padding::i#2
[74] (byte) printf_padding::i#1 ← ++ (byte) printf_padding::i#2
to:printf_padding::@1
(void()) printf_char((byte) printf_char::ch)
printf_char: scope:[printf_char] from printf_number_buffer::@8 printf_padding::@2 printf_str::@5
[73] (byte) printf_char::ch#3 ← phi( printf_number_buffer::@8/(byte) printf_char::ch#2 printf_padding::@2/(byte) printf_char::ch#0 printf_str::@5/(byte) printf_char::ch#1 )
[74] *((byte*) printf_char_cursor) ← (byte) printf_char::ch#3
[75] (byte*) printf_char_cursor ← ++ (byte*) printf_char_cursor
[76] if((byte*) printf_char_cursor<(const byte*) printf_screen+(word)(number) $28*(number) $19) goto printf_char::@return
[75] (byte) printf_char::ch#3 ← phi( printf_number_buffer::@8/(byte) printf_char::ch#2 printf_padding::@2/(byte) printf_char::ch#0 printf_str::@5/(byte) printf_char::ch#1 )
[76] *((byte*) printf_cursor_ptr) ← (byte) printf_char::ch#3
[77] (byte*) printf_cursor_ptr ← ++ (byte*) printf_cursor_ptr
[78] (byte) printf_cursor_x ← ++ (byte) printf_cursor_x
[79] if((byte) printf_cursor_x!=(byte) $28) goto printf_char::@return
to:printf_char::@1
printf_char::@1: scope:[printf_char] from printf_char
[77] phi()
[78] call memcpy
[80] (byte) printf_cursor_x ← (byte) 0
[81] (byte) printf_cursor_y ← ++ (byte) printf_cursor_y
[82] if((byte) printf_cursor_y!=(byte) $19) goto printf_char::@return
to:printf_char::@2
printf_char::@2: scope:[printf_char] from printf_char::@1
[79] phi()
[80] call memset
[83] phi()
[84] call memcpy
to:printf_char::@3
printf_char::@3: scope:[printf_char] from printf_char::@2
[81] (byte*~) printf_char::$8 ← (byte*) printf_char_cursor - (byte) $28
[82] (byte*) printf_char_cursor ← (byte*~) printf_char::$8
[83] (byte*) printf_line_cursor ← (byte*) printf_char_cursor
[85] phi()
[86] call memset
to:printf_char::@4
printf_char::@4: scope:[printf_char] from printf_char::@3
[87] (byte*~) printf_char::$6 ← (byte*) printf_cursor_ptr - (byte) $28
[88] (byte*) printf_cursor_ptr ← (byte*~) printf_char::$6
[89] (byte) printf_cursor_y ← -- (byte) printf_cursor_y
to:printf_char::@return
printf_char::@return: scope:[printf_char] from printf_char printf_char::@3
[84] return
printf_char::@return: scope:[printf_char] from printf_char printf_char::@1 printf_char::@4
[90] return
to:@return
(void*()) memset((void*) memset::str , (byte) memset::c , (word) memset::num)
memset: scope:[memset] from printf_char::@2 printf_cls
[85] (byte) memset::c#4 ← phi( printf_char::@2/(byte) ' ' printf_cls/(byte) ' ' )
[85] (void*) memset::str#3 ← phi( printf_char::@2/(void*)(const byte*) printf_screen+(word)(number) $28*(number) $19-(byte) $28 printf_cls/(void*)(const byte*) printf_screen )
[85] (word) memset::num#2 ← phi( printf_char::@2/(byte) $28 printf_cls/(word)(number) $28*(number) $19 )
[86] if((word) memset::num#2<=(byte) 0) goto memset::@return
memset: scope:[memset] from printf_char::@3 printf_cls
[91] (byte) memset::c#4 ← phi( printf_char::@3/(byte) ' ' printf_cls/(byte) ' ' )
[91] (void*) memset::str#3 ← phi( printf_char::@3/(void*)(number) $400+(number) $28*(number) $19-(number) $28 printf_cls/(void*) 1024 )
[91] (word) memset::num#2 ← phi( printf_char::@3/(byte) $28 printf_cls/(word)(number) $28*(number) $19 )
[92] if((word) memset::num#2<=(byte) 0) goto memset::@return
to:memset::@1
memset::@1: scope:[memset] from memset
[87] (byte*) memset::end#0 ← (byte*)(void*) memset::str#3 + (word) memset::num#2
[88] (byte*) memset::dst#4 ← (byte*)(void*) memset::str#3
[93] (byte*) memset::end#0 ← (byte*)(void*) memset::str#3 + (word) memset::num#2
[94] (byte*) memset::dst#4 ← (byte*)(void*) memset::str#3
to:memset::@2
memset::@2: scope:[memset] from memset::@1 memset::@3
[89] (byte*) memset::dst#2 ← phi( memset::@1/(byte*) memset::dst#4 memset::@3/(byte*) memset::dst#1 )
[90] if((byte*) memset::dst#2!=(byte*) memset::end#0) goto memset::@3
[95] (byte*) memset::dst#2 ← phi( memset::@1/(byte*) memset::dst#4 memset::@3/(byte*) memset::dst#1 )
[96] if((byte*) memset::dst#2!=(byte*) memset::end#0) goto memset::@3
to:memset::@return
memset::@return: scope:[memset] from memset memset::@2
[91] return
[97] return
to:@return
memset::@3: scope:[memset] from memset::@2
[92] *((byte*) memset::dst#2) ← (byte) memset::c#4
[93] (byte*) memset::dst#1 ← ++ (byte*) memset::dst#2
[98] *((byte*) memset::dst#2) ← (byte) memset::c#4
[99] (byte*) memset::dst#1 ← ++ (byte*) memset::dst#2
to:memset::@2
(void*()) memcpy((void*) memcpy::destination , (void*) memcpy::source , (word) memcpy::num)
memcpy: scope:[memcpy] from printf_char::@1
[94] phi()
memcpy: scope:[memcpy] from printf_char::@2
[100] phi()
to:memcpy::@1
memcpy::@1: scope:[memcpy] from memcpy memcpy::@2
[95] (byte*) memcpy::dst#2 ← phi( memcpy/(byte*)(const void*) memcpy::destination#0 memcpy::@2/(byte*) memcpy::dst#1 )
[95] (byte*) memcpy::src#2 ← phi( memcpy/(byte*)(const void*) memcpy::source#0 memcpy::@2/(byte*) memcpy::src#1 )
[96] if((byte*) memcpy::src#2!=(const byte*) memcpy::src_end#0) goto memcpy::@2
[101] (byte*) memcpy::dst#2 ← phi( memcpy/(byte*)(const void*) memcpy::destination#0 memcpy::@2/(byte*) memcpy::dst#1 )
[101] (byte*) memcpy::src#2 ← phi( memcpy/(byte*)(const void*) memcpy::source#0 memcpy::@2/(byte*) memcpy::src#1 )
[102] if((byte*) memcpy::src#2!=(const byte*) memcpy::src_end#0) goto memcpy::@2
to:memcpy::@return
memcpy::@return: scope:[memcpy] from memcpy::@1
[97] return
[103] return
to:@return
memcpy::@2: scope:[memcpy] from memcpy::@1
[98] *((byte*) memcpy::dst#2) ← *((byte*) memcpy::src#2)
[99] (byte*) memcpy::dst#1 ← ++ (byte*) memcpy::dst#2
[100] (byte*) memcpy::src#1 ← ++ (byte*) memcpy::src#2
[104] *((byte*) memcpy::dst#2) ← *((byte*) memcpy::src#2)
[105] (byte*) memcpy::dst#1 ← ++ (byte*) memcpy::dst#2
[106] (byte*) memcpy::src#1 ← ++ (byte*) memcpy::src#2
to:memcpy::@1
(void()) printf_str((byte*) printf_str::str)
printf_str: scope:[printf_str] from printf_number_buffer::@4
[101] phi()
[107] phi()
to:printf_str::@1
printf_str::@1: scope:[printf_str] from printf_str printf_str::@4 printf_str::@5
[102] (byte*) printf_str::str#2 ← phi( printf_str/(byte*) printf_str::str#1 printf_str::@4/(byte*) printf_str::str#0 printf_str::@5/(byte*) printf_str::str#0 )
[108] (byte*) printf_str::str#2 ← phi( printf_str/(byte*) printf_str::str#1 printf_str::@4/(byte*) printf_str::str#0 printf_str::@5/(byte*) printf_str::str#0 )
to:printf_str::@2
printf_str::@2: scope:[printf_str] from printf_str::@1
[103] (byte) printf_str::ch#0 ← *((byte*) printf_str::str#2)
[104] (byte*) printf_str::str#0 ← ++ (byte*) printf_str::str#2
[105] if((byte) printf_str::ch#0!=(byte) 0) goto printf_str::@3
[109] (byte) printf_str::ch#0 ← *((byte*) printf_str::str#2)
[110] (byte*) printf_str::str#0 ← ++ (byte*) printf_str::str#2
[111] if((byte) printf_str::ch#0!=(byte) 0) goto printf_str::@3
to:printf_str::@return
printf_str::@return: scope:[printf_str] from printf_str::@2
[106] return
[112] return
to:@return
printf_str::@3: scope:[printf_str] from printf_str::@2
[107] if((byte) printf_str::ch#0==(byte) '
[113] if((byte) printf_str::ch#0==(byte) '
') goto printf_str::@4
to:printf_str::@5
printf_str::@5: scope:[printf_str] from printf_str::@3
[108] (byte) printf_char::ch#1 ← (byte) printf_str::ch#0
[109] call printf_char
[114] (byte) printf_char::ch#1 ← (byte) printf_str::ch#0
[115] call printf_char
to:printf_str::@1
printf_str::@4: scope:[printf_str] from printf_str::@3
[110] phi()
[111] call printf_ln
[116] phi()
[117] call printf_ln
to:printf_str::@1
(word()) strlen((byte*) strlen::str)
strlen: scope:[strlen] from printf_number_buffer::@5
[112] phi()
[118] phi()
to:strlen::@1
strlen::@1: scope:[strlen] from strlen strlen::@2
[113] (word) strlen::len#2 ← phi( strlen/(word) 0 strlen::@2/(word) strlen::len#1 )
[113] (byte*) strlen::str#2 ← phi( strlen/(byte*) strlen::str#1 strlen::@2/(byte*) strlen::str#0 )
[114] if((byte) 0!=*((byte*) strlen::str#2)) goto strlen::@2
[119] (word) strlen::len#2 ← phi( strlen/(word) 0 strlen::@2/(word) strlen::len#1 )
[119] (byte*) strlen::str#2 ← phi( strlen/(byte*) strlen::str#1 strlen::@2/(byte*) strlen::str#0 )
[120] if((byte) 0!=*((byte*) strlen::str#2)) goto strlen::@2
to:strlen::@return
strlen::@return: scope:[strlen] from strlen::@1
[115] return
[121] return
to:@return
strlen::@2: scope:[strlen] from strlen::@1
[116] (word) strlen::len#1 ← ++ (word) strlen::len#2
[117] (byte*) strlen::str#0 ← ++ (byte*) strlen::str#2
[122] (word) strlen::len#1 ← ++ (word) strlen::len#2
[123] (byte*) strlen::str#0 ← ++ (byte*) strlen::str#2
to:strlen::@1
(void()) utoa((word) utoa::value , (byte*) utoa::buffer , (byte) utoa::radix)
utoa: scope:[utoa] from printf_uint::@1
[118] phi()
[124] phi()
to:utoa::@1
utoa::@1: scope:[utoa] from utoa utoa::@4
[119] (byte*) utoa::buffer#11 ← phi( utoa::@4/(byte*) utoa::buffer#14 utoa/(byte*)&(struct printf_buffer_number) printf_buffer+(const byte) OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS )
[119] (byte) utoa::started#2 ← phi( utoa::@4/(byte) utoa::started#4 utoa/(byte) 0 )
[119] (word) utoa::value#2 ← phi( utoa::@4/(word) utoa::value#6 utoa/(const word) printf_uint::uvalue#0 )
[119] (byte) utoa::digit#2 ← phi( utoa::@4/(byte) utoa::digit#1 utoa/(byte) 0 )
[120] if((byte) utoa::digit#2<(const byte) utoa::max_digits#2-(byte) 1) goto utoa::@2
[125] (byte*) utoa::buffer#11 ← phi( utoa::@4/(byte*) utoa::buffer#14 utoa/(byte*)&(struct printf_buffer_number) printf_buffer+(const byte) OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS )
[125] (byte) utoa::started#2 ← phi( utoa::@4/(byte) utoa::started#4 utoa/(byte) 0 )
[125] (word) utoa::value#2 ← phi( utoa::@4/(word) utoa::value#6 utoa/(const word) printf_uint::uvalue#0 )
[125] (byte) utoa::digit#2 ← phi( utoa::@4/(byte) utoa::digit#1 utoa/(byte) 0 )
[126] if((byte) utoa::digit#2<(const byte) utoa::max_digits#2-(byte) 1) goto utoa::@2
to:utoa::@3
utoa::@3: scope:[utoa] from utoa::@1
[121] (byte~) utoa::$11 ← (byte)(word) utoa::value#2
[122] *((byte*) utoa::buffer#11) ← *((const byte*) DIGITS + (byte~) utoa::$11)
[123] (byte*) utoa::buffer#3 ← ++ (byte*) utoa::buffer#11
[124] *((byte*) utoa::buffer#3) ← (byte) 0
[127] (byte~) utoa::$11 ← (byte)(word) utoa::value#2
[128] *((byte*) utoa::buffer#11) ← *((const byte*) DIGITS + (byte~) utoa::$11)
[129] (byte*) utoa::buffer#3 ← ++ (byte*) utoa::buffer#11
[130] *((byte*) utoa::buffer#3) ← (byte) 0
to:utoa::@return
utoa::@return: scope:[utoa] from utoa::@3
[125] return
[131] return
to:@return
utoa::@2: scope:[utoa] from utoa::@1
[126] (byte~) utoa::$10 ← (byte) utoa::digit#2 << (byte) 1
[127] (word) utoa::digit_value#0 ← *((const word*) RADIX_HEXADECIMAL_VALUES + (byte~) utoa::$10)
[128] if((byte) 0!=(byte) utoa::started#2) goto utoa::@5
[132] (byte~) utoa::$10 ← (byte) utoa::digit#2 << (byte) 1
[133] (word) utoa::digit_value#0 ← *((const word*) RADIX_HEXADECIMAL_VALUES + (byte~) utoa::$10)
[134] if((byte) 0!=(byte) utoa::started#2) goto utoa::@5
to:utoa::@7
utoa::@7: scope:[utoa] from utoa::@2
[129] if((word) utoa::value#2>=(word) utoa::digit_value#0) goto utoa::@5
[135] if((word) utoa::value#2>=(word) utoa::digit_value#0) goto utoa::@5
to:utoa::@4
utoa::@4: scope:[utoa] from utoa::@6 utoa::@7
[130] (byte*) utoa::buffer#14 ← phi( utoa::@7/(byte*) utoa::buffer#11 utoa::@6/(byte*) utoa::buffer#4 )
[130] (byte) utoa::started#4 ← phi( utoa::@7/(byte) utoa::started#2 utoa::@6/(byte) 1 )
[130] (word) utoa::value#6 ← phi( utoa::@7/(word) utoa::value#2 utoa::@6/(word) utoa::value#0 )
[131] (byte) utoa::digit#1 ← ++ (byte) utoa::digit#2
[136] (byte*) utoa::buffer#14 ← phi( utoa::@7/(byte*) utoa::buffer#11 utoa::@6/(byte*) utoa::buffer#4 )
[136] (byte) utoa::started#4 ← phi( utoa::@7/(byte) utoa::started#2 utoa::@6/(byte) 1 )
[136] (word) utoa::value#6 ← phi( utoa::@7/(word) utoa::value#2 utoa::@6/(word) utoa::value#0 )
[137] (byte) utoa::digit#1 ← ++ (byte) utoa::digit#2
to:utoa::@1
utoa::@5: scope:[utoa] from utoa::@2 utoa::@7
[132] (byte*) utoa_append::buffer#0 ← (byte*) utoa::buffer#11
[133] (word) utoa_append::value#0 ← (word) utoa::value#2
[134] (word) utoa_append::sub#0 ← (word) utoa::digit_value#0
[135] call utoa_append
[136] (word) utoa_append::return#0 ← (word) utoa_append::value#2
[138] (byte*) utoa_append::buffer#0 ← (byte*) utoa::buffer#11
[139] (word) utoa_append::value#0 ← (word) utoa::value#2
[140] (word) utoa_append::sub#0 ← (word) utoa::digit_value#0
[141] call utoa_append
[142] (word) utoa_append::return#0 ← (word) utoa_append::value#2
to:utoa::@6
utoa::@6: scope:[utoa] from utoa::@5
[137] (word) utoa::value#0 ← (word) utoa_append::return#0
[138] (byte*) utoa::buffer#4 ← ++ (byte*) utoa::buffer#11
[143] (word) utoa::value#0 ← (word) utoa_append::return#0
[144] (byte*) utoa::buffer#4 ← ++ (byte*) utoa::buffer#11
to:utoa::@4
(word()) utoa_append((byte*) utoa_append::buffer , (word) utoa_append::value , (word) utoa_append::sub)
utoa_append: scope:[utoa_append] from utoa::@5
[139] phi()
[145] phi()
to:utoa_append::@1
utoa_append::@1: scope:[utoa_append] from utoa_append utoa_append::@2
[140] (byte) utoa_append::digit#2 ← phi( utoa_append/(byte) 0 utoa_append::@2/(byte) utoa_append::digit#1 )
[140] (word) utoa_append::value#2 ← phi( utoa_append/(word) utoa_append::value#0 utoa_append::@2/(word) utoa_append::value#1 )
[141] if((word) utoa_append::value#2>=(word) utoa_append::sub#0) goto utoa_append::@2
[146] (byte) utoa_append::digit#2 ← phi( utoa_append/(byte) 0 utoa_append::@2/(byte) utoa_append::digit#1 )
[146] (word) utoa_append::value#2 ← phi( utoa_append/(word) utoa_append::value#0 utoa_append::@2/(word) utoa_append::value#1 )
[147] if((word) utoa_append::value#2>=(word) utoa_append::sub#0) goto utoa_append::@2
to:utoa_append::@3
utoa_append::@3: scope:[utoa_append] from utoa_append::@1
[142] *((byte*) utoa_append::buffer#0) ← *((const byte*) DIGITS + (byte) utoa_append::digit#2)
[148] *((byte*) utoa_append::buffer#0) ← *((const byte*) DIGITS + (byte) utoa_append::digit#2)
to:utoa_append::@return
utoa_append::@return: scope:[utoa_append] from utoa_append::@3
[143] return
[149] return
to:@return
utoa_append::@2: scope:[utoa_append] from utoa_append::@1
[144] (byte) utoa_append::digit#1 ← ++ (byte) utoa_append::digit#2
[145] (word) utoa_append::value#1 ← (word) utoa_append::value#2 - (word) utoa_append::sub#0
[150] (byte) utoa_append::digit#1 ← ++ (byte) utoa_append::digit#2
[151] (word) utoa_append::value#1 ← (word) utoa_append::value#2 - (word) utoa_append::sub#0
to:utoa_append::@1
(void()) printf_schar((signed byte) printf_schar::value , (byte) printf_schar::format_min_length , (byte) printf_schar::format_justify_left , (byte) printf_schar::format_sign_always , (byte) printf_schar::format_zero_padding , (byte) printf_schar::format_radix)
printf_schar: scope:[printf_schar] from main::@1 main::@3
[146] (byte) printf_schar::format_zero_padding#2 ← phi( main::@1/(byte) 0 main::@3/(byte) 1 )
[146] (byte) printf_schar::format_radix#2 ← phi( main::@1/(const byte) DECIMAL main::@3/(const byte) OCTAL )
[146] (byte) printf_schar::format_sign_always#2 ← phi( main::@1/(byte) 0 main::@3/(byte) 1 )
[146] (signed byte) printf_schar::value#3 ← phi( main::@1/(signed byte) -$4d main::@3/(signed byte) $63 )
[147] *((byte*)&(struct printf_buffer_number) printf_buffer) ← (byte) 0
[148] if((signed byte) printf_schar::value#3<(signed byte) 0) goto printf_schar::@1
[152] (byte) printf_schar::format_zero_padding#2 ← phi( main::@1/(byte) 0 main::@3/(byte) 1 )
[152] (byte) printf_schar::format_radix#2 ← phi( main::@1/(const byte) DECIMAL main::@3/(const byte) OCTAL )
[152] (byte) printf_schar::format_sign_always#2 ← phi( main::@1/(byte) 0 main::@3/(byte) 1 )
[152] (signed byte) printf_schar::value#3 ← phi( main::@1/(signed byte) -$4d main::@3/(signed byte) $63 )
[153] *((byte*)&(struct printf_buffer_number) printf_buffer) ← (byte) 0
[154] if((signed byte) printf_schar::value#3<(signed byte) 0) goto printf_schar::@1
to:printf_schar::@3
printf_schar::@3: scope:[printf_schar] from printf_schar
[149] if((byte) 0==(byte) printf_schar::format_sign_always#2) goto printf_schar::@2
[155] if((byte) 0==(byte) printf_schar::format_sign_always#2) goto printf_schar::@2
to:printf_schar::@4
printf_schar::@4: scope:[printf_schar] from printf_schar::@3
[150] *((byte*)&(struct printf_buffer_number) printf_buffer) ← (byte) '+'
[156] *((byte*)&(struct printf_buffer_number) printf_buffer) ← (byte) '+'
to:printf_schar::@2
printf_schar::@2: scope:[printf_schar] from printf_schar::@1 printf_schar::@3 printf_schar::@4
[151] (signed byte) printf_schar::value#5 ← phi( printf_schar::@1/(signed byte) printf_schar::value#0 printf_schar::@3/(signed byte) printf_schar::value#3 printf_schar::@4/(signed byte) printf_schar::value#3 )
[152] (byte) uctoa::value#1 ← (byte)(signed byte) printf_schar::value#5
[153] (byte) uctoa::radix#0 ← (byte) printf_schar::format_radix#2
[154] call uctoa
[157] (signed byte) printf_schar::value#5 ← phi( printf_schar::@1/(signed byte) printf_schar::value#0 printf_schar::@3/(signed byte) printf_schar::value#3 printf_schar::@4/(signed byte) printf_schar::value#3 )
[158] (byte) uctoa::value#1 ← (byte)(signed byte) printf_schar::value#5
[159] (byte) uctoa::radix#0 ← (byte) printf_schar::format_radix#2
[160] call uctoa
to:printf_schar::@5
printf_schar::@5: scope:[printf_schar] from printf_schar::@2
[155] (byte) printf_number_buffer::buffer_sign#1 ← *((byte*)&(struct printf_buffer_number) printf_buffer)
[156] (byte) printf_number_buffer::format_zero_padding#1 ← (byte) printf_schar::format_zero_padding#2
[157] call printf_number_buffer
[161] (byte) printf_number_buffer::buffer_sign#1 ← *((byte*)&(struct printf_buffer_number) printf_buffer)
[162] (byte) printf_number_buffer::format_zero_padding#1 ← (byte) printf_schar::format_zero_padding#2
[163] call printf_number_buffer
to:printf_schar::@return
printf_schar::@return: scope:[printf_schar] from printf_schar::@5
[158] return
[164] return
to:@return
printf_schar::@1: scope:[printf_schar] from printf_schar
[159] (signed byte) printf_schar::value#0 ← - (signed byte) printf_schar::value#3
[160] *((byte*)&(struct printf_buffer_number) printf_buffer) ← (byte) '-'
[165] (signed byte) printf_schar::value#0 ← - (signed byte) printf_schar::value#3
[166] *((byte*)&(struct printf_buffer_number) printf_buffer) ← (byte) '-'
to:printf_schar::@2
(void()) uctoa((byte) uctoa::value , (byte*) uctoa::buffer , (byte) uctoa::radix)
uctoa: scope:[uctoa] from printf_schar::@2
[161] if((byte) uctoa::radix#0==(const byte) DECIMAL) goto uctoa::@1
[167] if((byte) uctoa::radix#0==(const byte) DECIMAL) goto uctoa::@1
to:uctoa::@2
uctoa::@2: scope:[uctoa] from uctoa
[162] if((byte) uctoa::radix#0==(const byte) HEXADECIMAL) goto uctoa::@1
[168] if((byte) uctoa::radix#0==(const byte) HEXADECIMAL) goto uctoa::@1
to:uctoa::@3
uctoa::@3: scope:[uctoa] from uctoa::@2
[163] if((byte) uctoa::radix#0==(const byte) OCTAL) goto uctoa::@1
[169] if((byte) uctoa::radix#0==(const byte) OCTAL) goto uctoa::@1
to:uctoa::@4
uctoa::@4: scope:[uctoa] from uctoa::@3
[164] if((byte) uctoa::radix#0==(const byte) BINARY) goto uctoa::@1
[170] if((byte) uctoa::radix#0==(const byte) BINARY) goto uctoa::@1
to:uctoa::@5
uctoa::@5: scope:[uctoa] from uctoa::@4
[165] *((byte*)&(struct printf_buffer_number) printf_buffer+(const byte) OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS) ← (byte) 'e'
[166] *((byte*)&(struct printf_buffer_number) printf_buffer+(const byte) OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS+(byte) 1) ← (byte) 'r'
[167] *((byte*)&(struct printf_buffer_number) printf_buffer+(const byte) OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS+(byte) 2) ← (byte) 'r'
[168] *((byte*)&(struct printf_buffer_number) printf_buffer+(const byte) OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS+(byte) 3) ← (byte) 0
[171] *((byte*)&(struct printf_buffer_number) printf_buffer+(const byte) OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS) ← (byte) 'e'
[172] *((byte*)&(struct printf_buffer_number) printf_buffer+(const byte) OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS+(byte) 1) ← (byte) 'r'
[173] *((byte*)&(struct printf_buffer_number) printf_buffer+(const byte) OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS+(byte) 2) ← (byte) 'r'
[174] *((byte*)&(struct printf_buffer_number) printf_buffer+(const byte) OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS+(byte) 3) ← (byte) 0
to:uctoa::@return
uctoa::@return: scope:[uctoa] from uctoa::@5 uctoa::@8
[169] return
[175] return
to:@return
uctoa::@1: scope:[uctoa] from uctoa uctoa::@2 uctoa::@3 uctoa::@4
[170] (byte*) uctoa::digit_values#8 ← phi( uctoa/(const byte*) RADIX_DECIMAL_VALUES_CHAR uctoa::@2/(const byte*) RADIX_HEXADECIMAL_VALUES_CHAR uctoa::@3/(const byte*) RADIX_OCTAL_VALUES_CHAR uctoa::@4/(const byte*) RADIX_BINARY_VALUES_CHAR )
[170] (byte) uctoa::max_digits#7 ← phi( uctoa/(byte) 3 uctoa::@2/(byte) 2 uctoa::@3/(byte) 3 uctoa::@4/(byte) 8 )
[176] (byte*) uctoa::digit_values#8 ← phi( uctoa/(const byte*) RADIX_DECIMAL_VALUES_CHAR uctoa::@2/(const byte*) RADIX_HEXADECIMAL_VALUES_CHAR uctoa::@3/(const byte*) RADIX_OCTAL_VALUES_CHAR uctoa::@4/(const byte*) RADIX_BINARY_VALUES_CHAR )
[176] (byte) uctoa::max_digits#7 ← phi( uctoa/(byte) 3 uctoa::@2/(byte) 2 uctoa::@3/(byte) 3 uctoa::@4/(byte) 8 )
to:uctoa::@6
uctoa::@6: scope:[uctoa] from uctoa::@1 uctoa::@9
[171] (byte*) uctoa::buffer#11 ← phi( uctoa::@9/(byte*) uctoa::buffer#14 uctoa::@1/(byte*)&(struct printf_buffer_number) printf_buffer+(const byte) OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS )
[171] (byte) uctoa::started#2 ← phi( uctoa::@9/(byte) uctoa::started#4 uctoa::@1/(byte) 0 )
[171] (byte) uctoa::value#2 ← phi( uctoa::@9/(byte) uctoa::value#6 uctoa::@1/(byte) uctoa::value#1 )
[171] (byte) uctoa::digit#2 ← phi( uctoa::@9/(byte) uctoa::digit#1 uctoa::@1/(byte) 0 )
[172] (byte~) uctoa::$4 ← (byte) uctoa::max_digits#7 - (byte) 1
[173] if((byte) uctoa::digit#2<(byte~) uctoa::$4) goto uctoa::@7
[177] (byte*) uctoa::buffer#11 ← phi( uctoa::@9/(byte*) uctoa::buffer#14 uctoa::@1/(byte*)&(struct printf_buffer_number) printf_buffer+(const byte) OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS )
[177] (byte) uctoa::started#2 ← phi( uctoa::@9/(byte) uctoa::started#4 uctoa::@1/(byte) 0 )
[177] (byte) uctoa::value#2 ← phi( uctoa::@9/(byte) uctoa::value#6 uctoa::@1/(byte) uctoa::value#1 )
[177] (byte) uctoa::digit#2 ← phi( uctoa::@9/(byte) uctoa::digit#1 uctoa::@1/(byte) 0 )
[178] (byte~) uctoa::$4 ← (byte) uctoa::max_digits#7 - (byte) 1
[179] if((byte) uctoa::digit#2<(byte~) uctoa::$4) goto uctoa::@7
to:uctoa::@8
uctoa::@8: scope:[uctoa] from uctoa::@6
[174] *((byte*) uctoa::buffer#11) ← *((const byte*) DIGITS + (byte) uctoa::value#2)
[175] (byte*) uctoa::buffer#3 ← ++ (byte*) uctoa::buffer#11
[176] *((byte*) uctoa::buffer#3) ← (byte) 0
[180] *((byte*) uctoa::buffer#11) ← *((const byte*) DIGITS + (byte) uctoa::value#2)
[181] (byte*) uctoa::buffer#3 ← ++ (byte*) uctoa::buffer#11
[182] *((byte*) uctoa::buffer#3) ← (byte) 0
to:uctoa::@return
uctoa::@7: scope:[uctoa] from uctoa::@6
[177] (byte) uctoa::digit_value#0 ← *((byte*) uctoa::digit_values#8 + (byte) uctoa::digit#2)
[178] if((byte) 0!=(byte) uctoa::started#2) goto uctoa::@10
[183] (byte) uctoa::digit_value#0 ← *((byte*) uctoa::digit_values#8 + (byte) uctoa::digit#2)
[184] if((byte) 0!=(byte) uctoa::started#2) goto uctoa::@10
to:uctoa::@12
uctoa::@12: scope:[uctoa] from uctoa::@7
[179] if((byte) uctoa::value#2>=(byte) uctoa::digit_value#0) goto uctoa::@10
[185] if((byte) uctoa::value#2>=(byte) uctoa::digit_value#0) goto uctoa::@10
to:uctoa::@9
uctoa::@9: scope:[uctoa] from uctoa::@11 uctoa::@12
[180] (byte*) uctoa::buffer#14 ← phi( uctoa::@12/(byte*) uctoa::buffer#11 uctoa::@11/(byte*) uctoa::buffer#4 )
[180] (byte) uctoa::started#4 ← phi( uctoa::@12/(byte) uctoa::started#2 uctoa::@11/(byte) 1 )
[180] (byte) uctoa::value#6 ← phi( uctoa::@12/(byte) uctoa::value#2 uctoa::@11/(byte) uctoa::value#0 )
[181] (byte) uctoa::digit#1 ← ++ (byte) uctoa::digit#2
[186] (byte*) uctoa::buffer#14 ← phi( uctoa::@12/(byte*) uctoa::buffer#11 uctoa::@11/(byte*) uctoa::buffer#4 )
[186] (byte) uctoa::started#4 ← phi( uctoa::@12/(byte) uctoa::started#2 uctoa::@11/(byte) 1 )
[186] (byte) uctoa::value#6 ← phi( uctoa::@12/(byte) uctoa::value#2 uctoa::@11/(byte) uctoa::value#0 )
[187] (byte) uctoa::digit#1 ← ++ (byte) uctoa::digit#2
to:uctoa::@6
uctoa::@10: scope:[uctoa] from uctoa::@12 uctoa::@7
[182] (byte*) uctoa_append::buffer#0 ← (byte*) uctoa::buffer#11
[183] (byte) uctoa_append::value#0 ← (byte) uctoa::value#2
[184] (byte) uctoa_append::sub#0 ← (byte) uctoa::digit_value#0
[185] call uctoa_append
[186] (byte) uctoa_append::return#0 ← (byte) uctoa_append::value#2
[188] (byte*) uctoa_append::buffer#0 ← (byte*) uctoa::buffer#11
[189] (byte) uctoa_append::value#0 ← (byte) uctoa::value#2
[190] (byte) uctoa_append::sub#0 ← (byte) uctoa::digit_value#0
[191] call uctoa_append
[192] (byte) uctoa_append::return#0 ← (byte) uctoa_append::value#2
to:uctoa::@11
uctoa::@11: scope:[uctoa] from uctoa::@10
[187] (byte) uctoa::value#0 ← (byte) uctoa_append::return#0
[188] (byte*) uctoa::buffer#4 ← ++ (byte*) uctoa::buffer#11
[193] (byte) uctoa::value#0 ← (byte) uctoa_append::return#0
[194] (byte*) uctoa::buffer#4 ← ++ (byte*) uctoa::buffer#11
to:uctoa::@9
(byte()) uctoa_append((byte*) uctoa_append::buffer , (byte) uctoa_append::value , (byte) uctoa_append::sub)
uctoa_append: scope:[uctoa_append] from uctoa::@10
[189] phi()
[195] phi()
to:uctoa_append::@1
uctoa_append::@1: scope:[uctoa_append] from uctoa_append uctoa_append::@2
[190] (byte) uctoa_append::digit#2 ← phi( uctoa_append/(byte) 0 uctoa_append::@2/(byte) uctoa_append::digit#1 )
[190] (byte) uctoa_append::value#2 ← phi( uctoa_append/(byte) uctoa_append::value#0 uctoa_append::@2/(byte) uctoa_append::value#1 )
[191] if((byte) uctoa_append::value#2>=(byte) uctoa_append::sub#0) goto uctoa_append::@2
[196] (byte) uctoa_append::digit#2 ← phi( uctoa_append/(byte) 0 uctoa_append::@2/(byte) uctoa_append::digit#1 )
[196] (byte) uctoa_append::value#2 ← phi( uctoa_append/(byte) uctoa_append::value#0 uctoa_append::@2/(byte) uctoa_append::value#1 )
[197] if((byte) uctoa_append::value#2>=(byte) uctoa_append::sub#0) goto uctoa_append::@2
to:uctoa_append::@3
uctoa_append::@3: scope:[uctoa_append] from uctoa_append::@1
[192] *((byte*) uctoa_append::buffer#0) ← *((const byte*) DIGITS + (byte) uctoa_append::digit#2)
[198] *((byte*) uctoa_append::buffer#0) ← *((const byte*) DIGITS + (byte) uctoa_append::digit#2)
to:uctoa_append::@return
uctoa_append::@return: scope:[uctoa_append] from uctoa_append::@3
[193] return
[199] return
to:@return
uctoa_append::@2: scope:[uctoa_append] from uctoa_append::@1
[194] (byte) uctoa_append::digit#1 ← ++ (byte) uctoa_append::digit#2
[195] (byte) uctoa_append::value#1 ← (byte) uctoa_append::value#2 - (byte) uctoa_append::sub#0
[200] (byte) uctoa_append::digit#1 ← ++ (byte) uctoa_append::digit#2
[201] (byte) uctoa_append::value#1 ← (byte) uctoa_append::value#2 - (byte) uctoa_append::sub#0
to:uctoa_append::@1
(void()) printf_cls()
printf_cls: scope:[printf_cls] from main
[196] phi()
[197] call memset
[202] phi()
[203] call memset
to:printf_cls::@1
printf_cls::@1: scope:[printf_cls] from printf_cls
[198] (byte*) printf_line_cursor ← (const byte*) printf_screen
[199] (byte*) printf_char_cursor ← (byte*) printf_line_cursor
[204] (byte*) printf_cursor_ptr ← (byte*) 1024
[205] (byte) printf_cursor_x ← (byte) 0
[206] (byte) printf_cursor_y ← (byte) 0
to:printf_cls::@return
printf_cls::@return: scope:[printf_cls] from printf_cls::@1
[200] return
[207] return
to:@return

File diff suppressed because one or more lines are too long

View File

@ -31,7 +31,7 @@
(label) memcpy::@2
(label) memcpy::@return
(void*) memcpy::destination
(const void*) memcpy::destination#0 destination = (void*)(const byte*) printf_screen
(const void*) memcpy::destination#0 destination = (void*) 1024
(byte*) memcpy::dst
(byte*) memcpy::dst#1 dst zp[2]:10 1.000000001E9
(byte*) memcpy::dst#2 dst zp[2]:10 1.000000001E9
@ -39,7 +39,7 @@
(const word) memcpy::num#0 num = (word)(number) $28*(number) $19-(number) $28
(void*) memcpy::return
(void*) memcpy::source
(const void*) memcpy::source#0 source = (void*)(const byte*) printf_screen+(byte) $28
(const void*) memcpy::source#0 source = (void*)(number) $400+(number) $28
(byte*) memcpy::src
(byte*) memcpy::src#1 src zp[2]:6 2.000000002E9
(byte*) memcpy::src#2 src zp[2]:6 1.000000001E9
@ -67,20 +67,23 @@
(const byte*) printf_buffer_number::digits[(number) $b] = { fill( $b, 0) }
(byte) printf_buffer_number::sign
(void()) printf_char((byte) printf_char::ch)
(byte*~) printf_char::$8 zp[2]:16 2000002.0
(byte*~) printf_char::$6 zp[2]:16 2000002.0
(label) printf_char::@1
(label) printf_char::@2
(label) printf_char::@3
(label) printf_char::@4
(label) printf_char::@return
(byte) printf_char::ch
(byte) printf_char::ch#0 reg byte a 200002.0
(byte) printf_char::ch#1 reg byte a 200002.0
(byte) printf_char::ch#2 reg byte a 2002.0
(byte) printf_char::ch#3 reg byte a 1201004.0
(byte*) printf_char_cursor loadstore zp[2]:16 174758.36893203887
(void()) printf_cls()
(label) printf_cls::@1
(label) printf_cls::@return
(byte*) printf_cursor_ptr loadstore zp[2]:16 64815.83333333333
(byte) printf_cursor_x loadstore zp[1]:14 56075.785046728975
(byte) printf_cursor_y loadstore zp[1]:15 64221.19266055047
(byte) printf_format_number::justify_left
(byte) printf_format_number::min_length
(byte) printf_format_number::radix
@ -88,10 +91,9 @@
(byte) printf_format_number::zero_padding
(byte) printf_format_string::justify_left
(byte) printf_format_string::min_length
(byte*) printf_line_cursor loadstore zp[2]:14 323234.4343434343
(void()) printf_ln()
(label) printf_ln::@1
(label) printf_ln::@2
(byte*~) printf_ln::$0 zp[2]:16 2000002.0
(byte*~) printf_ln::$1 zp[2]:16 2000002.0
(label) printf_ln::@return
(void()) printf_number_buffer((byte) printf_number_buffer::buffer_sign , (byte*) printf_number_buffer::buffer_digits , (byte) printf_number_buffer::format_min_length , (byte) printf_number_buffer::format_justify_left , (byte) printf_number_buffer::format_sign_always , (byte) printf_number_buffer::format_zero_padding , (byte) printf_number_buffer::format_radix)
(word~) printf_number_buffer::$18 zp[2]:10 1001.0
@ -175,7 +177,6 @@
(signed byte) printf_schar::value#0 reg byte x 101.0
(signed byte) printf_schar::value#3 reg byte x 80.8
(signed byte) printf_schar::value#5 reg byte x 303.0
(const byte*) printf_screen = (byte*) 1024
(void()) printf_str((byte*) printf_str::str)
(label) printf_str::@1
(label) printf_str::@2
@ -345,8 +346,9 @@ reg byte x [ uctoa::value#2 uctoa::value#6 uctoa::value#1 uctoa::value#0 ]
zp[1]:13 [ uctoa::started#2 uctoa::started#4 printf_padding::pad#5 ]
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]:14 [ printf_line_cursor ]
zp[2]:16 [ printf_char_cursor printf_char::$8 ]
zp[1]:14 [ printf_cursor_x ]
zp[1]:15 [ printf_cursor_y ]
zp[2]:16 [ printf_cursor_ptr printf_char::$6 printf_ln::$0 printf_ln::$1 ]
reg byte a [ printf_str::ch#0 ]
reg byte a [ utoa::$11 ]
reg byte a [ utoa::$10 ]