[fpc-devel] Re: Episode 4. Addressing and it's limits Part Two

Mark Morgan Lloyd markMLl.fpc-devel at telemetry.co.uk
Thu Feb 9 11:49:32 CET 2012


steve smithers wrote:
>> rvmartin2 at ntlworld.com wrote on Wed, 8 Feb 2012 14:16:50 +0000 (GMT)
> 
>>> The implementation of calling conventions is up to the code generator as 
>>> well. You can invent your own conventions, and map them to any 
>>> predefined one. As a starting point it's sufficient to support only one 
>>> calling convention, the one for system calls. More conventions for 
>>> calling other external libraries may be required, depending on the 
>>> target OS conventions.
>> Where can I find details of the input to the back-end?
>> I'd like to have a crack at generating assembler code for VM/SP. 
>  
> Maybe I've misunderstood the logic here, but it's my understanding
> that the back-end produces assembler statements to produce executable
> code for the processor.  So if I want to move something from field a
> to field b say, or add two numbers together, the backend generated the
> MVC and it's related code or the Add instruction, Handles registers
> and addressability and stuff.  Anyway, whatever this stuff is called
> it lives in the COMPILER/VMSP (apologies to you case-sensitive types)
> sub-directory.
> 
> The bit that provides code for VM/SP as opposed to say MVS, is the RTL,
> so if I want to open a file, there is a routine in the RTL called OpenFile
> (or whatever) that issues the VM code for open.  This lives in System.pp
> or Sysfile.pp or whatever it's called in the RTL/VMSP sub-directory
> 
> Now, in order for the compiler to function it needs access to a certain
> level of base functionality in the VM/SP RTL.  Things like Allocate / 
> Deallocate memory, Open and Close a file, Read and Write from and to a
> file.  Create and Delete a file etc.  These may, or may not, be written
> totally or partially in assembler.

I've added example FPC output at 
http://wiki.lazarus.freepascal.org/ZSeries#Digression:_example_FPC_output 
which might be useful to the current discussion. I've used David Zhang's 
MIPS compiler to do this, since the register etc. model is probably 
closer to zSeries than any of the other v2 compilers.

Note that to get this level of detail the compiler has to be built with 
-dEXTDEBUG in order to enable the -an option, despite the fact that this 
always appears in fpc's -h output. If it were my choice I'd make that 
bit of help output conditional.
-- 
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]



More information about the fpc-devel mailing list