Changes

Jump to: navigation, search

6502 Assembly Language Lab

565 bytes added, 16:14, 28 September 2022
Experiments (Optional, Recommended)
*** [http://www.6502.org/tutorials/6502opcodes.html 6502 Opcodes with Register Definitions]
*** [https://www.masswerk.at/6502/6502_instruction_set.html 6502 Opcodes with Detailed Operation Information]
* [https://docs.google.com/spreadsheets/d/1a1-ZZ1opY8xcuUHNxj3YW75dxOPynSuP2-QGSvZGzYY/edit?usp=sharing Spreadsheet of bitmmapped bitmapped display memory locations]
== Lab 2 ==
2. The following code fills the emulator's bitmapped display with the colour yellow. Paste this code into the emulator:
lda #$00 ; set a pointer at 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
3. Test the code by pressing the Assemble button, then the Run button. If the there are any errors assembling (compiling) the code, they will appear in the message area at the bottom of the page. Make sure the code is running correctly and that you understands how it works. Don't be afraid to experiment!
=== Calculating Performance ===
4. Calculate how long it takes for the code to execute, assuming a 1 MHz clock speed(Watch [https://web.microsoftstream.com/video/ed7aedf1-fe6f-4b72-bbf1-c9b4e6e80af9 this video] if you would like a refresher on how to do this). Also calculate the total memory usage for the program plus any pointers or variables.
5. Consider ways to decrease the time taken to fill the screen with a solid colour. Calculate the execution time of the fastest version of this program that you can create.Challenge: the fastest version of this program is more than twice as fast as the original version shown above!
=== Modifying the Code ===
# Add this instruction after the <code>loop:</code> label and before the <code>sta ($40),y</code> instruction: <code>tya</code>
# What visual effect does this cause, and how many colours are on the screen? Why?
# Add this instruction after the <code>tya</code>: <code>lsalsr</code>
# What visual effect does this cause, and how many colours are on the screen? Why?
# Repeat the above tests with two, three, four, and five <code>lsr</code> instructions in a row. Describe and explain the effect in each case.
=== Challenges (Optional, Recommended) ===
# Set all of the display pixels to the same colour, except for the middle four pixels, which will be drawn in another colour.
# Write a program which draws lines at around the top and bottom edge of the display:
#* A red line across the top
#* A green line across the bottom
#* A blue line across the right side.
#* A purple line across the left size.
=== Write-Up ===

Navigation menu