My first ASM and it doesnt do what I expect
I think its my brain not registering something correctly since the code below compiles and runs but does not give the results I was expecting.
The code should plot a vartical column of charaters in column 37 of the text screen with the character being dependent on which row.
I have commented the code with what I believe should be happening, but instead of a vertical column of characters I get a horizontal row.
At least the characters are correct.
Code: Select all
; In theory this should plot a veritcal column of characters A,B or C in column 37 of the text screen; ; if the row number is less than 10 then its an A ; Row number = 10 then B ; Rows greater than 10 then C #define Y_POS 1 #define DISPLAY_ADRESS ($BB80+37+Y_POS*40) .text verticalchars .( ldy #28 ;load y with number of rows to loop loop sty Y_POS ; store current row number in Y_POS tya ; transfer y to a cmp #$01 ;compare a with 1 to not do anything in rows 0 and 1 bcs addblock ;not row 0 or 1 so plot something jmp decrem ; is row 0 or 1 so skip adding something addblock cmp #$0A ;compare a with decimal 10 which is a number between 1 and 26 bcs greqthan ; branch if a is greater or equal to 10 lda #<DISPLAY_ADRESS ; get display address and write char $41 to screen (an A) sta write+1 lda #>DISPLAY_ADRESS sta write+2 lda #$41 jmp write greqthan bne gthan ; do comparison again for greater than only lda #<DISPLAY_ADRESS ; get display address and write char $41 to screen (a B) sta write+1 lda #>DISPLAY_ADRESS sta write+2 lda #$42 jmp write gthan lda #<DISPLAY_ADRESS ; get display address and write char $41 to screen (a C) sta write+1 lda #>DISPLAY_ADRESS sta write+2 lda #$43 write sta $0123,y decrem dey bne loop rts .)
Thanks in advance