@BMODVAL — Modifies a value in a binary buffer.

Syntax:
%@BMODVAL[handle,offset,wordsize,operation,value,fmt,flags]

handlea handle returned by @BALLOC
offsetthe starting offset, in bytes, from the start of the buffer
wordssizethe size of the value to return: 1 a byte, 2 a word, 4 a doubleword, 8 a 64-bit integer
operationone of:
    AND or &: logical-ANDs the value in the buffer with value
    OR or |: logical-ORs the value in the buffer with value
    XOR: logical-XORs the value in the buffer with value
    ADD or +: adds value to the value in the buffer
    SUBTRACT or -: subtracts value from the value in the buffer
    SHL or <<: shifts the value in the buffer left value bits
    SHR or >>: shifts the value in the buffer right value bits
fmtthe format in which to return the value
flagsbitmapped:
     1: big-endian

@BMODVAL reads a value from a binary buffer, performs the requested operation on it, writes the new value back to the binary buffer, and returns the new value in the specified format.

If the value begins with either a + or - sign, the value is treated as a signed value; otherwise it’s unsigned. Either way, the value must fall within the range specified by the wordsize parameter.

The optional fmt parameter specifies the format for the returned value. If you are ignoring @BMODVAL’s return value, then its format doesn’t matter.

0unsigned decimal (the default)
1signed decimal
2hexadecimal with a leading 0x
3hexadecimal without any prefix
4octal

Operation-specific notes: