I feel for you, I did assembly for over 40 years, and switching to any high level language drove me batty. Over time I learned to let the tools do what they do best and not try to make the decision for them. Do you really care what registers it uses, probably not. If you do then you need to do it in Assembler. As you get into the language there are a few things like upper, lower etc, It is hard but it works. If speed is a problem use a faster processor, they are cheap. If you dig into what is available you can actually read each individual port.
My project is to control a Robot-arm. Using a 3 Axis Gyro.
(I have thought of a GSM- module, but as the Robot arm- base is fixed (only the Robot arm is movable), and I want to be able to (re)-position the head (grab ??) to any (pre) position I might want. I already have the Robot-arm. )
And to be honest. YES, I do care about the content of the registers (espicially the registers in the Analog Digital Control block), because I need to use these registers in a project , where in periods the ADC block will be heavily loaded. By examining these registers (and an careful analysis), I have a hope that the results will make me better in understanding what is actually happening in these registers (and as such a better programmer).
And YES, i know that these registers in a ATM2560 (as far as I remember) is only accessible by using the Z-index pointer,, but I have read ( somewhere ??? - "luckily forgot" (sigh)) that IT IS possible to read any IO-Port by using the Z-pointer. But I do not know why for the IO-port in the lower memory (IO) block.
I am in the same boat buy you have a step up on me, I know virtually nothing about the inner workings of the micro. I did that deliberately so I could learn the language. I am fairly sure the Arduino language supports inline assembler, try this link: Arduino Inline Assembly Tutorial #1 (Basic asm) | µC eXperiment All I know is that An inline assembly statement is processed as a string which specifies assembler code. The string can contain any instructions recognized by the assembler, including directives. GCC does not parse the assembler instructions and does not know what they mean or even whether they are valid. Multiple assembler instructions can be placed together in a single asm string. Hopefully the link will fill in the blanks.
Yes, it’s possible.
There is a big gap between registers A-G and registers H-K.
A-G are in low memory and will need to have 0x20 added to their symbol values. (PORTA is at 0x20 when you use LD, but at 0x0 when you use IN.)
You can use X or Y to hold the address as well. Use: