📄 asymspwm.asm
字号:
pac ; D13
sfr
sfr
ADD one,15
sach index_1 ; right shift 11 bits => D15
; Table lookup to get sin and cos
zac
lacc index_1
sub #720
blez indexa_1
sacl index_1
indexa_1
lac SIN_1st ;
add index_1 ;
tblr sin_theta ;
lt sin_theta ;D1
mpy vref ;D15
pac ;D17
sach temp1,2 ;D15
lacc temp1
add #1000
sacl temp2
zac
lacc index_1
add #480
sacl index_1
lacc index_1
sub #720
blez indexb_1
sacl index_1
indexb_1
lac SIN_1st
add index_1
tblr sin_theta
lt sin_theta ;D1
mpy vref ;D15
pac ;D17
sach temp3,2 ;D15
lacc temp3
add #1000
sacl temp4
zac
lacc index_1
add #480
sacl index_1
lacc index_1
sub #720
blez indexc_1
sacl index_1
indexc_1
lac SIN_1st
add index_1
tblr sin_theta
lt sin_theta ;D1
mpy vref ;D15
pac ;D17
sach temp5,2 ;D15
lacc temp5
add #1000
sacl temp6
lt theta_r_2 ; D3
mpy theta_i ; D3*D9=D13
pac ; D13
sfr
sfr
ADD one,15
sach index_2 ; right shift 11 bits => D15
; Table lookup to get sin and cos
zac
lacc index_2
sub #720
blez indexa_2
sacl index_2
indexa_2
lac SIN_1st ;
add index_2 ;
tblr sin_theta ;
lt sin_theta ;D1
mpy vref ;D15
pac ;D17
sach temp7,2 ;D15
lacc temp7
add #1000
sacl temp8
zac
lacc index_2
add #480
sacl index_2
lacc index_2
sub #720
blez indexb_2
sacl index_2
indexb_2
lac SIN_1st
add index_2
tblr sin_theta
lt sin_theta ;D1
mpy vref ;D15
pac ;D17
sach temp9,2 ;D15
lacc temp9
add #1000
sacl temp10
zac
lacc index_2
add #480
sacl index_2
lacc index_2
sub #720
blez indexc_2
sacl index_2
indexc_2
lac SIN_1st
add index_2
tblr sin_theta
lt sin_theta ;D1
mpy vref ;D15
pac ;D17
sach temp11,2 ;D15
lacc temp11
add #1000
sacl temp12
zac
LACC temp1
add temp7
BGZ T1
SPLK #0,temp1
B L1
T1:
sacl temp1
L1:
LACC temp3
add temp9
BGZ T2
SPLK #0,temp3
B L3
T2:
sacl temp3
L3:
LACC temp5
add temp11
BGZ T3
SPLK #0,temp5
B L5
T3:
sacl temp5
L5:
LACC temp2
add temp8
sacl temp2
lacc temp2
sub #2000
BLZ L2
SPLK #2000,temp2
L2:
LACC temp4
add temp10
sacl temp4
lacc temp4
sub #2000
BLZ L4
SPLK #2000,temp4
L4:
LACC temp6
add temp12
sacl temp6
lacc temp6
sub #2000
BLZ L6
SPLK #2000,temp6
L6:
lacc temp1
ldp #232
sacl CMPR1
ldp #6
lacc temp2
ldp #232
sacl CMPR2
ldp #6
lacc temp3
ldp #232
sacl CMPR3
ldp #6
lacc temp4
ldp #234
sacl CMPR4
ldp #6
lacc temp5
ldp #234
sacl CMPR5
ldp #6
lacc temp6
ldp #234
sacl CMPR6
B MAIN ; Branch back
**************************************
** Handle interrupt **
**************************************
_c_int1
LDP #232
splk #0000,ACTRA
SPLK #0040,T1CON
SPLK #0fffh,EVAIFRA ; Clear all Group A interrupt flags
SPLK #0ffh,EVAIFRB ; Clear all Group B interrupt flags
SPLK #0fh,EVAIFRC ; Clear all Group C interrupt flags
SPLK #0000h,EVAIMRA ; Mask all Grp A ints but GPT1 UF
SPLK #0h,EVAIMRB ; Mask all Grp B ints
SPLK #00h,EVAIMRC ; Mask all Grp C ints
LDP #234
splk #0000,ACTRB
SPLK #0040,T3CON
SPLK #0fffh,EVBIFRA ; Clear all Group A interrupt flags
SPLK #0ffh,EVBIFRB ; Clear all Group B interrupt flags
SPLK #0fh,EVBIFRC ; Clear all Group C interrupt flags
SPLK #0000h,EVBIMRA ; Mask all Grp A ints but GPT1 UF
SPLK #0h,EVBIMRB ; Mask all Grp B ints
SPLK #00h,EVBIMRC ; Mask all Grp C ints
SXH b SXH
RET
_c_int2
SST #ST0,ST0_SAVE ; save status register ST0
SST #ST1,ST1_SAVE ; save status register ST1
LDP #0 ; point to memory page 0
SACH ACCH ;
SACL ACCL ; save ACC
LDP #232 ; point to EV reg page
LACC EVAIFRA ; Read group A flag register
SACL EVAIFRA ; Clear all group A flags
LDP #6 ; Point to B1 page 0
SPLK #1,period_flag ; set start flag
LDP #0 ; point to memory page 0
ZALH ACCH ;
ADDS ACCL ; restore ACC
LST #ST1,ST1_SAVE ; restore status register ST1
LST #ST0,ST0_SAVE ; restore status register ST0
EINT ;
RET ;
PHANTOM
SST #ST0,ST0_SAVE ; save status register ST0
SST #ST1,ST1_SAVE ; save status register ST1
LDP #0 ; point to memory page 0
SACH ACCH ;
SACL ACCL ; save ACC
LDP #0 ; point to memory page 0
ZALH ACCH ;
ADDS ACCL ; restore ACC
LST #ST1,ST1_SAVE ; restore status register ST1
LST #ST0,ST0_SAVE ; restore status register ST0
EINT ;
RET ; return
.data
;-----------------------------------------------------------
; sine table for theta from 0 to 360 per every 2 degrees
;-----------------------------------------------------------
TB_S_ ; sin table
.word 0 ;theta= 0.00000000
.word 143 ;theta= 0.00872665
.word 286 ;theta= 0.01745329
.word 429 ;theta= 0.02617994
.word 572 ;theta= 0.03490659
.word 715 ;theta= 0.04363323
.word 857 ;theta= 0.05235988
.word 1000 ;theta= 0.06108652
.word 1143 ;theta= 0.06981317
.word 1285 ;theta= 0.07853982
.word 1428 ;theta= 0.08726646
.word 1570 ;theta= 0.09599311
.word 1713 ;theta= 0.10471976
.word 1855 ;theta= 0.11344640
.word 1997 ;theta= 0.12217305
.word 2139 ;theta= 0.13089969
.word 2280 ;theta= 0.13962634
.word 2422 ;theta= 0.14835299
.word 2563 ;theta= 0.15707963
.word 2704 ;theta= 0.16580628
.word 2845 ;theta= 0.17453293
.word 2986 ;theta= 0.18325957
.word 3126 ;theta= 0.19198622
.word 3266 ;theta= 0.20071286
.word 3406 ;theta= 0.20943951
.word 3546 ;theta= 0.21816616
.word 3686 ;theta= 0.22689280
.word 3825 ;theta= 0.23561945
.word 3964 ;theta= 0.24434610
.word 4102 ;theta= 0.25307274
.word 4240 ;theta= 0.26179939
.word 4378 ;theta= 0.27052603
.word 4516 ;theta= 0.27925268
.word 4653 ;theta= 0.28797933
.word 4790 ;theta= 0.29670597
.word 4927 ;theta= 0.30543262
.word 5063 ;theta= 0.31415927
.word 5199 ;theta= 0.32288591
.word 5334 ;theta= 0.33161256
.word 5469 ;theta= 0.34033920
.word 5604 ;theta= 0.34906585
.word 5738 ;theta= 0.35779250
.word 5872 ;theta= 0.36651914
.word 6005 ;theta= 0.37524579
.word 6138 ;theta= 0.38397244
.word 6270 ;theta= 0.39269908
.word 6402 ;theta= 0.40142573
.word 6533 ;theta= 0.41015237
.word 6664 ;theta= 0.41887902
.word 6794 ;theta= 0.42760567
.word 6924 ;theta= 0.43633231
.word 7053 ;theta= 0.44505896
.word 7182 ;theta= 0.45378561
.word 7311 ;theta= 0.46251225
.word 7438 ;theta= 0.47123890
.word 7565 ;theta= 0.47996554
.word 7692 ;theta= 0.48869219
.word 7818 ;theta= 0.49741884
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -