어셈블리 포스트를 배회하는 사람들은 어셈블리를 알아 내려고 할 때마다 새로운 것을 배울 때마다 꽤 많이 게시했음을 알 것입니다.assembly intel x86 구조와 인수로 구조 받기
어셈블리 결과를 얻는 지 확인하기 위해 어셈블리 테스트와 C 코드를 사용하고 있습니다. 번역 할 C 코드의 다음 비트에는 구조체가 있으며,이를 위해 어떤 좋은 예제도 찾을 수 없습니다.
typedef struct item {
int number;
char name[32];
} item;
/**
* Performs a binary sort on the items pointed to by the parameter list.
*
* @param[in/out] list pointer to an array of items
* @param[in] n total number of elements in the array
*/
void binary_sort_c(item *list, int n) {
int i;
int j;
int bottom;
int top;
int middle;
item temp;
if (list != NULL) {
i = 1;
while (i < n) {
temp = list[i];
bottom = 0;
top = i-1;
while (bottom <= top) {
middle = (bottom+top)/2;
if (temp.number < list[middle].number) {
top = middle-1;
} else {
bottom = middle+1;
}
}
j = i-1;
while (j >= bottom) {
list[j+1] = list[j];
j = j-1;
}
list[bottom] = temp;
i = i+1;
}
}
}
지금 여기 내 문제가있다
, 내가 어셈블리에서이 구조를 사용하는 방법을 알아낼 수 없습니다여기 내 C 코드입니다. 어셈블리에서 C 코드로 인수로 전달되는 경우 어셈블리에서 구조를 다시 작성해야합니까?
어셈블리에서 구조의 다른 요소에 어떻게 액세스합니까? 예를 들어, temp.number
어셈블리에서 list = NULL
을 어떻게 확인할 수 있습니까?
내가 작업 할 수있는 템플릿으로 사용할 수있는 간단한 예제 코드는 완벽 할 것입니다.
는'list'는 단순한 포인터 인수입니다. 멤버에 액세스하는 경우 오프셋을 알아야합니다. – Jester
@Jester 이렇게하면'if (list! = NULL)','mov eax, list','cmp eax, 0'' jne LABEL'을 검사하기에 충분합니까? – Monkleys
'list'가 선언 된 방법에 따라 작동합니다. – Jester