News for hackers. Stuff that matters.
Re:Internals of a Turbo Pascal Compiler by barrkel on Friday September 11, 2015 @04:23AM (#10202563)
This site doesn't describe the internals of Borland's Turbo Pascal compiler. It describes a compiler written in Turbo Pascal that can compile some subset of Turbo Pascal's language.

Borland's Turbo Pascal compiler was written in 16-bit x86 assembly, mostly by Anders Hejlsberg.

There is an explanation of this on the front page of the site, but it's not clear from the headline.

(I used to work at Borland on the Delphi compiler, and had access to the source of tpc.exe.)

Re:Internals of a Turbo Pascal Compiler by jgord on Friday September 11, 2015 @04:46AM (#10202638)
.. thats the story I was hoping to read, and have been waiting for, for many years.

I went from the necessity of A86 assembler, thru the desperation of GW-Basic .. finally finding Turbo Pascal, which was a revelation at the time, just this phenomenal product and superb piece of engineering.

Pulldown text menus, draggable text windows, editor out of the box .. fast compilation, wow - to me its one of the great monuments of computer history. I feel intensely nostalgic looking back on it now.

And their manuals were first rate.. classy all round.

Re:Internals of a Turbo Pascal Compiler by analog31 on Friday September 11, 2015 @08:40AM (#10203301)
My dad, who knew nothing about computers, saw an article in the Wall Street Journal about this guy with a new business model for selling software. On a whim, he got me a copy for my birthday. It was TP version 1.

I stuck with TP through version 5, and even convinced my college teachers to let me use it for my programming assignments rather than whatever was on the college mainframe.

The manuals were indeed a huge asset. You didn't really need to know anything about the OS, or go digging for third party documentation online, which was important because there was no online.

Re:Internals of a Turbo Pascal Compiler by vetinari on Friday September 11, 2015 @10:40AM (#10203899)
I learned programming by digging through TP6 online help.

That and Ralf Brown's Interrupt List, so I could do something useful.

Re:Internals of a Turbo Pascal Compiler by analog31 on Friday September 11, 2015 @01:25PM (#10204957)
Oops! What I meant was, there was no such thing as "online" at all, when TP1 came out. ;-)
Re:Internals of a Turbo Pascal Compiler by vetinari on Friday September 11, 2015 @05:37PM (#10206310)
Online as in "hlp file that's shown when you press F1". At the time online meant "not printed" :-)
Re:Internals of a Turbo Pascal Compiler by analog31 on Friday September 11, 2015 @06:28PM (#10206490)
Ah, yes. Now I get it. I'm kinda slow on the uptake sometimes. ;-)

I stopped with TP5. At that point, I was up to my ears in my thesis project, and was not going to change any of my tools. Plus I'm a real tightwad. By the time I finally finished my degree, got a new job, and a new computer, it was an Apple Mac. And the modern OS's kind of killed my interest in programming for a while.

Re:Internals of a Turbo Pascal Compiler by ido on Friday September 11, 2015 @09:52AM (#10203635)
Lightspeed Pascal (later renamed THINK Pascal) was a similarly solid compiler+IDE from about the same era for the early Macintosh.
Re:Internals of a Turbo Pascal Compiler by Tloewald on Friday September 11, 2015 @01:30PM (#10204989)
It all went downhill after they got bought by Symantec.
Re:Internals of a Turbo Pascal Compiler by Supraperplex on Friday September 11, 2015 @08:20AM (#10203220)
Desperation of GW-Basic?!

Be glad you had that one. The other BASICs of those times where much more limited! GW was a little bit of awesome in it's own way. Oh, and POKE and PEEK.

Re:Internals of a Turbo Pascal Compiler by insulanian on Friday September 11, 2015 @09:23AM (#10203498)
Yeah, my first lines were in QuickBASIC :)
Re:Internals of a Turbo Pascal Compiler by antimagic on Friday September 11, 2015 @05:17AM (#10202728)
I have very fond memories of just how blazingly fast Turbo Pascal was at compiling on my Mac. It stunned me every time. I remember spending most of one summer writing a text adventure game with it, based in the Australian Gold Rush. It even had NPCs which was quite advanced for text adventures of the day (I think the only NPCs in adventure games that I had encountered up to that point were those in the Hobbit, and of course the bloody thief in Zork (although he wasn't really an NPC, but was implemented as a bunch of semi-random encounters)...

Good times. In particular, I remember having to implement my own strings, because for a text adventure you often want to have access to strings longer than 255 characters...

Sadly, I never managed to make the jump from writing console applications with TP to writing proper Mac GUI apps. But "Inside Macintosh" cost an absolute fortune at the time (for a 10 year-old kid at any rate), so I ended up scraping enough money together to buy another text book whose name escapes me. I must have read the first few chapters about a million times - they talked about handles and graphics ports etc, but I could never get any code from them to run in TP (I think they were assuming that you would be using MPW?).

Which brings me to the point of this long rambling message - did TP really support graphics programming on the Mac? I know my version of TP was an official bought copy, so we had the manual, but I don't remember ever seeing anything that explained GUI programming in there.

Re:Internals of a Turbo Pascal Compiler by pjmlp on Friday September 11, 2015 @07:09AM (#10203019)
Well you also had Apple's Object Pascal as the original OS system programming language, which was the inspiration for the OOP approach Turbo Pascal adopted.

With that one, you could surely do graphics programming on the Mac.

As for Turbo Pascal itself, I wasn't aware it was available on the Mac as well.

Re:Internals of a Turbo Pascal Compiler by ido on Friday September 11, 2015 @09:57AM (#10203660)
A more popular alternative to Apple's MPW on the mac was the 3rd party Lightspeed Pascal (later renamed THINK Pascal), which in many ways was quite similar to Turbo Pascal on the PC.

IIRC TP was just a quick port & had a very short life on the mac.

Re:Internals of a Turbo Pascal Compiler by Tloewald on Friday September 11, 2015 @01:34PM (#10205018)
I didn't realize Turbo Pascal was ever released for the Mac. Apparently (according to Wikipedia) it was, but it was soon discontinued. Lightspeed/THINK Pascal/C ruled the roost on the Mac for a long time (thanks in large parts to just how horrible working with MPW was) until the PowerPC when Metrowerks took their place.
Re:Internals of a Turbo Pascal Compiler by jhallenworld on Friday September 11, 2015 @12:05PM (#10204456)
I remember at the time that C was more compelling specifically because of the limited strings in Turbo Pascal. At least TP had variable length strings.. older PASCALs did not have this (they had space filled strings instead).
Re:Internals of a Turbo Pascal Compiler by aidenn0 on Friday September 11, 2015 @12:06PM (#10204467)
If you haven't played it still, play Planetfall, it has Floyd as an NPC and is one of the greats from the Infocom days.
Re:Internals of a Turbo Pascal Compiler by Supraperplex on Friday September 11, 2015 @08:22AM (#10203226)
On DOS TP did support a texmode based "GUI".
Re:Internals of a Turbo Pascal Compiler by pvg on Friday September 11, 2015 @11:37AM (#10204265)
Turbo Pascal was originally written for and targeted the (8-bit) Z80, unless Wikipedia has it backwards.

https://en.wikipedia.org/wiki/Turbo_Pascal#CP.2FM_and_DOS_ve...

The Turbo Pascal compiler was based on the Blue Label Pascal compiler originally produced for the NasSys cassette-based operating system of the Nascom microcomputer in 1981 by Anders Hejlsberg. Borland licensed Hejlsberg's "PolyPascal" compiler core (Poly Data was the name of Hejlsberg's company in Denmark), and added the user interface and editor. Anders Hejlsberg joined the company as an employee and was the architect for all versions of the Turbo Pascal compiler and the first three versions of Borland Delphi.

Re:Internals of a Turbo Pascal Compiler by FullyFunctional on Friday September 11, 2015 @07:59PM (#10206756)
Indeed. Manuals and object files for the original, BLS Pascal, can be found at http://nascomhomepage.com and the motivated reader can even run it at http://thorn.ws/jsnascom/jsnascom.html (Download http://nascomhomepage.com/lang/Blspas.nas and use "Load NAS" to browse to it. After that type "E1000" return and you should end up in BLS Pascal. Type a program like

BEGIN WRITE('Hi'); END.

hit Ctrl-X and use R to run it.

Re:Internals of a Turbo Pascal Compiler by TD-Linux on Friday September 11, 2015 @01:12PM (#10204858)
That's correct, I even have a version of it for the Z80 Softcard on the Apple II. Even in that day, the license was still only for 1 CPU and you had to mail in a license registration card to be able to use the software (I don't think that sort of EULA is legally enforceable, though)
Re:Internals of a Turbo Pascal Compiler by pvg on Friday September 11, 2015 @01:45PM (#10205087)
How did that licensing work? Like any self-respecting 11-year-old, my Apple ][ CP/M copy of Turbo Pascal was pirated.
Re:Internals of a Turbo Pascal Compiler by TD-Linux on Sunday September 13, 2015 @04:42PM (#10212737)
The book just told you to mail in the registration card with strong language. I don't think it was legally enforceable in any way. There wasn't a license key or anything.
Re:Internals of a Turbo Pascal Compiler by kjs3 on Friday September 11, 2015 @03:53PM (#10205811)
That's correct. I first used it on a Z-80 CP/M machine.
Re:Internals of a Turbo Pascal Compiler by FullyFunctional on Friday September 11, 2015 @07:00PM (#10206584)
Actually, the CP/M version was called COMPAS Pascal, but it was very nearly the same code.
Re:Internals of a Turbo Pascal Compiler by pvg on Friday September 11, 2015 @08:13PM (#10206792)
I think they mean the CP/M version of Turbo Pascal (the Borland-licensed one with the built-in IDE)
Re:Internals of a Turbo Pascal Compiler by FullyFunctional on Friday September 11, 2015 @08:32PM (#10206830)
Borland never made CP/M software. This account matches my memory from back then: http://blogs.embarcadero.com/davidi/2008/11/02/38933
Re:Internals of a Turbo Pascal Compiler by pvg on Friday September 11, 2015 @08:44PM (#10206854)
I think you're misremembering things. I'm pretty sure I ran CP/M Turbo Pascal as a kid and the page you link says:

The final step in November 1983 - Turbo Pascal v1.0 is created for Borland International, Inc. Distributed on a single floppy disk, Turbo Pascal integrated the Pascal compiler, Wordstar-like text editor, runtime library, run in memory, and creation of .COM programs - all within 131,297 bytes in the TURBO.COM file. The whole product was 33k bytes in size and ran in 64k bytes of memory. The product was delivered for CP/M-80 (Z/80, 5.25 and 8 inch floppy disks), CP/M-86, and MS-DOS/PC-DOS.

Re:Internals of a Turbo Pascal Compiler by FullyFunctional on Friday September 11, 2015 @10:11PM (#10206989)
Blush. I'm delighted to be corrected as I didn't know this. A 15 year old version of me met The Man himself at a trade show where he was demoing COMPAS Pascal, running a maze generator. I've learned a lot from using and disassembling his software.
Re:Internals of a Turbo Pascal Compiler by shdon on Friday September 11, 2015 @07:55AM (#10203146)
According to the author, it is not just a subset and actually produces the same binary files as actual TP would (with the exception of debug info). I can't currently verify that claim, but here's what he says on the downloads page:

"It can compile any source code compatible with Turbo Pascal 7 syntax. It will generate the same executable file and unit files as the original Borland compiler."

Re:Internals of a Turbo Pascal Compiler by samuell on Friday September 11, 2015 @08:40AM (#10203299)
To me, FreePascal, with its upcoming 3.0 release, is much more interesting.

Interestingly, in 3.0, it will support compiling JVM byte code. [1]

[1] http://wiki.freepascal.org/FPC_New_Features_3.0#Support_for_...

Re:Internals of a Turbo Pascal Compiler by barrkel on Friday September 11, 2015 @08:28AM (#10203246)
It's unlikely to be 100% bug compatible with TP 7. There are various obscure bits in most languages that have been around for a while, where the implementation choices are a bit arbitrary and interaction between different features can turn up unexpected behaviour.

Turbo Pascal was a much smaller language than what Delphi became, so I can't point you out examples off the top of my head. If I were looking into compatibility issues, I'd play around with things like alignment and packing rules, TP's various hacks to get around Standard Pascal's fixed length strings (e.g. OpenString {$P+}), etc.

Re:Internals of a Turbo Pascal Compiler by Olivier26 on Friday September 11, 2015 @05:17AM (#10202729)
Turbo Pascal was also available on CP/M (so 8080/Z80 8-bit). It was the most powerful language on Amstrad CPC 6128, the only 8-bit low cost computer to offer CP/M compatibility.
Re:Internals of a Turbo Pascal Compiler by barrkel on Friday September 11, 2015 @08:15AM (#10203202)
IIRC from the stories I heard, Anders retargeted the compiler to x86 in the course of a single weekend. I don't remember what it targeted first, but it wasn't x86; it might have been Z80, I don't recall.
Re:Internals of a Turbo Pascal Compiler by vidarh on Friday September 11, 2015 @05:45AM (#10202795)
> the only 8-bit low cost computer to offer CP/M compatibility.

The Commodore 128 also offered CP/M compatibility (through a second CPU...), though rarely used.

Re:Internals of a Turbo Pascal Compiler by Olivier26 on Friday September 11, 2015 @06:09AM (#10202879)
You're right, in Europe the Amstrad was less expensive than the Commodore and hence far more popular. The CPC 6128 was probably at this time the less expensive computer to run Turbo Pascal.

The Apple II has an optional Z80 card, but the total price was not for everyone, at least in Europe.

Re:Internals of a Turbo Pascal Compiler by vidarh on Friday September 11, 2015 @09:14AM (#10203456)
I don't remember the 6128 being cheaper than the C128, and the prices I've found online doesn't seem to support that either. I'm sure it might have been the case in some markets, or some configuration (since the C128 could be bought without a hard drive and without a monitor) but it seems far from universal.

Amstrad also sold far less than C128. The whole Amstrad CPC line sold about 3 million vs 5 million C128's. I don't know the breakdown between the Amstrad CPC models, but I'd bet a substantial percentage of that was the 464.

I'm sure the Amstrads were more common for CP/M, though. Of the few people I knew with C128's, most used it as a glorified C64, and nobody used the CP/M mode.

(Incidentally you could also get CP/M support for C64 through a cartridge that housed a Z80...)

Re:Internals of a Turbo Pascal Compiler by Olivier26 on Friday September 11, 2015 @10:44AM (#10203925)
The floppy disc reader was required for CP/M (and a 80 column monitor), so the comparison is with the C128 + 1571 or with the C128D. If in 1985 the C128 had been cheaper than the 6128, I'd have bought the Commodore instead.
Re:Internals of a Turbo Pascal Compiler by krylon on Friday September 11, 2015 @01:46PM (#10205100)
I rememeber the CP/M floppy ... I booted it once or twice but did not know what to do with it, so I ignored it. I usually booted my C128 in C64 mode to play games.
Re:Internals of a Turbo Pascal Compiler by jacobush on Friday September 11, 2015 @06:58AM (#10202995)
All MSX could run CP/M, but this was somehow not much known.
Re:Internals of a Turbo Pascal Compiler by ptaipale on Friday September 11, 2015 @08:50AM (#10203355)
If you had a disk drive, that is. Many if not most MSX machines were typically used as game consoles running games from cartridges.

On CPC6128 the disk drive was standard (and yes, it was that strange 3" variant, not using the 3.5" disks that would later be known as the "3D model of the save icon".)

Re:Internals of a Turbo Pascal Compiler by cataflam on Friday September 11, 2015 @04:15PM (#10205926)
Interesting! Any stories you could share from your time at Borland ?

I started programming with Turbo Pascal pretty much (if one doesn't count a small bit of BASIC before). I also have a vivid memory of Delphi, both programming in Delphi (which was a breeze) and reverse engineering programs written in Delphi (which was a nightmare).