mirror of
https://gitlab.com/camelot/kickc.git
synced 2025-01-13 18:30:21 +00:00
Added memchr() to <string.h>
This commit is contained in:
parent
ffa0ae17d0
commit
e3555ff651
@ -18,4 +18,11 @@ void *memset(void *str, char c, size_t num);
|
||||
char* strcpy( char* destination, char* source );
|
||||
|
||||
// Computes the length of the string str up to but not including the terminating null character.
|
||||
size_t strlen(char *str);
|
||||
size_t strlen(char *str);
|
||||
|
||||
// Searches for the first occurrence of the character c (an unsigned char) in the first n bytes of the string pointed to, by the argument str.
|
||||
// - str: The memory to search
|
||||
// - c: A character to search for
|
||||
// - n: The number of bytes to look through
|
||||
// Return: A pointer to the matching byte or NULL if the character does not occur in the given memory area.
|
||||
void *memchr(const void *str, char c, size_t n);
|
@ -64,4 +64,19 @@ size_t strlen(char *str) {
|
||||
str++;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
// Searches for the first occurrence of the character c (an unsigned char) in the first n bytes of the string pointed to, by the argument str.
|
||||
// - str: The memory to search
|
||||
// - c: A character to search for
|
||||
// - n: The number of bytes to look through
|
||||
// Return: A pointer to the matching byte or NULL if the character does not occur in the given memory area.
|
||||
void *memchr(const void *str, char c, size_t n) {
|
||||
char * ptr = str;
|
||||
for(size_t i=0;i<n;i++) {
|
||||
if(*ptr==c)
|
||||
return ptr;
|
||||
ptr++;
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -44,6 +44,11 @@ public class TestPrograms {
|
||||
public TestPrograms() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStdlibStringMemChr1() throws IOException, URISyntaxException {
|
||||
compileAndCompare("stdlib-string-memchr-1.c");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProblemArraySizeDecl() throws IOException, URISyntaxException {
|
||||
assertError("problem-arraysize-decl.c", "BAR is not constant or is not defined");
|
||||
|
@ -125,8 +125,7 @@ void()* const musicPlay = (void()*) INTRO_MUSIC+0x06;
|
||||
|
||||
#pragma data_seg(Init)
|
||||
// SID tune
|
||||
// Pacmania Shaun Southern https://csdb.dk/sid/?id=53795
|
||||
// Relocated using ./sidreloc-1.0/sidreloc -p30 c64src/borderline/Pacmania.sid c64src/borderline/Pacmania_3000.sid
|
||||
// Pacman 2 channel music by Metal/Camelot
|
||||
char INTRO_MUSIC_CRUNCHED[] = kickasm(resource "pacman-2chn-simpler.prg", uses INTRO_MUSIC) {{
|
||||
.modify B2() {
|
||||
.pc = INTRO_MUSIC "INTRO MUSIC"
|
||||
|
49
src/test/kc/stdlib-string-memchr-1.c
Normal file
49
src/test/kc/stdlib-string-memchr-1.c
Normal file
@ -0,0 +1,49 @@
|
||||
// Test standard library <string.h> memchr()
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <conio.h>
|
||||
|
||||
void main() {
|
||||
|
||||
clrscr();
|
||||
|
||||
char* str = "this is a test";
|
||||
char* ptr = memchr( str, 'a', 14);
|
||||
assert_uint(8, (ptr-str), "finding a");
|
||||
|
||||
char* ptr2 = memchr( str, 'a', 7);
|
||||
assert_ptr((void*)0, ptr2, "not finding a");
|
||||
|
||||
}
|
||||
|
||||
void assert_char(char expect, char actual, char* message) {
|
||||
if(expect!=actual) {
|
||||
textcolor(RED);
|
||||
printf("Assert failed. expected:'%x' actual:'%c'. %s\n", expect, actual, message);
|
||||
} else {
|
||||
textcolor(GREEN);
|
||||
printf("ok! %s\n", message);
|
||||
}
|
||||
}
|
||||
|
||||
void assert_uint(unsigned int expect, unsigned int actual, char* message) {
|
||||
if(expect!=actual) {
|
||||
textcolor(RED);
|
||||
printf("Assert failed. expected:%u actual:%u. %s\n", expect, actual, message);
|
||||
} else {
|
||||
textcolor(GREEN);
|
||||
printf("ok! %s\n", message);
|
||||
}
|
||||
}
|
||||
|
||||
void assert_ptr(void* expect, void* actual, char* message) {
|
||||
if(expect!=actual) {
|
||||
textcolor(RED);
|
||||
printf("Assert failed. expected:0x%x actual:0x%x. %s\n", (unsigned int)expect, (unsigned int)actual, message);
|
||||
} else {
|
||||
textcolor(GREEN);
|
||||
printf("ok! %s\n", message);
|
||||
}
|
||||
|
||||
}
|
@ -4805,8 +4805,7 @@ RASTER_CODE_CRUNCHED:
|
||||
}
|
||||
|
||||
// SID tune
|
||||
// Pacmania Shaun Southern https://csdb.dk/sid/?id=53795
|
||||
// Relocated using ./sidreloc-1.0/sidreloc -p30 c64src/borderline/Pacmania.sid c64src/borderline/Pacmania_3000.sid
|
||||
// Pacman 2 channel music by Metal/Camelot
|
||||
INTRO_MUSIC_CRUNCHED:
|
||||
.modify B2() {
|
||||
.pc = INTRO_MUSIC "INTRO MUSIC"
|
||||
|
@ -22198,8 +22198,7 @@ RASTER_CODE_CRUNCHED:
|
||||
}
|
||||
|
||||
// SID tune
|
||||
// Pacmania Shaun Southern https://csdb.dk/sid/?id=53795
|
||||
// Relocated using ./sidreloc-1.0/sidreloc -p30 c64src/borderline/Pacmania.sid c64src/borderline/Pacmania_3000.sid
|
||||
// Pacman 2 channel music by Metal/Camelot
|
||||
INTRO_MUSIC_CRUNCHED:
|
||||
.modify B2() {
|
||||
.pc = INTRO_MUSIC "INTRO MUSIC"
|
||||
@ -31510,8 +31509,7 @@ RASTER_CODE_CRUNCHED:
|
||||
}
|
||||
|
||||
// SID tune
|
||||
// Pacmania Shaun Southern https://csdb.dk/sid/?id=53795
|
||||
// Relocated using ./sidreloc-1.0/sidreloc -p30 c64src/borderline/Pacmania.sid c64src/borderline/Pacmania_3000.sid
|
||||
// Pacman 2 channel music by Metal/Camelot
|
||||
INTRO_MUSIC_CRUNCHED:
|
||||
.modify B2() {
|
||||
.pc = INTRO_MUSIC "INTRO MUSIC"
|
||||
|
973
src/test/ref/stdlib-string-memchr-1.asm
Normal file
973
src/test/ref/stdlib-string-memchr-1.asm
Normal file
@ -0,0 +1,973 @@
|
||||
// Test standard library <string.h> memchr()
|
||||
// Commodore 64 PRG executable file
|
||||
.file [name="stdlib-string-memchr-1.prg", type="prg", segments="Program"]
|
||||
.segmentdef Program [segments="Basic, Code, Data"]
|
||||
.segmentdef Basic [start=$0801]
|
||||
.segmentdef Code [start=$80d]
|
||||
.segmentdef Data [startAfter="Code"]
|
||||
.segment Basic
|
||||
:BasicUpstart(__start)
|
||||
.const BINARY = 2
|
||||
.const OCTAL = 8
|
||||
.const DECIMAL = $a
|
||||
.const HEXADECIMAL = $10
|
||||
.const RED = 2
|
||||
.const GREEN = 5
|
||||
.const LIGHT_BLUE = $e
|
||||
.const OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS = 1
|
||||
.const SIZEOF_STRUCT_PRINTF_BUFFER_NUMBER = $c
|
||||
// Color Ram
|
||||
.label COLORRAM = $d800
|
||||
// Default address of screen character matrix
|
||||
.label DEFAULT_SCREEN = $400
|
||||
// The number of bytes on the screen
|
||||
// The current cursor x-position
|
||||
.label conio_cursor_x = $c
|
||||
// The current cursor y-position
|
||||
.label conio_cursor_y = $d
|
||||
// The current text cursor line start
|
||||
.label conio_line_text = $e
|
||||
// The current color cursor line start
|
||||
.label conio_line_color = $10
|
||||
// The current text color
|
||||
.label conio_textcolor = $12
|
||||
.segment Code
|
||||
__start: {
|
||||
// conio_cursor_x = 0
|
||||
lda #0
|
||||
sta.z conio_cursor_x
|
||||
// conio_cursor_y = 0
|
||||
sta.z conio_cursor_y
|
||||
// conio_line_text = CONIO_SCREEN_TEXT
|
||||
lda #<DEFAULT_SCREEN
|
||||
sta.z conio_line_text
|
||||
lda #>DEFAULT_SCREEN
|
||||
sta.z conio_line_text+1
|
||||
// conio_line_color = CONIO_SCREEN_COLORS
|
||||
lda #<COLORRAM
|
||||
sta.z conio_line_color
|
||||
lda #>COLORRAM
|
||||
sta.z conio_line_color+1
|
||||
// conio_textcolor = CONIO_TEXTCOLOR_DEFAULT
|
||||
lda #LIGHT_BLUE
|
||||
sta.z conio_textcolor
|
||||
// #pragma constructor_for(conio_c64_init, cputc, clrscr, cscroll)
|
||||
jsr conio_c64_init
|
||||
jsr main
|
||||
rts
|
||||
}
|
||||
// Set initial cursor position
|
||||
conio_c64_init: {
|
||||
// Position cursor at current line
|
||||
.label BASIC_CURSOR_LINE = $d6
|
||||
// line = *BASIC_CURSOR_LINE
|
||||
ldx BASIC_CURSOR_LINE
|
||||
// if(line>=CONIO_HEIGHT)
|
||||
cpx #$19
|
||||
bcc __b1
|
||||
ldx #$19-1
|
||||
__b1:
|
||||
// gotoxy(0, line)
|
||||
jsr gotoxy
|
||||
// }
|
||||
rts
|
||||
}
|
||||
main: {
|
||||
.label ptr = 2
|
||||
.label ptr2 = 2
|
||||
// clrscr()
|
||||
jsr clrscr
|
||||
// memchr( str, 'a', 14)
|
||||
lda #'a'
|
||||
sta.z memchr.c
|
||||
lda #<$e
|
||||
sta.z memchr.n
|
||||
lda #>$e
|
||||
sta.z memchr.n+1
|
||||
jsr memchr
|
||||
// memchr( str, 'a', 14)
|
||||
// assert_uint(8, (ptr-str), "finding a")
|
||||
lda.z assert_uint.actual
|
||||
sec
|
||||
sbc #<str
|
||||
sta.z assert_uint.actual
|
||||
lda.z assert_uint.actual+1
|
||||
sbc #>str
|
||||
sta.z assert_uint.actual+1
|
||||
jsr assert_uint
|
||||
// memchr( str, 'a', 7)
|
||||
lda #'a'
|
||||
sta.z memchr.c
|
||||
lda #<7
|
||||
sta.z memchr.n
|
||||
lda #>7
|
||||
sta.z memchr.n+1
|
||||
jsr memchr
|
||||
// memchr( str, 'a', 7)
|
||||
// assert_ptr((void*)0, ptr2, "not finding a")
|
||||
jsr assert_ptr
|
||||
// }
|
||||
rts
|
||||
.segment Data
|
||||
str: .text "this is a test"
|
||||
.byte 0
|
||||
message: .text "finding a"
|
||||
.byte 0
|
||||
message1: .text "not finding a"
|
||||
.byte 0
|
||||
}
|
||||
.segment Code
|
||||
// Set the cursor to the specified position
|
||||
// gotoxy(byte register(X) y)
|
||||
gotoxy: {
|
||||
.const x = 0
|
||||
.label __5 = $17
|
||||
.label __6 = $13
|
||||
.label __7 = $13
|
||||
.label line_offset = $13
|
||||
.label __8 = $15
|
||||
.label __9 = $13
|
||||
// if(y>CONIO_HEIGHT)
|
||||
cpx #$19+1
|
||||
bcc __b2
|
||||
ldx #0
|
||||
__b2:
|
||||
// conio_cursor_x = x
|
||||
lda #x
|
||||
sta.z conio_cursor_x
|
||||
// conio_cursor_y = y
|
||||
stx.z conio_cursor_y
|
||||
// (unsigned int)y*CONIO_WIDTH
|
||||
txa
|
||||
sta.z __7
|
||||
lda #0
|
||||
sta.z __7+1
|
||||
// line_offset = (unsigned int)y*CONIO_WIDTH
|
||||
lda.z __7
|
||||
asl
|
||||
sta.z __8
|
||||
lda.z __7+1
|
||||
rol
|
||||
sta.z __8+1
|
||||
asl.z __8
|
||||
rol.z __8+1
|
||||
lda.z __9
|
||||
clc
|
||||
adc.z __8
|
||||
sta.z __9
|
||||
lda.z __9+1
|
||||
adc.z __8+1
|
||||
sta.z __9+1
|
||||
asl.z line_offset
|
||||
rol.z line_offset+1
|
||||
asl.z line_offset
|
||||
rol.z line_offset+1
|
||||
asl.z line_offset
|
||||
rol.z line_offset+1
|
||||
// CONIO_SCREEN_TEXT + line_offset
|
||||
clc
|
||||
lda.z line_offset
|
||||
adc #<DEFAULT_SCREEN
|
||||
sta.z __5
|
||||
lda.z line_offset+1
|
||||
adc #>DEFAULT_SCREEN
|
||||
sta.z __5+1
|
||||
// conio_line_text = CONIO_SCREEN_TEXT + line_offset
|
||||
lda.z __5
|
||||
sta.z conio_line_text
|
||||
lda.z __5+1
|
||||
sta.z conio_line_text+1
|
||||
// CONIO_SCREEN_COLORS + line_offset
|
||||
clc
|
||||
lda.z __6
|
||||
adc #<COLORRAM
|
||||
sta.z __6
|
||||
lda.z __6+1
|
||||
adc #>COLORRAM
|
||||
sta.z __6+1
|
||||
// conio_line_color = CONIO_SCREEN_COLORS + line_offset
|
||||
lda.z __6
|
||||
sta.z conio_line_color
|
||||
lda.z __6+1
|
||||
sta.z conio_line_color+1
|
||||
// }
|
||||
rts
|
||||
}
|
||||
// clears the screen and moves the cursor to the upper left-hand corner of the screen.
|
||||
clrscr: {
|
||||
.label line_text = 4
|
||||
.label line_cols = 8
|
||||
lda #<COLORRAM
|
||||
sta.z line_cols
|
||||
lda #>COLORRAM
|
||||
sta.z line_cols+1
|
||||
lda #<DEFAULT_SCREEN
|
||||
sta.z line_text
|
||||
lda #>DEFAULT_SCREEN
|
||||
sta.z line_text+1
|
||||
ldx #0
|
||||
__b1:
|
||||
// for( char l=0;l<CONIO_HEIGHT; l++ )
|
||||
cpx #$19
|
||||
bcc __b2
|
||||
// conio_cursor_x = 0
|
||||
lda #0
|
||||
sta.z conio_cursor_x
|
||||
// conio_cursor_y = 0
|
||||
sta.z conio_cursor_y
|
||||
// conio_line_text = CONIO_SCREEN_TEXT
|
||||
lda #<DEFAULT_SCREEN
|
||||
sta.z conio_line_text
|
||||
lda #>DEFAULT_SCREEN
|
||||
sta.z conio_line_text+1
|
||||
// conio_line_color = CONIO_SCREEN_COLORS
|
||||
lda #<COLORRAM
|
||||
sta.z conio_line_color
|
||||
lda #>COLORRAM
|
||||
sta.z conio_line_color+1
|
||||
// }
|
||||
rts
|
||||
__b2:
|
||||
ldy #0
|
||||
__b3:
|
||||
// for( char c=0;c<CONIO_WIDTH; c++ )
|
||||
cpy #$28
|
||||
bcc __b4
|
||||
// line_text += CONIO_WIDTH
|
||||
lda #$28
|
||||
clc
|
||||
adc.z line_text
|
||||
sta.z line_text
|
||||
bcc !+
|
||||
inc.z line_text+1
|
||||
!:
|
||||
// line_cols += CONIO_WIDTH
|
||||
lda #$28
|
||||
clc
|
||||
adc.z line_cols
|
||||
sta.z line_cols
|
||||
bcc !+
|
||||
inc.z line_cols+1
|
||||
!:
|
||||
// for( char l=0;l<CONIO_HEIGHT; l++ )
|
||||
inx
|
||||
jmp __b1
|
||||
__b4:
|
||||
// line_text[c] = ' '
|
||||
lda #' '
|
||||
sta (line_text),y
|
||||
// line_cols[c] = conio_textcolor
|
||||
lda.z conio_textcolor
|
||||
sta (line_cols),y
|
||||
// for( char c=0;c<CONIO_WIDTH; c++ )
|
||||
iny
|
||||
jmp __b3
|
||||
}
|
||||
// Searches for the first occurrence of the character c (an unsigned char) in the first n bytes of the string pointed to, by the argument str.
|
||||
// - str: The memory to search
|
||||
// - c: A character to search for
|
||||
// - n: The number of bytes to look through
|
||||
// Return: A pointer to the matching byte or NULL if the character does not occur in the given memory area.
|
||||
// memchr(byte zp(6) c, word zp(4) n)
|
||||
memchr: {
|
||||
.label ptr = 2
|
||||
.label i = 8
|
||||
.label return = 2
|
||||
.label n = 4
|
||||
.label c = 6
|
||||
lda #<main.str
|
||||
sta.z ptr
|
||||
lda #>main.str
|
||||
sta.z ptr+1
|
||||
lda #<0
|
||||
sta.z i
|
||||
sta.z i+1
|
||||
__b1:
|
||||
// for(size_t i=0;i<n;i++)
|
||||
lda.z i+1
|
||||
cmp.z n+1
|
||||
bcc __b2
|
||||
bne !+
|
||||
lda.z i
|
||||
cmp.z n
|
||||
bcc __b2
|
||||
!:
|
||||
lda #<0
|
||||
sta.z return
|
||||
sta.z return+1
|
||||
// }
|
||||
rts
|
||||
__b2:
|
||||
// if(*ptr==c)
|
||||
ldy #0
|
||||
lda (ptr),y
|
||||
cmp.z c
|
||||
bne __b3
|
||||
rts
|
||||
__b3:
|
||||
// ptr++;
|
||||
inc.z ptr
|
||||
bne !+
|
||||
inc.z ptr+1
|
||||
!:
|
||||
// for(size_t i=0;i<n;i++)
|
||||
inc.z i
|
||||
bne !+
|
||||
inc.z i+1
|
||||
!:
|
||||
jmp __b1
|
||||
}
|
||||
// assert_uint(word zp(2) actual)
|
||||
assert_uint: {
|
||||
.const expect = 8
|
||||
.label actual = 2
|
||||
// if(expect!=actual)
|
||||
lda.z actual+1
|
||||
cmp #>expect
|
||||
bne __b1
|
||||
lda.z actual
|
||||
cmp #<expect
|
||||
bne __b1
|
||||
// textcolor(GREEN)
|
||||
lda #GREEN
|
||||
jsr textcolor
|
||||
// printf("ok! %s\n", message)
|
||||
lda #<s4
|
||||
sta.z cputs.s
|
||||
lda #>s4
|
||||
sta.z cputs.s+1
|
||||
jsr cputs
|
||||
// printf("ok! %s\n", message)
|
||||
lda #<main.message
|
||||
sta.z printf_string.str
|
||||
lda #>main.message
|
||||
sta.z printf_string.str+1
|
||||
jsr printf_string
|
||||
// printf("ok! %s\n", message)
|
||||
lda #<s3
|
||||
sta.z cputs.s
|
||||
lda #>s3
|
||||
sta.z cputs.s+1
|
||||
jsr cputs
|
||||
// }
|
||||
rts
|
||||
__b1:
|
||||
// textcolor(RED)
|
||||
lda #RED
|
||||
jsr textcolor
|
||||
// printf("Assert failed. expected:%u actual:%u. %s\n", expect, actual, message)
|
||||
lda #<s
|
||||
sta.z cputs.s
|
||||
lda #>s
|
||||
sta.z cputs.s+1
|
||||
jsr cputs
|
||||
// printf("Assert failed. expected:%u actual:%u. %s\n", expect, actual, message)
|
||||
ldx #DECIMAL
|
||||
lda #<expect
|
||||
sta.z printf_uint.uvalue
|
||||
lda #>expect
|
||||
sta.z printf_uint.uvalue+1
|
||||
jsr printf_uint
|
||||
// printf("Assert failed. expected:%u actual:%u. %s\n", expect, actual, message)
|
||||
lda #<s1
|
||||
sta.z cputs.s
|
||||
lda #>s1
|
||||
sta.z cputs.s+1
|
||||
jsr cputs
|
||||
// printf("Assert failed. expected:%u actual:%u. %s\n", expect, actual, message)
|
||||
lda.z actual
|
||||
sta.z printf_uint.uvalue
|
||||
lda.z actual+1
|
||||
sta.z printf_uint.uvalue+1
|
||||
ldx #DECIMAL
|
||||
jsr printf_uint
|
||||
// printf("Assert failed. expected:%u actual:%u. %s\n", expect, actual, message)
|
||||
lda #<s2
|
||||
sta.z cputs.s
|
||||
lda #>s2
|
||||
sta.z cputs.s+1
|
||||
jsr cputs
|
||||
// printf("Assert failed. expected:%u actual:%u. %s\n", expect, actual, message)
|
||||
lda #<main.message
|
||||
sta.z printf_string.str
|
||||
lda #>main.message
|
||||
sta.z printf_string.str+1
|
||||
jsr printf_string
|
||||
// printf("Assert failed. expected:%u actual:%u. %s\n", expect, actual, message)
|
||||
lda #<s3
|
||||
sta.z cputs.s
|
||||
lda #>s3
|
||||
sta.z cputs.s+1
|
||||
jsr cputs
|
||||
rts
|
||||
.segment Data
|
||||
s: .text "Assert failed. expected:"
|
||||
.byte 0
|
||||
s1: .text " actual:"
|
||||
.byte 0
|
||||
}
|
||||
.segment Code
|
||||
assert_ptr: {
|
||||
.label expect = 0
|
||||
// if(expect!=actual)
|
||||
lda.z main.ptr2+1
|
||||
cmp #>expect
|
||||
bne __b1
|
||||
lda.z main.ptr2
|
||||
cmp #<expect
|
||||
bne __b1
|
||||
// textcolor(GREEN)
|
||||
lda #GREEN
|
||||
jsr textcolor
|
||||
// printf("ok! %s\n", message)
|
||||
lda #<s4
|
||||
sta.z cputs.s
|
||||
lda #>s4
|
||||
sta.z cputs.s+1
|
||||
jsr cputs
|
||||
// printf("ok! %s\n", message)
|
||||
lda #<main.message1
|
||||
sta.z printf_string.str
|
||||
lda #>main.message1
|
||||
sta.z printf_string.str+1
|
||||
jsr printf_string
|
||||
// printf("ok! %s\n", message)
|
||||
lda #<s3
|
||||
sta.z cputs.s
|
||||
lda #>s3
|
||||
sta.z cputs.s+1
|
||||
jsr cputs
|
||||
// }
|
||||
rts
|
||||
__b1:
|
||||
// textcolor(RED)
|
||||
lda #RED
|
||||
jsr textcolor
|
||||
// printf("Assert failed. expected:0x%x actual:0x%x. %s\n", (unsigned int)expect, (unsigned int)actual, message)
|
||||
lda #<s
|
||||
sta.z cputs.s
|
||||
lda #>s
|
||||
sta.z cputs.s+1
|
||||
jsr cputs
|
||||
// printf("Assert failed. expected:0x%x actual:0x%x. %s\n", (unsigned int)expect, (unsigned int)actual, message)
|
||||
ldx #HEXADECIMAL
|
||||
lda #<0
|
||||
sta.z printf_uint.uvalue
|
||||
sta.z printf_uint.uvalue+1
|
||||
jsr printf_uint
|
||||
// printf("Assert failed. expected:0x%x actual:0x%x. %s\n", (unsigned int)expect, (unsigned int)actual, message)
|
||||
lda #<s1
|
||||
sta.z cputs.s
|
||||
lda #>s1
|
||||
sta.z cputs.s+1
|
||||
jsr cputs
|
||||
lda.z main.ptr2
|
||||
sta.z printf_uint.uvalue
|
||||
lda.z main.ptr2+1
|
||||
sta.z printf_uint.uvalue+1
|
||||
// printf("Assert failed. expected:0x%x actual:0x%x. %s\n", (unsigned int)expect, (unsigned int)actual, message)
|
||||
ldx #HEXADECIMAL
|
||||
jsr printf_uint
|
||||
// printf("Assert failed. expected:0x%x actual:0x%x. %s\n", (unsigned int)expect, (unsigned int)actual, message)
|
||||
lda #<s2
|
||||
sta.z cputs.s
|
||||
lda #>s2
|
||||
sta.z cputs.s+1
|
||||
jsr cputs
|
||||
// printf("Assert failed. expected:0x%x actual:0x%x. %s\n", (unsigned int)expect, (unsigned int)actual, message)
|
||||
lda #<main.message1
|
||||
sta.z printf_string.str
|
||||
lda #>main.message1
|
||||
sta.z printf_string.str+1
|
||||
jsr printf_string
|
||||
// printf("Assert failed. expected:0x%x actual:0x%x. %s\n", (unsigned int)expect, (unsigned int)actual, message)
|
||||
lda #<s3
|
||||
sta.z cputs.s
|
||||
lda #>s3
|
||||
sta.z cputs.s+1
|
||||
jsr cputs
|
||||
rts
|
||||
.segment Data
|
||||
s: .text "Assert failed. expected:0x"
|
||||
.byte 0
|
||||
s1: .text " actual:0x"
|
||||
.byte 0
|
||||
}
|
||||
.segment Code
|
||||
// Set the color for text output. The old color setting is returned.
|
||||
// textcolor(byte register(A) color)
|
||||
textcolor: {
|
||||
// conio_textcolor = color
|
||||
sta.z conio_textcolor
|
||||
// }
|
||||
rts
|
||||
}
|
||||
// Output a NUL-terminated string at the current cursor position
|
||||
// cputs(byte* zp(4) s)
|
||||
cputs: {
|
||||
.label s = 4
|
||||
__b1:
|
||||
// while(c=*s++)
|
||||
ldy #0
|
||||
lda (s),y
|
||||
inc.z s
|
||||
bne !+
|
||||
inc.z s+1
|
||||
!:
|
||||
cmp #0
|
||||
bne __b2
|
||||
// }
|
||||
rts
|
||||
__b2:
|
||||
// cputc(c)
|
||||
jsr cputc
|
||||
jmp __b1
|
||||
}
|
||||
// Print a string value using a specific format
|
||||
// Handles justification and min length
|
||||
// printf_string(byte* zp(4) str)
|
||||
printf_string: {
|
||||
.label str = 4
|
||||
// cputs(str)
|
||||
jsr cputs
|
||||
// }
|
||||
rts
|
||||
}
|
||||
// Print an unsigned int using a specific format
|
||||
// printf_uint(word zp(4) uvalue, byte register(X) format_radix)
|
||||
printf_uint: {
|
||||
.label uvalue = 4
|
||||
// printf_buffer.sign = format.sign_always?'+':0
|
||||
// Handle any sign
|
||||
lda #0
|
||||
sta printf_buffer
|
||||
// utoa(uvalue, printf_buffer.digits, format.radix)
|
||||
// Format number into buffer
|
||||
jsr utoa
|
||||
// printf_number_buffer(printf_buffer, format)
|
||||
lda printf_buffer
|
||||
// Print using format
|
||||
jsr printf_number_buffer
|
||||
// }
|
||||
rts
|
||||
}
|
||||
// Output one character at the current cursor position
|
||||
// Moves the cursor forward. Scrolls the entire screen if needed
|
||||
// cputc(byte register(A) c)
|
||||
cputc: {
|
||||
// if(c=='\n')
|
||||
cmp #'\n'
|
||||
beq __b1
|
||||
// conio_line_text[conio_cursor_x] = c
|
||||
ldy.z conio_cursor_x
|
||||
sta (conio_line_text),y
|
||||
// conio_line_color[conio_cursor_x] = conio_textcolor
|
||||
lda.z conio_textcolor
|
||||
sta (conio_line_color),y
|
||||
// if(++conio_cursor_x==CONIO_WIDTH)
|
||||
inc.z conio_cursor_x
|
||||
lda #$28
|
||||
cmp.z conio_cursor_x
|
||||
bne __breturn
|
||||
// cputln()
|
||||
jsr cputln
|
||||
__breturn:
|
||||
// }
|
||||
rts
|
||||
__b1:
|
||||
// cputln()
|
||||
jsr cputln
|
||||
rts
|
||||
}
|
||||
// Converts unsigned number value to a string representing it in RADIX format.
|
||||
// If the leading digits are zero they are not included in the string.
|
||||
// - value : The number to be converted to RADIX
|
||||
// - buffer : receives the string representing the number and zero-termination.
|
||||
// - radix : The radix to convert the number to (from the enum RADIX)
|
||||
// utoa(word zp(4) value, byte* zp($a) buffer, byte register(X) radix)
|
||||
utoa: {
|
||||
.label digit_value = $19
|
||||
.label buffer = $a
|
||||
.label digit = 7
|
||||
.label value = 4
|
||||
.label max_digits = 6
|
||||
.label digit_values = 8
|
||||
// if(radix==DECIMAL)
|
||||
cpx #DECIMAL
|
||||
beq __b2
|
||||
// if(radix==HEXADECIMAL)
|
||||
cpx #HEXADECIMAL
|
||||
beq __b3
|
||||
// if(radix==OCTAL)
|
||||
cpx #OCTAL
|
||||
beq __b4
|
||||
// if(radix==BINARY)
|
||||
cpx #BINARY
|
||||
beq __b5
|
||||
// *buffer++ = 'e'
|
||||
// Unknown radix
|
||||
lda #'e'
|
||||
sta printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
|
||||
// *buffer++ = 'r'
|
||||
lda #'r'
|
||||
sta printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS+1
|
||||
sta printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS+2
|
||||
// *buffer = 0
|
||||
lda #0
|
||||
sta printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS+3
|
||||
// }
|
||||
rts
|
||||
__b2:
|
||||
lda #<RADIX_DECIMAL_VALUES
|
||||
sta.z digit_values
|
||||
lda #>RADIX_DECIMAL_VALUES
|
||||
sta.z digit_values+1
|
||||
lda #5
|
||||
sta.z max_digits
|
||||
jmp __b1
|
||||
__b3:
|
||||
lda #<RADIX_HEXADECIMAL_VALUES
|
||||
sta.z digit_values
|
||||
lda #>RADIX_HEXADECIMAL_VALUES
|
||||
sta.z digit_values+1
|
||||
lda #4
|
||||
sta.z max_digits
|
||||
jmp __b1
|
||||
__b4:
|
||||
lda #<RADIX_OCTAL_VALUES
|
||||
sta.z digit_values
|
||||
lda #>RADIX_OCTAL_VALUES
|
||||
sta.z digit_values+1
|
||||
lda #6
|
||||
sta.z max_digits
|
||||
jmp __b1
|
||||
__b5:
|
||||
lda #<RADIX_BINARY_VALUES
|
||||
sta.z digit_values
|
||||
lda #>RADIX_BINARY_VALUES
|
||||
sta.z digit_values+1
|
||||
lda #$10
|
||||
sta.z max_digits
|
||||
__b1:
|
||||
lda #<printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
|
||||
sta.z buffer
|
||||
lda #>printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
|
||||
sta.z buffer+1
|
||||
ldx #0
|
||||
txa
|
||||
sta.z digit
|
||||
__b6:
|
||||
// max_digits-1
|
||||
lda.z max_digits
|
||||
sec
|
||||
sbc #1
|
||||
// for( char digit=0; digit<max_digits-1; digit++ )
|
||||
cmp.z digit
|
||||
beq !+
|
||||
bcs __b7
|
||||
!:
|
||||
// *buffer++ = DIGITS[(char)value]
|
||||
lda.z value
|
||||
tay
|
||||
lda DIGITS,y
|
||||
ldy #0
|
||||
sta (buffer),y
|
||||
// *buffer++ = DIGITS[(char)value];
|
||||
inc.z buffer
|
||||
bne !+
|
||||
inc.z buffer+1
|
||||
!:
|
||||
// *buffer = 0
|
||||
lda #0
|
||||
tay
|
||||
sta (buffer),y
|
||||
rts
|
||||
__b7:
|
||||
// digit_value = digit_values[digit]
|
||||
lda.z digit
|
||||
asl
|
||||
tay
|
||||
lda (digit_values),y
|
||||
sta.z digit_value
|
||||
iny
|
||||
lda (digit_values),y
|
||||
sta.z digit_value+1
|
||||
// if (started || value >= digit_value)
|
||||
cpx #0
|
||||
bne __b10
|
||||
cmp.z value+1
|
||||
bne !+
|
||||
lda.z digit_value
|
||||
cmp.z value
|
||||
beq __b10
|
||||
!:
|
||||
bcc __b10
|
||||
__b9:
|
||||
// for( char digit=0; digit<max_digits-1; digit++ )
|
||||
inc.z digit
|
||||
jmp __b6
|
||||
__b10:
|
||||
// utoa_append(buffer++, value, digit_value)
|
||||
jsr utoa_append
|
||||
// utoa_append(buffer++, value, digit_value)
|
||||
// value = utoa_append(buffer++, value, digit_value)
|
||||
// value = utoa_append(buffer++, value, digit_value);
|
||||
inc.z buffer
|
||||
bne !+
|
||||
inc.z buffer+1
|
||||
!:
|
||||
ldx #1
|
||||
jmp __b9
|
||||
}
|
||||
// Print the contents of the number buffer using a specific format.
|
||||
// This handles minimum length, zero-filling, and left/right justification from the format
|
||||
// printf_number_buffer(byte register(A) buffer_sign)
|
||||
printf_number_buffer: {
|
||||
.label buffer_digits = printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
|
||||
// if(buffer.sign)
|
||||
cmp #0
|
||||
beq __b2
|
||||
// cputc(buffer.sign)
|
||||
jsr cputc
|
||||
__b2:
|
||||
// cputs(buffer.digits)
|
||||
lda #<buffer_digits
|
||||
sta.z cputs.s
|
||||
lda #>buffer_digits
|
||||
sta.z cputs.s+1
|
||||
jsr cputs
|
||||
// }
|
||||
rts
|
||||
}
|
||||
// Print a newline
|
||||
cputln: {
|
||||
// conio_line_text += CONIO_WIDTH
|
||||
lda #$28
|
||||
clc
|
||||
adc.z conio_line_text
|
||||
sta.z conio_line_text
|
||||
bcc !+
|
||||
inc.z conio_line_text+1
|
||||
!:
|
||||
// conio_line_color += CONIO_WIDTH
|
||||
lda #$28
|
||||
clc
|
||||
adc.z conio_line_color
|
||||
sta.z conio_line_color
|
||||
bcc !+
|
||||
inc.z conio_line_color+1
|
||||
!:
|
||||
// conio_cursor_x = 0
|
||||
lda #0
|
||||
sta.z conio_cursor_x
|
||||
// conio_cursor_y++;
|
||||
inc.z conio_cursor_y
|
||||
// cscroll()
|
||||
jsr cscroll
|
||||
// }
|
||||
rts
|
||||
}
|
||||
// Used to convert a single digit of an unsigned number value to a string representation
|
||||
// Counts a single digit up from '0' as long as the value is larger than sub.
|
||||
// Each time the digit is increased sub is subtracted from value.
|
||||
// - buffer : pointer to the char that receives the digit
|
||||
// - value : The value where the digit will be derived from
|
||||
// - sub : the value of a '1' in the digit. Subtracted continually while the digit is increased.
|
||||
// (For decimal the subs used are 10000, 1000, 100, 10, 1)
|
||||
// returns : the value reduced by sub * digit so that it is less than sub.
|
||||
// utoa_append(byte* zp($a) buffer, word zp(4) value, word zp($19) sub)
|
||||
utoa_append: {
|
||||
.label buffer = $a
|
||||
.label value = 4
|
||||
.label sub = $19
|
||||
.label return = 4
|
||||
ldx #0
|
||||
__b1:
|
||||
// while (value >= sub)
|
||||
lda.z sub+1
|
||||
cmp.z value+1
|
||||
bne !+
|
||||
lda.z sub
|
||||
cmp.z value
|
||||
beq __b2
|
||||
!:
|
||||
bcc __b2
|
||||
// *buffer = DIGITS[digit]
|
||||
lda DIGITS,x
|
||||
ldy #0
|
||||
sta (buffer),y
|
||||
// }
|
||||
rts
|
||||
__b2:
|
||||
// digit++;
|
||||
inx
|
||||
// value -= sub
|
||||
lda.z value
|
||||
sec
|
||||
sbc.z sub
|
||||
sta.z value
|
||||
lda.z value+1
|
||||
sbc.z sub+1
|
||||
sta.z value+1
|
||||
jmp __b1
|
||||
}
|
||||
// Scroll the entire screen if the cursor is beyond the last line
|
||||
cscroll: {
|
||||
// if(conio_cursor_y==CONIO_HEIGHT)
|
||||
lda #$19
|
||||
cmp.z conio_cursor_y
|
||||
bne __breturn
|
||||
// memcpy(CONIO_SCREEN_TEXT, CONIO_SCREEN_TEXT+CONIO_WIDTH, CONIO_BYTES-CONIO_WIDTH)
|
||||
lda #<DEFAULT_SCREEN
|
||||
sta.z memcpy.destination
|
||||
lda #>DEFAULT_SCREEN
|
||||
sta.z memcpy.destination+1
|
||||
lda #<DEFAULT_SCREEN+$28
|
||||
sta.z memcpy.source
|
||||
lda #>DEFAULT_SCREEN+$28
|
||||
sta.z memcpy.source+1
|
||||
jsr memcpy
|
||||
// memcpy(CONIO_SCREEN_COLORS, CONIO_SCREEN_COLORS+CONIO_WIDTH, CONIO_BYTES-CONIO_WIDTH)
|
||||
lda #<COLORRAM
|
||||
sta.z memcpy.destination
|
||||
lda #>COLORRAM
|
||||
sta.z memcpy.destination+1
|
||||
lda #<COLORRAM+$28
|
||||
sta.z memcpy.source
|
||||
lda #>COLORRAM+$28
|
||||
sta.z memcpy.source+1
|
||||
jsr memcpy
|
||||
// memset(CONIO_SCREEN_TEXT+CONIO_BYTES-CONIO_WIDTH, ' ', CONIO_WIDTH)
|
||||
ldx #' '
|
||||
lda #<DEFAULT_SCREEN+$19*$28-$28
|
||||
sta.z memset.str
|
||||
lda #>DEFAULT_SCREEN+$19*$28-$28
|
||||
sta.z memset.str+1
|
||||
jsr memset
|
||||
// memset(CONIO_SCREEN_COLORS+CONIO_BYTES-CONIO_WIDTH, conio_textcolor, CONIO_WIDTH)
|
||||
ldx.z conio_textcolor
|
||||
lda #<COLORRAM+$19*$28-$28
|
||||
sta.z memset.str
|
||||
lda #>COLORRAM+$19*$28-$28
|
||||
sta.z memset.str+1
|
||||
jsr memset
|
||||
// conio_line_text -= CONIO_WIDTH
|
||||
sec
|
||||
lda.z conio_line_text
|
||||
sbc #$28
|
||||
sta.z conio_line_text
|
||||
lda.z conio_line_text+1
|
||||
sbc #0
|
||||
sta.z conio_line_text+1
|
||||
// conio_line_color -= CONIO_WIDTH
|
||||
sec
|
||||
lda.z conio_line_color
|
||||
sbc #$28
|
||||
sta.z conio_line_color
|
||||
lda.z conio_line_color+1
|
||||
sbc #0
|
||||
sta.z conio_line_color+1
|
||||
// conio_cursor_y--;
|
||||
dec.z conio_cursor_y
|
||||
__breturn:
|
||||
// }
|
||||
rts
|
||||
}
|
||||
// Copy block of memory (forwards)
|
||||
// Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
|
||||
// memcpy(void* zp($a) destination, void* zp(8) source)
|
||||
memcpy: {
|
||||
.label src_end = $1b
|
||||
.label dst = $a
|
||||
.label src = 8
|
||||
.label source = 8
|
||||
.label destination = $a
|
||||
// src_end = (char*)source+num
|
||||
clc
|
||||
lda.z source
|
||||
adc #<$19*$28-$28
|
||||
sta.z src_end
|
||||
lda.z source+1
|
||||
adc #>$19*$28-$28
|
||||
sta.z src_end+1
|
||||
__b1:
|
||||
// while(src!=src_end)
|
||||
lda.z src+1
|
||||
cmp.z src_end+1
|
||||
bne __b2
|
||||
lda.z src
|
||||
cmp.z src_end
|
||||
bne __b2
|
||||
// }
|
||||
rts
|
||||
__b2:
|
||||
// *dst++ = *src++
|
||||
ldy #0
|
||||
lda (src),y
|
||||
sta (dst),y
|
||||
// *dst++ = *src++;
|
||||
inc.z dst
|
||||
bne !+
|
||||
inc.z dst+1
|
||||
!:
|
||||
inc.z src
|
||||
bne !+
|
||||
inc.z src+1
|
||||
!:
|
||||
jmp __b1
|
||||
}
|
||||
// Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
|
||||
// memset(void* zp($19) str, byte register(X) c)
|
||||
memset: {
|
||||
.label end = $1b
|
||||
.label dst = $19
|
||||
.label str = $19
|
||||
// end = (char*)str + num
|
||||
lda #$28
|
||||
clc
|
||||
adc.z str
|
||||
sta.z end
|
||||
lda #0
|
||||
adc.z str+1
|
||||
sta.z end+1
|
||||
__b2:
|
||||
// for(char* dst = str; dst!=end; dst++)
|
||||
lda.z dst+1
|
||||
cmp.z end+1
|
||||
bne __b3
|
||||
lda.z dst
|
||||
cmp.z end
|
||||
bne __b3
|
||||
// }
|
||||
rts
|
||||
__b3:
|
||||
// *dst = c
|
||||
txa
|
||||
ldy #0
|
||||
sta (dst),y
|
||||
// for(char* dst = str; dst!=end; dst++)
|
||||
inc.z dst
|
||||
bne !+
|
||||
inc.z dst+1
|
||||
!:
|
||||
jmp __b2
|
||||
}
|
||||
.segment Data
|
||||
// The digits used for numbers
|
||||
DIGITS: .text "0123456789abcdef"
|
||||
// Values of binary digits
|
||||
RADIX_BINARY_VALUES: .word $8000, $4000, $2000, $1000, $800, $400, $200, $100, $80, $40, $20, $10, 8, 4, 2
|
||||
// Values of octal digits
|
||||
RADIX_OCTAL_VALUES: .word $8000, $1000, $200, $40, 8
|
||||
// Values of decimal digits
|
||||
RADIX_DECIMAL_VALUES: .word $2710, $3e8, $64, $a
|
||||
// Values of hexadecimal digits
|
||||
RADIX_HEXADECIMAL_VALUES: .word $1000, $100, $10
|
||||
s2: .text ". "
|
||||
.byte 0
|
||||
s3: .text @"\n"
|
||||
.byte 0
|
||||
s4: .text "ok! "
|
||||
.byte 0
|
||||
// Buffer used for stringified number being printed
|
||||
printf_buffer: .fill SIZEOF_STRUCT_PRINTF_BUFFER_NUMBER, 0
|
533
src/test/ref/stdlib-string-memchr-1.cfg
Normal file
533
src/test/ref/stdlib-string-memchr-1.cfg
Normal file
@ -0,0 +1,533 @@
|
||||
|
||||
void __start()
|
||||
__start: scope:[__start] from
|
||||
[0] phi()
|
||||
to:__start::__init1
|
||||
__start::__init1: scope:[__start] from __start
|
||||
[1] conio_cursor_x = 0
|
||||
[2] conio_cursor_y = 0
|
||||
[3] conio_line_text = DEFAULT_SCREEN
|
||||
[4] conio_line_color = COLORRAM
|
||||
[5] conio_textcolor = LIGHT_BLUE
|
||||
[6] call conio_c64_init
|
||||
to:__start::@1
|
||||
__start::@1: scope:[__start] from __start::__init1
|
||||
[7] phi()
|
||||
[8] call main
|
||||
to:__start::@return
|
||||
__start::@return: scope:[__start] from __start::@1
|
||||
[9] return
|
||||
to:@return
|
||||
|
||||
void conio_c64_init()
|
||||
conio_c64_init: scope:[conio_c64_init] from __start::__init1
|
||||
[10] conio_c64_init::line#0 = *conio_c64_init::BASIC_CURSOR_LINE
|
||||
[11] if(conio_c64_init::line#0<$19) goto conio_c64_init::@2
|
||||
to:conio_c64_init::@1
|
||||
conio_c64_init::@2: scope:[conio_c64_init] from conio_c64_init
|
||||
[12] phi()
|
||||
to:conio_c64_init::@1
|
||||
conio_c64_init::@1: scope:[conio_c64_init] from conio_c64_init conio_c64_init::@2
|
||||
[13] conio_c64_init::line#2 = phi( conio_c64_init::@2/conio_c64_init::line#0, conio_c64_init/$19-1 )
|
||||
[14] gotoxy::y#2 = conio_c64_init::line#2
|
||||
[15] call gotoxy
|
||||
to:conio_c64_init::@return
|
||||
conio_c64_init::@return: scope:[conio_c64_init] from conio_c64_init::@1
|
||||
[16] return
|
||||
to:@return
|
||||
|
||||
void main()
|
||||
main: scope:[main] from __start::@1
|
||||
[17] phi()
|
||||
[18] call clrscr
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main
|
||||
[19] phi()
|
||||
[20] call memchr
|
||||
[21] memchr::return#3 = memchr::return#2
|
||||
to:main::@2
|
||||
main::@2: scope:[main] from main::@1
|
||||
[22] main::ptr#0 = memchr::return#3
|
||||
[23] assert_uint::actual#0 = (byte*)main::ptr#0 - main::str
|
||||
[24] call assert_uint
|
||||
to:main::@3
|
||||
main::@3: scope:[main] from main::@2
|
||||
[25] phi()
|
||||
[26] call memchr
|
||||
[27] memchr::return#4 = memchr::return#2
|
||||
to:main::@4
|
||||
main::@4: scope:[main] from main::@3
|
||||
[28] main::ptr2#0 = memchr::return#4
|
||||
[29] call assert_ptr
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@4
|
||||
[30] return
|
||||
to:@return
|
||||
|
||||
void gotoxy(byte gotoxy::x , byte gotoxy::y)
|
||||
gotoxy: scope:[gotoxy] from conio_c64_init::@1
|
||||
[31] if(gotoxy::y#2<$19+1) goto gotoxy::@3
|
||||
to:gotoxy::@1
|
||||
gotoxy::@3: scope:[gotoxy] from gotoxy
|
||||
[32] phi()
|
||||
to:gotoxy::@1
|
||||
gotoxy::@1: scope:[gotoxy] from gotoxy gotoxy::@3
|
||||
[33] gotoxy::y#4 = phi( gotoxy::@3/gotoxy::y#2, gotoxy/0 )
|
||||
to:gotoxy::@2
|
||||
gotoxy::@2: scope:[gotoxy] from gotoxy::@1
|
||||
[34] conio_cursor_x = gotoxy::x#2
|
||||
[35] conio_cursor_y = gotoxy::y#4
|
||||
[36] gotoxy::$7 = (word)gotoxy::y#4
|
||||
[37] gotoxy::$8 = gotoxy::$7 << 2
|
||||
[38] gotoxy::$9 = gotoxy::$8 + gotoxy::$7
|
||||
[39] gotoxy::line_offset#0 = gotoxy::$9 << 3
|
||||
[40] gotoxy::$5 = DEFAULT_SCREEN + gotoxy::line_offset#0
|
||||
[41] conio_line_text = gotoxy::$5
|
||||
[42] gotoxy::$6 = COLORRAM + gotoxy::line_offset#0
|
||||
[43] conio_line_color = gotoxy::$6
|
||||
to:gotoxy::@return
|
||||
gotoxy::@return: scope:[gotoxy] from gotoxy::@2
|
||||
[44] return
|
||||
to:@return
|
||||
|
||||
void clrscr()
|
||||
clrscr: scope:[clrscr] from main
|
||||
[45] phi()
|
||||
to:clrscr::@1
|
||||
clrscr::@1: scope:[clrscr] from clrscr clrscr::@5
|
||||
[46] clrscr::line_cols#5 = phi( clrscr/COLORRAM, clrscr::@5/clrscr::line_cols#1 )
|
||||
[46] clrscr::line_text#5 = phi( clrscr/DEFAULT_SCREEN, clrscr::@5/clrscr::line_text#1 )
|
||||
[46] clrscr::l#2 = phi( clrscr/0, clrscr::@5/clrscr::l#1 )
|
||||
[47] if(clrscr::l#2<$19) goto clrscr::@3
|
||||
to:clrscr::@2
|
||||
clrscr::@2: scope:[clrscr] from clrscr::@1
|
||||
[48] conio_cursor_x = 0
|
||||
[49] conio_cursor_y = 0
|
||||
[50] conio_line_text = DEFAULT_SCREEN
|
||||
[51] conio_line_color = COLORRAM
|
||||
to:clrscr::@return
|
||||
clrscr::@return: scope:[clrscr] from clrscr::@2
|
||||
[52] return
|
||||
to:@return
|
||||
clrscr::@3: scope:[clrscr] from clrscr::@1 clrscr::@4
|
||||
[53] clrscr::c#2 = phi( clrscr::@1/0, clrscr::@4/clrscr::c#1 )
|
||||
[54] if(clrscr::c#2<$28) goto clrscr::@4
|
||||
to:clrscr::@5
|
||||
clrscr::@5: scope:[clrscr] from clrscr::@3
|
||||
[55] clrscr::line_text#1 = clrscr::line_text#5 + $28
|
||||
[56] clrscr::line_cols#1 = clrscr::line_cols#5 + $28
|
||||
[57] clrscr::l#1 = ++ clrscr::l#2
|
||||
to:clrscr::@1
|
||||
clrscr::@4: scope:[clrscr] from clrscr::@3
|
||||
[58] clrscr::line_text#5[clrscr::c#2] = ' '
|
||||
[59] clrscr::line_cols#5[clrscr::c#2] = conio_textcolor
|
||||
[60] clrscr::c#1 = ++ clrscr::c#2
|
||||
to:clrscr::@3
|
||||
|
||||
void* memchr(to_nomodify void* memchr::str , byte memchr::c , word memchr::n)
|
||||
memchr: scope:[memchr] from main::@1 main::@3
|
||||
[61] memchr::c#4 = phi( main::@1/'a', main::@3/'a' )
|
||||
[61] memchr::n#3 = phi( main::@1/$e, main::@3/7 )
|
||||
to:memchr::@1
|
||||
memchr::@1: scope:[memchr] from memchr memchr::@3
|
||||
[62] memchr::ptr#2 = phi( memchr/(byte*)(void*)main::str, memchr::@3/memchr::ptr#1 )
|
||||
[62] memchr::i#2 = phi( memchr/0, memchr::@3/memchr::i#1 )
|
||||
[63] if(memchr::i#2<memchr::n#3) goto memchr::@2
|
||||
to:memchr::@return
|
||||
memchr::@return: scope:[memchr] from memchr::@1 memchr::@4
|
||||
[64] memchr::return#2 = phi( memchr::@1/(void*) 0, memchr::@4/memchr::return#8 )
|
||||
[65] return
|
||||
to:@return
|
||||
memchr::@2: scope:[memchr] from memchr::@1
|
||||
[66] if(*memchr::ptr#2!=memchr::c#4) goto memchr::@3
|
||||
to:memchr::@4
|
||||
memchr::@4: scope:[memchr] from memchr::@2
|
||||
[67] memchr::return#8 = (void*)memchr::ptr#2
|
||||
to:memchr::@return
|
||||
memchr::@3: scope:[memchr] from memchr::@2
|
||||
[68] memchr::ptr#1 = ++ memchr::ptr#2
|
||||
[69] memchr::i#1 = ++ memchr::i#2
|
||||
to:memchr::@1
|
||||
|
||||
void assert_uint(word assert_uint::expect , word assert_uint::actual , byte* assert_uint::message)
|
||||
assert_uint: scope:[assert_uint] from main::@2
|
||||
[70] if(assert_uint::expect#0!=assert_uint::actual#0) goto assert_uint::@1
|
||||
to:assert_uint::@2
|
||||
assert_uint::@2: scope:[assert_uint] from assert_uint
|
||||
[71] phi()
|
||||
[72] call textcolor
|
||||
to:assert_uint::@10
|
||||
assert_uint::@10: scope:[assert_uint] from assert_uint::@2
|
||||
[73] phi()
|
||||
[74] call cputs
|
||||
to:assert_uint::@11
|
||||
assert_uint::@11: scope:[assert_uint] from assert_uint::@10
|
||||
[75] phi()
|
||||
[76] call printf_string
|
||||
to:assert_uint::@12
|
||||
assert_uint::@12: scope:[assert_uint] from assert_uint::@11
|
||||
[77] phi()
|
||||
[78] call cputs
|
||||
to:assert_uint::@return
|
||||
assert_uint::@return: scope:[assert_uint] from assert_uint::@12 assert_uint::@9
|
||||
[79] return
|
||||
to:@return
|
||||
assert_uint::@1: scope:[assert_uint] from assert_uint
|
||||
[80] phi()
|
||||
[81] call textcolor
|
||||
to:assert_uint::@3
|
||||
assert_uint::@3: scope:[assert_uint] from assert_uint::@1
|
||||
[82] phi()
|
||||
[83] call cputs
|
||||
to:assert_uint::@4
|
||||
assert_uint::@4: scope:[assert_uint] from assert_uint::@3
|
||||
[84] phi()
|
||||
[85] call printf_uint
|
||||
to:assert_uint::@5
|
||||
assert_uint::@5: scope:[assert_uint] from assert_uint::@4
|
||||
[86] phi()
|
||||
[87] call cputs
|
||||
to:assert_uint::@6
|
||||
assert_uint::@6: scope:[assert_uint] from assert_uint::@5
|
||||
[88] printf_uint::uvalue#1 = assert_uint::actual#0
|
||||
[89] call printf_uint
|
||||
to:assert_uint::@7
|
||||
assert_uint::@7: scope:[assert_uint] from assert_uint::@6
|
||||
[90] phi()
|
||||
[91] call cputs
|
||||
to:assert_uint::@8
|
||||
assert_uint::@8: scope:[assert_uint] from assert_uint::@7
|
||||
[92] phi()
|
||||
[93] call printf_string
|
||||
to:assert_uint::@9
|
||||
assert_uint::@9: scope:[assert_uint] from assert_uint::@8
|
||||
[94] phi()
|
||||
[95] call cputs
|
||||
to:assert_uint::@return
|
||||
|
||||
void assert_ptr(void* assert_ptr::expect , void* assert_ptr::actual , byte* assert_ptr::message)
|
||||
assert_ptr: scope:[assert_ptr] from main::@4
|
||||
[96] if(assert_ptr::expect#0!=(void*)(byte*)main::ptr2#0) goto assert_ptr::@1
|
||||
to:assert_ptr::@2
|
||||
assert_ptr::@2: scope:[assert_ptr] from assert_ptr
|
||||
[97] phi()
|
||||
[98] call textcolor
|
||||
to:assert_ptr::@10
|
||||
assert_ptr::@10: scope:[assert_ptr] from assert_ptr::@2
|
||||
[99] phi()
|
||||
[100] call cputs
|
||||
to:assert_ptr::@11
|
||||
assert_ptr::@11: scope:[assert_ptr] from assert_ptr::@10
|
||||
[101] phi()
|
||||
[102] call printf_string
|
||||
to:assert_ptr::@12
|
||||
assert_ptr::@12: scope:[assert_ptr] from assert_ptr::@11
|
||||
[103] phi()
|
||||
[104] call cputs
|
||||
to:assert_ptr::@return
|
||||
assert_ptr::@return: scope:[assert_ptr] from assert_ptr::@12 assert_ptr::@9
|
||||
[105] return
|
||||
to:@return
|
||||
assert_ptr::@1: scope:[assert_ptr] from assert_ptr
|
||||
[106] phi()
|
||||
[107] call textcolor
|
||||
to:assert_ptr::@3
|
||||
assert_ptr::@3: scope:[assert_ptr] from assert_ptr::@1
|
||||
[108] phi()
|
||||
[109] call cputs
|
||||
to:assert_ptr::@4
|
||||
assert_ptr::@4: scope:[assert_ptr] from assert_ptr::@3
|
||||
[110] phi()
|
||||
[111] call printf_uint
|
||||
to:assert_ptr::@5
|
||||
assert_ptr::@5: scope:[assert_ptr] from assert_ptr::@4
|
||||
[112] phi()
|
||||
[113] call cputs
|
||||
to:assert_ptr::@6
|
||||
assert_ptr::@6: scope:[assert_ptr] from assert_ptr::@5
|
||||
[114] printf_uint::uvalue#8 = (word)(void*)(byte*)main::ptr2#0
|
||||
[115] call printf_uint
|
||||
to:assert_ptr::@7
|
||||
assert_ptr::@7: scope:[assert_ptr] from assert_ptr::@6
|
||||
[116] phi()
|
||||
[117] call cputs
|
||||
to:assert_ptr::@8
|
||||
assert_ptr::@8: scope:[assert_ptr] from assert_ptr::@7
|
||||
[118] phi()
|
||||
[119] call printf_string
|
||||
to:assert_ptr::@9
|
||||
assert_ptr::@9: scope:[assert_ptr] from assert_ptr::@8
|
||||
[120] phi()
|
||||
[121] call cputs
|
||||
to:assert_ptr::@return
|
||||
|
||||
byte textcolor(byte textcolor::color)
|
||||
textcolor: scope:[textcolor] from assert_ptr::@1 assert_ptr::@2 assert_uint::@1 assert_uint::@2
|
||||
[122] textcolor::color#4 = phi( assert_ptr::@1/RED, assert_ptr::@2/GREEN, assert_uint::@1/RED, assert_uint::@2/GREEN )
|
||||
[123] conio_textcolor = textcolor::color#4
|
||||
to:textcolor::@return
|
||||
textcolor::@return: scope:[textcolor] from textcolor
|
||||
[124] return
|
||||
to:@return
|
||||
|
||||
void cputs(to_nomodify byte* cputs::s)
|
||||
cputs: scope:[cputs] from assert_ptr::@10 assert_ptr::@12 assert_ptr::@3 assert_ptr::@5 assert_ptr::@7 assert_ptr::@9 assert_uint::@10 assert_uint::@12 assert_uint::@3 assert_uint::@5 assert_uint::@7 assert_uint::@9 printf_number_buffer::@2 printf_string::@1
|
||||
[125] cputs::s#16 = phi( assert_ptr::@10/s4, assert_ptr::@12/s3, assert_ptr::@3/assert_ptr::s, assert_ptr::@5/assert_ptr::s1, assert_ptr::@7/s2, assert_ptr::@9/s3, assert_uint::@10/s4, assert_uint::@12/s3, assert_uint::@3/assert_uint::s, assert_uint::@5/assert_uint::s1, assert_uint::@7/s2, assert_uint::@9/s3, printf_number_buffer::@2/printf_number_buffer::buffer_digits#0, printf_string::@1/cputs::s#2 )
|
||||
to:cputs::@1
|
||||
cputs::@1: scope:[cputs] from cputs cputs::@2
|
||||
[126] cputs::s#15 = phi( cputs/cputs::s#16, cputs::@2/cputs::s#0 )
|
||||
[127] cputs::c#1 = *cputs::s#15
|
||||
[128] cputs::s#0 = ++ cputs::s#15
|
||||
[129] if(0!=cputs::c#1) goto cputs::@2
|
||||
to:cputs::@return
|
||||
cputs::@return: scope:[cputs] from cputs::@1
|
||||
[130] return
|
||||
to:@return
|
||||
cputs::@2: scope:[cputs] from cputs::@1
|
||||
[131] cputc::c#0 = cputs::c#1
|
||||
[132] call cputc
|
||||
to:cputs::@1
|
||||
|
||||
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 assert_ptr::@11 assert_ptr::@8 assert_uint::@11 assert_uint::@8
|
||||
[133] printf_string::str#10 = phi( assert_ptr::@11/main::message1, assert_ptr::@8/main::message1, assert_uint::@11/main::message, assert_uint::@8/main::message )
|
||||
to:printf_string::@1
|
||||
printf_string::@1: scope:[printf_string] from printf_string
|
||||
[134] cputs::s#2 = printf_string::str#10
|
||||
[135] call cputs
|
||||
to:printf_string::@return
|
||||
printf_string::@return: scope:[printf_string] from printf_string::@1
|
||||
[136] 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_upper_case , byte printf_uint::format_radix)
|
||||
printf_uint: scope:[printf_uint] from assert_ptr::@4 assert_ptr::@6 assert_uint::@4 assert_uint::@6
|
||||
[137] printf_uint::format_radix#4 = phi( assert_ptr::@4/HEXADECIMAL, assert_ptr::@6/HEXADECIMAL, assert_uint::@4/DECIMAL, assert_uint::@6/DECIMAL )
|
||||
[137] printf_uint::uvalue#4 = phi( assert_ptr::@4/0, assert_ptr::@6/printf_uint::uvalue#8, assert_uint::@4/assert_uint::expect#0, assert_uint::@6/printf_uint::uvalue#1 )
|
||||
to:printf_uint::@1
|
||||
printf_uint::@1: scope:[printf_uint] from printf_uint
|
||||
[138] *((byte*)&printf_buffer) = 0
|
||||
[139] utoa::value#1 = printf_uint::uvalue#4
|
||||
[140] utoa::radix#0 = printf_uint::format_radix#4
|
||||
[141] call utoa
|
||||
to:printf_uint::@2
|
||||
printf_uint::@2: scope:[printf_uint] from printf_uint::@1
|
||||
[142] printf_number_buffer::buffer_sign#0 = *((byte*)&printf_buffer)
|
||||
[143] call printf_number_buffer
|
||||
to:printf_uint::@return
|
||||
printf_uint::@return: scope:[printf_uint] from printf_uint::@2
|
||||
[144] return
|
||||
to:@return
|
||||
|
||||
void cputc(byte cputc::c)
|
||||
cputc: scope:[cputc] from cputs::@2 printf_number_buffer::@3
|
||||
[145] cputc::c#3 = phi( cputs::@2/cputc::c#0, printf_number_buffer::@3/cputc::c#2 )
|
||||
[146] if(cputc::c#3=='
|
||||
') goto cputc::@1
|
||||
to:cputc::@2
|
||||
cputc::@2: scope:[cputc] from cputc
|
||||
[147] conio_line_text[conio_cursor_x] = cputc::c#3
|
||||
[148] conio_line_color[conio_cursor_x] = conio_textcolor
|
||||
[149] conio_cursor_x = ++ conio_cursor_x
|
||||
[150] if(conio_cursor_x!=$28) goto cputc::@return
|
||||
to:cputc::@3
|
||||
cputc::@3: scope:[cputc] from cputc::@2
|
||||
[151] phi()
|
||||
[152] call cputln
|
||||
to:cputc::@return
|
||||
cputc::@return: scope:[cputc] from cputc::@1 cputc::@2 cputc::@3
|
||||
[153] return
|
||||
to:@return
|
||||
cputc::@1: scope:[cputc] from cputc
|
||||
[154] phi()
|
||||
[155] call cputln
|
||||
to:cputc::@return
|
||||
|
||||
void utoa(word utoa::value , byte* utoa::buffer , byte utoa::radix)
|
||||
utoa: scope:[utoa] from printf_uint::@1
|
||||
[156] if(utoa::radix#0==DECIMAL) goto utoa::@1
|
||||
to:utoa::@2
|
||||
utoa::@2: scope:[utoa] from utoa
|
||||
[157] if(utoa::radix#0==HEXADECIMAL) goto utoa::@1
|
||||
to:utoa::@3
|
||||
utoa::@3: scope:[utoa] from utoa::@2
|
||||
[158] if(utoa::radix#0==OCTAL) goto utoa::@1
|
||||
to:utoa::@4
|
||||
utoa::@4: scope:[utoa] from utoa::@3
|
||||
[159] if(utoa::radix#0==BINARY) goto utoa::@1
|
||||
to:utoa::@5
|
||||
utoa::@5: scope:[utoa] from utoa::@4
|
||||
[160] *((byte*)&printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS) = 'e'
|
||||
[161] *((byte*)&printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS+1) = 'r'
|
||||
[162] *((byte*)&printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS+2) = 'r'
|
||||
[163] *((byte*)&printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS+3) = 0
|
||||
to:utoa::@return
|
||||
utoa::@return: scope:[utoa] from utoa::@5 utoa::@8
|
||||
[164] return
|
||||
to:@return
|
||||
utoa::@1: scope:[utoa] from utoa utoa::@2 utoa::@3 utoa::@4
|
||||
[165] utoa::digit_values#8 = phi( utoa/RADIX_DECIMAL_VALUES, utoa::@2/RADIX_HEXADECIMAL_VALUES, utoa::@3/RADIX_OCTAL_VALUES, utoa::@4/RADIX_BINARY_VALUES )
|
||||
[165] utoa::max_digits#7 = phi( utoa/5, utoa::@2/4, utoa::@3/6, utoa::@4/$10 )
|
||||
to:utoa::@6
|
||||
utoa::@6: scope:[utoa] from utoa::@1 utoa::@9
|
||||
[166] utoa::buffer#11 = phi( utoa::@9/utoa::buffer#14, utoa::@1/(byte*)&printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS )
|
||||
[166] utoa::started#2 = phi( utoa::@9/utoa::started#4, utoa::@1/0 )
|
||||
[166] utoa::value#2 = phi( utoa::@9/utoa::value#6, utoa::@1/utoa::value#1 )
|
||||
[166] utoa::digit#2 = phi( utoa::@9/utoa::digit#1, utoa::@1/0 )
|
||||
[167] utoa::$4 = utoa::max_digits#7 - 1
|
||||
[168] if(utoa::digit#2<utoa::$4) goto utoa::@7
|
||||
to:utoa::@8
|
||||
utoa::@8: scope:[utoa] from utoa::@6
|
||||
[169] utoa::$11 = (byte)utoa::value#2
|
||||
[170] *utoa::buffer#11 = DIGITS[utoa::$11]
|
||||
[171] utoa::buffer#3 = ++ utoa::buffer#11
|
||||
[172] *utoa::buffer#3 = 0
|
||||
to:utoa::@return
|
||||
utoa::@7: scope:[utoa] from utoa::@6
|
||||
[173] utoa::$10 = utoa::digit#2 << 1
|
||||
[174] utoa::digit_value#0 = utoa::digit_values#8[utoa::$10]
|
||||
[175] if(0!=utoa::started#2) goto utoa::@10
|
||||
to:utoa::@12
|
||||
utoa::@12: scope:[utoa] from utoa::@7
|
||||
[176] if(utoa::value#2>=utoa::digit_value#0) goto utoa::@10
|
||||
to:utoa::@9
|
||||
utoa::@9: scope:[utoa] from utoa::@11 utoa::@12
|
||||
[177] utoa::buffer#14 = phi( utoa::@12/utoa::buffer#11, utoa::@11/utoa::buffer#4 )
|
||||
[177] utoa::started#4 = phi( utoa::@12/utoa::started#2, utoa::@11/1 )
|
||||
[177] utoa::value#6 = phi( utoa::@12/utoa::value#2, utoa::@11/utoa::value#0 )
|
||||
[178] utoa::digit#1 = ++ utoa::digit#2
|
||||
to:utoa::@6
|
||||
utoa::@10: scope:[utoa] from utoa::@12 utoa::@7
|
||||
[179] utoa_append::buffer#0 = utoa::buffer#11
|
||||
[180] utoa_append::value#0 = utoa::value#2
|
||||
[181] utoa_append::sub#0 = utoa::digit_value#0
|
||||
[182] call utoa_append
|
||||
[183] utoa_append::return#0 = utoa_append::value#2
|
||||
to:utoa::@11
|
||||
utoa::@11: scope:[utoa] from utoa::@10
|
||||
[184] utoa::value#0 = utoa_append::return#0
|
||||
[185] utoa::buffer#4 = ++ utoa::buffer#11
|
||||
to:utoa::@9
|
||||
|
||||
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_upper_case , byte printf_number_buffer::format_radix)
|
||||
printf_number_buffer: scope:[printf_number_buffer] from printf_uint::@2
|
||||
[186] phi()
|
||||
to:printf_number_buffer::@1
|
||||
printf_number_buffer::@1: scope:[printf_number_buffer] from printf_number_buffer
|
||||
[187] if(0==printf_number_buffer::buffer_sign#0) goto printf_number_buffer::@2
|
||||
to:printf_number_buffer::@3
|
||||
printf_number_buffer::@3: scope:[printf_number_buffer] from printf_number_buffer::@1
|
||||
[188] cputc::c#2 = printf_number_buffer::buffer_sign#0
|
||||
[189] call cputc
|
||||
to:printf_number_buffer::@2
|
||||
printf_number_buffer::@2: scope:[printf_number_buffer] from printf_number_buffer::@1 printf_number_buffer::@3
|
||||
[190] phi()
|
||||
[191] call cputs
|
||||
to:printf_number_buffer::@return
|
||||
printf_number_buffer::@return: scope:[printf_number_buffer] from printf_number_buffer::@2
|
||||
[192] return
|
||||
to:@return
|
||||
|
||||
void cputln()
|
||||
cputln: scope:[cputln] from cputc::@1 cputc::@3
|
||||
[193] conio_line_text = conio_line_text + $28
|
||||
[194] conio_line_color = conio_line_color + $28
|
||||
[195] conio_cursor_x = 0
|
||||
[196] conio_cursor_y = ++ conio_cursor_y
|
||||
[197] call cscroll
|
||||
to:cputln::@return
|
||||
cputln::@return: scope:[cputln] from cputln
|
||||
[198] return
|
||||
to:@return
|
||||
|
||||
word utoa_append(byte* utoa_append::buffer , word utoa_append::value , word utoa_append::sub)
|
||||
utoa_append: scope:[utoa_append] from utoa::@10
|
||||
[199] phi()
|
||||
to:utoa_append::@1
|
||||
utoa_append::@1: scope:[utoa_append] from utoa_append utoa_append::@2
|
||||
[200] utoa_append::digit#2 = phi( utoa_append/0, utoa_append::@2/utoa_append::digit#1 )
|
||||
[200] utoa_append::value#2 = phi( utoa_append/utoa_append::value#0, utoa_append::@2/utoa_append::value#1 )
|
||||
[201] if(utoa_append::value#2>=utoa_append::sub#0) goto utoa_append::@2
|
||||
to:utoa_append::@3
|
||||
utoa_append::@3: scope:[utoa_append] from utoa_append::@1
|
||||
[202] *utoa_append::buffer#0 = DIGITS[utoa_append::digit#2]
|
||||
to:utoa_append::@return
|
||||
utoa_append::@return: scope:[utoa_append] from utoa_append::@3
|
||||
[203] return
|
||||
to:@return
|
||||
utoa_append::@2: scope:[utoa_append] from utoa_append::@1
|
||||
[204] utoa_append::digit#1 = ++ utoa_append::digit#2
|
||||
[205] utoa_append::value#1 = utoa_append::value#2 - utoa_append::sub#0
|
||||
to:utoa_append::@1
|
||||
|
||||
void cscroll()
|
||||
cscroll: scope:[cscroll] from cputln
|
||||
[206] if(conio_cursor_y!=$19) goto cscroll::@return
|
||||
to:cscroll::@1
|
||||
cscroll::@1: scope:[cscroll] from cscroll
|
||||
[207] phi()
|
||||
[208] call memcpy
|
||||
to:cscroll::@2
|
||||
cscroll::@2: scope:[cscroll] from cscroll::@1
|
||||
[209] phi()
|
||||
[210] call memcpy
|
||||
to:cscroll::@3
|
||||
cscroll::@3: scope:[cscroll] from cscroll::@2
|
||||
[211] phi()
|
||||
[212] call memset
|
||||
to:cscroll::@4
|
||||
cscroll::@4: scope:[cscroll] from cscroll::@3
|
||||
[213] memset::c#1 = conio_textcolor
|
||||
[214] call memset
|
||||
to:cscroll::@5
|
||||
cscroll::@5: scope:[cscroll] from cscroll::@4
|
||||
[215] conio_line_text = conio_line_text - $28
|
||||
[216] conio_line_color = conio_line_color - $28
|
||||
[217] conio_cursor_y = -- conio_cursor_y
|
||||
to:cscroll::@return
|
||||
cscroll::@return: scope:[cscroll] from cscroll cscroll::@5
|
||||
[218] return
|
||||
to:@return
|
||||
|
||||
void* memcpy(void* memcpy::destination , void* memcpy::source , word memcpy::num)
|
||||
memcpy: scope:[memcpy] from cscroll::@1 cscroll::@2
|
||||
[219] memcpy::destination#2 = phi( cscroll::@1/(void*)DEFAULT_SCREEN, cscroll::@2/(void*)COLORRAM )
|
||||
[219] memcpy::source#2 = phi( cscroll::@1/(void*)DEFAULT_SCREEN+$28, cscroll::@2/(void*)COLORRAM+$28 )
|
||||
[220] memcpy::src_end#0 = (byte*)memcpy::source#2 + (word)$19*$28-$28
|
||||
[221] memcpy::src#4 = (byte*)memcpy::source#2
|
||||
[222] memcpy::dst#4 = (byte*)memcpy::destination#2
|
||||
to:memcpy::@1
|
||||
memcpy::@1: scope:[memcpy] from memcpy memcpy::@2
|
||||
[223] memcpy::dst#2 = phi( memcpy/memcpy::dst#4, memcpy::@2/memcpy::dst#1 )
|
||||
[223] memcpy::src#2 = phi( memcpy/memcpy::src#4, memcpy::@2/memcpy::src#1 )
|
||||
[224] if(memcpy::src#2!=memcpy::src_end#0) goto memcpy::@2
|
||||
to:memcpy::@return
|
||||
memcpy::@return: scope:[memcpy] from memcpy::@1
|
||||
[225] return
|
||||
to:@return
|
||||
memcpy::@2: scope:[memcpy] from memcpy::@1
|
||||
[226] *memcpy::dst#2 = *memcpy::src#2
|
||||
[227] memcpy::dst#1 = ++ memcpy::dst#2
|
||||
[228] memcpy::src#1 = ++ memcpy::src#2
|
||||
to:memcpy::@1
|
||||
|
||||
void* memset(void* memset::str , byte memset::c , word memset::num)
|
||||
memset: scope:[memset] from cscroll::@3 cscroll::@4
|
||||
[229] memset::c#4 = phi( cscroll::@3/' ', cscroll::@4/memset::c#1 )
|
||||
[229] memset::str#3 = phi( cscroll::@3/(void*)DEFAULT_SCREEN+(word)$19*$28-$28, cscroll::@4/(void*)COLORRAM+(word)$19*$28-$28 )
|
||||
to:memset::@1
|
||||
memset::@1: scope:[memset] from memset
|
||||
[230] memset::end#0 = (byte*)memset::str#3 + $28
|
||||
[231] memset::dst#4 = (byte*)memset::str#3
|
||||
to:memset::@2
|
||||
memset::@2: scope:[memset] from memset::@1 memset::@3
|
||||
[232] memset::dst#2 = phi( memset::@1/memset::dst#4, memset::@3/memset::dst#1 )
|
||||
[233] if(memset::dst#2!=memset::end#0) goto memset::@3
|
||||
to:memset::@return
|
||||
memset::@return: scope:[memset] from memset::@2
|
||||
[234] return
|
||||
to:@return
|
||||
memset::@3: scope:[memset] from memset::@2
|
||||
[235] *memset::dst#2 = memset::c#4
|
||||
[236] memset::dst#1 = ++ memset::dst#2
|
||||
to:memset::@2
|
8641
src/test/ref/stdlib-string-memchr-1.log
Normal file
8641
src/test/ref/stdlib-string-memchr-1.log
Normal file
File diff suppressed because one or more lines are too long
265
src/test/ref/stdlib-string-memchr-1.sym
Normal file
265
src/test/ref/stdlib-string-memchr-1.sym
Normal file
@ -0,0 +1,265 @@
|
||||
const byte BINARY = 2
|
||||
const nomodify byte* COLORRAM = (byte*) 55296
|
||||
const byte DECIMAL = $a
|
||||
const nomodify byte* DEFAULT_SCREEN = (byte*) 1024
|
||||
const byte* DIGITS[] = "0123456789abcdef"z
|
||||
const nomodify byte GREEN = 5
|
||||
const byte HEXADECIMAL = $10
|
||||
const nomodify byte LIGHT_BLUE = $e
|
||||
const byte OCTAL = 8
|
||||
const byte OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS = 1
|
||||
const byte RADIX::BINARY = 2
|
||||
const byte RADIX::DECIMAL = $a
|
||||
const byte RADIX::HEXADECIMAL = $10
|
||||
const byte RADIX::OCTAL = 8
|
||||
const word* RADIX_BINARY_VALUES[] = { $8000, $4000, $2000, $1000, $800, $400, $200, $100, $80, $40, $20, $10, 8, 4, 2 }
|
||||
const word* RADIX_DECIMAL_VALUES[] = { $2710, $3e8, $64, $a }
|
||||
const word* RADIX_HEXADECIMAL_VALUES[] = { $1000, $100, $10 }
|
||||
const word* RADIX_OCTAL_VALUES[] = { $8000, $1000, $200, $40, 8 }
|
||||
const nomodify byte RED = 2
|
||||
const byte SIZEOF_STRUCT_PRINTF_BUFFER_NUMBER = $c
|
||||
void __start()
|
||||
void assert_ptr(void* assert_ptr::expect , void* assert_ptr::actual , byte* assert_ptr::message)
|
||||
void* assert_ptr::actual
|
||||
void* assert_ptr::expect
|
||||
const void* assert_ptr::expect#0 expect = (void*) 0
|
||||
byte* assert_ptr::message
|
||||
const byte* assert_ptr::s[$1b] = "Assert failed. expected:0x"
|
||||
const byte* assert_ptr::s1[$b] = " actual:0x"
|
||||
void assert_uint(word assert_uint::expect , word assert_uint::actual , byte* assert_uint::message)
|
||||
word assert_uint::actual
|
||||
word assert_uint::actual#0 actual zp[2]:2 21.299999999999997
|
||||
word assert_uint::expect
|
||||
const word assert_uint::expect#0 expect = 8
|
||||
byte* assert_uint::message
|
||||
const byte* assert_uint::s[$19] = "Assert failed. expected:"
|
||||
const byte* assert_uint::s1[9] = " actual:"
|
||||
void clrscr()
|
||||
byte clrscr::c
|
||||
byte clrscr::c#1 reg byte y 20002.0
|
||||
byte clrscr::c#2 reg byte y 12501.25
|
||||
byte clrscr::l
|
||||
byte clrscr::l#1 reg byte x 2002.0
|
||||
byte clrscr::l#2 reg byte x 333.6666666666667
|
||||
byte* clrscr::line_cols
|
||||
byte* clrscr::line_cols#1 line_cols zp[2]:8 1001.0
|
||||
byte* clrscr::line_cols#5 line_cols zp[2]:8 1500.375
|
||||
byte* clrscr::line_text
|
||||
byte* clrscr::line_text#1 line_text zp[2]:4 667.3333333333334
|
||||
byte* clrscr::line_text#5 line_text zp[2]:4 1714.7142857142858
|
||||
void conio_c64_init()
|
||||
const nomodify byte* conio_c64_init::BASIC_CURSOR_LINE = (byte*) 214
|
||||
byte conio_c64_init::line
|
||||
byte conio_c64_init::line#0 reg byte x 11.0
|
||||
byte conio_c64_init::line#2 reg byte x 22.0
|
||||
byte conio_cursor_x loadstore zp[1]:12 1428573.4285714284
|
||||
byte conio_cursor_y loadstore zp[1]:13 2.6446282719008267E7
|
||||
byte* conio_line_color loadstore zp[2]:16 1.857143032773109E7
|
||||
byte* conio_line_text loadstore zp[2]:14 1.841666840833333E7
|
||||
byte conio_textcolor loadstore zp[1]:18 8859745.666666668
|
||||
void cputc(byte cputc::c)
|
||||
byte cputc::c
|
||||
byte cputc::c#0 reg byte a 2000002.0
|
||||
byte cputc::c#2 reg byte a 20002.0
|
||||
byte cputc::c#3 reg byte a 1.0505002E7
|
||||
void cputln()
|
||||
void cputs(to_nomodify byte* cputs::s)
|
||||
byte cputs::c
|
||||
byte cputs::c#1 reg byte a 1000001.0
|
||||
to_nomodify byte* cputs::s
|
||||
to_nomodify byte* cputs::s#0 s zp[2]:4 500000.5
|
||||
to_nomodify byte* cputs::s#15 s zp[2]:4 1550002.0
|
||||
to_nomodify byte* cputs::s#16 s zp[2]:4 101002.0
|
||||
to_nomodify byte* cputs::s#2 s zp[2]:4 2002.0
|
||||
void cscroll()
|
||||
void gotoxy(byte gotoxy::x , byte gotoxy::y)
|
||||
byte*~ gotoxy::$5 zp[2]:23 202.0
|
||||
byte*~ gotoxy::$6 zp[2]:19 202.0
|
||||
word~ gotoxy::$7 zp[2]:19 151.5
|
||||
word~ gotoxy::$8 zp[2]:21 202.0
|
||||
word~ gotoxy::$9 zp[2]:19 202.0
|
||||
word gotoxy::line_offset
|
||||
word gotoxy::line_offset#0 line_offset zp[2]:19 101.0
|
||||
byte gotoxy::x
|
||||
const byte gotoxy::x#2 x = 0
|
||||
byte gotoxy::y
|
||||
byte gotoxy::y#2 reg byte x 71.0
|
||||
byte gotoxy::y#4 reg byte x 67.33333333333333
|
||||
void main()
|
||||
const byte* main::message[$a] = "finding a"
|
||||
const byte* main::message1[$e] = "not finding a"
|
||||
byte* main::ptr
|
||||
void* main::ptr#0 ptr zp[2]:2 11.0
|
||||
byte* main::ptr2
|
||||
void* main::ptr2#0 ptr2 zp[2]:2 1.1
|
||||
const byte* main::str = "this is a test"
|
||||
void* memchr(to_nomodify void* memchr::str , byte memchr::c , word memchr::n)
|
||||
byte memchr::c
|
||||
byte memchr::c#4 c zp[1]:6 166.83333333333334
|
||||
word memchr::i
|
||||
word memchr::i#1 i zp[2]:8 2002.0
|
||||
word memchr::i#2 i zp[2]:8 750.75
|
||||
word memchr::n
|
||||
word memchr::n#3 n zp[2]:4 166.83333333333334
|
||||
byte* memchr::ptr
|
||||
byte* memchr::ptr#1 ptr zp[2]:2 1001.0
|
||||
byte* memchr::ptr#2 ptr zp[2]:2 1001.0
|
||||
void* memchr::return
|
||||
void* memchr::return#2 return zp[2]:2 30.75
|
||||
void* memchr::return#3 return zp[2]:2 22.0
|
||||
void* memchr::return#4 return zp[2]:2 22.0
|
||||
void* memchr::return#8 return zp[2]:2 202.0
|
||||
to_nomodify void* memchr::str
|
||||
void* memcpy(void* memcpy::destination , void* memcpy::source , word memcpy::num)
|
||||
void* memcpy::destination
|
||||
void* memcpy::destination#2 destination zp[2]:10
|
||||
byte* memcpy::dst
|
||||
byte* memcpy::dst#1 dst zp[2]:10 1.000000000001E12
|
||||
byte* memcpy::dst#2 dst zp[2]:10 1.0033333333346667E12
|
||||
byte* memcpy::dst#4 dst zp[2]:10 2.0000000002E10
|
||||
word memcpy::num
|
||||
void* memcpy::return
|
||||
void* memcpy::source
|
||||
void* memcpy::source#2 source zp[2]:8
|
||||
byte* memcpy::src
|
||||
byte* memcpy::src#1 src zp[2]:8 2.000000000002E12
|
||||
byte* memcpy::src#2 src zp[2]:8 1.00250000000125E12
|
||||
byte* memcpy::src#4 src zp[2]:8 1.0000000001E10
|
||||
byte* memcpy::src_end
|
||||
byte* memcpy::src_end#0 src_end zp[2]:27 1.2625000000025E11
|
||||
void* memset(void* memset::str , byte memset::c , word memset::num)
|
||||
byte memset::c
|
||||
byte memset::c#1 reg byte x 2.000000002E9
|
||||
byte memset::c#4 reg byte x 1.430000000002857E11
|
||||
byte* memset::dst
|
||||
byte* memset::dst#1 dst zp[2]:25 2.000000000002E12
|
||||
byte* memset::dst#2 dst zp[2]:25 1.3366666666683335E12
|
||||
byte* memset::dst#4 dst zp[2]:25 2.0000000002E10
|
||||
byte* memset::end
|
||||
byte* memset::end#0 end zp[2]:27 1.683333333336667E11
|
||||
word memset::num
|
||||
void* memset::return
|
||||
void* memset::str
|
||||
void* memset::str#3 str zp[2]:25
|
||||
struct printf_buffer_number printf_buffer loadstore mem[12] = {}
|
||||
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_upper_case , byte printf_number_buffer::format_radix)
|
||||
struct printf_buffer_number printf_number_buffer::buffer
|
||||
byte* printf_number_buffer::buffer_digits
|
||||
const byte* printf_number_buffer::buffer_digits#0 buffer_digits = (byte*)&printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
|
||||
byte printf_number_buffer::buffer_sign
|
||||
byte printf_number_buffer::buffer_sign#0 reg byte a 7001.0
|
||||
struct printf_format_number printf_number_buffer::format
|
||||
byte printf_number_buffer::format_justify_left
|
||||
byte printf_number_buffer::format_min_length
|
||||
byte printf_number_buffer::format_radix
|
||||
byte printf_number_buffer::format_sign_always
|
||||
byte printf_number_buffer::format_upper_case
|
||||
byte printf_number_buffer::format_zero_padding
|
||||
signed byte printf_number_buffer::len
|
||||
signed byte printf_number_buffer::padding
|
||||
void printf_string(byte* printf_string::str , byte printf_string::format_min_length , byte printf_string::format_justify_left)
|
||||
struct printf_format_string printf_string::format
|
||||
byte printf_string::format_justify_left
|
||||
byte printf_string::format_min_length
|
||||
signed byte printf_string::len
|
||||
signed byte printf_string::padding
|
||||
byte* printf_string::str
|
||||
byte* printf_string::str#10 str zp[2]:4 1001.0
|
||||
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_upper_case , byte printf_uint::format_radix)
|
||||
struct printf_format_number printf_uint::format
|
||||
byte printf_uint::format_justify_left
|
||||
byte printf_uint::format_min_length
|
||||
byte printf_uint::format_radix
|
||||
byte printf_uint::format_radix#4 reg byte x 333.6666666666667
|
||||
byte printf_uint::format_sign_always
|
||||
byte printf_uint::format_upper_case
|
||||
byte printf_uint::format_zero_padding
|
||||
word printf_uint::uvalue
|
||||
word printf_uint::uvalue#1 uvalue zp[2]:4 202.0
|
||||
word printf_uint::uvalue#4 uvalue zp[2]:4 601.5
|
||||
word printf_uint::uvalue#8 uvalue zp[2]:4 202.0
|
||||
const byte* s2[3] = ". "
|
||||
const byte* s3[2] = "
|
||||
"
|
||||
const byte* s4[5] = "ok! "
|
||||
byte textcolor(byte textcolor::color)
|
||||
byte textcolor::color
|
||||
byte textcolor::color#4 reg byte a 1001.0
|
||||
byte textcolor::old
|
||||
byte textcolor::return
|
||||
void utoa(word utoa::value , byte* utoa::buffer , byte utoa::radix)
|
||||
byte~ utoa::$10 reg byte a 200002.0
|
||||
byte~ utoa::$11 reg byte a 20002.0
|
||||
byte~ utoa::$4 reg byte a 200002.0
|
||||
byte* utoa::buffer
|
||||
byte* utoa::buffer#11 buffer zp[2]:10 28000.4
|
||||
byte* utoa::buffer#14 buffer zp[2]:10 150001.5
|
||||
byte* utoa::buffer#3 buffer zp[2]:10 20002.0
|
||||
byte* utoa::buffer#4 buffer zp[2]:10 200002.0
|
||||
byte utoa::digit
|
||||
byte utoa::digit#1 digit zp[1]:7 200002.0
|
||||
byte utoa::digit#2 digit zp[1]:7 26666.933333333334
|
||||
word utoa::digit_value
|
||||
word utoa::digit_value#0 digit_value zp[2]:25 60000.600000000006
|
||||
word* utoa::digit_values
|
||||
word* utoa::digit_values#8 digit_values zp[2]:8 5882.411764705882
|
||||
byte utoa::max_digits
|
||||
byte utoa::max_digits#7 max_digits zp[1]:6 5882.411764705882
|
||||
byte utoa::radix
|
||||
byte utoa::radix#0 reg byte x 10251.25
|
||||
byte utoa::started
|
||||
byte utoa::started#2 reg byte x 42857.57142857143
|
||||
byte utoa::started#4 reg byte x 100001.0
|
||||
word utoa::value
|
||||
word utoa::value#0 value zp[2]:4 100001.0
|
||||
word utoa::value#1 value zp[2]:4 1571.7142857142858
|
||||
word utoa::value#2 value zp[2]:4 51250.625
|
||||
word utoa::value#6 value zp[2]:4 150001.5
|
||||
word utoa_append(byte* utoa_append::buffer , word utoa_append::value , word utoa_append::sub)
|
||||
byte* utoa_append::buffer
|
||||
byte* utoa_append::buffer#0 buffer zp[2]:10 137500.25
|
||||
byte utoa_append::digit
|
||||
byte utoa_append::digit#1 reg byte x 1.00000001E8
|
||||
byte utoa_append::digit#2 reg byte x 1.005000015E8
|
||||
word utoa_append::return
|
||||
word utoa_append::return#0 return zp[2]:4 200002.0
|
||||
word utoa_append::sub
|
||||
word utoa_append::sub#0 sub zp[2]:25 3.33500005E7
|
||||
word utoa_append::value
|
||||
word utoa_append::value#0 value zp[2]:4 366667.3333333334
|
||||
word utoa_append::value#1 value zp[2]:4 2.00000002E8
|
||||
word utoa_append::value#2 value zp[2]:4 5.018333416666667E7
|
||||
|
||||
reg byte x [ conio_c64_init::line#2 conio_c64_init::line#0 ]
|
||||
reg byte x [ gotoxy::y#4 gotoxy::y#2 ]
|
||||
reg byte x [ clrscr::l#2 clrscr::l#1 ]
|
||||
reg byte y [ clrscr::c#2 clrscr::c#1 ]
|
||||
zp[2]:2 [ memchr::ptr#2 memchr::ptr#1 memchr::return#2 memchr::return#8 memchr::return#3 main::ptr#0 memchr::return#4 main::ptr2#0 assert_uint::actual#0 ]
|
||||
reg byte a [ textcolor::color#4 ]
|
||||
zp[2]:4 [ printf_uint::uvalue#4 printf_uint::uvalue#8 printf_uint::uvalue#1 utoa::value#2 utoa::value#6 utoa::value#1 utoa::value#0 utoa_append::value#2 utoa_append::value#0 utoa_append::value#1 utoa_append::return#0 cputs::s#15 cputs::s#16 cputs::s#2 cputs::s#0 printf_string::str#10 memchr::n#3 clrscr::line_text#5 clrscr::line_text#1 ]
|
||||
reg byte x [ printf_uint::format_radix#4 ]
|
||||
reg byte a [ cputc::c#3 cputc::c#0 cputc::c#2 ]
|
||||
zp[1]:6 [ utoa::max_digits#7 memchr::c#4 ]
|
||||
zp[1]:7 [ utoa::digit#2 utoa::digit#1 ]
|
||||
reg byte x [ utoa::started#2 utoa::started#4 ]
|
||||
reg byte x [ utoa_append::digit#2 utoa_append::digit#1 ]
|
||||
zp[2]:8 [ memcpy::source#2 memcpy::src#2 memcpy::src#4 memcpy::src#1 utoa::digit_values#8 memchr::i#2 memchr::i#1 clrscr::line_cols#5 clrscr::line_cols#1 ]
|
||||
zp[2]:10 [ memcpy::destination#2 memcpy::dst#2 memcpy::dst#4 memcpy::dst#1 utoa::buffer#11 utoa::buffer#14 utoa::buffer#4 utoa::buffer#3 utoa_append::buffer#0 ]
|
||||
reg byte x [ memset::c#4 memset::c#1 ]
|
||||
zp[1]:12 [ conio_cursor_x ]
|
||||
zp[1]:13 [ conio_cursor_y ]
|
||||
zp[2]:14 [ conio_line_text ]
|
||||
zp[2]:16 [ conio_line_color ]
|
||||
zp[1]:18 [ conio_textcolor ]
|
||||
zp[2]:19 [ gotoxy::$7 gotoxy::$9 gotoxy::line_offset#0 gotoxy::$6 ]
|
||||
zp[2]:21 [ gotoxy::$8 ]
|
||||
zp[2]:23 [ gotoxy::$5 ]
|
||||
reg byte a [ cputs::c#1 ]
|
||||
reg byte x [ utoa::radix#0 ]
|
||||
reg byte a [ printf_number_buffer::buffer_sign#0 ]
|
||||
reg byte a [ utoa::$4 ]
|
||||
reg byte a [ utoa::$11 ]
|
||||
reg byte a [ utoa::$10 ]
|
||||
zp[2]:25 [ utoa::digit_value#0 utoa_append::sub#0 memset::str#3 memset::dst#2 memset::dst#4 memset::dst#1 ]
|
||||
zp[2]:27 [ memset::end#0 memcpy::src_end#0 ]
|
||||
mem[12] [ printf_buffer ]
|
Loading…
x
Reference in New Issue
Block a user