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 53

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 9 ameziti
 
12
                ; ==========================================================
13 2 ameziti
start:
14
                LOAD    value,          0x1F    ; find sum of all values to 1F
15
                LOAD    total_low,      0x00    ; clear 16-bit total
16
                LOAD    total_high,     0x00
17
 
18
                CALL    sum_to_value            ; calculate sum of all numbers up to value
19 9 ameziti
 
20
                OUTPUT  total_low,      counter_port    ;       result : Value.LOW
21
                OUTPUT  total_high,     waveform_port   ;       result : Value.HIGH
22
                ; ==========================================================
23
 
24
                ; Test Wishbone Instructions
25 2 ameziti
                LOAD    value,          0x00    ; clear the register
26
                LOAD    value,          0x01    ;
27
                LOAD    value,          0x02    ;
28
 
29 17 ameziti
                WBWRSING        total_high,     0x04    ; Result will be 496 (1F0 hex)
30 2 ameziti
                LOAD    value,          0x03    ;
31
                LOAD    value,          0x04    ;
32
                LOAD    value,          0x05    ;
33 17 ameziti
                WBWRSING        total_low,      0x04
34
                LOAD    value,          0x06    ;
35
                LOAD    value,          0x07    ;
36
                LOAD    value,          0x08    ;
37
                WBRDSING        total_high,     0x01    ; Result will be 496 (1F0 hex)
38
                LOAD    value,          0x0A    ;
39
                LOAD    value,          0x0B    ;
40
                LOAD    value,          0x0C    ;
41
 
42 2 ameziti
end:
43
                JUMP    end
44
                ;
45
 
46
                ; Subroutine called recursively
47
sum_to_value:
48
                ADD             total_low,      value   ; perform 16-bit addition
49
                ADDCY   total_high,     00
50
                SUB             value,          01              ; reduce value by 1
51
                RETURN  Z                                       ; finished if down to zero
52
                CALL    sum_to_value            ; recursively call of subroutine
53
                RETURN                                          ; definitively finished!

powered by: WebSVN 2.1.0

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