10 Replies - 6653 Views - Last Post: 20 April 2013 - 02:05 PM

#1 cheesey315  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 26
  • Joined: 10-November 12

Read in a string and Display it

Posted 12 April 2013 - 01:00 PM

I am trying to write a program in assembly language that prompts the user to enter in a string of words. Then prompt the user to enter in a word from the original line of text entered by the user. Then prompt the user to enter in a word to replace that first word of equal length. After each prompt the user will enter in the info and press enter. After all the info is entered it the program is supposed to display the original line the user entered and then on the next line the same line as before but with every instance of the first single word entered replaced by the second single word entered. I am having difficulty with displaying the original string of words. I am not sure why but every time it outputs "p". I have not begun work on the code for replacing the word with the other word. Any help would be appreciated.

MODEL small
.STACK 100h

WriteSt MACRO MessLab
	push ax
	push dx
	mov ah,9
	mov dx,offset MessLab
	int 21h
	pop dx
	pop ax
ENDM

.DATA
	prompt1 db 10,13,'Enter Original Line:$'
	prompt2 db 10,13,'Enter First Word: $'
	prompt3 db 10,13,'Enter Replacement Word: $'
	symbol db '$'
	first db ?
	replacement db ?
	crlf db 10,13,'$'
	string db 80

	
.CODE
MAIN PROC
	mov ax,@DATA
	mov ds,ax
	
	WriteSt prompt1   ;display prompt1
	WriteSt crlf
	
	lea DI,string
	Call ReadString   ;get string
	
	WriteSt crlf
	
	WriteSt prompt2   ;display prompt2
	lea DI,first
	Call ReadString   ;get first
	
	WriteSt prompt3   ;display prompt3
	lea DI,Replacement
	Call ReadString   ;get replacement
	
	WriteSt crlf
	WriteSt crlf


	lea SI, string
	mov bx,80
	CALL DisplayString   ;display original string
	
	
	
	
	mov ax,4C00h
	int 21h
	
MAIN ENDP

ReadString PROC    NEAR                                     
     ; Reads and stores a string.                             
     ; input: DI offset of string                             
     ; output: DI offset of string                            
     ;        BX number of characters read                      
            PUSH    AX                                          
            PUSH    DI                                          
            CLD                     ;process from left          
            XOR     BX,BX           ;no. of chars read          
            MOV     AH,1            ;input char function        
            INT     21H             ;read a char into AL
     WHILE1:                                                  
            CMP     AL,0DH          ;<CR>?                      
            JE      END_WHILE1      ;yes, exit
     ;if char is backspace                                    
            CMP     AL,8H           ;backspace?                 
            JNE     ELSE1           ;no, store in string        
     ;then                                                    
            DEC     DI              ;yes, move string ptr back  
            DEC     BX              ;decrement char counter     
            JMP     READ            ;and go to read another char
     ELSE1:
            STOSB                   ;store char in string       
            INC     BX              ;increment char count       
     READ:
            INT     21H             ;read a char into AL
            JMP     WHILE1          ;and continue loop
     END_WHILE1:                                              
            POP     DI                                          
            POP     AX                                          
            RET                                                 
ReadString ENDP 
DisplayString   PROC
;displays a string 
;input: SI = offset of string
;       BX = no. of chars. to display
;output: none
        PUSH   AX
        PUSH   BX
        PUSH   CX
        PUSH   DX
        PUSH   SI
        MOV    CX,BX            ;no. of chars
        JCXZ   P_EXIT           ;exit if none
        CLD                     ;process left to right
        MOV    AH,2             ;prepare to print
TOP:
        LODSB                   ;char in AL
        MOV    DL,AL            ;move it to DL
        INT    21H              ;print char
        LOOP   TOP              ;loop until done
P_EXIT:
        POP    SI
        POP    DX
        POP    CX
        POP    BX
        POP    AX
        RET
DisplayString        ENDP
end MAIN



Is This A Good Question/Topic? 0
  • +

Replies To: Read in a string and Display it

#2 GunnerInc  Icon User is offline

  • "Hurry up and wait"
  • member icon




Reputation: 858
  • View blog
  • Posts: 2,281
  • Joined: 28-March 11

Re: Read in a string and Display it

Posted 13 April 2013 - 10:21 AM

Ok, let's change a few things.
This:
first db ?

Holds only 1 character, lets change it to:
first db 80 dup(?)

Now it (the buffer) will hold 79 characters.
Same for replacement db ?, should be:
replacement db 80 dup(?)


This:
string db 80 
is a string with the character "P", 80 is the ASCII code for uppercase P. Change that to:
string db 80 dup(?)


Change your ReadString to:
ReadString PROC    NEAR                                     
     
       ; si == pointer to buffer
Read:
    mov     ah, 01H
    int     21H                 ; read 1 character
    cmp     al, 13              ; is it return?
    je      Done                ; yes, we are done
    mov     [si], al            ; no, move charater into buffer
    inc     si                  ; increase pointer
    jmp     Read                ; loop back
    
Done:             
    mov     [si], "$"           ; NULL Terminate string
    ret       
ReadString ENDP 


.MODEL small
.STACK 100h

WriteSt MACRO MessLab
	push ax
	push dx
	mov ah,9
	mov dx,offset MessLab
	int 21h
	pop dx
	pop ax
ENDM

.DATA
	prompt1 db 10,13,'Enter Original Line:$'
	prompt2 db 10,13,'Enter First Word: $'
	prompt3 db 10,13,'Enter Replacement Word: $'
	symbol db '$'
	first db 80 dup(?)
	replacement db 80 dup(?)
	crlf db 10,13,'$'
	string db 80 dup(?)

	
.CODE
MAIN PROC
	mov ax,@DATA
	mov ds,ax
	
	WriteSt prompt1   ;display prompt1
	WriteSt crlf

    mov     si, offset string
	Call    ReadString   ;get string
	WriteSt string
	
	WriteSt prompt2   ;display prompt2
	
	mov     si, offset first
	Call ReadString   ;get first
	
	WriteSt prompt3   ;display prompt3
	mov     si, offset replacement
	Call ReadString   ;get replacement

    WriteSt string 
;	lea SI, string
;	mov bx,80
;	CALL DisplayString   ;display original string
	
	mov ax,4C00h
	int 21h
	
MAIN ENDP

ReadString PROC    NEAR                                     
     
       ; si == pointer to buffer
Read:
    mov     ah, 01H
    int     21H                 ; read 1 character
    cmp     al, 13              ; is it return?
    je      Done                ; yes, we are done
    mov     [si], al            ; no, move charater into buffer
    inc     si                  ; increase pointer
    jmp     Read                ; loop back
    
Done:             
    mov     [si], "$"           ; NULL Terminate string
    ret       
ReadString ENDP 


Now, work on the code to replace characters/words. You have 3 buffers, 1 contains original string, 2 contains word to replace, and 3rd contains replacement word.
Was This Post Helpful? 0
  • +
  • -

#3 cheesey315  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 26
  • Joined: 10-November 12

Re: Read in a string and Display it

Posted 16 April 2013 - 04:13 PM

Thank you for the help. I am now having an issue with the finding and replacing of a word in a string. It doesn't replace the word in the string. Also it just prints out a bunch of garbage. Can I get some help again?

MODEL small
.STACK 100h

WriteSt MACRO MessLab
	push ax
	push dx
	mov ah,9
	mov dx,offset MessLab
	int 21h
	pop dx
	pop ax
ENDM

.DATA
	prompt1 db 10,13,'Enter Original Line:$'
	prompt2 db 10,13,'Enter First Word: $'
	prompt3 db 10,13,'Enter Replacement Word: $'
	symbol db '$'
	first db 80 dup(?)
	replacement db 80 dup(?)
	crlf db 10,13,'$'
	string db 80 dup(?)

	
.CODE
MAIN PROC
	mov ax,@DATA
	mov ds,ax
	
	WriteSt prompt1           ;Display prompt1
	WriteSt crlf              ;New line
	
	lea SI,string             ;Load string into SI
	Call ReadString           ;Get info from keyboard
	
	WriteSt crlf              ;New line
	
	WriteSt prompt2           ;Display prompt2
	lea SI,first              ;Load first into SI
	Call ReadString           ;Get info from keyboard
	
	WriteSt prompt3           ;Display prompt3
	lea SI,replacement        ;Load replacement into SI
	Call ReadString           ;Get info from keyboard
	
	WriteSt crlf              ;New line
	WriteSt crlf              ;New line


	lea SI, string            ;Load string into SI
	mov bx,80                 ;Number of characters to be displayed
	Call DisplayString        ;Display string
	
	CLD
	lea DI, string
	mov al,first
	
	Top2:
		REPNE SCASB
		JE Replace
	
	Replace:
		mov al,replacement
		STOSB
		cmp cx,0
		JNE Top2
	
	mov cx,dx
	lea SI,string
	Repeat1:
		LODSB
		mov dl,al
		mov ah,2
		int 21h
		Loop Repeat1
 
 
	lea SI, string
	mov bx,80
	Call DisplayString 
	
	mov ax,4C00h              ;Exit to dos
	int 21h
	
MAIN ENDP

ReadString PROC NEAR
	Read:
		mov ah,01h
		int 21h                 ;Read 1 character
		cmp al,13               ;Is it return?
		je Done                 ;Yes, we are done reading in characters
		mov [si],al             ;No, move character into buffer
		inc si                  ;Increase pointer
		jmp Read                ;loop back
	Done:
		ret
Readstring ENDP

DisplayString   PROC
;displays a string 
;input: SI = offset of string
;       BX = no. of chars. to display
;output: none
        PUSH   AX
        PUSH   BX
        PUSH   CX
        PUSH   DX
        PUSH   SI
        MOV    CX,BX            ;no. of chars
        JCXZ   P_EXIT           ;exit if none
        CLD                     ;process left to right
        MOV    AH,2             ;prepare to print
TOP:
        LODSB                   ;char in AL
        MOV    DL,AL            ;move it to DL
        INT    21H              ;print char
        LOOP   TOP              ;loop until done
P_EXIT:
        POP    SI
        POP    DX
        POP    CX
        POP    BX
        POP    AX
        RET
DisplayString        ENDP
end MAIN


Was This Post Helpful? 0
  • +
  • -

#4 GunnerInc  Icon User is offline

  • "Hurry up and wait"
  • member icon




Reputation: 858
  • View blog
  • Posts: 2,281
  • Joined: 28-March 11

Re: Read in a string and Display it

Posted 16 April 2013 - 06:42 PM

Quote

it just prints out a bunch of garbage

Why wouldn't it? Your strings are not "NULL" terminated. In DOS, strings are terminated with a dollar sign - $. Look at the code I gave you:
ReadString PROC    NEAR                                     
     
       ; si == pointer to buffer
Read:
    mov     ah, 01H
    int     21H                 ; read 1 character
    cmp     al, 13              ; is it return?
    je      Done                ; yes, we are done
    mov     [si], al            ; no, move charater into buffer
    inc     si                  ; increase pointer
    jmp     Read                ; loop back
    
Done:             
    mov     [si], "$"           ; NULL Terminate string
    ret       
ReadString ENDP 

Now, look at the code you posted:
ReadString PROC NEAR
	Read:
		mov ah,01h
		int 21h                 ;Read 1 character
		cmp al,13               ;Is it return?
		je Done                 ;Yes, we are done reading in characters
		mov [si],al             ;No, move character into buffer
		inc si                  ;Increase pointer
		jmp Read                ;loop back
	Done:
		ret
Readstring ENDP

Notice something missing in your version of Readstring?

Also, as a parameter to DisplayString, you are passing 80 for the amount of characters to print, are you sure you are going to print 80 characters each time? We can modify ReadString to return the amount of characters read:
ReadString PROC NEAR
    mov     cx, si              ; cx == buffer start address
	Read:
		mov ah,01h
		int 21h                 ;Read 1 character
		cmp al,13               ;Is it return?
		je Done                 ;Yes, we are done reading in characters
		mov [si],al             ;No, move character into buffer
		inc si                  ;Increase pointer
		jmp Read                ;loop back
	Done:
	    mov [si], "$"           ; terminate string
	    mov ax, si              ; ax == buffer end address
	    sub ax, cx              ; return characters read in ax
		ret
Readstring ENDP

and to use, create a variable to hold each buffers length. For the first buffer - string it will be defined as: string_len dw ? or whatever you want to call it. Then after to fill the string buffer, move ax into this variable:
	lea     SI,string             ;Load string into SI
	Call    ReadString           ;Get info from keyboard
	mov     string_len, ax

now string_len contains the count of characters put into the buffer including the terminating $

Also, to replace text, the easiest way is to have 2 buffers - the original string (source) and a buffer to hold the modified string (destination). What happens if I enter Hello Mr. Gunner as the original text, the word to replace Mr. and the replacement word mister? You are going to overwrite something, so this is where a destination buffer will help, you just have to make sure the dest buffer is large enough to hold the modified string.

What you would do is:
Take your string and loop through it byte by byte moving each byte into the dest buffer, until you get to the first letter of the word to replace, save that address, now since this letter can appear many times in the string and it might not be the replacement word, compare each byte after the first one to the replacement word, if it matches, add the replacement word to the address you saved and continue moving the rest of the string into the dest buffer.
Was This Post Helpful? 0
  • +
  • -

#5 cheesey315  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 26
  • Joined: 10-November 12

Re: Read in a string and Display it

Posted 17 April 2013 - 02:01 PM

Quote

Take your string and loop through it byte by byte moving each byte into the dest buffer, until you get to the first letter of the word to replace, save that address, now since this letter can appear many times in the string and it might not be the replacement word, compare each byte after the first one to the replacement word, if it matches, add the replacement word to the address you saved and continue moving the rest of the string into the dest buffer.


Am I getting close at all to accomplishing this with this code? I am not good at assembly language obviously and am trying to teach myself. I know the idea of what I need to do but can't figure out how. I was able to do this in c++, but I can't seem to get it for assembly.

	CLD
	lea DI, string
	mov al,first
	
	Top2:
		REPNE SCASB
		JE Replace
	
	Replace:
		mov al,replacement
		STOSB
		cmp cx,0
		JNE Top2


Was This Post Helpful? 0
  • +
  • -

#6 GunnerInc  Icon User is offline

  • "Hurry up and wait"
  • member icon




Reputation: 858
  • View blog
  • Posts: 2,281
  • Joined: 28-March 11

Re: Read in a string and Display it

Posted 17 April 2013 - 03:22 PM

Quote

trying to teach myself

You are doing this on your own? Not for school or any type of course? If it is for you, then I will recommend you to learn 32bit Assembly instead of 16bit DOS code.

Quote

Am I getting close at all to accomplishing this with this code?

You tell me, what happens when you run it?

First problem I see is you move a character from first into al for repne scasb, then you do your replacement then jump back to Top2 and repeat repne scasb with whatever was in al from stosb after your replacement, you need to get the next character from first. Also, where do you load a value into cx? You test it for 0, but it could be 0 to begin with.

The easiest way to see if it works, is to run the code, see what happens, change some code and run again.
Was This Post Helpful? 0
  • +
  • -

#7 cheesey315  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 26
  • Joined: 10-November 12

Re: Read in a string and Display it

Posted 18 April 2013 - 01:12 PM

I am doing this for a class but my teacher didn't give any instruction for this, so I am teaching myself how to do it.

I am getting an error when I run the program. It happens as soon as I hit enter after entering in the replacement word.

the NTVDM CPU has encountered an illegal instruction.
CS:05ac IP:0080 OP:ff ff 00 a0 98

This error only happens when I enter the following information (original line=this is the line i am entering from the keyboard.) first=the replacement=myy

But when I use different word for replacement such as "now" it runs through the program.

When I use "now" for the replacement it gives me this output.

Enter Original line:
This is the line I am entering from the keyboard.
Enter First Word: the
Enter Replacement Word: now

This is the line I am entering from the keyboard.
this is the line I am entering from the keyboard.


I am still having difficulty with the replacement part. I made cx equal the length of first. I changed DI to SI on line 60 and then incremented it on line 71. Which is what I believe is how to move to the next character in string, but I am thinking I am wrong. I don't know what I am supposed to change.

MODEL small
.STACK 100h

WriteSt MACRO MessLab
	push ax
	push dx
	mov ah,9
	mov dx,offset MessLab
	int 21h
	pop dx
	pop ax
ENDM

.DATA
	prompt1 db 10,13,'Enter Original Line:$'
	prompt2 db 10,13,'Enter First Word: $'
	prompt3 db 10,13,'Enter Replacement Word: $'
	symbol db '$'
	first db 80 dup(?)
	replacement db 80 dup(?)
	crlf db 10,13,'$'
	string db 80 dup(?)
	string_len dw ?
	string_len1 dw ?

	
.CODE
MAIN PROC
	mov ax,@DATA
	mov ds,ax
	
	WriteSt prompt1           ;Display prompt1
	WriteSt crlf              ;New line
	
	lea SI,string             ;Load string into SI
	Call ReadString           ;Get info from keyboard
	mov string_len,ax
	
	WriteSt crlf              ;New line
	
	WriteSt prompt2           ;Display prompt2
	lea SI,first              ;Load first into SI
	Call ReadString           ;Get info from keyboard
	mov string_len1,ax
	
	WriteSt prompt3           ;Display prompt3
	lea SI,replacement        ;Load replacement into SI
	Call ReadString           ;Get info from keyboard
	
	WriteSt crlf              ;New line
	WriteSt crlf              ;New line


	lea SI, string            ;Load string into SI
	mov bx,string_len                 ;Number of characters to be displayed
	Call DisplayString        ;Display string
	
	mov cx,string_len1
	CLD
	lea SI, string
	mov al,first
	
	Top2:
		REPNE SCASB
		JE Replace
	
	Replace:
		mov al,replacement
		STOSB
		cmp cx,0
		inc SI
		JNE Top2
	
 
	WriteSt crlf
	lea SI, string
	mov bx,string_len
	Call DisplayString 
	
	mov ax,4C00h              ;Exit to dos
	int 21h
	
MAIN ENDP

ReadString PROC NEAR
	mov cx,si
	Read:
		mov ah,01h
		int 21h                 ;Read 1 character
		cmp al,13               ;Is it return?
		je Done                 ;Yes, we are done reading in characters
		mov [si],al             ;No, move character into buffer
		inc si                  ;Increase pointer
		jmp Read                ;loop back
	Done:
		mov [si],"$"
		mov ax,si
		sub ax,cx
		ret
Readstring ENDP

DisplayString   PROC
;displays a string 
;input: SI = offset of string
;       BX = no. of chars. to display
;output: none
        PUSH   AX
        PUSH   BX
        PUSH   CX
        PUSH   DX
        PUSH   SI
        MOV    CX,BX            ;no. of chars
        JCXZ   P_EXIT           ;exit if none
        CLD                     ;process left to right
        MOV    AH,2             ;prepare to print
TOP:
        LODSB                   ;char in AL
        MOV    DL,AL            ;move it to DL
        INT    21H              ;print char
        LOOP   TOP              ;loop until done
P_EXIT:
        POP    SI
        POP    DX
        POP    CX
        POP    BX
        POP    AX
        RET
DisplayString        ENDP
end MAIN


Was This Post Helpful? 0
  • +
  • -

#8 GunnerInc  Icon User is offline

  • "Hurry up and wait"
  • member icon




Reputation: 858
  • View blog
  • Posts: 2,281
  • Joined: 28-March 11

Re: Read in a string and Display it

Posted 18 April 2013 - 01:26 PM

give me a few hours. I will be home later and show you an example
Was This Post Helpful? 0
  • +
  • -

#9 cheesey315  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 26
  • Joined: 10-November 12

Re: Read in a string and Display it

Posted 19 April 2013 - 08:27 AM

Thank you for all your help Gunner. Not just in this post but I've looked at other posts that you have been in and they have all helped.
Was This Post Helpful? 0
  • +
  • -

#10 GunnerInc  Icon User is offline

  • "Hurry up and wait"
  • member icon




Reputation: 858
  • View blog
  • Posts: 2,281
  • Joined: 28-March 11

Re: Read in a string and Display it

Posted 19 April 2013 - 10:58 PM

Ok, this should get you going on your way. This is simple and crude, and there are a few things:
1. String to replace and replacement string must be same length (this can be changed, but needs a second buffer and more code)
2. It only searches for first letter of first word and replaces from there. (To be proper, needs to find whole first word)
.MODEL small
.STACK 100h

WriteSt MACRO MessLab
	push ax
	push dx
	mov ah,9
	mov dx,offset MessLab
	int 21h
	pop dx
	pop ax
ENDM

.DATA
prompt1     db 10,13,'Enter Original Line:$'
prompt2     db 10,13,'Enter First Word: $'
prompt3     db 10,13,'Enter Replacement Word: $'
prompt4     db 10, 13, 'Text not found $'
prompt5     db 10, 13, "Strings are not the same length $"
symbol      db '$'
crlf        db 10,13,'$'

.data?
string_len  dw ?
repl_len    dw ?
first_len   dw ?
first       db 80 dup(?)
replacement db 80 dup(?)
string      db 80 dup(?)
		
.CODE
MAIN PROC
	mov     ax, @DATA
	mov     ds, ax

DisplayPrompt:	
	WriteSt prompt1           ;Display prompt1
	
	lea     SI, string             ;Load string into SI
	Call    ReadString           ;Get info from keyboard
	mov     string_len, ax
	
	WriteSt prompt2                 ;Display prompt2
	lea     SI, first               ;Load first into SI
	Call    ReadString              ;Get info from keyboard
	mov     first_len, ax
	
	WriteSt prompt3                 ;Display prompt3
	lea     SI,replacement          ;Load replacement into SI
	Call    ReadString              ;Get info from keyboard
	
	mov     repl_len, ax
;#####################################  
    cmp     ax, first_len           ;# are word to replace and replacement word same length?
    je      StartFindWord           ;# Yes!, continue
    WriteSt prompt5                 ;# NO!!!
    jmp     DisplayPrompt           ;# Start over
    

StartFindWord:                                   
    mov     si, offset string       ;# Address of entered string buffer
    mov     bx, offset first        ;# Address of word to replace buffer
    xor     cx, cx                  ;# zero counter
    
FindWord:
    mov     al, byte ptr [bx]       ;# Get first letter of word to replace
    cmp     al, byte ptr [si]       ;# Compare with byte at pointer in si
    je      ReplaceStart            ;# if equal, word found
                                    ;# otherwise continue search
    inc     si                      ;# increase our string pointer to get next letter
    inc     cx                      ;# increase our counter
    cmp     cx, string_len          ;# does counter equal string length?
    jne     FindWord                ;# No, loop back to check next char
    jmp     NotFound                ;# Yes, word to replace not found

ReplaceStart:                      
    mov     bx, offset replacement  ;# Address of replacement word
    xor     cx, cx                  ;# zero counter
ReplaceIt:                          ;# si contains pointer to first char of word to replace
    mov     al, byte ptr [bx]       ;# get byte of replacement word
    mov     byte ptr [si], al       ;# replace char in si
    inc     si                      ;# increase string pointer
    inc     bx                      ;# increase replacement pointer
    inc     cx                      ;# increase loop counter
    cmp     cx, repl_len            ;# does it equal replacement text len?
    jne     ReplaceIt               ;# No, loop back to replace next char
    
    WriteSt string                  ;# display modified string

RepDone:
    mov     ax, 4C00h               ;# Exit to dos
	int     21h
	
NotFound:
    WriteSt prompt4                 ;# Text to replace not found!!
    jmp     RepDone
;#####################################
MAIN ENDP

ReadString PROC NEAR
    mov     cx, si              ; cx == buffer start address
	Read:
		mov ah,01h
		int 21h                 ;Read 1 character
		cmp al,13               ;Is it return?
		je Done                 ;Yes, we are done reading in characters
		mov [si],al             ;No, move character into buffer
		inc si                  ;Increase pointer
		jmp Read                ;loop back
	Done:
	    mov [si], "$"           ; terminate string
	    mov ax, si              ; ax == buffer end address
	    sub ax, cx              ; return characters read in ax
		ret
Readstring ENDP

DisplayString   PROC
;displays a string 
;input: SI = offset of string
;       BX = no. of chars. to display
;output: none
        PUSH   AX
        PUSH   BX
        PUSH   CX
        PUSH   DX
        PUSH   SI
        MOV    CX,BX            ;no. of chars
        JCXZ   P_EXIT           ;exit if none
        CLD                     ;process left to right
        MOV    AH,2             ;prepare to print
TOP:
        LODSB                   ;char in AL
        MOV    DL,AL            ;move it to DL
        INT    21H              ;print char
        LOOP   TOP              ;loop until done
P_EXIT:
        POP    SI
        POP    DX
        POP    CX
        POP    BX
        POP    AX
        RET
DisplayString        ENDP
end MAIN


Attached Image
Was This Post Helpful? 0
  • +
  • -

#11 cheesey315  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 26
  • Joined: 10-November 12

Re: Read in a string and Display it

Posted 20 April 2013 - 02:05 PM

Thank you. That was so much help. I never would have thought of using pointers. I have never been good with them.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1