【汇编】16进制转换成10进制(三种方法)
汇编语言程序:16进制转换成10进制(三种方法)
1 ;天水浪客(Gouki Jiang) , 16进制to10进制例题 2007.5.18 2 STACK SEGMENT PARA STACK 3 S_AREA DW 100H DUP(?) 4 S_TOP EQU $-S_AREA 5 STACK ENDS 6 7 DATA SEGMENT PARA 8 VALUE DW 0EB9AH ;060314 9 RESULT DB 5 DUP(?),'$' 10 DATA ENDS 11 12 CODE SEGMENT PARA 13 ASSUME CS:CODE,DS:DATA,SS:STACK 14 15 MAIN PROC FAR 16 MOV AX,DATA 17 MOV DS,AX 18 MOV AX,STACK 19 MOV SS,AX 20 MOV SP,S_TOP 21 MOV CX,5 22 MOV AX,VALUE 23 MOV BX,10 24 MOV DI,OFFSET RESULT+4 25 26 JYB: XOR DX,DX 27 DIV BX 28 OR DL,30H 29 MOV BYTE PTR [DI],DL 30 DEC DI 31 LOOP JYB 32 MOV DX,OFFSET RESULT 33 MOV AH,9 34 INT 21H 35 36 EXIT: MOV AX,4C00H 37 INT 21H 38 MAIN ENDP 39 CODE ENDS 40 END MAIN 41 42 ;--------------------------------------------- 43 44 ;天水浪客(Gouki Jiang) , 16进制to10进制倒除 2007.5.18 45 STACK SEGMENT PARA STACK 46 DW 100H DUP(?) 47 STACK ENDS 48 49 DATA SEGMENT PARA 50 VALUE DW 0EB9AH ;060314 51 DATA ENDS 52 53 CODE SEGMENT PARA 54 ASSUME CS:CODE,DS:DATA,SS:STACK 55 56 MAIN PROC FAR 57 MOV AX,DATA 58 MOV DS,AX 59 MOV CX,5 60 MOV AX,VALUE 61 MOV BX,10 62 63 JYB1: XOR DX,DX 64 DIV BX 65 OR DL,30H 66 PUSH DX 67 LOOP JYB1 68 MOV CX,5 69 JYB2: POP DX 70 MOV AH,2 71 INT 21H 72 LOOP JYB2 73 EXIT: MOV AX,4C00H 74 INT 21H 75 MAIN ENDP 76 CODE ENDS 77 END MAIN 78 ;----------------------------------------------- 79 80 ;天水浪客(Gouki Jiang) , 16进制to10进制 顺除 2007.5.18 81 STACK SEGMENT PARA STACK 82 DW 100H DUP(?) 83 STACK ENDS 84 85 DATA SEGMENT PARA 86 VALUE DW 0EB9AH ;060314 87 DIVISOR DW 10000,1000,100,10,1 88 DATA ENDS 89 90 CODE SEGMENT PARA 91 ASSUME CS:CODE,DS:DATA,SS:STACK 92 93 MAIN PROC FAR 94 MOV AX,DATA 95 MOV DS,AX 96 MOV CX,5 97 MOV AX,VALUE 98 MOV SI,OFFSET DIVISOR 99 100 JYB: XOR DX,DX 101 DIV WORD PTR[SI] 102 PUSH DX 103 OR AL,30H 104 MOV DL,AL 105 MOV AH,2 106 INT 21H 107 INC SI 108 INC SI 109 POP AX 110 LOOP JYB 111 112 EXIT: MOV AX,4C00H 113 INT 21H 114 MAIN ENDP 115 CODE ENDS 116 END MAIN 117 118 ;-------------------------------------
原文地址:http://blog.sina.com.cn/s/blog_4a9fe761010008mq.html