Bona Fide OS Development http://forums.osdever.net/ |
|
Update to Hello World Boot Loader http://forums.osdever.net/viewtopic.php?f=4&t=356 |
Page 1 of 1 |
Author: | ctimko [ Mon May 03, 2010 8:20 pm ] |
Post subject: | 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. |
Author: | AndyEsser [ Tue May 04, 2010 8:09 am ] |
Post subject: | Re: Update to Hello World Boot Loader |
Does having the 13,10,0 bytes at the end of the string actually do anything? I was under the impression that those would be implemented by the OS and therfore don't actually do a thing when using the BIOS Interrupts? Save yourself an extra 3 bytes |
Author: | ctimko [ Tue May 04, 2010 2:46 pm ] |
Post subject: | Re: Update to Hello World Boot Loader |
Yea, the whole 13 was from the original so I didn't change it since I didn't understand its purpose. I was more worried about removing the loop, when the BIOS is already able to support it. |
Author: | ctimko [ Tue May 04, 2010 2:51 pm ] |
Post subject: | Re: Update to Hello World Boot Loader |
Also, yea, I am going to be saving as many bytes as possible, so I can achieve my goal with the boot loader....super optimized.. |
Author: | Kieran [ Tue May 04, 2010 4:50 pm ] |
Post subject: | Re: Update to Hello World Boot Loader |
The 13 & 10 are carrage return (CR) and line feed (LF) and the 0 byte is used as a string terminator. |
Author: | ctimko [ Tue May 04, 2010 8:17 pm ] |
Post subject: | Re: Update to Hello World Boot Loader |
ok, so that line can be changed to: Code: HelloWorld db .asciiz "Hello World" @Kerian, yea, I knew what the zero was for and i understood what was going on after I said that. I just really wasn't reading the code (and I am a little rusty on my ASM). |
Author: | ctimko [ Fri May 07, 2010 11:26 am ] |
Post subject: | Re: Update to Hello World Boot Loader |
So, right, in theory my fix is supposed to work and when I tested it, I thought it did, until I realized that the original loop was still in the logic...and I removed it and tried again and it didn't work. So maybe I didn't correctly understand the other setting for printing a string. I will look into it and see if I can simplify the process down more. |
Page 1 of 1 | All times are UTC - 6 hours [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |