ݺߣ

ݺߣShare a Scribd company logo
ARM SWI                                 Stanley.Ho

 ADS  SVC ʽYҪ(1)ahandle.s(2)chandle.c(3)main.c(4)svc.h
ҪǽBʹ SVC(SWI)Ĺ܁ܛwД

main.c б
ʽf:
       Install_Handler() : ׃ԭ vector SWI 0x08 ă,׃҂Ҫ Branch routine 
       main() :  Install_Handler() SWI(0),SWI(1),SWI(2),SWI(3)
#include 
#include svc.h

unsigned *svc_vec = (unsigned *)0x08;

extern void SVC_Handler(void);

unsigned Install_Handler( unsigned routine, unsigned *vector ){
   unsigned vec, old_vec;

    vec = (routine - (unsigned)vector - 8) >> 2; //routinevectorďֵ
/*
Branch instructions contain a signed 2s complement 24 bit offset. This is shifted left
two bits, sign extended to 32 bits, and added to the PC. The instruction can therefore
specify a branch of +
Arm Swi (1)
Arm Swi (1)
Arm Swi (1)

More Related Content

Arm Swi (1)

  • 1. ARM SWI Stanley.Ho ADS SVC ʽYҪ(1)ahandle.s(2)chandle.c(3)main.c(4)svc.h ҪǽBʹ SVC(SWI)Ĺ܁ܛwД main.c б ʽf: Install_Handler() : ׃ԭ vector SWI 0x08 ă,׃҂Ҫ Branch routine main() : Install_Handler() SWI(0),SWI(1),SWI(2),SWI(3) #include #include svc.h unsigned *svc_vec = (unsigned *)0x08; extern void SVC_Handler(void); unsigned Install_Handler( unsigned routine, unsigned *vector ){ unsigned vec, old_vec; vec = (routine - (unsigned)vector - 8) >> 2; //routinevectorďֵ /* Branch instructions contain a signed 2s complement 24 bit offset. This is shifted left two bits, sign extended to 32 bits, and added to the PC. The instruction can therefore specify a branch of +