This is a bit wrong with you, first of all, you encode it as if you get the name and age as parameters, and you donβt, you just need ebx to keep the address in the list. And you have slightly fewer math indications, assuming the characters are 1 byte (thus 8 bytes in your array), integers and pointers 4 bytes that might work:
Person: push ebp; save callers ebp mov ebp, esp; setup new ebp init: mov ebx, [ebp + 4]; mov ecx, 0; k=0 forloop: cmp ecx, 100; jge end; if k>= 100 then break forloop cmp [ebx + 8 + 12 * ecx], 18 ; 12 * ecx to advance 12 bytes (8 char 4 int), plus 8 to compare the integer, which is 8 bytes away from the start of the pointer. jl auxloop; if list[k].age < 18 then go to auxloop jmp printName; printName: auxloop: inc ecx; jmp forloop; end: pop ebp;
source share