R. HUDYAKOV

Work experience with the peripheral processor UKNTS

Before the program will work in RAM, it must be downloaded there. We begin the story about this operation with an array of parameters (hereinafter referred to as the MP), the format of which is shown on the first printout.

MASSIV: .Byte 0; This byte will contain an error code or 0

COMAND: .Byte 0; Command (01-SELECT MEMORY, 02-REMOVE MEMORY, 10-READ, 20-WRITE, 30-START)

TYPDEV: .Word 32; Device - Peripheral

ADR $ PP: .Word 0; Address in RAM PP

ADR $ CP: .Word 0; Address in RAM CPU

LENGTH: .Word 0; The length of the program in words (not bytes!)

ADRMAS: .Word MASSIV; The word always contains the starting address of the parameter array

        .Word 401; Stop element (used during transmission)

ZAGR: .Enable LSB

        MOV # ADRMAS, R0; MP address in R0

        MOV # 5, R1

        BR     1 $; Transfer four bytes

$ 2: MOVB (R0) +, @ # 176676; (ADRMAS field and word containing 401)  

$ 1: TSTB @ # 176 674  

        BPL.-4

        SOB R1.2 $

        RTS PC; Return

Commands "Select memory ", "Free memory", "Read", "Write", "Start". For the correct execution of the “Allocate memory” command, the COMAND MP field must contain code 01, TYPDEV - code 32, and LENGTH - the length of the loaded program. The values ​​of the remaining fields are ignored. After forwarding the MP in the ADR $ PP field, the PP returns the address starting from which after the “RECORD” command the transferred program will be placed. Upon repeated request, memory is allocated from the remaining free. If the program size exceeds the free memory size in the software, then the free memory length is returned in the LENGTH field , and the MASSIV field will not be zero.

For the “Free memory” command, the ADR $ PP and LENGTH fields must contain the same parameters that were set when this segment was selected , otherwise the command will not be executed, and a nonzero value will be returned in the MASSIV field .

For the “Read” (“Write”) command, the ADR $ CP field contains the RAM address of the CPU, from where (where) the program will be forwarded. For the Start command, ADR $ PP contains the start address of the program. The program itself must be executed as a subprogram (end with RTS PC ) and be movable, since its location is not known in advance.

Listing 2 shows the subroutine for loading MP into the software.

ZAGPP: .Enable LSB

     MOVB # 1, COMAND; Execute the “SELECT MEMORY” command

     MOV (R5), OCP; A label from

     CALL ZAGR; two words. 1st — the length of the program, 2nd — its starting address in the RAM of the CPU

     TSTB MASSIV; Is there enough memory?

     BEQ 1 $         ; Yes    

     MOV # NOMEM, R0; We display an error message

     EMT 351; "Out of memory"

     CMP (R5) +, (R5) +; Increase R5 by four

     SEC; Set the error flag

     BR 2 $; And exit

1 $: MOVB # 20, COMAND; Work out "RECORD"

     MOV (R5) +, LENGTH; From the plate the 1st word in LENGTH,

     MOV (R5) +, ADR $ CP; 2nd in ADR $ CP

     CALL ZAGR

     MOVB # 30, COMAND; Run "START"

     CALL ZAGR

     MOVB # 2, COMAND; Work out “REMOVE MEMORY”

     MOV -4 (R5), ADR $ CP

     CALL ZAGR

$ 2: RTS R5 ; Return             

It transmits the address of the parameter array and two bytes of the completion of transmission, normalizing the state of the channel, via channel K2.

By pa spechatke 3 shows a complete download software program, its start-up and subsequent release of the PP memory after use.

.MACRO $ ZAGPP STA DR, ENDADR

        JSR R5, ZAGPP

        .WORD <ENDADR-STADR / 2>, STADR

.ENDM $ ZAGPP

The subroutine call format is shown in printout 4.

     .TITLE MYPROG

START: $ ZAGPP STARTPP, ENDPP   ; Download the program    

     EMT 350 ; Monitor output                   

; Here are routines, messages and an array of parameters

STARTPP: INC (PC) +   ; This program can be replaced with any other            

     .WORD 0 ; --- * --- * --- * --- * --- * -                       

     RTS PC ; Return to CPU                    

ENDPP:

     .END START

And here is a complete program.

↓ ----- ADDRESS

| 0000 | 0000 | 0000 | 0000 || 0000 | 0000 | 0000 | 0000 |

white yellow violet red turquoise green blue black

So, the program in the software is loaded.

Working with registers of external devices does not differ from usual. The address space of the RAM RAM has a range of 0–77777, the ROM of the software has a range of 100000-177777, that is, 32 Kbytes of RAM and 32 Kbytes of ROM. The PP (like the CPU) has its own remote debugger, which facilitates debugging of programs (you can enter it from the settings menu by pressing the UPR and @ keys simultaneously). You need to work with it in the same way as with the console CPU debugger.

We will focus on additional features that can only be used with software. Let's start with the display tools . To start, “click” the palette. In the UKSC any color displayed on the screen can be represented by any other (swap red and green, violet and turquoise, etc.). Let's say you changed blue to white. Now everything that you write down in a blue plan will appear in white on the screen, and if any other program does not change the value of the corresponding memory cell, then even after going to the monitor, everything that should be displayed in blue will be displayed in white including graphic information. Color swapping happens very quickly (almost instantly), on this you can build interesting effects.

The format of the control cells for the hardware display is shown in the figure (there are four such pairs of words, their “credentials” are given in Table 1). Each of the colors is represented by four bits. Bytes of each of the notebooks mean (from left to right):

color brightness (1 - 100% brightness, 0 - 50%);

red color (1 - red is, 0 - no);

green color (1 - yes, 0 - no);

blue color (1 - yes, 0 - no).

 

     MOV # 2470, R0       ; Screen palette address in R0     

     MOV (R0), - (SP); Remember the current value on the stack     

     MOV 2 (R0), - (SP); palettes     

     CLR (R0) ; Turn off the screen                 

     CLR 2 (R0) ; (all the colors on the screen are black)                

    MOV # 100000, @ # 177010     

     MOV # 30., R1     

$ 2: MOV # 20., R2     

$ 1: MOVB # 377, @ # 177012; Draw a square    

     INC @ # 177010     

     SOB R2.1 $     

     ADD # <80.-20.>, @ # 177010     

     SOB R1.2 $     

     MOV # 1, R1 ; Click the palette.                

$ 3: MOV R1, R3     

     .REPT 4 ; Four times ASL R3                  

     ASL R3     

     .ENDR

     BIC # 360, (R0)     

     BIS R3, (R0) ; The square is displayed              

     CLR R2 ; Blue to White                   

     SOB R2 ,. ; <- delay                 

     SOB R2 ,. ; <- delay                 

     INC R1     

     CMP # 8., R1     

     BNE 3 $     

     MOV (SP) +, 2 (R0); Return previous values     

     MOV (SP) +, (R0); cells     

     RTS PC ; Return                   

On letters 5 of the Kvant plant, the IS 155LP9 was removed from the color monitor controller circuit; therefore, the luminance bit does not affect the image; on almost half of the machines of the SEMZ plant, the IS 155LP9 was replaced by the IS 155LN2, therefore, in order to obtain 100% brightness, it is necessary to write 0 in the luminance bit, and 1 for 50%. All this is true only for a color monitor, for displaying gradations of brightness on black and white monitor luminance bit is not affected.

We also note that at the beginning of 1991 the connection scheme of the color monitor was changed (the outputs of the red and green colors changed places).

Table 1

Address

Area controlled by corresponding cells

2400

2470

4700

6750

Top service line

Actually the screen itself

Settings Menu

Bottom service line

Here is a program for software that does the following: the screen turns off , a blue square is drawn on it (invisibly); the screen turns on (a square appears); then the color of the square begins to change from blue to white.

      MOV PC, R0

      ADD    #SOOB -., R0; Calculate the address from the message

      MOV R0, AMT

      MOV PC, R0

      ADD # SOOB1 -., R0; Same

      MOV R0, AMT1

      MOV # 135230, @ # 2400; Allow all colors to be displayed on the screen

      MOV # 177334 @ # 2402; for top performance with Troki

      MOV    # 135230 @ # 6750; The same is done for n izhney

      MOV      # 177334, @ # 6752

      MOV    # 1, @ # 22614; The color of the characters on the top line is blue

      MOV # 3, @ # 23106; The color of the characters on the bottom line is turquoise

      MOV   # 63146, @ # 22620; The color of familiarity on the top line is yellow

      MOV # 52525, @ # 22622

      MOV # 52525, @ # 23112; Familiarity color in the bottom line - purple

      MOV # 42104, @ # 23114

      MOV   # 67, @ # 2372; Top line in 4 (10X24) format

      MOV # 47, @ # 6742; Bottom line in format 3 (20X24)

      EMT 52 ; Print the message to the top line             

AMT: .WORD 0 ; Here is the message address               

      EMT 56 ; Print the message to the bottom line             

AMT1: .WORD 0 ; Here is the address of the second message               

      RTS PC ; Return to CPU             

SOOB: .ASCIZ <40.> / TECHNOCOM /

SOOB1: .ASCIZ <40.> PRESENT

      .EVEN

When outputting information to service lines, you can change the format and colors of the character and familiarity, and the colors change in two ways. The first is a direct change in the colors of the symbol and familiarity, the second is through a change in the output color palette.

An example of a program with changing the colors of a symbol and familiarity.

      MOV     PC, R0 ; Calculate message address          

      ADD #SOOB -., R0

      MOV    R0, AMT

      MOV PC, R0 ; Same          

      ADD # SOOB1 -., R0

      MOV R0, AMT1

      EMT 52 ; Bring TECHNOCOM to the top line             

AMT: .WORD 0 ; Here is the message address               

      EMT 56 ; Print "REPRESENTS" in the bottom line             

AMT1: .WORD 0 ; Here is the address of the second message              

      MOV # 67, @ # 2372; The format of the top line is 4 (10X24)

      MOV # 47, @ # 6742; The format of the bottom line is 3 (20X24)

      MOV # 135236, @ # 2400; Present the yellow color for the top line

      MOV # 174734, @ # 2402; blue and black yellow

      MOV # 135235, @ # 6750; Present the yellow color for the bottom line

      MOV # 175734, @ # 6752; turquoise and black purple

      RTS   PC ; Return              

SOOB: .ASCIZ <40.> / TECHNOCOM /

SOOB1: .ASCIZ <40.> PRESENT

      .EVEN

Cells with addresses 2400, 2402 (6750, 6752) are responsible for the output palette for the upper (lower) service line. Their format has been described above.

In cells 22614, 23106, the color of the symbol is stored in the format (0 - black, 1 - blue, 2 - green, ... , 7 - white), and in cells 23112, 23114 - the familiar color in the format of the code for the background color code (177020, 177022) (this format will be discussed below). In the initial state (after turning on the power), the blue plan for output to service lines is blocked.

An example program with changing the output palette.

           3   2 1   - point number in octet

1770 20: 0000! 0000! 0000! 0000

          RGB RGB RGB RGB - Red, Green, Cyan Plans

           8 7 6 5 High bit    

177024: 0000! 0000! 0000! 0000 of each notebook   

          RGB RGB RGB RGB not used   

The requirements for outputting textual information to service lines are as follows: the first byte of any message is a positioning byte, and the message text itself must be eight-bit, since the codes <RUS> and <LAT> (16 (8) and 17 (8) are not processed when printing .

Now a little about the output of graphical information from the PP. There is a whole group of registers that greatly simplifies this process:

177016 (write / read) - register color code points. Format - a number from 0 to 7 (dot color);

177024 (record) - The octet register of a point. Format - an octal number from 0 to 377 (eight bits - eight points on the screen; the bit contains 1 - the point is lit, 0 - is canceled);

177020 - register of the background color code (plans 0-1), 177022 - register of the background color code (plans 1-2). Both registers are a single entity; the format is shown in the figure. We display an octet in which the first point is black, the second is blue; the third is green ..., the eighth is white. To do this, write the number 0011 0010 0001 0000 to 177020, and 0111 0110 0101 0100 to 177022.

      MOV # ^ B0011001000010000, @ # 177020; Download color code register

      MOV # ^ B0111011001010100, @ # 177022; background according to the principle of the 1st dot is black, the eighth is white

      MOV    # 100000, @ # 177010 ; Download the address of the plans in the register of addresses of plans.            

      MOV # <264. * 80.>, R1  ; In R1, the total number of bytes of the screen area            

$ 1: CLR @ # 177024        ; “Clear” the current octet             

      INC @ # 177010        ; Increase by 1 address in the plans            

      SOB R1.1 $ ; All this in a loop                       

; COLOR BARS ARE VISIBLE ON THE SCREEN

      MOV # ^ B0100010101100111, @ # 177020; Download other values

      MOV # ^ B0000000100100011, @ # 177022; background colors

      MOV PC, R2

      ADD    #SPRITE -., R2   ; Sprite address in R2             

      MOV # 100000, @ # 177010 ; Address in plans - 100000           

      MOV    # 7, @ # 177016     ; We will output in white             

      MOV # 11, R0 ; Sprite sizes (Y - 11, X - 21)                      

$ 3:   MOV # 21, R1

; THIS PART WILL BE SELECTED

$ 2: MOVB (R2) +, @ # 177024 ; Bytes of which the sprite consists, in order on the screen   

; END OF ALLOCATED PART

      INC @ # 177010        ; Let's increase the address in plans by 1  

      SOB R 1 , 2 $ ; Next byte to the screen             

      ADD # <80.-21>, @ # 177010; Pull back to display the next line

      SOB R0.3 $ ; sprite.              

      RTS PC ; Return                

; BELOW DAN SPRING

SPRITE: .Byte 377,7,377,37,36,36,74,170,340,77,360,340,201,377,300,3,17

        .Byte 61,6,6,30,30,6,30,60,60,140,140,140,300,200,201,3,7

        .Byte 60,0,6,0,60,3,30,60,30,300,140,60,140,0,203,207,7

        .Byte 60,0,6,0,340,1,30,60,30,300,140,30,140,0,203,315,6

        .Byte 60,0,376,1,300,0,370,77,30,300,340,17,140,0,203,171,6

        .Byte 60,0,6,0,340,1,30,60,30,300,140,30,140,0,203,61,6

        .Byte 60,0,6,0,60,3,30,60,30,300,140,60,140,0,203,1,6

        .Byte 60,0,6,30,30,6,30,60,60,140,140,140,300,200,201,1,6

        .Byte 170,0,377,37,36,36,74,170,340,77,360,340,201,377,300,3,217

      .Even

ENDPRG:; End of program in software                         

177026 - register mask plans. Format - a number from 0 to 7 (one or more plans into which you want to prohibit the recording of information). The register does not block writing to the green and red plans from the CPU.

Consider the use of these registers. The program below first fills the screen with colored vertical stripes with a thickness of one point, then displays a sprite in the upper left corner of the screen.

$ 2: MOVB (R2) +, R3

     MOV R3, @ # 177024

The output of information on the screen can be of two types - with the drawing of new information on the old background and with the erasure of old information. To draw on the old background, you need to address 177024 to the register byte ( MOVB ), to erase - as if ( MOV ). In the above example, rendering with erasure is provided by replacing the selected part of the program with the following:

     BIS # 6, @ # 177710     ; Clock frequency of the timer 16 μs  

     BIC # 17400, @ # 177716 ; Clear bits 8 through 12  

     MOV # 200, R0 ; Set to R0 a single digit - 7           

$ 1: XOR R0, @ # 177716 ; If it is in 177716, then remove it and vice versa      

     MOV # <pitch depends on this number>, R 1

     SOB R1 ,. ; Delay on this number              

     BR 1 $ ; Infinite loop                

As you can see, using this group of registers you can significantly increase the speed of graphics output, but sometimes this speed is not enough. You can increase it several times using non-register (direct) access to video RAM. But more about that next time.

Now a little about music. Sound from the UKSC speaker can be obtained using registers 177710 and 177716. In register 177716, bits 7 through 12 allow you to receive sounds with a frequency of 60 Hz to 64 kHz at a frequency of a programmable timer of 2, 4, 8, and 16 μs. In the table. Table 2 shows the correspondence of combinations of bits 8-16 of register 177716, and in Table. 3 - bits 1, 2 of the register 177710.

Sound frequencies are given for a clock frequency of 16 µs. If the clock frequency is 8 μs, then the frequency values ​​in the right column will increase by 2 times (respectively for 4 μs by 4 times, and for 2 μs by 8 times).

If bits 8-12 contain 0, then the sound frequency will depend on the speed with which bit 7 switches from 0 to 1. The way to extract sound is simple. By changing the value loaded for the delay, we control the pitch of the sound . The program below works on this principle.

Table 2

Register digits 177716

Sound frequency

7

12

eleven

ten

9

eight

Software generated

0

0

0

0

0

Corresponds to the program

one

0

0

0

0

one

0

0

0

one

0

0

0

one

0

0

0

one

0

0

0

one

0

0

0

0

60 Hz

250 Hz

500 Hz

1 kHz

8 kHz

0

Sound muted

 

one

Boolean combination

Assembly of the frequency grid according to "And"

Software generated

*

*

*

*

*

The assembly of the frequency grid according to "I" is modulated by the program

 

1st octave

      To - 130.8

      C sharp, D flat - 138.6

      Re - 146.8

      D Sharp, E Flat - 155.6

      Mi - 164.8

      Fa - 174.6

      F sharp, G flat - 185.0

      Salt - 196.0

      G sharp, a flat - 207.7

      A - 220.0

      A sharp, B flat - 233.1

      C - 246.9

      Average to - 261.7

2nd octave

      C sharp, D flat - 277.2

      Re - 293.7

      D Sharp, E Flat - 311.1

      Mi - 329.6

      Fa - 349.2

      F sharp, G flat - 370.0

      Salt - 392.0

      G sharp, a flat - 415.3

      La - 440.0

      A sharp, B flat - 466.2

      C - 493.9

      Average to - 523.3

This method has a significant drawback. On different machines, the pitch will “float”, since the performance of the software changes from machine to machine due to the spread of the parameters of the element base. This drawback can be eliminated by “collecting” the necessary frequencies from a set of standard ones. The assembly is carried out according to “I” (one frequency modulates the other), which allows, by controlling the frequency of the programmable timer and combining the values ​​of bits 8-12 of register 177716, to achieve the performance of simple melodies.

Table 3

Register digits 177710

Clock period

2

one

0

0

one

one

0

one

0

one

2 μs

4 μs

8 μs

16 μs

This method gives a stable sound, but its drawback is obvious: it is extremely difficult to get the required notes. It is much better to use the programmable timer in a “pure” form in the interrupt mode. The advantages of this method: clean stable sound, selection of frequencies up to units of hertz and ease of practical implementation. Indeed, since you can smoothly change the pitch and duration (this is implemented on another timer - network), then you can already play quite complex melodies. To facilitate the task, we give the values ​​of the frequencies of sounding notes of two octaves in hertz.

       The PC MOV, R0 ; Calculate address processing program prairie vany          

       ADD #POP -., R0      ; from programmable timer

       MOV R0, @ # 304; Load this address into the interrupt vector

       The PC MOV, R0 ; Calculate address processing program prairie vany          

       ADD #POPT -., R0; from the network timer

       MOV R0, @ # 100; Load this address into the interrupt vector

       The PC MOV, R0 ; Calculate the starting address of the array with the muse Coy          

       ADD #MUZON -., R 0

       MOV R0, ADRESS; Load this address into the ADRESS cell

       MOV R0, EADRES; Calculate and load into the EADRES cell

       ADD # <EP-MUZ0N>, EADRES; end address of the array with music

       BIS # 107, @ # 177710; Set the programmed clock period

       RTS    PC ; 16 μs timer and enable ; interrupt from it              

; PROGRAM OF PROCESSING INTERRUPTIONS FROM THE NETWORK TIMER

PORT: .ENABLE LSB

       DEC (PC) + ; Reduce by 1 the contents of the cell COUNT          

COUNT: .WORD 50 .; 50 ticks is 1 second (note duration)           

       BNE 1 $ ; If the second has not elapsed, then exit             

       MOV @ ADRESS, TON + 2; Play the next note from the array

       ADD # 2, ADRESS; Go to the next note

       CMP EADRES, ADRESS; Isn't the end of the array?

       BNE 2 $

       SUB # <EP-MUZ0N>, ADRESS; Yes. Back to the beginning

$ 2: MOV # 50., COUNT      ; 1 second in COUNT 

$ 1: JMP @ # 174612        ; Exit from interrupt 

; PROGRAM OF PROCESSING INTERRUPTIONS FROM WORLDWIDE TIMER PROGRAMS

POP: .ENABLE LSB;

       TST @ # 177714; Clear the register of the current value, etc. time.

       MOV R0, - (SP); Save on the stack R0

       MOV # 200, R0 ; Load the number 200 into R0        

       XOR R0, @ # 177716; 7th digit if any - remove, and vice versa

       MOV (SP) +, R0      ; Restore R0

An example of a program illustrating the use of a programmable timer:

TON: MOV # 0, @ # 177712; Load the current value of the cell T O N + 2 into the buffer register of the programmable timer

       RTI ; Return from interrupt                 

ADRESS: .WORD 0 ; Storage cell of the starting address of the array          

EADRES: .WORD 0 ; Storage cell of the final address of the array          

; FURTHER SHOULD BE A MASSIVE WITH MUSIC

MUZON: .WORD 478.; Until the first octave

        .WORD 426.; Re of the first octave

       .WORD 379.; Mi of the first octave

        .WORD 358.; Fa of the first octave

        .WORD 319.; Salt of the first octave

        .WORD 284.; A of the first octave

        .WORD 253.; C of the first octave

        .WORD 239.; median D on

       .WORD 213  .; Re of the second octave

       .WORD 190.; Mi of the second octave

       .WORD 179.; Fa of the second octave

        .WORD 159.; Salt of the second octave

        .WORD 142.; La second octave

        .WORD 127.; C of the second octave

        .WORD 119.; Until the second octave

EP:; End of program in PP                        

This program plays the specified notes in order in a loop. The values ​​of the numbers corresponding to the real sound frequencies are calculated by the formula A / F , where A corresponds to the clock frequency of the programmable timer (for a period of 16 μs A = 62500, for 8 μs A = 125000, for 4 μs A = 250000, for 2 μs A = 500000 (all values ​​are decimal), and F is the frequency that you want to get.Note that the buffer register of the programmable timer (177712) is 12- and not 16-bit! This should be remembered when loading data into the register.

Original text