文件我嘗試包括文件到使用不能包含在NASM
%include "input.asm"
但我boot.asm文件每次我試圖編譯它,我得到一個錯誤,指出NASM無法打開包含文件。
input.inc
與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
input.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擴展名? – Macmade
是的,無論我嘗試它還是說它不能被打開。 Include.inc是一個正常的asm文件,附有幾個標籤和代碼。 – TheMorfeus
'%include「input.inc」'不會包含名爲'Include.inc'的文件。 –