Commit Graph

23 Commits

Author SHA1 Message Date
Danny Milosavljevic c7bfc1de36
ARM: Fix strh sign handling.
* module/mescc/armv4/as.scm (armv4:word-r->local+n): Fix strh sign handling.
2019-09-09 18:34:07 +02:00
Danny Milosavljevic d0e05a4a80
ARM: If "ADD"'s immediate is less than 0, subtract.
* lib/arm-mes/arm.M1 (sub____$i8,%r0): New macro.
(sub____$i8,%r1): New macro.
* module/mescc/armv4/as.scm (armv4:call-label): Add comment.
(armv4:r-byte-mem-add): Subtract if value is negative.
(armv4:r-word-mem-add): Subtract if value is negative.
(armv4:local-ptr->r): Subtract if value is negative.
(armv4:r+value): Subtract if value is negative.
(armv4:r0+value): Subtract if value is negative.
2019-09-09 18:34:06 +02:00
Danny Milosavljevic b9b744001a
ARM: Fix storing bytes in the stack frame.
* lib/arm-mes/arm.M1 (strb___%r0,0x8(%ebp)): Rename to...
(strb___%r0,(%fp,+#$i8)): ... this.
(strb___%r0,(%fp,-#$i8)): New macro.
* module/mescc/armv4/as.scm (armv4:byte-r->local+n): Use them.
2019-09-09 18:34:05 +02:00
Danny Milosavljevic cf0c7db11f
ARM: Fix handling of negative offsets in load/store instructions.
* lib/arm-mes/arm.M1 (ldr____%r0,(%fp,+#$i8)): New macro.
(ldr____%r1,(%fp,+#$i8)): New macro.
(ldr____%r2,(%fp,+#$i8)): New macro.
(ldr____%r3,(%fp,+#$i8)): New macro.
(ldr____%r4,(%fp,+#$i8)): New macro.
(ldr____%r5,(%fp,+#$i8)): New macro.
(ldr____%r7,(%fp,+#$i8)): New macro.
(ldr____%fp,(%fp,+#$i8)): New macro.
(ldr____%sp,(%fp,+#$i8)): New macro.
(ldr____%r0,(%fp,-#$i8)): New macro.
(ldr____%r1,(%fp,-#$i8)): New macro.
(ldr____%r2,(%fp,-#$i8)): New macro.
(ldr____%r3,(%fp,-#$i8)): New macro.
(ldr____%r4,(%fp,-#$i8)): New macro.
(ldr____%r5,(%fp,-#$i8)): New macro.
(ldr____%r7,(%fp,-#$i8)): New macro.
(ldr____%fp,(%fp,-#$i8)): New macro.
(ldr____%sp,(%fp,-#$i8)): New macro.
(str____%r0,(%fp,+#$i8)): New macro.
(str____%r1,(%fp,+#$i8)): New macro.
(str____%r2,(%fp,+#$i8)): New macro.
(str____%r3,(%fp,+#$i8)): New macro.
(str____%r4,(%fp,+#$i8)): New macro.
(str____%r5,(%fp,+#$i8)): New macro.
(str____%r7,(%fp,+#$i8)): New macro.
(str____%fp,(%fp,+#$i8)): New macro.
(str____%sp,(%fp,+#$i8)): New macro.
(str____%r0,(%fp,-#$i8)): New macro.
(str____%r1,(%fp,-#$i8)): New macro.
(str____%r2,(%fp,-#$i8)): New macro.
(str____%r3,(%fp,-#$i8)): New macro.
(str____%r4,(%fp,-#$i8)): New macro.
(str____%r5,(%fp,-#$i8)): New macro.
(str____%r7,(%fp,-#$i8)): New macro.
(str____%fp,(%fp,-#$i8)): New macro.
(str____%sp,(%fp,-#$i8)): New macro.
(mov____%r0,0x8(%ebp)): Delete macro.
(mov____%r1,0x8(%ebp)): Delete macro.
(mov____%r2,0x8(%ebp)): Delete macro.
(mov____%r3,0x8(%ebp)): Delete macro.
(mov____%r4,0x8(%ebp)): Delete macro.
(mov____%r5,0x8(%ebp)): Delete macro.
(mov____%r7,0x8(%ebp)): Delete macro.
(mov____0x8(%ebp),%r0): Delete macro.
(mov____0x8(%ebp),%r1): Delete macro.
(mov____0x8(%ebp),%r2): Delete macro.
(mov____0x8(%ebp),%r3): Delete macro.
(mov____0x8(%ebp),%r4): Delete macro.
(mov____0x8(%ebp),%r5): Delete macro.
(mov____0x8(%ebp),%r7): Delete macro.
(mov____0x8(%ebp),%ebp): Delete macro.
(mov____0x8(%ebp),%esp): Delete macro.
* module/mescc/armv4/as.scm (armv4:local->r): Use them.
(armv4:r->local+n): Use them.
2019-09-09 18:34:05 +02:00
Danny Milosavljevic 105cf743ff
ARM: Support negative values as immediate.
* lib/arm-mes/arm.M1 (mvn____%r0,$i8): New macro.
(mvn____%r1,$i8): New macro.
(mvn____%r7,$i8): New macro.
* module/mescc/armv4/as.scm (immediate->r0): Use it.
(armv4:value->r): Use it.
2019-09-09 18:34:05 +02:00
Danny Milosavljevic 705be3f917
ARM: Fix instruction encoding for "add____$i8,%esp" in armv4:call-label.
* module/mescc/armv4/as.scm (armv4:call-label): Fix instruction encoding
for "add____$i8,%esp".
2019-09-09 18:33:59 +02:00
Danny Milosavljevic ba7338a466
ARM: Fix armv4:be?->r.
* module/mescc/armv4/as.scm (armv4:be?->r): Use "movhi__%r?,$i8".
2019-09-09 18:33:57 +02:00
Danny Milosavljevic badae1c4c4
ARM: Fix byte-mem-add.
* lib/arm-mes/arm.M1: Add macro "ldrb___%r0,(%r1)".
* module/mescc/armv4/as.scm (armv4:r-byte-mem-add): Use it.
2019-09-09 18:33:57 +02:00
Danny Milosavljevic 3bc75ab98b
ARM: Fix ldr*, str* references.
* module/mescc/armv4/as.scm (armv4:byte-r0->r1-mem): Fix output.
(armv4:word-mem->r): Fix output.
(armv4:byte-r0-mem->r1-mem): Fix output.
(armv4:byte-r->local+n): Fix output.
(armv4:word-r->local+n): Fix output.
2019-09-09 18:33:57 +02:00
Danny Milosavljevic f51d3a3356
ARM: Move r9 usage completely into "arm.M1".
* lib/arm-mes/arm.M1: Add "ret" macro.
* module/mescc/armv4/as.scm (armv4:ret): Use it.
* lib/arm-mes/arm.M1: Add macros "lsl____%r0,%r0,$i8", "lsl____%r1,%r1,$i8".
* module/mescc/armv4/as.scm (armv4:shl-r): Use them.
2019-09-09 18:33:55 +02:00
Danny Milosavljevic 794d242b9b
ARM: Division: Fix remainder pointer.
* module/mescc/armv4/as.scm (armv4:r0/r1): Fix remainder pointer.
2019-09-09 18:33:55 +02:00
Danny Milosavljevic 8a6092f2b4
ARM: Fix left shifts.
* lib/arm-mes/arm.M1: Add macros "lsl____%r0,%r0,%r9", "lsl____%r1,%r1,%r9",
"mov____$i8,%r9".
* module/mescc/armv4/as.scm (armv4:shl-r): Use them.
2019-09-09 18:33:55 +02:00
Danny Milosavljevic c72d349f53
ARM: Fix testing for zero.
* module/mescc/armv4/as.scm (armv4:r-zero?): Modify.
(armv4:xor-zf): Modify.
2019-09-09 18:33:55 +02:00
Danny Milosavljevic c4c94d68fe
ARM: Fix multiplication.
* lib/arm-mes/arm.M1: Delete "mul____%r1" macro.
Add "mul____%r1,%r0" and "mul____%r0,%r1" macros.
* module/mescc/armv4/as.scm (armv4:r0*r1): Use them.
2019-09-09 18:33:55 +02:00
Danny Milosavljevic 311a955b0b
ARM: Implement division and modulus.
* module/mescc/armv4/as.scm (armv4:r0/r1): Call "__mesabi_uldiv".
(armv4:r0%r1): Call "__mesabi_uldiv".
2019-09-09 18:33:55 +02:00
Danny Milosavljevic 26b6db0bbe
ARM: Introduce immediate->r0.
* module/mescc/armv4/as.scm (immediate->r0): New procedure.
(armv4:local-add): Use it.
(armv4:label-mem-add): Use it.
2019-09-09 18:33:55 +02:00
Danny Milosavljevic 7de32f00fc
ARM: Simplify source formatting.
* module/mescc/armv4/as.scm (armv4:local->r): Simplify.
(armv4:local-ptr->r): Indent.
(armv4:r+value): Simplify.
(armv4:r-cmp-value): Simplify.
(armv4:r0+value): Simplify.
2019-09-09 18:33:54 +02:00
Danny Milosavljevic 6c562bb065
ARM: Fix some typos.
* module/mescc/armv4/as.scm (armv4:r-byte-mem-add): Fix typo.
(armv4:r-word-mem-add): Fix typo.
(armv4:byte-r0->r1-mem): Fix typo.
(armv4:word-r0->r1-mem): Fix typo.
2019-09-09 18:33:54 +02:00
Danny Milosavljevic 3b8961465f
ARM: Fix armv4:zf->r.
* module/mescc/armv4/as.scm (armv4:zf->r): Use the correct macros.
2019-09-09 18:33:53 +02:00
Danny Milosavljevic a252b9ac08
ARM: Fix armv4:xor-zf.
* module/mescc/armv4/as.scm (armv4:xor-zf): Use the correct macros.
2019-09-09 18:33:53 +02:00
Danny Milosavljevic fd7c2d32cd
ARM: Fix function calls.
* lib/arm-mes/arm.M1: Delete "ret" macro.
Fix "push___%ebp" macro.
Add "pop____%lr" macro.
Add "push___%lr" macro.
Add "mov____%lr,%r9" macro.
Add "mov____%r9,%pc" macro.
* module/mescc/armv4/as.scm (armv4:function-preamble): Push lr, too.
(armv4:ret): Pop lr, too.  Return manually.
2019-09-09 18:33:53 +02:00
Danny Milosavljevic 59f22c5b86
ARM: Use architecture-dependent branch encoding for function calls.
* module/mescc/armv4/as.scm (armv4:call-label): Use architecture-dependent
branch encoding.
2019-09-09 18:33:53 +02:00
Danny Milosavljevic 83d8e41020
Add initial ARM implementation.
* include/linux/arm/syscall.h: New file.
* lib/arm-mes/arm.M1: New file.
* lib/arm-mes/elf-0footer.hex2: New file.
* lib/arm-mes/elf32-0header.hex2: New file.
* lib/arm-mes/elf32-body-exit-42.hex2: New file.
* lib/arm-mes/elf32-footer-single-main.hex2: New file.
* lib/arm-mes/elf32-header.hex2: New file.
* lib/arm-mes-mescc/exit-42.c: New file.
* lib/arm-mes-mescc/setjmp.c: New file.
* module/mescc/armv4/as.scm: New file.
* module/mescc/armv4/info.scm: New file.
* module/mescc/M1.scm (hex2:offset2): New procedure.
* module/mescc/mescc.scm: Include (mescc armv4 info).
(hex2:offset3): New procedure.
(info->M1): Use them.
* build-aux/build-guile.sh: Compile them.
2019-09-09 18:33:51 +02:00