EuroAssembler Index Manual Download Source Macros


Sitemap Links Forum Tests Projects

Test t7219: Macro Cube


Source file t7219.asm
      EUROASM DUMP=ON, DUMPALL=YES, DUMPWIDTH=28, LISTMACRO=YES
t7219 PROGRAM FORMAT=BIN, MODEL=SMALL, WIDTH=32, LISTMAP=OFF, LISTGLOBALS=OFF
;;
[CODE]
Cube %MACRO Number ; Define macro which calculates the 3rd power of unsigned integer Number.
       %IF "%Number" !== "EAX"
         MOV EAX,%Number ; Skip this step when Number already is in EAX.
       %ENDIF
       MOV ECX,EAX ; Copy the input value N to register ECX.
       MUL ECX     ; Let EDX:EAX = Number*Number
       JC $+4      ; CF=OF=1 when EDX is nonzero (32bit overflow). Skip the 2nd MUL.
       MUL ECX     ; Let EDX:EAX = Number*Number*Number
     %ENDMACRO Cube; Returns EDX:EAX=Number3, ECX=Number, CF=OF=1 on overflow.
;;
    Cube 5         ; Use the macro to compute 53.
   ENDPROGRAM t7219
Expected listing t7219.asm.lst
| | EUROASM DUMP=ON, DUMPALL=YES, DUMPWIDTH=28, LISTMACRO=YES | |t7219 PROGRAM FORMAT=BIN, MODEL=SMALL, WIDTH=32, LISTMAP=OFF, LISTGLOBALS=OFF | |;; |[CODE] |[CODE] | |Cube %MACRO Number ; Define macro which calculates the 3rd power of unsigned integer Number. | | %IF "%Number" !== "EAX" | | MOV EAX,%Number ; Skip this step when Number already is in EAX. | | %ENDIF | | MOV ECX,EAX ; Copy the input value N to register ECX. | | MUL ECX ; Let EDX:EAX = Number*Number | | JC $+4 ; CF=OF=1 when EDX is nonzero (32bit overflow). Skip the 2nd MUL. | | MUL ECX ; Let EDX:EAX = Number*Number*Number | | %ENDMACRO Cube; Returns EDX:EAX=Number3, ECX=Number, CF=OF=1 on overflow. | |;; |00000000: | Cube 5 ; Use the macro to compute 53. | +Cube %MACRO Number ; Define macro which calculates the 3rd power of unsigned integer Number. |TRUE + %IF "%Number" !== "EAX" |00000000:B805000000 + MOV EAX,%Number ; Skip this step when Number already is in EAX. | + %ENDIF |00000005:89C1 + MOV ECX,EAX ; Copy the input value N to register ECX. |00000007:F7E1 + MUL ECX ; Let EDX:EAX = Number*Number |00000009:7202 + JC $+4 ; CF=OF=1 when EDX is nonzero (32bit overflow). Skip the 2nd MUL. |0000000B:F7E1 + MUL ECX ; Let EDX:EAX = Number*Number*Number | + %ENDMACRO Cube; Returns EDX:EAX=Number3, ECX=Number, CF=OF=1 on overflow. | | ENDPROGRAM t7219
Expected messages t7219.out
I0180 Assembling source file "t7219.asm". I0270 Assembling source "t7219". I0310 Assembling source pass 1. I0330 Assembling source pass 2 - final. I0470 Assembling program "t7219". "t7219.asm"{2} I0510 Assembling program pass 1. "t7219.asm"{2} I0530 Assembling program pass 2 - final. "t7219.asm"{2} I0660 32bit SMALL BIN file "t7219.bin" created, size=13. "t7219.asm"{16} I0650 Program "t7219" assembled in 2 passes with errorlevel 0. "t7219.asm"{16} I0750 Source "t7219" (16 lines) assembled in 2 passes with errorlevel 0. I0860 Listing file "t7219.asm.lst" created, size=2065. I0990 EuroAssembler terminated with errorlevel 0.

▲Back to the top▲