設計內容:
本組負責設計一個文本編輯器(EDITOR),我主要編寫光標的移動和清除屏幕模塊,
實現光標的移動和屏幕的清空。
算法思想:
A. 光標移動:
(1) 該程序從鍵盤上操作;
(2) 向上的箭頭,表示光標要向上移動;
(3) 向左的箭頭表示光標要向左移動;
(4) 向下的箭頭表示光標要向下移動;
(5) 向右的箭頭表示光標要向右移動;
該模塊中,當輸入¥時,則退出程序;然后,當以鍵盤輸入箭頭時,就進入循環來辨別箭頭所實現的光標是向左向右還是向上向下
B. 清除屏幕模塊
(1) 鍵盤輸入前要清除屏幕;
(2) 使整個屏幕的底色顯示藍色;
光標移動主要使用循環和子程序調用。子程序中都用到了BIOS 中斷和DOS的功能調用。
編輯過程中的:
這次我們編輯的是一個文本編輯器。 在此次的編寫過程中,我充分的認識到,實踐與理論相結合重要性。以前在學習匯編的過程中,感覺有一些的枯燥,但看這小小的光標在藍色的屏幕上跳動,不盡的想:原來程序與現實距離是這么近。
1. 不足之處:程序編寫的有些復雜。在程序的調試和聯接過程中,出現了一些錯誤,但都及時的解決。
2. 經驗:要加強動手能力,多多的編程,多多的上機。
程序過程如下:
lxx segment
a db ?
han1 dw ?
lxx ends
prognam segment
main proc far
assume cs:prognam,ds:lxx
start:
push ds
mov ax,0
push ax
mov ax,lxx
mov ds,ax
call clen
repea:
mov ah,07h
int 21h
mov a,al
cmp a,$
je en
cmp al,48h ;行減一
jne x1
call y1
jmp repea
x1:
cmp a,4bh ;列減一
jne x2
call y2
jmp repea
x2:
cmp a,50h ;行減一
jne x3
call y3
jmp repea
x3:
cmp a,4dh ;列減一
jne repea
call y4
jmp repea
en:
ret
main endp
;-----------------------------------------------
y1 proc near
push ax
push bx
push dx
mov ah,3
int 10h
mov ah,2 ;行減一
dec dh
int 10h
pop dx
pop bx
pop ax
ret
y1 endp
;----------------------------------------
y2 proc near
push ax
push bx
push dx
mov ah,3
int 10h
mov ah,2
sub dl,2 ;列減一
int 10h
pop dx
pop bx
pop ax
ret
y2 endp
;--------------------------------------
y3 proc near
push ax
push bx
push dx
mov ah,3
int 10h
mov ah,2
inc dh ;行加一
int 10h
pop dx
pop bx
pop ax
ret
y3 endp
;----------------------------------------
y4 proc near
mov ah,3
int 10h
mov ah,2
inc dl ;列加一
int 10h
ret
y4 endp
;----------------------------------------------------
clen proc near
mov dh,1
mov han1,25d
cle:
mov ah,2h
mov dl,0
int 10h
mov ah,09h
mov al,
mov bl,90h
mov bh,0h ;yan se
mov cx,80
int 10h
inc dh
dec han1
cmp han1,01h
jne cle
ret
clen endp
;-------------------------------------
prognam ends
end start