Jump to content
IGNORED

Pascal on the 99/4A


apersson850

Recommended Posts

I found 30 minutes to have a play @apersson850 and can now find my way around the menu system with '?' and do basic operations like a disk directory. Many thanks

 

Decided to create a work disk for when I try my first application so formatted a DSDD disk (using CorComp disk manager) and then Zero'd it in p-code. It asked for the number of blocks and based on your information above I told it 720 blocks which created a PASCAL file that filled the DSDD disk so that looks good

 

But I don't think my boot disk is working properly because when I tried to execute *DFORMAT it gave a bad file error? Also, the boot disk doesn't have SYSTEM.COMPILER (there may be others missing). It was an image called 705.dsk I got from WHTech ftp site

 

Is there another disk image out there that has everything on it I might need to use the system please? (I only have two DSDD floppy drives so would like to have a boot disk with everything needed by the system and use dsk2, or should I say #5, for my own stuff while I learn)

 

Many thanks

 

Link to comment
Share on other sites

19 minutes ago, FarmerPotato said:

I've read much Niklaus Wirth in the past year, so new respect for Pascal. (Also Kernighan: Software Tools in Pascal.) 

Wirth was one those guys that did great work, but didn't get enough respect IMHO. 

After Pascal he went on to Modula and proved it could build an operating system. I think he even had custom silicon for one of his projects.

How many millions of man hours were wasted waiting for C to compile compared to if people had been using a fast compiling language like Modula.

Things I wonder ... :) 

Link to comment
Share on other sites

There are two code pools.

  • The primary one is between the screen data and disk buffers in VPD RAM.
  • The secondary is in 24 K RAM expansion between the heap and the stack.

Obviously the secondary pool is bigger to begin with, before anything has been loaded.

P-code is loaded in segments. A "standard" program is usually only in one segment, and that segment isn't bigger than it fits in any code pool. The system then puts it in the primary one, because that leaves more space in the other one for the heap and stack to grow into.

A big program can be split in several segments. For that to make any point, at least some of the different segments must be independent from each other, since a calling and called segment must stay in memory at the same time. But if you have a program with these functions, that is a good candidate for splitting up in segments, since it's likely that then only the main program and one of the other segments must be loaded at the same time.

 

Program structure

  • Main
  • Setup
  • Data entry
  • Printout

A program calling procedures in a separately compiled unit will also call a different segment. The units themselves may also be segmented.

 

Segment properties

  • A segment is loaded in memory only when needed.
  • A segment can be moved in memory, inside the code pool, if it's in the way for something else. So a segment that can be overwritten by a lot of data added to the stack can be moved towards the heap, to allow room for the stack to grow. Note that this can happen while the segment is executing. It will just be halted, moved and restarted from where it was halted.
  • A segment can be deleted from memory if it's not in use (no procedure running inside the segment).
  • A segment that has been discarded can be reloaded again, if procedures are called inside the segment once again.
  • Since segments in the primary code pool (VDP RAM) doesn't compete with data space (heap/stack), loading segments there has no space penalty. If you write your code in such a way that the segment Main and any one of the other three in the example above doesn't combine to larger size than will fit in the primary code pool (VDP), then you'll have the largest possible space for data all the time. The memory manager will also not need to move code, just load different segments when they are needed.
  • Segments manipulating VPD RAM directly themselves must run from CPU RAM, or they'll literally trap their own feet. Segments containing assembly code also must run from CPU RAM, of course. They can still be made relocatable.

The PME can execute code from CPU RAM, VDP RAM or GROM. Since reading from successive addresses in CPU RAM is different compared to reading from VDP RAM or GROM, the system replaces some code in the inner interpreter, if it switches from a segment in one type of code to the other.

Reading data bytes is the same, just from different addresses, for VDP RAM and GROM. But setting up the address is different, so when there's a jump in the p-code, a flag will tell the PME which address loader code to use.

 

As a summary, it's safe to say that the p-systems memory management capabilities is pretty outstanding, considering the machines and time it was running in.

  • Like 3
  • Thanks 1
Link to comment
Share on other sites

5 minutes ago, TheBF said:

Wirth was one those guys that did great work, but didn't get enough respect IMHO. 

After Pascal he went on to Modula and proved it could build an operating system. I think he even had custom silicon for one of his projects.

How many millions of man hours were wasted waiting for C to compile compared to if people had been using a fast compiling language like Modula.

Things I wonder ... :) 

The more I lean about C compilers--the preprocessor is the yuckiest. C is one hack atop another, which makes us hackers pleased (at first). But I feel like I work in the dead-end of ALGOL. I've stopped using C++ for money or pleasure. 
 

Imagining an alternative (still less than ideal) world where Pascal compiles to Pcode and prevented Java. 
 

In any of the Wirth languages, can you have a procedure that returns a procedure?
 

 

Link to comment
Share on other sites

The disks from TI were split up on several. One had the Compiler, another the Editor and Filer, a third the Assembler and Linker and a fourth the other utilities. You can make your own combination as you like, provided you do get the files to begin with.

Link to comment
Share on other sites

19 minutes ago, apersson850 said:

The disks from TI were split up on several. One had the Compiler, another the Editor and Filer, a third the Assembler and Linker and a fourth the other utilities. You can make your own combination as you like, provided you do get the files to begin with.

Have got a set of 5 x 92k dsk images for those (Compiler, Editor/Filer 1, Editor/Filer 2, Assemble/Link, Utils) I downloaded from somewhere, will try to use those to make a single 360k disk (less utils)

 

Thanks

Link to comment
Share on other sites

@apersson850 Thank you for the great explanation of code pools. I see now that,  to have the heap there, is a better use of CPU RAM. 
 

TI offered two other Pascals with choice of interpreted "Pcode" or compiled. It seems that compiled code was position-independent (PIC) (no absolute addresses!) but I haven't read that the runtime ever moved it. See TI's "Software Development Handbook" or  the MPX or RX manuals (Bitsavers) 

 

The Microprocessor  Pascal runtime source is 50% known, thanks to Dave Pitts. 

(I will post those  details appropriately into the  topic Assembly Language Tricks)

  • Like 3
Link to comment
Share on other sites

2 hours ago, Atari2600PAL said:

Have got a set of 5 x 92k dsk images for those (Compiler, Editor/Filer 1, Editor/Filer 2, Assemble/Link, Utils) I downloaded from somewhere, will try to use those to make a single 360k disk (less utils)

 

Thanks

Turned out it was 4 disks, not 5, that I had

 

Took a while to get my head around swapping the disks around so I could copy the 4 SSSD disks onto the 1 DSDD, but got there in the end and as a quick and dirty test I can now load *DFORMAT without error

 

I guess next up will be to try a short program to get some kind of handle on how more of the system works

 

Not used Pascal for decades so it won't be easy, but looking forward to it when I can find the time

 

Many thanks

Link to comment
Share on other sites

4 hours ago, FarmerPotato said:

The more I lean about C compilers--the preprocessor is the yuckiest. C is one hack atop another, which makes us hackers pleased (at first). But I feel like I work in the dead-end of ALGOL. I've stopped using C++ for money or pleasure. 
 

Imagining an alternative (still less than ideal) world where Pascal compiles to Pcode and prevented Java. 
 

In any of the Wirth languages, can you have a procedure that returns a procedure?
 

 

That's above my pay grade but it seems to have pointers so if you can return a pointer to function ...

Modula-2 tutorial: Pointers and Dynamic Allocation (modula2.org)

Link to comment
Share on other sites

Posted (edited)

There are pointers available in the UCSD implementation of Pascal too, but you can't call a procedure through them.

On the other hand, the intrinsic pmachine allows you to generate inline p-code as you wish, so by some unorthdox coding this may be possible anyway. I don't remember without checking the p-codes for calling a procedure how the argument for which one to call is handled. My gut feeling is that they are included in the p-code, in which case self-modifying code would be needed to change which procedure to call. But if there's something that's unreliable in this world, it's self modifying code that's also moved around in memory and swapped in/out from disk at any time.

 

A case statement listing the possible procedures and indexing which to call via a variable is at least a working method.

Edited by apersson850
  • Like 3
  • Haha 1
Link to comment
Share on other sites

1 hour ago, Vorticon said:

For anyone just starting out with UCSD Pascal, there is a Windows file utility called Pcode Tool which allows various manipulations of Pascal disk images and files, including copying and pasting of code from an external editor. Super helpful if you are emulator-based.

 

manual.pdf 376.09 kB · 1 download p-code-tool-V3.0.exe 156 kB · 1 download

Am going to have to consider getting a cheap windows laptop for the various emulators I’d like to run and for tools like this

  • Like 3
Link to comment
Share on other sites

  • 2 weeks later...

A Gotek drive emulates a floppy drive at the Shugart bus level, so it does not even know what a sector is or even a byte. It only delivers flux changes.

 

The only thing to consider is that only the HFE files can save special information that is outside of pure sector contents. Gotek can handle DSK files, but those only contain sector contents. As we're not talking about disk protection schemes but only about direct sector access, this should be OK. If needed, HFE files can be created with numerous tools from DSK, including my TIImageTool.

  • Like 2
Link to comment
Share on other sites

21 minutes ago, mizapf said:

A Gotek drive emulates a floppy drive at the Shugart bus level, so it does not even know what a sector is or even a byte. It only delivers flux changes.

 

The only thing to consider is that only the HFE files can save special information that is outside of pure sector contents. Gotek can handle DSK files, but those only contain sector contents. As we're not talking about disk protection schemes but only about direct sector access, this should be OK. If needed, HFE files can be created with numerous tools from DSK, including my TIImageTool.

Thanks for the info

 

From what you say I can see that it should work in theory, but am wondering if anyone has actually used a gotek with the p-code card

 

Ideally, if I got one, I'd really want to use it only with real iron (other than using my laptop to format a USB stick for it and simply copying dsk file images from/to it) and not need any other utilities (I don't want to install anything, like java, on my laptop)

 

Many thanks

Link to comment
Share on other sites

7 hours ago, Atari2600PAL said:

Thanks for the info

 

From what you say I can see that it should work in theory, but am wondering if anyone has actually used a gotek with the p-code card

 

Ideally, if I got one, I'd really want to use it only with real iron (other than using my laptop to format a USB stick for it and simply copying dsk file images from/to it) and not need any other utilities (I don't want to install anything, like java, on my laptop)

 

Many thanks

yes it works but i recommend you not use the stock firmware get flashfloppy 

  • Like 2
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...