pointers seen on assembly or registries
How does a pointer look like in assembly, I know a instruction like 'mov' for lets say a pic, is converted to a sequence of bits, these bits activate the circuits to do the job, but a pointer, how is it managed to assembly and t开发者_如何学JAVAhen manage to control circuits?. a simngle pointer is transformed in several assembly instructions, how do they look like?
Pointer is nothing but a unsigned integer indicating position in a memory (virtual address space to be precise).
The instruction
mov eax,[ebp
]
Moves value stored in a memory location whose address is stored in ebp into eax. Here ebp is a pointer.
Coming back to your question. Code is also data stored somewhere in memory and address of that memory is pointer. So using [] for dereferencing the pointer we can get that instruction(as done in above statement) and then cpu can interpret the code and execute.
Actually on 32bit x36 machines register eip stores a pointer which points to the memory which got current instruction which is getting executed.
The main feature of assembly is that a pointer can be present as label so that assemblers compiler can translate it to instructions op-code.
Actually any pointer is composed from one or more unsigned integers. At 8 bit PIC16 MCPUs you must first set appropriate memory bank, after that you can write in to memory, the reason is that address op-code size is only 7-bit in case that you are using direct memory addressing. You can also use indirect memory addressing in that case you must use FSR register that is composed from two 8-bit registers FSRL and FSRH. After setting pointer in FSR register you can read the result in INDF register as byte of that address.
Pointers are memory offsets. They look like integers with a width appropriate for the addressable size of the memory segment.
精彩评论