lsfs_16-bit now includes its own print functions

This commit is contained in:
Jørn Guldberg committed 2019-06-30 23:19:44 +00:00
1 parent a6a338c17a
commit 0f6e818ff6
6 files changed
+311 -354

No files matched your search

+51 -3
View File
@@ -8,11 +8,27 @@ char* string;
push bp
mov bp,sp
mov si,4[bp]
call 0x0000:0x7C47
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
new_print_print:
; Prints string in si
; IN si: zero terminated string to print
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
mov ah, #0xE ; Specify 'int 0x10' 'teletype output' function
; [AL = Character, BH = Page Number, BL = Colour (in graphics mode)]
.new_print_printchar:
lodsb ; Load byte at address SI into AL, and increment SI
test al, al
jz .new_print_done ; If the character is zero (NUL), stop writing the string
int #0x10 ; Otherwise, print the character via 'int 0x10'
jmp .new_print_printchar ; Repeat for the next character
.new_print_done:
pop bp
#endasm
}
void print_stack(argument)
{
#asm
@@ -24,7 +40,20 @@ void print_stack(argument)
mov ax, ss
mov ds, ax
mov si,4[bp]
call 0x0000:0x7C47
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
print_stack_print:
; Prints string in si
; IN si: zero terminated string to print
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
mov ah, #0xE ; Specify 'int 0x10' 'teletype output' function
; [AL = Character, BH = Page Number, BL = Colour (in graphics mode)]
.print_stack_printchar:
lodsb ; Load byte at address SI into AL, and increment SI
test al, al
jz .print_stack_done ; If the character is zero (NUL), stop writing the string
int #0x10 ; Otherwise, print the character via 'int 0x10'
jmp .print_stack_printchar ; Repeat for the next character
.print_stack_done:
pop ax
pop ds
@@ -45,7 +74,26 @@ void* input;
#asm
push bp
mov bp,sp
call 0x000:0x7C2A
pusha ; save registers
mov bx, ax
mov ah, #0xE ; Teletype output
mov cx, #4 ; 4 nipples in a 16 bit word
.dump_ax_loop:
rol bx, #4 ; rotate to next nipple
mov al, bl ; we copy to al because we need to mask only the low 4 bits
and al, #%1111 ; Do the masking
add al, #48 ; convert to ASCII
cmp al, #57 ; If we are greater than 9 ascii, we add 7 to make digit 10 be represented as 'A'
jbe .dump_ax_skip ; -|-
add al, #7 ; -|-
.dump_ax_skip: ; -|-
int #0x10 ; BIOS call 'output'
loop .dump_ax_loop
popa ; restore registers
pop bp
#endasm
}