Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Assembly Language Programming (ALP) Forum (http://www.go4expert.com/forums/assembly-language-programming-forum/)
-   -   PROGRAM 2: Number Table (http://www.go4expert.com/forums/program-2-number-table-t26847/)

_Marlon 5Oct2011 02:12

PROGRAM 2: Number Table
 
Here is the Description of the Task:

PROGRAM 2: Number Table
Write a program to produce a number table as described here. This table should be built from a single int8 value provided by the user. The program will display six rows based on the input entered. In the first column, label each of the five new rows as with the numbers 1, 2, 3, 4 and 5. In other words, the column values 1, 2, 3, 4 and 5 will always be shown with every horizontal table in the first column. Build each horizontal row by incrementing each value by one.
For example, the following output should be produced when the user inputs the starting value 15:

Gimme a starting value: 15
15 15 15 15 15
1 16 17 18 19 20

2 17 18 19 20 21
3 18 19 20 21 22
4 19 20 21 22 23
5 20 21 22 23 24

And here is the output that would be produced when the user inputs the starting value 10:

Gimme a starting value: 10
10 10 10 10 10
1 11 12 13 14 15

2 12 13 14 15 16
3 13 14 15 16 17
4 14 15 16 17 19
5 15 16 17 18 20



Here is my program. I tried for a few hours to no avail. HELP? I am not sure what i am doing wrong... my columns aren't adding correctly and my professors' comment is "NumberTable Program Was Very Incomplete." Help please? here is my program





_Marlon 6Oct2011 05:29

Re: PROGRAM 2: Number Table
 
Here is the code

Code:

program numsInColumns2;

#include ("stdlib.hhf")

var
        inputValue: int8;
        colCnt: int8;
       
       
begin numsInColumns2;

// Prompt the user
stdout.put( nl nl "Gimme a starting value: ");
stdin.get(inputValue);

stdout.put("    ", inputValue);
stdout.put("    ", inputValue);
stdout.put("    ", inputValue);
stdout.put("    ", inputValue);
stdout.put("    ", inputValue, nl);


mov(0,AH);
mov(inputValue, AH);

stdout.put("1":6);        // prints row 1+ increments of inputValue+ (N+1)

add(1, AH);
stdout.put(AH:6);
add(2, AH);
stdout.put(AH:6);
add(3, AH);
stdout.put(AH:6);
add(4, AH);
stdout.put(AH:6);
add(5, AH);
stdout.put(AH:6, nl);


mov(0,AH);
mov(inputValue, AH);

stdout.put("2":6);        // prints row 2+ increments of inputValue+ (N+1)

add(2, AH);
stdout.put(AH:6);
add(3, AH);
stdout.put(AH:6);
add(4, AH);
stdout.put(AH:6);
add(5, AH);
stdout.put(AH:6);
add(6, AH);
stdout.put(AH:6, nl);

mov(0,AH);
mov(inputValue, AH);


stdout.put("3":6);        // prints row 3+ increments of inputValue+ (N+1)

add(3, AH);
stdout.put(AH:6);
add(4, AH);
stdout.put(AH:6);
add(5, AH);
stdout.put(AH:6);
add(6, AH);
stdout.put(AH:6);
add(7, AH);
stdout.put(AH:6, nl);

mov(0,AH);
mov(inputValue, AH);

stdout.put("4":6);        // prints row 4+ increments of inputValue+ (N+1)

add(4, AH);
stdout.put(AH:6);
add(5, AH);
stdout.put(AH:6);
add(6, AH);
stdout.put(AH:6);
add(7, AH);
stdout.put(AH:6);
add(8, AH);
stdout.put(AH:6, nl);

mov(0,AH);
mov(inputValue, AH);

stdout.put("5":6);        // prints row 5+ increments of inputValue+ (N+1)

add(5, AH);
stdout.put(AH:6);
add(6, AH);
stdout.put(AH:6);
add(7, AH);
stdout.put(AH:6);
add(8, AH);
stdout.put(AH:6);
add(9, AH);
stdout.put(AH:6, nl);


stdout.put(nl);

end numsInColumns2;


_Marlon 6Oct2011 05:30

Re: PROGRAM 2: Number Table
 
My columns come out wrong for some reason... i think it has to do with the registers i am storing too, though i am not sure which i am suppose to store to if that is the case... help anyone?


All times are GMT +5.5. The time now is 15:05.