The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: AgentSmithers on May 25, 2009, 09:56:15 PM

Title: High Level .IF Byte Ptr
Post by: AgentSmithers on May 25, 2009, 09:56:15 PM
.IF byte ptr [esi] == 122

mov byte ptr [esi] == "0"

.ENDIF


Whats the proper syntax to complete this?

Thanks

-Agent
Title: Re: High Level .IF Byte Ptr
Post by: qWord on May 25, 2009, 10:00:46 PM
hi,

--> mov byte ptr [esi],'0'

qWord
Title: Re: High Level .IF Byte Ptr
Post by: AgentSmithers on May 25, 2009, 11:45:29 PM
Thankyou for the Reply, That was verry close but It is ment to be in quote so I get ASCII 48 and not Ascii NUL Term 0

I want to conferm if Line 1 is correct..
Title: Re: High Level .IF Byte Ptr
Post by: dedndave on May 26, 2009, 12:01:51 AM
in masm, single quotes are same as double quotes for string (byte) definitions

'0' is the same as "0"

don't try this, though - lol

"0'
Title: Re: High Level .IF Byte Ptr
Post by: AgentSmithers on May 26, 2009, 01:23:02 AM
Are you sure? Thats odd, but understandable... Is everything in line 1 correct for the .IF conditional statement?
Title: Re: High Level .IF Byte Ptr
Post by: dedndave on May 26, 2009, 01:49:17 AM

.IF byte ptr [esi] == 122

mov byte ptr [esi],'0'

.ENDIF


being rather familiar with ascii numerics, i would use

mov byte ptr [esi],30h

that way, if you look at it with a debugger, the code looks like your source text
Title: Re: High Level .IF Byte Ptr
Post by: AgentSmithers on May 27, 2009, 01:30:33 AM
With MASMv10 is their anyway to see the registers as they change like Debug -t Trace with Command Prompt?
Im having a hard time debugging.
Title: Re: High Level .IF Byte Ptr
Post by: dedndave on May 27, 2009, 01:31:54 AM
i haven't used one yet
if you want to see a register value - put in a print statement

.data
AscBuf  db '12345678',0

.code
.
.
        mov     eax,0FFFFFFFFh
        call    Hex32
        print   edi
        print   chr$(13,10)
.
.
;--------------------------------------------------------------------------

        OPTION PROLOGUE:NONE
        OPTION EPILOGUE:NONE

Hex32   proc

;
;Call With: EAX= DWORD value to convert
;
;  Returns: EDI= offset AscBuf

        std
        mov     edi,offset AscBuf+7
        mov     edx,eax
        mov     ecx,8

Hex32a: and     eax,0Fh
        add     eax,90h
        daa
        adc     eax,40h
        daa
        stosb
        shr     edx,4
        mov     eax,edx
        loop    Hex32a

        cld
        inc     edi
        ret

Hex32   endp

        OPTION PROLOGUE:PrologueDef
        OPTION EPILOGUE:EpilogueDef

;--------------------------------------------------------------------------
Title: Re: High Level .IF Byte Ptr
Post by: AgentSmithers on May 27, 2009, 01:42:21 AM
And this is not working as expected when WriteConsole

.data
                    CRLF db 13,10

start:

                        invoke WriteConsoleA, STDHandle, CRLF, 2, ecx, 0 ;Uses 2Byte Tchar's




This is only part of the code, Any idea why it not writing a Crlf to the console? Am I missing something?
Title: Re: High Level .IF Byte Ptr
Post by: dedndave on May 27, 2009, 01:47:06 AM
STDHandle should be = StdOut Handle
try
addr CRLF
or
offset CRLF

you want to pass an address to the string - not the string

not sure i would use WriteConsoleA for that

anyways - with the masm32 library...

print chr$(13,10)



        sub     esp,4
        mov     ebp,esp
        INVOKE  WriteFile,
                StdOutHndl,
                addr CRLF,
                lengthof CRLF,
                ebp,
                NULL
        pop     ecx


ecx returns number of bytes written
Title: Re: High Level .IF Byte Ptr
Post by: AgentSmithers on May 27, 2009, 02:04:55 AM
Thanks!
Title: Re: High Level .IF Byte Ptr
Post by: AgentSmithers on May 27, 2009, 02:34:05 AM
Invoke addr CRLF worked!