Conditional RST for Z80 Author OKUMURA N. Shin-ya English corrected by JGH Abstract Z80 is a 8bit micro-processor by Zilog, frequently used several years ago. However it seems old fashoned now, it is important one as education of MPU. I studied the method to do RST 38h with conditions. 1.Introduction Z80 was a widely used CPU in the 1970s to 1980s, but now it is commonly used as a micro controller. It has 8 interrupt vectors in interrupt mode zero, one vector in interrupt mode 1 and 256 vectors interrupt mode 2. In mode 0 the vectors are 0000h, 0008h, 0010h, 0018h, 0020h, 0028h, 0030h and 0038h. In mode 1, 0038h only. In mode 3 the vectors are determined with I register and data from I/O. 0038h is especially important. 0038h is the vector address in both mode 0 and 1. Additionally, for instance with the PC-8801's 0038h is the gate to BASIC's MON command, with the MSX 0038h a the unique vector because MSX use INT mode 1. I studied RST 38h for this reason. 2.Study The ordinary method for Z80 programmers to use RST 38h with a condition is as follows: JR Ncondition, LABEL RST 38h LABEL: ... For example, to do RST 38h if carry set, use: JR NC, L01 RST 38h L01: RET ; No work... But I can write it shorter, in only two bytes. I write it as follow: JR condition, -1 ; -1 == FFh JR is a relative (-128 to +127) jump with a condition and is a two byte Z80 instruction. RST 38h is coded as 'FFh' and the distance -1 is also coded as 'FFh'. The short jump of the JR is executed after the PC has been incremented, as follows: [JR C, -1] PC+=2; /* JR is 2 byte. */ if(C) PC-=1; /* See below */ If carry is set, the PC will be at the address of the JR +1 (+2-1). At that location the next byte is the 'FFh' of the jump offset. This is executed as a RST 38h. This is the Z80's conditioned RST 38h.