|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
怎么把做加法得到的ax中的值,放入显存中,也就是怎么把AX的值显示在屏幕上。
直接:
mov si,ax ax里面是前面一个加法的和想把ax里面的两个字节显示在屏幕中间这个语句求大神指点一下
mov ax,0b872h
mov es,ax
?
本帖最后由 jackz007 于 2019-3-31 15:41 编辑
哪有那么简单,要显示 ax 寄存器的值远比你想象的要复杂得多,下面是汇编代码:
- data segment para public
- db 020h dup(00)
- data ends
- stack segment stack
- dw 080h dup(00)
- stack ends
- code segment para public
- assume cs:code , ds:data , ss:stack
- bin2hex proc near
- push bx
- push cx
- push dx
- push ds
- push es
- mov si,0fh
- push ax
- pop bx
- mov cl,04h
- h1: mov al,bl
- and al,0fh
- shr bx,cl
- cmp al,0ah
- jb h2
- add al,37h
- jmp h3
- h2: add al,030h
- h3: mov [si],al
- or bx,bx
- jz h4
- dec si
- jmp h1
- h4: mov cx,0fh
- sub cx,si
- inc cx
- push ds
- pop es
- xor di,di
- rep movsb
- xor al,al
- stosb
- pop es
- pop ds
- pop dx
- pop cx
- pop bx
- ret
- bin2hex endp
- bin2dec proc near
- push bx
- push cx
- push dx
- push ds
- push es
- mov si,1fh
- b1: xor dx,dx
- mov cx,0ah
- div cx
- add dl,30h
- mov [si],dl
- or ax,ax
- jz b2
- dec si
- jmp b1
- b2: mov cx,1fh
- sub cx,si
- inc cx
- push ds
- pop es
- mov di,010h
- rep movsb
- xor al,al
- stosb
- pop es
- pop ds
- pop dx
- pop cx
- pop bx
- ret
- bin2dec endp
- show proc near
- push bx
- push cx
- push dx
- push si
- push di
- push ds
- push es
- push ax
- mov al,ah
- xor ah,ah
- mov cl,0a0h
- mul cl
- push ax
- pop di
- pop ax
- xor ah,ah
- add al,al
- add di,ax
- push di
- xor si,si
- mov ax,0b800h
- mov es,ax
- s1: lodsb
- or al,al
- jz s2
- stosb
- mov al,2
- stosb
- jmp s1
- s2: pop di
- add di,0a0h
- mov si,010h
- s3: lodsb
- or al,al
- jz s4
- stosb
- mov al,02
- stosb
- jmp s3
- s4: pop es
- pop ds
- pop di
- pop si
- pop dx
- pop cx
- pop bx
- ret
- show endp
- cls proc near
- push ax
- push bx
- push cx
- push dx
- mov ax,0600h
- xor cx,cx
- mov dx,0184fh
- int 10h
- pop dx
- pop cx
- pop bx
- pop ax
- ret
- cls endp
- ppause proc near
- push ax
- xor ax,ax
- int 016h
- pop ax
- ret
- ppause endp
- main proc far ; 程序入口
- mov ax,data
- push ax
- pop ds
- push ax
- pop es
- mov ax,1234h ; 屏幕显示 ax 的数值
- push ax
- call bin2dec ; 把数值转化为十进制字符串
- pop ax
- call bin2hex ; 把数值转化为十六进制字符串
- call cls ; 清屏
- mov ax,0b28h ; 在第11行,40列显示结果
- call show ; 在屏幕的指定位置显示字符串
- call ppause ; 等待键盘输入
- mov ax,4c00h
- int 21h
- main endp
- code ends
- end main
复制代码
|
|