Zur Übersicht - INFO - Neueste 50 Beiträge - Neuer Beitrag - Suchen - FAQ - Zum CC1-Forum - Zum CC-Pro-Forum

Re: call Kategorie: Programmierung (von mafoe's ghost - 26.07.2001 21:44)
Als Antwort auf Re: call von Eric - 25.07.2001 22:21

note:
 - your C/assembly code must be linked to 0003:0000
 - do not declare any variables in on-chip RAM
 - do not link any startup asm-file of Tasking to your project
 - your program must not have an own C-stack (ignore the linker warning)
 - just use the registers, but not R0!

 this example should run:

 #define REG164CI_NOOTP
 #define REG164CI_NOPEC
 #define REG164CI_NOCAN /* ! */
 #include "reg164ci.h"

 void led_on ( void );
 void led_off ( void );

 //--------------------
 void led_on ( void )
 //--------------------
 {
 P1L  = 1;
 }


 Inside the VM, something like this happens (I"m not really sure anymore, and maybe the
 comments below are not correct):


 //--------------------------
 void vmop_syscall ( void )
 //--------------------------
 {
 WORD segment, offset;

 offset = (WORD) vmstack_pop_int();
 segment = (WORD) vmstack_pop_int();

 system_syscall((BYTE)segment,offset);
 }


 //------------------------------------------
 void system_syscall ( BYTE seg, WORD off )
 //------------------------------------------
 {
 // calling a system routine at seg:off, which must return by RETS;
 // the register context is safed an restored,
 // R0 is used as CUSTACK pointer,

 sysjmp_struct.seg = seg;
 sysjmp_struct.off = off;

 #pragma asm

 RBANK1REGDEF R0-R15
 PUSH CP
 MOV RBANK1, R0
 MOV CP, #RBANK1
 CALLS SEG _sysjmp_struct, _sysjmp_struct
 POP CP

 #pragma endasm

 /*
 oldversion without own register bank:

 #pragma asm
 CALLS SEG _sysjmp_struct, _sysjmp_struct
 #pragma endasm
 */
 }