文本编译器(汇编语言实现的)

本文档提供了一个使用MASM编译的文本编辑器源代码,包括读取字符、显示菜单、处理功能键、创建窗口等功能。用户可以自行编译以体验这个基于汇编语言的文本编辑器。
摘要由CSDN通过智能技术生成

这是一个文本编辑器的源码:自己用MASM编译一下,肯定能用

red_chr macro                              ;读取字符宏定义
        mov ah,0
        int 16h
endm
string  macro p1                          ;输入字符光标
        mov ah,9
        lea dx,p1
        int 21h
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
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
data     segment                           ;定义数据段
         menu     db 'File  Edit  Help $'
       
         mass_1   db 'F1 Active file     F10 Active help','$'
         manu_1   db ' New      ',13,10,'$'
         manu_2   db ' Open     ',13,10,'$'
         manu_3   db ' Save     ',13,10,'$'
         manu_4   db ' Save as  ',13,10,'$'
         manu_5   db ' Exit     ','$'
         handle   dw ?
         message1 db ' Please input file name:','$'
         message2 db ' Please input save file name:','$'
         message3 db ' Please input open file name:','$'
         message4 db ' ***The file is not save! Save it now? (Y/N)***: ','$'
         path     db 50 dup(0),'$'
         buffer   db 2000 dup(?)
         bak      db 3850 dup(0)
         line     db ?
         row      db ?
         char     db ?
    help_mas1 db ' welcome use editor! $'       ;帮助内容
    help_mas2 db 'please the first active help! $'
    help_mas3 db 'good lucky!! $'
    help_mas4 db '==========================================================$'
    help_mas5 db 'Press F1 to active file. $'
    help_mas6 db 'You can use DOWN cursor key to choose the fuction $'
    help_mas7 db 'Press F10 to show the help massage.Press Esc To Quit$'
    date  db  'today ??/??/','$'      ;调用日期
    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,3eh,1,0,24,79                 ;定义窗口背景
         win 1,1fh,0,0,0,79
         win 0,1fh,24,0,24,79
show:                        ;显示菜单位置及内容
         pos_curse 0,0,1   
         mov ah,9
         lea dx,menu
         int 21h
show_2:          ;显示状态栏位置及内容
         pos_curse 0,24,1
         mov ah,9
         lea dx,mass_1
         int 21h
         call win3
         call win4
         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
first:
        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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值