1 |
;------------------------------------------------------------------------------- |
2 |
;$Header: /home/dashley/cvsrep/uculib01/uculib01/src/stm8/cosmic/modx0/mfcpuccrsetrxx/src/mfcpuccrsetrxx.s,v 1.3 2010/06/11 18:07:35 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 _UcuMfCpuCcrSetRxx |
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, 1 byte stacked by this function because of the |
49 |
;mechanism used to set the CCR, 0 bytes stacked by the caller. |
50 |
.dcall "3,0,_UcuMfCpuCcrSetRxx" |
51 |
; |
52 |
_UcuMfCpuCcrSetRxx: |
53 |
push a ;Push the caller's argument. |
54 |
pop cc ;Get it into the CCR. This is necessarily atomic. |
55 |
ret ;Return value set up. Can return. |
56 |
; |
57 |
end |
58 |
; |
59 |
;------------------------------------------------------------------------------- |
60 |
;End of $Id: mfcpuccrsetrxx.s,v 1.3 2010/06/11 18:07:35 dashley Exp $ |
61 |
;------------------------------------------------------------------------------- |
62 |
;$Log: mfcpuccrsetrxx.s,v $ |
63 |
;Revision 1.3 2010/06/11 18:07:35 dashley |
64 |
;Naming error corrected. |
65 |
; |
66 |
;Revision 1.2 2010/06/11 15:54:58 dashley |
67 |
;a)Extra line removed. |
68 |
;b)Comment added. |
69 |
; |
70 |
;Revision 1.1 2010/06/11 15:53:03 dashley |
71 |
;Initial checkin. |
72 |
;------------------------------------------------------------------------------- |
73 |
|