Datapack ch2 Onbekend, 00-00-00 << page 5 >> ---------------------------------------------------- CHAPTER 2 System organization ----------------------------------------------------- In this chapter We want to explain the hardware organization of the MSX Turbo R to start of with the new R800 CPU. 2.1 standard equipment (shiy(tm) blz 130) Below we show with the help of a summary the differences between the standards of msx 2+ and the Turbo R chart 1.1 outline ofthe standard equipment of the MSX Turbo R and the MSX 2+ -----------------------\------------------------\--------------------------- ¡ MSX Turbo R ¡ MSX 2+ ---------------------------------------------------------------------------- CPU ¡ R800 of eqv ¡ Z80A or eqv ¡(7.15909 Mhz) ¡ (3.579545 Mhz) -------\-------------------------------------------------------------------- ¡ ROM ¡ 160 KB ¡ 96 KB ¡ ¡(MSX BASIC ver.4) ¡ (MSX BASIC ver.3) ¡ ¡ MAIN ROM 32 KB ¡ MAIN ROM 32 KB ¡ ¡ SUB ROM 16 KB ¡ SUB ROM 16 KB ¡ ¡ KANJI Driver 32 KB ¡ KANJI Driver 32 KB ¡ ¡ MSX DOS1 16 KB ¡ MSX DOS1 16 KB memory ¡ ¡ MSx DOS2 48 KB ¡ (option) ¡ ¡ MSX MUSIC 16 KB ¡ (option) ¡ ------------------------------------------------------ ¡ RAM ¡ At least 256 Kb ¡ At least 64 KB ¡ -------------------------_---------------------------- ¡ VRAM ¡ 128 KB -------_---------------_----------------------------------------------------- <6 CHAPTER 2 SYSTEM ORGINATZATION> ------------------------\------------------------\---------------------------- ¡ MSX TURBO R ¡ MSX 2+ ---------\---------------------------------------_---------------------------- ¡ VDP ¡ V9958 or EQV ¡ ------------------------------------------------------ ¡ resolution ¡ 512x212 (non interlaced) ¡ (max) ¡ 512x424 (interlaced) ¡ ------------------------------------------------------ screen ¡ colors(max) ¡ 19268 colors ¡ ------------------------------------------------------ ¡ hardware ¡ vertically and horzontally ¡ scroll ¡ ---------_--------------------------------------\----------------------------- cassette interface ¡ not available ¡ FSK methode 1200 . 2400baud ---------\--------------------------------------_----------------------------- ¡PSG ¡ AY-3-8910 or eqv ¡ ------------------------------------------------------ ¡ FM sound ¡ MSX-AUDIO (option) sound ¡ source ------------------------\----------------------------- ¡ ¡ MX-MUSIC ¡ (option) ¡ ------------------------------------------------------ ¡ ¡ MSX-MIDI ¡ not available ¡ ¡ (option) ¡ ---------_-------------------------------------------------------------------- Keyboard ¡ English-nummerical, hirigana, katakana, grafic ¡ letter equivalence (????), JIS arrangement, 50?? ------------------------------------------------------------------------------ Floppydrive ¡ 3.5 inch 2dd ¡ (1DD read/write possibilitiy) ------------------------------------------------------ Format ¡ MS-DOS 2.11 standard ------------------------------------------------------------------------------ PRINTER ¡ 8 bit parallel ¡ centronicsinterface standard ------------------------------------------------------------------------------ cartridge slot ¡ ?? ------------------------------------------------------------------------------ Joystick ¡ 2 ---------\-------------------------------------------------------------------- KANIJ ¡ KANJI ROM ¡ 1 Standard function ¡ ¡ 2 Standard ¡ ------------------------------------------------------ ¡ KANJI INPUT ¡ SINGLE KANJI CONVERTOR (MSX JE EQUIVALANCE) ---------_-------------------------------------------------------------------- realtime clock ¡ RP5C01 or eqv ------------------------_----------------------------------------------------- <2.2 HARDWARE ORGINAZATION 7> 2.2 HARDWARE ORGINAZATION The hardware orginazation of the msx turbo r is shown here 2.2.1 MAIN LSI The most important LSI of the Turbo R are shown below here. CPU R800 or eqv (clock 7.15909 Mhz) Z80A or eqv (clock 3.57945 Mhz) VDP V9958 or eqv PSG AY-3-8910 or eqv FM soundsource MSX-MUSIC (YM2413 or eqv) MIDI MSX-MIDI (i8251 or eqv en i8253 or eqv en verder i8254 or eqv) PPI i8255 or eqv systemIC S1990 or eqv 2.2.2 MEMMORY The memory shown below is orginized in the MSX Turbo R. ROM MSX BASIC ver.4 80 KB (MAIN ROM 32 KB) (SUB ROM 16KB) (KANJI DRIVER 32KB) MSX-DOS1 16KB MSX-DOS2 48KB MSX-MUSIC 16KB RAM MAIN RAM 256 KB at least (memmory mapper is being used) VRAM 128 KB 2.2.3 BLOCK DIAGRAM The MSX Turbo-R system-equipment is explained with a block diagram. The MSX Turbo-R has 2 CPU's (Z80 and R800). The type of processor (R800 or Z80) can be freely changed in the use of program. If one of the processors is used the other processor will be put on HOLD. It is not possible to use both the processors at the same time. <8 CHAPTER 2 SYSTEM ORGINAZATION> Å--------ã Å--------ã Å---------ã Å------------ã ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ Z80 -------¢ S1990 -------¢ R800 ------¢ DRAM ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ -------- ----\--- --------- ------------ ¡ Å-------------------------------------------ã ¡ ¡ ¡ Å---_----ã Å----_----ã Å---------------_-----------ã ¡ ¡ ¡ ¡ ¡ ¡ ¡ SLOT ¡ ¡ ROM ¡ ¡ VDP, OPLL, FDC etc ¡ ¡ ¡ ¡ ¡ ¡ ¡ -------- --------- --------------------------- picture 1.1 MSX Turbo R Block scheme The S1990 is a LSI-systemcontroller as a solution for the switching of the CPU. The control of the slots and memory, the generation of wait signals as well as the I/O decoding etc is executed by the S1990. 2.3 SLOT ORGINASATION In the MSX Turbo R the slot orginazation was standarized. Because the Main Ram was directlty connected to the R800 or depending to which slot it is connected, the system performance can change graetly. Furthermore, a purpose is to simplify the develpment of application software. DOS contains both MSX DOS1 en MSX DOS2. In page 1 of slot 3-2 there are 4 local banks, the first 3 pages are for MSX-DOS2 and the last page 1 for MSX DOS1. In the system the combination of the two DOS versions with the 2 CPU can be changed freely but it simplifies the system and to avoid disorginazation of the user, in the standard there are 2 combinatios supported : Z80 and DOS1 (Z80 Mode) R800 and DOS2 (R800 Mode) When starting the system, depending on the inserted cartridge or disk is the selection between these 2 modes automatically done. <2.3 SLOT ORGINAZATION 9> 0-0 0-1 0-2 0-3 FFFFH Å-------ã Å-------ã Å-------ã Å-------ã ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ PAGE 3 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ C000H --------¢ --------¢ --------¢ --------¢ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ PAGE 2 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ 8000H --------¢ --------¢ --------¢ --------¢ ¡ ¡ ¡ ¡ ¡MSX ¡ ¡ ¡ PAGE 1 ¡ MAIN ¡ ¡ ¡ ¡MUSIC ¡ ¡ ¡ 4000H ¡ ¡ --------¢ --------¢ --------¢ ¡ ROM ¡ ¡ ¡ ¡ ¡ ¡ ¡ PAGE 0 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ 0000H ------- ------- ------- ------- 1 2 FFFFH Å-------ã Å-------ã ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ C000H ¡EXT. ¡ ¡EXT. ¡ ¡ ¡ ¡ ¡ ¡SLOT ¡ ¡SLOT ¡ 8000H ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ 4000H ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ 0000H ------- ------- 3-0 3-1 3-2 3-3 FFFFH Å-------ã Å-------ã Å-------ã Å-------ã ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ PAGE 3 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ C000H ¡ ¡ --------¢ --------¢--ã --------¢ ¡ MAIN ¡ ¡KANJI ¡ ¡ ¡-ã¡ ¡ ¡ PAGE 2 ¡ RAM ¡ ¡DRIVER ¡ ¡ ¡ã¡¡ ¡ ¡ 8000H ¡ (*1) ¡ ¡ ¡ --------¢¡¡ --------¢ ¡ ¡ ¡ ¡ ¡ DOS ¡¡ ¡ ¡ PAGE 1 ¡ ¡ ¡ ¡ ¡ ¡(*2)¡ ¡ 4000H ¡ ¡ --------¢ --------¢ --------¢ ¡ ¡ ¡ SUB ¡ ¡ ¡ ¡ ¡ PAGE 0 ¡ ¡ ¡ ROM ¡ ¡ ¡ ¡ ¡ 0000H ------- ------- ------- ------- (*1) With the memmory it contains at least 256 Kb. (*2) Local Bank. The first 3 pages are for MSX DOS2 and the last page is for MSX DOS1. Pricture 1.2 Slot orginasation of the MSX Turbo R <10 CHAPTER 2 SYSTEM ORGINAZATION> 2.4 R800 2.4.1 FEATURES OF THE R800 The R800, develloped CPUused in the Turbo R, has the features shown below. 1. Z80 and object-compatible With the software written for the Z80 note that the parts dependent on the timing of the CPU are removed and not-changed can be used. 2. The CPU clock frequency is 7.15909 Mhz Because compared with the number of clockpulses per instruction in the Z80 sharply lower , the z80 conversion is in fact at the speed on 28.63636Mhz (If there are no waitstates). 3. multiplication commands the multiply command that is supported has an accuracy of 8bit x 8bit -> 16 bit and also 16bit x 16bit -> 32 bit Dependend on this, bigscale progress of mathematical- operation-procedure speed is possible. (??) 4. LSB/MSB defenition instructions With the Z80 / The access of the higher and the lower 8 bit of register IX/IY with the LSB/MSB defenition is properly ensured In figure 1.2 the [verwerkings]speeds of the most important instructions is shown. (When the Turbo R has no waitstates. On the MSX 2+ 1 waitstate occurs on the M1 cycle.??) 2.5 WAIT In the MSX Turbo R normally no waitstates are generated. In the conditions below a waitstate is generated. 1. If an external slot is accessed (3 waitstates) When an external slot is accessed, to support the externale hardware up to now developed, the Turbo R is designed in the same way the MSX2+, it has the same accesstime while accessing. 2. If an internal rom is accessed (2 waitstates) internal ROMS are ROMS like BIOS, BASIC and as well as the internal DISKROM etc. In the first stage in the Turbo R because BIOS, BASIC, SUB ROM and the 16KB of the first part of the KANJI driver (64KB in total) are being copied to the main RAM, In that case approximately in state 3 waitstates are generated(????????????????????????) <2.5 WAIT 11> picture 1.2 execution-comparison of the MSX Turbo R and MSX2+ ----------------------------------------------------------------------------- INSTRUCTION MSX2+(in u.sec) MSX Turbo R(in u.sec) FACTOR ----------------------------------------------------------------------------- LD r,s 1.40 0.14 x 10.0 LD r,(HL) 2.23 0.42 x 5.3 LD r,(IX+n) 5.87 0.70 x 8.4 PUSH qq 3.35 0.56 x 6.0 LDIR (BC<>0) 6.43 0.98 x 6.6 ADD A,r 1.40 0.14 x 10.0 INC r 1.40 0.14 x 10.0 ADD HL,ss 3.35 0.14 x 24.0 INC ss 1.96 0.14 x 14.0 JP 3.07 0.42 x 7.3 JR 3.63 0.42 x 8.7 DJNZ (B<>0) 3.91 0.42 x 9.3 CALL 5.03 0.84 x 6.0 RET 3.07 0.56 x 5.5 MULTU A,r 160 1.96 x 82 MULTUW HL,rr 361 5.03 x 71 ----------------------------------------------------------------------------- 3. When the internal DRAM is being addressed (1 waitstate) the pageaccess-mode is supported what means that the R800 uses its own bus to the DRAM. Therefore it is possible to get the best performance of the DRAM. In differences with the memmory access the lower 8bit of the adress is just changed, in the page-address-mode highspeed access is possible. Except the lower 8 bit that are changed, the rest presents the pagebreak that is produced. Because when using the page-break 2 using the DRAM is done 1 about 1 time practically approximately 0.5 waitstate is generated. With the pagebreak also a DRAM refresh is generated. With the R800, different from the Z80, together with the commands in practice the DRAM refesh are not unsynchonized executed. In the MSX Turdo R the refresh takes every time 31 u.sec The refresh of 1 time takes 280 n.sec. Furthermore with jump instructions (relative jumps and absolute jumps) a pagebreak is absolutly generated. According to this it is better with highspeed access to pay attention to the things below with important programs. 1. Transmission of programs in RAM With a program in a ROM cartridge, highspeed can be used if a important part is moved by highspeed into ram. A program provided from diskette will inevitable put into RAM for using it so that will be no problem. <12 CHAPTER 2 SYSTEM ORGINASATION> 2. Coding where no pagebreak takes place. In the case of using into RAM when highspeed comes to a necessary loop /just the register of the CPU ?? /and when coding with few times accessing of datamemory (this also contains stack) the advantage of the pageacces mode makes the best use of it. Furthermore, a loop is most effective when it is programmed between xx00H and xxFFH. 3. Using the system-timer In the Turbo R the effect of the above mentioned pagebreak and refreshcycle like in the MSX 2+ understand exactly the timing of the instructions by means of the coding steps, is not needed. In accordance with that, even on the MSX Turbo R to make programs like making on the MSX 2+, timing with software loops is not recommended. In the MSx Turbo R becasue the systemclock is increased every 3.91 u.sec, it is recommended to be used for timing. <629 > CHAPTER 4 ------------------------------------------------------------------------------ MSX MIDI <630 > ------------------------------------------------------------------------------ CHAPTER 1 ABOUT MSX MIDI ------------------------------------------------------------------------------ Because MIDI (Musical Instrumental Digital Interface) functions were also added to MSX MUSIC, MIDI can be used via BASIC instructions. There is no BIOS used for MSX MUSIC. Except for Basic, programs that use MSX-MIDI access the I/O ports directly. MSX-MIDI can be built inside as well as it can be an external cartridge. MIDI was for the exclusive use of the MSX TURBO R and machines that might be build hereafter. On a MSX, MSX 2 or MSX 2+ it can't be used. MSX MIDI was constructed in the following way. * MIDI INTERFACE 8251 MIDI data communication IC 8253 and 8254 booreeto generator and timer IC futhermore there are some different IC's for the port access. * MSX-MIDI ROM (16Kb) In case it is internal, the ROM is in the same slot (slot 0-2, page1) as MSX MUSIC. In case it is in an external cartridge, the rom is fitted in the cartridge. When basic commands are used, the internal MSX MUSIC can't be used so the MSX MIDI in the external cartridge will be used that appeared in the booting process. <633> ------------------------------------------------------------------------------ CHAPTER 2 HARDWARE ------------------------------------------------------------------------------ The way of accessing and the way of construction of the hardware depends on the fact if there is an internal or an external MSX MIDI. Below the hardware construction of MSX MIDI is explained. Further, the timer IC 8253 and 8254 are being used but below only the 8253 is shown. 2.1 BLOCK DIAGRAM The hardware construction of MSX-MIDI. 8251 Å--------ã Å-----ã MIDI IN ¡ RTS ¡------------------------>¡ ¡ ------->¡ RXRDY ¡------------------------>¡ AND ¡ --ã ¡ DSR ¡<------------------ã ¡ ¡ ¡ ¡ DTR ¡-----------------ã ¡ ----- ¡ MIDI OUT¡ ¡<--ã ¡ ¡ ¡ Å-----ã <--------¡ ¡ ¡ ¡ ---------ã ->¡ ¡ -------- ¡ 500 KHz ¡ ¡ ¡ OR ¡ ------> INT ¡ ¡ Å-----ã ¡ Å----->¡ ¡ Å--------ã ¡ ->¡ ¡ ¡ ¡ ----- 4Mhz \-->¡ TIMER0 ¡--- ¡AND ¡--_- ¡ ---------¢ Å-----ã Å->¡ ¡ ¡ ¡ TIMER1 ¡---\---->¡S ¡ ¡ ----- ¡ ---------¢ ¡ ¡ FF ¡- -->¡ TIMER2 ¡--> Å->¡R ¡ -------- ¡ ----- ¡ 0EAH Write DIAGRAM 4.1 BLOCK SCHEME OF THE MSX MIDI <634 CHAPTER 2 HARDWARE > 2.2 BUILT-IN MIDI INTERFACE The following I/O ports of the built in MSX-MIDI interface are accessable. 8251 interface ; portnumber 0E8H, 0E9H 0E8H (READ) b7 b6 b5 b4 b3 b2 b1 b0 Å----\----\----\----\----\----\----\----ã ¡RXD7¡RXD6¡RXD5¡RXD4¡RXD3¡RXD2¡RXD1¡RXD0¡ ----_----_----_----_----_----_----_---- Å----\----\----\----\----\----\----\----ã (WRITE) ¡TXD7¡TXD6¡TXD5¡TXD4¡TXD3¡TXD2¡TXD1¡TXD0¡ ----_----_----_----_----_----_----_---- RXD7-RXD0 = 8251 received data TXD7-TXD0 = 8251 data to send 0E9H (READ) b7 b6 b5 b4 b3 b2 b1 b0 Å----\----\----\----\----\----\----\----ã ¡DSR ¡BRK ¡ FE ¡ OE ¡ PE ¡EMPT¡RDDY¡TRDY¡ ----_----_----_----_----_----_----_---- DSR 8253 data set ready (1= ?? detected) BRK 8251 break detection (1=detected) FE 8251 frame error flag (1=error detected) OE 8251 overrun error flag (1=error detected) PE 8251 parity error flag (1=parity error detected) EMPT 8251 transmitter buffer empty status (1=buffer is empty) RRDY 8251 receiver buffer status (1= data is present) TRDY 8251 transmitter status (1=transmission possible) (WRITE) 0E9H (Write) b7 b6 b5 b4 b3 b2 b1 b0 Å----\----\----\----\----\----\----\----ã mode ¡ S2 ¡ S1 ¡ EP ¡ PEN¡ L2 ¡ L1 ¡ B2 ¡ B1 ¡ ----_----_----_----_----_----_----_---- Å----\----\----\----\----\----\----\----ã command ¡ EH ¡ IR ¡RIE ¡ ER ¡SBRK¡ RE ¡TIE ¡TEN ¡ ----_----_----_----_----_----_----_---- EH normally set to 0 IR normally set to 0 RIE MIDI IN transmission enablen (1=enable; 0=disable) ER error reset (1=reset error flags; 0=no operation) <2.2 INTERNAL MIDI INERFACE 635> SBRK normally set to 0 PE MIDI IN receive enable (1=enable; 0=disable) TIE 8253 timer (counter #2) (1=enable; 0=disable) transmission enable TEN MIDI OUT transmission enable (1=enable; 0=disable) When writing to the command mode register of the 8251 it is nessesary to wait 16 clock cycles (3.579545 Mhz) for the result. When writing a sequence of commands to to command register please wait before writing the data. After writing 00H, 00H, 00H, 40H to the I/O port 0E9H the 8251 is resetted. Because when a wrong value to the mode was written the MIDI can't function properly, it is necessary to write the correct values after a reset. For details please see the accompanied programsample ([THRU.MAC]). 8253 OUT2 Latch of the signals of the terminal (adress 0EAH,0EBH) 0EAH (WRITE) b7 b6 b5 b4 b3 b2 b1 b0 Å----\----\----\----\----\----\----\----ã ¡ - ¡ - ¡ - ¡ - ¡ - ¡ - ¡ - ¡ - ¡ ----_----_----_----_----_----_----_---- 0EAH Reading the data from this adres is ineffective 0EBH Is the image of 0EAH dependent on the optional data written to adress 0EAH, the data read from counter #2 of the 8253 can be cancelled. 8253 INTERFACE (adres 0ECH-0EFH) b7 b6 b5 b4 b3 b2 b1 b0 Å----\----\----\----\----\----\----\----ã 0ECH (R/W) ¡CT7 ¡CT6 ¡CT5 ¡CT4 ¡CT3 ¡CT2 ¡CT1 ¡CT0 ¡ ----_----_----_----_----_----_----_---- Å----\----\----\----\----\----\----\----ã 0EDH (R/W) ¡CT17¡CT16¡CT15¡CT14¡CT13¡CT12¡CT11¡CT10¡ ----_----_----_----_----_----_----_---- Å----\----\----\----\----\----\----\----ã 0EEH (R/W) ¡C727¡CT26¡CT25¡CT24¡CT23¡CT22¡CT21¡CT20¡ ----_----_----_----_----_----_----_---- Å----\----\----\----\----\----\----\----ã 0EFH (READ) ¡ - ¡ - ¡ - ¡ - ¡ - ¡ - ¡ - ¡ - ¡ ----_----_----_----_----_----_----_---- Å----\----\----\----\----\----\----\----ã (WRITE)¡SC1 ¡SC0 ¡RW1 ¡RW0 ¡M2 ¡M1 ¡M0 ¡BCD ¡ ----_----_----_----_----_----_----_---- <636 CHAPTER 2 HARDWARE > CT7-CT0 counter 0 CT17-CT10 counter 1 CT27-CT20 counter 2 SC1, SC0 select counter, select counter RW1,RW0 counter read/write mode M2,M1,M0 counter mode BCD binairy counting/ BCD counting select every counter has the following features: - counter #0 The ?? generator of the 8251 is used. A clock unit gives a clockpulse of 4 Mhz. In contrast to the 8251 the ?? generator must give a clock pulse of 500 Khz (division by 8). Mode 3 is used ( 2^N = division -> 2^3 = 8) - counter #1 Can be used as a timer for any kind of use. By the clock unit the output of timer #2 is going to timer #1. (?????) - counter #2 Is used for writing ?? cycle to the CPU Normally mode 2 is used (N is the divsion factor). When OUT2 gets low, the latch data is transmitted and the ?? to the CPU is developped. The CLK unit gives a clockpulse of 4 MHz. 2.3 EXTERNAL MIDI INTERFACE The external MSX MIDI interface uses I/O port that is can be found in port 0E2H, the I/O port can be changed. * MIDI interface selections (adres 0E2H, 0EAH) 0E2H (WRITE) B7 B6 B5 B4 B3 B2 B1 B0 Å----\----\----\----\----\----\----\----ã ¡ EN ¡ - ¡ - ¡ - ¡ - ¡ - ¡ - ¡ E8 ¡ ----_----_----_----_----_----_----_---- EN MIDI interface enable (0=enable, 1=disable) With the initialization set to 1 E8 MIDI interface adres select (0=0E8H/0E9H) (1=0E0H/0E1H) If bit E8 is set to 0, I/O port of the external MIDI interface is changed from 0E2H to 0EAH, the internal MIDI interface is compatible with this. Further, the 8251 I/O adres becomes 0E8H and 0E9H. <2.3 EXTERNAL MIDI INTERFACE 637> If bit E8 is set to 1, the I/O port of the 8251 interface is 0E0H and 0E1H , the access of 0ECH to 0EFH as I/O of the cartridge is invalid. Further, the 8253 timer is also invalid. * 8251 INTERFACE (adres 0E0H and 0E1H) 0E0H b7 b6 b5 b4 b3 b2 b1 b0 Å----\----\----\----\----\----\----\----ã (read) ¡RXD7¡RXD6¡RXD5¡RXD4¡RXD3¡RXD2¡RXD1¡RXD0¡ ----_----_----_----_----_----_----_---- Å----\----\----\----\----\----\----\----ã (write) ¡TXD7¡TXD6¡TXD5¡TXD4¡TXD3¡TXD2¡TXD1¡TXD0¡ ----_----_----_----_----_----_----_---- RXD7-RXD0 = 8251 received data TXD7-TXD0 = 8251 data to send 0E1H b7 b6 b5 b4 b3 b2 b1 b0 Å----\----\----\----\----\----\----\----ã (read) ¡DSR ¡BRK ¡ FE ¡ OE ¡ PE ¡EMPT¡RDDY¡TRDY¡ ----_----_----_----_----_----_----_---- DSR 8253 data set ready (1= ?? detected) BRK 8251 break detection (1=detected) FE 8251 frame error flag (1=error detected) OE 8251 overrun error flag (1=error detected) PE 8251 parity error flag (1=parity error detected) EMPT 8251 transmitter buffer empty status (1=buffer is empty) RRDY 8251 receiver buffer status (1= data is present) TRDY 8251 transmitter status (1=transmission possible) (WRITE) 0E9H (Write) b7 b6 b5 b4 b3 b2 b1 b0 Å----\----\----\----\----\----\----\----ã mode ¡ S2 ¡ S1 ¡ EP ¡ PEN¡ L2 ¡ L1 ¡ B2 ¡ B1 ¡ ----_----_----_----_----_----_----_---- Å----\----\----\----\----\----\----\----ã command ¡ EH ¡ IR ¡RIE ¡ ER ¡SBRK¡ RE ¡TIE ¡TEN ¡ ----_----_----_----_----_----_----_---- <638 CHAPTER 2 HARDWARE > EH normally set to 0 IR normally set to 0 RIE MIDI IN transmission enablen (1=enable; 0=disable) ER error reset (1=reset error flags; 0=no operation) SBRK normally set to 0 PE MIDI IN receive enable (1=enable; 0=disable) TIE 8253 timer (counter #2) (1=enable; 0=disable) transmission enable TEN MIDI OUT transmission enable (1=enable; 0=disable) 2.4 CHECK MIDI In case of bit 0 of adres 002EH of the MAIN ROM being 1 MSX MIDI is built in. The versionnumber ([002DH) is 3 or more the built-in MSX MIDI can be used. The internal type and the external type have another hook. The difference is because of the application. In chapter 4- 3.2 the hooks are shown. The difference between an internal type and an external type can be seen at the adres 4018 beginning data. chart 4.1 data differences of the MSX MIDI ------------------------------------------------------------------ ADRES INTERNAL EXTERNAL ------------------------------------------------------------------ 4018H 41H(A) ??H(?) 4019H 50H(P) ??H(?) 401AH 52H(R) ??H(?) 401BH 4CH(L) ??H(?) 401CH 4FH(O) 4DH(M) 401DH 50H(P) 49H(I) 401EH 4CH(L) 44H(D) 401FH 4CH(L) 49H(I) ------------------------------------------------------------------ In the external cartridge starting at adres 4018H 4 bytes makercode that can change is located. From adres 401CH the data [MIDI] is located. < way of distinction of presence of the MIDI interface 639> 2.5 way of distinction of presence of the MIDI interface The presence of the MIDI interface can be detected by the following ways. 1. In case bit 0 of adres 002EH of the MAIN ROM equals 1 the MIDI interface is present. 2. In case the versionnumber of the MAIN ROM (002DH) is 3 or higher and in a slot the following can be found. DB "MIDI" When that is so, the external cartridge is installed. 3. If the above is not so, because the MIDI interface is not present, the MIDI functions can't be used. 4. In case the version nummer (002DH) equals 2 or lower, a MIDI interface can't be used. <650 > ----------------------------------------------------------------------------- CHAPTER 3 HOOKS ------------------------------------------------------------------------------ The hook for MSX MUSIC is used 1/60 second (NTSC) or 1/50 second (PAL) but MIDI from MSX BASIC the 8253 uses the hook every 5 milisecond. 3.2 HOOKS In the MSX Turbo R the following hooks are present related with the internal MIDI interface. diagram 4.2 Hooks of the internal MSX-MIDI ---------------------------------------------------------------------------- adres name old name contents ---------------------------------------------------------------------------- 0FF75H H.MDIN H.OKNORM MIDI IN hook 0FF93H H.MDTM H.FRQINT 8253 timer hook ---------------------------------------------------------------------------- In case of using an external cartridge, the hooks above can't be used therefore we advise you to use the hook H.KEYI. For the details of the usage please see chapter 4 [development of applications] diagram 4.3 Hook of the external MSX-MIDI ---------------------------------------------------------------------------- adres name ---------------------------------------------------------------------------- 0FD9AH H.KEYI ---------------------------------------------------------------------------- <643 > ---------------------------------------------------------------------------- CHAPTER 4 development of applications ---------------------------------------------------------------------------- 4.1 advice details for development of applications. If you will make MSX MIDI compatible programs please take care of the following things. 1. The hook of the internal MIDI interface is different than the external MIDI interface. When using interrupt hooks, verify if the type, if it is internal or external. 2. After the initialization of the MIDI interface the interrupt hooks are allowed, because of the mobility of the interrupt flags that can set, interrupt flags must be resetted. The interrupt flags that are available are below diagram 4.4 interrupt flags of the MIDI interface ------------------------------------------------------------------------- kind of hook hook direction way of handling ------------------------------------------------------------------------- timer bit 7 (DSR) of 0E9H or 0E1H write the option to 0EAH MIDI IN bit 1 (RRDY)of 0E9H or 0E1H read with an IN-instruction 0E8H ------------------------------------------------------------------------- 3. With an external MIDI interface external hooks MIDI IN and 8253 timer come also to H.KEYI. The hooks must be written from this adres. To detect if there is MIDI IN interrupt or not you have to verify bit 1 of I/O port 0E9H. To verify if there is an interrupt from the 8253 timer you will have to verify bit 7 of I/O port 0E9H. <644 CHAPTER 4 DEVELOPMENT OF APPLICATIONS> 4. The generation of MIDI IN interrupt signals is done every 320 u.sec. when a RST 30H instruction is used when a hook is read by a routine, it takes time to make an interslot call ,therefore there is not enough time for the interrupt signals handling. Therefore we advise to create the following handling routine * place the procudure routine in page 3 * Jump with a JP instruction to the handling routine 4.2 Sample program For more details about the MIDI interface and the flags please see the sample program (THRU.MAC). <645 > ------------------------------------------------------------------------------ CHAPTER 5 BASIC EXPANSIONS ------------------------------------------------------------------------------ 5.1 OUTLINE OF THE BASIC EXPANSIONS. The names of the commands for using MSX MIDI have been simplified and have been included in basic commands. The MSX-MIDI basic commands have been supported in the expansion of commands like CALL MUSIC. CALL an be substituted by '_' (underscore). With the MIDI interface external MIDI deveices can be used. Therefore, commands have been modificated and supplemented. Further, because both MML and MIDI must be corresponding, commands have been changed. 5.2 Explanation of the BASIC expansions CALL MUSIC ------------------------------------------------------------------------ Å-----------ã ¡Funktion ¡ Initialize MSX MIDI System ----------- Å-----------ã ¡ Form ¡ CALL MUSIC[([<MODE>],[,[0][,<single channel used for PLAY 1> ----------- [,<single channel used for PLAY2>[,...[,<single channel used for PLAY 9>]]]]]]]]]])] Å-----------ã ¡Explanation¡ When the built in sound chip LSI is designated how much ----------- FM channels per voice, the MIDI interface is also designated. After the initialisation after the CALL MUSIC, it is not possible to use other expansion BASIC statements. * <MODE> <646 CHAPTER 5 BASIC EXPANSION> ------------------------------------------------------------------------- designation meaning ------------------------------------------------------------------------- 0 No use of rythme 1 Use of rythme ------------------------------------------------------------------------- * channel in each mode the channels to be used are shown below. ------------------------------------------------------------------------- mode rythme maximum per channel ------------------------------------------------------------------------- 0 no 9 1 yes 6 fm channels + 1 rythme 8 MIDI channels + 1 rythme ------------------------------------------------------------------------- With mode 1 when using midi the number of voices used per channel can be increased up to 8. For the play command the number of OPLL channels used by built-in FM soundprocessor have to be designated. To use 0 voices is not possible. With the OPLL only channels 9 voices can be used. With mode 1 3 channels are used for rythme. In mode 0 9 channels can be used as maximum. In Mode 1 6 channels can be used as maximum. In case of using MIDI, a play line is assigned to 1 MIDI channel. A value of 2 or more is designated the meaning doesn't change. With the channels of the FM processor the number of channels can be changed. Because with MIDI 1 play line is assigned to 1 MIDI channel, in this occasion it can be designated as 1, 2, 3, .... . To change this is possible using the MML command @Hn. In case this parameter was set to 1 or more, the other value of this parameter can be 0. It is not possible to leave 0 out int the CALL MUSIC command. Please look at the following commands. CALL MUSIC (0,0,0,5,0) ¡ ¡ It is not possible to designate 0.(Illegal function call will be generated.) CALL MUSIC (0,0,1,,2) ¡ It is not possible to leave the parameter out.(Syntax error will be generated.) <5.3 explanations of the BASIC expansions 647> CALL MUSIC (1,0,1,1,1,1,1,1,0,0) ¡ ¡ In mode 1 channel 7 and 8 must be designated. In case of PLAY #1 Channel 1-8 are assigned for MIDI Channel 9 is assigned for MIDI rythme Channel 10 - 12 are assigned for the PSG In case of PLAY #2 Channel 1-6 are assigned for the FM soundprocessor Channel 7 and 8 can't be used Channel 9 is assigned for rythme sounds Channel 10-12 are assigned for the PSG. When it is used without parameters it is the same as CALL MUSIC (1,0,1,1,1). If CALL MUSIC is used because the systemhook is linked to the MSX MIDI software, the access of the handling routine is increased and the suruuputo(??) of the system decreases. Because of the workarea space of a CLEAR must be given, HIMEN ( 2 byte parameter of the CLEAR instruction) will be 807 bytes lower. Å-------ã ¡example¡ CALL MUSIC ------- Default setting. CALL MUSIC (0,0,1,1,1,1,1,1,1,1,10 One channel per PLAY line is assigned. CALL MDR ----------------------------------------------------------------------------- Å-----------ã ¡Funktion ¡ Designation of the MIDI note numbers for the rytme sounds in MML ----------- Å-----------ã ¡ Form ¡ CALL MDR (<MIDI note number of B>,<MIDI note number of S>,<MIDI ----------- note number of M>,<MIDI note number of C>,<MIDI note number of H>) Å-----------ã ¡Explanation¡ The in MML used rythme B,S,M,C,H commands can be designated to ----------- MIDI note numbers. <648 CHAPTER 5 BASIC EXPANSION> Because there are a lot of MIDI sounds, with 1 channel the rythme sounds can be assigned to the deveice (exclusive use of 1 track). In the PLAY line one channel can be assigned. In the same time multipal sounds of rythme in the exclusive rythme track is not allowed. This to the rythme assigned track is different per MIDI deveice. For the handling of the MIDI deveice please see for details in it's manual. The parameter must be between 0 and 127. It may not be left out. Initial value is 0. Å--------ã ¡example ¡ CALL MDR(35,38,45,49,42) -------- PLAY ------------------------------------------------------------------------------ Å-----------ã ¡Funktion ¡ Plays the in MML complied music. ----------- Å-----------ã ¡ Form ¡ PLAY [#<MODE>,]<line 1>[,>line 2>],<line 3> .. [,<line 12>] ----------- Å-----------ã ¡Explanation¡ With the play command the music is performed. Up to 12 tones can ----------- be produced, 9 from the built-in soundprocessor + 3 PSG and furthermore 9 from the MIDI deveice + 3 PSG. The in <line n> written MML data is performed. A call or other instruction is not needed. <mode> must be a value between 0 and 3. The play command and the mode give the following possibility. * When 0 or no data is given it is equal a the normal play commando in basic. Up to 3 PSG channels can be used. * When it is 1, the MIDI deveice and the PSG can be used. The relations between the playlines is the following : <MIDI deveice play line 1>, ... <MIDI deveice play line n>, <MIDI deveice rythme line>, <PSG play line 1>,<PSG play line 2>,<PSG play line 3> * When it is 2 or 3, the FM soundprocessor and PSG can be used. (the use of 2 or 3 is exactly the same.) The relations between the play lines is the following. <FM play line 1>,...<fm play line n> <FM rythme line>, <PSG play line 1>,<PSG play line 2>,<PSG play line 3> n is the number of MML playlines designated with CALL MUSIC. In case a mode is designated with no use of rythme wtih the CALL MUSIC the rythme play line as well as the komma (,) must be left out. Å--------ã ¡example ¡ PLAY #1,"CD","EF","GA" -------- USAGE OF MML FOR MIDI DEVEICES Here we explain the supplied and changed MML for the usage of MIDI deveices. figure 4.5 supplemented MML for the use of MIDI deveices. ------------------------------------------------------------------------ Character Meaning Value ------------------------------------------------------------------------ @Hn Designates the used MIDI channel number. 1 ó n ó 16 @Cm,n Send a control change. m = control change, n = value of the 1 ó m ó 127 control number to be changed. 1 ó n ó 127 @Sn Instruction related to the MIDI realtime clock n=0 Sends FCH(STOP) out, stop the clock n=1 Sends FAH(START) out, starts the clock n=2 Sends FBH(CONTINUE) out, continues the clock The tempo of the clock will be the same as defined in playline 1. ------------------------------------------------------------------------ figure 4.6 changed MML for the use of MIDI deveices. ------------------------------------------------------------------------ Character Meaning Value ------------------------------------------------------------------------ Ln Designates the length 1 ó n ó 96 Rn Designates the rest length 1 ó n ó 96 @Wn Continue the length with n 1 ó n ó 96 Vn This differss with the MIDI deveices, 1 ó n ó 15 8 times the values of the velocity is send out. @Vn Volume (Control change #7) is send out. 1 ó n ó 127 @n With the built in FM soundprocessor the color of the sound is changed but 1 ó n ó 63 with MIDI deveices it is different , a program change is send out. 1 ó n ó 127 Zn 1 byte MIDI data is send out. 1 ó n ó 255 ------------------------------------------------------------------------ <650 CHAPTER 5 BASIC EXPANSION > USAGE of rythme MML data Below here the supplied and changed MML for MIDI deveices are shown. figure 4.7 supplied MML for rythme data ------------------------------------------------------------------------ Character Meaning ------------------------------------------------------------------------ @n Different with MIDI deveices is that a program change is send out. For the built-in FM soundprocessor this is ignored. ------------------------------------------------------------------------- figure 4.8 changed MML for rythme data ------------------------------------------------------------------------ Character Meaning ------------------------------------------------------------------------ @An This is different for MIDI deveices, it is the same as Vn, the velocity is designated. ------------------------------------------------------------------------ <5.2 explanation of BASIC expansions 651> figure 4.9 ??????? ------------------------------------------------------------------------ Character MIDI FM PSG ------------------------------------------------------------------------ Mn - - O Sn - - O Vn O [0~15] O O Ln O O O Qn O O - On O O O < O O O > O O O Tn O O O Nn *1 O O O Rn O O O A~G O O O + O O O - O O O # O O O . O O O =x; O O O Xx; O O O & O O O {}n O O x @n O [0~127] O[0~63] - @Vn O [0~127] O[0~127] - @Wn O O the same as Rn * @Hn O [1~16] - - * @Cm, n O [0~127] - - Yr,d - O - Zn O [0~255] - (x) - * @Sn O [0~2] - - ------------------------------------------------------------------------ *1 The value of n is not the MIDI note number. It is the musical scale according that is existing.(???) * Changed commands for MSX MIDI x Creates an error - Can't be used [] Range of the parameter () The equivalence of the old MSX MUSIC <652 CHAPTER 5 BASIC EXPANSIONS> figure 4.10 Rythme sounds MML ------------------------------------------------------------------------- Command MIDI FM ------------------------------------------------------------------------- B *1 O O S *1 O O M *1 O O C *1 O O H *1 O O n O O ! O O Vn O O @An O O @Vn O [0~127] O Tn O O Rn O O =x; O O Xx; O O Yr,d - O * @Hn O [1~16] - * @Cm,n O [0~127] - * @n O [0~127] - (x) Zd O - (x) ------------------------------------------------------------------------ 1 In case of using MIDI deveices, the note number must be changed with CALL MDR. * Changed command in MSX MIDI x Generates an error - Can't be used [] Range of the parameter () The equivalence of the old MSX MUSIC 5.3 STATEMENTS THAT DON'T EFFECT MIDI DEVEICES The following statements have no meaning for the MIDI deveices. CALL AUDREG CALL PITCH CALL TEMPER CALL TRANSPOSE CALL VOICE CALL VOICE can't be used in combination with MIDI deveices, please use the MML command @n. <5.4 MIDI DATA FORMAT > 5.4 MIDI DATA FORMAT Below here the MIDI data format from the MSX MIDI BASIC expansion is shown. 5.4.1 transmission data 1. note data * note on status 1001nnnn (9nH) n = 0 ~ 15 MIDI channel number note number 0kkkkkkk k = 24 (C0) &¬ 119 (B7) velocity 0vvvvvvv v = 8 * i : i= 0 ~ 15 The velocity value, 8 times the value designated in @An, is send out. * note off status 1001nnnn (9nH) n = 0 ~ 15 MIDI channel number note number 0kkkkkkk k = 24 (C0) &¬ 119 (B7) velocity 00000000 (v=0) velocity off when if the rythme is used at the same time, both the music and rythme is stopped, the running-status is send out. 2. control changes * @Vv (volume) status 1011nnnn (BnH) n = 0 ~ 15 MIDI channel number control number 00000111 c = 7 control value 0vvvvvvv v = 0 ~ 127 * @Cc, v (control change) status 1011nnnn (BnH) n = 0 ~ 15 MIDI channel number control number 0ccccccc c = 0 ~ 127 control value 0vvvvvvv v = 0 ~ 127 3. program changes * @p (program changes) status 1100nnnn (CnH) n = 0 ~ 15 MIDI channel number program number 0ppppppp p = 0 ~ 127 4. system-realtime-message * timingclock status 11111000(F8H) The timingclock can be started with @S1 and @S2, used in a play line. When a playline has ended, the clock is stopped then STOP (FCH) has not to be used. * @S1 start status 11111010 (FAH) The starting of the clock is send out. * @S2 continue status 11111011 (FBH) The starting of the clock is send out. * @S0 stop status 11111100 (FCH) The stopping of the clock is send out. 5.4.2 Receiving data With the BASIC expansion receiving data is not posible. <5.4 MIDI DATA FORMAT 655> figure 4.11 MSX MIDI BASIC EXPANSION MML MIDI IMPLIMENTATION CHART Å-------------------------------\---------------\----------------------ã ¡ Function ¡ send signal ¡ Remarks ¡ -----------------------------------------------------------------------¢ ¡ BASIC channels on ¡ 1 - 9 ¡ ¡ ¡ CHANNELS available ¡ 1 - 16 ¡ @Hn ¡ -----------------------------------------------------------------------¢ ¡ channels on ¡ 3 ¡ ¡ ¡ MODE message ¡ x ¡ ¡ ¡ substitution ¡ ********* ¡ ¡ -----------------------------------------------------------------------¢ ¡ NOTE NUMBER ¡ O 24 - 119 ¡ 01C - 08B ¡ ¡ voice range ¡ ********* ¡ ¡ -----------------------------------------------------------------------¢ ¡ velocity note on ¡ O 9nH, v=8xn ¡ Vn, @An(n=0-15) ¡ ¡ ¡ ¡ @An is rythme only ¡ ¡ note off ¡ x 9nH, v=0 ¡ ¡ -----------------------------------------------------------------------¢ ¡ Aftertouch key ¡ x ¡ ¡ ¡ channel ¡ x ¡ ¡ -----------------------------------------------------------------------¢ ¡ Pitch handle ¡ x ¡ ¡ -----------------------------------------------------------------------¢ ¡ ¡ O (7) ¡ @Vn ¡ ¡ ¡ O (0-127) ¡ @Cm, n ¡ ¡ Control change ¡ ¡ ¡ -----------------------------------------------------------------------¢ ¡ program change ¡ O ¡ @n ¡ ¡ other posibility ¡ ********* ¡ ¡ -----------------------------------------------------------------------¢ ¡ access kuruushibu(??) ¡ x ¡ ¡ -----------------------------------------------------------------------¢ ¡ song portion ¡ x ¡ ¡ ¡ common song select ¡ x ¡ ¡ ¡ chain ¡ x ¡ ¡ -----------------------------------------------------------------------¢ ¡ Real time clock ¡ O ¡ ¡ ¡ command ¡ O ¡ @Sn ¡ -----------------------------------------------------------------------¢ ¡ local on/off ¡ x ¡ ¡ ¡ all note off ¡ O ¡ [CTRL] + [STOP] ¡ ¡ rest active sensing ¡ x ¡ ¡ ¡ reset ¡ x ¡ ¡ ------------------------------------------------_----------------------¢ ¡ remarks ¡ Zn : send 1 byte MIDI data ¡ ¡ ¡ ¡ -------------------------------_-------------------------------------- O = Available x = Not available MODE 1 : OMNI ON,POLY MODE 2 : OMNI ON,MONO MODE 3 : MONI OFF,POLY MODE 4 : OMNI OFF,MONO ************** means that the output data has no meaning. <656 > <657 > APPENDIX ------------------------------------------------------------------------ <658 > <659 > ------------------------------------------------------------------------ A R800 INSTRUCTION CHARTS ------------------------------------------------------------------------ In these charts instructions of the R800, grouped in kind of instructions are collected. Of the mnemonics in these charts the name of the instruction, usage of this instruction are smplified showed. In the column of the usage of an instruction when there is an <- symbol The details of the left side are shown on the rightside The KAKKO (??) means the details of the memory by the shown belonging register. (???) For example if there is : r <- [.hl] the details of the memory of the shown HL register is is going to 8 bit (???) The in/out-put instructions [n] and [.c] are the equivalence of the in/out-put ports. In the flag column the flags used are shown. OPcode column the machinecode of every different instruction is written down in HEX and BIN format. The B stands for the length of the code in bytes, the C stands for the length of the code in clock cycles.The shown mnemonics that have changed for the R800 can't be guaranteed to work properly on the Z80 because they are not the same as the z80 instructions. (??) <660 APPENDIX A R800 INSTRUCTION CHART> remarks Å-------\---------------------------------------------------------------ã ¡.a{7} ¡The highest bit of register .a ¡ ¡.{4..7}¡Bit 4-7 of register .a ¡ ¡; ¡Punctuation of the usage ¡ ¡.de:.hl¡.de is the upper 16bit and .hl is the lower 16 bit and 32 bit ¡ ¡ ¡ ¡ ¡ formed. ¡ ¡[.ix+d]¡adres is formed when the 8bit of d is added to .ix ¡ ¡C ¡carry flag ¡ ¡Z ¡zero flag ¡ ¡P/v ¡parity overflow ¡ ¡S ¡sign flag ¡ ¡N ¡substraction flag ¡ ¡H ¡half clear flag ¡ ¡ ¡flag don't change ¡ ¡- ¡flag changed in commando used ¡ ¡0 ¡flag is set to 0 ¡ ¡1 ¡flag is set to 1 ¡ ¡? ¡becomes uncertain ¡ ¡V ¡uses the overflow flag ¡ ¡P ¡uses the parity flag ¡ ¡i(iff) ¡value of the interrupt flipflop is attained ¡ ¡r,r' ¡8 bit register, .a,.b,.c,.d,.e,.h,.l ¡ ¡u,u' ¡8 bit register, .a,.b,.c,.d,.e,.ixh,.ixl ¡ ¡v,v' ¡8 bit register, .a,.b,.c,.d,.e,.iyh,.iyl ¡ ¡p ¡8 bit register, .ixh,.ixl ¡ ¡q ¡8 bit register, .iyh,.iyl ¡ ¡ss ¡16 bit register,.bc,.de,.hl,.sp ¡ ¡pp ¡16 bit register,.bc,.de,.ix,.sp ¡ ¡rr ¡16 bit register,.bc,.de,.iy,.sp ¡ ¡qq ¡16 bit register,.bc,.de,.hl,.af ¡ ¡e ¡8 bit value of short branch (+127~128) ¡ ¡k ¡adres of the brk comando, 00h,08h,10h,18h,20h,28h,30h,38h ¡ ¡nn ¡direct value of 16 bit, positive adres ¡ ¡n ¡direct value of 8 bit ¡ ¡b ¡value shown number of bits for the bits of the mathematical ¡ ¡ ¡ operation?? ¡ ¡NOT ¡bit rotation (??) ¡ ¡\/ ¡taking the OR of the bits ¡ ¡\-/ ¡taking the XOR of the bits ¡ ¡/\ ¡taking the AND of the bits ¡ ¡tmp ¡temporary value (??) ¡ ¡B ¡number of bytes of the instruction ¡ ¡C ¡number of clock cycles of the instruction ¡ -------_--------------------------------------------------------------- ??? <A1 8 bit transfer instructions 661> A.1 8 BIT TRANSFER INSTRUCTIONS Å------------\----------------------------\-------------\------------\-\-ã ¡MNEMONIC ¡ INSTRUCTION ACTION ¡ FLAGS ¡ OPCODE ¡ ¡ ¡ ¡ ¡ ¡ ---------\---¢ ¡ ¡ ¡ ¡ ¡S Z H P/v N C¡76543210¡HEX¡B¡C¡ -------------------------------------------------------------------------¢ ¡ld r,r' ¡ r <- r' ¡ ¡01 r r'¡ ¡1¡1¡ -------------------------------------------------------------------------¢ ¡ld r,n ¡ r <- n ¡ ¡00 r 110¡ ¡2¡2¡ ¡ ¡ ¡ ¡<- n ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡ld r,[.hl] ¡ r <- [.hl] ¡ ¡01 r 110¡ ¡1¡2¡ -------------------------------------------------------------------------¢ ¡ld r,[.ix+d]¡ r <- [.ix+d] ¡ ¡11011101¡DD ¡3¡5¡ ¡ ¡ ¡ ¡01 r 110¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡<- d ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡ld r,[.iy+d]¡ r <- [.iy+d] ¡ ¡11111101¡FD ¡3¡5¡ ¡ ¡ ¡ ¡01 r 110¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡<- d ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡ld [.hl],r ¡[.hl] <- r ¡ ¡10110 r ¡ ¡1¡2¡ -------------------------------------------------------------------------¢ ¡ld [.ix+d],r¡ [.ix+d] <- r ¡ ¡11011101¡DD ¡3¡5¡ ¡ ¡ ¡ ¡01110 r ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡<- d ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡ld [.iy+d],r¡ [.iy+d] <- r ¡ ¡11111101¡FD ¡3¡5¡ ¡ ¡ ¡ ¡01110 r ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡<- d ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡ld u,u' ¡ u <- u' ¡ ¡11011101¡DD ¡2¡2¡ ¡ ¡ ¡ ¡01 u u'¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡ld v,v' ¡ v <- v' ¡ ¡11111101¡FD ¡2¡2¡ ¡ ¡ ¡ ¡01 v v'¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡ld u,n ¡ u <- n ¡ ¡11011101¡DD ¡3¡3¡ ¡ ¡ ¡ ¡00 u 110¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡<- n ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡ld v,n ¡ v <- n ¡ ¡11111101¡FD ¡3¡3¡ ¡ ¡ ¡ ¡00 v 110¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡<- n ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡ld [.hl],n ¡ [.hl] <- n ¡ ¡00110110¡36 ¡2¡3¡ ¡ ¡ ¡ ¡<- n ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡ld [.ix+d],n¡ [.ix+d] <- n ¡ ¡11011101¡DD ¡4¡5¡ ¡ ¡ ¡ ¡00110110¡36 ¡ ¡ ¡ ¡ ¡ ¡ ¡<- d ->¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡<- n ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡ld [.iy+d],n¡ [.iy+d] <- n ¡ ¡11111101¡FD ¡4¡5¡ ¡ ¡ ¡ ¡00110110¡36 ¡ ¡ ¡ ¡ ¡ ¡ ¡<- d ->¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡<- n ->¡ ¡ ¡ ¡ ------------_----------------------------_-------------_--------_---_-_- <662 APPENDIX A R800 instruction chart> Å------------\----------------------------\-------------\------------\-\-ã ¡MNEMONIC ¡ INSTRUCTION ACTION ¡ FLAGS ¡ OPCODE ¡ ¡ ¡ ¡ ¡ ¡ ---------\---¢ ¡ ¡ ¡ ¡ ¡S Z H P/v N C¡76543210¡HEX¡B¡C¡ -------------------------------------------------------------------------¢ ¡ld .a,.i ¡ .a <- .i ¡- - 0 i 0 ¡11101101¡ED ¡2¡2¡ ¡ ¡ ¡ ¡01010111¡57 ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡ld .a,.r ¡ .a <- .r ¡- - 0 i 0 ¡11101101¡ED ¡2¡2¡ ¡ ¡ ¡ ¡01011111¡5F ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡ld .i,.a ¡ .i <- .ax+d] ¡ ¡11101101¡ED ¡2¡2¡ ¡ ¡ ¡ ¡01000111¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡ld .r,.a ¡ .r <- .a ¡ ¡11101101¡ED ¡2¡2¡ ¡ ¡ ¡ ¡01001111¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡ld .a,[.bc] ¡ .a <- [.bc] ¡ ¡00001010¡0A ¡1¡2¡ -------------------------------------------------------------------------¢ ¡ld .a,[.de] ¡ .a <- [.de] ¡ ¡00011010¡1A ¡1¡2¡ -------------------------------------------------------------------------¢ ¡ld .a,[nn] ¡ .a <- [nn] ¡ ¡00111010¡3A ¡3¡4¡ ¡ ¡ ¡ ¡<- NNl->¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡<- NNh->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡ld [.bc],.a ¡ [.bc] <- .a ¡ ¡00000010¡02 ¡1¡2¡ -------------------------------------------------------------------------¢ ¡ld [.de],.a ¡ [.de] <- .a ¡ ¡00010010¡12 ¡1¡2¡ -------------------------------------------------------------------------¢ ¡ld [nn],.a ¡ [nn] <- .a ¡ ¡00110010¡32 ¡3¡4¡ ¡ ¡ ¡ ¡<- NNl->¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡<- NNh->¡ ¡ ¡ ¡ ------------_----------------------------_-------------_--------_---_-_- Å-\----\----\----\----\----\----\----\----ã ¡ ¡000 ¡001 ¡010 ¡011 ¡100 ¡101 ¡110 ¡111 ¡ ------------------------------------------¢ ¡r¡ .b ¡ .c ¡ .d ¡ .e ¡ .h ¡ .l ¡ ¡ .a ¡ ------------------------------------------¢ ¡u¡ .b ¡ .c ¡ .d ¡ .e ¡.ixh¡.ixl¡ ¡ .a ¡ ------------------------------------------¢ ¡v¡ .b ¡ .c ¡ .d ¡ .e ¡.iyh¡.iyl¡ ¡ .a ¡ -_----_----_----_----_----_----_----_---- A.2 16 bit TRANSFER INSTRUCTIONS Å------------\----------------------------\-------------\------------\-\-ã ¡MNEMONIC ¡ INSTRUCTION ACTION ¡ FLAGS ¡ OPCODE ¡ ¡ ¡ ¡ ¡ ¡ ---------\---¢ ¡ ¡ ¡ ¡ ¡S Z H P/v N C¡76543210¡HEX¡B¡C¡ -------------------------------------------------------------------------¢ ¡ld ss,nn ¡ ss <- nn ¡ ¡00ss0001¡ ¡3¡3¡ ¡ ¡ ¡ ¡<-nnl ->¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡<-nnh ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡ld .ix,nn ¡ .ix <- nn ¡ ¡11011101¡DD ¡4¡4¡ ¡ ¡ ¡ ¡00100001¡21 ¡ ¡ ¡ ¡ ¡ ¡ ¡<-nnl ->¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡<-nnh ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡ld .iy,nn ¡ .iy <- nn ¡ ¡11111101¡FD ¡4¡4¡ ¡ ¡ ¡ ¡00100001¡21 ¡ ¡ ¡ ¡ ¡ ¡ ¡<-nnl ->¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡<-nnh ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡ld .sp,.hl ¡ .sp <- .hl ¡ ¡11111001¡F9 ¡1¡1¡ -------------------------------------------------------------------------¢ ¡ld .sp,.ix ¡ .sp <- .ix ¡ ¡11011101¡DD ¡2¡2¡ ¡ ¡ ¡ ¡11111001¡F9 ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡ld .sp,.iy ¡ .sp <- .iy ¡ ¡11111101¡FD ¡2¡2¡ ¡ ¡ ¡ ¡11111001¡F9 ¡ ¡ ¡ ------------_----------------------------_-------------_--------_---_-_- <A.2 16 bit transfer instructions 663> Å------------\----------------------------\-------------\------------\-\-ã ¡MNEMONIC ¡ INSTRUCTION ACTION ¡ FLAGS ¡ OPCODE ¡ ¡ ¡ ¡ ¡ ¡ ---------\---¢ ¡ ¡ ¡ ¡ ¡S Z H P/v N C¡76543210¡HEX¡B¡C¡ -------------------------------------------------------------------------¢ ¡ld ss,[nn] ¡ ssh <- [nn+1] ¡ ¡11101101¡ED ¡4¡6¡ ¡ ¡ ssl <- [nn] ¡ ¡01ss1011¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡<-nnl ->¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡<-nnh ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡ld .hl,[nn] ¡ .h <- [nn+1] ¡ ¡00101010¡2A ¡3¡5¡ ¡ ¡ .l <- [nn] ¡ ¡<-nnl ->¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡<-nnh ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡ld .ix,[nn] ¡.ixh <- [nn+1] ¡ ¡11011101¡DD ¡4¡6¡ ¡ ¡.ixl <- [nn] ¡ ¡00101010¡2A ¡ ¡ ¡ ¡ ¡ ¡ ¡<-nnl ->¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡<-nnh ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡ld .iy,[nn] ¡.iyh <- [nn+1] ¡ ¡11111101¡FD ¡4¡6¡ ¡ ¡.iyl <- [nn] ¡ ¡00101010¡2A ¡ ¡ ¡ ¡ ¡ ¡ ¡<-nnl ->¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡<-nnh ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡ld [nn],ss ¡[nn+1] <- ssh ¡ ¡11101101¡ED ¡4¡6¡ ¡ ¡[nn] <- ssl ¡ ¡01ss0011¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡<-nnl ->¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡<-nnh ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡ld [nn],.hl ¡[nn+1] <- .h ¡ ¡00100010¡22 ¡3¡5¡ ¡ ¡[nn] <- .l ¡ ¡<-nnl ->¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡<-nnh ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡ld [nn],.ix ¡[nn+1] <- .ixh ¡ ¡11011101¡DD ¡4¡6¡ ¡ ¡[nn] <- .ixl ¡ ¡00100010¡22 ¡ ¡ ¡ ¡ ¡ ¡ ¡<-nnl ->¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡<-nnh ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡ld [nn],.iy ¡[nn+1] <- .iyh ¡ ¡11111101¡FD ¡4¡6¡ ¡ ¡[nn] <- .iyl ¡ ¡00100010¡22 ¡ ¡ ¡ ¡ ¡ ¡ ¡<-nnl ->¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡<-nnh ->¡ ¡ ¡ ¡ ------------_----------------------------_-------------_--------_---_-_- Å--\---\---\---\---ã ¡ ¡00 ¡01 ¡10 ¡11 ¡ -------------------¢ ¡ss¡.bc¡.de¡.hl¡.sp¡ --_---_---_---_--- <664 appendix A r800 instruction chart > A.3 EXCHANGE INSTRUCTIONS Å-------------\----------------------------\-------------\------------\-\-ã ¡MNEMONIC ¡ INSTRUCTION ACTION ¡ FLAGS ¡ OPCODE ¡ ¡ ¡ ¡ ¡ ¡ ---------\---¢ ¡ ¡ ¡ ¡ ¡S Z H P/v N C¡76543210¡HEX¡B¡C¡ --------------------------------------------------------------------------¢ ¡xch .de,.hl ¡.de <-> .hl ¡ ¡11101011¡EB ¡1¡1¡ --------------------------------------------------------------------------¢ ¡xch .af,.af' ¡.af <-> .af' ¡- - - - - -¡00001000¡08 ¡1¡1¡ --------------------------------------------------------------------------¢ ¡xch [.sp],.hl¡.l <-> [.sp];.h <-> [sp+1] ¡ ¡11100011¡E3 ¡1¡5¡ ----------- --------------------------------------------------------------¢ ¡xch [.sp],.ix¡.ixl <-> [.sp] ¡ ¡11011101¡DD ¡2¡6¡ ¡ ¡.ixh <-> [.sp+1] ¡ ¡11100011¡E3 ¡ ¡ ¡ --------------------------------------------------------------------------¢ ¡xch [.sp],.iy¡.iyl <-> [.sp] ¡ ¡11111101¡FD ¡2¡6¡ ¡ ¡.iyh <-> [.sp] ¡ ¡11100011¡E3 ¡ ¡ ¡ --------------------------------------------------------------------------¢ ¡xchx ¡.bc <-> .bc';.de <-> de'; ¡ ¡11011001¡D9 ¡1¡1¡ ¡ ¡.hl <-> .hl' ¡ ¡ ¡ ¡ ¡ ¡ -------------_----------------------------_-------------_--------_---_-_- A.4 STACK OPERATION INSTRUCTIONS Å------------\----------------------------\-------------\------------\-\-ã ¡MNEMONIC ¡ INSTRUCTION ACTION ¡ FLAGS ¡ OPCODE ¡ ¡ ¡ ¡ ¡ ¡ ---------\---¢ ¡ ¡ ¡ ¡ ¡S Z H P/v N C¡76543210¡HEX¡B¡C¡ -------------------------------------------------------------------------¢ ¡push qq ¡[.sp-2]<-qql;[sp-1]<-qqh ¡ ¡11qq0101¡ ¡1¡4¡ ¡ ¡.sp <- .sp-2 ¡ ¡ ¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡push .ix ¡[.sp-2]<-.ixl;[.sp-1]<-.ixh ¡ ¡11011101¡DD ¡2¡5¡ ¡ ¡.sp <- .sp-2 ¡ ¡11100101¡E5 ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡push .iy ¡[.sp-2]<-.iyl;[.sp-1]<-.iyh ¡ ¡11111101¡FD ¡2¡5¡ ¡ ¡.sp <- .sp-2 ¡ ¡11100101¡E5 ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡pop qq ¡qql<-[.sp];qqh<-[.sp+1] ¡ ¡11qq0001¡ ¡1¡3¡ ¡ ¡.sp <- .sp+2 ¡ ¡ ¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡pop .ix ¡.ixl<-[.sp];.ixh<-[.sp+1] ¡ ¡11011101¡DD ¡2¡4¡ ¡ ¡.sp <- .sp+2 ¡ ¡11100001¡E1 ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡pop .iy ¡.iyl<-[.sp];.iyh<-[.sp+1] ¡ ¡11111101¡FD ¡2¡4¡ ¡ ¡.sp <- .sp+2 ¡ ¡11100001¡E1 ¡ ¡ ¡ ------------_----------------------------_-------------_--------_---_-_- Å--\---\---\---\---ã ¡ ¡00 ¡01 ¡10 ¡11 ¡ -------------------¢ ¡qq¡.bc¡.de¡.hl¡.af¡ --_---_---_---_--- In case of pop .af, all flags are changed <A.5 block move instructions 665> A.5 BLOCK MOVE INSTRUCTIONS Å------------\------------------------------\-------------\------------\-\-ã ¡MNEMONIC ¡ INSTRUCTION ACTION ¡ FLAGS ¡ OPCODE ¡ ¡ ¡ ¡ ¡ ¡ ---------\---¢ ¡ ¡ ¡ ¡ ¡S Z H P/v N C¡76543210¡HEX¡B¡C¡ ---------------------------------------------------------------------------¢ ¡move[.hl++],¡[.de]<-[.hl];.de<-.de+1 ¡ 0 - 0 ¡11101101¡ED ¡2¡4¡ ¡[.de++], ¡.hl<-.hl+1;.bc<-.bc-1 ¡ *1 ¡10100000¡A0 ¡ ¡ ¡ ---------------------------------------------------------------------------¢ ¡move[.hl--],¡[.de]<-[.hl];.de+.de-1 ¡ 0 - 0 ¡11101101¡ED ¡2¡4¡ ¡[.de--] ¡.hl<-.hl-1;.bc<-.bc-1 ¡ *1 ¡10101000¡A8 ¡ ¡ ¡ ---------------------------------------------------------------------------¢ ¡movem [.hl++¡repeat;[.de]<-[.hl];.de<-.de+1¡ 0 0 0 ¡11101101¡ED ¡2¡4¡ ¡ ],[.de++] ¡.hl<-.hl+1;.bc<-.bc-1;until.bc=0¡ ¡10110000¡B0 ¡ ¡ ¡ --------------------------------------------\-_----------------------------¢ ¡movem [.hl--¡repeat;[.de]<-[.hl];.de<-.de-1¡ 0 0 0 ¡11101101¡ED ¡2¡4¡ ¡ ],[.de--] ¡.hl<-.hl-1;.bc<-.bc-1;until.bc=0¡ ¡10111000¡B8 ¡ ¡ ¡ ------------_--------------------------------_-----------_--------_---_-_- *1 when .bc-1 = 0 it will be set to 0 else it will be set to 1 A.6 BLOCK SEARCH INSTRUCTION Å------------\----------------------------\-------------\------------\-\-ã ¡MNEMONIC ¡ INSTRUCTION ACTION ¡ FLAGS ¡ OPCODE ¡ ¡ ¡ ¡ ¡ ¡ ---------\---¢ ¡ ¡ ¡ ¡ ¡S Z H P/v N C¡76543210¡HEX¡B¡C¡ -------------------------------------------------------------------------¢ ¡cmp ¡.a-[.hl];.hl<-.hl+1 ¡- - - - 1 ¡11101101¡ED ¡2¡4¡ ¡ .a,[.hl++]¡.bc<-.bc-1 ¡ *2 *1 ¡10100001¡A1 ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡cmp ¡.a-[.hl];.hl<-.hl-1 ¡- - - - 1 ¡11101101¡ED ¡2¡4¡ ¡ .a,[.hl--]¡.bc<-.bc-1 ¡ *2 *1 ¡10101001¡A9 ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡cmpm ¡repeat;.a-[.hl];.hl<-.hl+1 ¡- - - - 1 ¡11101101¡ED ¡2¡5¡ ¡ .a,[hl++]¡.bc<-.bc-1;until .bc=0 ¡ *2 *1 ¡10110001¡B1 ¡ ¡ ¡ ¡ ¡ or .a=[.hl] ¡ ¡ ¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡cmpm ¡repeat;.a-[.hl];.hl<-.hl-1 ¡- - - - 1 ¡11101101¡ED ¡2¡5¡ ¡ .a,[hl--]¡.bc<-.bc-1;until .bc=0 ¡ *2 *1 ¡10111001¡B9 ¡ ¡ ¡ ¡ ¡ or .a=[.hl] ¡ ¡ ¡ ¡ ¡ ¡ ------------_----------------------------_-------------_--------_---_-_- *1 when bc-1=0 it will be set to 0 else it will be set to 1 *2 when .a=[.hl] it will be set to 1 else it will be set to 0 A.7 MULTIPLICATION INSTRUCTIONS Å------------\----------------------------\-------------\------------\-\--ã ¡MNEMONIC ¡ INSTRUCTION ACTION ¡ FLAGS ¡ OPCODE ¡ ¡ ¡ ¡ ¡ ¡ ---------\---¢ ¡ ¡ ¡ ¡ ¡S Z H P/v N C¡76543210¡HEX¡B¡C ¡ --------------------------------------------------------------------------¢ ¡mulub .a,r ¡.hl<-.a*r ¡0 - 0 -¡11101101¡ED ¡2¡14¡ ¡ ¡ ¡ ¡11 r 001¡ ¡ ¡ ¡ --------------------------------------------------------------------------¢ ¡muluw .hl,ss¡.de:.hl<-.hl*ss ¡0 - 0 -¡11101101¡ED ¡2¡36¡ ¡ ¡ ¡ ¡11ss0011¡ ¡ ¡ ¡ ------------_----------------------------_-------------_--------_---_-_-- With the mulub function when .b,.c,.d,.e are excluded of r the usage can't be guaranteed. (???) With the muluw function then .bc,.sp are excluded of ss the usage can't be guaranteed. (???) <666 appendix a r800 instruction chart> A.8 ADD INSTRUCTIONS Å------------\----------------------------\-------------\------------\-\-ã ¡MNEMONIC ¡ INSTRUCTION ACTION ¡ FLAGS ¡ OPCODE ¡ ¡ ¡ ¡ ¡ ¡ ---------\---¢ ¡ ¡ ¡ ¡ ¡S Z H P/v N C¡76543210¡HEX¡B¡C¡ -------------------------------------------------------------------------¢ ¡add .a,r ¡.a<-.a+r ¡- - - v 0 -¡10000 r ¡ ¡1¡1¡ -------------------------------------------------------------------------¢ ¡add .a,p ¡.a<-.a+p ¡- - - V 0 -¡11011101¡DD ¡2¡2¡ ¡ ¡ ¡ ¡10000 p ¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡add .a,q ¡.a<-.a+q ¡- - - V 0 -¡11111101¡FD ¡2¡2¡ ¡ ¡ ¡ ¡10000 q ¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡add .a,[.hl]¡.a<-.a+[.hl] ¡- - - V 0 -¡10000110¡86 ¡1¡2¡ -------------------------------------------------------------------------¢ ¡add ¡.a<-.a+[.ix+d] ¡- - - V 0 -¡11011101¡DD ¡3¡5¡ ¡ .a,[.ix+d] ¡ ¡ ¡10000110¡86 ¡ ¡ ¡ ¡ ¡ ¡ ¡<- d ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡add ¡.a<-.a+[.iy+d] ¡- - - V 0 -¡11111101¡FD ¡3¡5¡ ¡ .a,[.iy+d] ¡ ¡ ¡10000110¡86 ¡ ¡ ¡ ¡ ¡ ¡ ¡<- d ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡add a,n ¡.a<-.a+n ¡- - - V 0 -¡11000110¡C6 ¡2¡2¡ ¡ ¡ ¡ ¡<- n ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡addc .a.r ¡.a<-.a+r+C ¡- - - V 0 -¡10001 r ¡ ¡1¡1¡ -------------------------------------------------------------------------¢ ¡addc .a,p ¡.a<-.a+p+C ¡- - - V 0 -¡11011101¡DD ¡2¡2¡ ¡ ¡ ¡ ¡10001 p ¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡addc .a,q ¡.a<-.a+q+C ¡- - - V 0 -¡11111101¡FD ¡2¡2¡ ¡ ¡ ¡ ¡10001 q ¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡addc.a,[.hl]¡.a<-.a+[.hl]+C ¡- - - V 0 -¡10001110¡8E ¡1¡2¡ -------------------------------------------------------------------------¢ ¡addc ¡.a<-.a+[.ix+d]+C ¡- - - V 0 -¡11011101¡DD ¡3¡5¡ ¡ .a,[.ix+d] ¡ ¡ ¡10001110¡8E ¡ ¡ ¡ ¡ ¡ ¡ ¡<- d ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡addc ¡.a<-.a+[.iy+d]+C ¡- - - V 0 -¡11111101¡FD ¡3¡5¡ ¡ .a,[.iy+d] ¡ ¡ ¡10001110¡8E ¡ ¡ ¡ ¡ ¡ ¡ ¡<- d ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡addc .a,n ¡.a<-.a+n+C ¡- - - V 0 -¡11001110¡CE ¡2¡2¡ ¡ ¡ ¡ ¡<- n ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡addc .hl,ss ¡.hl<-.hl+ss+C ¡- - ? V 0 -¡11101101¡ED ¡2¡2¡ ¡ ¡ ¡ ¡01ss1010¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡add .hl,ss ¡.hl<-.hl+ss ¡ ? 0 -¡00ss1001¡ ¡1¡1¡ -------------------------------------------------------------------------¢ ¡add .ix,pp ¡.ix<-.ix+pp ¡ ? 0 -¡11011101¡DD ¡2¡2¡ ¡ ¡ ¡ ¡00pp1001¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡add .iy,rr ¡.iy<-.iy+rr ¡ ? 0 -¡11111101¡FD ¡2¡2¡ ¡ ¡ ¡ ¡00rr1001¡ ¡ ¡ ¡ ------------_----------------------------_-------------_--------_---_-_- <A.8 ADD INSTRUCTIONS 667> Å------------\----------------------------\-------------\------------\-\-ã ¡MNEMONIC ¡ INSTRUCTION ACTION ¡ FLAGS ¡ OPCODE ¡ ¡ ¡ ¡ ¡ ¡ ---------\---¢ ¡ ¡ ¡ ¡ ¡S Z H P/v N C¡76543210¡HEX¡B¡C¡ -------------------------------------------------------------------------¢ ¡inc r ¡r<-r+1 ¡- - - V 0 ¡00 r 100¡ ¡1¡1¡ -------------------------------------------------------------------------¢ ¡inc p ¡p<-p+1 ¡- - - V 0 ¡11011101¡DD ¡2¡2¡ ¡ ¡ ¡ ¡00 p 100¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡inc q ¡q<-q+1 ¡- - - V 0 ¡11111101¡FD ¡2¡2¡ ¡ ¡ ¡ ¡00 q 100¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡inc [.hl] ¡[.hl]<-[.hl]+1 ¡- - - V 0 ¡00110100¡34 ¡1¡4¡ -------------------------------------------------------------------------¢ ¡inc [.ix+d] ¡[.ix+d]<-[.ix+d]+1 ¡- - - V 0 ¡11011101¡DD ¡3¡7¡ ¡ ¡ ¡ ¡00110100¡34 ¡ ¡ ¡ ¡ ¡ ¡ ¡<- d ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡inc [.iy+d] ¡[.iy+d]<-[.iy+d]+1 ¡- - - V 0 ¡11111101¡FD ¡3¡7¡ ¡ ¡ ¡ ¡00110100¡34 ¡ ¡ ¡ ¡ ¡ ¡ ¡<- d ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡inc ss ¡ss<-ss+1 ¡ ¡00ss0011¡ ¡1¡1¡ -------------------------------------------------------------------------¢ ¡inc .ix ¡.ix<-.ix+1 ¡ ¡11011101¡DD ¡2¡2¡ ¡ ¡ ¡ ¡00100011¡23 ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡inc .iy ¡.iy<-.iy+1 ¡ ¡11111101¡FD ¡2¡2¡ ¡ ¡ ¡ ¡00100011¡23 ¡ ¡ ¡ ------------_----------------------------_-------------_--------_---_-_- Å--\---\---\---\---ã ¡ ¡00 ¡01 ¡10 ¡11 ¡ -------------------¢ ¡ss¡.bc¡.de¡.hl¡.sp¡ -------------------¢ ¡pp¡.bc¡.de¡.ix¡.sp¡ -------------------¢ ¡rr¡.bc¡.de¡.iy¡.sp¡ --_---_---_---_--- Å-\----\----\----\----\----\-----\----\----ã ¡ ¡000 ¡001 ¡010 ¡011 ¡100 ¡101 ¡110 ¡111 ¡ -------------------------------------------¢ ¡p¡ ¡ ¡ ¡ ¡.ixh¡.ixl ¡ ¡ ¡ -------------------------------------------¢ ¡q¡ ¡ ¡ ¡ ¡.iyh¡.iyl ¡ ¡ ¡ -_----_----_----_----_----_-----_----_---- <668 APPENDIX A R800 INSTRUCTION CHART> A.9 DECREASE INSTRUCTION Å------------\----------------------------\-------------\------------\-\-ã ¡MNEMONIC ¡ INSTRUCTION ACTION ¡ FLAGS ¡ OPCODE ¡ ¡ ¡ ¡ ¡ ¡ ---------\---¢ ¡ ¡ ¡ ¡ ¡S Z H P/v N C¡76543210¡HEX¡B¡C¡ -------------------------------------------------------------------------¢ ¡sub .a,r ¡.a<.a-r ¡- - - V 1 -¡10010 r ¡ ¡1¡1¡ -------------------------------------------------------------------------¢ ¡sub .a,p ¡.a<-.a-p ¡- - - V 1 -¡11011101¡DD ¡2¡2¡ ¡ ¡ ¡ ¡10010 p ¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡sub .a,q ¡.a<-.a-q ¡- - - V 1 -¡11111101¡FD ¡2¡2¡ ¡ ¡ ¡ ¡10010 q ¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡sub .a,[.hl]¡.a<-.a-[.hl] ¡- - - V 1 -¡10010110¡96 ¡1¡2¡ -------------------------------------------------------------------------¢ ¡sub .a, ¡.a<-.a-[.ix+d] ¡- - - V 1 -¡11011101¡DD ¡3¡5¡ ¡ [.ix+d] ¡ ¡ ¡10010110¡96 ¡ ¡ ¡ ¡ ¡ ¡ ¡<- d ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡sub .a, ¡.a<-.a-[.iy+d] ¡- - - V 1 -¡11111101¡FD ¡3¡5¡ ¡ [.iy+d] ¡ ¡ ¡10010110¡96 ¡ ¡ ¡ ¡ ¡ ¡ ¡<- d ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡sub .a,n ¡.a<-.a-n ¡- - - V 1 -¡11010110¡D6 ¡2¡2¡ ¡ ¡ ¡ ¡<- n ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡subc .a,r ¡.a<-.a-r-C ¡- - - V 1 -¡10011 r ¡ ¡1¡1¡ -------------------------------------------------------------------------¢ ¡subc .a,p ¡.a<-.a-p-C ¡- - - V 1 -¡11011101¡DD ¡2¡2¡ ¡ ¡ ¡ ¡10011 p ¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡subc .a,q ¡.a<-.a-q-C ¡- - - V 1 -¡11111101¡FD ¡2¡2¡ ¡ ¡ ¡ ¡10011 q ¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡subc .a, ¡.a<-.a-[.hl]-C ¡- - - V 1 -¡10011110¡9E ¡1¡2¡ ¡ [.hl] ¡ ¡ ¡ ¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡subc .a, ¡.A<-.A-[.IX+D]+c ¡- - - V 1 -¡11011101¡DD ¡3¡5¡ ¡ [.ix+d] ¡ ¡ ¡10011110¡9E ¡ ¡ ¡ ¡ ¡ ¡ ¡<- d ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡subc .a, ¡.a<-.a-[.iy+d]+c ¡- - - V 1 -¡11111101¡FD ¡3¡5¡ ¡ [.iy+d] ¡ ¡ ¡10011110¡9E ¡ ¡ ¡ ¡ ¡ ¡ ¡<- d ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡subc a,n ¡.a<-.a-n-C ¡- - - V 1 -¡11011110¡DE ¡2¡2¡ ¡ ¡ ¡ ¡<- n ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡subc .hl,ss ¡.hl<-.hl-ss-C ¡- - ? V 1 -¡11101101¡ED ¡2¡2¡ ¡ ¡ ¡ ¡01ss0010¡ ¡ ¡ ¡ ------------_----------------------------_-------------_--------_---_-_- <A.10 DECREASE INSTRUCTION 669> Å------------\----------------------------\-------------\------------\-\-ã ¡MNEMONIC ¡ INSTRUCTION ACTION ¡ FLAGS ¡ OPCODE ¡ ¡ ¡ ¡ ¡ ¡ ---------\---¢ ¡ ¡ ¡ ¡ ¡S Z H P/v N C¡76543210¡HEX¡B¡C¡ -------------------------------------------------------------------------¢ ¡dec r ¡r<-r-1 ¡- - - V 1 ¡00 r 101¡ ¡1¡1¡ -------------------------------------------------------------------------¢ ¡dec p ¡p<-p-1 ¡- - - V 1 ¡11011101¡DD ¡2¡2¡ ¡ ¡ ¡ ¡00 p 101¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡dec q ¡q<-q-1 ¡- - - V 1 ¡11111101¡FD ¡2¡2¡ ¡ ¡ ¡ ¡00 q 101¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡dec [.hl] ¡[.hl]<-[.hl]-1 ¡- - - V 1 ¡00110101¡35 ¡1¡4¡ -------------------------------------------------------------------------¢ ¡dec [.ix+d] ¡[.ix+d]<-[.ix+d]-1 ¡- - - V 1 ¡11011101¡DD ¡3¡7¡ ¡ ¡ ¡ ¡00110101¡35 ¡ ¡ ¡ ¡ ¡ ¡ ¡<- d ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡dec [.iy+d] ¡[.iy+d]<-[.iy+d]-1 ¡- - - V 1 ¡11111101¡FD ¡3¡7¡ ¡ ¡ ¡ ¡00110101¡35 ¡ ¡ ¡ ¡ ¡ ¡ ¡<- d ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡dec ss ¡ss<-ss-1 ¡ ¡00ss1011¡ ¡1¡1¡ -------------------------------------------------------------------------¢ ¡dec .ix ¡.ix<-.ix-1 ¡ ¡11011101¡DD ¡2¡2¡ ¡ ¡ ¡ ¡00101011¡2B ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡dec .iy ¡.iy<-.iy-1 ¡ ¡11111101¡FD ¡2¡2¡ ¡ ¡ ¡ ¡00101011¡2B ¡ ¡ ¡ ------------_----------------------------_-------------_--------_---_-_- A.10 COMPARISON INSTRUCTIONS Å------------\----------------------------\-------------\------------\-\-ã ¡MNEMONIC ¡ INSTRUCTION ACTION ¡ FLAGS ¡ OPCODE ¡ ¡ ¡ ¡ ¡ ¡ ---------\---¢ ¡ ¡ ¡ ¡ ¡S Z H P/v N C¡76543210¡HEX¡B¡C¡ -------------------------------------------------------------------------¢ ¡cmp .a,r ¡.a-r ¡- - - V 1 -¡10111 r ¡ ¡1¡1¡ -------------------------------------------------------------------------¢ ¡cmp .a,r ¡.a-p ¡- - - V 1 -¡11011101¡DD ¡2¡2¡ ¡ ¡ ¡ ¡10111 p ¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡cmp .a,q ¡.a-q ¡- - - V 1 -¡11111101¡FD ¡2¡2¡ ¡ ¡ ¡ ¡10111 q ¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡cmp .a,[.hl]¡.a-[.hl] ¡- - - V 1 -¡10111110¡BE ¡1¡2¡ -------------------------------------------------------------------------¢ ¡cmp .a, ¡.a-[.ix+d] ¡- - - V 1 -¡11011101¡DD ¡3¡5¡ ¡ [.ix+d] ¡ ¡ ¡10111110¡BE ¡ ¡ ¡ ¡ ¡ ¡ ¡<- d ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡cmp .a, ¡.a-[.iy+d] ¡- - - V 1 -¡11111101¡FD ¡3¡5¡ ¡ [.iy+d] ¡ ¡ ¡10111110¡BE ¡ ¡ ¡ ¡ ¡ ¡ ¡<- d ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡cmp .a,n ¡.a-n ¡- - - V 1 -¡11111110¡FE ¡2¡2¡ ¡ ¡ ¡ ¡<- n ->¡ ¡ ¡ ¡ ------------_----------------------------_-------------_--------_---_-_- < 670 APPENDIX A R800 INSTRUCTION CHART> A.11 LOGIC OPERATION INSTRUCTION Å------------\----------------------------\-------------\------------\-\-ã ¡MNEMONIC ¡ INSTRUCTION ACTION ¡ FLAGS ¡ OPCODE ¡ ¡ ¡ ¡ ¡ ¡ ---------\---¢ ¡ ¡ ¡ ¡ ¡S Z H P/v N C¡76543210¡HEX¡B¡C¡ -------------------------------------------------------------------------¢ ¡and .a,r ¡.a<-.a/\r ¡- - 1 P 0 0¡10100 r ¡ ¡1¡1¡ -------------------------------------------------------------------------¢ ¡and .a,p ¡.a<-.a/\p ¡- - 1 P 0 0¡11011101¡DD ¡2¡2¡ ¡ ¡ ¡ ¡10100 p ¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡and .a,q ¡.a<-.a/\q ¡- - 1 P 0 0¡11111101¡FD ¡2¡2¡ ¡ ¡ ¡ ¡10100 q ¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡and .a,[.hl]¡.a<-.a/\[.hl] ¡- - 1 P 0 0¡10100110¡A6 ¡1¡2¡ -------------------------------------------------------------------------¢ ¡and .a, ¡.a<-.a/\[.ix+d] ¡- - 1 P 0 0¡11011101¡DD ¡3¡5¡ ¡ [.ix+d] ¡ ¡ ¡10100110¡A6 ¡ ¡ ¡ ¡ ¡ ¡ ¡<- d ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡and .a, ¡.a<-.a/\[.iy+d] ¡- - 1 P 0 0¡11111101¡FD ¡3¡5¡ ¡ [.iy+d] ¡ ¡ ¡10100110¡A6 ¡ ¡ ¡ ¡ ¡ ¡ ¡<- d ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡and .a,n ¡.a<-.a/\n ¡- - 1 P 0 0¡11100110¡E6 ¡2¡2¡ ¡ ¡ ¡ ¡<- n ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡or .a,r ¡.a<-.a\/r ¡- - 0 P 0 0¡10110 r ¡ ¡1¡1¡ -------------------------------------------------------------------------¢ ¡or .a,p ¡.a<-.a\/p ¡- - 0 P 0 0¡11011101¡DD ¡2¡2¡ ¡ ¡ ¡ ¡10110 p ¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡or .a,q ¡.a<-.a\/q ¡- - 0 P 0 0¡11111101¡FD ¡2¡2¡ ¡ ¡ ¡ ¡10110 q ¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡or .a,[.hl] ¡.a<-.a\/[.hl] ¡- - 0 P 0 0¡10110110¡B6 ¡1¡2¡ -------------------------------------------------------------------------¢ ¡or .a, ¡.a<-.a\/[.ix+d] ¡- - 0 P 0 0¡11011101¡DD ¡3¡5¡ ¡ [.ix+d] ¡ ¡ ¡10110110¡B6 ¡ ¡ ¡ ¡ ¡ ¡ ¡<- d ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡or .a, ¡.a<-.a\/[.iy+d] ¡- - 0 P 0 0¡11111101¡FD ¡3¡5¡ ¡ [.iy+d] ¡ ¡ ¡10110110¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡<- d ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡or .a,n ¡.a<-.a\/n ¡- - 0 P 0 0¡11110110¡F6 ¡2¡2¡ ¡ ¡ ¡ ¡<- n > ¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡xor .a,r ¡.a<-.a\-/r ¡- - 0 P 0 0¡10101 r ¡ ¡1¡1¡ -------------------------------------------------------------------------¢ ¡xor .a,p ¡.a<-.a\-/p ¡- - 0 P 0 0¡11011101¡DD ¡2¡2¡ ¡ ¡ ¡ ¡10101 p ¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡xor .a,q ¡.a<-.a\-/q ¡- - 0 P 0 0¡11111101¡FD ¡2¡2¡ ¡ ¡ ¡ ¡10101 q ¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡xor .a,[.hl]¡.a<-.a\-/[.hl] ¡- - 0 P 0 0¡10101110¡AE ¡1¡2¡ -------------------------------------------------------------------------¢ ¡xor .a, ¡.a<-.a\-/[.ix+d] ¡- - 0 P 0 0¡11011101¡DD ¡3¡5¡ ¡ [.ix+d] ¡ ¡ ¡10101110¡AE ¡ ¡ ¡ ¡ ¡ ¡ ¡<- d ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡xor .a, ¡.a<-.a\-/[.iy+d] ¡- - 0 P 0 0¡11111101¡FD ¡3¡5¡ ¡ [.iy+d] ¡ ¡ ¡10101110¡AE ¡ ¡ ¡ ¡ ¡ ¡ ¡<- d ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡xor .a,n ¡.a<-.a\-/n ¡- - 0 P 0 0¡11101110¡EE ¡2¡2¡ ¡ ¡ ¡ ¡<- n ->¡ ¡ ¡ ¡ ------------_----------------------------_-------------_--------_---_-_- <A.12 BIT OPERATION INSTRUCTION 671> A.12 BIT OPERATION INSTRUCTION Å------------\----------------------------\-------------\------------\-\-ã ¡MNEMONIC ¡ INSTRUCTION ACTION ¡ FLAGS ¡ OPCODE ¡ ¡ ¡ ¡ ¡ ¡ ---------\---¢ ¡ ¡ ¡ ¡ ¡S Z H P/v N C¡76543210¡HEX¡B¡C¡ -------------------------------------------------------------------------¢ ¡bit b,r ¡z<-NOT r{b} ¡? - 1 ? 0 ¡11001011¡CB ¡2¡2¡ ¡ ¡ ¡ ¡01 b r ¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡bit b,[.hl] ¡z<-NOT [.hl]{b} ¡? - 1 ? 0 ¡11001011¡CB ¡2¡2¡ ¡ ¡ ¡ ¡01 b 110¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡bit b, ¡z<-NOT [.ix+d]{b} ¡? - 1 ? 0 ¡11011101¡DD ¡4¡5¡ ¡ [.ix+d] ¡ ¡ ¡11001011¡CB ¡ ¡ ¡ ¡ ¡ ¡ ¡<- d ->¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡01 b 110¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡bit b, ¡z<-NOT [.iy+d]{b} ¡? - 1 ? 0 ¡11111101¡FD ¡4¡5¡ ¡ [.iy+d] ¡ ¡ ¡11001011¡CB ¡ ¡ ¡ ¡ ¡ ¡ ¡<- d ->¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡01 b 110¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡set b,r ¡r{b}<-1 ¡ ¡11001011¡CB ¡2¡2¡ ¡ ¡ ¡ ¡11 b r ¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡set b,[.hl] ¡[.hl]{b}<-1 ¡ ¡11001011¡CB ¡2¡5¡ ¡ ¡ ¡ ¡11 b 110¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡set b, ¡[.ix+d]{b}<-1 ¡ ¡11011101¡DD ¡4¡7¡ ¡ [.ix+d] ¡ ¡ ¡11001011¡CB ¡ ¡ ¡ ¡ ¡ ¡ ¡<- d ->¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡11 b 110¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡set b, ¡[.iy+d]{b}<-1 ¡ ¡11111101¡FD ¡4¡7¡ ¡ [.iy+d] ¡ ¡ ¡11001011¡CB ¡ ¡ ¡ ¡ ¡ ¡ ¡<- d ->¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡11 b 110¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡clr b,r ¡r{b}<-0 ¡ ¡11001011¡CB ¡2¡2¡ ¡ ¡ ¡ ¡10 b r ¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡clr b,[.hl] ¡[.hl]{b}<-0 ¡ ¡11001011¡CB ¡2¡5¡ ¡ ¡ ¡ ¡10 b 110¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡clr b, ¡[.ix+d]{b}<-0 ¡ ¡11011101¡DD ¡4¡7¡ ¡ [.ix+d] ¡ ¡ ¡11001011¡CB ¡ ¡ ¡ ¡ ¡ ¡ ¡<= d ->¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡10 b 110¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡clr b, ¡[.iy+d]{b}<-0 ¡ ¡11111101¡FD ¡4¡7¡ ¡ [.iy+d] ¡ ¡ ¡11001011¡CB ¡ ¡ ¡ ¡ ¡ ¡ ¡<- d ->¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡10 b 110¡ ¡ ¡ ¡ ------------_----------------------------_-------------_--------_---_-_- <672 APPENDIX A R800 INSTRUCTION CHART> A.13 ROTATE INSTRUCTIONS Å------------\----------------------------\-------------\------------\-\-ã ¡MNEMONIC ¡ INSTRUCTION ACTION ¡ FLAGS ¡ OPCODE ¡ ¡ ¡ ¡ ¡ ¡ ---------\---¢ ¡ ¡ ¡ ¡ ¡S Z H P/v N C¡76543210¡HEX¡B¡C¡ -------------------------------------------------------------------------¢ ¡rol a ¡C<-.a{7};.a<-.a*2;a{0}<-C ¡ 0 0 -¡00000111¡07 ¡1¡1¡ -------------------------------------------------------------------------¢ ¡ror a ¡C<-.a{0};.a<-.a/2;a{7}<-C ¡ 0 0 -¡00001111¡0F ¡1¡1¡ -------------------------------------------------------------------------¢ ¡rolc a ¡tmp<-C;C<-.a{7};.a<-.a*2; ¡ 0 0 -¡00010111¡17 ¡1¡1¡ ¡ ¡ .a{0}<-tmp ¡ ¡ ¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡rorc a ¡tmp<-C;C<-.a{0};.a<-.a/2; ¡ 0 0 -¡00011111¡1F ¡1¡1¡ ¡ ¡ .a{7}<-tmp ¡ ¡ ¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡rol r ¡C<-r{7} ¡- - 0 P 0 -¡11001011¡CB ¡2¡2¡ ¡ ¡r<r*2;r{0}<-c ¡ ¡00000 r ¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡rol [.hl] ¡C<-[.hl]{7} ¡- - 0 P 0 -¡11001011¡CB ¡2¡5¡ ¡ ¡[.hl]<-[.hl]*2;[.hl]{0}<-C ¡ ¡00000110¡06 ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡rol [.ix+d] ¡C<-[.ix+d]{7} ¡- - 0 P 0 -¡11011101¡DD ¡4¡7¡ ¡ ¡[.ix+d]<-[.ix+d]*2 ¡ ¡ ¡CB ¡ ¡ ¡ ¡ ¡[.ix+d]{0}<-C ¡ ¡<- d ->¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡00000110¡06 ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡rol [.iy+d] ¡C<-[.iy+d]{7} ¡- - 0 P 0 -¡11111101¡FD ¡4¡7¡ ¡ ¡[.iy+d]<-[.iy+d]*2 ¡ ¡ ¡CB ¡ ¡ ¡ ¡ ¡[.iy+d]{0}<-C ¡ ¡<- d ->¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡00000110¡06 ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡ror r ¡C<-r{0} ¡- - 0 P 0 -¡11001011¡CB ¡2¡2¡ ¡ ¡r<-r/2;r{7}<-C ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡ror [.hl] ¡C<-[.hl]{0} ¡- - 0 P 0 -¡11001011¡CB ¡2¡5¡ ¡ ¡[.hl]<-[.hl]/2;[.hl]{7}<-C ¡ ¡00001110¡0E ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡ror [.ix+d] ¡C<-[.ix+d]{0} ¡- - 0 P 0 -¡11011101¡DD ¡4¡7¡ ¡ ¡[.ix+d]<-[.ix+d]/2 ¡ ¡ ¡CB ¡ ¡ ¡ ¡ ¡[.ix+d]{7}<-C ¡ ¡<- d ->¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡00001110¡06 ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡rol [.iy+d] ¡C<-[.iy+d]{0} ¡- - 0 P 0 -¡11111101¡FD ¡4¡7¡ ¡ ¡[.iy+d]<-[.iy+d]/2 ¡ ¡ ¡CB ¡ ¡ ¡ ¡ ¡[.iy+d]{7}<-C ¡ ¡<- d ->¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡00001110¡06 ¡ ¡ ¡ ------------_----------------------------_-------------_--------_---_-_- <A.13 ROTATE INSTRUCTIONS 673> Å------------\----------------------------\-------------\------------\-\-ã ¡MNEMONIC ¡ INSTRUCTION ACTION ¡ FLAGS ¡ OPCODE ¡ ¡ ¡ ¡ ¡ ¡ ---------\---¢ ¡ ¡ ¡ ¡ ¡S Z H P/v N C¡76543210¡HEX¡B¡C¡ -------------------------------------------------------------------------¢ ¡rolc r ¡tmp<-C;C<-r{7} ¡- - 0 P 0 -¡11001011¡CB ¡2¡2¡ ¡ ¡r<-r*2;r{0}<-tmp ¡ ¡00010 r ¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡rolc [.hl] ¡tmp<-C;C<-[.hl]{7} ¡- - 0 P 0 -¡11001011¡CB ¡2¡5¡ ¡ ¡[.hl]<-[.hl]*2;[.hl]{0}<-tmp¡ ¡00010110¡16 ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡rolc [.ix+d]¡tmp<-C ¡- - 0 P 0 -¡11011101¡DD ¡4¡7¡ ¡ ¡C<-[.ix+d]{7} ¡ ¡11001011¡CB ¡ ¡ ¡ ¡ ¡[.ix+d]<-[.ix+d]*2 ¡ ¡<- b ->¡ ¡ ¡ ¡ ¡ ¡[.ix+d]{0}<-tmp ¡ ¡00010110¡16 ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡rolc [.iy+d]¡tmp<-C ¡- - 0 P 0 -¡11111101¡FD ¡4¡7¡ ¡ ¡C<-[.iy+d]{7} ¡ ¡11001011¡CB ¡ ¡ ¡ ¡ ¡[.iy+d]<-[.iy+d]*2 ¡ ¡<- b ->¡ ¡ ¡ ¡ ¡ ¡[.iy+d]{0}<-tmp ¡ ¡00010110¡16 ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡rorc r ¡tmp<-C;C<-r{0} ¡- - 0 P 0 -¡11001011¡CB ¡2¡2¡ ¡ ¡r<-r/2;r{7}<-tmp ¡ ¡00011 r ¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡rorc [.hl] ¡tmp<-C;C<-[.hl]{0} ¡- - 0 P 0 -¡11001011¡CB ¡2¡5¡ ¡ ¡[.hl]<-[.hl]/2;[.hl]{7}<-tmp¡ ¡00011110¡1E ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡rorc [.ix+d]¡tmp<-C ¡- - 0 P 0 -¡11011101¡DD ¡4¡7¡ ¡ ¡C<-[.ix+d]{0} ¡ ¡11001011¡CB ¡ ¡ ¡ ¡ ¡[.ix+d]<-[.ix+d]/2 ¡ ¡<- b ->¡ ¡ ¡ ¡ ¡ ¡[.ix+d]{7}<-tmp ¡ ¡00011110¡16 ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡rorc [.iy+d]¡tmp<-C ¡- - 0 P 0 -¡11111101¡FD ¡4¡7¡ ¡ ¡C<-[.iy+d]{0} ¡ ¡11001011¡CB ¡ ¡ ¡ ¡ ¡[.iy+d]<-[.iy+d]/2 ¡ ¡<- b ->¡ ¡ ¡ ¡ ¡ ¡[.iy+d]{7}<-tmp ¡ ¡00011110¡1E ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡rol4 [.hl] ¡tmp<-.a{0..3} ¡- - 0 P 0 ¡11101101¡ED ¡2¡5¡ ¡ ¡.a{0..3}<-[.hl]{4..7} ¡ ¡11101111¡6F ¡ ¡ ¡ ¡ ¡[.hl]{4..7}<-[.hl]{0..3} ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡[.hl]{0..3}<-tmp ¡ ¡ ¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡rol4 [.hl] ¡tmp<-.a{0..3} ¡- - 0 P 0 ¡11101101¡ED ¡2¡5¡ ¡ ¡.a{0..3}<-[.hl]{4..7} ¡ ¡11100111¡67 ¡ ¡ ¡ ¡ ¡[.hl]{4..7}<-[.hl]{0..3} ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡[.hl]{0..3}<-tmp ¡ ¡ ¡ ¡ ¡ ¡ ------------_----------------------------_-------------_--------_---_-_- <674 APPENDIX A R800 INSTRUCTION CHART A.14 SHIFT INSTRUCTIONS Å------------\----------------------------\-------------\------------\-\-ã ¡MNEMONIC ¡ INSTRUCTION ACTION ¡ FLAGS ¡ OPCODE ¡ ¡ ¡ ¡ ¡ ¡ ---------\---¢ ¡ ¡ ¡ ¡ ¡S Z H P/v N C¡76543210¡HEX¡B¡C¡ -------------------------------------------------------------------------¢ ¡shl r ¡C<-r{7} ¡- - 0 P 0 -¡11001011¡CB ¡2¡2¡ ¡shla ¡r<-r*2 ¡ ¡00100 r ¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡shl [.hl] ¡C<-[.hl]{7} ¡- - 0 P 0 -¡11001011¡CB ¡2¡5¡ ¡shla ¡[.hl]<-[.hl]*2 ¡ ¡00100110¡26 ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡shl [,ix+d] ¡C<-[.ix+d]{7} ¡- - 0 P 0 -¡11011101¡DD ¡4¡7¡ ¡shla ¡[.ix+d]<-[.ix+d]*2 ¡ ¡11001011¡CB ¡ ¡ ¡ ¡ ¡ ¡ ¡<- d ->¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡00100110¡26 ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡shl [,iy+d] ¡C<-[.iy+d]{7} ¡- - 0 P 0 -¡11111101¡DD ¡4¡7¡ ¡shla ¡[.iy+d]<-[.iy+d]*2 ¡ ¡11001011¡CB ¡ ¡ ¡ ¡ ¡ ¡ ¡<- d ->¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡00100110¡26 ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡shr r ¡C<-r{0} ¡- - 0 P 0 -¡11001011¡CB ¡2¡2¡ ¡ ¡r<-r/2 ¡ ¡00111 r ¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡shr [.hl] ¡C<-[.hl]{0} ¡- - 0 P 0 -¡11001011¡CB ¡2¡5¡ ¡ ¡[.hl]<-[.hl]/2 ¡ ¡00111110¡3E ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡shr [,ix+d] ¡C<-[.ix+d]{0} ¡- - 0 P 0 -¡11011101¡DD ¡4¡7¡ ¡ ¡[.ix+d]<-[.ix+d]/2 ¡ ¡11001011¡CB ¡ ¡ ¡ ¡ ¡ ¡ ¡<- d ->¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡00111110¡3E ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡shr [,iy+d] ¡C<-[.iy+d]{0} ¡- - 0 P 0 -¡11111101¡DD ¡4¡7¡ ¡ ¡[.iy+d]<-[.iy+d]/2 ¡ ¡11001011¡CB ¡ ¡ ¡ ¡ ¡ ¡ ¡<- d ->¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡00111110¡3E ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡shra r ¡tmp<-r{7};C<-r{0} ¡- - 0 P 0 -¡11001011¡CB ¡2¡2¡ ¡ ¡r<-r/2;r{7}<-tmp ¡ ¡00101 r ¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡shra [.hl] ¡tmp<-[.hl]{7};C<-[.hl]{0} ¡- - 0 P 0 -¡11001011¡CB ¡2¡2¡ ¡ ¡[.hl]<-[.hl]/2;[.hl]{7}<-tmp¡ ¡00101110¡2E ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡shra [.ix+d]¡tmp<-[.ix+d]{7} ¡- - 0 P 0 -¡11011101¡DD ¡4¡7¡ ¡ ¡C<-[.ix+d]{0} ¡ ¡11001011¡CB ¡ ¡ ¡ ¡ ¡[.ix+d]<-[.ix+d]/2 ¡ ¡<- d ->¡ ¡ ¡ ¡ ¡ ¡[.ix+d]{7}<-tmp ¡ ¡00101110¡2E ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡shra [.iy+d]¡tmp<-[.iy+d]{7} ¡- - 0 P 0 -¡11111101¡FD ¡4¡7¡ ¡ ¡C<-[.iy+d]{0} ¡ ¡11001011¡CB ¡ ¡ ¡ ¡ ¡[.iy+d]<-[.iy+d]/2 ¡ ¡<- d ->¡ ¡ ¡ ¡ ¡ ¡[.iy+d]{7}<-tmp ¡ ¡00101110¡2E ¡ ¡ ¡ ------------_----------------------------_-------------_--------_---_-_- The shl instruction and the shla instruction are exectly the same and use the same operand. <A.15 BRANCH INSTRUCTIONS 675> A.15 BRANCH INSTRUCTIONS Å------------\----------------------------\-------------\------------\-\-ã ¡MNEMONIC ¡ INSTRUCTION ACTION ¡ FLAGS ¡ OPCODE ¡ ¡ ¡ ¡ ¡ ¡ ---------\---¢ ¡ ¡ ¡ ¡ ¡S Z H P/v N C¡76543210¡HEX¡B¡C¡ -------------------------------------------------------------------------¢ ¡br nn ¡.pc<-nn ¡ ¡11000011¡C3 ¡3¡3¡ ¡ ¡ ¡ ¡<-nnl ->¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡<-nnh ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡bnz nn ¡if z=0 ¡ ¡11000010¡C2 ¡3¡3¡ ¡ ¡.pc<-nn ¡ ¡<-nnl ->¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡<-nnh ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡bz nn ¡if z=1 ¡ ¡11001010¡CA ¡3¡3¡ ¡ ¡.pc<-nn ¡ ¡<-nnl ->¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡<-nnh ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡bnc nn ¡if c=0 ¡ ¡11010010¡D2 ¡3¡3¡ ¡ ¡.pc<-nn ¡ ¡<-nnl ->¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡<-nnh ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡bc nn ¡if c=1 ¡ ¡11011010¡DA ¡3¡3¡ ¡ ¡.pc<-nn ¡ ¡<-nnl ->¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡<-nnh ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡bpo nn ¡if P/v=0 ¡ ¡11100010¡E2 ¡3¡3¡ ¡ ¡.pc<-nn ¡ ¡<-nnl ->¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡<-nnh ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡bpe nn ¡if P/v=1 ¡ ¡11101010¡EA ¡3¡3¡ ¡ ¡.pc<-nn ¡ ¡<-nnl ->¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡<-nnh ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡bp nn ¡if s=0 ¡ ¡11110010¡F2 ¡3¡3¡ ¡ ¡.pc<-nn ¡ ¡<-nnl ->¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡<-nnh ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡bm nn ¡if s=1 ¡ ¡11111010¡FA ¡3¡3¡ ¡ ¡ ¡ ¡<-nnl ->¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡<-nnh ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡br [.hl] ¡.pc<-.hl ¡ ¡11101001¡E9 ¡1¡1¡ -------------------------------------------------------------------------¢ ¡br [.ix] ¡.pc<-.ix ¡ ¡11011101¡DD ¡2¡2¡ ¡ ¡ ¡ ¡11101001¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡br [.iy] ¡.pc<-.iy ¡ ¡11111101¡FD ¡2¡2¡ ¡ ¡ ¡ ¡11101001¡ ¡ ¡ ¡ ------------_----------------------------_-------------_--------_---_-_- <676 APPENDIX A R800 INSTRUCTION CHART> Å------------\----------------------------\-------------\------------\-\-ã ¡MNEMONIC ¡ INSTRUCTION ACTION ¡ FLAGS ¡ OPCODE ¡ ¡ ¡ ¡ ¡ ¡ ---------\---¢ ¡ ¡ ¡ ¡ ¡S Z H P/v N C¡76543210¡HEX¡B¡C¡ -------------------------------------------------------------------------¢ ¡short ¡.pc<-.pc+e ¡ ¡00011000¡18 ¡2¡3¡ ¡br e ¡ ¡ ¡<- e-2->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡short ¡if z=0 ¡ ¡00100000¡20 ¡2¡2¡ ¡bnz e ¡.pc<-.pc+e ¡ ¡<- e-2->¡ ¡ ¡3¡ -------------------------------------------------------------------------¢ ¡short ¡if z=1 ¡ ¡00101000¡28 ¡2¡2¡ ¡bz e ¡.pc<-.pc+e ¡ ¡<- e-2->¡ ¡ ¡3¡ -------------------------------------------------------------------------¢ ¡short ¡if c=0 ¡ ¡00110000¡30 ¡2¡2¡ ¡bnc e ¡.pc<-.pc+e ¡ ¡<- e-2->¡ ¡ ¡3¡ -------------------------------------------------------------------------¢ ¡short ¡if c=1 ¡ ¡00111000¡38 ¡2¡2¡ ¡bc e ¡.pc<-.pc+e ¡ ¡<- e-2->¡ ¡ ¡3¡ -------------------------------------------------------------------------¢ ¡dbnz e ¡.b<-.b-1;if .b<>0 ¡ ¡00010000¡10 ¡2¡2¡ ¡ ¡.pc<-.pc+e ¡ ¡<- e-2->¡ ¡ ¡ ¡ ------------_----------------------------_-------------_--------_---_-_- A.16 CALL INSTRUCTIONS Å------------\----------------------------\-------------\------------\-\-ã ¡MNEMONIC ¡ INSTRUCTION ACTION ¡ FLAGS ¡ OPCODE ¡ ¡ ¡ ¡ ¡ ¡ ---------\---¢ ¡ ¡ ¡ ¡ ¡S Z H P/v N C¡76543210¡HEX¡B¡C¡ -------------------------------------------------------------------------¢ ¡call nn ¡[.sp-2]<-.spl;[.sp-1]<-.sph ¡ ¡11001101¡CD ¡3¡5¡ ¡ ¡.sp<-.sp-2;.pc<-nn ¡ ¡<-nnl ->¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡<-nnh ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡call nz,nn ¡if z=0 ¡ ¡11000100¡C4 ¡3¡3¡ ¡ ¡[.sp-2]<-.pcl;[.sp-1]<-.pch ¡ ¡<-nnl ->¡ ¡ ¡5¡ ¡ ¡.sp<-.sp-2;.pc<-nn ¡ ¡<-nnh ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡call z,nn ¡if z=1 ¡ ¡11001100¡CC ¡3¡3¡ ¡ ¡[.sp-2]<-.pcl;[.sp-1]<-.pch ¡ ¡<-nnl ->¡ ¡ ¡5¡ ¡ ¡.sp<-.sp-2;.pc<-nn ¡ ¡<-nnh ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡call nc,nn ¡if c=0 ¡ ¡11010100¡D4 ¡3¡3¡ ¡ ¡[.sp-2]<-.pcl;[.sp-1]<-.pch ¡ ¡<-nnl ->¡ ¡ ¡5¡ ¡ ¡.sp<-.sp-2;.pc<-nn ¡ ¡<-nnh ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡call c,nn ¡if c=1 ¡ ¡11011100¡DC ¡3¡3¡ ¡ ¡[.sp-2]<-.pcl;[.sp-1]<-.pch ¡ ¡<-nnl ->¡ ¡ ¡5¡ ¡ ¡.sp<-.sp-2;.pc<-nn ¡ ¡<-nnh ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡call po,nn ¡if P/v=0 ¡ ¡11100100¡E4 ¡3¡3¡ ¡ ¡[.sp-2]<-.pcl;[.sp-1]<-.pch ¡ ¡<-nnl ->¡ ¡ ¡5¡ ¡ ¡.sp<-.sp-2;.pc<-nn ¡ ¡<-nnh ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡call pe,nn ¡if P/v=1 ¡ ¡11101100¡EC ¡3¡3¡ ¡ ¡[.sp-2]<-.pcl;[.sp-1]<-.pch ¡ ¡<-nnl ->¡ ¡ ¡5¡ ¡ ¡.sp<-.sp-2;.pc<-nn ¡ ¡<-nnh ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡call p,nn ¡if s=0 ¡ ¡11110100¡F4 ¡3¡3¡ ¡ ¡[.sp-2]<-.pcl;[.sp-1]<-.pch ¡ ¡<-nnl ->¡ ¡ ¡5¡ ¡ ¡.sp<-.sp-2;.pc<-nn ¡ ¡<-nnh ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡call m,nn ¡if s=1 ¡ ¡11111100¡FC ¡3¡3¡ ¡ ¡[.sp-2]<-.pcl;[.sp-1]<-.pch ¡ ¡<-nnl ->¡ ¡ ¡5¡ ¡ ¡.sp<-.sp-2;.pc<-nn ¡ ¡<-nnh ->¡ ¡ ¡ ¡ ------------_----------------------------_-------------_--------_---_-_- <A.16 CALL INSTRUCTIONS 677 Å------------\----------------------------\-------------\------------\-\-ã ¡MNEMONIC ¡ INSTRUCTION ACTION ¡ FLAGS ¡ OPCODE ¡ ¡ ¡ ¡ ¡ ¡ ---------\---¢ ¡ ¡ ¡ ¡ ¡S Z H P/v N C¡76543210¡HEX¡B¡C¡ -------------------------------------------------------------------------¢ ¡ret ¡.pcl<-[.sp];.pch<-[.sp+1] ¡ ¡11001001¡C9 ¡1¡3¡ ¡ ¡.sp<-.sp+2 ¡ ¡ ¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡ret nz ¡if z=0 ; .pcl<-[.sp] ¡ ¡11000000¡C0 ¡1¡1¡ ¡ ¡.pch<-.[.sp+1];.sp<-.sp+2 ¡ ¡ ¡ ¡ ¡3¡ -------------------------------------------------------------------------¢ ¡ret z ¡if z=1 ; .pcl<-[.sp] ¡ ¡11001000¡C8 ¡1¡1¡ ¡ ¡.pch<-.[.sp+1];.sp<-.sp+2 ¡ ¡ ¡ ¡ ¡3¡ -------------------------------------------------------------------------¢ ¡ret nc ¡if c=0 ; .pcl<-[.sp] ¡ ¡11010000¡D0 ¡1¡1¡ ¡ ¡.pch<-.[.sp+1];.sp<-.sp+2 ¡ ¡ ¡ ¡ ¡3¡ -------------------------------------------------------------------------¢ ¡ret c ¡if c=1 ; .pcl<-[.sp] ¡ ¡11011000¡D8 ¡1¡1¡ ¡ ¡.pch<-.[.sp+1];.sp<-.sp+2 ¡ ¡ ¡ ¡ ¡3¡ -------------------------------------------------------------------------¢ ¡ret po ¡if P/v=0 ; .pcl<-[.sp] ¡ ¡11100000¡E0 ¡1¡1¡ ¡ ¡.pch<-.[.sp+1];.sp<-.sp+2 ¡ ¡ ¡ ¡ ¡3¡ -------------------------------------------------------------------------¢ ¡ret pe ¡if P/v=1 ; .pcl<-[.sp] ¡ ¡11101000¡E8 ¡1¡1¡ ¡ ¡.pch<-.[.sp+1];.sp<-.sp+2 ¡ ¡ ¡ ¡ ¡3¡ -------------------------------------------------------------------------¢ ¡ret p ¡if s=0 ; .pcl<-[.sp] ¡ ¡11110000¡F0 ¡1¡1¡ ¡ ¡.pch<-.[.sp+1];.sp<-.sp+2 ¡ ¡ ¡ ¡ ¡3¡ -------------------------------------------------------------------------¢ ¡ret m ¡if s=1 ; .pcl<-[.sp] ¡ ¡11111000¡F8 ¡1¡1¡ ¡ ¡.pch<-.[.sp+1];.sp<-.sp+2 ¡ ¡ ¡ ¡ ¡3¡ -------------------------------------------------------------------------¢ ¡ret i ¡interrupt return ¡ ¡11101101¡ED ¡2¡5¡ ¡ ¡ ¡ ¡01001101¡4D ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡ret n ¡Non Maskable Interrupt ¡ ¡11101101¡ED ¡2¡5¡ ¡ ¡ return ¡ ¡01000101¡45 ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡brk k ¡[.sp-2]<-.pcl;[.sp-1]<-.pch ¡ ¡11 111¡C0 ¡1¡4¡ ¡ ¡.sp<-.sp-2;.pcl<-k;pch<-0 ¡ ¡ k/8 ¡ ¡ ¡ ¡ ------------_----------------------------_-------------_--------_---_-_- <678 APPENDIX A R800 INSTRUCTION CHART> A.17 INOUT/OUTPUT INSTRUCTIONS Å------------\----------------------------\-------------\------------\-\-ã ¡MNEMONIC ¡ INSTRUCTION ACTION ¡ FLAGS ¡ OPCODE ¡ ¡ ¡ ¡ ¡ ¡ ---------\---¢ ¡ ¡ ¡ ¡ ¡S Z H P/v N C¡76543210¡HEX¡B¡C¡ -------------------------------------------------------------------------¢ ¡in .a,[n] ¡.a<-[n] ¡ ¡11011011¡DB ¡2¡3¡ ¡ ¡ ¡ ¡<- n ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡in r,[.c] ¡r<-[.c] ¡- - 0 P 0 ¡11101101¡ED ¡2¡3¡ ¡ ¡ ¡ ¡01 r 000¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡in .f,[.c] ¡.f<-[.c] ¡- - 0 P 0 ¡11101101¡ED ¡2¡3¡ ¡ ¡ ¡ ¡01110000¡70 ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡in ¡[.hl]<-[.c];.b<-.b-1 ¡? - ? ? 1 ¡11101101¡ED ¡2¡4¡ ¡[.hl++],[.c]¡.hl<-.hl+1 ¡ *1 ¡10100010¡A2 ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡in ¡[.hl]<-[.c];.b<-.b-1 ¡? - ? ? 1 ¡11101101¡ED ¡2¡4¡ ¡[.hl--],[.c]¡.hl<-.hl-1 ¡ *1 ¡10101010¡AA ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡inm ¡repeat;[.hl]<-[.c];.b<-.b-1 ¡? 1 ? ? 1 ¡11101101¡ED ¡2¡4¡ ¡[.hl++],[.c]¡.hl<-.hl+1;until .b=0 ¡ ¡10110010¡B2 ¡ ¡3¡ -------------------------------------------------------------------------¢ ¡inm ¡repeat;[.hl]<-[.c];.b<-.b-1 ¡? 1 ? ? 1 ¡11101101¡ED ¡2¡4¡ ¡[.hl--],[.c]¡.hl<-.hl-1;until .b=0 ¡ ¡10111010¡BA ¡ ¡3¡ -------------------------------------------------------------------------¢ ¡out [n],.a ¡[n]<-.a ¡ ¡11010011¡D3 ¡2¡3¡ ¡ ¡ ¡ ¡<- n ->¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡out [.c],r ¡[.c]<-r ¡ ¡11101101¡ED ¡2¡3¡ ¡ ¡ ¡ ¡01 r 001¡ ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡out ¡[.c]<-[.hl];.b<-.b-1 ¡? - ? ? 1 ¡11101101¡ED ¡2¡4¡ ¡[.c],[.hl++]¡.hl<-.hl+1 ¡ *1 ¡10100011¡A3 ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡out ¡[.c]<-[.hl];.b<-.b-1 ¡? - ? ? 1 ¡11101101¡ED ¡2¡4¡ ¡[.c],[.hl--]¡.hl<-.hl-1 ¡ *1 ¡10101011¡AB ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡outm ¡repeat;[.c]<-[.hl];.b<-.b-1 ¡? 1 ? ? 1 ¡11101101¡ED ¡2¡4¡ ¡[.c],[.hl++]¡.hl<-.hl+1;until .b=0 ¡ ¡10110011¡B3 ¡ ¡3¡ -------------------------------------------------------------------------¢ ¡outm ¡repeat;[.c]<-[.hl];.b<-.b-1 ¡? 1 ? ? 1 ¡11101101¡ED ¡2¡4¡ ¡[.c],[.hl--]¡.hl<-.hl-1;until .b=0 ¡ ¡10111011¡BB ¡ ¡3¡ ------------_----------------------------_-------------_--------_---_-_- *1 als .b-1=0 it is set to 1 else it is 0 dependent of the external port which the .c register of in.f,[.c] desginates, flags will be changed. It doesn't matter where the external port is.(???) <A.18 CPU CONTROL INSTRUCTIONS 679> A.18 CPU CONTROL INSTRUCTIONS Å------------\----------------------------\-------------\------------\-\-ã ¡MNEMONIC ¡ INSTRUCTION ACTION ¡ FLAGS ¡ OPCODE ¡ ¡ ¡ ¡ ¡ ¡ ---------\---¢ ¡ ¡ ¡ ¡ ¡S Z H P/v N C¡76543210¡HEX¡B¡C¡ -------------------------------------------------------------------------¢ ¡adj .a ¡adjust to decimal ¡- - - P -¡00100111¡27 ¡1¡1¡ -------------------------------------------------------------------------¢ ¡not .a ¡.a<-NOT .a ¡ 1 1 ¡00101111¡2F ¡1¡1¡ -------------------------------------------------------------------------¢ ¡neg .a ¡.a<-NOT .a+1 ¡- - - V 1 -¡11101101¡ED ¡2¡2¡ ¡ ¡ ¡ ¡01000100¡44 ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡not c ¡C<-NOT C ¡ ? 0 -¡00111111¡3F ¡1¡1¡ -------------------------------------------------------------------------¢ ¡set c ¡C<-1 ¡ 0 0 1¡00110111¡37 ¡1¡1¡ -------------------------------------------------------------------------¢ ¡nop ¡NO operation ¡ ¡00000000¡00 ¡1¡1¡ -------------------------------------------------------------------------¢ ¡halt ¡HALT ¡ ¡01110110¡76 ¡1¡2¡ -------------------------------------------------------------------------¢ ¡di ¡IFF<-0 ¡ ¡11110011¡F3 ¡1¡2¡ -------------------------------------------------------------------------¢ ¡ei ¡IFF<-1 ¡ ¡11111011¡FB ¡1¡1¡ -------------------------------------------------------------------------¢ ¡im 0 ¡interrupt mode 0 ¡ ¡11101101¡ED ¡2¡3¡ ¡ ¡ ¡ ¡01000110¡46 ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡im 1 ¡interrupt mode 1 ¡ ¡11101101¡ED ¡2¡3¡ ¡ ¡ ¡ ¡01010110¡56 ¡ ¡ ¡ -------------------------------------------------------------------------¢ ¡im 2 ¡interrupt mode 2 ¡ ¡11101101¡ED ¡2¡3¡ ¡ ¡ ¡ ¡01011110¡5E ¡ ¡ ¡ ------------_----------------------------_-------------_--------_---_-_- <680 > <681 > ------------------------------------------------------------------------ B R800 MULTIPLICATION MACRO ------------------------------------------------------------------------ B.1 MULTIPLICATION INSTRUCTIONS OF THE R800 The following multiplication instructions are available. B.1.1 8 bit MULTIPLICATIONS Two of the same kind 8 bit registers are filled and the result appears in register HL. The multiplication is performed with an instruction. The instruction are shown below. ---------------------------------------------------------------------------- operation instruction clock cycles ---------------------------------------------------------------------------- HL<-A*B ED C1 14 HL<-A*C ED C9 14 HL<-A*D ED D1 14 HL<-A*E ED D9 14 --------------------------------------------------------------------------- B.1.2 16 bit MULTIPLICATIONS Two of the same kind 16 bit registers are filled and the result appears in registers DE:HL. The multiplication is performed with an instruction. The instruction are shown below. ---------------------------------------------------------------------------- operation instruction clock cycles ---------------------------------------------------------------------------- DE:HL<-HL*BC ED C3 36 DE:HL<-HL*SP ED F3 36 ---------------------------------------------------------------------------- <682 APPENDIX A R800 INSTRCUCTION CHART> B.2 MULTIPLICATION MACRO FOR M80 When using multiplications in M80, this macro can be used. mult8 macro reg ifidn <reg>,<b> defb 0edh,0c1h else ifidn <reg>,<B> defb 0edh,0c1h else ifidn <reg>,<c> defb 0edh,0c9h else ifidn <reg>,<C> defb 0edh,0c9h else ifidn <reg>,<d> defb 0edh,0d1h else ifidn <reg>,<D> defb 0edh,0d1h else ifidn <reg>,<e> defb 0edh,0d9h else ifidn <reg>,<E> defb 0edh,0d9h else if1 .printx *MULT8: illegal argument* defb 00h,00h err endif endif endif endif endif endif endif endif endif endm mult16 macro reg ifidn <reg>,<bc> defb 0edh, 0c3h else ifidn <reg>,<BC> defb 0edh,0c3h else <B.2 MULTIPLICATION MACRO FOR M80 683> ifidn <reg>,<sp> defb 0edh, 0f3h else ifidn <reg>,<SP> defb 0edh,0f3h else if1 .printx *MULT16: illegal argument* defb 00h, 00h err end if end if end if end if end if endm <684 > < 685> |