The SingleBit function
    (Source code written in GFA-Basic 32)
Function SingleBit(ByVal bs As Int64) As Int32

  . mov edx, dpt bs[4]
  . cmp edx, 0
  . je  .LoBits
  . bsr eax, edx
  . btr edx, eax
  . cmp edx, 0
  . jne .NoSolution
  . mov edx, dpt bs[0]
  . cmp edx, 0
  . jne .NoSolution
  . add eax, 33
  . mov dpt SingleBit[0], eax
Return

  .LoBits:
  . mov edx, dpt bs[0]
  . cmp edx, 0
  . je  .NoSolution
  . bsr eax, edx
  . btr edx, eax
  . cmp edx, 0
  . jne .NoSolution
  . add eax, 1
  . mov dpt SingleBit[0], eax
Return

  .NoSolution:
  . mov dpt SingleBit[0], 0
Return

End Func

Back to Methods for calculating SM           Walter Trump, Nürnberg, Germany, (c) 2014-06-06