what should you learn from if all the tips are no longer correct. there is nothing from sdcc in the bible and I have it at home.
thanks.
greeting
You are using inappropriate sources for learning. That's not tips being incorrect, that's a bad selection of outdated sources. You have a folder in CPCtelera full of examples to start. You don't need inline assembly as a starting point. In fact, you are constantly asking about things that are not from CPCtelera: you are asking on how to program, how to use SDCC compiler and how to call CPC firmware functions. All of this is not CPCtelera: this is programming the CPC. It has nothing to do with CPCtelera. CPCtelera is just providing you the compiler and the build system.
My Youtube channel is full of videos in which I teach how to program the CPC using CPCtelera also (
This list is for programming in C, for instance). They are in Spanish, but you can use them as sources for learning assembly and C programming for the Amstrad (either just by looking at the images or using automatic translation, which is far from perfect, but may be worthwhile). Another thing you need to learn is who calling conventions work, and which calling conventions does SDCC use if you want to create assembly functions.
As I told you before, you should start with examples up to your level. Start with drawing and moving a sprite using CPCtelera. You have ready-to-use examples in the examples folder. Why not to start playing with some of them? Why start inlining assembly, doing everything lowlevel and by-hand? If that is what you want to learn, you may think of assembly programming tutorials and books. You can also program assembly directly with CPCtelera.
In this example you have the very same mistake you had in the previous example. SDCC does not put IX pointing to the frame base of the stack anymore. Therefore, you are simply filling your registers with random values, as IX will be pointing anywere (probably to 0000 in this example). This fails exactly the same way as your previous example failed, and you are gaining nothing by copying/pasting these examples one by one without knowing what happens. It's much preferable that you start with C examples (like those in CPCtelera folder) that do not require you to know about assembly calling conventions and how the compiler works.
Anyway, a proper version of this example would be this one:
void BasicMove(u16 x, u16 y) __naked __z88dk_callee {
x;y;
__asm
pop hl
pop de
ex (sp), hl
jp 0xBBC0
__endasm;
}
void BasicDraw(u16 x, u16 y) __naked __z88dk_callee {
x;y;
__asm
pop hl
pop de
ex (sp), hl
jp 0xBBF6
__endasm;
}
void drawLine(u16 x1, u16 y1, u16 x2, u16 y2) {
BasicMove(x1,y1);
BasicDraw(x2,y2);
}
int main() {
drawLine(0,0,100,25);
drawLine(0,50,100,25);
drawLine(0,150,100,25);
while(1);
}
So, for proper learning:
- SDCC is a C compiler. Most important part is programming in C, not in SDCC. Learning should be: first master C, then carefully read SDCC manual.
- CPCtelera is a build system + a low-level library. If you know how to program in C, you can use it from the start. No need for assembly: just call CPCtelera functions, like in the examples. Use the examples as a start point for learning, then go to the documentation to understand what the functions do. Then use them in your own creative ways
- For amstrad CPC Firmware calls (like BBC0 and BBF6) you can read in the Firmware manual.
- For Z80 assembly you have many books on the subject, and many of them also dedicated to the Amstrad. There are many of such resources here in the forum.
- Finally, if you know assembly, C, calling conventions, Amstrad internals and know how SDCC internally works, then you can write your own assembly functions to be called from C. This is, by far, the most difficult and final part of the way. And you are trying to start from here.
Complementary, there is all the videos from my own youtube channel and others (like
Keith / Chibi Akumas, for instance) and many other resources that you may use.