Posts

Project Stage 1

Image
In this project, I set out to create a custom GCC pass that analyzed GIMPLE files by iterating through every function, counting the basic blocks, and tallying the number of GIMPLE statements. I successfully integrated this pass into the GCC build system and tested it on a simple C program. Here’s how I did it. 1. Writing the Pass Code I began by writing the pass code in C++ and saved it in a file named tree-my-new-pass.cc within the gcc subdirectory of my GCC source. My pass, which I named "my_new_pass", was designed to run during the GIMPLE phase. The code looked like this: #include "config.h" #include "system.h" #include "coretypes.h" #include "backend.h" #include "tree-pass.h" #include "pass_manager.h" #include "context.h" #include "diagnostic-core.h" #include "tree.h" #include "tree-core.h" #include "basic-block.h" #include "gimple.h" #include "gimp...

Lab 5 - Part 1 - Aarch 64

Image
In this lab, my goal is to dive into assembly programming on both the x86_64 and AArch64 platforms. For Task 1, 1. I will closely examine how the AArch64 assembly source code—written in a human-readable format—is transformed into an object file containing machine code. This investigation will help me understand the assembly process by highlighting the differences between the high-level source instructions and the low-level binary output generated by the assembler. Source file Object file 2 : Constructing a Loop That Prints “Loop” Six Times In this task, I need to adapt the assembly code on the aarch64 server so that it outputs the word “Loop” exactly six times. Starting with the provided code, I will introduce a counter in one of the general-purpose registers, initialize it to zero, and increment it after each print. Once the counter reaches six, the loop will terminate. This requires adjusting the assembly instructions to compare the loop counter against a maximum value, calling the a...

Lab 5 - Part 2 - x86

Image
  For the second part of this lab, I will further explore x86_64 assembly programming, building on what was done in Part 1. 1.  I'll compare the assembly source code with its generated object file to understand how the human-readable instructions are translated into machine code. This exercise will highlight the differences between the code we write and the low-level output produced by the assembler. Source code Object file 2. Revise an x86 assembly loop program so that it outputs "loop" six times. Below is the revised Makefile I used, which includes a rule for building loop-gas . I simply added another entry in the BINARIES list and replicated the same build steps used for hello-gas.s : BINARIES=hello-nasm hello-gas loop-gas all: ${BINARIES} AS_ARGS=-g hello-nasm: hello-nasm.s nasm -g -o hello-nasm.o -f elf64 hello-nasm.s ld -o hello-nasm hello-nasm.o hello-gas: hello-gas.s as ${AS...

Lab 4 - GCC Build Lab

Image
In this lab, we're learning how to build large software projects using tools like Make and Automake/Autotools. I'll be working on two servers, x86-001 and aarch64-002 . Task: On both servers, I'll download, build, and install the latest development version of the GCC compiler . Below are the steps to complete the lab! 1. Clone the GCC repository using the below command      git clone git://gcc.gnu.org/git/gcc.git 2. Configure the build      create a separate build directory to avoid building GCC in the source directory       mkdir ~/gcc-build-001        cd gcc-build-001 3. To  set up GCC to be installed in a specific location (e.g., gcc-test-001 ),  Run the configure    script with the preferred prefix for the installation path      ~/gcc/gcc/configure --prefix=$HOME/gcc-test-001 4. Build the source code using the below command      time make -j 24 |& tee build.lo...

Lab 3

Image
Introduction: This is a simple number guessing game written for the 6502 processor. The goal of the game is to guess a random number between 1 and 100. The player is prompted to input their guess, and the game provides feedback on whether the guess is too high, too low, or correct. Game Initialization The game starts by initializing important variables and generating a random target number. The INIT_GAME subroutine is responsible for setting things up, including clearing the screen and generating the target number. The CLEAR_SCREEN clears both the character display and bitmap display, while GENERATE_RANDOM produces a random target number between 1 and 100. The random number is stored in the memory location $10. Displaying the Prompt The game asks the user to guess a number between 1 and 100. This is done by the DISPLAY_PROMPT subroutine, which outputs the string "Guess a number (1-100):" to the screen. This subroutine breaks down the string into individual characters and sen...

Lab 2 - Lab Results

Introduction In this blog post, I will share my experience working on a lab where we animated a small 5x5 graphic to move diagonally across the screen and bounce off the edges. The lab required an understanding of low-level memory manipulation, conditional logic, and efficient screen rendering. I'll walk you through the code, the changes made to implement bouncing logic, and my reflections on the learning process. **Since we collaborated as a group on optimizing the code, my work may resemble that of my teammates =================================================================== Initial Code The following code moves a 5×5 graphic diagonally across the screen: ; ; draw-image-subroutine.6502 ; ; This is a routine that can place an arbitrary ; rectangular image on to the screen at given ; coordinates. ; ; Chris Tyler 2024-09-17 ; Licensed under GPLv2+ ; ; ; The subroutine is below starting at the ; label "DRAW:" ; ; Test code for our subroutine ; Moves an image diagon...