I made a chess program in under 1K of 6502 assembly that runs on an unexpended KIM-1

Discussion of anything and everything relating to chess playing software and machines.

Moderator: Ras

User avatar
maksimKorzh
Posts: 775
Joined: Sat Sep 08, 2018 5:37 pm
Location: Ukraine
Full name: Maksim Korzh

Re: I made a chess program in under 1K of 6502 assembly that runs on an unexpended KIM-1

Post by maksimKorzh »

Rebel wrote: Tue Jun 14, 2022 8:47 am Nice to see the good old 6502 code.

One thing

Code: Select all

LDA BOARD,Y      ;      occupied by pieces
CMP #$00         ;
BNE SCR          ;
One nice thing of the 6502 is after a load into memory the Zero Flag and Negative Flag are automatically set, meaning you can skip the CMP #$00 instruction.
Oh yeah, I know that))) I've spoiled HGM's MicroMax concept with my ugly and dirty implementation :mrgreen:
I did put those CMP where the flag has already been set elsewhere as well - it was just easier to make sure I
do compare (because unfortunately still thinking in high level languages).
You know, before I wrote this program I thought it's impossible to write ugly code in 6502 assembly,
well, I was so wrong about that)))

Can you please tell me was there a better way to manage local variables on the stack in a way other then:
TSX
TXA
CLC
ADC SOME_VALUE
TAX
LDA $0100,X

or just incrementing X register a few times if the variable is not that far?
May I should've used indirect addressing and create some shortcuts for the
stack variables in the zero page?

And one more thing - I feel like there's a ton of work to be done to improve the code
look and size, I believe it can be stripped down to 512 bytes (Oscar Toledo did chess in 352 bytes or something in x86!)
It won't make engine play better obviously but just as an exercise... ummm... I don't even know how to ask it probably...
There's no practical sense for doing that but it's kind of tempting, do you know that feeling?
User avatar
maksimKorzh
Posts: 775
Joined: Sat Sep 08, 2018 5:37 pm
Location: Ukraine
Full name: Maksim Korzh

Re: I made a chess program in under 1K of 6502 assembly that runs on an unexpended KIM-1

Post by maksimKorzh »

I made an update on both emulator and chess program,
so from now on it can be played in a TTY mode, here's how:
User avatar
maksimKorzh
Posts: 775
Joined: Sat Sep 08, 2018 5:37 pm
Location: Ukraine
Full name: Maksim Korzh

Re: I made a chess program in under 1K of 6502 assembly that runs on an unexpended KIM-1

Post by maksimKorzh »

Same program, but compiled via cc65 + KIM-1 60k expansion target: