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
2. Write a program with a loop and indexed addressing that exchanges every pair of values in an array with an even number of elements. Therefore, item i will exchange with item i+1, and item i+2 will exchange with item i+3, and so on.
1. Write a program that uses the variables below and MOV instructions to copy the value from bigEndian to littleEndian, reversing the order of the bytes. The number’s 32-bit value is understood to be 12345678 hexadecimal..data bigEndian BYTE 12h,34h,56h,78h littleEndian DWORD?
18. Insert a LABEL directive in the given data that permits myBytes to be moved directly to a 16-bit register.Use the following data definitions.data myBytes BYTE 10h,20h,30h,40h myWords WORD 3 DUP(?),2000h myString BYTE "ABCDE"
17. Insert a LABEL directive in the given data that permits myWords to be moved directly to a 32-bit register.Use the following data definitions.data myBytes BYTE 10h,20h,30h,40h myWords WORD 3 DUP(?),2000h myString BYTE "ABCDE"
16. Write an instruction that moves all four bytes in myBytes to the EAX register.Use the following data definitions.data myBytes BYTE 10h,20h,30h,40h myWords WORD 3 DUP(?),2000h myString BYTE "ABCDE"
15. Write an instruction that moves the second byte in myWords to the AL register.Use the following data definitions.data myBytes BYTE 10h,20h,30h,40h myWords WORD 3 DUP(?),2000h myString BYTE "ABCDE"
14. Write a single instruction that moves the first two bytes in myBytes to the DX register. The resulting value will be 2010h.Use the following data definitions.data myBytes BYTE 10h,20h,30h,40h myWords WORD 3 DUP(?),2000h myString BYTE "ABCDE"
13. What will be the value of EAX after each of the following instructions execute?mov eax,TYPE myBytes ; a.mov eax,LENGTHOF myBytes ; b.mov eax,SIZEOF myBytes ; c.mov eax,TYPE myWords ; d.mov eax,LENGTHOF myWords ; e.mov eax,SIZEOF myWords ; f.mov eax,SIZEOF myString ; g.Use the following data
12. Insert a directive in the given data that aligns myBytes to an even-numbered address.Use the following data definitions.data myBytes BYTE 10h,20h,30h,40h myWords WORD 3 DUP(?),2000h myString BYTE "ABCDE"
11. Write a sequence of instructions showing how the Zero flag could be used to indicate unsigned overflow after executing INC and DEC instructions.
10. Write a sequence of two instructions that set both the Carry and Overflow flags at the same time.
9. Implement the following expression in assembly language: AX = (val2 + BX) –val4.Assume that val2 and val4 are 16-bit integer variables.
8. Write a loop that iterates through a doubleword array and calculates the sum of its elements using a scale factor with indexed addressing.
7. Implement the following arithmetic expression in assembly language: EAX = –val2 + 7 –val3 + val1. Assume that val1, val2, and val3 are 32-bit integer variables.
6. Write a sequence of two instructions that set the Carry flag using subtraction.
5. Write a sequence of two instructions that use addition to set the Zero and Carry flags at the same time.
4. Write code using byte operands that adds two negative integers and causes the Overflow flag to be set.
3. Transmitted messages often include a parity bit whose value is combined with a data byte to produce an even number of 1 bits. Suppose a message byte in the AL register contains 01110101. Show how you could use the Parity flag combined with an arithmetic instruction to determine if this message
2. Using the XCHG instruction no more than three times, reorder the values in four 8-bit registers from the order A,B,C,D to B,C,D,A.
1. Write a sequence of MOV instructions that will exchange the upper and lower words in a doubleword variable named three.
19. What will be the value of the destination operand after each of the following instructions execute in sequence?mov edx,var4 ; a.movzx edx,var2 ; b.mov edx,[var4+4] ; c.movsx edx,var1 ; d.
18. What will be the value of the destination operand after each of the following instructions execute in sequence?mov ax,var2 ; a.mov ax,[var2+4] ; b.mov ax,var3 ; c.mov ax,[var3-2] ; d.
17. What will be the hexadecimal value of the destination operand after each of the following instructions execute in sequence?mov al,var1 ; a.mov ah,[var1+3] ; b.
16. For each of the following statements, state whether or not the instruction is valid:a. mov ax,var1?b. mov ax,var2c. mov eax,var3d. mov var2,var3e. movzx ax,var2f. movzx var2,al g. mov ds,ax h. mov ds,1000h
15. (Yes/No): Is it possible for both the Sign and Zero flags to be set at the same time?Use the following variable definitions for Questions 16–19:.data var1 SBYTE -4,-2,3,1 var2 WORD 1000h,2000h,3000h,4000h var3 SWORD -16,-42 var4 DWORD 1,2,3,4,5
14. (Yes/No): Is it possible for the NEG instruction to set the Overflow flag?
13. (Yes/No): Will the Overflow flag be set if you add a negative integer to a negative integer and produce a positive result?
12. (Yes/No): Is it possible to set the Overflow flag if you add a positive integer to a negative integer?
11. What will EAX contain after the following instructions execute?.data.dVal DWORD ?.code mov dVal,12345678h mov ax,WORD PTR dVal+2 add ax,3 mov WORD PTR dVal,ax mov eax,dVal
10. What value will EAX contain after the following instructions execute?.data dVal DWORD 12345678h.code mov ax,3 mov WORD PTR dVal+2,ax mov eax,dVal
9. What value will RAX contain after the following instructions execute?.data dwordVal DWORD 84326732h.code mov rax,0FFFFFFFF00000000h mov rax,dwordVal
8. What value will RAX contain after the following instruction executes?mov rax,44445555h
7. In the following code, the value in AL is intended to be a signed byte. Explain how the Overflow flag helps, or does not help you, to determine whether the final value in AL falls within a valid signed range.mov al,-1 add al,130
6. What will be the value of EAX and the Sign flag after the following lines execute?mov eax,5 sub eax,6
5. What will be the value of the Parity flag after the following lines execute?mov al,1 add al,3
4. What will be the value in EAX after the following lines execute?mov eax,1002FFFFh neg ax
3. What will be the value in EAX after the following lines execute?mov eax,30020000h dec ax
2. What will be the value in EAX after the following lines execute?mov eax,1002FFFFh inc ax
1. What will be the value in EDX after each of the lines marked (a) and (b) execute?.data one WORD 8002h two WORD 4321h.code mov edx,21348041h movsx edx,one ; (a)movsx edx,two ; (b)
6. What value will RCX contain after executing the following instructions?mov rcx,0DFFFh mov bx,3 add cx,bx
5. What value will the AL register contain after executing the following instructions?.data bArray BYTE 10h,20h,30h,40h,50h.code mov rdi,OFFSET bArray dec BYTE PTR [rdi+1]inc rdi mov al,[rdi]
4. What value will RCX contain after executing the following instructions?mov rcx,1234567800000000h add rcx,0ABABABABh
3. What value will RCX contain after executing the following instructions?mov rcx,1234567800000000h sub ecx,1
2. (True/False): A 32-bit constant may be moved to a 64-bit register, but 64-bit constants are not permitted.
1. (True/False): Moving a constant value of 0FFh to the RAX register clears bits 8 through 63.
10. Revise the code from the preceding question so the outer loop counter is not erased when the inner loop starts.
9. (Challenge): What will be the final value of EAX in this example?mov eax,0 mov ecx,10 ; outer loop counter L1:mov eax,3 mov ecx,5 ; inner loop counter L2:add eax,5 loop L2 ; repeat inner loop loop L1 ; repeat outer loop
8. (True/False): The target of a LOOP instruction must be within 256 bytes of the current location.
7. In real-address mode, which register is used as the counter by the LOOPD instruction?
6. In real-address mode, which register is used as the counter by the LOOP instruction?
5. (True/False): The LOOP instruction does the following: It decrements ECX; then, if ECX is not equal to zero, LOOP jumps to the destination label.
4. (True/False): The LOOP instruction first checks to see whether ECX is not equal to zero;then LOOP decrements ECX and jumps to the destination label.
3. If ECX is initialized to zero before beginning a loop, how many times will the LOOP instruction repeat? (Assume ECX is not modified by any other instructions inside the loop.)
2. (True/False): JMP is a conditional transfer instruction.
1. (True/False): A JMP instruction can only jump to a label inside the current procedure.
6. Fill in the requested register values on the right side of the following instruction sequence:mov esi,OFFSET myBytes mov ax,[esi] ;a. AX =mov eax,DWORD PTR myWords ;b. EAX =mov esi,myPointer mov ax,[esi+2] ;c. AX =mov ax,[esi+6] ;d. AX =mov ax,[esi-4] ;e. AX =
5. Fill in the requested register values on the right side of the following instruction sequence:mov esi,OFFSET myBytes mov al,[esi] ;a. AL =mov al,[esi+3] ;b. AL =mov esi,OFFSET myWords + 2 mov ax,[esi] ;c. AX =mov edi,8 mov edx,[myDoubles + edi] ;d. EDX =mov edx,myDoubles[edi] ;e. EDX =mov
4. (True/False): The following is an indexed operand: array[esi]
3. (True/False): The following instruction is invalid: inc [esi]
2. (True/False): The EBX register is usually reserved for addressing the stack.
1. (True/False): Any 32-bit general-purpose register can be used as an indirect operand.
5. (True/False): The SIZEOF operator returns the number of bytes in an operand.
4. (True/False): The LENGTHOF operator returns the number of bytes in an operand.
3. (True/False): The TYPE operator returns a value of 4 for doubleword operands.
2. (True/False): The PTR operator returns the 32-bit address of a variable.
1. (True/False): The OFFSET operator always returns a 16-bit value.
6. Where indicated, write down the values of the Carry, Sign, Zero, and Overflow flags after each instruction has executed:mov ax,7FF0h add al,10h ;a. CF = SF = ZF = OF =add ah,1 ;b. CF = SF = ZF = OF =add ax,2 ;c. CF = SF = ZF = OF =
5. If val4 is incremented by 1 using the ADD instruction, what will be the values of the Overflow and Sign flags?Use the following data.data val1 BYTE 10h val2 WORD 8000h val3 DWORD 0FFFFh val4 WORD 7FFFh
4. If val2 is incremented by 1 using the ADD instruction, what will be the values of the Carry and Sign flags?Use the following data.data val1 BYTE 10h val2 WORD 8000h val3 DWORD 0FFFFh val4 WORD 7FFFh
3. Write instructions that subtract val4 from val2.Use the following data.data val1 BYTE 10h val2 WORD 8000h val3 DWORD 0FFFFh val4 WORD 7FFFh
2. Write an instruction that subtracts val3 from EAX.Use the following data.data val1 BYTE 10h val2 WORD 8000h val3 DWORD 0FFFFh val4 WORD 7FFFh
1. Write an instruction that increments val2.Use the following data.data val1 BYTE 10h val2 WORD 8000h val3 DWORD 0FFFFh val4 WORD 7FFFh
6. Modify the AddVariables program so it uses 64-bit variables. Describe the syntax errors generated by the assembler and what steps you took to resolve the errors.
5. Generate a listing file for the AddTwoSum program and write a description of the machine code bytes generated for each instruction. You might have to guess at some of the meanings of the byte values.
4. Write a program that defines symbolic names for several string literals (characters between quotes). Use each symbolic name in a variable definition.
3. Write a program that contains a definition of each data type listed in Table 3-2 in Section 3.4.Initialize each variable to a value that is consistent with its data type.
2. Write a program that defines symbolic constants for all seven days of the week. Create an array variable that uses the symbols as initializers.
1. Using the AddTwo program from Section 3.2 as a reference, write a program that calculates the following expression, using registers: A = (A + B) − (C + D). Assign integer values to the EAX, EBX, ECX, and EDX registers.
15. Show the order of individual bytes in memory (lowest to highest) for the following doubleword variable:val1 DWORD 87654321h
14. Declare an array of 20 unsigned bytes named bArray and initialize all elements to zero.
13. Declare a string variable containing the word “TEST” repeated 500 times.
12. Declare an uninitialized array of 50 signed doublewords named dArray.
11. Declare a string variable containing the name of your favorite color. Initialize it as a nullterminated string.
10. Declare an unsigned 16-bit integer variable named wArray that uses three initializers.
9. Declare a 32-bit signed integer variable and initialize it with the smallest possible negative decimal value. (Hint: Refer to integer ranges in Chapter 1.)
8. Declare an array of byte and initialize it to the first 5 letters of the alphabet.
7. Declare an array of 120 uninitialized unsigned doubleword values.
6. Given the number 456789ABh, list out its byte values in little-endian order.
5. Write a program that contains two instructions: (1) add the number 5 to the EAX register, and (2) add 5 to the EDX register. Generate a listing file and examine the machine code generated by the assembler. What differences, if any, did you find between the two instructions?
4. Find out if you can declare a variable of type DWORD and assign it a negative value. What does this tell you about the assembler’s type checking?
3. Create a data definition for a doubleword that stored it in memory in big endian format.
2. Find out, by trial and error, if a program can have multiple code and data segments.
1. Define four symbolic constants that represent integer 25 in decimal, binary, octal, and hexadecimal formats.
29. Which data directive creates a 10-byte packed BCD variable?
28. Which data directive creates an 8-bit signed integer variable?
27. Which data directive creates a 64-bit unsigned integer variable?
26. Which data directive creates a 16-bit signed integer variable?
25. Which data directive creates a 32-bit signed integer variable?
24. (True/False): A link library is added to a program just before producing an Executable file.
23. (True/False): A Listing file is produced by the Assembler.
Showing 700 - 800
of 1525
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Last
Step by Step Answers