0
ここにアセンブリプログラムがあります。これは文字列を印刷し、何らかのテキストを入力させ、同じテキストを再度印刷して、プログラムを終了するのを待ちますWin32ネイティブ関数のみを使用します。
問題は、ユーザーが入力した文字列を印刷することを除いて、すべてが機能しているように見えるということです。空白の改行を表示するだけです。ここで動作するコードです -x86アセンブリで入力されたテキストを印刷できません
global _main
extern [email protected]
extern [email protected]
extern [email protected]
extern [email protected]
section .text
_main:
mov ebp, esp
sub esp, 12
push -11
call [email protected]
mov ebx, eax
push 0
push dword [ebp - 12]
lea ecx, [_msg_end - _msg]
push ecx
lea edx, [_msg]
push edx
push ebx
call [email protected]
push -10
call [email protected]
mov ebx, eax
push 0
lea ecx, [ebp - 8]
push ecx
push 20
lea edx, [ebp - 4]
push edx
push ebx
call [email protected]
push -11
call [email protected]
mov ebx, eax
push 0
push dword [ebp - 12]
lea ecx, [ebp - 8]
push ecx
lea edx, [ebp - 4]
push edx
push ebx
call [email protected]
push -10
call [email protected]
mov ebx, eax
push 0
lea ecx, [ebp - 8]
push ecx
push 1
lea edx, [ebp - 4]
push edx
push ebx
call [email protected]
push 0
call [email protected]
_msg:
db "Hello, world!", 10
_msg_end:
EDIT:
global _main
extern [email protected]
extern [email protected]
extern [email protected]
extern [email protected]
section .bss
_input_buf: resb 20
section .text
_main:
mov ebp, esp
sub esp, 8
push -10
call [email protected]
mov ebx, eax
push 0
lea ecx, [ebp - 4]
push ecx
push 20
lea eax, [_input_buf]
push eax
push ebx
call [email protected]
push -11
call [email protected]
mov ebx, eax
push 0
lea ecx, [ebp - 8]
push ecx
mov edx, [ebp - 4]
push edx
lea eax, [_input_buf]
push eax
push ebx
call [email protected]
push 0
call [email protected]
どのように仕事ができますか?あなたはバッファのためのスペースを予約していません。 –
はい私は、最大20文字の長い文字列を読んだ後にecxの代わりに8をスタックにプッシュし、プログラムを実行して「Benjamin」と入力するとしましょう。それから "Benjamin"を出力します。 – Benjamin