Pascal MT+ assignment of a word value into an integer variable?

121 views
Skip to first unread message

rwd...@gmail.com

unread,
Jun 12, 2024, 12:58:03 PMJun 12
to retro-comp
I am stumped in Pascal MT+ code to assign a WORD value into an INTEGER.

The BDOS function requires use of WORD but Writeln() throws up at attempting to handle WORD.

The manuals imply that assignments can be made but any attempt by me to assign Word into Integer or vice versa fails.

Has any one managed to do those or knows how to make BDOS calls using Integer rather than Word values?

I am actually attempting to get the current user number, save it,  run some code for different user numbers, then restore the original saved user number.

Any help would be greatly appreciated.

If it works ok on CPM 2.2 then I shall attempt to port over to MT+ on CP/M-68K

Cheers
Richard

Fred Weigel

unread,
Jun 12, 2024, 9:09:25 PMJun 12
to retro-comp
MOVE(source,destination,2);

Derek Cooper

unread,
Jun 16, 2024, 5:14:59 AMJun 16
to retro-comp

Are you calling a small external program to call the BDOS/BIOS ? if so the info in this guide may help:


Section 4.2.3 explains about passing parameters back and forth etc.

I did an exampe cpm-68k Pascal MT+ program some time ago, it's here:


(Sorry but some of the formatting seems to have gone a bit bonkers!). But it does show how to use machine code as a function in pascal etc.

Have fun
Derek

Richard Deane

unread,
Jun 18, 2024, 11:42:38 AMJun 18
to Derek Cooper, retro-comp
Hi,

My DMAP program works as expected on Pascal MT+ for cp/m 2.2 but ported across to 68k, changing it from Word parameters to Pointer parameters, then the bdos search first and search next fails, but set user and get user work fine.

My FCB is pre-filled with ? before the bdos search call and doesn't seem to get over-ridden with real data.

It could be my error, but I believe I have accurately followed the doc although it contains a lot of typo errors, and one of those may actually be significant.

If you have any inspiration, I'd love to hear.

Richard

============================================================================
Program DMAP;
Const
   SETUSR = 032;
  GETUSR = 032;
  SEAR = 017;
  SEARN = 018;
Type
   ptr = ^integer;  
   (* fcb length = 36 *)
   search_fcb =
RECORD
drive : char;end;
        name : array[1..8] of char;
        ext : array [1..3] of char;
        extnt : char;
        s1,s2 : char;
record_count : char;
blocks : array[1..16] of char;
        current_record : char;
R0,R1,R2 : CHAR;
END;
 
Var
i,j, number : integer;
Dsk : integer;
    ch : char;
    usercount : array[0..15] of integer;
fcb : search_fcb;
  user : integer;
saved_user : integer;
retcode : Integer;
parm : word;
k: integer;
   
EXTERNAL FUNCTION _BDOS(i:integer;p:ptr): INTEGER;

FUNCTION CONINP:CHAR;
begin
end;

FUNCTION rdstat:boolean;
begin
end;

procedure write3(i:integer);
var
num3: array[1..3] of char;
j,k,l,m : integer;
ch: char;
flag: boolean;
begin
    flag := false;
k:=i;
(* write(' '); *)
for j := 3 downto 1 do
begin
l := k MOD 10;
num3[j] := chr(l+48);
k := k DIV 10;
end;
for j:= 1 to 3 do
begin
  if num3[j] > '0' then flag := true;
  if ((num3[j] = '0') and (flag = false)) then num3[j] := ' ';
end;
write(num3);
write(' ');
end;


(* Main Program *)

BEGIN
   
k:= 255;
saved_user := _BDOS(GETUSR,ADDR(k));
writeln('Saved User is: ', saved_user);
writeln('DMAP - A program written in Pascal/MT+ (CP/M-68K)to show file count on each user/drive');
(*writeln('Press ESC or CTL-C to quit');*)
write('USR> ');
for i := 0 to 15 do
begin
 CASE i OF
00 : WRITE(' 00');
01 : WRITE(' 01');
02 : WRITE(' 02');
03 : WRITE(' 03');
04 : WRITE(' 04');
05 : WRITE(' 05');
06 : WRITE(' 06');
07 : WRITE(' 07');
08 : WRITE(' 08');
09 : WRITE(' 09');
10 : WRITE(' 10');
11 : WRITE(' 11');
12 : WRITE(' 12');
13 : WRITE(' 13');
14 : WRITE(' 14');
15 : WRITE(' 15');
end;
write(' ');
end;
writeln;
for Dsk := 1 to 16 do (* Loop through Drives (0 would be default drive) *)
begin
      for User := 0 TO 15 do (* Loop through Users *)
begin
retcode := _BDOS(SETUSR,ADDR(User));
   number := 0;
end;

 fcb.drive := chr(Dsk);
 fcb.name := '????????';
 fcb.ext := '???';
 retcode := _BDOS(SEAR,ADDR(FCB));
 writeln('search first on dsk', Dsk,'retcode: ', retcode, 'user ',user);
 while (retcode <> 255) do
 begin
   number := number + 1;
retcode := _BDOS(SEARN,ADDR(FCB));
writeln('search next on dsk', Dsk,'retcode: ', retcode, 'user ',user);
 end;
 usercount[User] := number;
        end; (* end loop users *)
   write(' ',chr(ord('@') + Dsk),':> ');
for i := 0 to 15 do
begin
j := usercount[i];
if j <> 0 then write3(usercount[i])
       else write('    ');
end;
writeln;
end; (* end loop Drive *)
    (*writeln('saved_user value: ',saved_user);*)
retcode := _BDOS(SETUSR,ADDR(Saved_User));
end. (*dmap *)



--
You received this message because you are subscribed to the Google Groups "retro-comp" group.
To unsubscribe from this group and stop receiving emails from it, send an email to retro-comp+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/retro-comp/82f3d0d2-6c03-43a7-8460-f2dba3dd4c02n%40googlegroups.com.

Derek Cooper

unread,
Jun 18, 2024, 12:58:07 PMJun 18
to retro-comp
It may not be the issue but I seem to recall when I was having a quick play with assemble language and mt+ the example i found for the 68k version was a total mess. It even got the parameters push on the stack in the wrong order, and i seem to recall it said they where little endian but the 68k expects big endian ordering.

Was my example any good to you on instructables, I know it's not exactly the same but it did show the order of parameters etc.

Derek

Reply all
Reply to author
Forward
0 new messages