Re: [Sdcc-user] PDK calling convention

2024-01-14 Thread Basil Hussain
e top 4 bits of flag aren't writeable, and the docs say they always read as '1', so I presume any value in that register will be 0b when saved to the stack. An interesting thought experiment nonetheless. Regards, Basil Hussain _

Re: [Sdcc-user] PDK peephole rules - notUsed('a') seems to give bogus results

2024-01-13 Thread Basil Hussain
need these snippets of inline assembly. Is there any scope for changing the PDK code generation to use t1sn.io/t0sn.io? Regards, Basil Hussain ___ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user

Re: [Sdcc-user] PDK calling convention

2024-01-13 Thread Basil Hussain
t you'd have to reset it back to zero before it is used by any SDCC-generated code. So you'd have to disable interrupts before using the byte (and then reeenable them again after zeroing the byte). Yes, precisely. I hadn't thought about interrupts attempting to use P, thanks

Re: [Sdcc-user] PDK calling convention

2024-01-12 Thread Basil Hussain
kay to use the upper byte of P for arbitrary purposes, so long as that byte is always reset back to zero afterwards? Regards, Basil Hussain ___ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user

[Sdcc-user] PDK calling convention

2024-01-12 Thread Basil Hussain
er? Functions always return using 'ret' instruction? That is, no 'goto' shenanigans? Are there any differences between PDK13, 14, 15? Regards, Basil Hussain ___ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://l

Re: [Sdcc-user] PDK peephole rules - notUsed('a') seems to give bogus results

2024-01-11 Thread Basil Hussain
d well at most conditions", which, apart from other issues discussed within the ticket, hindered the proper application of the submitter's rules too. Regards, Basil Hussain ___ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://li

Re: [Sdcc-user] PDK peephole rules - notUsed('a') seems to give bogus results

2024-01-11 Thread Basil Hussain
ll do that. Regards, Basil Hussain ___ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user

[Sdcc-user] PDK peephole rules - notUsed('a') seems to give bogus results

2024-01-10 Thread Basil Hussain
2     set0.io    __intrq, #2 00103$:     pop    af     mov    p, a     pop    af     reti You can see that for the lines following those that would match the first rule, no matter which branch is taken, the first use of A reg is to have something assigned to it

Re: [Sdcc-user] uCsim STM8: unexplainable discrepancy in timer values

2022-12-18 Thread Basil Hussain
On 18/12/2022 11:14, Daniel Drotos wrote: Can you send me hex of your two compiled test programs, A and B, please? I have sent you a hex file off-list. Regards, Basil Hussain ___ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https

Re: [Sdcc-user] uCsim STM8: unexplainable discrepancy in timer values

2022-12-18 Thread Basil Hussain
is an undocumented switch as far as I can see. Also, what is the difference between setting "sim_run=1" and the "run" command? Surely the latter should do what it says regardless of context? Regards, Basil Hussain ___ Sdcc-user

Re: [Sdcc-user] uCsim STM8: unexplainable discrepancy in timer values

2022-12-17 Thread Basil Hussain
int stopping execution and the last command in the breakpoint script being "run"? It seems to actually process the "run", as evidenced by the "Simulation started..." line, but stops regardless. Regards, Basil Hussain

[Sdcc-user] uCsim STM8: unexplainable discrepancy in timer values

2022-12-17 Thread Basil Hussain
ces in measured cycles from? I seem to recall that although cycle counts for some STM8 instructions were incorrect in older SDCC releases, they had been corrected quite a while ago - are some still incorrect? This is with uCsim 0.6.4 from SDCC 4.2.0. Regards, Basil Hussain _

Re: [Sdcc-user] Bad code generated having no SP rewind after function call

2022-10-21 Thread Basil Hussain
n 'foo' is in fact a __naked inline assembly function, where I am not cleaning the function arguments from the stack. Regards, Basil Hussain P.S. By the way, now I am looking at the manual again, is there not a mistake in section 4.5.1.2 describing calling convention version 0? It sa

[Sdcc-user] Bad code generated having no SP rewind after function call

2022-10-20 Thread Basil Hussain
ing to mitigate by rearranging my code in all sorts of ways, yet I cannot convince SDCC to emit the proper stack clean-up code for the affected function call. Anyone have any advice? Regards, Basil Hussain P.S. SDCC version: SDCC : mcs51/z80/z180/r2k/r2ka/r3ka/sm83/tlcs90/ez80_z80/z80n/ds

[Sdcc-user] Why are my string constants being redundantly duplicated?

2022-10-01 Thread Basil Hussain
re the strings directly in the array. But I fear I might end up having to do this if this duplicated strings problem is unresolvable. Regards, Basil Hussain P.S. SDCC version: SDCC : mcs51/z80/z180/r2k/r2ka/r3ka/sm83/tlcs90/ez80_z80/z80n/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8/pdk13/pdk

[Sdcc-user] What are the criteria for "conditional flow changed by optimizer..." warnings?

2022-09-22 Thread Basil Hussain
If zero, return false. Otherwise, mask out 'up' bit to set it to false, and return true. Where is the supposed change in conditional flow? It seems to be warning about nothing. Regards, Basil Hussain ___ Sdcc-user mailing list Sdcc-user

Re: [Sdcc-user] STM8: Incorrect optimization

2022-09-17 Thread Basil Hussain
willing to file one on his behalf. Regards, Basil Hussain ___ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user

Re: [Sdcc-user] STM8: Incorrect optimization

2022-09-14 Thread Basil Hussain
');     ld    a, (0x01, sp)     add    a, #0x30     pop    a     jp    _disp_putc 00101$: ;    foo.c: 18: }     pop    a     ret My SDCC version: SDCC : mcs51/z80/z180/r2k/r2ka/r3ka/sm83/tlcs90/ez80_z80/z80n/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8/pdk13/pdk14/pdk15/mos6502 4.

Re: [Sdcc-user] SDCC version numbers and calling version

2022-09-10 Thread Basil Hussain
calling convention, then this doesn't help, but I thought this approach was the most expedient for getting existing inline assembly code compiling with 4.2.0+. Regards, Basil Hussain ___ Sdcc-user mailing list Sdcc-user@lists.sourcefo

Re: [Sdcc-user] Any way to eliminate unnecessary STM8 DIV workaround from an ISR?

2022-08-13 Thread Basil Hussain
of the DIV workaround in their ISRs for no real reason. But then if you're that concerned about performance, you would be looking at the output assembly anyway, and discover it - like I was. :) Regards, Basil Hussain ___ Sdcc-user mailing list S

Re: [Sdcc-user] Any way to eliminate unnecessary STM8 DIV workaround from an ISR?

2022-08-13 Thread Basil Hussain
b-call to ___memcpy() - but I don't see why that would ever be using a DIV/DIVW instruction. Regards, Basil Hussain ___ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user

[Sdcc-user] Any way to eliminate unnecessary STM8 DIV workaround from an ISR?

2022-08-12 Thread Basil Hussain
on, which I don't want to happen, so I'd prefer if there was some other way. Regards, Basil Hussain ___ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user

Re: [Sdcc-user] A technique for STM8 to automatically bootstrap assembly functions to RAM

2022-08-04 Thread Basil Hussain
x27;t make any provision for code written in C, I don't know how relevant it may be for people looking for solutions in that context. Regards, Basil Hussain ___ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net

Re: [Sdcc-user] Possible changes to inline assembler syntax

2022-07-14 Thread Basil Hussain
atic C variables with whatever assembly symbol is associated with it. I always feel dirty relying on the informal implementation detail of SDCC making assembly symbols the same as the variable name prefixed with an underscore (e.g. "foo" => "_foo"). Regards, Basil Huss

Re: [Sdcc-user] ucSim STM8 stack pointer wrapping

2022-04-22 Thread Basil Hussain
ck of 512 bytes on their memory map, so one could assume that they behave the same as the STM8S/AF. But, without parts in hand to actually test, who really knows... Regards, Basil Hussain ___ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net h

Re: [Sdcc-user] ucSim STM8 stack pointer wrapping

2022-04-21 Thread Basil Hussain
cally roll over". Because, I guess, thinking about it, what would be the point of the latter? Regards, Basil Hussain ___ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user

Re: [Sdcc-user] ucSim STM8 stack pointer wrapping

2022-04-21 Thread Basil Hussain
overwrite existing data? Do you know which STM8 parts these are that have a limit but do not have roll-over? Regards, Basil Hussain ___ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user

Re: [Sdcc-user] ucSim STM8 stack pointer wrapping

2022-04-20 Thread Basil Hussain
M0016, section 3.1.2 "Stack handling" has a note on Figure 4 saying "The stack roll-over limit is not implemented on all devices". I'm not actually aware of any STM8 devices that _don't_ have a stack limit. Does anybody know of any t

[Sdcc-user] ucSim STM8 stack pointer wrapping

2022-04-18 Thread Basil Hussain
2 and pop1/pop2 macros (in stm8mac.h) appear to simply decrement/increment in an unbounded manner, and may not implement any SP wrapping. Regards, Basil Hussain ___ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge

Re: [Sdcc-user] Updating Code::Blocks IDE integration

2022-03-04 Thread Basil Hussain
::Blocks, 20.03, I am maintaining a version of the compiler options file compatible with that (the version currently in C::B trunk is incompatible) in a GitHub repository: https://github.com/basilhussain/codeblocks-sdcc-options. Regards, Basil Hussain

Re: [Sdcc-user] Updating Code::Blocks IDE integration

2022-03-02 Thread Basil Hussain
Question: for options that don't work on all ports, are they silently ignored, or will SDCC give an error? No. It will give a warning. Okay, that's good. It means if a user selects an option which doesn't apply to their target architecture, they'll know about it as soon as they attempt to

Re: [Sdcc-user] Updating Code::Blocks IDE integration

2022-03-02 Thread Basil Hussain
gt; Not sure if this works for all ports. Guess I could remove it then, as it's a pretty specialised and probably very rarely used option. Question: for options that don't work on all ports, are they silently ignored, or will SDCC give an error? Regards, Basil Huss

[Sdcc-user] Updating Code::Blocks IDE integration

2022-03-02 Thread Basil Hussain
. Regards, Basil Hussain P.S. If it aids comprehension, a reference of Code::Blocks compiler options syntax can be found here: https://wiki.codeblocks.org/index.php/Compiler_options_file

[Sdcc-user] Did --std-sdcc95 command line option ever exist?

2022-03-01 Thread Basil Hussain
Also adding the newer options for C2x and others such as --sdcccall. Regards, Basil Hussain ___ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user

Re: [Sdcc-user] New __sdcccall(0) attribute does not work with __naked - bug?

2022-02-24 Thread Basil Hussain
On 24/02/2022 18:33, Philipp Klaus Krause wrote: Looks like a bug to me. Please file a bug report. Thanks for confirming. I have filed a bug report: https://sourceforge.net/p/sdcc/bugs/3332/ Regards, Basil Hussain ___ Sdcc-user mailing list Sdcc

[Sdcc-user] New __sdcccall(0) attribute does not work with __naked - bug?

2022-02-24 Thread Basil Hussain
whether prologue and epilogue code inside that function is generated. Regards, Basil Hussain ___ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user

Re: [Sdcc-user] How to keep old STM8 calling ABI

2022-02-24 Thread Basil Hussain
ly how the function is to be called by other code, but also affects how SDCC generates code to access args within the function. Regards, Basil Hussain P.S. There is a minor error in the user manual in section 4.5.1.2. The second sentence begins "The stack is the stack is not adjusted for

[Sdcc-user] A technique for STM8 to automatically bootstrap assembly functions to RAM

2022-01-18 Thread Basil Hussain
foo.s' and the output object file linked as per normal. If anyone has an questions, feel free to ask. :) Regards, Basil Hussain P.S. In case you're wondering why I needed this, it's because I was experimenting with self-modifying assembly

Re: [Sdcc-user] Standard library printf() %p endianness

2021-11-12 Thread Basil Hussain
I have created a feature request: https://sourceforge.net/p/sdcc/feature-requests/756/ Included there is a test program to demonstrate the issue. If I have time, and I can get my SDCC build environment going again, I may try to fix it myself and submit a patch. Regards, Basil Hussain On

Re: [Sdcc-user] Standard library printf() %p endianness

2021-11-11 Thread Basil Hussain
plementation defined", but I think this should be fixed. Shall I create a feature request? Or a bug report? Regards, Basil Hussain On 10/11/2021 22:38, Basil Hussain wrote: Hi all, Quick question: was the SDCC standard library printf() implementation for the %p conversion specifier

[Sdcc-user] Standard library printf() %p endianness

2021-11-10 Thread Basil Hussain
arget platforms such as the STM8. Whenever you use %p, the pointer value is formatted with the bytes in the wrong order. For example, a pointer with value of 0x87A1 is output as "0xa187". It's annoying to have to mentally transpose the bytes when looking at debugging output. Re

[Sdcc-user] STM8 assembly syntax highlighting for Code::Blocks IDE

2021-11-02 Thread Basil Hussain
. :) Regards, Basil Hussain ___ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user

Re: [Sdcc-user] SDAS assembler doesn't support .define, etc. directives?

2021-10-30 Thread Basil Hussain
gument for displaying .define substitutions in source listings? Regards, Basil Hussain On 30/10/2021 16:32, Basil Hussain wrote: Hi all, Does the version of AS used for SDAS assemblers not support .define directives? I am tearing my hair out trying to figure out if it doesn't actually

[Sdcc-user] SDAS assembler doesn't support .define, etc. directives?

2021-10-30 Thread Basil Hussain
than when forked, but the .define directive (and it's siblings, .undefine, .ifdef, .ifndef, etc.) is actually mentioned in the SDAS docs that are included with SDCC. So what is going on here? Regards, Basil Hussain ___ Sdcc-user mailing list S

Re: [Sdcc-user] More functions for bit manipulation (Rotation, population count, endianness, etc) in the standard libary?

2021-10-03 Thread Basil Hussain
t thing is some stdlibs having a strrev(). Regards, Basil Hussain Disclaimer: I have written an optimised assembly library for STM8 that covers most of the mentioned functionality: https://github.com/basilhussain/stm8-utils. So my opinions may be slightly biased... :) On 03/10/2021 08:57, Phil

Re: [Sdcc-user] A possible new calling convention for stm8

2021-06-28 Thread Basil Hussain
sters were not in their original state when returning to ROM code. Regards, Basil Hussain ___ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user

Re: [Sdcc-user] A possible new calling convention for stm8

2021-06-25 Thread Basil Hussain
mory model, stack cleanup for stack parameters is done by the calle for some cases Typo obscures understanding here: is that supposed to be "caller" or "callee"? Regards, Basil Hussain ___ Sdcc-user mailing list Sdcc-user@li

[Sdcc-user] Pragma disable_warning and save/restore

2021-06-15 Thread Basil Hussain
s section of the manual explicitly stated whether each pragma can be saved and restored. Regards, Basil Hussain ___ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user

Re: [Sdcc-user] Interesting observation with SDCC (stm8)

2021-02-18 Thread Basil Hussain
#0x02     ld    %1+%3, a } by {     bset    %1+%3, #1 } if notUsed('a'), notUsed('n'), notUsed('z'), operandsLiteral(%3) The rule would need to be repeated to cover every bit position - e.g. #0x01, #0x02, #0x04, etc. for 'or' instruction

Re: [Sdcc-user] (STM8) Checking code and ram size

2021-01-23 Thread Basil Hussain
developed - see https://github.com/basilhussain/stm8-bootloader-erase-write/blob/main/src/check-seg-size.awk. I know I am missing something, but what is it? You're missing that the options you tried don't exist or don't have any effect on the target platform

Re: [Sdcc-user] Perplexed by varying STM8 assembly formatting

2020-12-12 Thread Basil Hussain
On 12/12/2020 16:26, Philipp Klaus Krause wrote: The code is correct, so it's not a bug. I suggest to file a feature request instead. Okay. I have filed feature request #728. Basil ___ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://

Re: [Sdcc-user] Perplexed by varying STM8 assembly formatting

2020-12-12 Thread Basil Hussain
rate different formatting for what ends up as the same instruction. Like I said earlier, it makes writing peephole optimiser rules needlessly difficult when there are such inconsistencies. Is it worth filing a bug report to address this? Regards, Basil Hussain ___ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user

Re: [Sdcc-user] Perplexed by varying STM8 assembly formatting

2020-12-12 Thread Basil Hussain
rOf, but the second case does not. Regards, Basil Hussain ___ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user

[Sdcc-user] Perplexed by varying STM8 assembly formatting

2020-12-11 Thread Basil Hussain
t;ldw    x, #(%1 + %3)", and one to match "ldw    x, #%1+%3", which is a whole lot of duplication for no good reason. Regards, Basil Hussain ___ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user

Re: [Sdcc-user] Does callee-saves option work for STM8?

2020-12-07 Thread Basil Hussain
I noticed it wasn't working. Any particular reason why callee-saves has not been implemented for STM8? Regards, Basil Hussain ___ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user

[Sdcc-user] Does callee-saves option work for STM8?

2020-12-07 Thread Basil Hussain
s wouldn't happen to be one of those SDCC features that is 8051-specific, but not documented as such? Regards, Basil Hussain ___ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user

Re: [Sdcc-user] ucSim serial interface redirection on Windows

2020-12-04 Thread Basil Hussain
On 04/12/2020 09:43, Philipp Klaus Krause wrote: There are newer builds on the snapshot page (usually about one day behind current trunk in svn), including Windows binaries: Oh, of course, I forgot about those. Thanks for reminding me. I will try the latest snapshot ucSim and see if it solves

Re: [Sdcc-user] ucSim serial interface redirection on Windows

2020-12-04 Thread Basil Hussain
On 04/12/2020 07:25, Daniel Drotos wrote: I'll try to test it. You mentioned "io ninja", I'll intall it. How do you create pipes with it? I've only recently started using IO Ninja myself, so I'm certainly no expert on it, but I played with the Pipe Server functionality: File > New Session >

Re: [Sdcc-user] ucSim serial interface redirection on Windows

2020-12-03 Thread Basil Hussain
On 03/12/2020 19:28, Daniel Drotos wrote: I do not have too much experience with windows, but on unix, this is normal. This is the behavior of the pipe, not the app. When first program opens one end of the pipe, it will be blocked by the OS. It waits to open other end. You have to start a progr

[Sdcc-user] ucSim serial interface redirection on Windows

2020-12-03 Thread Basil Hussain
ve first tried to type anything in the ucSim console, and then send data to the pipe, it makes what I typed appear, but the console is still unresponsive. It seems like the console is blocked, and piping data somehow temporarily causes it to be unblocked. Any ideas? Is this a bug in ucSim? Re

Re: [Sdcc-user] RAM program

2020-11-27 Thread Basil Hussain
w disassembly, it doesn't look like that. Maybe some global variable is used - the code certainly reads and writes several locations in the 0x80-0x90 area. Regards, Basil Hussain ___ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user

Re: [Sdcc-user] RAM program

2020-11-23 Thread Basil Hussain
ut from compilation? Or maybe the Hex file? Regards, Basil Hussain ___ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user

Re: [Sdcc-user] RAM program

2020-11-21 Thread Basil Hussain
ably getting some garbage value from the stack as an argument and going in to an infinite loop or some other unexpected behaviour, and not blinking the LED. Try instead substituting value of "-j" arg with whatever address main() is actually at - check the .map file after linking. Regard

Re: [Sdcc-user] Another question about interrupts on STM8

2020-11-19 Thread Basil Hussain
l be, so maybe that's not a problem given the S208's specification of 10k write cycles. But it would be suicide on smaller chips, like the STM8S003, where flash is only specified for 100 (yes, one hundred) write cycles. Regards, Basil Hussain

Re: [Sdcc-user] Another question about interrupts on STM8

2020-11-18 Thread Basil Hussain
SINIT segment with a command line argument: "-Wl-bGSINIT=0x8080". Regards, Basil Hussain On 18/11/2020 22:10, Karsten Langeloh wrote: Hello everyone, no this is not the "how do i do interrupts with sdcc" question :) I have used sdas-stm8 in the past to convert some &q

Re: [Sdcc-user] ASxxxx assembler looping macro

2020-07-30 Thread Basil Hussain
I figured something out. I think my problems were mostly down to the fact I was using a literal value as argument to the macro (e.g. "foo 6"). The assembler is not creating a new variable 'n' inside the macro, it is just substituting the argument in place of 'n'. So, of course, where there is "

[Sdcc-user] ASxxxx assembler looping macro

2020-07-28 Thread Basil Hussain
  ; ...etc...     ld a, #0     adc a, (0, sp)     ld (0, sp), a Anyone know how to do this? Regards, Basil Hussain ___ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user

Re: [Sdcc-user] ucSim instruction cycle counts - where defined?

2020-07-26 Thread Basil Hussain
I sat down this afternoon to take a look at seeing if I could myself make the modifications to ucSim to add better cycle counting by adding tick() calls... But after updating from SVN, configure, make, etc. I ran a little test case with some assembly with multi-cycle instructions and was very

Re: [Sdcc-user] ucSim instruction cycle counts - where defined?

2020-07-24 Thread Basil Hussain
Would it be much effort to implement a simplified version, i.e. ignoring pipelining, just counting a fixed number of cycles per instruction? Is it not just a case of ensuring that calls to tick() with appropriate argument value are implemented in the right places? Specifically, all the inst

Re: [Sdcc-user] ucSim instruction cycle counts - where defined?

2020-07-23 Thread Basil Hussain
It needs some work to make it more realistic. Yes. I was looking at the source code just now (stm8.src/stm8.cc and stm8.src/inst.cc) and it seems clock cycles are incremented by use of a tick() function call. All instructions appear to be assumed as taking 1 cycle by default, with addition

Re: [Sdcc-user] ucSim instruction cycle counts - where defined?

2020-07-23 Thread Basil Hussain
Nowhere, and nothing defines that. Correct tick counting is not implemented in uCsim (except s51). It counts 1 clock (tick) for every instruction which will be unreal especially when lot of jumps happen. Oh, I don't expect ucSim to fully and exactly replicate STM8 behaviour, including pipel

Re: [Sdcc-user] ucSim instruction cycle counts - where defined?

2020-07-22 Thread Basil Hussain
Yes, I am aware that the STM8 has a pipelined architecture. I don't think that this can be wholly explained by that. Let me provide some context. My benchmark for my strcpsn implementation performs 1000 iterations of the following: strcspn("1620376B3653", "abcdefghijklmnopqrstuvwxyzABCDEFGHI

[Sdcc-user] ucSim instruction cycle counts - where defined?

2020-07-22 Thread Basil Hussain
x27;t used elsewhere. Regards, Basil Hussain ___ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user

Re: [Sdcc-user] STM8 peephole rules to make better use of btjt/btjf instructions

2020-07-16 Thread Basil Hussain
Feature request, not bug, as the generated code is correct. Ah, yes, that's true. Sorry. Thanks for moving the ticket. ___ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user

Re: [Sdcc-user] STM8 peephole rules to make better use of btjt/btjf instructions

2020-07-15 Thread Basil Hussain
I have covered all the bases with the conditions/restrictions. Regards, Basil Hussain On 15/07/2020 20:21, Philipp Klaus Krause wrote: I'd suggest to open a ticket item if there is none yet. With the peephole rules and code samples to reproduce the inefficient code. Maybe part of it can

[Sdcc-user] STM8 peephole rules to make better use of btjt/btjf instructions

2020-07-15 Thread Basil Hussain
had to repeat some rules. Although, it seems the existing bset/bres/bcpl rules do this too, so maybe it's not actually possible to make the transformation. One other thing to note is that I figured it's not worth bothering to optimise ld+jrmi/jrpl to btjt/btjf (used when testing bit 7) because they are same number of cycles and bytes. Regards, Basil Hussain ___ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user

Re: [Sdcc-user] sdasstm8 listing output - no. of cycles of DECW instruction wrong?

2020-06-29 Thread Basil Hussain
he later 'pg90' table? 0x5A in that also gives a value of 2. Are these the correct locations? Regards, Basil Hussain ___ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user

[Sdcc-user] sdasstm8 listing output - no. of cycles of DECW instruction wrong?

2020-06-29 Thread Basil Hussain
document says (pg. 100) that this instruction takes 1 cycle. ucSim also runs DECW in a single cycle, which agrees with the docs. Which is correct? Regards, Basil Hussain ___ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https

Re: [Sdcc-user] STM8 standard library - why no optimised routines in 'large' version?

2020-06-19 Thread Basil Hussain
ge for its type", and some to do with trigraph operators. Given this, can I be 100% confident that my modifications are successful? I will create and submit a patch if so. Regards, Basil Hussain ___ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user

Re: [Sdcc-user] STM8 standard library - why no optimised routines in 'large' version?

2020-06-19 Thread Basil Hussain
. What was puzzling was that even doing a "make clean" didn't solve the problem, because for some reason that doesn't delete the end-product of the build, the .lib file, like one might expect it to. Running the regression tests again now, so far without warnings... Re

Re: [Sdcc-user] STM8 standard library - why no optimised routines in 'large' version?

2020-06-18 Thread Basil Hussain
ines referencing either the library name ("stm8" vs "stm8-large") or the SDCC command line (addition of "--model-large"). The only (single) mention of "strcmp" and "strcpy" is in the OBJ definition, where .rel files with those names

Re: [Sdcc-user] STM8 standard library - why no optimised routines in 'large' version?

2020-06-18 Thread Basil Hussain
at now have assembly implementations will no longer be included in the lib. That is, change the STM8_INT, STM8_LONG, STM8_LONGLONG and OBJ definitions to match the non-large lib's Makefile.in. If I have modified only the lib's Makefile.in, how do I then re-generate the Make

Re: [Sdcc-user] STM8 standard library - why no optimised routines in 'large' version?

2020-06-18 Thread Basil Hussain
oes this sound correct? Any other 'gotchas'? I am thinking I will try to copy and convert the code for use in the 'large' STM8 library and create a patch. If I do so, how can I test that my changes are working correctly? Can the regression tests do this? If so, how do I run

[Sdcc-user] STM8 standard library - why no optimised routines in 'large' version?

2020-06-18 Thread Basil Hussain
uch slower after I compiled it with --model-large. Now I know why... Regards, Basil Hussain ___ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user

Re: [Sdcc-user] Is this a good candidate for a peephole optimisation rule? (STM8)

2020-06-03 Thread Basil Hussain
of a register ('0x...'), which would preclude the whole rule! I implemented the optimization in code generation: https://sourceforge.net/p/sdcc/code/11643/ That's awesome, thanks very much! Regards, Basil Hussain ___ Sd

Re: [Sdcc-user] Is this a good candidate for a peephole optimisation rule? (STM8)

2020-06-02 Thread Basil Hussain
page_enum_t is: typedef enum {     CAN_PG_TX_MBOX_0 = 0,     // ...     CAN_PG_RX_FIFO = 7 } can_page_enum_t; CAN_PSR is defined as: #define CAN_PSR (*(volatile uint8_t *)(0x5427)) Regards, Basil Hussain ___ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user

[Sdcc-user] Is this a good candidate for a peephole optimisation rule? (STM8)

2020-06-01 Thread Basil Hussain
('a') Does the rule need anything else? Something to assert that the %1 and %2 source/destination addresses are 'longmem' (or 'shortmem')? Some way of determining if any following instructions rely on N/Z flags (e.g. JRNE)? Regards, Basil Hussain P.S. I als

Re: [Sdcc-user] μCsim simulator 'simif' interface

2020-05-28 Thread Basil Hussain
It is quite painful to interpret sometimes. I find that it makes too many assumptions that the user is running the 8051 simulator, barely acknowledges the other platforms it supports, and as I already mentioned, some commands are completely undocumented. Hopefully this can be rectified in future.

Re: [Sdcc-user] μCsim simulator 'simif' interface

2020-05-23 Thread Basil Hussain
Yes, I am aware of that. Like I already said, I have basic simif interface functionality working - I can use the 'detect' command and get back the proper response, as well as other commands. What I am interested in is how to access this information: Configuration memory of simif 0x00 0001

[Sdcc-user] μCsim simulator 'simif' interface

2020-05-21 Thread Basil Hussain
uint32_t val;     uint8_t raw[4]; } pc; UCSIM_IF = 0x0C; pc.raw[0] = UCSIM_IF; pc.raw[1] = UCSIM_IF; pc.raw[2] = UCSIM_IF; pc.raw[3] = UCSIM_IF; Can anyone tell me how I am supposed to read the simif configuration values? Regards, Basil Hussain ___

Re: [Sdcc-user] Bizarre and extraneous assembly code generated (STM8)

2020-05-20 Thread Basil Hussain
On 20/05/2020 05:30, Sebastian Riedel wrote: It’s integer promotion. Ah, yes, I see it now. Some sort of sign-extension. But it still doesn't make any sense to me. I tried compiling with --no-peep, to see if the optimiser was removing anything that would put the extraneous code in context,

Re: [Sdcc-user] Bizarre and extraneous assembly code generated (STM8)

2020-05-19 Thread Basil Hussain
Here's a self-contained example that I can replicate the issue with: #include uint8_t foo(uint16_t value) {     return value; } uint8_t bar(uint16_t value) {     return (value ? foo(value) + 1 : 0); } void main(void) {     uint8_t x = bar(0xFF); } Compiled with: sdcc.exe -mstm8 --std-c99 -I"C:\

[Sdcc-user] Bizarre and extraneous assembly code generated (STM8)

2020-05-19 Thread Basil Hussain
ct. uint8_t ffs_16(uint16_t value) {     uint8_t idx = 0;     if(value) idx = ctz_16(value) + 1;     return idx; } Regards, Basil Hussain ___ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user

[Sdcc-user] Crash of sdasstm8 with --debug, --out-fmt-elf and __naked functions

2020-05-10 Thread Basil Hussain
quot;C:\Program Files\SDCC\bin\..\include"  "main.c" sdcc: Generating code... sdcc: Calling assembler... sdcc: sdasstm8.exe -plosgffwy ""obj\IHX\main".asm" sdcc: Calling linker... sdcc: sdldstm8.exe -nf ""bin\IHX\test.lk"" I am using SDCC 4.0.0

Re: [Sdcc-user] Compiler defines for optimisation level?

2020-04-30 Thread Basil Hussain
te: Am 25.04.20 um 08:27 schrieb Basil Hussain: Hi all, Are there any predefined macros that indicate what level of optimisation SDCC is compiling with? No. Feel free to open a feature request (https://sourceforge.net/p/sdcc/feature-requests/). Philipp _

[Sdcc-user] Compiler defines for optimisation level?

2020-04-25 Thread Basil Hussain
Hi all, Are there any predefined macros that indicate what level of optimisation SDCC is compiling with? I have some inline assembly where I'd like to unroll a loop if '--opt-code-speed' optimisation is being used. Or maybe the opposite: a non-unrolled loop only if --opt-code-size is being u

[Sdcc-user] Script to calculate STM8 stack usage

2020-04-17 Thread Basil Hussain
stions for improvement. Thanks, Basil Hussain ___ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user

Re: [Sdcc-user] SDCC occasionally misses register bit set/reset instruction optimisations for STM8

2020-03-16 Thread Basil Hussain
Okay, I am confused now... I can probably solve the particular instance of this non-optimisation by removing the "push a" and "pop a" pro/epilogue from my inline assembly, as the following C code does not rely on A being maintained. But I am hesitant to do so, concerned that I may inadvertentl

Re: [Sdcc-user] SDCC occasionally misses register bit set/reset instruction optimisations for STM8

2020-03-16 Thread Basil Hussain
Hi, the use of inline assembly may lead to the optimizer being extra / overly careful. I'm not sure if the peephole optimizer looks into the resulting inline assembly or if it just sees a black box labeled "inline assembly inside" and assumes the worst: 'a' is read in there. Will it be extra

Re: [Sdcc-user] SDCC occasionally misses register bit set/reset instruction optimisations for STM8

2020-03-16 Thread Basil Hussain
Hi all, Sometimes, for reasons unclear to me, SDCC's optimiser fails to optimise simple C statements doing register bit set/clear operations in to the appropriate STM8 bset/bres instructions. Here's the example I noticed today. The C code, and the ASM it became: FLASH_NCR2 &= ~(1U << FLASH_N

  1   2   >