0: 174270
32: 0
The first word is the address of the dispatcher. The second is the word that is loaded into the processor status word (PS) when entering the interrupt routine. 0 means that all interrupts are allowed while the EMT manager is running.
The following is a block diagram of an EMT dispatcher with explanations:
The diagram shows that the dispatcher calls the subroutine, the address of which is determined by the following formula:
Adr = (160000 + XXX), where XXX is the low byte of EMT.
In other words, from the address 160000, a table is stored that contains the addresses of the desired routines. Of course, the low byte of EMT should be even, in order to avoid misunderstandings in the processor.
ROM addresses from 160000 to 160012 store some interrupt vectors, therefore EMT with low bytes is used, starting with 14. There are only 10 useful routines called by the EMT manager. A list of them is given in the appendix. The remaining routines consist of one command - RETURN.
<Scheme 4.0>
The TRAP dispatcher vector is written at address 34:
34: 174344
36: 200
The second word says that during the operation of the TRAP-manager interrupts from the network and programmable timers, from the keyboard, from the RESET command in the CPU, from channel interruptions will be prohibited.
The block diagram of the TRAP dispatcher looks like this:
<Scheme 4.1>
The routine address is calculated as follows:
Adr = (160160 + XXX), where XXX is the low byte of TRAP.
Those. subprogram addresses are stored from address 160160. There are only 3 of these subprograms, i.e. only three TRAP commands make sense:
TRAP 0,
TRAP 2,
TRAP 4.
The difference between them and EMT routines is that they should end on RTI, and not on RETURN.
Information on the screen is sent byte by byte. Each processor can have access to the output of symbolic and graphic information to the terminal. For this, each processor has its own path.
The CPU sends information through K0. PP sends it through EMT commands. But in any case, these bytes are written to a special area of the RAM RAM called the buffer. It is located in addresses from 2000 to 2177 (200 bytes).
The buffer allows you not to wait until the sent byte is displayed on the screen (in one way or another), and represents a "queue" of bytes ready for processing (output) - Fig. 5.0.
<Figure 5.0>
The variable in the RAM RAM (22544) is a pointer to the tail of this queue. That is, it contains the address of the cell where the next incoming package will be recorded (from the CPU or the PC).
When recording from the CPU to channel K0, with an allowed interrupt from the receiver, the interrupt from the receiver 320. If interrupts are disabled, then there is another way to read information from K0 into the buffer - this is the TRAP 4 command. Then, if the message was valid (the readiness bit was set in the receiver), the information is read into the buffer from the corresponding data register.
Both bp from K0 and TRAP 4 are essentially the same program, but with different entry points (Figure 5.1).
<Scheme 5.1>
A few more variables are used here. Their meaning is as follows:
Table 5.1
Address | Appointment |
704 2 | Enables or disables communication with the CPU through K0: 0 - communication is prohibited, 1 - communication is allowed. |
7064 | Counter of bytes to be processed. May contain from 0 to 177. |
22546 | Sign of buffer overflow. If (7064) = 177, and a new byte arrives, it will not be written to the buffer, and (22546) is assigned 2 (overflow). Resets via TRAP 4. |
The buffer can also be replenished from the PP. Three commands can be used for this: EMT 42, EMT 44 and EMT 46.
EMT 42 writes the low byte of R0 to the buffer, EMT 44 - the line whose address is contained in the word following the command, and EMT 46 - the line with the address in R1.
Figure 5.2 shows the execution of these commands. Since EMT routines can also be called via CALL, the diagram shows the addresses of additional entry points.
<Scheme 5.2>
If you execute, for example, such an excerpt from the program:
JSR R5, @ # 117204
.WORD A
.
.
A: ASCIZ / *** WHY DO YOU EMT 44? *** /
then a line is loaded into the buffer, the starting address of which is A. This will be somewhat faster than using the fragment:
EMT 44
.WORD A
.
.
A: ASCIZ / *** WHAT WOULD YOU DO WITHOUT EMT 44? *** /
since the call to the EMT dispatcher is bypassed.
Note that with the buffer pointer after the increase, the & ~ 200 command is executed, which prevents it from exceeding the value 2177.
- the interrupt from the receiver K0 is triggered.
- when calling TRAP 4.
Table 5.2
What we write and where | Ways to achieve | |
With immediate withdrawal | Without it | |
1 byte from R0 | EMT 42 | CALL @ # 117136 |
A string whose address is in R1 | EMT 46 | JSR R5, @ # 117206 |
A string whose address is A | EMT 44 Word a | JSR R5, @ # 117204 .WORD A |
Immediate display methods differ by executing TRAP 0 at the end of the subroutine.
Of all the procedures performed by the software, TRAP 0 is perhaps the most necessary and indispensable. In addition to the output to the screen, she is responsible for many other I / O functions, as well as some internal functions.
TRAP 0 can also be called a process manager , which coordinates the work of external devices, adjusting to their needs (and to the needs of the user, in the end) all the resources that are wired into ROM.
The TRAP 0 routine itself is laconic. It is just short (you can take a look at the 6.0 scheme). However, understanding her work immediately will be quite difficult. Therefore, in a simplified manner, we consider the "management strategy" in the RAM RAM.
We trace what happens in the criminal code when the power is turned on.
Further, all the work of the software goes through the process manager. How does this happen?
There is a table in RAM RAM at addresses from 7060 to 7102. We will call it a query table and try to explain this name.
Each word in the table has its own task:
7060 - processing information from the keyboard,
7062 - loading from WU,
7064 - screen output,
7066 - cursor control,
7070 - menu "Setting modes",
7072 - me "Download",
7074 - work with the printer,
7076 - start a user routine,
7100 - testing,
7102 - exit to the process manager (back).
Their normal state is zero. If you need to perform any of the above processes, 1 is added to the contents of the corresponding cell.
The process manager works on a cycle basis and scans the query table in its work. Having found a cell from the table nonzero (and he looks through them in order), the dispatcher calls the corresponding subroutine, i.e. the process itself. The addresses of such routines compose their own label — a table of process addresses.
This table is located in the ROM at the addresses 174232 ... 174252, i.e. contains 9 addresses. The last cell in the query table 7102 does not match the address in the process address table.
How and when does the contents of the query table change? We have already met with cell 7064 - each time it is written to the byte buffer, it is incremented. As you can see from the table, this cell is really responsible for the on-screen output. If it is set (not equal to 0), the dispatcher starts the screen output routine, and it already processes the information written to the buffer, subtracting the unit from (7064) after each processed byte. This is repeated until the cell is reset to zero. Then there is a return to the process manager and the scan continues.
Other processes treat their request cells in a similar way, with some decrementing and others immediately zeroing them out.
The increase or installation of requests is carried out "from the side", mainly by interrupts: from the keyboard, from channels, from the network timer.
The cell with the address 7102 - the last of the query tables - does not change its value - 1, and serves to resume the cycle of the process manager.
Immediately after the query table in RAM, another table follows - the table of vectors. If one of the processes is executing, and another process must be executed from it without completing the current one, then TRAP 0 is called (as is done from EMT 44, for example). The vector of the interrupted process, or rather, the current address is rewritten in the vector table. In it, each cell also corresponds to a process. The difference between the addresses of the "same" cells of the query table and the vector table is 24.
By executing the process for which it was called, TRAP 0 finds the installed cell in the query table. Depending on the contents of the vector table (or rather, its cell to which the established request corresponds), TRAP 0 either returns to the interrupted old process via JMP (in the vector table - a nonzero vector) or starts the process via CALL (in the vector table - 0) .
Minor subtlety: TRAP 0 cannot execute a process that is “below” the one from which it was called. That is, called from the screen output program (request address - 7064), it will not reach requests whose addresses are more than 7064 and can only process keyboards and external devices. Therefore, the processes are arranged in decreasing order of importance.
Example 12. Interception of requests.
The vector table is the most convenient loophole for intercepting processing of requests for processes. Let's try to intercept the processing of requests for the cursor tracking process.
In the PP monitor, record the following:
41000 : 042737 BIC # 200, @ # 177716
000 200
177716
052737 BIS # 200, @ # 177716
000200
177716
004737 CALL @ # 176056
176056
012737 MOV # 41000, @ # 7112
041000
007112
000137 JMP @ # 174222
174222
7112: 041000
Each time you access the cursor tracking process, a piezodynamic click will now sound.
All procedures executed by the software can be divided into internal and external relative to the process manager. Internal - processes controlled by the dispatcher. External ones are subroutines not controlled by the dispatcher (interrupt routine).
External procedures do not have the right to call TRAP 0, this will lead to the fact that the process manager will "fly out" of the loop and the machine will freeze.
The addresses of the vector query tables, as well as the contents of the task table are shown in table 6.0:
Table 6.0.
N | Process | Request Address | Vector Address | Process address |
one | Terminal input | 7060 | 7104 | 104306 |
2 | Download from WU | 7062 | 7106 | 125030 |
3 | Terminal output | 7064 | 7110 | 111144 |
four | Cursor control | 7066 | 7112 | 176056 |
five | Menu "Setting modes" | 7070 | 7114 | 100040 |
6 | Download Menu | 7072 | 7116 | 100742 |
7 | Work with printer | 7074 | 7120 | 176076 |
eight | User routine | 7076 | 7122 | 176116 |
9 | Testing | 7100 | 7124 | 176460 |
ten | Process manager cycle | 7102 | 7126 | - |
Example 13. Interception of a cycle of the manager of processes. Method 1
The last word of the vector table 7126 contains the number 174222 (address of the restart of the process manager). In principle, nothing prevents you from writing another address there, and do something like continue the process manager on it.
Our process will remain the same - click:
41100: 042737 BIC # 200, @ # 177716
000200
177716
052737 BIS # 200, @ # 177716
000200
177716
000137 JMP @ # 174230
174230
7112: 000000
7126: 041100
Do not be surprised, however, that after the changes made, everything will remain as it were, as it were - quiet and smooth. The PP monitor is the reason for this - it is part of the "Installation" menu process, and as long as you are in it, the process manager will not reach the end of the query table, which means that it will also restart request. Exit this menu, and if you do not immediately get into the "Download" menu, which, by the way, is one of the processes, you will hear sound with a frequency of about 10 kHz.
Example 14. Interception of a cycle of a manager of processes. Method 2
Let's see what happens if you reset the restart vector of the process manager: (7126) = 0. Then the dispatcher will process the restart process through CALL, taking the address from the table of process addresses in the ROM. But such an address is not provided for the restart process, and the dispatcher will take the first cell after the table. Its contents are 13700, which means that the subroutine will be called at address 13700. This is the second way to bring the dispatcher cycle to its ending. The exit from this ending should be through RETURN.
13700: 000137 JMP @ # 41200
041200
41200: 042737 BIC # 200, @ # 177716
000200
177716
052737 BIS # 200, @ # 177716
000200
177716
000207 RETURN
7126: 000000
Filling this example and exiting all the menus, you will hear a sound. So, we taught the process manager to whistle.
Everything that is included in paragraph 4 is called by the process manager.
1) internal to the process manager (the processes themselves),
2) external to it (initial start-up program, interrupt routines).
So, we figured out the buffer and the dispatcher. Consider this ordinary situation: the software “circles” in the Manager, scanning the query table and looking forward to the execution task.
Now let the CPU send a byte on channel K0 (it does not matter which one so far). The interrupt from the receiver K0 from the PP will work. Our byte will be written to the buffer, the buffer pointer will change.
Cell (7064) in the query table will also be installed. The interrupt routine ends and control returns to the Manager. It detects that a request has been received for screen maintenance (cell (7064) is not 0) and starts the screen output routine, the address of which is in the task table.
This address is 111144.
It is hardly worth rushing to describe this subroutine right away. Actually, it’s not very complicated. It will simply be more convenient to approach her from the other side.
Of the many tricks laid down in the Criminal Code by developers, this, at first glance, does not strike the eye. However, without it, the Criminal Code is not the Criminal Code.
Suppose you are working in BASIC, or in the remote debugger, and it was necessary, for example, to change the color of the symbol. What are you doing? Press the "SET" key. What's happening? The "Set Modes" menu appears. Having performed the necessary manipulations with this menu, you return again to the same environment where you were, by pressing the "ISP" or "Enter" keys.
In this case, you do not find any changes in the current screen. Even the cursor is in the same place.
In other words, the work in the “Set” menu did not concern your program and your screen. This work was carried out in a different screen. How did this other screen fit in instead of the main working one? Of course, using the row table. She began to point to other addresses at WHO, and thus made visible video information in another area of video memory.
This is the principle of screen separation in the Criminal Code. Instead of copying arrays of video information, preserving the old image, just a few cells in the table of rows just change, and as a result, you see a new screen.
Since the table of lines indicates entire lines, and not their segments, screens in the Criminal Code are horizontal "stripes" over the entire width of the screen, of different heights and locations on the screen.
The system supports 4 standard screens (see Fig. 7.0).
Two of them can be called screens with a stretch. They represent a character string each - service (at the top) and information (at the bottom). These "screens" are always present on the terminal. Each of them contains 40 familiarity.
The service line is used to display the current alphabet (RUS / LAT), indicate the inversion modes, underline, additional keyboard (INV, PODCH, DKL), the mode of indication of control characters (MIS), the mode "Setting modes" (SET). The developers provide for the output of some other inscriptions to the top line, but for some reason the System does not use these features.
The lower info line is not used at all in the System.
For output to these lines are intended EMT 52 and EMT 56. But more about them later. So far, another 2 screens are in line.
They are displayed in the "window" between the service line and the info line. One - let's call him a worker - the most important in the Criminal Code. Almost all user programs work in it.
This screen contains 26 character strings of 80 characters maximum. Of these 26 lines, 24 are always displayed, and the remaining two can be viewed by cyclically moving the screen up or down using terminal commands (UPR + R or UPR + V). Only in this screen does the roll operate, and the "Set Modes" menu changes the modes of this screen (changes colors, the format of the working screen, the type of roll).
And the last standard screen is the service one. It contains 20 character strings, with a maximum of 40 characters each. The roll in this screen is always off. The service screen is used to place the "Set Modes" menu, as well as under the PP monitor.
Enter this monitor as follows: call the "Setup" menu by pressing SET, and then press GRAPH + ICP or UPR + @. Work in the PC monitor is similar to work in the CPU monitor. However, hanging the car here is much easier. Exiting it in the "Settings" menu is done by pressing Ctrl + C.
Each screen in the row table has its own color and display control registers. Their addresses are given in table 7.1. Recall that each of these registers occupies 2 words in the row table.
Table 7.1 Display and color control register addresses for standard screens.
Screen | Adr. UO | Adr. CA |
Working | 2460 | 2470 |
Office | 4670 | 4700 |
Service line (top) | 2370 | 2400 |
Info line (bottom) | 6740 | 6750 |
The cell with address 2476 contains information about which screen - working or service - will be displayed in the window:
1) working screen: (2476) = 2500
2) service screen: (2476) = 4672.
It is clear how screens are displayed and how to display, for example, a service screen instead of a working one. But how is the output organized in each screen so that there is a complete separation of the screens? And is it possible to design your screens so that the output in them was carried out using standard software as easily and conveniently as in the working screen?
It turns out you can.
The output to the screen requires the placement in RAM of some variables, for example, the color of the character, familiarity, current address in the WHO, etc. So that the screen separation is complete, each of the screens has its own SAO
H8jshchiuschaya, etc. Then the call to the variables will be
look like this:
Bias Assembler Flowchart
10 10 (R5) (R5 + 10)
2 2 (R5) (R5 + 2 )
Table 7.2 shows the displacements of the variables, their meaning, as well as the characteristic values for each of the four screens.
<Table 7.2 Screen maps>
A detailed use of variables from on-screen maps will be given below, together with an on-screen output algorithm.
Example 15. Eternal lines.
Enter the PP monitor. Before you - a service screen. Let's decorate it with some decent, but indelible inscriptions.
By pressing D, you will be in terminal mode. Clear the screen - <RESET>, and make some decent inscription on the top line. Then exit this mode - <OPR> + C.
Now, to fix the inscription made, we will change some variables of the screen map:
1) (+2): (22756) = 155430 (shift the starting address of the WHOU “down”),
2) (+30) :( 23004) = 5104 ("lower" the address of the top video line in the row table),
3) (+14) :( 22770) = 312 (reduce the number of erased video lines by 11) :,
4) (+12) :( 22766) = 23 (reduce by 1 the number of character strings).
By these actions, we excluded our line from the service screen, although it will remain on the screen. Now you can be sure that only the initialization of the screen or a direct intrusion into the video memory will be able to erase the inscription made.
You can remove protection from the first line by bringing the changed EC cells to their original state (it is given in the application).
Top service line.
Working screen.
Service screen.
Bottom info line.
22560 - upper service line,
22656 - working screen,
22754 - service screen,
23052 - bottom info line.
We’ll start with the most important on-screen output program. Scheme 8.0 gives its algorithm. The beginning of important sections is marked with marks (M ...).
The description of this program is perhaps the most boring place in the chapter, therefore resorting to reading this verse should only be necessary. If there is none, we suggest you skip immediately to the summary, which is on page ....
So, we started ...
M0 ... M1 (addresses 111144-111202):
> A cell (7066) is set from the query table, indicating that the cursor should be highlighted.
> R5 is loaded from cell 23150 by the start address of the current screen map.
> The color code registers of the dot and background are loaded from the screen map:
RT from (R5 + 34),
RF from (R5 + 40).
Note that both words of the Russian Federation are loaded from the same variable.
> In the display control register, the cursor color from the cell (R5 + 70) is written in the 1st byte. In this cell, in addition to color, you can specify the type of cursor (graphic or symbolic), as well as the position of the graphic cursor in the octet.
* So, the colors of the point and familiarity are loaded. The cursor is ready to be turned on.
M1 ... M2 (addresses 111204-111230):
> 1 byte is written from the buffer to R0.
Cell (22542) serves as a buffer pointer when displayed. Its difference from the cell (22544) is as follows:
(22544) indicates the place in the buffer where the next byte is written (buffer head).
(22542) indicates where the new byte (tail) should be read from in the buffer (see Fig. 8.0).
<Fig. 8.0 Little picture-explanation>
It is clear that (22542) must point to an address no greater than that pointed to (22544) (head always ahead of tail):
(22542) <= (22544).
> The pointer-tail is changed - (22542). It is incremented, and to prevent the exit of the buffer limits, the & ~ 200 command is executed on it.
> The number 111126 is written to the stack. This is done so that when the RETURN command is sent from anywhere, control is transferred to the address 111126 (and not immediately to the Dispatcher).
> The least significant byte is allocated from R0.
* So, a byte is written from the buffer to R0. RETURN output control intercepted.
M2 ... (addresses 111232 ...):
> Depending on the value of R0, the contents are interpreted either as a control code (less than 40) or as a character (more than 40).
1. MANAGING CODE:
> Depending on the contents of the cell (22552), the control code is either displayed on the screen (MIS mode - indication of control characters) or the control code is being “executed”.
a) (22552) <> 0 - "ISU":
M21 ... M22 (addresses 111730-112020):
> A three-digit octal number equal to the control code is printed in angle brackets.
M22 ... RETURN (addresses 112022 ... 113036):
> If the control code is 12 (VK), a "carriage return" is performed (code 25).
b) (22552) = 0 - not "ISU":
M20 ...
> The content of R0 is multiplied by 2, 13142 is added to the result. The resulting number is the address of the cell that contains the address of the corresponding special function. (For special features, see below.)
> Goes to the address of the special function.
2. SYMBOL.
M3 ... M4 (addresses 111260 ... 111314):
> If R0> = 100, the contents of the cell (22556) are added to it by OR. This cell is used to switch between alphabets (Russian / latinsky).
> The content of R0 is multiplied by 2, 14142 is added to the result - the starting address of the character generator table. The word from the cell with the resulting address is written in R1. This is the address of the character generator (a plate containing 11 bytes). Each byte in the GP represents a section of a symbol, i.e. an octet.
> R0 is loaded from (R5 + 10) by a step in the WHOU between the video lines.
> In R2, 177010 (address of RA) is written, in R3, 177024 (address of RO). In RA, the current WHO address is written in this screen (first word EC).
* So, everything is ready to draw a symbol:
R1 indicates a character generator,
R0 contains a step in who
R2, R3 contain the addresses of the registers of the addresses of the plans and the octet.
RA is loaded with the current WHO address.
M4 ... M5 (addresses 111316-111420):
> The contents of the cell (R5 + 56) are added to the instruction counter. If inversion or underline modes are not enabled, this variable is 0. When you enable the corresponding mode, it is loaded with a certain value. Then control is transferred to the address calculated as follows:
A = 111322 + (R5 + 56).
> If this is the normal mode, then all 11 bytes from the character generator are transferred to WHO through the RO. At the same time, the set digits in these bytes correspond to the color of the character, and to the reset digits - the color of familiarity. If inversion, bytes are inverted before being written to an octet. If underscore, the last byte is replaced with 377.
* So, the symbol is drawn.
M5 ... M9.
> 1. is added to the current WHO address (first EC unit) 1. From (R5 + 16) 1. is subtracted. Cell (R5 + 16) shows the character position in the line, starting from the right edge. For extreme right familiarity, this cell is 1. Are you still reading? It’s strange.
> If the resulting value (R5 + 16) is different from 0 (the right edge is not reached), RETURN is executed.
* Well ... The current position of familiarity (along the X axis) has been changed.
> If (R5 + 16) = 0 (right edge of the screen), a transition to a new character string is performed. At the same time, the contents (R5 + 4) are copied to (R5 + 16), which is equal to the number of characters in the line displayed on this screen. By the way, this number is not necessarily equal to the number of octets in this mode (80, 40, 20
or 10).
> The current address in the row table - (R5 + 32) - increases by 54 (the difference in the addresses of the elements is through 11 video lines).
> The current WHO address - (R5) - records the contents of the variable (R5 + 22). This cell contains the number of familiarity (left), which begins the output in a row.
> In case the end of the row table is detected, i.e. the current address of the row table is equal to the final:
(R5 + 32) = (R5 + 26),
The current address becomes the starting one: (R5 + 32): = (R5 + 24).
> To the current WHO address - (R5) - the WHO address is added to which the current element of the row table indicates. The number of the current character string is reduced by 1 (it is considered from the bottom):
DEC 20 (R5).
* The position on Y has changed (in the case of switching to a new character string).
> If this is not the bottom line on the screen - (R5 + 20) is not 0 - RETURN is executed.
M12 ...
> Otherwise (bottom line) - there is a choice - scroll the roll one character line up (roll on) or not scroll (off). The last variable of the screen map is responsible for the state of the roll (on-off) - (R5 + 74).
... M13 - roll off:
> The output is again from the top of the screen. To do this, the current address in the row table becomes the address of the top row, and the current WHO address is the corresponding WHO address + indent from the left edge.
> The number of the current character string (counted from the bottom) becomes the maximum :
(R5 + 20): = (R5 + 12).
Then exit on RETURN.
... M14-M15 - the roll is on.
> In this case (R5 + 20) is incremented.
> 13 is written to the stack. This is the screen offset when scrolling.
> 54 is added to the address of the top row in the row table, indicating that after scrolling the roll, the top row on the screen will be another (11 video lines lower).
> If the address of the top row in the row table is 4670 (end address), it is replaced by 2500 (start address).
M15 ...
> Here the roll is being set for scrolling. Checks the roll counter - cell (23170). If it is empty (equal to 0), the cursor is extinguished, a new character string is cleared (which has not yet been displayed - it is below, beyond the horizon):
CALL 113344,
and a number from the stack (13) is added to the counter. If the counter at the time of verification was greater than 14 (modulo), TRAP 0 is executed. Then R5 is loaded from (23150) and everything is lost with M15.
The roll is scrolled through a network timer. The operation of the timer program is described in Chapter 5. For now, we only note that cell (23170) is responsible for the roll: its contents show how many pixels you need to scroll the screen. Positive values correspond to scrolling up, negative values (in the additional code) - down.
* So, the algorithm of the program is disassembled.
Now it remains to consider what happens when RETURN is executed from this program.
As already noted, on RETURN control is transferred to the address 111126. Here, the following is done:
> 1 is subtracted from (7064), i.e. 1 request is removed.
> If (7064) becomes equal to 0 (no requests), and also there is no buffer overflow ((22546) = 0), the program exits to the Manager via RETURN.
> If (7064) is not 0, (there are still requests for on-screen output), the cell (7060) containing requests from the keyboard is checked. If the latter are absent ((7060) = 0), we return to our procedure, to label M1, and everything repeats.
If, nevertheless, there is a request for a keyboard, an exit to the Manager is performed to satisfy this request.
> Finding the buffer full, ((22546) = 2), TRAP 4 is called (it reads the byte from the channel). Another request is added to (7064), and again to address 111126.
* Thus, the exit to the dispatcher is carried out:
1) If there are requests for the keyboard and the screen. 2) When running out of screen requests, if the buffer is not full.
For those who have little time to understand the algorithm, and just lazy people (that is, for almost everyone):
We group each group of variables in tables.
<Here, in theory, there are 3 tables: 8.1, 8.2, 8.3>
<And here also - figure 8.4 - Active screen page>
1) The colors of the symbol and familiarity, as well as the cursor, are loaded from the EC into the video registers. The cursor turns on.
2) Bytes are taken from the buffer. His character is checked. If it is less than 40 (bytes, not character), then this is the control code, a certain address corresponds to it. Management is transferred to this address.
If byte> = 40, then this is a character. It should be displayed on the screen.
3) The output to the screen is carried out from the character generator (ZG). ZG is a plate in which each code (symbol) corresponds to 11 bytes. These 11 bytes make up one character on the screen (11 * 8 points).
There are 3 display modes:
- normal
- inversion (all bytes are displayed inverted on the screen),
- underscore (the lowest byte of any character is displayed "filled in" - the number 377).
4) After the character is displayed, the current familiarity changes its position (the corresponding variables in the EC change).
5) If necessary, a command is given to “spin” the roll 11 video lines up (the screen is full).
6) If there are still bytes in the buffer that need to be "processed", everything is repeated from step 2.
However, if at the same time there is a request from the keyboard, the manager is logged out.
Also, the exit to the Dispatcher occurs when the requests are exhausted (the buffer is empty).
, Ž ‡ "PP Ґbvm 2 ЎlOzhl Ї® 0.5 ЉЎ © Je in r¤ n., Je r¤® © O§ det in ЄO¬ ®Ўa §®¬, b®¤ҐarOvbp 256 (400) bl®ў . '® Ґbvm loЎ®¬g § zҐёо Ў © in (0 ... 255) b®®vўҐvbvўgҐv Ї® bl®ўg ў Є r¤® © in ЎлёжҐ.
' ЎlOzh § Є®ЈҐҐa v®a (' ‡ ø) S £ Ґvbp b ¤aҐb 14142., ∞ © ea pvbp ¤aҐb § Є®ЈҐҐa v®a - v.Ґ. ¤aҐb 11 ¡The © vle in ЎlOzҐЄ, Je avO®Є ¤lp Je r¤®Ј® Є®¤ (0 ... 255). 'in ¤ Aulus © § Є®ЈҐҐa v®a § iOv ¢ ‡ P ", and the table is set for it, ie, indicates addresses in ROM.
If you wish, you can make your character generator, and set up a table on it. To accommodate an alternative character generator, memory is allocated in the RAM of the software - these are addresses from 15142 to 22540. Here, nobody will disturb your PG, unless another lover of inventing alphabets.
The table of special functions (TSF) begins with the address 13142. The addresses are also stored in it. But these are already addresses of subprograms called special functions. Each code has its own SF.
We have already seen how special functions with codes up to 40 are called up: the screen output program, upon detecting such a code, is immediately sent to the address that it finds in the table of special functions (TSF).
But what about codes from 40? After all, the screen output program will interpret such a byte as a character. To show the System that it is necessary to respond to this code with a special function, control code 33 is intended. 33 is placed before the required code, and this couple is interpreted as SF.
How does this happen? Take a look at diagram 9.0. It gives a block diagram of the SF-33, as well as a block diagram of one irreplaceable subroutine.
So, having received code 33, the System called SF-33. This SF works as follows.
The stack pointer is stored in cell (23152). Cell (23174) becomes equal to 2. This shows that work is going on "through 33" .
The subroutine with the address 110762 is called, after which our byte (following code 33) appears in R0.
Next comes the call to the desired special function, zeroing the cell (23174), restoring the stack pointer and returning.
Everything is clear here (at least to the author). Now let's see what is done in subroutine 110762.
Like a screen output program, work with the buffer is going on here. Having detected the arrival of the next byte following 33 ((7064) is not equal to 0), the subroutine writes the desired code to R0.
If it is from 40, it returns from the subroutine. Otherwise (less than 40), the corresponding special function is called (right there, inside this payment order), and upon exiting the SF, again, at the beginning of the payment order. An exception is made for code 33 - when it is detected, an “ejection” occurs in SF-33, to a point with the address 113544.
If the code has not yet arrived, (7064) = 0, the dispatcher goes out to enter the subroutine from address 110726 when it arrives again. When the buffer is full, TRAP 4 is called, and again the beginning of the subroutine.
Now consider all the standard special features. For this purpose, all algorithms (except the most trivial ones) are presented in diagram 9.1, and the actions of special functions are summarized in table 9.2.
Note that not for each code there is an address in the SF table that is different from 0. For codes addressing 0, there is no special function (address 0 contains a thoughtful RETURN command). These special functions are not listed in the table.
In the table, by the cursor we mean both the hardware cursor itself and the place where it can be displayed, i.e. current familiarity.
<Unmeasured Scheme 9.1>
<No less measured table 9.2>
Let's consider one special function in more detail. Its code is 120, and she is responsible for two tasks at once:
The keys in the UK-NTs are called 5 keys - K1, K2, K3, K4, K5. They are designed so that in one click the terminal sends a string - a package of several bytes. Moreover, these keys can be called from five registers:
The total number of keys is therefore 25. Each key can be assigned its own inscription. How is this done through the SF-120? It’s very strange.
The key number must be set not in the usual binary, but in decimal form. Those. if you need to determine the key number 18, instead of one byte equal to 18, you send 2 numbers: 1 and 8. The special function composes a binary number from them.
Another bleak moment: the key values are set in hexadecimal form. Therefore, instead of 12, say, a byte, you have to send 24 hexadecimal digits (characters from "0" to "9" and from "A" to "F").
And further. Initially, the special function provides the ability to redefine keys. What it is?
Key strings are written to a special area of RAM software. The current address in this area contains cell (13140). The location of the key area is from 11142 to 13130. Each time a key is determined, after writing a line, the pointer moves closer to the end of the area. When overridden, the pointer becomes 11142 (the beginning of the region), and all keys become empty.
However, a small mistake in the body of the special function precludes this possibility. The fact is that in the package one byte is responsible for the redefinition - it is called the sign of redefining keys. Here is a view of a standard package specifying keys:
Symbol: <33> P; <P> | <Cl1> / <Page1>; ...; <ClN> / <StRN>; <33> /
Code: 33 120 73 P 174 Kl1 57 Str1 73 73 KlN 57 StN 73 33 K
Here <Cl> is the key number (in decimal),
<page> - string (in hexadecimal format),
K is an arbitrary code (greater than 37).
<P> means, by design, a sign of redefinition. If it is even (the least significant bit is 0), the keys are redefined. An odd sign (the least significant bit is 1) means that the lines are still written from the current place, and the rest of the keys are not changed. The attribute must have a value of at least 40.
However, the error led to the fact that it is not the sign of overriding that is being analyzed, but the previous byte (code 73). It is clear that it will remain odd until the end of the century, and therefore it will not work to return the pointer to its original value.
Why is that bad? Because the area of RAM in which the keys are stored (more precisely, the lines to them) is limited. It is a little less than 1 Kbyte. If a sufficiently large number of programs redefining keys have worked on the machine, this area may become clogged, and then redefining the keys will fail again. Approaching the border of this area, the SF-120 will, as if nothing had happened, receive bytes, but will not be determined - the pointer (cell with address 13140) will not increase.
The keyboard section of the book shows how you can very easily redefine keys, and how, for example, make any key in an arbitrary register key.
There are also enough oddities here. Here is the parcel format for transcoding:
Character: <33> P; <code>; @ <obr1>; ...; <obrN> <33> /
Code: 33 120 73 Code 73 100 obr1 73 ... 73 obrN 33 K
Here <Code> is the character code, starting from which you want to transcode the character generator.
<obr> is a transcoding pattern.
K is an arbitrary code (greater than 37) .
The sample is defined as follows. Familiarity (11 * 8) is divided into 2 parts - the upper (5 * 8) and lower (6 * 8) - Fig. 9.3.
<Figure 9.3. Familiarity breakdown for SF-120>
Then each of the parts is divided into 8 vertically. It turns out 16 numbers: X1 ... X16.
The number 100 is added to each of them:
Y1 = X1 + 100, etc.
The bytes received make up the sample:
Y1 Y2 Y3 Y4 Y5 Y6 Y7 Y8 / Y9 Y10 Y11 Y12 Y13 Y14 Y15 Y16
As a separator, you can use any code from 40. In one package, you can write at least the entire character generator.
Not only is it impractical - instead of 11 bytes to send 17 (16 + separator), it is also quite a long time. In addition, in this part of the special functions, there were no errors. In the character generator (in the address range from 15142 to 22540), the address of the plate for each code should be calculated as follows:
A = 15142 + Code * 13, since each code corresponds to 13 (octal!) Bytes.
And in SF-120 this address is calculated as follows:
A = 15142 + Code * 11.
If you record the entire CG with one package, the error may not affect. But if, for example, we write down one part of a GP from a certain code and then continue with a different premise, the second part may overlap with the first, and you will not have to expect anything good from such a PG.
Now we’ll deal with three EMT subroutines. Two of them - EMT 52 and EMT 56 are used to output to the service (upper) and information (lower) lines. EMT 40 is used to initialize the screen.
So, EMT 52 and 56. If you wish, you can take a look at 10.0. Block diagrams of these routines are given here. More precisely, the subroutine is only one, but the entry points are different. EMT 52 sets the address 22560 (service line) at the beginning of the current screen map, and EMT 56 - 23052 (informational). In addition, you can "protect" the service line from inscriptions through EMT 52 - for this you need to set cell (7150) to 2.
These routines are not buffered. Bytes are output immediately from the line whose address is placed behind the EMT command. The first byte in this line is always interpreted as the X position on the screen. The string should end with 0.
Another small nuance. EMT 52 and 56 uses the standard on-screen screen output program with the address of the entry point to it 111272 for character output. This means that control codes (0 ... 37) will not be control codes here. They will not cause special functions, but are displayed in the form of characters (in the character generator you can write characters for such words).
When executing the initial start-up program, the software should, among other tasks, initialize the screen. What it is? This is a sequence of actions leading from scratch to the normal operation of the screen. Initialization includes:
1) WHO cleaning;
2) preparation of K0 for receiving bytes;
3) building a row table;
4) building a table of character generator;
5) building a table of special functions;
6) buffer initialization;
7) some initial settings (such as turning on the cursor).
All these actions are performed by EMT 40. His arrangement is shown in diagram 10.1. In addition to the initial entry point, some additional addresses are shown here.
If, for example, you do not need to clear the screen, but just need to rebuild the table of lines, TG, TSF, etc., you can call the subroutine through CALL from the following addresses:
Address Starting point (of the above)
107754 1
110022 2
110044 3
110050 4
110076 5
110114 6
110 136 7
Of course, first you need to save the registers you still need on the stack (when calling through EMT, you do not need to save the registers).
Now we will describe some procedures called from EMT 40.
Procedure 110266. Builds a table of rows. As already mentioned, this table consists of individual elements. Each item must contain the WHO address and the address of the next item. First, the "skeleton" of the table is built - the addresses of consecutive elements are written. Then, using procedure 110550, the WHO addresses are written to the table. And last but not least, amendments are made to the registers of UO and CA. Note that the procedure only builds a table of rows, and does not include it (cell 272 does not move).
Procedure 110550. Used by the previous procedure to build a continuous section of the row table. Called through JSR R5 and contains 4 parameters located in 4 words after the command.
The 1st parameter is the starting address at WHO.
The 2nd parameter is the starting address in the row table.
3rd parameter - the number of elements.
The 4th parameter is a step at WHO.
As a result, a table will be built in the RAM RAM in which the addresses of the WHO will be written in constant increment through the word.
Procedure 110656. This subroutine rewrites their initial values from the ROM (although it can also from RAM) to the on-screen cards, and then the UO and CA registers are written to the addresses indicated in the card. The procedure is called through JSR R5 and has 2 parameters.
1st parameter - starting address in ROM (RAM).
The 2nd parameter is the starting address of the screen map.
In ROM, each screen map is represented as follows:
1st word - the number of variables in EC. Next are these variables, and then 4 words - the contents of UO1, UO2, UTs1, UTs2.
1) erasing all 3 WHO plans;
2) enable interrupts from receiver K0;
3) building a row table;
4) rewriting the character generator table from ROM;
5) rewriting the table of special functions from ROM;
6) initial installation of buffer pointers;
7) rewriting screen cards from ROM;
8) initial settings:
- inclusion of a row table,
- current screen - working,
- turning on the cursor,
- initial settings for the colors of the symbol and familiarity.
-
Њл Ґ блгз © ® ўл¤ҐлЁЛё Ја дёЄг ў ®в¤Ґлмго Јл ўг. ‚Ёёв п ў П ‡“ “Љ, ®
§ ¬¬ Ґв Ў®лҐҐ ®¤® © Їпв® © Ї®бв®п® © Ї ¬пвЁ ¬ иёЛ ё ўлЇ®лпҐв ўҐбм¬
Ї®лҐ§лҐ ўҐйЁ.
, Bva®Ґ n Јa dOЄ Ї®§ў®lpҐv ўlЇ®lpvm blҐ¤goyOҐ dgЄzhOO:
Graphics procedures can be called both from the side of the CPU (on channel K0), and
by the PP (direct appeal to the procedures). That is, we can say that
Graphics can be called in both standard and non-standard ways.
Both of these methods are described in detail in this chapter. Let's start with the standard one.
So, we work either with channel K0 from the CPU or with a buffer from the PP. Working with graphics comes down to sending commands (codes) to the terminal. These commands are accepted by the graphics management program, and that, in turn, starts the necessary procedures with the necessary parameters.
In general, the terminal UK-NC has two modes - symbolic and graphic. The first is discussed in the chapter "Standard screen output" and includes the display of characters on the screen and the launch of special functions.
The second - graphic - is enabled by the special function 45 (%). After its inclusion, the codes sent to the terminal are analyzed in a special way and are no longer related to the screen output program. They are processed by the graphics management program. It starts with a sequence of codes:
character: <33>%! 0
Code: 33 45 41 60.
This is the inclusion of graphics mode.
The first two codes call SF-45, the third (!) Is set here, apparently for the greater seriousness, and the fourth (0) means that the graphics management program is called.
In general, the last code can be any, and only 2 low-order bits are taken into account. If they are zero - this is a graphic, then the cursor turns off and our program is called. If they are nonzero (the lowest digit of the code is 1,2,3 or 5,6,7), the SF-27 is simply called, which, as you know, includes the N1 command system. All this can be traced according to the block diagram of the SF-45 (scheme 11.0)
The coordinate system of the graphic mode is standard: the point (0,0) is the lower left corner of the screen.
After the graphic mode has been enabled, the program expects the arrival of sequences of codes that will be interpreted as graphic commands.
The general format of these packages is as follows:
<33> <Command> <Litera> [Parameters].
Here <Command> and <Litera> are codes representing this or that operation, and [Parameters] is a sequence of bytes in a special format, which can mean color or coordinates. Depending on the operation, the number of byte parameters can be different - from zero to 13.
This form of invoking operations (after 33) is similar to invoking special functions. However, we note again that graphic commands do not apply to special functions.
In the future, the operation of the graphics management program and the format for representing the parameters will be described in detail, but for now, we summarize the call to graphic operations in table 11.1. You can see that, as a rule, several letters correspond to each team.
Table 11.1 Call of operations of the graphic mode.
Team | Litera | Options | Operation action |
L | I | <Cs> <ts> <tse> | Sets the character color (Tss), familiar color (Ts) and screen color (Tse) in the current screen and in video registers. |
M | L | <Cp> | Sets the color for the line (CPU) |
| P | <f> | Sets the color to fill the path. <Цf> is a negative number in the ACE format (from 0 to -7). |
R | R | <X1Y1> <X2Y2> <Cb> | Fill a rectangle with coordinates (X1Y1) - (X2Y2) with color Tsb. |
T | D | <C1> <C2> | Sets the color of the cursor on the home screen (C1). C2 is also a color. What is not clear. |
U | A |
| Reading the color of the current point. <C> and code 15 (VK) are sent to the terminal. |
| B |
| Fill the outline of the color Cp with the color Cf, starting from the current point. |
| C |
| Filling an area from the current point. Points of color Cp are repainted with color Cf. |
| F | <XY> | Sets the coordinates of the current point (but does not set a point). |
| G | <XY> | Draws a segment from the current point to (XY) in the color of the CPU. This endpoint becomes current. |
| H | <XY> | Draws a point with coordinates (XY) in CPU color. This point becomes current. |
| I |
| Reading the coordinates of the current point. <XY> and code 15 (VK) are sent to the terminal. |
% | ! | Code | The code is the code of the digit indicating the number of the mode to which you must go: 60 (0) - we remain in the graphic; 61..63 (1..3) - go to symbolic. |
In table 11.1 in the column "Parameters" in angle brackets the data
transmitted through the buffer. This data can mean either one number (color),
or a pair of numbers (coordinates).
A 16-bit number in this format is converted to 3 bytes. It's done
in the following way:
1) a 16-bit word is divided into 3 parts - two 6-bit and one 4-bit;
<Here is a partitioning scheme>.
2) each part is supplemented with up to 8 bits by a mandatory prefix, and the third part
- also familiar.
<Here is also a diagram>.
As a result, we have 3 bytes ready to send.
In this case, two 12-bit numbers are represented as 5 bytes. Strategy that
But - each number is divided into parts, and then we compose these parts together with
prefixes:
1) <Here is a partition scheme>;
2) <And here is the layout diagram>.
The result is 5 bytes, in which, if desired, you can see a couple of coordinates.
Such a fun presentation of data seems to have been introduced for compatibility with
earlier versions of the terminal command system. For graphics of UK-NTs these
the conversion didn’t work: in order to start the operation with
parameters from the CPU, you must first encrypt the data in the AEC code, and then
The software decrypts them in the usual format and distributes them into variable cells (already
in normal form). Of course, this is a long time.
Further, in the next paragraph, we will show where in the RAM RAM the graphic
variables and how to directly call graphically procedures.
Now lovers of digging into the bowels of the car can see how it works
graphics management program. Others boldly scroll to §12.
So, the action of the SF-14 led to the fact that after turning off the cursor (CALL 111632)
The graphics management program (CALL 135436) was called up. Figure 11.3
The core of this program is presented.
When launched, the program saves R5 on the stack and assigns R5 a value
stack counter. Then comes the call to the director of the initial table (CALL 136274), and
upon leaving it, R0 is analyzed. If its value is 0, occurs
exit from the control program (with restoration of R5 and SP), otherwise
In the event, the director is restarted.
What is the director of the initial table? Recall that all managers
graphic sequences begin with code 33. The director, having accepted this code,
runs the director of teams. That, in turn, analyzes the second
incoming code, etc.
In general, the work of directors boils down to the following. In a special table
(for example, in the initial table or in the command table) codes and addresses are stored,
corresponding to these codes. Everything is very simple: the director, finding the code in the table,
equal to the incoming, sent to the appropriate address. If
there is no such code in the table, there is a transition to the address where just R0 is assigned
1 and there is a return to the previous director.
There are 3 "layers" of directors.
The first is the top one, this is the director of the initial table, it recognizes code 33 and
runs the director of teams.
The second layer consists of one team director. This parses the command
(2nd incoming code) and runs the letter directors.
The third layer is 6 letter directors. Each team has its own
letter director. It distributes control already directly to
depending on the letter (3rd code).
Block 11.3 shows the block diagrams of letter directors. They are all identical, beyond
the exception of one digit is the address of the letter table with which these directors
work. Letter tables are shown right there.
* The terminal of the Criminal Code has two modes - symbolic and graphic.
* The peculiarity of the graphic mode is that the codes sent to the terminal,
analyzed in a special way, and neither to symbols, nor to special functions of the relation
Dont Have.
* Graphic mode is activated by a sequence of codes:
<33>%! 0.
* Graphics mode operations are invoked by code sequences. Each
the sequence consists of 3 bytes and parameters:
1st byte - 33
2nd byte - command code
3rd byte - letter code.
Some operations have no parameters.
* Each operation is uniquely determined by the team and the letter.
* Parameters of graphic operations can be signed numbers, meaning
color, as well as a pair of coordinates - (X, Y).
* These parameters are transmitted to K0 (and to the buffer) in encoded form. Number
converts to 3 bytes, and a pair of coordinates to 5 bytes.
* The graphics management program is engaged in the analysis of command and character codes,
which associates with each allowed combination of codes the address and
sent to him.
This starts the graphical operation.
We settled on the fact that the "correct" combination of command codes and letters
inexorably causes surgery. The operations in table 11.1 can
add a few more that have no practical use, that is, nothing
not doing.
This is: RU,
RD
UE
U D.
Although the control program responds to them, they are all empty.
There are 2 more operations, the meaning of which is not completely clear:
MM
M V.
Now we will consider all existing operations in order. Figure 12.1
their action is shown.
LI ................ Setting character mode colors
The starting address is 136414.
Parameters: <Tss> <Ts> <Tse> (color of the character, familiarity and screen).
Act. In the current screen map, writes the colors of the symbol, familiarity and
screen. The colors of the symbol and familiarity are written in RT and the Russian Federation, respectively.
Job. Using routine 143756, the number from the ADC format is converted to
normal format and is written to the cell (23424). From there, the color corresponds
to the appropriate cell. This is repeated 3 times, each time with a new color.
Colors are written to cells:
(23456) - symbol color,
(23460) - the color of familiarity,
(23462) - screen color.
The contents of these cells are pushed onto the stack, procedure 117026 is called.
the colors from the stack are copied to the screen map and to cells (71 60), (7162),
(7164), and then in the RT and the Russian Federation. Upon exit from the procedure, the stack is restored and
there is a standard exit from the operation:
R0 = 1,
JMP 136046.
ML ................. Sets the color for the line.
Starting address: 136442.
Parameter: <Cn> (color for line and point).
Act. In cell (23442) the color of the line is copied.
Job. Procedure 143756 is used to convert to normal format.
MM ................ Setting the color of something.
Starting address: 136562.
Parameter: <C>.
Act. A number is written in cell (23446) (color, probably).
Job. Similar to M L.
MP ................ Set the fill color.
Starting address: 136602.
Parameter: <Цf>.
Act. The fill color (negative number) is written in cell (23450)
0 ...- 7 in the additional code).
Job. Similar to M L.
RD ................ Empty operation.
RU ................ No less empty operation.
RR .............. Filling a rectangular area.
Starting address: 136706.
Parameters: <X1Y1> <X2Y2> <Cb>.
Act. Draws a rectangle filled with color Tsb with coordinates
diagonals (X1, Y1) - (X2, Y2).
Job. Procedure 144104 converts the first coordinate pair (X1, Y1) to normal
format and writes them to cells (23420) and (23422):
X -> (23420),
Y -> (23422),
Then these values are compared with the maximum allowed:
Xmax = (23412),
Ymax = (22664),
and, if less than them, then the second pair of coordinates is taken and converted to normal
format. Their values are also checked, and if they do not go beyond the set
limits, color is read and converted to normal view. Resulting 5
words:
Cb, Y2, X2, Y1, X1
pushed onto the stack. Procedure 144666 is being performed, which, in fact,
draws a rectangle.
TD .............. Sets the color of the cursor.
Starting address: 137122.
Parameters: <C1> <C2>.
Act. Sets the color of the cursor on the home screen.
Job. The first color is accepted by the procedure 143756 in the cell (23452), then
the second - it is written in the cell (23454). The first byte through the stack is passed to
procedure 117004, where 4 low bits are allocated from it. They are written in the cell.
(7166), as well as in the EC of the working screen - in the cell (22742). Second color nowhere
not written, he sits in (23454). Everything ends traditionally - R0 = 1,
JMP 136046.
UA ................. Read point color.
Starting address: 137222.
Parameters: none.
Act. The color of the current point is sent by K0 in the AEC format. The package
ends with code 15 (vk).
Job. RA - (177010) is loaded from the variable (23430), which contains
address of the current point in WHO. Read RO (177024), while the Russian Federation -
(177020) ... (177022) - loaded with the contents of plans at this address. Then
the position of the point in the octet is checked (23440), and, depending on which
half an octet rests the starting point, R0 is loaded either first (177020),
or the second (177022) word of the Russian Federation. Further after some tricky manipulations
the color of the current point is still on the stack, and with the help of procedure 144304 it
sent to the channel in a very encrypted form. Then sent to the channel
code 15, the operation ends successfully.
UB ................... Fill the circuit.
Starting address: 137334.
Parameters: none.
Act. Starting from the current point (and its coordinates are stored in a pair of cells:
Xtec = (23414),
Ytek = (23416)),
filling begins with the color CF (cell (23450)) of the screen. Dots with color cp
(cell (23442)) cannot be filled. And since the filling is carried out
sequentially, point by point, then a closed loop drawn in color
direct, will be filled from the inside (if the current point is inside it) or
will be "surrounded" by the color CF outside (if the point is outside).
Job. Cells (23414) and (23416) - X and Y - are interchanged, then called
procedure 151714, at the output of X and Y, they are restored to their original values.
Procedure 151714 does the following. Registers are written to the stack (CALL 147662),
initial settings of variables are made (CALL 151756), the mode is set
filling ((23634) = 0), the filling procedure itself starts (CALL 145624),
then the variables (CALL 176300) and the registers (CALL 147706) are restored.
UC .............. Filling the area.
Starting address: 137334.
Parameters: none.
Act. The function is mirror operation "U B" (literally and figuratively).
Firstly, this operation repaints the area painted by the color of the CPU in the color
Cf (and "U B" does the opposite - does not touch the points with the color of the CPU). Secondly,
the coordinates of the current point are interchanged: X is Y, and Y is X. Other
in words, from a point with coordinates (Y, X) there is a repainting of the points,
communicating with the current, painted in CPU.
Job. Similar to "U B", but cells (23414) and (23416) do not swap
(hence mirroring), and cell (23634) is set to 177777 (mode
repainting). The "root" procedure is the same - 145624.
UD ...................... An empty operation.
UE ...................... An empty operation.
UF ................... Setting the coordinates of the current point.
Starting address: 137442.
Parameters: <XY>.
Job. Using procedure 144104, a coordinate pair is converted to
digestible look:
X = (23420),
Y = (23422).
Then they are checked for falling into the dimensions of the screen, and, if everything is in order,
necessary manipulations with graphic variables are performed.
The meaning of the variables used here is as follows:
(23414) - X current,
(23416) - Y current,
(23420) - X required
(23422) - Y required
(23426) - octet position in the line (X / 8),
(23430) - current address of the WHO,
(23432) - address of the bottom video line in the row table,
(23434) - address of the current video line in the row table,
(23436) - octet,
(23440) - the position of the point in the octet (0 ... 7).
UG ................. Drawing a line.
Starting address: 137620.
Parameters: <XY>.
Act. Draws a line segment from the current point to the specified parameters.
Color - CPU. Point (X, Y) becomes current.
Job. After receiving the coordinates and checking them, the first point is set, and then
the entire remaining segment is drawn (CALL 141330).
UH ................. Drawing a point.
Starting address: 137722.
Parameters: <XY>.
Act. Draws a point in the color of the CPU with the given coordinates. This point
becomes current.
Job. Similar to the work of "U F", but at the end the point is still set:
RT load: (177016) = (23422),
Loading RA: (177010) = (23430),
Loading Russian Federation: (177024)
(177010) = (23430),
Octet overlay: (177024) = (23436).
UI ................... Reading coordinates.
Starting address: 140140.
Parameters: none.
Act. Sends to the channel the coordinates of the current point in the AEC format. The package
ends with code 15 (VK).
Job. The contents of cells (23416) and (23414) are sent to the stack;
procedure 144454, which encodes the coordinates and sends them to the channel, then
code 15 goes on the stack and is also sent to the channel.
%! ................... Mode.
Starting address: 140232.
Parameters: N mode (1 byte).
Act. The byte following the letter is analyzed. If it is 60, nothing
Interesting does not happen (the graphic mode remains). Otherwise, there is a switch
to the mode indicated in the two least significant bits. If they are not zero, there is a return to
character mode.
Job. See "Action".
The bulkiness of a standard graphics call slows down and complicates
graphic programs. However, for managing graphics from the PP there is a good
opportunity - write parameters directly to cells, and call
necessary procedures also directly. Here we will tell you how convenient
just do it.
Graphic variables.
1. The coordinates.
Coordinates are set in the usual format, i.e. one number corresponds to a word,
a pair of coordinates - 2 words.
A pair of cells contains the current coordinates:
Xtec = (23414)
Ytek = (23416).
It is these coordinates that are read into the channel when reading through the operation "U I".
two more cells contain the specified (required) coordinates:
Xtr = (23420)
Ytr = (23422).
The difference between these coordinates is as follows. Current change graphic
procedures in the process of their work (from the inside), and the required ones change only from the outside,
when setting coordinates for procedures.
Another pair of cells is used for maximum values:
Xmax = (23412)
Ymax = (22664).
Note that cell (22664) is from the on-screen map of the home screen. She means
the number of video lines on the home screen.
2. Colors.
To set the color, there are two cells:
The color of the line and point: Cp = (23442).
Fill color: Cf = (23450).
Cf has a negative sign: color 7 corresponds to number 177771, and 0
matches 0.
These variables are used by point and line drawing procedures, as well as
filling the contour and area. The procedure for filling the rectangle is not
uses these cells, the color of the rectangle is set on the stack.
Three cells - (23444), (23446) and (23454), defined by the operations "M V", "M M" and
"T D", respectively, are not used by graphics procedures. You can with clean
conscience to use them in your own procedures.
3. Other variables.
Graphic procedures use several cells to fit your needs:
(23426) - position of the current octet in the video line,
(23430) - current address at WHO,
(23432) - address of the bottom video line in the vehicle,
(23434) - address of the current video line in the vehicle,
(23436) - octet,
(23440) - the position of the point in the octet (0 ... 7).
Another cell - (23424) is used for converted from the ATSE format
number.
You are welcome to use these variables to your needs!
Graphics in various screens.
The graphics are not related to screen cards, so operations will not work
only in the current screen. Changing the screens is quite simple: enough
change the value of the cell (23432), which means the address in the table of rows of
line, which is taken as the bottom (Y = 0).
The values for this cell for the four standard screens are shown in Table 12.2.
Table 12.2 Cell contents (23432) for working in standard screens.
Screen (23432)
Service line 2460
Home screen 4534
Service screen 6604
Info line 7024
Nominal value (default) - 4534 - working screen.
Direct call of graphic procedures.
We went directly to the graphical procedures, thereby useful
routines.
Their call, the transmitted parameters, as well as the actions are shown in table 12.3.
Table 12.3 Reference to graphical procedures.
<Here is the table!>
Such a "strange" call to procedures such as for a point, for example,
due to the fact that some of them do not exit immediately through RETURN,
but use the "stub" with the address 136046.
- paint over and fill the area.
- write coordinates and colors directly to cells - variable graphics and
- call graphic procedures directly (via CALL).
Пёб вм ЄЁЈг - § пвЁҐ зҐав®ўбЄЁ бл®р®Ґ. Пёб вм ЄЁЈг ®Ў “Љ-ЌЦ -
ў¤ў® © Ґ. ˆ ў®in Ї®zҐ¬g.
â,¬ §®Ўa vmbp ¢ and Ў®vҐ § Їgv le Їa®Јa ¬¬ ¢ E det eOva®bЇlҐvҐOpe,
ўл¤ ўлёў п §§ П З “л®ЈЁЈг ё §¤а ўл © б¬лбл Ї® Є ЇлҐ, ё Ґ¬Ґп Ї®¤ ¤ЄЄ ©
Lёm “Љ-ЌЦ, ¤Ё§ бᥬЎлҐа, aggЄg Ё Ўг¬ Јг, - нв® ў®-ЇҐаўле.
Все Explain everything found, so that in the written could
understand not only the author, but also some readers, and without
loss of mental health by both sides - this is the second.
All together at times it grows into a global problem - "And you need
is it ?! ". And only the innate irrationality of the will, referred to among the people
obstinacy, moves the author to continue work.
* * *
In this chapter, we will deal with the network timer PP, more precisely with
/ pa - - RX @ AKG \ @A] C + WpMQEA_ + KR \
Now that we’ve taken apart the main aspects of the screen output,
to summarize by putting everything together in practical recommendations. These
recommendations carry a minimum of new and maximum useful. Respectively,
minimum theory and maximum practice.
By changing the current screen, we understand such actions, after
which screen output will work in the desired screen predictably
and no problem.
First of all, you need to make the desired screen visible (for example,
changing the working screen to the service one). Work goes, of course, on the table
lines.
Here everything revolves around cell (2476), which contains the address
continuation of the row table, i.e. screen that we will include in the window
between information lines.
This address for the service screen is unique:
For the working screen, there is no such unambiguity. The reason is
that the roll can work in the working screen, and the cell value (2476)
changes when scrolling the screen.
Therefore, before changing the working screen to the service one, it is necessary
save cell value (2476). Then, upon return, it follows
restore.
As for the upper and lower information lines, the table
lines do not need to be changed here, because these lines are always present on
terminal.
problems with returning back:
1. Save the cell value (2476).
2. Record in number (2476) the number 4672.
3. When returning, restore the old value of the cell.
Now, in order to provide output to this screen, you need to change
screen map, writing in the cell (23150) its starting address:
Screen (23150)
Worker 22656
Office 22754
Bottom info line 22560
Upper info line 23052
However, if we need a cursor in a new screen, we must do
some more activities. Namely:
- change the contents of the cell (23160) - address of the highest byte of UO1;
- update the tracking cell from the EC with the cursor - (23164). And further
it is necessary to write the cursor color in UO1 (again from EC).
All these actions will be done for us by the final part of EMT 40.
(if you ask her well). The request should be as follows: in R5 we write the address
the screen map that we make current, and call
subroutine from the address 110210. She will do everything in the best possible way, including
number will write the address of the EC in the cell (23150) and load the colors from the EC
points and background in RT and RF:
MOV #A, R5
CALL 110210
#A is the address of the beginning of the screen map that we make current.
When transferring screen output to info lines, please note that in
their screen maps the cursor is off:
(R5 + 72) = 0, i.e. tracking turned off;
(R5 + 70) = 0, i.e. cursor color - 0.
If in these screens we need a full cursor, then, before
in order to call procedure 110210, you need to enable tracking and
set an acceptable cursor color (e.g. 7):
MOV # 2, 72 (R5)
MOV # 7, 70 (R5).
In case you are not satisfied with the standard screens of the Criminal Code, you can
develop your own. Development is carried out at several levels:
- screen map (EC),
- table of rows (TS),
- video RAM (WHO).
In fig. 16.1 shows a figurative diagram of the operation of the screen output.
Screen output program and special functions through the screen card work
with WHO (video information) and with vehicle (display of video information on
terminal).
<Fig. 16.1 On-screen output {77}>
Replaceable parts are EC, TS and WHO. In other words, it is necessary
take care:
- about the structure of the screen and its place on the terminal (in the TS);
- on the placement of video information (allocate space in RAM);
- All this must be summarized in a screen map.
Placement of video information.
Standard screens use 3 shared memory plans under video RAM
96 Kb And all 96 Kb are actively used by the System -
there is practically no free space in the plans (see Fig. 16.2 and
tab. 16.0).
Table 16.0 Addresses occupied by screens at WHO.
WHO Address Screen
initial end
worker 100000 154537
official 154540 175677
upper I.-.s. 175700 176567
lower and.-s. 176570 177457
auxiliary 177460 177777
the elements
<Fig. 16.2 Screens in the video memory. {78}>
For new screens, either plans should be used, and thus
disable some standard screens, or under WHO
Use RAM CPU + RAM RAM. In this case, work with this
video information will be possible directly. However standard programs
output work with video memory only using register access.
So by simply lowering the WHOU down you, alas, will not be able to increase
standard output speed.
Nevertheless, in this way you can use part of the RAM, in many
cases not needed:
* part of the RAM of the CPU (free from programs);
* System RAM CPU (8 Kb);
* part of the system RAM RAM (not more than 22 Kb).
Recall that the RAM of the CPU corresponds to the 1st and 2nd plans of WHO, RAM RAM
- 0-th plan (Fig. 1.2).
If, for example, you use 10 kilobytes of RAM RAM under the WHO (plan 0)
+ 20 Kb of CPU RAM, including RAM (plans 1 and 2), you can
implement a screen of 24 character strings in 40 familiarity mode
line, which is quite good and quite enough for most
programs.
Some possible combinations of screen sizes we presented in
table 16.1.
Table 16.1 Possible amount of video memory for various
screen sizes (Kb).
Number Number of familiarity per line
symbolic
lines 10 20 40 80
1 0.32 0.64 1.29 2.58
10 3.22 6.44 12.89 25.78
20 6.44 12.89 25.78 51.56
24 7.73 15.47 30.94 61.88
26 8.38 16.76 33.52 67.00
48 15.47 30.94 61.88 123.75
All this is true for 3-panel screens. But if you use
"stratification" of screens, you can increase their size by 3 times with the same
the amount of memory. But more on that later.
If you use the system RAM of the CPU under the WHO (addresses 160000 and
above), preferably when exiting the program to restore the RAM (it
contents). This is done using routine 173252. It is just
rewrites about 5.5 Kb from ROM to CPU RAM.
restore the programs usually written there
(monitor, etc.):
CALL 173252
Using RAM as a video memory, try not to allow
a program of situations leading to the transfer of the CPU to HALT mode. Otherwise
an interrupt will occur whose vector is at 160170, and
its contents may be unpredictable if it is part of
Whoo.
Organizing a row table.
Now let's quickly remember why we need a table of rows. And I need
it in order to display information in the who
sequence (line by line). In other words, TS is a bridge
between the video information at WHO and the video image on the screen.
We describe the standard row table in table 16.2 and in fig. 16.3.
Table 16.2 Standard row table.
N Addresses in the vehicle. Addresses in the WHO. Place on the screen N video
e-string
1 ... 18 270 ... 272, --- 18 empty elements ---
2270 ... 2366 com. Inappropriate
steal video lines
19 2370 ... 2376 --- UO top info ---
strings. Also not
matches video
line.
20 2400 ... 2406 --- UC upper info ---
strings. Also empty
element in the sense
WHO addresses.
21 ... 30 2410 ... 2456 175700 ... 176450 Upper 1 ... 10
(step 50) info line
31 2460 ... 2466 176520 End of upper 11
info lines
UO of the working screen.
32 2470 ... 2476 177460 Upper divider - 12
video line
CA home screen
33 ... 318 2500 ... 4666 100000 ... 154420 Operating screen 13 ... 276
(step 120)
319 4670 ... 4676 177460 Start of the top 13
rims
UO official
screen
320 4700 ... 4706 177460 Start of the top 14
rims
CA service
screen
321..340 4710 ... 5026 177460 Upper border 15 ... 34
service screen
(2 empty characters
ny lines)
341..560 5030 ... 6606 154540 ... 175630 Service screen 35 ... 254
(step 50)
561..582 6610 ... 6736 177460 Lower border 255 ... 0 + Еp + ё + R - ++ Q + v + pPV-Е¶Wёёёu-Рp + VQWUЎЖЕВї-РпёпWUT¶РЕЕ
In addition to creating your own screens, there are ways to change the work.
screen output itself.
To do this, it’s not necessary to redo everything all over again - Dispatcher,
screen output program, special functions, network timer program. Everything
these programs are made with high care and work quite
effectively.
These tools, wired in ROM, can be tailored to fit your specific
diverse needs, without changing the whole system as a whole.
Methods for modifying screen output:
In these ways, you can change the screen output beyond recognition, not
touching the fundamental principles of his work.
A rather interesting assembler for processors operating in the UK-NC,
allowed to write quite interesting and tricky programs.
You can use one of the tricks of system programmers to
victory over the inviolability and constancy of programs resting in ROM.
Irreplaceable, but not shining with a variety.
Software developers in some places unconventionally implemented conditional transitions,
those. branching programs.
Instead of using test commands (TST) or comparison (CMP)
with subsequent refinement of conditional branch commands, there are similar
fragments:
ADD X, R7
BR ADR2
BR ADR3
ADR1: ...; branch 1
...
...
...
ADR2: ...; branch 2
...
...
...
ADR3: ...; branch 3
...
...
...
The contents of the variable X are added to the command counter, and the control
transmitted to various points in the program.
Here X can take the values 0, 2, 4, while the control
passed to branches 2, 3, 1, respectively.
If you now place some fragment in RAM RAM
available in ROM and load the variable X offset from the point
branching to this fragment, the program will go off the well-worn track
and execute our newly minted fragment. Of course, we must then return
management into the main program.
The location of such "flexible" branch points, control variables
and the meaning of the branching is shown in table 17.0.
Table 17.0. Branching in an on-screen output program.
Address Status Cell Return Actions
branch - at the time of branching control standard use
branching X branches
111322 R1 - Address (R5 + 56) JMP 111422 Necessary measures- Extremely-
in the MH, the adoption of
R0 is the step in the current position of the stream:
Of growing familiarity.
R2 = 177010 If necessary, * create new
R3 = 177024 bridges will trigger output modes
(R2) is theroll. (AND, OR, XOR ...)
sheer hell * sprite output
res whoo jmp 111660 (r5 + 56) = 336: instead of characters
Character set up (arbitrary
LA in the HF mode size and many
color).
JMP 111704 (R5 + 56) = 362: * anything
Character set up
LA in INV mode.
Return just the end
programs .
111506 Lower Stro- (R5 + 74) JMP 111506 (R5 + 74) = 0: * Management ru-
ka worker roll off - bosom in its own way.
screen - the current one becomes- * In general, any
tabernacle, rubbing the top line. reaction to
moving the bottom
move to the next- JMP 111510 (R5 + 74) = 2: screen.
The next line the roll is on -
(way down). the screen is spinning
up one
string. New
the string is clean.
RETURN End of program.
114164 Upper (R5 + 74) JMP 114164 (R5 + 74) = 0: * The same applies-
the line the work roll is off - to reach
bringing the screen current becomes burning top of the screen
- current, bottom line. wound.
required
climb another JMP 114170 (R5 + 74) = 2:
above. roll on -
the screen is spinning
down one
string. New
the string is clean.
RETURN Return without action
action.
115752 Current change- (R5 + 74) JMP 115752 Current address in * Management interception
the familiar TS from R1 is written laziness when trying
places at (R5 + 32); to (R5) ke go beyond
extreme ver- the address of the case is added
they either WHO, respectively, up or down.
bottom ruling top te
live smoking video line. along with two
litter. Roll previous
switched off. JMP 115754 Smooth roll. teas because
If R1 <4670, from the variable
one and one is subtracted from him
2170 (the end of the vehicle is behind.
changes to
lo).
RETURN Exit.
111024 Subroutine (23174) JMP 111024 Just return.
fetch by
that of the RETURN buffer
in R0.
JMP 111026 Call Special Function
by the code in R0.
(And so on...)
Explanation of the table:
The branch address specified in the table is nothing but the address to which
control is transferred with a branch variable containing zero.
It was previously indicated that the system responds to any code from 0 to 377 either
by drawing a character, or by calling a subprogram - special functions.
Consider the second case.
There are only 90 standard special functions in the 256-code System. The rest have in
special function table (TSF) zeros - i.e. they call a subroutine with
address 0. In the zero address, of course, sits code 207 (RETUR N).
This means that only 35% of the codes are used. The remaining 65% can be applied to
homemade special functions. And this is very helpful.
If it is necessary to place a set of subprograms in RAM RAM
to each of them - there is nothing more convenient than making these routines
special functions. Then the call of these routines will be very convenient: in K0 from the CPU
helmet code 33 + code SF (40 ... 377), or just code SF (0 ... 37).
166 free codes will be enough for any tasks, and not only related
screen output, but also with sound and management of other system resources
PP
A = 13142 + Code * 2,
write down the address of the subroutine.
It is advisable not to use the codes provided by the System for standard
special functions.
Exit special functions via RETURN. Then control is transferred
to the address 111126 (standard exit from the screen output program).
And further. Special functions will be called when the ISU mode is off - the cell
(22552) is 0. Otherwise, each code less than 40 will be displayed on the screen in
octal representation in angle brackets, and codes from 40 will become
displayed as characters.
Codes that are not used by the System as special functions are presented here.
Free codes
0 ... 6
eleven
20.21
thirty
36
40 ... 44
46 ... 74
106, 107
114 ... 117
121 ... 130
134 ... 137
145 ... 177
235 ... 237
254 ... 266
271 ... 273
300 ... 377
The standard character generator is wired into the ROM, by default it is indicated by the TZG -
character generator table. In it, as in TSF, 256 words, and each corresponds
code. TZG starts at address 14142.
Creating your own character generator encoding is simple. It is necessary to write down addresses in the TG
"pictures" - plates of 11 bytes. Under the alternative character generator highlighted
special memory area in the RAM of the software - addresses 15142 ... 22540. Fit into it
all 256 11-byte tags.
Adr1 - address in TZG:
Adr1 = 14142 + Code * 2
Adr2 - address in an alternative ЗГ:
Adr2 = 15142 + Code * 13
The word with the address Adr1 must contain Adr2.
In the UK, the standard familiarity always consists of 11 octets (11 * 8 pixels).
However, this annoying monotony can be easily overcome and any
another sign generator system (for example, 8 * 6 or at least 20 * 20).
Using the previously discussed branching method, in particular, using
variable (+56) in the screen map, you can make any output system
character. You can even scale each character (draw it vector).
EC cell (+56) is triggered in the screen output program just before
by drawing a character, and here we can instead of banal loading 11 bytes from the GP
on screen do whatever our imagination wants.
For example, characters do not have to be monochrome. Can be output by codes
pictures - this will already be a sprite output, and the sizes for each picture
can do different.
This method of intercepting control is also convenient because it allows you to do
Each screen has its own character output system.
But there is a little inconvenience. To the branch point of the screen program
"Forgets" the character code, and only R1 contains the address in the GP. You can exit
suggest this: again, take this code from the buffer and act with it on
discretion. Recall that the current address of the buffer contains the cell (2254 2).
Using the same method of intercepting control during branching, you can redraw
at your discretion, cursor and roll.
The cursor can be multi-color, graphic, small or large, and a roll
can work in any screens, and ride in every imaginable direction.
But you never know what you can think of, there would be a desire! The interception principle is described
earlier, and the points in the interrupt program from the network timer are given
in table 17.1.
The processing program itself, more precisely, its structure, is presented in diagram 17.0.
<Table 17.1. Branching in a timer program>.
<Scheme 17.0. Timer Program Structure>.
You can talk for a long time about the importance of a good and different screen output. However, you will not mind that without input means the computer turns into something uncontrollable and unnecessary. This is clearly seen on the example of a frozen computer
(Fig. 1.0).
Figure 1 . An example of a frozen computer
The saddest property of freezing is the closure of information inside the machine. Of course, she can say something goodbye, but entering information through the keyboard is no longer possible (that's why it freezes).
Without a keyboard, the computer turns at best into Dendy, and at worst into an electric heater. It is unlikely that anyone was able to enter information into the car with passes or suggestion. Working with a mouse or with other animals, of course, has its charms, but you cannot do without a keyboard (reliable buttons + reliable drivers), especially on the Criminal Code.
What does all this say? Well, firstly, lyrical digressions (within reasonable limits, of course) give rest to the brains of readers and authors. And secondly, the reliability of programs, as well as the softness of the interface are directly related to the reliability and ease of use of keyboard drivers. Using standard software for your own purposes requires knowledge of all the subtleties of handling it.
Hence the thought - after reading this part of the book, you will know the keyboard input device at different levels, and at the same time you will learn how to tame, use and modify the firmware on the keyboard.
At the physical level, the keyboard is:
- matrix of switches (conductors + buttons);
- keyboard interface device.
The first substance is an 8 * 12 matrix, assembled on a separate board and consists of 88 buttons in its nodes (Fig. 18.1). All keys on the hardware level are equal and independent. The only exception is that 2 register shift keys (HP) correspond to one switch in the matrix, which means that they are identical at all levels. That is, in fact, there are 87 independent keys.
Although all keys are physically equal, they can be divided into groups:
- alphanumeric main keyboard;
- keys (K1 - K5);
- managers (NR, ALF, UPR, GRAF, FIX, TSI);
- keys of the additional keyboard;
- service (VK, Slaughter, TAB, AR2, etc.).
- key "Stop" ;
Each group has its own mission, which is determined by the system software.
The keyboard interface device (PEC) deals with the maintenance of the matrix. It is located in the KR1515XM1-031 chip. This microcircuit also contains other device interfaces: a programmable timer, a tape recorder, an audio signal generator.
What does a PEC do? It analyzes the state of the keyboard contacts and promptly reports a change in this state. In other words, the PEC responds to 2 situations:
keystroke ,
key release.
How and where does the PEC report these situations?
The PP I / O page has 2 registers representing the keyboard:
status register (177700),
data register (177702).
In addition, there is the possibility of generating interrupts with av.p. 300 when you press and release the keys.
The status register contains 2 useful bits. With their help, you can establish the fact of pressing or releasing:
<Picture - Byte (177700)>
6th category: interrupt resolution with a.v.p. 300.
0 - prohibited
1 - allowed.
When the discharge is set, an interrupt is generated if discharge 7 is set.
7th category: readiness.
Set to 1 when you press or release the keys.
It is reset by reading the data register.
The low-order bits are used in the data register. It allows you to find out if a key is pressed or pressed, as well as the physical key code:
<Picture - Byte (177702)>
Digits 0 ... 6: physical code of the pressed key.
Digits 0 ... 3: physical code of the pressed key.
Rank 7: Sign of pressing: 0 - key pressed,
1 - the key is pressed.
So, each key corresponds to its own code - a number that appears in the data register. It is called a scan code or physical code. It has nothing to do with the KOI-7 code or the like. It serves to identify the keys. All Scan-codes of keys are presented in table 18.1.
<Table 18.1. Scan codes and position in the key matrix>
Table 18.2 shows the status of the registers for 3 cases - pressing a key, pressing and reading a data register. Please note: during the release, part of the code is lost, and the recognition of the pressed key is carried out by four bits (out of seven), which is not always convenient .
The data register information is valid only when the readiness bit is set in the status register. When the readiness discharge is reset, the following occurs.
With a period of 64 μs, the data register is constantly increasing by 1, sequentially passing through all values from 0 to 377.
Suppose we pressed (or depressed) a key. The PEC, having carefully counted up to the key code for this key (taking into account the 7th digit), will fix this code, and the scan (i.e. increase) will stop. The code will “freeze” before reading the data register. After reading, scanning will continue with the same code.
Such hardware subtlety can be used, for example, to obtain pseudorandom numbers using RD as an eight-bit counter with a clock frequency of 15625 Hz.
- state ( 177700).
- data (177702).
- the key is pressed,
- the key is pressed.
First, we will analyze the general scheme of operation of the tools that serve the keyboard, and then we will deal with each tool separately.
1. When you press or release the key, an interrupt is triggered, and control is transferred to the interrupt program.
2. In it, the Scan code of the key (depressed or pressed) is written to the buffer for Scan codes from the data register. A request is set to the dispatcher for processing the read code.
3. The dispatcher accepts the request and launches the keyboard maintenance program - the central program in the circuit.
4. The program takes the Scan code from the buffer and is engaged in its analysis. If a key is pressed, its code is placed in a special buffer of pressed keys. When pressed, its code from the buffer is erased.
Depending on the Scan code and the current register in the TSC (code matching table), there is either an ASCII code corresponding to this key (alphanumeric key) or an ASCII line address (key key).
Switching registers is carried out using the register keys (e.g. GRAPH, UPR, HP, etc.). Their status is also reflected in the TSC.
ASCII code (or address) is placed in the ASCII buffer. Called TRAP 2.
5. TRAP 2 sends the codes from the ASCII buffer to channel K0, to the CPU.
In the event that the pressed key is held for longer than 0.5 seconds, the dispatcher is requested from the network timer program, and this is done at a frequency of 25 Hz until the key is depressed. This is called Auto Repeat.
Control keys and "Stop" do not suffer auto-repeat.
- Scan codes (without separating the pressed and pressed keys).
- Scan codes of the keys pressed at the moment.
- ASCII codes ready to be sent to K0.
Buffer Addresses Pointer
read write
1. Scan codes 2260 ... 2267 (7200) (7176)
2. Scan codes 2240 ... 2257 (7204) (7202)
click keys
3. ASCII codes 2200 ... 2237 (7210) (7206)
- The interrupt handling program (reads Scan codes from the data register into the buffer and gives a request to the Dispatcher.
- Dispatcher (calls the keyboard maintenance program).
- Keyboard maintenance program (depending on the current register - GRAPH, UPR, etc. - generates an ASCII code using the Scan code). Each register has its own code matching table (TSC). TSK 5 pieces. All of them are in RAM.
- TRAP 2 (deals with the transfer of ready-made ASCII codes to K0).
- Network timer interrupt service program (provides auto-retry of pressed keys).
So, on the fact of pressing / depressing, an interruption with a.v.p. 300. Consider the program serving it (Scheme 20.0).
Work program:
1. The Scan code from the data register is read into the buffer. The buffer is located at addresses 2260 ... 2270. Its size is enough for 4 keystrokes and release of keys (interruption will be called 8 times). Buffer pointer - cell (7200).
2. The read code is checked by the most significant (7th) bit - pressed / depressed. If the key is pressed, the sound is turned on and the variable (7046) is set to 2. This means that after 2 ticks the sound will turn off. As a result, we get a click (quite loud for such an oily piezodynamic, as on the Criminal Code).
3. Then it is checked whether the code for pressing the Stop key does not reflect.
a) not “Stop” (or depressing “Stop”):
The buffer counter is increased by 1, it is prevented from exiting the buffer.
The dispatcher is prompted for keyboard maintenance - cell (7060). Note that this is the first cell in the query table, and the keyboard thus has the highest priority.
There is an exit on RTI.
b) "Stop"
After saving three registers (R0, R1, R2), procedure 104054 (a fragment of the keyboard initialization program) is called.
It clears 2 buffers - Scan codes and Scan codes of pressed keys.
Pointers of all three buffers (and there are 6 of them - 2 for each) are set at the beginning of the buffers. Registers are restored.
The HALT mode is activated in the CPU - the console terminal mode. From this, the interrupt from the A.V.p. 160,270.
Exit by RTI.
This key is unusual not only in color on the keyboard.
It stands out among all the keys: code 4 processing (this is the Scan code for this key) is carried out immediately in the interrupt processing program. This code does not go further - code 4 does not get into the buffer, and no ASCII code is generated for it.
In addition, with this key you can quickly control the HALT CPU mode (in this, apparently, its innermost meaning in general).
This program is called by the Dispatcher in three cases:
1. The key is pressed.
2. The key is pressed.
3. The auto-retry of the pressed key has worked.
In the first two cases, the request is made from the program for processing interruptions from the keyboard, and in the third - from the program of the network timer when the auto-repeat counter is zeroed: (7227) b = 0.
Figure 21.0 shows a simplified flowchart of a keyboard maintenance program. We conditionally divided it into 3 global blocks:
- click
- squeeze,
- auto repeat.
In each of the following situations, you are working with three keyboard buffers:
- buffer of Scan codes (buffer N1),
- buffer of pressed keys (buffer N2),
- ASCII code buffer (buffer N3),
(for brevity, assign a number to each buffer).
1. A non-zero Scan code of the key is searched in buffer 1, located and stored. The code is erased from the buffer. So after processing all requests from the keyboard, this buffer contains only zeros. The dispatcher's request is also removed: (7060) -1.
2. According to the 7th bit of the received Scan code, it is determined that the key is pressed (7th bitnull).
3. Using the 6-bit Scan code, the offset from the beginning of the current code matching table (TSC) is searched. A word is taken from this table and analyzed.
a) The word <400. This means that the key status is alphanumeric, the content of the word is an ASCII code. This code from the TSK, folded by OR with a mask in the low byte of the cell (7220), is written to buffer 3, so that it can then go to K0 (or R0) via TRAP 2. The scan code of the key is written to buffer 2.
b) The word> = 1000. This key by status in TSK is the key. It corresponds to an entire ASCII string in the address space of the RAM RAM, and this word in the TSC contains its starting address (> = 1000). The same actions will be performed with this address as for the alphanumeric key (except for addition by OR, of course): the address will be written to buffer 3 (because its discreteness is a word), and the Scan code will be stored in buffer 2 for possible auto-repeat.
In cases a) and b), the presence of 2 Scan codes in the buffer is checked. If they are present there (auto-repeat works), the time of the next auto-repeat is set to 2 ticks. If not (first keystroke), the time until auto-repeat becomes equal to 25 ticks (0.5 sec).
c) The third way: a word from 400 to 1000. This is a control key. It does not match an ASCII code or an ASCII string. When it is pressed, control is transferred to the appropriate control task processing program, and all sorts of control actions are performed there. The address of this program is calculated based on the contents of the word in the TSK. But more on that later.
4. After each case a), b) and c) there is a transition again to the beginning of the program, and if new codes are received in buffer 1, the process is repeated. If nothing new has happened (buffer 1 has remained empty), and auto-retry has not yet worked (early), TRAP 2 is called, and the accumulated good from buffer 3 goes where necessary. And after TRAP 2 - exit from the program.
2 variables can affect the process of generating the ASCII code and its subsequent sending to the destination:
(7232) - if it is 0, everything is OK. But if you set it to 2, all the alphanumeric keys (code in TSK <400) will be turned off - no ASCII code will be generated, no Scan code will be sent to buffer 2. This is used in SF-133.
(7230) - this cell makes more sense. It is closely related to the operation of TRAP 2. Its normal value is 2. This means that all ASCII codes from buffer 3 have already been sent. Zero means that for some reason the buffer has not yet been completely displayed in K0, and calling TRAP 2 is useless so far: the CPU has not yet read the previously sent portion. Therefore, at a zero value (7230) TRAP 2 is not called at all, and there is an "empty" output.
There are 2 options here:
1) Pressing the register key (HP, ALF, GRAPH and others).
2) Depress any other keys.
This option is recognized by the contents of the register buffer (7212). This cell in two bytes contains the Scan-codes of the register keys (in the pressed form). They get there by pressing the register keys in the corresponding routines.
1. The found code is deleted from (72). If it was in the low byte, after it is reset, the bytes are swapped (the buffer is "shifted"), because the high byte must contain either the code of the last pressed register, or 0.
2. Depression of HP and ALF - the most important registers - is processed specially. About this - in the paragraph on keyboard registers.
3. Go to the beginning if not ALF is pressed. If ALF - code 16 or 17 is sent to buffer 3, and go to the beginning.
Here you need to find the Scan code in the keystroke buffer (buffer 2). It should be noted that control key codes do not fall into this buffer. The algorithm for finding the code is very tricky; those who wish can break their heads over it. We will present only the main points.
1. The 4 least significant bits in the scan code of the pressed key are highlighted. Keys are identified by them.
2. When found, the code is erased from the buffer. A gaping zero remains in its place. Management is transferred to the beginning.
3. If you reach the end of buffer 2 (it is all scanned), the normal auto-retry time is set: (7226) = 2, and - to the beginning of the keyboard maintenance program.
Auto repeat - fictitious keystroke while holding it down for a long time. This simulation is done by the network timer program, periodically setting a request to the Dispatcher.
Two variables (2 bytes) make a lot of sense here:
- auto repeat counter (7227);
- counter buffer (7226) (consists of one byte).
In the timer program, the counter decreases by 1 in one pass. Having reached 0, the subtraction stops and the following actions are performed:
- a request is made for auto-repeat: (7060) +1;
- the sound is turned on - the 7th bit (177716) is set to 1.
- the time is set - 1 tick - until the sound is turned off: (7046) = 1, that is, at the next tick the sound will be turned off.
So, the work of the keyboard maintenance program in auto-repeat mode.
1. The Scan code is searched in buffer 1 and is not located, because it is not there.
2. The last code in buffer 2 is searched and is located. This code is the last one written to buffer 2, and not necessarily the only one. We do not need it yet, therefore, the first nonzero code in this buffer is searched .
3. The found code is processed in the same way as if the key had really been pressed (item 3 in the pressing situation).
4. Exit from the pressing block is carried out back to the auto-repeat block. If there are more codes in buffer 2, they will also be processed.
5. The entire buffer 2 was scanned to the end. Its zero cells were skipped and nonzero cells processed. The auto-repeat counter is loaded with the new value from the counter buffer: (7227): = (7226).
1 request is removed:
(7060) -1.
6. Standard output (with or without TRAP 2).
The auto repeat counter (7227) is loaded either from the buffer (7226) or directly in the keyboard maintenance program.
Table 21.3. Cell loading situations (7226) and (7227).
Action Meaning Situation
(7227) = 0 AutoRemovement Buffers 1 and 2 are empty.
(7227) = 31 Turn on auto-repeat when the "Press" block. Buffer 2 is empty.
first press. t = 0.5 sec.
(7227) = (7226) Sets the next repeat. Auto repeat block. Buffer 1
is empty. In buffer 2 - Scan codes.
(7226) = 1 Acceleration of auto-repeat. t = 1 tick. HP register pressed when
hold another key.
(7226) = 2 Restore normal
auto repeat time. t = 2 ticks. The squeeze block. Viewed
entire buffer 2. The pressed code is not
found (shutdown
accelerated auto repeat).
Now back to the place of the keyboard maintenance program where the Scan-code decides what to do with the fact of pressing (or auto-repeat) this key.
Each of the 86 analyzed Scan codes corresponds to a word in the address space of the software. The combination of these words is one TSK.
How is TSK built? Yes, just in ascending order of Scan codes. There is, however, one subtlety. There are “dips” in some Scan codes due to idle Y0-Y4, and sometimes Y5 tires.
To TSK was continuous, this technique was applied. The special offset table shows the difference between the Scan code and the word number in the TSC. Since "empty" codes appear when switching from one X-bus to another, and the Scan-code is calculated depending on the coordinates in the matrix like this:
Sc = 16 * X + Y,
it’s enough to shift the Scan code 4 digits to the right (which is equivalent to dividing without a remainder by 16), and we get the X-bus number (0 ... 7).
This number determines the offset.
So, in TSK 86 words. Consider 3 possible classes of meanings of these words.
Meaning of the words TSK.
0 ... 377 - ASCII code.
This means that the key is alphanumeric, it corresponds to
one byte.
400 ... 777 - Control key.
The low byte of such a code is a signed offset, i.e. him
should be considered as a number from -177 to 200. For this number
the address of the control key processing program is determined:
A = 2 * n + 104714.
This is how control keys are implemented, including register keys.
1000 ... 177777 - Address of an ASCII string.
These keys correspond to a string in the address space
PP So implemented key, as well as some service
keys.
The starting address of the current TSC contains the variable (7214). TSK only 5, each register has its own. Keyboard registers are key operation modes. They are switched by control keys, which we will call register.
TSK number Key Register Address TSK.
1 - normal 7234
2 HP lower 7514
3 GRAPH pseudographic 7774
4 UPR control codes 10254
5 FIX register " FIX " 10534
Table 22.2. Variables serving keyboard registers.
Address Value
7212/7213 Scan-codes of pressed register keys (in the pressed form).
7214 Address of the current TSK.
7216 Saved TSK address.
7220/7221 Flashing OR set-top box for switching on / off the HP: 40/0.
7222/7223 Flashing code for changing the alphabet LAT / RUS: 16/17.
7224 In low byte - code 16 or 17, sent to the channel when
ALP. If ALP is not pressed, it is 0.
It is perhaps necessary to clarify the meaning of the "blinking" variables (7212/7213), (7220/7221), (7222/7223).
A pair (7212/7213) is the very same buffer of Scan-codes of register keys. He was already caught in the main keyboard maintenance program. Writing to such a buffer is usually carried out after a byte exchange command (SWAB), in the low byte (7212).
Scan-codes of keys here have the format of pressed keys for recognition of pressed keys
registers:
HP - 205,
FIX - 207,
ALF, GRAPH, UPR - 206.
OR prefix (7220/7221). So we will name the cell, the contents of which are added by OR with ASCII codes, which enter buffer 3. More precisely, the operation is performed with the least significant byte of the prefix. Its meaning:
0 - without HP,
40 - with HP.
These values are also changed via SWAB.
The flashing light (7222/7223) always contains 16 in one byte, in another 17. Byte (7222) contains the code for the current alphabet:
16 - RUS,
17 - LAT.
Diagram 22.0 shows a block diagram of the operation of keyboard registers with some explanations.
Since the registers belong to the control keys, operations to change the registers take place in mini-programs that serve the situation of pressing these keys.
All ASCII codes for alphanumeric keys can be overprinted with a lowercase. Code 40 from cell (7220) b, folded in OR with an ASCII code, changes uppercase characters to uppercase. The change of numbers to special characters is carried out by changing the current TSK.
* HP
When you press and hold HP normally, the current TSK address becomes 7514 (lower case TSK), and the OR-prefix (7220) b changes (becomes 40).
When you release the HP (7220), SWAB is activated, and this is done in the keyboard maintenance program.
* HP + FIX
If we fix HP with the FIX key:
1) pressing HP
2) pressing FIX,
3) pressing these keys in any order,
then, as a result, the OR prefix will change: (7220) = 40, but the TSK will remain the same. Therefore, for example, numbers (on the main keyboard) do not become special characters (!, ¤, &, etc.), but remain numbers in this mode.
Using HP for fast auto-repeat
The HP key allows you to double the frequency of auto-repeat. To do this, after pressing the auto-retry key, you must, without releasing it, press HP. As a result, the number 401 is written in cell (7226), i.e. 1 in the low and high bytes. This corresponds to a frequency of 50 Hz (auto-repeat at each tick).
Restoring the normal frequency (25 Hz) is done by squeezing HP.
* ALF
When the ALF key is pressed and held normally, code 16 or 17 (depending on the current alphabet) is sent to buffer 3 from the low byte (7222). Changes in cells (7220) and (7222) occur upon sending back to К0 (from the CPU) of these codes is an echo. Then the SF-16 (or SF-17) will work, and the SWAB operation will be performed with these variables.
So:
Alphabet (7222)
st ml
RUS 16 17
LAT 17 16
Note that SF-16 and SF-17 using cell (7222), in fact, are preparing to cancel the current alphabet, i.e. in (7222) b, the inverse code of the alphabet is written: 17 for RUS, 16 for LAT. Please note that the OR prefix (7220) changes both the HP register and the ALF.
With the release of the ALF, of course, everything will return to square one.
* ALF + FIX
When fixing ALF, it also depends on whether there is feedback from the CPU (whether codes 16 and 17 are returned to the PP).
If not, then nothing changes. If yes, then after pressing these keys, the new alphabet is saved and the cells (7220) and (7222) change.
When the ALF + FIX sequence is re-implemented, the previous disposition will return.
* GRAPH (UPR)
Pretty simple registers. They are simple in that they only change the address of the current TSK, and there are no OR consoles for them.
Just like HP and ALF, these registers can be fixed.
* GRAPH + FIX (UPR + FIX)
Note some subtleties when working with fixed GRAPH and UPR:
1) Pressing HP (and holding) leads to a change in the register upper-lower; pressing ALP does not change the current TSK - the GRAPH or UPR remain, although the cells of the OR-set-top boxes and LAT-RUS codes (7220) and (7222) honestly fulfill SWAB.
2) Pressing the UPR with a fixed GRAPH or GRAP with a fixed UPR allows you to turn on (temporarily, before depressing) the registers of UPR and GRAP, respectively.
3) Pressing the UPR (or GRAPH) with the register fixed with the same name turns off (before depressing) the corresponding register, and the TSC with the starting address 7234 (the very first is the neutral register) is valid for this period.
All the registers listed above can be fixed in a slightly different way: first press FIX, and, without releasing, press the register. Squeeze everything. To remove this fixation follows the most usual way: REG + FIX.
It is no coincidence that we especially consider the FIX key here. For it not only makes it possible to fix other registers, but also represents a full register with its TSK.
The address of this TSK is 10534. Its contents practically coincide with the values of the 1st TSK (neutral), so with a simple press of FIX we will not notice anything new. And only when programming the keys it is finally discovered that the keys 21 ... 25 correspond to the FIX register and the 5th, last TSK.
This register differs from others in that it cannot be fixed (a sort of shoemaker without boots).
In addition to the five considered register keys: HP, ALF, GRAPH, UPR, FIX, we still have 3 more control keys. More precisely, there are 3 standard programs, with the ability to turn them on with the control keys: UST, ISU, PrtScr.
The table of addresses of control program maintenance programs.
Table 22.5.
N Address Managing Content Task
program word key in TSK
1 104766 HP 400 HP
2 105044 ALF 401 ALF
3 105 116 GRAPH 402 GRAPH
4 105150 UPR 403 UPR
5 105160 FIX 404 FIX
6 104734 UST 405 menu UST
7 105234 UPR + POM 406 ISU mode
8 104746 UPR + ICP 407 PrtScr
* The keyboard maintenance program has 3 call cases:
1) keystroke,
2) key release,
3) auto repeat.
Accordingly, for each case there is a branch of the program.
* Actions on buffers in these three cases:
Buffer N1 - Scan-codes N2 - Scan-codes N3 - ASCII-codes
keystrokes
Press Selects a scan code. If it is not a control code. For alphanumeric
key pressed , on the key, the keys are written here , and also for
its place is written 0. Scan-code of the pressed keys by Scan-code
keys. It dwells being produced either
here before squeezing. ASCII code or address
ASCII strings. He here
and fits with
to be shipped
to the right place with
using TRAP 2.
Release Selects Scan Code. Finds Scan Code.
pressed keys, on pressed keys, on
its place is written 0. its place in the buffer is
0 is written.
Auto - Scan codes are read, Same actions as
The second present here, when pressed.
they are being processed as
if they were
selected from buffer 1
when you press. Buffer
viewed all from
auto repeat frequency
every time from the beginning.
* Auto-retry is called from the network timer software program. Auto Repeat Counter
- byte (7127) b. A nonzero counter is decremented at each tick, and at
zeroing, the dispatcher is prompted for the keyboard maintenance process.
* Counter (7127) b is loaded from the auto-repeat buffer - (7126) b. Buffer
contains either 1 (accelerated auto-repeat - at each tick), or 2 (normal
- through the tick).
* Each key is associated with a word in RAM PP. Combination of these
words for 86 keys is one TSK (code matching table).
* According to the content of words in TSK, the keys can be divided into 3 groups:
1) 0 ... 377 - ASCII codes (byte keys);
2) 400 ... 777 - control keys;
3) 1000 ... 177777 - string keys.
* Each control key has its own mini-program in which
this or that mini-task is being implemented (whether it is a case change, inclusion of a menu
"Set" or screen print).
* The control keys include register keys. They are in charge of switching
registers.
* There are 5 standard registers:
- neutral
- lower (HP key),
- pseudographics characters (GRAPH key),
- control codes (UPR key),
- register "Fix" (FIX key).
Each register has its own TSK.
* There is no ALF register as such (there is no corresponding TSC). Switching
of the alphabet РУС / ЛАТ is carried out by sending to K0 codes 16/17 followed by
reciprocal sending and working off of SF-16 or SF-17.
* When you press ALP, HP changes OR prefix (7220) b. She is responsible for the shift
uppercase / lowercase letters and folds OR with the ASCII character code.
* In addition to the register, there are 3 more control tasks:
SET - menu "Settings" (key SET),
ISU - a mode of indication of control characters (combination of UPR + POM),
PrtScr - screen printing (combination of UPR + ICP).
It would be necessary to start the description of the keys with the main group. Yes, just write here
almost nothing - all these keys in their application are enough
are trivial. All of them can be recognized by the ingenuous white color of the buttons.
main keyboard. Their value in the TSC can be found in the appendix.
Let’s do it better with service keys. We will assign buttons to them
AR2, TAB, RESET, ENTER, POM, SET, COI, Slaughter, as well as control keys
the cursor.
A feature of these keys is that, being official, they manage
remain byte-like (like the main key group). Here
the content of the relevant words in TSC:
AP2 - <33>,
TAB - <11>,
Slaughter - <177>.
We also note that these values are the same for all 5 TSKs, and also do not change
when changing terminal modes.
Among this trinity stands TSI - this key, as you know, causes
process "Setting Modes", and therefore is assigned to the control keys.
The other two keys are string:
POM - <33> <176>
COI - <33> <177>.
POM in the register UPR calls the ISU mode, and the ICP in this register - the operation
screen prints, here they are governing.
In the TSC register GRAPH these keys have the following meanings:
GRAPH + POM - <12>
GRAPH + COI - <0>.
All these keys also do not change their encodings when changing terminal modes.
A very important group of keys. No wonder the values of the codes they change when changing
TSK, when changing terminal modes.
Perhaps it’s time to tell about these notorious regimes. UK supports 2
main command systems: VT-52 (N1) and 15IE-00-013 (N2). Differences between these
modes such:
- cursor control keys are encoded differently - in neutral, HP, UPR and
FIX registers.
- the RESET key is encoded differently - in neutral and HP registers;
- the combination of UPR + ENTER is encoded differently;
- differently determined SF-10.
The redefinition of the SF-10 during the transition to the N2 command system consists in
copying in TSF to the address of SF-10 the address of SF-110. Let me remind you that SF-10 -
this is the "cursor to the left", and SF-110 - "cursor to the upper left corner." Such
redefinition is associated with the transcoding of the RESET key.
Take a look at table 23.0. Here are the differences in keyboard encoding for
both modes. Empty cells mean that the encoding differences for
no data combinations.
For convenience, the values of special functions corresponding to
used codes.
Table 23.0 Keyboard encoding differences in N1 and N2 modes.
neutr. HP UPR FIX
1 2 1 2 1 2 1 2
Up <33> A <34> <33> A <22> <33> A <34> <33> A <34>
Down <33> B <35> <33> B <26> <33> J <37> <33> B <35>
Left <33> C <32> <33> C <24> <33> C <32> <33> C <32>
Right <33> D <31> <33> D <23> <33> K <13> <33> D <31>
RESET <33> H <10> <33> J <14>
ENTER <15><12> <25>
Table 23.1 Special functions corresponding to the service key codes.
SF Codes Designation Value
<10> 10 <left> Left cursor
<12> 12 <down> Cursor down
<13> 13 Clear to end Erase from cursor to end of line
<14> 14 Clear Screen Erase the screen
<15> 15 CL Cursor - to leftmost position
<22> 22 Roll up Scroll up a line
<23> 23 Line feed
<24> 24 Line Shift
<25> 25 CR / LF Carriage Return
<26> 26 Roll down Scroll down a line
<31> 31 <to the right> Cursor to the right
<32> 32 <left> = SF-10
<34> 34 <up> Cursor up
<35> 35 <down> = SF-12
<33> A 101 <up>> = SF-34
<33> B 102 <down> = SF-12
<33> C 103 <to the right> = SF-31
<33> D 104 <left> = SF-10
<33> H 110 Cursor - upper left
<33> J 112 Clear to bottom Erase from cursor to end of page
<33> K 113 Clear to end = SF-13
The keyboard of the UK-NTs compares favorably with the keyboard of its “lesser brother” BK
the presence of an additional numeric keypad. Here we come closer to
personal computer, rather than a home (or training) computer.
So, an additional keyboard. It consists of 15 keys. They all change
your encoding when switching to DCL mode and vice versa. DCL mode turns everything
these keys are string keys whose lines begin with the code <33>. Turning
only applies to the neutral register and only an additional keyboard. AT
Table 23.2 gives the encoding of the DCL mode.
Table 23.2 Set of DKL mode codes.
Key String Codes
Enter <33>? M <33><77> <115>
. <33>? N <33><77> <156>
0 <33>? P <33><77> <160>
1 <33>? Q <33><77> <161>
2 <33>? R <33><77> <162>
3 <33>? S <33><77> <163>
4 <33>? T <33><77> <164>
5 <33>? U <33><77> <165>
6 <33>? V <33><77> <166>
7 <33>? W <3 3> <77> <167>
8 <33>? X <33><77> <170>
9 <33>? Y <33><77> <171>
+ <33> P <33> <120>
- <33> Q <33> <121>
, <33> R <33> <122>
The DKL mode is activated using the SF-75. Turns off - SF-76. Moreover, with
shutdown restores the old value of the codes for additional keys
keyboards.
For reliable operation of both console debuggers (in the CPU and software) was provided
a set of encodings that affects most utility keys.
When practicing SF-275 (which may include HALT CPU mode, depending
from the variable (22500)), subroutine 105346 s is necessarily triggered
relevant parameters. She rewrites the codes in TSK for the debugger keys,
previously saving the old codes in a special memory area.
When this SF is canceled (the sequence <33><277> <275>) is restored
CPU mode USER - again, looking at the variable (22500), - and restored
old values in the TSC (subroutine 105400).
Where and when is this special function called? SF-275 direct action is called
each time you enter the debugger, both the CPU and the PP. It should be noted that for
of the CPU debugger, the HALT mode in the CPU is set to (22500) = 0, and for the PP debugger
this is not done - (22500) = 2, and the program running at that time in the CPU does not
is interrupted.
The cancellation of the SF-275 occurs when the CPU debugger exits (via "ICP"). But when
For some reason, this cancellation is not provided for exiting the PP monitor (via UPR + C).
Therefore, it happens like this: you crawl in the debugger
application in the CPU, you return to it, but it does not listen to the keys
cursor control - in the TSC, there is still a set of debugger. Exit - Click
“Stop” followed by pressing “Use”, alas, is not applicable to all programs.
But enough about the sad. Table 23.3 shows a set of modifiable codes in the TSC
for the debugger, and in table 23.4 - the corresponding special functions. All digital
keys - additional keyboard.
Table 23.3 Console Debugger Kit
Key Encryption Key Encryption
0 <60> POM <33> <176>
1 <61> ICP <33> <177>
2 <62> up <33> <200>
3 <63> down <33> <201>
4 <64> left <33> <202>
5 <65> right <33> <203>
6 <66> HP up <33> <204>
7 <67> HP down <33> <205>
8 <70> HP left <33> <206>
9 <71> N / A <33> <207>
ENTER <15> space <40>
Enter <15> Slaughter <177>
RESET <14>
Table 23.4. Some special functions corresponding to the debugger encoding.
SF Codes Designation Value
<14> 14 Clear Screen Clear the screen
<15> 15 CL Cursor - to the left edge of the screen
<33> <200> 200 up Cursor up (= SF-34)
<33> <201> 201 down Cursor down (= SF-12)
<33> <202> 202 left Cursor left (= SF-10)
<33> <203> 203 right Cursor right (= SF-31)
<33> <204> 204 Cursor - to the top of the screen
<33> <205> 205 Cursor - to the bottom edge of the screen
<33> <206> 206 Cursor - to the beginning of the line
<33> <207> 207 Cursor - to the end of the line
Having examined the differences between one mode and another, it would be nice to get to know
a mechanism that allows you to change modes - change the contents of the TSK.
To begin with, downloadable "pieces" are written in ROM. They correspond with
using standard routines, which will now be discussed.
There are 3 routines:
105430 - for rewriting fragments from ROM to TSK without saving old
values
105346 - for the same, but with preservation;
105400 - to restore old values.
Subroutine 105430. Call:
JSR R5, 105430
.Word1
Loads fragments to TSK from memory. It has 1 parameter - memory address (ROM)
beginning of the array from which the fragments are loaded. The array has such
structure:
1 word - offset in TSC,
2 word - load value,
3 word - offset in TSC,
4 word - load value,
etc.
Here the offset is the difference between the word address in the TSK and the value 7232.
The load value, of course, is also the load value in Africa. Array
must end with zero (in the word offset).
Using this subroutine, the command systems N1 and N2 are loaded. Also this
the subroutine reacts very correctly to this situation: the set is loaded
debugger (and it loads with the old values of the TSC), and
change the command system. What she does: checks for an array
values stored in RAM, and if it finds, then for those words ТСК, which
changed by the debugger, writes new values not to TSK, but to this copy array.
So when the debugger set becomes low, there will be a new one in TSK
command system.
Subroutine 105346. Call:
JSR R5, 105346
.Word1
.Word2
Loads fragments of TSK from memory with preservation of old values. 1st parameter
- the address in memory (in ROM), from where the array is copied to the TSK. 2nd parameter -
address in RAM, starting from which the old word meanings are written in the TSC.
The subroutine only works if the first word of the specified
The array in RAM contains 0 - the array is not busy. Then she writes in this word 1
- a sign of employment.
This routine is used to load DCL mode encodings, as well as
console debugger. Here are the areas in RAM for these needs:
11014 - 11052: under DCL,
11054 - 11136: under the debugger.
The information in these arrays has the following structure :
1st word equals 1 for real arrays, other words contain
meaning of saved words from TSK.
Subroutine 105400. Call:
JSR R5, 105400
.Word1
.Word2
The subprogram in its effect is the reverse of the previous one - it restores
old values in the TSC from the specified array in RAM. Parameter words have one
same meaning. The first parameter - the address in the ROM - is needed in order to find in
the array in the ROM is the offset in the TSC - after all, there are no offsets in the RAM array. At work
the subroutine invalidates the array in RAM - writes 0 to its first word.
And finally, about the areas of ROM where replaceable sets of codes are written:
N1: 106634,
N2: 107002,
DCL: 107120,
debugger: 107310.
The reader of this book probably knows what keys are and why they are needed.
The definition of keys using the standard special function SF-120 was described in
relevant section.
In RAM, about 1 Kb is allocated for the key strings. When their number is 25
pieces it turns out that each key can freely have up to 38 characters.
The location of the area under the keys: 11140 - 13130.
No one, of course, will forbid you to store strings under keys in any place, and not
only in the indicated area of memory.
In order to make it easier for you (and your programs) to search for keys in TSK,
I will give a plate with offsets from address 7232. The plate is in the body
СФ-120 with address 115342 and contains offsets for all 25 keys (in order).
Table 23.5 Offset from address 7232 in the TSC for 25 key keys.
Keys Registers
neutr. HP GRAPH UPR FIX
K1 10 270 550 1030 13 10
K2 12 272 552 1032 1312
K3 14 274 554 1034 1314
K4 20 300 560 1040 1320
K5 22 302 562 1042 1322
The purpose of the TRAP 2 routine is to send codes from an ASCII buffer
keyboards in K0 (in the CPU) or in the register R0 (in a program running in the PC).
Recall that the dimension of the keyboard ASCII code buffer (buffer N3) is a word, and
it can equally well contain both ASCII codes (0 ... 377) and addresses
ASCII lines (1000 ... 177777). TRAP 2 gentlemanly handles both of these
situation.
The general strategy of TRAP 2 with channel K0 is simply beautiful. Judge for yourself. Of
keyboard maintenance programs called TRAP 2. That checks the case
status, and if everything is in order (the channel is ready for recording) it writes to the source RD
channel bytes from the buffer and quietly rounded off. When that moment comes
when the CPU deigns to read this byte from the RD of its receiver, it is called in the PP
the interrupt processing routine from the source K0, which is nothing but
like TRAP 2, but with an entry point just below. He writes the byte to the channel again, and
again, TRAP 2 completes without any problems. And so on until
it turns out that the entire buffer has been sent to the channel. It is recognized by equality
values of pointers to write and read information from buffer N3 (cells
(7210) and (7206), respectively).
Cell (7230) serves as an indicator of this state. She is zeroed at every
call TRAP 2, and takes the value 2 only after the combination of values
both buffer pointers. This cell is parsed every time before a call.
TRAP 2, and if it is equal to zero, the TRAP call is simply not made (to the best
times).
A very important feature of TRAP 2 is to write ASCII codes of keys not in K0, but in
PP register R0 due to the fact that not always the final information from the keyboard
accepts CPU. For example, when the menu "Set modes" or "Download" PP
It itself accepts ASCII codes of pressed keys and is not advised with the CPU at all.
The choice between K0 and R0 is carried out depending on the variable (7042),
which, in principle, serves to turn on / off the channel K0. If she
equal to 2, work is underway with the channel (it is “on”), and if it is 0, then with R0 (channel
"switched off"). The same cell is checked in TRAP 4, which deals with reception
byte from K0 (for the screen output program). There at its zero value in general
nothing happens, and bytes are not fetched from the channel.
Now it's time to take apart the mechanism for working with the keyboard via R0 (from the software).
This EMT routine (addresses for both EMTs are the same - 104132) works like this.
It calls TRAP 2, and upon return, it analyzes the cell (7230). If it is equal
0, then everything is in order, and after exiting the EMT manager in R0 it turns out
the next byte from the ASCII code buffer (this focus is made on the stack). If a
the same (7230) = 2, that is, all information currently from the buffer has already been read, then
This cell takes the value 0, and TRAP is called 0 for execution
accumulated processes (including from the keyboard). After TRAP 0 again
TRAP 2 is called and the circle closes. Let me remind you, all this happens within
EMT 22.
One thing to remember always - EMT 22 (or rather TRAP 2) writes ASCII codes to R0
if and only if channel K0 is turned off from work - the variable (7042) = 0.
Otherwise, nothing useful will get into R0.
Similar to screen output, there is an EMT routine that executes
initialization of the keyboard, as they say, from scratch.
Figure 24.2 shows a block diagram of this EMT (address 103564).
First, A.V.P. and interrupts from the keyboard and from
K0-source PP. Then, in routine 104064, the initial
Values for all 6 keyboard buffer pointers.
In the next step, the key region pointer takes its initial value:
(13140) = 11140, the initial values of the keyboard variables are assigned.
Then comes the construction of the TSC. Like building a row table, this process
passes in several stages.
1st stage.
The "backbone" of the TSK is being built: byte key codes are copied from the ROM. In ROM these
codes are stored in compressed form - one code takes a byte, not a word, as in TSK.
2nd stage.
Enter the codes of the control keys. In ROM, serial numbers are written in the TSK
these keys, and the program itself writes to the corresponding cells of the number 400,
401 etc.
3rd stage.
Activation of string service keys. Row addresses are written for those
string keys that do not change when changing the terminal command system -
such as POM, COI. The ROM stores a kind of mini-lines, the first byte of which
- the serial number of the key, and the subsequent ones make up the line onto which
a link is written in TSK. These mini-lines end with 0, as expected
self-respecting and other lines.
4th stage.
Key keys are being configured. In ROM, there are also micro-lines consisting of
the sequence number of the key words in the TSK in the first byte, and zero in the next. On
these zeros indicate the keys after such a setup.
These four steps are repeated sequentially 5 times for all TSCs. Here are the addresses
in ROM, by which you can find "minimized" TSK:
N TSK Register Start Address
1 neutr. 105520
2 HP 105702
3 GRAPH 106064
4 UPR 106262
5 FIX 106452
Last of all, procedure 113670 is called, which is nothing but
as SF-27 (installation of the command system N1). That writes a set of codes N1, and, - about
miracle! - the brand new 5 TSK are ready.
Well, in the last turn, the time of normal
auto repeat: (7226) = 2.
Everything. Return.
* Code matching tables do not remain unshakable throughout
his life in RAM. They are changing (fragmented). Change is happening
when changing terminal modes.
* Terminal modes can change the encoding of service keys, also
The key coding of the additional keyboard changes.
* TSK values change when changing the terminal systems:
N1 - 15IE-00-013,
N2 - VT-52.
When changing the mode, the old values of the changed words TSK disappear without
news, and some heroically die.
* Two more modes turn on and off "on top" of different systems
commands:
- DKL mode (additional keyboard),
- mode of the remote debugger.
When they are turned on, the old TSC values are saved. When turned off -
are being restored.
* Change of modes is carried out using three subprograms:
105430 - loads a fragment into the TSK without saving the old values,
105346 - the same, but with preservation,
105400 - restores a saved fragment of the TSK.
Summary to §23.24:
* Code matching tables do not remain unshakable throughout
his life in RAM. They are changing (fragmented). Change is happening
when changing terminal modes.
* Terminal modes can change the encoding of service keys, also
The key coding of the additional keyboard changes.
* TSK values change when changing terminal command systems:
N 1 - 15IE-00-013,
N 2 - VT -52.
When changing the mode, the old values of the changed words TSK disappear without
news, and some heroically die.
* Two more modes turn on and off "on top" of different systems
commands:
- DKL mode (additional keyboard),
- mode of the remote debugger.
When they are turned on, the old TSC values are saved. When turned off -
are being restored.
* Change of modes is carried out using three subprograms:
105430 - loads a fragment into the TSK without saving the old values,
105346 - the same, but with preservation,
105400 - restores a saved fragment of the TSK.
This chapter will talk about ways to change the service system.
keyboards. It often happens that this is tough and at first glance
an unshakable system is not very suitable for the specific requirements of the programmer.
Creating a new keyboard driver is not the only way to solve this
Problems. I will try to show those "soft" points of the system by working on
which, you can rebuild the system in your own way.
Here are the main ways to customize your keyboard:
* interception of keyboard interruptions
* reconfiguration TSK
* add control keys
* interception of exit from a p.p. network timer (auto repeat off)
* control interception in TRAP 2
* work with buffers.
Now in detail and in detail - about each method.
Interrupt interception is the most common among most
programmers way - it just lies on the surface.
His most frontal decision is to write his own po (processing program
interruptions) and creating your own keyboard maintenance system. Old
systems, of course, killed.
Another thing is if you do not completely kill the system, but simply
interfere with the flow of information from the keyboard. Then just install
control over the receipt of Scan codes from the keyboard RD into the Scan codes buffer
(buffer N 1).