The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Neil on July 05, 2010, 06:02:50 PM

Title: write macro
Post by: Neil on July 05, 2010, 06:02:50 PM
What if any is the advantage of the write MACRO as against using just plain StdOut
Title: Re: write macro
Post by: jj2007 on July 05, 2010, 06:10:47 PM
Quote from: Neil on July 05, 2010, 06:02:50 PM
What if any is the advantage of the write MACRO as against using just plain StdOut
It avoids Repetitive Stress Injury (http://www.google.it/search?q=Repetitive+Stress+Injury&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-GB:official&client=firefox-a).
Title: Re: write macro
Post by: oex on July 05, 2010, 06:13:27 PM
!RSI (http://en.wikipedia.org/wiki/Repetitive_strain_injury) :lol
Title: Re: write macro
Post by: Neil on July 05, 2010, 06:21:16 PM
So it's a physical advantage rather than better code Hmm!
Title: Re: write macro
Post by: Neil on July 05, 2010, 06:58:05 PM
Getting a bit more serious I have number of strings  each one having its own label, the list of labels (Addresses) will be be put in a list & esi will be used as a pointer to one of the labels something like this :-

txt1 db "some text",0
txt2 db "some text",0
txt3 db "some text",0
txt4 db "some text",0

List DD txt1
      DD txt2
      DD txt3
      DD txt4

Is it feasable to then use Invoke StdOut,esi
Title: Re: write macro
Post by: Tedd on July 05, 2010, 07:58:33 PM
Most things are feasible, but that doesn't mean they're sensible :lol

Use GetStdHandle to get STD_OUTPUT_HANDLE, save it, and then use that as the file handle in WriteFile and write each string as you get its pointer.
Title: Re: write macro
Post by: jj2007 on July 05, 2010, 07:58:59 PM
include \masm32\include\masm32rt.inc

.data
List DD txt1, txt2, txt3, txt4, 0
txt1 db "some text A",0
txt2 db "some text B",0
txt3 db "some text C",0
txt4 db "some text D",0

.code
start: mov esi, offset List
.Repeat
lodsd
.Break .if !eax
print eax, 13, 10
.Until 0
inkey "We are done"
exit

end start


Now if you want to see nice little StdOut, pardon: WriteFile calls, run the exe with Olly :bg
Title: Re: write macro
Post by: Neil on July 06, 2010, 05:41:22 AM
Thanks for your suggestions, I'll do some tests when I've written some more code, I'm in the planning stage at the moment.