The routine below should average two numbers (7 and 51), add 12 (extra credit) t
ID: 3604047 • Letter: T
Question
The routine below should average two numbers (7 and 51), add 12 (extra credit) to them, and then display the total: A. Fix and list any assembly level problems problems and explain why they are errors; B. correct any comments ; C. run. Save the updated source code and printscreen the final run. BR main xtrcrdt: .EQUATE 12 ;constant Quiz1: .BLOCK 2 ;global variable #2d Quiz2: .BLOCK 2 ;global variable #2d Points: .BLOCK 2 ;global variable #2d main: LDWA Quiz1,d ADDA Quiz2,d ;Points = Quiz1 + Quiz2 ASRA ;Points = Points/4 ADDA xtrcrdt,i STWA Points,d STRO msg,d ;printf("Points = %d ", Points) DECO Points,d LDBA ' ',i STBA charOut,d STOP msg: .ASCII "Points = " .END 2. For the routines below, A. run them and see that they run identically; B. explain why the execute exactly the same way; C, step thru each and take a screenshot of each just before the last STBA executes; D. rewrite Problem 2A fully in assembly (it's currently half assembly and half machine). Save the two screenshots and the new fully assembly source code (make sure it runs correctly. ;Problem 2A ; ; LDBA 0x0013,d STBA 0xFC16,d LDBA 0x0014,d STBA 0xFC16,d LDBA 0x0015,d STBA 0xFC16,d STOP .ASCII "Pun" .END ;Problem 2B ; ; ; LDBA 0x0013,d STBA 0xFC16,d LDBA 0x0014,d STBA 0xFC16,d LDBA 0x0015,d STBA 0xFC16,d STOP ADDSP 0x756E,i .END
Explanation / Answer
When you're just starting to program, design is a real challenge. Knowing how to think about programming is one piece, but the other piece is knowing how to put programs together in a way that makes it easy to modify them later. Ideas like "commenting your code", "encapsulation and data hiding" and "inheritance" don't really mean anything when you haven't felt the pain of not having them. The problem is that program design is all about making things easier for your future self--sort of like eating your vegetables. Bad designs make your program inflexible to future changes, or impossible to understand after you've written. Frequently, bad design exposes too many details of how something is implemented, so that every part of the program has to know all the details of each other section of the program.
.model smallRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.