实验五 80x86分支,循环,子程序,宏程序设计姓名:学号:序号:班级:分数:1.编写设计一个2,10,16进制的码制转换程序,要求:①程序有友好的运行界面;②输入任意类型进制的数据,转换为其余两种进制类型;③要求程序有方便的输入输出功能;④要求程序能够处理基本的错误信息;⑤程序的基本结构采用子程序结构;源程序:.8086.model small.datastr db 0ah,0dh,'please input 1 to 8 to choise the function',0ah,0dhdb '1.btd',0ah,0dhdb '2.bth',0ah,0dhdb '3.dth',0ah,0dhdb '4.dtb',0ah,0dhdb '5.htb',0ah,0dhdb '6.htd',0ah,0dhdb '7.again',0ah,0dhdb '8.end',0ah,0dh,'$'b db 'Please input a Binary number',0ah,0dh,'$'d db 'Please input a decimal number',0ah,0dh,'$'h db 'Please input a Hexadecimal number',0ah,0dh,'$'agai db 'Please input again',0ah,0dh,'$'wr db 'A wrong number!',0ah,0dh,'$'num db 6,?,6 dup (?)num1 db 16,?,16 dup (?).codestart:mov ax,@datamov ds,axchoice:lea dx,strmov ah,9int 21hmov ah,1int 21hjmp C1mov ah,2int 21hmov dl,0dhmov ah,2int 21hjmp choiceMo: mov dx,offset agai mov ah,9int 21hjmp choiceC1: cmp al,'1'jnz C2call btdjmp againC2: cmp al,'2'jnz C3call bthjmp againC3: cmp al,'3'jnz C4call dthjmp againC4: cmp al,'4'jnz C5call dtbjmp againC5: cmp al,'5'jnz C6call htbjmp againC6: cmp al,'6'jnz C7call htdjmp againC7: cmp al,'7'jnz C8jmp Mojnz wrongen: mov ah,4chint 21hwrong:lea dx,wrmov ah,9int 21hjmp Mobtd procmov dx,offset bmov ah,9int 21hmov dx,offset num1mov ah,0ahint 21hmov dl,0ahmov ah,2int 21hmov dl,0dhmov ah,2int 21hmov di,offset num1mov ch,[di+1]zq2: mov dl,[di+2]cmp dl,39hjg zqsub dl,30hjmp zq1zq: sub dl,37hzq1: mov dh,0or bx,dxcmp ch,1jz zq3rol bx,1zq3: inc didec chjnz zq2jj1: cmp bx,10000 jc jjsub bx,10000inc sijmp jj1jj: mov dx,siand dx,0fhadd dl,30hmov ah,2int 21hxor si,siL1: cmp bx,1000jc L2sub bx,1000inc sijmp L1L2: mov dx,siand dx,0fhadd dl,30hmov ah,2int 21hxor si,siL3: cmp bx,100jc L4sub bx,100inc sijmp L3L4: mov dx,siand dx,0fhadd dl,30hmov ah,2int 21hxor si,siL5: cmp bx,10jc L6sub bx,10inc sijmp L5L6: mov dx,simov ah,2int 21hxor dx,dxmov dx,bxand dx,0fhadd dl,30hmov ah,2int 21hretbtd endpbth procmov dx,offset bmov ah,9int 21hmov dx,offset num1mov ah,0ahint 21hmov dl,0ahmov ah,2int 21hmov dl,0dhmov ah,2int 21hmov di,offset num1mov ch,[di+1]K1: mov al,[di+2]sub al,30hor bl,alrol bx,1inc didec chjnz K1ror bx,1mov ch,4mov cl,4K4: rol bx,clmov dl,bland dl,0fhadd dl,30hjmp K3K2: add dl,37hK3: mov ah,2int 21hdec chjnz K4retbth endpdth proclea dx,dmov ah,9int 21hmov dx,offset nummov ah,0ahint 21hmov dl,0ahmov ah,2int 21hmov dl,0dhmov ah,2int 21hmov di,offset nummov cl,[di+1]add di,2mov dl,[di]sub dl,30hmov al,10mul dlmov ch,0dec cxI: inc dimov dl,[di]sub dl,30hmov dh,0add ax,dxcmp cx,1jz I1mov bx,axI1: loop Imov bx,axmov si,offset nummov ch,[si+1]inc chinc chmov cl,4O: rol bx,clmov dl,bland dl,0fhcmp dl,9jg MMadd dl,30hjmp PPMM: add dl,37h PP: mov ah,2int 21hdec chjnz Oretdth endpdtb proclea dx,dmov ah,9int 21hmov dx,offset nummov ah,0ahint 21hmov dl,0ahmov ah,2int 21hmov dl,0dhmov ah,2int 21hmov di,offset nummov cl,[di+1]add di,2mov al,10mul dlmov ch,0dec cxc: inc dimov dl,[di]sub dl,30hmov dh,0add ax,dxcmp cx,1jz ccmov bx,10mul bxmov bx,axcc: dec cxjnz cmov bx,axmov cx,16x: rol bx,1mov dl,bland dl,01hadd dl,30hmov ah,2int 21hloop xretdtb endphtb procmov dx,offset hmov ah,9int 21hmov dx,offset nummov ah,0ahint 21hmov dl,0ahmov ah,2int 21hmov dl,0dhmov ah,2int 21hmov ch,[di+1]Z1: mov bl,[di+2]cmp bl,39hjg ZZsub bl,30hjmp ZXZZ: sub bl,37hZX: mov cl,4mov bh,4shl bl,clZ: rol bl,1mov dl,bland dl,01hadd dl,30hY: mov ah,2int 21hdec bhjnz Zinc didec chjnz Z1rethtb endphtd procmov dx,offset hmov ah,9int 21hmov dx,offset nummov ah,0ahint 21hmov dl,0ahmov ah,2int 21hmov dl,0dhmov ah,2int 21hmov di,offset nummov ch,[di+1]u2: mov dl,[di+2]sub dl,30hjmp u1u: sub dl,37h u1: mov dh,0or bx,dxcmp ch,1jz Rmov cl,4rol bx,cl R: inc didec chjnz u2xor si,sis1: cmp bx,1000jc s2sub bx,1000inc sijmp s1s2: mov dx,siand dx,0fhadd dl,30hmov ah,2int 21hxor si,sis3: cmp bx,100jc s4sub bx,100inc sijmp L3xor si,sis4: cmp bx,10jc s5sub bx,10inc sijmp s3s5: mov dx,siand dx,0fhadd dl,30hmov ah,2int 21hmov dx,bxand dx,0fhadd dl,30hmov ah,2int 21hrethtd endpend start实验结果:。