Review of Native Documentation (Part 2 - Design Issues)
Posted: 17 January 2008, 22:29 PM
I have reviewed the modified documentation for the native mode devices. I concentrated on chapter 4 and the Resource Usage section. I have the following design/implementation questions:
- Defining external routines for use by ZBasic code is good. However mistakes can be made. It would be good if there was a ZX compiler flag to generate the C prototypes. Then these could be used to either verify correctness of the C code or as a starting point to write the implementation. If the signatures get changed then the programmer is on their own to apply the newly generated signatures to existing C code.
- Can the alias feature be applied to regular ZBasic sub/functions or only those that are declared? There would be no harm in allowing this synonym capability. If so then the description of the alias feature in section 3.21 needs to be extended.
- Can an ISR be called from (or jumped to) from another ISR? This then leads to the idea of declaring an ISR as having an external alias.
- A naked ISR might be better declared as ISR Timer1_CompB() Attribute(Naked), thereby using the same ATTRIBUTE keyword with a value rather than adding yet another specialized keyword (Naked).
- Presumably an ISR is always Public by default and could be declared as PUBLIC ISR Timer1_CompB(). What happens if someone declares a PRIVATE ISR? This is a compiler error? Or could PRIVATE be used as a scoping check to someone tried to Call or Jump into an ISR, this wouldn't be allowed by the ZBasic compiler.
- Presumably the unhandled interrupt error is retrievable using Register.FaultType. The text on the top of page 90 should clarify this fact.
- The new functions DisableInt()/EnableInt() describe what the function implements rather than what it does. If this was renamed to something like Enter/ExitCriticalSection then these same routines could also be used in regular ZBasic code.
- If an ISR is written in C, how can it update the RTC if needed? Is there a way for C code to call the ZBasic provided library functions such as calling zf_UpdateRTC. I couldn't find a description of this anywhere.
- An atomic block construction achieves the same as calls to DisableInt()/EnableInt() but without the nesting which could be a problem. There should really only be one solution to this problem. DisableInt()/EnableInt() at its simplest could result in a function that is inlined or is that what Atomic does?