Hi Kurenai ryu
I am starting to read you reply in post #10. I have some very basic question on the program. I wrote my question in
RED. This is the first time I read a real assemble code, not just a clip of example. I want to learn how to define the variable, register and all that. So it might be really stupid question.
View attachment 184260
Thank, I still have to read the rest of it.
Can you give me a link how to write a complete program with #include, how to define things and all that?
Thanks
You can define R23 ith a different name?
yes, you can use whatever name you like, you also don't need to use name and use R23 directly... just to note that you can change to aonther free register (like R16 or higher, why? because LDI instruction uses register R16 to R31 to load directly.
are the ":" on the first few lines a mistake?
no, they are comments in the assembly file , I commented the stack initialization as a fresh reset in a microntroller shouldn't need it, but anyway its recommended in case of using a bootloader (like in your board)
RAMEND is 0x08FF it's a 16bit value to represent the last address of the RAM memory. lo8(RAMEND) indeed will get the lower byte, in this case 0xFF, hi8(RAMEND) gets the higer byte so in this case, 0x08
an alternative is to define two constants:
RAMEND_LO 0xFF
RAMEND_HI 0x08
and use them accordingly, but I included ths other way, because it's more readable, as the value you will need is a 16 bit value of 0x08FF but the instructions are only of 8 bits values (very common escenario)
yeah, direct numbers are in decimal 50, for hex values you can append '0x' and for octal values '0' (so be careful of leading 0s)
Should add { and } for sobroutine like below?
in Assembler you don't use brackets {} for subroutines, you usually have a label: and call (rcall) from somewhere in the code, just note that a subroutine should ha a RET instruction somewhere to return from the place it was called.