<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>how can choose</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/24355/how-can-choose</link><description> 
This is a function that i wrote using assembly: 

 
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;NAME: clearXdataNBytes
;FUNCTION:
; This functioin clear n bytes in the external ;space starting with the address specified</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: how can choose</title><link>https://community.arm.com/thread/149899?ContentTypeID=1</link><pubDate>Thu, 23 Jul 2009 18:18:42 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:b8e3616e-ef0c-41c2-a4e8-352a2821c943</guid><dc:creator>yu zhou</dc:creator><description>&lt;p&gt;&lt;p&gt;
I think it&amp;#39;s ok that using the registers to realize reentrant
function,I am confused because of the POPs in the &amp;quot;reentrant
function&amp;quot;, i placed them at the end of it,so i can reduce the code
space,because these codes are scattered all over if this function
called all over.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how can choose</title><link>https://community.arm.com/thread/149898?ContentTypeID=1</link><pubDate>Thu, 23 Jul 2009 17:52:33 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:f98a3abf-cf89-49f4-bfcb-fca4644b819e</guid><dc:creator>yu zhou</dc:creator><description>&lt;p&gt;&lt;p&gt;
So,how can i write a reentranted function that uses some registers
to pass parameters?!&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how can choose</title><link>https://community.arm.com/thread/149431?ContentTypeID=1</link><pubDate>Thu, 23 Jul 2009 09:27:37 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:7d21fb45-7f22-43af-a4a2-6a3bd42b8441</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
Explain what?&lt;/p&gt;

&lt;p&gt;
A reentrant function that uses DPL/DPH should save them. A
reentrant function that uses B should save it. The function should
not require someone else to do it or it will not be reentrant.&lt;/p&gt;

&lt;p&gt;
Next thing is that a prologue is the entry code for a function -
not how you call it.&lt;/p&gt;

&lt;p&gt;
In this case, you use DPH/DPL/B for parameter passing. That means
that your function can&amp;#39;t be reentrant, and should not try to be. It
is up to the calling function to be reentrant (if required). That
means that the calling function should contain both the push and the
pop. If the calling function has both push and pop, then the calling
function can do:&lt;/p&gt;

&lt;pre&gt;
    push DPH
    push DPL
    push B
    MOV   DPTR,#startAddr
    MOV   B,#200
    LCALL clearXdataNBytes
    MOV   DPTR,#startAddr2
    MOV   B,#100
    LCALL clearXdataNBytes
    ...
    pop   B
    pop   DPL
    pop   DPH
&lt;/pre&gt;

&lt;p&gt;
&lt;br /&gt;
When you mix the responsibility of push and pop between multiple
functions, then you get into the trouble that a loop calling the
function will have to repeat the save for each call.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how can choose</title><link>https://community.arm.com/thread/148946?ContentTypeID=1</link><pubDate>Thu, 23 Jul 2009 08:36:16 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:0dc3ce8b-1fb8-449d-820f-5804cb5e15c3</guid><dc:creator>yu zhou</dc:creator><description>&lt;p&gt;&lt;p&gt;
?,explain it in more detail,please!&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how can choose</title><link>https://community.arm.com/thread/125593?ContentTypeID=1</link><pubDate>Thu, 23 Jul 2009 08:32:13 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:91aa2137-56ae-406b-83cb-fc1b73c0ce2c</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
Why to you require the caller to perform some of the work then? A
reentrant function should be self-sufficient, and not require the
caller to hold the hand.&lt;/p&gt;

&lt;p&gt;
It should be enough for the caller to initialize the parameters.
The rest is up to the called function.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how can choose</title><link>https://community.arm.com/thread/118969?ContentTypeID=1</link><pubDate>Thu, 23 Jul 2009 08:23:48 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:53dd8315-90fb-4863-98f0-40d51c33b277</guid><dc:creator>yu zhou</dc:creator><description>&lt;p&gt;&lt;p&gt;
I just want to make this function reentrant by doing that
way!!!&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how can choose</title><link>https://community.arm.com/thread/103284?ContentTypeID=1</link><pubDate>Thu, 23 Jul 2009 08:20:49 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:7bd7c24a-0f2a-415f-af0e-b547aeed6974</guid><dc:creator>Advanced Zeusti</dc:creator><description>&lt;p&gt;&lt;p&gt;
HI.&lt;/p&gt;

&lt;p&gt;
but&lt;/p&gt;

&lt;pre&gt;
  push
  push
  push
  call
    push
    ..
    ..
    pop
    pop
    pop
    pop
    ret
&lt;/pre&gt;

&lt;p&gt;
looks very very very bad to me for this situetion.&lt;/p&gt;

&lt;p&gt;
Always yo&amp;#39;re freind.&lt;/p&gt;

&lt;p&gt;
Zeusti.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how can choose</title><link>https://community.arm.com/thread/77610?ContentTypeID=1</link><pubDate>Thu, 23 Jul 2009 07:57:49 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:bb9b619d-66d2-4755-bdba-98e8d3f131b1</guid><dc:creator>yu zhou</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;b&gt;&lt;i&gt;How can this code be generic, i.e. not related to any
processor architecture? Do you really think any processor can handle
your assembler code?&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
I wrote it for 51&lt;/p&gt;

&lt;p&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;
You (?) have written a function. If you call this function from a
loop, the code in the function will be processed identically as if
you call this function only once.&lt;br /&gt;&lt;/i&gt;&lt;/b&gt; What do you mean?&lt;/p&gt;

&lt;p&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;
If you need to clear more memroy, then you can write another
assembler function that performs a push/pop and then uses two nested
loops for the clear.&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
you mean if i want to avoid this situation that i described,only
write another function like you said!?&lt;/p&gt;

&lt;p&gt;
thank you!!!&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how can choose</title><link>https://community.arm.com/thread/89876?ContentTypeID=1</link><pubDate>Thu, 23 Jul 2009 07:51:20 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:99a3d77c-0ac7-4cfc-bec6-de5b59db05b3</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
Not if you follow the stated &lt;b&gt;Prologue:&lt;/b&gt;&lt;/p&gt;

&lt;pre&gt;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;NAME:    clearXdataNBytes
;FUNCTION:
;         This functioin clear n bytes in the external
;         space starting with the address specified
;PARAMETERS:
;         B(unsigned byte)---the numbers of bytes to ;be cleared!
;         DPTR(unsigned word)---the starting address
;RETURNS: None!
;PROLOGUE       BY      CALLING:
;    PUSH DPL,PUSH ;DPH,PUSH B,MOV DPTR,#startAddr,MOV ;B,#nbytes!
;EPILOG BY CALLING:NONE!
;NOTES:   The MAX number of bytes to be cleared is 255...
;EXAMPLES:
; ...&lt;b&gt;
; //Prologue:
; PUSH  DPL
; PUSH  DPH
; PUSH  B&lt;/b&gt;
; //Move the parameters
; MOV   DPTR,#startAddr
; MOV   B,#200
; //Call this function
; LCALL clearXdataNBytes
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how can choose</title><link>https://community.arm.com/thread/56477?ContentTypeID=1</link><pubDate>Thu, 23 Jul 2009 07:44:04 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:f81b3228-e858-4aaa-b76c-5be1ae057ec3</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
Well of course they are - that is the whole point of a loop!&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how can choose</title><link>https://community.arm.com/thread/89881?ContentTypeID=1</link><pubDate>Thu, 23 Jul 2009 07:33:14 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:3a2a164b-fcb6-4c45-8353-133cf4cc8a05</guid><dc:creator>Advanced Zeusti</dc:creator><description>&lt;p&gt;&lt;p&gt;
HI.&lt;/p&gt;

&lt;p&gt;
i think it is C51. sorry if not.&lt;/p&gt;

&lt;p&gt;
Always yo&amp;#39;re freind.&lt;/p&gt;

&lt;p&gt;
Zeusti.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how can choose</title><link>https://community.arm.com/thread/56478?ContentTypeID=1</link><pubDate>Thu, 23 Jul 2009 07:32:09 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:aab25c83-772d-4c88-910d-793d47edff78</guid><dc:creator>Advanced Zeusti</dc:creator><description>&lt;p&gt;&lt;p&gt;
HI.&lt;/p&gt;

&lt;p&gt;
mistake number won. u pop more than u push!&lt;/p&gt;

&lt;p&gt;
mistake number too. u do not need to preserve ACC or B or DPTR for
routine called by C51&lt;/p&gt;

&lt;p&gt;
Always yo&amp;#39;re freind.&lt;/p&gt;

&lt;p&gt;
Zeusti.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how can choose</title><link>https://community.arm.com/thread/56476?ContentTypeID=1</link><pubDate>Thu, 23 Jul 2009 07:12:02 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:af97c78d-b95d-4f90-8c2a-e7a4f17dd8b0</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
How can this code be generic, i.e. not related to any processor
architecture? Do you really think any processor can handle your
assembler code?&lt;/p&gt;

&lt;p&gt;
You (?) have written a function. If you call this function from a
loop, the code in the function will be processed identically as if
you call this function only once.&lt;/p&gt;

&lt;p&gt;
If you need to clear more memroy, then you can write another
assembler function that performs a push/pop and then uses two nested
loops for the clear.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how can choose</title><link>https://community.arm.com/thread/56475?ContentTypeID=1</link><pubDate>Thu, 23 Jul 2009 07:11:30 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:ddd580b0-3d05-4c61-8859-1189cbb6062d</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
How can this code be generic, i.e. not related to any processor
architecture? Do you really think any processor can handle your
assembler code?&lt;/p&gt;

&lt;p&gt;
You (?) have written a function. If you call this function from a
loop, the code in the function will be processed identically as if
you call this function only once.&lt;/p&gt;

&lt;p&gt;
If you need to clear more memroy, then you can write another
assembler function that performs a push/pop and then uses two nested
loops for the clear.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how can choose</title><link>https://community.arm.com/thread/56479?ContentTypeID=1</link><pubDate>Thu, 23 Jul 2009 07:10:44 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:afd73029-f0c5-4d4a-8905-08221dfff015</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
How can this code be generic, i.e. not related to any processor
architecture? Do you really think any processor can handle your
assembler code?&lt;/p&gt;

&lt;p&gt;
You (?) have written a function. If you call this function from a
loop, the code in the function will be processed identically as if
you call this function only once.&lt;/p&gt;

&lt;p&gt;
If you need to clear more memroy, then you can write another
assembler function that performs a push/pop and then uses two nested
loops for the clear.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>