Compare commits
13 Commits
master
...
wip-arm-0.
Author | SHA1 | Date |
---|---|---|
|
b14c2cbab6 | |
|
3536aa5f0d | |
|
a3f70c9a5b | |
|
72d4d0cdaf | |
|
b33626f261 | |
|
ab377dad52 | |
|
f9a9713e5f | |
|
f4dfe0ef7e | |
|
7d183c2c98 | |
|
25cbc48686 | |
|
7a4ed0d535 | |
|
a64e292ce2 | |
|
688b4ffbb6 |
2
PORTING
2
PORTING
|
@ -22,7 +22,7 @@ to your config.scm and run guix system reconfigure.
|
|||
|
||||
For example (note: ARM is no longer a 'port', see HACKING)
|
||||
#+BEGIN_SRC bash
|
||||
guix shell --system=armhf-linux --pure bash coreutils diffutils findutils gawk gcc-toolchain@7 grep git guile@2.2 gzip help2man make mescc-tools nyacc openssh-sans-x pkg-config sed tar texinfo
|
||||
guix shell --system=armhf-linux --pure bash coreutils diffutils findutils gawk gcc-toolchain grep git guile gzip help2man make mescc-tools nyacc openssh-sans-x pkg-config sed tar texinfo
|
||||
#+END_SRC
|
||||
|
||||
** Try it
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#! /bin/sh
|
||||
|
||||
# GNU Mes --- Maxwell Equations of Software
|
||||
# Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
# Copyright © 2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
#
|
||||
# This file is part of GNU Mes.
|
||||
#
|
||||
|
@ -29,6 +29,7 @@ fi
|
|||
|
||||
. ./config.sh
|
||||
. ${srcdest}build-aux/trace.sh
|
||||
. ${srcdest}build-aux/cflags.sh
|
||||
|
||||
if $courageous; then
|
||||
set +e
|
||||
|
@ -42,25 +43,6 @@ else
|
|||
}
|
||||
fi
|
||||
|
||||
case "$mes_cpu" in
|
||||
arm)
|
||||
stage0_arch=40
|
||||
stage0_cpu=armv7l
|
||||
;;
|
||||
x86_64)
|
||||
stage0_arch=2
|
||||
stage0_cpu=amd64
|
||||
;;
|
||||
x86)
|
||||
stage0_arch=1
|
||||
stage0_cpu=x86
|
||||
;;
|
||||
*)
|
||||
stage0_arch=1
|
||||
stage0_cpu=$mes_cpu
|
||||
;;
|
||||
esac
|
||||
|
||||
trace "CCLD ${srcdest}lib/$mes_kernel/$mes_cpu-mes-$compiler/exit-42.S" $CC\
|
||||
-nostdlib\
|
||||
-g\
|
||||
|
|
|
@ -38,25 +38,6 @@ set -u
|
|||
. ./config.sh
|
||||
. ${srcdest}build-aux/cflags.sh
|
||||
|
||||
case "$mes_cpu" in
|
||||
arm)
|
||||
stage0_arch=40
|
||||
stage0_cpu=armv7l
|
||||
;;
|
||||
x86_64)
|
||||
stage0_arch=2
|
||||
stage0_cpu=amd64
|
||||
;;
|
||||
x86)
|
||||
stage0_arch=1
|
||||
stage0_cpu=x86
|
||||
;;
|
||||
*)
|
||||
stage0_arch=1
|
||||
stage0_cpu=$mes_cpu
|
||||
;;
|
||||
esac
|
||||
|
||||
if $courageous; then
|
||||
echo "Applying courage"
|
||||
set +e
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# GNU Mes --- Maxwell Equations of Software
|
||||
# Copyright © 2018,2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
# Copyright © 2018,2019,2020,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
#
|
||||
# This file is part of GNU Mes.
|
||||
#
|
||||
|
@ -16,6 +16,25 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
case "$mes_cpu" in
|
||||
arm)
|
||||
stage0_arch=40
|
||||
stage0_cpu=armv7l
|
||||
;;
|
||||
x86_64)
|
||||
stage0_arch=2
|
||||
stage0_cpu=amd64
|
||||
;;
|
||||
x86)
|
||||
stage0_arch=1
|
||||
stage0_cpu=x86
|
||||
;;
|
||||
*)
|
||||
stage0_arch=1
|
||||
stage0_cpu=$mes_cpu
|
||||
;;
|
||||
esac
|
||||
|
||||
AM_CPPFLAGS="
|
||||
-D HAVE_CONFIG_H=1
|
||||
-I ${srcdest}include
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#! /bin/sh
|
||||
|
||||
# GNU Mes --- Maxwell Equations of Software
|
||||
# Copyright © 2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
# Copyright © 2017,2018,2019,2020,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
#
|
||||
# This file is part of GNU Mes.
|
||||
#
|
||||
|
@ -117,6 +117,7 @@ lib/tests/scaffold/54-argv.c
|
|||
lib/tests/scaffold/55-char-array.c
|
||||
lib/tests/scaffold/60-math.c
|
||||
lib/tests/scaffold/60-math-itoa.c
|
||||
lib/tests/scaffold/60-math-modulo.c
|
||||
lib/tests/scaffold/61-array.c
|
||||
lib/tests/scaffold/62-array.c
|
||||
lib/tests/scaffold/63-struct.c
|
||||
|
|
|
@ -31,6 +31,7 @@ DEFINE add____$i8,%r0 0090e2 # adds r0, r0, #xx; ADDSI = immediate op1 '09' op
|
|||
# 1090e2 # adds r1, r0, #xx; ADDSI = immediate op1 '09' op2 'e2'
|
||||
DEFINE add____$i8,%r1 1091e2 # adds r1, r1, #xx
|
||||
DEFINE add____$i8,%r13 d09de2 # adds r13, r13, #xx
|
||||
DEFINE add____$i8,%ebp e28cc0 # adds ip, ip, #xx
|
||||
DEFINE sub____$i8,%r0 0050e2 # subs r0, r0, #xx
|
||||
DEFINE sub____$i8,%r1 1051e2 # subs r1, r1, #xx
|
||||
DEFINE add____%r0,%r0 000090e0 # adds r0, r0, r0
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
### GNU Mes --- Maxwell Equations of Software
|
||||
### Copyright (C) 2016 Jeremiah Orians
|
||||
### Copyright © 2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
### Copyright © 2017,2018,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
### Copyright © 2020 Danny Milosavljevic <dannym@scratchpost.org>
|
||||
###
|
||||
### This file is part of GNU Mes.
|
||||
###
|
||||
|
@ -17,6 +18,47 @@
|
|||
### You should have received a copy of the GNU General Public License
|
||||
### along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
:UNUSED_start
|
||||
;; ??? from M2
|
||||
'0' SP BP NO_SHIFT MOVE_ALWAYS ; Setup Base Pointer
|
||||
|
||||
push___%lr
|
||||
push___%ebp
|
||||
mov____%esp,%ebp
|
||||
allocate_stack_4180
|
||||
!0 mov____$i8,%r0
|
||||
mov____%r0,0x32 &GLOBAL___stdin
|
||||
!1 mov____$i8,%r0
|
||||
mov____%r0,0x32 &GLOBAL___stdout
|
||||
!2 mov____$i8,%r0
|
||||
mov____%r0,0x32 &GLOBAL___stderr
|
||||
!8 ldr____%r0,(%fp,+#$i8)
|
||||
mov____%fp,%r1
|
||||
!12 add____%r1,$i8
|
||||
add____%r2,%r1,%r0,lsl#2
|
||||
!4 add____%r2,$i8
|
||||
mov____%r2,0x32 &GLOBAL_environ
|
||||
|
||||
; M2-Planet calling convention pushes forward
|
||||
push___%r0 ; argc
|
||||
push___%r1 ; argv
|
||||
push___%r2 ; environ
|
||||
|
||||
!4 add____$i8,%ebp ;M2-Planet calling convention
|
||||
^~FUNCTION_main bl
|
||||
!0x0 add____$i8,%esp
|
||||
!0x0 cmp____$i8,%r0
|
||||
SYS_exit mov____$i8,%r7
|
||||
swi____$0
|
||||
:__start_loop
|
||||
wfi
|
||||
!0x1 mov____$i8,%r0
|
||||
!0x0 cmp____$i8,%r0
|
||||
^~__start_loop b
|
||||
mov____%ebp,%esp
|
||||
pop____%ebp
|
||||
ret
|
||||
|
||||
:_start
|
||||
'0' SP BP NO_SHIFT MOVE_ALWAYS ; Setup Base Pointer
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2016,2017,2018,2019,2020,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -23,7 +23,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#if __M2_PLANET__ || !(__MESC__ && __arm__)
|
||||
#if __M2_PLANET__ || (!(__MESC__ && __arm__) && !(__TINYC__ && __arm__ && BOOTSTRAP))
|
||||
size_t
|
||||
__mesabi_uldiv (size_t a, size_t b, size_t *remainder)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
* GNU Mes is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* GNU Mes is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <mes/lib.h>
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
int i;
|
||||
|
||||
oputs ("\n");
|
||||
|
||||
oputs ("t: 1 % 2\n");
|
||||
i = 1 % 2;
|
||||
if (i != 1)
|
||||
return 1;
|
||||
|
||||
oputs ("t: 2 % 4\n");
|
||||
i = 2 % 4;
|
||||
if (i != 2)
|
||||
return 2;
|
||||
|
||||
oputs ("t: 3 % 4\n");
|
||||
i = 3 % 4;
|
||||
if (i != 3)
|
||||
return 3;
|
||||
|
||||
oputs ("t: 1 % 256\n");
|
||||
i = 1 % 256;
|
||||
if (i != 1)
|
||||
return 4;
|
||||
|
||||
unsigned u;
|
||||
|
||||
oputs ("\n");
|
||||
|
||||
oputs ("t: 1U % 2\n");
|
||||
u = 1 % 2;
|
||||
if (u != 1)
|
||||
return 5;
|
||||
|
||||
oputs ("t: 2U % 4\n");
|
||||
u = 2 % 4;
|
||||
if (u != 2)
|
||||
return 6;
|
||||
|
||||
oputs ("t: 3U % 4\n");
|
||||
u = 3 % 4;
|
||||
if (u != 3)
|
||||
return 7;
|
||||
|
||||
oputs ("t: 1U % 256\n");
|
||||
u = 1 % 256;
|
||||
if (u != 1)
|
||||
return 8;
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -143,8 +143,8 @@
|
|||
((type-name ,type) (ast->type type info))
|
||||
((type-spec ,type) (ast->type type info))
|
||||
|
||||
((sizeof-expr ,expr) (get-type "unsigned" info))
|
||||
((sizeof-type ,type) (get-type "unsigned" info))
|
||||
((sizeof-expr ,expr) (get-type "default" info))
|
||||
((sizeof-type ,type) (get-type "default" info))
|
||||
|
||||
((string ,string) (make-c-array (get-type "char" info) (1+ (string-length string))))
|
||||
|
||||
|
@ -1218,9 +1218,9 @@
|
|||
((rshift ,a ,b) ((binop->r info) a b 'r0>>r1))
|
||||
((div ,a ,b)
|
||||
((binop->r info) a b 'r0/r1
|
||||
(signed? (ast->type a info))))
|
||||
(or (signed? (ast->type a info)) (signed? (ast->type b info)))))
|
||||
((mod ,a ,b) ((binop->r info) a b 'r0%r1
|
||||
(signed? (ast->type a info))))
|
||||
(or (signed? (ast->type a info)) (signed? (ast->type b info)))))
|
||||
((mul ,a ,b) ((binop->r info) a b 'r0*r1))
|
||||
|
||||
((not ,expr)
|
||||
|
@ -1361,7 +1361,7 @@
|
|||
info)))
|
||||
(info (expr->register a info))
|
||||
(info (append-text info (wrap-as (as info 'swap-r0-r1))))
|
||||
(signed? (signed? type))
|
||||
(signed? (or (signed? type) (signed? type-b)))
|
||||
(info (append-text info (cond ((equal? op "+=") (wrap-as (as info 'r0+r1)))
|
||||
((equal? op "-=") (wrap-as (as info 'r0-r1)))
|
||||
((equal? op "*=") (wrap-as (as info 'r0*r1)))
|
||||
|
|
21
src/math.c
21
src/math.c
|
@ -191,24 +191,13 @@ modulo (struct scm *a, struct scm *b)
|
|||
assert_number ("modulo", a);
|
||||
assert_number ("modulo", b);
|
||||
long n = a->value;
|
||||
long v = b->value;
|
||||
if (v == 0)
|
||||
long d = b->value;
|
||||
if (d == 0)
|
||||
error (cstring_to_symbol ("divide-by-zero"), a);
|
||||
int sign_p = 0;
|
||||
size_t w = v;
|
||||
if (v < 0)
|
||||
{
|
||||
sign_p = 1;
|
||||
w = -v;
|
||||
}
|
||||
while (n < 0)
|
||||
n = n + w;
|
||||
size_t u = n;
|
||||
if (u != 0)
|
||||
u = u % w;
|
||||
n = u;
|
||||
if (sign_p)
|
||||
n = -n;
|
||||
n = n + d;
|
||||
if (n != 0)
|
||||
n = n % d;
|
||||
return make_number (n);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2016,2017,2018,2019,2020,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -23,7 +23,7 @@
|
|||
|
||||
#include <string.h>
|
||||
|
||||
// char const *MES_VERSION = "0.23";
|
||||
// char const *MES_VERSION = "0.24";
|
||||
|
||||
#if __M2_PLANET__
|
||||
#define M2_CELL_SIZE 12
|
||||
|
|
Loading…
Reference in New Issue