logo elektroda
logo elektroda
X
logo elektroda
REKLAMA
REKLAMA
Adblock/uBlockOrigin/AdGuard mogą powodować znikanie niektórych postów z powodu nowej reguły.

TMS320 "nieprawidłowy" wynik mnozenia (PREG)

coberr 17 Lis 2014 21:48 3189 2
REKLAMA
  • #1 14141475
    coberr
    Poziom 20  
    Witam.

    Nie wiem, czy to własciwy dział - jednak z uwagi na to, że to forum odwiedza sporo programistów procesorów TMS320 - wolałem ten temat umiescic tutaj.

    Problem być moze dla niektórych okaże się banalny - jednak ja juz strawiłem na niego sporo czasu i przyznam szczerze - sam się juz zastanawiam - co jest jego przyczyną...

    Problem dotyczy prostej operacji mnozenia dla TMS320F24x - a dokładniej tego - co wyrabia się w starszych bitach rejestru P - po wykonaniu operacji mnozenia.

    Przykładowy , prosty program:

    CLRC SXM
    LT liczba1 ; komórka pamięci ; liczba np. 39601d (9AB1h)
    MPY #liczba2 ; stała - np 20d (14h)

    w rejestrze P teoretycznie powinniśmy otrzymać wynik : 792020d (000C 15D4)

    tymczasem - otrzymuję (pomimo sxm=0) wynik: FFF8 15D4 (czyli jak kto woli: -518700) Tym bardziej mnie to dziwi - że przy SXM=0 - żadne takie szopki z najstarszymi bitami PREG nie powinny miec miejsca.

    Nie iwem czy winę ponosi sam procesor czy moze CCS3.3 czy moze moj boski emulator JTAG :)

    Szperałem w dokumentacji ale nic wiecej nie mogę się doszukać...
  • REKLAMA
  • Pomocny post
    #2 14141771
    __Grzegorz__
    Poziom 30  
    Cytat:

    The TMS320x24x devices use a 16 x 16-bit hardware multiplier that is capable of computing a signed or an
    unsigned 32-bit product in a single machine cycle. All multiply instructions, except the MPYU (multiply unsigned)
    instruction, perform a signed multiply operation. That is, two numbers being multiplied are treated as
    2s-complement numbers, and the result is a 32-bit 2s-complement number. There are two registers associated
    with the multiplier, as follow:
     16-bit temporary register (TREG) that holds one of the operands for the multiplier
     32-bit product register (PREG) that holds the product


    Cytat:

    The MPYU instruction performs an unsigned multiplication, which greatly facilitates extended-precision
    arithmetic operations. The unsigned contents of TREG are multiplied by the unsigned contents of the addressed
    data memory location, with the result placed in PREG. This process allows the operands of greater than 16 bits
    to be broken down into 16-bit words and processed separately to generate products of greater than 32 bits. The
    SQRA (square/add) and SQRS (square/subtract) instructions pass the same value to both inputs of the
    multiplier for squaring a data memory value.


    Musisz użyć MPYU, SXM nie ma tu znaczenia...

    Twoje 39601d (9AB1h) to dla procesora -25935d w połączeniu z instrukcją MPY...
  • #3 14141943
    coberr
    Poziom 20  
    KURCZE - dziękuję - faktycznie - nie zwróciłem uwagi na ten drobny szczegół :)
    W efekcie wyłozyłem sie na pier...ole :)
    (dekiel juz totalnie zamulony - po wertowaniu setek stron dokumentacji :) )
    teraz program działa poprawnie. wynik = 000C 15D4h
REKLAMA