Woo. Thanks guys. Now the code works, both the segments and the strcmp. so, last questions:
Because of this topic, it proved that I'm quite a beginner at segments and assembly. So my last question is,
What are some good pdf/websites that I should read though that is really helpful?
Thanks for the help guys
Note: For those who want to know my working code for this problem, here it is.
boot.asm:
Code: Select all
BDA equ 0x0040 ; BDA segment
MEM equ 0x0013 ; Offset to memsize
ReBoot equ 0x0019
SYSTEM_SERVICES equ 0x0015
DISK_IO equ 0x0013
D_STATUS equ 0x0001
D_READ equ 0x0200
D_WRITE equ 0x0300
GET_DP equ 0x0048
SECTORS equ 0x08 ; sectors to read, change to what you need. sectors = file size (bytes) / 512 (bytes)
jmp 0x7c0:Begin ; For quirky BIOS's so we know CS = 7c0H
;----------------------------
; standard variables
;----------------------------
Begin:
mov ax, BDA ; Points to BIOS DATA AREA
mov ds, ax
mov ax, [MEM] ; Get number of 1k pages. Propably 27Fh
shl ax, 6 ; Convert to segment address
sub ah, 16
cli
mov ss, ax
xor sp, sp
sti
mov ax, cs
add ax, 32
mov es, ax
xor bx, bx ; ES:BX = 0x7c0:0
mov ax, D_READ + SECTORS ; AH = 2, AL = 8 sectors to read
mov cx, 2 ; Begin @ sector 2
mov dh, 0 ; Head 0, probably was that already
int DISK_IO
jc Failed
jmp 0:0x7e00 ; Jump to second stage.
times 506 - ($-$$) db 90H
Failed:
int 0x16
int ReBoot
dw 0xAA55
kernel.asm:
Code: Select all
BITS 16
ORG 0x7e00
os_main:
cli
cld
mov ax, 0x0000
mov ss, ax
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov sp, 0
sti
; do what you want here
times 0x1000 db 0x0 ; this is to make the file exactly 4kb or 8 sectors on disk. If you need another size,
; change this to want you want but remember to change SECTORS in bootloader