annotate src/varargs.inc @ 654:75e90cd0c2c3

hwOS sport 10.77 release
author heinrichsweikamp
date Thu, 14 Mar 2024 16:56:46 +0100
parents 4050675965ea
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
3 ; File varargs.inc * combined next generation V3.0.1
0
heinrichsweikamp
parents:
diff changeset
4 ;
heinrichsweikamp
parents:
diff changeset
5 ; Utilities to pass multiple arguments in compact code stream.
heinrichsweikamp
parents:
diff changeset
6 ;
654
75e90cd0c2c3 hwOS sport 10.77 release
heinrichsweikamp
parents: 634
diff changeset
7 ; Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
0
heinrichsweikamp
parents:
diff changeset
8 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
9 ; HISTORY
heinrichsweikamp
parents:
diff changeset
10 ; 2011-05-27 : [jDG] Creation.
heinrichsweikamp
parents:
diff changeset
11 ;
heinrichsweikamp
parents:
diff changeset
12
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
13
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
14 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
15 ; Prepare reading inline Data: set Table Pointer to the Beginn of the inline Data
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
16 ;
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 0
diff changeset
17 VARARGS_BEGIN macro
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
18 movff TOSL, TBLPTRL ; copy program counter address to table pointer
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
19 movff TOSH, TBLPTRH ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
20 movff TOSU, TBLPTRU ; ...
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 0
diff changeset
21 endm
0
heinrichsweikamp
parents:
diff changeset
22
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
23
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
24 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
25 ; Read 1 Byte of inline Data
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
26 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
27 VARARGS_GET8 macro register
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
28 tblrd*+ ; read 1 byte from program memory
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
29 movff TABLAT, register ; store to register
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 0
diff changeset
30 endm
0
heinrichsweikamp
parents:
diff changeset
31
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
32
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
33 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
34 ; Read 2 Bytes of inline Data
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
35 ;
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 0
diff changeset
36 VARARGS_GET16 macro register
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
37 tblrd*+ ; read 1st byte from program memory
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
38 movff TABLAT, register+0 ; store to register
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
39 tblrd*+ ; read 2nd byte from program memory
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
40 movff TABLAT, register+1 ; store to register
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 0
diff changeset
41 endm
0
heinrichsweikamp
parents:
diff changeset
42
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
43
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
44 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
45 ; Read 3 Bytes of inline Data
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
46 ;
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 0
diff changeset
47 VARARGS_GET24 macro register
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
48 tblrd*+ ; read 1st byte from program memory
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
49 movff TABLAT, register+0 ; store to register
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
50 tblrd*+ ; read 2nd byte from program memory
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
51 movff TABLAT, register+1 ; store to register
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
52 tblrd*+ ; read 3rd byte from program memory
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
53 movff TABLAT, register+2 ; store to register
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 0
diff changeset
54 endm
0
heinrichsweikamp
parents:
diff changeset
55
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
56
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
57 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
58 ; Align Table Pointer to an even Address
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
59 ;
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 0
diff changeset
60 VARARGS_ALIGN macro
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
61 btfsc TBLPTRL,0 ; table pointer pointing to an even address?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
62 tblrd*+ ; NO - do a dummy read to advance to next even address
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 0
diff changeset
63 endm
0
heinrichsweikamp
parents:
diff changeset
64
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
65
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
66 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
67 ; End reading inline Data: set Return Address behind End of the inline Data
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
68 ;
0
heinrichsweikamp
parents:
diff changeset
69 VARARGS_END macro
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
70 movf TOSL,W ; compute how may inline bytes have been read
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
71 subwf TBLPTRL,W ; WREG = (TBLPTRL - TOSL) modulo 256
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
72 addwf TOSL,F ; advance the return address by this number
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
73 movlw 0 ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
74 addwfc TOSH,F ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
75 addwfc TOSU,F ; ...
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 0
diff changeset
76 endm