Procedure at Absolute Address

Pascal Compiler for 8051 Microcontrollers

You can force placing a procedure at absolute address with the absolute directive. This way you can also reserve some bytes at fixed addresses in code segment. There is no need to call procedures at absolute addresses, linker will place them where they should be - of course, you can call them if you need to. See some examples below:

Program AbsoluteProcedures;

{ Usless program just to demonstrate procedures/functions at absolute addersses }


{ This procedure will be placed at code address $1000 and will occupy just one byte (RET) }

Procedure MustBeFixed absolute $1000;
begin
end;


{ This procedure will also occupy just one byte at code address $0045 }

Procedure JustOneByte absolute $45; Assembler;
Asm
  DB    $00
{$NoReturn }    { Don't generate RET instruction }
end;


{ This procedure will be placed at code address $F000 }

Procedure Restart absolute $F000;
begin
  Asm
    LJMP   $0000
  end;
end;

begin
// no need to call procedures at absolute addresses, linker will just put them where they should be
end.
Ccompiled code:
; Turbo51 version 0.1.3.10, Copyright 2000 - 2011 Igor Funa

$REGISTERBANK (0)

_CODE         SEGMENT  CODE

              EXTRN    IDATA (StackStart)

; Program AbsoluteProcedures;
; 
; { Usless program just to demonstrate procedures/functions at absolute addersses }
; 
; 
; { This procedure will be placed at code address $1000 and will occupy just one byte (RET) }
; 
; Procedure MustBeFixed absolute $1000;


CSEG AT $1000

USING 0

MustBeFixed:
; begin
; end;
              RET

; 
; 
; { This procedure will also occupy just one byte at code address $0045 }
; 
; Procedure JustOneByte absolute $45; Assembler;


CSEG AT $0045

JustOneByte:
; Asm
;   DB    $00
              DB        0

; {$NoReturn }    { Don't generate RET instruction }
; end;
; 
; 
; { This procedure will be placed at code address $F000 }
; 
; Procedure Restart absolute $F000;


CSEG AT $F000

Restart:
; begin
;   Asm
;     LJMP   $0000
              LJMP      0

;   end;
; end;


CSEG AT $0000

              AJMP     AbsoluteProcedures


RSEG _CODE

AbsoluteProcedures:
; 
; begin
              MOV       SP, #StackStart-1

; // no need to call procedures at absolute addresses, linker will just put them where they should be
; end.
L_0006:
              SJMP      L_0006

RSEG _CONST


              END

Copyright © 2024 Igor Funa. All Rights Reserved. Terms, Conditions and Privacy policy