flat assembler
Message board for the users of flat assembler.

Index > Tutorials and Examples > BTDClock: a simple Win32 GUI Program

Author
Thread Post new topic Reply to topic
yeohhs



Joined: 19 Jan 2004
Posts: 195
Location: N 5.43564° E 100.3091°
yeohhs 13 Dec 2017, 07:57
Sorry, this program is no longer available.


Last edited by yeohhs on 02 Dec 2020, 04:32; edited 2 times in total
Post 13 Dec 2017, 07:57
View user's profile Send private message Visit poster's website Reply with quote
fasmnewbie



Joined: 01 Mar 2011
Posts: 555
fasmnewbie 13 Dec 2017, 09:23
Nice! Camana nak letak color kat text. Mana kod nak ubah?
Post 13 Dec 2017, 09:23
View user's profile Send private message Visit poster's website Reply with quote
yeohhs



Joined: 19 Jan 2004
Posts: 195
Location: N 5.43564° E 100.3091°
yeohhs 13 Dec 2017, 10:43
Kod ini: invoke SetTextColor,[wparam],[hcolortx] ; set edit control's text color

SetTextColor is a Windows API function. Tak perlu ubah kod. User boleh pilih warna dari Window's standard color dialog. Lihat SelectTextColor proc.
Post 13 Dec 2017, 10:43
View user's profile Send private message Visit poster's website Reply with quote
fasmnewbie



Joined: 01 Mar 2011
Posts: 555
fasmnewbie 13 Dec 2017, 13:23
Thanks for the clue. Sekarang tengah cari font digital. nak ubah appearance n size. Nanti siap aku share.
Post 13 Dec 2017, 13:23
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20516
Location: In your JS exploiting you and your system
revolution 13 Dec 2017, 13:25
Erm, Malay language? Looks somewhat familiar from a project I did about 12 years ago. Ah the memories.
Post 13 Dec 2017, 13:25
View user's profile Send private message Visit poster's website Reply with quote
fasmnewbie



Joined: 01 Mar 2011
Posts: 555
fasmnewbie 13 Dec 2017, 17:41
revolution wrote:
Erm, Malay language? Looks somewhat familiar from a project I did about 12 years ago. Ah the memories.
A language project? Or did u spend some time down here? Btw, FASM has seen actions in the deepest jungle of Borneo! Congratulations to FASM Very Happy
Post 13 Dec 2017, 17:41
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20516
Location: In your JS exploiting you and your system
revolution 13 Dec 2017, 17:49
fasmnewbie wrote:
Or did u spend some time down here?
Yes. Some extended time in KL with one of our clients.

It is one of the few languages I've heard that I was actually able to pick-up without really trying hard. Although having not used for 12 years now I've forgotten most of it again. Sad
Post 13 Dec 2017, 17:49
View user's profile Send private message Visit poster's website Reply with quote
yeohhs



Joined: 19 Jan 2004
Posts: 195
Location: N 5.43564° E 100.3091°
yeohhs 13 Dec 2017, 21:52
fasmnewbie wrote:
Nanti siap aku share.


Baik.
Post 13 Dec 2017, 21:52
View user's profile Send private message Visit poster's website Reply with quote
yeohhs



Joined: 19 Jan 2004
Posts: 195
Location: N 5.43564° E 100.3091°
yeohhs 13 Dec 2017, 22:01
revolution wrote:
Looks somewhat familiar from a project I did about 12 years ago. Ah the memories.


Very Happy I love my asm coding memories all the way back to 2003 when I started with SpAsm/RosAsm. Then I moved on to Flat Assembler, which is even more awesome.
Post 13 Dec 2017, 22:01
View user's profile Send private message Visit poster's website Reply with quote
MHajduk



Joined: 30 Mar 2006
Posts: 6115
Location: Poland
MHajduk 14 Dec 2017, 00:04
Hi yeohhs.

I think that the sources are quite neat and many people here could take it as an example of good coding techniques.

After a quick review of the source I have found a place in the code that, in my opinion, could be optimized a bit. I mean here the 'GetTime' procedure.

Here is your original code:
Code:
proc GetTime,TimeBuffer,TimeFormat
local mst:MYSYSTEMTIME,\
      dHour:DWORD,dMinute:DWORD,dSecond:DWORD

     invoke GetLocalTime, addr mst
     xor eax, eax
     mov ax,word[mst.wHour]
     mov [dHour],eax
     ;mov [dHour],0
     xor eax, eax
     mov ax,word[mst.wMinute]
     mov [dMinute],eax
     ;mov [dMinute],0
     xor eax, eax
     mov ax,word[mst.wSecond]
     mov [dSecond],eax
     ;mov [dSecond],0
     .if [TimeFormat] = 0
         cinvoke wsprintfA,[TimeBuffer],TimeFmt0,[dHour],[dMinute],[dSecond]
     .elseif [TimeFormat] = 1
         cinvoke wsprintfA,[TimeBuffer],TimeFmt1,[dHour],[dMinute],[dSecond]
     .elseif [TimeFormat] = 2
         .if [dHour] > 12
             sub [dHour],12
             cinvoke wsprintfA,[TimeBuffer],TimeFmt2PM,[dHour],[dMinute],[dSecond]
         .elseif [dHour] = 12
             cinvoke wsprintfA,[TimeBuffer],TimeFmt2PM,[dHour],[dMinute],[dSecond]
         .elseif [dHour] = 0
             add [dHour],12
             cinvoke wsprintfA,[TimeBuffer],TimeFmt2AM,[dHour],[dMinute],[dSecond]
         .else
             cinvoke wsprintfA,[TimeBuffer],TimeFmt2AM,[dHour],[dMinute],[dSecond]
         .endif
     .endif
     ret
endp    
And here is my proposition of optimization (main differences are in the second part of the procedure body):
Code:
proc    GetTime, TimeBuffer, TimeFormat
push    ebx ecx edx
local   mst:MYSYSTEMTIME,\
        dHour:DWORD, dMinute:DWORD, dSecond:DWORD

        invoke  GetLocalTime, addr mst
        xor     eax, eax
        mov     ax, word[mst.wHour]
        mov     [dHour], eax

        xor     eax, eax
        mov     ax, word[mst.wMinute]
        mov     [dMinute], eax

        xor     eax, eax
        mov     ax, word[mst.wSecond]
        mov     [dSecond], eax

        .if [TimeFormat] = 0
                mov ebx, TimeFmt0 
        .elseif [TimeFormat] = 1
                mov ebx, TimeFmt1 
        .elseif [TimeFormat] = 2
                .if [dHour] >= 12
                        mov ebx, TimeFmt2PM
                .else
                        mov ebx, TimeFmt2AM
                .endif

                mov     eax, [dHour]

                ; Transformation from the 24h format to the 12h format
                ; f: Z -> {1,2,3, ..., 12}
                ; f(x) = (x - 1) mod 12 + 1
                ;
                ; or equivalently
                ; f(x) = (x + 11) mod 12 + 1
                ;
                add     eax, 11
                xor     edx, edx
                mov     ecx, 12
                div     ecx
                inc     edx
                mov     [dHour], edx
        .endif

        cinvoke wsprintfA, [TimeBuffer], ebx, [dHour], [dMinute], [dSecond]
        pop     edx ecx ebx
        ret
endp    
Transformation from the 24h model to 12h model may be done with use of the following function


\newline f: \mathbb{Z} \rightarrow \{1, 2, \ldots, 12\} \newline f(x) = (x - 1) \bmod 12 +1
i.e. in other words
f(x) = (x + 11) \bmod 12 +1
Post 14 Dec 2017, 00:04
View user's profile Send private message Visit poster's website Reply with quote
yeohhs



Joined: 19 Jan 2004
Posts: 195
Location: N 5.43564° E 100.3091°
yeohhs 14 Dec 2017, 03:03
MHajduk wrote:

I think that the sources are quite neat and many people here could take it as an example of good coding techniques.

After a quick review of the source I have found a place in the code that, in my opinion, could be optimized a bit. I mean here the 'GetTime' procedure.

Hi MHajduk,

I hope the sources are readable. Thanks for your optimized code. It's elegant. By the way, I visited your website. It's interesting.
Post 14 Dec 2017, 03:03
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.