这个汇编语言程序需要做什么改变?

时间:2014-04-07 20:16:36

标签: string loops assembly

该程序应该采用一个字符串并以小写格式返回。例如:" HEllO"将返回"你好。"

现在这里是代码,但它以相反的方式工作(较低的是向上):

    .586
.MODEL FLAT

INCLUDE io.h            ; header file for input/output

.STACK 4096

.DATA
prompt1 BYTE    "Enter string", 0
string  BYTE    40 DUP (?)
resultLbl BYTE  "The string is", 0

.CODE
_MainProc PROC
                input   prompt1, string, 40      ; read ASCII characters
                lea     ebx, string
        L2:     cmp byte ptr[ebx], 0
                je end1
                cmp byte ptr[ebx], 'a'
                jl L1
                cmp byte ptr[ebx], 'z'
                jg L1
                sub byte ptr[ebx], 20h
        L1:
                inc ebx
                jmp L2
        end1:
                output resultLbl, string


                mov     eax, 0  ; exit with return code 0
                ret
_MainProc ENDP
END                             ; end of source code

1 个答案:

答案 0 :(得分:1)

没关系,找出自己。只需改变' a'和' z'到' A'和' Z'并告诉程序添加而不是减去字节ptr [ebx],20h'。

相关问题