Reputation:
I have this simple bootloader code, but am not sure what all of it does.
mov ax, 07c00h
mov ds, ax
mov si, msg
ch_loop: lodsb
or al, al
jz hang
mov ah, 0eh
int 10h
jmp ch_loop
hang:
jmp hang
msg db "Hello, world!", 13, 10, 0
times 512-($-$$) db 0
First of all, I think you're telling the BIOS to load at memory location 7c00 (why not say org 7c00h? Or is that not x86 assembly?). Next you moving the value of ax into dx. Then, moving the value of 'msg' into si (why si?). Following, I think you're creating a loop to print all the characters on the screen. I have no idea what or al, al
means. jump if zero to hang function (does it euqal 0 when all the characters of finished being printed to the screen?). The next two lines have got to do with video. I know that int 10h
is a BIOS interrupt for video/graphics mode. After the int 10h
I understand. I really find Assembly very difficult. I know ax
is an accumalator register, but what does that actually mean?
Please could some one help me!
Thanks in advance
Any questions, please comment!
PS Any really in-depth website for something like this? Aslo, what are 'pages' in Assembly? You use the bh
register, but why bh
?
Upvotes: 1
Views: 554
Reputation: 28921
Are you sure the code starts with
mov ax,07c00h
mov ds,ax
as opposed to
mov ax,07c0h
mov ds,ax
?
The BIOS always loads a boot (or the partition) sector at 0000:7c00. For Microsoft partition sector, the BIOS loads in the sector image at 0000:7c00, and the code moves itself down to 0000:0600, which then locates and loads a boot sector into 0000:7c00, and jumps to the boot sector code. For a multi-boot system, the cycle may be repeated again.
Upvotes: 2
Reputation: 2541
int 10h calls BIOS video services. in this case, outputting a character. Around int 10h is a loop, reading chars from message, and the 0 at message end causes the loop to exit to another, but endless, "hang" loop. Now, putting those actions together, what do you expect that code to do :)
Upvotes: 1
Reputation: 3110
Any really in-depth website for something like this?
OSDev is the place to search for answers to questions like this:
Upvotes: 1