您的位置:自考365 > 复习指导 > 历年试题 > 北大汇编语言程序设计上机题(04年9月15)

北大汇编语言程序设计上机题(04年9月15)

2006-06-20 14:24  北京自考热线 【 】【我要纠错

  输入俩十进制的整数

  1.在进行输入和输出之前必须先显示相应的提示信息;提示信息必须独占一行;输入必须用回车符结束;

  2.判断两数全能整除3,能就输出YSE,否则输出NO.

  3.用二进制输出这俩数的平均数。

  4.用十进制输出俩数的差(较大的减较小的)。

  5.125做了及格,1235良

data segment
     mess1 db 'please input 2 dec number n(0-255):',0ah,0dh,'$'
     mess2 db '(1).whether two nums are all divide 3 exactly: ','$'
     mess3 db '(2).output ave in bin: ','$'
     mess4 db '(3).the differ of two nums is(in dec): ','$'
     mess5 db 'yes!','$'
     mess6 db 'no!','$'
     num1  db ?
     num2  db ?
   nozero  db 0
data ends

code segment
     assume cs:code,ds:data
start:mov ax,data
      mov ds,ax

      lea dx,mess1
      call prompt

      call putindec
      mov num1,bl
      call crlf
      call putindec
      mov num2,bl
      call crlf
      lea dx,mess2
      call prompt
      mov al,num1
      mov ah,0
      mov bh,3
      div bh
      cmp ah,0
      jne tt
      mov al,num2
      mov ah,0
      mov bh,3
      div bh
      cmp ah,0
      jne tt
      lea dx,mess5
      call prompt
      jmp tt1
tt:   lea dx,mess6
      call prompt

tt1:  call crlf
      lea dx,mess3
      call prompt
      mov al,num1
      add al,num2
      mov ah,0
      mov bh,2
      div bh
      mov bl,al
      call putoutbin
      call crlf

      lea dx,mess4
      call prompt
      mov al,num1
      cmp al,num2
      ja kk
      xchg al,num2
kk:   sub al,num2
      mov bl,al
      call putoutdec

exit: mov ah,4ch
      int 21h
prompt proc
       mov ah,9
       int 21h
       ret
prompt endp
crlf   proc
       mov dl,0ah
       mov ah,2
       int 21h
       mov dl,0dh
       mov ah,2
       int 21h
       ret
crlf   endp

whitespace proc
           mov dl,20h
           mov ah,2
           int 21h
           ret
whitespace endp

putindec proc
         push cx
         mov bl,0
ppp:     mov ah,1
         int 21h
         cmp al,0dh
         je putinexit
         sub al,30h
         mov ah,0
         xchg al,bl
         mov bh,10
         mul bh
         xchg al,bl
         add bl,al
         jmp ppp
putinexit:pop cx
          ret
putindec endp

putoutdec proc
          push cx
          mov nozero,0
          mov cl,100
          call main
          mov cl,10
          call main
          mov cl,1
          call main
          cmp nozero,0
          jne ll
          mov dl,30h
          mov ah,2
          int 21h
ll:       pop cx
          ret
main  proc
      mov al,bl
      mov ah,0
      div cl
      mov bl,ah
      mov dl,al
      cmp dl,0
      jne ll1
      cmp nozero,0
      jne ll1
      jmp ll2
ll1:  mov nozero,1
      add dl,30h
      mov ah,2
      int 21h
ll2:  ret
main  endp
putoutdec endp

putoutbin proc
          push cx
          mov nozero,0
          mov cl,8
rr2:      mov dl,0
          test bl,80h
          je rr
          mov nozero,1
          mov dl,1
rr:       cmp nozero,0
          je rr1
          add dl,30h
          mov ah,2
          int 21h
rr1:      shl bl,1
          loop rr2
          pop cx
          ret
putoutbin endp

code ends
     end start

本文转载链接:北大汇编语言程序设计上机题(04年9月15)

分享到:
  • 站内搜索
  • 课程搜索
  • 试题搜索

热门搜索:教材 报名 查分 免考 考试计划