Título: Mask / merge two bytes Publicado por: theNestruo en 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. |