News:

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

masm uses .if instead of jmp etc?

Started by xellos, November 01, 2010, 07:50:47 PM

Previous topic - Next topic

xellos


box


xellos


Vortex

Quote from: xellos on November 01, 2010, 08:00:33 PM
so you can replace .if  with jmp?


.IF is a high-level construct, an important element of Macro Assemblers like Masm. You can replace .IF like the following :


include     IFtest.inc

BUFFER_SIZE equ 100

.data

msg1        db 'Please type your name :',13,10,0
msg2        db 'You did not type your name.',0
msg3        db 'Nice to meet you %s',0

.data?

buffer      db BUFFER_SIZE dup(?)

.code

start:

    invoke  crt_printf,ADDR msg1
    invoke  StdIn,ADDR buffer,BUFFER_SIZE

    invoke  StrLen,ADDR buffer
    sub     eax,2   ; remove CR+LF

    .IF eax==0

        invoke  crt_printf,ADDR msg2

    .ELSE

        invoke  crt_printf,ADDR msg3,ADDR buffer

    .ENDIF

    invoke  ExitProcess,0

END start


Converted to :


    invoke  StrLen,ADDR buffer
    sub     eax,2   ; remove CR+LF

    test    eax,eax
    jnz     @f

    invoke  crt_printf,ADDR msg2
    jmp     _exit

@@:

    invoke  crt_printf,ADDR msg3,ADDR buffer

_exit:   

    invoke  ExitProcess,0