Assembly with Turbo Pascal 3
Assembly with Turbo Pascal 3
I'm trying to figure out how to use external assembly language routines with TP3 under CP/M. The manual is extremely sparse on details when it comes to that, particularly as to how the external assembly routine is to be set up. Does anyone have any experience with this?
I did find a reference online, but it's pertaining to MS-DOS only.
I did find a reference online, but it's pertaining to MS-DOS only.
Re: Assembly with Turbo Pascal 3
I'm not sure if you have it yet, but here's the manual:
https://archive.org/details/bitsavers_b ... 88_6578073
On page 157 they talk about the INLINE command, that's how I used to do it.
https://archive.org/details/bitsavers_b ... 88_6578073
On page 157 they talk about the INLINE command, that's how I used to do it.
Re: Assembly with Turbo Pascal 3
I actually do have the manual. The inline command is not very practical for more than a few assembly lines because everything has to be converted to bytes manually. The 'external' identifier for procedures (mentioned just before the inline command entry for CPM 80 in the manual) is what I am interested in because it allows you to use full assembly routines, a far more practical feature.lotonah wrote: ↑Tue Jul 23, 2019 5:05 amI'm not sure if you have it yet, but here's the manual:
https://archive.org/details/bitsavers_b ... 88_6578073
On page 157 they talk about the INLINE command, that's how I used to do it.
It requires the address of the routine in memory, but there is no mention as to how to set up the registers or the stack in the routine nor how to return from the routine in assembly. I tried a few tests and could not get it to work. I am also not clear how you would load an assembly routine into memory before launching a Turbo Pascal program... The process for the DOS version of TP3 is simpler and well documented online, but no so for the CPM 80 version unfortunately.
Re: Assembly with Turbo Pascal 3
I would suspect that TP3 for DOS had a lot more going for it than CP/M (TP3 was the last version Borland made for it). You are right, there is a ton of documentation for MS-DOS, little for CP/M. I don't have proof, but I think that TP3 for MS-DOS outsold the CP/M edition by a pretty wide margin.
As far as I know, the INLINE command is the only way to do it (although you can compile code into a library and call it that way).
I can't do it today, but I'll try to dig out some of my old code to show you how to get underway.
As far as I know, the INLINE command is the only way to do it (although you can compile code into a library and call it that way).
I can't do it today, but I'll try to dig out some of my old code to show you how to get underway.
Re: Assembly with Turbo Pascal 3
If I am going to use the INLINE feature, I suppose I could just copy the HEX object code generated by ASM and add the / separator between each byte as required by TP3. A pain to say the least, but doable, at least for short routines.
I'll run some tests over the next few days and see how it goes.
The object of all my inquiries on this is that I want to add low-level routines to TP3 that allow easy access to the VDP for graphics and such. There is a PORT function in TP3 that allows access to the Z80 ports, but I suspect it will be slow, although this will need testing as well.
Should keep me busy for a while
I'll run some tests over the next few days and see how it goes.
The object of all my inquiries on this is that I want to add low-level routines to TP3 that allow easy access to the VDP for graphics and such. There is a PORT function in TP3 that allows access to the Z80 ports, but I suspect it will be slow, although this will need testing as well.
Should keep me busy for a while
Re: Assembly with Turbo Pascal 3
Cpm has all the vdp routines on it same as eos - you can call them via BDOS
Milli
Re: Assembly with Turbo Pascal 3
Correct, but it's likely slower than direct access, which is why I rolled my own with ADAMED. That said, they may he perfectly serviceable depending on the application.
Re: Assembly with Turbo Pascal 3
So I managed to get a simple Hello World test program working with the INLINE function:
This test verifies that TP3 does indeed support 8080 assembly and that bdos calls from TP3 work.
That said, it's a royal pain to enter assembly programs that way, so better keep it short!
Code: Select all
program test;
var Hello : String[255];
begin
Hello := 'Hello World!$';
inline ($0E/9/ {mvi c,9}
$11/Hello/ {lxi d,Hello}
$CD/5/0/ {call 5}
$C3/0/0); {jmp 0}
end.
That said, it's a royal pain to enter assembly programs that way, so better keep it short!