Author Topic: 6801 simulator?  (Read 1079 times)

0 Members and 1 Guest are viewing this topic.

Offline metertech58761Topic starter

  • Frequent Contributor
  • **
  • Posts: 271
  • Country: us
6801 simulator?
« on: July 15, 2025, 05:21:37 pm »
Looking for something that can help me single-step through some 6801-specific code... I found sim68xx but I haven't tried it yet... is it any good?

What I'm looking to accomplish is understanding one section of code in the attached dump - specifically, the 'code integrity check' (labels codeck ... chk_09).

It seems to be using the processor stack as a second index register while checking out the on-chip system to make sure everything is okey-dokey.
This is confusing me as the pointer gets reset multiple times (and even gets lowered into space allocated to variables at one point).

If all the checks pass, it calls one routine to cause the status LED to blink three times then continues with the main app code.
If it errors out at any point, it flashes the LED rapidly and re-runs this code check (the effect being that the status LED will then flash continuously to indicate the unit has failed).
 

Offline edavid

  • Super Contributor
  • ***
  • Posts: 3786
  • Country: us
Re: 6801 simulator?
« Reply #1 on: July 15, 2025, 05:54:52 pm »
You can use the "6800IDE" emulator in 6811 mode to do this.

http://www.hvrsoftware.com/6800emu.htm
 

Offline metertech58761Topic starter

  • Frequent Contributor
  • **
  • Posts: 271
  • Country: us
Re: 6801 simulator?
« Reply #2 on: July 15, 2025, 06:11:00 pm »
Parts of the code gives me the strong impression that it does paranoia-level checks to ensure it is in fact running on a 6801 in single-chip mode before it will execute... so I'm not sure 68(HC)11 mode will work.

Edit: I got it figured out... tests RAM by filling it with $80 to $FF, then with inverted values ($7F to $00), cleans out the space normally allocated to variables ($80 to $D3), then does a checksum of ROM.

... it WAS indeed just a POP thing. I'd never seen code before that reset the stack multiple times (as well as temporarily lowering the pointer). Learn something new every day, I guess.  :-[
« Last Edit: July 15, 2025, 08:41:17 pm by metertech58761 »
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 6400
  • Country: nz
Re: 6801 simulator?
« Reply #3 on: July 16, 2025, 03:39:27 am »
It seems to be using the processor stack as a second index register while checking out the on-chip system to make sure everything is okey-dokey.

Pretty common, I'd think. It's the only way to get a reasonable performance memcpy() or similar e.g.

Code: [Select]
loop:
  pul a
  sta 0,x
  pul a
  sta 1,x
  pul a
  sta 2,x
  pul a
  sta 3,x
  dec b
  bne loop

... can get you close to 10 cycles per byte. Anything involving alternately loading X from src and dst pointers in RAM is going to be far slower.

Of course you need to disable interrupts and have a couple of fixed locations to stash S in while you do it.

6809 made life a LOT easier, in so many ways, including 4 index registers if you did the same trick with S.
 

Offline metertech58761Topic starter

  • Frequent Contributor
  • **
  • Posts: 271
  • Country: us
Re: 6801 simulator?
« Reply #4 on: July 16, 2025, 06:06:56 am »
It seems the 'RAM-less' memory tests are a thing as I can see similar code in some of the other code dumps I have at hand...
at least those other code files are for processors that have the luxury of a minimum of two indexes (i.e., HC11 and as you mention, the 6809).

Just goes to show the level of creativity required when you have a single index register and a mere 128 bytes of RAM!
I've got that section properly commented, now then... time to tackle the remaining unidentified addresses in the definitions.
 

Offline metertech58761Topic starter

  • Frequent Contributor
  • **
  • Posts: 271
  • Country: us
Re: 6801 simulator?
« Reply #5 on: July 24, 2025, 02:32:26 am »
Just gonna leave an updated copy of the source code here - got a few more things figured out.

Edit: POP strikes again - had a major flash of insight and got it 98% figured out... (three variables remain, one likely a vestige of other code)
« Last Edit: August 05, 2025, 04:04:28 am by metertech58761 »
 

Offline metertech58761Topic starter

  • Frequent Contributor
  • **
  • Posts: 271
  • Country: us
Re: 6801 simulator?
« Reply #6 on: August 05, 2025, 04:18:31 am »
And that should be the finished code. That said, there are a couple things I'm just not seeing.
One is where it counts off the header bits (a '1' for attention, then the preamble: 01010101011).
The other is the timer for the test LED. Supposedly, once the unit sees a valid message (likely meaning that it matched the unit's group address), the test LED is to remain lit for 64 minutes.

And just for some context, here are also schematics of the unit this code was read out of.
« Last Edit: August 05, 2025, 04:27:26 am by metertech58761 »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf