D
dingyongqi
Unregistered / Unconfirmed
GUEST, unregistred user!
这是我的课程设计要求:
1。编写一个具体有控制光标上下左右移动字符输入删除功能的简单字处理程序要求使用DOS。BIOS调用。
2。通过该课程设计熟悉操作系统功能调用进一步了解汇编语言控制计算机硬件的方法提高汇编语言应用程序的设计能力!
源程序如下:
dseg segment
kdb_buf db 96 dup('')
cntl db 16 dup('')
bufpt dw 0
buftl dw 0
colpt db 0
rowpt db 0
rowmx dw 0
dseg end
curs macro row,col
mov dh,row
mov dl,col
mov bh,0
mov ah,2
int 10h
endp
cseg segment
main proc far
assume cs:cseg,ds:dseg,es:dseg
start:
push ds
sub ax,ax
push ax
mov ax,dseg
mov ds,ax
mov es,ax
mov buftl,0
mov colpt,0
mov rowpt,0
mov bufpt,0
mov rowmx,0
mov cx,length cntl
mov al,0
lea di,cntl
cld
rep stosb
mov ah,6
mov al,0
mov cx,0
mov dh,24
mov dl,79
mov bh,07
int 10h
curs 0,0
read_k:
mov ah,0
int 16h
cmp al,lbh
jnz arrow
ret
arrow:
cmp ah,4bh
jz left
cmp ah,4dh
jz right
cmp ah,48h
jz up
cmp ah,50h
jz do
wn
cmp ah,53h
jz del
inst: jmp ins_k
left: jmp left_k
right: jmp right_k
up: jmp up_k
down: jmp do
wn_k
del: jmp del_k
ins_k:
mov bx,bufpt
mov cx,buftl
cmp bx,cx
je km
lea di,kbd_buf
add di,cx
mov si,di
dec si
sub cx,bx
std
rep movsb
km:
mov kbd_buf[bx],al
inc bufpt
inc buftl
cmp al,0dh
jnz kn
lea si,cntl
add si,rowmx
inc si
mov di,si
inc di
mov cx,rowmx
sub cl,rowpt
std
rep movsb
mov bl,rowpt
xor bh,bh
mov cl.colpt
mov ch,cntl[bx]
sub ch,colpt
mov cntl[bx].cl
mov cntl[bx+1],ch
mov ax,rowmx
mov bh,07
mov ch,rowpt
mov dh,24
mov cl,0
mov dl,79
mov ah,6
int 10h
inc rowpt
inc rowmx
mov colpt,0
jmp short kp
kn:
mov bl,rowpt
xor bh,bh
inc ctnl[bx]
inc colpt
kp:
call dispbf
curs rowpt,colpt
jmp read_k
left_k:
cmp colpt,0
jnz k2
cmp rowpt,0
jz lret
dec rowpt
mov al,rowpt
lea bx,cntl
xlat cntl
mov colpt,al
jmp k3
k2: dec colpt
k3: dec bufpt
curs rowpt,colpt
lret: jmp read_k
right_k:
mov bx,bufpt
cmp bx,buftl
je rret
inc colpt
cmp kbd_buf[bx],0dh
jnz k4
inc rowpt
mov colpt,0
k4: inc bufpt
curs rowpt,colpt
rret: jmp read_k
up_k:
cmp rowpt,0
je uret
dec rowpt
mov bl,rowpt
xor bh,bh
mov al,cntl[bx]
cmp al,colpt
jnz ll
mov cl,colpt
xor ch,ch
sub bufpt,cx
mov colpt,al
jmp 12
ll: xor ah,ah
sub bufpt
l2: dec bufpt
curs rowpt,colpt
down_k:
mov al,rowpt
xor ah,ah
cmp ax,rowmx
jz dret
inc rowpt
mov bl,rowpt
xor bh,bh
mov al,cotl[bx]
cmp al,colpt
jnz l3
mov cl,colpt
xor ch,ch
sub bufpt,cx
mov colpt,al
dec bx
mov dl,cntl[bx]
xor dh,dh
xor ah,ah
add bufpt,ax
adc bufpt,dx
jmp l4
l3: dec bx
mov cl,cntl[bx]
xor ch,ch
add bufpt
l4: inc bufpt
curs rowpt,colpt
disp mov al,kbd_buf[bx]
push bx
mov bx,0700
mov ah,0eh
int 10h
pop bx
cmp al,0dh
jnz kk
mov al,0ah
mov ah,0eh
int 10h
kk: inc bx
loop disp
ret
dispbf endp
main endp
cseg ends
end start
1。编写一个具体有控制光标上下左右移动字符输入删除功能的简单字处理程序要求使用DOS。BIOS调用。
2。通过该课程设计熟悉操作系统功能调用进一步了解汇编语言控制计算机硬件的方法提高汇编语言应用程序的设计能力!
源程序如下:
dseg segment
kdb_buf db 96 dup('')
cntl db 16 dup('')
bufpt dw 0
buftl dw 0
colpt db 0
rowpt db 0
rowmx dw 0
dseg end
curs macro row,col
mov dh,row
mov dl,col
mov bh,0
mov ah,2
int 10h
endp
cseg segment
main proc far
assume cs:cseg,ds:dseg,es:dseg
start:
push ds
sub ax,ax
push ax
mov ax,dseg
mov ds,ax
mov es,ax
mov buftl,0
mov colpt,0
mov rowpt,0
mov bufpt,0
mov rowmx,0
mov cx,length cntl
mov al,0
lea di,cntl
cld
rep stosb
mov ah,6
mov al,0
mov cx,0
mov dh,24
mov dl,79
mov bh,07
int 10h
curs 0,0
read_k:
mov ah,0
int 16h
cmp al,lbh
jnz arrow
ret
arrow:
cmp ah,4bh
jz left
cmp ah,4dh
jz right
cmp ah,48h
jz up
cmp ah,50h
jz do
wn
cmp ah,53h
jz del
inst: jmp ins_k
left: jmp left_k
right: jmp right_k
up: jmp up_k
down: jmp do
wn_k
del: jmp del_k
ins_k:
mov bx,bufpt
mov cx,buftl
cmp bx,cx
je km
lea di,kbd_buf
add di,cx
mov si,di
dec si
sub cx,bx
std
rep movsb
km:
mov kbd_buf[bx],al
inc bufpt
inc buftl
cmp al,0dh
jnz kn
lea si,cntl
add si,rowmx
inc si
mov di,si
inc di
mov cx,rowmx
sub cl,rowpt
std
rep movsb
mov bl,rowpt
xor bh,bh
mov cl.colpt
mov ch,cntl[bx]
sub ch,colpt
mov cntl[bx].cl
mov cntl[bx+1],ch
mov ax,rowmx
mov bh,07
mov ch,rowpt
mov dh,24
mov cl,0
mov dl,79
mov ah,6
int 10h
inc rowpt
inc rowmx
mov colpt,0
jmp short kp
kn:
mov bl,rowpt
xor bh,bh
inc ctnl[bx]
inc colpt
kp:
call dispbf
curs rowpt,colpt
jmp read_k
left_k:
cmp colpt,0
jnz k2
cmp rowpt,0
jz lret
dec rowpt
mov al,rowpt
lea bx,cntl
xlat cntl
mov colpt,al
jmp k3
k2: dec colpt
k3: dec bufpt
curs rowpt,colpt
lret: jmp read_k
right_k:
mov bx,bufpt
cmp bx,buftl
je rret
inc colpt
cmp kbd_buf[bx],0dh
jnz k4
inc rowpt
mov colpt,0
k4: inc bufpt
curs rowpt,colpt
rret: jmp read_k
up_k:
cmp rowpt,0
je uret
dec rowpt
mov bl,rowpt
xor bh,bh
mov al,cntl[bx]
cmp al,colpt
jnz ll
mov cl,colpt
xor ch,ch
sub bufpt,cx
mov colpt,al
jmp 12
ll: xor ah,ah
sub bufpt
l2: dec bufpt
curs rowpt,colpt
down_k:
mov al,rowpt
xor ah,ah
cmp ax,rowmx
jz dret
inc rowpt
mov bl,rowpt
xor bh,bh
mov al,cotl[bx]
cmp al,colpt
jnz l3
mov cl,colpt
xor ch,ch
sub bufpt,cx
mov colpt,al
dec bx
mov dl,cntl[bx]
xor dh,dh
xor ah,ah
add bufpt,ax
adc bufpt,dx
jmp l4
l3: dec bx
mov cl,cntl[bx]
xor ch,ch
add bufpt
l4: inc bufpt
curs rowpt,colpt
disp mov al,kbd_buf[bx]
push bx
mov bx,0700
mov ah,0eh
int 10h
pop bx
cmp al,0dh
jnz kk
mov al,0ah
mov ah,0eh
int 10h
kk: inc bx
loop disp
ret
dispbf endp
main endp
cseg ends
end start