NASM Forum > Programming with NASM
Multi-array struct in assembly
(1/1)
mik3ca:
I'm doing a project which requires me to manage a multi-dimensional struct. Each struct is 2 dwords. I'll give an example of what I mean in a real world scenario.
Suppose 10 mailmen are assigned to deliver 10 items to homes on different routes but the only information they have is a street code and a delivery code with a barcode that they scan to find the right house.
So this struct applies for every mailman possible.
--- Code: ---delivercode dd 0
streetcode dd 0
--- End code ---
now for 1 mailman to do 10 items, I could change my declarations to this:
--- Code: ---delivercode times 10 dd 0
streetcode times 10 dd 0
--- End code ---
then I'd have to access them like this (assuming BX=item number wanted and ECX is resulting street code based on that item number):
--- Code: ---shl BX,2
mov ECX,[streetcode+BX]
--- End code ---
But now I'm stuck on the most efficient way to do declarations for the remaining mailmen because I only covered one in this example.
Here is how I would address multiple mailmen:
Assuming BX is house number, and AX is mailman number, I could read values like this maybe:
--- Code: ---mul AX,200
shl BX,2
add BX,AX
mov ECX,[streetcode+BX]
--- End code ---
Is there an easier way to define a multidimensional struct?
like maybe something like:
--- Code: --- (delivercode dd 0, streetcode dd 0) times 10 times 10
--- End code ---
I have nasm 2.10.04.
Navigation
[0] Message Index
Go to full version