Hi all,
I am using the SDCC for my ZBM project and have begun writing a library so the C program can interface with system calls (RST). I am having some trouble with this and the manual is not very helpful at all. When I generate the output assembly and go through it the first variation of C code produces a sensible output. The second variation does not.
Here is the first C program:
And this is the assembler it produces:
This makes sense and I like it. Register A holds the character (not sure why it is pushing af then increment the sp though).
Here is the second variation that DOES NOT make sense.
This is the generated output
Why is it exchanging the variable found in the stack pointer with hl? And why is it now using register l instead of a like before? My printChar function relies on the same register being used every time. I dont care if it is a or l but I cant have SDCC keep changing its mind :S
Any help?
I am using the SDCC for my ZBM project and have begun writing a library so the C program can interface with system calls (RST). I am having some trouble with this and the manual is not very helpful at all. When I generate the output assembly and go through it the first variation of C code produces a sensible output. The second variation does not.
Here is the first C program:
Code:
printChar('a');
userinput = getline();
printString(userinput);
Code:
;Source\main.c:11: printChar('a');
ld a,#0x61
push af
inc sp
call _printChar
inc sp
;Source\main.c:12: userinput = getline();
call _getline
ld (_userinput),hl
;Source\main.c:13: printString(userinput);
ld hl,(_userinput)
push hl
call _printString
pop af
Here is the second variation that DOES NOT make sense.
Code:
userinput = getline();
printString(userinput);
printChar('a');
Code:
;Source\main.c:12: userinput = getline();
call _getline
ld (_userinput),hl
;Source\main.c:13: printString(userinput);
ld hl,(_userinput)
push hl
call _printString
;Source\main.c:14: printChar('a');
ld h,#0x61
ex (sp),hl
inc sp
call _printChar
inc sp
Any help?