回 帖 发 新 帖 刷新版面

主题:高手指点,程序运行不理想

count equ 2
data  segment
str1  db  0dh,0ah,'please enter the multipicand: $'
str2  db  0dh,0ah,'please enter the multiplier: $'
str3  db  0dh,0ah,'the product  is: $'
mcand dw  ?
      dw  4 dup (?)
mcato dw  ?
      dw  4 dup (?)
prot  dw  6 dup(?)
data  ends
STACK segment STACK
      db 100 dup(?)
stack ends
code  segment
      assume cs:code,ds:data,es:data,ss:stack
main  proc far
start:push ds
      mov  ax,0
      push ax
      mov  ax,data
      mov  ds,ax
      mov  es,ax
      lea  dx,str1
      mov  ah,09
      int  21h
      lea  si,mcand
      mov  ah,0ah
      int  21h
      lea  dx,str2
      mov  ah,09
      int  21h
      lea  bx,mcato
      mov  ah,0ah
      int  21h
      lea  dx,str3
      mov  ah,09
      int  21h
      lea  di,prot
      push di
      mov  ax,0
      mov  cx,2*count
      cld
      rep  stosw
      pop  di
      mov  cx,count
exter:push cx
      mov  dx,[bx]
      inc  bx
      inc  bx
      push di
      push si
      mov  cx,count
inter:push cx
      push dx
      lodsw
      mul  dx
      add  [di],ax
      inc  di
      inc  di
      adc  [di],dx
      mov  ah,02h
      int  21h
      pop  dx
      pop  cx
      loop inter
      pop  si
      pop  di
      inc  di
      inc  di
      pop  cx
      loop exter
      ret
main  endp
code  ends
      end   start
运行之后不会在屏幕上显示结果

回复列表 (共4个回复)

沙发


粗略的看了一下,有很多问题.
  21h号中断的0ah号功能的入口参数有问题.缓冲区地址应为 DS:DX 不是DS:SI
  所以:
      lea  si,mcand
      mov  ah,0ah
      int  21h
  应改为:
      lea  dx,mcand
      mov  ah,0ah
      int  21h
还有几处也应该这样改.
另外,缓冲区应该以字节为单位,不是字

  你最好说一下你的程序想要达到的目的.

板凳

我有改了下 但结果不对,是算32位无符号数乘法,高手帮我看下
count equ 2
data  segment
str1  db  0dh,0ah,'please enter the multipicand: $'
str2  db  0dh,0ah,'please enter the multiplier: $'
str3  db  0dh,0ah,'the product  is: $'
mcand dw  2 dup (?)
mcato dw  2 dup (?)
prot  dw  4 dup (?)      ;
data  ends
sstack segment stack
      db 100 dup(?)
sstack ends
code  segment 
      assume cs:code,ds:data,es:data,ss:sstack
main  proc far
start:push ds
      xor  ax,ax         
      push ax            ;chushihua ax
      mov  ax,data
      mov  ds,ax
      mov  es,ax         ;

      mov  ah,09
      lea  dx,str1
      int  21h              ;shuru str1
      mov  dx,offset mcand
      mov  si,dx
      mov  [si],byte ptr 9  ;gei siyigerongliangweijiudekongjian
      mov  ah,0ah
      int  21h             

      mov  ah,09
      lea  dx,str2
      int  21h
      mov  dx,offset mcato
      mov  bx,dx
      mov  [bx],byte ptr 9
      mov  ah,0ah
      int  21h


      lea  di,prot
      push di
      mov  ax,0
      mov  cx,2*count
      cld
      rep  stosw
      pop  di
      mov  cx,count
exter:push cx
      mov  dx,[bx]
      inc  bx
      inc  bx
      push di
      push si
      mov  cx,count
inter:push cx
      push dx
      lodsw
      mul  dx
      add  [di],ax
      inc  di
      inc  di
      adc  [di],dx
      pop  dx
      pop  cx
      loop inter
      pop  si
      pop  di
      inc  di
      inc  di
      pop  cx
      loop exter

      mov  ah,09
      lea  dx,str3
      int  21h

      mov  bx,offset prot
      mov  al,[di]
      call p1
      inc  di
      inc  di
      mov  al,[di]
      call p1
      inc  di
      inc  di
      mov  al,[di]
      call p1
      inc  di
      inc  di
      mov  al,[di]
      call p1
      inc  di
      inc  di
      mov  al,[di]
      call p1
      inc  di
      inc  di
      mov  al,[di]
      call p1
      inc  di
      inc  di
      mov  al,[di]
      call p1
      inc  di
      inc  di
      mov  al,[di]
      call p1
      ret  
main  endp
   p1 proc
      push cx
      push dx
      push ax
      mov  cl,4
      shr  al,cl    ;xiang you yi 4 wei chu yi 8
      add   al,30h
      cmp  al,3ah
      jb   br1
      add  al,7
  br1:mov  dl,al
      mov  ah,2
      int  21h
      pop  ax
      and  al,0fh
      add   al,30h
      cmp  al,3ah
      jb   br2
      add  al,7
  br2:mov  dl,al
      mov  ah,2
      int  21h
      pop  dx
      pop  cx
      ret
   p1 endp
code  ends
end   start

3 楼


说一下具体有什么要求

4 楼

要求16位乘法指令完成32位无符号数乘法
 要求16进制输入被乘数,乘数,以16进制输出结果```
 
 我算的结果总是不对
 输入的数据好象没有被真正的调用

我来回复

您尚未登录,请登录后再回复。点此登录或注册