1
0
Fork 0
mirror of https://github.com/tailix/loadwarka.git synced 2024-11-18 13:54:56 -05:00

Move func "print_number" to common module

This commit is contained in:
Alex Kotov 2022-01-28 00:15:21 +05:00
parent 984e9c7826
commit ca6447cd14
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
2 changed files with 35 additions and 37 deletions

View file

@ -6,6 +6,7 @@
.global hang
.global print_char
.global print_str
.global print_number
.section .text
hang:
@ -30,3 +31,37 @@ print_str:
jz do_ret
call print_char
jmp print_str
// AX - number
print_number:
test %ax, %ax
jnz print_number_notnull
mov $0x0e, %ah
mov $'0', %al
int $0x10
ret
// AX - number
print_number_notnull:
test %ax, %ax
jz do_ret
// DX - dividend high (always zero)
// AX - dividend low
xor %dx, %dx
// BX - divisor (always 10)
mov $10, %bx
// AX - quotient
// DX - remainder
div %bx
push %dx
call print_number_notnull
pop %dx
mov $0x0e, %ah
mov %dl, %al
add $'0', %al
int $0x10
ret

View file

@ -108,43 +108,6 @@ finish:
ljmp $0, $STAGE2_BASE
ljmp $0, $hang
do_ret:
ret
// AX - number
print_number:
test %ax, %ax
jnz print_number_notnull
mov $0x0e, %ah
mov $'0', %al
int $0x10
ret
// AX - number
print_number_notnull:
test %ax, %ax
jz do_ret
// DX - dividend high (always zero)
// AX - dividend low
xor %dx, %dx
// BX - divisor (always 10)
mov $10, %bx
// AX - quotient
// DX - remainder
div %bx
push %dx
call print_number_notnull
pop %dx
mov $0x0e, %ah
mov %dl, %al
add $'0', %al
int $0x10
ret
// AX - size
print_stage2_size:
push %ax