nasm:disk.asm:32:错误:符号'print'未定义

时间:2019-10-12 19:24:39

标签: assembly x86 nasm bootloader

我正在按照操作系统教程进行操作,我正在使用nasm,并且已指示我运行此命令来编译名为disk.asm的文件的源代码:

nasm -f bin disk.asm -o disk.bin

并且我不断收到以下错误:

disk.asm:32: error: symbol `print' undefined
disk.asm:33: error: symbol `print_nl' undefined
disk.asm:35: error: symbol `print_hex' undefined
disk.asm:40: error: symbol `print' undefined

这是disk.asm的源代码:

; load 'dh' sectors from drive 'dl' into ES:BX
disk_load:
pusha
; reading from disk requires setting specific values in all registers
; so we will overwrite our input parameters from 'dx'. Let's save it
; to the stack for later use.
push dx

mov ah, 0x02 ; ah <- int 0x13 function. 0x02 = 'read'
mov al, dh   ; al <- number of sectors to read (0x01 .. 0x80)
mov cl, 0x02 ; cl <- sector (0x01 .. 0x11)
             ; 0x01 is our boot sector, 0x02 is the first 'available'        sector
mov ch, 0x00 ; ch <- cylinder (0x0 .. 0x3FF, upper 2 bits in 'cl')
; dl <- drive number. Our caller sets it as a parameter and gets it    from BIOS
; (0 = floppy, 1 = floppy2, 0x80 = hdd, 0x81 = hdd2)
mov dh, 0x00 ; dh <- head number (0x0 .. 0xF)

; [es:bx] <- pointer to buffer where the data will be stored
; caller sets it up for us, and it is actually the standard location  for int 13h
int 0x13      ; BIOS interrupt
jc disk_error ; if error (stored in the carry bit)

pop dx
cmp al, dh    ; BIOS also sets 'al' to the # of sectors read. Compare it.
jne sectors_error
popa
ret


disk_error:
mov bx, DISK_ERROR
call  print 
call print_nl
mov dh, ah ; ah = error code, dl = disk drive that dropped the error
call print_hex ; check out the code at http://stanislavs.org/helppc    /int_13-1.html
jmp disk_loop

sectors_error:
mov bx, SECTORS_ERROR
call print

disk_loop:
jmp $

DISK_ERROR: db "Disk read error", 0
SECTORS_ERROR: db "Incorrect number of sectors read", 0

有人注意到代码有什么问题吗?谢谢您提前提供的所有帮助。

0 个答案:

没有答案