

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Due Date: May 6, 2008 Total Points: 100
Solution: See text.
Solution: See text.
Solution:
(a) LDA $ ACC = code for ADA# $002 = $100 002
STA $ Mem[$004] = $100 002
ADA# $ ACC = ACC + $000 002 = $100 002 + $000 002 = $100 004
Since ACC is a positive number (left most bit is 0), it is not less than zero, and therefore LT = 0. PC = address of last executed instruction plus 1 = $004.
(b) LDA# $ ACC = $000 003
ADA $ ACC = ACC + Mem[$004] = $000 003 + $7FF FFF = $800 002
OV = 1 since addition of two identically signed numbers has produced an oppositely signed result. EQ = 0.
STA $ Mem[$004] = $800 002
HLT Stopped.
(c) LDA# $ ACC = $000 005
CMA $ Mem[$007] = $F0345E (a negative number)
So ACC > Mem[$007], → EQ = 0 and LT = 0.
JLT $ This instruction not executed because LT is not 1.
SBA# $0A ACC = ACC - $000 0A3 = $FFF F LT = 1 because ACC is negative.
JMP $ Unconditional jump to the HLT instruction at $006.
PC = address of last executed instruction plus 1 = $007.
(d) LDA $ This sets the ACC to the code for ”LDA $000”. This code is $002 000. So ACC = $002 000
ADA $ ACC = ACC + Mem[$000 005] = $002 002
STA $ Mem[$003] = $002 002
ADA# $05C Actually this instruction has been overwritten by the previous instruction which wrote $002 002 in place of this instruction. So the instruction here is ”LDA $002”. This causes ACC to be set to Mem[$002], which is the code for ”STA $003”. That is, ACC = $042 003
Solution:
(a) LDA# $ ACC = $000 003
STA $ Mem[$006] = $000 003
ADA $ ACC = ACC + code for HLT = $000 003 + $FFF FFF = $000 002
OV = 0 because there can be no overflow when a positive number and a negative number are added.
(b) LDA# $ ACC = $000 123
STA $ Mem[$007] = $000 123