Basically I am testing in boch. I have my floppy.img file with the first sector containing code
Code: Select all
org 0x7C00
BITS 16
jmp start
greetings db 'Greetings and welcome ',13d,10d,'$'
BOOTLOADER_NAME db 'Nates BootLoader Stage 1' ,13d,10d,'$'
STARTSECTOR db 2 ;start sector to load
LOADADDRESS dw 8000h ; where to load the sectors into memory
NUMBEROFSECTORS db 1 ; number of bytes to load begining at STARTSECTOR
clear_screen:
mov ax , 600h ; clear screen scroll up function
mov bh , 7h ; white on black background
mov ch , 0h ;upper line (top)
mov cl , 0h ;left col (far left)
mov dh , 18h ;bottom
mov dl , 4Fh ;far right
int 10h ; do the clearing
ret
readsectors_into_memory:
mov ah , 02h ; read function
mov al , NUMBEROFSECTORS ; number of sectors to read
mov ch , 0h ; cylinder number
mov cl , STARTSECTOR ; starting sector to begin reading from
mov dh , 0h ; head number
mov dl , 00h ;drive for floppy
mov bx , LOADADDRESS ; es:ds-> buffer for where the sectors will be loaded in this case 0000:8000h
int 13 ; execute the interrupt for reading into memory
ret
start:
mov ax , 0x9100 ;set the stack to some random address
mov ss , ax
mov sp , 0x9000 ; set the stack pointer to some random address
xor ax , ax
mov ds , ax ;data segment is at segment zero
mov es , ax ; exta segment is at segment zero now.
call clear_screen
mov ah , 13h
mov al , 01h
mov bh , 0h
mov bl , 0Fh
mov dh , 5h
mov dl , 3h
mov cx , greetings
mov bp , cx
mov cx , 22d
int 10h
mov cx , BOOTLOADER_NAME
mov bp , cx
mov cx , 24d
mov dh , 10h
mov dl , 0h
int 10h
readData:
call readsectors_into_memory
jc readData
jmp 0000:8000 ;[color=#BF0000]When I get to this it loops back and seems like it executing the same code over and over and over It is not jumping to the correct place[/color]
Code: Select all
org 0x8000
BITS 16
jmp main
hello db 'This is sector 2!',13d,10d,'$' ;Put any data here!
main:
mov ax , 0
mov ds , ax
mov es , ax
mov ax , 0x1110 ; set the stack to some random place.
mov ss , ax
mov sp , ax
mov ax , 600h ; clear screen scroll up function
mov bh , 7h ; white on black background
mov ch , 0h ;upper line (top)
mov cl , 0h ;left col (far left)
mov dh , 18h ;bottom
mov dl , 4Fh ;far right
int 10h ;do the clearing
; display the string This is sector 2 on the screen
;mov ax , 0
;mov es , ax
mov ah , 13h
mov al , 01h
mov bh , 0h
mov bl , 0Fh
mov dh , 5h
mov dl , 3h
mov cx , hello
mov bp , cx
mov cx , 16d
int 10h
; loop forever
endsss:
jmp endsss
Then it should load sector 2 which just displays 'This is sector 2!
I cann't figure out how to debug very well in boch. I am under windows xp.
The best I can do is look at the bochesout.txt which doesn't tell me very much.
If anybody has the time to run the to file I would greatly appreciatie it.
Since I have been stuck for ever with this. And I am more curious on why it isn't working as opposed to getting it working AHHHHHHHH
Thanks