1、实验二数码转码编程及程序调试本版为免费版,源自百度文库用户 lengjj914 1.将 ASCII码表示的十进制数转换为二进制数。STACK SEGMENT STACK STACKDB 100 DUP(?)STACK ENDSASSUME CS:CODE,SS:STACKCODE SEGMENTORG 2000HSTART:MOV CX,4HMOV BX,0AHXOR AH,AHMOV SI,3500HMOV DI,3510HMOV AL,BYTE PTRSISUB AL,30HAGAIN:MUL BXINC SISUB BYTE PTRSI,30HCLCADD AL,BYTE PTRSIAD
2、C AH,0LOOP AGAINEXIT: MOV DI,AXMOV AX,4C00HINT 21HCODE ENDSEND START2.将从键盘输入的五位十进制数的 ASCII码存在 3500起始的内存单元中。把它转换成 BCD码后,再按位分别存入 350A起始的内存单元内。若输入的不是十进制的 ASCII码,则显示 FF.STACK SEGMENT STACK STACKDB 100 DUP(?)STACK ENDSCODE SEGMENTASSUME CS:CODE,SS:STACKORG 2000HSTART:MOV SI,3500HMOV DI,350AHMOV CX,0005HA
3、GAIN: MOV DL,0FFHMOV AL,BYTE PTRSICMP AL,39HJA ERRORCMP AL,30HJB ERRORMOV BL,30HSUB AL,BLMOV DI,ALJMP EXITERROR: MOV DI,DLEXIT: INC SIINC DILOOP AGAINMOV AX,4C00HINT 21HCODE ENDSEND START3. 将十六位二进制数转换为 ASCII码表示的十进制数。STACK SEGMENT STACK STACKDB 100 DUP(?)STACK ENDSCODE SEGMENTASSUME CS:CODE,SS:STACKO
4、RG 2000HSTART: MOV DI,3500HMOV AX,DIMOV SI,3514HINC SIAGAIN: DEC SIMOV DX,0000HMOV BX,000AHDIV BXADD DL,30HMOV SI,DLCMP AX,0HJNE AGAINAGAIN1: DEC SIMOV DL,30HMOV SI,DLCMP SI,3510HJNE AGAIN1MOV AX,4C00HINT 21HCODE ENDSEND START4. 十六进制数转换为 ASCII码。STACK SEGMENT STACK STACKDB 100 DUP(?)STACK ENDSCODE SE
5、GMENTASSUME CS:CODE,SS:STACKORG 2000HSTART: MOV CX,0004HMOV DI,350AHMOV SI,3500HMOV DX,SIAGAIN: MOV AX,DXAND AX,000FHCMP AL,09HJB ZEROJMP SEVENZERO: ADD AL,30HJMP EXITSEVEN: ADD AL,37HEXIT: MOV DI,ALINC DIPUSH CXMOV CL,04HSHR DX,CLPOP CXLOOP AGAINMOV AX,4C00HINT 21HCODE ENDSEND START5. BCD码转换为二进制码STACK SEGMENT STACK STACKDB 100 DUP(?)STACK ENDSCODE SEGMENTASSUME CS:CODE,SS:STACKORG 2000HSTART:MOV SI,3500HMOV DI,3510HMOV CX,0008HAGAIN: MOV AL,BYTE PTRSIMOV BL,0AHMUL BLINC SIMOV AH,00HMOV DL,BYTE PTRSIADD AL,DLMOV DI,AXINC DIINC DIINC SILOOP AGAINMOV AX,4C00HINT 21HCODE ENDSEND START