ARM: Implement division and modulus.
* module/mescc/armv4/as.scm (armv4:r0/r1): Call "__mesabi_uldiv". (armv4:r0%r1): Call "__mesabi_uldiv".
This commit is contained in:
parent
26b6db0bbe
commit
311a955b0b
|
@ -350,55 +350,28 @@
|
||||||
(r1 (get-r1 info)))
|
(r1 (get-r1 info)))
|
||||||
`((,(string-append "and____%" r1 ",%" r0)))))
|
`((,(string-append "and____%" r1 ",%" r0)))))
|
||||||
|
|
||||||
|
;; FIXME: Signed or not?
|
||||||
(define (armv4:r0/r1 info signed?)
|
(define (armv4:r0/r1 info signed?)
|
||||||
(let ((signed? #f) ; nobody knows, -- all advice are belong to us?
|
(let ((r0 (get-r0 info))
|
||||||
(allocated (.allocated info))
|
|
||||||
(r0 (get-r0 info))
|
|
||||||
(r1 (get-r1 info)))
|
(r1 (get-r1 info)))
|
||||||
(if (not (member "edx" allocated))
|
;; __mesabi_uldiv(a, b, remainderp)
|
||||||
`(,@(if (equal? r0 "r0") '()
|
(cons* `(,(string-append "push___0"))
|
||||||
`(("push___%r0")
|
`(,(string-append "push___%" r1))
|
||||||
(,(string-append "mov____%" r0 ",%r0"))))
|
`(,(string-append "push___%" r0))
|
||||||
,(if signed? '("cltd") '("xor____%edx,%edx"))
|
(armv4:call-label #f "__mesabi_uldiv" (* 4 3)))))
|
||||||
,(if signed? `(,(string-append "idiv___%" r1)) `(,(string-append "div___%" r1)))
|
|
||||||
,@(if (equal? r0 "r0") '()
|
|
||||||
`((,(string-append "mov____%r0,%" r0))
|
|
||||||
("pop____%r0"))))
|
|
||||||
`(("push___%r0")
|
|
||||||
("push___%r1")
|
|
||||||
("push___%edx")
|
|
||||||
(,(string-append "mov____%" r1 ",%r1"))
|
|
||||||
(,(string-append "mov____%" r0 ",%r0"))
|
|
||||||
,(if signed? '("cltd") '("xor____%edx,%edx"))
|
|
||||||
,(if signed? `(,(string-append "idiv___%r1")) `(,(string-append "div___%r1")))
|
|
||||||
("pop____%edx")
|
|
||||||
("pop____%r1")
|
|
||||||
(,(string-append "mov____%r0,%" r0))
|
|
||||||
("pop____%r0")))))
|
|
||||||
|
|
||||||
(define (armv4:r0%r1 info signed?)
|
(define (armv4:r0%r1 info signed?)
|
||||||
(let ((signed? #f) ; nobody knows, -- all advice are belong to us?
|
(let ((r0 (get-r0 info))
|
||||||
(allocated (.allocated info))
|
|
||||||
(r0 (get-r0 info))
|
|
||||||
(r1 (get-r1 info)))
|
(r1 (get-r1 info)))
|
||||||
(if (not (member "edx" allocated))
|
;; __mesabi_uldiv(a, b, remainderp)
|
||||||
`(,@(if (equal? r0 "r0") '()
|
(append `(("push___%r0") ; slot for remainder
|
||||||
`(("push___%r0")
|
("mov____%esp,%r0")
|
||||||
(,(string-append "mov____%" r0 ",%r0"))))
|
((#:immediate1 4) "add____$i8,%r0")
|
||||||
,(if signed? '("cltd") '("xor____%edx,%edx"))
|
("push___%r0") ; pointer to remainder
|
||||||
,(if signed? `(,(string-append "idiv___%" r1)) `(,(string-append "div___%" r1)))
|
(,(string-append "push___%" r1))
|
||||||
(,(string-append "mov____%edx,%" r0)))
|
(,(string-append "push___%" r0)))
|
||||||
`(("push___%r0")
|
(armv4:call-label #f "__mesabi_uldiv" (* 4 3))
|
||||||
("push___%r1")
|
`(("pop____%r0")))))
|
||||||
("push___%edx")
|
|
||||||
(,(string-append "mov____%" r1 ",%r1"))
|
|
||||||
(,(string-append "mov____%" r0 ",%r0"))
|
|
||||||
,(if signed? '("cltd") '("xor____%edx,%edx"))
|
|
||||||
,(if signed? `(,(string-append "idiv___%r1")) `(,(string-append "div___%r1")))
|
|
||||||
("pop____%edx")
|
|
||||||
("pop____%r1")
|
|
||||||
(,(string-append "mov____%edx,%" r0))
|
|
||||||
("pop____%r0")))))
|
|
||||||
|
|
||||||
(define (armv4:r+value info v)
|
(define (armv4:r+value info v)
|
||||||
(let ((r (get-r info)))
|
(let ((r (get-r info)))
|
||||||
|
|
Loading…
Reference in New Issue