Lab - 2 6502 Assembly Language Lab

 We are required to alter a piece of code in 6502 Assembly language lab that was provided to us in order to achieve the following results:

1) Change the code to fill the display with light blue instead of yellow: Changing LDA #$07 to LDA #$0E, which is a binary code that turns the color of yellow into light blue, is all that is necessary to accomplish this. As we are sending the instruction for the color to change to light blue, we are aware that LDA signifies that something is going to be loaded in the accumulator.

2) Change the code to fill the display with a different color on each page: Four loops are necessary for this since they will vary the color of each page. As demonstrated in class using basic code, such as loading a byte with some color in y and then storing it in byte, it is incremented and made to loop until all 256 bytes have been used, at which point it becomes one loop. 

The basic code looks like this: 

1) Code to fill the display with light blue instead of yellow:

        lda #$00	; set a pointer 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 #$0E	; 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
	ldx $41		; get the current page number
	cpx #$06	; compare with 6
	bne loop	; continue until done all pages

The result of first code:



2) Code to fill the display with a different color on each page:
lda #$00    ; set a pointer at $40 to point to $0200
        sta $40
        lda #$02

        sta $41

        lda #$07    ; colour number

        sta $10 ; store colour number to memory location $10

        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

        inc $10 ; increment the color number

        lda $10 ; colour number

        ldx $41 ; get the current page number

        cpx #$06 ; compare with 6

        bne loop ; continue until done all pages
The result of second code:



This is a straightforward process that involves repeating the action four times and printing in a different color each time. Adding an ASL command just beneath the first bne loop is all that is required to alter this code using the original base code. The value will be increased or shifted to the left and the color will be changed as in certain default values when it is finished. Following the completion of the first bne loop, when the first page with some color is printed, we give the instruction to change pages since we may either print the bitmap in its whole or in 4 pages.


#Calculating the Performance:



Comments

Popular posts from this blog

Lab 5 - Algorithm Selection Lab

SPO600 - Project Stage 2

Auto Vectorization