Update to Hello World Boot Loader
So, I have been playing with the Hello World Boot Loader, trying to turn it into something useful and I thought I would go ahead and clear up some of the code and make the loader smaller and faster.
Code:
[BITS 16] ; 16 bit code generation
[ORG 0x7C00] ; Origin location
; Main program
main: ; Label for the start of the main program
mov ax,0x0000 ; Setup the Data Segment register
; Location of data is DS:Offset
mov ds,ax ; This can not be loaded directly it has to be in two steps.
; 'mov ds, 0x0000' will NOT work due to limitations on the CPU
mov si, HelloWorld ; Load the string into position for the procedure.
mov ah,0x13 ; 0x13 Prints a full String
mov bh,0x00 ; Page number
mov bl,0x07 ; Normal text attribute
lodsb ; I think of this as LOaD String Block
; (Not sure if thats the real meaning though)
; Loads [SI] into AL and increases SI by one
int 0x10 ; Run the BIOS video interrupt
jmp $ ; Never ending loop
; Data
HelloWorld db 'Loading Stage 1...',13,10,0
; End Matter
times 510-($-$$) db 0 ; Fill the rest with zeros
dw 0xAA55 ; Boot loader signature
This is optimized. So what did I do? I removed the loop, because the author was using the BIOS code for White TTY Character (0x0E). Instead I decided on 0x13 which is White TTY String.
Also, LODSB stands for Load String Bytes.