Commit 84c08b23 by triazo

Change function to take number of bytes as argument

parent ceba1955
Showing with 16 additions and 19 deletions
...@@ -65,33 +65,24 @@ PrintChar: ; print char at AL ...@@ -65,33 +65,24 @@ PrintChar: ; print char at AL
mov bl, 0x07 ; light gray mov bl, 0x07 ; light gray
int 0x10 ; print character int 0x10 ; print character
ret ret
MOV AH, 0x0E ; Teletype Mode
MOV BH, 0x00 ; Page zero
MOV BL, 0x07 ; Light Gray
INT 0x10 ; Print Character
RET
PrintHexStr: ; print <ax> bytes starting at [si]
;------------------ DATA BLOCK ------------------; mov di, si ; initilize the loop registers
str1 db 'Hello World', 0 ; Hello World mov dx, si
str2 db 'WHY IS THIS', 0 add dx, ax
hexChars db '0123456789abcdef' ; Used for hex formatting
PrintHexStr:
nexthchar: nexthchar:
mov al, [si] ; grab next char cmp di, dx
or al, al ; if char is null term jge exith ; NO IDEA HOW THIS WORKS
jz exith ; then return mov al, BYTE [di] ; grab next char
call PrintHexChar ; else print char call PrintHexChar ; else print char
inc si ; inc pointer to next char inc di
jmp nexthchar ; loop jmp nexthchar ; loop
exith: exith:
ret ret
PrintHexChar: PrintHexChar:
;; call PrintChar ;; call PrintChar
xor ebx, ebx
mov cl, al mov cl, al
mov bl, al mov bl, al
and bl, 0xf0 and bl, 0xf0
...@@ -104,11 +95,17 @@ PrintHexChar: ...@@ -104,11 +95,17 @@ PrintHexChar:
call PrintChar call PrintChar
ret ret
;------------------ DATA BLOCK ------------------;
str1 db 'Hello World', 0 ; Hello World
str2 db 'WHY IS THIS', 0
hexChars db '0123456789abcdef' ; Used for hex formatting
Main: ;main section Main: ;main section
nop nop
nop nop
mov si, str2 mov si, str2
call PrintStr call PrintStr
mov si, str2 mov si, str1
mov ax, 10
call PrintHexStr ; print string call PrintHexStr ; print string
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment