From d9bda458538e306ac4ee5dbf7a56d832f1ed3b98 Mon Sep 17 00:00:00 2001 From: Danny Milosavljevic Date: Thu, 18 Jun 2020 20:40:38 +0200 Subject: [PATCH] ARM: Handle signed values in r-byte-mem-add, r-word-mem-add. * lib/arm-mes/arm.M1 (ldrb___%r0,(%r1)): Delete macro. (ldrh___%r0,(%r0)): Delete macro. (ldrsh__%r0,(%r0)): New macro. (ldrh___%r0,(%r1)): Delete macro. (ldrsh__%r0,(%r1)): New macro. (ldrh___%r1,(%r1)): Delete macro. (ldrsh__%r1,(%r1)): New macro. (ldrh___%r2,(%r2)): Delete macro. (ldrsh__%r2,(%r2)): New macro. (ldrh___%r3,(%r3)): Delete macro. (ldrsh__%r3,(%r3)): New macro. (ldrsb__%r0,(%r1)): New macro. * module/mescc/armv4/as.scm (armv4:r-byte-mem-add): Use ldrsb. (armv4:r-word-mem-add): Use ldrsh, add____$i32,(%r0). (armv4:word-mem->r): Use ldrsh. --- lib/arm-mes/arm.M1 | 12 ++++++------ module/mescc/armv4/as.scm | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/arm-mes/arm.M1 b/lib/arm-mes/arm.M1 index 676e6971..99041e5b 100644 --- a/lib/arm-mes/arm.M1 +++ b/lib/arm-mes/arm.M1 @@ -193,17 +193,17 @@ DEFINE str____%sp,(%fp,-#$i8) d00be5 DEFINE str____%lr,(%fp,-#$i8) e00be5 # Note: Loads INTO register r0 (ARM original operand order) DEFINE ldrsb__%r0,(%r0) d000d0e1 # ldrsb r0, [r0] +DEFINE ldrsb__%r0,(%r1) d000d1e1 # ldrsb r0, [r1] DEFINE ldrsb__%r1,(%r1) d010d1e1 # ldrsb r1, [r1] DEFINE ldrsb__%r2,(%r2) d020d2e1 # ldrsb r2, [r2] DEFINE ldrsb__%r3,(%r3) d030d3e1 # ldrsb r3, [r3] DEFINE ldrsb__%r4,(%r4) d040d4e1 # ldrsb r4, [r4] DEFINE ldrsb__%r5,(%r5) d050d5e1 # ldrsb r5, [r5] -DEFINE ldrb___%r0,(%r1) 0000d1e5 # ldrb r0, [r1] -DEFINE ldrh___%r0,(%r0) b000d0e1 # ldrh r0, [r0] -DEFINE ldrh___%r0,(%r1) b000d1e1 # ldrh r0, [r1] -DEFINE ldrh___%r1,(%r1) b010d1e1 # ldrh r1, [r1] -DEFINE ldrh___%r2,(%r2) b020d2e1 # ldrh r2, [r2] -DEFINE ldrh___%r3,(%r3) b030d3e1 # ldrh r3, [r3] +DEFINE ldrsh__%r0,(%r0) f000d0e1 # ldrsh r0, [r0] +DEFINE ldrsh__%r0,(%r1) f000d1e1 # ldrsh r0, [r1] +DEFINE ldrsh__%r1,(%r1) f010d1e1 # ldrsh r1, [r1] +DEFINE ldrsh__%r2,(%r2) f020d2e1 # ldrsh r2, [r2] +DEFINE ldrsh__%r3,(%r3) f030d3e1 # ldrsh r3, [r3] DEFINE strb___%r0,(%r0) 0000c0e5 # strb r0, [r0] DEFINE strb___%r0,(%r1) 0000c1e5 # strb r0, [r1] DEFINE strb___%r1,(%r1) 0010c1e5 # strb r1, [r1] diff --git a/module/mescc/armv4/as.scm b/module/mescc/armv4/as.scm index 05f65111..138ff201 100644 --- a/module/mescc/armv4/as.scm +++ b/module/mescc/armv4/as.scm @@ -148,7 +148,7 @@ (define (armv4:r-byte-mem-add info v) (let ((r (get-r info))) `((,(string-append "push___%r0")) - (,(string-append "ldrb___%r0,(%" r ")")) + (,(string-append "ldrsb__%r0,(%" r ")")) ,(optimize-immediate v `((#:immediate1 ,v) ,(string-append "add____$i8,%r0")) `((#:immediate1 ,(- v)) ,(string-append "sub____$i8,%r0")) @@ -159,11 +159,11 @@ (define (armv4:r-word-mem-add info v) (let ((r (get-r info))) `((,(string-append "push___%r0")) - (,(string-append "ldrh___%r0,(%" r ")")) + (,(string-append "ldrsh__%r0,(%" r ")")) ,(optimize-immediate v `((#:immediate1 ,v) ,(string-append "add____$i8,%r0")) `((#:immediate1 ,(- v)) ,(string-append "sub____$i8,%r0")) - (error "armv4:r-word-mem-add got immediate that doesn't fit into 8 bits but that is not implemented.")) + `(("add____$i32,(%r0)" (#:immediate ,v)))) (,(string-append "strh___%r0,(%" r ")")) (,(string-append "pop____%r0"))))) @@ -256,7 +256,7 @@ (define (armv4:word-mem->r info) (let ((r (get-r info))) - `((,(string-append "ldrh___%" r ",(%" r ")"))))) + `((,(string-append "ldrsh__%" r ",(%" r ")"))))) (define (armv4:mem->r info) (let ((r (get-r info)))