| ??? 12/03/02 22:10 Read: times |
#33704 - Or, inline assembler: |
mov r0,#0x10 ; number of pages to waste
mov a,#0x00 ; value to waste the pages with mov dph,#0x90 ; high byte of start of memory mov dpl,#0x00 ; low byte of start of memory mov r1,#0x00 ; inner loop count, set to 256 loop1: movx @dptr,a inc dptr djnz r1,#loop1 djnz r0,#loop1 I have seen such bloated compiled code that I have said to hell with compiling C for the 8051. In the above example, load DPTR with the same address that would have been passed to memset() in the first argument. Next, load ACC with the value that would have been memset's arg2. And lastly, load r0 with the number of 256 byte pages to apply the new value. IF the resultant memory block were not a multiple of 256, the code would be slightly larger. As long as the number of bytes is the product of two integers (one integer being the outer loop, the other integer being the inner loop) then it is still do-able. It would be much more complex if the total number of bytes were greater than 255 AND a prime number. I assure you your c compiler thinks about $hit like this. It tries to form the simplest/fastest code possible. But I find that hand rolled assembler usually beats it. PLUS it makes the programmer so much better at the Art of Programming. http://www.tigerprecision.com |
| Topic | Author | Date |
| Intialising arrays | 01/01/70 00:00 | |
| RE: Intialising arrays | 01/01/70 00:00 | |
| RE: Intialising arrays | 01/01/70 00:00 | |
| RE: Intialising arrays | 01/01/70 00:00 | |
| RE: Intialising arrays | 01/01/70 00:00 | |
| RE: Intialising arrays | 01/01/70 00:00 | |
| Or, inline assembler: | 01/01/70 00:00 | |
| RE: Or, inline assembler: | 01/01/70 00:00 | |
| RE: Or, inline assembler: | 01/01/70 00:00 | |
| Rob, that is precisely what to do | 01/01/70 00:00 | |
RE: Or, inline assembler: | 01/01/70 00:00 |



