求大神翻译汇编语言

溪毅 2018-01-24 05:04:21
RSEG DATA16_Z

OUTP DS 2 ; allocate 2 Byte
inp21 DS 2
outp11 DS 2
outp21 DS 2
inp23 DS 2
outp13 DS 2
outp23 DS 2
inp15 DS 2
inp25 DS 2
outp15 DS 2
outp25 DS 2
p11 DS 2
p13 DS 2
p15 DS 2
delay2 DS 2
delay3 DS 2
delay4 DS 2

avg_temp_2 DS 2 ; averaging result n-2

peaks DS 2 ; captures number of peaks
zeros DS 2 ; captures number of zero crossings

integ_total_2 DS 2 ; result integral total signal
integ_HPB DS 2 ; result integral high pass signal

sample_count DS 2 ; captures number of samples
sample_count_2 DS 2

div_count_1 DS 2 ; overflow count if integ_total
div_count_2 DS 2 ; overflow count if integ_HPB

ratio_false DS 2 ; count failure ratio rule
peak_false DS 2 ; count failure peaks rule
zero_false DS 2 ; count failure zero crossing rule

AAF_select DS 2 ; select anti aliasing filter
;-------------------------------------------------------------------------------
; Main
;-------------------------------------------------------------------------------
RSEG CSTACK ; define stack segment
;-------------------------------------------------------------------------------
RSEG CODE ; assemble to Flash memory
;-------------------------------------------------------------------------------

RESET mov.w #SFE(CSTACK),SP ; initialize stackpointer
StopWDT mov.w #WDTPW+WDTHOLD,&WDTCTL ; stop WDT

SetupBC_ call #SetDCO_8Mhz

SetupP1 mov.b #0FFh,&P1DIR ; all P1.x outputs
clr.b &P1OUT ; all P1.x reset

SetupP2 mov.b #0FFh,&P2DIR ; all ports output, P2.0 don't care, P2.2 don't care,
mov.b #BIT0+BIT1+BIT2, &ADC10AE0
; P2.0 OA0I0, P2.1 OA0O (ADC IN)
; P2.2 OA0I1

clr.b &P2OUT ; all P2.x reset
SetupP3 mov.b #0FFh,&P3DIR ; all P3.x outputs
clr.b &P3OUT ; all P3.x reset
SetupP4 mov.b #0FFh,&P4DIR ; all P4.x output, P4.6 don't care, P4.4 don't care
clr.b &P4OUT ; all P4.x reset

mov.w #0, AAF_select ; select AAF, "0" off else "on"
cmp.w #1, AAF_select
jlo no_AAF ; unsigned
SetupADC10
call #SetupADC10_wakeup_AAF
jmp SetupOP0
no_AAF call #SetupADC10_wakeup_no_AAF

SetupOP0 call #SetupOP1_2
SetupTA_ call #SetupTA

call #INITMEM ; clear all variables

bis.w #MC_1, TACTL ; up mode, TA start
mov.b #LPM3+GIE, SR ; enable LPM3 mode and global interrupts

Mainloop jmp Mainloop
;------------------------------------------------------------------------------
TA0_ISR;
;------------------------------------------------------------------------------
bic.w #MC_1, TACTL ; TA stop

bis.b #BIT0, P4OUT ; microphone on
bis.b #BIT4, P2OUT ; offset on

bis.w #OAPM_3,&OA0CTL0_ ; start OP0 fast mode, amplifier

cmp.w #1, AAF_select
jlo cont_4 ; jump if no AAF selected
bis.w #OAPM_3,&OA1CTL0_ ; start OP1 fast mode, start filter
call #delay_8MHz_AAF ; OP settling time
jmp cont_5

cont_4 call #delay_8MHz_no_AAF ; OP settling time

cont_5 bis.w #ADC10ON,&ADC10CTL0
bis.w #ENC+ADC10SC,&ADC10CTL0 ; enable ADC10 + start conversion

wait_IFG bit.w #ADC10IFG, &ADC10CTL0 ; ADC10IFG set?
jz wait_IFG ; jump if ADC10IFG not set
bic.w #ADC10IFG, &ADC10CTL0

mov.w &ADC10MEM, temp1 ; save ADC10MEM to a working register
sub.w #520, temp1 ; subtract 520 because of 520 Offset

cmp.w #trigger_lvl_low, temp1 ; compare trigger level with input level
jl trigger ; temp1 < trigger level?
cmp.w #trigger_lvl_high, temp1; compare trigger level with input level
jge trigger ; temp1 > trigger level?
jmp no_trigger

trigger call #SetDCO_12Mhz
bic.w #ENC, &ADC10CTL0 ; disable ADC10
bit.w #BIT3, &OA1CTL0_
jz cont_9 ; jump if AAF off
call #SetupADC10_cont_AAF ; execute if AAF on
jmp cont_10
cont_9 call #SetupADC10_cont_no_AAF
cont_10 bis.w #ENC+ADC10SC,&ADC10CTL0 ; enable ADC10 + start conversion
bic.b #LPM3, 0(SP) ; disable LPM3 mode
reti

no_trigger
bic.w #OAPM0+OAPM1,&OA0CTL0_ ; OP0 off
bic.w #OAPM0+OAPM1,&OA1CTL0_ ; OP1 off
bic.w #ENC,&ADC10CTL0 ; disable ADC10
bic.w #ADC10ON, &ADC10CTL0 ; ADC10 off
bic.b #BIT0, P4OUT ; microphone off
bic.b #BIT4, P2OUT ; offset off
bis.w #MC_1, TACTL ; up mode, TA start
reti

;------------------------------------------------------------------------------
ADC10_ISR;
;------------------------------------------------------------------------------
mov.w &ADC10MEM, temp1 ; save ADC10MEM to a working register
sub.w #512, temp1 ; subtract 512 because of 512 Offset
inc sample_count
call #signal_analysis
reti
;------------------------------------------------------------------------------
signal_analysis; analysing input signal 60ms = 2336 samples at fs=38961Hz
;------------------------------------------------------------------------------
...全文
1197 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
kernelkoder 2018-04-16
  • 打赏
  • 举报
回复
这里有pdf书,你可以下载看看 http://www.allitebooks.com/?s=assembly

21,453

社区成员

发帖
与我相关
我的任务
社区描述
汇编语言(Assembly Language)是任何一种用于电子计算机、微处理器、微控制器或其他可编程器件的低级语言,亦称为符号语言。
社区管理员
  • 汇编语言
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧