资源描述:
《十进制与十六进制互换》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、十进制与十六进制互换说明:程序运行,选择功能。按1键:十进制转换成十六进制,键入值:0-255;按2键:十六进制转换成十进制,键入值:0-ff;按q键:退出。代码部分:stacksegmentstack'stack'dw100hdup(?)toplabelwordstackendsdatasegmentselectdb?decimaldb5dup(?)bufferdb100dup(?)keybufferdb100db?db100dup(?)string1db'press1:deciamaltoHexadecimal',0dh,0ah,'press2:Hexadecimaltodec
2、iamal',0dh,0ah,'pressq:out',0dh,0ah,'$'string2db'pleaseinputdeciamaldata(0-255):$'string3db'pleaseinputHexadecimaldata(0-ff):$'string4db'changetoHexadecimal:$'string5db'changetodeciamal:$'dataendscodesegmentassumecs:code,ds:data,es:data,ss:stackstart:;键盘输入十六进制数(最大:ff),输出十进制数(255)movax,datamovd
3、s,axmoves,axmovax,stackmovss,axleasp,topmovcx,5movdx,0hleasi,decimallps:mov[si],dxincsilooplpsleadx,string1;显示选择功能提示movah,09hint21hmovah,01h;保存选择项int21hmovselect,alcmpselect,71hjeovercalldispcrcmpselect,31h;根据选择项显示提示jekeleadx,string3jmpkrke:leadx,string2kr:movah,09hint21hmovah,0ahleadx,keybuff
4、erint21hleasi,keybuffer+1leadi,buffermovcx,[si]cmpselect,31hjekremovbx,10hjmplpkre:movbx,10lp:;取值到存储单元incsideccxmoval,[si]subal,30hcmpselect,31hjedecmpal,0ahjbdesubal,27hde:add[di],almoval,0dhcmp[si],aljeovercmp[si+1],aljemp;是回车moval,[di];不是回车乘16mulbxmov[di],allooplpmp:calldispcrcmpselect,31hj
5、eucleadx,string5jmpuctuc:leadx,string4uct:movah,09hint21hmovcx,dileasi,buffersubcx,siinccxxorax,axmoval,[si]calldispaxdcalldispcr;calldispcr;jmpstart;over:movah,4chint21hdispcrprocnearpushaxpushdxmovah,02hmovdl,0ahint21hmovah,02hmovdl,0dhint21hpopdxpopaxretdispcrendpdispaxdprocnearpushcxpushsi
6、leasi,decimalmovcx,0hcmpselect,31hjetcrmovbl,10jmptrxtcr:movbl,10htrx:jmpkitc:incsiki:divblinccxmov[si],ahxorah,ahcmpselect,31hjeutcmpal,09hjmputrut:cmpal,0fhutr:jgtccmpal,0hjexoincsiinccxmov[si],alxo:movdl,[si]adddl,30hcmpselect,31hjnesdcmpdl,3ahjbsdadddl,27hsd:movah,02hint21hdecsiloopxopopsi
7、popcxretdispaxdendpcodeendsendstart运行截图: