1 / 4

#include <hidef.h> /* defines and macros */

Programme principal en C. #include <hidef.h> /* defines and macros */ #include <mc9s12c32.h> /* derivative information */ #include "main_asm.h" /* interface to the assembly module */ #pragma LINK_INFO DERIVATIVE "mc9s12c32" void main(void) { int m=1,p=2,q=3,r ;

dash
Download Presentation

#include <hidef.h> /* defines and macros */

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Programme principal en C #include <hidef.h> /* defines and macros */ #include <mc9s12c32.h> /* derivative information */ #include "main_asm.h" /* interface to the assembly module */ #pragma LINK_INFO DERIVATIVE "mc9s12c32" void main(void) { int m=1,p=2,q=3,r ; EnableInterrupts; r = _add(m,p,q); /* Appel d'une fonction assembleur */ for( ; ; ) {} /* pour toujours */ }

  2. Prototypage de la fonction add #ifndef _MAIN_ASM_H #define _MAIN_ASM_H #ifdef __cplusplus extern "C" { /* our assembly functions have C calling convention */ #endif int _add(int,int,int); /* interface to my assembly main function */ #ifdef __cplusplus } #endif #endif /* _MAIN_ASM_H */

  3. Programme principal en assembleur LEAS -8,SP ; trou sur la pile LDAB #1 CLRA STD 2,SP ; sauvegarde du chiffre 1 ASLB STD 0,SP ; sauvegarde du chiffre 2 INCB STD 6,SP ; sauvegarde du chiffre 3 CLI ; interruption en marche LDX 2,SP PSHX ; premier paramètre sur la pile LDY 2,SP PSHY ; second paramètre sur la pile JSR _add ; appel de la fonction add LEAS 4,SP ; remise en place de la pile STD 4,SP ; sauvegarde de la réponse BRA *+0 ; ; fin du programme (for ever)

  4. Programme add en assembleur ;************************************************************** ;* Programme pour additionner 3 entiers et retourner la * ;* réponse dans D * ;************************************************************** XDEF _add ; variable/data section MY_EXTENDED_RAM: SECTION vara ds.w 1 varb ds.w 1 varc ds.w 1 ; code section MyCode: SECTION _add: CLI ; interruption en marche std varc ; sauvegarde des 3 entiers tfr sp,x ldd 4,x std vara ldd 2,x std varb ldd varc ; addition des trois entiers addd varb addd vara ; réponse finale dans D RTS ; retour à l'appelant

More Related