flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Loading a sector and executing it.

Author
Thread Post new topic Reply to topic
windwakr



Joined: 30 Jun 2004
Posts: 827
windwakr 22 Jul 2009, 21:43
Hello, I don't really have any experience in loading a sector off a floppy. Why doesn't my code print an 'a' on the screen after its done fading? Is it a problem in my floppy loading code or my code to jump to loaded sector?
Sorry for the messy code, thats just how I write. Confused


EDIT: CODE FIXED
BOOT CODE:
Code:
;WIND OS
;Bootloader v0.000001 beta....no actual bootLOADER yet, just the boot part lol
;By ------ aka windwakr
format binary as "img"

org 7C00h

use16

;Start of code
bootloader:

cli
xor ax,ax
mov ds,ax
mov es,ax
mov fs,ax
mov gs,ax
mov ss,ax
mov sp,0FFFFh
sti

mov ax,03h
int 10h

mov cx,2000h
mov ah,1
int 10h

mov ax,1003h
xor bx,bx
int 10h

mov si,hellomsg
mov di,1936   ;8 in, 13th line
mov bl,00001001b ;Bright Blue text
call prntstr

mov cx,27 ;wait approximately 1.48 seconds
mov bx,[es:046ch]
waiter:
mov ax,[es:046ch]
cmp bx,ax
je waiter
mov bx,ax
loop waiter

mov cx,64
mov bx,[es:046ch]
colorloop:
mov ax,[es:046ch]
cmp bx,ax
je colorloop
mov bx,ax
mov al,0
mov dx,03c8h
out dx,al
mov al,[color]
inc dx
out dx,al
out dx,al
out dx,al
inc [color]
inc [counter]
cmp [counter],3
jnz @f
mov [counter],0
mov dx,03c8h
mov al,39h
out dx,al
inc dx
add [color2],2
mov al,[color2]
out dx,al
out dx,al
mov al,63
out dx,al
@@:
loop colorloop

push es
push 0B800h
pop es
mov di,1936
mov al,0
mov cx,200
rep stosb
pop es

mov dx,03c8h
mov al,39h
out dx,al
inc dx
mov al,21
out dx,al
out dx,al
mov al,63
out dx,al

mov cx,64
mov bx,[es:046ch]
@@:
mov ax,[es:046ch]
cmp bx,ax
je @b
mov bx,ax
mov al,0
mov dx,03c8h
out dx,al
mov al,[color3]
inc dx
out dx,al
out dx,al
out dx,al
dec [color3]
loop @b

;Kernel will be loaded to 1000h:0000h

mov cl,0
@@:
mov ax,0
mov dl,0
int 13h
jnc loader
inc cl
cmp cl,3
jne @b
errormsg:
mov si,error
mov di,1996
mov bl,00001100b ;Bright RED text
call prntstr
jmp $
loader:
mov ax,1000h
mov es,ax
xor bx,bx
mov ah,02h
mov al,01h
mov ch,0
mov cl,2
xor dx,dx
int 13h
jnc @f
inc [counter2]
cmp [counter2],3
jne loader
jmp errormsg
@@:

mov ax,1000h
mov es,ax
mov ds,ax
mov gs,ax
mov fs,ax
mov sp,0FFFFh
push word 1000h
push word 0
retf

prntstr:
pusha
push es
mov dx,es
push 0B800h
pop es
@@:
lodsb
or al,al
jz @f
stosb
mov al,bl
stosb
jmp @b
@@:
pop es
popa
ret

;DATA

hellomsg db 'Welcome to the future of Operating systems, Welcome to WIND OS.',0
error db 'ERROR',0
color db 0
color2 db 21
color3 db 63
counter db 0
counter2 db 0

times 510-($-$$) db 0

dw 0AA55h   
    



second sector
Code:
org 0

push 0B800h
pop es

mov di,10
mov al,'a'
stosb
mov al,01111001b
stosb

jmp $

times 512-($-$$) db 0                    
    

_________________
----> * <---- My star, won HERE


Last edited by windwakr on 15 Jul 2012, 20:56; edited 3 times in total
Post 22 Jul 2009, 21:43
View user's profile Send private message Reply with quote
windwakr



Joined: 30 Jun 2004
Posts: 827
windwakr 23 Jul 2009, 01:19
*FACEPALM*
Ugh...always the simple things......in my loader code after the floppy reset I have "jnc @f" thats a remnant of when I just used @@'s for labels in the whole floppy loader. But as it got more complex with error checking I had to rename the part it jumped to "loader". I guess I forgot to update that jump. Works fine now.
Post 23 Jul 2009, 01:19
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.