我是刚学的
这个程序要实现16进制输入一个多项式又以16进制输出结果
我写的程序如下 我调试后看见buf1的内容竟然存在kaitou的中间了 这是为什么?
我只写到了 计算那步 后来10进制换回16进制的代码还没写
data segment buf2 db ? kaitou db 'please input a expression ',0dh,0ah, '$' buf1 db 7 dup(0) xuanze db ' input 0 out,input 1 continue ',0dh,0ah,'$' jieshu db ' Thanks for your useing!$' data ends code segment assume cs:code,ds:data,es:data start: mov ax,data mov ds,ax mov es,ax enter: lea dx,kaitou mov ah,9 int 21h mov cx,7 lea di,buf1 mov ah,10 int 21h rep stosb mov cx,7 lea di,buf1 xor ax,ax
sz: mov al,[di] cmp al,'+' je lop cmp al,'-' je lop cmp al,'*' je lop jmp h_b mov cx,7 lea si,buf1
j_s: mov al,[si] cmp al,'*' je cf cmp al,'+' je jf1 cmp al,'-' je jf2 inc si loop j_s mov dl,buf2 mov ah,2 int 21h mov ah,4ch int 21h
lop: inc di loop sz
jf1: mov al,[si-1] add al,[si+1] mov [si+1],al inc si mov buf2,al loop j_s jf2: mov al,[si-1] sub al,[si+1] mov [si+1],al inc si mov buf2,al loop j_s cf: mov al,[si-1] mov dl,[si+1] mul dl inc si mov buf2,al loop j_s
h_b: mov bx,0 sub al,30H jl lop cmp al,10d jl add_to sub al,27h cmp al,0ah jl lop cmp al,10h jge lop
add_t push cx mov cl,4 shl bx,cl mov ah,0 add bx,ax
b_d: mov cx,10000d call dec_d mov cx,1000d call dec_d mov cx,100d call dec_d mov cx,10d call dec_d mov cx,1d call dec_d pop cx jmp lop
dec_d proc near mov ax,bx mov dx,0 div cx mov bx,dx mov dl,al add dl,30H ret dec_d endp
code ends end start