Comments (4)
Hi Philipp,
issue 1
Unfortunately, I didn't keep the files when I found that problem. I can't find any examples anymore, so I assume it was fixed in one of the later compiler revisions.
issue 2
minimal example code:
int array[4];
void array_access(unsigned char index)
{
array[index] = 0;
}
compiled using the latest snapshot build 9998:
$ /opt/sdcc/bin/sdcc -c -mstm8 issue14-2.c
$ /opt/sdcc/bin/sdcc -v
SDCC : mcs51/z80/z180/r2k/r3ka/gbz80/tlcs90/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8 3.6.9 #9998 (Linux)
published under GNU General Public License (GPL)
results in this code:
000000 47 _array_access:
000000 52 02 [ 2] 48 sub sp, #2
49 ; issue14.c: 6: array[index] = 0;
000002 AEr00r00 [ 2] 50 ldw x, #_array+0
000005 1F 01 [ 2] 51 ldw (0x01, sp), x
000007 7B 05 [ 1] 52 ld a, (0x05, sp)
000009 97 [ 1] 53 ld xl, a
00000A A6 02 [ 1] 54 ld a, #0x02
00000C 42 [ 4] 55 mul x, a
00000D 72 FB 01 [ 2] 56 addw x, (0x01, sp)
000010 6F 01 [ 1] 57 clr (0x1, x)
000012 7F [ 1] 58 clr (x)
000013 5B 02 [ 2] 59 addw sp, #2
000015 81 [ 4] 60 ret
When I look at it I see that the mul
command already includes the transfer of the result into x which needs to happen anyway. It would be great if the temporary variable (0x01,sp) could be avoided in the first place.
issues 3-5
Thank you for your explanation!
I noticed the recent changes in the backend, the optimizer and the simulator. I would like to compare the development of the code size compared to an older version. Thank you for all the work there!
Michael
from sduino.
Issue 2: Thanks. I can see how using sllw could save 1 byte and 2 cycles vs the current solution using mul. I'll probably look into implementing it next week.
Philipp
P.S.: Eliminating the temporary at (1,sp) would take more effort, since it needs an optimization capable of folding ADDRESS_OF into '+'.
from sduino.
As of revision #10000, a sllw is used instead of the mul. The mcs51 backend can optimize out the temporary that holds the array address; I'll look into porting the solution to stm8 (and maybe z80).
Philipp
P.S.: See also https://sourceforge.net/p/sdcc/feature-requests/536/
from sduino.
sllw works with rev. 10088 and saves one byte.
I am looking forward to see the temporary optimized out, that could save 7 bytes on every array access. I will follow the discussion on SF, no need to duplicate it here.
from sduino.
Related Issues (20)
- Disable I2C ports PB4 PB5 HOT 1
- ERROR: Timer and interrupt on STM8 using SPL HOT 9
- unable to install in arduino 2 beta HOT 1
- Cannot upload STM8S-discovery board using its ST-link
- Any chance for STM7? HOT 7
- PA1 on the STM8S105x4/6 cannot be an interrupt
- IRQ example not quite right
- Not enough memory when compiling the oled-mini example HOT 1
- STM8S103 with arduino IDE has error HOT 3
- Space in username causes compile error.
- Software Reset not implemented
- Generic selection functional after SDCC 13402
- Is there possible software serial support?
- Compilation error when including .c file from the same directory
- Lack of example of using I2C. Event interrupts not implemented? HOT 5
- 'Upload using programmer' fails with "Error while uploading: missing 'program.params.verbose' configuration parameter" HOT 3
- Arduino IDE 2.0.3 gives "Error: 13 INTERNAL: Cannot install platform: installing platform" HOT 1
- Sleep and interrupt in Sduino HOT 2
- FAQ: Output high frequency PWM ?
- Cannot get PC5 to be high
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sduino.