Re: A82: Help


[Prev][Next][Index][Thread]

Re: A82: Help




>  ld a,b
>  ld b,32
>  cp b \ jr c,Done
>  ld b,64
>  cp b \ jr c,Done
>  ret
>
>That's 12 bytes. I hope someone can beat that. I thought I did for a while 
>with this code, but if you look carefully you'll see it doesn't exactly do 
>the same thing. If you want to challenge yourself, take a look and see if 
>you can figure out why they are different:
>
>  ld a,32
>  cp b \ jr nc,ldba
>  add a,a
>  cp b \ ret c
>ldba:
>  ld b,a
>  jr Done


  The first routines says:
     If B<32, then B=32
     If B<64, then B=64

  The second one says:
     If B < or = 32, then B=32
     If B < or = 64, then B=64

If B = 32, then
  #1 says B = 64
  #2 says B = 32

If B = 32, then
  #1 says B = 64
  #2 says B = 32

If B = 64, then
  #1 says B = nothing
  #2 says B = 64

  #2 seems more logical if you are rounding, but whatever.
  Sam


______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com