Everything

Software interrupt handler (#pragma interrupt_brk)


Output object code required by software interrupt.

[Function]

-

An interrupt vector is generated.

-

A code for returning with RETB is generated with the target function definition used as a software interrupt handler.

-

The interrupt handler definition is output to the .text section in the same way as normal function definitions. The section name can be changed through #pragma section.
Note that the start address of the interrupt handler should be a location that can be accessed in 16-bit addressing.

-

The specification becomes __near forcibly, regardless of whether __far is specified explicitly or implicitly.
No warning message is output.

[Effect]

-

Interrupt handlers can be written in the C source level.

[Usage]

-

Specify a function name and interrupt specifications through the #pragma directive.

-

Write the #pragma directive before the target function definition.

#pragma interrupt_brk   [(]interrupt-handler-name[(interrupt-specification [,...])][)]

 

The interrupt specifications can include the following.

Item

Format

Description

Register bank specification

bank={RB0|RB1|RB2|RB3}

Register bank for use by the interrupt handler.

Changing the register bank makes it unnecessary to save the values of general registers in the stack.

Note that ES and CS are saved in the stack.

When this setting is omitted, the general registers are saved in the stack.Note

Nested interrupt enable specification

enable={true|false}

true: Enables nested interrupts at the entry to a function; that is, EI is generated at the start of the interrupt handler generated by the compiler.

false: EI is not generated. When enable is omitted, EI is not generated.

Note

For details of register saving during interrupt processing or the stack frame, see "9.1 Function Call Interface".

 

If the same item is written more than once at the same time, a compilation error will occur.

Example

#pragma interrupt_brk func(bank=RB0, bank=RB1)     //Error

 

"#pragma interrupt_brk" generates a vector table. Therefore, if a vector table is defined through Section definition directives in the assembly language (for example, in the startup routine), a linkage error will occur.

Use the .VECTOR directive to write a vector table in the assembly language instead of using the section definition directive.

[Restrictions]

-

If an interrupt handler is called in the same way as a normal function, a compilation error will occur.

-

If __inline, __callt or another #pragma is specified, a compilation error will occur.

-

The parameters and return value of an interrupt handler should be declared as void (e.g., void func (void);).
If the type is not void, a compilation error will occur.

-

If no register is used or no function is called in an interrupt handler, a register bank switching instruction is not output even though register bank switching has been specified by "#pragma interrupt".

[Example]

The output program is the same as that when #pragma interrupt is specified, except that the interrupt source is BRK and RETB is used in the code for returning.

Therefore, the following shows an example when there is no function call in the interrupt handler.

 

[ Input program ]

#pragma interrupt_brk   inter
 
void __near inter ( void ) {
        /*Interrupt processing (only AX, HL, and ES are used)*/
}

 

[ Output program ]

_inter  .vector 0x007E          ;BRK
        .SECTION    .text, TEXT
_inter:
        push    AX              ;Code for saving the general registers to be used in
                                ;the stack
        push    HL
        mov     A, ES
        push    AX
 
        ;Interrupt processing for the BRK instructions
        ;(body of the function. only AX, HL, and ES are used)
 
        pop     AX              ;Code for restoring the general registers to be used
                                ;from the stack
        mov     ES, A
        pop     HL
        pop     AX
        retb