Hi everyone, new guy here. Sort of a long time lurker though because I've been sittin' on my curiosity concerning NES development for awhile now, and so far I've been able to answer most of my questions using the search function, but now I'm stumped. I was following the nerdy nights tutorials pretty well, but then remembered that it's a bad idea to jump into game/graphical programming when you're new to the language. So I grabbed a Commodore 64 emulator and a .pdf of "Machine Language for the Commodore 64 and other Commodore Computers" by Jim Butterfield, so I could start with Hello World and the usual introductory stuff.
So here's where I'm stuck. There's an exercise in the book that has you get a character from the input stream and display it on the screen if it's a numeric character or a letter, all other characters should be ignored. I do this by calling a subroutine stored in ROM that gets a character from the keyboard and stores it in the accumulator. The idea is that if the value in the accumulator is in the range of $30-$39 (ascii 0-9) or in the range of $41-$5A (ascii A-Z), then output it to the screen, otherwise loop back to the top and get another character. My program excludes $0-29 and $5B-$FF well enough, but I can seem to exclude $3A-$40 (; , < = > ? @). This is my code, any ideas? (The code uses actual memory addresses for the branch instructions because the book hasn't covered labels yet)
So here's where I'm stuck. There's an exercise in the book that has you get a character from the input stream and display it on the screen if it's a numeric character or a letter, all other characters should be ignored. I do this by calling a subroutine stored in ROM that gets a character from the keyboard and stores it in the accumulator. The idea is that if the value in the accumulator is in the range of $30-$39 (ascii 0-9) or in the range of $41-$5A (ascii A-Z), then output it to the screen, otherwise loop back to the top and get another character. My program excludes $0-29 and $5B-$FF well enough, but I can seem to exclude $3A-$40 (; , < = > ? @). This is my code, any ideas? (The code uses actual memory addresses for the branch instructions because the book hasn't covered labels yet)
Code:
processor 6502
org $033C
JSR $FFE1 ; Check run/stop key
BEQ $0359 ; Check if z flag is set, return to BASIC
JSR $FFE4 ; ROM subroutine, Get value from input buffer and LDA
CMP #$30 ; Compare value in A to $30
BCC $033C ; < $30 get another input
CMP #$39 ; Compare value in A to value of $39
BCC $0354 ; < $39, output
CMP #$5B ; Compare value in A to value of $5B
BCS $033C ; If value in A >= $5B, restart
CMP #$41 ; Compare value in A to value of $41
BCS $0354 ; If value in A >= $41, output
JSR $FFD2 ; Value in A is numeric or alpha, output to screen (ROM Subroutine)
AND #$0F ; Convert ASCII to binary for later exercise
RTS ; Return to BASIC
org $033C
JSR $FFE1 ; Check run/stop key
BEQ $0359 ; Check if z flag is set, return to BASIC
JSR $FFE4 ; ROM subroutine, Get value from input buffer and LDA
CMP #$30 ; Compare value in A to $30
BCC $033C ; < $30 get another input
CMP #$39 ; Compare value in A to value of $39
BCC $0354 ; < $39, output
CMP #$5B ; Compare value in A to value of $5B
BCS $033C ; If value in A >= $5B, restart
CMP #$41 ; Compare value in A to value of $41
BCS $0354 ; If value in A >= $41, output
JSR $FFD2 ; Value in A is numeric or alpha, output to screen (ROM Subroutine)
AND #$0F ; Convert ASCII to binary for later exercise
RTS ; Return to BASIC