Change STOP byte count to 1

Abierto
#31 8 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
42/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado

Línea de trabajo

Localiza la entrada del opcode STOP en el repositorio e inspecciona cómo se representan los recuentos de bytes y M-cycle. Usa el comportamiento de STOP y wakeup indicado en el issue y, a continuación, elige y aplica una de las dos resoluciones mencionadas; se considera terminado cuando la entrada refleja ese comportamiento de forma coherente.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

It doesn't make sense to have a 2-byte instruction which takes 1 M-cycle, as that's impossible to actually achieve on the CPU in any way (yes, that even includes ADD HL, r16, as it does ALU operation on both M-cycles, lower half first, then upper half in the second cycle).

There are two ways to solve this issue:

  • make it 1B 1M, as that's what it actually is
  • keep it as 2B, but make it 32769M (execution of STOP takes a single M-cycle, and wakeup from STOP mode fetches the next instruction on the 32768th cycle)

And yes, STOP is actually a single byte opcode, which can be observed when STOP fails to stop due to a button being held.
The short explaination of why STOP consumes two bytes can be summarized in these points:

  • PC is always one byte ahead of the currently executed instruction
  • if STOP enters stop mode, it fetches the next opcode, incrementing PC (PC points to STOP +2)
  • the fetched opcode is discarded, and replaced with NOP
  • on wakeup, the NOP fetches the instruction at STOP +2, and executes it in the next cycle
    More details can be found here.

The reason HALT does not consume two bytes is because PC is not incremented when HALT fetches the next opcode, but otherwise works similar to STOP. More details here.

Lenguaje dominante
SCSS
Estrellas
29
Forks
10
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de gbdev/gb-opcodes

Todos los issues de gbdev/gb-opcodes

Issues similares

Más issues de Documentation

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.