Skip to content

Instantly share code, notes, and snippets.

@paolorotolo
Created January 27, 2019 11:00
Show Gist options
  • Save paolorotolo/203b2ae99c39cc3e09e56c507aa8df4e to your computer and use it in GitHub Desktop.
Save paolorotolo/203b2ae99c39cc3e09e56c507aa8df4e to your computer and use it in GitHub Desktop.
Y= aX + bZ
X 1000
Z 2000
Y 3000
A 4000
B 5000
N 6000
R1 <- N
R2 <- N (in bit)
R3 <- resto (in bit)
F2 <- a
F4 <- b
ADDI R1 R0 #N
SLI R2 R1 #3
ANDI R3 R2 #7
LOAD F2 R0 #4000
LOAD F4 R0 #5000
# LOOP RESTO
LOAD R4 R3 #992
LOAD R5 R3 #1992
MUL F6 F2 R4
MUL F8 F4 R5
ADD F6 F6 F8
STORE F6 R3 #2992
ADDI R3 R3 #-8
BNEZ R3 #-8
# AGGIORNA CONTATORE MAIN LOOP
SUB R2 R2 R3
# MAIN LOOP
# VETTORE X
LOAD R4 R2 #992
LOAD R5 R2 #984
LOAD R6 R2 #976
LOAD R7 R2 #968
# VETTORE Z
LOAD R8 R2 #1992
LOAD R9 R2 #1984
LOAD R10 R2 #1976
LOAD R11 R2 #1968
# aX
MUL F6 R4 F2
MUL F8 R5 R2
MUL F10 R6 F2
MUL F12 R7 F2
# bZ
MUL F14 R8 F4
MUL F16 R9 F4
MUL F18 R10 F4
MUL F20 R11 F4
# aX + bZ
ADD F6 F6 F14
ADD F8 F8 F16
ADD F10 F10 F18
ADD F12 F12 F20
# STORE
STORE F6 R2 #2992
STORE F8 R2 #2984
STORE F10 R2 #2976
STORE F12 R2 #2968
# AGGIORNA CONTATORE
ADDI R2 R2 #-32
BNEZ R2 #-22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment