Question: I need a program for this to run on Visual Studio Procedure: Write an assembly program that receives the variables X and Y from the

I need a program for this to run on Visual Studio

Procedure: Write an assembly program that receives the variables X and Y from the keyboard instead of being hard coded in the program. They are used to compute W as shown below. W is then printed on the screen.

Void main

{

int X, Y, W, loc1, loc2, loc3, sum;

int A=90;

.... lines of code to input X from the Keyboard

.... Lines of Code to input Y from the Keyboard

loc1 = Y * 160 + X *2

loc2 = A * 950

loc3 = loc2 - loc1

Y=3000

Y=Y-1

sum = loc3/16 + Y + Y/4 + Y/200

W=sum % 7 + 3

Where sum % 7 = sum MOD 7

....Lines of code to W to screen

}

Algorithm for Multi-input Decimal Digits converted to BinaryHere are some detailed steps to help you input variable X from the keyboard based on the algorithm specified in the table above. For simplicity the following algorithm forces you to type exactly four digits to the screen regardless of the number. Thus, leading zeros are used if the number of decimal digits is less than four. We will learn how to input a variable number of digits without leading zeros in the future.

1. Initialize X=0

2. Set loop counter to 4

3. Multiply X by 10. Make sure you replace X with X*10.

4. Get Digit from Keyboard (it will be in ASCII)

5. Convert ASCII digit to a number (by subtracting 30h from it)

6. Add Number to X

7. Go to Step 3; You may use the LOOP instruction for this.

Output Session: A typical session on the screen will look like the following

Input X= 0040

Input Y= 0024

Output W= ?

Input X= 0001

Input Y= 0001

Output W= ?

Input X= 1234

Input Y= 0016

Output W= ?

HINTS: Declare variables for strings in the data area. For instance

inputX BYTE Input X=, 0

inputY BYTE Input Y=, 0

outputW BYTE Output W=, 0

newline BYTE 0dh, 0ah, 0

Note1: You may not use any library functions other than the ones specified below. For this assignment you will need the following Irvine Library calls.: ReadChar for input from keyboard (new for this lab), WriteChar for output of single character to screen (used in lab4), and WriteString for output of string of characters (eg. Input X=) to the screen. Recall that WriteString was used in Lab2. Check class notes for further details. Note2: Your program should be able to handle up to 4 digit unsigned decimal numbers for X and Y.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!