Ooops
October 24, 2021, 11:35:44

Author Topic: 6502 code  (Read 1100 times)

Online Baggey

  • Full Member
  • ***
  • Posts: 189
6502 code
« on: August 08, 2021, 18:16:49 »
Does anyone have full access to 6502 commands in this form?

Code: [Select]
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
Currently Running a PC that just Aint fast enough!?
ZX Spectrum 48k, NEXT, C64, ORIC Atmos 48K, Enterprise 128K, The SID chip.

Jesus was only famous because of his DAD.

Online Xerra

  • Hero Member
  • *****
  • Posts: 1347
  • Wait, what? This isn't Porn Hub?
    • Retro Evolved
Re: 6502 code
« Reply #1 on: August 12, 2021, 16:45:17 »
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.
« Last Edit: August 12, 2021, 16:47:05 by Xerra »

Online Baggey

  • Full Member
  • ***
  • Posts: 189
Re: 6502 code
« Reply #2 on: September 17, 2021, 19:59:42 »
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.
 
Code: [Select]
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
Currently Running a PC that just Aint fast enough!?
ZX Spectrum 48k, NEXT, C64, ORIC Atmos 48K, Enterprise 128K, The SID chip.

Jesus was only famous because of his DAD.

Online Baggey

  • Full Member
  • ***
  • Posts: 189
Re: 6502 code
« Reply #3 on: September 22, 2021, 17:52:10 »
Has anybody got a PDF link to this book?

An Introduction to 6502 Machine Code by Bernard Babani

Baggey
Currently Running a PC that just Aint fast enough!?
ZX Spectrum 48k, NEXT, C64, ORIC Atmos 48K, Enterprise 128K, The SID chip.

Jesus was only famous because of his DAD.

Online Xerra

  • Hero Member
  • *****
  • Posts: 1347
  • Wait, what? This isn't Porn Hub?
    • Retro Evolved
Re: 6502 code
« Reply #4 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.

Online Baggey

  • Full Member
  • ***
  • Posts: 189
Re: 6502 code
« Reply #5 on: September 23, 2021, 18:45:36 »
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
Currently Running a PC that just Aint fast enough!?
ZX Spectrum 48k, NEXT, C64, ORIC Atmos 48K, Enterprise 128K, The SID chip.

Jesus was only famous because of his DAD.

Online Xerra

  • Hero Member
  • *****
  • Posts: 1347
  • Wait, what? This isn't Porn Hub?
    • Retro Evolved
Re: 6502 code
« Reply #6 on: September 24, 2021, 21:38:11 »
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

Online dawlane

  • Full Member
  • ***
  • Posts: 198
Re: 6502 code
« Reply #7 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

Online Baggey

  • Full Member
  • ***
  • Posts: 189
Re: 6502 code
« Reply #8 on: October 10, 2021, 17:32:10 »
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
Currently Running a PC that just Aint fast enough!?
ZX Spectrum 48k, NEXT, C64, ORIC Atmos 48K, Enterprise 128K, The SID chip.

Jesus was only famous because of his DAD.

Online Baggey

  • Full Member
  • ***
  • Posts: 189
Re: 6502 code
« Reply #9 on: October 10, 2021, 17:43:50 »
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
« Last Edit: Today at 08:51:12 by Baggey »
Currently Running a PC that just Aint fast enough!?
ZX Spectrum 48k, NEXT, C64, ORIC Atmos 48K, Enterprise 128K, The SID chip.

Jesus was only famous because of his DAD.

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal