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

Subversion Repositories zipcpu

[/] [zipcpu/] [trunk/] [sw/] [lib/] [mpy32u.S] - Blame information for rev 125

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

Line No. Rev Author Line
1 59 dgisselq
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;
3
; Filename:     mpyu.S
4
;
5
; Project:      Zip CPU -- a small, lightweight, RISC CPU soft core
6
;
7
; Purpose:      Zip assembly file for running doing an unsigned 32x32 bit
8
;               multiply..
9
;
10
; Creator:      Dan Gisselquist, Ph.D.
11 69 dgisselq
;               Gisselquist Technology, LLC
12 59 dgisselq
;
13
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14
;
15
; Copyright (C) 2015, Gisselquist Technology, LLC
16
;
17
; This program is free software (firmware): you can redistribute it and/or
18
; modify it under the terms of  the GNU General Public License as published
19
; by the Free Software Foundation, either version 3 of the License, or (at
20
; your option) any later version.
21
;
22
; This program is distributed in the hope that it will be useful, but WITHOUT
23
; ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
24
; FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
25
; for more details.
26
;
27
; License:      GPL, v3, as defined and found on www.gnu.org,
28
;               http://www.gnu.org/licenses/gpl.html
29
;
30
;
31
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
32
;
33
;
34
;
35
mpy32u: ; unsigned R0 * unsigned R1 -> unsigned R0:R1, R2 = rtn addr (on stack)
36 69 dgisselq
        SUB     3,SP
37
        STO     R2,(SP)
38 59 dgisselq
        STO     R3,1(SP)
39
        STO     R4,2(SP)
40 69 dgisselq
        ;
41 45 dgisselq
        MOV     R0,R2
42 69 dgisselq
        MPYU    R1,R2   ; R2 = Low order bits, low(R0) * low(R1)
43 45 dgisselq
        MOV     R0,R3
44
        LSR     16,R3   ; Put high order bits in lower half of R3
45 69 dgisselq
        MPYU    R1,R3   ; R3 = Mid order bits, high(R0) * low(R1)
46 45 dgisselq
        LSR     16,R1   ; R1 = High order bits of R1, being done w/ low order
47
        MOV     R1,R4   ;
48 69 dgisselq
        MPYU    R0,R4   ; R4 = Mid order bits, low(R0) * high(R1)
49 45 dgisselq
        LSR     16,R0
50 69 dgisselq
        MPYU    R1,R0   ; R0 = High order bits, high(R0) * high(R1)
51 45 dgisselq
        ADD     R3,R4   ; R4 = sum of mid order bits
52
        ADD.C   0x010000,R0     ; Add in the carry (if it happened)
53
        MOV     R4,R3
54
        LSR     16,R3
55
        ADD     R3,R0   ; R0 = high order bits plus high order mid-bits
56
        LSL     16,R4
57
        ADD     R4,R2   ; R2 = low order bits plus low order mid-bits
58
        ADD.C   1,R0    ; Add in the carry to R0 (if it happened)
59
        MOV     R2,R1   ; Place low order bits into R1
60 69 dgisselq
        ;
61
        LOD     (SP),R2
62 59 dgisselq
        LOD     1(SP),R3
63
        LOD     2(SP),R4
64 69 dgisselq
        ADD     3,SP
65 59 dgisselq
        JMP     R2
66 69 dgisselq
 

powered by: WebSVN 2.1.0

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