![]() |
Routines |
| Prev: 08020 | Up: Map |
|
The address of this routine is found in the parameter table.
During syntax checking a DEF FN statement is checked to ensure that it has the correct form. Space is also made available for the result of evaluating the function.
But in 'run-time' a DEF FN statement is passed by.
|
||||||||||
| DEF_FN | 08032 | CALL SYNTAX_Z | Jump forward if checking syntax. | |||||||
| 08035 | JR Z,DEF_FN_1 | |||||||||
| 08037 | LD A,206 | Otherwise pass by the 'DEF FN' statement. | ||||||||
| 08039 | JP PASS_BY | |||||||||
|
First consider the variable of the function.
|
||||||||||
| DEF_FN_1 | 08042 | SET 6,(IY+1) | Signal 'a numeric variable' (set bit 6 of FLAGS). | |||||||
| 08046 | CALL ALPHA | Check that the present code is a letter. | ||||||||
| 08049 | JR NC,DEF_FN_4 | Jump forward if not. | ||||||||
| 08051 | RST 32 | Fetch the next character. | ||||||||
| 08052 | CP "$" | Jump forward unless it is a '$'. | ||||||||
| 08054 | JR NZ,DEF_FN_2 | |||||||||
| 08056 | RES 6,(IY+1) | Reset bit 6 of FLAGS as it is a string variable. | ||||||||
| 08060 | RST 32 | Fetch the next character. | ||||||||
| DEF_FN_2 | 08061 | CP "(" | A '(' must follow the variable's name. | |||||||
| 08063 | JR NZ,DEF_FN_7 | |||||||||
| 08065 | RST 32 | Fetch the next character. | ||||||||
| 08066 | CP ")" | Jump forward if it is a ')' as there are no parameters of the function. | ||||||||
| 08068 | JR Z,DEF_FN_6 | |||||||||
|
A loop is now entered to deal with each parameter in turn.
|
||||||||||
| DEF_FN_3 | 08070 | CALL ALPHA | The present code must be a letter. | |||||||
| DEF_FN_4 | 08073 | JP NC,REPORT_C | ||||||||
| 08076 | EX DE,HL | Save the pointer in DE. | ||||||||
| 08077 | RST 32 | Fetch the next character. | ||||||||
| 08078 | CP "$" | Jump forward unless it is a '$'. | ||||||||
| 08080 | JR NZ,DEF_FN_5 | |||||||||
| 08082 | EX DE,HL | Otherwise save the new pointer in DE instead. | ||||||||
| 08083 | RST 32 | Fetch the next character. | ||||||||
| DEF_FN_5 | 08084 | EX DE,HL | Move the pointer to the last character of the name to the HL register pair. | |||||||
| 08085 | LD BC,6 | Now make six locations after that last character and enter a 'number marker' into the first of the new locations. | ||||||||
| 08088 | CALL MAKE_ROOM | |||||||||
| 08091 | INC HL | |||||||||
| 08092 | INC HL | |||||||||
| 08093 | LD (HL),14 | |||||||||
| 08095 | CP "," | If the present character is a ',' then jump back as there should be a further parameter; otherwise jump out of the loop. | ||||||||
| 08097 | JR NZ,DEF_FN_6 | |||||||||
| 08099 | RST 32 | |||||||||
| 08100 | JR DEF_FN_3 | |||||||||
|
Next the definition of the function is considered.
|
||||||||||
| DEF_FN_6 | 08102 | CP ")" | Check that the ')' does exist. | |||||||
| 08104 | JR NZ,DEF_FN_7 | |||||||||
| 08106 | RST 32 | The next character is fetched. | ||||||||
| 08107 | CP "=" | It must be an '='. | ||||||||
| 08109 | JR NZ,DEF_FN_7 | |||||||||
| 08111 | RST 32 | Fetch the next character. | ||||||||
| 08112 | LD A,(23611) | Save the nature - numeric or string - of the variable (bit 6 of FLAGS). | ||||||||
| 08115 | PUSH AF | |||||||||
| 08116 | CALL SCANNING | Now consider the definition as an expression. | ||||||||
| 08119 | POP AF | Fetch the nature of the variable and check that it is of the same type as found for the definition (specified by bit 6 of FLAGS). | ||||||||
| 08120 | XOR (IY+1) | |||||||||
| 08123 | AND 64 | |||||||||
| DEF_FN_7 | 08125 | JP NZ,REPORT_C | Give an error report if it is required. | |||||||
| 08128 | CALL CHECK_END | Exit via CHECK_END (thereby moving on to consider the next statement in the line). | ||||||||
|
This routine continues into UNSTACK_Z.
|
||||||||||
| Prev: 08020 | Up: Map |