1.6循环程序设计

来源:互联网 发布:淘宝开直通车 编辑:程序博客网 时间:2024/05/18 05:57

实验任务:编一程序,显示ASCII码表,将这些字符以16行,16列的表格形式显示出来。要求显示时按ASCII码的递增顺序分行显示(即行内的ASCII码依此递增,与附录D列出的表格位置正好倒置)。每个相邻的两字符间用空白符或空格分开。注:采用的是BIOS调用

代码(测试可用,排版格式问题请自行调整):

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

;This program is created by LiZhuYang(LzySeed) 转载请注明出处;
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

assume cs:code,ss:stack
stack segment
 db 512 dup(?)
stack ends

code segment
   start: mov ax,stack
      mov ss,ax
      mov sp ,512
      mov si,0
      mov bl,23h
      mov cx,256
      sd:mov ah,02h
         push bx
         and bl,00001111b
         add bl,bl
      movdl,bl
      pop bx
      pushbx
      pushcx
      movcl,4
      shrbl,cl
      movdh,bl
      pop cx
      movbh,0
      int10h
      pop bx
      movah,0Ah
      pushbx
      moval,bl
      movbh,0
      pushcx
      movcx,1
      int10h
      pop cx
      pop bx
      inc bl
      loop sd
      
      movah,02                ;将光标置到(23,23)以免中断提示覆盖显示的内容

      mov dh,23
      mov dl,23
      mov bh,0
      int 10h
      
         mov ax,4c00h
    int21h
code ends
end start

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

 实验任务二:在CRT上显示九九乘法表。注,采用的是Dos调用

代码:

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;This program is created by LiZhuYnag(LzySeed) 转载请注明出处;
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
assume cs:code,ss:stack
stack segment
 db 512 dup(?)
stack ends

code segment
  start:mov ax,stack
    movss,ax
    movsp,512
    movbl,31h
    movcx,9
   s99:mov si,31h
     push bx
      sub bl,30h
      push cx
      mov cl,bl
      add bl,30h
   s11:movah,02h               
      mov dl,bl
      int 21h
      movah,02h               ;*号
      mov dl,2Ah
      int 21h
      mov dx,si
      mov ah,02h
      int 21h
      movah,02h               ;=号
      mov dl,3dh
      int 21h
         call_16to10             ;调用计算显示程序
         movah,02h               ;空格
         mov dl,00h
         int 21h
         inc si
         loop s11 
         pop cx
         pop bx  
      incbl               
      movah,02h               ;换行
      mov dl,0Ah
      int 21h
      movah,02h               ;回车
      mov dl,0dh
      int 21h
      loop s99
      mov ax,4c00h
      int 21h
  _16to10:pushax                  ;此函数用来显示计算出的值
         push bx
         push cx
         sub bl,30h
         mov al,bl
         mov bx,si
         sub bl,30h
         mul bl
         mov dl,10
         div dl
         add al,30h
         mov dl,al
         push ax
         mov ah,02h
         int 21h
         pop ax
         add ah,30h
         mov dl,ah
         mov ah,02h
         int 21h
        
         pop cx
         pop bx
         pop ax
         ret
code ends
end start

 

0 0