From 9925112da98bdbc8a22a49c21304797383650ff6 Mon Sep 17 00:00:00 2001 From: biouman <> Date: Sun, 20 May 2001 00:38:11 +0000 Subject: *** empty log message *** --- aclocal.m4 | 58 ++-- include/alu.h | 22 +- include/interne.h | 3 - lib/alu.c | 866 +++++++++++++++++------------------------------------ lib/interne.c | 20 +- po/ProjetArchi.pot | 16 +- po/cat-id-tbl.c | 106 ++++--- 7 files changed, 385 insertions(+), 706 deletions(-) diff --git a/aclocal.m4 b/aclocal.m4 index 8aa6b71..61d5760 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -159,7 +159,7 @@ else fi]) -# serial 40 AC_PROG_LIBTOOL +# serial 39 AC_PROG_LIBTOOL AC_DEFUN(AC_PROG_LIBTOOL, [AC_REQUIRE([AC_LIBTOOL_SETUP])dnl @@ -172,7 +172,7 @@ LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \ LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \ DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \ ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \ -$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $lt_target \ +$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $host \ || AC_MSG_ERROR([libtool configure failed]) # Reload cache, that may have been modified by ltconfig @@ -204,11 +204,6 @@ AC_REQUIRE([AC_PROG_NM])dnl AC_REQUIRE([AC_PROG_LN_S])dnl dnl -case "$target" in -NONE) lt_target="$host" ;; -*) lt_target="$target" ;; -esac - # Check for any special flags to pass to ltconfig. libtool_flags="--cache-file=$cache_file" test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared" @@ -227,7 +222,7 @@ test x"$silent" = xyes && libtool_flags="$libtool_flags --silent" # Some flags need to be propagated to the compiler or linker for good # libtool support. -case "$lt_target" in +case "$host" in *-*-irix6*) # Find out which ABI we are using. echo '[#]line __oline__ "configure"' > conftest.$ac_ext @@ -443,6 +438,7 @@ else AC_MSG_RESULT(no) fi test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH]) +AC_SUBST(LD) AC_PROG_LD_GNU ]) @@ -488,13 +484,14 @@ else fi]) NM="$ac_cv_path_NM" AC_MSG_RESULT([$NM]) +AC_SUBST(NM) ]) # AC_CHECK_LIBM - check for math library AC_DEFUN(AC_CHECK_LIBM, [AC_REQUIRE([AC_CANONICAL_HOST])dnl LIBM= -case "$lt_target" in +case "$host" in *-*-beos* | *-*-cygwin*) # These system don't have libm ;; @@ -509,35 +506,30 @@ esac ]) # AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for -# the libltdl convenience library and INCLTDL to the include flags for -# the libltdl header and adds --enable-ltdl-convenience to the -# configure arguments. Note that LIBLTDL and INCLTDL are not -# AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called. If DIR is not -# provided, it is assumed to be `libltdl'. LIBLTDL will be prefixed -# with '${top_builddir}/' and INCLTDL will be prefixed with -# '${top_srcdir}/' (note the single quotes!). If your package is not -# flat and you're not using automake, define top_builddir and -# top_srcdir appropriately in the Makefiles. +# the libltdl convenience library, adds --enable-ltdl-convenience to +# the configure arguments. Note that LIBLTDL is not AC_SUBSTed, nor +# is AC_CONFIG_SUBDIRS called. If DIR is not provided, it is assumed +# to be `${top_builddir}/libltdl'. Make sure you start DIR with +# '${top_builddir}/' (note the single quotes!) if your package is not +# flat, and, if you're not using automake, define top_builddir as +# appropriate in the Makefiles. AC_DEFUN(AC_LIBLTDL_CONVENIENCE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl case "$enable_ltdl_convenience" in no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;; "") enable_ltdl_convenience=yes ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;; esac - LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la - INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) + LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdlc.la ]) # AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for -# the libltdl installable library and INCLTDL to the include flags for -# the libltdl header and adds --enable-ltdl-install to the configure -# arguments. Note that LIBLTDL and INCLTDL are not AC_SUBSTed, nor is -# AC_CONFIG_SUBDIRS called. If DIR is not provided and an installed -# libltdl is not found, it is assumed to be `libltdl'. LIBLTDL will -# be prefixed with '${top_builddir}/' and INCLTDL will be prefixed -# with '${top_srcdir}/' (note the single quotes!). If your package is -# not flat and you're not using automake, define top_builddir and -# top_srcdir appropriately in the Makefiles. +# the libltdl installable library, and adds --enable-ltdl-install to +# the configure arguments. Note that LIBLTDL is not AC_SUBSTed, nor +# is AC_CONFIG_SUBDIRS called. If DIR is not provided, it is assumed +# to be `${top_builddir}/libltdl'. Make sure you start DIR with +# '${top_builddir}/' (note the single quotes!) if your package is not +# flat, and, if you're not using automake, define top_builddir as +# appropriate in the Makefiles. # In the future, this macro may have to be called after AC_PROG_LIBTOOL. AC_DEFUN(AC_LIBLTDL_INSTALLABLE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl AC_CHECK_LIB(ltdl, main, @@ -550,12 +542,10 @@ AC_DEFUN(AC_LIBLTDL_INSTALLABLE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl ]) if test x"$enable_ltdl_install" = x"yes"; then ac_configure_args="$ac_configure_args --enable-ltdl-install" - LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la - INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) + LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdl.la else ac_configure_args="$ac_configure_args --enable-ltdl-install=no" LIBLTDL="-lltdl" - INCLTDL= fi ]) @@ -568,8 +558,8 @@ AC_DEFUN(AM_DISABLE_STATIC, [indir([AC_DISABLE_STATIC], $@)])dnl AC_DEFUN(AM_PROG_LD, [indir([AC_PROG_LD])])dnl AC_DEFUN(AM_PROG_NM, [indir([AC_PROG_NM])])dnl -dnl This is just to silence aclocal about the macro not being used -ifelse([AC_DISABLE_FAST_INSTALL])dnl +dnl This is just to quiet aclocal about the macro not being used +if(a,b,[AC_DISABLE_FAST_INSTALL])dnl # Macro to add for using GNU gettext. # Ulrich Drepper , 1995. diff --git a/include/alu.h b/include/alu.h index 128d9d4..079efcc 100644 --- a/include/alu.h +++ b/include/alu.h @@ -6,6 +6,9 @@ typedef struct couple { Uint32 deb, fin; } couple; +typedef struct { char st, nd; } chars; + + Uint32 AdditionNonSigne(Uint32 a, Uint32 b); Uint32 AdditionSigne(Uint32 a, Uint32 b); Uint32 SoustractionNonSigne(Uint32 a, Uint32 b); @@ -18,7 +21,24 @@ Uint32 AND(Uint32 a, Uint32 b); Uint32 OR(Uint32 a, Uint32 b); Uint32 SHL(Uint32 a); Uint32 SHR(Uint32 a); - +chars CreerChars(char x, char y); +chars AddBit(char a, char b, char re); +chars SubBit(char a, char b, char re); +Uint32 NOT(Uint32 a); +Uint32 OPP(Uint32 a); +Uint32 Decalage(Uint32 a, char c); +Uint32 NSHR(Uint32 a); +Uint32 NSHL(Uint32 a); +Uint32 SUB_SS(Uint32 a, Uint32 b); +Uint32 ADD_SS(Uint32 a, Uint32 b); +Uint32 ADD_UU(Uint32 a, Uint32 b); +Uint32 SUB_UU(Uint32 a, Uint32 b); +Uint32 MUL_UU(Uint32 a, Uint32 b); +Uint32 MUL_SS(Uint32 a, Uint32 b); +Uint32 DivMod_UU(Uint32 a, Uint32 b); +Uint32 DivMod_SS(Uint32 a, Uint32 b); +Uint32 NAND(Uint32 x, Uint32 y); +Uint32 NOR(Uint32 x, Uint32 y); extern int errRet, Rapide; extern Uint32 SecondResult; #endif diff --git a/include/interne.h b/include/interne.h index 337ec2d..623b163 100644 --- a/include/interne.h +++ b/include/interne.h @@ -24,9 +24,6 @@ char Or(char a, char b); char Xor(char a, char b); char Nand(char a, char b); char Nor(char a, char b); -void SetOverflow(int * o); -void ResetOverflow(int * o); -int Overflow(int o); char OrWord(Uint32 a); char AndWord(Uint32 a); #endif \ No newline at end of file diff --git a/lib/alu.c b/lib/alu.c index 0b4525a..bde852d 100644 --- a/lib/alu.c +++ b/lib/alu.c @@ -2,6 +2,7 @@ #include "config.h" #include "exceptions.h" #include "registre.h" +#include "interne.h" /*****************************************/ /** **/ @@ -275,625 +276,314 @@ Uint32 RSHR(Uint32 a) /* ALU normale (binaire) */ - /*On compte de 0 ŕ 31 */ - /*Return la valeur du ieme bit en position 0 */ -Uint32 ValeurIbitsAuDeb(Uint32 nb, int i) -{ - Uint32 val, un = 1; - - if ((i > 31) || (i < 0)) { - exception(1, _("ValeurIbitsAuDeb: position not in interval")); - } - val = nb >> i; - val = val & un; - return (val); +/* Renvoie un couple de bits */ +chars CreerChars(char x, char y) { + chars z; + z.st = x; + z.nd = y; + return (z); } - - /*Return la valeur du ieme bit en sa position d origine */ -/* -Uint32 ValeurIbit(Uint32 nb, int i) { - Uint32 val = 0, un = 1; - - if ((i > 31) || (i < 0)) { - fprintf(stderr, "erreur, ValeurIbit: la position demande n est pas dans l'intervalle"); - return (0); - } - val = un << i; - val = AndBit(un, nb); - return (val); +/* Additionne deux bits avec retenue */ +chars AddBit(char a, char b, char re) { + return CreerChars(Xor(re, Xor(a, b)), Or(And(a, b), And(re, Xor(a,b)))); } -*/ - - /*Met a vrai le ieme bit */ -Uint32 MettreAVIbit(Uint32 nb, int i) -{ - Uint32 val = 1; - return (nb | (val << i)); +/* Soustrait deux bits avec retenue */ +chars SubBit(char a, char b, char re) { + char c = Or(And(re, Or(And(Not(a), Not(b)), And(a, b))), And(Not(re), Xor(a, b))); + char d = Or(And(Not(a), Or(re, b)), And(re, b)); + return CreerChars(c,d); } - - /* Met a Vrai le Uint32 */ -Uint32 MetAVUint32(void) -{ +Uint32 NOT(Uint32 a) { int i; - - Uint32 val = 0, un = 1; - - for (i = 0; i <= 31; i++) { - val = (val | un); - un <<= 1; - } - return (val); -} - - - /* Met a Faux le Uint32 */ -Uint32 MetAFUint32(void) -{ - return (0); -} - - - /* Inverse la valeur du i eme bit */ -Uint32 InverseIbit(Uint32 nb, int i) -{ - Uint32 un = 1; - - if ((i > 31) || (i < 0)) { - exception(1, _("InverseIbit: position not in interval")); - } - un = (un << i); - return (nb ^ un); + Uint32 s = ZERO(); + for (i = 0; i < 32; i++) + AffecteBit(&s, Not((char) ValeurBit(a, i)), i); + return (s); } +Uint32 OPP(Uint32 a) { return (ADD_UU(NOT(a), ONE())); } - /* Inverse le Uint32 */ -Uint32 InverseUint32(Uint32 x) -{ +Uint32 Decalage(Uint32 a, char c) { int i; - - Uint32 val = x; - - for (i = 0; i <= 31; i++) { - val = InverseIbit(val, i); - } - return (val); -} - -Uint32 NAND(Uint32 x, Uint32 y) -{ - Uint32 m = 1, z = 0; + Uint32 resultat; + AffecteBit(&resultat, And(c, (char) ValeurBit(a, 30)), 31); + for (i = 1; i < 31; i++) + AffecteBit(&resultat, Or(And(Not(c), (char) ValeurBit(a, i + 1)), And(c, (char) ValeurBit(a, i - 1))), i); + AffecteBit(&resultat, And(Not(c), (char) ValeurBit(a, 1)), 0); + return (resultat); +} + +Uint32 NSHR(Uint32 a) { return (Decalage(a, 0)); } + +Uint32 NSHL(Uint32 a) { return (Decalage(a, 1)); } + +/* Soustrait deux mots signés */ +Uint32 SUB_SS(Uint32 a, Uint32 b) { + Uint32 resultat; + if (!Neg(a) && !Neg(b)) { + resultat = SUB_UU(a, b); + ResetOverflow(); + } + else if (!Neg(a) && Neg(b)) { + resultat = ADD_SS(a, OPP(b)); + } + else if (Neg(a) && !Neg(b)) { + resultat = OPP(ADD_SS(OPP(a), b)); + if (Not((char) ValeurBit(resultat, 31))) + SetOverflow(); + else + ResetOverflow(); + } + else + resultat = SUB_SS(OPP(b), OPP(a)); + return resultat; +} + +/* Additionne deux mots signés */ +Uint32 ADD_SS(Uint32 a, Uint32 b) { + Uint32 resultat; + if (!Neg(a) && !Neg(b)) { + resultat = ADD_UU(a, b); + if (ValeurBit(resultat, 31)) + SetOverflow(); + else + ResetOverflow(); + } + else if (!Neg(a) && Neg(b)) { + resultat = SUB_UU(a, OPP(b)); + ResetOverflow(); + } + else if (Neg(a) && !Neg(b)) { + resultat = SUB_UU(b, OPP(a)); + ResetOverflow(); + } + else { + resultat = (OPP(ADD_SS(OPP(a), OPP(b)))); + if (Not((char) ValeurBit(resultat, 31))) + SetOverflow(); + else + ResetOverflow(); + } + return resultat; +} + +/* Additionne deux mots non signés */ +Uint32 ADD_UU(Uint32 a, Uint32 b) { int i; - + Uint32 s = ZERO(); + chars aux = CreerChars(0, 0); for (i = 0; i < 32; i++) { - z |= (x & m) & (y & m); - m <<= 1; + aux = AddBit((char) ValeurBit(a, i), (char) ValeurBit(b, i), aux.nd); + AffecteBit(&s, aux.st, i); } - return (z); + if ((aux.nd == 0) ? 0 : 1) + SetOverflow(); + else + ResetOverflow(); + return (s); } -Uint32 NOR(Uint32 x, Uint32 y) -{ - Uint32 m = 1, z = 0; +/* Soustrait deux mots non signés */ +Uint32 SUB_UU(Uint32 a, Uint32 b) { int i; - + Uint32 s = ZERO(); + chars aux = CreerChars(0, 0); for (i = 0; i < 32; i++) { - z |= (x & m) | (y & m); - m <<= 1; - } - return (z); -} + aux = SubBit((char) ValeurBit(a, i), (char) ValeurBit(b, i), aux.nd); + AffecteBit(&s, aux.st, i); + } + if ((aux.nd == 0) ? 0 : 1) + SetOverflow(); + else + ResetOverflow(); + return (s); +} + +Uint32 MUL_UU(Uint32 a, Uint32 b) { + int i, j, k; + Uint32 c; + Uint32 retenue = ZERO(); + Uint32 u = ZERO(); + Uint32 v = ZERO(); + for (k = 0; k < 64; k++) { + c = ZERO(); + for (i = 0; i < 32; i++) + for (j = 0; j < 32; j++) + if (i + j == k) + c = ADD_UU(c, And((char) ValeurBit(a, i), (char) ValeurBit(b, j))); + c = ADD_UU(c, retenue); + retenue = SHR(c); + c = ValeurBit(c, 0); + if (k < 32) + AffecteBit(&u, (char) c, k); + else + AffecteBit(&v, (char) c, k - 32); + } + + + if (OrWord(v)) + SetOverflow(); + else + ResetOverflow(); + SecondResult=u; + return (v); +} + +Uint32 MUL_SS(Uint32 a, Uint32 b) { + Uint32 RegistreRG=0, RegistreRD=0; + if (!Neg(a) && !Neg(b)) { + RegistreRG=MUL_UU(a, b); + RegistreRD=SecondResult; + if (Or((char) Overflow(), (char) ValeurBit(RegistreRD, 31))) + SetOverflow(); + else + ResetOverflow(); + + } + if (!Neg(a) && Neg(b)) { + RegistreRG=MUL_UU(a, OPP(b)); + RegistreRD=SecondResult; + RegistreRD = OPP(RegistreRD); + if (Or((char) Overflow(), Not((char) ValeurBit(RegistreRD, 31)))) + SetOverflow(); + else + ResetOverflow(); + + } + if (Neg(a) && !Neg(b)) { + RegistreRG=MUL_UU(OPP(a), b); + RegistreRD=SecondResult; + RegistreRD = OPP(RegistreRD); + if (Or((char) Overflow(), Not((char) ValeurBit(RegistreRD, 31)))) + SetOverflow(); + else + ResetOverflow(); + + } + if (Neg(a) && Neg(b)) { + RegistreRG=MUL_UU(OPP(a), OPP(b)); + RegistreRD=SecondResult; + if (Or((char) Overflow(), (char) ValeurBit(RegistreRD, 31))) + SetOverflow(); + else + ResetOverflow(); + } + SecondResult=RegistreRD; + return (RegistreRG); +} + +Uint32 DivMod_UU(Uint32 a, Uint32 b) { + Uint32 div = ZERO(); + if (OrWord(b) == 0) + SetOverflow(); + else { + ResetOverflow(); + while (ValeurBit(SUB_UU(a, b), 31) == 0) { + a = SUB_UU(a, b); + div = ADD_UU(div, ONE()); + } + } + SecondResult = a; + return (div); +} + +Uint32 DivMod_SS(Uint32 a, Uint32 b) { + Uint32 RegistreRG=0, RegistreRD=0; + if (!Neg(a) && !Neg(b)) + RegistreRG = DivMod_UU(a, b); + RegistreRD = SecondResult; + if (!Neg(a) && Neg(b)) { + RegistreRG = DivMod_UU(a, OPP(b)); + RegistreRD = SecondResult; + RegistreRG = OPP(RegistreRG); + } + if (Neg(a) && !Neg(b)) { + RegistreRG = DivMod_UU(OPP(a), b); + RegistreRD = SecondResult; + RegistreRD = OPP(RegistreRD); + RegistreRG = OPP(RegistreRG); + } + if (Neg(a) && Neg(b)) { + RegistreRG = DivMod_UU(OPP(a), OPP(b)); + RegistreRD = SecondResult; + RegistreRD = OPP(RegistreRD); + } + SecondResult = RegistreRD; + return (RegistreRG); +} + + +Uint32 NAND(Uint32 x, Uint32 y) +{ + Uint32 m = 1, z = 0; + int i; + + for (i = 0; i < 32; i++) { + z |= (x & m) & (y & m); + m <<= 1; + } + return (z); +} + +Uint32 NOR(Uint32 x, Uint32 y) +{ + Uint32 m = 1, z = 0; + int i; + + for (i = 0; i < 32; i++) { + z |= (x & m) | (y & m); + m <<= 1; + } + return (z); +} + + +Uint32 NAdditionNonSigne(Uint32 a, Uint32 b) +{ + return ADD_UU(a,b); +} + +Uint32 NAdditionSigne(Uint32 a, Uint32 b) +{ + return ADD_SS(a,b); +} + +Uint32 NSoustractionNonSigne(Uint32 a, Uint32 b) +{ + return SUB_UU(a,b); +} + +Uint32 NSoustractionSigne(Uint32 a, Uint32 b) +{ + return ADD_SS(a,b); +} -Uint32 NSHLi(Uint32 x, int i) -{ - return (x << i); -} - -Uint32 NSHRi(Uint32 x, int i) -{ - return (x >> i); -} - -Uint32 NSHL(Uint32 x) -{ - return NSHLi(x, 1); -} - -Uint32 NSHR(Uint32 x) -{ - return NSHRi(x, 1); -} - -Uint32 NAdditionNonSigne(Uint32 x, Uint32 y) -{ - int i; - - Uint32 a, b, tp, add = 0, ret = 0; - - if (x == 0) - return (y); - if (y == 0) - return (x); - for (i = 0; i < 32; i++) { - a = ValeurIbitsAuDeb(x, i); - b = ValeurIbitsAuDeb(y, i); - tp = a + b + ret; - if (tp == 3) { - ret = 1; - tp = 1; - tp <<= i; - add |= tp; - } - - else { - if (tp == 2) { - ret = 1; - tp = 0; - tp <<= i; - add |= tp; - } - - else { - if (tp == 1) { - ret = 0; - tp = 1; - tp <<= i; - add |= tp; - } - - else { - ret = 0; - } - } - } - if (i == 31) { - if (ret == 1) { - errRet = 1; - } - } - } - return (add); -} - -Uint32 NAdditionSigne(Uint32 x, Uint32 y) -{ - int i; - - Uint32 a, b, tp, add = 0, ret = 0; - - if (x == 0) - return (y); - if (y == 0) - return (x); - for (i = 0; i < 32; i++) { - a = ValeurIbitsAuDeb(x, i); - b = ValeurIbitsAuDeb(y, i); - tp = a + b + ret; - if (tp == 3) { - ret = 1; - tp = 1; - tp <<= i; - add |= tp; - } - - else { - if (tp == 2) { - ret = 1; - tp = 0; - tp <<= i; - add |= tp; - } - - else { - if (tp == 1) { - ret = 0; - tp = 1; - tp <<= i; - add |= tp; - } - - else { - ret = 0; - } - } - } - if (i == 30) { - if (ret == 1) { - errRet = 1; - } - } - } - return (add); -} - -Uint32 NSoustractionNonSigne(Uint32 x, Uint32 y) -{ /* x - y */ - int i; - - Uint32 a, b, tp, sou = 0, ret = 0; - - for (i = 0; i < 32; i++) { - a = ValeurIbitsAuDeb(x, i); - b = ValeurIbitsAuDeb(y, i); - if (((a == 0) && (b == 0) && (ret == 0)) - || ((a == 1) && (b == 1) && (ret == 0)) || ((a == 1) - && (b == 0) - && (ret == 1))) { - ret = 0; - tp = 0; - tp <<= i; - sou |= tp; - } - - else { - if (((a == 0) && (b == 0) && (ret == 1)) - || ((a == 0) && (b == 1) && (ret == 0)) || ((a == 1) - && (b == 1) - && (ret == 1))) { - ret = 1; - tp = 1; - tp <<= i; - sou |= tp; - } - - else { - if ((a == 1) && (b == 0) && (ret == 0) || 0) { - ret = 0; - tp = 1; - tp <<= i; - sou |= tp; - } - - else { - ret = 1; - tp = 0; - tp <<= i; - sou |= tp; - } - } - } - if (i == 31) { - if (ret == 1) { - errRet = 1; - } - } - } - return (sou); -} - -Uint32 NSoustractionSigne(Uint32 x, Uint32 y) -{ /* x - y */ - int i; - - Uint32 a, b, tp, sou = 0, ret = 0; - - for (i = 0; i < 32; i++) { - a = ValeurIbitsAuDeb(x, i); - b = ValeurIbitsAuDeb(y, i); - if (((a == 0) && (b == 0) && (ret == 0)) - || ((a == 1) && (b == 1) && (ret == 0)) || ((a == 1) - && (b == 0) - && (ret == 1))) { - ret = 0; - tp = 0; - tp <<= i; - sou |= tp; - } - - else { - if (((a == 0) && (b == 0) && (ret == 1)) - || ((a == 0) && (b == 1) && (ret == 0)) || ((a == 1) - && (b == 1) - && (ret == 1))) { - ret = 1; - tp = 1; - tp <<= i; - sou |= tp; - } - - else { - if ((a == 1) && (b == 0) && (ret == 0) || 0) { - ret = 0; - tp = 1; - tp <<= i; - sou |= tp; - } - - else { - ret = 1; - tp = 0; - tp <<= i; - sou |= tp; - } - } - } - if (i == 30) { - if (ret == 1) { - errRet = 1; - } - } - } - return (sou); -} - -couple Addition(Uint32 x, Uint32 y) -{ /* Renvoye le resultat + eventuellement une retenue */ - int i; - - couple z; - Uint32 a, b, tp, add = 0, ret = 0; - - for (i = 0; i < 32; i++) { - a = ValeurIbitsAuDeb(x, i); - b = ValeurIbitsAuDeb(y, i); - tp = a + b + ret; - if (tp == 3) { - ret = 1; - tp = 1; - tp <<= i; - add |= tp; - } - - else { - if (tp == 2) { - ret = 1; - tp = 0; - tp <<= i; - add |= tp; - } - - else { - if (tp == 1) { - ret = 0; - tp = 1; - tp <<= i; - add |= tp; - } - - else { - ret = 0; - } - } - } - if (i == 31) { - if (ret == 1) { - z.deb = add; - z.fin = 1; - return (z); - } - } - } - z.deb = add; - z.fin = 0; - return (z); -} - -couple Add30Mul(Uint32 x, Uint32 y) -{ - int i; - - couple z; - Uint32 a, b, tp, add = 0, ret = 0; - - for (i = 0; i < 31; i++) { - a = ValeurIbitsAuDeb(x, i); - b = ValeurIbitsAuDeb(y, i); - tp = a + b + ret; - if (tp == 3) { - ret = 1; - tp = 1; - tp <<= i; - add |= tp; - } - - else { - if (tp == 2) { - ret = 1; - tp = 0; - tp <<= i; - add |= tp; - } - - else { - if (tp == 1) { - ret = 0; - tp = 1; - tp <<= i; - add |= tp; - } - - else { - ret = 0; - } - } - } - if (i == 30) { - if (ret == 1) { - z.deb = add; - z.fin = 1; - return (z); - } - } - } - z.deb = add; - z.fin = 0; - return (z); -} - -Uint32 MultChifNomb(Uint32 x, Uint32 y) -{ - int i; - - Uint32 mul = 0, a, un = 1; - - if (y == 0) - return (0); - if (x == 0) - return (0); - if (y == 1) - return (x); - for (i = 0; i < 32; i++) { - a = ValeurIbitsAuDeb(x, i); - if (a == 1) { - un <<= i; - mul |= un; - } - } - return (mul); -} - -couple MultipliNonSig(Uint32 x, Uint32 y) +Uint32 NMultiplicationNonSigne(Uint32 a, Uint32 b) { - couple z, w; - int i; - - Uint32 tp, dec, add, a, pa1 = 0, pa2 = 0; - - for (i = 0; i < 32; i++) { - a = ValeurIbitsAuDeb(y, i); - tp = MultChifNomb(x, a); - dec = (tp >> (32 - i)); - pa2 = NAdditionNonSigne(pa2, dec); - add = tp << i; - z = Addition(pa1, add); - pa1 = z.deb; - if (z.fin == 1) { - w = Addition(pa2, 1); - pa2 = w.deb; - } - } - z.deb = pa1; - z.fin = pa2; - - printf("\n"); - return (z); -} + return MUL_UU(a,b); +} -couple MultipliSig(Uint32 x, Uint32 y) +Uint32 NMultiplicationSigne(Uint32 a, Uint32 b) { - couple z, w; - int i; - - Uint32 tp, dec, add, a, b, pa1 = 0, pa2 = 0, x1 = x, y1 = y; - - a = ValeurIbitsAuDeb(x, 31); - b = ValeurIbitsAuDeb(y, 31); - if (((a == 0) && (b == 0)) || ((a == 1) && (b == 1))) { /* Le resultat sera pos */ - if ((a == 1) && (b == 1)) { - x1 = InverseIbit(x, 31); - y1 = InverseIbit(y, 31); - } - for (i = 0; i < 31; i++) { - a = ValeurIbitsAuDeb(y1, i); - tp = MultChifNomb(x1, a); - dec = tp >> (31 - i); - w = Addition(pa2, dec); - pa2 = w.deb; - add = tp << i; - z = Add30Mul(pa1, add); - pa1 = z.deb; - if (z.fin == 1) { - w = Addition(pa2, 1); - pa2 = w.deb; - } - } - z.deb = pa1; - z.fin = pa2; - return (z); - } - if (a == 1) - x1 = InverseIbit(x, 31); - if (b == 1) - y1 = InverseIbit(y, 31); - for (i = 0; i < 31; i++) { - a = ValeurIbitsAuDeb(y1, i); - tp = MultChifNomb(x1, a); - dec = tp >> (31 - i); - pa2 = NAdditionNonSigne(pa2, dec); - add = tp << i; - z = Add30Mul(pa1, add); - pa1 = z.deb; - if (z.fin == 1) { - pa2 = NAdditionNonSigne(pa2, 1); - } - } - pa1 = MettreAVIbit(pa1, 31); - pa2 = MettreAVIbit(pa2, 31); - z.deb = pa1; - z.fin = pa2; - return (z); -} + return MUL_SS(a,b); +} Uint32 NDivisionNonSigne(Uint32 a, Uint32 b) { - Uint32 quot, rest; + return DivMod_UU(a,b); +} - if (b > a) { - quot = 0; - rest = a; - } else { - if (b == a) { - quot = 1; - rest = 0; - } else { - quot = 0; - rest = a; - while (rest >= b) { - rest = NSoustractionNonSigne(rest, b); - quot++; - } - } - } - SecondResult = rest; - return quot; -} - -Uint32 NDivisionSigne(long int a, long int b) -{ - long int quot, rest; - - if (b > a) { - quot = 0; - rest = a; - } else { - if (b == a) { - quot = 1; - rest = 0; - } else { - quot = 0; - rest = a; - while (rest >= b) { - rest = NSoustractionNonSigne(rest, b); - quot++; - } - } - } - SecondResult = rest; - return quot; -} - -Uint32 NMultiplicationNonSigne(Uint32 a, Uint32 b) +Uint32 NDivisionSigne(Uint32 a, Uint32 b) { - couple z; + return DivMod_SS(a,b); +} - z = MultipliNonSig(a, b); - SecondResult = z.fin; - return z.deb; -} -Uint32 NMultiplicationSigne(Uint32 a, Uint32 b) -{ - couple z; - - z = MultipliNonSig(a, b); - - SecondResult = z.fin; - return z.deb; -} Uint32 AdditionNonSigne(Uint32 a, Uint32 b) { diff --git a/lib/interne.c b/lib/interne.c index 642ce16..ea532cc 100644 --- a/lib/interne.c +++ b/lib/interne.c @@ -54,23 +54,24 @@ Uint32 ONE(void) { return (1); } /* Met le bit 'position' ŕ zéro */ void ResetBit(Uint32 * i, int position) { + int k; + Uint32 maxi = ZERO(); if (position < 0 || position > 31) exception(1, _("ResetBit: Incorrect Value")); else { - int k; - Uint32 VAL_MAX = ZERO(); + for (k = 0; k < 32; k++) - SetBit(&VAL_MAX, k); - * i &= VAL_MAX - (ONE() << position); + SetBit(&maxi, k); + * i &= maxi - (ONE() << position); } } /* Met le bit 'position' ŕ un */ void SetBit(Uint32 * i, int position) { + Uint32 aux = ONE() << position; if (position < 0 || position > 31) exception(1, _("SetBit: Incorrect Value")); else { - Uint32 aux = ONE() << position; * i |= aux; } } @@ -91,15 +92,6 @@ int Neg(Uint32 a) { return (ValeurBit(a, 31)); } -/* Met le flag d'overflow ŕ zéro */ -void SetOverflow(int * o) { * o = ONE(); } - -/* Met le flag d'overflow ŕ un */ -void ResetOverflow(int * o) { * o = ZERO(); } - -/* Donne la valeur du flag d'overflow */ -int Overflow(int o) { return (o); } - /* Affiche tous les bits d'un mot */ void Uint32toBin(Uint32 i) { int k; diff --git a/po/ProjetArchi.pot b/po/ProjetArchi.pot index cf2fe84..ebe7a0c 100644 --- a/po/ProjetArchi.pot +++ b/po/ProjetArchi.pot @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2001-05-14 11:06+0200\n" +"POT-Creation-Date: 2001-05-20 02:30+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -425,26 +425,18 @@ msgstr "" msgid "Error context empty, but popcontext() called." msgstr "" -#: lib/interne.c:25 +#: lib/interne.c:60 msgid "ResetBit: Incorrect Value" msgstr "" -#: lib/interne.c:37 +#: lib/interne.c:73 msgid "SetBit: Incorrect Value" msgstr "" -#: lib/interne.c:49 +#: lib/interne.c:85 msgid "ValeurBit: Incorrect Value" msgstr "" -#: lib/alu.c:286 -msgid "ValeurIbitsAuDeb: position not in interval" -msgstr "" - -#: lib/alu.c:346 -msgid "InverseIbit: position not in interval" -msgstr "" - #: lib/fpu.c:14 msgid "FPU not implemented" msgstr "" diff --git a/po/cat-id-tbl.c b/po/cat-id-tbl.c index 38c658c..6dc7bbe 100644 --- a/po/cat-id-tbl.c +++ b/po/cat-id-tbl.c @@ -110,81 +110,79 @@ Statistics: %i words of text, %i words of data, and %i words reserved.\n\ {"ResetBit: Incorrect Value", 98}, {"SetBit: Incorrect Value", 99}, {"ValeurBit: Incorrect Value", 100}, - {"ValeurIbitsAuDeb: position not in interval", 101}, - {"InverseIbit: position not in interval", 102}, - {"FPU not implemented", 103}, - {"Invalid Memory Adress", 104}, - {"Invalid Register Descriptor", 105}, - {"premature end of file", 106}, - {"Processing file %s", 107}, - {"Bad signature", 108}, - {"Startpoint already defined.", 109}, - {"Reading symbols", 110}, - {"Reading text and data segments", 111}, - {"Symbol %s not found", 112}, - {"Internal error", 113}, - {"No startpoint defined.", 114}, - {"Writing headers", 115}, - {"Writing relocating informations", 116}, - {"Writing text segments", 117}, - {"Writing data segments", 118}, - {"Statistics: %i words of text, %i words of data and reserving %i words\n", 119}, - {"Output file size: %i words containing %i relocating offsets.\n", 120}, - {"Adresse: Call With Invalid r/m Field State ( r/m=00 )", 121}, - {"Adresse: Unmatched Addr Field", 122}, - {"MOV: Memory to Memory Forbidden On This Type Of Processor", 123}, - {"DecodeExec: Invalid Opcode", 124}, - {"Shutdown requested", 125}, + {"FPU not implemented", 101}, + {"Invalid Memory Adress", 102}, + {"Invalid Register Descriptor", 103}, + {"premature end of file", 104}, + {"Processing file %s", 105}, + {"Bad signature", 106}, + {"Startpoint already defined.", 107}, + {"Reading symbols", 108}, + {"Reading text and data segments", 109}, + {"Symbol %s not found", 110}, + {"Internal error", 111}, + {"No startpoint defined.", 112}, + {"Writing headers", 113}, + {"Writing relocating informations", 114}, + {"Writing text segments", 115}, + {"Writing data segments", 116}, + {"Statistics: %i words of text, %i words of data and reserving %i words\n", 117}, + {"Output file size: %i words containing %i relocating offsets.\n", 118}, + {"Adresse: Call With Invalid r/m Field State ( r/m=00 )", 119}, + {"Adresse: Unmatched Addr Field", 120}, + {"MOV: Memory to Memory Forbidden On This Type Of Processor", 121}, + {"DecodeExec: Invalid Opcode", 122}, + {"Shutdown requested", 123}, {"\ Help:\n\ G: go\n\ P: Proceed\n\ R: display registers\n\ T: trace\n\ -Q: quit\n", 126}, - {"Opening file %s", 127}, - {"Invalid Signature", 128}, - {"Loading file %s", 129}, - {"Executing file %s", 130}, - {"could not set terminal attributes", 131}, - {"could not open terminal", 132}, +Q: quit\n", 124}, + {"Opening file %s", 125}, + {"Invalid Signature", 126}, + {"Loading file %s", 127}, + {"Executing file %s", 128}, + {"could not set terminal attributes", 129}, + {"could not open terminal", 130}, {"\ Assembler v1.0\n\ -\n", 133}, - {"Usage: compilo program.asm objet.out\n", 134}, - {" o Initialising the meta engine... ", 135}, +\n", 131}, + {"Usage: compilo program.asm objet.out\n", 132}, + {" o Initialising the meta engine... ", 133}, {"\ Done!\n\ - o Meta language loading... ", 136}, - {"Meta language loading failed.", 137}, + o Meta language loading... ", 134}, + {"Meta language loading failed.", 135}, {"\ Done!\n\ - o Initialising the assembler core...", 138}, - {"Assembler core init failed.", 139}, - {" Done!\n", 140}, - {"Signal received: segfault", 141}, + o Initialising the assembler core...", 136}, + {"Assembler core init failed.", 137}, + {" Done!\n", 138}, + {"Signal received: segfault", 139}, {"\ \n\ Performing initialisation...\n\ -\n", 142}, +\n", 140}, {"\ \n\ Performing shutdown...\n\ -\n", 143}, - {"Exitting, bye!\n", 144}, +\n", 141}, + {"Exitting, bye!\n", 142}, {"\ Simul v1.0\n\ -\n", 145}, - {"Usage: linker [-s] [-d] binary\n", 146}, - {" o Initialising the simulator... ", 147}, - {"Beginning simulation", 148}, +\n", 143}, + {"Usage: linker [-s] [-d] binary\n", 144}, + {" o Initialising the simulator... ", 145}, + {"Beginning simulation", 146}, {"\ Linker v1.0\n\ -\n", 149}, - {"Usage: linker obj1 [obj2 [obj3 [...]]] binary\n", 150}, - {" o Initialising the linker... ", 151}, - {"Linking files...\n", 152}, - {"Generating output file...\n", 153}, +\n", 147}, + {"Usage: linker obj1 [obj2 [obj3 [...]]] binary\n", 148}, + {" o Initialising the linker... ", 149}, + {"Linking files...\n", 150}, + {"Generating output file...\n", 151}, }; -int _msg_tbl_length = 153; +int _msg_tbl_length = 151; -- cgit v1.2.3