diff options
author | Ratakor <ratakor@disroot.org> | 2023-09-17 23:04:51 +0200 |
---|---|---|
committer | Ratakor <ratakor@disroot.org> | 2023-09-17 23:04:51 +0200 |
commit | 5edd4065a9bcb70e9cd557548f49cf3605303fe8 (patch) | |
tree | 0cf7f409d5d443dc5c44770fb66f84baffaed6f6 | |
parent | 22d49764e95b41562fd7c216ce556f96287091fa (diff) |
Fix README and clarify bf.s
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | src/bf.s | 36 |
2 files changed, 18 insertions, 19 deletions
@@ -25,6 +25,5 @@ Options: -o <file> Place the output into <file>. -S Compile only, do not assemble or link. -c Compile and assemble, but do not link. - -g Produce debugging information. -s Strip the output file. ``` @@ -70,32 +70,32 @@ _start: .main_loop: ; switch [instruction] -.case1: ; case '>' - cmp bl, 0x3e +.case1: + cmp bl, '>' jne .case2 inc r12w ; data_idx++ jmp .switch_end -.case2: ; case '<' - cmp bl, 0x3c +.case2: + cmp bl, '<' jne .case3 dec r12w ; data_idx-- jmp .switch_end -.case3: ; case '+' - cmp bl, 0x2b +.case3: + cmp bl, '+' jne .case4 inc byte [data + r12] ; data[data_idx]++ jmp .switch_end -.case4: ; case '-' - cmp bl, 0x2d +.case4: + cmp bl, '-' jne .case5 dec byte [data + r12] ; data[data_idx]-- jmp .switch_end -.case5: ; case '[' - cmp bl, 0x5b +.case5: + cmp bl, '[' jne .case6 cmp byte [data + r12], 0 jne .case5.else ; data[data_idx] == 0 @@ -104,12 +104,12 @@ _start: inc rbp ; rbp = & next instruction mov bl, [rbp] ; bl = current instruction - cmp bl, 0x5b ; '[' + cmp bl, '[' jne .case5.loop.elseif inc rcx ; bracket_counter++ jmp .case5.loop .case5.loop.elseif: - cmp bl, 0x5d ; ']' + cmp bl, ']' jne .case5.loop dec rcx ; bracket_counter-- cmp rcx, 0 @@ -121,8 +121,8 @@ _start: mov [rsp], rbp ; save address for matching ']' jmp .switch_end -.case6: ; case ']' - cmp bl, 0x5d +.case6: + cmp bl, ']' jne .case7 cmp byte [data + r12], 0 je .case6.else ; data[data_idx] != 0 @@ -132,8 +132,8 @@ _start: add rsp, 8 ; discard saved instruction address jmp .switch_end -.case7: ; case '.' - cmp bl, 0x2e +.case7: + cmp bl, '.' jne .case8 mov rdx, 1 ; count lea rsi, [data + r12] ; buf = &data[data_idx] @@ -142,8 +142,8 @@ _start: syscall jmp .switch_end -.case8: ; case ',' - cmp bl, 0x2c +.case8: + cmp bl, ',' jne .switch_end mov rdx, 1 ; count lea rsi, [data + r12] ; buf = &data[data_idx] |