CP/M User
Veteran Member
I was just wondering if anyone here has had a crack at understanding this vast Library routines which attaches itself to Turbo Pascal 3 "COM" files (specifically in the 8bit version of Turbo Pascal)?
Here's what I've come up with - basically before your TP program is executed some things are setup - what they are I can only guess they have something to do with where Data and other bits 'n' blobs go - some of which looks as if engages with CP/M since some CP/M addresses (below 100h) are used - perhaps it has something to do with Parameter passing?
Execution from 0100 (since this is where COM files execute from) takes you to 20E2 and you get these routines
This code above at 364 seems to be very critical for my program cause eliminating it crashed the program. I've disassembled this following routine though I managed to run my program without - that's not to imply all my programs will work without it, I just thought if anyone had any ideas what it might be doing that would be great. I'm not posting the complete think or at least I don't think I am, if anyone wants the routines which it's Jumping & calling to I try and get those (unfortunately there's a 'JP (HL)' statement in there as well and I'm unsure where that ones going - I hate JumPs so much :-x)
Any help or comments would be great. I seem to have highlighted the core which is processed prior to program (well in part - seems amazing there's so much code prior to my program being executed, I prepared another program in Turbo Pascal using Inline M/C - just to get a program running outside of CP/M and in AMSDOS on my CPC, the result was a very limited program which I had running outside of CP/M, though CP/M seems to cling on for dear life to that TP Library. This seems more complicated, once I'm into my program there are calls to the library the first - 666 looks to be it's pointing to a 'FOR' routine which was the first thing I wrote in my Main Routine, followed by Calls to other Procedures which I did.
What I'm trying to do is understand the process so then I can start removing what I don't need and create a small executable program. Don't think I'll be able to make a program which allows you to do this - and I think the easiest way to make the program smaller is to simply move the program to where it sits - 20E2 (or whatever). Different programs will obviously have different routines and it would have to be a process of removing and leaving the ones which are used.
Here's what I've come up with - basically before your TP program is executed some things are setup - what they are I can only guess they have something to do with where Data and other bits 'n' blobs go - some of which looks as if engages with CP/M since some CP/M addresses (below 100h) are used - perhaps it has something to do with Parameter passing?
Execution from 0100 (since this is where COM files execute from) takes you to 20E2 and you get these routines
Code:
20E2: LD SP,0100h
LD HL,93C2h
LD BC,FF00h
CALL 364h
LD HL,222Bh
LD DE,9BA8h
LD BC,9C42h
LD A,01
CALL 04D4h
JP <Start of Main Pascal Program>
Code:
364: LD (00D2h),HL
LD A,B
LD (00DDh),A
LD A,C
OR A
JR Z,037Ah
LD A,C3h
LD (0038h),A
LD HL,1FFBh
LD (0039h),HL
LD HL,03A5h
LD DE,00A0h
LD BC,0018h
LDIR
LD HL,03BDh
LD DE,00B8h
LD BC,000Ch
LDIR
XOR A
LD L,A
LD H,A
LD (00D0h),A
LD (00D4h),HL
LD (00D6h),HL
LD A,7Eh
LD (00D1h),A
LD (00E0h),A
RET
This code above at 364 seems to be very critical for my program cause eliminating it crashed the program. I've disassembled this following routine though I managed to run my program without - that's not to imply all my programs will work without it, I just thought if anyone had any ideas what it might be doing that would be great. I'm not posting the complete think or at least I don't think I am, if anyone wants the routines which it's Jumping & calling to I try and get those (unfortunately there's a 'JP (HL)' statement in there as well and I'm unsure where that ones going - I hate JumPs so much :-x)
Code:
4D4: LD (00D8h),A
PUSH BC
CALL 1EAFh
POP BC
LD HL,(0006h)
OR A
SBC HL,BC
JP C,20A8h
EX DE,HL
POP DE
LD SP,HL
LD BC,FC00h
ADD HL,BC
LD (00C6h),HL
XOR A
LD L,A
LD H,A
LD (00CEh),HL
LD (00DCh),A
LD A,C3h
LD (00D9h),A
LD HL,20DEh
LD (00DAh),HL
EX DE,HL
LD (00CCh),HL
JP (HL)
PUSH HL
LD HL,(00C6h)
OR A
SBC HL,BC
LD (00C6h),HL
LD DE,(00C4h)
OR A
SBC HL,DE
ADD HL,DE
EX DE,HL
POP HL
JP C,1D75h
LDIR
RET
Any help or comments would be great. I seem to have highlighted the core which is processed prior to program (well in part - seems amazing there's so much code prior to my program being executed, I prepared another program in Turbo Pascal using Inline M/C - just to get a program running outside of CP/M and in AMSDOS on my CPC, the result was a very limited program which I had running outside of CP/M, though CP/M seems to cling on for dear life to that TP Library. This seems more complicated, once I'm into my program there are calls to the library the first - 666 looks to be it's pointing to a 'FOR' routine which was the first thing I wrote in my Main Routine, followed by Calls to other Procedures which I did.
What I'm trying to do is understand the process so then I can start removing what I don't need and create a small executable program. Don't think I'll be able to make a program which allows you to do this - and I think the easiest way to make the program smaller is to simply move the program to where it sits - 20E2 (or whatever). Different programs will obviously have different routines and it would have to be a process of removing and leaving the ones which are used.
Last edited: