week 5: Lab 4 - 6502 Assembly Language String Lab

Hello everyone and welcome to my blog.

We continue to learn and master our skills in assembly language using 6502. During this week's lab we were to practice assembly language string operations. We were to choose two out of the four project options to work on in groups. The options were to create: Adding Calculator, Data Input Form, Hexdump or Screen Colour Selector. In this lab we were to learn and practice such techniques as convert a digit into a character, get the upper digit, get the lower difit, turn decimal mode on and off, indicate the cursor position and more.

After voting we chose to build a Screen Colour Selector and Adding Calculator. This project options seemed to be very interesting and challenging. So the tasks were:

Option 1: Adding Calculator

Create a subroutine which enables the user to enter two numbers of up to two digits. Indicate where the cursor is, and allow the user to use the digit keys (0-9), backspace, and enter keys. Return the user's input value in the accumulator (A) register. Using this subroutine, write a program which add the two numbers (each of which is in the range 0-99) and print the result.

Option 4: Screen Colour Selector

Create a subroutine which displays on the character display a list of colours available on the bitmapped display, one colour per line, with one of the colours names highlighted in reverse video (white on black). The user may use the up/down arrow keys to change the highlighted row. Return the user's selection as a number in the accumulator (A) register when they press Enter.
Using this subroutine, get a colour from the user, then fill the bitmap display with this colour, and allow the user to select a different colour.

We started working on problem by looking into example code kindly provided by our teacher. The link is here, https://wiki.cdot.senecacollege.ca/wiki/6502_Emulator_Example_Code

We found "Type on the Screen" example the most useful for us. This example gave us some understanding regarding how to type on the screen interactively and print messages. So using "Type on the Screen" as a base we started to make our experiments with the resulting code below.

; ROM routines  
define SCINIT $ff81 

; initialize/clear screen 
define CHRIN $ffcf 

; input character from keyboard 
define CHROUT $ffd2 

; output character to screen 
define SCREEN $ffed 

; get screen size 
define PLOT $fff0 
; get/set cursor coordinates 

          jsr SCINIT ldy #$00 

char: 
         lda text,y 
         beq done 
         jsr CHROUT 
         iny 
         bne char 

done: 
         brk 

text: 
         dcb "6","5","0","2",32,"w","a","s",32,"h","e","r","e",".",00

To sum everything up, we managed to print the lines on the screen and to display the color.

This code is slightly cleaned, changed version of a "Type on the Screen" example code. It is not a complete work for our option 4 - Screen Colour Selector. We continue to work on creating the Screen Colour Selector in the next lab period. You may read more about completing the pong game in my Lab 4 continued

Comments