I downloaded and successfully used the driver listed above on a HCS09GB60. A couple of notes:
1) The code is a expanded mix of the examples in the data book and the "Standard Software SGF Driver for HCS08". Don't let the comments at the top of the source code think you are using the SGF (which is available).
2) For the HCS08, the correct call from C would be as follows. Note the order of the parameters differs from the example above. (sorry, I renamed the functions):
byte Flash_Init(byte fcdiv);
byte Flash_Erase(char* dest);
byte Flash_Write(char* dest, char* source, byte length);
3) For the Flash_Write, note the length is of type byte. This means you can only write 255 bytes at a time (This could be fixed but the 255 byte limit works for me).
4) The include file "9s08gb60.inc" is out dated: Use "mc9s08gb60.inc" located in the
{compiler}\lib\hc08c\device\asm_include directory. I had to put this into my project "User" paths so it would not find the wrong one.
5) Perhaps obvious but, don't for get that you must erase the block of data (512 bytes) before you can write it. So if you want to update one byte, you must read then entire block from FLASH to RAM, update your byte in RAM, erase the FLASH and write the block back to FLASH.
6) The Flash_Init function should only be called once at power up.
7) Make sure you have enough stack for the loaded code to run in RAM. (I get 51 bytes)
Bill