Posts

Project Stage 3

 The final stage of this project was all about tying up loose ends and making sure that everything I worked on in Stage 2 was complete and functional. The main goal was to ensure the GCC custom pass could identify cloned functions, determine if they were fundamentally the same or different, and provide appropriate output in the diagnostic dump file. I worked on integrating it into GCC, testing it with both provided and custom test cases, and verifying its outputs. Integration and Enhancements After the initial setup and testing of the tree-ctyler pass in Stage 2, I ensured it was properly integrated into the GCC compilation process. This involved verifying the modifications made to Makefile.in , passes.def , and tree-pass.h . These changes ensured the pass was correctly registered and could be invoked during compilation. The pass was placed late in the compilation pipeline to ensure that all significant optimizations, such as vectorization, were completed before its execution. By ...

Lab4

Image
   Introduction This project demonstrates the implementation of loops in AArch64 and x86_64 assembly languages. The objective is to print numbers from  0–10  and  0–30  in specific formats, leveraging both single and double-digit handling mechanisms. The implementation showcases system calls, ASCII conversion, and data handling techniques. AArch64 Assembly: Loop from 0 to 10 This code outputs numbers from  0  to  10 , appending them to a predefined string  "Loop: " . The loop index is converted to ASCII before being displayed. .text .globl _start // Define constants min = 0                          // Starting value for the loop index max = 10                         // Maximum value for the loop index _start:     mov     x19, min             // Initi...

Lab3

Image
  Introduction In this lab, I implemented a Pong game in 6502 Assembly Language. Pong is a classic game, and recreating it provided me with an opportunity to dive deep into assembly programming while learning how to handle graphics, input, and game logic efficiently. This blog post outlines the implementation, key challenges faced, and my reflections on the project. Project Overview The goal of this project was to create a functional version of Pong in 6502 Assembly Language. This involved three key objectives: first, to display a moving ball on the screen with smooth updates; second, to allow the player to control a paddle using arrow keys for interaction; and third, to implement collision detection to ensure the ball bounces off walls and the paddle accurately, creating a playable and engaging game. Code Implementation ; Memory Locations define ROW        $20    ; Ball's vertical position define COL        $21    ; Ball'...

Lab2

  Introduction In this lab, I worked on a 6502 assembly language project where I animated a small graphic, making it move across the screen and bounce within predefined screen boundaries. The main objective was to write assembly code that would control the movement of a 5x5 pixel graphic, simulate the bouncing effect when it hit the screen's edges, and explore how changing movement increments could impact performance. The task helped me understand the challenges of low-level programming and the limitations of early computer hardware. The process began with creating a basic routine to move a 5x5 pixel graphic (represented as a blue "O") across the screen. The graphic's position was adjusted along both the X and Y axes. Once the basic movement was working, I added a bouncing effect when the graphic hit the screen's edges. I also experimented with different increments to refine the graphic's motion. Lab Code ; ; draw-image-subroutine.6502 ; ; This is a routine th...

Project Stage 2

Image
This blog is about my journey into learning GCC. It’s been a mix of downloading the source code, fixing directory problems, and trying to add a custom pass. Honestly, I’ve learned more about compilers in the past few days than I ever thought I would. Let me share my experience with you. Step 1: Setting Up the Project First, I created a project directory to keep things organized. I wanted separate folders for the GCC source code, the build files, and the final installation. Here’s what my structure looked like: mkdir -p ~/gcc-project/{src,build,install} Downloading the Source Code Next, I cloned the GCC repository. This took some time because the GCC codebase is  huge : git clone git://gcc.gnu.org/git/gcc.git ~/gcc-project/src When the cloning finished, I was ready to configure and build GCC. Or so I thought. Step 2: It showed No Such File When I tried to configure GCC, I hit my first big roadblock. Running  ../src/configure  from the  build  directory didn’t wor...

Project Stage 1

Building GCC on AArch64 and Exploring Compilation Dumps Introduction Welcome to my journey through Project Stage 1 for the SPO600 course, where we dive into building the GNU Compiler Collection (GCC) from source. This semester, our task is to create a proof-of-concept for the function-pruning component of Automatic Function Multi-Versioning (AFMV) on AArch64 systems . In this post, I’ll guide you through my experience with setting up GCC on an AArch64 server and exploring the diagnostic output, or “dumps,” generated during its compilation passes. Building a compiler from source was a first for me, and it provided essential insights into the build process and initial compiler optimizations. Why Build GCC? Compiling GCC from source is crucial for working directly with the compiler’s code. It lets us configure custom builds, test changes, and understand the system we’re developing for in a hands-on way. Setting up a local GCC build on the aarch64-002 server was my first step in getting...

Lab1

Image
  Lab 1: 6502 Assembly Language Lab Introduction In this lab, we explore 6502 assembly language using a processor emulator. The 6502 is a well-known 8-bit microprocessor, and understanding its low-level architecture will allow us to grasp fundamental programming concepts, including memory management and CPU cycles. In this exercise, we wrote and optimized an assembly program that fills the screen with color. We then calculate execution time, memory usage, and modify the code to achieve specific outcomes. Setup To follow this lab, we used the 6502 Emulator .  Bitmap Code The following code fills the screen with the color yellow by pointing to memory at $0200 and incrementally writing the color to every pixel.     lda #$00        ; Load $00 into accumulator (low byte of pointer)     sta $40         ; Store low byte in address $40     lda #$02        ; Load $02 into accumulator (high b...