Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Thank you and sorry didn't provide the related question before. Exercise 1: Using the AddSub program from the book as a reference, write an assembly

Thank you and sorry didn't provide the related question before.

image text in transcribed

image text in transcribed

image text in transcribed

Exercise 1: Using the AddSub program from the book as a reference, write an assembly program to perform the following operations using only 16-bit registers: AX = 20 - (15+ 30). You must perform 15 + 30 first and then perform the subtraction operation. Use additional registers as needed. Insert a call DumpRegs statement after each operation and confirm that AX is holding the correct result. Add a comment after each instruction to describe it. For example: mov bx, 1 add bx, 2 ; assign 1 to bx so bx = 1 ; add 2 to bx so bx = 3 In addition, display the message "Author: Your Name." at the beginning of your program by defining a null-terminated string and then add a call WriteString instruction. Once your program is working correctly, modify it to add the following calculation: BX = a - (b + d), but do keep the code from previous step. Once again, you must perform addition operation first and then perform the subtraction operation. Define variables a, b, and d as 16-bits signed integers with values 20, 15, and 30 respectively. Use DumRegs to confirm that it calculates the result for BX correctly. ; instructions to calculate AX = 20 - (15 + 30), using constants ; instructions to calculate BX = a (b + d), using variables ; AX and BX should have the same value Exercise 2: Write an assembly program in 32-bit Protected mode that implements the following arithmetic expressions using as few instructions and registers as possible without simplifying the expression manually (i.e., perform operations in correct order according to normal precedence and use variables as applicable). Assume that r1 is a 32- bit signed value and r2 is a 16-bit unsigned value. You can confirm that variables r1 and r2 hold correct values by assign them to different registers and call DumpRegs. r1 = -(V2 - (v3 + v1)) + 1 r2 = v4 + 10h Use the following data definitions: v1 SDWORD 10h v2 SDWORD 30h v3 SDWORD 20 r1 SDWORD ? v4 WORD OFFFFh r2 WORD ? In comments next to each instruction, write the current hexadecimal value of the affected register or variable (for example: mov eax, 12 ; eax = OCh). Insert a call DumpRegs statement at the end of the program and you should examine various registers to confirm that your program is working properly. In addition, display the message "Author: Your Name." at the beginning of your program by defining a null-terminated string and then add a call WriteString instruction. 1: How does MSVS know that you are working with an assembly program instead another program such as C++? 2: What do you have to modify in your program to compute EBX = a - (b +d)? Just answer the question without modifying your program. Exercise 1: Using the AddSub program from the book as a reference, write an assembly program to perform the following operations using only 16-bit registers: AX = 20 - (15+ 30). You must perform 15 + 30 first and then perform the subtraction operation. Use additional registers as needed. Insert a call DumpRegs statement after each operation and confirm that AX is holding the correct result. Add a comment after each instruction to describe it. For example: mov bx, 1 add bx, 2 ; assign 1 to bx so bx = 1 ; add 2 to bx so bx = 3 In addition, display the message "Author: Your Name." at the beginning of your program by defining a null-terminated string and then add a call WriteString instruction. Once your program is working correctly, modify it to add the following calculation: BX = a - (b + d), but do keep the code from previous step. Once again, you must perform addition operation first and then perform the subtraction operation. Define variables a, b, and d as 16-bits signed integers with values 20, 15, and 30 respectively. Use DumRegs to confirm that it calculates the result for BX correctly. ; instructions to calculate AX = 20 - (15 + 30), using constants ; instructions to calculate BX = a (b + d), using variables ; AX and BX should have the same value Exercise 2: Write an assembly program in 32-bit Protected mode that implements the following arithmetic expressions using as few instructions and registers as possible without simplifying the expression manually (i.e., perform operations in correct order according to normal precedence and use variables as applicable). Assume that r1 is a 32- bit signed value and r2 is a 16-bit unsigned value. You can confirm that variables r1 and r2 hold correct values by assign them to different registers and call DumpRegs. r1 = -(V2 - (v3 + v1)) + 1 r2 = v4 + 10h Use the following data definitions: v1 SDWORD 10h v2 SDWORD 30h v3 SDWORD 20 r1 SDWORD ? v4 WORD OFFFFh r2 WORD ? In comments next to each instruction, write the current hexadecimal value of the affected register or variable (for example: mov eax, 12 ; eax = OCh). Insert a call DumpRegs statement at the end of the program and you should examine various registers to confirm that your program is working properly. In addition, display the message "Author: Your Name." at the beginning of your program by defining a null-terminated string and then add a call WriteString instruction. 1: How does MSVS know that you are working with an assembly program instead another program such as C++? 2: What do you have to modify in your program to compute EBX = a - (b +d)? Just answer the question without modifying your program

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Excel As Your Database

Authors: Paul Cornell

1st Edition

1590597516, 978-1590597514

More Books

Students also viewed these Databases questions

Question

What is the Definition for Third Normal Form?

Answered: 1 week ago

Question

Provide two examples of a One-To-Many relationship.

Answered: 1 week ago