COM File and boot sector. Where BIOS loaded it and what value added at CS? and where did Windows Load an EXE program.

Thank you,
Posted on 2003-04-30 06:28:33 by realvampire
bios loads bootsector at 7C00. Iirc, most bioses will do this as 0000:7C00, but some do it as 07C0:0000. Well, that or the other way around.

COM files are loaded by dos at an arbitrary segment at fixed offset 0x0100. The first 256 bytes of you segment contains "interesting stuff" ^_^

EXE files can also be loaded at arbitrary segments, but they may contain SEG:OFS pairs in the code, so they have a reloc table.

PE EXEs (windows exes) run in the flat address space, and will be loaded at the image base specified in the PE header. If that image base cannot be reserved (very unlikely because of separate process spaces), windows will relocate it. That is of course only possible if the relocation information is present. If not, image can't be loaded.
Posted on 2003-04-30 06:42:41 by f0dder
So if my COM file have a text variable at 0x130 then I must move the address to DX and then Use interupt.

Like this:

000:mov DX,0130h
004:mov ah,9
006:int 21h
0130 db "This is the text$"

Right ?
Posted on 2003-04-30 06:48:05 by realvampire
hey realvampire, dont you just playing with your question that you know the answer already??? :mad:
Posted on 2003-04-30 06:52:50 by dion
No Just make sure, I do the right thing. Assembler and interupt are really destructivable if we had mistake handling it.

Posted on 2003-04-30 08:24:52 by realvampire

Don't forget to initialise the data segment:
Posted on 2003-04-30 12:38:14 by Vortex
I thought DOS would load CS, DS, ES and SS all with the same value.
Posted on 2003-04-30 13:59:44 by Sephiroth3
Here is it. CS set By BIOS at 7C00. Its a Boot loader.

test dl,dl ;I dont know the jmp Opcode <DS:0>
jz 8 <DS:2>
dw <DS:4>
mov ax,7c00
mov ss,ax <Set Stack>
mov sp,03fe <0x3FE byte>
mov bp,sp <sp=bp>
mov ax,cs
mov ds,ax <Data Seg=Code Seg>
mov si,4 <DS:4=TheProgram Data>
mov ax,4f02 <Default Video Mode>
mov bx,105 <1024x768-256 C>
int 10
push FFFF ;Put Return address on Stack
push 0
ret ; Tada, Restarted

Test it Please. BTW if I set SI to above 1MB, will it read there if I use Mov al, at RM ?
Posted on 2003-04-30 22:20:57 by realvampire