25Fermer27
FarewellLe 26/06/2012 à 23:44
Pas besoin de link/unlk, c'est lent ces instructions. On peut faire plus rapide en asm. [nosmile]

Je fais comme ça en général :
;========================================================
;       2. Create and initialize the stack frame. Musn't use a0/a3  until descriptors are saved
;       CHECKED
;========================================================
        addq.l  #4,sp                                   ; Remove return address, we will use exit()
        move.w  (sp)+,d6                                ; argc
        movea.l (sp),a4                                 ; argv
        lea     -STACK_FRAME_SIZE(sp),sp
        movea.l sp,a6

Avec un header de ce type :
;========================================================
;       CMDLINE
;
;       Type            CMDLINE structure used by pdtlib
;       Initialisation  Initialized by pdtlib::InitCmdline
;       Usage           -/-
;                       A pointer to this structure is passed to functions
;                       of ptdlib which request it.
;                       Never read or modify this structure by hand
;========================================================
CMDLINE			    equ	0

;========================================================
;       FLAGS
;
;       Type            uint32
;       Initialisation  Content of Flags variable, modifiable with config.h.
;       Usage           R/W. Modified by the config file if it exists (system/as).
;                       Modified by the options of the command line passed before
;                       the first source file
;========================================================
FLAGS			    equ	8

;========================================================
;       STDERR
;
;       Type            FILE*
;       Initialisation  pedrom::stderr
;       Usage           R. Given to system functions which need it
;========================================================
STDERR              equ 12

;========================================================
;       PRINTF
;
;       Type            trampoline
;       Initialisation  jmp opcode + pedrom::printf
;       Usage           Executable. Perform a system call
;========================================================
PRINTF              equ 18

;========================================================
;       FPRINTF
;
;       Type            trampoline
;       Initialisation  jmp opcode + pedrom::fprintf
;       Usage           Executable. Perform a system call
;========================================================
FPRINTF             equ 24

...

STACK_FRAME_SIZE	equ 194

Ensuite, ça s'utilise comme ça :
        move.w  d6,ARGC(a6)
        move.w  a4,ARGV(a6)
        move.l  a0,PDTLIB_DESC(a6)                      ; Descriptors
        move.l  a3,SYSLIB_DESC(a6)

...

        lea     StrConfigFileContent(pc),a1
        lea     StrConfigFileSeparators(pc),a2
        lea     NEXT_CHAR(a6),a3
        jsr     COMPARE_STRINGS(a6)

Ca permet de ne pas utiliser de variables en section de code, donc entre autre d'écrire du code PIC, sans relogement, d'exécuter le code en flash et autres joyeusetés. C'est polyvalent et pas plus compliqué que d'utiliser des variables en section de code.