summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLizzy Fleckenstein <eliasfleckenstein@web.de>2023-12-07 14:52:20 +0100
committerLizzy Fleckenstein <eliasfleckenstein@web.de>2023-12-07 14:52:20 +0100
commit7d1991f8e6475f774263bdc5a0be15c9c0b79068 (patch)
tree848247e55dc6d2d7236a664a346dcc6a021e7de7
parente3976c3f58084ccdee5b24cf526dae41b57018cd (diff)
downloadcuddles-7d1991f8e6475f774263bdc5a0be15c9c0b79068.tar.xz
include 16-bit number printing functions in stage1
-rw-r--r--stage1/print.asm47
-rw-r--r--stage2/main.asm47
2 files changed, 47 insertions, 47 deletions
diff --git a/stage1/print.asm b/stage1/print.asm
index 3505eb6..5c4b399 100644
--- a/stage1/print.asm
+++ b/stage1/print.asm
@@ -10,3 +10,50 @@ print_str:
jmp .print
.return:
ret
+
+; modify eax, ebx, ecx, edx
+print_hex:
+ mov ebx, 0x10
+ jmp print_num
+print_dec:
+ mov ebx, 10
+print_num:
+ xor ecx, ecx
+.convert:
+ inc ecx
+ xor edx, edx
+ div ebx
+ cmp dl, 10
+ jb .digit
+ add dl, 'A'-10
+ jmp .next
+.digit:
+ add dl, '0'
+.next:
+ push dx
+ cmp eax, 0
+ jne .convert
+.print:
+ cmp ecx, 0
+ je .return
+ dec ecx
+ pop ax
+ mov ah, 0x0E
+ int 0x10
+ jmp .print
+.return:
+ ret
+
+newline:
+ mov al, 10
+ call print_chr
+
+ mov al, 13
+ call print_chr
+
+ ret
+
+print_chr:
+ mov ah, 0x0E
+ int 0x10
+ ret
diff --git a/stage2/main.asm b/stage2/main.asm
index 50fee42..2181999 100644
--- a/stage2/main.asm
+++ b/stage2/main.asm
@@ -33,53 +33,6 @@ setup:
%include "stage2/paging.asm"
%include "stage1/print.asm"
-; modify eax, ebx, ecx, edx
-print_hex:
- mov ebx, 0x10
- jmp print_num
-print_dec:
- mov ebx, 10
-print_num:
- xor ecx, ecx
-.convert:
- inc ecx
- xor edx, edx
- div ebx
- cmp dl, 10
- jb .digit
- add dl, 'A'-10
- jmp .next
-.digit:
- add dl, '0'
-.next:
- push dx
- cmp eax, 0
- jne .convert
-.print:
- cmp ecx, 0
- je .return
- dec ecx
- pop ax
- mov ah, 0x0E
- int 0x10
- jmp .print
-.return:
- ret
-
-newline:
- mov al, 10
- call print_chr
-
- mov al, 13
- call print_chr
-
- ret
-
-print_chr:
- mov ah, 0x0E
- int 0x10
- ret
-
[bits 64]
long_mode: