鱼C论坛

 找回密码
 立即注册
查看: 3657|回复: 1

[汇编作业] 实验16

[复制链接]
发表于 2020-3-20 17:51:02 | 显示全部楼层 |阅读模式

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

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

x
  1. assume cs:code

  2. code segment
  3. start:
  4.                 mov ax,cs
  5.                 mov ds,ax
  6.                 mov si,offset do0
  7.                 mov ax,0
  8.                 mov es,ax
  9.                 mov di,200h                ;将do0写到0:200处
  10.                 mov cx,offset do0end-offset do0
  11.                 cld
  12.                 rep movsb
  13.                
  14.                 ;设置中断向量表
  15.                 mov ax,0                                       
  16.                 mov es,ax                                                ;将es指向中断向量表
  17.                 mov word ptr es:[7ch*4],200h        ;发生7ch中断时跳转到0:200处执行
  18.                 mov word ptr es:[7ch*4+2],0
  19.                
  20.                 mov ax,4c00h
  21.                 int 21h
  22.                
  23.                
  24. ;(1)清屏
  25. ;(2)设置前景色
  26. ;(3)设置背景色
  27. ;(4)向上滚动一行               
  28. ;参数:
  29. ;ah:功能号,0清屏,1设置前景色,2设置背景色,3向上滚动一行
  30. ;针对1,2号功能,用al传递颜色值,0<=al<=7
  31. do0:        jmp short set
  32. table: dw 200h+offset sub1-offset do0,200h+offset sub2-offset do0,200h+offset sub3-offset do0,200h+offset sub4-offset do0

  33. set:       
  34.                 cmp ah,3
  35.                 ja sret
  36.                
  37.                 push es
  38.                 push si
  39.                 push ax
  40.                 push cx
  41.                 push bx
  42.                 push di
  43.                
  44.                 mov cx,0B800H
  45.                 mov es,cx
  46.                 mov si,0       
  47.                 add ah,ah                                        ;word两字节,ah*2
  48.                 mov cx,0
  49.                 mov cl,ah
  50.                 mov bx,200h+offset table-offset do0
  51.                 add bx,cx
  52.                 call word ptr cs:[bx]                ;调用对应的功能子程序
  53.                
  54.                 pop di
  55.                 pop bx
  56.                 pop cx
  57.                 pop ax
  58.                 pop si
  59.                 pop es
  60.                
  61. sret:        iret
  62.                
  63. sub1:
  64.                 mov ax,0020H        ;' '               
  65.                 mov cx,80*25                ;每页80*25个字符
  66.         s0:        mov es:[si],ax
  67.                 add si,2
  68.                 loop s0
  69.                 ret
  70.                
  71. sub2:
  72.                 mov cx,80*25                ;每页80*25个字符
  73.                 cmp al,1
  74.                 jb rsub2
  75.                 cmp al,7
  76.                 ja rsub2
  77.                
  78.         s1:       
  79.                 mov bh,es:[si+1]
  80.                 and bh,11111000b        ;前景色清零
  81.                 or bh,al
  82.                 mov es:[si+1],bh
  83.                 add si,2
  84.                 loop s1
  85. rsub2:        ret
  86.                
  87. sub3:
  88.                 mov cx,80*25                ;每页80*25个字符
  89.                 cmp al,1
  90.                 jb rsub3
  91.                 cmp al,7
  92.                 ja rsub3
  93.                 shl al,1
  94.                 shl al,1
  95.                 shl al,1
  96.                 shl al,1
  97.                
  98.         s2:       
  99.                 mov bh,es:[si+1]
  100.                 and bh,10001111b        ;被景色清零

  101.                 or bh,al
  102.                 mov es:[si+1],bh
  103.                 add si,2
  104.                 loop s2
  105. rsub3:        ret

  106. sub4:
  107.                 mov cx,80*24       
  108.                 mov di,160
  109.         s3:       
  110.                 mov ax,es:[di]
  111.                 mov es:[si],ax
  112.                 add si,2
  113.                 add di,2
  114.                 loop s3
  115.                
  116.                 mov cx,80                        ;清空最后一行
  117.                 mov bh,20H
  118.         s4:        mov es:[si],bh
  119.                 add si,2
  120.                 loop s4
  121.                 ret

  122. do0end: nop               

  123. code ends
  124. end start
复制代码


心情不太好,感觉有点乱糟糟的,懒得改了
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2020-3-20 17:51:43 | 显示全部楼层
测试程序

  1. assume cs:code

  2. code segment
  3. start:
  4.                 ;设置前景色为2  ok
  5.                 mov al,2
  6.                 mov ah,1
  7.                 int 7ch
  8.                 call delay
  9.                 ;设置背景色 4
  10.                 mov al,4
  11.                 mov ah,2
  12.                 int 7ch
  13.                 call delay       
  14.                
  15.                 ;向上滚动一行
  16.                 mov ah,3
  17.                 int 7ch
  18.                 call delay
  19.                
  20.                 ;清屏
  21.                 mov ah,0
  22.                 int 7ch
  23.                 call delay

  24.                
  25.                 mov ax,4c00h
  26.                 int 21h
  27.        
  28.        
  29.        
  30. delay:        push ax
  31.                 push dx
  32.                 mov dx,10h
  33.                 mov ax,0
  34.                
  35. s1:                sub ax,1
  36.                 sbb dx,0
  37.                 jne s1
  38.                
  39.                 cmp dx,0
  40.                 jne s1
  41.                 pop dx
  42.                 pop ax
  43.                 ret
  44.        


  45. code ends
  46. end start
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-6-9 09:29

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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