Simple Assembly Question on Strings

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

Join Date: Nov 2007
Posts: 5
Reputation: art vandelay is an unknown quantity at this point 
Solved Threads: 0
art vandelay art vandelay is offline Offline
Newbie Poster

Simple Assembly Question on Strings

 
0
  #1
Nov 25th, 2007
Hey people.

I'm trying to build a loop to move from Arthur Vandelay to Tim Pennypacker, to Bob Sacamano. I know how to move from 54 to 21 to -2 and so on but I can't get the code right to move from Arthur Vandelay to Tim Pennypacker. I know it's something simple that I'm missing but the online documentation is scarce.

  1. Emp1 db 'Arthur Vandelay',13,10,'$'
  2. Num1 dw 54,21,-2,25
  3. db 'Tim Pennypacker',13,10,'$'
  4. dw 24,81,-14,22
  5. db 'Bob Sacamano',13,10,'$'
  6. dw 72,-9,-51,-22

Much appreciated.
Last edited by art vandelay; Nov 25th, 2007 at 11:39 pm.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 5
Reputation: art vandelay is an unknown quantity at this point 
Solved Threads: 0
art vandelay art vandelay is offline Offline
Newbie Poster

Re: Simple Assembly Question on Strings

 
0
  #2
Nov 26th, 2007
I'm now trying mov bx,Offset Emp1+17 (or whatever the size of the previous string is.)
Last edited by art vandelay; Nov 26th, 2007 at 12:23 am.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,502
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1479
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: Simple Assembly Question on Strings

 
0
  #3
Nov 26th, 2007
why don't you make it easy on yourself and give each one a name like you did Emp1 == use Emp2, Emp3, etc. Then I think you can create a jump table
  1. table dw Emp1, Emp2, Emp3
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 199
Reputation: Tight_Coder_Ex is an unknown quantity at this point 
Solved Threads: 14
Tight_Coder_Ex's Avatar
Tight_Coder_Ex Tight_Coder_Ex is offline Offline
Junior Poster

Re: Simple Assembly Question on Strings

 
0
  #4
Nov 26th, 2007
Based on your example and because you have variable length records SCASB is your best option

  1. mov edi, Emp1
  2. mov al, '$'
  3. xor ecx, ecx
  4. dec ecx
  5. repnz scasb

Now you are pointing to the numeric values and you just have to add 8 to edi to point to the next employee.

Although this does work, it is very problematic. Fixed record lengths or pointers via a table as Ancient Dragon has pointed out are the best way s to go.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 5
Reputation: art vandelay is an unknown quantity at this point 
Solved Threads: 0
art vandelay art vandelay is offline Offline
Newbie Poster

Re: Simple Assembly Question on Strings

 
0
  #5
Dec 3rd, 2007
I ended up storing the offsets for each employee, but I'm switching to your solution for obvious reasons.

Now I'm trying to sort the data by last name, first name. Any tips?

Thanks.
Last edited by art vandelay; Dec 3rd, 2007 at 1:00 am.
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 199
Reputation: Tight_Coder_Ex is an unknown quantity at this point 
Solved Threads: 14
Tight_Coder_Ex's Avatar
Tight_Coder_Ex Tight_Coder_Ex is offline Offline
Junior Poster

Re: Simple Assembly Question on Strings

 
0
  #6
Dec 3rd, 2007
Post your code please so we can see exactly what it is you have done
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