The biggest time you will use this is BITMASKS where you set a bit in a number to represent options.
lets take a byte:
now lets make a bunch of flags that we can use:
Code:
FLAG1 equ 1d
FLAG2 equ 2d
FLAG3 equ 4d
FLAG4 equ 8d
FLAG5 equ 16d
FLAG6 equ 32d
FLAG7 equ 64d
FLAG8 equ 128d
now in order to apply these flags we use "or"
Code:
.data
Flag db 0
.code
mov eax, FLAG ;eax = 00000000b
or eax, FLAG1 ;eax = 00000001b
;00000000b eax
;00000001b FLAG1
or eax, FLAG3 ;eax = 00000101b
;00000001b eax
;00000100b FLAG3 cause 100b = 4d aka FLAG3
or eax, FLAG6 ;eax = 00100101b
;00000101b eax
;00100000b FLAG6 cause 00100000b = 32d aka FLAG6
as you see we can change the bit in a byte by changing the byte to binary and changing the number we "or" into binary then "or'ing" them together...
@Junior731:
01b = 1d not -1
negative numbers use the SIGN FLAG to determine if the number should be negative or not. dword -1 in programming= 0FFFFFFFFh and will not necessarily set the sign flag. the sign flag is used in math functions, not set on a per data section. (aka all data is positive unless your math made it negative then it is only negative if you use the sign flag to tell if it is.)