Welcome to Dream.In.Code
Getting Help is Easy!

Join 136,577 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,890 people online right now. Registration is fast and FREE... Join Now!




hi,, im reign

 
Reply to this topicStart new topic

hi,, im reign

reign
4 Oct, 2008 - 07:52 PM
Post #1

New D.I.C Head
*

Joined: 4 Oct, 2008
Posts: 3

can you help me with this code

CODE

.MODEL SMALL
.STACK 100h
.DATA

MAXIMUM_STRING_LENGTH  EQU  1000

StringToReverse       DB      'Type a string: $'    ;MAXIMUM_STRING_LENGTH DUP(?)

ReverseString        DB      13,10,'Result: $'    ;MAXIMUM_STRING_LENGTH DUP(?)

.CODE
       mov  ax,@data
       mov  ds,ax                     ;set DS to point to the data segment
       mov  ah,3fh                     ;DOS read from handle function #
       mov  bx,0                                ;standard input handle
       mov  dx,OFFSET StringToReverse      ;store the string here
       mov  cx,MAXIMUM_STRING_LENGTH   ;read up to maximum number of characters
    
       int  21h                            ;get the string
       and  ax,ax                               ;were any characters read?
       jz   Done                             ;no, so you're done
       mov  cx,ax                                      ;put string length in CX, where
                                                     ; you can use it as a counter
       push cx                               ;save the string length
       mov  bx,OFFSET StringToReverse
       mov  si,OFFSET ReverseString
       add  si,cx
       dec  si                                       ;point to the end of the
                                                    ; reverse string buffer
ReverseLoop:

       mov  al,[bx]                        ;get the next character
       mov  [si],al                                   ;store the characters in reverse order
       inc  bx                                         ;point to next character
       dec  si                                         ;point to previous location in reverse buffer
       loop ReverseLoop                                ;move next character, if any
       pop  cx                                              ;get back the string length
       mov  ah,40h                                         ;DOS write from handle function #
       mov  bx,1                                            ;standard output handle
      
     mov  dx,OFFSET ReverseString                  ;print this string
       int  21h                                             ;print the reversed string

Done:
       mov  ah,4ch                                     ;DOS terminate program function #
       int  21h                                      ;terminate the program

END



it should display the reverse of the inputted string

** Edit ** code.gif
User is offlineProfile CardPM
+Quote Post

no2pencil
RE: Hi,, Im Reign
4 Oct, 2008 - 07:54 PM
Post #2

My fridge be runnin OH NOEZ!
Group Icon

Joined: 10 May, 2007
Posts: 6,465



Thanked: 66 times
Dream Kudos: 2425
Expert In: Goofing Off

My Contributions
Is it giving you errors?
Does it assemble, but not perform the desired function?
Please use code tags
Please post in the correct topic (other languages) & not in "introduce yourself"

** Topic Moved **
User is offlineProfile CardPM
+Quote Post

reign
RE: Hi,, Im Reign
4 Oct, 2008 - 08:14 PM
Post #3

New D.I.C Head
*

Joined: 4 Oct, 2008
Posts: 3

QUOTE(reign @ 4 Oct, 2008 - 08:52 PM) *

can you help me with this code

CODE

.MODEL SMALL
.STACK 100h
.DATA

MAXIMUM_STRING_LENGTH  EQU  1000

StringToReverse       DB      'Type a string: $';MAXIMUM_STRING_LENGTH DUP(?)

ReverseString        DB      13,10,'Result: $';MAXIMUM_STRING_LENGTH DUP(?)

.CODE
       mov  ax,@data
       mov  ds,ax                    ;set DS to point to the data segment
       mov  ah,3fh                    ;DOS read from handle function #
       mov  bx,0                            ;standard input handle
       mov  dx,OFFSET StringToReverse     ;store the string here
       mov  cx,MAXIMUM_STRING_LENGTH  ;read up to maximum number of characters
    
       int  21h                           ;get the string
       and  ax,ax                              ;were any characters read?
       jz   Done                            ;no, so you're done
       mov  cx,ax                                     ;put string length in CX, where
                                                    ; you can use it as a counter
       push cx                           ;save the string length
       mov  bx,OFFSET StringToReverse
       mov  si,OFFSET ReverseString
       add  si,cx
       dec  si                                      ;point to the end of the
                                                ; reverse string buffer
ReverseLoop:

       mov  al,[bx]                    ;get the next character
       mov  [si],al                               ;store the characters in reverse order
       inc  bx                                     ;point to next character
       dec  si                                     ;point to previous location in reverse buffer
       loop ReverseLoop                            ;move next character, if any
       pop  cx                                             ;get back the string length
       mov  ah,40h                                     ;DOS write from handle function #
       mov  bx,1                                        ;standard output handle
      
     mov  dx,OFFSET ReverseString                 ;print this string
       int  21h                                         ;print the reversed string

Done:
       mov  ah,4ch                                    ;DOS terminate program function #
       int  21h                                     ;terminate the program

END



it should display the reverse of the inputted string

** Edit ** code.gif



ahm no it doesnt give me errors..
It doesnt function in the sense that there's is no display output
when I compile it it is said that there's no error but why there no output on the screen.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/3/08 12:15AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month