flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > is it a BIOS problem? |
Author |
|
sinsi 05 May 2008, 02:24
Is your old laptop old enough to be a 286?
|
|||
05 May 2008, 02:24 |
|
edfed 05 May 2008, 02:37
no, it is my good old PIII OMNIBOOK XE3
and it is at least the 29th time i try to correct this bug. it freeze at "B" debug point. i didn't try this on my 386 and 486, but i'm pretty sure it is ok. thanx! |
|||
05 May 2008, 02:37 |
|
Alphonso 05 May 2008, 08:15
Hi Edfed,
did the same on my PIII notebook. Initializing DS seemed to sort it, at least to 'E' anyway. Maybe "push cs, pop ds" at the start will help. |
|||
05 May 2008, 08:15 |
|
edfed 05 May 2008, 11:17
thanks Alphonso.
it helped, now the problem is to reboot from drive 80h, it reboot from original boot drive (floppy in this case) instead of hard drive. it don't work at all, but i'll find a solution. edit: problem solved, it was DS that wasn't initialised when return from kernel Last edited by edfed on 13 May 2008, 13:38; edited 1 time in total |
|||
05 May 2008, 11:17 |
|
edfed 12 May 2008, 15:50
hello, one more strange problem with the boot loader.
Code: ; This comloader.bin file is a bootloader ; it will be writen on the first sector of a drive ; ; the kernel will be a .com binary ; this binary shall be writen from sector 2 and above ; ;;;;;;;;;;;;;;;;;;;;;;;; sector 1 ; bootloader ; ; ; ;;;;;;;;;;;;;;;;;;;;;;;; sector 2 ; .com binary ; ; ; ; this program can be ; ; any .com program ; ; but shouldn't depend ; ; on dos INT, ; ; a simple ret will ; ; return to the ; ; bootloader ; ;;;;;;;;;;;;;;;;;;;;;;;; up to 70h sectors ;version 05/05/2008 01:50;;;;; comloader: ; ;use16 ; not usefull org 7C00h ; push cs ; pop ds ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; A: ; used as a debug point mov bx,01241h ; will fill the screen with "A" call cls ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; mov si,reload ; point to reload_boot object mov [si+disk.drv],dl ; overwrite the drv field with boot device call disk ; execute the object ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; B: ; "B" debug point mov bx,02342h ; call cls ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;; it hangs there ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;; GRRRRR ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; mov word[si+disk.off],there jmp far dword[si+disk.off]; jump to reloaded boot sector there: ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; C: ; "C" debug point mov bx,03443h ; call cls ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; push cs ; pop ds ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; mov si,kernel ; mov ax,[si+disk.seg] ; point to PSP location mov es,ax ; xor bx,bx ; mov cl,psp.end-psp ; mov di,psp ; @@: ; copy the PSP code at 2000h:0 mov ax,[di+bx] ; mov [es:bx],ax ; add bx,2 ; dec cl ; jne @b ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; D: ; "D" debug point mov bx,04544h ; call cls ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; mov [si+disk.drv],dl ; overwrite the drv param call disk ; will copy it just 100h after PSP, building .com environment ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; E: ; "E" debug point mov bx,05645h ; call cls ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; call far dword[si+disk.off]; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; push cs ; pop ds ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; mov bx,0b101h ; fill the text memory with a blinking smiley call cls ; just for fun while the dos prompt ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; mov si,reboot ; point to the reboot object mov byte[si+disk.drv],80h ; overwrite with C: drive call disk ; will load the bootloader from hard drive jmp far dword[si+disk.off] ; and reboot on this OS. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; cls: ; mov di,80*25*2-2 ; mov ax,0b800h ; mov es,ax ; @@: ; mov [es:di],bx ; sub di,2 ; jnl @b ; ret ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; psp: ; push cs ; pop ds ; mov ax,100h ; call ax ; retf ; .end: ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; align 4 ; reload:; dd disk ; dd 00010002h,1,1000h:7c00h,0;,0 ; disk operation, read the boot sector from floppy at 1000h:7C00h kernel:; dd disk ; dd 00700002h,2,2000h:0100h,0;,0 ; disk operation, read 70h sectors after boot from floppy reboot:; dd disk ; dd 00018002h,1,0000:7c00h,0;,0 ; disk operation, read the boot sector from hard drive at boot entry ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; include 'disk.inc' ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; free = 510-(padding-$$) padding rb free dw 0aa55h ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; macro from the boot an Adam Marquis's sector , an user of FASM board ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; d1 = '0'+ free shr 8 and 0Fh d2 = '0'+ free shr 4 and 0Fh d3 = '0'+ free and 0Fh if d1>'9' d1 = d1 + 7 end if if d2>'9' d2 = d2 + 7 end if if d3>'9' d3 = d3 + 7 end if display d1,d2,d3,'h ' display 'free bytes ',13,10 the problem is simple, it blocks at "B" when i run it at Boot or in bochs, but it works when making the same thing in a dos program: Code: org 100h mov ax,cs mov word[there+2],ax mov si,there-8 mov word[si+8],start jmp far [si+8] start: .... there dd 0:0 |
|||
12 May 2008, 15:50 |
|
revolution 12 May 2008, 16:29
So the same thing as before, you are not initialising the segment for the far call?
Code: mov word[si+disk.off],there mov word[si+disk.off+2],cs ;which segment do you want? Or is this 32bit mode? jmp far dword[si+disk.off]; jump to reloaded boot sector there: |
|||
12 May 2008, 16:29 |
|
edfed 12 May 2008, 17:33
Quote: So the same thing as before, you are not initialising the segment for the far call? not true. and i'm not so stupid to make the same error two consecutive times. i initialise the segment. it is initialised during compilation there: Code: reload:; dd disk ; dd 00010002h,1,1000h:7c00h,0;,0 and used as an object to reload the boot sector elsewhere, then, jump to the far ptr in the structure. in the second case i initialise the ptr with the curent value of CS because i just want to do a jmp far [xx] with xx pointing to a far pointer. and just before the jump, i set the segment part to current cs. in the first case, the far pointer is defined in source code, and will be modified during execution to set th eright address whereto jump... but it don't works. |
|||
12 May 2008, 17:33 |
|
revolution 12 May 2008, 17:50
If 'B' prints and 'C' does not print then the only place for a mistake is the jmp far. So are you sure your segment is correct? Are you sure the offset is correct? Is 'there:' still at the correct offset? Are you changing IP at any point and making all your compiled offsets wrong?
|
|||
12 May 2008, 17:50 |
|
edfed 12 May 2008, 18:08
it worked with the direct far pointer.
Code: jmp 1000h:there i'm sure the segment is correct. i'm sure the offset is correct. "there" is at the right offset, the org 7c00h permit to localise it. ip never changes until the supposed jump. only some calls and ints are made. the disk.inc funtion is not the reason of errors, it don't affect anything. i use the far pointer as a reference where to reload the boot loader, then, i modify the offset field. but it don't works at boot time... it looks like an impossible thing to do. what a pity. maybe it is the default segment for si the guilty... is it possible that si uses es by default in real mode??? |
|||
12 May 2008, 18:08 |
|
revolution 12 May 2008, 18:25
What is the value of disk.off? You haven't shown all the code so it is difficult to know where is your mistake.
And of course si default segment is ds. Why would you thing it is different in realmode? |
|||
12 May 2008, 18:25 |
|
edfed 12 May 2008, 18:57
Quote: What is the value of disk.off? You haven't shown all the code so it is difficult to know where is your mistake. Code: disk: ;.call=0 ; not usefull for bootloader .cmd=0;4 ; then, relocate the fields .drv=1;5 ; and will save 4 bytes by objects. .cnt=2;6 .s=4;8 .h=5;9 .c=6;10 .off=8;12 .seg=10;14 .s0=12;16 .h0=13;17 .c0=14;18 ;.kb0=20 ; not usefull for now, save 4 bytes + source code. .n=2 call .id mov al,[si+.s] mov ah,[si+.h] mov bx,[si+.c] mov cx,[si+.cnt] mov dx,[si+.off] push cx dx es .next: sub word[si+.cnt],.n jl .end push ax bx mov cx,bx mov bl,cl mov cl,ch mov ch,bl shl cl,6 and cl,0c0h or cl,al mov dh,ah pushaw call .atom jnc @f popaw pushaw call .atom jnc @f popaw pushaw call .atom jnc @f .error: popaw pop bx ax clc jmp .tchao @@: add word[si+.off],512*.n popaw pop bx ax inc al cmp al,[si+.s0] jne @f mov al,1 inc ah cmp ah,[si+.h0] jl @f mov ah,0 inc bx cmp bx,[si+.c0] jl .next mov bx,0 @@: jmp .next .atom: call .reset mov bx,[si+.seg] mov es,bx mov bx,[si+.off] mov ah,[si+.cmd] mov al,.n mov dl,[si+.drv] int 13h ret .reset: mov dl,[si+.drv] mov ah,0 int 13h ret @@: clc ret .id: cmp byte[si+.drv],0 jnl .floppy call .reset jc @b mov ah,8 mov dl,[si+.drv] int 13h inc dh mov [si+.h0],dh mov bx,cx and cl,not 0c0h mov [si+.s0],cl mov cl,ch mov ch,bl shr ch,6 inc cx mov [si+.c0],cx @@: ; movzx ax,byte[si+.s0] ; movzx bx,byte[si+.h0] ; mov cx,word[si+.c0] ; imul ax,bx ; imul ax,cx ; shr ax,1 ; mov [si+.kb0],ax stc ret .floppy: mov word[si+.c0],80 mov byte[si+.h0],2 mov byte[si+.s0],18 jmp @b .end: stc .tchao: pop es dx cx mov [si+.off],dx mov [si+.cnt],cx ret Quote:
i assumed that because of the lods instructions. |
|||
12 May 2008, 18:57 |
|
revolution 12 May 2008, 19:34
What happens if you insert this line before the jmp far?
Code: mov word[si+disk.off+2],0x1000 |
|||
12 May 2008, 19:34 |
|
edfed 12 May 2008, 19:45
it don't change anything.
i've tried all possibilities, from reversing the prt:components to overwrite them. i've posted the code as it is supposed to work. but i sould say it is breaking my mind. indeed, thanks for your help.. maybe we'll find the solution. |
|||
12 May 2008, 19:45 |
|
revolution 12 May 2008, 20:02
Code: reload:; dd disk ; dd 00010002h,1,1000h:7c00h,0;,0 Code: .n=2 ... sub word[si+.cnt],.n jl .end |
|||
12 May 2008, 20:02 |
|
edfed 12 May 2008, 20:25
thanks. little story about .n=2 i tryed to increase the speed of disk.read function by reading at least 2 sectors. i forgot this dumb idea right now, as it is not that fast. and i meat some problems to compute the right count of sectors function of .n now it works. thanks a lot revolution... |
|||
12 May 2008, 20:25 |
|
revolution 12 May 2008, 20:29
edfed wrote: the disk.inc funtion is not the reason of errors, it don't affect anything. |
|||
12 May 2008, 20:29 |
|
edfed 12 May 2008, 20:31
Quote:
exact. at least, today, i learnt to be carefull about this kind of assumptions. thanks again. it took me 7 days to decide to ask for help. and now, i have a new version to upload:
|
|||||||||||
12 May 2008, 20:31 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.