Closed purdeaandrei closed 3 months ago
I think you could probably get the same benefit by converting that giant conditional to be an if..else
one and adding explicit return
to all paths that do not stall, leaving the stalling paths to fall through.
When you mean giant conditional, are you referring to this?:
if(glasgow_config.revision < GLASGOW_REV_C0 ||
!iobuf_get_pull(arg_selector,
(__xdata uint8_t *)EP0BUF + 0,
(__xdata uint8_t *)EP0BUF + 1)) {
Yeah. The duplication of STALL_EP0()
could be eliminated by reordering it. (This is something I've been thinking about for a while already; I'm not principally opposed to goto
, it just seems like the restructuring would obviate the need for it.)
hmm, the two stalls in the while loop: I don't think those can be optimized without goto, unless I add another check to see if the loop exited early or not
I tried without goto (except for those two stalls in the while loop), and the code size increased!
This is what I tried: https://github.com/purdeaandrei/glasgow/commit/85deafc2264b8a7cc7ad7a716e248e1f1467d84f
And it increased code size by 37 bytes :( . I don't know what the explanation is
Oh no ;; sdcc is like this sometimes. Thank you for trying!
In this case the goto
solution is the obvious winner, let me review this.
Saves 59 bytes