闲着……学学写写汇编(只贴代码)(5)

来源:互联网 发布:天刀回归活动网络繁忙 编辑:程序博客网 时间:2024/06/09 21:32

中间忙了点别的事……这段代码有段时间了,自己回顾一下也有点问题,还好改完了



assume cs: code,ss:stackdata segmentdb 16 dup (0)data endsstack segmentdb 16 dup (0)stack endscode segmentstart:mov ax,317Ah;12666mov bx,datamov ds,bxmov si,0mov di,0call dtoc ; dwords to characters  12666->  1  2  6  6  6 mov dh,8mov dl,3mov cl,2call show_str ; show strings one the 8 ,3 MOV AH,1;调用1号中断,用户任意按键INT 21HMOV   AH,0AH           ;调用0A号中断,读入键盘输入的字符串.         INT   21Hmov ax,4c00hint  21hdtoc: ;---------------------------------------------------------dtoc startmov dx,0mov di,10mov bx,0 push bx;-------------------------make sure 0 is bottom of the stack next get can detect it and end the loops00:div  dimov cx,dxmov si,0  jcxz nextstep1      ;  ------------- if ax --quotient --- is 0push  dx;Remainder  1 2 6 6 6 0mov dx,0jmp short s00nextstep1:;--------------------------write to data segment   for  storemov ch,0pop  cxjcxz nextstep2add cl,30hmov [si],clinc sijmp short nextstep1nextstep2:;-----------------------------clearmov cx,0mov di,0mov si,0ret;---------------------------------------------------------dtoc endshow_str:mov bp,cxmov cx,0mov ax,0b800hmov es,axmov cl,dhs1:add bx,00a0hloop s1mov cl,dls2:add si,2loop s2mov cx,0j1:mov cx,0mov ah,0mov al,ds:[di]mov cl,aljcxz over1mov ah,2hmov word ptr es:[bx+si],axinc diadd si,2hjmp short j1over1:mov cx,bpret code endsend start


呵呵 就是显示到屏幕上,主要问题再div di 那,本来我写成 div word ptr di,masm编译报错,Illegal use of register ,不晓得了,然后改成 div di 通过了,希望哪个大大给指点一下为什么会这样……继续前进,函数调用 call 有了深入的理解


原创粉丝点击