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.

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

Much appreciated.

Recommended Answers

All 5 Replies

I'm now trying mov bx,Offset Emp1+17 (or whatever the size of the previous string is.)

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

table  dw Emp1, Emp2, Emp3

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

mov     edi, Emp1
mov     al, '$'
xor     ecx, ecx
dec     ecx
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.

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.

Post your code please so we can see exactly what it is you have done

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.