Page 1 of 1
[asm]boot + img
Posted: Tue Jun 22, 2004 12:01 pm
by PJ
Hi i have big problem
i Have this code:
[BITS 16]
[ORG 0000h]
jmp start
paleta db 0,0,0
db 63,63,63
db 61,61,61
db 59,59,59
db 57,57,57
db 55,55,55
db 53,53,53
db 51,51,51
db 49,49,49
db 47,47,47
db 45,45,45
db 43,43,43
db 41,41,41
db 39,39,39
db 37,37,37
db 35,35,35
db 33,33,33
db 31,31,31
db 29,29,29
db 27,27,27
db 25,25,25
db 23,23,23
db 21,21,21
db 19,19,19
db 17,17,17
db 15,15,15
db 13,13,13
db 11,11,11
db 9,9,9
db 7,7,7
db 5,5,5
db 3,3,3
db 1,1,1
start: mov ax,0013h
int 10h
mov ax,0x07C0
mov ds,ax
mov es,ax
mov fs,ax
mov gs,ax
mov ax,00h
mov ss,ax
mov sp,0xFFFF
MOV SI,paleta
MOV CX,99
MOV DX,03C8H
XOR AL,AL
CLI
OUT DX,AL
CLD
INC DX
REP OUTSB
STI
mov ah,00h
mov dl,00h
int 13h
mov ah,00h
mov dl,00h
int 13h
mov ah,00h
mov dl,00h
int 13h
mov ax,100h
mov es,ax
xor bx,bx
mov ah,02h
mov al,06h
mov ch,03h
mov cl,0ch
mov dl,00h
int 13h
mov bx,0x0C00
mov ah,02h
mov al,12h
mov ch,04h
mov cl,00h
mov dl,00h
int 13h
mov ax,0xA000
mov es,ax
xor ax,ax
mov di,ax
mov ax,100h
mov ds,ax
xor ax,ax
mov si,ax
mov cx,3000h
rep movsb
ret
TIMES 510-($-$$) DB 0
DW 0xAA55
I will read 65 sector to 88 sector to 0100:000 and of the 0100:0000 to A000:0000, in sector 0 is bootloader
I booting....... I look and see black monitor why? in the 65-88 sector is monohromatic picture, i dont know why?
please help ME!!!
Re:[asm]boot + img
Posted: Wed Jun 23, 2004 2:04 am
by Pype.Clicker
i'm still surprised at those people who completely ignore to check the status of a BIOS disk query and hope a coherent behaviour ...
The floppy *will* fail from time to time because of its internal mechanics and *you* have to catch BIOS errors, retry the load command at least 3 times before concluding to a fatal error.
starting writing sectors in memory from 0x100:0000 might not be wise since it may erase your bootloader if you have more than 6C00 bytes of data to load ... your first row of sectors (12 of them iiuc) is 0xC * 0x200 == 0x1800 (so it shouldn't harm)
Iirc, the 'palette setting' required the color index to be refreshed every time a new color will be set. Isn't your loop setting 33 successive different values for color #0 ?
drawing a test line on screen could help you guessing if it worked correctly or not:
Code: Select all
mov ax,0013h
int 0x10
mov ax,0xa000
mov es,ax
xor bx,bx
.loop
mov [es:bx],bl
inc bl
jnz .loop
;; now you can do your palette setting stuff
strange enough, you load 0x1800 bytes at 0x100:0000 and then 0x800 bytes at 0x100:0C00, which means you overwrite a part of what you've been doing before ...
On the other side, you have a large amount of palette data... did you check the whole bootsector wasn't above 512 bytes ?
Re:[asm]boot + img
Posted: Wed Jun 23, 2004 2:45 am
by Brendan
Hi,
PJ wrote:
Code: Select all
start: mov ax,0013h
int 10h
mov ax,0x07C0
mov ds,ax
mov es,ax
mov fs,ax
mov gs,ax
mov ax,00h
mov ss,ax
mov sp,0xFFFF
Your stack should be aligned for better performance - "mov sp,0xFFFE", or "mov sp,0".
PJ wrote:
Code: Select all
MOV SI,paleta
MOV CX,99
MOV DX,03C8H
XOR AL,AL
CLI
OUT DX,AL
CLD
INC DX
REP OUTSB
STI
I'm not sure if the video card will be fast enough to keep up with "rep outsb". You might want to try ".l1: lodsb; out dx,al; loop .l1" to see if it makes a difference. Also some video cards are not VGA compatible, and this code can have unexpected results. You'd be better to use the BIOS function "INT 0x10, AX = 1002h", which would work on a wider variety of video cards (and would take up less space in the boot sector).
You could also add some code here to test if the pallette is set correctly, for e.g.:
Code: Select all
mov bx,0xA000
xor di,di
mov es,bx
mov cx,8192
.l1: mov al,cl
stosb
loop .l1
.die: jmp .die
PJ wrote:
Code: Select all
mov ax,100h
mov es,ax
xor bx,bx
mov ah,02h
mov al,06h
mov ch,03h
mov cl,0ch
mov dl,00h
int 13h
mov bx,0x0C00
mov ah,02h
mov al,12h
mov ch,04h
mov cl,00h
mov dl,00h
int 13h
You've got no way of knowing if any of this worked. The BIOS "load sector" function should be retried up to 3 times before an error message is displayed. Also the BIOS load sector function doesn't work for multiple sectors unless you tell the BIOS about the geometry of the disk first (I think it's INT 0x13, AH = 0x18).
Cheers,
Brendan
Re:[asm]boot + img
Posted: Wed Jun 23, 2004 7:28 am
by PJ
I have new light code. I know where is error. Error is in read sectors. I dont know why
.
i will read sector 1 and save in 0100:0000 and save in A000:0000 from 0100:0000. This code is break down
why?
Code: Select all
[BITS 16]
[ORG 0000h]
jmp start
paleta db 0,0,0
;; still same palette stuff
db 1,1,1
start: mov ax,0013h
int 10h
mov ax,0x07C0
mov ds,ax
mov es,ax
mov fs,ax
mov gs,ax
mov ax,00h
mov ss,ax
mov sp,0xFFFF
MOV SI,paleta
MOV CX,99
MOV DX,03C8H
XOR AL,AL
CLI
OUT DX,AL
CLD
INC DX
REP OUTSB
STI
clc
ready: mov ah,0eh
mov al,41h
mov bl,01h
int 10h
mov ah,00h
mov dl,00h
int 13h
jc ready
mov ax,100h
mov es,ax
xor bx,bx
mov ah,0eh
mov al,01h
mov ch,00h
mov cl,01h
mov dl,00h
int 13h
mov ax,100h
xor bx,bx
mov ds,ax
mov si,bx
mov ax,0xA000
xor bx,bx
mov es,ax
mov di,bx
mov cx,200h
rep movsb
ret
TIMES 510-($-$$) DB 0
DW 0xAA55
Have you some time? If yes---> please write small code a'la this code.
ALL THX
Re:[asm]boot + img
Posted: Wed Jun 23, 2004 8:33 am
by Pype.Clicker
you should jc retry after *each* INT13 ...
Re:[asm]boot + img
Posted: Wed Jun 23, 2004 8:45 am
by PJ
ekhmmmm... ???
If "driver" of floppy is ready --> code read sector ecd.
Please help of this code!! i dont know why this code is broken down
I KNOW!!!!!!!
code of read is error
i dont know why
in 100% reading sector is erroring
help me please
Re:[asm]boot + img
Posted: Wed Jun 23, 2004 9:21 am
by Pype.Clicker
INT 10, AH=2
Return:
CF set on error
Notes: Errors on a floppy may be due to the motor failing to spin up quickly enough; the read should be retried at least three times, resetting the disk with AH=00h between attempts.
http://www.ctyme.com/intr/rb-0607.htm
Re:[asm]boot + img
Posted: Wed Jun 23, 2004 12:39 pm
by PJ
Ok i have normal code
I have new problem:
If I read 1-18 is all ok, if I read 19 and up is error, why?
mov ch,00h mov ch,01h
mov cl,01h mov cl,01h
Code: Select all
[BITS 16]
[ORG 0000h]
jmp start
paleta db 0,0,0
... ; same stuff as initial post
db 1,1,1
start: mov ax,0013h
int 10h
mov ax,0x07C0
mov ds,ax
mov es,ax
mov fs,ax
mov gs,ax
mov ax,00h
mov ss,ax
mov sp,0xFFFF
MOV SI,paleta
MOV CX,99
MOV DX,03C8H
XOR AL,AL
CLI
OUT DX,AL
CLD
INC DX
REP OUTSB
STI
ready: clc
mov ah,0eh
mov al,41h
mov bl,01h
int 10h
mov ah,00h
mov dl,00h
int 13h
jc ready
clc
mov ax,100h
mov es,ax
xor bx,bx
mov ah,02h
mov al,01h
mov ch,00h
mov cl,01h
mov dh,00h
mov dl,00h
int 13h
jc ready
mov ax,100h
xor bx,bx
mov ds,ax
mov si,bx
mov ax,0xA000
xor bx,bx
mov es,ax
mov di,bx
mov cx,200h
rep movsb
ret
TIMES 510-($-$$) DB 0
DW 0xAA55
Re:[asm]boot + img
Posted: Wed Jun 23, 2004 6:40 pm
by Curufir
Because sector 19 isn't on the 2nd cylinder, it's on the second head of the first cylinder.
For the sake of your own (And our) sanity can you please comment your code. Large expanses of uncommented assembly, with undescriptive labelling, won't motivate people to actually bother looking at the source to try and help you. It also won't be fun for you to plough through again a few months from now when it's no longer fresh in your mind.
Re:[asm]boot + img
Posted: Thu Jun 24, 2004 6:51 am
by PJ
OK this is my problem:
......
mov ax,100h
mov es,ax
xor bx,bx
mov ah,02h
mov al,01h
mov ch,00h 0 track
mov cl,01h 1 sector
mov dh,00h
mov dl,00h
int 13h
...... ^-- This code of UP is ok, reading first sector of track 0
......
mov ax,100h
mov es,ax
xor bx,bx
mov ah,02h
mov al,01h
mov ch,01h 1 track
mov cl,01h 1 sector
mov dh,00h
mov dl,00h
int 13h
.......
^-- This code of UP is broken down why? i will reading 19 sector->> first secotor of 1 track
Re:[asm]boot + img
Posted: Thu Jun 24, 2004 7:17 am
by Candy
PJ wrote:
OK this is my problem:
......
mov ax,100h
mov es,ax
xor bx,bx
mov ah,02h
mov al,01h
mov ch,00h 0 track
mov cl,01h 1 sector
mov dh,00h
mov dl,00h
int 13h
...... ^-- This code of UP is ok, reading first sector of track 0
......
mov ax,100h
mov es,ax
xor bx,bx
mov ah,02h
mov al,01h
mov ch,01h 1 track
mov cl,01h 1 sector
mov dh,00h
mov dl,00h
int 13h
.......
^-- This code of UP is broken down why? i will reading 19 sector->> first secotor of 1 track
Terminology fix: the CH content is the cluster number. The combination of cluster * heads + head => track number
Re:[asm]boot + img
Posted: Thu Jun 24, 2004 7:33 am
by PJ
ekhm..
error
ok ok
HELP mEEEE!!
Re:[asm]boot + img
Posted: Thu Jun 24, 2004 8:21 am
by Pype.Clicker
PJ wrote:
ekhm..
error
ok ok
HELP mEEEE!!
okay,
be a big boy, stop crying and start explaining ...
what do make you thing the second one is "broken" ? what do you expect the code to do and what does it do instead ? ...
Also, you must know that
- you may not request several sectors if the first and the last one of your request are not on the same 'track' (iirc, BIOS can deal with switching heads, but not moving heads to another 'cylinder')
- every PC considers sector N, head 0, track Y to be followed by sector 1, head 1, track Y and not sector 1, head 0, track Y+1
- when moving to another track, you're very likely to experience a few read errors as it'll need time for the heads to move and the BIOS may not compensate for this ...
Re:[asm]boot + img
Posted: Thu Jun 24, 2004 8:28 am
by Pype.Clicker
Since you're always restarting the whole process (init, read first track, read next track) on errors, wherever the error occured there's little chance the whole operation can complete.
consider the following:
ready:
RESET
(successful)
INT13 (read track 0, head 0)
(not yet ready -- e.g. spinning too slow)
RESET
(successful)
INT13 (track 0)
(successful)
INT13 (track 1)
(not yet ready -- e.g. still moving arm to track 1)
RESET
(successful)
INT13 (track 0)
(not yet ready -- e.g. moving arm back to track 0)
RESET
(successful)
INT13 (track 0)
(successful)
INT13 (track 1)
(not yet ready -- e.g. still moving arm to track 1)
RESET
(successful)
INT13 (track 0)
... etc ...