Original link: https://blog.csdn.net/weixin_41944412/article/details/79951229
. 1 the ASSUME CS: code 2 DATAl segment . 3 DW 123 , 12666 , . 1 , . 8 , . 3 , 38 is . 4 DATAl ends . 5 Data segment . 6 DB 30 DUP ( 0 ) ; string storage section of the converter . 7 Data ends . 8 code segment . 9 Start: MOV AX, DATAl 10 MOV ES, AX . 11 MOV AX, Data 12 is MOVDS, AX 13 is MOV Si, 0 ; addressing data segment with 14 MOV BX, 0 ; address data1 Seg, now points to the first number 123 15 MOV CX, 6 ; cycle number 6, a total of six Data word 16 . 17 S: MOV ax, ES: [BX] ; scratch would require converted data to the ax 18 is Push CX ; the temporary cycles CX: Drawing . 19 Call DTOC ; the data string is converted to the ax, coexist in the data section 20 is POPcx ; the cx Recovery 21 is the Add BX, 2 ; BX points to the next data 22 is Loop S ; (cx) = (cx) -1, circulating the six data conversion is complete 23 is MOV byte PTR DS: [Si + . 1 ], 0 ; after the last string place 0, the end flag 24 25 MOV DH, . 8 26 is MOV DL, . 3 27 MOV Cl, 2 28 Call showstr ; the associated string into a memory location 29 30 MOV AX, 4c00h 31 is int 21H 32 33 is DTOC: Push AX ; protected field 34 is Push BX 35 Push CX 36 Push DX 37 [ MOV BX, 0 ; behind the counter needs 38 is 39 DTO: MOV CX, AX 40 jcxz OK1 ; Analyzing supplier whether 0, 0 when the conversion is complete, skip OK1 41 is MOV DX, 0 42 is MOV CX, 10 43 is div CX 44 is the Add DX, 30h ; DX is the remainder, digital + 30h converted into corresponding code ascll 45 Push DX ; each of the digital codes of ascll stack 46 is inc is BX ; bits of a recording digital converter 47 JMP Short DTO ; the full cycle of a data conversion is completed 48 49 50 OK1: MOV CX, BX ; the number of cycles assigned CX 51 is S1: POPDX ; a stack of ascll digit code 52 is MOV DS: [Si], DL ; the 8-digit code is placed in the data segment ascll 53 is inc is Si ; Si +. 1, ready for the next transfer of a number ascll code 54 is Loop S1 ; the individual bits of the code data are transmitted ascll the data segment 55 MOV Al, for 20 h 56 is MOV DS: [Si], Al ; put a space behind each ascll code data, to separate the individual data 57 INC. Si ; The si + 1, otherwise the next data into the data section, will cover the spaces ascll code 58 59 60 POP DX 61 is POP CX 62 is POP BX 63 is POP AX 64 RET ; return s, continue with the next data code conversion ascll 65 66 showstr: Push AX 67 Push BX 68 Push CX 69 Push DI 70 Push Si 71 is Push ES 72 MOV AX, Data 73 is MOV DS, AX 74 MOVSi, 0 75 .mov AX, 0b800h 76 .mov Es, AX 77 78 79 .mov Si, 0 80 .mov al . , 160 81 Mul Dh 82 .mov BX, AX 83 .mov Dh, 0 84 .mov al . , 2 85 Mul dl , 86 : add BX, AX 87 88 89 .mov by ah, CL 90 Str : .mov CL, DS: [Si] 91 mov ch,0 92 jcxz ok2 93 mov ch,ah 94 mov es:[bx+di],cx 95 inc si 96 add di,2 97 jmp short str 98 ok2:pop es 99 pop si 100 pop di 101 pop cx 102 pop bx 103 pop ax 104 ret 105 code ends 106 end start