Example:
| Macro
Definition |
Use in
Program |
Macro
Expansion |
_Div Macro N Mov eDx, 0 Mov eBx, &N Div eBx endm |
Call ReadInt _Div 34 Call WriteInt |
Call ReadInt XOR eDX,eDX Mov eBx, 34 Div eBx Call WriteInt |
| Macro
Definition |
Use in
Program |
Macro
Expansion |
_Swap Macro A, B PushA Mov eAx, &A Mov eBx, &B Mov &A, eBx Mov &B, eAx PopA endm |
_Swap X, Y |
2. (4)
| Macro
Definition |
Use in
Program |
Macro
Expansion |
_DCG Macro X, Y local L ifb <&y> exitm endif while&L: cmp &Y, 0 Jne do&L Jmp endwhile&L do&L: _Swap &X, &Y Jmp while&L endwhile&L: endm |
_DCG A, B |
3. (4) Give the macro to compute the power of xn, x is signed and n unsigned 8 bit, both may be constants. The result is in Ax. No overflow checking is performed. Use the following real operations.
Mov eAx, 1 Mov eCx, x Mov Bh, n while: Cmp Bh, 0 JA do Jmp endwhile do: Imul eCx Dec Bh Jmp while endwhile:Part B. Give the results of the following bit operations:
MOV AL,01001010B ZF = _0_ AND AL,00001010B AL = _00001010_ MOV AL,00011100B ZF = _0_ STC CF = _0_ RCR AL,1 AL = _10001110_
4. (3) MOV CL,5 CLC ZF = __ MOV AL,11101110B CF = __ ROL AL,CL AL = _____________ 5. (3) MOV CL, 4 ZF = __ MOV AL,10100000B CF = __ SAR AL, CL AL = _____________ 6. (3) MOV AL, 10010001B ZF = __ OR AL, 10000001B AL = _____________
Document last modified: