Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unnecessary Push/Pop
#3
Straight to assembler, without O3 -

Code:
SUB pokethis(value as uByte)
poke @label+1,value
return

label:
asm
LD A,0 ; This will be poked.
end asm
END SUB

Turns the relevant part into:

Code:
_pokethis:
    push ix
    ld ix, 0
    add ix, sp
    ld hl, __LABEL__label
    inc hl
    push hl
    ld a, (ix+5)
    pop hl
    ld (hl), a
    jp _pokethis__leave
__LABEL__label:
#line 6
        LD A,00

With O3, it does certainly see the optimization, showing that the optimizer module is very impressive!:
Code:
_pokethis:
    push ix
    ld ix, 0
    add ix, sp
    ld hl, __LABEL__label
    inc hl
    ld a, (ix+5)
    ld (hl), a
    jp _pokethis__leave


The other thing that I'm curious about (as I noted in the other post, with this code in it), is that it doesn't load HL with [@label+1] - it loads it with @label, and then does inc HL. This isn't optimized by -O3.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)