Menu

[59a2c7]: / examples / test.asm  Maximize  Restore  History

Download this file

48 lines (39 with data), 980 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Subroutine call
macro .call @lb
# Push previous return addr onto stack
subi r30,r30,1
st r31,r30,0
# Make the call
bt @lb,r31
nop # branch delay slot
# Pop previous return addr
ld r31,r30,0
addi r30,r30,1
end
# Return from sub
macro .ret
jmp r31
end
# define some constants
@start = 10 # Initial value of some variable
@n = 3 # Number of loop iterations
# First instruction of program
ori r2,r0,@start # Load consts into registers
ori r1,r0,@n
out r2
out r1
@loop:
.call @mysub # Call the subroutine
out r2
subi r1,r1,1 # Decrement loop counter
out r1
bne @loop # Branch if still looping
nop # Branch delay slot
nop # Let the pipeline flush before halt
nop
halt # Stop the program
# A subroutine (which doesn't do a lot)
@mysub:
addi r2,r2,1
.ret
nop
MongoDB Logo MongoDB