Skip to main content
1 of 2
matja
  • 606
  • 4
  • 5

You can rephrase it by saying how to multiply by the reciprocal of 3 which is binary 0.01010101(..)

You can calculate a*01010110 (rounding up to handle exact multiples) and then return the high byte.

Z80 code to divide a by 3:

 ld b,0 ld c,$56 ld hl,0 ld e,8 loop: rra jr nc, skip add hl,bc skip: sla c rl b or a jr nz, loop ld a,h 
matja
  • 606
  • 4
  • 5