1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-11-22 16:33:48 +00:00

Fixed atoi().

This commit is contained in:
jespergravgaard 2020-04-25 21:25:27 +02:00
parent ad76f3a9ed
commit 0da4300069
6 changed files with 63 additions and 90 deletions

View File

@ -0,0 +1,7 @@
clc
lda {m1}
adc ({z2}),y
sta {m1}
bcc !+
inc {m1}+1
!:

View File

@ -1,7 +0,0 @@
clc
lda {m2}
adc {m3},x
sta {m1}
lda {m2}+1
adc {m3}+1,x
sta {m1}+1

View File

@ -1,7 +0,0 @@
clc
lda {m2}
adc {m3},y
sta {m1}
lda {m2}+1
adc {m3}+1,y
sta {m1}+1

View File

@ -0,0 +1,7 @@
clc
lda {m2}
adc ({z3}),y
sta {m1}
bcc !+
inc {m2}+1
!:

View File

@ -509,7 +509,13 @@ atoi: {
asl.z __3 asl.z __3
rol.z __3+1 rol.z __3+1
// res * 10 + str[i] // res * 10 + str[i]
.assert "Missing ASM fragment Fragment not found vwsz1=vwsz1_plus_pbuz2_derefidx_vbuyy. Attempted variations vwsz1=vwsz1_plus_pbuz2_derefidx_vbuyy ", 0, 1 clc
lda.z __4
adc (str),y
sta.z __4
bcc !+
inc.z __4+1
!:
// res = res * 10 + str[i] - '0' // res = res * 10 + str[i] - '0'
sec sec
lda.z res lda.z res

View File

@ -4277,14 +4277,14 @@ atoi: {
rol rol
sta.z __3+1 sta.z __3+1
// [131] (signed word~) atoi::$4 ← (signed word~) atoi::$3 + *((to_nomodify byte*) atoi::str#2 + (byte) atoi::i#4) -- vwsz1=vwsz2_plus_pbuz3_derefidx_vbuz4 // [131] (signed word~) atoi::$4 ← (signed word~) atoi::$3 + *((to_nomodify byte*) atoi::str#2 + (byte) atoi::i#4) -- vwsz1=vwsz2_plus_pbuz3_derefidx_vbuz4
ldx.z i ldy.z i
clc clc
lda.z __3 lda.z __3
adc.z str,x adc (str),y
sta.z __4 sta.z __4
lda.z __3+1 bcc !+
adc.z str+1,x inc.z __3+1
sta.z __4+1 !:
// [132] (signed word) atoi::res#1 ← (signed word~) atoi::$4 - (byte) '0' -- vwsz1=vwsz2_minus_vbuc1 // [132] (signed word) atoi::res#1 ← (signed word~) atoi::$4 - (byte) '0' -- vwsz1=vwsz2_minus_vbuc1
sec sec
lda.z __4 lda.z __4
@ -4533,29 +4533,29 @@ Uplift Scope [printf_format_string]
Uplift Scope [printf_cls] Uplift Scope [printf_cls]
Uplift Scope [main] Uplift Scope [main]
Uplifting [memcpy] best 24392 combination zp[2]:12 [ memcpy::src#2 memcpy::src#1 ] zp[2]:14 [ memcpy::dst#2 memcpy::dst#1 ] Uplifting [memcpy] best 24382 combination zp[2]:12 [ memcpy::src#2 memcpy::src#1 ] zp[2]:14 [ memcpy::dst#2 memcpy::dst#1 ]
Uplifting [memset] best 24286 combination zp[2]:10 [ memset::dst#2 memset::dst#4 memset::dst#1 ] zp[2]:48 [ memset::end#0 ] reg byte x [ memset::c#4 ] zp[2]:5 [ memset::num#2 ] zp[2]:7 [ memset::str#3 ] Uplifting [memset] best 24276 combination zp[2]:10 [ memset::dst#2 memset::dst#4 memset::dst#1 ] zp[2]:48 [ memset::end#0 ] reg byte x [ memset::c#4 ] zp[2]:5 [ memset::num#2 ] zp[2]:7 [ memset::str#3 ]
Uplifting [utoa_append] best 23683 combination zp[2]:24 [ utoa_append::value#2 utoa_append::value#0 utoa_append::value#1 ] reg byte x [ utoa_append::digit#2 utoa_append::digit#1 ] zp[2]:59 [ utoa_append::sub#0 ] zp[2]:61 [ utoa_append::return#0 ] zp[2]:57 [ utoa_append::buffer#0 ] Uplifting [utoa_append] best 23673 combination zp[2]:24 [ utoa_append::value#2 utoa_append::value#0 utoa_append::value#1 ] reg byte x [ utoa_append::digit#2 utoa_append::digit#1 ] zp[2]:59 [ utoa_append::sub#0 ] zp[2]:61 [ utoa_append::return#0 ] zp[2]:57 [ utoa_append::buffer#0 ]
Uplifting [printf_ln] best 23683 combination zp[2]:42 [ printf_ln::$0 ] zp[2]:44 [ printf_ln::$1 ] Uplifting [printf_ln] best 23673 combination zp[2]:42 [ printf_ln::$0 ] zp[2]:44 [ printf_ln::$1 ]
Uplifting [printf_char] best 23647 combination zp[2]:46 [ printf_char::$6 ] reg byte a [ printf_char::ch#3 printf_char::ch#2 printf_char::ch#1 ] Uplifting [printf_char] best 23637 combination zp[2]:46 [ printf_char::$6 ] reg byte a [ printf_char::ch#3 printf_char::ch#2 printf_char::ch#1 ]
Uplifting [printf_str] best 23527 combination zp[2]:2 [ printf_str::str#4 printf_str::str#6 printf_str::str#0 ] reg byte a [ printf_str::ch#0 ] Uplifting [printf_str] best 23517 combination zp[2]:2 [ printf_str::str#4 printf_str::str#6 printf_str::str#0 ] reg byte a [ printf_str::ch#0 ]
Uplifting [] best 23527 combination zp[2]:35 [ printf_cursor_ptr ] zp[1]:34 [ printf_cursor_y ] zp[1]:33 [ printf_cursor_x ] mem[12] [ printf_buffer ] Uplifting [] best 23517 combination zp[2]:35 [ printf_cursor_ptr ] zp[1]:34 [ printf_cursor_y ] zp[1]:33 [ printf_cursor_x ] mem[12] [ printf_buffer ]
Uplifting [utoa] best 23393 combination zp[2]:22 [ utoa::buffer#11 utoa::buffer#14 utoa::buffer#4 ] zp[2]:19 [ utoa::value#2 utoa::value#6 utoa::value#1 utoa::value#0 ] zp[1]:18 [ utoa::digit#2 utoa::digit#1 ] reg byte a [ utoa::$10 ] reg byte x [ utoa::started#2 utoa::started#4 ] zp[2]:55 [ utoa::digit_value#0 ] reg byte a [ utoa::$11 ] zp[2]:52 [ utoa::buffer#3 ] Uplifting [utoa] best 23383 combination zp[2]:22 [ utoa::buffer#11 utoa::buffer#14 utoa::buffer#4 ] zp[2]:19 [ utoa::value#2 utoa::value#6 utoa::value#1 utoa::value#0 ] zp[1]:18 [ utoa::digit#2 utoa::digit#1 ] reg byte a [ utoa::$10 ] reg byte x [ utoa::started#2 utoa::started#4 ] zp[2]:55 [ utoa::digit_value#0 ] reg byte a [ utoa::$11 ] zp[2]:52 [ utoa::buffer#3 ]
Uplifting [atoi] best 23190 combination reg byte y [ atoi::i#4 atoi::i#2 ] zp[2]:31 [ atoi::return#2 atoi::return#0 atoi::res#2 atoi::res#1 ] zp[2]:63 [ atoi::$8 ] zp[2]:65 [ atoi::$9 ] zp[2]:67 [ atoi::$3 ] zp[2]:69 [ atoi::$4 ] reg byte x [ atoi::negative#2 ] zp[2]:27 [ atoi::str#2 ] zp[2]:37 [ atoi::return#3 ] zp[2]:39 [ atoi::return#4 ] Uplifting [atoi] best 23170 combination reg byte y [ atoi::i#4 atoi::i#2 ] zp[2]:31 [ atoi::return#2 atoi::return#0 atoi::res#2 atoi::res#1 ] zp[2]:63 [ atoi::$8 ] zp[2]:65 [ atoi::$9 ] zp[2]:67 [ atoi::$3 ] zp[2]:69 [ atoi::$4 ] reg byte x [ atoi::negative#2 ] zp[2]:27 [ atoi::str#2 ] zp[2]:37 [ atoi::return#3 ] zp[2]:39 [ atoi::return#4 ]
Uplifting [printf_number_buffer] best 23181 combination reg byte a [ printf_number_buffer::buffer_sign#0 ] Uplifting [printf_number_buffer] best 23161 combination reg byte a [ printf_number_buffer::buffer_sign#0 ]
Uplifting [printf_sint] best 23181 combination zp[2]:16 [ printf_sint::value#5 printf_sint::value#0 printf_sint::value#3 printf_sint::value#1 printf_sint::value#2 ] Uplifting [printf_sint] best 23161 combination zp[2]:16 [ printf_sint::value#5 printf_sint::value#0 printf_sint::value#3 printf_sint::value#1 printf_sint::value#2 ]
Uplifting [RADIX] best 23181 combination Uplifting [RADIX] best 23161 combination
Uplifting [printf_format_number] best 23181 combination Uplifting [printf_format_number] best 23161 combination
Uplifting [printf_buffer_number] best 23181 combination Uplifting [printf_buffer_number] best 23161 combination
Uplifting [printf_format_string] best 23181 combination Uplifting [printf_format_string] best 23161 combination
Uplifting [printf_cls] best 23181 combination Uplifting [printf_cls] best 23161 combination
Uplifting [main] best 23181 combination Uplifting [main] best 23161 combination
Attempting to uplift remaining variables inzp[1]:34 [ printf_cursor_y ] Attempting to uplift remaining variables inzp[1]:34 [ printf_cursor_y ]
Uplifting [] best 23181 combination zp[1]:34 [ printf_cursor_y ] Uplifting [] best 23161 combination zp[1]:34 [ printf_cursor_y ]
Attempting to uplift remaining variables inzp[1]:33 [ printf_cursor_x ] Attempting to uplift remaining variables inzp[1]:33 [ printf_cursor_x ]
Uplifting [] best 23181 combination zp[1]:33 [ printf_cursor_x ] Uplifting [] best 23161 combination zp[1]:33 [ printf_cursor_x ]
Attempting to uplift remaining variables inzp[1]:18 [ utoa::digit#2 utoa::digit#1 ] Attempting to uplift remaining variables inzp[1]:18 [ utoa::digit#2 utoa::digit#1 ]
Uplifting [utoa] best 23181 combination zp[1]:18 [ utoa::digit#2 utoa::digit#1 ] Uplifting [utoa] best 23161 combination zp[1]:18 [ utoa::digit#2 utoa::digit#1 ]
Coalescing zero page register [ zp[2]:35 [ printf_cursor_ptr ] ] with [ zp[2]:46 [ printf_char::$6 ] ] - score: 2 Coalescing zero page register [ zp[2]:35 [ printf_cursor_ptr ] ] with [ zp[2]:46 [ printf_char::$6 ] ] - score: 2
Coalescing zero page register [ zp[2]:5 [ memset::num#2 ] ] with [ zp[2]:48 [ memset::end#0 ] ] - score: 1 Coalescing zero page register [ zp[2]:5 [ memset::num#2 ] ] with [ zp[2]:48 [ memset::end#0 ] ] - score: 1
Coalescing zero page register [ zp[2]:7 [ memset::str#3 ] ] with [ zp[2]:10 [ memset::dst#2 memset::dst#4 memset::dst#1 ] ] - score: 1 Coalescing zero page register [ zp[2]:7 [ memset::str#3 ] ] with [ zp[2]:10 [ memset::dst#2 memset::dst#4 memset::dst#1 ] ] - score: 1
@ -4572,53 +4572,13 @@ Coalescing zero page register [ zp[2]:35 [ printf_cursor_ptr printf_char::$6 pri
Coalescing zero page register [ zp[2]:55 [ utoa::digit_value#0 ] ] with [ zp[2]:59 [ utoa_append::sub#0 ] ] - score: 1 Coalescing zero page register [ zp[2]:55 [ utoa::digit_value#0 ] ] with [ zp[2]:59 [ utoa_append::sub#0 ] ] - score: 1
Coalescing zero page register [ zp[2]:16 [ printf_sint::value#5 printf_sint::value#0 printf_sint::value#3 printf_sint::value#1 printf_sint::value#2 utoa::value#2 utoa::value#6 utoa::value#1 utoa::value#0 atoi::return#3 atoi::return#4 ] ] with [ zp[2]:24 [ utoa_append::value#2 utoa_append::value#0 utoa_append::value#1 utoa_append::return#0 ] ] - score: 2 Coalescing zero page register [ zp[2]:16 [ printf_sint::value#5 printf_sint::value#0 printf_sint::value#3 printf_sint::value#1 printf_sint::value#2 utoa::value#2 utoa::value#6 utoa::value#1 utoa::value#0 atoi::return#3 atoi::return#4 ] ] with [ zp[2]:24 [ utoa_append::value#2 utoa_append::value#0 utoa_append::value#1 utoa_append::return#0 ] ] - score: 2
Coalescing zero page register [ zp[2]:16 [ printf_sint::value#5 printf_sint::value#0 printf_sint::value#3 printf_sint::value#1 printf_sint::value#2 utoa::value#2 utoa::value#6 utoa::value#1 utoa::value#0 atoi::return#3 atoi::return#4 utoa_append::value#2 utoa_append::value#0 utoa_append::value#1 utoa_append::return#0 ] ] with [ zp[2]:31 [ atoi::return#2 atoi::return#0 atoi::res#2 atoi::res#1 atoi::$9 atoi::$4 ] ] - score: 2 Coalescing zero page register [ zp[2]:16 [ printf_sint::value#5 printf_sint::value#0 printf_sint::value#3 printf_sint::value#1 printf_sint::value#2 utoa::value#2 utoa::value#6 utoa::value#1 utoa::value#0 atoi::return#3 atoi::return#4 utoa_append::value#2 utoa_append::value#0 utoa_append::value#1 utoa_append::return#0 ] ] with [ zp[2]:31 [ atoi::return#2 atoi::return#0 atoi::res#2 atoi::res#1 atoi::$9 atoi::$4 ] ] - score: 2
Warning! Unknown fragment for statement [131] (signed word~) atoi::$4 ← (signed word~) atoi::$3 + *((to_nomodify byte*) atoi::str#2 + (byte) atoi::i#4)
Missing ASM fragment Fragment not found vwsz1=vwsz1_plus_pbuz2_derefidx_vbuyy. Attempted variations vwsz1=vwsz1_plus_pbuz2_derefidx_vbuyy
File /Users/jespergravgaard/c64/kickc/src/main/kc/lib/stdlib.c
Line 264
res * 10 + str[i]
Coalescing zero page register [ zp[2]:16 [ printf_sint::value#5 printf_sint::value#0 printf_sint::value#3 printf_sint::value#1 printf_sint::value#2 utoa::value#2 utoa::value#6 utoa::value#1 utoa::value#0 atoi::return#3 atoi::return#4 utoa_append::value#2 utoa_append::value#0 utoa_append::value#1 utoa_append::return#0 atoi::return#2 atoi::return#0 atoi::res#2 atoi::res#1 atoi::$9 atoi::$4 ] ] with [ zp[2]:67 [ atoi::$3 ] ] - score: 2 Coalescing zero page register [ zp[2]:16 [ printf_sint::value#5 printf_sint::value#0 printf_sint::value#3 printf_sint::value#1 printf_sint::value#2 utoa::value#2 utoa::value#6 utoa::value#1 utoa::value#0 atoi::return#3 atoi::return#4 utoa_append::value#2 utoa_append::value#0 utoa_append::value#1 utoa_append::return#0 atoi::return#2 atoi::return#0 atoi::res#2 atoi::res#1 atoi::$9 atoi::$4 ] ] with [ zp[2]:67 [ atoi::$3 ] ] - score: 2
Warning! Unknown fragment for statement [131] (signed word~) atoi::$4 ← (signed word~) atoi::$3 + *((to_nomodify byte*) atoi::str#2 + (byte) atoi::i#4)
Missing ASM fragment Fragment not found vwsz1=vwsz1_plus_pbuz2_derefidx_vbuyy. Attempted variations vwsz1=vwsz1_plus_pbuz2_derefidx_vbuyy
File /Users/jespergravgaard/c64/kickc/src/main/kc/lib/stdlib.c
Line 264
res * 10 + str[i]
Coalescing zero page register [ zp[2]:12 [ memcpy::src#2 memcpy::src#1 ] ] with [ zp[2]:5 [ memset::num#2 memset::end#0 ] ] Coalescing zero page register [ zp[2]:12 [ memcpy::src#2 memcpy::src#1 ] ] with [ zp[2]:5 [ memset::num#2 memset::end#0 ] ]
Warning! Unknown fragment for statement [131] (signed word~) atoi::$4 ← (signed word~) atoi::$3 + *((to_nomodify byte*) atoi::str#2 + (byte) atoi::i#4)
Missing ASM fragment Fragment not found vwsz1=vwsz1_plus_pbuz2_derefidx_vbuyy. Attempted variations vwsz1=vwsz1_plus_pbuz2_derefidx_vbuyy
File /Users/jespergravgaard/c64/kickc/src/main/kc/lib/stdlib.c
Line 264
res * 10 + str[i]
Coalescing zero page register [ zp[2]:14 [ memcpy::dst#2 memcpy::dst#1 ] ] with [ zp[2]:7 [ memset::str#3 memset::dst#2 memset::dst#4 memset::dst#1 ] ] Coalescing zero page register [ zp[2]:14 [ memcpy::dst#2 memcpy::dst#1 ] ] with [ zp[2]:7 [ memset::str#3 memset::dst#2 memset::dst#4 memset::dst#1 ] ]
Warning! Unknown fragment for statement [131] (signed word~) atoi::$4 ← (signed word~) atoi::$3 + *((to_nomodify byte*) atoi::str#2 + (byte) atoi::i#4)
Missing ASM fragment Fragment not found vwsz1=vwsz1_plus_pbuz2_derefidx_vbuyy. Attempted variations vwsz1=vwsz1_plus_pbuz2_derefidx_vbuyy
File /Users/jespergravgaard/c64/kickc/src/main/kc/lib/stdlib.c
Line 264
res * 10 + str[i]
Coalescing zero page register [ zp[2]:16 [ printf_sint::value#5 printf_sint::value#0 printf_sint::value#3 printf_sint::value#1 printf_sint::value#2 utoa::value#2 utoa::value#6 utoa::value#1 utoa::value#0 atoi::return#3 atoi::return#4 utoa_append::value#2 utoa_append::value#0 utoa_append::value#1 utoa_append::return#0 atoi::return#2 atoi::return#0 atoi::res#2 atoi::res#1 atoi::$9 atoi::$4 atoi::$3 ] ] with [ zp[2]:2 [ printf_str::str#4 printf_str::str#6 printf_str::str#0 ] ] Coalescing zero page register [ zp[2]:16 [ printf_sint::value#5 printf_sint::value#0 printf_sint::value#3 printf_sint::value#1 printf_sint::value#2 utoa::value#2 utoa::value#6 utoa::value#1 utoa::value#0 atoi::return#3 atoi::return#4 utoa_append::value#2 utoa_append::value#0 utoa_append::value#1 utoa_append::return#0 atoi::return#2 atoi::return#0 atoi::res#2 atoi::res#1 atoi::$9 atoi::$4 atoi::$3 ] ] with [ zp[2]:2 [ printf_str::str#4 printf_str::str#6 printf_str::str#0 ] ]
Warning! Unknown fragment for statement [131] (signed word~) atoi::$4 ← (signed word~) atoi::$3 + *((to_nomodify byte*) atoi::str#2 + (byte) atoi::i#4)
Missing ASM fragment Fragment not found vwsz1=vwsz1_plus_pbuz2_derefidx_vbuyy. Attempted variations vwsz1=vwsz1_plus_pbuz2_derefidx_vbuyy
File /Users/jespergravgaard/c64/kickc/src/main/kc/lib/stdlib.c
Line 264
res * 10 + str[i]
Coalescing zero page register [ zp[2]:27 [ atoi::str#2 ] ] with [ zp[2]:22 [ utoa::buffer#11 utoa::buffer#14 utoa::buffer#4 utoa::buffer#3 utoa_append::buffer#0 ] ] Coalescing zero page register [ zp[2]:27 [ atoi::str#2 ] ] with [ zp[2]:22 [ utoa::buffer#11 utoa::buffer#14 utoa::buffer#4 utoa::buffer#3 utoa_append::buffer#0 ] ]
Warning! Unknown fragment for statement [131] (signed word~) atoi::$4 ← (signed word~) atoi::$3 + *((to_nomodify byte*) atoi::str#2 + (byte) atoi::i#4)
Missing ASM fragment Fragment not found vwsz1=vwsz1_plus_pbuz2_derefidx_vbuyy. Attempted variations vwsz1=vwsz1_plus_pbuz2_derefidx_vbuyy
File /Users/jespergravgaard/c64/kickc/src/main/kc/lib/stdlib.c
Line 264
res * 10 + str[i]
Coalescing zero page register [ zp[2]:63 [ atoi::$8 ] ] with [ zp[2]:55 [ utoa::digit_value#0 utoa_append::sub#0 ] ] Coalescing zero page register [ zp[2]:63 [ atoi::$8 ] ] with [ zp[2]:55 [ utoa::digit_value#0 utoa_append::sub#0 ] ]
Warning! Unknown fragment for statement [131] (signed word~) atoi::$4 ← (signed word~) atoi::$3 + *((to_nomodify byte*) atoi::str#2 + (byte) atoi::i#4)
Missing ASM fragment Fragment not found vwsz1=vwsz1_plus_pbuz2_derefidx_vbuyy. Attempted variations vwsz1=vwsz1_plus_pbuz2_derefidx_vbuyy
File /Users/jespergravgaard/c64/kickc/src/main/kc/lib/stdlib.c
Line 264
res * 10 + str[i]
Coalescing zero page register [ zp[2]:27 [ atoi::str#2 utoa::buffer#11 utoa::buffer#14 utoa::buffer#4 utoa::buffer#3 utoa_append::buffer#0 ] ] with [ zp[2]:12 [ memcpy::src#2 memcpy::src#1 memset::num#2 memset::end#0 ] ] Coalescing zero page register [ zp[2]:27 [ atoi::str#2 utoa::buffer#11 utoa::buffer#14 utoa::buffer#4 utoa::buffer#3 utoa_append::buffer#0 ] ] with [ zp[2]:12 [ memcpy::src#2 memcpy::src#1 memset::num#2 memset::end#0 ] ]
Warning! Unknown fragment for statement [131] (signed word~) atoi::$4 ← (signed word~) atoi::$3 + *((to_nomodify byte*) atoi::str#2 + (byte) atoi::i#4)
Missing ASM fragment Fragment not found vwsz1=vwsz1_plus_pbuz2_derefidx_vbuyy. Attempted variations vwsz1=vwsz1_plus_pbuz2_derefidx_vbuyy
File /Users/jespergravgaard/c64/kickc/src/main/kc/lib/stdlib.c
Line 264
res * 10 + str[i]
Coalescing zero page register [ zp[2]:63 [ atoi::$8 utoa::digit_value#0 utoa_append::sub#0 ] ] with [ zp[2]:14 [ memcpy::dst#2 memcpy::dst#1 memset::str#3 memset::dst#2 memset::dst#4 memset::dst#1 ] ] Coalescing zero page register [ zp[2]:63 [ atoi::$8 utoa::digit_value#0 utoa_append::sub#0 ] ] with [ zp[2]:14 [ memcpy::dst#2 memcpy::dst#1 memset::str#3 memset::dst#2 memset::dst#4 memset::dst#1 ] ]
Allocated (was zp[2]:16) zp[2]:2 [ printf_sint::value#5 printf_sint::value#0 printf_sint::value#3 printf_sint::value#1 printf_sint::value#2 utoa::value#2 utoa::value#6 utoa::value#1 utoa::value#0 atoi::return#3 atoi::return#4 utoa_append::value#2 utoa_append::value#0 utoa_append::value#1 utoa_append::return#0 atoi::return#2 atoi::return#0 atoi::res#2 atoi::res#1 atoi::$9 atoi::$4 atoi::$3 printf_str::str#4 printf_str::str#6 printf_str::str#0 ] Allocated (was zp[2]:16) zp[2]:2 [ printf_sint::value#5 printf_sint::value#0 printf_sint::value#3 printf_sint::value#1 printf_sint::value#2 utoa::value#2 utoa::value#6 utoa::value#1 utoa::value#0 atoi::return#3 atoi::return#4 utoa_append::value#2 utoa_append::value#0 utoa_append::value#1 utoa_append::return#0 atoi::return#2 atoi::return#0 atoi::res#2 atoi::res#1 atoi::$9 atoi::$4 atoi::$3 printf_str::str#4 printf_str::str#6 printf_str::str#0 ]
Allocated (was zp[1]:18) zp[1]:4 [ utoa::digit#2 utoa::digit#1 ] Allocated (was zp[1]:18) zp[1]:4 [ utoa::digit#2 utoa::digit#1 ]
@ -4627,11 +4587,6 @@ Allocated (was zp[1]:33) zp[1]:7 [ printf_cursor_x ]
Allocated (was zp[1]:34) zp[1]:8 [ printf_cursor_y ] Allocated (was zp[1]:34) zp[1]:8 [ printf_cursor_y ]
Allocated (was zp[2]:35) zp[2]:9 [ printf_cursor_ptr printf_char::$6 printf_ln::$0 printf_ln::$1 ] Allocated (was zp[2]:35) zp[2]:9 [ printf_cursor_ptr printf_char::$6 printf_ln::$0 printf_ln::$1 ]
Allocated (was zp[2]:63) zp[2]:11 [ atoi::$8 utoa::digit_value#0 utoa_append::sub#0 memcpy::dst#2 memcpy::dst#1 memset::str#3 memset::dst#2 memset::dst#4 memset::dst#1 ] Allocated (was zp[2]:63) zp[2]:11 [ atoi::$8 utoa::digit_value#0 utoa_append::sub#0 memcpy::dst#2 memcpy::dst#1 memset::str#3 memset::dst#2 memset::dst#4 memset::dst#1 ]
Warning! Unknown fragment for statement [131] (signed word~) atoi::$4 ← (signed word~) atoi::$3 + *((to_nomodify byte*) atoi::str#2 + (byte) atoi::i#4)
Missing ASM fragment Fragment not found vwsz1=vwsz1_plus_pbuz2_derefidx_vbuyy. Attempted variations vwsz1=vwsz1_plus_pbuz2_derefidx_vbuyy
File /Users/jespergravgaard/c64/kickc/src/main/kc/lib/stdlib.c
Line 264
res * 10 + str[i]
ASSEMBLER BEFORE OPTIMIZATION ASSEMBLER BEFORE OPTIMIZATION
// File Comments // File Comments
@ -5448,8 +5403,14 @@ atoi: {
// [130] (signed word~) atoi::$3 ← (signed word~) atoi::$9 << (byte) 1 -- vwsz1=vwsz1_rol_1 // [130] (signed word~) atoi::$3 ← (signed word~) atoi::$9 << (byte) 1 -- vwsz1=vwsz1_rol_1
asl.z __3 asl.z __3
rol.z __3+1 rol.z __3+1
// [131] (signed word~) atoi::$4 ← (signed word~) atoi::$3 + *((to_nomodify byte*) atoi::str#2 + (byte) atoi::i#4) // [131] (signed word~) atoi::$4 ← (signed word~) atoi::$3 + *((to_nomodify byte*) atoi::str#2 + (byte) atoi::i#4) -- vwsz1=vwsz1_plus_pbuz2_derefidx_vbuyy
.assert "Missing ASM fragment Fragment not found vwsz1=vwsz1_plus_pbuz2_derefidx_vbuyy. Attempted variations vwsz1=vwsz1_plus_pbuz2_derefidx_vbuyy ", 0, 1 clc
lda.z __4
adc (str),y
sta.z __4
bcc !+
inc.z __4+1
!:
// [132] (signed word) atoi::res#1 ← (signed word~) atoi::$4 - (byte) '0' -- vwsz1=vwsz1_minus_vbuc1 // [132] (signed word) atoi::res#1 ← (signed word~) atoi::$4 - (byte) '0' -- vwsz1=vwsz1_minus_vbuc1
sec sec
lda.z res lda.z res
@ -5925,7 +5886,7 @@ mem[12] [ printf_buffer ]
FINAL ASSEMBLER FINAL ASSEMBLER
Score: 19613 Score: 19823
// File Comments // File Comments
// Test atoi() // Test atoi()
@ -6693,8 +6654,14 @@ atoi: {
asl.z __3 asl.z __3
rol.z __3+1 rol.z __3+1
// res * 10 + str[i] // res * 10 + str[i]
// [131] (signed word~) atoi::$4 ← (signed word~) atoi::$3 + *((to_nomodify byte*) atoi::str#2 + (byte) atoi::i#4) // [131] (signed word~) atoi::$4 ← (signed word~) atoi::$3 + *((to_nomodify byte*) atoi::str#2 + (byte) atoi::i#4) -- vwsz1=vwsz1_plus_pbuz2_derefidx_vbuyy
.assert "Missing ASM fragment Fragment not found vwsz1=vwsz1_plus_pbuz2_derefidx_vbuyy. Attempted variations vwsz1=vwsz1_plus_pbuz2_derefidx_vbuyy ", 0, 1 clc
lda.z __4
adc (str),y
sta.z __4
bcc !+
inc.z __4+1
!:
// res = res * 10 + str[i] - '0' // res = res * 10 + str[i] - '0'
// [132] (signed word) atoi::res#1 ← (signed word~) atoi::$4 - (byte) '0' -- vwsz1=vwsz1_minus_vbuc1 // [132] (signed word) atoi::res#1 ← (signed word~) atoi::$4 - (byte) '0' -- vwsz1=vwsz1_minus_vbuc1
sec sec