6502 Assembly Language Lab (Old Version)

From CDOT Wiki
Revision as of 10:41, 13 January 2020 by Chris Tyler (talk | contribs) (Created page with "Category:SPO600 Labs{{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...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Lab icon.png
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

Lab 1

Setup

  1. Organize a group of 4-6 students around one of the monitor/whiteboard groups in the classroom. Arrange the furniture so that everyone has a comfortable view of the display.
  2. Gather these supplies:
    • HDMI cable
    • Whiteboard markers
  3. Select one person to be the "Driver". That person should connect a device (laptop, table) to the HDMI display and open the 6502 Emulator at [1] as well as this page.
Important.png
Save Your Work
The emulator does not save your work. Remember to periodically save it to a file (copy-and-paste the code).

Bitmap Code

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

	ldy #$00	; set index to 0

loop:	sta ($40),y	; set pixel

	iny		; increment index
	bne loop	; continue until done the page

	inc $41		; increment the page
	ldx $41		; get the page
	cpx #$06	; compare with 6
	bne loop	; continue until done all pages
  1. Test the code. Make sure everyone in your group understands how it works.
  2. Add this instruction after the loop: label and before the sta ($40),y instruction:
 tya
  1. What visual effect does this cause? Why?
  2. Add this instruction after the tya:
 lsr
  1. What visual effect does this cause? Why?
  2. Add a second lsr and observe the effect. Add a third one and test again. What is the effect produced in each case? Why?
  3. Remove the lsr instructions and replace them with one, two, then three asl instructions. What is the effect produced? Why?