flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > If someone need operations with power 2 numeric ranges

Author
Thread Post new topic Reply to topic
ProMiNick



Joined: 24 Mar 2012
Posts: 798
Location: Russian Federation, Sochi
ProMiNick 05 Mar 2019, 15:01
analog to winversion(\ntddi or similar constants) in HLL SDKs
we not needed to correlate them with GetVersion & GetVersionEx outputs,
because checking allowed api set via LoadLibrary & GetProcAddr is much wiser.
so these constants only for design time and we can define them in any way as we want.
Code:
;======================================================
; SPECIFIC TO OSVERSION SET OF API & SYSCALL INTERFACES
;
; EACH CONSTANT SPECIFIES UNIQE SET OF ACCESIBLE
; FUNCTIONS WITH LIBRARIES THEY ARE IN (OUT OF THE BOX) 
;
; MAKED ASSUMPTION THAT CONSTANT CAN BE SHARED 
; BY COUPLE OF OSES, BUT IN THIS CASE - 
;(SET OF ACCESIBLE FUNCTIONS WITH LIBRARIES THEY ARE IN)
; - SAME FOR THESE OSES
;======================================================
TARGET_MS_OS_ALL                 = $FFFFFFFF
; DOS:
TARGET_DOS                      = $00000001
TARGET_WIN16_WIN3_0_DOS         = $00000002
TARGET_WIN16_WIN3_1_DOS         = $00000004
TARGET_WIN32_WIN3_1_DOS         = $0000000C
; WIN9x:
TARGET_WIN32_WIN4_0_WIN95       = $00000010
TARGET_WIN32_WIN4_1_WIN98       = $00000020
TARGET_WIN32_WIN4_1_WIN98SE     = $00000040
TARGET_WIN32_WIN4_9_WINME       = $00000080
; WINNT:
TARGET_WINNT_WIN3_1_WINNT31     = $00000100
TARGET_WINNT_WIN3_5_WINNT35     = $00000200
TARGET_WINNT_WIN3_5_WINNT351    = $00000400
TARGET_WINNT_WIN4_0_WINNT       = $00000800
TARGET_WINNT_WIN4_0_WINNTSP1    = $00001000
TARGET_WINNT_WIN4_0_WINNTSP2    = $00002000
TARGET_WINNT_WIN4_0_WINNTSP3    = $00004000
TARGET_WINNT_WIN4_0_WINNTSP4    = $00008000
TARGET_WINNT_WIN5_0_WIN2K       = $00010000
TARGET_WINNT_WIN5_1_WINXP       = $00020000
TARGET_WINNT_WIN5_1_WINXPSP1    = $00040000
TARGET_WINNT_WIN5_1_WINXPSP2    = $00080000
TARGET_WINNT_WIN5_1_WINXPSP3    = $00100000
TARGET_WINNT_WIN5_2_WS03        = $00200000
TARGET_WINNT_WIN5_2_WS03SP1     = $00400000
TARGET_WINNT_WIN5_2_WS03SP2     = $00800000
TARGET_WINNT_WIN6_0_VISTA       = $01000000
TARGET_WINNT_WIN6_0_VISTASP1    = $02000000
TARGET_WINNT_WIN6_0_WS08        = $04000000
TARGET_WINNT_WIN6_1_WIN7        = $08000000
TARGET_WINNT_WIN6_1_WIN7SP1     = $10000000
TARGET_WINNT_WIN6_2_WIN8        = $20000000
TARGET_WINNT_WIN6_3_WIN81       = $40000000
TARGET_WINNT_WINA_0_WIN10       = $80000000
; WINCE
;TARGET_WINCE_WINCE1_0           = $00000001
;TARGET_WINCE_WINCE2_0           = $00000002
;TARGET_WINCE_WINCE3_0           = $00000003
;TARGET_WINCE_WINCE4_0           = $00000004
;TARGET_WINCE_WINCE5_0           = $00000005
;TARGET_WINCE_WINCE6_0           = $00000006

; by default TARGET__OS = ALL = $FFFFFFFF    


and fasm1 macros to operate on ranges (in fasmg they could operate much larger ranges)
Code:
macro TARGET__OS_XOR item* { TARGET__OS = TARGET__OS xor (item) }
macro TARGET__OS_ACCEPT item* { TARGET__OS = TARGET__OS or (item) }
macro TARGET__OS_EXTRACT item* { TARGET__OS = TARGET__OS and (not (item)) }
macro TARGET__OS_RANGE range& {
        match begin+,range \{
                assert bsf begin = bsr begin
                TARGET__OS = $FFFFFFFF xor (begin-1) \}
        match end-,range \{
                assert bsf end = bsr end
                TARGET__OS = (end shl 1)-1 \}
        match begin=,end,range \{
                assert end > begin
                assert bsf begin = bsr begin
                assert bsf end = bsr end
                TARGET__OS = ((end shl 1)-1) xor (begin-1) \} }
macro TARGET__OS_EXTRACT_RANGE range& {
        match begin+,range \{
                assert bsf begin = bsr begin
                TARGET__OS = TARGET__OS and (not ($FFFFFFFF xor (begin-1))) \}
        match end-,range \{
                assert bsf end = bsr end
                TARGET__OS = TARGET__OS and (not ((end shl 1)-1)) \}
        match begin=,end,range \{
                assert end > begin
                assert bsf begin = bsr begin
                assert bsf end = bsr end
                TARGET__OS = TARGET__OS and (not (((end shl 1)-1) xor (begin-1))) \} }
macro TARGET__OS_ACCEPT_RANGE range& {
        match begin+,range \{
                assert bsf begin = bsr begin
                TARGET__OS = TARGET__OS or ($FFFFFFFF xor (begin-1)) \}
        match end-,range \{
                assert bsf end = bsr end
                TARGET__OS = TARGET__OS or ((end shl 1)-1) \}
        match begin=,end,range \{
                assert end > begin
                assert bsf begin = bsr begin
                assert bsf end = bsr end
                TARGET__OS = TARGET__OS or (((end shl 1)-1) xor (begin-1)) \} }
        TARGET__OS = TARGET__OS or (((end shl 1)-1) xor (begin-1)) }    


let suppose we targeted GUI 4.0
Code:
macro targetGUI4_0 {
        TARGET__OS_RANGE                TARGET_WINNT_WIN4_0_WINNT+
        TARGET__OS_ACCEPT_RANGE         TARGET_WIN32_WIN4_0_WIN95,TARGET_WIN32_WIN4_9_WINME }    


and we got TARGET__OS=$FFFFF8F0

_________________
I don`t like to refer by "you" to one person.
My soul requires acronim "thou" instead.
Post 05 Mar 2019, 15:01
View user's profile Send private message Send e-mail 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.