Waldek Hebisch wrote:
Note that it depends on your OS what will be at the address 0x80000. If you try to access video memory after entering protected mode, but before you initialize memory management your OS will crash.
I think I will just leave out the first 1MB altogether and consider it off-limits. Then I can safely use the video buffer there, identity mapped, as the buffer for kprintf() or KWrite/KWriteLn as the case would be in Pascal.
Also variables and pointer types used to access hardware should be marked `volatile', but I just noticed that currently GPC does not allow this...
So perhaps I will have to compile without any optimisations so that no optimisations are performed that might mess things up.
In general GPC uses the same calling convention as C. However, Pascal has much more possibilities for parameter passing then C (variable parameters, conformal arrays) and extra types. Also, GPC adds some extensions to standard Pascal. Things which are not present in C are mapped to C-like constructs -- for example variable parameters are implemented by passing pointers (addreses of the parameters).
That's good. So to implement a printf-like function I am not looking at pass by value, I just need to remember I am dealing with pass by reference in all cases for varargs functions.
It is fairly easy to link-in alternative runtime library (or no runtime library at all), just use gcc as a linker. OTOH GPC assumes presence of runtime support and generates calls to support routines when needed. So you have to provide support routines for all constructs that you use. As first approximation operations on strings, sets and files and memory (de)allocation are implemented by runtime calls.
Thanks very much, that's been very useful information.
I will implement my own string functions, memory allocation, file handling and basic I/O and leave out the rest, being careful not to use it. I will probably not use sets or anything like that, or any object orientation. The closest I will get is using the C equivalent of struct, i.e. the record type.
Thanks, :) JD