About: DEF FN   Sponge Permalink

An Entity of Type : owl:Thing, within Data Space : dbkwik.org associated with source dataset(s)

The DEF FN (DEFine FuNction) command can be used to add a total of 52 new functions to Sinclair BASIC; 26 numeric functions (A-Z) and 26 string functions (A$-Z$). Owing to the internal structure of Sinclair BASIC, the best place to store these functions is in line 0. This prevents the line being accidentally edited or deleted and also gives the maximum possible speed (on a standard Spectrum with no Interface I attached, line 1 can be converted into line 0 with POKE 23756,0). A ROM bug, mentioned on states: The FN error (from ZX Computing Monthly - Toni Baker) which is replaced with

AttributesValues
rdfs:label
  • DEF FN
rdfs:comment
  • The DEF FN (DEFine FuNction) command can be used to add a total of 52 new functions to Sinclair BASIC; 26 numeric functions (A-Z) and 26 string functions (A$-Z$). Owing to the internal structure of Sinclair BASIC, the best place to store these functions is in line 0. This prevents the line being accidentally edited or deleted and also gives the maximum possible speed (on a standard Spectrum with no Interface I attached, line 1 can be converted into line 0 with POKE 23756,0). A ROM bug, mentioned on states: The FN error (from ZX Computing Monthly - Toni Baker) which is replaced with
dcterms:subject
abstract
  • The DEF FN (DEFine FuNction) command can be used to add a total of 52 new functions to Sinclair BASIC; 26 numeric functions (A-Z) and 26 string functions (A$-Z$). Owing to the internal structure of Sinclair BASIC, the best place to store these functions is in line 0. This prevents the line being accidentally edited or deleted and also gives the maximum possible speed (on a standard Spectrum with no Interface I attached, line 1 can be converted into line 0 with POKE 23756,0). The more complicated or frequently called functions should be given the higher priority; for example, the MOD function should normally occur first. Where possible, the following functions are compatible or partially compatible with their Beta BASIC equivalents. Some of the numeric functions are restricted to dealing with 8-bit numbers (0-255) while their Beta BASIC equivalents can handle 16-bit numbers. This is because dealing with 16-bit numbers in BASIC would be tortuously slow. Recursive functions can be constructed, but are avoided where possible (in order to permit compilation with HiSoft BASIC). hex4$ = 4 digit hex string ("0000"-"FFFF") posint8 = 8-bit positive integer (0-255) posint16 = 16-bit positive integer (0-65535) string1 = non-null 1 character string string2 = 2 character string A ROM bug, mentioned on states: The FN error (from ZX Computing Monthly - Toni Baker) When a user-defined function is evaluated the value of the system variable (CH_ADD) which stores the address of the next character to be interpreted, is saved on the machine stack instead of in one of the dynamic variables such as (X_PTR) during the evaluation of the function. This means that any user-defined function which causes the BASIC program area to move up or down in memory will cause error report C; Nonsense in BASIC. This is not normally possible, but exceptions can occur if the DEF FN statement contains the function USR, and could also conceivably happen with the function INKEY#X. To avoid this bug you must ensure that any machine code subroutine which is called by a DEF FN statement does not disturb the BASIC program area (e.g. it is impossible to define a function FN D (X,Y) which would delete BASIC lines X to Y inclusive without also manipulating the machine stack). Keep this remark in mind especialy with DEF FN x()=USR adress or with creating a channel. The characters used here are used as example but in some cases DEF FN can depend on other DEF FN when they are nested. This makes them more readable and in some cases faster. So if you copy them have a good look. The EVEN(number, 0 or 1) can save a lot of space since it checks the last BIT of a number so: the last bit-check of the AND FN logicly will hold as last part which is replaced with since it is in fact a Bit_0 check which is an ODD or EVEN check. This saves calculating time as well as space. The characters used so far in this Wiki are: A,B,..,D,E,F,G,..,I,..,..,..,M,N,O,P,Q,..,..,T,U,V,..,..,X,Z A$,B$,C$,...,H$,...,L$,...,Q$,R$,S$,T$,U$,...,W$,...
Alternative Linked Data Views: ODE     Raw Data in: CXML | CSV | RDF ( N-Triples N3/Turtle JSON XML ) | OData ( Atom JSON ) | Microdata ( JSON HTML) | JSON-LD    About   
This material is Open Knowledge   W3C Semantic Web Technology [RDF Data] Valid XHTML + RDFa
OpenLink Virtuoso version 07.20.3217, on Linux (x86_64-pc-linux-gnu), Standard Edition
Data on this page belongs to its respective rights holders.
Virtuoso Faceted Browser Copyright © 2009-2012 OpenLink Software