Message board for the users of flat assembler.
> DOS > boot and bios? problem with JMP instruction size, boot code.
because dos irq are not there yet.../no system in memory...
I use bios IRQ 10h function 0x0e(AH) to show some text on the screen.
but the program does not work properly:
org 7c00h jmp start times 100 db 0x41 start: mov ax,0000 int 10h mov bx,0x0007 mov di,0 mov cx,6 mov ah,0xe loopek: mov al,byte [szText+di] add di,1 int 10h loop loopek go: jmp go szText db "Atomic", 0
when I run it under windows (org 100h like a standard com)
everything is OK:
I write it by rawrite to a:\ and with an offset 7c00.
Microsoft: brings power of yesterday to computers of today.
Last edited by HarryTuttle on 07 Jan 2004, 16:05; edited 2 times in total
|01 Jan 2004, 23:21||
You forgot about two things:
1) jump instruction in the beginning of the boot loader is assumed to be 3-bytes long, but FASM will generate optimised code so your JMP will occupy only 2 bytes; That's why you need extra NOP instruction;
2) boot loader should have 0x55aa signature in the end.
org 7c00h jmp start nop ; <---- times 100 db 0x41 start: mov ax,0000 int 10h mov bx,0x0007 mov di,0 mov cx,6 mov ah,0xe loopek: mov al,byte [szText+di] add di,1 int 10h loop loopek go: jmp go szText db "Atomic", 0 rb 0x7C00+512-2-$ ; <------- db 0x55 db 0xaa
I tested this code under Bochs only, but it should work with real floppy too .
BTW: on FASM homepage you can find very interesting bootsector expamle - PHBOOT.
|02 Jan 2004, 10:36||
I think BIOS post boots to video mode 3
so you can do direct screen writes ?
PUSH WORD 0xB800 POP ES XOR DI,DI ; ES:DI = screen seg row0,col0,page0 PUSH CS POP DS ; DS = CS CALL PSTR0 DB 4,"Howdy wurld !",0 ;color 4 ;more code here, & exit ? ;put endless loop here, CLI & JMP $ PSTR0: ;Vmem print proc POP SI ;pop return address = message adr LODSB MOV AH,AL ;color Ptop: LODSB ;get AL from DS:SI OR AL,AL ;check for nul=0 end JZ BYEBYE ;exit print proc STOSW ;write AL=char & AH=attribute color to ES:DI screen seg & INC DI JMP Ptop ;loop, Fasm optimizes to short/byte jump BYEBYE: ;Xit JMP SI ; CS:SI = end of string = return address, so jump SI
|15 Feb 2004, 06:31||
< Last Thread | Next Thread >
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.