在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