Posts

Showing posts from January, 2025

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

Lab 2 - 6502 Math Lab

 Hey there! Today, I’m diving into an Assembly Language project where I built a simple animation that moves a 5×5 graphic diagonally across the screen and makes it bounce off the edges—kind of like a classic screensaver. This project was all about getting hands-on with low-level programming, handling memory directly, and figuring out how to make things move smoothly within a constrained environment. If you’ve ever wondered how old-school games and animations worked behind the scenes, this is a great example of the kind of logic they used. Let’s break it down!

Lab 1 - Experiments

Image
                                                                 Experiments Add this instruction after the  loop:  label and before the  sta ($40),y  instruction:  tya Visibly I see 32 stripes of color by running the above code. Adding the tya instruction before sta ($40),y causes the value of the Y register (the current index) to be transferred to the accumulator ( A ). Since sta ($40),y writes the value of the accumulator to memory, this change means that the color stored at each pixel now depends on the current value of Y . As Y increments from 0 to 255 within each page, the accumulator's value also changes, resulting in different color codes being written to the screen. This creates a series of stripes, as each pixel or small group of pixels gets a unique color...

Lab 1 - Modifying Code

  7. Change the code to fill the display with light blue instead of yellow. 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 #$06 ; colour changes to blue from yellow 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   8. Change the code to fill the display with a different colour on each page (each “page” will be one-quarter of the bitmapped display). This program fills the screen with alternating colors using indexed addressing and loops. It begins by setting up a pointer at  $40-$41  to start at the memory location  $0200  and storing four color codes i...

Lab 1 - Calculating Performance

Image
                2. The following code fills the emulator's bitmapped display with the colour yellow. Paste                            this code into the emulator: The code runs correctly  code by pressing the  Assemble  button, then the  Run  button. No compiling errors. 4. Calculate how long it takes for the code to execute, assuming a 1  MHz  clock speed. The code works by initializing memory pointers and then running a loop to fill a 32x32 pixel display (spread across 4 memory pages) with a specific color. The setup phase runs once, using 16 cycles to prepare the pointers and initial values. The main loop, which repeats 1024 times (once for each pixel), executes instructions to store the color, update the index, and check if the loop should continue, taking a total of 10232 cycles. After completing each page, the pro...

Introduction

Hello all, this lab is a creative demonstration of how the 6502 processor can efficiently fill a screen with colors using assembly language. By utilizing memory pointers, indexed addressing, and looping structures, the program cycles through multiple predefined colors and applies them to each pixel on the screen, page by page. It showcases the simplicity and power of low-level programming while highlighting the processor’s ability to manage memory and execute repetitive tasks with precision. Whether you're exploring retro computing or learning the basics of assembly, this code provides a fun and engaging example of bringing a screen to life.