Hi,

On Mon, Jul 23, 2018 at 11:54 AM, David McMackins <cont...@mcmackins.org> wrote:
>
> I have two oppositions to this. First, I'd like to be able to do this in
> pure C. Second, this appears to be a byte-level operation, but the whole
> point of doing this is to work on multiple bytes simultaneously.
>
> I think I might be able to do it with a subtraction and two bitshifts,
> though. Think that would be meaningfully faster?

"Pure C" doesn't exist. You're still relying on your environment
(hardware, userland software, memory, APIs, OS, etc). Even "standard"
C was intentionally meant to be both portable and unportable (if
needed/desired). So you're allowed to shoot yourself in the foot for
extra speed or features or whatever. It's a noble goal to be as
"strictly conformant" as possible, but it's not wrong to have
non-portable routines, optional or mandatory. Lots of things aren't
well-supported across platforms and compilers (e.g. bitfields).

Also, if you're targeting 16-bit, you're at the mercy of your compiler
and which exact cpu you're running on. Like I've mentioned, the 8086
isn't as efficient as the 286, much less the 486 or Pentium. And I
don't just mean clock speed, I mean overall many things (internally)
were implemented better/smarter/faster in later cpus. And most
compilers of the era weren't very good or only targeted a small subset
of those cpus. Basically, your compiler probably sucks, so don't treat
it like it knows everything. Don't expect compiled output to be
optimal by default.

So "faster" means nothing to a C compiler. You have to make it fast,
work around it's lacks, bugs, misfeatures, quirks, omissions, etc.
I'll admit that inline asm is annoyingly incompatible across
compilers, and even external .ASM files take a lot of effort to work
across compilers too. It's not really worth it unless you're desperate
or extremely diligent (bored!). But (some minimal amount of) assembly
is the only true way to get it faster. Well, technically you need a
good algorithm first (and must avoid any obvious pitfalls)! So
assembly alone is no panacea.

Sorry, I know this post isn't directly helpful, just some simple advice.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel

Reply via email to