Spectrum Progress #01
30 сентября 1996

Notes programmer - Extended opertivnost memory for ZX Spectrum.

<b>Notes programmer</b> - Extended opertivnost memory for ZX Spectrum.
  As happens sometimes a shame when useful
program with enviable persistence refuses
use the entire amount of computer memory and
naively believes stupid that the 128 or 256
kilobyte - a breathtaking luxury for
the late twentieth century.


  (C) Denis Parinov, 1996.



  When they say "memory" that are due to memory, ie memory that 
is directly connected to the microprocessor and is designed for 
storage and execution of programs and data directly involved in 
operations. 


  Under the memory-management software to understand
access and distribution among programs.


  In the ZX Spectrum computer processor is used Z80, which has 
a 16-bit bus addresses, which allows it addressed

to 2 ^ 16 = 65536 memory cells. In the model
ZX Spectrum 48 processor itself could
addressed to all the memory cells.


  But in the model ZX Spectrum 128 address
space of the processor was not enough and his
the developers decided to use a paging memory model.


  Page model of memory differs from the linear so that each 
cell has a linear its own individual address and the processor 
may be addressed to it at any time, and paging, the cells are 
arranged in groups (pages) on 16 Kbps and the processor may be 
addressed in any time to 32 kilobytes of memory linear

(RAM), to 16 kilobytes (ROM), as well as to 16 kilobytes paged 
memory (RAM). 


  Switching memory pages is carried out with

                               command

  Page model of memory. OUT 32765, n, where

                               n - Configuration

                               Port 32765 dec /

                 7 Page # 7FFD hex.

                               Appointment of bits

               Page 6 D0 ... D2 - Room

                               current page

             4 page hosted in

                              address range

           3 starnitsa with 49152 (# C000)

                              to 65535 (# FFFF).

         1 page D3 - current ROM:
# FFFF 65535 0-128 ROM, ROM 1-48

       0 page D4 - active screen

                            0-normal to 16,384 /

                            # 4000, 1-extra # C000 49,152 are 
positive with the 49152 / 

       2 page # C000 at the 7 th page

                            memory.

                            D5 - lock
# 8000 32768 port 32765 / # 7FFD

       5 Page D6 .. D7-in ZX Spect
                            rum 128 is not used
                            characterizes.
# 4000 16384 Before switching

                            pages must

         16K ROM, follow these

                            steps:
# 0000 0 a) move

                            stack pointer to
address below 49152, it can be done from
assembler command LD SP, # BFFF or BASIC
49151 CLEAR command.

    b) put in a system environment variable 128-th
BASIC "BANK" (23388) configuration value
port 32765 (# 7FFD), to the interruption
page of RAM is not switched to normal
state.


    Example:


     LD (STACK), SP; Save stack pointer

     LD SP, # BFFF; Set stack 49151

     LD HL, # C000;

     LD A, 1, Switch to 1-th country
     CALL BANK; per unit of memory.

     LD B, (HL); Take the contents of the cell

                     , 49152 on the 1 st page of memory.

     LD A, 0 Switch to 0-th country
     CALL BANK; per unit of memory.

     LD C, (HL); Take the contents of the cell

                     , 49152 on the 0-th page of memory.

     LD SP, (STACK); recovery index

                     ; Stack.

     RET; return from the program.

BANK DI; disable the interrupts.

     PUSH BC; Remember BC.

     LD BC, # 7FFD;

     OR # 10; Install ROM 48.

     LD (23388), A; Change lane. BANK.

     OUT (C), A; Output to port 32765 values
                     ; Chenie battery.

     POP BC; Recall BC.

     EI; Enable interrupts.

     RET; Return from subroutine



             Additional screen.


  The computer ZX Spectrum 128 has
second, additional screen.


  It is located at the 7 th page of memory
49,152 addresses (# C000) and has exactly the same
structure as a conventional screen. Only
difference is the 15-th bit of screen addresses to
normal screen, this bit is 0, and the
Supplementary 1.


  Switching between screens is carried out
port 32765 (# 7FFD), to display an additional screen should run 
the program: 


     DI; Disable interrupts.

     PUSH BC; Remember BC.

     LD BC, # 7FFD;

     LD A, (23388) Get the contents of the first. BANK

     SET 3, A; Install the third bit is determined
                    , That returns the active screen.

     LD (23388), A; Post New znaeenie in

                    ; Variable BANK.

     OUT (C), A; Output port 32765 (# 7FFD)

                    , The contents of the battery.

     POP BC; Recall BC.

     EI; Enable interrupts.

     RET; Return from the program.



  For conventional screen:


     DI; Disable interrupts.

     PUSH BC; Remember BC.

     LD BC, # 7FFD;

     LD A, (23388) Get the contents of the first. BANK

     RES 3, A; Reset the third bit is determined
                    ; Yuschy active screen.

     LD (23388), A; Post New znaeenie in

                    ; Variable BANK.

     OUT (C), A; Output port 32765 (# 7FFD)

                    , The contents of the battery.

     POP BC; Recall BC.

     EI; Enable interrupts.

     RET; Return from the program.


  The above program operates only display one of the screens by 
changing the third bit of the port configuration. 


  Before displaying the image for an additional
screen should include the 7 th page of memory and
display an image.


  After that you can include any other
memory page, the image will be displayed
yet installed the third bit is the port # 7FFD/32765.



      Invalid use of incomplete

         Addressing the port configuration.


  Due to lack of information on the above topic, novice 
programmers trying to understand other people's programs and at 
some point find a "best" way to switch pages with the command 
OUT (# FD), A. 


  They safely replace more cumbersome:


                  LD BC, # 7FFD

                  OUT (C), A

more compact: OUT (# FD), A.


  Since there are no programs running on
computers Scorpion, Profi and others whose memory is 128K.


  By the way, if you really were talking about these cars, then 
consider the short-memory management in Scorpio.



  Port # 7FFD (32,765), the appointment of bits:

 D0-D2 - the page number memory, placed with

         Address # C000.
 D3 - choose 1 of the first screen to display on

         display.
 D4 - select ROM 48.
 D5 - turn off the port # 7FFD.
 D6 - not used.
 D7 - not used.


  Port # 1FFD (8189), the appointment of bits:

 D0 - replacement ROM zero page memory.
 D1 - select option ROM with a shadow

      service monitor.
 D2 - is not used.
 D3 - output to RS-232.
 D4 - Bank of RAM. (0-basic, 1 advanced).
 D5 - STROBE signal to CENTRONICS.
 D6 - not used.
 D7 - not used.


  The sample program will demonstrate the above.


  Suppose we want to save the contents of the screen on the 8 
th page fault, bring another image, wait for pressing and

restore the screen.


       ORG # 8000; Move the stack to

       LD (STACK), SP; address # 7FFF, to

       LD SP, # 7FFF; could return
                          ; Found from Progressive. BANK.

       LD A, 8; Choice 8-th page

       CALL BANK; memory.

       LD HL, # 4000; Installation param.dlya

       LD DE, # DB00; save screen

       LD BC, # 1B00; address # DB00.

       LDIR; Save the screen.

       LD A, 0; Choosing 0-th page

       CALL BANK; memory.

       LD HL, # C000; Installation param.dlya

       LD DE, # 4000; display

       LD BC, # 1B00; image # C000

       LDIR; Displays.


       RES 5, (IY +1); clicking Reset flag
LOOP BIT 5, (IY +1); key is pressed?

       JR Z, LOOP; Repeat if not

                          ; Pressed.

       LD A, 8; Choice 8-th page

       CALL BANK; memory.

       LD HL, # DB00; Installation param.dlya

       LD DE, # 4000; impeccably. Screen

       LD BC, # 1B00; to address # DB00.

       LDIR; Displays.

       LD A, 0; Choosing 0-th page

       CALL BANK; memory.

       LD SP, (STACK); Recover stack.

       RET; Return of the prog
                          ; FRAMEWORK.
STACK DEFW 0; Cell Storage

                          , The stack pointer.
BANK DI; disable the interrupts.

       PUSH BC; Save BC.

       PUSH AF; Save AF.

       AND # 08; Page Number> 7

       RLA; Result

       LD BC, # 1FFD; issue

       OUT (C), A; the port # 1FFD.

       POP AF; Recall AF.

       AND # 07; Adjust

                          , Page number

                          ; Port # 7FFD.

       OR # 10; Install ROM 48.

       LD B, # 7F; issue in

       OUT (C), A; port # 7FFD.

       POP BC; Restore BC.

       EI; Enable interrupt
                          ; Of.

       RET; Return of the prog
                          ; FRAMEWORK BANK.


  Note. Transfer the stack is necessary if he
is above the address # C000, as at room
memory page from # C000, information at
placing the stack will not match the return address.


  As you see, not much memory of the Scorpion
Spectrum harder. So do not forget
support in their programs the possibility of its
use, and thank all our customers will appreciate your work.





Other articles:

From the Editor - We invite you, dear readers, in a world of creativity to the world of the Spectrum.

From the Editor - a description of the shell magazine.

Game room - the passage of the famous game Prince of Persia.

Game room - description of a unique non-deterministic game Soldiers of the Future.

Game room - description of the game about the mafia and the FBI - The Movie.

Notes programmer - Extended opertivnost memory for ZX Spectrum.

Notes programmer - univkrsalnaya library for working with graphics from Vyacheslav Mednonogova - Graphic Library v1.1

Notes programmer - a program of Russification (Russian translation).

Notes programmer - bug monitor debugger ZS Scorpion 256.

Toolkit - We offer to meet with the new operating system Domen OS!

Toolkit - description of a new editor-font FONT EDITOR.

Toolkit - a program to work with the modem on the ZX Spectrum - Macro Modem (MMD).

piece of iron - The company "Peters presents his new development of a home computer, "Sprinter".

piece of iron - the story of creation and development firm Peters. "

piece of iron - The scheme modem for c program Macro Modem.

Contest - a better name for a new home computer for the modern user!

News - for new projects on the Spectrum: The Legend of Kirandii, Dune 2, Modem Chess, Sprtnter, Domain OS, new graphical editor for sprinters.

News - a brief report and results from Enlight'96.

Aquarius - open the last secret of the legendary game ELITE!

Forum - Dear readers - write letters!

Advertising - free advertising and announcements.


Темы: Игры, Программное обеспечение, Пресса, Аппаратное обеспечение, Сеть, Демосцена, Люди, Программирование

Similar articles:
System - Overview of System Software: Sample Compiler v 0.3
Our relish - a few petseptov ppigotovleniya moonshine ve.pnites' starters.
Authors - The authors of the journal and photos.

В этот день...   28 April