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

Subversion Repositories copyblaze

[/] [copyblaze/] [trunk/] [copyblaze/] [sw/] [code/] [pBlaze/] [wishbone/] [wishbone.asm] - Blame information for rev 2

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

Line No. Rev Author Line
1 2 ameziti
; this programm calculate the sum of the "value" 16bit.
2
; value = 5; total = 5 + 3 + 2 + 1 = 15
3
; the result is 16bit outputed
4
                waveform_port           .EQU    0x02
5
                counter_port            .EQU    0x04
6
 
7
                total_low       .EQU   s0
8
                total_high      .EQU   s1
9
                value           .EQU   s8
10
                ;
11
start:
12
                LOAD    value,          0x1F    ; find sum of all values to 1F
13
                LOAD    total_low,      0x00    ; clear 16-bit total
14
                LOAD    total_high,     0x00
15
 
16
                CALL    sum_to_value            ; calculate sum of all numbers up to value
17
 
18
                LOAD    value,          0x00    ; clear the register
19
                LOAD    value,          0x01    ;
20
                LOAD    value,          0x02    ;
21
 
22
                WBWRSING        total_high,     counter_port    ; Result will be 496 (1F0 hex)
23
;               WBWRSING        total_low,      waveform_port
24
 
25
                LOAD    value,          0x03    ;
26
                LOAD    value,          0x04    ;
27
                LOAD    value,          0x05    ;
28
end:
29
                JUMP    end
30
                ;
31
 
32
                ; Subroutine called recursively
33
sum_to_value:
34
                ADD             total_low,      value   ; perform 16-bit addition
35
                ADDCY   total_high,     00
36
                SUB             value,          01              ; reduce value by 1
37
                RETURN  Z                                       ; finished if down to zero
38
                CALL    sum_to_value            ; recursively call of subroutine
39
                RETURN                                          ; definitively finished!

powered by: WebSVN 2.1.0

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