assembly nasm -错误:行首应有标签或说明

l7mqbcuq  于 2023-08-06  发布在  其他
关注(0)|答案(3)|浏览(80)

你好,我是一个汇编新手(今天刚开始),在做this tutorial中所说的事情时遇到了这个问题。我用这个文本创建了一个asm文件:

bits    16
org     0x7c00
jmp     Main

:In=  si = string, ah = 0eh, al = char, Out= character screen
Print:
lodsb
cmp     al, 0
je      Done
mov     ah, 0eh
int     10h
jmp     Print

Done:
ret

Main
mov     si, msg
call Print

cls
hlt

msg     db  "Hello World",0

times 510 - ($-$$)      db      0

dw      0xAA55

字符串
在我的asm文件夹中,我有一个nasm和nasmpath的副本,我也有一个到bochs的快捷方式。我想做的是把它转换成一个bin文件。当我把这个命令:

nasm -f bin boot.asm -o boot.bin


我得到这个错误

boot.asm:5: error: label or instruction expected at the start of line


我想知道这是一个糟糕的教程还是我输入错误的东西。我也想知道“标签或说明”是什么意思。

pieyvz9o

pieyvz9o1#

[org 0x0100]
jmp启动
截面数据
name db'Name:Ali shan',0
vuid db'VUID:bc210410288',0
vuid_asc db'vuid sorted:001122488',0 vuid_desc db'vuid sorted:884221100',0
Current_values db vuid-vuid
节文本开始; mov ah,0 mov al,3 int 0x10
mov ah,0x0e mov si,name call print_string_color
mov al,0x0d int 0x10 mov al,0x0a int 0x10 mov si,current_values调用print_string_color
mov ax,0 mov es,ax cli mov word[es:9*4],kbisr mov [es:9*4+2],cs sti l1:mov ah,0 int 0x16 cmp al,27 jne l1 mov ax,0x4c00 int 0x21
kbisr:push ax push es mov ax,0xb800 mov es,ax in al,0x60 cmp al,0x2a je.left_shift_pressed cmp al,0x36 je.right_shift_pressed
mov ax,0 int 0x10 jmp.end
.left_shift_pressed:mov ax,0 int 0x10 mov ah,0x0e mov si,name call print_string_color
mov al,0x0d int 0x10 mov al,0x0a int 0x10 mov si,vuid调用print_string_color
mov al,0x0d int 0x10 mov al,0x0a int 0x10 mov si,vuid_desc call print_string_color
jmp end .right_shift_pressed:mov ax,0 int 0x10 mov ah,0x0e mov si,name call print_string_color
mov al,0x0d int 0x10 mov al,0x0a int 0x10
mov si,vuid call print_string_color mov al,0x0d int 0x10 mov al,0x0a int 0x10
mov ah,0x0e mov si,vuid_asc调用print_string_color
.end:mov al,0x20 out 0x20,al pop es pop ax iret print_string_color:lodsb cmp al,0 je.done mov ah,0x0e mov bh,0 int 0x10 jmp priny_string_color
.done:ret

9gm1akwq

9gm1akwq2#

在第5行中使用注解。要将一行标记为注解,需要使用分号。“标签或指令”意味着每一行必须是指令(如mov、add等操作码),或者它必须是标签(如Print:)或后面跟着指令的标签。

ekqde3dh

ekqde3dh3#

您还应该将冒号放在Main和cls之后

bits    16
org     0x7c00
jmp     Main

;In=  si = string, ah = 0eh, al = char, Out= character screen
Print:
lodsb
cmp     al, 0
je      Done
mov     ah, 0eh
int     10h
jmp     Print

Done:
ret

Main:
mov     si, msg
call Print

cls:
hlt

msg     db  "Hello World",0

times 510 - ($-$$)      db      0

dw      0xAA55

字符串

相关问题