我的boot-loader有以下代码:
[org 0x7c00]
KERN_OFFSET equ 0x1000
mov bx, BOOTLOADER_MSG
call print_string
mov [BOOTDISK], dl
mov dl, 0x0 ;0 is for floppy-disk
mov ah, 0x2 ;Read function for the interrupt
mov al, 0x15 ;Read 15 sectors conating kernel
mov ch, 0x0 ;Use cylinder 0
mov cl, 0x2 ;Start from the second sector which contains kernel
mov dh, 0x0 ;Read head 0
mov bx, KERN_OFFSET
int 0x13
jc disk_error
cmp al, 0x15
jne disk_error
jmp $
disk_error:
mov bx, DISK_ERROR_MSG
call print_string
jmp $
%include "print_string.asm"
DISK_ERROR_MSG:
db 'Disk Read Error',0
BOOTLOADER_MSG:
db 'Reading Kernel from sector 2',0
BOOTDISK: db 0
times 510-($-$$) db 0
dw 0xaa55
print_string.asm文件是:
print_string:
pusha
mov ah, 0xe
sub bx, 0x1
print:
add bx, 0x1
mov al, [bx]
int 0x10
cmp al, 0x0
jne print
popa
ret
这个程序使用nasm命令组装好但是如果我尝试使用as86它会显示很多错误:
00001 [org 0x7c00]
00024 %include "print_string.asm"
00027 003B 44 db 'Disk Read Error',0
***** junk after operands............................^
00030 003C 52 db 'Reading Kernel from sector 2',0
***** junk after operands............................^
00034 0000003E> times 510-($-$$) db 0
***** illegal label...................................^
00001 [org 0x7c00]
00004 0004 E8 0000 call print_string
***** unbound label..................................^
***** relocation impossible......................................^
00017 0030 EB 00 jmp $
***** relocation impossible..........................^
00021 0036 E8 0000 call print_string
***** unbound label..................................^
***** relocation impossible......................................^
00022 0039 EB 00 jmp $
***** relocation impossible..........................^
00024 %include "print_string.asm"
00027 003B 44 db 'Disk Read Error',0
***** junk after operands............................^
00030 003C 52 db 'Reading Kernel from sector 2',0
***** junk after operands............................^
00034 0000003E> times 510-($-$$) db 0
***** illegal label...................................^
我想用16位机器语言汇编这段代码。我可以在这段代码中使用nasm吗? 另外,为什么这段代码没有与as86组装?