summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2015-01-08 07:49:16 +0100
committerMichael Pavone <pavone@retrodev.com>2015-01-08 07:49:16 +0100
commita31f4516fe504091f8339884cad69351178c34a2 (patch)
tree268c840998fea98e68a6bf9eeeb57cfa2330036e
parentbd14f5b08583c050e8e23af5814908b99ba8d547 (diff)
parentf1ad0a3e376b1103b48689fc48ed9443641a038f (diff)
Merge
-rw-r--r--gen_arm.c36
-rw-r--r--gen_arm.h4
2 files changed, 40 insertions, 0 deletions
diff --git a/gen_arm.c b/gen_arm.c
index 5d9fab6..1534ee2 100644
--- a/gen_arm.c
+++ b/gen_arm.c
@@ -548,3 +548,39 @@ uint32_t popm_cc(code_info *code, uint32_t reglist, uint32_t cc)
*(code->cur++) = cc | POPM | reglist;
return CODE_OK;
}
+
+uint32_t load_store_immoff(code_info *code, uint32_t op, uint32_t dst, uint32_t base, int32_t offset, uint32_t cc)
+{
+ if (offset >= 0x1000 || offset <= -0x1000) {
+ return INVALID_IMMED;
+ }
+ check_alloc_code(code);
+ uint32_t instruction = cc | op | POST_IND | OFF_IMM | SZ_W | base << 16 | dst << 12;
+ if (offset >= 0) {
+ instruction |= offset | DIR_UP;
+ } else {
+ instruction |= (-offset) | DIR_DOWN;
+ }
+ *(code->cur++) = instruction;
+ return CODE_OK;
+}
+
+uint32_t ldr_cc(code_info *code, uint32_t dst, uint32_t base, int32_t offset, uint32_t cc)
+{
+ return load_store_immoff(code, OP_LDR, dst, base, offset, cc);
+}
+
+uint32_t ldr(code_info *code, uint32_t dst, uint32_t base, int32_t offset)
+{
+ return ldr_cc(code, dst, base, offset, CC_AL);
+}
+
+uint32_t str_cc(code_info *code, uint32_t src, uint32_t base, int32_t offset, uint32_t cc)
+{
+ return load_store_immoff(code, OP_STR, src, base, offset, cc);
+}
+
+uint32_t str(code_info *code, uint32_t src, uint32_t base, int32_t offset)
+{
+ return str_cc(code, src, base, offset, CC_AL);
+}
diff --git a/gen_arm.h b/gen_arm.h
index 749f78c..191a80f 100644
--- a/gen_arm.h
+++ b/gen_arm.h
@@ -149,5 +149,9 @@ uint32_t pop(code_info *code, uint32_t reg);
uint32_t pop_cc(code_info *code, uint32_t reg, uint32_t cc);
uint32_t popm(code_info *code, uint32_t reglist);
uint32_t popm_cc(code_info *code, uint32_t reglist, uint32_t cc);
+uint32_t ldr_cc(code_info *code, uint32_t dst, uint32_t base, int32_t offset, uint32_t cc);
+uint32_t ldr(code_info *code, uint32_t rst, uint32_t base, int32_t offset);
+uint32_t str_cc(code_info *code, uint32_t src, uint32_t base, int32_t offset, uint32_t cc);
+uint32_t str(code_info *code, uint32_t src, uint32_t base, int32_t offset);
#endif //GEN_ARM_H_