You are on page 1of 3

Sheet 4 Solution

[9] What is wrong with a MOV CS, AX instruction?

CS cannot be a destination for a move statement, if the value of CS changed,


the program flow changed.
[10] Which registers move onto the stack with the PUSHA instruction?

PUSHA (push all) instruction: copies the registers to the stack in the following
order: AX, CX, DX, BX, SP, BP, SI and DI.
[11] Which registers move onto the stack for a PUSHAD instruction?

PUSHAD: push the contents of the 32-bit register set found in 80386 through
the pentium4 in the following: EAX, ECX, EDX, EBX, ESP, EBP, ESI and EDI.
[12] Describe the operation of each of the following instructions :
(a)
(b)

PUSH AX
POP EAX

PUSH AX: copy the AX register to the stack.


POP EAX: remove a doubleword from the stack and
places it into the EAX register.
[13] Explain how the PUSH [DI] instruction functions.

PUSH [DI] instruction: copy the content of memory location identified by


the offset value stored in DI register into the stack.

[14] What registers are placed on the stack by the PUSHA instruction? In
what order?

PUSHA (push all) instruction: copies the registers to the stack in the
following order: AX, CX, DX, BX, SP, BP, SI and DI into the stack.

[15] What does the PUSHAD instruction accomplish?

PUSHAD: copy the contents of the 32-bit register in the following: EAX, ECX,
EDX, EBX, ESP, EBP, ESI and EDI into the stack.
[16] Which instruction places the EFLAGS on the stack in the Pentium 4
microprocessor?

PUSHFD
[17] Explain what happens when the PUSH BX instruction executes.
Make sure to show where BH and BL are stored. (Assume that SP =
0100H and SS = 0200H.)

The instruction copies the contents of BX onto the stack where address SS:
[SP-1] =BH, SS: [SP-2] =BL and after instruction execution SP=SP -2.
Stack location= SS*10H+SP=02100H
BH stored at location 020FFH
BL stored at location 020FEH
SP becomes FEH
[18] Repeat above question for the PUSH EAX instruction.

PUSH EAX: copy the EAX register to the stack.


In the same manner, except that after instruction execution SP=SP -4.

[19] Describe how the LDS BX, NUMB instruction operates.

LDS BX, NUMB: Load DS and BX with the address of NUMB.

[21] What does the REP prefix accomplish and what type of instruction is
it used with?

REP Prefix: repeats instructions CX times, it is used with string instruction


except LODS instruction. The REP prefix causes CX to decrement by 1
each time the string instruction executes.

You might also like