die Version des Linkers aus dem MASM32-Paket ist nur in der Lage 32-Bit-Code zu linken. Dies ist der Bootloader aber nicht. Um 16-Bit-Code linken zu können benötigst du diese Version des Linkers: http://download.microsoft.com/download/ ... Lnk563.exe.
Der vorliegende Bootloader-Code ist anscheinend nicht für MASM geschrieben worden, sondern für einen anderen Assembler, da MASM haufenweise Fehler ausgibt.
Ich habe den Code dahingehend verändert, dass MASM keine Fehler ausgibt:
Code: Alles auswählen
; Datei: test.asm
.386
.model TINY
.code
start:
org 7C00h
jmp label1
;start:
label1:
; Update the segment registers
mov ax, cs
mov ds, ax
mov es, ax
init_memory:
; set stack
cli
mov ax, 9000h
mov ss, ax
mov sp, 0ffffh
sti
read_drive_number:
; save drive number
mov [bootdrv], dl
make_stuff:
; say hello
lea ax, hello_string
mov [string], ax
call print_string
check_for_386:
; check if we have an CPU >= 386
pushf
pushf
pop bx; old FLAGS -> BX
mov ax,bx
xor ah,70h; try changing b14 (NT)...
push ax; ... or b13:b12 (IOPL)
popf
pushf
pop ax; new FLAGS -> AX
popf
xor ah,bh; 32-bit CPU if we changed NT...
and ah,70h; ...or IOPL
; found -> say it make next
jne is_386
; not found -> error string and stop
lea ax, found_not_386_string
mov [string], ax
call print_string
jmp run_to_death
is_386:
; say that we have found an 386
lea ax, found_386_string
mov [string], ax
call print_string
read_boot_loader:
; read the rest of the boot loader
reset_disk:
mov ah, 0;
mov dl, [bootdrv]
int 13
jnc load_sectors
lea ax, error_reset_disk_string
mov [string], ax
call print_string
jmp run_to_death
load_sectors:
mov ax, 0000h
mov es, ax
mov ah, 02h
mov al, 1;(end_boot_loader / 512)
mov cx, 2
mov dx, 0
mov dl, [bootdrv]
mov bx, 7e00h
int 13
jnc load_sectors_finished
; loaded?
cmp ah, 80h
je load_sectors
;failed! error string and end
lea ax, failed_reading_disk_string
mov [string], ax
call print_string
jmp run_to_death
load_sectors_finished:
; give an message that we got the rest of the boot loader
lea ax, loaded_sectors_string
mov [string], ax
call print_string
; run the second stage of the boot loader
jmp boot_loader_stage_2
run_to_death:
; death end after errors
jmp run_to_death
print_string:
; function to print strings
mov si, [string]
print_string_start:
lodsb
or al, al
jz print_string_end
mov ah, 0Eh
mov bx, 0007h
int 10h
jmp print_string_start
print_string_end:
retn
bootdrv db 0
string dw 0
hello_string db init kernel, 13, 10, 0
found_386_string db 386 found, 13, 10, 0
found_not_386_string db 386 not found, 13, 10, 0
error_reset_disk_string db couldnt reset disk, 13, 10, 0
failed_reading_disk_string db couldnt read out of disk, 13, 10, 0
loaded_sectors_string db read disk without problems, 13, 10, 0
ORG 7DFDH
;times 510-($-$$) db 0
dw 0AA55h
; the second stage of the boot loader is important
; for all the other stuff. -> to get into protected
; mode and such
boot_loader_stage_2:
lea ax, boot_loader_stage_2_string
mov [string], ax
call print_string
run_to_death_2:
jmp run_to_death_2
boot_loader_stage_2_string:
db starting boot loader stage 2!, 13, 10, 0
end_boot_loader:
; **********************************
; ***********End Boot Loader********
; **********************************
END startwobei link16.exe der Linker aus dem oben genannten Archiv ist.ml /AT /c test.asm
link16 /TINY test.obj
Marwin