【发布时间】:2013-08-07 06:44:43
【问题描述】:
我尝试使用
将文件包含到我的 boot.asm 文件中%include "input.asm"
但是每次我尝试编译它时,我都会收到一条错误消息,指出 nasm 无法打开包含文件。input.inc IS 与 boot.asm 位于同一目录中
我在这里和谷歌上寻找答案,但没有一个对我有帮助。
是否有一种特殊的方法应该在包含之前编译/格式化包含文件?还是只是我的 nasm 对我咆哮?
编辑:这是包含的代码:
mov ax, 0x07C0 ; set up segments
mov ds, ax mov es, ax
mov si, welcome
call print_string
mov si, welcome2
call print_string
mov si, welcome4
call print_string
jmp .mainloop
%include 'input.asm'
mainloop: ;loop here
输入.asm:
; ================
; calls start here
; ================
print_string:
lodsb ; grab a byte from SI
or al, al ; logical or AL by itself
jz .done ; if the result is zero, get out
mov ah, 0x0E
int 0x10 ; otherwise, print out the character!
jmp print_string
.done:
ret
get_string:
xor cl, cl
.loop:
mov ah, 0
int 0x16 ; wait for keypress
cmp al, 0x08 ; backspace pressed?
je .backspace ; yes, handle it
cmp al, 0x0D ; enter pressed?
je .done ; yes, we're done
cmp cl, 0x3F ; 63 chars inputted?
je .loop ; yes, only let in backspace and enter
mov ah, 0x0E
int 0x10 ; print out character
stosb ; put character in buffer
inc cl
jmp .loop
.backspace:
cmp cl, 0 ; beginning of string?
je .loop ; yes, ignore the key
dec di
mov byte [di], 0 ; delete character
dec cl ; decrement counter as well
mov ah, 0x0E
mov al, 0x08
int 10h ; backspace on the screen
mov al, ' '
int 10h ; blank character out
mov al, 0x08
int 10h ; backspace again
jmp .loop ; go to the main loop
.done:
mov al, 0 ; null terminator
stosb
mov ah, 0x0E
mov al, 0x0D
int 0x10
mov al, 0x0A
int 0x10 ; newline
ret
strcmp:
.loop:
mov al, [si] ; grab a byte from SI
mov bl, [di] ; grab a byte from DI
cmp al, bl ; are they equal?
jne .notequal ; nope, we're done.
cmp al, 0 ; are both bytes (they were equal before) null?
je .done ; yes, we're done.
inc di ; increment DI
inc si ; increment SI
jmp .loop ; loop!
.notequal:
clc ; not equal, clear the carry flag
ret
.done:
stc ; equal, set the carry flag
call print_string
ret
错误信息:
D:\ASMT\boot.asm:14: 致命:无法打开包含文件 `input.asm'
【问题讨论】:
-
刚刚尝试使用我的 NASM 版本(0.98),它可以正常工作,正如预期的那样......可能是您的版本中的错误。您是否尝试过在 .inc 文件中添加 .asm 扩展名?
-
是的,不管我怎么试,还是说打不开。 Include.inc 是一个普通的 asm 文件,带有一些标签和代码。
-
%include "input.inc"不会包含名为Include.inc的文件。 -
@CharlesBailey,我的错,应该在那里写 input.inc。另外,我刚刚更新到 NASM 2.10.09(使用的是 2.07 prev),我仍然得到同样的错误
-
@TheMorfeus 也许试试 YASM...