Subversion Repositories Kolibri OS

Rev

Rev 2745 | Rev 4934 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2745 Rev 3625
Line 8... Line 8...
8
;;   Calc 1.1
8
;;   Calc 1.1
9
;;           1) changed design
9
;;           1) changed design
10
;;           2) new procedure of draw window (10 decimal digits, 23 binary, "+" not displayed now)
10
;;           2) new procedure of draw window (10 decimal digits, 23 binary, "+" not displayed now)
11
;;           3) window with skin
11
;;           3) window with skin
12
;;   Calc 1.2
12
;;   Calc 1.2
13
;;           1)added some useful functions, such as arcsin, arccos, arctg, 1/x, x^2
13
;;           1) added some useful functions, such as arcsin, arccos, arctg, 1/x, x^2
14
;;   Calc 1.31
14
;;   Calc 1.31
15
;;           1)optimised program
15
;;           1) optimised program
16
;;           2)new type of window (you need kernel 114 revision or higher)
16
;;           2) new type of window (you need kernel 114 revision or higher)
17
;;   Calc 1.32
17
;;   Calc 1.32
18
;;           1)fixed arccos
18
;;           1) fixed arccos
-
 
19
;;   Calc 1.33
-
 
20
;;           1) align button captions in proper way, finally!
Line 19... Line -...
19
 
-
 
20
 
-
 
21
appname equ 'Calc '
-
 
22
version    equ '1.32'
21
 
23
 
22
 
24
use32
23
use32
25
               org    0x0
24
        org     0x0
26
               db    'MENUET01'            ; 8 byte id
25
        db      'MENUET01'      ; 8 byte id
27
               dd     0x01                      ; header version
26
        dd      0x01            ; header version
28
               dd     START                    ; start of code
27
        dd      START           ; start of code
29
               dd     I_END                    ; size of image
28
        dd      I_END           ; size of image
30
               dd     0x1000                  ; memory for app
29
        dd      E_END           ; memory for app
Line 31... Line 30...
31
               dd     0x1000                  ; esp
30
        dd      E_END           ; esp
Line 32... Line 31...
32
               dd     0x0,0x0                 ; I_Param , I_Icon
31
        dd      0x0,0x0         ; I_Param , I_Icon
33
 
-
 
34
include '..\..\..\macros.inc'
32
 
35
 
33
include '../../../macros.inc'
36
START:
-
 
37
 
34
 
38
 red:
-
 
39
    call draw_window
-
 
40
 
35
START:
41
 still:  
36
red:
42
    push 10 
37
        call    draw_window
43
    pop eax 
38
still:  
44
    mcall
39
        mcall   10
45
 
40
 
46
    dec eax
41
        dec     eax
47
    jz red
42
        jz      red
48
    dec eax 
43
        dec     eax 
49
    jz key 
-
 
50
 
44
        jz      key 
51
  button:
45
 
52
    mov  al,17      ; ¯®«ãç¨âì ¨¤¥­â¨ä¨ª â®à ­ ¦ â®© ª­®¯ª¨
46
button:
53
    mcall
47
        mcall   17      ; get button id
54
    shr  eax,8
48
        shr     eax, 8
55
    jmp  testbut
-
 
56
 
49
        jmp     testbut
57
  key:         
50
 
58
    mov  al,2       ; ¯®«ãç¨âì ASCII-ª®¤ ­ ¦ â®© ª« ¢¨è¨
51
key:
59
    mcall
52
        mcall   2       ; get ASCII key code
60
    shr  eax,8
53
        shr     eax, 8
61
    mov  edi,asci   ; ¯¥à¥¢®¤ ASCII ¢ ¨¤¥­â¨ä¨ª â®à ª­®¯ª¨
54
        mov     edi, asci       ; convert ASCII into button id
62
    mov  ecx,18
55
        mov     ecx, 18
63
    cld
56
        cld
64
    repne scasb
57
        repne   scasb
65
    jne  still
58
        jne     still
66
    sub  edi,asci
59
        sub     edi, asci
67
    dec  edi
60
        dec     edi
68
    mov  esi,butid
61
        mov     esi, butid
69
    add  esi,edi
62
        add     esi, edi
70
    lodsb
63
        lodsb
71
     
64
 
72
  testbut:
-
 
Line 303... Line 295...
303
 
295
 
304
  show_result:
296
show_result:
Line 305... Line 297...
305
    call   ftoa
297
        call    ftoa
306
    call   print_display
298
        call    print_display
307
    jmp    still
299
        jmp     still
308
 
300
 
309
error:
301
error:
310
    jmp  still
302
        jmp     still
311
 
303
 
312
calculate:
304
calculate:
313
    pusha
305
        pusha
314
    cmp  [calc],' '
306
        cmp     [calc], ' '
315
    je   no_calculation
307
        je      no_calculation
316
    cmp  [calc],'/'
308
        cmp     [calc], '/'
317
    jne  no_cdiv
309
        jne     no_cdiv
318
    fdiv [trans1]
310
        fdiv    [trans1]
319
  
311
 
320
  no_cdiv:
312
no_cdiv:
321
    cmp  [calc],'*'
313
        cmp     [calc], '*'
322
    jne  no_cmul
314
        jne     no_cmul
323
    fmul [trans1]
315
        fmul    [trans1]
324
 
316
 
325
  no_cmul:
317
no_cmul:
326
    cmp  [calc],'+'
318
        cmp     [calc], '+'
327
    jne  no_cadd
319
        jne     no_cadd
328
    fadd [trans1]
320
        fadd    [trans1]
329
 
321
 
330
  no_cadd:
322
no_cadd:
331
    cmp  [calc],'-'
323
        cmp     [calc], '-'
332
    jne  no_cdec
324
        jne     no_cdec
333
    fsub [trans1]
325
        fsub    [trans1]
334
  
326
 
Line 335... Line 327...
335
  no_cdec:
327
no_cdec:
Line 336... Line 328...
336
    call   ftoa
328
        call    ftoa
Line 337... Line 329...
337
   
329
 
338
  no_calculation:
330
no_calculation:
339
    call   print_display
331
        call    print_display
340
    popa
332
        popa
341
    ret
333
        ret
342
 
334
 
343
number_entry:
335
number_entry:
344
 
336
 
345
    pusha
337
        pusha
346
 
338
 
347
    cmp  eax,[entry_multiplier]
339
        cmp     eax, [entry_multiplier]
348
    jge  no_entry
340
        jge     no_entry
349
    cmp  [id],1
341
        cmp     [id], 1
350
    je   decimal_entry
342
        je      decimal_entry
351
    mov  ebx,[integer]
343
        mov     ebx, [integer]
352
    test ebx,0xF0000000
344
        test    ebx, 0xf0000000
353
    jnz  no_entry
345
        jnz     no_entry
354
    mov  ebx,eax
346
        mov     ebx, eax
355
    mov  eax,[integer]
347
        mov     eax, [integer]
356
    mov  ecx,[entry_multiplier]
348
        mov     ecx, [entry_multiplier]
357
    mul  ecx
349
        mul     ecx
358
    add  eax,ebx
350
        add     eax, ebx
359
    mov  [integer],eax
351
        mov     [integer], eax
360
    call print_display
352
        call    print_display
361
    call to_muuta
353
        call    to_muuta
362
    popa
354
        popa
363
    ret
355
        ret
364
 
356
 
365
  decimal_entry:
357
decimal_entry:
366
 
358
 
367
    imul eax,[new_dec]
359
        imul    eax, [new_dec]
368
    add  [decimal],eax
360
        add     [decimal], eax
369
    mov  eax,[new_dec]
361
        mov     eax, [new_dec]
370
    xor  edx,edx
362
        xor     edx, edx
371
    mov  ebx,[entry_multiplier]
363
        mov     ebx, [entry_multiplier]
372
    div  ebx
364
        div     ebx
373
    mov  [new_dec],eax
365
        mov     [new_dec], eax
374
    call print_display
366
        call    print_display
375
    call to_muuta
367
        call    to_muuta
376
    popa
368
        popa
377
    ret
369
        ret
378
 
370
 
379
  no_entry:
371
no_entry:
380
 
372
 
381
    call print_display
373
        call    print_display
382
    call to_muuta
374
        call    to_muuta
383
    popa
375
        popa
384
    ret
376
        ret
385
 
377
 
386
 to_muuta:
378
to_muuta:
387
 
379
 
388
    pusha
380
        pusha
389
    mov  al,[dsign]
381
        mov     al, [dsign]
390
    mov  esi,muuta0
382
        mov     esi, muuta0
391
    mov  edi,muuta1
383
        mov     edi, muuta1
392
    mov  ecx,18
384
        mov     ecx, 18
393
    cld
385
        cld
394
    rep  movsb
386
        rep     movsb
395
    mov  [muuta1],al
387
        mov     [muuta1], al
396
    mov  edi,muuta1+10     ; 楫®¥
388
        mov     edi, muuta1+10     ; []
397
    mov  eax,[integer]
389
        mov     eax, [integer]
398
  
390
 
399
  new_to_muuta1:
391
new_to_muuta1:
400
  
392
 
401
    mov  ebx,10
393
        mov     ebx, 10
402
    xor  edx,edx
394
        xor     edx, edx
403
    div  ebx
395
        div     ebx
404
    mov  [edi],dl
396
        mov     [edi], dl
405
    add  [edi],byte 48
397
        add     [edi], byte 48
406
    dec  edi
398
        dec     edi
407
    cmp  edi,muuta1+1
399
        cmp     edi, muuta1+1
408
    jge  new_to_muuta1
400
        jge     new_to_muuta1
409
    mov  edi,muuta1+17     ; ¤à®¡­®¥
401
        mov     edi, muuta1+17     ; {}
410
    mov  eax,[decimal]
402
        mov     eax, [decimal]
411
  
403
 
412
  new_to_muuta2:
404
new_to_muuta2:
413
    
405
 
Line 414... Line 406...
414
    mov  ebx,10
406
        mov     ebx, 10
Line 415... Line 407...
415
    xor  edx,edx
407
        xor     edx, edx
416
    div  ebx
408
        div     ebx
417
    mov  [edi],dl
409
        mov     [edi], dl
418
    add  [edi],byte 48
410
        add     [edi], byte 48
419
    dec  edi
411
        dec     edi
420
    cmp  edi,muuta1+12
412
        cmp     edi, muuta1+12
421
    jge  new_to_muuta2
413
        jge     new_to_muuta2
422
    popa
414
        popa
423
    ret
415
        ret
424
 
416
 
425
new_entry:
417
new_entry:
426
 
418
 
427
    pusha
419
        pusha
428
    mov  esi,muuta1
420
        mov     esi, muuta1
429
    mov  edi,muuta2
421
        mov     edi, muuta2
430
    mov  ecx,18
422
        mov     ecx, 18
431
    cld
423
        cld
432
    rep  movsb
424
        rep     movsb
Line 433... Line 425...
433
    mov  esi,muuta0
425
        mov     esi, muuta0
434
    mov  edi,muuta1
426
        mov     edi, muuta1
435
    mov  ecx,18
427
        mov     ecx, 18
436
    cld
428
        cld
437
    rep  movsb
429
        rep     movsb
438
    mov  [integer],0
430
        mov     [integer], 0
439
    mov  [decimal],0
431
        mov     [decimal], 0
440
    mov  [id],0
432
        mov     [id], 0
441
    mov  [new_dec],100000
433
        mov     [new_dec], 100000
442
    mov  [sign],byte '+'
434
        mov     [sign], byte '+'
443
    popa
435
        popa
444
    ret
436
        ret
445
 
437
 
446
 
438
 
447
ftoa:                         ; fpu st0 -> [integer],[decimal]
439
ftoa:                         ; fpu st0 -> [integer],[decimal]
448
    pusha
440
        pusha
449
    fst    [tmp2]
441
        fst     [tmp2]
450
    fstcw  [controlWord]      ; set truncate integer mode
442
        fstcw   [controlWord]      ; set truncate integer mode
451
    mov    ax,[controlWord]
443
        mov     ax, [controlWord]
452
    mov    [tmp], ax
444
        mov     [tmp], ax
453
    or     [tmp], word 0x0c00
445
        or      [tmp], word 0x0c00
454
    fldcw  [tmp]
446
        fldcw   [tmp]
455
    ftst                      ; test if st0 is negative
447
        ftst                      ; test if st0 is negative
456
    fstsw  ax
448
        fstsw   ax
457
    and    ax, 0x4500
449
        and     ax, 0x4500
458
    mov    [sign], 0
450
        mov     [sign], 0
459
    cmp    ax, 0x0100
451
        cmp     ax, 0x0100
460
    jne    no_neg
452
        jne     no_neg
461
    mov    [sign],1
453
        mov     [sign], 1
462
  
454
 
463
  no_neg:
455
no_neg:
464
    fld    [tmp2]
456
        fld     [tmp2]
465
    cmp    byte [sign], 0     ; change fraction to positive
457
        cmp     byte [sign], 0     ; change fraction to positive
466
    je     no_neg2
458
        je      no_neg2
467
    fchs
459
        fchs
468
 
460
 
469
  no_neg2:
461
no_neg2:
470
    fadd   [smallValueForRounding]
462
        fadd    [smallValueForRounding]
471
    fist   [integer]
463
        fist    [integer]
472
    fisub  [integer]
464
        fisub   [integer]
473
    mov    [res],0     ; convert 6 decimal numbers
465
        mov     [res], 0     ; convert 6 decimal numbers
474
    mov    edi,6
466
        mov     edi, 6
475
 
467
 
476
   newd:
468
newd:
477
    fimul  [kymppi]
469
        fimul   [kymppi]
478
    fist   [decimal]
470
        fist    [decimal]
479
    mov    ebx,[res]
471
        mov     ebx, [res]
480
    imul   ebx,10
472
        imul    ebx, 10
481
    mov    [res],ebx
473
        mov     [res], ebx
482
    mov    eax,[decimal]
474
        mov     eax, [decimal]
483
    add    [res],eax
475
        add     [res], eax
484
    fisub  [decimal]
476
        fisub   [decimal]
485
    fst    [tmp2]
477
        fst     [tmp2]
486
    ftst
478
        ftst
487
    fstsw  ax
479
        fstsw   ax
488
    test   ax,1
480
        test    ax, 1
489
    jnz    real_done
481
        jnz     real_done
490
    fld    [tmp2]
482
        fld     [tmp2]
491
    dec    edi
483
        dec     edi
492
    jz	   real_done
484
        jz      real_done
493
    jmp    newd
485
        jmp     newd
494
 
486
 
495
  real_done:
487
real_done:
496
    fldcw  [controlWord]
488
        fldcw   [controlWord]
497
    mov    eax,[res]
489
        mov     eax, [res]
498
    mov    [decimal],eax
490
        mov     [decimal], eax
499
    cmp    [integer],0x80000000
491
        cmp     [integer], 0x80000000
500
    jne    no_error
492
        jne     no_error
501
    call   clear_all
493
        call    clear_all
502
    mov    [calc],'E'
494
        mov     [calc], 'E'
503
  
495
 
Line 504... Line 496...
504
  no_error:
496
no_error:
505
    mov    [dsign],byte '+'
497
        mov     [dsign], byte '+'
506
    cmp    [sign],byte 0      ; convert negative result
498
        cmp     [sign], byte 0      ; convert negative result
507
    je     no_negative
499
        je      no_negative
508
;    mov    eax,[integer]
500
;       mov     eax, [integer]
509
;    not    eax
501
;       not     eax
510
;    inc    eax
502
;       inc     eax
511
;    mov    [integer],eax
503
;       mov     [integer], eax
512
    mov    [dsign],byte '-'
504
        mov     [dsign], byte '-'
513
  
505
 
514
  no_negative:
506
no_negative:
515
    call   to_muuta
507
        call    to_muuta
516
    popa
508
        popa
517
    ret
509
        ret
518
 
510
 
519
 
511
 
520
atof:
512
atof:
521
    push ax
513
        push    ax
522
    push di
514
        push    di
523
    fldz
515
        fldz
524
    mov di, 0
516
        mov     di, 0
525
    cmp si, 0
517
        cmp     si, 0
526
    je .error            ; Jump if string has 0 length.
518
        je      .error            ; Jump if string has 0 length.
527
    mov byte [sign], 0
519
        mov     byte [sign], 0
528
    cmp byte [bx], '+'   ; Take care of leading '+' or '-'.
520
        cmp     byte [bx], '+'   ; Take care of leading '+' or '-'.
529
    jne .noPlus
521
        jne     .noPlus
530
    inc di
522
        inc     di
531
    jmp .noMinus
523
        jmp     .noMinus
532
  
524
 
533
  .noPlus:
525
  .noPlus:
534
    cmp byte [bx], '-'
526
        cmp     byte [bx], '-'
535
    jne .noMinus
527
        jne     .noMinus
536
    mov byte [sign], 1   ; Number is negative.
528
        mov     byte [sign], 1   ; Number is negative.
Line 537... Line 529...
537
    inc di
529
        inc     di
538
  
530
 
539
  .noMinus:
531
  .noMinus:
Line 540... Line 532...
540
    cmp si, di
532
        cmp     si, di
541
    je .error
533
        je      .error
542
    call atof_convertWholePart
534
        call    atof_convertWholePart
543
    jc .error
535
        jc      .error
Line 544... Line 536...
544
    call atof_convertFractionalPart
536
        call    atof_convertFractionalPart
Line 545... Line 537...
545
    jc .error
537
        jc      .error
546
    cmp byte [sign], 0
538
        cmp     byte [sign], 0
547
    je .dontNegate
539
        je      .dontNegate
Line 548... Line 540...
548
    fchs    ; Negate value
540
        fchs    ; Negate value
549
 
541
 
550
  .dontNegate:
542
  .dontNegate:
551
    mov bh, 0    ; Set bh to indicate the string is a valid number.
543
        mov     bh, 0    ; Set bh to indicate the string is a valid number.
552
    jmp .exit
544
        jmp     .exit
553
 
545
 
554
  .error:
546
  .error:
555
    mov bh, 1    ; Set error code.
547
        mov     bh, 1    ; Set error code.
Line 556... Line 548...
556
   ; fstp st0    ; Pop top of fpu stack.
548
;       fstp    st0    ; Pop top of fpu stack.
557
 
549
 
Line 558... Line 550...
558
  .exit:
550
  .exit:
559
    pop di
551
        pop     di
560
    pop ax
552
        pop     ax
Line 561... Line 553...
561
    ret
553
        ret
Line 562... Line 554...
562
 
554
 
563
atof_convertWholePart:
555
atof_convertWholePart:
564
 
556
 
565
    ; Convert the whole number part (the part preceding the decimal
557
    ; Convert the whole number part (the part preceding the decimal
566
    ; point) by reading a digit at a time, multiplying the current
558
    ; point) by reading a digit at a time, multiplying the current
567
    ; value by 10, and adding the digit.
559
    ; value by 10, and adding the digit.
Line 568... Line 560...
568
 
560
 
569
.mainLoop:
561
  .mainLoop:
570
    mov al, [bx + di]
562
        mov     al, [bx + di]
Line 571... Line 563...
571
    cmp al, '.'
563
        cmp     al, '.'
572
    je .exit
564
        je      .exit
573
    cmp al, '0'       ; Make sure character is a digit.
565
        cmp     al, '0'       ; Make sure character is a digit.
Line 574... Line 566...
574
    jb .error
566
        jb      .error
575
    cmp al, '9'
567
        cmp     al, '9'
Line 576... Line 568...
576
    ja .error
568
        ja      .error
577
 
569
 
578
    ; Convert single character to digit and save to memory for
570
    ; Convert single character to digit and save to memory for
579
    ; transfer to the FPU.
571
    ; transfer to the FPU.
580
 
572
 
581
    sub al, '0'
573
        sub     al, '0'
582
    mov ah, 0
574
        mov     ah, 0
583
    mov [tmp], ax
575
        mov     [tmp], ax
584
 
576
 
585
    ; Multiply current value by 10 and add in digit.
577
    ; Multiply current value by 10 and add in digit.
586
 
578
 
587
    fmul dword [ten]
579
        fmul    dword [ten]
588
    fiadd word [tmp]
580
        fiadd   word [tmp]
589
    inc di
581
        inc     di
590
    cmp si, di         ; Jump if end of string has been reached.
582
        cmp     si, di         ; Jump if end of string has been reached.
Line 591... Line 583...
591
    je .exit
583
        je      .exit
592
    jmp .mainLoop
584
        jmp     .mainLoop
Line 593... Line 585...
593
 
585
 
594
  .error:
586
  .error:
595
    stc                ; Set error (carry) flag.
587
        stc                ; Set error (carry) flag.
596
    ret
588
        ret
Line 597... Line 589...
597
 
589
 
598
  .exit:
590
  .exit:
599
    clc                ; Clear error (carry) flag.
591
        clc                ; Clear error (carry) flag.
600
    ret
592
        ret
Line 601... Line 593...
601
 
593
 
602
 
594
 
603
atof_convertFractionalPart:
595
atof_convertFractionalPart:
604
    fld1               ; Load 1 to TOS.  This will be the value of the decimal place.
596
        fld1               ; Load 1 to TOS.  This will be the value of the decimal place.
Line 605... Line 597...
605
 
597
 
606
  .mainLoop:
598
  .mainLoop:
607
    cmp si, di         ; Jump if end of string has been reached.
599
        cmp     si, di         ; Jump if end of string has been reached.
Line 608... Line 600...
608
    je .exit
600
        je      .exit
609
    inc di             ; Move past the decimal point.
-
 
610
    cmp si, di         ; Jump if end of string has been reached.
-
 
611
    je .exit
601
        inc     di             ; Move past the decimal point.
612
    mov al, [bx + di]
-
 
613
    cmp al, '0'        ; Make sure character is a digit.
602
        cmp     si, di         ; Jump if end of string has been reached.
614
    jb .error
-
 
615
    cmp al, '9'
-
 
616
    ja .error
-
 
617
    fdiv dword [ten]   ; Next decimal place
603
        je      .exit
618
    sub al, '0'
-
 
619
    mov ah, 0
604
        mov     al, [bx + di]
620
    mov [tmp], ax
-
 
621
 
605
        cmp     al, '0'        ; Make sure character is a digit.
622
    ; Load digit, multiply by value for appropriate decimal place,
606
        jb      .error
623
    ; and add to current total.
607
        cmp     al, '9'
624
 
608
        ja      .error
625
    fild  word [tmp]
609
        fdiv    dword [ten]   ; Next decimal place
626
    fmul  st0, st1
610
        sub     al, '0'
627
    faddp st2, st0
611
        mov     ah, 0
628
    jmp .mainLoop
612
        mov     [tmp], ax
629
 
613
 
630
  .error:
614
    ; Load digit, multiply by value for appropriate decimal place,
631
    stc           ; Set error (carry) flag.
615
    ; and add to current total.
632
    fstp st0    ; Pop top of fpu stack.
616
 
633
    ret
617
        fild    word [tmp]
634
 
618
        fmul    st0, st1
635
  .exit:
619
        faddp   st2, st0
636
    clc              ; Clear error (carry) flag.
620
        jmp     .mainLoop
637
    fstp st0    ; Pop top of fpu stack.
621
 
638
    ret
622
  .error:
639
 
623
        stc           ; Set error (carry) flag.
640
;   *********************************************
624
        fstp    st0    ; Pop top of fpu stack.
641
;   ******* WINDOW DEFINITIONS AND DRAW *********
625
        ret
642
;   *********************************************
626
 
643
 
627
  .exit:
644
draw_window:
628
        clc              ; Clear error (carry) flag.
645
    
629
        fstp    st0    ; Pop top of fpu stack.
646
    mov  eax,12
630
        ret
647
    mov  ebx,1
631
 
648
    mcall
632
;   *********************************************
649
                                   
633
;   ******* WINDOW DEFINITIONS AND DRAW *********
650
    mov  eax,48
634
;   *********************************************
651
    mov  ebx,3
635
 
652
    mov  ecx,sc
636
draw_window:
-
 
637
        mcall   12, 1
-
 
638
 
-
 
639
        mcall   48, 3, sc, sizeof.system_colors
-
 
640
 
-
 
641
        mcall   48, 4
-
 
642
 
-
 
643
        mov     ecx, eax
-
 
644
        xor     eax, eax                     
-
 
645
        mov     ebx, 200 shl 16 + 256
-
 
646
        add     ecx, 200 shl 16 + 158
-
 
647
        mov     edx, [sc.work]
-
 
648
        or      edx, 0x34000000
-
 
649
        mov     edi, title
-
 
650
        mcall
-
 
651
 
-
 
652
        mov     eax, 8
-
 
653
        mov     ebx, 19 shl 16 + 28
-
 
654
        mov     ecx, 49 shl 16 + 18
-
 
655
        mov     edx, 6
-
 
656
        mov     esi, [sc.work_button]
-
 
657
        mov     edi, 7
-
 
658
newbutton:
-
 
659
        dec     edi
-
 
660
        jnz     no_new_row
-
 
661
        mov     edi, 7
-
 
662
        mov     ebx, 19 shl 16 + 28
Line 653... Line -...
653
    mov  edx,sizeof.system_colors
-
 
654
    mcall
-
 
655
 
-
 
656
    mov  eax,48
-
 
657
    mov  ebx,4
-
 
658
    int  0x40
-
 
659
    mov  ecx, eax
-
 
660
    xor  eax,eax                     
-
 
661
    mov  ebx,200 shl 16+256        
-
 
662
    add  ecx,200 shl 16+158
-
 
663
    mov  edx,[sc.work]
-
 
664
    or   edx,0x34000000
-
 
665
    mov  edi,title
663
        add     ecx, 20 shl 16
666
    mcall
-
 
667
 
-
 
668
    mov  eax,8
-
 
669
    mov  ebx,19 shl 16+28
-
 
Line -... Line 664...
-
 
664
no_new_row:
670
    mov  ecx,49 shl 16+18
665
        mcall
Line 671... Line 666...
671
    mov  edx,6
666
        add     ebx, 30 shl 16
672
    mov  esi,[sc.work_button]
667
        inc     edx
673
    mov  edi,7
668
        cmp     edx, 39
-
 
669
        jbe     newbutton
-
 
670
 
-
 
671
        mcall   , <199, 28>, <49, 18>, 2        ; 'C'
-
 
672
        mcall   , <220,  8>, < 7,  8>, 3        ; 'dec-bin-hex'
-
 
673
 
-
 
674
 
-
 
675
        mov     ecx, [sc.work_button_text]
-
 
676
        mov     edx, text
-
 
677
        mov     edi, 55 - 20
-
 
678
next_line:
-
 
679
        inc     edx
-
 
680
        and     edi, 0x0000ffff
-
 
681
        add     edi, 20 SHL 16 + 20
-
 
682
next_button:
-
 
683
        movzx   esi, byte[edx - 1]
-
 
684
        imul    eax, esi, 6
-
 
685
        neg     eax
-
 
686
        add     eax, 29
-
 
687
        shr     eax, 1
-
 
688
        shl     eax, 16
-
 
689
        mov     ebx, edi
Line 674... Line -...
674
  newbutton:
-
 
675
    dec  edi
-
 
676
    jnz  no_new_row
-
 
677
    mov  edi,7
-
 
678
    mov  ebx,19 shl 16+28
-
 
679
    add  ecx,20 shl 16
-
 
680
  no_new_row:
-
 
681
    mcall
-
 
682
    add  ebx,30 shl 16
-
 
683
    inc  edx
-
 
684
    cmp  edx,39
-
 
685
    jbe  newbutton
-
 
686
  
-
 
687
    mcall  ,199 shl 16+28,49 shl 16+18,2               ; 'C'
-
 
688
    mcall  ,220 shl 16+8,7 shl 16+8,3                     ; 'dec-bin-hex'
-
 
689
 
-
 
690
    mov  eax,4
-
 
691
    mov  ebx,27 shl 16+55
-
 
692
    mov  ecx,[sc.work_button_text]
-
 
693
    mov  edx,text
-
 
694
    mov  esi,33
-
 
695
  newline:
-
 
696
    mcall
-
 
697
    add  ebx,20
-
 
698
    add  edx,33
-
 
699
    cmp  [edx],byte 'x'
690
        add     ebx, eax
700
    jne  newline
691
        mcall   4
701
    
692
        add     edx, esi
702
    call print_display
693
        inc     edx
703
    
694
        add     edi, 30 SHL 16
704
    mov  eax,12
695
        cmp     [edx - 1], byte 0
705
    mov  ebx,2
696
        jne     next_button
706
    mcall
-
 
707
 
-
 
708
    ret
-
 
709
 
-
 
710
print_display:
-
 
711
    pusha
-
 
712
    mcall 13,18 shl 16+210,19 shl 16+13,0xffffff
-
 
713
 
697
        cmp     [edx], byte 'x'
714
    mov  eax,4
-
 
715
    mov  ebx,135 shl 16+7
-
 
716
    mov  ecx,[sc.work_text]
-
 
717
    or   ecx,0x40000000
-
 
718
    mov  edx,calc
-
 
719
    mov  esi,1
698
        jne     next_line
720
    mov  edi,[sc.work]
-
 
721
    mcall
-
 
722
 
-
 
723
    mov  ebx,198 shl 16+8
-
 
724
    mov  edx,[display_type]
-
 
725
    shl  edx,2
-
 
726
    add  edx,display_type_text
-
 
727
    mov  esi,3
-
 
728
    mov  edi,[sc.work]
-
 
729
    mcall
-
 
730
   
-
 
731
    cmp  [dsign],byte '+'
-
 
732
    je   positive
-
 
733
    mov  ebx,23 shl 16+22
-
 
734
    mov  ecx,0x0
-
 
735
    mov  edx,dsign
-
 
736
    mov  esi,1
-
 
737
    mcall  
-
 
738
 
-
 
739
positive:  
-
 
740
    cmp  [display_type],0
-
 
741
    jne  no_display_decimal
-
 
742
    cmp  [decimal],0
-
 
743
    je   whole
-
 
744
 
-
 
745
    mov  ebx,180 shl 16+22
-
 
746
    mov  ecx,0x0
-
 
747
    mov  edx,dot
-
 
748
    mov  esi,1
-
 
749
    mcall
-
 
750
    
-
 
751
    mov  eax,47
-
 
752
    mov  ebx,10 shl 16
-
 
753
    mov  ecx,[integer]
-
 
754
    mov  edx,120 shl 16+22
-
 
755
    mov  esi,0x0
-
 
756
    mcall     
-
 
757
    
-
 
758
    mov  ebx,6 shl 16
-
 
Line 759... Line 699...
759
    mov  ecx,[decimal]
699
 
760
    mov  edx,187 shl 16+22     
700
        call    print_display
761
    mov  esi,0x0
-
 
762
    mcall 
-
 
763
 
-
 
764
    popa
-
 
765
    ret
-
 
766
    
-
 
767
whole:
-
 
768
    mov  ebx,220 shl 16+22
-
 
769
    mov  ecx,0x0
-
 
770
    mov  edx,dot
-
 
771
    mov  esi,1
-
 
Line 772... Line -...
772
    mcall
-
 
773
 
-
 
774
    cmp  [integer],0
-
 
775
    je  null
701
 
776
 
-
 
777
    mov  eax,47
-
 
778
    mov  ebx,10 shl 16
-
 
779
    mov  ecx,[integer]
702
        mcall   12, 2
780
    mov  edx,160 shl 16+22
-
 
781
    mov  esi,0x0
-
 
Line -... Line 703...
-
 
703
        ret
-
 
704
 
-
 
705
print_display:
782
    mcall
706
        pusha
-
 
707
        mcall   13, <19, 209>, <19, 13>, 0xffffff
-
 
708
 
-
 
709
        mov     eax, 4
-
 
710
        mov     ebx, 135 shl 16 + 7
-
 
711
        mov     ecx, [sc.work_text]
-
 
712
        or      ecx, 0x40000000
-
 
713
        mov     edx, calc
-
 
714
        mov     esi, 1
-
 
715
        mov     edi, [sc.work]
-
 
716
        mcall
-
 
717
 
-
 
718
        mov     ebx, 198 shl 16 + 8
-
 
719
        mov     edx, [display_type]
-
 
720
        shl     edx, 2
-
 
721
        add     edx, display_type_text
-
 
722
        mov     esi, 3
-
 
723
        mov     edi, [sc.work]
-
 
724
        mcall
-
 
725
 
-
 
726
        cmp     [dsign], byte '+'
-
 
727
        je      positive
783
 
728
        mcall   , <23, 22>, 0, dsign, 1
Line 784... Line 729...
784
    popa
729
 
785
    ret
730
positive:  
786
              
731
        cmp     [display_type], 0
787
  no_display_decimal:
732
        jne     no_display_decimal
788
    cmp  [display_type],1
733
        cmp     [decimal], 0
789
    jne  no_display_hexadecimal
734
        je      whole
790
    cmp  [integer],0
735
 
791
    je  null
736
        mcall   , <180, 22>, 0, dot, 1
792
    
737
        mcall   47, <10, 0>, [integer], <120, 22>, 0
793
    mov  eax,47
738
        mcall   , <6, 0>, [decimal], <187, 22>, 0
794
    mov  ebx,256+8 shl 16
739
 
795
    mov  ecx,[integer]
740
        popa
796
    mov  edx,173 shl 16+22
741
        ret
797
    mov  esi,0x0
742
 
798
    mcall
743
whole:
799
 
744
        mcall   , <220, 22>, 0, dot, 1
800
    popa
745
 
801
    ret
746
        cmp     [integer], 0
802
 
747
        je      null
803
  no_display_hexadecimal:
748
        mcall   47, <10, 0>, [integer], <160, 22>, 0
Line 804... Line 749...
804
    cmp  [integer],0
749
        popa
Line 805... Line 750...
805
    je  null
750
        ret
Line 806... Line 751...
806
 
751
 
807
    mov  eax,47
752
no_display_decimal:
808
    mov  ebx,2*256+32 shl 16
753
        cmp     [display_type], 1
809
    mov  ecx,[integer]
754
        jne     no_display_hexadecimal
810
    mov  edx,32 shl 16+22
755
        cmp     [integer], 0
811
    mov  esi,0x0
756
        je      null
812
    mcall
757
        mcall   47, <8, 256>, [integer], <173, 22>, 0
813
 
758
        popa
814
    popa
759
        ret
815
    ret
760
 
816
  
761
no_display_hexadecimal:
817
  null:
762
        cmp     [integer], 0
818
    mov  eax,47
763
        je      null
819
    mov  ebx,1 shl 16
764
        mcall   47, <32, 2*256>, [integer], <32, 22>, 0
820
    mov  ecx,0
765
        popa
821
    mov  edx,214 shl 16+22
766
        ret
822
    mov  esi,0x0
767
 
823
    mcall
768
null:
824
 
769
        mcall   47, <1, 0>, 0, <214, 22>, 0
825
    popa
770
        popa
826
    ret
771
        ret
827
 
772
 
Line 828... Line 773...
828
clear_all:
773
clear_all:
829
    pusha
774
        pusha
830
    mov  [calc],' '
775
        mov     [calc], ' '
831
    mov  [integer],0
776
        mov     [integer], 0
Line 832... Line 777...
832
    mov  [decimal],0
777
        mov     [decimal], 0
833
    mov  [id],0
778
        mov     [id], 0
834
    mov  [dsign],byte '+'
779
        mov     [dsign], byte '+'
835
    mov  esi,muuta0
780
        mov     esi, muuta0
836
    mov  edi,muuta1
781
        mov     edi, muuta1
837
    mov  ecx,18
782
        mov     ecx, 18
838
    cld
783
        cld
Line 839... Line 784...
839
    rep  movsb
784
        rep     movsb
840
    mov  esi,muuta0
785
        mov     esi, muuta0
Line 841... Line 786...
841
    mov  edi,muuta2
786
        mov     edi, muuta2
Line 842... Line 787...
842
    mov  ecx,18
787
        mov     ecx, 18
-
 
788
        cld
-
 
789
        rep     movsb