Page 1 of 1

Some questions about 6809 programming (answered)

Posted: Sat Aug 27, 2022 11:40 pm
by cobaka

Hello all:
Got an answer to this posting. Thanks to all.

I am trying to build/run a 6809 simulator & machine code for the 8-bit Motorola 6809.
I got a full working archive from GitHub, a package written by Lennart Benschop.
Something I don't understand - but a 'C' language / make question - not Puppy Linux.
Question: Where is the best place to ask: Votz going on in this C code?
I know there will be a simple answer.

Below: Irrelevant detail to my "Q" above.
The archive included source for assembler (a09), emulator (v09) and a small utility program that converted Motorola "S" files to machine code (it was called 'make.rom')

Lennart's 'make' file built everything from the source (both C and assembly language). I read his code with interest. Running 'make' gave me a monitor program ("Buggy") that ran 6809 machine code under Linux on Intel hardware.
When I loaded and ran the monitor I saw: "Welcome to Buggy, version 1.0". Amazing!
The point: Using 'make' everything in the archive is built from original source, so the source works.
The assembler is coded in C; and the assembler is used to produce the monitor in Motorola "S" file format.

Now I'm trying to use Lennart's code as a model to produce a few simple working programs written in 6809 assembler. I'm close - or at least I think I'm close - but a problem remains when I run some of the C code.

Again: Is there an alternate forum where I can ask about C source or a 'make' file?
Clearly this isn't anything relating to Linux or Puppy Linux.
Thought about this for nearly 2 days now and no solution in sight.

собака


Re: Some questions about 6809 programming (answered)

Posted: Mon Aug 29, 2022 7:41 pm
by puppy_apprentice

Re: Some questions about 6809 programming (answered)

Posted: Mon Aug 29, 2022 11:43 pm
by cobaka

@puppy_apprentice

Thank you for these links.
I spent two days looking for the reason why the order of every second pair of bytes was reversed.

Basically I had a C program read the content of a Motorola "S" format file and converted it to executable (machine-code) binary.
The Motorola "S" format was common in the mid to late 70s. It is (generally) a 2-character representation of an 8-bit byte.
So two bytes might be represented this: 12 5F in the "S" file.
After processing I dumped the machine code using the Linux/bash utility "od".
In terms of the C language I'm a beginner. I read the code (C source) carefully to find where the bytes were switched.
Couldn't see it.

Returned to the command "od". I thought "od" meant "object (file) dump", but no - it means octal dump.
The native "printing" format is octal.
My command-line was #od -x <S-file.hex>
The "-x" switch prints the file in 2-char. hex format.
And I always saw 12 5F >>-->> 5F 12. So the C program must be switching the order of bytes, right? Wrong!!

I submitted the machine code to an on-line dump program and saw the bytes correctly ordered.
The "od" command was the source of my confusion, not the C program.

So - thank you for your suggestion. I know I'll post there in the future.

Thanks and bye.
собака


Re: Some questions about 6809 programming (answered)

Posted: Tue Aug 30, 2022 3:43 am
by williams2

Little Endian vs. Big Endian. https://betterexplained.com/articles/un ... yte-order/

6809 is Little Endian.

Z80 is Big Endian


Re: Some questions about 6809 programming (answered)

Posted: Tue Aug 30, 2022 5:15 am
by puppy_apprentice
williams2 wrote: Tue Aug 30, 2022 3:43 am

Little Endian vs. Big Endian.

A little digression.
If I remember correctly, it's Dune II and Pirates! (i was playing both on my Amiga 500) used LE and BE to record the amount of spice and gold in the game saves. You had to change the appropriate values using both byte orders. In Dune II, the value written in LE corresponded to the amount of free space in the silos and the value written in BE corresponded to the currently stored amount of spice. The value in LE should be greater than that in BE or else you would lose the spice.


Re: Some questions about 6809 programming (answered)

Posted: Tue Aug 30, 2022 7:59 am
by Grey
puppy_apprentice wrote: Tue Aug 30, 2022 5:15 am

If I remember correctly, it's Dune II and Pirates! (i was playing both on my Amiga 500) used LE and BE to record the amount of spice and gold in the game saves.

Well, why did you cheat in such a legendary game?! I'm even a little disappointed :) I played on Sega Mega Drive (m68k CPU + Z80), without a mouse and on a Soviet TV and did not use any cheats :shock: And I won the battle for Arrakis. Now there is a romhack of this game, for an emulator in which Poland (and + one neighboring country) are fighting with Russia for some strange oil, and you are about cheating ;)


Re: Some questions about 6809 programming (answered)

Posted: Tue Aug 30, 2022 11:35 pm
by puppy_apprentice

I was hacking save game files because it was fun and I also learned different number systems by the way. In those days, among my buddies, only I could do it and knew how to use the hex editor so I was respected ;)


Re: Some questions about 6809 programming (answered)

Posted: Wed Aug 31, 2022 7:02 pm
by williams2

Is there an alternate forum where I can ask about C source or a 'make' file?

Maybe https://stackexchange.com/ ?
maybe https://stackexchange.com/users/25742018/clang

I don't think they are as friendly as the Puppy forum.
They might be able to recommend another forum for C