P81例4.9 用查表法计算平方(一)
ORG 0000H
MOVDPTR,#TABLE ;表首地址送DPTRMOV A,#05;被查数字05?AMOVC A,@A+DPTR;查表求平方SJMP $
TABLE:DB 0,1,4,9,16,25,36,49,64,81
END
P81例4.9 用查表法计算平方(二)
ORG0000H
0000H MOV A,#05;05 ?A0002H ADDA,#02;修正累加器A0004H MOVC A,@A+PC;查表求平方0005H SJMP $
0007H:DB 0,1,4,9,16,25,36,49,64,81
END