Midterm2_Solutions_42 - 、 ∶ ≥ }∶ 乇 \ Midterm2...

Info iconThis preview shows pages 1–28. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 、 ∶ ≥ }∶ 乇 \ Midterm2 "EsC,s COpmht◎ 0Hy A"er2009 Due NOv17,2009 舳Name枷 Last Name∶ Lab session∶ 143彳 2一 ons: "idterm lnstruct∶ is a take home prolectfor a total of30098+607。 1 This midterm oxtra credit 2 Each lη idterm must be staρ !ed[50弘 。 score deducted othenⅣ isel 3 Use this page as a coVer 4 show deta"s of your work,and explain in words,exoeptin the most obvious Cases 5 Your work must be neat and clear LCˉ 3Code Instructions: 1 FOr a"problems use x3000as the starting address 2 Last Ⅱ of code is a TRAP instruction and is∶ xFO25 ne “ set Value” meansjust double c"ck on the location and type the va丨 3 use ue (Everything else is done using LCˉ 3binary instructions) 4 Your code should be well commented (FOll° w the commen刂 ng style of the code examples provided in class and in the textbook) 搀 鬟 锪搬 曩 饿 配 搬曦 搬触 搬檄e 搬 簏 Pr皤 篌缪搬冁 鼷 飘 蠹 躞 髓 a,A1gooth【 n Design a羽 d Flowcharts, b。 Coding Conditional Logic Operations and Iterations, c。 COmputau。 n spacc and Tilllc, ,薮 g务 遘 Jo斌 e Tes备 宓ga⒑ 撼馕 狨 )ch睇 gg啻 巍 锇 媾 巍 c.Simula羟 ing Cel1u1ar Autolll械 a, 1, T⒒ ree脚 【 Ilput AND(70%)∶ The three¨ input AND is deⅡ ned by thc tmth tablc∶ A 0 B 0 0 C AND(A,受 $,蜓)) 0 0 0 0 1 1 0 0 0 0 0 0 0 0 1 1 1 菝 ^ θ 1 0 0 Ι 1 ⊥ 1 1 ⊥ 1 △ Ι 1 0 △ △ 1 Midterm2 Due Nov17,2009 OHy A"er2009 3.“ Surviva⒈ ” If at1east one of its ncighbors is alivc,a living cell goes On living。 Writc a program that si1nulatcs this universe and its evo1ution,in the follo、ving steps∶ a.Write LC¨ 3code that inputs the initia1statcs Of thc ce11sA,B, C and D intO registers R0,R1,R2and R3rcspectiⅤ e1y。 Spe。 灯 address,instructon and cOmments as in the example in Question1(c)aboⅤ C(5%), b,COnⅤ crt thc rules of thc game abOⅤ e into an algOrithn△ that uses the input states of A,B,C and D,that tored in R0, R1,R2and R3,to compute thc neⅩ t rc itin R4, a flowchart of s and output it tO I△ emory address x3100。 tll^algoritllm O0%)。 c.COnvc⒒ your flOwchartinto a⒒ ne-by-line LC-3code。 SpecⅡˇ addrcss,instructon alld cOmmellts(20%). d.Write your code in the LC-3simulator,and take a screcn shot Of it6%). c.Test and debug your code by using it to cva1uate thc truth tablc fOr thc first updatc Of A, and fi11-in thc table bclO、 based on thc Output Of your cOde〈 10%・ )∶ 晏 rlputs Ao 0 0 0 0 1 △ 〓 ⊥ δ。 0 0 Do 0 1 1 0 1 1 0 0 0 1 1 1 0 1 1 Ι 1 Ι 《 put )lJ鸾 AI o 0 O 、 r9 l l Ⅴ / Midterm2 J"◎ Due Nov17,2009 ○Hy A"er2009 f, Writc additional cOde lincs that rcpeat this cOmputation for thc ncⅩ t statcs of B,C andlD,and output thc rcsults tO x3101, x3102 and x3103,rcspcctivcly, Spccify address, instructiOn and cOmmc11ts(20%)。 g,I△ nish thc computation of thc first update Of a1l four cclls、 Ⅴ ith a piccc of codc that reads the cOntcnt of X3I00,x3101,x3102 and x3103intO R0,R1,R2and R3,rcspcctivcly,Speci灯 address,hs“ uction and cOmments(5%), h,Writc yOur cOdc in thc LC-3siInulator and takc a scrccn shot of it。 Tcst and dcbug yOur cOde for updating B,C and D,and cxplain hO、v you do that(廑 0%,). i, NOw that cach ce11has becn updatcd Oncc,dcsignatc R5as a cOuntcr,and crcatc a lOOp that repeats thc updating 12tilllcs 5%), j,XV1・ ⒒ yOur cε ,9G/,佗 ″ cOdc in thc LC-3simulatOr and take a e scrccn shOt Of it。 Tcst and dcbug your cOdc for the lOOp,and and tllen exits tlle program(黄 int∶ You could fOllOw the Ⅴ cxplain hO、 v you dO that,⒈ 【 alue Of k。 any Onc variablc as it gcts updated(10%). Usc yOur prOgral11tO play thc four-cclls gamc of1ifc with thc initia1 conditions below。 Fi11-in the updatcs Of thc irst, second,third,fourth and12tll iteratiOns。 Which Of thcsc initial cOnditiOns lcads tO Osci11ations in the statcs Of thc four cells (30孑 Q)? 跚 田 跚 田 跚 EIH Midterm2 Due Nov17,2009 圉 田 田 田 田 /'∫ 3.T抵 e Ga酮 e of Life as Log晏 cC泗 cui篱 卩0%)∶ a.DeⅡ ve from the“ uth table of Question2(e)the logic cqu扯 ion of the first update of A,A1,in terms Of the initial states A0, B0,CO and D。 .Simplify止 so⒒ is symmetrk h tcrms Ofthe ne圯 hbors of A(10%)。 b.Imp1ement this logic cquation in thc ˇ ulti1nedia Logic 【 simulator and take a screen shot.Usc your implementation to tcst your logic equation by cOmparing it to the truth table of QuCstion20)(10%). c.Use this logic equatiOn in an algor⒈ hn△ that takes the input states of A,B,C and D,as they are stored in R0,R1,R2and R3,and computes the next state of A, store it in R4, and output⒒ to memory address x3100。 Draw a flowch盯 t of this a塘 Orithm⑿ o%). 峤 〃 丨 — 艹 古 堡 扭 _Ai1≡ 弩 ∷ 舆 。 灬 一 ⒊ 1b》 +± 。 a-札 哪 -扣 ψ :一 :心 r、 呐 弋r→ ° ^P G∶ ∴∷ 嘤 趱乞 纡 勹 ,钿遗盂△滩冫 扌了 钅1庞石下 7~ tFI弓 ˇ cs/、 \vr、 ↑ ” lL凵 口 丨 △∷ 【犰9 」、 ~ o|。 、 Ι __ L__ 遏匝 ~⒍ _~_⊥ t0、 、l 1~ ° 1、 O aD C,11 0ll _ J⒈ 00aD 00C,、 ρ 0! )宀 000ot口 |小 巛⒉ N跞 ~`R)》 七∴ ∶ ND0`?R)宀 ∶ pQ1ool pl 冫hα '|+ 丿 ∷ 性cJ ρ ¨ 廴 `尔 ` 坠 如v 山 议 ' '。 ∴ R'∶ =・ 。 C ~pPlN廷 、 v抵 冫 t廴 ^ ~ ω刂 -亠 lt,m少 0~m9虫 卩 /ˉ 't叻 /l砭 钣隘蛐 :灬 atYˉ Lo ×?饨田 ~甲 9`A b烫 rp'ˇ 民 饭 蛴 吒 心廴 u`1 诹夤抿 ⒏酾 Ⅰ TD Ⅳ t丬P{~∷ ε 0 扯 Ps山 趿 ・ lGt铽 巾 盅 。∷ 竺丫 _⒕ J讠 研 ˇ 5 r C b R31D 否岛 ″孓 9rJL~‘ Cl沪 偕∵ 弘 ∵ ~F~ ∷ 廴 :、 -证 xW蚺即 《 __ ˇ |热 ε (9Ⅱ犭 0ˇ Δ -押 q冖 叶 s印 映 ˇ 0Q⊥ Cn ~ 器∷ 宝 投鸾 F占 路 辶 — t 踹 ∶ ^ 氵 Ⅰ 丨 — — — pRlNTε D |N⑷ 丿 ∶ 】 ∶ ‘ 谋 \管 ∶ 罕 ∶噬亡 :∶ :∶ Lf+∶ 1|∴ -∶ i〖 [i∶ s∶ )ˇ ~_ ) 0七 爪甚D`七 ω K | starts at x3000 LD RO` A ; 1oads A into Ro LD R1` B 氵 1oads B into R1 LD R2` C 氵 1oads C into R2 A .F工 LL xO001, B 。F工 LL XO001氵 C 。F工 △L XO001氵 AND ADD AND BRz in the va△ ue o£ 1 fi11s in the va1ue of 1 £⊥11s in the va1ue o£ 1 A △ £i11s n B n n 工 c ⊥ c1ears out R4 R4` R4`0 , R4` R4` 1 氵 stores 1 in R召 R4`R4、 RO ・ ANDs R4 and RO` st0res zero 氵 工F R4=O the program goes to R‰ R%o 、 c1ears out R4 AND R4` R4` R1 氵 stores 1 in R4 ェF R4=O the program 9oes to BRz zero ; the resu1t ⊥n R4 △ abe1 zero` 0therw土 se it continues 勰 /丿 gg R4` R4、 0 冫 c1ears out R4 t in Rzl AND R4` R4、 R2 氵 ANDs R4 and R2` and stores the resu△ se it continues BRz zero 氵 工F R4=O the program goes to 1abe1 zero` 0therW土 ⊥ R3 n th R4 and stores the resu1t AND R3` R4` R4 氵 ANDs R4 W土 BRnzp done 氵 IF R4=0 the pr0gram goes to 1abe1 zero` 0therWise it cont1nues t ⊥n R3 AND R3、 R3` 0 ; ANDs R3 With O aod stores the resu△ BRnzp done 氵 工F R3=0 or PositiVe or negat⊥ ve` ⊥t goes to 1abe△ done 芡 zero 1abe1 zero、 0therWise it continues dor,e ha1t : ha△ ts .END , ends the program 冫 starts at △D RO` A 冫 △0ads LD R1` B ・ 1oads LD R2` C 氵 1oads LD R3、 D ; 1oads X3000 A into Ro B int° R1 C into R2 D ⊥nto R3 2己 AND RO`RO、 1 ; ANDs RO and 1 and stores △he resu1t in Ro BRp one ・ 工£ RO=1 then it branohes to 1abe△ one` °therWise it continues AND R5` R3、 R1 : ANDs R1 W⊥ th R3 and stores the resu△ t ⊥n R5 BRp £our , 工£ R0=1 then ⊥t branches to 1abe1 £ our` otherWise it c° nt⊥ nues ADD R4、 R4` o 氵 stores O ⊥n R4 sT工 R4` Extra 氵 stores R仕 in the me1nory 1° cat⊥ °n Extra BRnzp done , I£ R4=0 or positive or negat⊥ ve、 then ⊥t branches to △abe1 on∈ one ADD R5、 R1` R3 three ADD R4` R4` o ` stores O 土n R4 sT工 R4` EXtra 扌 stores R4 in the me1nory 1。 cat⊥ on Extra BRnzp done ・ stores R4 ⊥n the meIpory △ooat⊥ on Extra ADD R4、 R4` 1 ・ ADDs 1 & R之 ⊥t in R4 ` stores sT工 R4` Extra , stores R4 in the memory 1ooation Extra BRnzp done ・ I£ R4=0 or positive or negative` then it branches to 1abel on∈ 氵 ADDs R1 & R3` stores it in R5 BRz three氵 工f R0=1 then it branches to 1abe1 three` otherwise it c。 ntinues ADD R4、 R4、 1冫 ADDs 1 & R俘 、 stores it in R4 sT△ R4` EXtra 【 nemory 1ooati° n Extra 氵 stores R4 in the BRnzp done 冫 工£ R4=0 or positive or negat⊥ ve` then it branches to 1abe1 onc four £i△ 1s ⊥n the XO000氵 £⊥11s in the X0000氵 £⊥11s in the X0001冫 f⊥ 11s in the £Xtra .F工 LL X3100冫 £i11s in A .F工 LL XO001氵 B C D 。 LL F工 。 LL F工 。 LL F工 done HALT 氵 ha1ts END ・ 。 ends the program va1ue o£ 1 ⊥n A va1ue of O in B Va1ue of O in C va1ue of 1 in D the va1ue o£ 3100 in Extra 9b 〓 〓 冖 冖 × 〓 一 一 一 〓 〓 μ 冖 冖 ∽ μ ● 冖 ● 两 ● 凶 冖 e 〓 〓 冖 冖 × 〓 〓 冖 冖 × ∞ ∞ ● 0 0 0 0 0 0 0 〓 一 N 一 〓 冖 冖 冖 ∽ μ 〓 〓 〓 冖 冖 ∽ μ 0 0 冖 冖 ● ● , Φ ● 0 ● ” 〓 ω 一 〓 〓 “ 为 △ " μ 〓 ● 〓 冖 ● Φ 冖 ^ 〓 e △ 冖 ● 一 μ ● ● △ ` ` " " 一 一 i 一 ` 〓 ` Φ 0 凶 0 0 ` 两 0 ● ● 〓 汀 × △ 〓 0 ● ∽ μ 冖 灬 ● ● ° 0 0 〓 ` 0 ● 0 0 ∈ , ● c 0 0 0 " × 0 ● 0 ~ 〓 △ c 〓 ∽●∞●∞● △△∞〓∞〓 一0 一 〓 一0 ° 〓 →∞ ∞ ∞ △ ∽● 0 〓∞ 、 ∞ ∞〓 △ 〓∞ 汴 〓一 灬 〓 〓∞ 〓 一∞ ∞ ∞● 〓 〓 〓 ∽∽ △ 泞冖 ●∽ ° 〓 ~● 冖 0∽ ∞ ● 两一 ∽∽● ● 0 ∞凶 ∞ Φμ 一 μ ● 冖 μ冖ε μ0 μ臼 ハ ∞ 口 汴一 夕砂 〓 ″△ ハ0 , ハ ∞ο “ ● ハ Φ夕 ● 两∽ 彐 Φハ∽ 冖 〓 ∽● 日 一冖 ° 〓° ●∽ ∽ 冖冖 〓° ∞ 〓 〓〓 口氵 ° σ 〓〓 灬∽ 冖 △ 冖 汁 μ 灬, ∽ μ ‘ ● ˇ ` 喧 ` ” 0 Φ ` ● 0 0 两 0 " ● 0 ・ c c 0 p 一・ ● 0冖 ∽ μ 0 ● 夕 0∞ 冖 冖● , 冖 `ε Φ 一 ` μμ ∈ ハ∽ μ〓 ∽∞ Φ∽〓 冖 冖 冖 0ハ ` 〓 ∝ 冖 ` 0 0 0 ° 冖 ● 冖 冖 0 △ 〓 ∽ 冖 冖 ∈ 〓 ∽ , starts at x3ooo LD RO、 LD R1` 1oads 1oads 1oads 1oads A B c D LD R2、 LD R3、 A B C D int° Ro into R1 into R2 into R3 A .F△ LL xO001 扌 fi11s ±n the va1ue of B .F工 LL xooo1 氵 £i11s in the Va⊥ ue °£ C .FILL xOoo1 氵 £i工 1s ⊥n the Va1ue °£ D 。 LL xOooェ ; £⊥⊥1s in the va1ue °f P工 2F 1 ±n A 1 in B 1 in C 1 ⊥n D AND AND BRp AND BRp ADD R4`R衽 ears R4 氵 °ェ RO`RO`1`o 氵 ANDs Ro and 1 and st° res the resu1t ⊥ Ro n °ne ; ェ£ RO=1 then it branohes t° 1abe1 °ne、 °therw△ se ェt c。 ntinues R6` R3、 R1 , ANDs Rェ with R3 and stores the resu1t ⊥ R5 n £°ur 氵 ェ£ Ro=1 then it branches t° 1abe1 f° ur` °therwise it c° ntinues Rzl` R4` o ; st° res o ⊥n R4 sT工 R4、 Extra 氵 st° res R4 in the memory 1° cati。 n Extra BRnzp d。 ne 氵 ェ£ R4=o °r pos⊥ tive °r negat⊥ ve` then ⊥t branches t° 1abe1 °nc — ˉ one } } l ¨’ three 叠丢 ∶ ∶Ι。 £ 。 ∶ ∶ e〖 'ェ :: :e:∶ :3R:=sD:帚 e11i∶ :菖 n〖 :∶ a∶ hree` therwise it c° ntinues ADD R4` R4、 王氵 ADDs 1 & R4` st。 res ⊥t :1 sT工 R4` Extra 氵 st° res R4 in the mem° ry 1。 cati。 n BRnzp d° ne 氵 ェf R4=0 or posit⊥ ve °r negative` then Extra ⊥t branches t° 1abe△ 。nc AND R4` R4、 o 氵 AND R4 and O and store the resu1t in R4 s♀ 工 R4` Extra ; st。 res R4 in the meInory 1° cati。 n Extra £ ∶° 昱 °∶ 亡 ∶ z;:∶ ur :∶ BRnzp d° ne i :∶ :r:∶ 氵 △£ R4=o °r :4∶ done }丨 — i∶ it∶ :∶ tra °£ 3王 1abe1 °nc 00 in Extra AND R6、 R6` o ・ clears °ut R6 AND R召 、 R4` o 氵 c1ears °ut R4 AND R1、 R1、 1 , ANDs R1 with 1 and st° res the resu1t in R1 BRp °neB 氵 ェP R1=1 then it branches t∶ 1th:e:菖 i晏 ntinues AND R4` Ro` R2 ANDs RO with R2 and t:E:∶ s::teI晋 s it c° BRp f° urB 氵 △F R5=1 then it branches t。 1abe1 f° urB` °therwise it c。 ntinuee ADD lRzl` R4、 0 氵 st° res O in R4 }} — — 昼 。ξ : 晏 e:r :。 ∶ 甓 :z:4古 ItF早 r∶ :ェ 丨 :营 — oneB 秃DD ˉ— — threeB }— ェ 氵F R6=1 £ ourB — r;:∶ :∶ :r;:∶ — ¨ L tr∶ :∶ F:∶ :A言 :∶ :::r昌 :∶ :∶ t:::、 ;° :∶ 1abe1 d° neB` ; 晷 言:∶ 吞 :r :〖 tr〖 ti:舁 or negat⊥ LVe ve、 〖三;r∶ 〖c∶ [∶ 。丢 :。 ∶l∶ i:皿 or negat⊥ ve` LVe 土 t nt⊥ nv anches t° 1abe1 d° ne:` atl〖 nr:晏 :::⊥ e∶ 。:∶ :r;:∶ ˉ Ⅰ :anches t° 1r∶ t∶ sT:z::∶ — ` ⊥branches)∶ res the resu△ t in R6 t ⊥ t c° ∶∶ ∶8:in 蛋 s :erwise ::r :∶ ::∶ then srr:z::∶ — :° :芒 l∶ :∶ :∶ :∶ 宫 ∶吾舌 ∶ ∶ Ⅰ 言∶ξ∶ ∶晷 。 ∶°∶ 芒 ∶∶ ::z:营 :。 :∶ — :2舌 R6、 R2` RO ; ADDs R2 and RO and st° BRp threeB }饣 — :∶ ;∶ pos⊥ t± ve or negative` then it branches t° Extra .Fェ LL x31oo氵 fi11s in the va1ue — ∶ 丨∶ ∶ ∶ ∶ 8tl∶ :;∶ &∶ ::s∶ n mem。 ry △ ocation R4 branches to 1abe△ d。 neB` n mem。 ry 1ocati。 n R4 芟:∶ aξ ⊥ branches t to 1abe1 d° neB` Fェ 了 LL x3101 , £ i11s in the va1ue o£ x3101 for ExtraB 2F R6`R6`0 冫 ANDs R6 With O and stores the resu1t in R6 R4`R仕 、0 氵 c1ears R4 R2`R2`1 氵 ANDs R2 With 1 and stores the resu1t in R2 nues △abe△ oneC` otherwise it cont⊥ oneC ・ IF R2=1 then it braches to AND R6、 R1` R3 9 ANDs R1 and R3 and stores the resu1t in R6 £ ourC、 otherwise it cont⊥ nueε BRp £ourC , IF R5=1 then it branches to 1abe1 t ⊥n R每 ADD R4` R4` 0 氵 ADDs R⒋ and O and stores the resu△ s。 rェ R4` ExtraC , stores R4 in memory 1ocation ExtraC 工 r R4=o or positive or negatiVe` then it branches to 1abe1 dc 【 BRnzp doneC ` AND AND AND BRp oneC ADD R6` R3` R1 ; ADDs R3 and R1 and st0res the resu1t in R6 △ abe1 threeC` otherw⊥ se ±t continV BRp threeC ・ 工F R6=1 then it branches to and O and stores the resu△ t ⊥n R4 ADD R4` R4` 0 ; ADDs R每 △ 0ads R4 into me1nory △ooation ExtraC sT工 R4、 ExtraC , ⊥ branches to 1abe1 dc t F BRnzp doneC 冫 工 R4=0 0r posi△ ive or negative、 then threeC ADD R4` R4、 1 : ADDs Rzl with 1 and stores the resu1t in R6 sirェ R4` ExtraC 氵 1oads R6 into memory 1ocation ExtraC ⊥ branches to 1abe1 dc t 工 R4=0 or positive or negative` then P BRnzp doneC : fourC ADD R4` R4` 1 ; ADDs R4 with 1 and stores the resu1t in R4 into nemory 1ocation ExtraC sT工 R4` 日xtraC , 1oads R⒋ F BRnzp doneC 冫 工 R4=0 0r p° sitiVe or negative` then it branches to 1abe1 dc 3102 in ExtraC .F王 LL doneC AND AND AND BRp AND BRp oneD ・ ADDs RO and R2 and st0res the resu1t in R6 ADD R6` RO` R2 BRp threeD , 工F R6=1 then it branches to 1abe1 threeD` otherWise it continv ⊥ R迳 n ADD R逛 、 R4、 0 冫 ADDs R4 and O` and stores the resu1t 皿em0ry 1ocation EXtraD sT工 R仕 ` EXtraD 工F1oads R4 into : R4=0 or posit± ve or ne9at⊥ ve` then it branches to 1abe1 dc BRnzp doneD ; twoD and 1` and stores the resu1t in R4 ADD R4` R4` 1 , ADDs R刍 △ ooat土 on ExtraD sT工 R4` EXtraD , stores R4 in memory 土 branches to 1abe1 dc t 工 R4=0 or positive or negative` then F BRnzp doneD ; tores the resu△ t ±n R仕 日 ADD R仕 A 1 ` R4` 1 氵・ DDs R4 and in and stores R4 Inemory 1ocation ExtraD sT工 R4` ExtraD 工 R4=0 or pos⊥ tive or negatiVe` then it branches to 1abe1 dc F BRnzp d0neD ; ADD R4` R4` 1 , ADDs R4 and 1 and stores the resu1t in R4 △ ocation ExtraD sT工 R4` ExtraD 氵 stores R4 in Inemory ve` then ⊥t branches to 1abe1 dc 工 R4=0 or positiVe or negat⊥ F BRnzp doneD | threeD £ourD ExtraD X3102 氵 £⊥11s ExtraC n 土 R6 R6`R6、 0 ; ANDs R6 and O and st0res the resu1t R4`R4、 0 氵 ANDs R仕 and 0 and stores the resu1t in R4 R3`R3`1 氵 ANDs R3 and 1 and stores the resu1t in R3 ⊥ continues t △ abe1 oneD` otherWise oneD 氵 工F R3=1 then it branches to t 土n R6 R6` R2` R0 ; ANDs R2 and RO and stores the resu△ £ourD` otherWise it continues fourD ・ IF R5=1 then it braohes to 1abe△ ADD R4、 R4` 0 : ADDs R疫 and O and stores the resu1t in R4 ry 1ocation ExtraD sT工 R4` EXtraD , 1oads R4 into mem° dc ・ 工 R4=0 or positive or negative` then ⊥ branches to 1abe△ t F BRnzp doneD .F工 LL X3103 , F工 L△ s 3103 into EXtraD ha△ ts ` starts LD R0` LD R1` LD R2` A B c D LD R3、 A B C D 。 LL XO001 F】 .F工 LL XO001 。 LL xO001 F工 。 IjL xO001 F△ at X3000 loads 1oads 1oads 1oads ・ £⊥11s ・ £⊥11s ・ £i11s : £⊥11s △ nn n △ n △ 工 A into Ro B into R1 C ⊥nto R2 D into R3 the the the △he va1ue va1ue va1ue va1ue 攴 o£ o£ o£ o£ 1in A 廴 in B 1 in C 1 in D G AND AND BRp AND BRp ADD R4`R4`0 : o1ears R4 RO`R0`1 氵 ANDs RO and 1 and stores the resu1t in Ro se ⊥t continues one ; 工£ RO=1 then it branches to 1abe1 one` otherw土 ・ ANDs R1 with R3 and stores the resu1t ⊥n R5 R6` R3` R1 £ our、 otherwise it cont⊥ nues £ our , 王£ Ro=1 then it branches to 1abe1 R4` R4、 0 ; stores O in R4 s△ △ R4` Extra : stores R4 in the memory 1ooation Extra BRnzp done , 工£ R砼 =0 or posit土 ve or neqative` then it branches to 1abe1 onc one ADD R6` R1` R3 氵 ADDs R1 & R3` stores it in R6 three` otherWise it continues BRz three氵 工£ R6=O then it branohes to 1abe△ ⊥n R4 ADD R4` R4` 1氵 ADDs 1 & R4` stores it ⊥ ±n the memory ooat⊥ on Extra sT工 Rzi` Extra 氵 stores R4 BRnzp done 氵 工f R4=0 or positiVe or negative` then it branches to 1abe1 on∈ three t in R4 AND R4` R4` 0 氵 AND R4 and 0 and store the resu△ ・ stores R4 in the memory 廴 ocation Extra sT工 R4` EXtra ⊥ ocation εxtra BRnzp done 冫 stores R4 in the memory ADDs 1 & R4` stores it in R龟 ADD R4` R4、 1 ・ ・ stores R4 in the memory 1ooation Extra sT工 R4` EXtra BRnzp done ; 工£ R4=0 or positive or negative` then it branches to 1abe1 onc £our Extra .F工 LL X3100・ done D R6、 R6、 o threeB 310O in Extra 、 R4` R4、 o 土 R6 n ADD R6` R2` Ro 氵 ADDs R2 and RO and stores the resu1t BRp threeB , 工F R6=】 △hen ⊥t branohes to 1abe1 threeB` otherWise it cont1nv ⊥n R4 ADD R4` R4` o 冫 ADDs R4 and O` and stores the resu1t 皿em0ry 1ooation ExtraB sT工 R4` ExtraB , stores R4 in △ abe1 doneB` BRnzp doneB 氵 工F R4=0 or p° s± tiVe or negative` it branches to t in mem° ry △ocat⊥ on R4 屈xtraB R4` ExtraB , stores R4 in IneInory 1ooation ⊥abe1 doneB、 BRnzp doneB 氵 工P R4=0 0r p。 sitive or nega△ iVe` it branches to ⊥n 1 and stores △he resu1t in IneInory 1ocat土 on R每 ADD R4、 R召 氵 ADDs R4 `1 sTI R4` ExtraB ; stores R4 ⊥n 皿em0ry 1ooation ExtraB ・ 工 R4=0 or positiVe or negative` it branches to 1abe1 doneB` F BRnzp doneB ADD R4、 R4、 1 ; ADDs R4 and 1 and stores the resu△ sfrェ £ ourB in the va1ue o£ c1ears out R6 ` c1ears out R4 ・ ANDs R1 With 1 and stores the resu1t in R1 AND RI`R1`1 土 oont⊥ nues t BRp oneB 氵 工F R1=1 then ±t branches to 1abe1 oneB` otherwise AND R4` RO` R2 氵 ANDs RO with R2 and stores the resu1t in R5 土 cont⊥ nue∈ t 1abe1 fourB` otherwise BRp fourB , 王F R5=1 then it branohes t° ADD R4、 R4` o , stores O in R4 sT工 R4` EXtraB 氵 stores R5 in IneInory 1ooation ExtraB BRnzp doneB 氵 工£ R5=0 or positiVe or negat土 ve` it branohes to 1abe1 doneB` Al【 乃 0`D oneB £i11s .F工 LL X3101 氵 £i11s in the Va1ue o£ x3101 £ or 迓G ExtraB R6`R6、 0 ; ANDs R6 With 0 and stores the resu1t in R6 R4`R4`0 冫 c1ears R4 ・ ANDs R2 With 1 and stores the resu1t 1n R2 R2`R2`1 △abe△ oneC` otherwise it continues oneC 冫 工F R2=1 then it braches to R6` R1、 R3 , ANDs R1 and R3 and stores the resu1t in R6 £ourC` otherw⊥ se it continuee F £ourC 冫 工 R5=1 then it branches to 1abe△ t ⊥n R4 R4` R4` o ` ADDs R4 and O n memory 1ocation ExtraC and stores the resu△ sT工 R4、 EXtraC , stores R4 ⊥ IP R4=0 or p° s△ tive or negat⊥ ve` then it branches to 1abe1 dc BRnzp doneC , doneB AND AND AND BRp AND BRp ADD oneC ADD R6` R3` R1 ; ADDs R3 and R1 and stores the resu1t in R6 BRp threeC , IF R6=1 then it branches to 1abe1 threeC` otherwise it continv ⊥n R4 ADD R4` R4` 0 ; ADDs R4 and O and stores the resu1t △ ocation ExtraC oads R4 into memory sT王 R4` EXtraC 氵△ F 王 R4=0 or positiVe or negatiVe` then it branches to 1abe1 dc BRnzp doneC , threeC ADD R4` R4` 1 ; ADDs R4 w土 th 1 and stores the resu1t sT工 R4` EXtraC : 10ads R6 into memory 1ocation ExtraC BRnzp doneC ・ 工F R4=0 or pos△ tive or negative` then fourC ExtraC doneC tWoD threeD £ourD ExtraD ェ t with 1 and stores the resu1t in R4 ADD R4、 R遮 ` 1 , ADDs R每 ⊥nto memory 1ocat⊥ on ExtraC sT工 R4` ExtraC , 10ads R4 BRnzp doneC ; IF R您 =0 or pos⊥ tive or neqat⊥ ve` then F工 LL X3102 , fi1△ s 3102 ⊥ n 土 t R6 △ abe1 branches to dc branches to 1abe1 dc ExtraC AND R6`R6`0 氵 ANDs R6 and O and stores the resu1t in R6 0 ・ ANDs R4 and O and stores the resu1t in R4 R3、 1 , ANDs R3 and 1 and stores the resu1t in R3 BRp oneD , 工F R3=1 then ⊥t branches to 1abe△ oneD` otherwise it AND R6` R2、 RO ; ANDs R2 and RO and stores the resu1t in R6 £ ourD` otherwise it BRp £ourD 扌 工F Rrl=1 then it braches to 1abe1 ・ ADDs R4 and O and stores the resu1t in R4 ADD R4` R4` 0 △ ocation ExtraD sT工 R4` ExtraD 氵 1oads R4 into memory ⊥ branches t BRnzp doneD , IF R4=0 or positive or negatiVe` then AND R4、 AND R3、 oneD ⊥n R4、 ADD R6` RO` R2 ; ADDs RO and R2 and stores the resu1t in R6 BRp threeD 氵 工F R6=1 then it branches to 1abe1 threeD` otherwise ADD R4` R4` 0 | ADDs R4 and O` and stores the resu1t in R4 sT工 R4` ExtraD ; 1oads R4 into memory 1ocation ExtraD tive or negative、 then ⊥t branches BRnzp doneD , IF R4=0 or pos⊥ ADD R4` R4、 1 氵 ADDs R4 and 1、 and stores the resu△ t ⊥n R4 △ ocation ExtraD sTI R4` ExtraD , stores R4 in memory ェ branches t tive or negatiVe` then BRnzp doneD ; IF R4=0 or posェ t in R4 ADD R钍 ` R4` 1 ; ADDs R4 and 1 in memory 1ocat± on ExtraD ・ stores R每 and stores the resu△ sT工 R每 ` ExtraD 工F R每 =0 or positive or negat土 ve` then it branches BRnzp doneD ; and 1 and stores the resu1t in R会 ADD R4` R召 ` 1 ; ADDs R会 on ExtraD sIrェ R4` ExtraD 氵 stores R4 in memory 1ocat⊥ △ branches t BRnzp doneD 氵 IF R4=0 or pos△ tive or negat⊥ ve、 then .FILL X3103 ; FILLs 3103 ⊥ nto 日xtraD cont△ nues continues to △abe1 dc it continv to △abe1 dc to 1abe1 dc to 1abe1 dc to 1abe1 dc 丶 0 , 01ears X3100 冫 £⊥11s BA .F工 LL x3101 氵 £i廴 1s FILL X3102 氵 £i11s C1 。 D1 .IlILL X3】 03 氵 £i11s 7` R7、 。 LL F工 LD工 R0` LD工 R1、 LD工 R2` LD工 R3、 A1 氵 1oads A1 into Ro BA ・ 1oads BA into R1 ⊥ nto R2 C1 ; 1oads C1 ・廴 oads D1 into R3 D1 HALI : ha1ts ・ end 冫 Ends pr0gra皿 ˉ— — — — 丨 丨 〓 L l R7 A1 with X3】 00 BA W△ th X3101 C1 with X3102 D1 with x3103 '6 , starts at X3000 LD LD LD LD LD A B C D E Ro R1 R2 R3 R5 XO001 xO001 。 F工 LL XO001 .F王 LL XO001 .F王 LL xO00C A 土nto R0 B into R1 1oads C into R2 △ oads D ⊥nto R3 1oads E into R5` for the counter △ oads △ oads A B C D E 。 F工 LL £⊥11s 。 F工 LL f⊥ 1oop ! ‘ 11s £i11s fi11s fi11s in in in in in the the the the the va1ue va1ue va1ue va1ue va1ue o£ o£ o£ o£ o£ 1 ⊥n A 1 in B 1 in C 1 in D △2 in E 'I AND R4`R4`0 ; c1ears R4 ・ ANDs RO and 1 and stores the resu1t in Ro AND RO`RO`1 BRp one 氵 王£ RO=1 then it branohes to 1abe1 one` otherw土 se it continues AND R6、 R3` R1 ; ANDs R1 With R3 and stores the resu1t in R5 BRp £our , 工f R0=1 then it branches to 1abe1 four、 otherwise i△ continues ADD Rzl` R4` 0 , stores 0 in R4 sΨ I R4` Extra ocat土 on Extra 氵 stores R4 in the me皿 ory △ BRnzp done , 工f R4=0 or p° sitive or negatiVe` then 土 branches to 1abe1 onc t one ADD R6` R1` R3 , ADDs R1 & R3` st0res =t in R6 △ BRz three, If R6=O then it branches to abe1 three、 otherwise it cont⊥ nues ⊥ in R4 t ADD R4` R4` 1; ADDs 1 & R4` stores sT工 R4` Extra , stores Rzi in the me1nory 1ocation Extra BRnzp done 氵 I£ R4=0 or pos⊥ tiVe or negative` then it branches to 1abe1 on∈ three AND R4` R4` 0 ⊥n R4 扌 AND R4 and O and store the resu1t sT工 R4` EXtra 氵 stores R4 in the memory 1ocation Extra BRnzp done ` stores R4 in the memory 1ocation Extra ADD R4、 R4` 1 ;ADDs 1 & R4` stores it in R4 ・ stores R4 in the memory 1ocation Extra sT王 R4` EXtra BRnzp done ; 工£ Rzl=0 or positive or ne9at△ ve、 then it branches to 1abe1 onc 丨 lt }} 丨 ˉ four Extra .F工 LL X3100氵 fi11s done oneB threeB 丨 丨‘ }— } ¨ L the va1ue of 3】 00 in Extra AND AND AND BRp AND BRp ADD R6` R6` 0 氵 c△ ears ou△ R6 R4` R4` 0 , c△ ears out R4 R1`R1`1 ; ANDs R1 With 1 and stores the resu1t 1n R1 oneB ; 工F R1=1 then it branches to 1abe⊥ oneB` otherw⊥ se ⊥t cont⊥ nues R4` RO、 R2 : ANDs RO W⊥ th R2 and stores the resu1t 1n R5 £ £ ourB 氵 工F R5=1 then ⊥t branches to 1abe1 ourB` otherw⊥ se it cont土 nueε ⊥n R4 R4` R4` 0 氵 stores 0 sT工 R4` BXtraB 氵 stores R5 in me皿 0ry 1° oa△ ion ExtraB BRnzp doneB 氵 工£ R5=0 or positive or neqative` ⊥ branohes to 1abe⊥ t doneB` ADD R6` R2` RO , ADDs R2 and RO and stores the resu1t ⊥n R6 BRp threeB 冫 王F R6=1 then it branches to 1abe1 threeB` otherwise it con△ inv ADD R4` R4` 0 氵 ADDs R4 and O` and stores the resu1t in R龟 sT工 R4` ExtraB 氵 stores R4 in memory 1ooation ExtraB ・ 工 R4=0 or positive or negative、 F BRnzp doneB 土 branches to t △abe1 doneB` R4 and 1 and stores the resu1t ⊥n memory 1ocation R4 R4` ExtraB ⊥n me1nory 1ocation ExtraB 氵 stores R4 BRnzp doneB 氵 工F R4=0 or pos± tive or negat⊥ ve、 it branches to △abe△ doneB` ・ ADDs R4 in 1 and stores the resu1t in memory ADD R4` R4` 1 1ocation R4 土n memory 1ocation sT工 Rzl` EXtraB 氵 stores R4 日xtraB BRnzp doneB 氵 【F R4=0 0r posit⊥ ve or ne9ative` ⊥ branches to t 1abe1 doneB` ADD R4、 R4、 1 sT工 £ourB ⊥n ・ ADDs 。 LL F工 doneB x31o1 AND R6、 AND R4、 ・ £i1△ s in the va1ue x3101 f° r ExtraB 0 : ANDs R6 with O and st° res the resu1t in R6 o 氵 c1ears R4 AND R2`R2、 1 氵 ANDs R2 With 1 and st。 res the resu△ BRp 。neC 氵 ェF R2=1 then ⊥t braohes t° 1abe1 °neC` t in R2 °therw⊥ se it c° ntinues AND R6` R1` R3 , ANDs R1 and R3 and st° res the resu△ t in R6 BRp f° urC ・ ェF R5=1 then it branches to △abe1 £ourC` 。therwise ⊥t c° ntinueε ADD R4` R忽 ` o , ADDs R4 and O and st。 res the resu1t in R4 R6、 'I R4、 ξ 。:r?c.∶ 晏 r :。 ∶ 蚤 :z:4。 :2:e∶ :tI∶ :营 oneC °f 〖t branches t° c± :° :兰 :∶ :晷 [∶ ::` [:ξ ADD R6、 R3、 Rェ 氵 ADDs R3 and R1 and st° res the resu1t in R6 BRp threeC ; 王F R6=1 then it branches to 1abe△ threeC` 。therwise it c° ntin△ ADD R4` R4` o ` ADDs R4 and o and st° res the resu1t in R遮 ξ 。:r?c王 ; 蚤 [4p::::i弓 :m:Fyn::∶ ∶ [酋 :;a:t branches t° 蚤景 :z:4占 营 :2:s。 :::l threeC ADD R4、 R4、 1 ∶景 蚤ξ :z:4;。 :r∶ £ ourC 1abe1 dc ADD R4、 R4` 氵 ADDs cェ R4 W⊥ th 1 and st° res the resu1t in R6 yn∶ a:t branches t。 量 ; ;∶ :s。 :6p:∶ :∶ i弓 Em:三 ェ 氵 ADDs R4 With 1 and st° Ⅰ 。 吾:2:s。 E4p:::∶ 景 ::r∶ 蚤 z]zl。 :∶ i号 EIn8£ ∶∶ ; [苷 :↓ :Ι 1abe1 dc res the resu1t in R4 a:t branches t° yn::∶ cェ :蚤 1abe1 dc ∶ [Ⅰ ξ ::E∶ 丢 1abe1 dc ExtraC 。 FILL doneC AND R6、 R6`o 氵 ANDs R6 and O and st° res the resu1t in R6 AND R4、 R4、 o ・ ANDs R4 and O and st° res the resu1t in R4 AND R3`R3、 1 氵 BRp °neD ; ェF ⊥ c° nt⊥ nues t AND R6、 R2` Ro BRp £ourD ; ェP it c° nt⊥ nues ADD R4` R4、 o sT工 R4` ExtraD 1oads R迢 int。 memory 1。 cati。 n ExtraD BRnzp doneD , 工p R4=0 or positive or negative` then it branches t° labe1 dc ADD R6` RO` R2 氵 ADDs RO and R2 and st。 res the resu1t in R6 BRp threeD 氵 王F R6=1 then ⊥t branches to 1abe△ threeD、 °therwise ⊥ c° ntinˇ t ADD R4、 R4、 o 氵 ADDs R4 and 0` and st° res the resu△ t in R每 sT工 R4` ExtraD 1oads R遮 ⊥nt° memory 1° cat⊥ °n ExtraD BRnzp d。 neD 氵 R4=0 °r p° sit⊥ ve or negative` then it branches t° 1abe1 dc oneD tWoD x31o2 ADD R4` R4` 氵 £⊥11s 31o2 in ExtraC res the resu△ t in R4 ` ADDs R4 and 1` and st° ` ExtraD 氵 stores R4 in mem° ry 1° cati° n ExtraD BRnzp d° neD 扌 工 F R4=0 or positive or negative` then it branches t° 1abe1 dc threeD ADD R4` R4、 1 ADDs Rzl and 1 and st° res the resu1t in R4 sT工 R4、 ExtraD stores R4 in memory 1° °ati° n ExtraD BRnzp d° neD ; 王 F R4=0 or positive or negative` then ⊥ branches t° 1abe1 dc t £ ourD ADD R4` R4` 1 ADDs R4 and 1 and st° res the resu1t 土 R4 n sT工 R4` ExtraD ry 1。 °ati° n ExtraD BRnzp d。 neD , △F R4=0 。r p° s⊥mem° 。r negat⊥ ve、 ' stores R4 in t⊥ ve then it bran° hes t° 1abe1 dc EXtraD .FILL x31o3 氵 Fェ LLs 31o3 into ExtraD sT工 R召 置 ′ b:ξ 胥p ∶ ˉ 晏 a::∶ ± efr:le:h∶ 彗 8F军 t :。 T ∶ end 氵 ha1ts 、 Ends program i苎 :h∶ va工 ue ⊥n R5 bran° hes t。 1abe1 1° ° p 2 ェ — ∷ 川 倦 Ⅷ ≡ 硝 槲 Ⅲ 柑 汨 Ⅶ 旧 啊 Ⅱ J 日 ■ J J ■ ■ ■ ■ ■ ■ o0 ; starts at LD LD LD LD LD RO` R1` R2` R3` R5` A B C D E ・ 1oads oads 1oads 1oads 1oads ・△ 氵 ・ 氵 X3000 A int° Ro B ⊥nto R1 C into R2 D into R3 E into R5` for the counter 夕」 XO001 氵 £i11s in the va△ ue o£ 1 in A XO001 扌 f⊥ 11s in the va△ ue of 1 in B C F工 LL XO000 ; f⊥ 11s in the va1ue of 1 in C D .lP工 LL xO001 氵 £⊥1△ s in the va1ue of 1 in D E .F工 LL x000C 。£ 12 in E 氵 £i1△ s ⊥n the va1ue A B 。 LL F工 ,F工 LL △ oop AND R呕 、 R4`0 氵 c1ears R4 AND RO、 R0、 1 , ANDs R0 and 1 and stores the resu△ t in R0 BRp 。ne 氵 工f RO=1 then it branches to 1abe1 one` otherw⊥ se it continues AND R6` R3` R1 , ANDs R1 with R3 and st° res the resu1t in R5 BRp £。ur , ェf R0=1 then it branches to 1abe1 f° ur` otherw⊥ se it c。 nt⊥ nues ADD R4` R4` 0 ; stores O in R4 sT工 R每 ⊥ the Inem° ry 1° cati° n Ex△ ra n ` Extra , R4=0 R4 BRnzp done 冫 工£storesor posit⊥ ve or negative` then it branches t° 1abe1 onc one ADD R6` R1、 R3 , ADDs R1 & R3、 stores it in R6 BRz three; 工£ R6=O then it branches to 1abe1 three、 °therwise ⊥ c° ntinues t ADD R迢 1; ADDs 1 & R4、 st。 res ±t ⊥n R4 ` R4、 sT△ R4、 Extra ` st° res R4 ⊥ the mem° ry 1° cati° n Extra n BRnzp done ; 王£ R4=0 or posit⊥ ve or negat⊥ ve` then it branches to 1abe△ on∈ three AND R4` R4` 0 ; AND R4 and O and store the resu1t in R每 sT工 R4、 Extra , stores R4 in the Inemory 1ocati° n Extra BRnzp d。 ne 氵 st° res R4 in the memory 1° cation Extra ADD R4` R仕 ` 1 :ADDs 1 & R4` st° res ⊥t ⊥n R4 sT工 R4` Extra , stores R4 in the meInory 1ocati° n Extra BRnzp done ・ ェf R4=0 or positive or negative` then it branches t° £ our Extra Fェ 。 LL x3100, fi△ △s 1abe1 onc in the va1ue of 3100 in Extra done AND AND AND BRp AND BRp ADD oneB ADD R6` R2、 RO ・ ADDs R2 and R0 and st° res the resu1t in R6 BRp threeB 氵 IF R6=1 then ⊥ branohes to 1abe1 threeB、 t otherwise ⊥t c° ntinv ADD R4、 R4、 0 氵 ADDs R4 and O` and st° res the resu1t in R4 sT工 R4、 ExtraB , stores R4 in memory 1ocation ExtraB BRnzp doneB F 氵 ェ R4=0 or positive or negat⊥ ve` ±t branches to ⊥abe1 doneB` threeB ADD R4` R织 and 1 and stores the resu1t in memory 1ocation R每 ` 1 ; ADDs R4 R4 in inemory 1ocat⊥ sT工 R4` ExtraB 扌 stores °n ExtraB BRnzp doneB ; 工 R衽 =0 or positive or negative` it branches to F labe1 doneB` ADD R4` R4` 1 in 1 and st° res the resu1t in memory 氵 ADDs R4 1ocat⊥ on R4 ・ stores sT工 R4` ExtraB R4 in memory 1ocation ExtraB BRnzp doneB 工 R4=0 or F pos⊥ t⊥ ve or negat土 ve` ⊥t branches to 氵 1abe△ d° neB、 £ourB R6` R6、 0 氵 c1ears out R6 R4` R4、 0 , c1ears out R4 R1`R1、 1 氵 ANDs R1 with 1 and stores the resu1t in R1 oneB ; 工F R1=1 then it branches to 1abe1 oneB、 otherwise it c。 ntinues R4` R0` R2 res the resu1t in R5 氵 ANDs RO with R2 and st° £ urB 氵 ェ R5=1 then it branches to 1abe1 。 F £ urB` °therwise it c° nt土 nueε 。 R4` R4、 0 ; stores 0 in R4 sT工 R4、 ExtraB 氵 stores R5 in memory 1ocation ExtraB BRnzp doneB , 工f R5=0 or positive or negative` it branches to 1abe1 doneB` | 氵 f± doneB 11s ⊥ n the va1ue of x3101 £°r 2J ExtraB AND R6`R6`0 , ANDs R6 With O and stores the resu1t in R6 AND R4、 R4`0 ・ o1ears R之 AND R2、 R2`1 ; ANDs R2 With 1 and stores the resu1t in R2 BRp oneC ; 工F R2=1 then ⊥t braches to △abe1 oneC、 °therwise it c° ntinues ・ ANDs R1 and R3 and stores the resu1t in R6 AND R6` R1` R3 BRp fourC 氵 工F R5=1 then it branches to △ abe1 £ourC、 otherwise it continues ADD R遮 、 R4、 0 氵 ADDs R4 and 0 and stores the resu1t ⊥n R4 sT工 R4、 ExtraC 皿em0ry 1ocation ExtraC 氵 stores R4 1n BRnzp doneC , 工 R4=0 or pos⊥ tive or negative` then it branches to 1abe1 dc F oneC ADD R6、 R3` R1 ; ADDs R3 and R1 and stores the resu1t in R6 BRp threeC 氵 工F R6=1 then it branches to △ abe△ threeC` otherwise it continv ADD R4、 R4` 0 ; ADDs R4 and O and stores the resu1t in R4 sT工 R4` ExtraC , 1oads R4 into memory 1ocation ExtraC BRnzp doneC ⊥ branches to 1abe1 dc t 扌 IF R4=0 or posit⊥ ve or ne9at⊥ ve` then threeC ADD R4` R龟 th 1 and stores the resu△ t in R6 ` 1 氵 ADDs R4 w⊥ ry 1ocat⊥ on ExtraC ` ExtraC , R4=0 or positive or BRnzp doneC 氵 △F1oads R6 into meIn° negat⊥ ve、 then it branches to sTI R仕 fourC △abe1 resu1t in R绘 氵 A0Ds R4 W± th 1 and stores the ExtraC ; △oads R每 ⊥nto memory 1ocat⊥ on ExtraC BRnzp doneC , 工 R4=0 or pos⊥ t⊥ ve or negative` F then △t branches to 1abe△ dc ADD R4、 R4` 1 sT工 R4、 ExtraC .F工 LL doneC AND AND AND BRp AND BRp ADD oneD tWoD X3102 dc ・ £i11s 3102 土n ExtraC R6`R6、 0 ; ANDs R6 and 0 and stores the resu△ t in R6 R4`R4`0 t in R4 氵 ANDs R4 and O and stores the resu△ R3`R3`1 ; ANDs R3 and 1 and stores the resu△ t in R3 oneD 氵 △F R3=1 then it branohes to △ abe1 oneD` otherwise ⊥ oontinues t R6` R2` RO res the resu1t in R6 氵 ANDs R2 and R0 and st° £ourD ; 工 R5=1 then it braches to F △ abe1 fourD` otherwise it continues R4` R4、 0 ・ ADDs R4 and 0 and stores the resu1t in R4 sT工 R4` ExtraD ; 1oads R4 ⊥nto meInory △ ocat⊥ on ExtraD BRnzp doneD 氵 工F R龟 =0 or positive or negative` then it branches to △abe1 dc ADD R6` RO` R2 : ADDs R0 and R2 and stores the resu△ t in R6 BRp threeD ` 工F R6=1 then it branches to 1abe1 threeD` otherwise it cont⊥ ADD R刍 、 R4、 0 , ADDs R4 and O` and stores the resu1t 土 R4 n sT工 R4、 ExtraD ; 1oads R4 ⊥ nto memory 1ocation ExtraD BRnzp doneD , IF R4=0 or posit⊥ ve or negative` then ⊥ branches to labe1 dc t ADD R4、 R4、 1 ; ADDs R4 and 1` and stores the resu1t in EXtraD 氵 stores R4 ⊥n memory △ocation ExtraD BRnzp doneD F △ t 氵 工 R4=0 or positive or negative` then ADD R4、 R4` 1 ; ADDs R4 and 1 and stores the resu1t ⊥n sT工 R4、 ExtraD ; stores R4 in memory 1ocat⊥ on ExtraD BRnzp doneD ; 工 R4=0 or posit⊥ ve or negat⊥ ve、 then it F ADD R4` R4` 1 ; ADDs R4 and 1 and stores the resu1t in sT工 R4` ExtraD , stores R4 in meInory 1ocation ExtraD BRnzp doneD ・ 工P R4=0 or pos△ t⊥ ve or negative、 then △t n△ R4 sT王 R4、 threeD £ ourD ExtraD Fェ 。 LL X3103 ` F工 LLs 3103 into ExtraD branches to 1abe1 R4 branches to 1abe1 dc R4 branches to 1abe1 dc dc A1 BA C1 D1 LD工 LD工 LD工 LD工 R7` R7` 0 氵 o1ears X3100 氵 £i11s X3101 ; fi△ 1s .Ir王 LL X3王 02 氵 £ i△ 1s .F工 LL X3103 £i11s 氵 .F工 LL 。 FI△ L R0` R1` R2` R3` A1 , 1oads BA , 1oads C1 冫 10ads D1 氵 △oads R7 A1with x3100 BA with x3101 C1w⊥ th x3102 D1 with x31o3 彐J A1 into Ro BA 土nt° R1 C1 into R2 D1 ⊥nto R3 ADD R5` R5` #-1 ; subtraots one froⅢ the va1ue ⊥n R5 BRp 1oop 冫 △£ the R5 is p° sitive` then it branches to 1abe1 1oop HALT .end 氵 氵 ha1ts Ends prograIn 1 辫〓 严鹕 η〓 一屮 泖 冲柄 宀护 %〓 栉 尸叱 骈 # v 砷 〓〓 h锶 扭吒 梦 辩 屮炽 期溯 泓严 ν‰ 岬 〓阽 沽 护 叩 岙手 弓罕 弓吕 ∽播 ⒏μ 〓 冖 岂〓 β h 〓 % 一 % r 秃 p " ハ 沪 8 丰 ≡≡ ≡ ≡〓〓谳≡ 〓≡砷〓 〓〓⒀≡ ≡≡〓 〓≡〓≡ 〓≡≡ 〓 ≡・ ~ 鼋鼍耄毫芎弓鼋耄鼋耄亳耄耄鼋弓 耄趸尾耄焉弓耄鼍耄亳鼋耄耄弓甬 № 吵 函 L~ LD LD LD LD R0`A R1`B R2`C R3`D A FlLL XO001 B FILLX0000 C FlLL XO001 D FlLLX0000 NOT R4`RO;NOT RO store in R4 AND R4、 R4`R1;AND(R4`R1)st° re in R4 AND NOT AND AND NOT AND NOT AND AND NOT NOT AND Not R4`R4`R3;AND(R4`R3)store in R4 R5`R1;NOT R1`store in R5 R5`Rs`RO;AND(R5`RO)st° R5`Rs`R3;AND(R5`R3)st° R6`R3;NOT R3`store in R6 R6`R6`R3;AND(R6`R3)st° R6`R6;NOT R6`store in R6 R6`R6`RO;AND(R6`RO)st° R6`R6`R1;AND(R6`R1)st° R4`R4;NOT R4`store in R4 R5`Rs;NOT R5`store in R5 R4`R4`R5;AND(R4`R5)st° R4`R4;NOT R4`store in R4 re in R5 re in R5 re in R6 re in R6 re in R6 re in R4 NOT R6`R6氵 NOT R6'store in R6 NOT R4`R4;NOT R4`store in R4 AND R4丿 R6`R4;AND(R6`R4)st° re in R4 NOT R4`R4;NOT R4`store in R4 halt EN D 绌Ⅳ o0 ,starts at x3000 LD RO` A LD R1、 B LD R2` C LD R3` D ・ 10ads A into Ro 10ads B ⊥nt° R1 氵 10ads C into R2 冫 ・ 10ads D into R3 RO` M1氵 store RO in the me皿 ory △ocat⊥ on at M1 1ocation at M2 n sTェ 大1` M2; store R1 ± the memory n R2` M3・ store R2 ⊥ the 皿em0ry 1ocation at M3 sT工 the memory 1ocation at M4 sT工 R3` M4; store R3 in sT工 the the |1s the M3 .FILL X3102氵 f⊥ F工 M4 。 LL x3103, £±11s the M1 .F工 LL X3100; M2 .F工 LL X3101氵 £i11s £i11s the the F工 B 。 L△ xO001; the F工 LIj XO001・ C。 F工 D 。 L△ XO00】 氵 fi11s the A .F工 L△ XO001, done HALT .BND £i11s £i1△ s £i11s va1ue Va1ue va1ue Va1ue o£ o£ o£ o£ va1ue o£ va△ ue o£ va1ue o£ va1ue o£ 3100 3101 3102 3103 0001 0001 0001 0001 t0 t0 t° t0 t° t° t° t° A B C D A B C D ...
View Full Document

This note was uploaded on 01/12/2010 for the course BME 14345 taught by Professor Orlyalter during the Fall '09 term at University of Texas at Austin.

Page1 / 28

Midterm2_Solutions_42 - 、 ∶ ≥ }∶ 乇 \ Midterm2...

This preview shows document pages 1 - 28. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online