home *** CD-ROM | disk | FTP | other *** search
/ PC Shareware 1996 December / PC_Shareware-1996-12.iso / windows / spectrum / sources / z80 / ld16bits.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-16  |  4.5 KB  |  134 lines

  1. /* Ld16Bits.c: Z80 16 bit load instructions.
  2.  *
  3.  * Copyright 1996 Rui Fernando Ferreira Ribeiro.
  4.  *
  5.  * This program is free software; you can redistribute it and/or modify
  6.  * it under the terms of the GNU General Public License as published by
  7.  * the Free Software Foundation; either version 2 of the License, or
  8.  * (at your option) any later version.
  9.  *
  10.  * This program is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  * GNU General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this program; if not, write to the Free Software
  17.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  */
  19.  
  20. /*
  21.  *      History:
  22.  *      5th April 96:
  23.  *              Added new IX/IY logic.
  24.  */
  25.  
  26. #include "env.h"
  27.  
  28. /*=========================================================================*
  29.  *                            ld_dd_nn                                     *
  30.  *=========================================================================*/
  31.  
  32. #define ld_dd_nn(dd,TS) { T(TS); dd=Getnextword(); }
  33.  
  34. void ld_bc_nn() ld_dd_nn(BC, 10);
  35. void ld_de_nn() ld_dd_nn(DE, 10);
  36. void ld_hl_nn() ld_dd_nn(HL, 10);
  37. void ld_ix_nn() ld_dd_nn(IX, 14);
  38. void ld_iy_nn() ld_dd_nn(IY, 14);
  39. void ld_sp_nn() ld_dd_nn(SP, 10);
  40.  
  41. #undef ld_dd_nn
  42.  
  43. /*=========================================================================*
  44.  *                            ld_dd_pnn                                    *
  45.  *=========================================================================*/
  46.  
  47. #define ld_dd_pnn(dd, TS) { T(TS); dd=readword(Getnextword() ); }
  48.  
  49. void ld_hl_pnn() ld_dd_pnn(HL, 16);
  50. void ld_ix_pnn() ld_dd_pnn(IX, 20);
  51. void ld_iy_pnn() ld_dd_pnn(IY, 20);
  52. void ld_bc_pnn() ld_dd_pnn(BC, 20);
  53. void ld_de_pnn() ld_dd_pnn(DE, 20);
  54. void ld_sp_pnn() ld_dd_pnn(SP, 20);
  55. void ld_hl_pnnED() ld_dd_pnn(HL, 20);
  56. #undef ld_dd_pnn
  57.  
  58. /*=========================================================================*
  59.  *                            ld_pnn_dd                                    *
  60.  *=========================================================================*/
  61.  
  62. #define ld_pnn_dd(dd, TS) { T(TS); writeword(Getnextword(), dd); }
  63.  
  64. void ld_pnn_hl() ld_pnn_dd(HL, 16);
  65. void ld_pnn_ix() ld_pnn_dd(IX, 20);
  66. void ld_pnn_iy() ld_pnn_dd(IY, 20);
  67. void ld_pnn_bc() ld_pnn_dd(BC, 20);
  68. void ld_pnn_de() ld_pnn_dd(DE, 20);
  69. void ld_pnn_sp() ld_pnn_dd(SP, 20);
  70. void ld_pnn_hlED() ld_pnn_dd(HL, 20);
  71.  
  72. #undef ld_pnn_dd
  73.  
  74. #define ld_sp_dd(dd, TS) { T(TS); SP = dd; }
  75. /*=========================================================================*
  76.  *                            ld_sp_hl                                     *
  77.  *=========================================================================*/
  78. void ld_sp_hl() ld_sp_dd(HL, 6);
  79.  
  80. /*=========================================================================*
  81.  *                            ld_sp_ix                                     *
  82.  *=========================================================================*/
  83. void ld_sp_ix() ld_sp_dd(IX, 10);
  84.  
  85. /*=========================================================================*
  86.  *                            ld_sp_iy                                     *
  87.  *=========================================================================*/
  88. void ld_sp_iy() ld_sp_dd(IY, 10);
  89.  
  90. #undef ld_sp_dd
  91.  
  92. /*=========================================================================*
  93.  *                            push_qq                                      *
  94.  *=========================================================================*/
  95.  
  96. #define push_qq(R, TS) { T(TS); push(R); }
  97.  
  98. void push_bc() push_qq(BC, 11);
  99. void push_de() push_qq(DE, 11);
  100. void push_hl() push_qq(HL, 11);
  101. void push_ix() push_qq(IX, 15);
  102. void push_iy() push_qq(IY, 15);
  103. void push_af()
  104. {
  105.     T(11);
  106.     build_F();
  107.     push(AF);
  108. }
  109.  
  110. #undef push_qq
  111.  
  112. /*=========================================================================*
  113.  *                            pop_qq                                       *
  114.  *=========================================================================*/
  115.  
  116. #define pop_qq(r, TS) { T(TS); (r) = pop(); }
  117.  
  118. void pop_bc() pop_qq(BC, 10);
  119. void pop_de() pop_qq(DE, 10);
  120. void pop_hl() pop_qq(HL, 10);
  121. void pop_ix() pop_qq(IX, 14);
  122. void pop_iy() pop_qq(IY, 14);
  123.  
  124. void pop_af()
  125. {
  126.     T(10);
  127.     AF = pop();
  128.     read_F();
  129. }
  130.  
  131. #undef pop_qq
  132.  
  133. /* EOF : Ld16Bits.c */
  134.