aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bfc.S59
1 files 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