Question

In: Computer Science

AT&T x64/GNU Assembly syntax only please Write an assembly language program which either hardcodes or reads...

  • AT&T x64/GNU Assembly syntax only please

Write an assembly language program which either hardcodes or reads in the lengths of the sides of a triangle, and outputs a truthy value (1, “true”, “yes”, and others) indicating whether the triangle is a valid one or not (0, “false”, “no”, etc). A triangle is valid if the sum of each pair of sides is greater than the unpaired side. Meaning if a, b, c are the three sides of a triangle, then the triangle is valid if all three of these conditions are satisfied:

• a + b > c

• a + c > b

• b + c > a

This would invalidate a triangle such as a=3, b=3, c=6, which would only be a line. Use this as a test case, as well as creating your own test cases.

I found a similar question that was answered but I wanted to see if someone else had different insight into this problem. I am still trying to learn assembly.

Solutions

Expert Solution

The Software Used for Writing ALP is MASM-32

Procedure:

1.) Save the program using .asm extension written in q-editor of masm-32 software

2.) Open the command prompt from Q-editor and type the following

set path=c:/masm32/bin

ml/Zi filename.asm

cv filename.exe

3.) Observe the registers by clicking F5 (direct result) or F10(step by step execution)

Program:

.model small

.dosseg

.data

A dw 01H

B dw 02H

C dw 03H

msg1 db 'Valid Triangle','$'

msg2 db 'Not a Valid Triangle','$'

.code

START:

MOV AX, @DATA;

MOV DS, AX; // intialising data segment with data

XOR AX, AX; // clearing accumulator register

XOR BX, BX; // clearing base register

XOR CX, CX; // clearing count register

XOR DX, DX; // clearing data register

MOV AX, A; // move A data into Accumulator register

MOV BX, B; // move B data into Base register

MOV CX, C; // move C data into Count register

ADD AX, BX; // Adding contents of ax,bx and storing in ax

ADD BX, CX; // Adding contents of bx,cx and storing in bx

ADD CX, AX; // Adding contents of cx,ax and storing in cx

CMP AX, C; // comparing content of ax with C (if C is bigger carry occurs)

JNC L1; // if content of ax is greater than C , jump to L1

MOV DX, OFFSET msg2; // moving address of msg2 into dx

MOV AH,09H; // moving 09h to ah

INT 21H; //sending an interrupt to stop execution

HLT; // stop execution

L1: CMP BX, A; // comparing bx with A

JNC L2; // if no carry occurs jump to L2

MOV DX, OFFSET msg2; // move address of msg2 to dx

MOV AH,09H; //move 09h to ax

INT 21H; //interrupt the program

HLT; //stop execution

L2: CMP CX, B; // comparing cx and B

JNC L3; // jump if no carry to L3

MOV DX, OFFSET msg2; // moving address of msg2 to dx

MOV AH,09H; //moving 09h to ah

INT 21H; //interrupt the program

HLT; // stop execution

L3: MOV DX, OFFSET msg1; // moving address of msg1to dx

MOV AH,09H; // moving 09h to ah

INT 21H; // interrupt program

HLT; // stop execution

END START; //end the start

END; // end of program


Related Solutions

**IN AT&T ASSEMBLY LANG** Write an assembly language program which either hardcodes or reads in two...
**IN AT&T ASSEMBLY LANG** Write an assembly language program which either hardcodes or reads in two integers, A and B, and uses them to compute the following expressions. You must use the same values for A and B throughout all three expressions. A * 5 (A + B) - (A / B) (A - B) + (A * B)
Must use AT&T x64/GNU Assembly syntax. Write an assembly language program that reads in two integers,...
Must use AT&T x64/GNU Assembly syntax. Write an assembly language program that reads in two integers, A and B, and uses them to compute the following expressions. You must use the same values for A and B throughout all three expressions. 1) A * 5 2) (A + B) - (A / B) 3) (A - B) + (A * B)
1. Write an assembly language program that prompts the user for and reads four integers (x1,...
1. Write an assembly language program that prompts the user for and reads four integers (x1, y1, x2, y2) which represent the coordinates of two points. Make sure you keep track of which number is which. 2. Treat the line between the points as the radius of a sphere and compute the surface area of the sphere. Print the output with a label, such as “The surface area of the sphere is: …”. Hint: The distance between the points is...
ASSEMBLY LANGUAGE ONLY OR I WILL DOWNVOTE write a program that will allow a person to...
ASSEMBLY LANGUAGE ONLY OR I WILL DOWNVOTE write a program that will allow a person to play a Guess a C♠rd Game. This section specifies the required functionality of the program. The interface must be a BlueJ Terminal Window, otherwise zero marks will be awarded. Only a simple screen presentation of the game is required; however, more marks will be gained for a game that is easy to follow with clear informative messages to the player. The aim of the...
Write an assembly language program that reads move review information from a text file and reports...
Write an assembly language program that reads move review information from a text file and reports the overall scores for each movie as well as identifying the movie with the highest total score. There are four movie reviewers numbered from 1 to 4. They are submitting reviews for five movies, identified by the letters from “A” through “E”. Reviews are reported by using the letter identifying the movie, the review rating, which is a number from 0 to 100, and...
Write a mips assembly language program that asks the user to enter an alphabetic character (either...
Write a mips assembly language program that asks the user to enter an alphabetic character (either lower or upper case)and change the case of the character from lower to upper and from upper to lower and display it.
Q1: A. WRITE AN ASSEMBLY LANGUAGE PROGRAM TO EXCHANGE 16-BIT NUMBERS B. WRITE AN ASSEMBLY LANGUAGE...
Q1: A. WRITE AN ASSEMBLY LANGUAGE PROGRAM TO EXCHANGE 16-BIT NUMBERS B. WRITE AN ASSEMBLY LANGUAGE PROGRAM TO SOLVE THE EQUATION Z=A+B-(C/D)+E please write the answer separately part A its own code and part B its own code this is microprocessor the ASSEMBLY LANGUAGE emu8086 should be written like this EX: mov ax,100h mov bx,200h etc
Write an assembly language program that corresponds to the following C program ****Please give correct answer...
Write an assembly language program that corresponds to the following C program ****Please give correct answer using Pep/9 machine**** int num1; int num2; ;int main () { scanf("%d", &num1); num2 = -num1; printf("num1 = %d\n", num1); printf("num2 = %d\n", num2); return 0; }
Please write in x86 Assembly language on Visual Studio Write a program to compare two strings...
Please write in x86 Assembly language on Visual Studio Write a program to compare two strings in locations str1 and str2. Initialize str1 to Computer and initialize str2 to Compater. Assume Str1 holds the correct spelling and str2 may have an incorrect spelling. Use string instructions to check if str2 is correct and if not correct the mistake in str2.
Assembly Language for x86 processors You are to write a program which should first ask for...
Assembly Language for x86 processors You are to write a program which should first ask for 4 random numbers from 0-20 (user will inpute these numbers in no preset order). Input these 5 numbers in variables called num1, num2, num3, num4, and num5. When done, your program should sort these numbers (you will use lots of conditions to check order). num1 should contain smallest number while num5 should contain the biggest. display the contents of num1 through num5 on the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT