Hello, I have been working on this a got some of the code to work now I need to figure out how to get the string that is stored in the buffer into the variable fName. I just dont know how to do that I tried using the
mov fName, ADDR buffer but that gave me an error. So how should I go about doing this.
Here is what I have so far and this works but I want to store the contents of read console in the firstN variable and not read it from the buffer.
TITLE MASM Template						(main.asm)

; Description:
;
; Revision date:

INCLUDE Irvine32.inc
BufSize = 80
.data
endl EQU <0dh,0ah> ; end of line sequence

;variable holders
firstN db ?
fNSize db ($-firstN)

;messages for getting input
fName LABEL BYTE
BYTE "Enter your first name", endl
fNameSize DWORD ($-fName)

;output handlers
consoleHandle HANDLE 0    ; handle to standard output device
bytesWritten  DWORD ?      ; number of bytes written

;input handlers
buffer BYTE BufSize DUP(?)
stdInHandle HANDLE ?
bytesRead  DWORD ?

.code
main PROC
  ; Get the console output handle:
INVOKE GetStdHandle, STD_OUTPUT_HANDLE
mov consoleHandle,eax

  ; Write a string to the console:
INVOKE WriteConsole,
  consoleHandle, ; console output handle
  ADDR fName,      ; string pointer
  fNameSize, ; string length
  ADDR bytesWritten, ; returns num bytes written
  0     ; not used

  ; Get handle to standard input
INVOKE GetStdHandle, STD_INPUT_HANDLE
mov stdInHandle,eax

  ; Wait for user input
INVOKE ReadConsole, stdInHandle, ADDR buffer,
  BufSize, ADDR bytesRead, 0
 
INVOKE WriteConsole,
  consoleHandle,        ; console output handle
  ADDR buffer,          ; string pointer
  bytesRead,            ; string length
  ADDR bytesWritten,    ; returns num bytes written
  0                    ; not used
INVOKE ExitProcess,0
main ENDP
END main


Thanks for any help
Posted on 2011-11-30 14:35:44 by lordgus
Start by making the "firstN" variable big enough to hold the input - you've only got one byte - same size as buffer would be good. Then you can copy the input from the buffer to firstN (rep movsb, perhaps)... but it would be much simpler to read it directly to the variable.

Best,
Frank

Posted on 2011-11-30 23:21:38 by fbkotler
Ah thank for that it helped out a lot  :lol:
Posted on 2011-12-06 09:11:31 by lordgus