|
楼主 |
发表于 2012-6-1 01:17:43
|
显示全部楼层
最终修改版。。。。求高手解决退格问题
enter macro
push dx
push ax
mov dl,0ah
mov ah,2
int 21h
mov dl,0dh
mov ah,2
int 21h
pop ax
pop dx
endm
assume cs:code,ds:data
data segment
table db 300 dup(0)
pro1 db 13,10,'_________________________________________________',13,10
db 'no more than 20 characters English name.',13,10
db 'For example:',0ah,0dh,'liang xin hui',13,10
db 'XXX',13,10,'XXX',13,10,'......',13,10,'...',13,10
db '.................................................',13,10
db 'Please input:',13,10,'$'
pro2 db '.................................................',13,10
db 'The results are as follows:','$'
cont db '________________________________________________',13,10
db 'Can You Continue(Y/N):','$'
cp dd 50 dup(0)
data ends
code segment
start : mov ax,data
mov ds,ax
call prop1
mov bx,offset table
mov si,0
mov di,0
call enterchar
perp:
dec si
mov dx,si
inc si
mov cx,si
call arrange
call prop2
call putchar
liang:
call Continue
call judge
mov ax,4c00h
int 21h
Continue: enter
mov dx,offset cont
mov ah,9h
int 21h
ret
judge: mov ah,1
int 21h
or al,100000b
cmp al,79h
je clear
cmp al,6eh
je endj
jmp liang
endj: ret
clear: mov bx,offset table
mov cx,300
zero: mov byte ptr [bx],0
inc bx
loop zero
jmp start
enterchar: mov ah,1
int 21h
mov byte ptr [bx],al
cmp al,13
je endchar
mov di,1
inc bx
jmp enterchar
endchar: enter
mov byte ptr [bx],' '
cmp di,0
je perp
inc si
mov ax,si
mov dx,21
mul dx
mov di,0
mov bx,ax
jmp enterchar
arrange: push si
push cx
mov cx,dx
mov si,0
mov di,21
s1: push cx
mov bx,0
mov cx,20
ss1: mov al,table[si+bx]
cmp al, table[di+bx]
ja jiao
jb s2
inc bx
loop ss1
jmp s2
jiao: mov bx,0
mov cx,20
jiao1: mov al,table[si+bx]
xchg al,table[di+bx]
mov table[si+bx],al
inc bx
loop jiao1
s2: add si,21
add di,21
pop cx
loop s1
pop cx
pop si
loop arrange
ret
putchar: mov bx,0
mov di,1
mov cx,si
put1: push cx
push bx
enter
mov bl,10
mov ax,di
div bl
mov bh,ah
add bh,30h
add al,30h
mov dl,al
mov ah,2
int 21h
mov dl,bh
mov ah,2
int 21h
mov dl,3ah
mov ah,2
int 21h
pop bx
mov cx,20
push bx
put2:
mov dl,table[bx]
mov ah,2h
int 21h
inc bx
loop put2
inc di
pop bx
add bx,21
pop cx
loop put1
ret
prop1:
mov dx,offset pro1
mov ah,9h
int 21h
enter
ret
prop2: enter
mov dx,offset pro2
mov ah,9h
int 21h
ret
code ends
end start
|
|