Subversion Repositories Kolibri OS

Rev

Rev 9070 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;    mpint.asm - Multi Precision INTeger routines test suite
  2. ;
  3. ;    Copyright (C) 2015-2021 Jeffrey Amelynck
  4. ;
  5. ;    This program is free software: you can redistribute it and/or modify
  6. ;    it under the terms of the GNU General Public License as published by
  7. ;    the Free Software Foundation, either version 3 of the License, or
  8. ;    (at your option) any later version.
  9. ;
  10. ;    This program is distributed in the hope that it will be useful,
  11. ;    but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ;    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. ;    GNU General Public License for more details.
  14. ;
  15. ;    You should have received a copy of the GNU General Public License
  16. ;    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  17.  
  18. format binary as ""
  19.  
  20. __DEBUG__       = 1
  21. __DEBUG_LEVEL__ = 2
  22.  
  23. MAX_BITS    = 4096
  24.  
  25. use32
  26.  
  27.         db      'MENUET01'      ; signature
  28.         dd      1               ; header version
  29.         dd      start           ; entry point
  30.         dd      i_end           ; initialized size
  31.         dd      mem+65536       ; required memory
  32.         dd      mem+65536       ; stack pointer
  33.         dd      0               ; parameters
  34.         dd      0               ; path
  35.  
  36. include '../../../macros.inc'
  37. purge mov,add,sub
  38. include '../../../proc32.inc'
  39. include '../../../debug-fdo.inc'
  40.  
  41. include '../mpint.inc'
  42.  
  43. cmptestctr = 0x10000000
  44.  
  45. macro cmptesteq arg1, arg2 {
  46.         stdcall mpint_cmp, arg1, arg2
  47.         je      @f
  48.         mov     eax, cmptestctr
  49.         int3
  50.   @@:
  51. cmptestctr = cmptestctr + 1
  52. }
  53.  
  54. macro cmptesta arg1, arg2 {
  55.         stdcall mpint_cmp, arg1, arg2
  56.         ja      @f
  57.         mov     eax, cmptestctr
  58.         int3
  59.   @@:
  60. cmptestctr = cmptestctr + 1
  61.         stdcall mpint_cmp, arg2, arg1
  62.         jb      @f
  63.         mov     eax, cmptestctr
  64.         int3
  65.   @@:
  66. cmptestctr = cmptestctr + 1
  67. }
  68.  
  69. start:
  70.  
  71.         DEBUGF  3, "MPINT Test suite\n"
  72.  
  73. ; First, do some checks on the compare routine
  74.         cmptesteq mpint_0_0, mpint_0_0
  75.         cmptesteq mpint_0_0, mpint_0_1
  76.         cmptesteq mpint_0_1, mpint_0_0
  77.         cmptesteq mpint_0_1, mpint_0_1
  78.         cmptesteq mpint_0_5, mpint_0_0
  79.         cmptesteq mpint_0_0, mpint_0_5
  80.         cmptesteq mpint_0_5, mpint_0_1
  81.         cmptesteq mpint_0_1, mpint_0_5
  82.  
  83.         cmptesteq mpint_1_1, mpint_1_1
  84.         cmptesteq mpint_1_1, mpint_1_2
  85.         cmptesteq mpint_1_2, mpint_1_1
  86.         cmptesteq mpint_1_2, mpint_1_2
  87.         cmptesteq mpint_1_5, mpint_1_1
  88.         cmptesteq mpint_1_1, mpint_1_5
  89.         cmptesteq mpint_1_5, mpint_1_2
  90.         cmptesteq mpint_1_2, mpint_1_5
  91.  
  92.         cmptesteq mpint_2_1, mpint_2_1
  93.         cmptesteq mpint_2_1, mpint_2_2
  94.         cmptesteq mpint_2_2, mpint_2_1
  95.         cmptesteq mpint_2_2, mpint_2_2
  96.         cmptesteq mpint_2_5, mpint_2_1
  97.         cmptesteq mpint_2_1, mpint_2_5
  98.         cmptesteq mpint_2_5, mpint_2_2
  99.         cmptesteq mpint_2_2, mpint_2_5
  100.  
  101.         cmptesta mpint_1_1, mpint_0_0
  102.         cmptesta mpint_1_1, mpint_0_1
  103.         cmptesta mpint_1_1, mpint_0_5
  104.  
  105.         cmptesta mpint_1_5, mpint_0_0
  106.         cmptesta mpint_1_5, mpint_0_1
  107.         cmptesta mpint_1_5, mpint_0_5
  108.  
  109.         cmptesta mpint_2_1, mpint_1_1
  110.         cmptesta mpint_2_1, mpint_1_2
  111.         cmptesta mpint_2_1, mpint_1_5
  112.  
  113.         cmptesta mpint_2_2, mpint_1_1
  114.         cmptesta mpint_2_2, mpint_1_2
  115.         cmptesta mpint_2_2, mpint_1_5
  116.  
  117.         cmptesta mpint_2_5, mpint_1_1
  118.         cmptesta mpint_2_5, mpint_1_2
  119.         cmptesta mpint_2_5, mpint_1_5
  120.  
  121.         cmptesta mpint_100, mpint_ff
  122.         cmptesta mpint_10000, mpint_ff00
  123.         cmptesta mpint_100000000, mpint_ff000000
  124.  
  125.  
  126. iglobal
  127. mpint_0_0 dd 0
  128.           rb MPINT_MAX_LEN
  129.  
  130. mpint_0_1 dd 1
  131.           db 0
  132.           rb MPINT_MAX_LEN - 1
  133.  
  134. mpint_0_2 dd 2
  135.           db 0, 0
  136.           rb MPINT_MAX_LEN - 2
  137.  
  138. mpint_0_3 dd 3
  139.           db 0, 0, 0
  140.           rb MPINT_MAX_LEN - 3
  141.  
  142. mpint_0_4 dd 4
  143.           db 0, 0, 0, 0
  144.           rb MPINT_MAX_LEN - 4
  145.  
  146. mpint_0_5 dd 5
  147.           db 0, 0, 0, 0, 0
  148.           rb MPINT_MAX_LEN - 5
  149.  
  150. mpint_1_1 dd 1
  151.           db 1
  152.           rb MPINT_MAX_LEN - 1
  153.  
  154. mpint_1_2 dd 2
  155.           db 1, 0
  156.           rb MPINT_MAX_LEN - 2
  157.  
  158. mpint_1_3 dd 3
  159.           db 1, 0, 0
  160.           rb MPINT_MAX_LEN - 3
  161.  
  162. mpint_1_4 dd 4
  163.           db 1, 0, 0, 0
  164.           rb MPINT_MAX_LEN - 4
  165.  
  166. mpint_1_5 dd 5
  167.           db 1, 0, 0, 0, 0
  168.           rb MPINT_MAX_LEN - 5
  169.  
  170. mpint_2_1 dd 1
  171.           db 2
  172.           rb MPINT_MAX_LEN - 1
  173.  
  174. mpint_2_2 dd 2
  175.           db 2, 0
  176.           rb MPINT_MAX_LEN - 2
  177.  
  178. mpint_2_3 dd 3
  179.           db 2, 0, 0
  180.           rb MPINT_MAX_LEN - 3
  181.  
  182. mpint_2_4 dd 4
  183.           db 2, 0, 0, 0
  184.           rb MPINT_MAX_LEN - 4
  185.  
  186. mpint_2_5 dd 5
  187.           db 2, 0, 0, 0, 0
  188.           rb MPINT_MAX_LEN - 5
  189.  
  190. mpint_ff  dd 2
  191.           db 0xff, 0
  192.           rb MPINT_MAX_LEN - 2
  193.  
  194. mpint_100 dd 2
  195.           db 0, 1
  196.           rb MPINT_MAX_LEN - 2
  197.  
  198. mpint_ff00  dd 3
  199.           db 0, 0xff, 0
  200.           rb MPINT_MAX_LEN - 3
  201.  
  202. mpint_10000 dd 3
  203.           db 0, 0, 1
  204.           rb MPINT_MAX_LEN - 3
  205.  
  206. mpint_ff000000  dd 5
  207.           db 0, 0, 0, 0xff, 0
  208.           rb MPINT_MAX_LEN - 5
  209.  
  210. mpint_100000000 dd 5
  211.           db 0, 0, 0, 0, 1
  212.           rb MPINT_MAX_LEN - 5
  213.  
  214.  
  215. endg
  216.  
  217. include "tests.inc"
  218.  
  219.         DEBUGF  3, "All tests completed\n"
  220.  
  221.         mcall   -1
  222.  
  223. IncludeIGlobals
  224.  
  225. i_end:
  226.  
  227. starttime dq ?
  228.  
  229. mpint_tmp       rb MPINT_MAX_LEN+4
  230.  
  231. include_debug_strings
  232.  
  233. mem: