组装开关小写字母用于大写字母,反之亦然 [英] Assembler switch lower case for upper case and vice versa

查看:122
本文介绍了组装开关小写字母用于大写字母,反之亦然的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创建一个汇编程序,同时将大写字母更改为小写字母,反之亦然.

im trying to do an Assembler program, that change the upper cases for lower cases and vice versa, all at the same time.

例如:
输入为:您好,这是一个示例.

我想要

输出为:hELLO,这是一个示例.

我所能获得的只是将字符串更改为大写,即时消息我知道使用汇编程序8086和Microsoft宏汇编程序(MASM).

all i have get is to change the string to Uppercase only, im using Assembler 8086 and Microsoft Macro Assembler (MASM) as far i know.

谢谢!

这是我的代码

    stackseg segment para stack 'stack'
    db 32 dup (' ')
stackseg ends

datasgmt segment para 'data'
    show db 'write here:','$'
    ln db 0
    gv db 35
    savedata db 35 dup(' '),'$'
rg db 1
    db (' ')
    db (' ')
datasgmt ends

codepos segment para 'code'
    start proc far
    assume cs:codepos,ss:stackseg,ds:datasgmt
push ds
xor ax,ax
push ax
mov ax,datasgmt
mov ds,ax

mov ch,0
mov cl,0
mov dh,24d
mov dl,79d
mov bh,07
mov al,0
mov ah,06
int 10h

mov ah,02
mov dh,5
mov dl,7
mov bh,0
int 10h

lea dx, show
mov ah,09h
int 21h

mov ah,02
mov dh,6
mov dl,7
mov bh,0
int 10h

lea dx,gv
mov ah,0ah
int 21h

lea si,savedata
mov bh,00
mov bl,ln
mov savedata[bx],07h

lea si, savedata

startagain: cmp byte ptr[si],61h
    jb dont
    cmp byte ptr[si],7ah
    ja dont
    sub byte ptr[si],20h
    jb dont
    dont:inc si
    cmp byte ptr[si],0dh
    jne startagain

mov ah,02
mov dh,8
mov dl,19
mov bh,0
int 10h

mov ah,09    
lea dx, savedata
int 21h

lea dx,rg
mov ah,0ah
int 21h

ret
start endp
codepos ends
end start

推荐答案

更改:

startagain: cmp byte ptr[si],61h
    jb dont
    cmp byte ptr[si],7ah
    ja dont
    sub byte ptr[si],20h
    jb dont
    dont:inc si
    cmp byte ptr[si],0dh
    jne startagain

具有:

startagain: cmp byte ptr[si],61h
    jb dont
    cmp byte ptr[si],7ah
    ja dont
    sub byte ptr[si],20h
    jmp dont2
 dont:   
    cmp byte ptr[si],41h
    jb dont2
    cmp byte ptr[si],5ah
    ja dont2
    add byte ptr[si],20h

dont2:
    inc si
    cmp byte ptr[si],0dh
    jne startagain

这篇关于组装开关小写字母用于大写字母,反之亦然的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆