码迷,mamicode.com
首页 > 编程语言 > 详细

汇编语言(王爽 第三版)第十七章字符串的输入

时间:2016-05-30 19:58:53      阅读:332      评论:0      收藏:0      [点我收藏+]

标签:

    assume cs:code
    data segment
    db 128 dup (0)
    data ends
    
    code segment
start:    mov ax,data
    mov ds,ax
    mov dh,24
    mov dl,2
    mov si,0

    call getstr
    mov ax,4c00h
    int 21h

getstr:
    push ax
getstrs:
    mov ah,0
    int 16h
    cmp al,20h
    jb nochar
    mov ah,0
    call charstack
    mov ah,2
    call charstack
    jmp getstrs
nochar:
    cmp ah,0eh
    je backspace
    cmp ah,1ch
    je enter
    jmp getstrs
backspace:
    mov ah,1
    call charstack
    mov ah,2
    call charstack
    jmp getstrs
enter:
    mov al,0
    mov ah,0
    call charstack
    mov ah,2
    call charstack
    pop ax
    ret
    
charstack:
    jmp short charstart
    table     dw charpush,charpop,charshow
    top    dw 0
charstart:
    push bx
    push dx
    push di
    push es
    cmp ah,2
    ja sret
    mov bl,ah
    mov bh,0
    add bx,bx
    jmp word ptr table[bx]

charpush:
    mov bx,top
    mov [si][bx],al
    inc top
    jmp sret
charpop:
    cmp top,0
    je sret
    dec top
    mov bx,top
    mov al,[si][bx]
    jmp sret
charshow:
    mov bx,0b800h
    mov es,bx
    mov al,160
    mov ah,0
    mul dh
    mov di,ax
    add dl,dl
    mov dh,0
    add di,dx
    mov bx,0
charshows:
    cmp bx,top
    jne noempty
    mov byte ptr es:[di], 
    jmp sret
noempty:
    mov al,[si][bx]
    mov es:[di],al
    mov byte ptr es:[di+2], 
    inc bx
    add di,2
    jmp charshows
sret:    pop es
    pop di
    pop dx
    pop bx
    ret
    code ends
    end start

 

汇编语言(王爽 第三版)第十七章字符串的输入

标签:

原文地址:http://www.cnblogs.com/monster-prince/p/5543543.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!