diff --git a/module/language/c99/compiler.mes b/module/language/c99/compiler.mes index 28a4a80c..9c3424a7 100644 --- a/module/language/c99/compiler.mes +++ b/module/language/c99/compiler.mes @@ -2117,18 +2117,25 @@ _))))) (i386:accu+base))) (list (lambda (f g ta t d) (i386:pop-base))) - (cond ((equal? array "g_functions") ;; FIXME - (list (lambda (f g ta t d) - (append - (i386:base-address->accu-address) - (i386:accu+n 4) - (i386:base+n 4) - (i386:base-address->accu-address) - (i386:accu+n 4) - (i386:base+n 4) - (i386:base-address->accu-address))))) - (else (list (lambda (f g ta t d) - (i386:base->accu-address))))))))) + (if (eq? size 1) (list (lambda (f g ta t d) + (i386:byte-base->accu-address))) + (append + (list (lambda (f g ta t d) + (i386:base-address->accu-address))) + (if (> size 4) + (list (lambda (f g ta t d) + (append + (i386:accu+n 4) + (i386:base+n 4) + (i386:base-address->accu-address)))) + '()) + (if (> size 8) + (list (lambda (f g ta t d) + (append + (i386:accu+n 4) + (i386:base+n 4) + (i386:base-address->accu-address)))) + '()))))))) ;; g_cells[i] = c; ((expr-stmt (assn-expr (array-ref (p-expr (ident ,index)) (p-expr (ident ,array))) (op ,op) ,b)) @@ -2161,18 +2168,25 @@ _))))) (i386:accu+base))) (list (lambda (f g ta t d) (i386:pop-base))) - (cond ((equal? array "g_functions") ;; FIXME - (list (lambda (f g ta t d) - (append - (i386:base-address->accu-address) - (i386:accu+n 4) - (i386:base+n 4) - (i386:base-address->accu-address) - (i386:accu+n 4) - (i386:base+n 4) - (i386:base-address->accu-address))))) - (else (list (lambda (f g ta t d) - (i386:base->accu-address))))))))) + (if (eq? size 1) (list (lambda (f g ta t d) + (i386:byte-base->accu-address))) + (append + (list (lambda (f g ta t d) + (i386:base-address->accu-address))) + (if (> size 4) + (list (lambda (f g ta t d) + (append + (i386:accu+n 4) + (i386:base+n 4) + (i386:base-address->accu-address)))) + '()) + (if (> size 8) + (list (lambda (f g ta t d) + (append + (i386:accu+n 4) + (i386:base+n 4) + (i386:base-address->accu-address)))) + '()))))))) ;; g_functions[g_function++] = g_foo; ((expr-stmt (assn-expr (array-ref (post-inc (p-expr (ident ,index))) (p-expr (ident ,array))) (op ,op) ,b)) @@ -2204,19 +2218,25 @@ _))))) (i386:accu+base))) (list (lambda (f g ta t d) (i386:pop-base))) - ;; FIXME - (cond ((equal? array "g_functions") ;; FIXME - (list (lambda (f g ta t d) - (append - (i386:base-address->accu-address) - (i386:accu+n 4) - (i386:base+n 4) - (i386:base-address->accu-address) - (i386:accu+n 4) - (i386:base+n 4) - (i386:base-address->accu-address))))) - (else (list (lambda (f g ta t d) - (i386:base->accu-address))))) + (if (eq? size 1) (list (lambda (f g ta t d) + (i386:byte-base->accu-address))) + (append + (list (lambda (f g ta t d) + (i386:base-address->accu-address))) + (if (> size 4) + (list (lambda (f g ta t d) + (append + (i386:accu+n 4) + (i386:base+n 4) + (i386:base-address->accu-address)))) + '()) + (if (> size 8) + (list (lambda (f g ta t d) + (append + (i386:accu+n 4) + (i386:base+n 4) + (i386:base-address->accu-address)))) + '()))) ((ident-add info) index 1))))) ;; DECL diff --git a/module/mes/as-i386.mes b/module/mes/as-i386.mes index 7343614b..9b1a63df 100644 --- a/module/mes/as-i386.mes +++ b/module/mes/as-i386.mes @@ -72,10 +72,10 @@ '(#x50)) ; push %eax (define (i386:pop-base) - '(#x5a)) ; pop %eax + '(#x5a)) ; pop %edx (define (i386:push-base) - '(#x52)) ; push %eax + '(#x52)) ; push %edx (define (i386:ret) '(#xc9 ; leave diff --git a/scaffold/t.c b/scaffold/t.c index 7b2d95e4..db43cd8e 100644 --- a/scaffold/t.c +++ b/scaffold/t.c @@ -323,14 +323,26 @@ struct_test () functiony = g_functions[g_cells[fn].cdr].function; if ((functiony) (1) != 0) return 16; - puts ("t: g_functions[].arity;"); + puts ("t: g_functions[].arity\n"); if (g_functions[fn].arity != 1) return 18; + // fake name + scm_fun.car = 33; scm_fun.cdr = g_function; - g_functions[g_function++] = g_fun; + //g_functions[g_function++] = g_fun; + g_functions[g_function] = g_fun; cell_fun = g_free++; g_cells[cell_fun] = scm_fun; + puts ("t: TYPE (cell_fun)\n"); + if (TYPE (cell_fun) != TFUNCTION) return 1; + + puts ("t: CAR (cell_fun)\n"); + if (CAR (cell_fun) != 33) return 1; + + puts ("t: CDR (cell_fun)\n"); + if (CDR (cell_fun) != g_function) return 1; + return make_tmps_test (g_cells); }