Hacker News new | ask | show | jobs
by bbarn 595 days ago
The last version of TP I used was I think 7? and it added in inline assembler. It was super nice for 14 year old me to learn assembly just enough to do the things TP couldn't do (like control a mouse on DOS). It was my gateway to a life of software development.
2 comments

I used that a bit (absolutely great) but that was near the end of my TP career, for the most part I wrote library subroutines in assembly.

For instance, the 8086 had a REP MOVS instruction that copies a block of bytes, the TP standard library used that for the copy data function. 80186 added REP MOVSW which would move 2 bytes at a time and be about two times faster on my 80286 machine. I had several replacements for library subroutines which took advantage of 80286 instructions to get much better performance.

Inline Assembly was already on Turbo Pascal 4.
Wikipedia claims that TP 6 added inline assembly, I looked at the TP 4 manual and found you can write

  procedure FillWord(var Dest,Count,Data: word);
  begin
  inline(
     $C4/$BE/Dest/       { LES DI,Dest[BP] }
     $8B/$8E/Count/      { MOV CX,Count[BP] }
     $8B/$86/Data/       { MOV AX,Data[BP] }
     $FC/                { CLD }
     $F3/$AB);           { REP STOSW }
  end;
Note that {} is a comment so this is raw machine code expressed in bytes where you can substitute in addresses or other values. Not as cool as what came later.
It is about having the feature available in some form.
Well, prior to 7 I had the yellow one. 6? and no books or manuals, just some snippets from a Peter Norton book I got from the library enough times that the librarian asked me to not check it out for two weeks once. I got 7 for christmas and it came with the manual and maybe I mis-remember the difference between "added" and "I learned about it then"