home *** CD-ROM | disk | FTP | other *** search
/ Dream 55 / Amiga_Dream_55.iso / RISCOS / MAGAZINE / NEWS / PCE021.ZIP / Pce021 / Src / cpu / s / stack < prev    next >
Text File  |  1998-02-26  |  1KB  |  93 lines

  1. ;    stack.s
  2. ;    -------
  3. ;    Stack opcodes
  4.  
  5.  
  6.     GET    hdr.common
  7.     GET    hdr.memory
  8.  
  9.  
  10.     GBLS    value
  11.     GBLS    r_p_temp
  12.  
  13.  
  14. ;    Push specified register onto stack
  15.     MACRO
  16.     m_push    $push_reg
  17.     NEW    value
  18.     mov    $value, $push_reg, lsr #24
  19.     write_byte_sp $value
  20.     DELETE    value
  21.     MEND
  22. ;    Push flags onto stack
  23.     MACRO
  24.     m_push_p
  25.     write_byte_sp r_p
  26.     MEND
  27.  
  28. ;    Pull specified register from stack
  29.     MACRO
  30.     m_pull    $pull_reg
  31.     read_byte_sp $pull_reg
  32.     bic    r_p, r_p, #N_FLAG + Z_FLAG
  33.     movs    $pull_reg, $pull_reg, lsl #24
  34.     orreq    r_p, r_p, #Z_FLAG
  35.     orrmi    r_p, r_p, #N_FLAG
  36.     MEND
  37. ;    Pull flags from stack
  38.     MACRO
  39.     m_pull_p
  40.     NEW    r_p_temp
  41.     read_byte_sp $r_p_temp
  42.     bic    r_p, r_p, #0xff
  43.     orr    r_p, r_p, $r_p_temp
  44.     bic    r_p, r_p, #T_FLAG        ; *****
  45.     tst    r_p, #I_FLAG                ; check restored I_FLAG
  46.     orreq    r_p, r_p, #0x80 << 16
  47.     orrne    r_p, r_p, #0x80 << 16            ; update internal IRQ enable bit
  48.     DELETE    r_p_temp
  49.     MEND
  50.  
  51.  
  52.     AREA    |cpu$$opcodes|, CODE, READONLY
  53.  
  54.  
  55.     IMPORT    Next_Opcode
  56.  
  57.  
  58.     DEF_OPCODE pha
  59.     m_push    r_a
  60.     END_OPCODE
  61.  
  62.     DEF_OPCODE php
  63.      m_push_p
  64.     END_OPCODE
  65.  
  66.     DEF_OPCODE phx
  67.     m_push    r_x
  68.     END_OPCODE
  69.  
  70.     DEF_OPCODE phy
  71.     m_push    r_y
  72.     END_OPCODE
  73.  
  74.  
  75.     DEF_OPCODE pla
  76.      m_pull    r_a
  77.     END_OPCODE
  78.  
  79.     DEF_OPCODE plp
  80.      m_pull_p
  81.     END_OPCODE
  82.  
  83.     DEF_OPCODE plx
  84.      m_pull    r_x
  85.     END_OPCODE
  86.  
  87.     DEF_OPCODE ply
  88.      m_pull    r_y
  89.     END_OPCODE
  90.  
  91.  
  92.     END
  93.