Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

What is a macro and how does it work? What is a data overflow and a data underfl

ID: 3750484 • Letter: W

Question

What is a macro and how does it work? What is a data overflow and a data underflow? What is a stack? What is the purpose of a stack? What is binary? What is BCD? What is ASCII code? What is a clock cycle? How many clock cycles do typical AVR instructions take to process? What is an execution cycle? What are its phases? What are loops and what kinds of loops are there? What is a shift register? What does a shift do? Are there different kinds of shift? What are the Step functions in AVR studio and how do they work? How do they differ from one another?

Explanation / Answer

1. What is macro and how does it work?

Answer:

A macro is a sequence of instructions, assigned by a name and could be used anywhere in the program.

In NASM, macros are defined with %macro and %endmacrodirectives.

The macro begins with the %macro directive and ends with the %endmacro directive.

The Syntax for macro definition

Where, number_of_params specifies the number parameters, macro_namespecifies the name of the macro.

The macro is invoked by using the macro name along with the necessary parameters. When you need to use some sequence of instructions many times in a program, you can put those instructions in a macro and use it instead of writing the instructions all the time.

For example, a very common need for programs is to write a string of characters in the screen. For displaying a string of characters, you need the following sequence of instructions

In the above example of displaying a character string, the registers EAX, EBX, ECX and EDX have been used by the INT 80H function call. So, each time you need to display on screen, you need to save these registers on the stack, invoke INT 80H and then restore the original value of the registers from the stack. So, it could be useful to write two macros for saving and restoring data.

We have observed that, some instructions like IMUL, IDIV, INT, etc., need some of the information to be stored in some particular registers and even return values in some specific register(s). If the program was already using those registers for keeping important data, then the existing data from these registers should be saved in the stack and restored after the instruction is executed.

2. What is a data overflow and a data underflow?

Answer: Data overflow is the condition that occurs when a calculation produces a result that is greater in magnitude than that which a given register or storage location can store or represent.

So, for instance:

Data underflow is

the condition in a computer program that can occur when the true result of a floating point operation is smaller in magnitude (that is, closer to zero) than the smallest value representable as a normal floating point number in the target datatype.

So, for instance:

3. What is a stack?

Answer:

A stack represents a sequence of objects or elements in a linear data structure format. The stack consists of a bounded bottom and all the operations are carried out on the top position. Whenever an element is added to the stack by the push operation, the top value is incremented by one, and when an element is popped out from the stack, the top value is decremented by one. A pointer to the top position of the stack is also known as the stack pointer.

A stack may be fixed in size or may have dynamic implementation where the size is allowed to change. In the case of bounded capacity stacks, trying to add an element to an already full stack causes a stack overflow exception. Similarly, a condition where a pop operation tries to remove an element from an already empty stack is known as underflow.

4. What is the purpose of a stack?

Answer: Following are the purposes of a stack:

5. What is binary?

Answer:

Binary describes a numbering scheme in which there are only two possible values for each digit: 0 and 1. The term also refers to any digital encoding/decoding system in which there are exactly two possible states. In digital data memory, storage, processing, and communications, the 0 and 1 values are sometimes called "low" and "high," respectively.

A bit (short for binary digit) is the smallest unit of data on a computer; each bit has a single value of either 1 or 0. Executable (ready-to-run) programs are often identified as binary filesand given a file name extension of ".bin.” Programmers often call executable files binaries.

6. What is BCD?

Answer:

Binary coded decimal (BCD) is a system of writing numerals that assigns a four-digit binarycode to each digit 0 through 9 in a decimal (base-10) numeral. The four-bit BCD code for any particular single base-10 digit is its representation in binary notation, as follows:

0 = 0000
1 = 0001
2 = 0010
3 = 0011
4 = 0100
5 = 0101
6 = 0110
7 = 0111
8 = 1000
9 = 1001

Numbers larger than 9, having two or more digits in the decimal system, are expressed digit by digit. For example, the BCD rendition of the base-10 number 1895 is

0001 1000 1001 0101

The binary equivalents of 1, 8, 9, and 5, always in a four-digit format, go from left to right.

The BCD representation of a number is not the same, in general, as its simple binary representation. In binary form, for example, the decimal quantity 1895 appears as

11101100111

Other bit patterns are sometimes used in BCD format to represent special characters relevant to a particular system, such as sign (positive or negative), error condition, or overflow condition.

The BCD system offers relative ease of conversion between machine-readable and human-readable numerals. As compared to the simple binary system, however, BCD increases the circuit complexity. The BCD system is not as widely used today as it was a few decades ago, although some systems still employ BCD in financial applications.

NOTE: As per Chegg policy, I am allowed to answer only 4 questions on a single post. I have gone ahead and answered 6. Kindly post the remaining questions separately and I will try to answer them. Sorry for the inconvenience caused.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote