flat assembler
Message board for the users of flat assembler.

Index > Windows > GetVersion-Could be shorter?

Author
Thread Post new topic Reply to topic
HarryTuttle



Joined: 26 Sep 2003
Posts: 211
Location: Poland
HarryTuttle
Code:
include '%fasminc%/win32ax.inc'

; Get the system version
.data
wersja  dd      ?
bufor   rb 20
.code

start:

invoke GetVersion
       mov [wersja],eax
       xor ebx,ebx
       xor ecx,ecx
       and eax,0ffffh
       push eax
       and eax,0ff00h
       shr eax,8
       mov ebx,eax
       pop eax
       and eax,00ffh
       mov ecx,eax
cinvoke wsprintf,bufor,"System version: %d.%d",ecx,ebx
invoke MessageBox,0,bufor,"info",0
       xor eax,eax
       ret
.end start
    


What is the shortest way to present system version?

_________________
Microsoft: brings power of yesterday to computers of today.
Post 11 Feb 2005, 10:47
View user's profile Send private message Reply with quote
HarryTuttle



Joined: 26 Sep 2003
Posts: 211
Location: Poland
HarryTuttle
of course in byte size shorter:

Code:
include '%fasminc%/win32ax.inc'

; Get the system version
.code
start:
invoke GetVersion
       and eax,0ffffh
       push eax
       and eax,0ff00h
       shr eax,8
       mov ebx,eax
       pop eax
       and eax,00ffh
       mov ecx,eax
       pop ebp
       mov ebp,esp
       sub esp,20
       mov esi,esp
cinvoke wsprintf,esi,"System version: %d.%d",ecx,ebx
invoke MessageBox,0,esi,"info",0
       mov esp,ebp
       pop ebp
       xor eax,eax
       ret
.end start 
    

_________________
Microsoft: brings power of yesterday to computers of today.
Post 11 Feb 2005, 10:58
View user's profile Send private message Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard
why do you have to complicate the code so much? Wink

Code:
include '%fasminc%/win32ax.inc'

; Get the system version
.data
wersja  dd      ?
bufor   rb 20
.code

start:

invoke GetVersion

       mov ecx,eax
       and ecx,0xff
       shr eax,8
       and eax,0xff

cinvoke wsprintf,bufor,"System version: %d.%d",ecx,eax
invoke MessageBox,0,bufor,"info",0
       xor eax,eax
       ret
.end start    


works well too Smile
Post 11 Feb 2005, 12:20
View user's profile Send private message Visit poster's website Reply with quote
HarryTuttle



Joined: 26 Sep 2003
Posts: 211
Location: Poland
HarryTuttle
yeah! always could be better!
Code:
include '%fasminc%/win32ax.inc'

; Get the system version
.data
napis:
        db "system version:"
        wersja dd ?
.code
start:
invoke GetVersion
       add eax,3030h
       mov word [wersja],ax
invoke MessageBox,0,napis,0,0
       xor eax,eax
       ret
.end start
    

and how to add the dot between digits? Wink
may be MMX or another staff (I do not know) will helps?

_________________
Microsoft: brings power of yesterday to computers of today.
Post 11 Feb 2005, 13:23
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7795
Location: Kraków, Poland
Tomasz Grysztar
Why not:
Code:
include '%fasminc%/win32ax.inc'

; Get the system version
.data
napis:
        db "system version: "
        mj db ?,'.'
        mn db ?,0
.code
start:
invoke GetVersion
       add eax,3030h
       mov [mj],al
       mov [mn],ah
invoke MessageBox,0,napis,0,0
       xor eax,eax
       ret
.end start     
Post 11 Feb 2005, 13:41
View user's profile Send private message Visit poster's website Reply with quote
HarryTuttle



Joined: 26 Sep 2003
Posts: 211
Location: Poland
HarryTuttle
that's it! THX!

_________________
Microsoft: brings power of yesterday to computers of today.
Post 11 Feb 2005, 14:06
View user's profile Send private message 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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.