943,155 Members | Top Members by Rank

Ad:
  • Assembly Discussion Thread
  • Unsolved
  • Views: 732
  • Assembly RSS
Feb 9th, 2010
0

Help on program to take 2 int8 values from the user and create table

Expand Post »
Here is the description of my project:
write a program to produce an "addition table." This table should input two small int8 values from the user. It should verify that the input is correct(i.e., handle the ex.ConversionError and ex.ValueOutOfRange exceptions) and is postitive. The second input value must be greater than the first input value. The program will display a row of values specified. Finally, it will print a matrix of sums.
The following is the expected output for the user inputs 15 & 18.
add 15 16 17 18
15 30 31 32 33
17 32 33 34 35
18 33 34 35 36
Okay and here is what Me and my friend have got so far:
Assembly Syntax (Toggle Plain Text)
  1. program testBadInput5;
  2.  
  3. #include( "stdlib.hhf" )
  4.  
  5. static
  6.  
  7. input: int8;
  8. input2: int8;
  9. colSize: int8;
  10. i: int8;
  11. GoodInput: boolean := false;
  12. i16: int16;
  13.  
  14. //line 15
  15. begin testBadInput5;
  16.  
  17.  
  18. repeat
  19.  
  20. mov( false, GoodInput );
  21. try
  22.  
  23. //Gets 2 Values to use to make addition table
  24.  
  25. stdout.put( "Enter two digits, the first one being LESS than the second one: " );
  26. stdin.get( input, input2 );
  27. mov(input, AL);
  28. stdout.put( "The two input values are: ", input, " ", input2, nl nl );
  29. //30
  30.  
  31. // If statement to make sure the first Value is not larger than the second one.
  32.  
  33. if( AL > input2 ) then
  34.  
  35. stdout.put("Your first number was larger than the second,",
  36. " please have the first number smaller than the second." nl nl );
  37.  
  38. mov( false, GoodInput );
  39.  
  40. else
  41. stdout.put("You entered the number correctly." nl nl );
  42. mov( true, GoodInput );
  43.  
  44. endif;
  45.  
  46. //47
  47. exception( ex.ValueOutOfRange )
  48.  
  49. stdout.put( "The value was too large, reenter." nl, nl );
  50.  
  51. exception( ex.ConversionError )
  52.  
  53. stdout.put( "The input contained illegal characters, reenter." nl, nl );
  54.  
  55.  
  56. endtry;
  57.  
  58. until( GoodInput = true ); // repeats until there is a good, qualified input that can be used
  59. //60
  60.  
  61. stdout.put( "The numbers are: ", input, " " , input2, nl );
  62.  
  63.  
  64. mov( input2 , AH ); //move input2 into 8 bit register AH
  65. sub( input , AH ); //subtract input - AH(input2) to get the amount of colums needed
  66. add( 1, AH );
  67. mov( AH , colSize ); //moves AH into variable colSize
  68.  
  69. stdout.put( "The colSize is ", colSize, nl nl );
  70. //70
  71. mov( input2, BL);
  72. add( 1, BL );
  73. While( input < BL ) do
  74.  
  75. if( colSize = 0 ) then
  76.  
  77. stdout.put("ColSize = ", colSize );
  78.  
  79. //mov( 0, colSize );
  80.  
  81. endif;
  82.  
  83. stdout.put( input:5 );
  84. add( 1, input );
  85. sub( 1, colSize );
  86. stdout.newln();
  87.  
  88. endwhile;
  89.  
  90. // in comments so we can test program
  91.  
  92. //mov( 96, i32 );
  93. //mov( 0, ColCnt );
  94.  
  95. // while( colSize > 0 ) do
  96.  
  97. // if( ColCnt = 8 ) then
  98.  
  99. // stdout.newln();
  100. // mov( 0, ColCnt );
  101.  
  102. // endif;
  103. // stdout.puti32Size( i32, 5, ' ' );
  104. // sub( 1, i32 );
  105. // add( 1, ColCnt );
  106.  
  107. // endwhile;
  108. // stdout.newln();
  109.  
  110.  
  111. end testBadInput5;


Having some trouble with displaying any help would be much appreciated
Last edited by xerreck; Feb 9th, 2010 at 1:33 am.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
xerreck is offline Offline
8 posts
since Nov 2009
Feb 9th, 2010
0
Re: Help on program to take 2 int8 values from the user and create table
forgot to put my output when ran:

Enter two digits, the first on being LESS than the second on: 5 8
The two input values are:5 8

You entered the number correctly

The numbers are: 5 8
The colSize is 4
5
6
7
8
Reputation Points: 10
Solved Threads: 0
Newbie Poster
xerreck is offline Offline
8 posts
since Nov 2009
Feb 9th, 2010
0
Re: Help on program to take 2 int8 values from the user and create table
okay so I figured out I am going to need a loop inside a loop for this to work and here is a basic idea of what I am trying to do but not in assembly code
Assembly Syntax (Toggle Plain Text)
  1. for i = low; i <= high i ++
  2. print low
  3. for j =al; j<= al + high J ++
  4. print J
  5.  
  6. print nl
I now just need help getting it into assembly code? Thanks
Reputation Points: 10
Solved Threads: 0
Newbie Poster
xerreck is offline Offline
8 posts
since Nov 2009
Feb 10th, 2010
0
Re: Help on program to take 2 int8 values from the user and create table
Thanks for everyone's help... I guess.. I figured it out anyways... This site wasn't any real help. oh well.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
xerreck is offline Offline
8 posts
since Nov 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Assembly Forum Timeline: Beginner question: from memory to register
Next Thread in Assembly Forum Timeline: A thread from 1985...





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC