我想创建一个接受输入并打印出结果的程序,但是我不能创建一个可以接受字符串输入的空变量。这就是我的意思:
.data
emptyvar db ???? ; I don't know what to do here
.data?
buffer dd 100 dup(?)
.code
start:
lea eax, buffer
push eax
call StdIn ; get input
; NOW HERE IS WHAT I DON'T KNOW WHAT TO DO:
; I know have input, what I want to do is print that result. But where
; do I store the input and how do I print the result?
我知道我可以在空变量中存储一个整数,我可以打印它,但是如何创建一个空字符串变量?
非常感谢任何帮助,
此致
Progrmr
答案 0 :(得分:1)
.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\masm32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\masm32.lib
.data
msg1 db 'Please type your name',13,10,0
msg2 db 'Nice to see you ',0
.data?
buffer db 100 dup(?)
.code
start:
invoke StdOut,ADDR msg1
invoke StdIn,ADDR buffer,100 ; receive text input
invoke StdOut,ADDR msg2
invoke StdOut,ADDR buffer
invoke ExitProcess,0
END start
答案 1 :(得分:0)
Stdin返回指向字符串的指针。只需将指针弹出为eax即可。 [eax]不应包含第一个字符