Lab 1 - Experiments

                                                    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 based on its position within the memory page. The variety of colors is due to the sequential progression of the Y register value.

Add this instruction after the tyalsr

Adding the lsr instruction after tya divides the value of the Y register (transferred to the accumulator) by 2, reducing the range of color codes. Originally, Y values from 0 to 255 produced 256 possible colors, but after the shift, the range is halved to 0–127. Since the 6502 supports only 16 unique colors (0–15), the colors now repeat every 16 values, resulting in 16 distinct colors displayed on the screen. The visual effect is wider stripes of color, as each color spans two consecutive pixel rows due to two Y values mapping to the same color after the shift.


Repeat the above tests with two, three, four, and five lsr instructions in a row. Describe and explain the effect in each case.



The 8-bit Y value (ranging from 0–255) creates 32 distinct color groups, each group representing 8 consecutive rows (256/32 = 8 rows per stripe). This results in the 32 stripes horizontally, with the appearance of horizontal bands because each stripe is repeated for a certain number of rows based on how the Y value maps to the color. As more lsr instructions are added, the color resolution continues to decrease, leading to fewer stripes with wider bands. The horizontal layout is inherent to how the rows are scanned and colored sequentially in memory. 


Repeat the tests using asl instructions instead of lsr instructions. Describe and explain the effect in each case.

Using asl (Arithmetic Shift Left) instead of lsr produces vertical stripes as the color values shift to higher bits, doubling each time. Each asl operation effectively multiplies the Y register's value (transferred to the accumulator by tya) by 2, increasing the separation between color groups. This results in fewer, wider color bands because higher bit values change less frequently. For instance, after one asl, there are 32 vertical stripes. Adding more asl instructions continues to reduce the number of stripes while further widening them, as the bit values become less granular and more uniform over wider sections. The stripes are vertical because the memory addressing for screen pixels maps color changes across columns, rather than rows, when the bit values shift.


Repeat the tests using asl instructions instead of lsr instructions. Describe and explain the effect in each case.

The ASL (Arithmetic Shift Left) instruction shifts all bits in the accumulator (A) one place to the left, effectively multiplying the value by 2. Unlike LSR, which divides by 2, ASL increases the spread between values, causing fewer, wider color bands to appear on the screen.


The original code includes one iny instruction. Test with one to five consecutive iny instructions. Describe and explain the effect in each case. Note: it is helpful to place the Speed slider is on its lowest setting (left) for these experiments.

In the original code, a single INY instruction increments the Y index register by 1, ensuring that each pixel is written to sequentially. Increasing the number of consecutive INY instructions affects how frequently colors are written to the screen, creating different visual effects.



Observations for Different INY Counts
One INY Instruction (Original Code)

The program colors every pixel sequentially, with smooth color transitions.
The screen is filled completely with the set color.

Two INY Instructions

The Y register increments by 2 each iteration, skipping every other pixel.
Creates striped horizontal bands, where every other pixel remains uncolored.

Three INY Instructions

The Y register increments by 3, skipping two pixels between each colored pixel.
Wider horizontal gaps between colored pixels, with colors appearing every 3 pixels.

Four INY Instructions

The Y register increments by 4, coloring only every fourth pixel.
Very noticeable horizontal gaps, creating a checkerboard-like effect when combined with multiple pages.

Five INY Instructions

The Y register increments by 5, skipping four pixels between each color.
The screen is filled with scattered pixels, each spaced further apart, making the pattern appear sparse.





Comments

Popular posts from this blog

Lab 2 - Lab Results

Project Stage 1

Lab 5 - Part 1 - Aarch 64