diff --git a/src/asm-tests.ss b/src/asm-tests.ss index 41a4796..be7f5e5 100755 --- a/src/asm-tests.ss +++ b/src/asm-tests.ss @@ -10,6 +10,7 @@ `([0 (label ,(gensym)) . ,ls])))]) (let ([proc (#%$code->closure code)]) (let ([v (proc)]) + (printf "running\n") (unless (equal? v res) (printf "failed!\n") (error 'test-asm "expected ~s, got ~s" res v))))) @@ -65,6 +66,27 @@ [movl (disp -8 %esp) %eax] [ret])) +(asm-test 1 + '([movl 0 (disp -4 %esp)] + [movl %esp %eax] + [movl -4 %ebx] + [movb 4 (disp %eax %ebx)] + [movl (disp -4 %esp) %eax] + [ret])) + + + +(asm-test 3 + '([movl 4 (disp -4 %esp)] + [orl 8 (disp -4 %esp)] + [movl (disp -4 %esp) %eax] + [ret])) + +(asm-test 3 + '([movl -1 (disp -4 %esp)] + [andl 12 (disp -4 %esp)] + [movl (disp -4 %esp) %eax] + [ret])) (printf "Happy Happy Joy Joy\n") diff --git a/src/geninstr/Makefile b/src/geninstr/Makefile index 121ebba..6a8a144 100644 --- a/src/geninstr/Makefile +++ b/src/geninstr/Makefile @@ -1,6 +1,7 @@ all: - ./gen.pl > tmp.s - gcc -o tmp.o -c tmp.s - objdump -d tmp.o > tmp.dump + ./gen.pl > tmp.s + gcc -o tmp.o -c tmp.s + otool -t tmp.o + otool -tv tmp.o diff --git a/src/geninstr/gen.pl b/src/geninstr/gen.pl index 2dddf9e..230450b 100755 --- a/src/geninstr/gen.pl +++ b/src/geninstr/gen.pl @@ -33,6 +33,20 @@ sub gen2{ } } +sub gen2_no_esp{ + my $tmpl = shift; + foreach my $r1 (@regs){ + foreach my $r2 (@regs_no_esp){ + my $x = $tmpl; + $x =~ s/r1/$r1/g; + $x =~ s/r2/$r2/g; + print $x; + } + } +} + + + sub gen3{ my $tmpl = shift; foreach my $r1 (@regs){ @@ -51,7 +65,7 @@ sub gen3{ #gen1 "addl \$0x12345678, 7(r1)\n"; #gen2 "addl 0x23(r1), r2\n"; -gen2 "addl r1, 0x23(r2)\n"; +gen2_no_esp "movb \$24, 0(r1,r2)\n"; #gen1 "movb \$0, 4(r1)\n"; #gen1 "movb -2(r1), %ah\n"; diff --git a/src/geninstr/tmp.s b/src/geninstr/tmp.s index 69a3a7e..bc551ee 100644 --- a/src/geninstr/tmp.s +++ b/src/geninstr/tmp.s @@ -1,65 +1,57 @@ .text -addl %eax, 0x23(%eax) -addl %eax, 0x23(%ecx) -addl %eax, 0x23(%edx) -addl %eax, 0x23(%ebx) -addl %eax, 0x23(%esp) -addl %eax, 0x23(%ebp) -addl %eax, 0x23(%esi) -addl %eax, 0x23(%edi) -addl %ecx, 0x23(%eax) -addl %ecx, 0x23(%ecx) -addl %ecx, 0x23(%edx) -addl %ecx, 0x23(%ebx) -addl %ecx, 0x23(%esp) -addl %ecx, 0x23(%ebp) -addl %ecx, 0x23(%esi) -addl %ecx, 0x23(%edi) -addl %edx, 0x23(%eax) -addl %edx, 0x23(%ecx) -addl %edx, 0x23(%edx) -addl %edx, 0x23(%ebx) -addl %edx, 0x23(%esp) -addl %edx, 0x23(%ebp) -addl %edx, 0x23(%esi) -addl %edx, 0x23(%edi) -addl %ebx, 0x23(%eax) -addl %ebx, 0x23(%ecx) -addl %ebx, 0x23(%edx) -addl %ebx, 0x23(%ebx) -addl %ebx, 0x23(%esp) -addl %ebx, 0x23(%ebp) -addl %ebx, 0x23(%esi) -addl %ebx, 0x23(%edi) -addl %esp, 0x23(%eax) -addl %esp, 0x23(%ecx) -addl %esp, 0x23(%edx) -addl %esp, 0x23(%ebx) -addl %esp, 0x23(%esp) -addl %esp, 0x23(%ebp) -addl %esp, 0x23(%esi) -addl %esp, 0x23(%edi) -addl %ebp, 0x23(%eax) -addl %ebp, 0x23(%ecx) -addl %ebp, 0x23(%edx) -addl %ebp, 0x23(%ebx) -addl %ebp, 0x23(%esp) -addl %ebp, 0x23(%ebp) -addl %ebp, 0x23(%esi) -addl %ebp, 0x23(%edi) -addl %esi, 0x23(%eax) -addl %esi, 0x23(%ecx) -addl %esi, 0x23(%edx) -addl %esi, 0x23(%ebx) -addl %esi, 0x23(%esp) -addl %esi, 0x23(%ebp) -addl %esi, 0x23(%esi) -addl %esi, 0x23(%edi) -addl %edi, 0x23(%eax) -addl %edi, 0x23(%ecx) -addl %edi, 0x23(%edx) -addl %edi, 0x23(%ebx) -addl %edi, 0x23(%esp) -addl %edi, 0x23(%ebp) -addl %edi, 0x23(%esi) -addl %edi, 0x23(%edi) +movb $24, 0(%eax,%eax) +movb $24, 0(%eax,%ecx) +movb $24, 0(%eax,%edx) +movb $24, 0(%eax,%ebx) +movb $24, 0(%eax,%ebp) +movb $24, 0(%eax,%esi) +movb $24, 0(%eax,%edi) +movb $24, 0(%ecx,%eax) +movb $24, 0(%ecx,%ecx) +movb $24, 0(%ecx,%edx) +movb $24, 0(%ecx,%ebx) +movb $24, 0(%ecx,%ebp) +movb $24, 0(%ecx,%esi) +movb $24, 0(%ecx,%edi) +movb $24, 0(%edx,%eax) +movb $24, 0(%edx,%ecx) +movb $24, 0(%edx,%edx) +movb $24, 0(%edx,%ebx) +movb $24, 0(%edx,%ebp) +movb $24, 0(%edx,%esi) +movb $24, 0(%edx,%edi) +movb $24, 0(%ebx,%eax) +movb $24, 0(%ebx,%ecx) +movb $24, 0(%ebx,%edx) +movb $24, 0(%ebx,%ebx) +movb $24, 0(%ebx,%ebp) +movb $24, 0(%ebx,%esi) +movb $24, 0(%ebx,%edi) +movb $24, 0(%esp,%eax) +movb $24, 0(%esp,%ecx) +movb $24, 0(%esp,%edx) +movb $24, 0(%esp,%ebx) +movb $24, 0(%esp,%ebp) +movb $24, 0(%esp,%esi) +movb $24, 0(%esp,%edi) +movb $24, 0(%ebp,%eax) +movb $24, 0(%ebp,%ecx) +movb $24, 0(%ebp,%edx) +movb $24, 0(%ebp,%ebx) +movb $24, 0(%ebp,%ebp) +movb $24, 0(%ebp,%esi) +movb $24, 0(%ebp,%edi) +movb $24, 0(%esi,%eax) +movb $24, 0(%esi,%ecx) +movb $24, 0(%esi,%edx) +movb $24, 0(%esi,%ebx) +movb $24, 0(%esi,%ebp) +movb $24, 0(%esi,%esi) +movb $24, 0(%esi,%edi) +movb $24, 0(%edi,%eax) +movb $24, 0(%edi,%ecx) +movb $24, 0(%edi,%edx) +movb $24, 0(%edi,%ebx) +movb $24, 0(%edi,%ebp) +movb $24, 0(%edi,%esi) +movb $24, 0(%edi,%edi) diff --git a/src/ikarus.boot b/src/ikarus.boot index 602d385..d6afd89 100644 Binary files a/src/ikarus.boot and b/src/ikarus.boot differ diff --git a/src/libaltcogen.ss b/src/libaltcogen.ss index 777b551..deda99a 100644 --- a/src/libaltcogen.ss +++ b/src/libaltcogen.ss @@ -13,7 +13,6 @@ ;;; | (forcall "name" *) ;;; | (funcall *) ;;; | (jmpcall