The MASM Forum Archive 2004 to 2012

General Forums => The Laboratory => Topic started by: hutch-- on June 18, 2005, 02:34:07 AM

Title: Emulating high level languages macro.
Post by: hutch-- on June 18, 2005, 02:34:07 AM
MASM is reasonably successful at emulating some of the capacity of popular high level languages but its always been very poor at actually getting the same size output file so here is a macro that levels the playing field a little. Judicious use of this macro will make the non-informed user think you wrote the APP in CPP or Delphi.


; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    include \masm32\include\masm32rt.inc
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

comment * -----------------------------------------------------
                        Build this  template with
                       "CONSOLE ASSEMBLE AND LINK"
        ----------------------------------------------------- *

    bloat MACRO lang
      LOCAL cntr
      IFIDN <lang>,<CPP>
        echo Emulating C++
        cntr = 50000
      ELSEIFIDN <lang>,<DELPHI>
        echo Emulating Delphi
        cntr = 50000
      ELSEIFIDN <lang>,<C>
        echo Emulating C with standard runtime libraries
        cntr = 25000
      ELSEIFIDN <lang>,<PASCAL>
        echo Emulating procedural Pascal
        cntr = 20000
      ELSEIFIDN <lang>,<BASIC>
        echo Emulating a basic compiler
        cntr = 5000
      ELSEIFIDN <lang>,<CNRT>
        echo Emulating C without the runtime library
        cntr = 1000
      ELSEIFIDN <lang>,<ASM>
        EXITM
      ELSE
        echo "Please wait, this OP is slow"
        cntr = 100000
      ENDIF
     
      REPEAT cntr
        nop
      ENDM
      align 16
    ENDM

    .code

start:
   
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

    call main

    exit

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

main proc

    cls
    print "Hello World",13,10

    ret

    bloat CPP

main endp

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

end start
Title: Re: Emulating high level languages macro.
Post by: Mark Jones on June 18, 2005, 02:43:27 AM
     :bdg    :bdg    :bdg    :bdg    :bdg    :bdg    :bdg    :bdg
Title: Re: Emulating high level languages macro.
Post by: chep on June 18, 2005, 03:13:50 AM
:naughty: Size is not sufficient! There's still the problem of the speed of execution... :bdg

:U
Title: Re: Emulating high level languages macro.
Post by: zooba on June 18, 2005, 08:47:20 AM
You forgot:

IFIDN <developer>,<MICRO$OFT>
WHILE 1
    nop
ENDM
Title: Re: Emulating high level languages macro.
Post by: doomsday on June 18, 2005, 03:12:46 PM
LOL.  Just the thing for those occasions when your code is just too quick and/or small :)

regards,
-Brent
Title: Re: Emulating high level languages macro.
Post by: daydreamer on June 18, 2005, 11:18:04 PM
 :lol
actually I beat C size with asm proggy, without intentionally fill program with bloat, my asm program is whopping 1 058 816 byte

its a dx9 program which only displays a textured triangle(this is without texture), so I dont know if my includes are included automatically +included by includes could be the problem