Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

REVERSE STRING PLEASE HELP!!!

singerksingerk Member Posts: 11
Hi. I have been working on this for awhile and here is what I need to do:
I input string from keyboard using int 21h option 0Ah....then whatever the contents of the buffer, the procedure is supposed to display it in reverse. I have a maximum buffer length of 100 bytes. I don't need to enter in 100 bytes.
I am not sure from here. The option 2 int 21h should be used but I don't know how to incorporate it here.
The reversed string is to be placed 3 lines below on centre-NEWPOS procedure.


Here is my code:
;RVSTRING reverses the string entered into the buffer
;In this procedure,SI and DI will point to the beginning/end of string
;The reversed string must be displayed 3 lines below centre of screen(call)
;The option2 of int 21h must be used to display all inputted characters

RVSTRING PROC
CALL NEWPOS ;call procedure to set string at the specified location
MOV SI,OFFSET BUFFER ;put buffer contents in SI for start position
MOV DI,OFFSET BUFFER+100D ;put DI pointing to end of string
;(+100D refers to the maximum number of bytes in string)
????? from here on




RET
RVSTRING ENDP

If you have any ways on INC SI and DEC DI and echo the reversed string please let me know because I have too many ideas that are bogging me down.
Thank you
KS

Comments

  • eikedehlingeikedehling Member Posts: 123
    : Hi. I have been working on this for awhile and here is what I need to do:
    : I input string from keyboard using int 21h option 0Ah....then whatever the contents of the buffer, the procedure is supposed to display it in reverse. I have a maximum buffer length of 100 bytes. I don't need to enter in 100 bytes.
    : I am not sure from here. The option 2 int 21h should be used but I don't know how to incorporate it here.
    : The reversed string is to be placed 3 lines below on centre-NEWPOS procedure.
    :
    :
    : Here is my code:
    : ;RVSTRING reverses the string entered into the buffer
    : ;In this procedure,SI and DI will point to the beginning/end of string
    : ;The reversed string must be displayed 3 lines below centre of screen(call)
    : ;The option2 of int 21h must be used to display all inputted characters
    :
    : RVSTRING PROC
    : CALL NEWPOS ;call procedure to set string at the specified location
    : MOV SI,OFFSET BUFFER ;put buffer contents in SI for start position
    : MOV DI,OFFSET BUFFER+100D ;put DI pointing to end of string
    : ;(+100D refers to the maximum number of bytes in string)
    : ????? from here on
    :
    :
    :
    :
    : RET
    : RVSTRING ENDP
    :
    : If you have any ways on INC SI and DEC DI and echo the reversed string please let me know because I have too many ideas that are bogging me down.
    : Thank you
    : KS
    :

    [code]
    mov si, offset buffer
    mov di, offset buffer + [blue]actual_length_of_string[/blue]

    loop_label:
    mov al, byte ptr di
    mov ah, byte ptr si
    mov byte ptr si, al
    mov byte ptr di, ah ; congratulations. you just swapped a pair.

    inc si
    dec di ; now move to the next pair. we go from outside to inside.

    cmp si, di
    jbe end
    loop loop_label

    end:
    [/code]

    SUSE LINUX 7.3 PRO - The world starts behind windows

  • Chris BrownChris Brown USAMember Posts: 4,624 ✭✭

    _________ // http://forcoder.org // free ebooks and video tutorials about \ PHP, R, C, Scratch, Swift, Objective-C, Perl, PL/SQL, Java, Assembly, Delphi, C++, Python, C#, Visual Basic .NET, Go, Visual Basic, MATLAB, Ruby, JavaScript Rust, Dart, Scala, Apex, COBOL, Prolog, FoxPro, VBScript, Crystal, Bash, SAS, ML, D, Alice, Lua, Awk, LabVIEW, Ada, F#, ABAP, Hack, Clojure, Kotlin, Lisp, Fortran, Erlang, Julia, Transact-SQL, Scheme, Logo \ ______________

Sign In or Register to comment.