diff --git a/jumpforth.S b/jumpforth.S index 5b0eb14..a8aeafa 100644 --- a/jumpforth.S +++ b/jumpforth.S @@ -57,6 +57,7 @@ _start: cmpl %eax,(data_BRK) jne 0f mov $cold_start,%esi + xor %edi,%edi NEXT 0: movl $254,%ebx movl $__NR_exit,%eax @@ -392,13 +393,15 @@ defcode PICK defcode ROLL pop %ecx movl (%esp,%ecx,4),%ebx - mov %esi,%edx + mov %esi,%eax + mov %edi,%edx lea -4(%esp,%ecx,4),%esi lea (%esp,%ecx,4),%edi std rep movsd cld - mov %edx,%esi + mov %eax,%esi + mov %edx,%edi movl %ebx,(%esp) NEXT @@ -690,11 +693,11 @@ defcode DRSHIFT .macro defzcmp label,ncc,name="\label",flags=0 defcode \label,"\name",0,\flags pop %eax - xor %edi,%edi + xor %edx,%edx test %eax,%eax j\ncc 0f - dec %edi -0: push %edi + dec %edx +0: push %edx NEXT .endm @@ -712,12 +715,12 @@ defzcmp ZGE,nge,"0>=" defcode \label,"\name",0,\flags pop %ebx pop %eax - xor %edi,%edi + xor %edx,%edx sub $0,%ebx sbb $0,%eax j\ncc 0f - dec %edi -0: push %edi + dec %edx +0: push %edx NEXT .endm @@ -735,11 +738,11 @@ defdzcmp DZGE,nge,"D0>=" defcode \label,"\name",0,\flags pop %eax pop %ebx - xor %edi,%edi + xor %edx,%edx cmp %eax,%ebx j\ncc 0f - dec %edi -0: push %edi + dec %edx +0: push %edx NEXT .endm @@ -761,6 +764,7 @@ defcmp UGE,nae,"U>=" .macro defdcmp label,ncc,name="\label",flags=0 defcode \label,"\name",0,\flags + PUSHRSP %edi pop %edx pop %ecx pop %ebx @@ -771,6 +775,7 @@ defcode \label,"\name",0,\flags j\ncc 0f dec %edi 0: push %edi + POPRSP %edi NEXT .endm @@ -890,24 +895,29 @@ defcode TWOXCHG,"2XCHG" defcode FILL pop %eax pop %ecx + mov %edi,%edx pop %edi rep stosb + mov %edx,%edi NEXT /* ( xu ... x1 n a-addr -- ) Store x1 through xn in ascending cells at a-addr */ defcode NSTORE,"N!" - mov %esi,%edx + mov %esi,%eax + mov %edi,%edx pop %edi pop %ecx mov %esp,%esi lea (%esp,%ecx,4),%esp rep movsd - mov %edx,%esi + mov %eax,%esi + mov %edx,%edi NEXT /* ( n a-addr -- xu ... x1 ) Load x1 through xn from ascending cells at a-addr */ defcode NFETCH,"N@" - mov %esi,%edx + mov %esi,%eax + mov %edi,%edx pop %esi pop %ecx mov %ecx,%ebx @@ -915,22 +925,26 @@ defcode NFETCH,"N@" lea (%esp,%ebx,4),%esp mov %esp,%edi rep movsd - mov %edx,%esi + mov %eax,%esi + mov %edx,%edi NEXT /* ( src dst n -- ) Block copy n bytes from src to dst (ascending addresses) */ defcode CMOVE - mov %esi,%edx + mov %esi,%eax + mov %edi,%edx pop %ecx pop %edi pop %esi rep movsb - mov %edx,%esi + mov %eax,%esi + mov %edx,%edi NEXT /* ( src dst n -- ) Block copy n bytes from src to dst (descending addresses) */ defcode CMOVE_UP,"CMOVE>" - mov %esi,%edx + mov %esi,%eax + mov %edi,%edx pop %ecx pop %edi pop %esi @@ -939,11 +953,13 @@ defcode CMOVE_UP,"CMOVE>" std rep movsb cld - mov %edx,%esi + mov %eax,%esi + mov %edx,%edi NEXT /* ( c-addr1 u1 c-addr2 u2 -- -1 | 0 | 1 ) Lexically compare two strings */ defcode COMPARE + PUSHRSP %edi mov %esi,%edx mov (%esp),%ecx mov 8(%esp),%ebx @@ -964,6 +980,7 @@ defcode COMPARE 4: add $16,%esp push %eax mov %edx,%esi + POPRSP %edi NEXT /* ( a -- ) ( R: -- a ) */ @@ -1013,7 +1030,8 @@ defcode TWORFETCH,"2R@" /* ( xu ... x1 u -- ) ( R: -- xu ... x1 u ) */ defcode NTOR,"N>R" - mov %esi,%edx + mov %esi,%eax + mov %edi,%edx movl (%esp),%ecx add $1,%ecx mov %ecx,%ebx @@ -1023,12 +1041,14 @@ defcode NTOR,"N>R" mov %ebp,%edi rep movsd mov %esi,%esp - mov %edx,%esi + mov %eax,%esi + mov %edx,%edi NEXT /* ( R: xu ... x1 u -- ) ( -- xu ... x1 u ) */ defcode NFROMR,"NR>" - mov %esi,%edx + mov %esi,%eax + mov %edi,%edx movl (%ebp),%ecx add $1,%ecx mov %ecx,%ebx @@ -1038,12 +1058,14 @@ defcode NFROMR,"NR>" mov %esp,%edi rep movsd mov %esi,%ebp - mov %edx,%esi + mov %eax,%esi + mov %edx,%edi NEXT /* ( R: xu ... x1 u -- xu ... x1 u ) ( -- xu ... x1 u ) */ defcode NRFETCH,"NR@" - mov %esi,%edx + mov %esi,%eax + mov %edi,%edx movl (%ebp),%ecx add $1,%ecx mov %ecx,%ebx @@ -1052,7 +1074,8 @@ defcode NRFETCH,"NR@" mov %ebp,%esi mov %esp,%edi rep movsd - mov %edx,%esi + mov %eax,%esi + mov %edx,%edi NEXT /* ( -- a-addr ) */ @@ -1168,45 +1191,49 @@ defcode HASHCELL /* ( ebx ecx edx esi edi ebp eax/sc -- eax/result ) */ defcode SYSCALL6 - mov %ebp,%ecx + mov %ebp,%edx + mov %edi,%ecx mov %esi,%ebx pop %eax pop %ebp pop %edi pop %esi - pop %edx - xchg %ecx,(%esp) - xchg %ebx,4(%esp) + xchg %edx,(%esp) + xchg %ecx,4(%esp) + xchg %ebx,8(%esp) int $0x80 pop %ebp + pop %edi pop %esi push %eax NEXT /* ( ebx ecx edx esi edi eax/sc -- eax/result ) */ defcode SYSCALL5 + mov %edi,%ecx mov %esi,%ebx pop %eax pop %edi pop %esi pop %edx - pop %ecx - xchg %ebx,(%esp) + xchg %ecx,(%esp) + xchg %ebx,4(%esp) int $0x80 + pop %edi pop %esi push %eax NEXT /* ( ebx ecx edx esi eax/sc -- eax/result ) */ defcode SYSCALL4 - mov %esi,%edi + mov %esi,%ebx pop %eax pop %esi pop %edx pop %ecx - pop %ebx + xchg %ebx,(%esp) int $0x80 - mov %edi,%esi + pop %esi push %eax NEXT