代码编译就好了[NASM
]代码崩溃(议会)
但只要我输入我的第一个值,它崩溃
我不知道什么是错,我们的目标是输入的字符串,并输出字符串的反向,而所有在一个循环重复,如果用户(“Y”或“Y”)说是
**.DATA
; Initialized Data Definitions
strlength EQU 40
PromptStr dd "Please input a string (must be less than 40 characters long): ", 0
OutputStr dd "The reverse string is: ", 0
AgainStr dd "Would you like ot try again? ('Y' or 'y' for yes): ", 0
.UDATA
; Uninitialized Data Definitions
string resb strlength
.CODE
; Program Code
.STARTUP
nwln ; start output at a new line
PutStr PromptStr
nwln
while:
GetStr string
mov EBX, string
loop_in:
push dword[EBX]
add EBX, 4
cmp dword[EBX], 0
jnz loop_in
loop_out:
XOR EBX, EBX
pop EBX
PutCh [EBX]
cmp dword[EBX], 0
jnz loop_out
nwln
PutStr AgainStr
GetStr EBX
mov AL, [EBX]
cmp AL, 'Y'
jz while
cmp AL, 'y'
jz while
Pause
.EXIT**
我改变第一环路到
loop_in:
mov AL, [EBX]
push byte[AL]
add EBX, 4
cmp byte[AL], 0
jnz loop_in
,并即时得到这个错误“错误:无效的有效地址”
当我更改为“字节”
loop_in:
push byte[EBX]
add EBX, 4
cmp byte[EBX], 0
jnz loop_in
我得到“错误:操作码和操作数的组合无效”
为{add EBX,4}
所以我改变了
loop_in:
push EBX
inc EBX
cmp byte[EBX], 0
jnz loop_in
loop_out:
XOR EBX, EBX
pop EBX
PutCh [EBX]
cmp byte[EBX], 0
jnz loop_out
,现在它编译,我走到这一步
Please input a string (must be less than 40 characters long):
asdf
fdsaêë
崩溃到Windows
前
使用调试器,通过步入机器指令。 'PutStr'不是一个汇编指令。 –
使用宏文件 – BKreger
然后显示宏文件或至少链接到它。 –