annotate src/varargs.inc @ 113:f3062a611eef

Merge
author heinrichsweikamp
date Mon, 23 Jun 2014 16:14:33 +0200
parents 11d4fc797f74
children ca4556fb60b9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
heinrichsweikamp
parents:
diff changeset
3 ; File varargs.inc
heinrichsweikamp
parents:
diff changeset
4 ;
heinrichsweikamp
parents:
diff changeset
5 ; Utilities to pass multiple arguments in compact code stream.
heinrichsweikamp
parents:
diff changeset
6 ;
heinrichsweikamp
parents:
diff changeset
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
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
heinrichsweikamp
parents:
diff changeset
13 VARARGS_BEGIN macro
heinrichsweikamp
parents:
diff changeset
14 movff TOSL, TBLPTRL
heinrichsweikamp
parents:
diff changeset
15 movff TOSH, TBLPTRH
heinrichsweikamp
parents:
diff changeset
16 movff TOSU, TBLPTRU
heinrichsweikamp
parents:
diff changeset
17 endm
heinrichsweikamp
parents:
diff changeset
18
heinrichsweikamp
parents:
diff changeset
19 VARARGS_GET8 macro register
heinrichsweikamp
parents:
diff changeset
20 tblrd*+
heinrichsweikamp
parents:
diff changeset
21 movff TABLAT, register
heinrichsweikamp
parents:
diff changeset
22 endm
heinrichsweikamp
parents:
diff changeset
23
heinrichsweikamp
parents:
diff changeset
24 VARARGS_GET16 macro register
heinrichsweikamp
parents:
diff changeset
25 tblrd*+
heinrichsweikamp
parents:
diff changeset
26 movff TABLAT, register+0
heinrichsweikamp
parents:
diff changeset
27 tblrd*+
heinrichsweikamp
parents:
diff changeset
28 movff TABLAT, register+1
heinrichsweikamp
parents:
diff changeset
29 endm
heinrichsweikamp
parents:
diff changeset
30
heinrichsweikamp
parents:
diff changeset
31 VARARGS_GET24 macro register
heinrichsweikamp
parents:
diff changeset
32 tblrd*+
heinrichsweikamp
parents:
diff changeset
33 movff TABLAT, register+0
heinrichsweikamp
parents:
diff changeset
34 tblrd*+
heinrichsweikamp
parents:
diff changeset
35 movff TABLAT, register+1
heinrichsweikamp
parents:
diff changeset
36 tblrd*+
heinrichsweikamp
parents:
diff changeset
37 movff TABLAT, register+2
heinrichsweikamp
parents:
diff changeset
38 endm
heinrichsweikamp
parents:
diff changeset
39
heinrichsweikamp
parents:
diff changeset
40 VARARGS_ALIGN macro
heinrichsweikamp
parents:
diff changeset
41 local no_tblptr_align
heinrichsweikamp
parents:
diff changeset
42
heinrichsweikamp
parents:
diff changeset
43 btfss TBLPTRL,0
heinrichsweikamp
parents:
diff changeset
44 bra no_tblptr_align
heinrichsweikamp
parents:
diff changeset
45 incf TBLPTRL
heinrichsweikamp
parents:
diff changeset
46 movlw 0
heinrichsweikamp
parents:
diff changeset
47 addwfc TBLPTRH
heinrichsweikamp
parents:
diff changeset
48 addwfc TBLPTRU
heinrichsweikamp
parents:
diff changeset
49 no_tblptr_align:
heinrichsweikamp
parents:
diff changeset
50 endm
heinrichsweikamp
parents:
diff changeset
51
heinrichsweikamp
parents:
diff changeset
52 VARARGS_END macro
heinrichsweikamp
parents:
diff changeset
53 ; Compute string length (modulo 256):
heinrichsweikamp
parents:
diff changeset
54 movf TOSL,W
heinrichsweikamp
parents:
diff changeset
55 subwf TBLPTRL,W
heinrichsweikamp
parents:
diff changeset
56
heinrichsweikamp
parents:
diff changeset
57 ; Then 24bit add to return address
heinrichsweikamp
parents:
diff changeset
58 addwf TOSL,F
heinrichsweikamp
parents:
diff changeset
59 movlw 0 ; Clear WREG, but keep carry
heinrichsweikamp
parents:
diff changeset
60 addwfc TOSH,F
heinrichsweikamp
parents:
diff changeset
61 addwfc TOSU,F
heinrichsweikamp
parents:
diff changeset
62 endm
heinrichsweikamp
parents:
diff changeset
63