Does that mean your example is still an error? static struct { unsigned char STK[128]; } s; void *v = (void *)(s.STK + 1); I think section 6.6 explicitly mentions this case: 7 More latitude is permitted for constant expressions in initializers. Such a constant expression shall be, or evaluate to, one of the following: ... — an address constant for a complete object type plus or minus an integer constant expression.
Ok, maybe that was the root of the problems I've seen? The z88dk library uses preserves_regs extensively.
The recent commit: https://sourceforge.net/p/sdcc/code/9998/tree/trunk/sdcc/src/z80/main.c?diff=513f4d42271846342871488b:9997&diformat=sidebyside would seem to indicate there were major bugs associated with preserves_regs on the z80 but I haven't seen any of that up to 9958 (I haven't updated from there yet because some bugs have been introduced since that I haven't had the time to locate yet). Was there a change after 9958 that required changing the register enumeration?
incorrect initialization of static array of pointers
Also reported in #2632
Works fine for me. Maybe try updating your install? 4,844 1.asm 80 1.c 715 1.ihx 238 1.lk 10,684 1.lst 13,367 1.map 1,192 1.mem 2,016 1.rel 10,684 1.rst 31,836 1.sym sdcc -v 3.6.8 9949 (MINGW64) >sdcc --verbose 1.c sdcc: Calling preprocessor... sdcc: sdcpp -nostdinc -Wall -std=c11 -obj-ext=.rel -D__SDCC_CHAR_UNSIGNED -D__SDCC_MODEL_SMALL -D__SDCC_FLOAT_REENT -D__SDCC=3_6_8 -D__SDCC_VERSION_MAJOR=3 -D__SDCC_VERSION_MINOR=6 -D__SDCC_VERSION_PATCH=8 -DSDCC=368 -D__SDCC_REVISION=9949 -D__SDCC_mcs51 -D__STDC_NO_COMPLEX__=1...
z80: array index incorrectly computed by truncating 16-bit computed value to 8-bit
Provided it knows which symbol is requested during linking and the object has its clear boundaries in library... That's the problem.. there are no clear boundaries in the library between items in the same file. That's why it's necessary to split into files first. If you know this from the beginning, it's less a big deal. However I'm more used to making libraries out of z80 asm functions where separation into files turns out to be a good way to organize asm code. This is less natural for C code I...
What's not being explicitly mentioned is that when you form your library you should have one function per file. The linker pulls out an entire file (proper name = module) when it forms the binary.
This one is now fixed too. Philip have you had a chance to run the tests yet on the current sdcc for the z80? I've moved on to testing more compiles and it seems there are more errors there.
signed comparison implemented as unsigned comparison by compiler leading to incorrect code
compiler wipes out register holding temp in if-else with reserve-regs-iy
Yes, sdcc #9883 is still available at the sdcc snapshot page and I've just verified that it does apply the full set of rules. Edit: Or rather more of them. The output still doesn't match the 9880 at the original website. I'll check if I missed something in the peep.def file. Edit: No nothing is missing. I think the discrepancy is down to there not being any interplay between the sdcc rules and peep.def in the examples we have here. In z88dk the two rulesets are together in the same file so they both...
Yes, sdcc #9883 is still available at the sdcc snapshot page and I've just verified that it does apply the full set of rules. Edit: Or rather more of them. The output still doesn't match the 9880 at the original website. I'll check if I missed something in the peep.def file. Edit: No nothing is missing. I think the discrepancy is down to there not being any interplay between the sdcc rules and peep.def in the examples we have here. In z88dk the two rulesets are together in the same file so they both...
Yes, sdcc #9883 is still available at the sdcc snapshot page and I've just verified that it does apply the full set of rules. Edit: Or rather more of them. The output still doesn't match the 9880 at the original website. I'll check if I missed something in the peep.def file.
Yes, sdcc #9883 is still available at the sdcc snapshot page and I've just verified that it does apply the full set of rules.
Yes that's how I found the rules. I think it's only going to let me attach one file. So here is test.c: #define GAME_LIN_FLOOR 152 extern unsigned char phase_left; extern unsigned char lin[8]; extern unsigned char col[8]; extern unsigned char sprite; extern void enemy_walk(void); extern void spr_destroy(unsigned char f_sprite) __z88dk_fastcall; void enemy_coin1(void){ //COINS N SLIPICE if ( phase_left > 0 ) { enemy_walk(); if ( ( lin[sprite] == GAME_LIN_FLOOR ) && ( col[sprite] == 3 || col[sprite]...
It was brought to my attention in this project: https://bitbucket.org/CmGonzalez/pietro_bros/overview The binary size increased from ~32700 bytes to ~34000 bytes. I could see that most peephole rules were not being applied. The enemy_coin1 function can be used as example. This is code generated by 9880: 811 0000 ; --------------------------------- 812 0000 ; Function enemy_coin1 813 0000 ; --------------------------------- 814 0000 _enemy_coin1: 815 0000 3A 00 00 ld a,(_phase_left) 816 0003 B7 or...
Philip, the patch applied is flawed. I found recently compiled programs were 2k+ larger because some peephole rules were not being applied. The code that is in there now in function matchLine(): static bool matchLine (char *s, const char *d, hTab ** vars) { if (!s || !(*s)) return FALSE; /* skip leading white spaces */ while (ISCHARSPACE (*s)) s++; while (ISCHARSPACE (*d)) d++; while (*s && *d) { /* if the destination is a var */ if (*d == '%' && ISCHARDIGIT (*(d + 1)) && vars) { const char *v =...
When I search for small-C the only target in common with SDCC I can find is the Z80. You'll find small C connected with the 8080, 8085, 8088, z80, 6502, 68xx. It had a lot of influence on compilers of that era because it was given away for free. Can I assume that there is no specification for Small-C and more specifically for its calling convention, making the original implementation the standard? Yes the original Small-C defined the convention. There might have been influence from Pascal because...
Signed char not promoted to signed int before pointer arithmetic
Bug in how SDCCpeeph.c matches source lines and peephole rules
In revision #9868, support for the Small-C calling convention in callees has been...
That should be "operandsNotRelated" and not "notOperandsRelated"
z80: bug in peephole rule #15
asz80 does not support those undocumented instructions. There's some previous discussion...
z80: smallc and _z88dk_callee c functions not flagged as error during compile
I put in "Front End" but this seems to be a z80-related problem.
compiler hangs for 32-bit left shift given int shift value
z80: seg fault caused by application of __smallc attribute
Z88DK v1.99B Released 10-Jan-2017
Z88DK v1.99B Released 10-Jan-2017
Z88DK v1.99B Released 10-Jan-2017
delayed error reporting for function prototypes with missing terminating semicolon
z80: stack frame set up for compiler generated c fastcall functions bugged for opt-code-size
z80: compiler generated c fastcall functions sometimes bugged for reserve-regs-iy
A litte further research and it turns out this is not a bug. The C standard specfies...
Escaped hex code in char string incorrectly encoded
If it's not the case, here's the point: isn't it the assignment in register E completely...
[quote] If it's not the case, here's the point: isn't it the assignment in register...
sdcc doesn't seem to properly cost use of iy; I always get much better code as a...
z88dk can automatically create these banks but it's using a different linker than...
You may also want to check if chars need to be signed. By default they are unsigned...
Have a look at z88dk: http://www.z88dk.org/wiki/doku.php?id=libnew:target_embedded...
Subtraction of Result of Two Independent Function Calls Incorrectly Eliminated
No, the compiler would be forced to generate poor code which would wipe out any gains....
I figured out how to do the code size reduction from the peepholer and a little post-processing....
I figured out how to do the code size reduction from the peepholer and a little post-processing....
I figured out how to do the code size reduction from the peepholer and a little post-processing....
Small bump to indicate the bug is still present for the z80 in 3.5.6 #9605 (MINGW64)....
The code is definitely bugged when c is made unsigned and will produce incorrect...
The code is incorrect for unsigned char - the programmer should be using signed char....
This bug occurs in nearly all 64-bit programs I have been test compiling. The compiler...
Ah, if you compile with "--no-peep" the single-byte-at-a-time push of a 64-bit number...
I no longer have that original code fragment -- I thought sdcc was doing that all...
[z80] union and 64-bit type fatal internal compiler error
I've been adding longlong to z88dk for sdcc and found that the code sdcc is generating...
You can insert code that has no side effects to registers anywhere ("di" and "ei"...
I think it actually works Ben. We don't see an example of actually using the parameter...
(when not inlined) This loads the value into dehl, calls swap_words which accepts...
The generated code looks correct to me? Maybe point out version, compile line and...
The generated code looks correct to me? Maybe point out version, compile line and...
The generated code looks correct to me? Maybe point out version, compile line and...
The generated code looks correct to me? Maybe point out version, compile line and...
The generated code looks correct to me? Maybe point out version, compile line and...
The generated code looks correct to me? Maybe point out version, compile line and...
Ben I think you misunderstand -- the rule is incorrect and leads to generation of...
Btw. Alvin, it would really help if you can also provide a test case that exhibits...
This means the difference is much smaller, but the 3 rules still perform worse than...
Btw. Alvin, it would really help if you can also provide a test case that exhibits...
Ben I don't think you understand -- the rule is incorrect and leads to generation...
We pluck the sdcc binary out and insert into our own toolchain with front end, libraries,...
[z80] Peephole Rule #25 Incorrect
sdcc mangles string constants in inlined asm
sdcc -v 9507 MSVC The original code is generating a warning: test7.c:35: warning...
sdcc -v 9507 MSVC The original code is generating a warning: test7.c:35: warning...
Thanks Ben - everything works as expected now.
Yes as Peter says, I'm not saying the code should be accepted -- I'm saying that...
Hi Ben, the fix works on the test cases thanks. I took a hint from the error message...
compile line used to produce output assembly: sdcc -mz80 -S test.c
Incorrect Initiaization of Global Array Containing Pointers
Maybe similar to sverx and a solution I am trying with peephole rules below. This...
Maybe similar to sverx and a solution I am trying with peephole rules below. This...
Maybe similar to sverx and a solution I am trying with peephole rules below. This...
Maybe similar to sverx and a solution I am trying with peephole rules below. This...
Maybe similar to sverx and a solution I am trying with peephole rules below. This...
Maybe similar to sverx and a similar solution I am trying with peephole rules below....
I had some build trouble with MSVC so hopefully it isn't affecting the results here....
I had some build trouble with MSVC so hopefully it isn't affecting the results here....
It looks like the z88dk_fastcall decoration has to be last.
I've got a patch that will fix "ex de,hl", "ex (sp),hl", the load issues and the...
I ran across the same code generation error and again only if --reserve-regs-iy is...
ok. I updated the patch to the version I'll foist on z88dk. I found one more bug:...
I've got a patch that will fix "ex de,hl", "ex (sp),hl", the load issues and the...
I've got a patch that will fix "ex de,hl", "ex (sp),hl", the load issues and the...
Ben, here is a patch for sdcc/src/z80/peeph-z80.def I did not touch rules after the...
Ben, here is a patch for sdcc/src/z80/peeph-z80.def
I found three cases in the source code I was testing: Scanning ld ((_udata + 0x000c)),...
sorry ben, i got a really bad flu in december and then forgot about it :/ The issues...
Yes I realize it's all a work in progress :) I'm poking at the peepholer quite a...