From WikiTI
Jump to: navigation, search


Official Name: BigNumCompare

BCALL Address: 801E

Checks to see if two large integers are equal.


  • HL: Address of first integer to compare.
  • DE: Address of second integer to compare.


  • Zero Flag: Set if integers are equal


  • HL,DE,A


This B_CALL compares two big integers. This BCALL is used by the OS in its digital signature verification routines to compare the computed MD5 against the decrypted signature.

The BCALL can actually be used to compare any two data structures in RAM such as strings, but must follow the large integer format that the OS uses in its verification routines. The first byte must be the length of the integer in bytes. After the size byte, the number is listed in little endian form.


Suppose the contents of RAM were as follows:

8100h: 04 12 34 56 78

8105h: 04 AA BB CC DD

810Ah: 03 12 34 56 78

The large integer stored at 8100h is the integer 78563412h and the integer stored at 8105h is the integer DDCCBBAAh. Below is code to compare the integers above.

 ld  hl,8100h
 ld  de,8105h
 B_CALL BigNumCompare ;should return nz
 ld  hl,8100h
 ld  de,810Ah
 B_CALL BigNumCompare ;should return z