Jump to content
IGNORED

CLSN Pascal


tjb

Recommended Posts

Good. You could run the application from inside a batch file and clear the screen on exit.

 

I just sat for half an hour with DIS6502 trying to figure out what's different about the way AUTORUN.SYS loads the main program and I got nowhere so far. The only obvious thing is that the autorun loader ensures against the host DOS having an issue with PORTB being changed during the load. There are no segments loading to the region where the crash occurs, so I wonder if I'm actually looking at SDX crashing while running in its extended bank.

Edited by flashjazzcat
Link to comment
Share on other sites

Looking at the object code that CLSN produces, it's really quite appalling. Almost makes PL65 look good. It doesn't seem as though it does anything inline. Every operation seems to involve multiple (4+) subroutine calls, three of which are to do with pushing and popping things off the stack which is located in a bank. It might be faster than Basic, but it can't be by much if it is.

 

I can't believe how bad these compiled languages are. Action! sure runs rings around them for code performance.

Link to comment
Share on other sites

Looking at the object code that CLSN produces, it's really quite appalling. Almost makes PL65 look good. It doesn't seem as though it does anything inline. Every operation seems to involve multiple (4+) subroutine calls, three of which are to do with pushing and popping things off the stack which is located in a bank. It might be faster than Basic, but it can't be by much if it is.

 

I can't believe how bad these compiled languages are. Action! sure runs rings around them for code performance.

It sounds a little like a BASIC compiler I looked at.

Link to comment
Share on other sites

  • 2 months later...
  • 2 years later...
  • 1 month later...

Here is working Pascal program

program list;

type
  link = ^node;
  node = record
           data: integer;
           next: link;
         end;

var
  head: link;
  key : integer;
  l   : integer;

procedure addnew(var a: link; d: integer);
var
  c: link;
begin
  if a = nil then begin
    new(a);
    a^.data := d;
    a^.next := nil;
  end

  else begin
    c := a;
    while c^.next <> nil do c := c^.next;
      new(c^.next);
      c^.next^.data := d;
      c^.next^.next := nil;
    end
end;

function showlast(a: link):integer;
var
  c: link;
begin
  c := a;
  if c <> nil then begin
  while c^.next <> nil do c := c^.next;
  showlast := c^.data;
  end
  else
  showlast := 0;
end;

procedure deletelast(var a: link);
var
  c: link;
begin
  if a <> nil then
  begin
  if a^.next <> nil then begin
    c := a;
    while (c^.next^.next <> nil) do c := c^.next;
    dispose(c^.next);
    c^.next := nil;
    end
  else
    begin
    dispose(a);
    a := nil;
    end;
  end;
end;

procedure show_list(a: link);
var
  c: link;
begin
  if a = nil then
  writeln('Stack is empty')
else
  begin
  c := a;
  while c <> nil do
    begin
    write(c^.data:2);
    c := c^.next;
    end;
  writeln;
  end;
end;

begin
  head := nil;

  repeat
    clrscr;
    writeln;
    show_list(head);

    writeln;
    writeln('Select operation');
    writeln('1 - Addition');
    writeln('2 - Deletion');
    writeln('3 - Typing');
    writeln('4 - Exit');

    readln(key);

  case key of
  1: begin
    writeln('Enter number');
    readln(l);
    addnew(head,l);
  end;

  2: deletelast(head);

  3: begin
    writeln;
    show_list(head);
    writeln;
    writeln('Press Return');
    readln;
  end;

  end;
  until key = 4;
end.
Link to comment
Share on other sites

  • 1 month later...
Hello Friends.


CLSN is a convenient Pascal version working with Heap like BASIC XE out of a Box!

And it's heap is ALL 130XE extended memory 16*3 = 48k. (Do you like it?)


Being a strictly type-care language Pascal itself can NOT be too simple.

BUT. It's really simple!


I leave PL65 for CLSN!!!


Certainly!!!


Because of...

CLSN is THE ONLY high level language feeling HIGH-leveled itself.

Please look at Action!

- It's realy Atari-Lang but It's not compartible with any other machine.

- I'm an Atari FAN but I want to transfer my ideas to a world!

IDEAS I mean! And what is the IDEA above Action! itself?


Moreover, rtlibs placing separately on disk, killed dosen langs:

- all C dialects

- Action!

...


All the attempts to make serious high level lang beyond BASIC failed on Atari, but CLSN.

Let's try CLSN!


The main Idea to work with ATARI heap is to supply compiler with acceptable data.


AND WHAT IS IT?

- the consensus of types

- the consensus of data


Let's try to make bytes area on heap. Can do you like?


Don't forget to remember that Pascal is strictly... etc.


- At first for the case of heap we need some pointer type, because of it's THE ONLY way to point to never declared entity. (* It's the only exception in Pascal's too striked typization *)

- At second we need to declare THE entity itself!

- At third we need to make variable(static) to touch to every point of our beloved entity on heap!


Here is the code to make Dinamic Array on heap.




program dyn;
type
arrP = ^arrT;
arrT = array[1..1] of byte;
(* On this stage there are no any array on Heap! *)
(* But array is clearly declared as one-dimensioned! And it's size is 1 byte. *)
(* Size means NOTHING for declaration! It's for compiler itself! We can redimension it while runtime!!! *)
var
a: arrP; (* Here we have created a static variable 'a' to access dynamic data. It's possible because of early accurate Pascal typyzation! *)
i,num: integer;
begin
writeln('Enter number of array elements');
readln(num);


(* Dynamic programming *)
getmem(a, sizeof(byte)*num); (* We've got a needed part of memory. Now it's marked as used in Pascal. *)
for i := 1 to num do begin
writeln('Enter ', i , '-th array element');
readln(a^[i]);
end;
(* Then all array-oriented cycles can use 'num' as a max-border *)
freemem(a,num*sizeof(byte)); (* freeing used earlier memory *)
end.



P.S.

If you are interested in Linked Lists in Pascal I can give you freely used codes...

Just whistle!


zen

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

Deque implementation with Doubly Linked List.

Contains full set of Deque functions.

program deque;
type
(* Container type *)
  infoT = Char;


(* Types for DLL *)
  linkT = ^nodeT;


  nodeT = Record
               data: infoT;
               next, prev: linkT;
             End;


(* Type for deque *)
  deqT = Record
           front,rear: linkT;
         End;


(* Useful functions *)
Function isEmpty(Var deq: deqT): Boolean;
Begin
  isEmpty := (deq.front = nil);
End;


Procedure printDeq(Var deq: deqT);
  Var p: linkT;
Begin
  WriteLn( 'Printing Deque ...' );
  writeln;
  If isEmpty(deq) Then
    Begin
      WriteLn('<empty>'); Exit;
    End;
  p := deq.front;
  While p <> nil Do
    Begin
      Write( p^.data, ' ' );
      p := p^.next;
    End;
  WriteLn;
End;


Procedure pushFront(Var deq: deqT; Ch: infoT);
  Var neo: linkT;
Begin
  new(neo);
  neo^.next := deq.front;
  neo^.prev := nil;
  neo^.data := Ch;
  If deq.front <> nil Then
    deq.front^.prev := neo
  Else
    deq.rear := neo;
  deq.front := neo;
End;


Procedure pushRear(Var deq: deqT; Ch: infoT);
  Var neo: linkT;
Begin
  new(neo);
  neo^.next := nil;
  neo^.prev := deq.rear;
  neo^.data := Ch;
  If deq.rear <> nil Then
    deq.rear^.next := neo
  Else
    deq.front := neo;
  deq.rear := neo;
End;


Function popFront(Var deq: deqT): infoT;
  Var toDelete: linkT;
Begin
  popFront := #0;
  If isEmpty(deq) Then Exit;
  toDelete := deq.front;
  deq.front := toDelete^.next;
  If deq.front <> nil Then
    deq.front^.prev := nil
  Else
    deq.rear := nil;
  popFront := toDelete^.data;
  Dispose(toDelete);
End;


Function popRear(Var deq: deqT): infoT;
  Var toDelete: linkT;
Begin
  popRear := #0;
  If isEmpty(deq) Then Exit;
  toDelete := deq.rear;
  deq.rear := toDelete^.prev;
  If deq.rear <> nil Then
    deq.rear^.next := nil
  Else
    deq.front := nil;
  popRear := toDelete^.data;
  Dispose(toDelete);
End;


Procedure initDeq(Var deq: deqT);
Begin
  deq.front := nil;
  deq.rear := nil;
End;


Procedure killDeq(Var deq: deqT);
  var D: infoT;
Begin
  While not isEmpty(deq) Do D := popFront(deq);
End;


Var mD: deqT;
Begin
  initDeq(mD);
  pushFront(mD, 'A');
  pushFront(mD, 'B');
  pushRear(mD, 'F');
  pushRear(mD, 'G');
  writeln;
  writeln('Forward traversing');
  printDeq(mD);
  writeln;
  writeln('Backward traversing');
  writeln('Printing Deque ...');
  writeln;
  While not isEmpty(mD) Do
    WriteLn( popRear(mD) );
  killDeq(mD);
End.

And the Result:

 

Also you know that These functions can be used as standard functions of Stack, Oueue etc...

post-20208-0-43804700-1532615129.png

Edited by 576XE
  • Like 1
Link to comment
Share on other sites

The Joystick's implementations in CLSN is the same as in PL65.

 

It's just an array of system Equates.

But there are never sayed that logic calculations are the same as in Basic, PL65 etc.

 

This string make me comfort:

isEmpty := (deq.front=nil);

 

We CAN calculate bulean value and then equate it to variable!

Thus:

(* Globals *)type
  stk = record
            dx,dy: byte; (* to be returned to main program *)
          end;
var
  s: byte;


procedure rdStick();
  var i: integer;
begin
  for i := 0 to 1 do begin
    s := stick[i];
    stk.dx := (s=5 or s=6 or s=7) - (s=9 or s=10 or s=11);
    stk.dy := (s=5 or s=9 or s=13) - (s=6 or s=10 or s=14);
  end;
end;
Sorry it needs to be checked, but is so clear and simple that I don't even want to make a control program.
zen
Link to comment
Share on other sites

 

The Joystick's implementations in CLSN is the same as in PL65.

 

It's just an array of system Equates.

But there are never sayed that logic calculations are the same as in Basic, PL65 etc.

 

This string make me comfort:

isEmpty := (deq.front=nil);

 

We CAN calculate bulean value and then equate it to variable!

Thus:

(* Globals *)type
  stk = record
            dx,dy: byte; (* to be returned to main program *)
          end;
var
  s: byte;


procedure rdStick();
  var i: integer;
begin
  for i := 0 to 1 do begin
    s := stick[i];
    stk.dx := (s=5 or s=6 or s=7) - (s=9 or s=10 or s=11);
    stk.dy := (s=5 or s=9 or s=13) - (s=6 or s=10 or s=14);
  end;
end;
Sorry it needs to be checked, but is so clear and simple that I don't even want to make a control program.
zen

 

 

strange Pascal dialect

 

STK in this example is TYPE, not VARIABLE

stk.dx := .....

Error: Variable identifier expected

stk.dx := (s=5 or s=6 or s=7) - (s=9 or s=10 or s=11);

Error: Incompatible types: got "Boolean" expected "LongInt"

Error: Operator is not overloaded: "Boolean" - "Boolean"

 

Pascal needs parenthesis

 

correct version of example (FreePascal, MadPascal)

type
  Tstk = record
            dx,dy: byte;
          end;
 
var stk: Tstk;
      s: byte;
 
begin
    s := stick0;
    stk.dx := ord((s=5) or (s=6) or (s=7)) - ord((s=9) or (s=10) or (s=11));
    stk.dy := ord((s=5) or (s=9) or (s=13)) - ord((s=6) or (s=10) or (s=14));
end.
Edited by tebe
  • Like 1
Link to comment
Share on other sites

Hi there, tebe-

You are absolutely right !!!

must be:

(* Globals *)
type
  stkT = record
            dx,dy: byte; (* to be returned to main program *)
          end;
var
  s: byte; stk: stkT; 


procedure rdStick();
  var i: integer;
begin
  for i := 0 to 1 do begin
    s := stick[i];
    stk.dx := (s=5 or s=6 or s=7) - (s=9 or s=10 or s=11);
    stk.dy := (s=5 or s=9 or s=13) - (s=6 or s=10 or s=14);
  end;
end;
Link to comment
Share on other sites

  • 2 months later...

Hello, FRIENDS!

 

For about 2 months I can NOT arrange Line Screen Access to SCREEN just to eliminate multiplication in cycles (which is the native Pascal way of thinking.)

 

Here is a short program which has to be working but ...

program ptr;

var
  (* It;s INITIALIZATION of _Scr! Now _Scr contains SAVMSC data. *)
  _Scr: word absolute $58;
  _Len: byte; _Adr: word;
  (* We say that _Val contains the ADDRESS of byte which placed in absolute _Adr location *)
  _Val: ^byte absolute _Adr;

procedure invLin(a: word; l: byte);
begin
  (* Move Args to Globals *)
  _Adr := a; _Len := l;
  inline(
         $a0/$00/  (*         LDY #$00   *)
                   (* ------------------ *)
         $B9/_Adr/ (* LOOP    LDA _Adr,Y *)
         $49/$80/  (*         EOR #$80   *)
         $99/_Adr/ (*         STA _Adr,Y *)
                   (* ------------------ *)
         $C8/      (*         INY        *)
         $CC/_Len/ (*         CPY _Len   *)
         $D0/$F2   (*         BNE LOOP   *)
        );
end;

var
  a: word; l: byte; c: char;
begin
  (* Just to be visible in CLSN IDE  *)
  writeln;
  (* Move Args to Globals *)
  a := _Scr; l := 10;
  write('?>'); c := readkey; writeln;
  (* This part is lost in time... *)
  invLin(a,l);
  writeln;
  write('?>'); c := readkey; writeln;
end.

CLSN is VERY impressive.

Please help me make CLSN better

zen

 

Link to comment
Share on other sites

  • 2 years later...

Hello, Friends -

Here I'd like to represent to you fully working CLSN Pascal "Dynamic Blocks ML-code Library" for fast screen access.

Blocks means - Rectangular GR.0 Screen Areas

Dynamic means - All Pascal variables intended for Heap access may be accessed from Pascal only with pointers i.e. dynamically.

ML-code means - it's Fast! But nothing interesting!!!
Just the Garbage of bytes. (ACTION! boys, Do you here me?)
Another REMark - when I saw many times ago the code of the newest version of "CC8 Compiler" I decided that it's defect of transmission. Really, it was UUENCODED! I even not try to copy this.
So sorry!!!

Library - means that it's (being carefully initialized in "Main Pascal Routine" will be accepted in All Others! With the Pascal Rules of course.)

The Main IDEA is: Pascal and ML-code know NOTHING about each-other!!!!!
BUT ALL OF THEM KNOWS ADDRESSING! It's Rule of Thumbs !!!

Let's investigate main program.

Here is the Code:

(*==================================*)
(*   CLSN Pascal DYNBLK Library     *)
(*      Demonstration Program       *)
(*                           ZenSoft*)
(*----------------------------------*)
(*Evgeny Zolotarev,(aka 576XE), 2021*)
(*==================================*)
program savres;

type
  bArr = array[0..0] of byte;
  bufP = ^bArr;
  ptrT = pointer;
  adrT = word;
var
  SAVMSC: adrT absolute $58;
  buf: bufP;
  srcP: ptrT absolute $ca;
  srcA: adrT absolute $ca;
  dstP: ptrT absolute $cd;
  dstA: adrT absolute $cd;
  sWid: byte absolute $d0;
  sHei: byte absolute $d1;

include 'D1:DYNBLK.PAS';

(*= Main Procedure =================*)
label loop;
var
  x,y,w,h: byte; ch: char;
begin
  x:=2; y:=2; w:=20; h:=10;

loop:
  ch := readkey; if ch=#27 then exit;
  getmem(buf,sizeof(byte)*w*h);
  saveBlk(x,y,w,h);
  putFram(x,y,w,h);
  invLine(x+1,y+1,w-2);

  ch := readkey;
  restBlk(x,y,w,h);
  freemem(buf,sizeof(byte)*w*h);
  if ch=#27 then exit;
  goto loop;
end.

 

1. At first we are declaring dynamic array bArr with traversing step of byte.
2. Then declaring pointer bufP to access bArr's data
3. Then we need GP pointer type to access some pointers (init/reinit)
4. And at last we need GP word type to set/re-set address field of pointers thus to give them address arithmetic (Pointer structure in memory is LSB,MSB,BNK).

5. We define SAVMSC for screen addressing
6. Then define buf for access dynamic buffer on heap
7. And define two pairs (with the same address on Z-Page) of Pascal's Pointer/Address data. Pointer serves to access heap and Address (LSB/MSB) serves to traversing heap array variable in runtime.
8. At last we define Swid,sHey Z-Page vars to eazy access them from ML

Every Subroutine in Library works with Pascal part (Calculating, Initializing) and ML part (only addressing and actions)

getmem initialises dynamic array buf at runtime with it's sentinels by calculating w*h.
i.e. buf = array[0..(w*h)-1] of byte;
freemem deletes buf memory from heap.

You may use this library at your disposal of course :)

zen
 

CLSN_MAE.atr

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...