diff options
author | Michael Pavone <pavone@retrodev.com> | 2015-05-28 21:19:55 -0700 |
---|---|---|
committer | Michael Pavone <pavone@retrodev.com> | 2015-05-28 21:19:55 -0700 |
commit | ef033e39c170fe272a956b1417f217a0d3cce29c (patch) | |
tree | 0ca08ba1614e87cee73f4904ea362928565b2531 /gen_arm.c | |
parent | 632c82bd63a13da242c90a5d93dfe7482a0bebe6 (diff) | |
parent | 6817ef558d165b50a9b08a337dd93c4f1f46304e (diff) |
Merge windows branch with latest changes
Diffstat (limited to 'gen_arm.c')
-rw-r--r-- | gen_arm.c | 36 |
1 files changed, 36 insertions, 0 deletions
@@ -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); +} |