Search found 9 matches

by ppelleti
Fri Aug 24, 2018 6:24 pm
Forum: Programming
Topic: JSON65: a JSON parser in 6502 assembly language
Replies: 2
Views: 2820

Re: JSON65: a JSON parser in 6502 assembly language

Did you write a C version first and port it, or just start with raw assembly?
I just wrote it in assembly to begin with.

Since json.s is < 1800 lines, fair to assume that this is 1500-2000 bytes of total code when assembled?
Here are the sizes for all of the files:

json65.o 2240 bytes
json65 ...
by ppelleti
Fri Aug 24, 2018 5:30 pm
Forum: Programming
Topic: JSON65: a JSON parser in 6502 assembly language
Replies: 2
Views: 2820

JSON65: a JSON parser in 6502 assembly language

I just finished writing my first 6502 project in 25 years. It is a JSON parser for the 6502:

https://github.com/ppelleti/json65

The event-driven parser is written entirely in 6502 assembly language, although it provides a C API (meant to be called from cc65 programs). There are some helper ...
by ppelleti
Fri Aug 17, 2018 3:29 am
Forum: Programming
Topic: Assembly programming
Replies: 48
Views: 13601

Re: Assembly programming

It's normal these days to cross-assemble, typically running your editor and assembler on a PC or laptop. But for a more authentic experience you might seek out a native assembler for your platform of choice: Merlin and ORCA/M are popular (were popular) on the Apple II. (You might need to search a ...
by ppelleti
Fri Aug 17, 2018 3:10 am
Forum: Programming
Topic: 8-bit random number generator
Replies: 36
Views: 20314

Re: 8-bit random number generator

Bob Jenkins has a 32-bit random number generator: http://burtleburtle.net/bob/rand/smallprng.html

It's perhaps more complicated than you'd want to run on a 6502, but it's still a lot simpler than Mersenne Twister. It has 16 bytes of state (organized as four 32-bit integers).
by ppelleti
Sun Aug 12, 2018 7:51 am
Forum: General Discussions
Topic: Introduce yourself
Replies: 716
Views: 418634

Re: Introduce yourself

Hi, I'm Patrick! I grew up programming on the Apple IIe in the 1980s.

I initially programmed in BASIC, but quickly started writing snippets of 6502 code in the Mini-Assembler to call from BASIC to make my programs go faster.

Around the 8th grade or so, I decided to write my own assembler. First, I ...
by ppelleti
Fri Aug 10, 2018 11:19 pm
Forum: Programming
Topic: BIT instruction sets Z flag differently than AND instruction
Replies: 8
Views: 3342

Re: BIT instruction sets Z flag differently than AND instruc

I've gone ahead and submitted a pull request to fix sim65.

Klaus' suite is a very good one. Several linked here:
http://visual6502.org/wiki/index.php?title=6502TestPrograms
Thanks! I might look into porting it to sim65, to make sure there aren't any more bugs lurking there. sim65 doesn't seem to ...
by ppelleti
Fri Aug 10, 2018 7:16 pm
Forum: Programming
Topic: BIT instruction sets Z flag differently than AND instruction
Replies: 8
Views: 3342

Re: BIT instruction sets Z flag differently than AND instruc

Chromatix wrote:
Does sim65 pass the test suites?
What test suites should I be running on sim65?
by ppelleti
Fri Aug 10, 2018 7:13 pm
Forum: Programming
Topic: BIT instruction sets Z flag differently than AND instruction
Replies: 8
Views: 3342

Re: BIT instruction sets Z flag differently than AND instruc

It looks like this is a bug in sim65:

static void OPC_6502_2C (void)
/* Opcode $2C: BIT abs */
{
unsigned Addr;
unsigned char Val;
Cycles = 4;
Addr = MemReadByte (Regs.PC+1);
Val = MemReadByte (Addr);
SET_SF (Val & 0x80);
SET_OF (Val & 0x40);
SET_ZF ((Val & Regs.AC) == 0);
Regs.PC += 3 ...
by ppelleti
Fri Aug 10, 2018 6:43 pm
Forum: Programming
Topic: BIT instruction sets Z flag differently than AND instruction
Replies: 8
Views: 3342

BIT instruction sets Z flag differently than AND instruction

I seem to not be understanding how the BIT instruction sets the Z flag. I had thought that the Z flag should be set if the accumulator anded with the value at the given address is zero? But I've written a simple test program that seems to show otherwise:

.export _main
.import _exit

.rodata
foo ...