flat assembler
Message board for the users of flat assembler.

Index > DOS > boot and bios? problem with JMP instruction size, boot code.

Author
Thread Post new topic Reply to topic
HarryTuttle



Joined: 26 Sep 2003
Posts: 211
Location: Poland
HarryTuttle
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:

Code:
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:


why?

I write it by rawrite to a:\ and with an offset 7c00.

regards?
h

_________________
Microsoft: brings power of yesterday to computers of today.


Last edited by HarryTuttle on 07 Jan 2004, 16:05; edited 2 times in total
Post 01 Jan 2004, 23:21
View user's profile Send private message Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard
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.

try:
Code:
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 Wink.
BTW: on FASM homepage you can find very interesting bootsector expamle - PHBOOT.

regards,
Decard
Post 02 Jan 2004, 10:36
View user's profile Send private message Visit poster's website Reply with quote
Bitdog



Joined: 18 Jan 2004
Posts: 97
Bitdog
I think BIOS post boots to video mode 3
so you can do direct screen writes ?
Code:
 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
    

;Bitdog
Post 15 Feb 2004, 06:31
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.