mes.git
4 months agoARM: Fix argc, argv and envp handling. wip-arm-0.20
Danny Milosavljevic [Sun, 25 Aug 2019 14:00:19 +0000 (16:00 +0200)]
ARM: Fix argc, argv and envp handling.

* lib/linux/arm-mes-mescc/crt1.c (_start): Fix argc, argv and envp handling.
* lib/arm-mes/arm.M1 (add____%r2,%r0,%r1,lsl#2): Add macro.
(add____%r2,%r0,%r1,lsl#4): Delete macro.
(add____%r2,%r1,%r0,lsl#2): Add macro.

4 months agoARM: Add macro "ldrh___%r0,(%r1)".
Danny Milosavljevic [Fri, 19 Jul 2019 07:23:32 +0000 (09:23 +0200)]
ARM: Add macro "ldrh___%r0,(%r1)".

* lib/arm-mes/arm.M1 (ldrh___%r0,(%r1)): Add macro.

4 months agoARM: Add macro "strh___%r0,(%fp,-#$i8)".
Danny Milosavljevic [Fri, 19 Jul 2019 07:18:12 +0000 (09:18 +0200)]
ARM: Add macro "strh___%r0,(%fp,-#$i8)".

* lib/arm-mes/arm.M1 (strh___%r0,(%fp,-#$i8)): Add macro.

4 months agoARM: Fix encoding of "mov____0x32(%ebp),%r1", "mov____0x32(%ebp),%r0", "xchg___%r0...
Danny Milosavljevic [Thu, 18 Jul 2019 23:49:02 +0000 (01:49 +0200)]
ARM: Fix encoding of "mov____0x32(%ebp),%r1", "mov____0x32(%ebp),%r0", "xchg___%r0,(%esp)" pseudo-instructions.

* lib/arm-mes/arm.M1 (mov____0x32(%ebp),%r1): Modify.
(mov____0x32(%ebp),%r0): Modify.
(xchg___%r0,(%esp)): Modify.

4 months agoARM: Fix strh sign handling.
Danny Milosavljevic [Thu, 30 May 2019 10:22:49 +0000 (12:22 +0200)]
ARM: Fix strh sign handling.

* module/mescc/armv4/as.scm (armv4:word-r->local+n): Fix strh sign handling.

4 months agoARM: Add macro "strh___%r0,(%fp,+#$i8)".
Danny Milosavljevic [Thu, 30 May 2019 10:19:59 +0000 (12:19 +0200)]
ARM: Add macro "strh___%r0,(%fp,+#$i8)".

* lib/arm-mes/arm.M1 (strh___%r0,(%fp,+#$i8)): New macro.

4 months agoARM: Add macro "sxth__%r1,%r1".
Danny Milosavljevic [Thu, 30 May 2019 09:56:03 +0000 (11:56 +0200)]
ARM: Add macro "sxth__%r1,%r1".

* lib/arm-mes/arm.M1 (sxth__%r1,%r1): New macro.

4 months agoARM: Add "strh___%r0,(%r1)" macro.
Danny Milosavljevic [Thu, 30 May 2019 09:53:32 +0000 (11:53 +0200)]
ARM: Add "strh___%r0,(%r1)" macro.

* lib/arm-mes/arm.M1 (strh___%r0,(%r1)): New macro.

4 months agoARM: Add __sys_call6, _sys_call6.
Danny Milosavljevic [Wed, 15 May 2019 20:39:45 +0000 (22:39 +0200)]
ARM: Add __sys_call6, _sys_call6.

* lib/linux/arm-mes-mescc/syscall.c (__sys_call6): New procedure.
(_sys_call6): New procedure.

4 months agoARM: Fix add____$i32,(%r0).
Danny Milosavljevic [Wed, 15 May 2019 19:17:13 +0000 (21:17 +0200)]
ARM: Fix add____$i32,(%r0).

* lib/arm-mes/arm.M1 (add____$i32,(%r0)): Fix it.

4 months agoARM: Use %fp in _start.
Danny Milosavljevic [Wed, 15 May 2019 18:44:03 +0000 (20:44 +0200)]
ARM: Use %fp in _start.

* lib/linux/arm-mes-mescc/crt1.c (_start): Use %fp instead of %sp.

4 months agoARM: If "ADD"'s immediate is less than 0, subtract.
Danny Milosavljevic [Sun, 14 Apr 2019 20:01:25 +0000 (22:01 +0200)]
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.

4 months agoARM: Fix loads.
Danny Milosavljevic [Sun, 14 Apr 2019 12:20:12 +0000 (14:20 +0200)]
ARM: Fix loads.

Follow-up to 7e40a92732c3035003ae779022e5beaf6562375f.

* lib/arm-mes-mescc/setjmp.c (longjmp): Disable.
* lib/linux/arm-mes-mescc/mini.c (_exit): Use ldr.
(_write): Use ldr.
* lib/linux/arm-mes-mescc/syscall.c (__sys_call): Use ldr.
(__sys_call1): Use ldr.
(__sys_call2): Use ldr.
(__sys_call3): Use ldr.
(__sys_call4): Use ldr.

4 months agoARM: Clean up comments.
Danny Milosavljevic [Sat, 13 Apr 2019 21:33:41 +0000 (23:33 +0200)]
ARM: Clean up comments.

* lib/arm-mes/arm.M1: Clean up comments.

4 months agoRevert "Work around nyacc #define parsing/evaluation bug."
Jan Nieuwenhuizen [Fri, 12 Apr 2019 20:59:26 +0000 (22:59 +0200)]
Revert "Work around nyacc #define parsing/evaluation bug."

This reverts commit 7e8dfb474340b2fd809ee54e4d816b4a4275364d.

4 months agoARM: Fix storing bytes in the stack frame.
Danny Milosavljevic [Fri, 12 Apr 2019 15:44:28 +0000 (17:44 +0200)]
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.

4 months agoARM: Fix handling of negative offsets in load/store instructions.
Danny Milosavljevic [Fri, 12 Apr 2019 08:45:24 +0000 (10:45 +0200)]
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.

4 months agoAdd missing #include.
Danny Milosavljevic [Thu, 11 Apr 2019 17:59:48 +0000 (19:59 +0200)]
Add missing #include.

* lib/arm-mes-mescc/setjmp.c: Add missing #include.

4 months agoARM: Support negative values as immediate.
Danny Milosavljevic [Thu, 11 Apr 2019 17:58:08 +0000 (19:58 +0200)]
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.

4 months agoARM: Make "ret" macro do the right thing.
Danny Milosavljevic [Thu, 11 Apr 2019 16:06:00 +0000 (18:06 +0200)]
ARM: Make "ret" macro do the right thing.

* lib/arm-mes/arm.M1 (ret): Make it do the right thing.

4 months agoWork around nyacc #define parsing/evaluation bug.
Danny Milosavljevic [Thu, 11 Apr 2019 15:01:02 +0000 (17:01 +0200)]
Work around nyacc #define parsing/evaluation bug.

* lib/linux/time.c: Use "#if defined" instead of "#if".

4 months agoARM: Fix sub____%r1,%r0 encoding.
Danny Milosavljevic [Thu, 11 Apr 2019 03:21:41 +0000 (05:21 +0200)]
ARM: Fix sub____%r1,%r0 encoding.

* lib/arm-mes/arm.M1 (sub____%r1,%r0): Fix encoding.

4 months agoARM: Remove OABI-only system call numbers.
Danny Milosavljevic [Wed, 10 Apr 2019 13:41:56 +0000 (15:41 +0200)]
ARM: Remove OABI-only system call numbers.

* include/linux/arm/syscall.h (SYS_time): Delete definition.

4 months agoARM: Workarounds for running mescc.
Jan Nieuwenhuizen [Sun, 7 Apr 2019 21:29:37 +0000 (21:29 +0000)]
ARM: Workarounds for running mescc.

* module/mescc.scm (mescc:main): Oops, handle -std=STANDARD.
* build-aux/build.sh.in (CFLAGS): Add -std=gnu99.  Fixes compilation
with gcc-4.9.
* src/reader.c (reader_read_identifier_or_number): Ugly hack: exit at
EOF.  Fixes running mescc.

4 months agoARM: Mes C Library: Compile fixes.
Jan Nieuwenhuizen [Sun, 7 Apr 2019 19:01:07 +0000 (21:01 +0200)]
ARM: Mes C Library: Compile fixes.

* lib/arm-mes-mescc/setjmp.c (setjmp): Do not use x86 registers.
* lib/arm-mes/arm.M1 (uxtb__%r1,%r1): New macro.

4 months agoARM: mescc: Handle command-line option "-marm".
Danny Milosavljevic [Wed, 20 Mar 2019 16:46:30 +0000 (17:46 +0100)]
ARM: mescc: Handle command-line option "-marm".

* module/mescc/mescc.scm (arch-get): Handle command-line option "-marm".

4 months agoARM: Prevent setjmp/longjmp inlining.
Danny Milosavljevic [Sat, 16 Mar 2019 21:43:53 +0000 (22:43 +0100)]
ARM: Prevent setjmp/longjmp inlining.

* lib/arm-mes-gcc/setjmp.c (longjmp): Prevent inlining.
(setjmp): Prevent inlining.

4 months agoARM: Add case for ARM.
Danny Milosavljevic [Thu, 14 Mar 2019 23:17:43 +0000 (00:17 +0100)]
ARM: Add case for ARM.

* lib/tests/scaffold/76-pointer-arithmetic.c (main): Add case for ARM.

4 months agoARM: Implement setjmp/longjmp, part 2.
Danny Milosavljevic [Thu, 14 Mar 2019 20:34:53 +0000 (21:34 +0100)]
ARM: Implement setjmp/longjmp, part 2.

Follow-up to 102ccc27f6e619ca7207b6360ac918342711613a.

* include/setjmp.h (__jmp_buf): Add case for ARM.

4 months agoARM: Implement setjmp/longjmp.
Danny Milosavljevic [Thu, 14 Mar 2019 17:46:06 +0000 (18:46 +0100)]
ARM: Implement setjmp/longjmp.

* lib/arm-mes-gcc/setjmp.c (setjmp): Implement.
(longjmp): Implement.

4 months agoARM: Special-case "struct sigaction".
Danny Milosavljevic [Wed, 13 Mar 2019 23:32:56 +0000 (00:32 +0100)]
ARM: Special-case "struct sigaction".

* include/signal.h (struct sigaction): Special-case for ARM.

4 months agoARM: Special-case O_DIRECTORY.
Danny Milosavljevic [Wed, 13 Mar 2019 22:28:35 +0000 (23:28 +0100)]
ARM: Special-case O_DIRECTORY.

* include/fcntl.h (O_DIRECTORY): Special-case for ARM.

4 months agoARM: Fix test.
Danny Milosavljevic [Wed, 13 Mar 2019 17:01:12 +0000 (18:01 +0100)]
ARM: Fix test.

* lib/tests/scaffold/7k-for-each-elem.c: Fix test.

4 months agoARM: Disable Thumb mode.
Danny Milosavljevic [Tue, 12 Mar 2019 23:06:14 +0000 (00:06 +0100)]
ARM: Disable Thumb mode.

* build-aux/build.sh.in: Disable Thumb mode.
* build-aux/check.sh.in: Disable Thumb mode.

4 months agoARM: Fix stat test.
Danny Milosavljevic [Tue, 12 Mar 2019 11:38:43 +0000 (12:38 +0100)]
ARM: Fix stat test.

* build-aux/test-c.sh: Increase test timeout to 20 s.
* lib/tests/io/90-stat.c: Add __arm__ case for stat structure.

4 months agoARM: Fix test.
Danny Milosavljevic [Mon, 11 Mar 2019 22:43:32 +0000 (23:43 +0100)]
ARM: Fix test.

* lib/tests/scaffold/85-sizeof.c: Fix test.

4 months agoARM: Fix comment.
Danny Milosavljevic [Mon, 11 Mar 2019 19:34:13 +0000 (20:34 +0100)]
ARM: Fix comment.

Follow-up to ca5425bfc4cd0ca0fee5002220e4cd329643d8c5.

* lib/mes/div.c: Fix comment.

4 months agoARM: Provide __aeabi_* only for ARM.
Danny Milosavljevic [Mon, 11 Mar 2019 19:23:34 +0000 (20:23 +0100)]
ARM: Provide __aeabi_* only for ARM.

Follow-up to 25b3ac2ba85d9833227f75f841503a6697aab45e.

* lib/mes/div.c (__aeabi_idivmod, __aeabi_idiv, __aeabi_uidivmod,
__aeabi_uidiv): Add guard for ARM.

4 months agoARM: Remove unused struct uidiv_t.
Danny Milosavljevic [Mon, 11 Mar 2019 19:22:28 +0000 (20:22 +0100)]
ARM: Remove unused struct uidiv_t.

Follow-up to 25b3ac2ba85d9833227f75f841503a6697aab45e.

* lib/mes/div.c (uidiv_t): Delete.

4 months agoARM: Return both the quotient and the remainder.
Danny Milosavljevic [Mon, 11 Mar 2019 18:33:53 +0000 (19:33 +0100)]
ARM: Return both the quotient and the remainder.

* lib/mes/div.c (__aeabi_idivmod): Use ldiv.  Return both quotient and
remainder.
(__aeabi_uidivmod): Use __mesabi_uldiv.  Return both quotient and remainder.

4 months agoARM: Handle sign when dividing integers using gcc.
Danny Milosavljevic [Mon, 11 Mar 2019 16:41:29 +0000 (17:41 +0100)]
ARM: Handle sign when dividing integers using gcc.

* lib/mes/div.c (__aeabi_idivmod): Use ldiv.
(__aeabi_idiv): Use ldiv.

4 months agoARM: Delete _sys_call6 from arm-mes-gcc port.
Danny Milosavljevic [Mon, 11 Mar 2019 16:11:13 +0000 (17:11 +0100)]
ARM: Delete _sys_call6 from arm-mes-gcc port.

* lib/linux/arm-mes-gcc/syscall.c (_sys_call6): Delete procedure.

4 months agoARM: Specify R7 as changed.
Danny Milosavljevic [Mon, 11 Mar 2019 16:00:44 +0000 (17:00 +0100)]
ARM: Specify R7 as changed.

* lib/linux/arm-mes-gcc/mini.c (_exit): Specify R7 as changed.
* lib/linux/arm-mes-gcc/syscall.c (_sys_call, _sys_call1, _sys_call2,
_sys_call3, _sys_call4): Specify R7 as changed.

4 months agoARM: Fix system call handling in arm-mes-gcc.
Danny Milosavljevic [Mon, 11 Mar 2019 15:33:40 +0000 (16:33 +0100)]
ARM: Fix system call handling in arm-mes-gcc.

* lib/linux/arm-mes-gcc/syscall.c (_sys_call, _sys_call1, _sys_call2,
_sys_call3, _sys_call4, _sys_call5, _sys_call6): Modify.

4 months agoARM: Fix environment setup.
Danny Milosavljevic [Mon, 11 Mar 2019 10:53:09 +0000 (11:53 +0100)]
ARM: Fix environment setup.

* lib/linux/arm-mes-gcc/crt1.c (_start): Fix environment setup.

4 months agoARM: Clean up _start.
Danny Milosavljevic [Mon, 11 Mar 2019 10:51:32 +0000 (11:51 +0100)]
ARM: Clean up _start.

lib/linux/arm-mes-gcc/crt1.c (_start): Clean up the function.

4 months agoARM: Use GCC-emitted frame pointer.
Danny Milosavljevic [Mon, 11 Mar 2019 10:26:50 +0000 (11:26 +0100)]
ARM: Use GCC-emitted frame pointer.

* lib/linux/arm-mes-gcc/crt1.c (_start): Use GCC-emitted frame pointer.

4 months agoARM: Fix arm-mes-gcc _start.
Danny Milosavljevic [Sun, 10 Mar 2019 20:45:25 +0000 (21:45 +0100)]
ARM: Fix arm-mes-gcc _start.

* lib/linux/arm-mes-gcc/crt1.c: Fix arm-mes-gcc _start.

4 months agoporting: arm scaffold WIP
Jan Nieuwenhuizen [Thu, 7 Mar 2019 20:24:50 +0000 (21:24 +0100)]
porting: arm scaffold WIP

4 months agoARM: Fix syscalls, part 2.
Danny Milosavljevic [Wed, 6 Mar 2019 09:15:58 +0000 (10:15 +0100)]
ARM: Fix syscalls, part 2.

* include/linux/arm/syscall.h: Fix syscalls.

4 months agoARM: Add macro "mov____$i32,%r7".
Danny Milosavljevic [Wed, 6 Mar 2019 09:09:31 +0000 (10:09 +0100)]
ARM: Add macro "mov____$i32,%r7".

* lib/arm-mes/arm.M1: Add macro "mov____$i32,%r7".

4 months agoARM: Fix syscall numbers.
Danny Milosavljevic [Wed, 6 Mar 2019 09:09:01 +0000 (10:09 +0100)]
ARM: Fix syscall numbers.

* lib/arm-mes/arm.M1: Fix syscall numbers.

4 months agoARM: Fix "bl" macro.
Danny Milosavljevic [Wed, 6 Mar 2019 08:57:21 +0000 (09:57 +0100)]
ARM: Fix "bl" macro.

* lib/arm-mes/arm.M1: Fix "bl" macro.

4 months agoARM: some build hacks REVERTME
Jan Nieuwenhuizen [Sun, 3 Mar 2019 14:43:35 +0000 (15:43 +0100)]
ARM: some build hacks REVERTME

4 months agoARM: Mes C Library: Support gcc __aeabi.
Jan Nieuwenhuizen [Sun, 3 Mar 2019 18:58:19 +0000 (19:58 +0100)]
ARM: Mes C Library: Support gcc __aeabi.

* lib/mes/div.c (__aeabi_idivmod, __aeabi_idiv, __aeabi_uidivmod,
__aeabi_uidiv): New function.

4 months agoARM: Mes C Library: Add compile stub for time.
Jan Nieuwenhuizen [Sun, 3 Mar 2019 21:14:29 +0000 (22:14 +0100)]
ARM: Mes C Library: Add compile stub for time.

* lib/linux/time.c (time)[SYS_gettimeofday]: Implemnt using gettimeofday.
(time)[!SYS_time && !SYS_gettimeofday]: Compile stub.

4 months agoARM: Mes C Library: Support gcc-sans-libc.
Jan Nieuwenhuizen [Sun, 3 Mar 2019 17:11:36 +0000 (18:11 +0100)]
ARM: Mes C Library: Support gcc-sans-libc.

* lib/linux/arm-mes-gcc/crt1.c: New file.
* lib/linux/arm-mes-gcc/mini.c: New file.
* lib/linux/arm-mes-gcc/syscall.c: New file.
* lib/arm-mes-gcc/setjmp.c: New file.

4 months agoARM: Mes C Library: Support abort.
Jan Nieuwenhuizen [Sun, 3 Mar 2019 17:08:38 +0000 (18:08 +0100)]
ARM: Mes C Library: Support abort.

* lib/stdlib/abort.c (abort): Support Arm.
* lib/arm-mes/arm.M1 (wfi): New macro.

4 months agoARM: Fix instruction encoding for "add____$i8,%esp" in armv4:call-label.
Danny Milosavljevic [Wed, 27 Feb 2019 16:50:42 +0000 (17:50 +0100)]
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".

4 months agoARM: Fix off-by-one error in "mov____%r0,0x32".
Danny Milosavljevic [Wed, 27 Feb 2019 16:42:51 +0000 (17:42 +0100)]
ARM: Fix off-by-one error in "mov____%r0,0x32".

* lib/arm-mes/arm.M1: Fix off-by-one error in "mov____%r0,0x32".

4 months agoARM: Make the ELF headers and footers very similar to x86 again.
Danny Milosavljevic [Wed, 27 Feb 2019 15:50:14 +0000 (16:50 +0100)]
ARM: Make the ELF headers and footers very similar to x86 again.

* lib/arm-mes/elf32-0header.hex2: Modify.
* lib/arm-mes/elf32-footer-single-main.hex2: Modify.
* lib/arm-mes/elf32-header.hex2: Modify.

4 months agoARM: Define LONG_MIN etc.
Danny Milosavljevic [Wed, 27 Feb 2019 15:32:34 +0000 (16:32 +0100)]
ARM: Define LONG_MIN etc.

* include/stdint.h: Define LONG_MIN etc for ARM.

4 months agoWhen emitting a function, also emit an aligner first.
Danny Milosavljevic [Tue, 26 Feb 2019 23:24:14 +0000 (00:24 +0100)]
When emitting a function, also emit an aligner first.

* module/mescc/M1.scm (info->M1): When emitting a function, also emit
an aligner first.

4 months agoARM: Delete r9-exposing macros.
Danny Milosavljevic [Tue, 26 Feb 2019 17:30:40 +0000 (18:30 +0100)]
ARM: Delete r9-exposing macros.

* lib/arm-mes/arm.M1: Delete r9-exposing macros.

4 months agoARM: Add macro "mov____%esp,%r0".
Danny Milosavljevic [Tue, 26 Feb 2019 17:29:41 +0000 (18:29 +0100)]
ARM: Add macro "mov____%esp,%r0".

* lib/arm-mes/arm.M1: Add macro "mov____%esp,%r0".

4 months agoARM: Assume that double and long double are 4 Byte for now (FIXME).
Danny Milosavljevic [Tue, 26 Feb 2019 17:22:04 +0000 (18:22 +0100)]
ARM: Assume that double and long double are 4 Byte for now (FIXME).

* module/mescc/armv4/info.scm (armv4:type-alist): Assume that double and
long double are 4 Byte for now (FIXME).

4 months agoARM: Fix "jmp____*%r1".
Danny Milosavljevic [Tue, 26 Feb 2019 16:33:16 +0000 (17:33 +0100)]
ARM: Fix "jmp____*%r1".

* lib/arm-mes/arm.M1: Fix "jmp____*%r1".

4 months agoARM: Add macro "uxtb__%r1,%r1".
Danny Milosavljevic [Tue, 26 Feb 2019 16:25:19 +0000 (17:25 +0100)]
ARM: Add macro "uxtb__%r1,%r1".

* lib/arm-mes/arm.M1: Add macro "uxtb__%r1,%r1".

4 months agoARM: Fix armv4:be?->r.
Danny Milosavljevic [Tue, 26 Feb 2019 16:16:30 +0000 (17:16 +0100)]
ARM: Fix armv4:be?->r.

* module/mescc/armv4/as.scm (armv4:be?->r): Use "movhi__%r?,$i8".

4 months agoARM: Fix byte-mem-add.
Danny Milosavljevic [Tue, 26 Feb 2019 16:08:28 +0000 (17:08 +0100)]
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.

4 months agoARM: Add macro "mov____0x32(%ebp),%r0".
Danny Milosavljevic [Tue, 26 Feb 2019 16:05:11 +0000 (17:05 +0100)]
ARM: Add macro "mov____0x32(%ebp),%r0".

* lib/arm-mes/arm.M1: Add macro "mov____0x32(%ebp),%r0".

4 months agoARM: Use i386 struct stat.
Danny Milosavljevic [Tue, 26 Feb 2019 15:38:11 +0000 (16:38 +0100)]
ARM: Use i386 struct stat.

* include/sys/stat.h: Use i386 struct stat for ARM.

4 months agoARM: Fix ldr*, str* references.
Danny Milosavljevic [Tue, 26 Feb 2019 15:09:59 +0000 (16:09 +0100)]
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.

4 months agoARM: Add macros like "ldrh___%r?,(%r?)", "strb___%r0,0x8(%ebp)", "push___0",
Danny Milosavljevic [Tue, 26 Feb 2019 15:08:37 +0000 (16:08 +0100)]
ARM: Add macros like "ldrh___%r?,(%r?)", "strb___%r0,0x8(%ebp)", "push___0",
"add____$i32,%r?", "strb___%r0,0x32(%ebp)".

4 months agoARM: Add "mov____0x8(%ebp),%esp" macro.
Danny Milosavljevic [Sun, 24 Feb 2019 10:56:52 +0000 (11:56 +0100)]
ARM: Add "mov____0x8(%ebp),%esp" macro.

* lib/arm-mes/arm.M1: Add "mov____0x8(%ebp),%esp" macro.

4 months agoARM: Add "mov____0x8(%ebp),%ebp" macro.
Danny Milosavljevic [Sun, 24 Feb 2019 10:54:57 +0000 (11:54 +0100)]
ARM: Add "mov____0x8(%ebp),%ebp" macro.

* lib/arm-mes/arm.M1: Add "mov____0x8(%ebp),%ebp" macro.

4 months agoARM: Fix setjmp.
Danny Milosavljevic [Fri, 22 Feb 2019 18:53:07 +0000 (19:53 +0100)]
ARM: Fix setjmp.

* lib/arm-mes/setjmp.c: Fix setjmp.

4 months agoARM: Add macros "mov____%r7,0x8(%ebp)", "mov____0x8(%ebp),%r7".
Danny Milosavljevic [Fri, 22 Feb 2019 18:42:47 +0000 (19:42 +0100)]
ARM: Add macros "mov____%r7,0x8(%ebp)", "mov____0x8(%ebp),%r7".

* lib/arm-mes/arm.M1: Add macros "mov____%r7,0x8(%ebp)", "mov____0x8(%ebp),%r7".

4 months agoARM: Add macros like "mov??__%r1,$i8".
Danny Milosavljevic [Fri, 22 Feb 2019 18:38:17 +0000 (19:38 +0100)]
ARM: Add macros like "mov??__%r1,$i8".

* lib/arm-mes/arm.M1: Add macros like "mov??__%r1,$i8".

4 months agoARM: Add macro "add____$i32,(%r0)".
Danny Milosavljevic [Fri, 22 Feb 2019 18:35:13 +0000 (19:35 +0100)]
ARM: Add macro "add____$i32,(%r0)".

* lib/arm-mes/arm.M1: Add macro "add____$i32,(%r0)".

4 months agoARM: Add macro "xchg___%r0,(%esp)".
Danny Milosavljevic [Fri, 22 Feb 2019 18:30:06 +0000 (19:30 +0100)]
ARM: Add macro "xchg___%r0,(%esp)".

* lib/arm-mes/arm.M1: Add macro "xchg___%r0,(%esp)".

4 months agoARM: Move r9 usage completely into "arm.M1".
Danny Milosavljevic [Fri, 22 Feb 2019 18:22:06 +0000 (19:22 +0100)]
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.

4 months agoARM: Division: Fix remainder pointer.
Danny Milosavljevic [Fri, 22 Feb 2019 18:17:28 +0000 (19:17 +0100)]
ARM: Division: Fix remainder pointer.

* module/mescc/armv4/as.scm (armv4:r0/r1): Fix remainder pointer.

4 months agoARM: Fix left shifts.
Danny Milosavljevic [Fri, 22 Feb 2019 16:29:13 +0000 (17:29 +0100)]
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.

4 months agoARM: Fix testing for zero.
Danny Milosavljevic [Fri, 22 Feb 2019 16:22:29 +0000 (17:22 +0100)]
ARM: Fix testing for zero.

* module/mescc/armv4/as.scm (armv4:r-zero?): Modify.
(armv4:xor-zf): Modify.

4 months agoARM: Fix multiplication.
Danny Milosavljevic [Fri, 22 Feb 2019 16:17:22 +0000 (17:17 +0100)]
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.

4 months agoARM: Implement division and modulus.
Danny Milosavljevic [Thu, 21 Feb 2019 23:23:23 +0000 (00:23 +0100)]
ARM: Implement division and modulus.

* module/mescc/armv4/as.scm (armv4:r0/r1): Call "__mesabi_uldiv".
(armv4:r0%r1): Call "__mesabi_uldiv".

4 months agoARM: Introduce immediate->r0.
Danny Milosavljevic [Wed, 20 Feb 2019 00:46:49 +0000 (01:46 +0100)]
ARM: Introduce immediate->r0.

* module/mescc/armv4/as.scm (immediate->r0): New procedure.
(armv4:local-add): Use it.
(armv4:label-mem-add): Use it.

4 months agoARM: Simplify source formatting.
Danny Milosavljevic [Wed, 20 Feb 2019 00:45:45 +0000 (01:45 +0100)]
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.

4 months agoARM: Add "add____%r0,%r1" macro.
Danny Milosavljevic [Wed, 20 Feb 2019 00:38:29 +0000 (01:38 +0100)]
ARM: Add "add____%r0,%r1" macro.

* lib/arm-mes/arm.M1: Add "add____%r0,%r1" macro.

4 months agoARM: Add "mov____0x32(%ebp),%r1" macro.
Danny Milosavljevic [Wed, 20 Feb 2019 00:37:52 +0000 (01:37 +0100)]
ARM: Add "mov____0x32(%ebp),%r1" macro.

* lib/arm-mes/arm.M1: Add "mov____0x32(%ebp),%r1" macro.

4 months agoARM: Add "strb___%r0,(%r1)" macro.
Danny Milosavljevic [Tue, 19 Feb 2019 23:52:32 +0000 (00:52 +0100)]
ARM: Add "strb___%r0,(%r1)" macro.

* lib/arm-mes/arm.M1: Add "strb___%r0,(%r1)" macro.

4 months agoARM: Fix some typos.
Danny Milosavljevic [Tue, 19 Feb 2019 23:44:52 +0000 (00:44 +0100)]
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.

4 months agoARM: Add "mov____$i32,%r0", "mov____$i32,%r1", "mov____$i32,%r2" macros.
Danny Milosavljevic [Tue, 19 Feb 2019 23:38:10 +0000 (00:38 +0100)]
ARM: Add "mov____$i32,%r0", "mov____$i32,%r1", "mov____$i32,%r2" macros.

* lib/arm-mes/arm.M1: Add "mov____$i32,%r0", "mov____$i32,%r1",
"mov____$i32,%r2" macros.

4 months agoARM: Add "mul____%r1" macro.
Danny Milosavljevic [Tue, 19 Feb 2019 23:37:37 +0000 (00:37 +0100)]
ARM: Add "mul____%r1" macro.

* lib/arm-mes/arm.M1: Add "mul____%r1" macro.

4 months agoARM: Add sxtb__%r1,%r1.
Danny Milosavljevic [Tue, 19 Feb 2019 23:15:59 +0000 (00:15 +0100)]
ARM: Add sxtb__%r1,%r1.

* lib/arm-mes/arm.M1: Add "sxtb__%r1,%r1" macro.

4 months agoARM: Fix armv4:zf->r.
Danny Milosavljevic [Tue, 19 Feb 2019 23:12:37 +0000 (00:12 +0100)]
ARM: Fix armv4:zf->r.

* module/mescc/armv4/as.scm (armv4:zf->r): Use the correct macros.

4 months agoARM: Fix armv4:xor-zf.
Danny Milosavljevic [Tue, 19 Feb 2019 22:57:59 +0000 (23:57 +0100)]
ARM: Fix armv4:xor-zf.

* module/mescc/armv4/as.scm (armv4:xor-zf): Use the correct macros.

4 months agowaitpid: Add case for ARM.
Danny Milosavljevic [Tue, 19 Feb 2019 22:56:58 +0000 (23:56 +0100)]
waitpid: Add case for ARM.

* lib/linux/waitpid.c: Add case for ARM.

4 months agoARM: Fix function calls.
Danny Milosavljevic [Tue, 19 Feb 2019 12:02:47 +0000 (13:02 +0100)]
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.