wwarthen / RomWBW

System Software for Z80/Z180/Z280 Computers
GNU Affero General Public License v3.0
323 stars 93 forks source link

Hi-Tech C compiler generates error "Can't execute $EXEC". Is it a bug or a feature? #364

Closed skullandbones closed 7 months ago

skullandbones commented 9 months ago

I created a simple Hello Word test program HELLO.C:

J>TYPE HELLO.C
main()
{
    printf("Hello, world\n");
}

I built the Hi-Tech image hd1k_hitechc.img from the dev branch with head commit ID d3f5643791a3f50027822b2e3cb84f2a8968e548

I created a custom combo image with C: CP/M 2.2 D: Z80 Assembler E: Hi-Tech C compiler J: HELLO.C file

I am using a RC2014 Z80 based system.

RomWBW HBIOS v3.2.0, 2023-03-18

RCBus [RCZ80_std] Z80 @ 7.372MHz

I can successfully build HELLO.C by being in the E: drive using the command sequence:

C>E:
E>C -V J:HELLO.C
Hi-Tech Z80 C Compiler (CP/M-80) V3.09-17
Copyright (C) 1984-87 HI-TECH SOFTWARE
Updated from https://github.com/agn453/HI-TECH-Z80-C
0:CPP -DCPM -DHI_TECH_C -Dz80 -I J:HELLO.C $CTMP1.$$$
0:P1 $CTMP1.$$$ $CTMP2.$$$ $CTMP3.$$$
0:CGEN $CTMP2.$$$ $CTMP1.$$$
0:ZAS -N -OHELLO.OBJ $CTMP1.$$$
ERA $CTMP1.$$$
ERA $CTMP2.$$$
ERA $CTMP3.$$$
ERA $CTMP5.$$$
0:LINQ -Z -Ptext=0,data,bss -C100H -OHELLO.COM CRTCPM.OBJ HELLO.OBJ LIBC.LIB
ERA HELLO.OBJ
ERA $$EXEC.$$$

However, if I am in the J: drive and refer to the Hi-Tech C compiler in the E: drive I get an error:

E>J:
J>E:C HELLO.C
Hi-Tech Z80 C Compiler (CP/M-80) V3.09-17
Copyright (C) 1984-87 HI-TECH SOFTWARE
Updated from https://github.com/agn453/HI-TECH-Z80-C
Can't execute $EXEC

So I am guessing that the compiler cannot find parts of itself as the current drive is not E: where the binaries are located.

I was hoping not to contaminate the installed Hi-Tech drive with build files.

Is this a bug or a feature ?

Thanks, Dean

wwarthen commented 9 months ago

Depends on your definition of a bug. 😀

It is (as far as I know), the expected behavior of Hi-Tech C. I took a quick look at the manual and saw no command line options for setting location(s) to search for it's components.

Which OS are you using? Other than CP/M 2.2, all of the OSes have some mechanism to "search" for files. Kind of like the MS-DOS PATH variable.

Thanks,

Wayne

On Thu, Sep 28, 2023 at 11:12 AM Dean Jenkins @.***> wrote:

I created a simple Hello Word test program HELLO.C:

J>TYPE HELLO.C main() { printf("Hello, world\n"); }

I built the Hi-Tech image hd1k_hitechc.img from the dev branch with head commit ID d3f5643 https://github.com/wwarthen/RomWBW/commit/d3f5643791a3f50027822b2e3cb84f2a8968e548

I created a custom combo image with C: CP/M 2.2 D: Z80 Assembler E: Hi-Tech C compiler J: HELLO.C file

I am using a RC2014 Z80 based system.

RomWBW HBIOS v3.2.0, 2023-03-18

RCBus [RCZ80_std] Z80 @ 7.372MHz

I can successfully build HELLO.C by being in the E: drive using the command sequence:

C>E: E>C -V J:HELLO.C Hi-Tech Z80 C Compiler (CP/M-80) V3.09-17 Copyright (C) 1984-87 HI-TECH SOFTWARE Updated from https://github.com/agn453/HI-TECH-Z80-C 0:CPP https://github.com/agn453/HI-TECH-Z80-C0:CPP -DCPM -DHI_TECH_C -Dz80 -I J:HELLO.C $CTMP1.$$$ 0:P1 $CTMP1.$$$ $CTMP2.$$$ $CTMP3.$$$ 0:CGEN $CTMP2.$$$ $CTMP1.$$$ 0:ZAS -N -OHELLO.OBJ $CTMP1.$$$ ERA $CTMP1.$$$ ERA $CTMP2.$$$ ERA $CTMP3.$$$ ERA $CTMP5.$$$ 0:LINQ -Z -Ptext=0,data,bss -C100H -OHELLO.COM CRTCPM.OBJ HELLO.OBJ LIBC.LIB ERA HELLO.OBJ ERA $$EXEC.$$$

However, if I am in the J: drive and refer to the Hi-Tech C compiler in the E: drive I get an error:

E>J: J>E:C HELLO.C Hi-Tech Z80 C Compiler (CP/M-80) V3.09-17 Copyright (C) 1984-87 HI-TECH SOFTWARE Updated from https://github.com/agn453/HI-TECH-Z80-C Can't execute $EXEC

So I am guessing that the compiler cannot find parts of itself as the current drive is not E: where the binaries are located.

I was hoping not to contaminate the installed Hi-Tech drive with build files.

Is this a bug or a feature ?

Thanks, Dean

— Reply to this email directly, view it on GitHub https://github.com/wwarthen/RomWBW/issues/364, or unsubscribe https://github.com/notifications/unsubscribe-auth/AATNT2OQOIRSTEFWVSC7YZDX4W4YXANCNFSM6AAAAAA5LLQCSE . You are receiving this because you are subscribed to this thread.Message ID: @.***>

skullandbones commented 9 months ago

@wwarthen I am using CP/M 2.2 but I am new to CP/M so I don't know what the limitations are.

I have watched some You-Tube videos on CP/M. I note that there are some "dir" replacements and shell extensions like XCCP for CP/M 2.2.

In your opinion, which OS would give the best "search path" setting experience ?

Also, are "batch files" supported on any OS ? I mean, can I have a file that executes a list of CP/M commands ?

Thanks, Dean

wwarthen commented 9 months ago

I have watched some You-Tube videos on CP/M. I note that there are some "dir" replacements and shell extensions like XCCP for CP/M 2.2.

A CCP (command processor) replacement probably won't help you. A CCP can only "search" for the actual application specified on the command line. You need an an OS that implements searching for all files the OS attempts to open.

In your opinion, which OS would give the best "search path" setting experience ?

I suggest you use ZSDOS. As I pointed out above, you need the file searching to be at the OS level because you need every opened file to be searched, not just the command-line executable. ZSDOS implements a DOS search path that should do what you want and ZSDOS is a very popular and reliable CP/M 2.2 replacement. WARNING: You will need to carefully read the ZSDOS documentation.

Also, are "batch files" supported on any OS ? I mean, can I have a file that executes a list of CP/M commands ?

Yes. All OSes (even CP/M 2.2) have a mechanism to do this. In general, the SUBMIT command is what you want to look into.

Thanks,

Wayne

wwarthen commented 9 months ago

Hi @skullandbones,

OK to close this issue?

Thanks,

Wayne

skullandbones commented 9 months ago

@wwarthen I am struggling to find any examples of writing batch files for ZSDOS and I have not yet found out how to set a PATH for searching across drives. Do you have any hints ?

Is there a way to echo text strings from inside a batch file ?

So can we leave the issue open for a little while ?

Thanks,

Dean

wwarthen commented 9 months ago

@wwarthen I am struggling to find any examples of writing batch files for ZSDOS and I have not yet found out how to set a PATH for searching across drives. Do you have any hints ?

Yeah, ZSDOS does not have it's own batch file processor. You would use the CP/M 2.2 SUBMIT command which is included on the ZSDOS images. The SUBMIT command is documented in the "CP/M Manual" in the Doc directory.

Setting of the ZSDOS PATH is documented in the "ZSDOS Manual" in the Doc directory. It is a bit confusing because the command you use (ZPATH) has the ability to set a ZSDOS PATH and/or a ZCPR3 PATH. Here is an example of using ZPATH to set a ZSDOS PATH:

A>zpath /d=A0,B0,C0

ZPATH  v1.1   4 Jul 93 (ZSDOS 1.1)

- ZCPR3 Path...
        - None -

- ZSDOS Path...
   Symbolic : A0: --> B0: --> C0:
   DU       : A0: --> B0: --> C0:
   Named    : Noname: --> Noname: --> Noname:

This sets the ZSDOS PATH search order to first look at A0:, then B0:, then C0:. Note that the ZSDOS PATH is limited to 3 arguments unless you do some fancy stuff.

Is there a way to echo text strings from inside a batch file ?

Not when using the CP/M 2.2 SUBMIT facility. If you run out of steam with standard ZSDOS, I suggest you look into ZCPR3. The third slice of the combo image has NZ-COM which is an implementation of ZCPR3.4. ZCPR3 is a massive enhancement of CP/M 2.2. It has a batch processing facility called ZEX. You will really need to thoroughly review the documentation in the "NZCOM Users Manual". You do not need to do the "setup" work described in the manual, because that has already been done in the RomWBW slice.

So can we leave the issue open for a little while ?

Happy to leave this open as long as you still have questions.

Thanks,

Wayne

rprouse commented 9 months ago

Sorry I missed this. I wrote a blog post on how I got it working, https://8bitlabs.ca/Posts/2023/06/15/hi-tech-c-compiler

wwarthen commented 9 months ago

Hi @rprouse,

Sorry I missed this. I wrote a blog post on how I got it working, https://8bitlabs.ca/Posts/2023/06/15/hi-tech-c-compiler

This is very useful. Thanks for the link.

-Wayne

wwarthen commented 9 months ago

Hi @skullandbones,

There hasn't been any activity on this issue for a while. OK to close?

Thanks,

Wayne

skullandbones commented 8 months ago

@rprouse I managed to get the "Hello Word" C example to build.

My settings were: I: drive was assigned to the Hi-Tech slice SD0:8 J: drive was my C development slice SD0:21

I created J:HELLO.C containing the hello world printf.

I created J:ENVIRON which contained: HITECH=0:I: TMP=J:

Then built HELLO.C J>I:C -V HELLO.C

I found your webpage https://8bitlabs.ca/Posts/2023/06/15/hi-tech-c-compiler helpful but also a bit confusing.

My suggestion for making the instructions a bit clearer is to say that the drive where the C files are located needs to have the ENVIRON file. Meaning the J: drive in my example and not the A: drive as per your webpage. Perhaps your HELLO.C is located in A: and you ran I:C -V HELLO.C from the A: drive but that was also unclear to me.

Anyway, thanks for the link.

Dean

rprouse commented 8 months ago

@skullandbones , I just checked the HI-Tech C docs and they do say "will attempt to open a file in the current user number on the current drive called ENVIRON." which supports your findings. It does however work for me with the ENVIRON file on the A drive. My Hi-Tech drive is G: and the drive with my source code is L:.

When I figured it out however, I did so from this GitHub issue, https://github.com/agn453/HI-TECH-Z80-C/issues/37 which states, You can also create a file called ENVIRON. on the source-file drive to override the default, or have a system-wide one in 0:A:ENVIRON.

I am booting to ZDOS v1.1, maybe CP/M 2.2 is different? Or are you booting to a different drive?

skullandbones commented 8 months ago

@wwarthen my understanding is that the A: drive is a RAM drive, right ? So writing the ENVIRON file to A: is not going to be permanent.

I am using CP/M 2.2 by booting with the 'C' bootloader option. So booting to B:

I have a "profile file" C:PROFSDC.SUB which I run to assign I: to my Hi-Tech slice and assigns J: to my C source code slice.

The ENVIRON file is in the J: drive with my C source code.

Building seems to work OK.

I think it would be helpful to put some quick start notes for building C source code with the Hi-Tech compiler.

It is all too easy to get discouraged when information is not immediately to hand. For example, I did not realise that you had put the Hi-Tech documents into your distribution so I was googling for stuff instead.

Thanks,

Dean

wwarthen commented 8 months ago

Hi @skullandbones,

Booting to ROM is intended to be a very simple quick-start mechanism for users to play with CP/M. It allows users to play with CP/M even if they don't have a working disk system. It is sub-optimal an many ways and not intended for "real" use of a CP/M system.

Any significant use of RomWBW should be done by booting directly to a slice. When booting to a slice, the A: drive will always be a useful filesystem that can contain any desired configuration files including PROFILE.SUB as well as stuff like the Hi-Tech ENVIRON file. Since PROFILE.SUB will run automatically, you can setup a slice to boot directly into a fully configured environment.

This approach was very much by design. The idea is that you can setup as many boot slices as you want and each one can be customized for a specific workflow.

I don't remember how clearly I have articulated this in the User Guide, but I will review it and enhance as appropriate.

Thanks,

Wayne

wwarthen commented 8 months ago

I have updated the User Guide to try and address use of ROM OS boot vs. physical disk OS boot.

Thanks,

Wayne

skullandbones commented 8 months ago

@wwarthen when I first purchased the SC126 kit, the ROM was

RomWBW HBIOS v3.0, 2020-03-27

and the bootloader had the options

SC126 Boot Loader

ROM: (M)onitor (C)P/M (Z)-System (F)orth (B)ASIC (T)-BASIC (P)LAY (U)SER ROM  
Disk: (0)MD1 (1)MD0 (2)IDE0 (3)IDE1 (4)SD0 

Boot Selection?

this was a bit clearer to understand without having to read the User Guide in advance. Option '4' boots from the SD card. Then I think the slice number is asked for.

In

RomWBW HBIOS v3.4.0-dev.14, 2023-10-25

the bootloader says

Small Computer SC126 [SCZ180_sc126] Boot Loader

Boot [H=Help]: 

if you are a novice user, without access to the User Guide then there is a hint to press 'H'

Boot [H=Help]: h

  L           - List ROM Applications
  D           - Device Inventory
  R           - Reboot System
  I <u> [<c>] - Set Console Interface/Baud code
  V [<n>]     - View/Set HBIOS Diagnostic Verbosity
  <u>[.<s>]   - Boot Disk Unit/Slice

Boot [H=Help]: 

A novice user like me then presses 'L'


ROM Applications:

  M: Monitor
  Z: Z-System
  C: CP/M 2.2
  F: Forth
  B: BASIC
  T: Tasty BASIC
  P: Play a Game
  N: Network Boot
  X: XModem Flash Updater
  U: User App

Boot [H=Help]: 

Rightly or wrongly, I thought 'C' is the option I should use for booting CP/M 2.2.

I think that there are 3 things that would assist a novice user.

  1. Have a hint in the bootloader menu help option to display a URL to the User Guide and to suggest reading it first.
  2. Add a technical glossary into the User Guide to map old terms against modern terms eg. disk can mean SD or CF card
  3. Reorder the bootloader help menu options into the most used order.

I would think that a novice user would start with the first item in the bootloader help menu and work down the list until something works eg. CP/M 2.2 starts.

I suggest that a better order would be:

  <u>[.<s>]   - Boot Disk Unit/Slice
  D           - Device Inventory
  L           - List ROM Applications
  R           - Reboot System
  I <u> [<c>] - Set Console Interface/Baud code
  V [<n>]     - View/Set HBIOS Diagnostic Verbosity

That is why I missed <u>[.<s>] because I thought it to be unimportant as it was bottom of the list.

The other problem is the term "Boot Disk" because it is really a bootable block device such as a SD card or CF card, real hard disk, real floppy drive etc. Perhaps rename to Boot Media or Boot Device ?

Now I have read 3.2 Starting Operating Systems from Disk in the 3.4.0-dev-.16 User Guide. I now know that I should use option '4' just like in the 3.0.0 ROM bootloader menu to boot CP/M 2.2. However, this section in the User Guide appears to lack any discussion on booting from SD or CF cards. I realise the term 'Disk" is including SD and CF cards but I think things could be clearer. Perhaps have an example for booting from an SD card ?

I hope that helps to explain how I missed using the boot option <u>[.<s>].

Thanks,

Dean

wwarthen commented 8 months ago

Thanks @skullandbones.

Some good suggestions here. I am out of town for a few days, but will try to make some of these changes when I get back.

The one thing I will probably not do is the glossary only because it would take more time than I have available right now. Feel free to contribute something if you are inclined.

Thanks,

Wayne

wwarthen commented 7 months ago

Closing this issue due to lack of activity. I don't think there is any specific action required at this time.