Tuesday, February 25, 2020

Lab 4 Reflection - Part 4 (Final)

Before you continue please read posts "Lab 4 Reflection - Part 1", "Lab 4 Reflection - Part 2", and "Lab 4 Reflection - Part 3". These posts will give you much needed context on this entry and since this is the last in the series it will be even more important that you read them. Without further a due this is the final entry in my lab 4 reflection series and will give you my thoughts on the three week journey working on this lab.


To begin this conclusion I will start when myself and others were given this assignment. We were told it was based around text input and you are to complete two of the four tasks given to you. After a brief discussion with a few of my peers I decided to complete tasks named "Option 1" and "Option 4". Option 1 required you to create a program where the user can add two numbers they typed together. And option 4 required to make a program where the user can control what colour is shown on the bit mapped display through a text list they controlled. Of the two tasks I selected I felt that option 4 would be handled first as it felt the most approachable. While option 1 definitely felt like a bigger challenge and would require more time to think about.


The process of working on option 4 took about four days to complete as I was able to separate its tasks in manageable chunks. It first began with me trying to get keyboard input working. Then trying to get the keyboard to control the colour shown on the screen. And finally it concluded with me trying to get text colour list to work and making sure it lined up with what colour was selected. Of all the tasks that took the most work it was the text colour list that takes that honor, as it was the first time I worked with character output on the 6502.


Finally there is option 1 which took a couple weeks to think of. This was due to me feeling overwhelmed and not knowing where to begin. At first I tried to use existing sample code as a base for my work but it felt like I had no control over it so I scrapped it. I also tried to go for the two digit input scheme. But after struggling how to get a single digit number working for two weeks, I ultimately decided to scope down and only get single digit input to work just so that I have something to show. In the end I'm glad I made that decision as I was able to have a clear idea on what to do as well as gain encouragement to do the best I can.


Overall working on this lab and more so than the previous ones taught me the lesson of sticking with the problem as in the end it will workout.

Thank you for reading this 4 part series on lab 4 and as always see you on the other side :)


My code for lab 4


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)". 

Monday, February 17, 2020

AArch64 / x86_64 Study Reflection


This post is going to cover my thoughts on the AArch64 / x86_64 architectures after studying them for a quiz I did on the previous Friday.


Some of the key aspects that stood out to me when studying these architectures includes their approach to registers and how they are coded through assembly language. 


In terms of how the registers were done what stuck out to me was that there a lot more than the 6502 chip I worked with in the past and that most of them were multi purpose. Regarding the quantity of registers AArch64 has 30 registers that are mostly usable and x86_64 has 16 registers that most can be used safely. In comparison, the 6502 chip I worked with only has 3. A great aspect to these two architectures is that all of these registers are multipurpose while the 6502 chip only has two registers that can increment numbers and only one that can add more than one number.


When it comes to programming those chips what surprised me was how similar it was to coding on a 6502. For instance, on the 6502 all optcodes worked by typing a 3 letter command and then feeding that command with a register, a address in memory, or with a hex or decimal number. On the AArch64 / x86_64 chips it works in the same way, the only difference is how numbers, addresses, and registers are referenced when feeding them into optcodes. Another quirk I found mainly between the two architectures I studied was how values were are transferred to registers. On the AArch64 a value would fed into a register from right to left (ex: add r0, r1, r2 | here the value from r1+ r2 would be fed into the register r0). While on x86_64 side it would be left or right (ex: add %r10, %r11 | here the values in r10 and r11 are added together and the result is stored in r11).


Overall after studying these architectures I feel a little less overwhelmed in trying them out as well as a little excited in programming the hardware I use everyday instead of the emulator of a really old chip.


References;
https://wiki.cdot.senecacollege.ca/wiki/AArch64_Register_and_Instruction_Quick_Start

https://wiki.cdot.senecacollege.ca/wiki/X86_64_Register_and_Instruction_Quick_Start

Saturday, February 8, 2020

Lab 4 Reflection - Part 2


This blog post is a follow up from the previous post called "Lab 4 Reflection - Part 1". It is highly recommended you read that post prior to this one so you have context on what this entry is all about. This post will cover my completion of "option 4" for lab 4 including a brief breakdown on how the code works.


Code link: https://gist.github.com/Megawats777/30f5b436042aff848263d483ebaf051d


To describing the code briefly it is best to explain the general flow of it all. When the program first boots up I first initialize the variables "colour" and "colourNameIndex" to zero as well as draw the text menu for colour selection. Afterwards, I start the whole input loop where I check whether the up or down arrow keys have been pressed. These keys will control the change of the colour shown on the bitmap display. After the appropriate keys are pressed the "colour" variable will have it's value changed and that variable will be used to draw the selected colour on screen. Once the colour on screen is drawn I then update the text colour list to show which colour is selected. I represent the selected colour on the text list via reversing the video on the selected colour name. Finally, once all of this is done I go back to checking for input from the user.


See you in the next part.

Thursday, February 6, 2020

Lab 4 Reflection - Part 1


Hi, this blog entry will be about my first encounters with Lab 4. To bring you up to speed about what lab 4 is, this lab is divided into two tasks that I chose. The first task is to create a display that is filled by a colour selected by the user. With their options being shown on a fully text based list. This task in the assignment is designated as, "option 4". The second task is to create a fully text based application where the user can add two numbers together and see the result. This task in the assignment is designated as, "option 1". For now this blog entry will be about my current progress into the first task


What I was able to complete so far was the keyboard input as well as filling the display with the selected colour. The colours are chosen and the display is updated when you press either up or down arrows on the keyboard. As of now the user will have access to all 15 colours available on the display. However there maybe a chance that this will be reduced as I may struggle to fit all 15 options in the text based menu.


Here is my code so far: https://gist.github.com/Megawats777/07aa867839f595ee26ba7242f598a96d


See you on the other side ;)