 4 jit-code-format set
 
 : ds-reg 14 ;
+: quot-reg 3 ;
 : temp-reg 6 ;
-: aux-reg 7 ;
+: aux-reg 11 ;
 
 : factor-area-size 4 bootstrap-cells ;
 

: next-save stack-frame bootstrap-cell - ;
: xt-save stack-frame 2 bootstrap-cells - ;

! jit-profiling

[
    0 temp-reg LOAD32                          ! load XT

] rc-relative-ppc-3 rt-xt 0 jit-word-jump jit-define

: jit-call-quot ( -- )
    temp-reg quot-reg quot-xt@ LWZ             ! load quotation-xt
    temp-reg MTCTR                             ! jump to quotation-xt
    BCTR ;

[
    0 quot-reg LOAD32                          ! point quot-reg at false branch
    temp-reg ds-reg 0 LWZ                      ! load boolean
    0 temp-reg \ f tag-number CMPI             ! compare it with f
    2 BNE                                      ! skip next insn if its not f
    quot-reg dup 4 ADDI                        ! point quot-reg at true branch
    quot-reg dup 0 LWZ                         ! load the branch
    ds-reg dup 4 SUBI                          ! pop boolean
    jit-call-quot
] rc-absolute-ppc-2/2 rt-literal 1 jit-if-jump jit-define

[
    0 quot-reg LOAD32                          ! load dispatch array
    quot-reg dup 0 LWZ                         ! indirection
    temp-reg ds-reg 0 LWZ                      ! load index
    temp-reg dup 1 SRAWI                       ! turn it into an array offset
    quot-reg dup temp-reg ADD                  ! compute quotation location
    quot-reg dup array-start LWZ               ! load quotation
    ds-reg dup 4 SUBI                          ! pop index
    jit-call-quot
] rc-absolute-ppc-2/2 rt-literal 1 jit-dispatch jit-define

[
    0 1 lr-save stack-frame + LWZ              ! load return address
