Questions d'entretien

Entretien pour Embedded Software Engineer

-

Apple

Accurately (this is the catch) read a 64bit register value using a method that can read only 32bit at a time

Répondre

Réponses aux questions d'entretien

4 réponse(s)

3

uint32_t read_context; memcpy(&read_context, (void *)(REGISTER_BASE_ADDR), 4); printf("Register MSW: %x \t", read_context, 0, 0, 0, 0, 0); memcpy(&read_context, (void *)(REGISTER_BASE_ADDR + 4), 4); printf("Register LSW: %x \t" , read_context, 0, 0, 0, 0, 0);

Anonymous le

0

uint64_t result = (uint64_t) read32(ptr1) | read32(ptr1+4)

Utilisateur anonyme le

1

#include #include void register_read(void* reg,void *result); int main() { //printf("Hello World"); uint64_t reg=0xAAAAAAAAFFFFFFFF,result; register_read((void*)®,(void*)&result); printf("%lX",result); return 0; } void register_read(void* reg,void *result){ uint32_t *ptr1,*ptr2; ptr1=(uint32_t *)(reg); ptr2=(uint32_t *)(result); for(int i=0;i<2;i++){ *ptr2=*ptr1; ptr1++; ptr2++; }

Srihari Danduri le

0

Create two new buffers. 32 bit buffer and 64 bit buffer. Pass the 32 bit buffer to read32() and when you get back 32 bits, store that in the 64 bit buffer (remember to keep track of the index pointing to the first empty entry in 64 bit buffer). Repeat the above again with empty 32 bit buffer.

iamGodzilla le

Ajouter des réponses ou des commentaires

Pour commenter ceci, connectez-vous ou inscrivez-vous.