Changeset 1360


Ignore:
Timestamp:
07/24/09 18:55:27 (3 years ago)
Author:
debrouxl
Message:

library:

  • use explicit register parameters for Sprite8/16/32, bsearch and qsort;
  • regenerate headers;
  • 2-byte optimization in Sprite8: shift count can be computed differently.
Location:
trunk/tigcc
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/tigcc/archive/bsearch.c

    r1356 r1360  
    5050 * look at item 3. 
    5151 */ 
    52 __ATTR_LIB_C__ void *bsearch(const void *key, const void *bptr, short n, short w, compare_t cmp_func); 
     52void *bsearch(const void *key asm("a0"), const void *bptr asm("a1"), short n asm("d0"), short w asm("d1"), compare_t cmp_func asm("a2")) __ATTR_LIB_ASM__; 
    5353asm(" 
    5454        .text 
     
    5656        .globl  bsearch 
    5757bsearch: 
    58         movem.l %d3-%d5/%a2-%a4,-(%sp) 
     58        movem.l %d3-%d5/%a3-%a4,-(%sp) 
    5959        move.l %a0,%d5  ;# key, key 
    6060        move.w %d1,%d4  ;# w, w 
     
    8383.L4: 
    8484        move.l %a4,%a0  ;# rptr, <result> 
    85         movem.l (%sp)+,%d3-%d5/%a2-%a4 
     85        movem.l (%sp)+,%d3-%d5/%a3-%a4 
    8686        rts 
    8787"); 
  • trunk/tigcc/archive/qsort.c

    r1359 r1360  
    77// For sorting data that has no significant statistical property, on embedded platforms 
    88// without processor caches, the shell sort is one of the very best size/speed tradeoffs. 
    9 __ATTR_LIB_C__ void qsort(void *list, short num_items, short size, compare_t cmp_func); 
     9void qsort(void *list asm("a0"), short num_items asm("d0"), short size asm("d1"), compare_t cmp_func asm("a2")) __ATTR_LIB_ASM__; 
    1010 
    1111asm(" 
     
    2323        .globl qsort 
    2424qsort: 
    25         movem.l %d3-%d7/%a2-%a4/%a6,-(%sp) 
     25        movem.l %d3-%d7/%a3-%a4/%a6,-(%sp) 
    2626        move.l %a0,%a4  ;# list, list 
    2727        move.w %d1,%d7  ;# size, size 
    28         move.l %a1,%a2  ;# cmp_func, cmp_func 
    2928        move.w #4096,%d5        ;#, k 
    3029        cmp.w #16,%d0   ;#, num_items 
     
    8584        bne.s .L6       ;# 
    8685 
    87         movem.l (%sp)+,%d3-%d7/%a2-%a4/%a6 
     86        movem.l (%sp)+,%d3-%d7/%a3-%a4/%a6 
    8887        rts 
    8988"); 
     
    193192        rts 
    194193*/ 
    195 // In six steps, 30 bytes were saved, yielding the ASM routine at the top of this file. 
     194// In seven steps, 34 bytes were saved, yielding the ASM routine at the top of this file. 
  • trunk/tigcc/archive/sprite16.s

    r1344 r1360  
    1616        addq.w #1,%d0 | 2 
    1717 
    18         move.w %d4,-(%a7) | 2 
    19         move.l %d3,-(%a7) | 2 
    20 | d4: drawing mode. 
    21         move.w 4+6(%a7),%d4 | 4 
    22         subq.w #1,%d4 | 2 
    23 | d3: mask used by AND and RPLC. 
    24         moveq #-1,%d3 | 2 
    25         clr.w %d3 | 2 
    26         rol.l %d0,%d3 | 2 
     18        move.l %d4,-(%a7) | 2 
     19| d3: drawing mode. 
     20        subq.w #1,%d3 | 2 
     21| d4: mask used by AND and RPLC. 
     22        moveq #-1,%d4 | 2 
     23        clr.w %d4 | 2 
     24        rol.l %d0,%d4 | 2 
    2725| Jump to loop entry. 
    2826        bra.s .L__s16_loopentry | 2 
     
    3028| AND. 
    3129.L__s16_Am: 
    32         or.l %d3,%d1 | 2 
     30        or.l %d4,%d1 | 2 
    3331        and.l %d1,(%a1) | 2 
    3432 
     
    4543        move.w (%a0)+,%d1 | 2 
    4644        lsl.l %d0,%d1 | 2 
    47         cmp.w #1,%d4 | 4 
     45        cmp.w #1,%d3 | 4 
    4846        beq.s .L__s16_Am | 2 
    49         tst.w %d4 | 2 
     47        tst.w %d3 | 2 
    5048        blt.s .L__s16_Xm | 2 
    5149        beq.s .L__s16_Om | 2 
    5250| RPLC. 
    53         and.l %d3,(%a1) | 2 
     51        and.l %d4,(%a1) | 2 
    5452 
    5553| OR. 
     
    6563| Return 
    6664.L__s16_rts: 
    67         move.l (%a7)+,%d3 | 2 
    68         move.w (%a7)+,%d4 | 2 
     65        addq.w #1,%d3 | 2 
     66        move.l (%a7)+,%d4 | 2 
    6967        rts | 2 
  • trunk/tigcc/archive/sprite32.s

    r1344 r1360  
    1818 
    1919| d4: drawing mode. 
    20         move.w 4+5*4(%a7),%d4 | 4 
    21         subq.w #1,%d4 | 2 
     20        subq.w #1,%d3 | 2 
    2221| d3, d6: masks used by AND and RPLC. 
    23         moveq #-1,%d3 | 2 
    24         lsr.w %d0,%d3 | 2 
    25         move.w %d3,%d6 | 2 
    26         not.l %d3 | 2 
    27         swap %d3 | 2 
     22        moveq #-1,%d4 | 2 
     23        lsr.w %d0,%d4 | 2 
     24        move.w %d4,%d6 | 2 
     25        not.l %d4 | 2 
     26        swap %d4 | 2 
    2827| Jump to loop entry. 
    2928        bra.s .L__s32_loopentry | 2 
     
    3130| AND. 
    3231.L__s32_Am: 
    33         or.l %d3,%d1 | 2 
     32        or.l %d4,%d1 | 2 
    3433        or.w %d6,%d7 | 2 
    3534        and.l %d1,(%a1)+ | 2 
     
    4746        move.l (%a0)+,%d1 | 2 
    4847        move.w %d1,%d7 | 2 
    49         lsr.l %d0,%d1 | 2 
    50         lsl.w %d5,%d7 | 2 
    51         cmp.w #1,%d4 | 4 
     48        lsr.l %d0,%d1 | 2 
     49        lsl.w %d5,%d7 | 2 
     50        cmp.w #1,%d3 | 4 
    5251        beq.s .L__s32_Am | 2 
    53         tst.w %d4 | 2 
     52        tst.w %d3 | 2 
    5453        blt.s .L__s32_Xm | 2 
    5554        beq.s .L__s32_Om | 2 
    5655| RPLC. 
    57         and.l %d3,(%a1) | 2 
     56        and.l %d4,(%a1) | 2 
    5857        and.w %d6,4(%a1) | 2 
    5958| OR. 
  • trunk/tigcc/archive/sprite8.s

    r1344 r1360  
    1212        adda.w %d1,%a1 | 2 
    1313| d0: shift count. 
    14         not.w %d0 | 2 
     14        moveq #24,%d1 | 2 
    1515        and.w #15,%d0 | 4 
    16         add.w #9,%d0 | 4 
     16        sub.w %d0,%d1 | 2 
    1717 
    18         move.w %d4,-(%a7) | 2 
    19         move.l %d3,-(%a7) | 2 
    20 | d4: drawing mode. 
    21         move.w 4+6(%a7),%d4 | 4 
    22         subq.w #1,%d4 | 2 
    23 | d3: mask used by AND and RPLC. 
    24         moveq #-1,%d3 | 2 
    25         clr.b %d3 | 2 
    26         rol.l %d0,%d3 | 2 
     18        move.l %d4,-(%a7) | 2 
     19| d3: drawing mode. 
     20        subq.w #1,%d3 | 2 
     21| d4: mask used by AND and RPLC. 
     22        moveq #-1,%d4 | 2 
     23        clr.b %d4 | 2 
     24        rol.l %d1,%d4 | 2 
    2725| Jump to loop entry. 
    2826        bra.s .L__s8_loopentry | 2 
     
    3028| AND. 
    3129.L__s8_Am: 
    32         or.l %d3,%d1 | 2 
    33         and.l %d1,(%a1) | 2 
     30        or.l %d4,%d0 | 2 
     31        and.l %d0,(%a1) | 2 
    3432 
    3533| Next line. 
     
    4240        blt.s .L__s8_rts | 2 
    4341 
    44         moveq #0,%d1 | 2 
    45         move.b (%a0)+,%d1 | 2 
    46         lsl.l %d0,%d1 | 2 
    47         cmp.w #1,%d4 | 4 
     42        moveq #0,%d0 | 2 
     43        move.b (%a0)+,%d0 | 2 
     44        lsl.l %d1,%d0 | 2 
     45        cmp.w #1,%d3 | 4 
    4846        beq.s .L__s8_Am | 2 
    49         tst.w %d4 | 2 
     47        tst.w %d3 | 2 
    5048        blt.s .L__s8_Xm | 2 
    5149        beq.s .L__s8_Om | 2 
    5250| RPLC. 
    53         and.l %d3,(%a1) | 2 
     51        and.l %d4,(%a1) | 2 
    5452 
    5553| OR. 
    5654.L__s8_Om: 
    57         or.l %d1,(%a1) | 2 
     55        or.l %d0,(%a1) | 2 
    5856        bra.s .L__s8_loop | 2 
    5957 
    6058| XOR 
    6159.L__s8_Xm: 
    62         eor.l %d1,(%a1) | 2 
     60        eor.l %d0,(%a1) | 2 
    6361        bra.s .L__s8_loop | 2 
    6462 
    6563| Return 
    6664.L__s8_rts: 
    67         move.l (%a7)+,%d3 | 2 
    68         move.w (%a7)+,%d4 | 2 
     65        addq.w #1,%d3 | 2 
     66        move.l (%a7)+,%d4 | 2 
    6967        rts | 2 
  • trunk/tigcc/doc/System/Include/sprites.h/Sprite16.hsf

    r1307 r1360  
    55Header Files=sprites.h 
    66Definition=void Sprite16 (short x, short y, short height, const unsigned short *sprite, void *vm_addr, short mode); 
    7 Real Definition=extern void Sprite16(short,short,short,__cpushort,void*,short)__ATTR_LIB_C__; 
     7Real Definition=extern void Sprite16(short asm("d0"),short asm("d1"),short asm("d2"),__cpushort asm("a0"),void* asm("a1"),short asm("d3"))__ATTR_LIB_ASM__; 
     8 
     9[Library Call] 
     10Asm=1 
     11 
     12[Registers] 
     13x=d0 
     14y=d1 
     15height=d2 
     16sprite=a0 
     17vm_addr=a1 
     18mode=d3 
    819 
    920[Description] 
  • trunk/tigcc/doc/System/Include/sprites.h/Sprite32.hsf

    r1307 r1360  
    55Header Files=sprites.h 
    66Definition=void Sprite32 (short x, short y, short height, const unsigned long *sprite, void *vm_addr, short mode); 
    7 Real Definition=extern void Sprite32(short,short,short,__cpulong,void*,short)__ATTR_LIB_C__; 
     7Real Definition=extern void Sprite32(short asm("d0"),short asm("d1"),short asm("d2"),__cpulong asm("a0"),void* asm("a1"),short asm("d3"))__ATTR_LIB_ASM__; 
     8 
     9[Library Call] 
     10Asm=1 
     11 
     12[Registers] 
     13x=d0 
     14y=d1 
     15height=d2 
     16sprite=a0 
     17vm_addr=a1 
     18mode=d3 
    819 
    920[Description] 
     
    2334<BR><BR> 
    2435If you want to use sprites wider than 32 pixels (which is not very likely), one solution is to 
    25 use DoorsOS and its "put_sprite" function (see <A HREF="$$INFOLINK(faq)">Frequently Asked Questions</A> 
    26 for more info about how to do it). If you don't want to use DoorsOS, the proposed method depends 
    27 on what the use of the sprite will be. If you don't need too fast action, the built-in TIOS function 
    28 <A HREF="$$LINK(graph.h/BitmapPut)">BitmapPut</A> may be good enough. If you need a very fast sprite 
    29 routine for very large sprites, then you must write it yourself. 
     36use a "kernel"-based program and <CODE>graphlib::put_sprite</CODE> (see <A HREF="$$INFOLINK(faq)">Frequently Asked Questions</A> 
     37for more info about how to do it). If you don't want to use kernel-based programs, the proposed method depends 
     38on what the use of the sprite will be: 
     39<UL> 
     40<LI> 
     41If you don't need too fast action, the built-in TIOS function <A HREF="$$LINK(graph.h/BitmapPut)">BitmapPut</A> may be good enough. 
     42</LI> 
     43<LI> 
     44If you need a very fast sprite routine for very large sprites, then you must write it yourself, or use prewritten ones in 
     45ExtGraph or Genlib. 
     46</LI> 
     47</UL> 
    3048<BR><BR> 
    3149See <A HREF="$$LINK(sprites.h/Sprite8)">Sprite8</A> for more info about sprites. 
  • trunk/tigcc/doc/System/Include/sprites.h/Sprite8.hsf

    r1344 r1360  
    55Header Files=sprites.h 
    66Definition=void Sprite8 (short x, short y, short height, const unsigned char *sprite, void *vm_addr, short mode); 
     7 
     8[Library Call] 
     9Asm=1 
     10 
     11[Registers] 
     12x=d0 
     13y=d1 
     14height=d2 
     15sprite=a0 
     16vm_addr=a1 
     17mode=d3 
    718 
    819[Description] 
  • trunk/tigcc/doc/System/Include/sprites.h/sprites.hsh

    r1307 r1360  
    66 
    77[Bottom] 
    8 For a lot of advanced drawing routines, we recommend you to download the <A HREF="http://www.ticalc.org/archives/files/fileinfo/187/18705.html">ExtGraph library</A> by the <A HREF="http://tict.ticalc.org/">TI-Chess Team</A>. 
     8For lots of advanced drawing routines, we recommend you to download either the <A HREF="http://tict.ticalc.org/">ExtGraph static library</A> by the <A HREF="http://tict.ticalc.org/">TI-Chess Team</A> or <A HREF="http://www.yaronet.com/t3/?id=20">Genlib "kernel"-based dynamic library</A> by the <A HREF="http://www.yaronet.com/t3/">Time To Team</A>. 
  • trunk/tigcc/doc/System/Include/stdlib.h/bsearch.hsf

    r1358 r1360  
    66Definition=void *bsearch (const void *Key, const void *BasePtr, unsigned short NoOfElements, unsigned short Width, compare_t cmp_func); 
    77See Also=stdlib.h/qsort 
     8 
     9[Library Call] 
     10Asm=1 
     11 
     12[Registers] 
     13Key=a0 
     14BasePtr=a1 
     15NoOfElements=d0 
     16Width=d1 
     17cmp_func=a2 
    818 
    919[Description] 
  • trunk/tigcc/doc/System/Include/stdlib.h/qsort.hsf

    r1358 r1360  
    55Header Files=stdlib.h 
    66Definition=void qsort (void *BasePtr, unsigned short NoOfElements, unsigned short Width, compare_t cmp_func); 
     7See Also=stdlib.h/bsearch 
     8 
     9[Library Call] 
     10Asm=1 
     11 
     12[Registers] 
     13BasePtr=a0 
     14NoOfElements=d0 
     15Width=d1 
     16cmp_func=a2 
    717 
    818[Description] 
  • trunk/tigcc/include/C/basfunc.h

    r1319 r1360  
    2525#endif 
    2626#if MIN_AMS>=101 
     27#define push_format ({__need_in_use_bit;_rom_call(void,(ESI,ESI),315);}) 
    2728#define push_getfold _rom_call(void,(void),317) 
    2829#define push_getkey ({__need_in_use_bit;_rom_call(void,(void),316);}) 
  • trunk/tigcc/include/C/estack.h

    r1319 r1360  
    173173#define index_numeric_term _rom_call(ESI,(CESI),2CD) 
    174174#define index_of_lead_base_of_lead_term _rom_call(ESI,(CESI),2CE) 
     175#define init_list_indices _rom_call(ESI*,(ESI*,CESI),2BA) 
     176#define init_matrix_indices _rom_call(ESI*,(ESI*,CESI),2BB) 
    175177#define is_advanced_tag _rom_call(short,(ESQ),2D0) 
    176178#define is_antisymmetric ({__need_in_use_bit;_rom_call(short,(CESI,CESI),2D1);}) 
  • trunk/tigcc/include/C/sprites.h

    r1344 r1360  
    66/* Begin Auto-Generated Part */ 
    77enum SprtModes{SPRT_XOR,SPRT_OR,SPRT_AND,SPRT_RPLC}; 
    8 extern void Sprite8(short,short,short,const unsigned char*,void*,short)__ATTR_LIB_C__; 
    9 extern void Sprite16(short,short,short,__cpushort,void*,short)__ATTR_LIB_C__; 
    10 extern void Sprite32(short,short,short,__cpulong,void*,short)__ATTR_LIB_C__; 
     8extern void Sprite8(short asm("d0"),short asm("d1"),short asm("d2"),const unsigned char* asm("a0"),void* asm("a1"),short asm("d3"))__ATTR_LIB_ASM__; 
     9extern void Sprite16(short asm("d0"),short asm("d1"),short asm("d2"),__cpushort asm("a0"),void* asm("a1"),short asm("d3"))__ATTR_LIB_ASM__; 
     10extern void Sprite32(short asm("d0"),short asm("d1"),short asm("d2"),__cpulong asm("a0"),void* asm("a1"),short asm("d3"))__ATTR_LIB_ASM__; 
    1111/* End Auto-Generated Part */ 
    1212 
  • trunk/tigcc/include/C/stdlib.h

    r1307 r1360  
    4242extern short atoi(const char*)__ATTR_LIB_C__; 
    4343extern long atol(const char*)__ATTR_LIB_C__; 
    44 extern void *bsearch(const void*,const void*,short,short,compare_t)__ATTR_LIB_C__; 
     44extern void *bsearch(const void* asm("a0"),const void* asm("a1"),short asm("d0"),short asm("d1"),compare_t asm("a2"))__ATTR_LIB_ASM__; 
    4545#ifndef __HAVE_calloc 
    4646#define __HAVE_calloc 
     
    5858#define max(a,b) ({typeof(a) __a = (a); typeof(b) __b = (b); (__a > __b) ? __a : __b;}) 
    5959#define min(a,b) ({typeof(a) __a = (a); typeof(b) __b = (b); (__a < __b) ? __a : __b;}) 
    60 extern void qsort(void*,short,short,compare_t)__ATTR_LIB_C__; 
     60extern void qsort(void* asm("a0"),short asm("d0"),short asm("d1"),compare_t asm("a2"))__ATTR_LIB_ASM__; 
    6161extern short rand(void)__ATTR_LIB_ASM__; 
    6262#define random(x) ((short)((long)(unsigned short)rand()*(unsigned short)(x)/32768)) 
  • trunk/tigcc/include/C/unknown.h

    r1319 r1360  
    273273#define InitDEMem ({__need_in_use_bit;_rom_call(unknown_retval,(),1EA);}) 
    274274#define InitTimeSeq ({__need_in_use_bit;_rom_call(unknown_retval,(),1D9);}) 
    275 #define is_executable _rom_call(unknown_retval,(),25A) 
     275#define is_executable _rom_call(short,(CESI),25A) 
    276276#define LoadSymFromFindHandle _rom_call(void,(void),281) 
    277277#define NG_cleanup_graph_fun ({__need_in_use_bit;_rom_call(unknown_retval,(),262);}) 
     
    330330#define has_unit_base _rom_call(short,(ESI),3AF) 
    331331#define index_after_match_endtag _rom_call(ESI,(ESI,char),2B1) 
    332 #define init_list_indices _rom_call(unknown_retval,(),2BA) 
    333 #define init_matrix_indices _rom_call(unknown_retval,(),2BB) 
    334332#define init_unit_system _rom_call(unknown_retval,(),3B0) 
    335333#define is_pathname _rom_call(short,(CESI),3C6) 
     
    339337#define push_ans_entry _rom_call(HANDLE,(CESI),2B0) 
    340338#define push_auto_units_conversion ({__need_in_use_bit;_rom_call(unknown_retval,(),3B2);}) 
    341 #define push_float_qr_fact ({__need_in_use_bit;_rom_call(unknown_retval,(),2BC);}) 
    342 #define push_format ({__need_in_use_bit;_rom_call(unknown_retval,(),315);}) 
    343 #define push_lu_fact ({__need_in_use_bit;_rom_call(unknown_retval,(),2BD);}) 
    344 #define push_mrow_aux ({__need_in_use_bit;_rom_call(unknown_retval,(),31B);}) 
     339#define push_float_qr_fact ({__need_in_use_bit;_rom_call(ESI,(ESI,float),2BC);}) 
     340#define push_lu_fact ({__need_in_use_bit;_rom_call(ESI,(ESI,float),2BD);}) 
     341#define push_mrow_aux ({__need_in_use_bit;_rom_call(void,(ESI,ESI,short,short),31B);}) 
    345342#define push_parse_prgm_or_func_text _rom_call(void,(const char*,ESI,short),3C9) 
    346343#define push_sq_matrix_to_whole_number ({__need_in_use_bit;_rom_call(unknown_retval,(),3C0);}) 
    347 #define push_symbolic_qr_fact ({__need_in_use_bit;_rom_call(unknown_retval,(),2BE);}) 
     344#define push_symbolic_qr_fact ({__need_in_use_bit;_rom_call(ESI,(ESI),2BE);}) 
    348345#define push_unit_system_list _rom_call(unknown_retval,(),3B3) 
    349346#define push_user_func ({__need_in_use_bit;_rom_call(void,(ESI,short),2B3);}) 
    350347#define push_var _rom_call(void,(const char*,const char*),3CB) 
    351 #define push_zero_partial_column _rom_call(unknown_retval,(),3C2) 
     348#define push_zero_partial_column _rom_call(void,(ESI,short,short),3C2) 
    352349#define setup_unit_system _rom_call(unknown_retval,(),3B4) 
    353350#define store_func_def ({__need_in_use_bit;_rom_call(void,(ESI),2B4);}) 
Note: See TracChangeset for help on using the changeset viewer.