Recent

Author Topic: Inline code does not compile?  (Read 412 times)

Weiss

  • New Member
  • *
  • Posts: 10
Inline code does not compile?
« on: July 04, 2022, 09:52:48 am »
I am studying by "Turbo Pascal 6 Complete Reference Guide". The part where it describes using inline code does not compile. Sometimes  the  "inline" identifier is not recognized.  Most of the time Compiler sees "(" where it wants ":". I tried using compiler directives {$mode TP} and {$INLINE+} or {$INLINE ON} but syntax error is still there.

What is the trick here? How do we use inline code in FPC, that is different from what was in TP?

MarkMLl

  • Hero Member
  • *****
  • Posts: 4730
Re: Inline code does not compile?
« Reply #1 on: July 04, 2022, 10:55:21 am »
SHOW US YOUR CODE!!!!!!!!!!!!

If it's a small program it's OK to put it inline with your message but you will need to mark it with the code tag. Otherwise add it as an attachment. In either case please make sure that it's a complete program, i.e. something that other people can fairly be expected to compile without spending lots of time working out what you're trying to do.

Apart from that, what version of FPC etc. are you using?

Note also that in some cases the FPC compiler will compile something without obeying an inline directive (due to code complexity etc.); you will get a warning if this happens.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 10170
  • FPC developer.
Re: Inline code does not compile?
« Reply #2 on: July 04, 2022, 11:23:47 am »
The inline command (with bytes to inline assembler) of Turbo Pascal is not supported yet. (though I can vaguely recall Nikolay adding it to trunk).

But even then it is  16-bits dos only, and I'm not sure you want that, so in practice you will need to find other solutions anyway.

Examples would help, and also what your goal is (really dos?  16-bit or 32-bit ?)
« Last Edit: July 04, 2022, 11:37:44 am by marcov »

Zvoni

  • Hero Member
  • *****
  • Posts: 1269
Re: Inline code does not compile?
« Reply #3 on: July 04, 2022, 11:30:20 am »
Apart from that, what version of FPC etc. are you using?
LOL. What did we discuss in that other thread of yours?
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

440bx

  • Hero Member
  • *****
  • Posts: 2933
Re: Inline code does not compile?
« Reply #4 on: July 04, 2022, 11:31:13 am »
I am studying by "Turbo Pascal 6 Complete Reference Guide". The part where it describes using inline code does not compile. Sometimes  the  "inline" identifier is not recognized. 
The old TP inline thing where the programmer had to hand code the bytes for opcodes and data is really extremely undesirable.

With FPC, you can code that inline stuff in assembler.  I remember that, at least most of the time, programmers were courteous enough to put the equivalent assembly statements next to the hand coded bytes as a comment thus, making the "port" to real assembler fairly straightforward.

My recommendation is: stay as far away from that old inline stuff and, if needed, convert it to assembler.

FPC v3.0.4 and Lazarus 1.8.2 on Windows 7 64bit.

PascalDragon

  • Hero Member
  • *****
  • Posts: 4290
  • Compiler Developer
Re: Inline code does not compile?
« Reply #5 on: July 04, 2022, 01:20:18 pm »
The inline command (with bytes to inline assembler) of Turbo Pascal is not supported yet. (though I can vaguely recall Nikolay adding it to trunk).

Trunk supports the Inline statement in mode TP on any platform (and it was added by Yuriy, not Nikolay ;) ).

Though for new code I definitely suggest to use an asmend-block as one doesn't need to fiddle around with hex dumps then.

Weiss

  • New Member
  • *
  • Posts: 10
Re: Inline code does not compile?
« Reply #6 on: July 05, 2022, 01:08:10 pm »
Thank you for all replies, fellas.

seems like a great crowd here.. Anyways, I am re-writing inline snippets in assembler now. Like 440bx suspected, there are asm equivalents commented on each line.

There is no point posting the code, I was typing examples from that book, interrupts etc.

By the way, assembler is fun in its own right.

MarkMLl

  • Hero Member
  • *****
  • Posts: 4730
Re: Inline code does not compile?
« Reply #7 on: July 05, 2022, 02:19:58 pm »
seems like a great crowd here.. Anyways, I am re-writing inline snippets in assembler now. Like 440bx suspected, there are asm equivalents commented on each line.

My apologies that I misinterpreted your initial posting: since you didn't specify assembler I assumed you'd found some odd case associated with the inline modifier which can be applied to functions etc.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

PascalDragon

  • Hero Member
  • *****
  • Posts: 4290
  • Compiler Developer
Re: Inline code does not compile?
« Reply #8 on: July 05, 2022, 02:25:20 pm »
seems like a great crowd here.. Anyways, I am re-writing inline snippets in assembler now. Like 440bx suspected, there are asm equivalents commented on each line.

My apologies that I misinterpreted your initial posting: since you didn't specify assembler I assumed you'd found some odd case associated with the inline modifier which can be applied to functions etc.

Weiss mentioned Turbo Pascal 6 which does not know the inline modifier, so it was clear without him mentioning assembly code. ;)

 

TinyPortal © 2005-2018