Error when running z80pack with -x option

204 views
Skip to first unread message

Paolo Amoroso

unread,
Oct 26, 2021, 3:00:07 PM10/26/21
to
Is the -x filename option of the z80pack CP/M emulation scripts supposed to boot CP/M and run the filename executable program? If so, I have an issue with -x.

Here's a Linux shell session in which I try to run the te screen editor by Miguel Garcia:


paoloamoroso@penguin:~/cpm/sim$ ./cpm2 -x te.com

####### ##### ### ##### ### # #
# # # # # # # # ## ##
# # # # # # # # # # #
# ##### # # ##### ##### # # # #
# # # # # # # # #
# # # # # # # # # #
####### ##### ### ##### ### # #

Release 1.37, Copyright (C) 1987-2021 by Udo Munk

CPU speed is unlimited, CPU executes undocumented instructions
Loader statistics for file te.com:
START : FFFFH
END : 0000H
LOADED: 0002H (2)


Booting...

INT disabled and HALT Op-Code reached at 7704
paoloamoroso@penguin:~/cpm/sim$


Executing the same command with the -f option results in a different error, and sometimes the session hangs at Booting... (omitting the banner and version number for brevity):


paoloamoroso@penguin:~/cpm/sim$ ./cpm2 -f4 -x te.com

[...]

CPU speed is 4 MHz, CPU executes undocumented instructions
Loader statistics for file te.com:
START : FFFFH
END : 0000H
LOADED: 0002H (2)


Booting...

E (1535) system: Op-code trap at e91b fd f5
paoloamoroso@penguin:~/cpm/sim$


The error happens with any CP/M program. The same executable files that cause an error with -x run fine when copied to a disk image and invoked from CCP.

I'm using z80pack on Crostini Linux, the Chrome OS Linux container that currently runs Debian Buster. z80pack otherwise works great with the same setup.

Any insight or suggestions? Am I using the -x option or the argument incorrectly?

Udo Munk

unread,
Oct 26, 2021, 3:11:04 PM10/26/21
to
With option -x the code gets loaded and executed, there is no CP/M and the program will
run off.

Paolo Amoroso

unread,
Oct 26, 2021, 3:53:19 PM10/26/21
to
Thanks Udo, I misunderstood what -x does. I thought cpmsim booted CP/M and passed the -x argument to the operating system for execution, instead it runs the argument in a Z80 system with no operating system environment.

Udo Munk

unread,
Oct 26, 2021, 5:49:38 PM10/26/21
to
Correct, you can use -x to load a monitor or some other boot code, passing arguments to CP/M for execution
after cold boot is not implemented in the OS.

Paolo Amoroso

unread,
Oct 27, 2021, 3:59:18 AM10/27/21
to
I thought the z80pack -x option worked like the CP/M emulator by Joe Allen[1], which can take an executable .com file as a command line argument and run it inside the CP/M environment.


[1] https://github.com/jhallen/cpm

Udo Munk

unread,
Oct 29, 2021, 7:00:18 AM10/29/21
to
If you want that prepare a modified CP/M without cold boot, that jumps to 0100H instead
of into the CCP and load it together with the CP/M program. Also setup DI!HLT @ 0 instead
of the usual JMP, probably no point in warm booting if the program terminates.

BTW, the -x option can load files in Intel Hex or Mostek binary format, not a plain binary.

dott.Piergiorgio

unread,
Nov 5, 2021, 8:57:27 AM11/5/21
to
Aside that is easy to get (or cobble together...) a bin2hex converter, I
think that a binary loader isn't a bad addition, the only complication
being that the switch need two parameters (the binary file and its
address in memory)

Best regards from Italy,
dott. Piergiorgio.

Udo Munk

unread,
Nov 5, 2021, 11:09:24 AM11/5/21
to
dott.Piergiorgio schrieb am Freitag, 5. November 2021 um 13:57:27 UTC+1:
> Aside that is easy to get (or cobble together...) a bin2hex converter, I
> think that a binary loader isn't a bad addition, the only complication
> being that the switch need two parameters (the binary file and its
> address in memory)

That is why z80pack includes a bin2hex in cpmsim/srctools.
And that is why it loads Intel hex and Mostek binary, because theses include
load address(es).

Paolo Amoroso

unread,
Nov 12, 2021, 10:13:24 AM11/12/21
to
After running a program with the -x option, is there any way of inspecting the machine state such as the contents of the registers or memory?

Udo Munk

unread,
Nov 12, 2021, 10:51:37 AM11/12/21
to
paolo....@gmail.com schrieb am Freitag, 12. November 2021 um 16:13:24 UTC+1:
> After running a program with the -x option, is there any way of inspecting the machine state such as the contents of the registers or memory?

Yes, with option -s the complete machine state, registers and 64KB memory of bank 0 are written
into a file core.z80 which can be inspected.
For post mortem analysis z80sim -l is helpful, with the ICE it is possible to look at CPU registers
and memory that were saved into a core.z80 file.

Paolo Amoroso

unread,
Nov 12, 2021, 10:57:17 AM11/12/21
to
Thanks, I see the core.z80 dump generated by the -s option is a binary file. Is it in a standard file format I can inspect with some tool?

Udo Munk

unread,
Nov 12, 2021, 11:21:53 AM11/12/21
to
paolo....@gmail.com schrieb am Freitag, 12. November 2021 um 16:57:17 UTC+1:
> Thanks, I see the core.z80 dump generated by the -s option is a binary file. Is it in a standard file format I can inspect with some tool?

The binary file just contains the CPU registers and memory contents. As I said, it can be loaded with -l
into z80sim and then CPU registers and memory can be inspected. Or you can write your own tools,
the file format is trivial, for order of contents see here:
https://github.com/udo-munk/z80pack/blob/master/z80core/sim0.c
Functions save_core() and load_core().

Paolo Amoroso

unread,
Nov 14, 2021, 6:47:42 AM11/14/21
to
When I start the emulator with the -l option, it exits to the shell after running the code in the loaded core file, so I'm not sure to inspect the registers or memory. However, I wrote some Bash scripts[1] for inspecting z80pack core files.


[1] https://groups.google.com/g/comp.os.cpm/c/T6Aj_XciVnY/m/kJ6CEPvnBwAJ

Udo Munk

unread,
Nov 14, 2021, 7:28:51 AM11/14/21
to
paolo....@gmail.com schrieb am Sonntag, 14. November 2021 um 12:47:42 UTC+1:
> When I start the emulator with the -l option, it exits to the shell after running the code in the loaded core file, so I'm not sure to inspect the registers or memory. However, I wrote some Bash scripts[1] for inspecting z80pack core files.

Which simulation are you using? You need to build and use z80sim included in z80pack,
it will not start running anything, also not with option -l. At the prompt type ? for help.

The other emulation will continue to execute the saved machine state when used
with option -l.

Paolo Amoroso

unread,
Nov 14, 2021, 8:12:56 AM11/14/21
to
Got it, you're of course right. I was running cpmsim instead of z80sim.
Reply all
Reply to author
Forward
0 new messages