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

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




tasm

 
Reply to this topicStart new topic

tasm

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

New D.I.C Head
*

Joined: 4 Oct, 2008
Posts: 3

CODE


.MODEL SMALL[code]
.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




why was i dont have any ouput when I run or compile this program yet when i chck it, it has no errors?
the program should reverse an inputted string

This post has been edited by reign: 4 Oct, 2008 - 07:42 PM
User is offlineProfile CardPM
+Quote Post

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

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