Mercurial > public > hwos_code
comparison src/varargs.inc @ 0:11d4fc797f74
init
author | heinrichsweikamp |
---|---|
date | Wed, 24 Apr 2013 19:22:45 +0200 |
parents | |
children | ca4556fb60b9 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:11d4fc797f74 |
---|---|
1 ;============================================================================= | |
2 ; | |
3 ; File varargs.inc | |
4 ; | |
5 ; Utilities to pass multiple arguments in compact code stream. | |
6 ; | |
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. | |
8 ;============================================================================= | |
9 ; HISTORY | |
10 ; 2011-05-27 : [jDG] Creation. | |
11 ; | |
12 | |
13 VARARGS_BEGIN macro | |
14 movff TOSL, TBLPTRL | |
15 movff TOSH, TBLPTRH | |
16 movff TOSU, TBLPTRU | |
17 endm | |
18 | |
19 VARARGS_GET8 macro register | |
20 tblrd*+ | |
21 movff TABLAT, register | |
22 endm | |
23 | |
24 VARARGS_GET16 macro register | |
25 tblrd*+ | |
26 movff TABLAT, register+0 | |
27 tblrd*+ | |
28 movff TABLAT, register+1 | |
29 endm | |
30 | |
31 VARARGS_GET24 macro register | |
32 tblrd*+ | |
33 movff TABLAT, register+0 | |
34 tblrd*+ | |
35 movff TABLAT, register+1 | |
36 tblrd*+ | |
37 movff TABLAT, register+2 | |
38 endm | |
39 | |
40 VARARGS_ALIGN macro | |
41 local no_tblptr_align | |
42 | |
43 btfss TBLPTRL,0 | |
44 bra no_tblptr_align | |
45 incf TBLPTRL | |
46 movlw 0 | |
47 addwfc TBLPTRH | |
48 addwfc TBLPTRU | |
49 no_tblptr_align: | |
50 endm | |
51 | |
52 VARARGS_END macro | |
53 ; Compute string length (modulo 256): | |
54 movf TOSL,W | |
55 subwf TBLPTRL,W | |
56 | |
57 ; Then 24bit add to return address | |
58 addwf TOSL,F | |
59 movlw 0 ; Clear WREG, but keep carry | |
60 addwfc TOSH,F | |
61 addwfc TOSU,F | |
62 endm | |
63 |