1 |
;------------------------------------------------------------------------------- |
2 |
;$Header: /home/dashley/cvsrep/uculib01/uculib01/src/stm8/cosmic/modx0/mfcpusptrpcgetrxx/src/mfcpusptrpcgetrxx.s,v 1.4 2010/03/21 04:50:34 dashley Exp $ |
3 |
;------------------------------------------------------------------------------- |
4 |
;Copyright (c)2010 David T. Ashley |
5 |
; |
6 |
;Permission is hereby granted, free of charge, to any person obtaining a copy |
7 |
;of this software source code and associated documentation files (the |
8 |
;"Software"), to deal in the Software without restriction, including without |
9 |
;limitation the rights to use, copy, modify, merge, publish, distribute, |
10 |
;sublicense, and/or sell copies of the Software, and to permit persons to whom |
11 |
;the Software is furnished to do so, subject to the following conditions: |
12 |
; |
13 |
;The above copyright notice and this permission notice shall be included in |
14 |
;all copies or substantial portions of the Software. |
15 |
; |
16 |
;THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
17 |
;IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
18 |
;FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
19 |
;AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
20 |
;LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
21 |
;OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
22 |
;THE SOFTWARE. |
23 |
;------------------------------------------------------------------------------- |
24 |
;This function doesn't use any static storage, so it is OK for either mods0 or |
25 |
;modsl0 memory models. However, it does assume call/ret (rather than callf/retf) |
26 |
;which affects both instructions used, stack offsets, and numerical values in |
27 |
;the .dcall directive. For this reason, must error out if being assembled |
28 |
;for the wrong memory model. |
29 |
#ifndef UCU_BD_MMBP |
30 |
#error "Program memory model define not provided on command line (UCU_BD_MMBP)." |
31 |
#endif |
32 |
#if (UCU_BD_MMBP != 1) |
33 |
#error "Attempt to assemble module for wrong program memory model (UCU_BD_MMBP != 1)." |
34 |
#endif |
35 |
; |
36 |
switch .text |
37 |
xdef _UcuMfCpuSptrPcGetRxx |
38 |
; |
39 |
;Per discussion with Cosmic, the first integer is the stack space used by the |
40 |
;call instruction plus any automatic storage used by the function. The second integer |
41 |
;is the number of bytes stacked by the caller. Haven't yet discussed the scenario |
42 |
;of one assembly-language function called by another. I've noticed that some |
43 |
;assembly-language functions have a larger first integer than the stack they |
44 |
;used, so there may be a special convention if C calls .S which then calls .S, |
45 |
;as maybe the tools don't detect the .S calling the .S. Will need to investigate |
46 |
;further with Cosmic. |
47 |
; |
48 |
;2 bytes stacked by the CALL instruction, 0 bytes stacked by the caller. |
49 |
.dcall "2,0,_UcuMfCpuSptrPcGetRxx" |
50 |
; |
51 |
_UcuMfCpuSptrPcGetRxx: |
52 |
ldw x,sp ;Copy the stack pointer to x. |
53 |
addw x,#2 ;The call caused the stack to grow towards lower memory addresses by 2. |
54 |
;This addition causes the stack pointer at the time of call to be |
55 |
;calculated. The X register is the location of the return value. |
56 |
ret ;Return value set up. Can return. |
57 |
; |
58 |
end |
59 |
; |
60 |
;------------------------------------------------------------------------------- |
61 |
;End of $Id: mfcpusptrpcgetrxx.s,v 1.4 2010/03/21 04:50:34 dashley Exp $ |
62 |
;------------------------------------------------------------------------------- |
63 |
;$Log: mfcpusptrpcgetrxx.s,v $ |
64 |
;Revision 1.4 2010/03/21 04:50:34 dashley |
65 |
;Comments corrected. |
66 |
; |
67 |
;Revision 1.3 2010/02/20 16:07:22 dashley |
68 |
;Missing switch directive added. |
69 |
; |
70 |
;Revision 1.2 2010/02/14 03:26:04 dashley |
71 |
;Extra line removed. |
72 |
; |
73 |
;Revision 1.1 2010/02/14 03:25:40 dashley |
74 |
;Initial checkin. |
75 |
;------------------------------------------------------------------------------- |
76 |
|