From e8e9e921f30beb38de7edb0f2cb709584b586d9f Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Thu, 26 Dec 2024 18:12:10 +0100 Subject: add l_compile_move_left --- bfc.S | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 54 insertions(+), 5 deletions(-) diff --git a/bfc.S b/bfc.S index c3edde2..8badee3 100644 --- a/bfc.S +++ b/bfc.S @@ -69,12 +69,61 @@ l_read_loop: cmp $0, %rax je l_read_loop_end - mov $SYS_WRITE, %rax - mov $1, %rdi - mov $v_input_char, %rsi - mov $1, %rdx - syscall + mov $v_input_char, %rbx + mov (%rbx), %rax + cmp $'<', %rax + je l_compile_move_left + cmp $'>', %rax + je l_compile_move_right + cmp $'+', %rax + je l_compile_inc + cmp $'-', %rax + je l_compile_dec + cmp $'[', %rax + je l_compile_loop_start + cmp $']', %rax + je l_compile_loop_end + cmp $'.', %rax + je l_compile_write + cmp $',', %rax + je l_compile_read + jmp l_read_loop + +l_compile_move_left: + mov $v_buffer_cursor, %rbx + mov (%rbx), %rsi + add $3, %rsi + call f_check_buffer + + mov $v_buffer_cursor, %rbx + mov (%rbx), %rax + movl $0xc0ff48, (%rax) + add $3, %rax + mov %rax, (%rbx) + + jmp l_read_loop + +l_compile_move_right: + jmp l_read_loop + +l_compile_inc: + jmp l_read_loop + +l_compile_dec: + jmp l_read_loop + +l_compile_loop_start: jmp l_read_loop + +l_compile_loop_end: + jmp l_read_loop + +l_compile_write: + jmp l_read_loop + +l_compile_read: + jmp l_read_loop + l_read_loop_end: call f_close_files -- cgit v1.2.3-70-g09d2