Subversion Repositories Kolibri OS

Rev

Rev 5673 | Rev 6215 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;;   Calculator for MenuetOS (c) Ville Turjanmaa
  2. ;;  
  3. ;;   Compile with FASM
  4. ;;  
  5. ;;   Pavel Rymovski (Heavyiron) - version for KolibriOS
  6. ;;
  7. ;; What's new:
  8. ;;   Calc 1.1
  9. ;;           1) changed design
  10. ;;           2) new procedure of draw window (10 decimal digits, 23 binary, "+" not displayed now)
  11. ;;           3) window with skin
  12. ;;   Calc 1.2
  13. ;;           1) added some useful functions, such as arcsin, arccos, arctg, 1/x, x^2
  14. ;;   Calc 1.31
  15. ;;           1) optimised program
  16. ;;           2) new type of window (you need kernel 114 revision or higher)
  17. ;;   Calc 1.32
  18. ;;           1) fixed arccos
  19. ;;   Calc 1.33
  20. ;;           1) align button captions in proper way, finally!
  21. ;;   Calc 1.4 - Leency
  22. ;;           1) better GUI, big fonts
  23.  
  24. use32
  25.         org     0x0
  26.         db      'MENUET01'      ; 8 byte id
  27.         dd      0x01            ; header version
  28.         dd      START           ; start of code
  29.         dd      I_END           ; size of image
  30.         dd      E_END           ; memory for app
  31.         dd      E_END           ; esp
  32.         dd      0x0,0x0         ; I_Param , I_Icon
  33.  
  34. include '../../../macros.inc'
  35. include '../../../KOSfuncs.inc'
  36.  
  37. macro DrawBar  x, y, width, height, color
  38. {
  39.         mcall 13, (x) shl 16 + (width), (y) shl 16 + (height), color
  40. }
  41.  
  42. macro DrawRectangle  x, y, w, h, color
  43. {
  44.         DrawBar x,y,w,1,color
  45.         DrawBar x,y+h,w,1
  46.         DrawBar x,y,1,h
  47.         DrawBar x+w,y,1,h+1
  48. }
  49.  
  50. START:
  51. red:
  52.         call    draw_window
  53. still:  
  54.         mcall   10
  55.  
  56.         dec     eax
  57.         jz      red
  58.         dec     eax
  59.         jz      key
  60.  
  61. button:
  62.         mcall   17      ; get button id
  63.         shr     eax, 8
  64.         jmp     testbut
  65.  
  66. key:
  67.         mcall   2       ; get ASCII key code
  68.         shr     eax, 8
  69.         mov     edi, asci       ; convert ASCII into button id
  70.         mov     ecx, 18
  71.         cld
  72.         repne   scasb
  73.         jne     still
  74.         sub     edi, asci
  75.         dec     edi
  76.         mov     esi, butid
  77.         add     esi, edi
  78.         lodsb
  79.  
  80. testbut:
  81.         cmp     eax, 1  ; button 1 -- exit
  82.         jne     noexit
  83.         mcall   -1
  84.  
  85. noexit:
  86.         cmp     eax, 2
  87.         jne     no_reset
  88.         call    clear_all
  89.         jmp     still
  90.  
  91. no_reset:
  92.         finit
  93.         mov     ebx, muuta1     ; convert to FPU format
  94.         mov     esi, 18
  95.         call    atof
  96.         fstp    [trans1]
  97.         mov     ebx, muuta2
  98.         mov     esi, 18
  99.         call    atof
  100.         fst     [trans2]
  101.  
  102.         cmp     eax, 33
  103.         jne     no_sign
  104.         cmp     [dsign], byte '-'
  105.         jne     no_m
  106.         mov     [dsign], byte '+'
  107.         call    print_display
  108.         jmp     still
  109.  
  110. no_m:
  111.         mov     [dsign], byte '-'
  112.         call    print_display
  113.         jmp     still
  114.  
  115. no_sign:
  116.         cmp     eax, 3
  117.         jne     no_display_change
  118.         inc     [display_type]
  119.         cmp     [display_type], 2
  120.         jbe     display_continue
  121.         mov     [display_type], 0
  122.  
  123. display_continue:
  124.         mov     eax, [display_type]
  125.         mov     eax, [multipl + eax*4]
  126.         mov     [entry_multiplier], eax
  127.         call    print_display
  128.         jmp     still
  129.  
  130. no_display_change:
  131.         cmp     eax, 6
  132.         jb      no_a_f
  133.         cmp     eax, 11
  134.         jg      no_a_f
  135.         add     eax, 4
  136.         call    number_entry
  137.         jmp     still
  138.  
  139. no_a_f:
  140.         cmp     eax, 12
  141.         jb      no_13
  142.         cmp     eax, 14
  143.         jg      no_13
  144.         sub     eax, 11
  145.         call    number_entry
  146.         jmp     still
  147.  
  148. no_13:
  149.         cmp     eax, 19
  150.         jb      no_46
  151.         cmp     eax, 21
  152.         jg      no_46
  153.         sub     eax, 15
  154.         call    number_entry
  155.         jmp     still
  156.  
  157. no_46:
  158.         cmp     eax, 26
  159.         jb      no_79
  160.         cmp     eax, 28
  161.         jg      no_79
  162.         sub     eax, 19
  163.         call    number_entry
  164.         jmp     still
  165.  
  166. no_79:
  167.         cmp     eax, 34
  168.         jne     no_0
  169.         xor     eax, eax
  170.         call    number_entry
  171.         jmp     still
  172.  
  173. no_0:
  174.         cmp     eax, 35
  175.         jne     no_id
  176.         inc     [id]
  177.         and     [id], 1
  178.         mov     [new_dec], 100000
  179.         jmp     still
  180.  
  181. no_id:
  182.         cmp     eax, 17
  183.         jne     no_sin
  184.         fld     [trans1]
  185.         fsin
  186.         jmp     show_result
  187.  
  188. no_sin:
  189.         cmp     eax, 18
  190.         jne     no_asin
  191.         fld     [trans1]
  192.         fld     st0
  193.         fmul    st, st1
  194.         fld1
  195.         fsubrp  st1, st0
  196.         fsqrt
  197.         fpatan
  198.         jmp     show_result
  199.  
  200. no_asin:
  201.         cmp     eax, 16
  202.         jne     no_int
  203.         fld     [trans1]
  204.         frndint
  205.         jmp     show_result
  206.  
  207. no_int:
  208.         cmp     eax, 23
  209.         jne     no_1x
  210.         fld1
  211.         fdiv    [trans1]
  212.         jmp     show_result
  213.  
  214. no_1x:  
  215.         cmp     eax, 24
  216.         jne     no_cos
  217.         fld     [trans1]
  218.         fcos
  219.         jmp     show_result
  220.  
  221. no_cos:
  222.         cmp     eax, 25
  223.         jne     no_acos
  224.         fld     [trans1]
  225.         fld     st0
  226.         fmul    st, st1
  227.         fld1
  228.         fsubrp  st1, st0
  229.         fsqrt
  230.         fxch    st1
  231.         fpatan
  232.         jmp     show_result
  233.  
  234. no_acos:  
  235.         cmp     eax, 30
  236.         jne     no_x2
  237.         fld     [trans1]
  238.         fmul    st, st0
  239.         jmp     show_result
  240.  
  241. no_x2:  
  242.         cmp     eax, 31
  243.         jne     no_tan
  244.         fld     [trans1]
  245.         fptan
  246.         fstp    st2
  247.         jmp     show_result
  248.  
  249. no_tan:
  250.         cmp     eax, 32
  251.         jne     no_atan
  252.         fld     [trans1]
  253.         fld1
  254.         fpatan
  255.         jmp     show_result
  256.  
  257. no_atan:
  258.         cmp     eax, 38
  259.         jne     no_pi
  260.         fldpi
  261.         jmp     show_result
  262.  
  263. no_pi:
  264.         cmp     eax, 37
  265.         jne     no_sqrt
  266.         fld     [trans1]
  267.         fsqrt
  268.         jmp     show_result
  269.  
  270. no_sqrt:
  271.         cmp     eax, 15
  272.         jne     no_add
  273.         call    calculate
  274.         call    new_entry
  275.         mov     [calc], '+'
  276.         jmp     still
  277.  
  278. no_add:
  279.         cmp     eax, 22
  280.         jne     no_sub
  281.         call    calculate
  282.         call    new_entry
  283.         mov     [calc], '-'
  284.         jmp     still
  285.  
  286. no_sub:
  287.         cmp     eax, 29
  288.         jne     no_div
  289.         call    calculate
  290.         call    new_entry
  291.         mov     [calc], '/'
  292.         jmp     still
  293.  
  294. no_div:
  295.         cmp     eax, 36
  296.         jne     no_mul
  297.         call    calculate
  298.         mov     [calc], '*'
  299.         call    new_entry
  300.         jmp     still
  301.  
  302. no_mul:
  303.         cmp     eax, 39
  304.         jne     no_calc
  305.         call    calculate
  306.         jmp     still
  307.  
  308. no_calc:
  309.         jmp     still
  310.  
  311. show_result:
  312.         call    ftoa
  313.         call    print_display
  314.         jmp     still
  315.  
  316. error:
  317.         jmp     still
  318.  
  319. calculate:
  320.         pusha
  321.         cmp     [calc], ' '
  322.         je      no_calculation
  323.         cmp     [calc], '/'
  324.         jne     no_cdiv
  325.         fdiv    [trans1]
  326.  
  327. no_cdiv:
  328.         cmp     [calc], '*'
  329.         jne     no_cmul
  330.         fmul    [trans1]
  331.  
  332. no_cmul:
  333.         cmp     [calc], '+'
  334.         jne     no_cadd
  335.         fadd    [trans1]
  336.  
  337. no_cadd:
  338.         cmp     [calc], '-'
  339.         jne     no_cdec
  340.         fsub    [trans1]
  341.  
  342. no_cdec:
  343.         call    ftoa
  344.  
  345. no_calculation:
  346.         call    print_display
  347.         popa
  348.         ret
  349.  
  350. number_entry:
  351.  
  352.         pusha
  353.  
  354.         cmp     eax, [entry_multiplier]
  355.         jge     no_entry
  356.         cmp     [id], 1
  357.         je      decimal_entry
  358.         mov     ebx, [integer]
  359.         test    ebx, 0xf0000000
  360.         jnz     no_entry
  361.         mov     ebx, eax
  362.         mov     eax, [integer]
  363.         mov     ecx, [entry_multiplier]
  364.         mul     ecx
  365.         add     eax, ebx
  366.         mov     [integer], eax
  367.         call    print_display
  368.         call    to_muuta
  369.         popa
  370.         ret
  371.  
  372. decimal_entry:
  373.  
  374.         imul    eax, [new_dec]
  375.         add     [decimal], eax
  376.         mov     eax, [new_dec]
  377.         xor     edx, edx
  378.         mov     ebx, [entry_multiplier]
  379.         div     ebx
  380.         mov     [new_dec], eax
  381.         call    print_display
  382.         call    to_muuta
  383.         popa
  384.         ret
  385.  
  386. no_entry:
  387.  
  388.         call    print_display
  389.         call    to_muuta
  390.         popa
  391.         ret
  392.  
  393. to_muuta:
  394.  
  395.         pusha
  396.         mov     al, [dsign]
  397.         mov     esi, muuta0
  398.         mov     edi, muuta1
  399.         mov     ecx, 18
  400.         cld
  401.         rep     movsb
  402.         mov     [muuta1], al
  403.         mov     edi, muuta1+10     ; []
  404.         mov     eax, [integer]
  405.  
  406. new_to_muuta1:
  407.  
  408.         mov     ebx, 10
  409.         xor     edx, edx
  410.         div     ebx
  411.         mov     [edi], dl
  412.         add     [edi], byte 48
  413.         dec     edi
  414.         cmp     edi, muuta1+1
  415.         jge     new_to_muuta1
  416.         mov     edi, muuta1+17     ; {}
  417.         mov     eax, [decimal]
  418.  
  419. new_to_muuta2:
  420.  
  421.         mov     ebx, 10
  422.         xor     edx, edx
  423.         div     ebx
  424.         mov     [edi], dl
  425.         add     [edi], byte 48
  426.         dec     edi
  427.         cmp     edi, muuta1+12
  428.         jge     new_to_muuta2
  429.         popa
  430.         ret
  431.  
  432. new_entry:
  433.  
  434.         pusha
  435.         mov     esi, muuta1
  436.         mov     edi, muuta2
  437.         mov     ecx, 18
  438.         cld
  439.         rep     movsb
  440.         mov     esi, muuta0
  441.         mov     edi, muuta1
  442.         mov     ecx, 18
  443.         cld
  444.         rep     movsb
  445.         mov     [integer], 0
  446.         mov     [decimal], 0
  447.         mov     [id], 0
  448.         mov     [new_dec], 100000
  449.         mov     [sign], byte '+'
  450.         popa
  451.         ret
  452.  
  453.  
  454. ftoa:                         ; fpu st0 -> [integer],[decimal]
  455.         pusha
  456.         fst     [tmp2]
  457.         fstcw   [controlWord]      ; set truncate integer mode
  458.         mov     ax, [controlWord]
  459.         mov     [tmp], ax
  460.         or      [tmp], word 0x0c00
  461.         fldcw   [tmp]
  462.         ftst                      ; test if st0 is negative
  463.         fstsw   ax
  464.         and     ax, 0x4500
  465.         mov     [sign], 0
  466.         cmp     ax, 0x0100
  467.         jne     no_neg
  468.         mov     [sign], 1
  469.  
  470. no_neg:
  471.         fld     [tmp2]
  472.         cmp     byte [sign], 0     ; change fraction to positive
  473.         je      no_neg2
  474.         fchs
  475.  
  476. no_neg2:
  477.         fadd    [smallValueForRounding]
  478.         fist    [integer]
  479.         fisub   [integer]
  480.         mov     [res], 0     ; convert 6 decimal numbers
  481.         mov     edi, 6
  482.  
  483. newd:
  484.         fimul   [kymppi]
  485.         fist    [decimal]
  486.         mov     ebx, [res]
  487.         imul    ebx, 10
  488.         mov     [res], ebx
  489.         mov     eax, [decimal]
  490.         add     [res], eax
  491.         fisub   [decimal]
  492.         fst     [tmp2]
  493.         ftst
  494.         fstsw   ax
  495.         test    ax, 1
  496.         jnz     real_done
  497.         fld     [tmp2]
  498.         dec     edi
  499.         jz      real_done
  500.         jmp     newd
  501.  
  502. real_done:
  503.         fldcw   [controlWord]
  504.         mov     eax, [res]
  505.         mov     [decimal], eax
  506.         cmp     [integer], 0x80000000
  507.         jne     no_error
  508.         call    clear_all
  509.         mov     [calc], 'E'
  510.  
  511. no_error:
  512.         mov     [dsign], byte '+'
  513.         cmp     [sign], byte 0      ; convert negative result
  514.         je      no_negative
  515. ;       mov     eax, [integer]
  516. ;       not     eax
  517. ;       inc     eax
  518. ;       mov     [integer], eax
  519.         mov     [dsign], byte '-'
  520.  
  521. no_negative:
  522.         call    to_muuta
  523.         popa
  524.         ret
  525.  
  526.  
  527. atof:
  528.         push    ax
  529.         push    di
  530.         fldz
  531.         mov     di, 0
  532.         cmp     si, 0
  533.         je      .error            ; Jump if string has 0 length.
  534.         mov     byte [sign], 0
  535.         cmp     byte [bx], '+'   ; Take care of leading '+' or '-'.
  536.         jne     .noPlus
  537.         inc     di
  538.         jmp     .noMinus
  539.  
  540.   .noPlus:
  541.         cmp     byte [bx], '-'
  542.         jne     .noMinus
  543.         mov     byte [sign], 1   ; Number is negative.
  544.         inc     di
  545.  
  546.   .noMinus:
  547.         cmp     si, di
  548.         je      .error
  549.         call    atof_convertWholePart
  550.         jc      .error
  551.         call    atof_convertFractionalPart
  552.         jc      .error
  553.         cmp     byte [sign], 0
  554.         je      .dontNegate
  555.         fchs    ; Negate value
  556.  
  557.   .dontNegate:
  558.         mov     bh, 0    ; Set bh to indicate the string is a valid number.
  559.         jmp     .exit
  560.  
  561.   .error:
  562.         mov     bh, 1    ; Set error code.
  563. ;       fstp    st0    ; Pop top of fpu stack.
  564.  
  565.   .exit:
  566.         pop     di
  567.         pop     ax
  568.         ret
  569.  
  570. atof_convertWholePart:
  571.  
  572.     ; Convert the whole number part (the part preceding the decimal
  573.     ; point) by reading a digit at a time, multiplying the current
  574.     ; value by 10, and adding the digit.
  575.  
  576.   .mainLoop:
  577.         mov     al, [bx + di]
  578.         cmp     al, '.'
  579.         je      .exit
  580.         cmp     al, '0'       ; Make sure character is a digit.
  581.         jb      .error
  582.         cmp     al, '9'
  583.         ja      .error
  584.  
  585.     ; Convert single character to digit and save to memory for
  586.     ; transfer to the FPU.
  587.  
  588.         sub     al, '0'
  589.         mov     ah, 0
  590.         mov     [tmp], ax
  591.  
  592.     ; Multiply current value by 10 and add in digit.
  593.  
  594.         fmul    dword [ten]
  595.         fiadd   word [tmp]
  596.         inc     di
  597.         cmp     si, di         ; Jump if end of string has been reached.
  598.         je      .exit
  599.         jmp     .mainLoop
  600.  
  601.   .error:
  602.         stc                ; Set error (carry) flag.
  603.         ret
  604.  
  605.   .exit:
  606.         clc                ; Clear error (carry) flag.
  607.         ret
  608.  
  609.  
  610. atof_convertFractionalPart:
  611.         fld1               ; Load 1 to TOS.  This will be the value of the decimal place.
  612.  
  613.   .mainLoop:
  614.         cmp     si, di         ; Jump if end of string has been reached.
  615.         je      .exit
  616.         inc     di             ; Move past the decimal point.
  617.         cmp     si, di         ; Jump if end of string has been reached.
  618.         je      .exit
  619.         mov     al, [bx + di]
  620.         cmp     al, '0'        ; Make sure character is a digit.
  621.         jb      .error
  622.         cmp     al, '9'
  623.         ja      .error
  624.         fdiv    dword [ten]   ; Next decimal place
  625.         sub     al, '0'
  626.         mov     ah, 0
  627.         mov     [tmp], ax
  628.  
  629.     ; Load digit, multiply by value for appropriate decimal place,
  630.     ; and add to current total.
  631.  
  632.         fild    word [tmp]
  633.         fmul    st0, st1
  634.         faddp   st2, st0
  635.         jmp     .mainLoop
  636.  
  637.   .error:
  638.         stc           ; Set error (carry) flag.
  639.         fstp    st0    ; Pop top of fpu stack.
  640.         ret
  641.  
  642.   .exit:
  643.         clc              ; Clear error (carry) flag.
  644.         fstp    st0    ; Pop top of fpu stack.
  645.         ret
  646.  
  647. ;   *********************************************
  648. ;   ******* WINDOW DEFINITIONS AND DRAW *********
  649. ;   *********************************************
  650.  
  651. BTNSP_X equ 39
  652.  
  653. draw_window:
  654.         mcall   12, 1
  655.  
  656.         mcall   48, 3, sc, sizeof.system_colors
  657.  
  658.                 mcall SF_STYLE_SETTINGS, SSF_GET_SKIN_HEIGHT
  659.  
  660.                 mov     ecx, 200 shl 16 + 210
  661.                 add     ecx, eax                ; add skin height to window height
  662.         mov     edx, [sc.work]
  663.         or      edx, 0x34000000
  664.                 mov     edi, title
  665.         mcall   0, <250, 317>
  666.                
  667.         mov     eax, SF_DEFINE_BUTTON
  668.         mov     ebx, 19 shl 16 + 36
  669.         mov     ecx, 55 shl 16 + 22
  670.         mov     edx, 6
  671.         mov     esi, [sc.work_button]
  672.         mov     edi, 7
  673. newbutton:
  674.         dec     edi
  675.         jnz     no_new_row
  676.         mov     edi, 7
  677.         mov     ebx, 19 shl 16 + 36
  678.         add     ecx, 28 shl 16
  679. no_new_row:
  680.         mcall
  681.         add     ebx, BTNSP_X shl 16
  682.         inc     edx
  683.         cmp     edx, BTNSP_X
  684.         jbe     newbutton
  685.  
  686.         mcall   , <253, 36>, <55, 22>, 2, 0xF0969D        ; 'C'
  687.         mcall   , <235,54>, <20,26>, 3, [sc.work]        ; 'dec-bin-hex'
  688.                 mov     esi, [sc.work_button]
  689.  
  690.  
  691.         mov     ecx, [sc.work_button_text]
  692.                 or      ecx, 0x10000000
  693.         mov     edx, text
  694.         mov     edi, 31
  695. next_line:
  696.         inc     edx
  697.         and     edi, 0x0000ffff
  698.         add     edi, 24 SHL 16 + 28
  699. next_button:
  700.         movzx   esi, byte[edx - 1]
  701.         imul    eax, esi, 8
  702.         neg     eax
  703.         add     eax, 29
  704.         shr     eax, 1
  705.         shl     eax, 16
  706.         mov     ebx, edi
  707.         add     ebx, eax
  708.         mcall   4
  709.         add     edx, esi
  710.         inc     edx
  711.         add     edi, BTNSP_X SHL 16
  712.         cmp     [edx - 1], byte 0
  713.                 jne     next_button
  714.         cmp     [edx], byte 'x'
  715.         jne     next_line
  716.  
  717.         call    print_display
  718.  
  719.         mcall   12, 2
  720.         ret
  721.  
  722. print_display:
  723.         pusha
  724.         mcall   13, < 21, 206>, <22, 24>, 0xFFFfff
  725.                 DrawRectangle 19,20,208,26, [sc.work_graph]
  726.         mcall   38, < 20, 226>, <21, 21>, 0xE0E0E0 ; internal shadow
  727.                 mcall   38, < 20,  20>, <23, 43>, 0xE0E0E0 ; internal shadow
  728.                
  729.         mov     ecx, [sc.work_text]
  730.         or      ecx, 0x40000000
  731.         mcall   4, <135,7>,,calc,1,[sc.work]
  732.  
  733.         mov     ebx, 250 shl 16 + 26
  734.         mov     edx, [display_type]
  735.         shl     edx, 2
  736.         add     edx, display_type_text
  737.         mov     esi, 3
  738.         mov     edi, [sc.work]
  739.                 or      ecx, 0x10000000
  740.         mcall
  741.  
  742.         cmp     [dsign], byte '+'
  743.         je      positive
  744.         mcall   , <23, 26>, 0, dsign, 1
  745.  
  746. positive:  
  747.         cmp     [display_type], 0
  748.         jne     no_display_decimal
  749.         cmp     [decimal], 0
  750.         je      whole
  751.  
  752.         mcall   , <144, 26>, [number_color], dot, 1
  753.         mcall   47, <10, 0>, [integer], <26, 26>, [number_color]
  754.         mcall   , <6, 0>, [decimal], <151, 26>, [number_color]
  755.  
  756.         popa
  757.         ret
  758.  
  759. whole:
  760.         mcall   , <214, 26>, [number_color], dot, 1
  761.  
  762.         cmp     [integer], 0
  763.         je      null
  764.         mcall   47, <10, 0>, [integer], <94, 26>, [number_color]
  765.         popa
  766.         ret
  767.  
  768. no_display_decimal:
  769.         cmp     [display_type], 1
  770.         jne     no_display_hexadecimal
  771.         cmp     [integer], 0
  772.         je      null
  773.         mcall   47, <8, 256>, [integer], <130, 26>, [number_color]
  774.         popa
  775.         ret
  776.  
  777. no_display_hexadecimal:
  778.         cmp     [integer], 0
  779.         je      null
  780.         mcall   47, <32, 2*256>, [integer], <32, 30>, 0
  781.         popa
  782.         ret
  783.  
  784. null:
  785.         mcall   47, <1, 0>, 0, <202, 26>, [number_color]
  786.         popa
  787.         ret
  788.  
  789. clear_all:
  790.         pusha
  791.         mov     [calc], ' '
  792.         mov     [integer], 0
  793.         mov     [decimal], 0
  794.         mov     [id], 0
  795.         mov     [dsign], byte '+'
  796.         mov     esi, muuta0
  797.         mov     edi, muuta1
  798.         mov     ecx, 18
  799.         cld
  800.         rep     movsb
  801.         mov     esi, muuta0
  802.         mov     edi, muuta2
  803.         mov     ecx, 18
  804.         cld
  805.         rep     movsb
  806.         call    print_display
  807.         popa
  808.         ret
  809.  
  810.  
  811. ;data
  812.  
  813. title   db 'Calc 1.4', 0
  814.  
  815. display_type            dd  0    ; 0 = decimal, 1 = hexadecimal, 2= binary
  816. entry_multiplier        dd  10
  817. display_type_text       db  'dec hex bin'
  818. number_color            dd 0x81333333
  819.  
  820. dot             db  '.',0
  821. calc            db  ' ',0
  822. integer         dd  0
  823. decimal         dd  0
  824. kymppi          dd  10
  825. ten             dd  10.0, 0
  826. tmp             dw  1, 0
  827. sign            db  1, 0
  828. tmp2            dq  0, 0
  829. exp             dd  0, 0
  830. new_dec         dd  100000, 0
  831. id              db  0, 0
  832. res             dd  0
  833. trans1          dq  0
  834. trans2          dq  0
  835. controlWord     dw  1
  836. smallValueForRounding dq        0.0000005 ; 1/2 from last significant digit
  837. multipl         dd  10,16,2
  838.  
  839. dsign:
  840. muuta1          db  '+0000000000.000000'
  841. muuta2          db  '+0000000000.000000'
  842. muuta0          db  '+0000000000.000000'
  843.  
  844. text:
  845.         db 1,'A',   1,'B', 1,'C', 1,'D', 1,'E',   1,'F',   3,'CLR', 0
  846.         db 1,'1',   1,'2', 1,'3', 1,'+', 3,'Int', 3,'Sin', 4,'Asin', 0
  847.         db 1,'4',   1,'5', 1,'6', 1,'-', 3,'1/x', 3,'Cos', 4,'Acos', 0
  848.         db 1,'7',   1,'8', 1,'9', 1,'/', 3,'x^2', 3,'Tan', 4,'Atan', 0
  849.         db 3,'+/-', 1,'0', 1,'.', 1,'*', 3,'Sqr', 2,'Pi',  1,'=', 0
  850.         db 'x'
  851.  
  852. asci:   db 49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 43, 61, 45, 42, 47, 44, 46, 27
  853. butid:  db 12, 13, 14, 19, 20, 21, 26, 27, 28, 34, 15, 39, 22, 36, 29, 35, 35, 1
  854.  
  855. I_END:
  856.  
  857. sc      system_colors
  858. rb      0x200   ; stack
  859. E_END:
  860.