mescc: Another attempt at divide.
[mes.git] / module / mescc / i386 / as.scm
index 178ab98e9da9b32c2a93c96a67ab00a41bc53de4..3256a323a77f69f2a31b892e5419513a5abdbd18 100644 (file)
     `((,(string-append "and____%" r1 ",%" r0)))))
 
 (define (i386:r0/r1 info signed?)
-  (let ((allocated (.allocated info))
+  (let ((signed? #f)              ; nobody knows, -- all advice are belong to us?
+        (allocated (.allocated info))
         (r0 (get-r0 info))
         (r1 (get-r1 info)))
     (if (not (member "edx" allocated))
                 `(("push___%eax")
                   (,(string-append "mov____%" r0 ",%eax"))))
           ,(if signed? '("cltd") '("xor____%edx,%edx"))
-          (,(string-append "idiv___%" r1))
+          ,(if signed? `(,(string-append "idiv___%" r1)) `(,(string-append "div___%" r1)))
           ,@(if (equal? r0 "eax") '()
                 `((,(string-append "mov____%eax,%" r0))
                   ("pop____%eax"))))
           (,(string-append "mov____%" r1 ",%ebx"))
           (,(string-append "mov____%" r0 ",%eax"))
           ,(if signed? '("cltd") '("xor____%edx,%edx"))
-          (,(string-append "idiv___%ebx"))
+          ,(if signed? `(,(string-append "idiv___%ebx")) `(,(string-append "div___%ebx")))
           ("pop____%edx")
           ("pop____%ebx")
           (,(string-append "mov____%eax,%" r0))
           ("pop____%eax")))))
 
 (define (i386:r0%r1 info signed?)
-  (let ((allocated (.allocated info))
+  (let ((signed? #f)              ; nobody knows, -- all advice are belong to us?
+        (allocated (.allocated info))
         (r0 (get-r0 info))
         (r1 (get-r1 info)))
     (if (not (member "edx" allocated))
                 `(("push___%eax")
                   (,(string-append "mov____%" r0 ",%eax"))))
           ,(if signed? '("cltd") '("xor____%edx,%edx"))
-          (,(string-append "idiv___%" r1))
+          ,(if signed? `(,(string-append "idiv___%" r1)) `(,(string-append "div___%" r1)))
           (,(string-append "mov____%edx,%" r0)))
         `(("push___%eax")
           ("push___%ebx")
           (,(string-append "mov____%" r1 ",%ebx"))
           (,(string-append "mov____%" r0 ",%eax"))
           ,(if signed? '("cltd") '("xor____%edx,%edx"))
-          (,(string-append "idiv___%ebx"))
+          ,(if signed? `(,(string-append "idiv___%ebx")) `(,(string-append "div___%ebx")))
           ("pop____%edx")
           ("pop____%ebx")
           (,(string-append "mov____%edx,%" r0))