Open main menu

CDOT Wiki β

Changes

6502 Assembly Language Lab (Old Version)

455 bytes added, 10:23, 15 September 2022
no edit summary
{{Admon/important|This lab is not used in the current semester.|Please refer to the other labs in the [[:Category:SPO600 Labs|SPO600 Labs]] category.}}[[Category:SPO600 Labs- Retired]]{{Admon/lab|Purpose of this Lab|In this lab, you will learn some of the basics of [[6502]] assembly language, in preparation for learning more complex x86_64 and AArch64 assembly language.}}
== Resources ==
* [[6502]]Wiki Page
* [[6502 Emulator]]
* [[6502 Emulator Example Code]]
=== Setup ===
1. Organize a group of 4-6 students around one of Enter the monitor/whiteboard groups in the classroom. Arrange the furniture so that everyone has a comfortable view of the displaybreakout room assigned to you. 2. Gather these supplies:* HDMI cable* Whiteboard markers 3. Select one person to be the "Driver", who will type/operate the computer for the group. That person should connect a device (laptop, table) to the HDMI display and 3. The driver will open the [[6502 Emulator]] at [http://6502.cdot.systems] (and, ideally, this lab page as well as this Lab page. It's a good idea to ensure that the Speed slider on the emulator is at its lowest setting (left) and that the Text Screen is turned off (unchecked).
{{Admon/tip|Sharing Results|Decide how group results will be shared between the members of the group. (Suggestion: consider using a git repository).}}
=== Bitmap Code ===
43. Paste this code into the emulator:
lda #$00 ; set a pointer at $40 to point to $0200
sta $41
lda #$07 ; colournumber
ldy #$00 ; set index to 0
loop: sta ($40),y ; set pixelat the address (pointer)+Y
iny ; increment index
inc $41 ; increment the page
ldx $41 ; get the current pagenumber
cpx #$06 ; compare with 6
bne loop ; continue until done all pages
54. 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. 6. Add this instruction after the <code>loopTry some experiments:</code> label and before the <code>sta ($40)use different colours,y</code> instruction: tya 7. What visual effect does this cause, and how many colours are on the screen? Why? 8or draw only every second dot. Add this instruction after the <code>tya</code>: lsr 9. What visual effect does this cause, and how many colours are on the screen? Why?
10=== Writing Code ===5. Repeat Write code to draw a green line across the top of the above tests with two, three, four, bitmap screen and five <code>lsr</code> instructions in a row. Describe and explain blue line across the effect in each casebottom.
116. Repeat Extend the tests using <previous code>asl</code> instructions instead to draw a yellow line down the left side of <code>lsr</code> instructions. Describe the screen and explain a purple line down the effect in each caseright side.
12. Remove the <code>tya</code> and all <code>asl</code> and <code>lsr</code> instructions.=== Performance ===
137. The original code includes one <code>iny<In the [[#Resources|Resources]] section, the opcode/code> instruction. Test with one to five consecutive <code>iny</code> instructions. Describe and explain references will tell you the effect in number of machine cycles that each caseinstruction will take. '''Note:''' ensure that the Speed slider If your system is on its lowest setting running at 1 MHz (lefta typical speed for a 6502 processor), each machine cycle will take 1 microsecond (uS) for these experiments.What is the total time that your code (from step 6) will take to execute?
=== Writing Code, Part 1 Optional (Recommended): Experiments ===14. Write code to draw a green line across the top of the bitmap screen and a blue line across the bottom.
=== Writing CodeGo back to the bitmap code above, and try these experiments:# 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>lsa</code># What visual effect does this cause, Part 2 ===and how many colours are on the screen? Why?15. Extend # Repeat the previous above tests with two, three, four, and five <code>lsr</code to draw > instructions in a yellow line down row. Describe and explain the effect in each case.# Repeat the left side tests using <code>asl</code> instructions instead of <code>lsr</code> instructions. Describe and explain the screen 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 a purple line down explain the effect in each case. '''Note:''' ensure that the right sideSpeed 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 Writing Code'' portion portions of the lab, describing what happened in each case including the code, a description of how the code works, and the reasons for itresults produced.# The results from Your answers to the two ''Writing CodePerformance'' portions of the labquestion, including the code, a description of how you reached your answer.# Optional (Recommended): the code worksresults of the Experiments section (above), and the results producedyour explaination for each observed result.# Your experiences with this lab -- your impressions of the Assembly Language, what you learned, and your reflections of on the process.
Remember to follow the [[Blog Guidelines]] as you write.