The MASM Forum

Miscellaneous => Irvine Book Questions. => Topic started by: The Mushroom Fiefdom on August 18, 2023, 12:12:48 PM

Title: Utilizing ReadString with Macros
Post by: The Mushroom Fiefdom on August 18, 2023, 12:12:48 PM
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

Title: Re: Utilizing ReadString with Macros
Post by: zedd151 on August 18, 2023, 12:16:24 PM
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...
Title: Re: Utilizing ReadString with Macros
Post by: jj2007 on August 18, 2023, 07:30:50 PM
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
Title: Re: Utilizing ReadString with Macros
Post by: The Mushroom Fiefdom on August 18, 2023, 09:58:50 PM
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?
Title: Re: Utilizing ReadString with Macros
Post by: jj2007 on August 18, 2023, 10:04:32 PM
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.
Title: Re: Utilizing ReadString with Macros
Post by: The Mushroom Fiefdom on August 19, 2023, 05:53:02 AM
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!
Title: Re: Utilizing ReadString with Macros
Post by: zedd151 on August 19, 2023, 06:18:47 AM
Quote from: The Mushroom Fiefdom on August 19, 2023, 05:53:02 AMThanks jj, got it working!
:thumbsup:    :biggrin: