Tuesday, February 25, 2020
Lab 4 Reflection - Part 3
In order to understand this blog post it is highly recommended you read the posts "Lab 4 Reflection - Part 1" and "Lab 4 Reflection - Part 2" . As these posts will give you much needed context on what I'm going to discuss in this post. The following will cover my completion of Option 1.
Option 1 Code Link: https://gist.github.com/Megawats777/11f462dee4a9330403d791444fda966e
To begin lets discuss my work on Option 1, where the task was to create a program where the user can enter two numbers (0-99) and add them together. To be honest upfront, I was not able to figure out how to retrieve two digit number input and was only able to get single digit input to work. Another issue is that while I was able to filter out letters from being used as input I was not able to get certain characters such as commas to be filtered out. Finally, there is an issue that a zero is not the default value for the user's input. With those issues explained lets proceed to how my program works.
To start off the code walkthrough, at the top are a bunch of define statements. These statements define what ROM routines I'll use for character output, the location of the user's input, the results of the user's input, and finally the results of the addition. The values for most the define statements are initialized before any input is requested. Speaking of input lets go through the main program loop.
The main program loop first starts with a message asking for a number to be entered. Afterwards a constant check for input begins along with various filters in place to ensure that only numbers are entered. Once a number is entered its value will be show on the screen in reverse video mode. And when the enter key is pressed the entered number is filtered out in a way that removes the reverse video properties as well as its high byte. By removing the high byte only the pure number will be stored. Once all the filtering has finished taking place the result is stored in the appropriate define statement (ex: firstNumber, secondNumber). After that input loop is done a second number is requested and in turn the process repeats. Finally when the second number is retrieved the addition process proceeds.
The addition process first begins by adding the define statements firstNumber and secondNumber together in decimal mode. Afterwards, I separate both digits in the addition result in order to prepare them for output. Once the output preparation phase is done both digits are outputted in separate locations but in a way that makes them look they are together.
Thank you for reading and my overall thoughts for this lab will be posted on the entry "Lab 4 Reflection - Part 4 (Final)".
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment