|
|||||||||||||
|
Technical Support On-Line Manuals C166 User's Guide |
C166 User's GuideInterrupt FunctionsThe C166 Compiler allows you to write interrupt function in the C language which eliminates the need for assembly language interrupt routine. For example: void funcname (void) interrupt vector <[>using bankname<]> Where
The interrupt attribute requires an interrupt vector argument. You may specify an arbitrary interrupt name (whose trap number is specified by the linker INTNO directive), a trap number, or both for the vector. For example:
Where
The interrupt attribute affects the object code of the function as follows:
The following sample program shows how to use the interrupt attribute and displays the code sequences detailing the prologue and epilogue for this example function. A using attribute is also specified in the example. The generated code switches register banks using the CP register. For example:
stmt level source
1 extern bit alarm;
2 int alarm_count;
3 extern void alfunc (bit b0);
4
5 void falarm (void) interrupt 0x21 using f_regs {
6 1 alarm_count++;
7 1 alfunc (alarm = 1);
8 1 }
ASSEMBLY LISTING OF GENERATED OBJECT CODE
; FUNCTION falarm (BEGIN RMASK = @0x7FFF)
; SOURCE LINE # 5
0000 C6030300 SCXT DPP3,#03H
0004 CC00 NOP
0006 F6F00000 R MOV f_regs,R0
000A C60800C0 R SCXT CP,#f_regs
000E CC00 NOP
0010 EC00 PUSH DPP0
0012 C6871000 SCXT MDC,#010H
0016 EC06 PUSH MDH
0018 EC07 PUSH MDL
; SOURCE LINE # 6
001A 248F0000 R SUB alarm_count,ONES
; SOURCE LINE # 7
001E 0FFF BSET R15.0
0020 4AFF0000 E BMOV alarm,R15.0
0024 CA000000 E CALLA cc_UC,alfunc
; SOURCE LINE # 8
0028 FC07 POP MDL
002A FC06 POP MDH
002C FC87 POP MDC
002E FC00 POP DPP0
0030 FC08 POP CP
0032 FC03 POP DPP3
0034 FB88 RETI
; FUNCTION falarm (END RMASK = @0x7FFF)
Note
Note | ||||||||||||
|
|||||||||||||