Skip to content

Commit

Permalink
Add print_int32 (support for negative numbers)
Browse files Browse the repository at this point in the history
Closed #2
  • Loading branch information
ChillerDragon committed Aug 2, 2024
1 parent 722f7b1 commit 77f8374
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/data/logger.asm
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
char_newline db 0x0a
char_space db 0x20
char_dot db '.'
char_minus db '-'
char_single_quote db 0x27
char_double_quote db 0x22

Expand Down
24 changes: 24 additions & 0 deletions src/logger.asm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ print_newline:
pop_registers
ret

print_minus:
push_registers

mov rax, SYS_WRITE
mov rdi, STDOUT
mov rsi, char_minus
mov rdx, 1
syscall

pop_registers
ret

print_single_quote:
push_registers

Expand Down Expand Up @@ -67,6 +79,18 @@ dbg_print_uint32:

ret


print_int32:
; print_int32 [rax]
cmp rax, 0
jge .print_int32_positive
.print_int32_negative:
call print_minus
neg rax
.print_int32_positive:
call print_uint32
ret

print_uint32:
; print_uint32 [rax]
;
Expand Down

0 comments on commit 77f8374

Please sign in to comment.