あなたが書いた文字列を返すプログラムを書いています。しかし、それは常に最初の文字なしでそれを印刷します。また、最初のスペースを超えて何も戻さない。NASM - printfは最初の文字を出力しません
例:
IN: test
OUT: est
コード:
extern printf, scanf, exit
global main
section .text
main:
push rbp
;input of string
mov rdi, format
mov rsi, string
mov rax, 0
call scanf
;output of string
mov rdi, format_out
mov rsi, qword [string]
mov rax, 0
call printf
_exit: ;end of program
pop rbp
call exit
section .data
format db "%s", 0
string db 0
format_out db "You wrote: %s", 0
私はに文全体を印刷し、私は「string db
にstring db 0
を変更した場合、それはエラーを示しているが、プログラムが正しく動作することに気づきました残念なことに、私はその情報をどうしたらよいかわからない。答えをありがとう。
「string」は、ユーザーが入力した文字列を格納する変数です。ユーザーが入力する文字数は何文字ですか?変数 'string'のサイズは? –
私は分かりません。 20を最大文字数としましょう。今私は何をしますか? – Zumalo
次に、文字列に2バイト以上を割り当てる必要があります。最大値は –