New Semester
Started
Get
50% OFF
Study Help!
--h --m --s
Claim Now
Question Answers
Textbooks
Find textbooks, questions and answers
Oops, something went wrong!
Change your search query and then try again
S
Books
FREE
Study Help
Expert Questions
Accounting
General Management
Mathematics
Finance
Organizational Behaviour
Law
Physics
Operating System
Management Leadership
Sociology
Programming
Marketing
Database
Computer Network
Economics
Textbooks Solutions
Accounting
Managerial Accounting
Management Leadership
Cost Accounting
Statistics
Business Law
Corporate Finance
Finance
Economics
Auditing
Tutors
Online Tutors
Find a Tutor
Hire a Tutor
Become a Tutor
AI Tutor
AI Study Planner
NEW
Sell Books
Search
Search
Sign In
Register
study help
business
implementing programming languages
Assembly Language For X86 Processors 7th Edition Kip Irvine - Solutions
4. (True/False): As long as it is in the code segment, a macro definition may appear either before or after statements that invoke the macro.
3. What is the primary advantage to using macros with parameters versus macros without them?
2. (True/False): Macro expansion is handled by the assembler’s preprocessor.
1. (True/False): When a macro is invoked, the CALL and RET instructions are automatically inserted into the assembled program.
9. Write an expression that returns the number of bytes in field2 of MyStruct.
8. What value does the expression SIZEOF MyStruct return?
7. What value does the expression TYPE MyStruct return?
6. Using the MyStruct array from the preceding exercise, use ESI to index to the third array element and move AX to field1. Hint: Use the PTR operator.
5. Using the MyStruct array from the preceding exercise, move field1 of the first array element to AX.
4. Declare a variable as an array of 20 MyStruct objects.
3. Declare a MyStruct variable and initialize the second field to an array containing all zeros.
2. Declare a MyStruct variable that initializes the first field to zero.
1. Declare a MyStruct variable with default values.
3. Write runtime instructions that access the structure fields?
2. Declare one or more variables of the structure type, called structure variables?
1. Define the structure?
Create a variant of the Str_trim procedure that lets the caller remove all instances of a set of characters from the end of a string. For example, if you were to call it with a pointer to the string“ABC#$&” and pass it a pointer to an array of filter characters containing “%#!;$&*”, the
Create a variant of the Str_trim procedure that lets the caller remove all instances of a leading character from a string. For example, if you were to call it with a pointer to the string “###ABC”and pass it the # character, the resulting string would be “ABC.”
Write a procedure named calc_row_sum that calculates the sum of a single row in a two-dimensional array of bytes, words, or doublewords. The procedure should have the following stack parameters:array offset, row size, array type, row index. It must return the sum in EAX. Use explicit stack
Use the letter matrix generated in the previous programming exercise as a starting point for this program. Generate a single random four-by-four letter matrix in which each letter has a 50% probability of being a vowel. Traverse each matrix row, column, and diagonal, generating sets of
Create a procedure that generates a four-by-four matrix of randomly chosen capital letters.When choosing the letters, there must be a 50% probability that the chosen letter is a vowel.Write a test program with a loop that calls your procedure five times and displays each matrix in the console
Rewrite the binary search procedure shown in this chapter by using registers for mid, first, and last. Add comments to clarify the registers’ usage.
Add a variable to the BubbleSort procedure in Section 9.5.1 that is set to 1 whenever a pair of values is exchanged within the inner loop. Use this variable to exit the sort before its normal completion if you discover that no exchanges took place during a complete pass through the array. (This
The Sieve of Eratosthenes, invented by the Greek mathematician of the same name, provides a quick way to find all prime numbers within a given range. The algorithm involves creating an array of bytes in which positions are “marked” by inserting 1s in the following manner: Beginning with
Write a procedure named Get_frequencies that constructs a character frequency table. Input to the procedure should be a pointer to a string and a pointer to an array of 256 doublewords initialized to all zeros. Each array position is indexed by its corresponding ASCII code. When the procedure
Write a procedure called Str_nextWord that scans a string for the first occurrence of a certain delimiter character and replaces the delimiter with a null byte. There are two input parameters: a pointer to the string and the delimiter character. After the call, if the delimiter was found, the Zero
Write a procedure named Str_find that searches for the first matching occurrence of a source string inside a target string and returns the matching position. The input parameters should be a pointer to the source string and a pointer to the target string. If a match is found, the procedure sets the
Write a procedure named Str_remove that removes n characters from a string. Pass a pointer to the position in the string where the characters are to be removed. Pass an integer specifying the number of characters to remove. The following code, for example, shows how to remove “xxxx”from
Write a procedure named Str_concat that concatenates a source string to the end of a target string. Sufficient space must exist in the target string to accommodate the new characters. Pass pointers to the source and target strings. Here is a sample call:.data targetStr BYTE "ABCDE",10
The Str_copy procedure shown in this chapter does not limit the number of characters to be copied.Create a new version (named Str_copyN) that receives an additional input parameter indicating the maximum number of characters to be copied.
16. Write a sequence of instructions that use the Str_compare procedure to determine the larger of two input strings and write it to the console window.
15. Write instructions that use SCASW to scan for the 16-bit value 0100h in an array named wordArray, and copy the offset of the matching member into the EAX register.
15. Write instructions using CMPSW that compare two arrays of 16-bit values named sourcew and targetw.
14. In the BinarySearch procedure from Section 9.5, how might the statement at label L4 be eliminated?
13. In the BinarySearch procedure from Section 9.5, why could the statement at label L2 be removed without affecting the outcome?
12. In the FillArray procedure from the Binary Search example in Section 9.5, why must the Direction flag be cleared by the CLD instruction?
11. What is the maximum number of comparisons needed by the binary search algorithm when an array contains 1,024 elements?
10. If the Str_length procedure from Section 9.3 used SCASB, how would it calculate and return the string length?
9. If the Str_length procedure from Section 9.3 used SCASB, which repeat prefix would be most appropriate?
8. What happens in the Str_ucase procedure from Section 9.3 if the target string contains a digit?
7. Why does the Str_trim procedure from Section 9.3 use the JNE instruction?
6. What Direction flag setting is used in the Str_trim procedure from Section 9.3?
5. When scanning an array for the first occurrence of a particular character, which repeat prefix would be best?
4. When the Direction flag is clear and SCASB has found a matching character, where does EDI point?
3. In what way is the CMPS instruction ambiguous?
2. When a repeat prefix is used with STOSW, what value is added to or subtracted from the index register?
1. Which Direction flag setting causes index registers to move backward through memory when executing string primitives?
4. If it were found (through testing) that an array of 500 integers could be sorted in 0.5 seconds, how many seconds would it take to bubble sort an array of 5000 integers?
3. In the BubbleSort procedure, does the inner loop always execute the same number of times?
2. In the BubbleSort procedure, how many times does the inner loop execute on the first pass through the array?
1. If an array were already in sequential order, how many times would the outer loop of the BubbleSort procedure in Section 9.5.1 execute?
3. In 32-bit mode, should you use EBP to address an array?
2. Suppose a two-dimensional array of doublewords has three logical rows and four logical columns. If ESI is used as the row index, what value is added to ESI to move from one row to the next?
1. In 32-bit mode, which registers can be used in a base-index operand?
4. (True/False): The Str_copy procedure prevents a string from being copied into too small a memory area.
3. (True/False): The 32-bit Str_length procedure uses SCASB to find the null terminator at the end of the string.
2. (True/False): The 32-bit Str_compare procedure does not need to use ESI and EDI to access memory.
1. (True/False): The Str_compare procedure stops when the null terminator of the longer string is reached.
5. What does the REPZ prefix do for a CMPSB instruction?
4. Which instruction copies data from the memory location addressed by ESI into AX?
3. Which index register is used by the STOSD instruction?
2. Which instruction compares a 32-bit integer in the accumulator to the contents of memory, pointed to by EDI?
1. In reference to string primitives, which 32-bit register is known as the accumulator?
Write a procedure named ShowParams that displays the address and hexadecimal value of the 32-bit parameters on the runtime stack of the procedure that called it. The parameters are to be displayed in order from the lowest address to the highest. Input to the procedure will be a single integer that
Write a procedure named CountNearMatches that receives pointers to two arrays of signed doublewords, a parameter that indicates the length of the two arrays, and a parameter that indicates the maximum allowed difference (called diff) between any two matching elements. For each element xi in the
Write a procedure named CountMatches that receives points to two arrays of signed doublewords, and a third parameter that indicates the length of the two arrays. For each element xi in the first array, if the corresponding yi in the second array is equal, increment a count. At the end, return a
Write a recursive implementation of Euclid’s algorithm for finding the greatest common divisor(GCD) of two integers. Descriptions of this algorithm are available in algebra books and on the Web. Write a test program that calls your GCD procedure five times, using the following pairs of integers:
Create an array of randomly ordered integers. Using the Swap procedure from Section 8.4.6 as a tool, write a loop that exchanges each consecutive pair of integers in the array.
Write a procedure named DifferentInputs that returns EAX = 1 if the values of its three input parameters are all different; otherwise, return with EAX = 0. Use the PROC directive with a parameter list when declaring the procedure. Create a PROTO declaration for your procedure, and call it five
Create a procedure named FindThrees that returns 1 if an array has three consecutive values of 3 somewhere in the array. Otherwise, return 0. The procedure’s input parameter list contains a pointer to the array and the array’s size. Use the PROC directive with a parameter list when declaring
This exercise extends Exercise 2. Every 500 milliseconds, change the color of the colored squares and redisplay the board. Continue until you have shown the board 16 times, using all possible 4-bit background colors. (The white squares remain white throughout.)
Write a program that draws an 8 8 chess board, with alternating gray and white squares. You can use the SetTextColor and Gotoxy procedures from the Irvine32 library. Avoid the use of global variables, and use declared parameters in all procedures. Use short procedures that are focused on a single
Create a procedure named FindLargest that receives two parameters: a pointer to a signed doubleword array, and a count of the array’s length. The procedure must return the value of the largest array member in EAX. Use the PROC directive with a parameter list when declaring the procedure. Preserve
9. (True/False): If you pass an immediate value to a procedure that expects a reference parameter, you can generate a general-protection fault.
8. (True/False): If you pass a variable containing the offset of an array of bytes to a procedure that expects a pointer to an array of words, the assembler will flag this as an error.
7. (True/False): When using the PROC directive, all parameters must be listed on the same line.
6. What advantages might the C calling convention have over the STDCALL calling convention?
5. In the C++ example shown in Section 8.2.3, how much stack space is used by a variable of type int?
4. How is the LEA instruction more powerful than the OFFSET operator?
3. How does a program using the STDCALL calling convention clean up the stack after a procedure call?
2. When a C function returns a 32-bit integer, where is the return value stored?
1. Which statements belong in a procedure’s epilogue when the procedure has stack parameters and local variables?
4. (True/False): PROTO directives use up memory, so you must be careful not to include a PROTO directive for a procedure unless the procedure is actually called.
3. (True/False): In a multimodule program, an END statement with a label occurs only once, in the startup module.
2. (True/False): Separating a large program into short modules makes a program more difficult to maintain.
1. (True/False): Linking OBJ modules is much faster than assembling ASM source files.
4. (True/False): The PROC directive can contain a USES operator, but the PROTO directive cannot.
3. (True/False): The INVOKE directive can only pass memory operands, but not register values.
2. (True/False): The INVOKE directive can include up to a maximum of three arguments.
1. (True/False): The CALL instruction cannot include procedure arguments.
5. Challenge: How many bytes of stack space would be used by the Factorial procedure when calculating 5!?
4. What would happen to the Factorial program’s output if you tried to calculate 13!?
3. Which instructions in the assembly language Factorial procedure execute after each recursive call has finished?
2. In the Factorial function, what condition terminates the recursion?
1. (True/False): Given the same task to accomplish, a recursive subroutine usually uses less memory than a nonrecursive one.
7. What are the two common types of stack parameters?
6. (True/False): Passing by reference means that an argument’s address is stored on the runtime stack.
5. (True/False): In 32-bit mode, the last argument to be pushed on the stack in a subroutine call is stored at location EBP + 8.
4. (True/False): Local variables are created by adding a positive value to the stack pointer.
3. (True/False): A subroutine’s prologue code always pushes EBP on the stack.
Showing 400 - 500
of 1525
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Last
Step by Step Answers