OpenCores
URL https://opencores.org/ocsvn/zipcpu/zipcpu/trunk

Subversion Repositories zipcpu

[/] [zipcpu/] [trunk/] [sw/] [lib/] [mpy32s.S] - Blame information for rev 45

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 45 dgisselq
; We could build mul32s (32-bit signed multiply) as
2
mpy32s:
3
        PUSH    R2
4
        CLR     R2              ; Keep track of resulting sign in R2
5
        TST     R0              ; Is R0 negative?
6
        XOR.LT  #1,R2           ; If so, resulting sign will be negative, and
7
        NEG.NZ  R0              ; then we negate R0 (R0 = ABS(R0))
8
        TST     R1              ; Is R1 negative?
9
        XOR.LT  #1,R2           ; If so, result will be opposite sign of before
10
        TST     R1              ; Need to retest since xor modified flags
11
        NEG.LT  R1              ; Now we get R1=ABS(R1)
12
        JSR     mpy32u          ; Do our unsigned multiply
13
        CMP     R2              ; Check resulting sign
14
        BZ      ret_mul32s      ; If positive, do nothing more
15
        NOT     R0              ; If negative, negate the result
16
        NOT     R1
17
        ADD     $1,R1
18
        ADD.C   $1,R0
19
ret_mul32s:
20
        POP     R2
21
        RET
22
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.