
	EXPORT	|swi|
	EXPORT	|swi_fast|
	EXPORT	|swi_fast_r0|
	EXPORT	|swi_fast_r1|
	EXPORT	|swi_fast_r2|
	EXPORT	|swi_error|
	EXPORT	|swi_error_fast|
	EXPORT	|swi_get_error|

	AREA	|C$$code|, CODE
|swi_fast|
|swi_fast_r0|
        add     a4, a4, #0xef000000
        adr     ip, swi_code_fast
        str     a4, [ip]
|swi_code_fast|
        swi     256
        mov     pc, lr

|swi_fast_r1|
        add     a4, a4, #0xef000000
        adr     ip, swi_code_fast_r1
        str     a4, [ip]
|swi_code_fast_r1|
        swi     256
        mov     a1, a2
        mov     pc, lr
        
|swi_fast_r2|
        add     a4, a4, #0xef000000
        adr     ip, swi_code_fast_r2
        str     a4, [ip]
|swi_code_fast_r2|
        swi     256
        mov     a1, a2
        mov     pc, lr

|swi_error_fast|
        add     a4, a4, #0xef000000
        add     a4, a4, #0x00020000
        adr     ip, swi_error_code_fast
        str     a4, [ip]
|swi_error_code_fast|
        swi     256
        movvc   r0, #0
        movvc   pc, lr
        adr     r2, err_block
        str     r0, [r2]
        mov     r0, #1
        mov     pc, lr

|swi|
        mov     ip, a2
        add     a1, a1, #0xef000000
        adr     a3, swi_code
        str     a1, [a3]
        adr     a3, store_regs
        stmia   a3, {v1-v6}
        ldmia   ip, {r0-r9}
|swi_code|
        swi     256
        stmia   ip, {r0-r9}
        adr     ip, store_regs
        ldmia   ip, {v1-v6}
        mov     pc, lr

|swi_error|
        mov     ip, a2
        add     a1, a1, #0xef000000
        add     a1, a1, #0x00020000
        adr     a3, swi_err_code
        str     a1, [a3]
        adr     a3, store_regs
        stmia   a3, {v1-v6}
        ldmia   ip, {r0-r9}
|swi_err_code|
        swi     256
        stmia   ip, {r0-r9}
        adr     ip, store_regs
        movvc   r0, #0
        movvc   pc, lr
        adr     r2, err_block
        str     r0, [r2]
        mov     r0, #1
        ldmia   ip, {v1-v6}
        mov     pc, lr

|swi_get_error|
        adr     r1, err_block
        ldr     r1, [r1]
        ldr     r2, [r1]
        str     r2, [r0]
        add     r0, r1, #4
        mov     pc, lr

|err_block|
        DCD     0
|store_regs|
        DCD     0
        DCD     0
        DCD     0
        DCD     0
        DCD     0
        DCD     0
 END
