lesson 5 with hex printer

pull/6/head
Carlos Fenollosa 10 years ago
parent fc73be819b
commit 545546ce5e

@ -110,15 +110,26 @@ The syntax is
%include "file.asm"
```
Printing hex values
-------------------
In the next lesson we will start reading from disk, so we need some way
to make sure that we are reading the correct data. File `boot_sect_print_hex.asm`
extends `boot_sect_print.asm` to print hex bytes, not just ASCII chars.
Code!
-----
Let's jump to the code. File `boot_sect_print.asm` is the subroutine which will
get `%include`d in the main file. It uses a loop to print bytes on screen.
The main file `boot_sect_main.asm` loads a couple strings, calls `print` and hangs. If you understood
the previous sections, it's quite straightforward.
As a last goodie, we will learn how to print newlines. The familiar `'\n'` is
It also includes a function to print a newline. The familiar `'\n'` is
actually two bytes, the newline char `0x0A` and a carriage return `0x0D`. Please
experiment by removing the carriage return char and see its effect.
As stated above, `boot_sect_print_hex.asm` allows for printing of bytes.
The main file `boot_sect_main.asm` loads a couple strings and bytes,
calls `print` and `print_hex` and hangs. If you understood
the previous sections, it's quite straightforward.

@ -4,22 +4,23 @@
mov bx, HELLO
call print
; We will get fancy and print a newline
; feel free to integrate newline code into "boot_sect_print"
mov ah, 0x0e
mov al, 0x0A ; newline char
int 0x10
mov al, 0x0D ; carriage return char
int 0x10
call print_nl
mov bx, GOODBYE
call print
call print_nl
mov dx, 0x1234
call print_hex
; that's it! we can hang now
jmp $
; remember to include subroutines below the hang
%include "boot_sect_print.asm"
%include "boot_sect_print_hex.asm"
; data
HELLO:

@ -21,3 +21,17 @@ start:
done:
popa
ret
print_nl:
pusha
mov ah, 0x0e
mov al, 0x0a ; newline char
int 0x10
mov al, 0x0d ; carriage return
int 0x10
popa
ret

Loading…
Cancel
Save