鱼C论坛

 找回密码
 立即注册
查看: 2893|回复: 2

[已解决]跪求各位大神指点一下!!!

[复制链接]
发表于 2019-3-31 12:46:39 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
怎么把做加法得到的ax中的值,放入显存中,也就是怎么把AX的值显示在屏幕上。
   
直接:

mov si,ax             ax里面是前面一个加法的和想把ax里面的两个字节显示在屏幕中间这个语句求大神指点一下
mov ax,0b872h
mov es,ax
?
最佳答案
2019-3-31 15:07:53
本帖最后由 jackz007 于 2019-3-31 15:41 编辑

    哪有那么简单,要显示 ax 寄存器的值远比你想象的要复杂得多,下面是汇编代码:
  1. data segment para public
  2.      db 020h dup(00)
  3. data ends
  4. stack segment stack
  5.      dw 080h dup(00)
  6. stack ends
  7. code segment para public
  8.     assume cs:code , ds:data , ss:stack
  9.     bin2hex proc near
  10.             push bx
  11.             push cx
  12.             push dx
  13.             push ds
  14.             push es
  15.             mov si,0fh
  16.             push ax
  17.             pop bx
  18.             mov cl,04h
  19.         h1: mov al,bl
  20.             and al,0fh
  21.             shr bx,cl
  22.             cmp al,0ah
  23.             jb h2
  24.             add al,37h
  25.             jmp h3
  26.         h2: add al,030h
  27.         h3: mov [si],al
  28.             or bx,bx
  29.             jz h4
  30.             dec si
  31.             jmp h1
  32.         h4: mov cx,0fh
  33.             sub cx,si
  34.             inc cx
  35.             push ds
  36.             pop es
  37.             xor di,di
  38.             rep movsb   
  39.             xor al,al
  40.             stosb
  41.             pop es
  42.             pop ds
  43.             pop dx
  44.             pop cx
  45.             pop bx
  46.             ret
  47.     bin2hex endp
  48.     bin2dec proc near
  49.             push bx
  50.             push cx
  51.             push dx
  52.             push ds
  53.             push es
  54.             mov si,1fh
  55.         b1: xor dx,dx
  56.             mov cx,0ah
  57.             div cx
  58.             add dl,30h
  59.             mov [si],dl
  60.             or ax,ax
  61.             jz b2
  62.             dec si
  63.             jmp b1
  64.         b2: mov cx,1fh
  65.             sub cx,si
  66.             inc cx
  67.             push ds
  68.             pop es
  69.             mov di,010h
  70.             rep movsb   
  71.             xor al,al
  72.             stosb
  73.             pop es
  74.             pop ds
  75.             pop dx
  76.             pop cx
  77.             pop bx
  78.             ret
  79.     bin2dec endp
  80.     show proc near
  81.             push bx
  82.             push cx
  83.             push dx
  84.             push si
  85.             push di
  86.             push ds
  87.             push es
  88.             push ax
  89.             mov al,ah
  90.             xor ah,ah
  91.             mov cl,0a0h
  92.             mul cl
  93.             push ax
  94.             pop di
  95.             pop ax
  96.             xor ah,ah
  97.             add al,al
  98.             add di,ax
  99.             push di
  100.             xor si,si
  101.             mov ax,0b800h
  102.             mov es,ax
  103.         s1: lodsb
  104.             or al,al
  105.             jz s2
  106.             stosb
  107.             mov al,2
  108.             stosb
  109.             jmp s1
  110.         s2: pop di
  111.             add di,0a0h
  112.             mov si,010h
  113.         s3: lodsb
  114.             or al,al
  115.             jz s4
  116.             stosb
  117.             mov al,02
  118.             stosb
  119.             jmp s3
  120.         s4: pop es
  121.             pop ds
  122.             pop di
  123.             pop si
  124.             pop dx
  125.             pop cx
  126.             pop bx
  127.             ret
  128.     show endp
  129.     cls proc near
  130.             push ax
  131.             push bx
  132.             push cx
  133.             push dx
  134.             mov ax,0600h
  135.             xor cx,cx
  136.             mov dx,0184fh
  137.             int 10h
  138.             pop dx
  139.             pop cx
  140.             pop bx
  141.             pop ax
  142.             ret
  143.     cls endp
  144.     ppause proc near
  145.             push ax
  146.             xor ax,ax
  147.             int 016h
  148.             pop ax
  149.             ret
  150.     ppause endp
  151.     main proc far                  ; 程序入口
  152.             mov ax,data
  153.             push ax
  154.             pop ds
  155.             push ax
  156.             pop es

  157.             mov ax,1234h           ; 屏幕显示 ax 的数值
  158.             push ax
  159.             call bin2dec           ; 把数值转化为十进制字符串
  160.             pop ax
  161.             call bin2hex           ; 把数值转化为十六进制字符串

  162.             call cls               ; 清屏

  163.             mov ax,0b28h           ; 在第11行,40列显示结果
  164.             call show              ; 在屏幕的指定位置显示字符串

  165.             call ppause            ; 等待键盘输入

  166.             mov ax,4c00h
  167.             int 21h
  168.     main endp
  169. code ends
  170. end main
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2019-3-31 15:07:53 | 显示全部楼层    本楼为最佳答案   
本帖最后由 jackz007 于 2019-3-31 15:41 编辑

    哪有那么简单,要显示 ax 寄存器的值远比你想象的要复杂得多,下面是汇编代码:
  1. data segment para public
  2.      db 020h dup(00)
  3. data ends
  4. stack segment stack
  5.      dw 080h dup(00)
  6. stack ends
  7. code segment para public
  8.     assume cs:code , ds:data , ss:stack
  9.     bin2hex proc near
  10.             push bx
  11.             push cx
  12.             push dx
  13.             push ds
  14.             push es
  15.             mov si,0fh
  16.             push ax
  17.             pop bx
  18.             mov cl,04h
  19.         h1: mov al,bl
  20.             and al,0fh
  21.             shr bx,cl
  22.             cmp al,0ah
  23.             jb h2
  24.             add al,37h
  25.             jmp h3
  26.         h2: add al,030h
  27.         h3: mov [si],al
  28.             or bx,bx
  29.             jz h4
  30.             dec si
  31.             jmp h1
  32.         h4: mov cx,0fh
  33.             sub cx,si
  34.             inc cx
  35.             push ds
  36.             pop es
  37.             xor di,di
  38.             rep movsb   
  39.             xor al,al
  40.             stosb
  41.             pop es
  42.             pop ds
  43.             pop dx
  44.             pop cx
  45.             pop bx
  46.             ret
  47.     bin2hex endp
  48.     bin2dec proc near
  49.             push bx
  50.             push cx
  51.             push dx
  52.             push ds
  53.             push es
  54.             mov si,1fh
  55.         b1: xor dx,dx
  56.             mov cx,0ah
  57.             div cx
  58.             add dl,30h
  59.             mov [si],dl
  60.             or ax,ax
  61.             jz b2
  62.             dec si
  63.             jmp b1
  64.         b2: mov cx,1fh
  65.             sub cx,si
  66.             inc cx
  67.             push ds
  68.             pop es
  69.             mov di,010h
  70.             rep movsb   
  71.             xor al,al
  72.             stosb
  73.             pop es
  74.             pop ds
  75.             pop dx
  76.             pop cx
  77.             pop bx
  78.             ret
  79.     bin2dec endp
  80.     show proc near
  81.             push bx
  82.             push cx
  83.             push dx
  84.             push si
  85.             push di
  86.             push ds
  87.             push es
  88.             push ax
  89.             mov al,ah
  90.             xor ah,ah
  91.             mov cl,0a0h
  92.             mul cl
  93.             push ax
  94.             pop di
  95.             pop ax
  96.             xor ah,ah
  97.             add al,al
  98.             add di,ax
  99.             push di
  100.             xor si,si
  101.             mov ax,0b800h
  102.             mov es,ax
  103.         s1: lodsb
  104.             or al,al
  105.             jz s2
  106.             stosb
  107.             mov al,2
  108.             stosb
  109.             jmp s1
  110.         s2: pop di
  111.             add di,0a0h
  112.             mov si,010h
  113.         s3: lodsb
  114.             or al,al
  115.             jz s4
  116.             stosb
  117.             mov al,02
  118.             stosb
  119.             jmp s3
  120.         s4: pop es
  121.             pop ds
  122.             pop di
  123.             pop si
  124.             pop dx
  125.             pop cx
  126.             pop bx
  127.             ret
  128.     show endp
  129.     cls proc near
  130.             push ax
  131.             push bx
  132.             push cx
  133.             push dx
  134.             mov ax,0600h
  135.             xor cx,cx
  136.             mov dx,0184fh
  137.             int 10h
  138.             pop dx
  139.             pop cx
  140.             pop bx
  141.             pop ax
  142.             ret
  143.     cls endp
  144.     ppause proc near
  145.             push ax
  146.             xor ax,ax
  147.             int 016h
  148.             pop ax
  149.             ret
  150.     ppause endp
  151.     main proc far                  ; 程序入口
  152.             mov ax,data
  153.             push ax
  154.             pop ds
  155.             push ax
  156.             pop es

  157.             mov ax,1234h           ; 屏幕显示 ax 的数值
  158.             push ax
  159.             call bin2dec           ; 把数值转化为十进制字符串
  160.             pop ax
  161.             call bin2hex           ; 把数值转化为十六进制字符串

  162.             call cls               ; 清屏

  163.             mov ax,0b28h           ; 在第11行,40列显示结果
  164.             call show              ; 在屏幕的指定位置显示字符串

  165.             call ppause            ; 等待键盘输入

  166.             mov ax,4c00h
  167.             int 21h
  168.     main endp
  169. code ends
  170. end main
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-3-31 16:11:25 | 显示全部楼层
jackz007 发表于 2019-3-31 15:07
哪有那么简单,要显示 ax 寄存器的值远比你想象的要复杂得多,下面是汇编代码:

谢谢大佬,我再好好学习一下,谢谢!!!
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-6-10 02:34

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表