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 9

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
                WBWRSING        total_high,     counter_port    ; Result will be 496 (1F0 hex)
30
;               WBWRSING        total_low,      waveform_port
31
 
32
                LOAD    value,          0x03    ;
33
                LOAD    value,          0x04    ;
34
                LOAD    value,          0x05    ;
35
end:
36
                JUMP    end
37
                ;
38
 
39
                ; Subroutine called recursively
40
sum_to_value:
41
                ADD             total_low,      value   ; perform 16-bit addition
42
                ADDCY   total_high,     00
43
                SUB             value,          01              ; reduce value by 1
44
                RETURN  Z                                       ; finished if down to zero
45
                CALL    sum_to_value            ; recursively call of subroutine
46
                RETURN                                          ; definitively finished!

powered by: WebSVN 2.1.0

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