@@ -15,6 +15,7 @@ struct hyperstone_device::compiler_state
15
15
16
16
const uint8_t m_mode;
17
17
uml::code_label m_labelnum = 1 ;
18
+ uint8_t m_check_delay = 1 ;
18
19
};
19
20
20
21
@@ -260,6 +261,7 @@ void hyperstone_device::code_compile_block(uint8_t mode, offs_t pc)
260
261
UML_MOV (block, I7, 0 );
261
262
262
263
/* iterate over instructions in the sequence and compile them */
264
+ compiler.m_check_delay = 1 ;
263
265
for (const opcode_desc *curdesc = seqhead; curdesc != seqlast->next (); curdesc = curdesc->next ())
264
266
{
265
267
generate_sequence_instruction (block, compiler, curdesc);
@@ -759,10 +761,46 @@ void hyperstone_device::generate_sequence_instruction(drcuml_block &block, compi
759
761
760
762
if (!(desc->flags & OPFLAG_VIRTUAL_NOOP))
761
763
{
764
+ if (compiler.m_check_delay == 1 )
765
+ {
766
+ // if PC is used in a delay instruction, the delayed PC should be used
767
+ const int nodelay = compiler.m_labelnum ++;
768
+ const int done = compiler.m_labelnum ++;
769
+ UML_TEST (block, mem (&m_core->delay_slot ), 1 );
770
+ UML_JMPc (block, uml::COND_Z, nodelay);
771
+ UML_MOV (block, DRC_PC, mem (&m_core->delay_pc ));
772
+ UML_MOV (block, mem (&m_core->delay_slot ), 0 );
773
+ UML_MOV (block, mem (&m_core->delay_slot_taken ), 1 );
774
+ UML_JMP (block, done);
775
+ UML_LABEL (block, nodelay);
776
+ UML_ADD (block, DRC_PC, DRC_PC, desc->length );
777
+ UML_MOV (block, mem (&m_core->delay_slot_taken ), 0 );
778
+ UML_LABEL (block, done);
779
+ }
780
+ else
781
+ {
782
+ UML_ADD (block, DRC_PC, DRC_PC, desc->length );
783
+ UML_MOV (block, mem (&m_core->delay_slot_taken ), 0 );
784
+ }
785
+
762
786
// compile the instruction
763
- if (!generate_opcode (block, compiler, desc))
787
+ if (generate_opcode (block, compiler, desc))
788
+ {
789
+ if (compiler.m_check_delay )
790
+ {
791
+ if (compiler.m_check_delay == 1 )
792
+ {
793
+ UML_TEST (block, mem (&m_core->delay_slot_taken ), ~uint32_t (0 ));
794
+ UML_CALLHc (block, uml::COND_NZ, *m_delay_taken[compiler.m_mode ]);
795
+ }
796
+ --compiler.m_check_delay ;
797
+ }
798
+
799
+ if (BIT (compiler.m_mode , 1 ) && !desc->delayslots )
800
+ UML_EXHc (block, uml::COND_Z, *m_exception, EXCEPTION_TRACE);
801
+ }
802
+ else
764
803
{
765
- UML_MOV (block, DRC_PC, desc->pc );
766
804
UML_MOV (block, mem (&m_core->arg0 ), desc->opptr .w [0 ]);
767
805
UML_CALLC (block, &c_funcs::unimplemented, this );
768
806
}
@@ -775,8 +813,6 @@ bool hyperstone_device::generate_opcode(drcuml_block &block, compiler_state &com
775
813
{
776
814
uint32_t op = (uint32_t )desc->opptr .w [0 ];
777
815
778
- UML_ADD (block, DRC_PC, DRC_PC, 2 );
779
-
780
816
switch (op >> 8 )
781
817
{
782
818
case 0x00 : generate_chk<GLOBAL, GLOBAL>(block, compiler, desc); break ;
@@ -1039,14 +1075,5 @@ bool hyperstone_device::generate_opcode(drcuml_block &block, compiler_state &com
1039
1075
1040
1076
UML_ROLINS (block, DRC_SR, ((desc->length >> 1 ) << ILC_SHIFT) | P_MASK, 0 , ILC_MASK | P_MASK);
1041
1077
1042
- UML_TEST (block, mem (&m_core->delay_slot_taken ), ~uint32_t (0 ));
1043
- UML_CALLHc (block, uml::COND_NZ, *m_delay_taken[compiler.m_mode ]);
1044
-
1045
- if (BIT (compiler.m_mode , 1 ))
1046
- {
1047
- UML_TEST (block, mem (&m_core->delay_slot ), 1 );
1048
- UML_EXHc (block, uml::COND_Z, *m_exception, EXCEPTION_TRACE);
1049
- }
1050
-
1051
1078
return true ;
1052
1079
}
0 commit comments