SET
SAVE
= L 6.1
= L 6.1
L 0
T #i
A #Fill
JCN A7d0
L #DstDb
T #DBNumber
L #LastDstAdr
L #FstDstAdr
-I
L #AdrDif
/I
T #imax
L #imax
L 0
T #i
TAK
T LW 8
TAK
A7d1: L #i
L LW 8
<=I
JCN A7d2
L #DBNumber
T LW 10
L #i
L #AdrDif
*I
L #FstDstAdr
+I
ITD
L L#8
*D
L #vmax
OPN DB [LW 10]
TAK
LAR1
TAK
T DBD [AR1,P#0.0]
L #i
L 1
+I
T #i
JU A7d1
A7d2: CLR
A7d0: CLR
A L 6.1
SAVE
BE
最佳答案
SET
SAVE
= L 6.1
= L 6.1 //置位L6.1
L 0
T #i //初始化变量#i为0
A #Fill //#Fill为0就跳转到A7d0,为1就执行以下程序
JCN A7d0
L #DstDb
T #DBNumber //#DBNumber=#DstDb
L #LastDstAdr
L #FstDstAdr
-I //#LastDstAdr-#FstDstAdr
L #AdrDif
/I //(#LastDstAdr-#FstDstAdr)/#AdrDif
T #imax //#imax=(#LastDstAdr-#FstDstAdr)/#AdrDif
L #imax //累加器1=#imax
L 0 //累加器1=0 ,累加器2=#imax
T #i //
TAK //累加器1和累加器2的值互换累加器1=#imax,累加器2=0
T LW 8 //LW 8=#imax
TAK //累加器1和累加器2的值互换累加器1=0,累加器2=#imax
A7d1: L #i
L LW 8
<=I
JCN A7d2 //LW 8<=#i就执行以下程序,否社跳转A7d2
L #DBNumber
T LW 10 //LW10=#DBNumber
L #i
L #AdrDif
*I //#i*#AdrDif
L #FstDstAdr
+I //#FstDstAdr +#i*#AdrDif
ITD //int转化为dint
L L#8
*D //(#FstDstAdr +#i*#AdrDif)*8
L #vmax //累加器1=#vmax 累加器2=(#FstDstAdr +#i*#AdrDif)*8
OPN DB [LW 10] //打开LW10 对应的DB块
TAK //累加器1和累加器2互换:累加器1=(#FstDstAdr +#i*#AdrDif)*8 累加器2=#vmax
LAR1 //将累加器1里的数据传给地址寄存器1里
TAK //交换累加器1和累加器2,累加器1=#vmax 累加器2=#vmax(#FstDstAdr +#i*#AdrDif)*8
T DBD [AR1,P#0.0] //AR1对应的地址的数据=#vmax
L #i
L 1
+I
T #i //#i自加1
JU A7d1 //无条件跳转到A7d1
A7d2: CLR
A7d0: CLR
A L 6.1
SAVE
BE
提问者对于答案的评价:
感谢,
原创文章,作者:more0621,如若转载,请注明出处:https://www.zhaoplc.com/plc126828.html