anchor.diff:  unit integermath;
   
   interface
  -procedure fpc_div_mod_byte(Dividend, Divisor: byte; out result, remainder: byte);
  -procedure fpc_div_mod_word(Dividend, Divisor: word; var result, remainder: word);
  -procedure fpc_div_mod_dword(Dividend, Divisor: dword; var result, remainder: dword);
  -function fpc_div_mod_qword(Dividend, Divisor: qword; out Remainder: qword): qword;
  -
  -implementation
  +
   // Based on restoring division algorithm
   // Algorithm source document: Lecture notes by S. Galal and D. Pham, Division algorithms and hardware implementations.
   // Link to documentation http://www.seas.ucla.edu/~ingrid/ee213a/lectures/division_presentV2.pdf
   
  +// Note these functions do not generate runtime errors
   // Note that the algorithm automatically yields the following results for special cases:
   // x div 0 = MAX(type)
   // 0 div 0 = MAX(type)
  
positive.code:   st Z, R25
  end;
  
  procedure fpc_div_mod_dword(Dividend, Divisor: dword; var Result, Remainder: dword); assembler; nostackframe;
  label
    start, div1, div2, div3, finish;
  asm
  
negative.code:   st  Z, R24
  end;
  
  procedure div_mod_word(Dividend, Divisor: word; out Result, Remainder: word); assembler; nostackframe;
  label
    start, div1, div2, div3, finish;
  asm
  