2014-04-07 55 views
-2

該程序應該接受一個字符串並以小寫格式返回。例如:「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

將'a'和'z'更改爲'Z',然後添加20h而不是減去。 –

回答

1

沒關係找出自己。只需將'a'和'z'改爲'A'和'Z',然後告訴程序添加,而不是減去'byte ptr [ebx],20h'。