代碼編譯就好了[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
然後顯示宏文件或至少鏈接到它。 –