程序地址 |
机器码 |
反汇编语言 |
指令说明 |
|
|
;IN |
可以使用此指令在cop2000上输入数据 |
00 |
7C4B |
MOV A,#4BH |
模拟输入X补 |
02 |
80 |
MOV R0,A |
放入R0 |
03 |
88F9 |
MOV 0F9H,A |
放入F9 |
05 |
1C80 |
ADD A,#80H |
判断是不是负数 |
07 |
70 |
MOV A,R0 |
X补放到A (求2X补) |
08 |
D4 |
RL A |
左移一位 |
09 |
A00D |
JC YIYI |
是负数的话跳到YIYI |
0B |
AC11 |
JMP LLING |
不是就到LLING |
|
|
YIYI: |
|
0D |
6C80 |
OR A,#80H |
将左移后的X补首位强制换为1 |
0F |
AC13 |
JMP ZXC |
|
|
|
LLING: |
|
11 |
5C7F |
AND A,#7FH |
强制换为0 |
|
|
ZXC: |
|
13 |
88FA |
MOV 0FAH,A |
换好后放入FA,此为2X补 |
|
|
|
|
15 |
70 |
MOV A,R0 |
求 [-X]补 |
16 |
E4 |
CPL A |
|
17 |
1C01 |
ADD A,#01H |
末位加一 |
19 |
88FE |
MOV 0FEH,A |
[-X]补放入OFEH |
1B |
1C80 |
ADD A,#80H |
求2[-X]补 |
1D |
A028 |
JC ZHIYI |
|
1F |
78FE |
MOV A,0FEH |
|
21 |
D4 |
RL A |
|
22 |
6C80 |
OR A,#80H |
首位置1 |
24 |
1C80 |
ADD A,#80H |
|
26 |
AC2D |
JMP o1 |
|
|
|
ZHIYI: |
|
28 |
78FE |
MOV A,0FEH |
|
2A |
D4 |
RL A |
|
2B |
6C80 |
OR A,#80H |
|
|
|
o1: |
|
2D |
88FD |
MOV 0FDH,A |
2[-X]补放入OFDH |
|
|
|
|
|
|
;IN |
|
2F |
7CA6 |
MOV A,#0A6H |
模拟输入Y补 |
31 |
81 |
MOV R1,A |
Y放到R1 |
|
|
|
|
32 |
7C04 |
MOV A,#04H |
循环次数 |
34 |
88FB |
MOV 0FBH,A |
放入OFBH |
|
|
|
|
|
|
|
|
|
|
MAIN: |
主流程 |
36 |
BCCA |
CALL GET_N |
计算Yn+1 + Yn - Yn-1的值 |
38 |
73 |
MOV A,R3 |
|
39 |
1C01 |
ADD A,#01H |
判断值是多少 并跳转到相应位置 |
3B |
A44B |
JZ FUYI |
|
3D |
1C01 |
ADD A,#01H |
|
3F |
A452 |
JZ FUER |
|
41 |
3C02 |
SUB A,#02H |
|
43 |
A45E |
JZ LING |
|
45 |
3C01 |
SUB A,#01H |
|
47 |
A456 |
JZ YI |
|
49 |
AC5A |
JMP ER |
|
|
|
|
|
|
|
FUYI: |
|
4B |
78FE |
MOV A,0FEH |
对应规则表找到要操作的数 |
4D |
83 |
MOV R3,A |
放到R3 |
4E |
BCAE |
CALL GET_F8 |
得到部分积的新符号 |
50 |
AC9F |
JMP XIANG_JIA |
|
|
|
FUER: |
|
52 |
78FD |
MOV A,0FDH |
同上 |
54 |
AC60 |
JMP YOU_HUA2 |
|
|
|
YI: |
|
56 |
78F9 |
MOV A,0F9H |
同上 |
58 |
AC60 |
JMP YOU_HUA2 |
|
|
|
ER: |
|
5A |
78FA |
MOV A,0FAH |
同上 |
5C |
AC60 |
JMP YOU_HUA2 |
|
|
|
LING: |
|
5E |
78FF |
MOV A,0FFH |
同上 |
|
|
YOU_HUA2: |
|
60 |
83 |
MOV R3,A |
|
61 |
BCAE |
CALL GET_F8 |
|
63 |
AC9F |
JMP XIANG_JIA |
|
|
|
JIA_WAN: |
|
65 |
BC75 |
CALL YOU_YI_YI_CI |
把Y、部分积右移一次 |
67 |
78FB |
MOV A,0FBH |
看循环是否结束 |
69 |
3C01 |
SUB A,#01H |
|
6B |
A4EE |
JZ EN |
结束就结束 |
6D |
88FB |
MOV 0FBH,A |
不结束就继续 |
6F |
BC75 |
CALL YOU_YI_YI_CI |
|
71 |
AC36 |
JMP MAIN |
|
|
|
|
|
73 |
ACEE |
JMP EN |
分隔上下文,使思路更清晰 |
|
|
|
|
|
|
YOU_YI_YI_CI: |
|
75 |
71 |
MOV A,R1 |
Y补放到A |
76 |
5C01 |
AND A,#01H |
将末位移到0FCH |
78 |
A47E |
JZ TT1 |
|
7A |
7C80 |
MOV A,#80H |
|
7C |
AC80 |
JMP TT2 |
|
|
|
TT1: |
|
7E |
7C00 |
MOV A,#00H |
|
|
|
TT2: |
|
80 |
88FC |
MOV 0FCH,A |
|
82 |
71 |
MOV A,R1 |
右移Y补 |
83 |
D0 |
RR A |
|
84 |
81 |
MOV R1,A |
|
85 |
72 |
MOV A,R2 |
判断Y补符号 |
86 |
5C01 |
AND A,#01H |
|
88 |
71 |
MOV A,R1 |
|
89 |
A48E |
JZ TT3 |
|
8B |
71 |
MOV A,R1 |
|
8C |
6C80 |
OR A,#80H |
|
|
|
TT3: |
|
8E |
81 |
MOV R1,A |
|
8F |
78F8 |
MOV A,0F8H |
判断部分积符号并右移部分积 |
91 |
3C00 |
SUB A,#00H |
|
93 |
A49B |
JZ TNT |
|
95 |
72 |
MOV A,R2 |
|
96 |
D0 |
RR A |
|
97 |
6C80 |
OR A,#80H |
|
99 |
AC9D |
JMP TNT1 |
|
|
|
TNT: |
|
9B |
72 |
MOV A,R2 |
|
9C |
D0 |
RR A |
|
|
|
TNT1: |
|
9D |
82 |
MOV R2,A |
|
9E |
CC |
RET |
|
|
|
|
|
|
|
XIANG_JIA: |
|
9F |
73 |
MOV A,R3 |
把对应的值放到A并相加 |
A0 |
12 |
ADD A,R2 |
|
A1 |
82 |
MOV R2,A |
|
A2 |
A0A6 |
JC TMT |
求出完全0F8的值 |
A4 |
AC65 |
JMP JIA_WAN |
|
|
|
TMT: |
|
A6 |
78F8 |
MOV A,0F8H |
|
A8 |
3C01 |
SUB A,#01H |
|
AA |
88F8 |
MOV 0F8H,A |
|
AC |
AC65 |
JMP JIA_WAN |
|
|
|
|
|
|
|
GET_F8: |
求出部分0F8的值 |
AE |
1C80 |
ADD A,#80H |
判断规则表对应数的首位是否为1 |
B0 |
72 |
MOV A,R2 |
部分积放到A |
B1 |
A0BF |
JC T1 |
部分积首位与规则表首位相加在放到0F8H |
B3 |
1C80 |
ADD A,#80H |
|
B5 |
A0BB |
JC T3 |
|
B7 |
7C00 |
MOV A,#00H |
|
B9 |
ACC7 |
JMP YOU_HUA |
|
|
|
T3: |
|
BB |
7C01 |
MOV A,#01H |
|
BD |
ACC7 |
JMP YOU_HUA |
|
|
|
T1: |
|
BF |
1C80 |
ADD A,#80H |
|
C1 |
A0C5 |
JC T2 |
|
C3 |
ACBB |
JMP T3 |
|
|
|
T2: |
|
C5 |
7C02 |
MOV A,#02H |
|
|
|
YOU_HUA: |
|
C7 |
88F8 |
MOV 0F8H,A |
|
C9 |
CC |
RET |
|
|
|
|
|
|
|
GET_N: |
|
CA |
78FC |
MOV A,0FCH |
Yn+1放到A |
CC |
1C80 |
ADD A,#80H |
分别找到八种情况对应的4种值并将Yn+1+Yn-2Yn-1结果存入R3 |
CE |
A0D4 |
JC YI2 |
|
D0 |
7C00 |
MOV A,#00H |
|
D2 |
ACD6 |
JMP LINGG |
|
|
|
YI2: |
|
D4 |
7C01 |
MOV A,#01H |
|
|
|
LINGG: |
|
D6 |
83 |
MOV R3,A |
|
D7 |
71 |
MOV A,R1 |
|
D8 |
5C01 |
AND A,#01H |
|
DA |
A4E0 |
JZ LING1 |
|
DC |
7C01 |
MOV A,#01H |
|
DE |
ACE2 |
JMP YI1 |
|
|
|
LING1: |
|
E0 |
7C00 |
MOV A,#00H |
|
|
|
YI1: |
|
E2 |
13 |
ADD A,R3 |
|
E3 |
83 |
MOV R3,A |
|
E4 |
71 |
MOV A,R1 |
|
E5 |
5C02 |
AND A,#02H |
|
E7 |
A4ED |
JZ LING3 |
|
E9 |
73 |
MOV A,R3 |
|
EA |
3C02 |
SUB A,#02H |
|
|
|
LING2: |
|
EC |
83 |
MOV R3,A |
|
|
|
LING3: |
|
ED |
CC |
RET |
|
|
|
|
|
|
|
|
|
|
|
EN: |
结束中断 |
EE |
71 |
MOV A,R1 |
将最后的Y末位清零 |
EF |
5CFE |
AND A,#0FEH |
|
F1 |
81 |
MOV R1,A |
|
F2 |
ACEE |
JMP EN |
花了好多天搞出来的,不忍心在硬盘中把它直接删掉,(八位其中首位为符号位,结果存在R2与R1)