Re: ASM for math



[A complimentary Cc of this posting was sent to
John W Kennedy
<jwkenne@xxxxxxxxxxxxx>], who wrote in article <48dbfb58$0$4917$607ed4bc@xxxxxx>:
express. Most processors have special tricks for multi-word arithmetic
(such as the Intel ADC instruction or the new z/Architecture ALC family
of instructions) that cannot be expressed at all in, say, C. (That is, C
has no way of saying, "Add X to Y, and add an additional 1 if the last
addition set the CPU carry flag.")

IIRC, PARI does not use anything "as advanced as that" ;-). There are
about 10 macros which an architecture should better imlement in
assembler; they are all very primitive, like

add two numbers and return the carry flag,
word x word --> twowords multiplication,
calculate number of trailing 0bits in a word, etc.

A typical PARI assembler file for an architecture is about 100 LOC.
(GMP kernel uses much larger assembler base, so it may be slightly
quickier for very large numbers - and slower for smaller ones for
independent reasons.)

Hope this helps,
Ilya
.



Relevant Pages

  • Re: Assembler syntax/instructions for different architecures and assemblers?
    ... Assembler, Netwide Assembler, TASM, etc.). ... written for ARM architecture with NASM? ... don't believe there is (nasm only really targeting x86 and variants). ...
    (alt.lang.asm)
  • Re: Moving from 8051 to AVR
    ... If you have sigificant amount of code written in assembler, ... you are locked into that architecture. ... porting it to an AVR was an even less smart thing to do. ... I would agree but the problem is you start with a nice small 8 bit MCU ...
    (comp.arch.embedded)
  • Re: Assembler syntax/instructions for different architecures and assemblers?
    ... The assembly code syntax is different for different assemblers (Gnu ... Assembler, Netwide Assembler, TASM, etc.). ... written for ARM architecture with NASM? ...
    (alt.lang.asm)
  • Re: Question on ProDOS SmartPort drive remapping
    ... assembler which generated two bytes of executable code: ... address on entry is stored in register 14. ... It was unavoidable for an architecture that introduced so many ... registers, long base registers with short instruction displacements, ...
    (comp.sys.apple2)
  • Re: GNU toolchain + ARM options
    ... My best guess at what is happening is that when you compile with no options ... the code generated by GCC itself is for ARMv4 or somesuch. ... assembler is allowing any version of the architecture. ...
    (comp.sys.arm)