1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

PROGRAM 2: Number Table

Discussion in 'Assembly Language Programming (ALP) Forum' started by _Marlon, Oct 4, 2011.

?

Did you have problems with this question?

  1. Yes, i did not understand what the question was?

    100.0%
  2. No, i understood everything.

    0 vote(s)
    0.0%
  1. _Marlon

    _Marlon Banned

    Joined:
    Oct 4, 2011
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    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




     
  2. _Marlon

    _Marlon Banned

    Joined:
    Oct 4, 2011
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    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;
     
  3. _Marlon

    _Marlon Banned

    Joined:
    Oct 4, 2011
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    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?
     

Share This Page