hi all
i have this code and now i need to print it char yes and char no i.e.- the sentce is my-second-exercis and now i need to print it m-eod-xri
how do i do that?
then i need to print the first sentence backwords
how do i do that also?
here is the code
10x!

data segment
dec bp
pop cx
sub ax,4553h
inc bx
dec di
dec si
inc sp
sub ax,5845h
inc bp
push dx
inc bx
dec cx
push bx
inc bp
and al,36
data ends

I'm sorry, but I didn't understand your first question.

To print a string backwards, you can use two ways. First you print it directly the other way round:

MOV ECX,stringlength
MOV EBX,ECX   ;stringlength as well, but better performance; EBX: Vector
printloop:
DEC EBX  ;let the vector move to the beginning
MOV AL,[string+EBX]  ;get the char
;printing stuff (dont' know BIOS-Interrupt, google a bit)
LOOP printloop  ;repeat

This code stores the chars of the string the other way round and prints it on the screen.

or, in my opinion, the better way:

MOV ECX,stringlength
MOV EBX,ECX   ;stringlength as well, but better performance; EBX: Vector
XOR EDX,EDX   ;EDX: Vector for 2nd string
printloop:
DEC EBX    ;let the vector move to the beginning
MOV AL,[string+EBX]  ;get the char, but this time...
MOV [string2+EDX],AL  ;store the char in the new string
INC EDX   ;increase the vector of the 2nd string
LOOP printloop   ;...over and over again
;print string2

This time the code saves the string in string2 (new memory). Then you can not only print it but also use it for further calculation.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.