1 / 7

CS 206D Computer Organization Lab9

CS 206D Computer Organization Lab9. 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 . Solution .

apollo
Download Presentation

CS 206D Computer Organization Lab9

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS 206D Computer Organization Lab9 CS 111

  2. 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. Solution • Initial: AX=1234h BX=5678hCX=9ABChSP=0100h • PUSH AX 1234 56789ABC00FE 1234 is pushed • PUSH BX 1234 56789ABC00FC 5678 is pushed • XCHG AX,CX 9ABC 5678123400FC • POP CX 9ABC 5678567800FE 5678 is popped • PUSH AX 9ABC 5678567800FC 9ABC is pushed • POP BX 9ABC 9ABC567800FE 9ABC is popped CS 111

  4. 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. 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. 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

More Related