Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Load binary file using Assembler

84 views
Skip to first unread message

Rodrigo Vale

unread,
Dec 30, 2021, 11:58:32 PM12/30/21
to
Hi folks,

I am having a lot of fun studying Apple II assembler but got stuck with a simple task: how to load a binary file into memory from an assembler application? Basically I am trying to load game levels (no surprises =).

I was able to find a high level description that it is possible to run BASIC commands from an assembler application by adding the BLOAD FILENAME, A$MEMORY command in a buffer and calling an address memory to execute it, but the same information didn't provide any detail about how to do it. Does anyone know how to do it?

I also found some assembler code teaching how to avoid DOS/PRODOS and write an assembler code to read from scratch, but I think that for my level I would prefer to go with the DOS/PRODOS command approach. (Avoiding DOS/PRODOS at this moment seems to add a lot of complexity on how to store, execute and test my code)

Thank you in advance!

fadden

unread,
Dec 31, 2021, 12:08:41 PM12/31/21
to
On Thursday, December 30, 2021 at 8:58:32 PM UTC-8, rodrigo...@gmail.com wrote:
> I was able to find a high level description that it is possible to run BASIC commands from an assembler application by adding the BLOAD FILENAME, A$MEMORY command in a buffer and calling an address memory to execute it, but the same information didn't provide any detail about how to do it. Does anyone know how to do it?

In DOS you can just output the commands prefixed by Ctrl+M Ctrl+D, assuming you haven't redirected character I/O. For example, the Scott Adams adventure games used this to load and save games from disk. See https://6502disassembly.com/a2-scott-adams/GoldenVoyage.html#SymSaveGame (look for "dos_save_cmd"). (As examples go it's a bit convoluted... just write the characters to COUT like you would any other text.)

For ProDOS you can use a sequence of MLI commands (OPEN / READ / CLOSE). These work whether or not BASIC.System is active. See e.g. _Beneath Apple ProDOS_.

Oliver Schmidt

unread,
Dec 31, 2021, 3:04:58 PM12/31/21
to
Hi,

> For ProDOS you can use a sequence of MLI commands (OPEN / READ / CLOSE).

A pretty straight forward example of doing just that:
https://github.com/oliverschmidt/contiki/blob/master/platform/apple2enh/lib/pfs.S

Regards,
Oliver

Antoine Vignau

unread,
Jan 3, 2022, 4:14:57 PM1/3/22
to
Happy New Year,

DOS is not ProDOS.
DOS contains the BASIC file interpreter (eg. BLOAD) when ProDOS does not. It is included in the Basic Interpreter. When one wants to load files in the ProDOS file system, they use the MLI (Machine Language Interface) which is really simple and powerful to use.

If you want something common between the two environments, follow the advice of Andy.

Cheers,
Antoine

Oliver Schmidt

unread,
Jan 5, 2022, 3:39:47 AM1/5/22
to
Hi,

> [...] the MLI (Machine Language Interface) which is really simple and powerful to use.

Full ACK - maybe except for this:

The MLI doesn't really have a notion of drives. The "usual", "expected"
behavior of allowing to save some file to (the root directory of) some
drive like S6,D1 (like e.g. BASIC.SYSTEM does) requires you to explicitly
get the volume name of the disk in that drive and build an absolute
pathname like

/<volume name>/<file name>

(Yes, I know about the prefix, but it doesn't apply in this scenario.)

If you (again like BASIC.SYSTEM) want to do this without specifying a
drive, then it gets even (somewhat) more complicated, because you need to
first get the last used drive and then do the above.

Many MLI newcomers expect this logic to be built into the PRODOS core
instead of being a BASIC.SYSTEM feature (which therefore needs to be
reimplemented by every MLI user).

Regards,
Oliver
0 new messages