Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Locomotive BASIC
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Machine code support and RSXs == Machine code is well supported (but not to the impressive heights of the BBC Micro's, in-line assembler). There is an easy method of allocating "safe" memory (see below) and once loaded either from disc or cassette or <CODE>POKE</CODE>d in, Z80 machine code can be executed with <code>CALL <addr></code>. CALL supports a method to pass parameters to the machine code using BASIC variables (including strings) using the form <CODE>CALL <addr>,Q,@X$</CODE>. Integer variables and integer immediates can be passed directly as their value (ByVAL). All variables, but specifically strings can be passed using the <CODE>@</CODE> directive, which points to the address of the variable descriptor (ByREF). Thus, transfer of data in both directions between a BASIC program and machine code is trivial. Another method, leveraging the firmware, allows for named sections of machine code using a feature known as Resident System eXtensions (RSX). Although not a purely BASIC feature, Amstrad BASIC embraces this mechanism of RSXs and the names can be used in the BASIC program as if they were reserved keywords - each being prefixed with the bar <CODE>|</CODE> symbol, the remaining syntax being identical to CALL. e.g. <CODE>|MYRSX,Q,@X$</CODE> (note a comma is required between the RSX name and any arguments). The code for the RSXs has a very specific header structure - the RSX names, their entry points and 4 bytes of scratchpad RAM for the firmware to link in and out of the list. A call is made using the KERNEL routine $BCD1 KL_LOG_EXT to initialise the names and they are then available to use throughout the system (by finding each named section using $BCD4 KL_FIND_COMMAND - BASIC does this for | commands). A major advantage of RSXs is not needing to know the address of a piece of machine code, in whatever bank (CALL can only access the main 64KB address map, however configured) - the KERNEL returns the parameters necessary to execute the code in question no matter where it resides, in the entire memory map and in all ROM/RAM banks (see "bank switching" below). Code can simply call sideways by searching for the RSX name and from the link structure, the firmware immediately knows the required ROM/RAM bank configuration. <CODE>KL_SIDE_CALL</CODE>, <CODE>KL_SIDE_PCHL</CODE> etc. is used to run the machine code. Thus all memory is usable for machine code program. Use of RSXs ensures that machine code in sideways ROMs is fully integrated with BASIC and the disc commands <CODE>|DIR, |A, |TAPEIN, |ERA</CODE> etc. all reside in ROM and are used throughout BASIC program code. On the CPC464, disc commands were only added when the FDI1 (floppy disc interface, with its sideways ROM) is plugged in the rear expansion port. In UK CPC circles at that time, it was popular to [[pun]] words that began with "bar" and name RSXs accordingly, e.g. |BQ, |BARASTREISAND, |STARD etc.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)