83Plus:BCALLs:801E

From WikiTI
Revision as of 21:27, 29 March 2005 by FloppusMaximus (Talk | contribs)

Jump to: navigation, search

Synopsis

Official Name: BigNumCompare

BCALL Address: 801E

Checks to see if two large integers are equal.

Inputs

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

Outputs

  • Zero Flag: Set if integers are equal

Destroys

  •  ??

Comments

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.

Example

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