URL
https://opencores.org/ocsvn/copyblaze/copyblaze/trunk
Subversion Repositories copyblaze
[/] [copyblaze/] [trunk/] [copyblaze/] [sw/] [code/] [pBlaze/] [wishbone/] [wishbone.asm] - Rev 17
Compare with Previous | Blame | View Log
; this programm calculate the sum of the "value" 16bit.; value = 5; total = 5 + 3 + 2 + 1 = 15; the result is 16bit outputedwaveform_port .EQU 0x02counter_port .EQU 0x04total_low .EQU s0total_high .EQU s1value .EQU s8;; ==========================================================start:LOAD value, 0x1F ; find sum of all values to 1FLOAD total_low, 0x00 ; clear 16-bit totalLOAD total_high, 0x00CALL sum_to_value ; calculate sum of all numbers up to valueOUTPUT total_low, counter_port ; result : Value.LOWOUTPUT total_high, waveform_port ; result : Value.HIGH; ==========================================================; Test Wishbone InstructionsLOAD value, 0x00 ; clear the registerLOAD value, 0x01 ;LOAD value, 0x02 ;WBWRSING total_high, 0x04 ; Result will be 496 (1F0 hex)LOAD value, 0x03 ;LOAD value, 0x04 ;LOAD value, 0x05 ;WBWRSING total_low, 0x04LOAD value, 0x06 ;LOAD value, 0x07 ;LOAD value, 0x08 ;WBRDSING total_high, 0x01 ; Result will be 496 (1F0 hex)LOAD value, 0x0A ;LOAD value, 0x0B ;LOAD value, 0x0C ;end:JUMP end;; Subroutine called recursivelysum_to_value:ADD total_low, value ; perform 16-bit additionADDCY total_high, 00SUB value, 01 ; reduce value by 1RETURN Z ; finished if down to zeroCALL sum_to_value ; recursively call of subroutineRETURN ; definitively finished!
