PDA

View Full Version : Trying Hi Tech C with different results...



alank2
February 13th, 2018, 05:47 PM
I have a program that compiles to around 19K using the z88dk cross compiler. I'd like to find a native in CP/M compiler though instead that can produce 8080 (and possibly Z80) code though. Tonight I was testing Hi Tech C, but it wouldn't work under the 2.2 CP/M from the N8VEM (or is it zcpr or something?), but it would work on the cpmplus.zip for SIMH that I downloaded.

Could this be because cpmplus has more TPA available?

On the n8vem image, I was getting odd things where the c.exe became corrupted, and then it would hang when I was compiling main.c.

Is there a tool or utility that shows the maximum TPA in a CP/M system? Is there a built in command to do it?

Alphasite
February 15th, 2018, 05:35 PM
I didn't get a chance to download tpa.asm before the forum went down and the messages got lost. Can it be reposted?

alank2
February 15th, 2018, 06:01 PM
; Program to print TPA space available, in K-bytes

org 100h
lxi d,0
lhld 6
mov a,h
rrc
rrc
ani 03fh
loop1:
cpi 10
jc lt10
sui 10
mov d,a
mov a,e
adi 10h
daa
mov e,a
mov a,d
jmp loop1
lt10: add e
daa
push h
call hexout
pop h
mov a,h
ani 03h
mov h,a
mvi a,0
jz zero
loop2:
adi 25h
daa
dcr h
jnz loop2
push psw
mvi e,'.'
mvi c,2
call 5
pop psw
call hexout
zero:
lxi d,kmsg
mvi c,9
call 5
jmp 0

hexout:
push psw
rrc
rrc
rrc
rrc
call hexdig
pop psw
hexdig: ani 0fh
adi 90h
daa
aci 40h
daa
mov e,a
mvi c,2
jmp 5

kmsg: db 'K TPA',13,10,'$'

end

Chuck(G)
February 15th, 2018, 07:21 PM
Whew, that's a lot of code!

How about this (It's been more than 30 years since I've had to code 8080, but here goes):


org 100H

Entry:
lda 7
dcr a
rar
rar
ani 3fh
mvi l,'0'
cvd2: sui 10
jc cvd4
inr l
jmp cvd2

cvd4: adi 10+'0'
mov h,a
shld kdec
lxi d,kmsg
mvi c,9
jmp 5

kmsg: db 13,10
kdec: db '00K available',13,10,'$'

end entry

Note that using XSUB will reduce the TPA size.

mloewen
February 16th, 2018, 02:18 PM
(I posted this before the crash).

Back in the day, I used BDS C on a TRS-80 Model 4 running Montezuma Micro CP/M 2.2. The compiler and documentation are freely available, here:

https://www.bdsoft.com/resources/bdsc.html

alank2
February 16th, 2018, 03:46 PM
I tried your tpa version Chuck. Here is both. Yours is TPA2.COM.



A>tpa
A:TPA COM
61K TPA

A>tpa2
A:TPA2 COM

60K available

A>


Any idea why it is showing the A:TPA COM and A:TPA2 COM ??? I don't remember it doing that when I ran TPA.COM before???

Also, they aren't the same!

Chuck - yours is considerably shorter!

durgadas311
February 16th, 2018, 04:39 PM
I tried your tpa version Chuck. Here is both. Yours is TPA2.COM.



A>tpa
A:TPA COM
61K TPA

A>tpa2
A:TPA2 COM

60K available

A>


Any idea why it is showing the A:TPA COM and A:TPA2 COM ??? I don't remember it doing that when I ran TPA.COM before???

Also, they aren't the same!

Chuck - yours is considerably shorter!

My program reports the memory boundary at the top of TPA, to 1/4 K. Chuck's reports the amount of memory between 0100 and top of TPA, truncated to K bytes. Neither really tells you how much memory a given application will be able to use, since the size of the application, and it's data requirements, factors into that.

Chuck(G)
February 16th, 2018, 04:49 PM
Exactly. I don't count the lower 100h as being available memory, since you can't load a program into it. I also truncate, but could just as easily have rounded up by adding 3 to a before the two right shifts.

As I mentioned, there are things that can affect the amount in the TPA. Try running the program with XSUB active, for example.

I thought mine was kind of interesting because it uses no stack space at all.

alank2
February 16th, 2018, 05:24 PM
Any idea why it shows a directory like thing in the CP/M 3.1 OS's like I showed above?

Chuck(G)
February 16th, 2018, 05:28 PM
CP/M 3 BIOS/XBIOS is tricky stuff. I suspect a bug. Have you tried on real z80 hardware?

Alphasite
February 16th, 2018, 06:04 PM
I didn't get a chance to read through before the post was lost. I was wondering if it was doing something other than looking at where BDOS started.

On my CP/M Plus (which reports the TPA as 61K on boot) durgadas311's reports the TPA as 53K and Chuck's reports the TPA as 60K.

alank2
February 16th, 2018, 06:05 PM
This is from the cpmplus.zip archive with altairz80... It happens with cpm3bk and cpm3nb, but not cpm80.

Chuck(G)
February 16th, 2018, 06:37 PM
Well, I've got a CP/M Plus system here. Tell me where to get the files needed to reproduce the problem and I'll give it a try.

alank2
February 16th, 2018, 06:42 PM
Hi Chuck,

Here is the file - http://www.classiccmp.org/cpmarchives/cpm/mirrors/www.schorn.ch/cpm/zip/cpmplus.zip

Thanks!

durgadas311
February 16th, 2018, 06:43 PM
Any idea why it shows a directory like thing in the CP/M 3.1 OS's like I showed above?

There is an option on CP/M 3 to echo a command before executing it. I suspect that option is turned on.

durgadas311
February 16th, 2018, 06:47 PM
I didn't get a chance to read through before the post was lost. I was wondering if it was doing something other than looking at where BDOS started.

On my CP/M Plus (which reports the TPA as 61K on boot) durgadas311's reports the TPA as 53K and Chuck's reports the TPA as 60K.

I actually threw that program together for running on CP/M Plus, so I could notice the difference between running my CP/NET RSX and not. On my systems, it reported the same value as the CP/M Plus boot did (when CP/NET was not loaded). It uses the BDOS entry JMP at location 0005, the only thing I can think of is that some RSX was loaded - but 8K is a lot to lose.

Chuck(G)
February 16th, 2018, 06:58 PM
Hi Chuck,

Here is the file - http://www.classiccmp.org/cpmarchives/cpm/mirrors/www.schorn.ch/cpm/zip/cpmplus.zip

Thanks!

Okay, I'll try to get to it over the long weekend. It's supposed to be rainy, so no work outside.

Alphasite
February 16th, 2018, 07:06 PM
I actually threw that program together for running on CP/M Plus, so I could notice the difference between running my CP/NET RSX and not. On my systems, it reported the same value as the CP/M Plus boot did (when CP/NET was not loaded). It uses the BDOS entry JMP at location 0005, the only thing I can think of is that some RSX was loaded - but 8K is a lot to lose.

I tried running it again and it's reporting 61K now. I didn't have any RSX loaded so I don't know what happened last time.

Plasmo
February 17th, 2018, 03:10 AM
Got CP/M2.2 running in my Z280 board. Typed in the TPA program, assembled, load & run. It reports "56K available". My CP/M code started from 0xDC00, so TPA size is 56K.

I'm really new to CP/M2.2 and 8080 assembly code, could you tell me how you figure out the TPA size?

alank2
February 17th, 2018, 06:41 AM
I'm really new to CP/M2.2 and 8080 assembly code, could you tell me how you figure out the TPA size?

I'd like to know too.

Also, is the command echo a feature that is compiled in, or is it configurable. If configurable, what command would enable/disable it?

durgadas311
February 17th, 2018, 07:52 AM
I'd like to know too.

Also, is the command echo a feature that is compiled in, or is it configurable. If configurable, what command would enable/disable it?

The CP/M BDOS is defined as the top of the TPA. All memory above that is reserved for the system. CP/M defines that a JMP at location 0005 will go to the BDOS entry for function calls. CP/M has established that the BDOS entry must be the first (reserved) part of the BDOS. So, examining the JMP address at location 0005 will tell you the start of the BDOS - and thus, the top of the TPA.

In practice, the first 6 bytes of the BDOS are reserved for the serial number, but that is not used after booting and normally is totally ignored. So, if you look at the JMP at location 0005 you'll see an address of the form xx06. The "xx" defines the top boundary of the TPA. Programs that use large amounts of memory must look at this JMP address and ensure that they do not overrun the BDOS.

As previously mentioned, there are cases where somethign attaches itself beneath the BDOS, in CP/M 3 these are RSX (Resident System eXtensions). Another example is DDT/SID. These programs modify the JMP at location 0005 and thus affect the TPA - although in a more-temporary manner.

The CP/M 3 command echo is an option that I think can be set by GENCPM, but is also controlled by a utility. I'd have to go look at documents or HELP to tell which. Check your boot disk for a PROFILE.SUB file, it may be getting set in that.

alank2
February 17th, 2018, 08:53 AM
That was it - there was a profile.sub that has this line:
SETDEF * A: [ORDER=(COM,SUB) DISPLAY UK]

I renamed it and that stopped it.

Chuck(G)
February 17th, 2018, 10:01 AM
Hi Chuck,

Here is the file - http://www.classiccmp.org/cpmarchives/cpm/mirrors/www.schorn.ch/cpm/zip/cpmplus.zip

Thanks!

I'm not interested in your copy of CP/M 3--I've already got a system that's running it natively. I'd like to see the program that's giving you trouble on CP/M 3 and try it on my system. No .IMDs, please, just the files.

alank2
February 17th, 2018, 12:02 PM
Hi Chuck,

I just took your tpa.asm and used asm and load on it to turn it into a COM file, nothing more than that. The way it was echoing back the command was figured out so no worries.

Thanks!

Alan

Chuck(G)
February 17th, 2018, 01:16 PM
Before I drift away from this thread, I thought about the bit of converting a one-byte binary number to decimal and this was the best I could come up with:



;
; Assume binary number between 0-99 is in register H
; Output will be 2 ASCII digits in HL, with the high order digit in L.
;
MVI L,0
LXI B,0F601h
L1: DAD B
JC L1
LXI B,3A2Fh
DAD B