⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 111.asm

📁 字处理演示程序 实现书上程序已经有的字处理功能
💻 ASM
字号:
     pos_curse macro op1,op2,op3               ;定义光标位置
         mov ah,2
         mov bh,op1
         mov dh,op2
         mov dl,op3
         int 10h
endm
pos_get  macro                             ;显示光标位置
         mov ah,03h
         mov bh,0
         int 10h
endm
win macro opr1,opr2,opr3,opr4,opr5,opr6    ;建立窗口
         mov ah,06h
         mov al,opr1
         mov bh,opr2
         mov ch,opr3
         mov cl,opr4
         mov dh,opr5
         mov dl,opr6
         int 10h
endm
data     segment
         path     db 50 dup(0),'$'
         buffer   db 2000 dup(?)
         bak      db 3850 dup(0)
         line     db ?                      ;光标行
         row      db ?                      ;光标列
         char     db ?
         hanglie  db '???//???','$'     
data     ends
code     segment                       
main     proc far                           ;主程序
         assume cs:code,ds:data
start:
         push ds
         sub  ax,ax
         push ax
         mov  ax,data
         mov  ds,ax
         call wind                
         call edit                                
         ret
main     endp
wind proc near                               ;创建窗口子程序
         win 0,07h,1,0,24,79                  ;定义窗口背景
         win 0,07h,0,0,0,79
         win 0,07h,24,0,24,79
show1:
         pos_curse  0,1,0
         mov row,dh
         mov line,dl
wind endp
edit proc near
char_get:                             ;读字符
      call com
com proc near                         ;定义功能鍵
        pos_get
        mov  row,dh
        mov  line,dl
new:
        pos_curse 0,row,line
j00:    mov ah,0
        int 16h                      ;从键盘读字符ah=扫描码al=字符码
        push ax
        lea dx,buffer
        mov buffer[bx],al
        inc bx
        cmp  ah,48h                    ;上
        jz   up_1
        cmp  ah,50h                    ;下
        jz   down_1
        cmp  ah,4bh                    ;左
        jz   left
        cmp  ah,4dh                    ;右
        jz   right
        cmp  ah,1ch                    ;回车
        jz   enter_1
        call fuc_key
        mov ah,2
        mov dl,al
        int 21h
        pop ax
        call  menu_show
        jmp   j6
down_1:
        jmp down
enter_1:
        jmp enter_2
up_1:  
        jmp up
left:                                   ;光标左移
        pos_get
        mov row,dh
        mov dl,line
        cmp line,0
        jnz direct
        mov line,79
        dec row
        cmp row,0
        je  stop2                                            
        jmp new
stop2: 
        mov row,1
        jmp new
direct:   
        dec line
        call show                     ;显示光标位置
        jmp new
right:                                ;光标右移
        pos_get
        mov row,dh
        mov dl,line
        cmp line,79
        jnz direct2
        mov line,0
        inc row
        cmp row,24
        je  returns1       
        jmp new
direct2:
        inc  line
        call show
        jmp new
enter_2:
        jmp enter
up:                                 ;上移光标
        pos_get
        mov row,dh
        mov dl,line
        dec row
        cmp row,0
        je  stop1
        call show
        jmp new
stop1:  
        mov row,1
        jmp new
down:                                ;下移光标
        pos_get
        mov row,dh
        mov dl,line   
        inc row
        cmp row,24
        je  stop3
        call show
        jmp new
stop3:  
        mov row,23
        jmp new
returns1:
        jmp returns
enter:                               ;回车换行
        pos_get
        mov row,dh
        mov line,dl
        inc row
        cmp row,24
        je  returns
        mov line,0
        call show
        jmp new
returns:
        mov row,24
     mov line,0
     jmp new
j6:     
        ret
com     endp
ins:                                ;插入功能
        pos_get
        mov row,dh
       mov line,dl
        dec line
        pos_get 0,row,line
        mov ah,2
        mov dl,00
        int 21h
       inc line
        call show
        jmp new
im:     
        cmp line,00
       jz  pos_im
pos_im:
        pos_curse 0,0,0
        jmp new
fuc_key proc near                 ;功能键子程序  
 next:  
        cmp ah,53h                ;delete键
        jz  del
        ret
clear:  call cle
del:                                ;DEL删除
        pos_get
        mov row,dh
        mov line,dl
        dec line
        pos_get 0,row,line
        mov ah,2
        mov dl,00
        int 21h
        inc line
        call show
        jmp new
cm:     
        cmp line,00
        jz  pos_cm
pos_cm:
        pos_curse 0,0,0
        jmp new
cle   proc  near
      call savedisplay               ; 
      pos_get
      pos_curse 0,dh,dl
      mov  ah,0
      int  16h
      cmp  ah,36h                      
      jnz  cls
cls:  
      win 0,1eh,9,10,13,70            ;清屏
      call backdisplay
cle   endp
fuc_key endp
menu_show proc near                     
        call savedisplay
        push cx
        jmp char_get
menu_show endp
savedisplay proc near
        push ax
        push bx
        push cx
        push dx
        push ds
        mov ax,0002h
        int 33h
        mov bx,0d
        mov cx,3840d
loop1:
        mov ax,0b800h
        mov ds,ax
        mov dl,ds:[bx]
        mov ax,data
        mov ds,ax
        mov bak[bx],dl
        inc bx
        loop loop1
        mov ax,0001h
        int 33h
        pop ds
        pop dx
        pop cx
        pop bx
        pop ax
savedisplay endp
backdisplay proc near
        push ax
        push bx
        push cx
        push dx
        push ds
        mov bx,0d
        mov cx,3840d
loop11:
        mov ax,data
        mov ds,ax
        mov dl,bak[bx]
        mov ax,0b800h
        mov ds,ax
        mov ds:[bx],dl
        inc bx
        loop loop11
        pop ds
        pop dx
        pop cx
        pop bx
        pop ax
        ret
backdisplay endp
edit   endp
show    proc  near                             ;显示光标 
        mov ah,03h
        mov bh,0
        int 10h                                    
        mov  bl,100d
        mov  bh,10d
        mov  ax,0
        mov  al,dh
        div bl 
        add  al,30h                              
        mov  [hanglie+0],al
        mov al,ah      
        mov ah,0                                    
        div bh  
        add ax,3030h
        mov [hanglie+1],al
        mov [hanglie+2],ah                                                      
        mov  ax,0                                       
        mov  al,dl
        div bl 
        add  al,30h                            
        mov  [hanglie+5],al
        mov al,ah      
        mov ah,0                                  
        div bh  
        add ax,3030h
        mov [hanglie+6],al
        mov [hanglie+7],ah
        pos_curse 0,24,61
        mov  dx,offset hanglie
        mov  ah,09h
        int  21h
        ret
show    endp
code    ends                           
        end start                          ;结束

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -