CS 1104 AY T3 Unit 8 Discussion Assignment- University of the People
0 view 0 purchase
Course
CS 1104
Institution
CS 1104
CS 1104 AY T3 Unit 8 Discussion Assignment- University of the People/CS 1104 AY T3 Unit 8 Discussion Assignment- University of the People/CS 1104 AY T3 Unit 8 Discussion Assignment- University of the People/CS 1104 AY T3 Unit 8 Discussion Assignment- University of the People/CS 1104 AY T3 Unit 8 Di...
cs 1104 ay t3 unit 8 discussion assignment university of the peoplecs 1104 ay t3 unit 8 discussion assignment university of the peoplecs 1104 ay t3 unit 8 discussion assignment university of the
Written for
CS 1104
All documents for this subject (6)
Seller
Follow
Millenialnurse
Reviews received
Content preview
3/26/2019 CS 1104 - AY2019-T3: Unit 8 Discussion Assignment
HOME CONTACT US RESOURCES LINKS FACULTY
MY COURSES
MENU
CS 1104 Computer Systems - Term 3, 2018-2019
Home ► My courses ► CS 1104 - AY2019-T3 ► 21 March - 27 March ►
Discussion Forum Unit 8 ► Unit 8 Discussion Assignment
Search forums
Discussion Forum Unit 8
Unit 8 Discussion Assignment
Subscribe
Unit 8 Discussion Assignment
by Onyekwere Oluoha (Instructor) - Wednesday, 30 January 2019, 5:40 AM
There are assemblers that are capable of handling macro commands.
Please explain in your own words what a macro command is and provide an example.
When would you program a macro and when would you program a subprogram (also called
functions, subroutines, methods)?
43 words
Permalink | Reply
Re: Unit 8 Discussion Assignment
by Stanislas Mihaljcuk - Thursday, 21 March 2019, 10:48 AM
Macro commands are shortcut words that execute a speci c sequence of other
predetermined commands. As said in TutorialPoint (n.d.):
https://my.uopeople.edu/mod/forum/discuss.php?d=191807 1/18
,3/26/2019
"A macro is a sequence of instructions, assigned by a name and could be used anywhere
CS 1104 - AY2019-T3: Unit 8 Discussion Assignment
in the program."(TutorialPoint, n.d.)
Here is an example from the textbook:
"If you nd this coding style tedious or even peculiar, you should note that friendlier
macro commands like D=D+M[xxx] and GOTO YYY can easily be introduced into the
language, causing Hack assembly code to be more readable as well as about 50 percent
shorter. The trick is to have the assembler translate these macro commands into binary
code e ecting @xxx followed by D=D+M, @YYY followed by 0;JMP, and so on."(Nisan &
Schocken, p. 117, 2008)
Therefore, instead of doing
@xxx
D=D+M
One could do:
D=D+M[xxx]
this would make the tedious task of getting the memory etc. much easier.
You want to use macros when you are repeating a certain simple task that doesn't
involve logic. When you go fetch a memory block to assign to something, this
information doesn't need its own line, it'd be best if you integrate to the operation itself.
However, if you want some logic, usually a longer combination of code then I'd say a
function is better. This is my opinion.
The main di erence between a macro and function is that the former is pre-processed
while the later is compiled. Macros are faster but are more di cult to debug. Type
checking is done on functions and not on macros. (Macros vs Functions, 2018)
References:
Macros vs Functions. (2018, December 21). Retrieved from
https://www.geeksforgeeks.org/macros-vs-functions/
Nisan, N., & Schocken, S. (2008). The elements of computing systems: Building a modern
computer from rst principles. Cambridge Mass.: The MIT Press.
Tutorialspoint.com. (n.d.). Assembly Macros. Retrieved from
https://www.tutorialspoint.com/assembly_programming/assembly_macros.htm
, 3/26/2019 319 words CS 1104 - AY2019-T3: Unit 8 Discussion Assignment
Rate: Rate... Permalink | Show parent | Reply
Re: Unit 8 Discussion Assignment
by Onyekwere Oluoha (Instructor) - Sunday, 24 March 2019, 6:24 AM
Hello Stanislas/Class,
It was nice reading your post. In addition, function could be described as a named unit
of codes or section of a program, which performs a designated task (Saddleback
College, n.d.). Functions are very helpful in that their use make programs much easier
to read, test and debug. A Macro is very similar to a Function, but each has its unique
purpose based on programmer requirements (Mahipal, Phaneendhar & Srinivas, n.d.).
In addition to your list, the following are major di erences between Macros and
Functions:
1. A Function is assembled once and then can be called from any location.
However, the assembler has to copy and compile the Macro whenever invoked
(Bishop's University, n.d.).
2. Macro have some “side e ect” or downsides as compared to Functions, such as
no type checking for incompatible operand and the likes. These could lead to major
complications if not carefully put into consideration while coding. Also, they are
generally more di cult to debug.
3. Macros avoid overhead of return instructions/calls, register shu ing and
argument passing, which are present in Functions.
4. Macros are processed before program compilation, while functions are
compiled directly.
5. Macros are usually faster than functions in execution speed. This could largely
be attributed to the fact that Macros don’t such overheads (like function calls) as is
present in functions.
OLuOHA.
References
Bishop's University (n.d.) “Macro in assembly language” online. Retrieved from:
http://cs.ubishops.ca/ljensen/asm/marros-assembly.html
https://my.uopeople.edu/mod/forum/discuss.php?d=191807 3/18
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller Millenialnurse. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $15.98. You're not tied to anything after your purchase.