在NASM我有strconst_0 dw 5, 0, __utf16__('hello')
(单反引号)作为字符串从字符串文字中检索单词?
我试图访问这样的“h”(其中,[EBP + 8]是0并且[EBP + 4]是的地址字符串)
mov eax, [ebp+8] ; get the index
mov ebx, [ebp+4] ; get the address
movzx eax, word [ebx + 2 * eax + 4]
push eax
call print_char ; call the print function
然而,当我运行此代码,只是一个空字符打印
编辑:全部房源
main:
pop edx
push ebp
mov ebp, esp
sub esp, 4
mov [ebp-4], edx
mov eax, strconst_0
push eax
push dword 0
call getChar
add esp, 8
push eax
call printChar
add esp, 4
mov edx, [ebp-4]
add esp, 4
pop ebp
push edx
ret
getChar:
pop edx
push ebp
mov ebp, esp
sub esp, 4
mov [ebp-4], edx
mov eax, [ebp+8]
mov ebx, [ebp+4]
movzx eax, word [ebx + 2 * eax + 4]
push eax
pop eax
mov edx, [ebp-4]
add esp, 4
pop ebp
push edx
ret
OT,但是,为什么这么多的代码来计算地址?尤其是那个双倍宽度的mul ..'movzx eax,word [ebx + 2 * eax + 4]' – harold 2013-04-27 13:32:13
不知道你可以用地址来做 – CallumDev 2013-04-27 13:36:27
不错,对不对?但是这并不能解决这个问题,我不知道什么是错的 – harold 2013-04-27 13:41:33