Subversion Repositories Kolibri OS

Rev

Rev 107 | Rev 153 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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