1.

Accessing Fixed Memory Locations?

Answer»

Embedded systems are OFTEN characterized by requiring the programmer to access a specific memory LOCATION. On a certain project it is required to set an integer variable at the absolute address 0x67a9 to the value 0xaa55. The compiler is a pure ANSI compiler. Write code to accomplish this task.

This problem TESTS whether you know that it is legal to typecast an integer to a pointer in order to access an absolute location. The exact syntax varies depending upon one's STYLE. However, I would typically be looking for something like this:

int *ptr; ptr = (int *)0x67a9; *ptr = 0xaa55;

A more OBSCURE approach is:

*(int * const)(0x67a9) = 0xaa55;

Embedded systems are often characterized by requiring the programmer to access a specific memory location. On a certain project it is required to set an integer variable at the absolute address 0x67a9 to the value 0xaa55. The compiler is a pure ANSI compiler. Write code to accomplish this task.

This problem tests whether you know that it is legal to typecast an integer to a pointer in order to access an absolute location. The exact syntax varies depending upon one's style. However, I would typically be looking for something like this:

A more obscure approach is:



Discussion

No Comment Found