Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums

Go Back   Code Forums > Application and Web Development > Assembly

Reply
 
LinkBack Thread Tools Display Modes
Old 05-03-2009, 02:18 PM   #1 (permalink)
Lamya
Recruit
 
Lamya's Avatar
 
Join Date: May 2009
Location: KSA
Posts: 2
Lamya is on a distinguished road
Question Please Correct My Code ( Small Model )


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 :





.MODEL SMALL
.STACK 100H

.DATA

CR EQU 0DH ;Carriage Return
LF EQU 0AH ;Line Feed

MSG1 DB CR,LF,'Please Enter Capital letters: $'
MSG2 DB CR,LF,'Small Letters in reverse order: $'
LETTERS DB ?

.CODE

MAIN PROC

MOV AX,@DATA ;get data segment
MOV DS,AX ;initialize DS


;Display MSG1

LEA DX,MSG1 ;load address of MSG1 message
MOV AH,9 ;select string output
INT 21H ;output MSG

;Read the input from the user

;AND LETTERS,0H
MOV AH,1
MOV CL,5

WHILE_:

INT 21H
MOV LETTERS,AL
DEC CL
JCXZ PRO_
CMP AL,0DH
JNE WHILE_

PRO_:
XOR SI,SI
ARR:
CMP LETTERS[SI],' '
JE NEXT
XOR LETTERS[SI],0DFH

NEXT:
DEC SI
LOOP ARR

;Display MSG2

LEA DX,MSG2 ;load address of MSG2 message
MOV AH,9 ;select string output
INT 21H ;output MSG


MOV AH,9
LEA SI,LETTERS

READ:

INT 21H
ADD SI,2 ; IN CASE IT IS 2
LOOP READ


EXIT:
MOV AH,4CH ;DOS exit
INT 21H

MAIN ENDP ;ENDP ends a procedure
END MAIN ;END ends the source program





Lamya is offline   Reply With Quote
Old 05-03-2009, 02:59 PM   #2 (permalink)
Lamya
Recruit
 
Lamya's Avatar
 
Join Date: May 2009
Location: KSA
Posts: 2
Lamya is on a distinguished road
The OutPut Should Be :

Please Enter Capital letters: ABCDE
Small Letters in reverse order: edcba
Lamya is offline   Reply With Quote
Old 06-03-2009, 08:51 PM   #3 (permalink)
Trep
Recruit
 
Join Date: Jun 2009
Posts: 3
Trep is on a distinguished road
Going from capital to lowercase and back to capital is as easy as subtracting or adding the difference in ascii values. Check an ascii table
Trep is offline   Reply With Quote
Old 08-07-2009, 03:27 AM   #4 (permalink)
TheDevilsFather
Recruit
 
TheDevilsFather's Avatar
 
Join Date: Aug 2009
Posts: 7
TheDevilsFather is on a distinguished road
I am tired .. i might come back and do it all complete ..but here is a test so you can see ..how to get it done ..

Code:

mov   AL , ARRAY_OF_CHAR   
sub    AH, AH 

LOOP:

cmp  BYTE [AL+AH] , 0 
je      REVERSE_STRING

add  [AL+AH] , 20H
add  AH, 4 
inc    CL 
jmp   LOOP

REVERSE_STRING:

dec  CL 
sub  AH, 4 

PUTCHAR [AL+AH]

cmp BYTE CL , 0
je     DONE 

jmp  REVERSE_STRING

Hope it helps




[/code]
TheDevilsFather is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
using correct path in open function mike_cana Standard C, C++ 2 10-25-2004 07:06 PM
what happens when the OO model makes things too slow? sde Java 3 10-06-2004 07:42 AM
[mfp] Model-View-Controller DavH27 Program Design and Methods 4 08-17-2004 12:44 PM
Applications for a small Linux server for a small business.... Admin Linux / BSD / OS X 4 07-04-2004 05:16 PM
Would you mind if there were small flash elements at code newbie? sde Lounge 10 05-29-2004 10:05 PM


All times are GMT -8. The time now is 08:02 PM.


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0 RC8 ©2007, Crawlability, Inc.





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting