Author Topic: Tcalc version 2  (Read 201 times)

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 9988
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Tcalc version 2
« on: August 31, 2022, 04:56:15 PM »
The dialog interface has been redrawn and an addition operation has been added, calculating powers. All seems to work OK.

; «»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»

fpPow proc fpv1:REAL8, fpv2:REAL8

    LOCAL vInt  :QWORD                      ; integer value
    LOCAL pbuf  :QWORD                      ; buffer pointer
    LOCAL buff[64]:BYTE                     ; 64 byte buffer

    mov pbuf, ptr$(buff)                    ; get pointer

    rcall GetWindowText,hEdit2,pbuf,64      ; get the text from hEdit2
    mov vInt, uval(pbuf)                    ; convert it to an integer

    movsd xmm0, fpv1                        ; load 1st stack arg into xmm0
    movsd xmm1, xmm0                        ; make a copy of xmm0

    .if vInt { 2
      invoke MsgboxI,hWnd,"The power value must be two or greater", \
                          "Incorect power value",MB_OK,10
    .endif

    .if vInt == 2
      mulsd xmm0, xmm1                      ; simple case
      jmp show
    .endif

  @@:
    mulsd xmm0, xmm1                        ; looped case
    sub vInt, 1
    jnz @B

  show:
    movsd fpv2, xmm0                        ; store xmm0 in stack arg
    rcall fptoa,fpv2,pbuf                   ; convert stack arg to string
    rcall SetWindowText,hEdit3,pbuf         ; display it in hEdit3
    rcall SetClipboardText,pbuf             ; copy string

    ret

fpPow endp

; «»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy: