News:

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

Emulating high level languages macro.

Started by hutch--, June 18, 2005, 02:34:07 AM

Previous topic - Next topic

hutch--

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
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Mark Jones

     :bdg    :bdg    :bdg    :bdg    :bdg    :bdg    :bdg    :bdg
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

chep

:naughty: Size is not sufficient! There's still the problem of the speed of execution... :bdg

:U

zooba

You forgot:

IFIDN <developer>,<MICRO$OFT>
WHILE 1
    nop
ENDM

doomsday

LOL.  Just the thing for those occasions when your code is just too quick and/or small :)

regards,
-Brent

daydreamer

 :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