Delphi 7 and Windows 7

As you can see in this blog, I recently started programming again in Pascal, eh, Delphi Object Pascal. The version I use (since it is the last version close to traditional Windows programming) is version 7. The best version to use  is the version that floats around as Delphi 7.2 Second Edition (search a torrent site) which is a trimmed and bugfixed small package.

Of course this package runs fine on Windows XP. But how on Windows 7?

This is how I got it to work.

Installation

  • Make sure you run this as administrator,  you will need the privs.
  • Run the Delphi installer. Use defaults for the file locations, ignore the incompability warnings.
  • Dont start Delphi 7 as it will complain when starting a project  about unable to rename delphi32.$$$ to .dro in the /program files/delphi directories . And something about debug options requiring a change.
    So there are access problems, as to be expected. Windows 7 is a lot more robust, so directories are better protected.

Solve the access problems

  1. Run this as administrator.
  2. Open the properties on c:/program files/delphixxx directory.
  3.  On the first tab Clear the Read-only attribute and press Apply for all files including subdirectory.
  4.  Open the security tab
  5. Give users (and admins if necessary) full access to  c:/program files/delphixxx directory   

Now Delphi can be used to write programs again.

Edit August 2010: Windows 7 64 bit is also not a problem. Delphi is installed in C:\PROGRAM Files (X86)

Fix Winhelp

Help does not function, a windows pops up telling “winhelp is not supported anymore on this Windows version, go to microsoft.com for a fix” .
The fix for Vista is already made, the Windows 7  fix will be here Real Soon Now. 

Edit january 2010:  Search ‘ Windows Help program (WinHlp32.exe) for Windows 7′ on microsoft.com, currently here ,  install that and you do not need the next trick.

So this will be fixed in the future, but for now it can be solved as follows.

  1. Remove the Read-only attribute from winhlp32.exe and winhelp32.exe in c:/windows
  2. Set  ownership of the winhlp32.exe file (properties, security tap, advanced)  to administrators (and remember, you are logged on as admin!)
  3.  change the security to full control
  4.  rename winhlp32.exe to something like winhlp32old.exe just in case
  5. copy from a Windows  XP system the files winhlp32.exe and winhelp.exe in c:\windows

Now help functions also.

Delphi and electronics

A PC is such a dull device. With my other computers it is so much fun to control other devices, especially the 6502 SBC’s are great for that.

What would be great is to let the PC talk to a SBC, with something faster than a serial port. Or have the PC control the SBC via that serial port with a program much more intelligent that hyperterminal.

So I have been looking lately at ways to get something done with that.
Pascal as programming language, Delphi 7 is what I have.  Good books, lots of information on the internet very stable and a functional very rich version. FreePascal and Lazarus are fine too, I have made console programs with FreePascal. But I am a bit too unexperienced with windows programs to fight with Lazarus, still a beta.

First program is TEST LPT. Gives access to all pins of the parallel interface,  good for testing. I learned a lot, I/O port access, all the visible things, event driven programming, object orientation, make a help file, add a menu, add an installer. All the essential things to create a professional program. I know how to program for some decades now, I have now learned to do that in Delphi’s rich visual environment.

Here is the page I have devoted to parallel port access.

Emulith, a Lilith emulator

Emulith is a functional emulation of the ETH Lilith Modula2 computer. Its is programmed by Jos Dreesen, owner of one of the few remaining operational Lilith’s.

The ETH, later DISER, Lilith is a 16 bit workstation developed at the ETH by a team under lead of Prof. N. Wirth between ca. 1979 and 1982. Main reasons to fame were the fact that the hardware was developed to fit the Modula2 language requirements and its high resolution display. It is also one of the earliest personal computers to have a mouse as a standard input device.

The Lilith emulator Emulith is a functional equivalent of the actual Lilith hardware, uses unchanged microcode and disk images of the real machine and gives a reasonable good idea of what the real Lilith looks like. High resolution display, cartridge disk, mouse and keyboard are all part of the emulation. Not covered (yet ?) are RS232, Ethernet and printer interface.

The following hardware and software is needed to run Emulith :
- A reasonable fast PC ( > 1 GHz) running Linux. Ubuntu is fine, even the Live cD.
- Minimal screen resolution of 1280×1024 ( The Lilith itself has a 704×928 resolution.
- Some willingness to read documentation : the Lilith is a 25 year old system and its usage is not comparable with current operating systems. A Lilith manual is part of the documentation.

The performance of Emulith on a 1 GHz machine is comparable with the real hardware, which used a 7 Mhz main clock. Any operation involving the disk is considerably faster on the emulator.

Download the emulator ftp://jdreesen.dyndns.org/ftp/emulith/emulith.tgz .
More on Lilith can be read here.

L65, a structured language instead of an assembler

Inspired by the latest work of Niklaus Wirth, his PICL language. I am thinking of designing a new language for my 6502 based machines.

Programming the small 6502 machines, like the KIM-1, Micro-KIM or the Apple 1 replica’s for applications suitable for this kind of computer, like I/O contriol and not the generic workstation personal productivity, is either done in higly inefficient Basic or Pascal, with lots of unnecessary overhead or via assembler.

The issue here is, that high level langauge are too far removed from the actual CPU. And assembler is the worst kind of programming language thinkable (yes even worse than C).

So the PICL report made me think again on a programming language, based on the structured concepts in the Wirth tradition but close enough to the hardware to replace the assembler. In fact, I would like a language just as powerful as assembler but without the tedious instruction by instruction programming, no type checking, no data hiding, no structure. But the langauge should be able to precisely control the resulting code and data placement. Resulting code must also be ROMmable, very compact, requiring no runtime and the language itself will not put demands on hardware like a keyboard or display.
Buidling libraries (modules) will do for that.

At the moment I am writing a language report and thinking of code generation and how to add modular programming concepts.

What I can think of already is:

  • syntax like Pascal
    - IF conditon THEN .. ELSE
    - WHILE .. DO
    - CASE (jumptable or if then else code)
  • operators as usual, not the cryptic PICL choices
  • basic data types byte (0.255), word/address (0.65536), char (ANSII, ordinal values 0.255), string (lengthmax 255 with byte preceeding characters)
  • records and arrays
  • no subranges
  • sets (byte)
  • no recursion
  • functions and procedures
  • value and variable parameters, passing via A, X, Y register or zero page pointer
  • local variables, stored at location in zero page or data segments, freedom in location
  • access to I/O registers (memory based, bit based etc)
  • interrupt handlers for NMI and IRQ and RESET
  • type casting
  • I am not sure about:
    - integers
    - longwords (24 or 32 bit)
    - pointers
    - inline assembler code (handy, but not in the spirit of the language)

Code generation is something to think about. It is tempting to generate assembler code and leave binary code generation to an assembler. That makes it possible to ‘include’ assembly code and have ‘inline’ assembly code. Anyway, no recursion means no demands on stacks for variables, but static assignment only.

Of course the implementation of L65 will be in (Free)Pascal. A cross compiler, console based in my first attempts. And in the Wirth tradition, a hand-crafted recursive descent down parser.  A small language, so a small compiler also. And readable, I really don’t like what Wirth has done in PICL with expressions.

Something to think about during the vacation in Jordan! Lets see how the desert inspires language design.

Ah, and read this: Wirth on the current state of Informatics

The school of Niklaus Wirth: The Art of Simplicity

School of Wirth

Got myself an excellent book on the Art of Simplicity. Niklaus Wirth designed programming langauages like Pascal and sequels like Modula-2 and Oberon.  His style and dedication to simplicity in a clear writing and presentation style made a great impression on me.

This book gives unique insites in what has happened and is still happening in the school of Niklaus Wirth. Excellent book!

From the book’s advertisement: 

Niklaus Wirth is one of the great pioneers of computer technology and winner of the ACM’s A.M. Turing Award, the most prestigious award in computer science. he has made substantial contributions to the development of programming languages, compiler construction, programming methodology, and hardware design. While working at ERH Zurich, he developed the languages Pascal and Modula-2. He also designed an early high performance workstation, the Personal Computer Lilith, and most recently the language and operating system Oberon.
While Wirth has often been praised for his excellent work as a language designer and engineer, he is also an outstanding educator, something for which he is not as well known. This book brings together prominent computer scientists to describe Wirth’s contributions to education. With the exception of some of his colleagues such as Professors Dijkstra, Hoare, and Rechenberg, all of the contributors to this book are students of Wirth. The essays provide a wide range of contemporary views on modern programming practice and also illuminate the one persistent and pervasive quality found in all his work: his unequivocal demand for simple solutions. The authors and editors hope to pass on their enthusiasm for simple engineering solutions along with their feeling for a man to whom they are all so indebted.

Pascal-M, software archeology

In 1978, via the KIM-1 user club, a Pascal compiler written by Mark Rustad, based on the P2 compiler, with a 6502 interpreter by G.J. v.d. Grinten, was given to me.
It was a complete package, on a KIM-1 cassette tape, and with rudimentary documentation. Quickly Micro-Ade, the invaluable assembler/editor, was enhanced to edit Pascal program source.

Pascal-M

The idea was great, the result was terrible: load Micro-Ade, edit a Pascal program, load the interpreter (4K), compiler (19K), compile the program, load the object, and run the program. Of course the compiler would find errors and then the editing and compiling cycle on a cassette based system could start again.
I did this several times and then gave up. No way a Pascal compiler was a viable option on a dual cassette player based KIM-1. The lack of a file system in the compiler even made it worse.
At that moment I was finishing my Masters at the VU university in Amsterdam, in Computer Science, and was introduced to Pascal. compilers, the VU Pascal compiler and that was very exciting. My good friend Anton Muller managed to get the sources of the compiler (in Pascal) and the interpreter (assembler), all on paper photocopies and it was exciting to study those.
Alas, I could not do anything useful with all this,  and so I stored paper and cassette tapes away.

In 1983 I joined Digital Equipment as system programmer and had access to first the PDP-11 RSX-11M Pascal compiler and a bit later the first versions of VAX/VMS Pascal. And now things were possible that made me return to the Pascal-M compiler: cross-compile on VMS and run on the KIM-1! I had sources, so I spent all my lunch hours typing in the sources, compiling, testing, all possible on those excellent Digital machines! /br> In fact, it took me two years of lunch breaks to have the first working version of the PASCAL-M compiler on VMS, an interpreter/debugger in Pascal on VMS and an interpreter on the KIM-1. And with some VMS tools I could compile on VMS and load the program from cassette on the KIM-1. This is version 1.x of the PASCAL-M compiler, still mostly original as received form Mark Rustad en Willem v d Grinten, but completely embedded in the VMS - KIM-1 tool-bench.
Now the plans were made to enhance the KIM-1 with floppy disk drives and the compiler with a file system, already in place in the VMS version  compiler/interpreter.
Nothing like that happened though. CP/M (on the Spectravideo SVI-738) and and Turbo Pascal came along and I left the PASCAL-M compiler, together with all KIM-1 related work, alone to collect dust. Luckily most source files, living on the VAX/VMS system, made it to floppies on CP/M and later survived many PC changes. All paper of course was of course kept, I seldom throw something away!
In 2003 Ruud Baltissen (HCC Commodore GG) asked on Usenet about Pascal and 6502 and I remembered the PASCAL-M compiler. So I digged up the paper, and loaded the sources in what I had available then: Borland Pascal 7. And found out I could get the package working on that platform! Still fun. I was too bsuy to fire up the KIM-1. It still runs, but I have my doubts about the reliability of the memory IC’s. So it is not tested again on the real hardware.
That will change, as the micro-KIM is coming along! The perfect excuse to finally get this package working again and make it better.
Now here you will find the version 1 package. All is here to get a working PASCAL-M compiler/interpreter again. Either by cross-compiling (it is Borland Pascal syntax now, so FreePascal will compile on many platforms, MS-DOS executables are included). 6502 assembler sources are TASM (Squeek Valley) assembler sources. Or on the 6502 itself, the compiler can compile on the 6502, it can even compile itself on a 6502 (with enough memory!). 
The compiler is still very close to the P2 compiler, the original mainframe source is available in scanned format.

See here for sources, scanned original PASCAL-M compiler, documentation, tools , all what is needed to get it running now on a KIM-1 with extra memory!
For the micro-KIM project I will try to get all my new ideas implemented for a version 2. And make the cross-compile part less retro than MS-DOS ;)