[444] | 1 | ############################################################################## |
---|
| 2 | # setjmp.S -- CR16 setjmp routine # |
---|
| 3 | # # |
---|
| 4 | # Copyright (c) 2004 National Semiconductor Corporation # |
---|
| 5 | # # |
---|
| 6 | # The authors hereby grant permission to use, copy, modify, distribute, # |
---|
| 7 | # and license this software and its documentation for any purpose, provided # |
---|
| 8 | # that existing copyright notices are retained in all copies and that this # |
---|
| 9 | # notice is included verbatim in any distributions. No written agreement, # |
---|
| 10 | # license, or royalty fee is required for any of the authorized uses. # |
---|
| 11 | # Modifications to this software may be copyrighted by their authors # |
---|
| 12 | # and need not follow the licensing terms described here, provided that # |
---|
| 13 | # the new terms are clearly indicated on the first page of each file where # |
---|
| 14 | # they apply. # |
---|
| 15 | # # |
---|
| 16 | # C library -- setjmp, longjmp # |
---|
| 17 | # longjmp(a,v) # |
---|
| 18 | # will generate a "return(v)" # |
---|
| 19 | # from the last call to # |
---|
| 20 | # setjmp(a) # |
---|
| 21 | # by restoring r7-ra, sp, # |
---|
| 22 | # and pc from 'a' # |
---|
| 23 | # and doing a return. (Makes sure that longjmp never returns 0). # |
---|
| 24 | ############################################################################## |
---|
| 25 | |
---|
| 26 | .text |
---|
| 27 | .file "setjmp.s" |
---|
| 28 | .align 4 |
---|
| 29 | |
---|
| 30 | .globl _setjmp |
---|
| 31 | .align 4 |
---|
| 32 | _setjmp: |
---|
| 33 | #r3, r2: .blkw |
---|
| 34 | storw r7, 0(r3,r2) |
---|
| 35 | addd $2, (r3,r2) |
---|
| 36 | storw r8, 0(r3,r2) |
---|
| 37 | addd $2, (r3,r2) |
---|
| 38 | storw r9, 0(r3,r2) |
---|
| 39 | addd $2, (r3,r2) |
---|
| 40 | storw r10, 0(r3,r2) |
---|
| 41 | addd $2, (r3,r2) |
---|
| 42 | storw r11, 0(r3,r2) |
---|
| 43 | addd $2, (r3,r2) |
---|
| 44 | |
---|
| 45 | stord (r12), 0(r3,r2) |
---|
| 46 | addd $4, (r3,r2) |
---|
| 47 | stord (r13), 0(r3,r2) |
---|
| 48 | addd $4, (r3,r2) |
---|
| 49 | |
---|
| 50 | stord (ra), 0(r3,r2) |
---|
| 51 | addd $4, (r3,r2) |
---|
| 52 | stord (sp), 0(r3,r2) |
---|
| 53 | |
---|
| 54 | movd $0,(r1,r0) |
---|
| 55 | jump (ra) |
---|
| 56 | |
---|
| 57 | .globl _longjmp |
---|
| 58 | _longjmp: |
---|
| 59 | #r3, r2: .blkw # pointer save area |
---|
| 60 | #r5, r4: .blkw # ret vlaue |
---|
| 61 | |
---|
| 62 | loadw 0(r3,r2), r7 |
---|
| 63 | addd $2, (r3,r2) |
---|
| 64 | loadw 0(r3,r2), r8 |
---|
| 65 | addd $2, (r3,r2) |
---|
| 66 | loadw 0(r3,r2), r9 |
---|
| 67 | addd $2, (r3,r2) |
---|
| 68 | loadw 0(r3,r2), r10 |
---|
| 69 | addd $2, (r3,r2) |
---|
| 70 | loadw 0(r3,r2), r11 |
---|
| 71 | addd $2, (r3,r2) |
---|
| 72 | |
---|
| 73 | loadd 0(r3,r2), (r12) |
---|
| 74 | addd $4, (r3,r2) |
---|
| 75 | loadd 0(r3,r2), (r13) |
---|
| 76 | addd $4, (r3,r2) |
---|
| 77 | |
---|
| 78 | loadd 0(r3,r2), (ra) |
---|
| 79 | addd $4, (r3,r2) |
---|
| 80 | loadd 0(r3,r2), (sp) |
---|
| 81 | |
---|
| 82 | #ifdef __INT32__ |
---|
| 83 | movd (r5,r4), (r1,r0) |
---|
| 84 | cmpd $0, (r5,r4) |
---|
| 85 | bne end1 |
---|
| 86 | movd $1, (r1,r0) |
---|
| 87 | #else |
---|
| 88 | movw r4, r0 |
---|
| 89 | cmpw $0, r4 |
---|
| 90 | bne end1 |
---|
| 91 | movw $1, r0 |
---|
| 92 | #endif |
---|
| 93 | end1: |
---|
| 94 | jump (ra) |
---|
| 95 | .align 4 |
---|
| 96 | |
---|
| 97 | |
---|