I am planning to do something in C for Oric and I need
the Basic's functions PLOT and SCRN.
In the OSDK the hello_world_advanced is included
in the C samples. In this project there is a function
written in assembly which is called AdvancedPrint and is
equivalent to PLOT (I think so).
Is the Basic's SCRN already implemented somehow in C?
If not, then I would prefer to prepare something in assembly.
The AdvancedPrint demonstrates how to read arguments
passed from a call from C (use of sp variable). Can anyone
please tell me how can I return a value (say a char) from
assembly to C?
Thanks
V.
C - Assembly
Re: C - Assembly
Depends of the performance you are looking for, but the PLOT and SCRN functions can be implemented like that in C:
Disclaimer: Just typed on the message, not tested
Code: Select all
void PLOT(unsigned char x,unsigned char y,unsigned char car)
{
unsigned char* screen=(unsigned char*)0xBB80;
screen[x+(int)y*40]=car;
}
unsigned char SCRN(unsigned char x,unsigned char y)
{
unsigned char* screen=(unsigned char*)0xBB80;
return screen[x+(int)y*40];
}
Re: C - Assembly
Thanks Dbug. I will use this for the moment, see how things go
and decide if I need something funkier.
V.
and decide if I need something funkier.
V.
Re: C - Assembly
Dbug wrote:Depends of the performance you are looking for, but the PLOT and SCRN functions can be implemented like that in C:
Disclaimer: Just typed on the message, not testedCode: Select all
void PLOT(unsigned char x,unsigned char y,unsigned char car) { unsigned char* screen=(unsigned char*)0xBB80; screen[x+(int)y*40]=car; } unsigned char SCRN(unsigned char x,unsigned char y) { unsigned char* screen=(unsigned char*)0xBB80; return screen[x+(int)y*40]; }
void PLOT(int x,int y, char car)
{
screen[x+(y+1)*40]=car;
}
unsigned char SCRN(int x,int y)
{
return screen[x+(y+1)*40];
}
The first line is not accessible by Basic's PLOT so you need to increase y by 1.
V.
Re: C - Assembly
Please correct me if I am wrong. The register A contains the highvrozos wrote: Can anyone
please tell me how can I return a value (say a char) from
assembly to C?
V.
and the register X the low value of the address where function
result is stored.
V.
Re: C - Assembly
Not sure if I that is correct. In fact the returned value, I think, is always a 16-bit number stored in A and X (can't remember which one holds the high byte and which the low byte), not the address of the value.vrozos wrote:Please correct me if I am wrong. The register A contains the highvrozos wrote: Can anyone
please tell me how can I return a value (say a char) from
assembly to C?
V.
and the register X the low value of the address where function
result is stored.
V.