Difference between revisions of "6502 Assembly Language Lab (Old Version)"
Chris Tyler (talk | contribs) (→Writing Code, Part 2) |
Chris Tyler (talk | contribs) (→Lab 1) |
||
Line 51: | Line 51: | ||
=== Writing Code, Part 2 === | === Writing Code, Part 2 === | ||
6. Extend the previous code to draw a yellow line down the left side of the screen and a purple line down the right side. | 6. Extend the previous code to draw a yellow line down the left side of the screen and a purple line down the right side. | ||
+ | |||
+ | === Optional: Experiments === | ||
+ | # Add this instruction after the <code>loop:</code> label and before the <code>sta ($40),y</code> instruction: | ||
+ | tya | ||
+ | # What visual effect does this cause, and how many colours are on the screen? Why? | ||
+ | # Add this instruction after the <code>tya</code>: | ||
+ | lsr | ||
+ | # 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. | ||
+ | # Repeat the tests using <code>asl</code> instructions instead of <code>lsr</code> instructions. Describe and explain the effect in each case. | ||
+ | # Remove the <code>tya</code> and all <code>asl</code> and <code>lsr</code> instructions. | ||
+ | # The original code includes one <code>iny</code> instruction. Test with one to five consecutive <code>iny</code> instructions. Describe and explain the effect in each case. '''Note:''' ensure that the Speed slider is on its lowest setting (left) for these experiments. | ||
== Write-Up == | == Write-Up == |
Revision as of 00:23, 16 September 2021
Contents
Resources
- 6502 Wiki Page
- 6502 Emulator
- 6502 Emulator Example Code
- Opcode/Instruction References
Lab 1
Setup
- Enter the breakout room assigned to you.
- Select one person to be the "Driver", who will type/operate the computer for the group.
- The driver will open the 6502 Emulator at [1] (and, ideally, this lab page as well).
Bitmap Code
3. Paste this code into the emulator:
lda #$00 ; set a pointer at $40 to point to $0200 sta $40 lda #$02 sta $41 lda #$07 ; colour number ldy #$00 ; set index to 0 loop: sta ($40),y ; set pixel at the address (pointer)+Y iny ; increment index bne loop ; continue until done the page inc $41 ; increment the page ldx $41 ; get the current page number cpx #$06 ; compare with 6 bne loop ; continue until done all pages
4. 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 everyone in your group understands how it works.
Writing Code, Part 1
5. Write code to draw a green line across the top of the bitmap screen and a blue line across the bottom.
Writing Code, Part 2
6. Extend the previous code to draw a yellow line down the left side of the screen and a purple line down the right side.
Optional: Experiments
- Add this instruction after the
loop:
label and before thesta ($40),y
instruction:
tya
- What visual effect does this cause, and how many colours are on the screen? Why?
- Add this instruction after the
tya
:
lsr
- 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
lsr
instructions in a row. Describe and explain the effect in each case. - Repeat the tests using
asl
instructions instead oflsr
instructions. Describe and explain the effect in each case. - Remove the
tya
and allasl
andlsr
instructions. - The original code includes one
iny
instruction. Test with one to five consecutiveiny
instructions. Describe and explain the effect in each case. Note: ensure that the Speed slider is on its lowest setting (left) for these experiments.
Write-Up
Post an entry on your blog describing your experiments in this lab. Include:
- An introduction, so that someone who happens across your blog will understand the context of what you're writing about.
- The results from the Bitmap Code portion of the lab, describing what happened in each case and the reasons for it.
- The results from the two Writing Code portions of the lab, including the code, a description of how the code works, and the results produced.
- Your experiences with this lab -- your impressions of the Assembly Language, what you learned, and your reflections of the process.
Remember to follow the Blog Guidelines as you write.