Fixed read loop glitch
This commit is contained in:
6
helper.s
6
helper.s
@@ -64,6 +64,7 @@ read:
|
||||
# rsi = char*
|
||||
write:
|
||||
push r15
|
||||
push r11
|
||||
mov r15, rdi
|
||||
mov rdi, rsi # no need to touch rsi
|
||||
call count
|
||||
@@ -73,6 +74,7 @@ write:
|
||||
mov rdi, r15
|
||||
|
||||
syscall
|
||||
pop r11
|
||||
pop r15
|
||||
ret
|
||||
|
||||
@@ -80,9 +82,9 @@ write:
|
||||
count:
|
||||
mov rax, rdi
|
||||
count_loop:
|
||||
mov r8b, [rax]
|
||||
mov r9b, [rax]
|
||||
inc rax
|
||||
cmp r8b, 0
|
||||
cmp r9b, 0
|
||||
jnz count_loop
|
||||
dec rax
|
||||
sub rax, rdi
|
||||
|
15
main.s
15
main.s
@@ -165,9 +165,22 @@ process_prnt:
|
||||
ret
|
||||
|
||||
process_inpt:
|
||||
# Gotta flush the buffer first
|
||||
mov rdi, 1
|
||||
mov rsi, r13
|
||||
call write
|
||||
|
||||
# Clear Text buffer
|
||||
mov rdi, r10
|
||||
sub rdi, r13
|
||||
mov rsi, rdi
|
||||
mov rdi, r13
|
||||
call clear_heap_block
|
||||
mov r10, r13
|
||||
|
||||
# Ask character
|
||||
mov rdi, r14
|
||||
add rdi, r15
|
||||
|
||||
mov rsi, rdi # char*
|
||||
xor rdi, rdi # fd
|
||||
mov rdx, 1 # size
|
||||
|
1
tests/test5.bf
Normal file
1
tests/test5.bf
Normal file
@@ -0,0 +1 @@
|
||||
++++++++[>++++++++<-]>+.,+.,,
|
@@ -1 +1,2 @@
|
||||
+++++++++[>++++++++>+++++++++++>++++>++++++++++>+++++++++++>++++>+++++++++++<<<<<<<-]>.>++.+++++++..+++.>---.-.>---.>++.<<<---.>>>--.<<<+++.--.>>>++.<<.<+++++++.-----.>.>>--.--.<<<+++++.>>>>+++.<<<<-.>.>>+.<<<-.>>>-.++++++++.+++++.>>+++.<<<<<+++.>>>>>---.<<---.<<.>>--.+++++.<<<-.>>>>>++.<<++++.--.++.>>.<<++.>>.<<--.>+++++.<<<.<+++.>>>.>>++++.<<++..>>----.<<------.<<.>>-----.+++++.<<.<<-------.>>>----.------.<+.>>>>>++++++++++.
|
||||
,+++..,
|
||||
|
Reference in New Issue
Block a user