Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Assembly language help!!

Status
Not open for further replies.

INS-ANI

Full Member level 3
Joined
Feb 28, 2007
Messages
152
Helped
2
Reputation
4
Reaction score
1
Trophy points
1,298
Activity points
2,377
dup assembly language

Here is the problem statement:
>> WAP to take a string from user and then display it.

solution( what i have found till now)


Code:
.MODEL SMALL

.DATA
DISP1 DB 0DH,0AH,"Enter the desired string=",0DH,0AH,"$"
DISP2 DB 0DH,0AH,"The stored string is=",0DH,0AH,"$"
STRIP DB (?)

.CODE
        MOV AX,@DATA
        MOV DS,AX

        MOV AH,09H
        LEA DX,DISP1
        INT 21H

        MOV CL,07H
        LEA SI,STRIP

LOOP2:
        MOV AH,01H
        INT 21H
               
        MOV [SI],AL

        INC SI
        DEC CL
        JNZ LOOP2

        MOV AH,09H
        LEA DX,DISP2
        INT 21H

        MOV CL,07H
        LEA SI,STRIP

LOOP1:
        MOV AH,02H
        LEA DL,[SI]
        INT 21H

        INC SI
        DEC CL
        JNZ LOOP1



        MOV AH,4CH
        INT 21H

        END

the problem:
I am able to take input from user succesfully, but it is not displayed properly .
I request some experienced member to please help me out.

Also if possible, please advice me on troubleshooting process.
Thanks in advance.:)
 

assembly language db

Have you tried changing LEA DL,[SI] to MOV DL,[SI]

How is memory for STRIP allocated? Have you considered defining it as:
STRIP DB 00H,00H,00H,00H,00H,00H...
 

mov si,offset str1

@jayson
NOT GOOD, When i use the syntax as adviced by you, i am experiencing an error in line 38 , that is
"LEA DL,[SI] "

Added after 5 minutes:

got it,
i changed the syntax to

STRIP DB 10 DUP(?)

and the line 38 to MOV DL,SI

and the code works..now need to verify which line had the error.

Added after 4 minutes:

Guys, please help me out why the correction works?

in line 38 i earlier tried LEA Dl,STRIP
but it didnt work.

similarly

STRIP DB DUP(?) doesn't work

why?
 

what is ah/ assembly language

At minimum LEA needs a 16-bit destination register to store the address, DL is an 8-bit register.

STRIP DB DUP(?) is invalid since the syntax for DUP is:
count DUP (initialvalue [[, initialvalue]]...)
 

what is 0dh in assembly language

Thanks sir.
 

dup (?) assembly language

Here is a program to take a string from user, then test how many times a given char occurs in the string.


Code:
.MODEL SMALL

.DATA
MSG1 DB 0DH,0AH,"ENTER THE STRING=",0DH,0AH,"$"
MSG2 DB 0DH,0AH,"ENTER THE CHARACTER TO BE SEARCHED=",0DH,0AH,"$"
MSG3 DB 0DH,0AH,"THE COUNT OF CHARACTER IS =",0DH,0AH,"$"
COUNT DB 01 DUP()
STR1 DB 10 DUP()
CHAR DB 01 DUP()

.CODE
          MOV AX,@DATA
          MOV DS,AX
          MOV ES,AX

          MOV AH,09H
          MOV DX,OFFSET MSG1
          INT 21H

          MOV CX,07H
          MOV SI,OFFSET STR1

LOOP1:    MOV AH,01H
          INT 21H

          MOV [SI],AL

          INC SI
          DEC CX

          JNZ LOOP1

          MOV AH,09H
          MOV DX,OFFSET MSG2
          INT 21H

          MOV SI,OFFSET CHAR

          MOV AH,01H
          INT 21H

          MOV [SI],AL

          MOV CX,07H
          MOV DI,OFFSET STR1
          XOR BL,BL
          MOV SI,OFFSET CHAR
          CLD

SCAN:
          MOV AL,[SI]
          SCASB 
          JNZ NEXT1
          INC BL
NEXT1:
          INC SI
          DEC CL
          JNZ SCAN

          ADD BL,30H
          LEA SI,COUNT
          MOV [SI],BL

             


          

                   
          MOV [SI],BL


          MOV AH,09H
          MOV DX,OFFSET MSG3
          INT 21H

          MOV AH,02H
          MOV DL,OFFSET COUNT
          INT 21H

          MOV AH,4CH
          INT 21H


          END

I was able to get the string from user, but i guess there's something wrong in the later part.
 

assembly language dup

I don't see an error at first look. Trace execution in debug.

P.S.: I wonder why you are using pointers for simple variables. You could write e.g.
Code:
MOV Count,AL
as well.
 

mov dl,[si]

i will try that.. thanks.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top