Lab2 - 6502 Assembly Language Lab(Modifying code)
In the course Software Portability and Optimization we have given a code that is for 6502 Assembly language and we need to modify it and get the outcomes as follows:
1) Change the code to fill the display with light blue instead of yellow.
For this it is were simple to do it as we just change LDA #$07 to LDA #$0E which is a binary code for changing the yellow colour to light blue. As we now that lda means that something is going to loaded in accumulator and we are passing the command for colour to change to light blue.
2) Change the code to fill the display with a different colour on each page.
For this one in simple word we need to make four loop as they will make the part or page with different color. As shown in class with the simple code like loading a byte with some color in y and then store it in byte after that it is incremented and make the loop till the 256 bytes are fully completed and it become 1 loop. We are repeating this thing for four time and then we are printing the different color every time. and this is simple way. Now from this code if we need to change it using the original bas code that we just need to add ASL command just below 1st bne loop; is completed this will increment or shift the value to left and change the color as in some default values. we are putting this as the first bne loop is done when they print 1st page with some color and after that we are passing command to change pages after that as we can printing in 4 pages or the whole bitmap.
So, this is the solution for this two questions.
The base code is as follow :
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 #$07 ; 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 pa
Code For 1)
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
Code For 2)
a)
lda #$0E
ldy #$00
loop: sta $0200,y
iny
bne loop
lda #$07
ldy #$00
loop2: sta $0300,y
iny
bne loop2
lda #$05
ldy #$00
loop3: sta $0400,y
iny
bne loop3
lda #$0A
ldy #$00
loop4: sta $0500,y
iny
bne loop4
Code For 2) b) 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 #$07 ; 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) asl inc $41 ; increment the page ldx $41 ; get the current page number cpx #$06 ; compare with 6 bne loop ; continue until done all pages
Comments
Post a Comment