Please Correct My Code ( Small Model )

Please support our Assembly advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: May 2009
Posts: 5
Reputation: Lamya is an unknown quantity at this point 
Solved Threads: 0
Lamya Lamya is offline Offline
Newbie Poster

Please Correct My Code ( Small Model )

 
0
  #1
May 3rd, 2009
Hello Programmers

This Is My Question & the answer
But .. The out put not exist
i don't know what is the wrong with it

Write a program that will take as an input 5 Capital Letters and then display on next line in small letters and in reverse order.

• Use Logical operator to convert the capital letters to small letters.
• Save the input capital letters in an array named LETTERS.
• Use only indexed addressing mode.



My Answer :






  1. .MODEL SMALL
  2. .STACK 100H
  3.  
  4. .DATA
  5.  
  6. CR EQU 0DH ;Carriage Return
  7. LF EQU 0AH ;Line Feed
  8.  
  9. MSG1 DB CR,LF,'Please Enter Capital letters: $'
  10. MSG2 DB CR,LF,'Small Letters in reverse order: $'
  11. LETTERS DB ?
  12.  
  13. .CODE
  14.  
  15. MAIN PROC
  16.  
  17. MOV AX,@DATA ;get data segment
  18. MOV DS,AX ;initialize DS
  19.  
  20.  
  21. ;Display MSG1
  22.  
  23. LEA DX,MSG1 ;load address of MSG1 message
  24. MOV AH,9 ;select string output
  25. INT 21H ;output MSG
  26.  
  27. ;Read the input from the user
  28.  
  29. AND LETTERS,0H
  30. MOV AH,1
  31. MOV CL,5
  32.  
  33. WHILE_:
  34.  
  35. INT 21H
  36. MOV LETTERS,AL
  37. DEC CL
  38. JCXZ PRO_
  39. CMP AL,0DH
  40. JNE WHILE_
  41.  
  42. PRO_:
  43. XOR SI,SI
  44. ARR:
  45. CMP LETTERS[SI],' '
  46. JE NEXT
  47. XOR LETTERS[SI],0DFH
  48.  
  49. NEXT:
  50. DEC SI
  51. LOOP ARR
  52.  
  53. ;Display MSG2
  54.  
  55. LEA DX,MSG2 ;load address of MSG2 message
  56. MOV AH,9 ;select string output
  57. INT 21H ;output MSG
  58.  
  59.  
  60. MOV AH,9
  61. LEA SI,LETTERS
  62.  
  63. READ:
  64.  
  65. INT 21H
  66. ADD SI,2 ; IN CASE IT IS 2
  67. LOOP READ
  68.  
  69.  
  70. EXIT:
  71. MOV AH,4CH ;DOS exit
  72. INT 21H
  73.  
  74. MAIN ENDP ;ENDP ends a procedure
  75. END MAIN ;END ends the source program



Correct it please , & that is very Kind of you
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 5
Reputation: Lamya is an unknown quantity at this point 
Solved Threads: 0
Lamya Lamya is offline Offline
Newbie Poster

Re: Please Correct My Code ( Small Model )

 
0
  #2
May 3rd, 2009
The OutPut Should Be :

Please Enter Capital letters: ABCDE
Small Letters in reverse order: edcba
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 39
Reputation: sysop_fb is an unknown quantity at this point 
Solved Threads: 5
sysop_fb sysop_fb is offline Offline
Light Poster

Re: Please Correct My Code ( Small Model )

 
0
  #3
May 4th, 2009
Originally Posted by Lamya View Post
The OutPut Should Be :

Please Enter Capital letters: ABCDE
Small Letters in reverse order: edcba
You know the difference between an upper and lower case character?
20h
You know the difference between the binary of an upper and lower case character?
1 bit.
Consider the following
E - 01000101
e - 01100101

A - 1000001
a - 1100001
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 5
Reputation: Lamya is an unknown quantity at this point 
Solved Threads: 0
Lamya Lamya is offline Offline
Newbie Poster

Re: Please Correct My Code ( Small Model )

 
0
  #4
May 4th, 2009
I know that , but i dont know how to make the loop in reverse order.
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 5
Reputation: Lamya is an unknown quantity at this point 
Solved Threads: 0
Lamya Lamya is offline Offline
Newbie Poster

Re: Please Correct My Code ( Small Model )

 
0
  #5
May 4th, 2009
Help !! Guys !!
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 39
Reputation: sysop_fb is an unknown quantity at this point 
Solved Threads: 5
sysop_fb sysop_fb is offline Offline
Light Poster

Re: Please Correct My Code ( Small Model )

 
0
  #6
May 4th, 2009
Originally Posted by Lamya View Post
I know that , but i dont know how to make the loop in reverse order.
In an array of chars as such
ABCDEF
You access the 'A' via base address + 0 so you access the F via base address + 5
Then we load up our new array.
so...
new_array+0 = (user_input+5 with altered bit)
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 5
Reputation: Lamya is an unknown quantity at this point 
Solved Threads: 0
Lamya Lamya is offline Offline
Newbie Poster

Re: Please Correct My Code ( Small Model )

 
0
  #7
May 4th, 2009
Ooooh, Thanks Alot
you are soo kind..
that helps me
I will try it now ..
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC