Question

I want to create a program that takes in input and prints out the result, but I can't create an empty variable that can take a string input. Here is what I mean:

.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?

I know that I can store an integer in an empty variable, and I could print that, but how can I create an empty string variable?

Any help would be greatly appreciated,

Regards,

Progrmr

Was it helpful?

Solution

.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

OTHER TIPS

Stdin returns a pointer to the string. Just pop the Poniter to eax. [eax] should now contain the first character

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top