News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Utilizing ReadString with Macros

Started by The Mushroom Fiefdom, August 18, 2023, 12:12:48 PM

Previous topic - Next topic

The Mushroom Fiefdom

Hello!
I am working on an assignment for school and we are just starting our discussion of MACROS. For brevity and the no homework rule I have a very short code section that I can't seem to get working. I am trying to get a string and repeat it back to the user.
Thanks!

Include Irvine32.inc

mGreeting MACRO progStart
push EDX
mov EDX, OFFSET progStart
call WriteString
pop EDX
ENDM

.data
numberReq BYTE "Please enter a signed number: ",0
userInput SDWORD ?

.code
main PROC
mGreeting numberReq
call ReadString
        call CrLf
mGreeting userInput
Invoke ExitProcess,0 ; exit to operating system
main ENDP


zedd151

Hello again, The Mushroom Fiefdom
This topic has been moved into the proper board "Irvine Book Questions".

Sorry, I cannot help with this one. The Irvine system is highly specialised and most members do not have the Irvine32 libraries installed. It is possible that some do have the Irvine32 libraries installed, but you will have to be patient...

jj2007

Hi Mushroom,

Welcome to the forum :thup:

Please check the docs about ReadString: it must know where to copy that string.

Include Irvine32.inc

mGreeting MACRO progStart
push EDX
mov EDX, OFFSET progStart
call WriteString
pop EDX
ENDM

.data
@CrLf db 13, 10, 0
numberReq BYTE "Please enter a signed number: ",0
userInput db "This should be your string", 0 ;SDWORD ?

.code
main PROC
mGreeting numberReq ; print a string
mov edx, offset userInput ; ****** doesn't work, but something similar should *****
call ReadString ; read a string, but where to???
       mGreeting @CrLf ; instead of call CrLf
mGreeting userInput ; print a string, not a SDWORD number
Invoke ExitProcess,0 ; exit to operating system
main ENDP
end main

The Mushroom Fiefdom

Quote from: zedd151 on August 18, 2023, 12:16:24 PMHello again, The Mushroom Fiefdom
This topic has been moved into the proper board "Irvine Book Questions".

Thanks!

Quote from: jj2007 on August 18, 2023, 07:30:50 PMWelcome to the forum :thup:

Please check the docs about ReadString: it must know where to copy that string.

Thanks!
So less of an issue with my MACRO usage and more to do with just properly using ReadString? Also, could you say a little more about using @CrLf in data instead of repeatedly throughout the program?

jj2007

Quote from: The Mushroom Fiefdom on August 18, 2023, 09:58:50 PMcould you say a little more about using @CrLf in data instead of repeatedly throughout the program?

Your macro takes a label, e.g. @CrLf, adds "offset" and passes it to WriteString using edx.

The "call CrLf" probably does the same, but I don't have the complete Irvine library, and the CrLf proc is missing, so I had to find a workaround.

The Mushroom Fiefdom

Quote from: jj2007 on August 18, 2023, 07:30:50 PMHi Mushroom,

Welcome to the forum :thup:

Please check the docs about ReadString: it must know where to copy that string.


Thanks jj, got it working!