DATAS SEGMENT
w dw 0
keybuf db 255
db 0
db 255 dup(0) ;定义键盘输入需要的缓冲区
DATAS ENDS
STACKS SEGMENT
db 200 dup(?)
STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS
START:
MOV AX,DATAS
MOV DS,AX
mov dx,offset keybuf ;用0a号功能,输入一个字符串
mov ah,0ah ;用回车结束
int 21h
mov dl,0ah ;再进行换行,以便在下一行显示转换后的字符串
mov ah,2
int 21h
; push ax
; push dx
; mov dl,cl
; mov ah,02
; int 21h
; pop dx
; pop ax
mov bx,offset keybuf+1 ;取出字符串的字符个数,作为循环的次数
mov cl,[bx]
mov ch,0
mov ax,0
again:
inc bx
mov ax,[w]
push bx
mov bx,16
mul bx
pop bx ;是小写字母,则转换为大写字母
mov [w],ax
mov dl,[bx] ;取出一个字符,
cmp dl,'9'
jbe lab1
cmp dl,'F'
jbe Lab2
sub dl,32
Lab2: sub dl ,07h
lab1: sub dl,30h
add [w],dx
loop again
mov ax,[w]
mov bx,-1
push bx
mov bx,10
lab3 :mov dx,0
div bx
push dx
cmp ax,0
jnz lab3
lab5: pop dx
cmp dx,-1
jz lab4
add dl,30h
mov ah,02
int 21h
jmp lab5 ;循环,处理完整个字符串
lab4: MOV AH,4CH
INT 21H
CODES ENDS
END START
标签:
汇编
上传时间:
2015-04-02
上传用户:wcc0310