[OpenGOAL] make multiplication/divsion like GOAL and support in decompiler (#483)

* support in compiler

* multiplication in the decompiler

* update divisions
This commit is contained in:
water111
2021-05-14 18:43:12 -04:00
committed by GitHub
parent b3eb05e37f
commit d9f9d36f37
31 changed files with 441 additions and 326 deletions
+11 -11
View File
@@ -227,7 +227,7 @@
;; definition for method 5 of type type
;; INFO: Return type mismatch uint vs int.
(defmethod asize-of type ((obj type))
(the-as int (logand #xfffffff0 (+ (shl (-> obj allocated-length) 2) 43)))
(the-as int (logand #xfffffff0 (+ (* (-> obj allocated-length) 4) 43)))
)
;; definition for function basic-type?
@@ -893,7 +893,7 @@
;; Used lq/sq
(defun qmem-copy<-! ((dst pointer) (src pointer) (size int))
(let ((result dst))
(let ((qwc (sar (+ size 15) 4)))
(let ((qwc (/ (+ size 15) 16)))
(while (nonzero? qwc)
(+! qwc -1)
(set!
@@ -912,9 +912,9 @@
;; Used lq/sq
(defun qmem-copy->! ((dst pointer) (src pointer) (size int))
(let ((result dst))
(let* ((qwc (sar (+ size 15) 4))
(dst-ptr (&+ dst (shl qwc 4)))
(src-ptr (&+ src (shl qwc 4)))
(let* ((qwc (/ (+ size 15) 16))
(dst-ptr (&+ dst (* qwc 16)))
(src-ptr (&+ src (* qwc 16)))
)
(while (nonzero? qwc)
(+! qwc -1)
@@ -995,15 +995,15 @@
;; definition (debug) for function mem-print
(defun-debug mem-print ((data (pointer uint32)) (word-count int))
(dotimes (current-qword (sar word-count 2))
(dotimes (current-qword (/ word-count 4))
(format
0
"~X: ~X ~X ~X ~X~%"
(&-> data (shl current-qword 2))
(-> data (shl current-qword 2))
(-> data (+ (shl current-qword 2) 1))
(-> data (+ (shl current-qword 2) 2))
(-> data (+ (shl current-qword 2) 3))
(&-> data (* current-qword 4))
(-> data (* current-qword 4))
(-> data (+ (* current-qword 4) 1))
(-> data (+ (* current-qword 4) 2))
(-> data (+ (* current-qword 4) 3))
)
)
#f
@@ -1045,10 +1045,10 @@
)
)
((< f0-2 0.2)
(set! arg0 (shl arg0 2))
(set! arg0 (* arg0 4))
)
((< f0-2 0.3)
(set! arg0 (shl arg0 1))
(set! arg0 (* arg0 2))
)
)
)
@@ -1489,7 +1489,7 @@
arg0
)
(let ((s2-0 *print-column*))
(set! *print-column* (the-as binteger (shl (shl arg1 2) 3)))
(set! *print-column* (the-as binteger (* (* arg1 4) 8)))
(inspect arg0)
(set! *print-column* s2-0)
)
@@ -575,7 +575,7 @@
result
(the-as
int
(+ (+ (-> next-char-2 0) -55) (the-as uint (shl result 4)))
(+ (+ (-> next-char-2 0) -55) (the-as uint (* result 16)))
)
)
)
@@ -589,14 +589,14 @@
result
(the-as
int
(+ (+ (-> next-char-2 0) -87) (the-as uint (shl result 4)))
(+ (+ (-> next-char-2 0) -87) (the-as uint (* result 16)))
)
)
(set!
result
(the-as
int
(+ (+ (-> next-char-2 0) -48) (the-as uint (shl result 4)))
(+ (+ (-> next-char-2 0) -48) (the-as uint (* result 16)))
)
)
)
@@ -615,7 +615,7 @@
)
(set!
result
(the-as int (+ (+ (-> a0-4 0) -48) (the-as uint (shl result 1))))
(the-as int (+ (+ (-> a0-4 0) -48) (the-as uint (* result 2))))
)
(set! a0-4 (&-> a0-4 1))
)