Posts

Project update 1.2

 As the semester coming to an end today, I decided to show what I find and my potential solution for this issue. I wish I was a bit smarter and had more time to work on this issue as it's very interesting to me. Anyways, here are what I found so far that could potentially be beneficial in the future. All the files I mention below will be located in gcc/gcc/config/aarch64. What I found in the GCC repo that may be useful in the future: I believe I located the file that store all the values for the target_versions, it's a file called:  aarch64-option-extensions.def . There is another file called  aarch64-cores.def which included all the aarch64 architectures (in this file, they call those options "core options", if I understand correctly then they are the same). If this is the case, then the update process seems to be a bit easier as we already have the implementation to design for a specific architecture when we use target_version. Last but not least, in aarch64.cc , t...

Project Progress update 1.1

 So far I have spent lots of time researching and trying to understand how I can update the GCC code to accept another value target_clonse (in this case, we're aiming to add arch to the compiler). So far I have come to a few understanding and now I'm trying to identify where I can put my code in to update the compiler. However, this comes with lot of trials and errors. As the result, I will sum up both my understanding and what I have tried and failed so far March vs Mtune This one first confused me a lot. I didn't know the differences between the two. Turn out, -march is for a specific CPU architecture and -mtune is used when we want the program to run on all CPUs, but the compiler would choose those algorithms and functions that benefits the defined architecture Aarch64 march vs x86_64 march Although they use the same syntax, each GCC version for the specified architecture has a different range of values. Based on what I understand right now, it seems like in x86_64, you...

GCC Project and My potential contribution

 In the following weeks, I will work with the GCC for Aarch64 machines . This is, for me, a very interesting project as well as challenging. In my whole life, I have never thought of actually modifying an existing compiler let along one of the most popular, powerful one. In this article, we will see what this project aims to do and my part as a contributor of the project Project description Normally, when we compile a program, we often compile it for a specific architecture. Everything would be fine if the architecture stays the same forever. However, like us, they are also improved, with more and more features, functionalities that could potentially provide faster runtime and better experience for their users. As the result, we programmer aims to make our programs faster and better, and one of the way to do so is to pick up new features whenever possible so that our programs can utilize all available resources that the machine offers them. This is a problem for the GCC compiler be...

Lab 3

 In this lab, I learned how to write a basic for loop and create if else conditions and I found a lot of fun.  During a previous class, professor taught me how the syntaxes of 2 architectures: x86_64 and aarch64. He showed me how to create a basic program that prints out the iteration index 10 times. My responsibility is to update the program and let it runs 30 times. At first I thought it was easy (in JavaScript it takes only 3 lines to do so) and then I realized that this was Assembly and I still have PTSD about the time I worked on lab 1 and 2. However, I think because I worked with 6502 before, this was not as difficult as I think. Or maybe because I didn't have to work with a screen, I don't really know. Anyways, here is the code: Aarch64:  .text  .globl _start  min = 0                          /* starting value for the loop index; **note that this is a symbol (constant)**, not a variable */ ...

Lab 2 - Letter guessing game

Image
 In this lab, I decided to mimic something professor has taught in his recording, which shows how to get input, print output and jump to different branches based on conditions. Assembly is supper difficult for me as I'm really not familiar with the language. As a result, I decide to combine my lab 1 and his instructions to create a letter guessing game. This program will randomly select a letter from A to Z, store it in the memory. The user will guess the letter. If they guess it correctly, a prompt will appear and the screen will become green, else there will be an error prompt followed by an input prompt for retry, and the screen will turn red. Here is the code: ; ROM routines define SCINIT $ff81 ; initialize/clear screen define CHRIN $ffcf ; input character from keyboard define CHROUT $ffd2 ; output character to screen define SCREEN $ffed ; get screen size define PLOT $fff0 ; get/set cursor coordinates define GENERATED_LETTER $0040 define IN...

How to get multiple inputs from the emulator

Description Currently, I'm creating a project where you would have to guess a letter the from the emulator, and I would need the user to enter a random character and the application will let the user know whether they entered a correct character or not. This is what I learnt about how to get an input from a user Get an input and print it out In our emulator , if we click the note button, we can see these definitions, we’ll focus on CHRIN and CHROUT today.   ; ROM routines define          SCINIT          $ff81 ; initialize/clear screen define          CHRIN           $ffcf ; input character from keyboard define          CHROUT          $ffd2 ; output character to screen define         ...

Lab 1 - SPO 600

Image
 Description In this lab, we work will a basic assembly code that will color our screen here using this 6502 emulator Here is our base code: lda #$00 ; set a pointer in memory location $40 to point to $0200 sta $40 ; ... low byte ($00) goes in address $40 lda #$02 sta $41 ; ... high byte ($02) goes into address $41 lda #$07 ; colour number ldy #$00 ; set index to 0 loop: sta ($40),y ; set pixel colour at the address (pointer)+Y iny ; increment index bne loop ; continue until done the page (256 pixels) inc $41 ; increment the page ldx $41 ; get the current page number cpx #$06 ; compare with 6 bne loop ; continue until done all pages  The code above will fill the screen with yellow Calculating Performance Base code To calculate the performance, we need to know the time the CPU takes to run the application. We need to know the number of cycles the CPU has to iterate to finish the code. Each instruction takes a different number of cycles and by...