From: Frank K. <fbk...@zy...> - 2009-06-29 14:35:31
|
zak100 wrote: This is the problem: > mov ax,0B800h > mov es,ax ; One example you've got puts characters to screen memory, at B800h:????. "stosw" is used to put character and color to es:di. The other example uses bios int 10h, subfunction 13h, which expects es:bp to point to the string (unusual parameters to this interrupt!). (the tut you've got explains other parameters to this int, but fails to mention the es:bp thing) When our bootsector receives control from the bios, we don't know what ds and es are. If we've assembled at "org 0", we want them to be 7C0h. If we've assembled at 7C00h, we want them to be zero... to refer to any data in our bootsector (if we want screen memory, 0B800h - an old ttl mono card wants 0B000h - we probably won't encounter such a thing, but really should check... int 11h, IIRC). The example that prints registers on the screen, is quite "non-standard", and probably isn't a good starting point for other bootsectors. This one uses a different int 10h subfunction, 0Eh, which prints the character in al (put there by lodsb). ;------------------------------------ ; same as boot01, pretty much... ; nasm -f bin -o boot01.bin boot01.asm ; dd count=1 if=boot01.bin of=/dev/fd0 ;------------------------------------- org 7C00h section .text jmp short overdata nop db 'MyOS ' ; OEM id dw 200h ; bytes/sector db 1 ; sectors per cluster dw 1 ; sectors before FAT db 2 ; number of FATs dw 0E0h ; max rootdir entries dw 0B40h ; total sectors db 0Fh ; media descriptor dw 9 ; sectors per FAT dw 12h ; sectors per track dw 2 ; number heads times 0Ah db 0 db 29h db 0EFh db 7 db 10h db 24h db 'LINUX BOOT FAT12 ' ;---------------------------- overdata: xor ax,ax mov ds,ax mov es,ax ; should probably set up a sane stack here, too. mov si,msg ; "our dear string" mov bx,7 mov ah,0Eh msgloop: lodsb or al,al jz blackhole int 10h ; since we're still in RM, we can use bios. jmp msgloop blackhole: jmp blackhole msg db "We be bootin'2!",0 times 510-($-$$) db 90h ; don't think it matters, but we'll use NOP db 55h,0AAh ; boot sector signature ;------------------------- I'll see if I can work up an example using int 10h subfunction 13h... maybe even set up the stack, instead of just saying we should. :) Won't be immediately, but I'll try to get to it "soon"... Best, Frank |