User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Assembly section within the Software Development category of DaniWeb, a massive community of 423,871 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,986 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Assembly advertiser: Programming Forums
Views: 2296 | Replies: 1
Reply
Join Date: Apr 2005
Posts: 2
Reputation: The Angel is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
The Angel The Angel is offline Offline
Newbie Poster

Help I need help

  #1  
Apr 14th, 2005
Hi guys
I want to write program in assembly language to read string from user and replace each symbol * in string to E but i do not know how i can replace * to E after read string>>>Iam begginer in this language

this is my code and i hope to help me >>>pl.help me iam wating your help


STACKSEG SEGMENT
DW 32 DUP(?)
STACKSEG ENDS
;============================
DATASEG SEGMENT

LF EQU 0AH
CR EQU 0DH
MSG DB 'Enter the firts string...$'
MSG1 DB CR,LF, 'The string is: $'
STR1 DB 9 DUP(?)

DATASEG ENDS
;===========================
CODESEG SEGMENT

BEGIN PROC FAR
ASSUME SSTACKSEG,DSATASEG,CS:CODESEG

MOV AX,DATASEG
MOV DS,AX
MOV ES,AX

;Reading the messege
LEA DX,MSG
MOV AH,9
INT 21H

;===========================

MOV CX,0
CLD
LEA DI,STR1
MOV AH,1

REPEATE:

INT 21H
STOSB
INC DX


UNTIL:
CMP AL,0DH
JNE REPEATE
DEC DI
MOV AL,'$'
STOSB

;================================
CLD
MOV DX,CX
;Scan symbol * and replace it into E
LEA SI,STR1
;Looking for the * in string
MOV AL,'*'
REPNE SCASB
JE FOUND

FOUND:
MOV AL,'E'
STOSB
DEC DX

;=================================
;Print string1
LEA DX,MSG1
MOV AH,9
INT 21H

LEA SI,STR1
REP:
LODSB
MOV DL,AL
MOV AH,2
INT 21H
DEC CX
CMP CX,0
JE END_PROG
LOOP REP


;Return control for assembler
END_PROG:
MOV AH,4CH
INT 21H

BEGIN ENDP
CODESEG ENDS
END BEGIN
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Apr 2005
Posts: 2
Reputation: The Angel is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
The Angel The Angel is offline Offline
Newbie Poster

Help Re: I need help

  #2  
Apr 15th, 2005
hi guys
i can replace each symbol * in string to E by using LODSB but i want do that using SCASB
------------------------------------------------------
STACKSEG SEGMENT
DW 32 DUP(?)
STACKSEG ENDS
;============================
DATASEG SEGMENT

LF EQU 0AH
CR EQU 0DH
MSG DB 'Enter the firts string...$'
MSG1 DB CR,LF,'THe string is: $'
STR1 DB 9 DUP(?)
STR2 DB 9 DUP(?)
DATASEG ENDS
;===========================
CODESEG SEGMENT

BEGIN PROC FAR
ASSUME SSTACKSEG,DSATASEG,CS:CODESEG

MOV AX,DATASEG
MOV DS,AX
MOV ES,AX

;Reading the messege
LEA DX,MSG
MOV AH,9
INT 21H

;===========================

MOV CX,1
CLD
LEA DI,STR1
MOV AH,1

REPEATE:

INT 21H
STOSB
INC CX

UNTIL:
CMP AL,0DH
JNE REPEATE
DEC DI
MOV AL,'$'
STOSB

MOV DX,CX

;----------------------------------------------------
;FINd * and replace it
LEA SI,STR1
LEA DI,STR2

REP:
LODSB
CMP AL,'*'
JE STORE
STOSB
LOOP REP

STORE:
MOV AL,'E'
STOSB
CMP CX,0
JNE REP

;----------------------------------------------------

MOV CX,DX

LEA DX,MSG1
MOV AH,9
INT 21H
;Copy the character of string
LEA SI,STR2
REP1:
LODSB
MOV DL,AL
MOV AH,2
INT 21H

LOOP REP1

;Return control for assembler
MOV AH,4CH
INT 21H

BEGIN ENDP
CODESEG ENDS
END BEGIN
--------------------------------------------------
-------------------------------------------------
--------------------------------------------------
another way
but i can do that using SCASB :cry: :cry: :cry: :cry:
STACKSEG SEGMENT
DW 32 DUP(?)
STACKSEG ENDS
;============================
DATASEG SEGMENT

LF EQU 0AH
CR EQU 0DH
MSG DB 'Enter the firts string...$'
MSG1 DB CR,LF,'The string is: $'
STR1 DB 9 DUP(?)
STR2 DB 9 DUP(?)
DATASEG ENDS
;===========================
CODESEG SEGMENT

BEGIN PROC FAR
ASSUME SSTACKSEG,DSATASEG,CS:CODESEG

MOV AX,DATASEG
MOV DS,AX
MOV ES,AX

;Reading the messege
LEA DX,MSG
MOV AH,9
INT 21H

;===========================

MOV CX,0
CLD
LEA DI,STR1
MOV AH,1

REPEATE:

INT 21H
STOSB
INC CX

UNTIL:
CMP AL,0DH
JNE REPEATE
DEC DI
MOV AL,'$'
STOSB

MOV DX,CX
;------------------------------------------------
CLD
LEA DI,STR1
MOV AL,'*'

TOP:
REPNE SCASB
JE REPLACE

REPLACE:
MOV AL,'E'
STOSB
CMP CX,0
JNE TOP

;----------------------------------------------------

MOV CX,DX

LEA DX,MSG1
MOV AH,9
INT 21H
;Copy the character of string
LEA SI,STR1
REP1:
LODSB
MOV DL,AL
MOV AH,2
INT 21H

LOOP REP1

;Return control for assembler
MOV AH,4CH
INT 21H

BEGIN ENDP
CODESEG ENDS
END BEGIN
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Assembly Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the Assembly Forum

All times are GMT -4. The time now is 4:23 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC