It is currently Sun Jan 20, 2019 12:13 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Mon Oct 15, 2018 5:33 pm 
Offline
User avatar

Joined: Mon Apr 13, 2015 7:52 am
Posts: 7
i see opcode halt about http://www.devrs.com/gb/files/faqs.html#HALT

There is such a description.
------------------------------------------------------------------------------
HALT operates differently depending on whether the Interrupt Master Enable (IME) is set or reset.
Assembly command EI sets IME to 1.
Assembly command DI resets IME to 0.
IME = 0 - [$ff0f].AND.[$ffff] = 0 :
HALT is aborted. Next instruction is executed normally.
If IME is set to 1 at a later time then a halt condition
will occur one instruction after IME is set to 1 to complete
the halt that was not allowed to finish earlier.
------------------------------------------------------------------------------
If the description is correct... emm..

At IME=0, [$ff0f].AND.[$ffff] = = 0
If DMG executes halt, it will not cause a pause.
In this case, DMG will continue to execute instructions after halt?


Top
 Profile  
 
PostPosted: Fri Jan 04, 2019 6:31 pm 
Offline
User avatar

Joined: Fri Jan 04, 2019 5:31 pm
Posts: 16
Location: France, right of a pile of consoles
That's incorrect. The correct behavior of HALT is as follows:
  • If IME == 1:
    Execution is paused until IE & IF & $1F != 0
  • If IME == 0:
    • If IE & IF & $1F == 0:
      Execution is paused until IE & IF & $1F != 0, after which execution resumes normally.
      This is basically the same as IME = 1, but the interrupt handler is not called.
    • If IE & IF & $1F != 0:
      Execution doesn't pause, but the byte after the HALT is read twice (PC fails to increment).
      This would cause single-byte instructions to be simply repeated (such as `dec a`), and multi-byte instructions will read the opcode again as the first operand byte, and the last operand byte will be executed as an opcode. (Example: `ld a, $AF` = `3E AF` will turn into `3E 3E AF` = `ld a, $3E ; xor a`)

According to beware (BGB's developer), the game The Smurfs relies on the latter behavior, whereas this emulator detection code I've written relies on the former. (Note that this code only passes on GBA's, and relies on dodgy HDMA behavior for the most part)

_________________
The French Lord of Laziness (and a huge Legend of Zelda fan)
https://github.com/ISSOtm
ASMu is laifu <3


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group