944,017 Members | Top Members by Rank

Ad:
  • Assembly Discussion Thread
  • Unsolved
  • Views: 1516
  • Assembly RSS
Nov 25th, 2007
0

Simple Assembly Question on Strings

Expand Post »
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.

Assembly Syntax (Toggle Plain Text)
  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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
art vandelay is offline Offline
5 posts
since Nov 2007
Nov 26th, 2007
0

Re: Simple Assembly Question on Strings

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
art vandelay is offline Offline
5 posts
since Nov 2007
Nov 26th, 2007
0

Re: Simple Assembly Question on Strings

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
Assembly Syntax (Toggle Plain Text)
  1. table dw Emp1, Emp2, Emp3
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,953 posts
since Aug 2005
Nov 26th, 2007
0

Re: Simple Assembly Question on Strings

Based on your example and because you have variable length records SCASB is your best option

asm Syntax (Toggle Plain Text)
  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.
Reputation Points: 47
Solved Threads: 17
Posting Whiz in Training
Tight_Coder_Ex is offline Offline
215 posts
since Feb 2005
Dec 3rd, 2007
0

Re: Simple Assembly Question on Strings

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
art vandelay is offline Offline
5 posts
since Nov 2007
Dec 3rd, 2007
0

Re: Simple Assembly Question on Strings

Post your code please so we can see exactly what it is you have done
Reputation Points: 47
Solved Threads: 17
Posting Whiz in Training
Tight_Coder_Ex is offline Offline
215 posts
since Feb 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Assembly Forum Timeline: Two dimensional Arrays in MIPS
Next Thread in Assembly Forum Timeline: Sparc Assembly Help!





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC