%dispatch: sometimes the generated sequence is one byte longer, so instead of hard-coding it, compute the right length
parent
54876d0cba
commit
4db44cd23f
|
@ -30,12 +30,14 @@ M: x86.32 temp-reg-2 EDX ;
|
||||||
M:: x86.32 %dispatch ( src temp -- )
|
M:: x86.32 %dispatch ( src temp -- )
|
||||||
! Load jump table base.
|
! Load jump table base.
|
||||||
temp src HEX: ffffffff [+] LEA
|
temp src HEX: ffffffff [+] LEA
|
||||||
|
building get length cell - :> start
|
||||||
0 rc-absolute-cell rel-here
|
0 rc-absolute-cell rel-here
|
||||||
! Go
|
! Go
|
||||||
temp HEX: 7f [+] JMP
|
temp HEX: 7f [+] JMP
|
||||||
|
building get length :> end
|
||||||
! Fix up the displacement above
|
! Fix up the displacement above
|
||||||
cell code-alignment
|
cell code-alignment
|
||||||
[ 7 + building get dup pop* push ]
|
[ end start - + building get dup pop* push ]
|
||||||
[ align-code ]
|
[ align-code ]
|
||||||
bi ;
|
bi ;
|
||||||
|
|
||||||
|
|
|
@ -23,15 +23,17 @@ M: x86.64 rs-reg R15 ;
|
||||||
M: x86.64 stack-reg RSP ;
|
M: x86.64 stack-reg RSP ;
|
||||||
|
|
||||||
M:: x86.64 %dispatch ( src temp -- )
|
M:: x86.64 %dispatch ( src temp -- )
|
||||||
|
building get length :> start
|
||||||
! Load jump table base.
|
! Load jump table base.
|
||||||
temp HEX: ffffffff MOV
|
temp HEX: ffffffff MOV
|
||||||
0 rc-absolute-cell rel-here
|
0 rc-absolute-cell rel-here
|
||||||
! Add jump table base
|
! Add jump table base
|
||||||
temp src ADD
|
temp src ADD
|
||||||
temp HEX: 7f [+] JMP
|
temp HEX: 7f [+] JMP
|
||||||
|
building get length :> end
|
||||||
! Fix up the displacement above
|
! Fix up the displacement above
|
||||||
cell code-alignment
|
cell code-alignment
|
||||||
[ 15 + building get dup pop* push ]
|
[ end start - 2 - + building get dup pop* push ]
|
||||||
[ align-code ]
|
[ align-code ]
|
||||||
bi ;
|
bi ;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue