RL A
MOV B, A
MOV DPTR, #TAB
MOVC A, @A + DPTR
MOV R7, A
MOV A, B
INC A
MOVC A, @A + DPTR
MOV R6, A
RET
TAB:
DW 0, 1, 4, 9, 16, 25, 36, 49, ..., 400 平方源源扮数据表,楼主自裂轿己补全吧。雹灶
END
org 0000hmov 30h, #1
mov 31h, #3
mov 32h, #5
mov 33h, #7
mov 34h, #9
mov 35h, #2
mov 36h, #4
mov 37h, #6
mov 38h, #8
mov 39h, #10
call SQRT
sjmp $
查表法求平方的程序如下。
SQRT:
MOV R0, #30H
MOV R1, #40H
MOV R2, #10
LOOP:
MOV A, @R0
ADD A, #S_TAB - ($ + 4)
MOVC A, @A + PC
MOV @R1, A
INC R0
INC R1
DJNZ R2, LOOP
RET
S_TAB:
DB 1, 4, 9, 16, 25, 36, 49, 64, 81, 100
完
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)