[Oberon] Inline procedures

Chris Burrows chris at cfbsoftware.com
Sun Jul 6 13:07:39 CEST 2014


> -----Original Message-----
> From: oberon at moravcik.info [mailto:oberon at moravcik.info]
> Sent: Saturday, 5 July 2014 9:21 PM
> To: oberon at lists.inf.ethz.ch
> Subject: Re: [Oberon] Why macros were not implemented in oberon language?
> 
> >From all of the ETH oberon documents I have read so far I cannot remember
> there was a mention of some procedure inlining in oberon compiler.
> Therefore I think there is neither manual nor automatic procedure inlining
> built in oberon compiler.

Some of the Oberon compilers for Intel have implemented procedure inlining
as an Oberon extension. I have only seen the documentation describing its
use with inline assembler routines. However, I just checked ETH PlugIn
Oberon for WindowsTM / Win32 2.5 (7.2.2009) and it works well for simple
normal procedures at least as well. I recall reading somewhere that the
limit is a 256-byte procedure. 

The syntax for an inline procedure is a minus sign in front of the procedure
name e.g.

PROCEDURE -Double(VAR i: INTEGER);
BEGIN
  i := i * 2
END Double;  

When this procedure is 'called' e.g.

PROCEDURE Test*(VAR i: INTEGER);
BEGIN
  Double(i);
END Test;

The resulting disassembly listing is:

PROCEDURE Test
0019H: 55                                  PUSH    EBP
001AH: 8B EC                               MOV     EBP,ESP
001CH: 8B 5D 08                            MOV     EBX,8[EBP]
001FH: 66|8B 1B                            MOV     BX,0[EBX]
0022H: 66|D1 E3                            SHL/SAL BX,1
0025H: 8B 55 08                            MOV     EDX,8[EBP]
0028H: 66|89 1A                            MOV     0[EDX],BX
002BH: 8B E5                               MOV     ESP,EBP
002DH: 5D                                  POP     EBP
002EH: C2 04 00                            RET     4

----------------------------------------------------------------

If Double is changed to a normal procedure, the resulting disassembly
listing is:

PROCEDURE Test
0031H: 55                                  PUSH    EBP
0032H: 8B EC                               MOV     EBP,ESP
0034H: 8B 5D 08                            MOV     EBX,8[EBP]
0037H: 53                                  PUSH    EBX
0038H: E8 DC FF FF FF                      CALL    -36  (00000019H)
003DH: 8B E5                               MOV     ESP,EBP
003FH: 5D                                  POP     EBP
0040H: C2 04 00                            RET     4

----------------------------------------------------------------

Regards,
Chris 

Chris Burrows
CFB Software
http://www.astrobe.com






More information about the Oberon mailing list