MCS51辛普生积分程序源代码(ASM)
;辛普生积分程序
;入口 :DPTR,N,COUNT
;占用资源:ACC,R3,R4,R6,R7
;堆栈需求:2字节
;出口 :R3,R4
SJF :MOV R7,N
MOVX A,@DPTR
INC DPTR
MOV R4,A
MOV R3,#00H
DEC R7
SJF1 :MOVX A,@DPTR
INC DPTR
CLR C
RLC A
MOV R6,A
CLR A
RLC A
XCH A,R7
JNB ACC.0,SJF2
XCH A,R6
RLC A
XCH A,R6
XCH A,R7
RLC A
XCH A,R7
SJF2 :XCH A,R7
XCH A,R6
ADD A,R4
MOV R4,A
MOV A,R6
ADDC A,R3
MOV R3,A
DJNZ R7,SJF1
SJF3 :MOVX A,@DPTR
ADD A,R4
MOV R4,A
CLR A
ADDC A,R3
MOV R3,A
MOV R7,#COUNT
LCALL NMUL21
MOV A,N
MOV B,#03H
MUL AB
MOV R7,A
LCALL NDIV31
RET
NMUL21 :MOV A,R4
MOV B,R7
MUL AB
MOV R4,A
MOV A,B
XCH A,R3
MOV B,R7
MUL AB
ADD A,R3
MOV R3,A
CLR A
ADDC A,B
MOV R2,A
CLR OV
RET
NDIV31 :MOV B,#10H
NDV311 :CLR C
MOV A,R4
RLC A
MOV R4,A
MOV A,R3
RLC A
MOV R3,A
MOV A,R2
RLC A
MOV R2,A
MOV F0,C
CLR C
SUBB A,R7
JB F0,NDV312
JC NDV313
NDV312 :MOV R2,A
INC R4
NDV313 :DJNZ B,NDV311
RET
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)