Menu

#37 add signed shift operators <<< and >>>

open
nobody
None
1
2004-02-13
2003-08-08
No

Currently NASM provides the << and >> operators,
which perform unsigned or logical shifts.

In my local forked version I have added support
for signed or arithmetic shifts, by implementing
the new <<< and >>> operators.

The changes required to do so were quite simple:

nasm.h
- add TOKEN_SAL and TOKEN_SAR to enum

preproc.c
- skip <<< and >>> in tokenise()
- handle <<< and >>> in ppscan()

nasmlib.c
- handle <<< and >>> in stdscan()

eval.c
- add TOKEN_SAL and TOKEN_SAR to while() in expr3()
- handle TOKEN_SAL and TOKEN_SAR as signed shifts
- handle large shift counts (optional, see SF 785325)

user manual
- document <<< and >>>

Discussion

  • Nickolay Yurchenko

    Logged In: YES
    user_id=806493

    I am not too happy about unsigned shifts of negative
    numbers. It works when we work with 32-bit numbers, but it
    will give another result with 64-bit numbers.

    Large number support is necessary for IA-64. I think the best
    way is to make Nasm operate with unlimited integer numbers
    when the result of operation is more than 32 bits long. I have
    written one such library on my leave. This has a lot of bugs
    and I will work with it after I finish my work with
    preprocessor. Unlimited integer (BigInt) is able to keep string
    value (like pascal string), so it will allow to use long strings in
    arithmetic equations.

    Unsigned shifts need shift base whereas unlimited numbers
    have floating size. This is a problem. Also there is one more
    problem - with unsigned division.

    The should also be support of unlimited floating point
    numbers. Assembler programmers usually need various
    calculation tables (like sine/cosine) and it would be
    convenient if they can make such tables with help of Nasm
    preprocessor.

     
  • nasm64developer

    nasm64developer - 2004-02-13
    • priority: 5 --> 1
     

Log in to post a comment.