## Exercise 7            Name       _________________    Points __/19

Part A. Give the expansions for the following macros.

Example:
 Macro Definition Use in Program Macro Expansion ```_Div    Macro  N         Mov    Dx, 0         Mov    Bx, &N             Div    Bx endm``` ```Call  GetDec _Div  34 Call  PutDec      ``` ```Call  GetDec Mov   Dx, 0 Mov   Bx, 34 Div   Bx Call  PutDec```
1.   (2)
 Macro Definition Use in Program Macro Expansion ```_Swap Macro  A, B       PushA         Mov    Ax, &A              Mov    Bx, &B       Mov    &A, Bx       Mov    &B, Ax       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  Ax, 1
Mov  Cx, x
Mov  Bh, n
while:
Cmp  Bh, 0
Ja   do
Jmp  endwhile
do: Imul Cx
Dec  Bh
Jmp  while
endwhile:```
Part B.    Give the results of the following bit operations:
Examples:
```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:   document.write(document.lastModified);

```