Assembly with Turbo Pascal 3

Post your CP/M & TDOS questions here
Post Reply
User avatar
Wmaalouli
Posts: 155
Joined: Sat Jul 20, 2019 2:09 pm

Assembly with Turbo Pascal 3

Post by Wmaalouli » Mon Jul 22, 2019 9:34 am

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.

lotonah
Posts: 14
Joined: Sat Jul 20, 2019 5:26 pm

Re: Assembly with Turbo Pascal 3

Post by lotonah » Tue Jul 23, 2019 5:05 am

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.

User avatar
Wmaalouli
Posts: 155
Joined: Sat Jul 20, 2019 2:09 pm

Re: Assembly with Turbo Pascal 3

Post by Wmaalouli » Tue Jul 23, 2019 8:12 am

lotonah wrote:
Tue Jul 23, 2019 5:05 am
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.
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.
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.

lotonah
Posts: 14
Joined: Sat Jul 20, 2019 5:26 pm

Re: Assembly with Turbo Pascal 3

Post by lotonah » Wed Jul 24, 2019 3:13 am

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.

User avatar
Wmaalouli
Posts: 155
Joined: Sat Jul 20, 2019 2:09 pm

Re: Assembly with Turbo Pascal 3

Post by Wmaalouli » Wed Jul 24, 2019 9:04 pm

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 :)

User avatar
Milli
Site Admin
Posts: 224
Joined: Fri Jul 19, 2019 3:13 pm
Location: Beaver Falls PA
Contact:

Re: Assembly with Turbo Pascal 3

Post by Milli » Wed Jul 24, 2019 9:48 pm

Cpm has all the vdp routines on it same as eos - you can call them via BDOS
Milli

User avatar
Wmaalouli
Posts: 155
Joined: Sat Jul 20, 2019 2:09 pm

Re: Assembly with Turbo Pascal 3

Post by Wmaalouli » Wed Jul 24, 2019 10:17 pm

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.

User avatar
Wmaalouli
Posts: 155
Joined: Sat Jul 20, 2019 2:09 pm

Re: Assembly with Turbo Pascal 3

Post by Wmaalouli » Sat Jul 27, 2019 10:46 am

So I managed to get a simple Hello World test program working with the INLINE function:

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.
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!

Post Reply