Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 206D Computer Organization

Similar presentations


Presentation on theme: "CS 206D Computer Organization"— Presentation transcript:

1 CS 206D Computer Organization
Lab9 CS 111

2 Suppose that AX=7800h BX=1234h CX=91ACh and SP=0100h
Question 2 Suppose that AX=7800h BX=1234h CX=91ACh and SP=0100h Give the content of AX, BX, CX and SP after executing the following instructions: PUSH AX PUSH BX XCHG AX ,CX POP CX PUSH AX POP BX CS 111

3 Initial: AX=1234h BX=5678h CX=9ABCh SP=0100h
Solution Initial: AX=1234h BX=5678h CX=9ABCh SP=0100h PUSH AX ABC FE is pushed PUSH BX ABC FC is pushed XCHG AX,CX 9ABC FC POP CX ABC FE is popped PUSH AX ABC FC 9ABC is pushed POP BX ABC 9ABC FE 9ABC is popped CS 111

4 Write some code to do the following:
Question 2 Write some code to do the following: Place the top of the stack into AX without changing the stack contents 2) Place the word that is below the stack top into CX, without changing the stack contents. You may use AX. 3) Exchange the top two words on the stack. You may use AX and BX. CS 111

5 POP AX ;place top of stack into AX PUSH AX ;restore stack contents
Solution 1) Place the top of the stack into AX without changing the stack contents POP AX ;place top of stack into AX PUSH AX ;restore stack contents CS 111

6 POP AX ;place original stack top into AX
Solution 2) Place the word that is below the stack top into CX, without changing the stack contents. You may use AX. POP AX ;place original stack top into AX POP CX ;place word that is below original stack top into CX PUSH CX ;restore word that is below original stack top PUSH AX ;restore original stack top CS 111

7 Solution 3) Exchange the top two words on the stack. You may use AX and BX. POP AX ;place original stack top into AX POP BX ;place word that is below original stack top into BX PUSH AX ;place original stack top back on stack PUSH BX ;place word that was originally below stack top onto stack top CS 111


Download ppt "CS 206D Computer Organization"

Similar presentations


Ads by Google