Karoshi MSX Community
05 de Julio de 2021, 10:47:48 am *
Bienvenido(a), Visitante. Por favor, ingresa o regístrate.

Ingresar con nombre de usuario, contraseña y duración de la sesión
Noticias:
 
   Inicio   Ayuda Buscar Ingresar Registrarse  
Páginas: [1]
  Imprimir  
Autor Tema: Mask / merge two bytes  (Leído 5740 veces)
0 Usuarios y 1 Visitante están viendo este tema.
theNestruo
Karoshi Lover
***
Mensajes: 236


Email
« : 18 de Octubre de 2013, 06:38:14 pm »

Hi!

Don't know if reinventing the wheel but...

Código:
; Overwrites [hl] with a, but only the bits specified by b.
; i.e.: [hl] = a = ([hl] & not(b)) | (a & b)
; param hl: destination address
; param a: value to set
; param b: mask
; return a: value set
LD_HL_A_WITH_MASK:
    xor [hl]
    and b
    xor [hl]    ; ...15 tstates, 3 bytes
    ld  [hl], a ; ...23 tstates, 4 bytes (remove if not needed)
    ret         ; ...34 tstates, 5 bytes

If the mask is and known at compile time, and b can be replaced by and $nn.

And, of course, the original value can be accesed through [ix+n] or [iy+n] instead of [hl]. Or be in a register (c, d, e) instead of RAM.
« Última modificación: 18 de Octubre de 2013, 07:03:04 pm por theNestruo » En línea

theNestruo."Old BASIC programmers never die; they GOSUB but never RETURN."
Páginas: [1]
  Imprimir  
 
Ir a:  

Impulsado por MySQL Impulsado por PHP Powered by SMF 1.1.21 | SMF © 2013, Simple Machines XHTML 1.0 válido! CSS válido!