# The Firmware Guide - Summary

The Firmware Jumpblock is the recommended method of communicating with the routines in the lower ROM - it is used by BASIC, and it should also be used by other programs. The reason for using the jumpblock is that the routines in the lower ROM are located at different positions on the different machines. The entries in the jumpblock, however, are all in the same place - the instructions in the jumpblock redirect the computer to the correct place in the lower ROM. Thus, providing a program uses the jumpblock, it should work on any CPC computer. By altering the firmware jumpblock it is possible to make the computer run a different routine from normal. This could either be a different routine in the lower or upper ROM, or a routine written by the user - this is known as 'patching the jumpblock'. It is worth noting that because BASIC uses the firmware jumpblock quite heavily, it is possible to alter the effect of BASIC commands. The following example will change the effect of calling SCR SET MODE (&BC0E) - instead of changing the mode, any calls to this location will print the letter 'A'. The first thing to do is to assemble the piece of code that will be used to print the letter - this is printed below and starts at &4000.

`ORG &4000
LD A,65 ; 65 is ASCII FOR 'A'
CALL &BB5A ; TXT OUTPUT
RET ; return from subroutine
`

The jumpblock entry for SCR SET MODE is now patched so that it reroutes all calls to &BC0E away from the lower ROM and to our custom routine at &4000. This is done by changing the bytes at &BC0E, &BC0F and &BC10 to &C3, &00, &40 respectively (ie JP &4000). Any calls to &BC0E or MODE commands will now print the letter A instead of changing mode. The indirections jumpblock contains a small number of routines which are called by the rest of the firmware. By altering this jumpblock, it is possible to alter the way in which the firmware operates on a large scale - thus it is not always necessary to patch large numbers of entries in the firmware jumpblock. There are two jumpblocks which are to do with the Kemel (ie the high and low Kernel jumpblocks). The high jumpblock allows ROM states and interrupts to be altered, and also controls the introduction of RSXs. The low jumpblock contains general routines and restart instructions which are used by the computer for its own purposes.