sjalloq wrote:Firstly, can someone explain access to the data region using the data pointer? Is it fixed and all access to data is an offset from this pointer?
The mapper gathers all writable data into a single region in the final image. The boot code initialises the dp register of every thread to the start of this region. If you use a label with a dp relative instruction then at link time the offset to that label from the start of the data region is patched into the instruction.
Secondly, in the following assembler, can you explain in layman's terms what is going on?
I've tried annotating the code:
Code: Select all
// Define symbol my_out_func to be the current pc
// Load the word at the address of the my_port symbol into r11.
// dp relative addressing is used (explained above).
ldw r11, dp[my_port]
// Output the value in r0 to resource whose resource identifier is held in r11
out res[r11], r0
// Jump to the value of lr (i.e. return from the function)
If the port is in its default mode (no serialisation or ready signals) then this instruction sequence will drive the value in r0 to the port's pins on the next falling edge of port's clock.