idk what i added
This commit is contained in:
@@ -11,68 +11,96 @@ os_print_string:
|
||||
lodsb ; Get char from si into al
|
||||
cmp al, 0 ; Compare al to 0
|
||||
je .done ; If char is zero, end of string
|
||||
|
||||
cmp al, 0Ah ; When there's an NL or CR, do both, linux encodes files only with NL
|
||||
je .new_line
|
||||
cmp al, 0Dh
|
||||
je .repeat
|
||||
|
||||
cmp al, 5Ch ; backslash
|
||||
je .backslash
|
||||
|
||||
int 10h ; Otherwise, print it
|
||||
jmp .repeat ; And move on to next char
|
||||
|
||||
.backslash: ; If there is a '\', do what it says, \n for newline, \t for tab etc
|
||||
lodsb
|
||||
dec si
|
||||
cmp al, 6Eh ; 'n'
|
||||
je .newline
|
||||
cmp al, 74h ; \t
|
||||
je .tab
|
||||
cmp al, 5Ch ; '\'
|
||||
je .another_backslash
|
||||
jmp .repeat
|
||||
.newline:
|
||||
mov al, 0Ah ; new line
|
||||
int 10h
|
||||
mov al, 0Dh ; carriage return
|
||||
int 10h
|
||||
jmp .finish_backslash
|
||||
.tab:
|
||||
mov al, 09h ; tab
|
||||
int 10h
|
||||
jmp .finish_backslash
|
||||
.another_backslash: ; This just prints 1 backslash
|
||||
mov al, 5Ch
|
||||
int 10h
|
||||
jmp .finish_backslash
|
||||
.finish_backslash:
|
||||
inc si
|
||||
.new_line:
|
||||
mov al, 0Ah
|
||||
int 10h
|
||||
mov al, 0Dh
|
||||
int 10h
|
||||
jmp .repeat
|
||||
.backslash:
|
||||
call text_backslash
|
||||
jmp .repeat
|
||||
.done:
|
||||
popa
|
||||
ret
|
||||
|
||||
; This is similar to the previous, however it prints
|
||||
; raw output (including null) and prints the number
|
||||
; of character defined by ax
|
||||
; of character defined by cx
|
||||
; IN:
|
||||
; SI = pointer to start of string to be printed
|
||||
; AX = Length of string to print
|
||||
text_raw_output:
|
||||
; CX = Length of string to print
|
||||
text_print_raw:
|
||||
pusha
|
||||
add cx, 1
|
||||
mov ah, 0Eh
|
||||
.repeat:
|
||||
dec cx
|
||||
cmp cx, 0
|
||||
je .finish
|
||||
lodsb
|
||||
cmp al, 00h ; Print a space in place of a Null
|
||||
je .space
|
||||
cmp al, 0Ah ; When there's an NL or CR, do both, linux encodes files only with NL
|
||||
je .new_line
|
||||
cmp al, 0Dh
|
||||
je .repeat
|
||||
int 10h
|
||||
jmp .repeat
|
||||
.space:
|
||||
mov al, 20h
|
||||
int 10h
|
||||
jmp .repeat
|
||||
.new_line:
|
||||
mov al, 0Ah
|
||||
int 10h
|
||||
mov al, 0Dh
|
||||
int 10h
|
||||
jmp .repeat
|
||||
.finish:
|
||||
popa
|
||||
ret
|
||||
|
||||
mov di, ax
|
||||
|
||||
mov ah, 0Eh ; int 10h teletype function, we're telling the BIOS we will print something
|
||||
|
||||
.repeat:
|
||||
lodsb ; Get char from si into al
|
||||
int 10h ; Otherwise, print it
|
||||
dec di
|
||||
cmp di, 00h
|
||||
je .done
|
||||
jne .repeat
|
||||
.done:
|
||||
popa
|
||||
ret
|
||||
|
||||
|
||||
; NO PUSHING/POPPING!
|
||||
text_backslash: ; If there is a '\', do what it says, \n for newline, \t for tab etc
|
||||
lodsb
|
||||
dec si
|
||||
cmp al, 6Eh ; 'n'
|
||||
je .newline
|
||||
cmp al, 74h ; \t
|
||||
je .tab
|
||||
cmp al, 5Ch ; '\'
|
||||
je .another_backslash
|
||||
ret
|
||||
.newline:
|
||||
mov al, 0Ah ; new line
|
||||
int 10h
|
||||
mov al, 0Dh ; carriage return
|
||||
int 10h
|
||||
jmp .finish_backslash
|
||||
.tab:
|
||||
mov al, 09h ; tab
|
||||
int 10h
|
||||
jmp .finish_backslash
|
||||
.another_backslash: ; This just prints 1 backslash
|
||||
mov al, 5Ch
|
||||
int 10h
|
||||
jmp .finish_backslash
|
||||
.finish_backslash:
|
||||
inc si
|
||||
ret
|
||||
; --------------------------------------------
|
||||
|
||||
os_print_newline:
|
||||
|
||||
Reference in New Issue
Block a user