Added as10k1 tool (EMU10K1 FX8010 DSP assembler).

This commit is contained in:
Jaroslav Kysela 2001-04-12 08:21:01 +00:00
parent a4569af2bb
commit f2d80b5b5d
28 changed files with 3523 additions and 0 deletions

11
as10k1/examples/Makefile Normal file
View file

@ -0,0 +1,11 @@
TARGETS = blank.emu10k1 chorus.emu10k1 delay.emu10k1 eq2.emu10k1 eq5.emu10k1 \
fir.emu10k1 flanger.emu10k1 sine.emu10k1 tremolo.emu10k1 vibrato.emu10k1 \
vol_ctrl.emu10k1
%.emu10k1: %.asm
../as10k1 $<
all: $(TARGETS)
clean:
rm -f *~ *.emu10k1

View file

@ -0,0 +1,3 @@
;;; A blank file for clearing programs from the emu10k1
end

View file

@ -0,0 +1,87 @@
;;; Simple Chorus
;;; Author:Daniel Bertrand
;;; Date: Oct 12, 2000
;;; This program is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 2 of the License, or
;;; (at your option) any later version.
;;; References:
;;; http://www.harmony-central.com/Effects/Articles/Chorus
;;; speed(formerly "delta")=2*pi*freq/48000
;;; this give us our delta value for a specific freq (0.1-0.3Hz is good)
include "emu_constants.asm"
name "Chorus"
in IO
out equ in
speed control 4e-05 , 0 , 1e-4 ; Controls frequency (radians)
delay control &40e-3 ,&10e-3 , &80e-3; twice (2*) average delay (sec)
width control #0.3 ,0 ,0.5 ; width control
mix control #1 ,0 ,#1 ; forward mix
;; sine generator storage spaces:
sinx sta 0
cosx sta #0.5
tmp dyn
tmp2 dyn
;;; Two Delay Lines:
dly delay &80e-3 ;10msec delay line
write twrite dly,0 ; tram writes
ready tread dly,0 ; tram reads
reada tread dly,0
;;;The code:
;;; two opcode sinewave generator (I love this chip!):
macs sinx,sinx,speed,cosx
macs1 cosx,cosx,speed,sinx
;;; 0.5Asint+0.5:
macs tmp,C_2^30,sinx,width
;;; calculate address:
macs ready.a,write.a,delay,tmp
;second addresses for interpolation:
;(interesting how the emu engineers decided that $800 wasn't a needed value)
macints reada.a,ready.a,C_8,C_256
;;; Write to the delay line:
macs write,C_0,in,C_2^29
;;; output values:
;;; 0x55 is 00100000 (?)
macints tmp,C_0,reada.a,C_LSshift; get least significant part of address
interp tmp2,ready,tmp,reada ;interpolate in-between the two delay line readings
macs out,in,tmp2,mix
end

29
as10k1/examples/delay.asm Normal file
View file

@ -0,0 +1,29 @@
;;; A simple delay routine
include "emu_constants.asm"
name "delay"
level control 0.5, #0 , #1
feedback control #0.3, #0 , #1
delay control &0.2, &0, &0.5
io IO
dly delay &0.5 ; 0.5 sec delay block
write twrite dly,0 ; write at 0 sec
read tread dly,&.2 ; read at 0.2 sec
acc3 read.a,delay,write.a,C_0
macs io,io,level,read
macs write,io,read,feedback
end

View file

@ -0,0 +1,117 @@
;some hardware constants C_[n]<DecimalValue>, 'n' indicates negative value
;
;these are in 2's complement representation
C_0 equ $040 ;;00000000
C_1 equ $041 ;;00000001
C_2 equ $042 ;;00000002
C_3 equ $043 ;;00000003
C_4 equ $044 ;;00000004
C_8 equ $045 ;;00000008
C_16 equ $046 ;;00000010
C_32 equ $047 ;;00000020
C_256 equ $048 ;;00000100
C_65536 equ $049 ;;00010000
C_2^23 equ $04A ;;00080000
C_2^28 equ $04b ;;10000000
C_2^29 equ $04c ;;20000000 (C_max /4) +1
C_2^30 equ $04d ;;40000000 ( C_max / 2 ) + 1 (almost half)
C_nmax equ $04e ;;80000000 most negative number
C_max equ $04f ;;7fffffff most positive number
C_n1 equ $050 ;;ffffffff -1
C_n2 equ $051 ;;fffffffe -2
C_n2^30 equ $052 ;;c0000000 C_nmax /2
C_LSshift equ $55 ;;to left shift an address by using macsints
;;for fractional addresses
ZERO equ C_0;
ONE equ C_1;
;;; Hardware Registers:
ACCUM equ $56
CCR equ $57
NOISE1 equ $58
NOISE2 equ $59
IRQ equ $5A
DBAC equ $5B
and macro dest,srcA,srcB
andxor dest,srcA,srcB,C_0
endm
xor macro dest,srcA,srcB
andxor dest,C_n1,srcA,srcB
endm
not macro dest,src
andxor dest,src,C_n1,C_n1
endm
nand macro dest,srcA,srcB
andxor dest,srcA,srcB,C_n1
endm
or macro dest,srcA,srcB
not C_0,srcA
andxor dest,ACCUM,srcA,srcB
endm
nor macro dest,srcA,scrB
not dest,srcA
andxor dest,srcB,dest,srcA
not dest,dest
endm
neg macro dest,src
macs1 dest,C_0,C_1,C_nmax
endm
;;; branch on:
;;; ==0
beq macro count
skip CCR,CCR,C_8,count
endm
;;; !=0
bne macro count
skip CCR,CCR,C_256,count
endm
;;; <0
blt macro count
skip CCR,CCR,C_4,count
endm
;;; always branch
bra macro count
skip C_0,C_max,C_max,count
endm
;;; on saturation
bsa macro count
skip CCR,CCR,C_16,count
endm
bge macro count
C___80 con $80
skip CCR,CCR,C___80,count
endm
bgt macro count
C___180 con $180
skip CCR,CCR,C___180,count
endm
move macro dest,src
macs dest,src,C_0,C_0
endm
end
;;; usefull for testing values before a skip
test macro test
macs C_0,test,C_0,C_0
endm
cmp macro src1.scr2
macints C_0,src1,C_n1,src2
endm

69
as10k1/examples/eq2.asm Normal file
View file

@ -0,0 +1,69 @@
;;; Bass and Treble Effect
;;; By: Daniel Bertrand
;;; Date: Dec 19th,200
;;; License: GPL v2
;;;
name "Eq2"
include "emu_constants.asm"
;;; a and b coefs for bass:
b_b con 2.736129417e-01 5.240710533e-01 2.620355267e-01
a_b con 9.560258858e-01 -4.576868881e-01
;;; a and b coef for treble:
b_t con -4.982305773e-01 9.964611547e-01 -4.982305773e-01
a_t con 9.317583774e-01 -4.356836381e-01
scalein con 2.449e-05, 1.157407407e-04
scaleout con 128, 16192
bass control 0.25,#0,#1
treble control 0.25,#0,#1
in IO
out equ in
tmp dyn
tmpout dyn
dly_b sta 0,0
dly_t sta 0,0
;;; bass filter(iir):
macw tmp, C_0, dly_b+1, a_b+1
macw tmp, tmp, dly_b , a_b
macw tmp,tmp,in,scalein
macints tmp, C_0, tmp, C_2
macs C_0,C_0,C_0,C_0
macmv dly_b+1,dly_b, dly_b+1, b_b+2
macmv dly_b,tmp, dly_b, b_b+1
macw tmp,ACCUM, tmp, b_b
macs tmp,C_0,bass,tmp
macints tmpout,C_0,tmp,scaleout
;;; treble
macw tmp, C_0, dly_t+1, a_t+1
macw tmp, tmp, dly_t , a_t
macw tmp, tmp, in,scalein+1
macints tmp,C_0,tmp,C_2
macs C_0,C_0,C_0,C_0
macmv dly_t+1,dly_t, dly_t+1, b_t+2
macmv dly_t,tmp, dly_t, b_t+1
macw tmp,ACCUM, tmp, b_t
macs tmp,C_0,treble,tmp
macints out,tmpout,tmp,scaleout+1
end

60
as10k1/examples/eq5.asm Normal file
View file

@ -0,0 +1,60 @@
name "5 band EQ"
include "emu_constants.asm"
c0 con -0.98485626 0.98502633 0.99034926 -0.99034926
c1 con -0.95169465 0.95337028 0.93878619 -0.93878619
c2 con -0.84376963 0.85967945 0.84174451 -0.84174451
c3 con -0.47720462 0.61368058 0.73503304 -0.73503304
c4 con -0.28987550 0.11999291 0.72670869 -0.72670869
scalein sta 0.00013665 0.00134590 0.01265823 0.10000000 0.50000000
scaleout sta 420.00000000 140.00000000 50.00000000 20.00000000 10.00000000
in io
out equ in
F_100Hz control #0.2,0,#1
F_316Hz control #0.1,0,#1
F_1000Hz control #0.1,0,#1
F_3160Hz control #0.1,0,#1
F_10000Hz control #0.2,0,#1
dly0 sta 0 0
dly1 sta 0 0
dly2 sta 0 0
dly3 sta 0 0
dly4 sta 0 0
out_tmp dyn
tmp2 dyn
tmp dyn
;;; Band Pass Filter Macro:
BPF macro OUT , IN , DELAY , COEF , SCALEIN , SCALEOUT , FOO , GAIN
macs tmp,C_0,SCALEIN,IN
macs1 tmp,tmp,DELAY,FOO
macw1 tmp,tmp,DELAY,COEF
macw1 tmp,tmp,DELAY+1,COEF+1
macs tmp2,C_0,DELAY+1,COEF+3
macs DELAY+1,DELAY,C_0,C_0
macs tmp2,tmp2,tmp,COEF+2
macs DELAY,tmp,C_0,C_0
macints tmp2,C_0,tmp2,SCALEOUT
macs OUT,OUT,tmp2,GAIN
endm
macs out_tmp,C_0,C_0,C_0
BPF out_tmp,in,dly0,c0,scalein,scaleout,C_nmax,F_100Hz
BPF out_tmp,in,dly1,c1,scalein+1,scaleout+1,C_nmax,F_316Hz
BPF out_tmp,in,dly2,c2,scalein+2,scaleout+2,C_nmax,F_1000Hz
BPF out_tmp,in,dly3,c3,scalein+3,scaleout+3,C_nmax,F_3160Hz
BPF out_tmp,in,dly4,c4,scalein+4,scaleout+4,C_0,F_10000Hz
macs out,out_tmp,C_0,C_0
end

39
as10k1/examples/fir.asm Normal file
View file

@ -0,0 +1,39 @@
;;; low pass filter with cut off at 0.004pi (96Hz)
name "trebass"
include "emu_constants.asm"
coef con 0.038684406 0.058115275 0.113007075 0.194116501 0.287525429 0.377072924 0.447195555 0.485671998 0.485783252 0.447503000 0.377505237 0.287987288 0.194517783 0.113292922 0.058289230 0.038818213
n equ 15 ; filter order
in io
out equ in
bass control 0,0,#1
delay sta 0,0,0,0,0 ,0,0,0,0,0 ,0,0,0,0,0 ,0
tmp dyn
macints delay,in,C_0,C_0
;;;our filter for the left channel
macs C_0,C_0,C_0,C_0
for i = n : 1
macmv delay+i,delay+i-1,delay+i,coef+i
endfor
macs tmp,ACCUM,delay,coef
macs1 out,in,tmp,bass
end

View file

@ -0,0 +1,83 @@
;;; Simple mono flanger
;;; Author:Daniel Bertrand
;;; Date: May 29,2000
;;; This program is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 2 of the License, or
;;; (at your option) any later version.
;;; References:
;;; http://www.harmony-central.com/Effects/Articles/Flanging/
;;; speed( formerly "delta")=2*pi*freq/48000
;;; this give us our delta value for a specific freq (0.1-0.3Hz is good)
include "emu_constants.asm"
name "flanger"
in IO
out equ in
speed control 2e-05 , 0 , 1e-4 ; Controls frequency (radians)
delay control &7e-3 ,$1600 , 20e-3 ; twice (2*) average delay (sec)
width control #0.33 ,0 ,0.5 ; width control
forward control #1 ,0 ,#1 ; forward mix
feedback control 0.3 ,0 ,0.5 ; feedback level
;; sine generator storage spaces:
sinx sta 0
cosx sta #0.5
tmp dyn
tmp2 dyn
;;; Two Delay Lines:
dly delay &20e-3 ;20msec delay line
write twrite dly,0 ; tram writes
ready tread dly,0 ; tram reads
reada tread dly,0
;;;The code:
;;; two opcode sinewave generator (I love this chip!):
macs sinx,sinx,speed,cosx
macs1 cosx,cosx,speed,sinx
;;; 0.5Asint+0.5:
macs tmp,C_2^30,sinx,width
;;; calculate address:
macs ready.a,write.a,delay,tmp
;second addresses for interpolation:
;(interesting how the emu engineers decided that $800 wasn't a needed value)
macints reada.a,ready.a,C_8,C_256
;;; output values:
;;; 0x55 is 00100000 (?)
macints tmp,C_0,reada.a,C_LSshift; get least significant part of address
interp tmp2,ready,tmp,reada ;interpolate in-between the two delay line readings
macs out,in,tmp2,forward
;;; feedback and write to the delay line:
macs write,in,tmp2,feedback
end

29
as10k1/examples/sine.asm Normal file
View file

@ -0,0 +1,29 @@
name "Sine wave Gen"
include "emu_constants.asm"
in io
out equ in
delta control $3afa691,0,$7fffffff ; controls frequency
cosx control #1,0,#1 ; amplitude of sinewave
sinx sta 0
macs sinx,sinx,delta,cosx
macs1 cosx,cosx,delta,sinx
macmv out,cosx,C_0,C_0
end

View file

@ -0,0 +1,51 @@
;;; Tremolo Effect
;;; By: Daniel Bertrand
;;; Oct 29, 2000
include "emu_constants.asm"
name "tremolo"
in IO
out equ in
;;; sinewave generator:
delta control 10e-4,0,1e-2 ; controls frequency (2*pi*freq/48000)
cosx sta #0.5
sinx sta 0
depth control &0.001,0,&0.001
tmp dyn
delay delay &0.01
wrt twrite delay,0
rd tread delay,0
rd2 tread delay,0
c1000 sta $1000
macs wrt,in,C_0,C_0
;;; sinwave generator:
macs sinx,sinx,delta,cosx
macs1 cosx,cosx,delta,sinx
;;; calulate address = depth*sin(wt)+0.5*depth
macs tmp,c1000,depth,C_2^30
macs tmp,tmp,sinx,depth
acc3 rd.a,tmp,C_0,wrt.a
macints rd2.a,rd.a,C_8,C_256 ;;;next address
;;; get fractional address:
macints tmp,C_0,rd.a,C_LSshift
;;; linear interpolate fraction between the 2 reads
;;; output result
interp out,rd,tmp,rd2
end

View file

@ -0,0 +1,31 @@
;;; written by: Daniel Bertrand <d.bertrand@ieee.ca>
include "emu_constants.asm"
name "Vibro Effect"
in io
out equ in
;;; sinewave generator:
delta control 1.5e-3,0,1e-2 ; controls frequency (2*pi*freq/48000)
cosx sta #0.5
sinx sta 0
depth control #1,0,#1
sin2 dyn 1
macs sinx,sinx,delta,cosx
macs1 cosx,cosx,delta,sinx
;; depth control (and add 0.5 DC offset):
macs sin2,C_2^30,sinx,depth
;;; multiply signals by sinewave
macs out,C_0,in,sin2
end

View file

@ -0,0 +1,13 @@
name "hw vol ctrl"
include "emu_constants.asm"
Vol_ctrl control #1,0,#1
in IO
out equ in
macs out,C_0,in,Vol_ctrl
end