Tuan Thanh Tan

Posted on

# Assembly Language Lab SPO600 - Lab 02

Hello everyone, I'm Tuan Thanh Tan aka Dustin. If you happen to read this blog. Thank you!

This is the lab 2 for my SPO course. This lab is about writing code in 6502 assembly language. One of the most difficult and cumbersome lab I've ever had.

``````lda #\$00    ; set a pointer at \$40 to point to \$0200
sta \$40
lda #\$02
sta \$41

lda #\$05    ; colour number

ldy #\$00    ; set index to 0

top: sta (\$40), y;

top:        sta (\$40), y         ; set pixel

iny                      ; increment index

cpy #\$20            ; compare y value with 20. If the index is 20, end the loop

bne top

lda #\$05

sta \$41               ; point the last page

lda #\$06             ; set color blue
ldy #\$e0             ; set the index to indicate the last linex

bottom:  sta (\$40), y      ; set pixel
iny                      ; increment index
bne bottom         ; continue until done the line
right_left: lda #\$07         ; set index to 0

sta (\$40), y          ; set the color yellow

tax                       ; transfer a to x
tya                       ; transfer y to a
adc #\$1f              ; add with #\$1f so it indicates the last line

tay                       ; transfer a to y
txa                       ; transfer x to a

lda #\$04              ; set the color purple

sta (\$40), y          ; set pixel
iny                       ; increment index
bne right_left       ; continue until done the page   : 2

inc \$41                ; increment the page
ldx \$41                ; get the page
cpx #\$06             ; compare with 6 (the last page is 05 so if it is 06, it means all pages are already painted)

bne right_left       ; continue until done all page

``````

I found this language has a great deal of complexity and difficulties. But as time goes on, I'll get used to it.

For the performance, I used this website to get the number of circles of each instruction and sum it up. The result that I have is 106.