diff --git a/module/language/c99/compiler.mes b/module/language/c99/compiler.mes index 3cb94c6e..91d60269 100644 --- a/module/language/c99/compiler.mes +++ b/module/language/c99/compiler.mes @@ -2315,9 +2315,14 @@ (format (current-error-port) " :~a\n" name) (let loop ((statements (.statements o)) (info (clone info #:locals locals #:function (.name o) #:text text))) - (if (null? statements) (clone info - #:function #f - #:functions (append (.functions info) (list (cons name (assert-return (.text info)))))) + (if (null? statements) (let* ((locals (.locals info)) + (local (and (pair? locals) (car locals))) + (count (and=> local (compose local:id cdr))) + (stack (and count (* count 4)))) + (if (and stack (getenv "MESC_DEBUG")) (stderr " stack: ~a\n" stack)) + (clone info + #:function #f + #:functions (append (.functions info) (list (cons name (assert-return (.text info))))))) (let* ((statement (car statements))) (loop (cdr statements) ((ast->info info) (car statements))))))))) diff --git a/module/mes/as-i386.mes b/module/mes/as-i386.mes index d5059c43..4ffb7923 100644 --- a/module/mes/as-i386.mes +++ b/module/mes/as-i386.mes @@ -38,7 +38,7 @@ ("mov____%esp,%ebp"))) (define (i386:function-locals) - '(("sub____%esp,$i8" (#:immediate1 #x40)))) ; sub %esp,$0x40 # 16 local vars + `(("sub____%esp,$i32" (#:immediate ,(+ (* 4 1025) (* 20 4)))))) ; sub %esp,xxx 4*1024 buf, 20 local vars (define (i386:push-label label) `(("push___$i32" (#:address ,label)))) ; push $0x