6502 code

Started by Baggey, August 08, 2021, 18:16:49

Previous topic - Next topic

Baggey

Does anyone have full access to 6502 commands in this form?

Hexdump   Dissassembly
-----------------------
  a9 01     LDA #$01
  c9 02     CMP #$02
  d0 02     BNE $0608
  85 22     STA $22
  00         BRK


Preferably with Tstates on the end. Why have pepole written 6502 in such a hard to understand way? I dont care if it's indexed, indirect immediate etc it's irrelevant.

Kind Regards Baggey
Running a PC that just Aint fast enough!? i7 Quad core 16GB ram 1TB SSD and NVIDIA Quadro K620 . DID Technology stop! Or have we been assimulated!

ZX Spectrum 48k, C64, ORIC Atmos 48K, Enterprise 128K, The SID chip. Im Misunderstood!

Xerra

#1
But they've not written this in such a hard way. This is a disassembly of some 6502 code, rather than the original assembly source code, which likely would have been fully commented and include labels instead of direct addressing JMP/JSR instructions for loops and branches. We're talking 8 bit machines here. No serious assembler is going to fill memory by writing labels or comments into the compiled code else you'd never fit anything into a 5k Vic 20, for example.

The hex codes give you the operand and the input, so you can see that LDA (load accumulator) is a9 in hex and, from memory is 169 in digital. Because the 6502 was all peek to read a byte and poke to write one, then this was pretty much how things were coded, and a lot of people could actually code this way from practice without even using an assembler. That just freaks the hell out of me, with my bad memory, but these were smart kids at the time.

As we're talking 8 bit, the max size number in a byte was 255, which allowed for 8 bits to be toggled on and off. The instruction set only used something like 112 different commands so it was always possible to fit an op-code into one byte but often you would need two bytes to put an actual address for the program counter to move to. So, you can imagine what fun a disassembly could be, if you started it from where a 2 byte address was stored, rather than an op-code :)

I hope I've understood what you're asking here.
M2 Pro Mac mini - 16GB 512 SSD
ACER Nitro 5 15.6" Gaming Laptop - Intel® Core™ i7, RTX 3050, 1 TB SSD
Vic 20 - 3.5k 1mhz 6502

Latest game - https://xerra.itch.io/Gridrunner
Blog: http://xerra.co.uk
Itch.IO: https://xerra.itch.io/

Baggey

Starting to look at the 6502 Instructions. There are apparently only 56 Type of Instructions.  :o  But used in different modes there upto 152!

Im sure there will be UnDocumented ones like the Z80.

Immediate there are     :- 11
Zero Page there are     :- 26
Zero Paged indexed      :- 34
Absolute                :- 23
Indirect pre-indexed    :- 34
Absolute indexed        :- 24
Future Expansion
Possible Undocumented   :- 103


Any corrections please let me know

Baggey
Running a PC that just Aint fast enough!? i7 Quad core 16GB ram 1TB SSD and NVIDIA Quadro K620 . DID Technology stop! Or have we been assimulated!

ZX Spectrum 48k, C64, ORIC Atmos 48K, Enterprise 128K, The SID chip. Im Misunderstood!

Baggey

Has anybody got a PDF link to this book?

An Introduction to 6502 Machine Code by Bernard Babani

Baggey
Running a PC that just Aint fast enough!? i7 Quad core 16GB ram 1TB SSD and NVIDIA Quadro K620 . DID Technology stop! Or have we been assimulated!

ZX Spectrum 48k, C64, ORIC Atmos 48K, Enterprise 128K, The SID chip. Im Misunderstood!

Xerra

Not this one but I do have a couple that might help you in pdf.

C64 Programmers Reference guide.pdf
Mastering the Commodore 64.pdf

Direct message me if you want a copy of either. I'm not attaching them here.
M2 Pro Mac mini - 16GB 512 SSD
ACER Nitro 5 15.6" Gaming Laptop - Intel® Core™ i7, RTX 3050, 1 TB SSD
Vic 20 - 3.5k 1mhz 6502

Latest game - https://xerra.itch.io/Gridrunner
Blog: http://xerra.co.uk
Itch.IO: https://xerra.itch.io/

Baggey

Quote from: Xerra on September 22, 2021, 19:12:54
Not this one but I do have a couple that might help you in pdf.

C64 Programmers Reference guide.pdf
Mastering the Commodore 64.pdf

Direct message me if you want a copy of either. I'm not attaching them here.

Hi,

Thanks ive got them already. Almost tempted to by a copy at £30  :-X

Baggey
Running a PC that just Aint fast enough!? i7 Quad core 16GB ram 1TB SSD and NVIDIA Quadro K620 . DID Technology stop! Or have we been assimulated!

ZX Spectrum 48k, C64, ORIC Atmos 48K, Enterprise 128K, The SID chip. Im Misunderstood!

Xerra

Remember, if you're wanting to work direct with 6502 assembly, and not using a different language to compile with 6502 then CBM prog studio is a brilliant complete dev system for Windows to make developing C64 programs much, much easier with its built-in assembler. Developing on the C64 itself is just making life hard for yourself with no reason these days. Unless you're a true hardcore fan, of course.

My memories of writing six line programs in assembler and waiting minutes for them to compile using the first version of assembler 64, which was written in Basic, still haunt me to this day.

http://www.ajordison.co.uk/download.html
M2 Pro Mac mini - 16GB 512 SSD
ACER Nitro 5 15.6" Gaming Laptop - Intel® Core™ i7, RTX 3050, 1 TB SSD
Vic 20 - 3.5k 1mhz 6502

Latest game - https://xerra.itch.io/Gridrunner
Blog: http://xerra.co.uk
Itch.IO: https://xerra.itch.io/

dawlane

There's information on the 6502 cpu behaviour over on Nes Dev.
https://wiki.nesdev.org/w/index.php?title=CPU

Baggey

So,

Im Fully Deep in 6502 which is now turning into 6510 and starting to move onto the Undocumented codes!

I think im heading down the road's of creating a C64Blitz Emulator.  ???

I keep coming across the VicII chip what a strange beast  :-\

Finally i might start on the SID chip! Now where's MIDI MASTER when you need him  ;)

Another Month i should be able to start throwing code at it.  :D

Baggey
Running a PC that just Aint fast enough!? i7 Quad core 16GB ram 1TB SSD and NVIDIA Quadro K620 . DID Technology stop! Or have we been assimulated!

ZX Spectrum 48k, C64, ORIC Atmos 48K, Enterprise 128K, The SID chip. Im Misunderstood!

Baggey

#9
Quote from: dawlane on September 26, 2021, 10:11:39
There's information on the 6502 cpu behaviour over on Nes Dev.
https://wiki.nesdev.org/w/index.php?title=CPU

Hi, Thanks for that the Formulae for the Addressing modes make a little sense  ;) Don't think im going to be able to some how cross the 6502/6510 with a Z80 thou  :-X


This has now moved to https://www.syntaxbomb.com/8-bit-16-bit-retro-world/6510-op_codes/

Baggey
Running a PC that just Aint fast enough!? i7 Quad core 16GB ram 1TB SSD and NVIDIA Quadro K620 . DID Technology stop! Or have we been assimulated!

ZX Spectrum 48k, C64, ORIC Atmos 48K, Enterprise 128K, The SID chip. Im Misunderstood!

guest8544

This is an old topic, but if anyone's still thinking about coding on C64 they may find this collection of books useful.