上述程式的缺点为:在循环过程中,速度有所损失,而且用四位元查表也费事耗时。如果用一字元查表,则需增大「表」的对应值,再改为「总表」的方式,一次即可查到。且由第20行改起,并力求指令的精简,如: 20: MOV DX,OFFSET BYTETB 21: MVDB: 22: LODSB 23: SUB AH,AH 24: SHL AX,1 ; 一字元须变为二字元 25: ADD AX,DX ; 之位置以查表 26: MOV BX,AX ; BX可供间接定址用 27: MOV AX,[BX] ; 以一字元查表值 28: STOSW ; 查妥存入第一行 29: MOV [DI+4],AX ; 上下再重复一行 30: LODSB 31: SUB AH,AH ; 处 32: SHL AX,1 ; 理 33: ADD AX,DX 34: MOV BX,AX ; 第 35: MOV AX,[BX] ; 二 36: STOSW ; 列 37: MOV [DI+4],AX ; 38: LODSB ; 39: SUB AH,AH ; 处 40: SHL AX,1 ; 理 41: ADD AX,DX 42: MOV BX,AX ; 第 43: MOV AX,[BX] ; 三 44: STOSW ; 列 45: MOV [DI+4],AX ; 46: ADD DI,6 ; 再处理下一行 47: LOOP MVDB ; 共24次 48: DEC BP ; 做10,000次 49: JNZ S3 ; 完成 50: MOV AX,4C00H 51: INT 21H 52: RET
程式到此为止,下面还有一转换总表,可供各程式共用。 1:;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2:; 转 换 表 ; 3:;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 4: BYTETB LABEL WORD 5: DB 000H,000H,000H,003H,000H,00CH,000H,00FH 6: DB 000H,030H,000H,033H,000H,03CH,000H,03FH 7: DB 000H,0C0H,000H,0C3H,000H,0CCH,000H,0CFH 8: DB 000H,0F0H,000H,0F3H,000H,0FCH,000H,0FFH 9: DB 003H,000H,003H,003H,003H,00CH,003H,00FH 10: DB 003H,030H,003H,033H,003H,03CH,003H,03FH 11: DB 003H,0C0H,003H,0C3H,003H,0CCH,003H,0CFH 12: DB 003H,0F0H,003H,0F3H,003H,0FCH,003H,0FFH 13: DB 00CH,000H,00CH,003H,00CH,00CH,00CH,00FH 14: DB 00CH,030H,00CH,033H,00CH,03CH,00CH,03FH 15: DB 00CH,0C0H,00CH,0C3H,00CH,0CCH,00CH,0CFH 16: DB 00CH,0F0H,00CH,0F3H,00CH,0FCH,00CH,0FFH 17: DB 00FH,000H,00FH,003H,00FH,00CH,00FH,00FH 18: DB 00FH,030H,00FH,033H,00FH,03CH,00FH,03FH 19: DB 00FH,0C0H,00FH,0C3H,00FH,0CCH,00FH,0CFH 20: DB 00FH,0F0H,00FH,0F3H,00FH,0FCH,00FH,0FFH 21: DB 030H,000H,030H,003H,030H,00CH,030H,00FH 22: DB 030H,030H,030H,033H,030H,03CH,030H,03FH 23: DB 030H,0C0H,030H,0C3H,030H,0CCH,030H,0CFH 24: DB 030H,0F0H,030H,0F3H,030H,0FCH,030H,0FFH 25: DB 033H,000H,033H,003H,033H,00CH,033H,00FH 26: DB 033H,030H,033H,033H,033H,03CH,033H,03FH 27: DB 033H,0C0H,033H,0C3H,033H,0CCH,033H,0CFH 28: DB 033H,0F0H,033H,0F3H,033H,0FCH,033H,0FFH 29: DB 03CH,000H,03CH,003H,03CH,00CH,03CH,00FH 30: DB 03CH,030H,03CH,033H,03CH,03CH,03CH,03FH 31: DB 03CH,0C0H,03CH,0C3H,03CH,0CCH,03CH,0CFH 32: DB 03CH,0F0H,03CH,0F3H,03CH,0FCH,03CH,0FFH 33: DB 03FH,000H,03FH,003H,03FH,00CH,03FH,00FH 34: DB 03FH,030H,03FH,033H,03FH,03CH,03FH,03FH 35: DB 03FH,0C0H,03FH,0C3H,03FH,0CCH,03FH,0CFH 36: DB 03FH,0F0H,03FH,0F3H,03FH,0FCH,03FH,0FFH 37: DB 0C0H,000H,0C0H,003H,0C0H,00CH,0C0H,00FH 38: DB 0C0H,030H,0C0H,033H,0C0H,03CH,0C0H,03FH 39: DB 0C0H,0C0H,0C3H,0C0H,0CCH,0C0H,0CFH,0C0H 40: DB 0C0H,0F0H,0C0H,0F3H,0C0H,0FCH,0C0H,0FFH 41: DB 0C3H,000H,0CH3,003H,0C3H,00CH,0C3H,00FH 42: DB 0C3H,030H,0C3H,033H,0C3H,03CH,0C3H,03FH 43: DB 0C3H,0C0H,0C3H,0C3H,0C3H,0CCH,0C3H,0CFH 44: DB 0C3H,0F0H,0C3H,0F3H,0C3H,0FCH,0C3H,0FFH 45: DB 0CCH,000H,0CCH,003H,0CCH,00CH,0CCH,00FH 46: DB 0CCH,030H,0CCH,033H,0CCH,03CH,0CCH,03FH 47: DB 0CCH,0C0H,0CCH,0C3H,0CCH,0CCH,0CCH,0CFH 48: DB 0CCH,0F0H,0CCH,0F3H,0CCH,0FCH,0CCH,0FFH 49: DB 0CFH,000H,0CFH,003H,0CFH,00CH,0CFH,00FH 50: DB 0CFH,030H,0CFH,033H,0CFH,03CH,0CFH,03FH 51: DB 0CFH,0C0H,0CFH,0C3H,0CFH,0CCH,0CFH,0CFH 52: DB 0CFH,0F0H,0CFH,0F3H,0CFH,0FCH,0CFH,0FFH 53: DB 0F0H,000H,0F0H,003H,0F0H,00CH,0F0H,00FH 54: DB 0F0H,030H,0F0H,033H,0F0H,03CH,0F0H,03FH 55: DB 0F0H,0C0H,0F0H,0C3H,0F0H,0CCH,0F0H,0CFH 56: DB 0F0H,0F0H,0F0H,0F3H,0F0H,0FCH,0F0H,0FFH 57: DB 0F3H,000H,0F3H,003H,0F3H,00CH,0F3H,00FH 58: DB 0F3H,030H,0F3H,033H,0F3H,03CH,0F3H,03FH 59: DB 0F3H,0C0H,0F3H,0C3H,0F3H,0CCH,0F3H,0CFH 60: DB 0F3H,0F0H,0F3H,0F3H,0F3H,0FCH,0F3H,0FFH 61: DB 0FCH,000H,0FCH,003H,0FCH,00CH,0FCH,00FH 62: DB 0FCH,030H,0FCH,033H,0FCH,03CH,0FCH,03FH 63: DB 0FCH,0C0H,0FCH,0C3H,0FCH,0CCH,0FCH,0CFH 64: DB 0FCH,0F0H,0FCH,0F3H,0FCH,0FCH,0FCH,0FFH 65: DB 0FFH,000H,0FFH,003H,0FFH,00CH,0FFH,00FH 66: DB 0FFH,030H,0FFH,033H,0FFH,03CH,0FFH,03FH 67: DB 0FFH,0C0H,0FFH,0C3H,0FFH,0CCH,0FFH,0CFH 68: DB 0FFH,0F0H,0FFH,0F3H,0FFH,0FCH,0FFH,0FFH 69: CG ENDS 70: END START 本程式因为加了个转换表,空间增大为1471字元,但速度却加快为2.5 秒,这是空间换时间的最佳例证。
 
2/2 首页 上一页 1 2 |