When I include assembler code into a GCB program for 8-bit AVR, which registers (among R0 to R25) can I use without interfering with those used by the code generated by the compiler ?
Sorry for the misspelling in the title, but I can't modify it anymore ...
Thanks for any answer ...
Last edit: Bertrand BAROTH 2018-02-14
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Byte,word,long word,string,array....
Sir,it's basic. No need for asm. Try gcb as just basic and see it's asm which shows the basic and asm generated together. It's a shock at first. GCB really works!
I use 328 nano/uno with gcb and it's very nice as you can use the teminal from the usb no prob.
avr asm is different to pic asm but I don't bother with either. I haven't found the need yet. Gcb timing is accurate.
Last edit: stan cartwright 2018-02-14
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I thought of ASM to make bit-level operations, for example waiting for inputs, until one bit goes high OR another one goes low (coming from detectors on my railway layout and so capture "shorter" states) and then transmit the corresponding, ready-to-use data to the main prgm, or formatting several data together for one port (3 bits for turnouts + 1 bit for direction + 4 bits for speed selection, pure DC, no PWM : I read it could be harmful for some Z-scale motors and cause radio interferences due to harmonics) but You are right, I can do the same at Basic level, and with the time constants on the detectors it will be fast enough ...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
gcb commands like this do bits
myByteVariable.0 = 1 'will set bit 0 to 1
myByteVariable.1 = 0 'will set bit 1 to 0
myByteVariable.2 = 1 'will set bit 2 to 1
You could also do var1= var2 and var3 to mask a bit (or OR to set)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello everybody.
When I include assembler code into a GCB program for 8-bit AVR, which registers (among R0 to R25) can I use without interfering with those used by the code generated by the compiler ?
Sorry for the misspelling in the title, but I can't modify it anymore ...
Thanks for any answer ...
Last edit: Bertrand BAROTH 2018-02-14
You just use variable names - do not be troubled by the registers let Great Cow BASIC handle the variables.
Thanks for Your answer ; I think that the variables to be used (with most instructions) should be of single byte type ?
Last edit: Bertrand BAROTH 2018-02-14
Depends - what are you trying to do? Typically, you should be able to avoid ASM. Can you share your project goals and why you need ASM?
Byte,word,long word,string,array....
Sir,it's basic. No need for asm. Try gcb as just basic and see it's asm which shows the basic and asm generated together. It's a shock at first. GCB really works!
I use 328 nano/uno with gcb and it's very nice as you can use the teminal from the usb no prob.
avr asm is different to pic asm but I don't bother with either. I haven't found the need yet. Gcb timing is accurate.
Last edit: stan cartwright 2018-02-14
I thought of ASM to make bit-level operations, for example waiting for inputs, until one bit goes high OR another one goes low (coming from detectors on my railway layout and so capture "shorter" states) and then transmit the corresponding, ready-to-use data to the main prgm, or formatting several data together for one port (3 bits for turnouts + 1 bit for direction + 4 bits for speed selection, pure DC, no PWM : I read it could be harmful for some Z-scale motors and cause radio interferences due to harmonics) but You are right, I can do the same at Basic level, and with the time constants on the detectors it will be fast enough ...
You do all that without using ASM. The compiler generates optimised asm and therefore will operate at clock frequency.
gcb commands like this do bits
myByteVariable.0 = 1 'will set bit 0 to 1
myByteVariable.1 = 0 'will set bit 1 to 0
myByteVariable.2 = 1 'will set bit 2 to 1
You could also do var1= var2 and var3 to mask a bit (or OR to set)
And, I guess - check out the 100s of demonstrations they show most operations in real code.
The Help is key - for inputs and outputs on AVR the Help addresses the correct syntax.
But, welcome to the world of Great Cow BASIC.