Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create an HLA Assembly language program that prompts for a value from the user and then prints the next six values starting with the value

Create an HLA Assembly language program that prompts for a value from the user and then prints the next six values starting with the value entered that are evenly divisible by six.
Here are some example program dialogues to guide your efforts:
Feed me: 11
12
18
24
30
36
42
Feed me: 12
12
18
24
30
36
42
Feed me: 40
42
48
54
60
66
72
In an effort to help you focus on building an Assembly program, Id like to offer you the following C statements which match the program specifications stated above. If you like, use them as the basis for building your Assembly program.
// print the next six numbers evenly divisible by six
int answer =0;
int x =0;
int howMany =6;
int evenlyDivisibleBy =6;
printf( "Feed Me: ");
scanf("%d", &x );
answer = x;
int i =1;
while( i <= howMany )
{
while( answer >0)
{
answer = answer - evenlyDivisibleBy;
}
if (answer ==0)
{
printf("%d
", x );
i = i +1;
}
x = x +1;
answer = x;
}
without high level language such as for loops and if statements.
Heres my code
program DivisibleBySix;
#include("stdlib.hhf")
static
x: int32; // User input value
i: int32 :=0; // Loop counter for six values
current: int32; // Current value being checked
remainder: int32; // Remainder when dividing by 6
begin DivisibleBySix;
// Prompt the user for input
stdout.put("Feed me: ");
stdin.get(x);
// Initialize the current value to the user input
current := x;
// Loop to find and print the next six values divisible by 6
while(i <6) do
// Check if the current value is divisible by 6
remainder := current mod 6;
if(remainder =0) then
// If divisible by 6, print the value
stdout.put(current, nl);
// Increment the counter for found values
i := i +1;
endif;
// Increment the current value to check the next one
current := current +1;
endwhile;
end DivisibleBySix;

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions