printing in assembly

Please support our Assembly advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Mar 2008
Posts: 43
Reputation: severman is an unknown quantity at this point 
Solved Threads: 0
severman severman is offline Offline
Light Poster

printing in assembly

 
0
  #1
Mar 27th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 150
Reputation: sDJh is an unknown quantity at this point 
Solved Threads: 13
sDJh sDJh is offline Offline
Junior Poster

Re: printing in assembly

 
0
  #2
Apr 20th, 2008
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:
  1. MOV ECX,stringlength
  2. MOV EBX,ECX ;stringlength as well, but better performance; EBX: Vector
  3. printloop:
  4. DEC EBX ;let the vector move to the beginning
  5. MOV AL,[string+EBX] ;get the char
  6. ;printing stuff (dont' know BIOS-Interrupt, google a bit)
  7. 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:
  1. MOV ECX,stringlength
  2. MOV EBX,ECX ;stringlength as well, but better performance; EBX: Vector
  3. XOR EDX,EDX ;EDX: Vector for 2nd string
  4. printloop:
  5. DEC EBX ;let the vector move to the beginning
  6. MOV AL,[string+EBX] ;get the char, but this time...
  7. MOV [string2+EDX],AL ;store the char in the new string
  8. INC EDX ;increase the vector of the 2nd string
  9. LOOP printloop ;...over and over again
  10. ;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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC