News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

High Level .IF Byte Ptr

Started by AgentSmithers, May 25, 2009, 09:56:15 PM

Previous topic - Next topic

AgentSmithers

.IF byte ptr [esi] == 122

mov byte ptr [esi] == "0"

.ENDIF


Whats the proper syntax to complete this?

Thanks

-Agent

qWord

hi,

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

qWord
FPU in a trice: SmplMath
It's that simple!

AgentSmithers

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..

dedndave

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'

AgentSmithers

Are you sure? Thats odd, but understandable... Is everything in line 1 correct for the .IF conditional statement?

dedndave


.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

AgentSmithers

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.

dedndave

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

;--------------------------------------------------------------------------

AgentSmithers

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?

dedndave

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


AgentSmithers