bug-mes
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-mes] Simple division algorithm


From: Jeremiah
Subject: Re: [bug-mes] Simple division algorithm
Date: Sat, 23 Feb 2019 00:32:53 +0000

> What about lib/mes/__idiv.c and #include it in lib/libc.c (assuming
> that is where we need it).
Or just include it in the ARM runtime which is where most ARM C
compilers put it.
Simply tack the function on after the _start routine's return

> We need it to be available in any program compiled by mescc that
> contains an "/" or "%" operator, without the user #including
> anything.
Aka, when the --archicture ARM is set, simply replace the native
instruction with a naked call to the __idiv function with the
expectation that values will be in R0 and R1 and the result will be
returned in R0.

> I've committed a new file lib/mes/div.c to origin/wip+wip-arm and
> also modified lib/mes/ntoab.c to be the first explicit user (that's not so
> nice--but I keep it for now as a place where I can see it).
Personally I would have hand converted it into assembly and thrown it in
lib/linux/arm-mes/crt1.c right below  asm ("hlt");

One would only need to write
asm("__idiv:"); and then paste the C code if one doesn't wish to put the
effort of hand converting the function to assembly.

-Jeremiah



reply via email to

[Prev in Thread] Current Thread [Next in Thread]