Page 1 of 1
trying to make a program which boots from disk...
Posted: Wed Dec 24, 2003 12:00 am
by wasiliy
hi, i just read a bit about making a boot disk. as i understand it: all i need is that 0AA55h at the end of the 512 bytes. so i have written the code below which is supposed to draw a pixel on the screen but all i get is a flickering screen. do i need to do something else essencial??
model tiny
.386
.code
org 100h
main:
mov ax,13h
int 10h
mov ax,0a000h
mov es,ax
mov bx,320*100+160
mov al,15
mov es:[bx],al
inf:
jmp inf-100h
org 512+100h
dw 0AA55h
end main
RE:trying to make a program which boots from disk...
Posted: Thu Dec 25, 2003 12:00 am
by Chase
>> as i understand it: all i need is that 0AA55h at the end of the 512 bytes
Not exactly, some BIOSes need a short jump followed by a nop at the beginning. Different BIOSes may or may not setup your stack. My boot sector would start like this(nasm syntax):
[BITS 16]
[ORG 0]
jmp short Start
nop
Start:
mov ax,0x07c0
mov ds,ax
mov es,ax
xor ax,ax
mov ss,ax
mov sp,0x7c00
jmp short $
times 510-($-$$) db 0
dw 0xAA55
It could also be that your video card doesn't provide the BIOS service routine to set to 320x200x256 but that'd be a little odd. Also note that the ORG is 0, an ORG of 0x100 is for DOS com programs.
RE:trying to make a program which boots from disk...
Posted: Thu Dec 25, 2003 12:00 am
by wasiliy
yes that org 100h is needed by the linker "tlink", it doesnt accept anything else and gives errors. when i use jumps i just jump at:
label:
jmp label-100h
because i assume that the bios loads the code at 0000h anyways. i think org is just relevant for the labels.
but i will try that "jmp-start-nop" thingy, thank you very much.
RE:trying to make a program which boots from disk...
Posted: Thu Dec 25, 2003 12:00 am
by wasiliy
ok i downloaded nasm now and got the code to work... thank you very much for your help!