what westor is after is the ability to work in bit ranges. to say: Everything I'm passing is 16bit or 32bit. The end goal is to have a proper binary variable representation still in the native 8bit. (The ability to ADD/INSERT/APPEND a word/nword/long/nlong rather than have to convert it into high/low bits)
So like /bset <&var> <N> <value> [value value]
N represents the position, value is a range of 0-255
if we used a flag for 16bit, now "value" is of range 0-65535.
if we used a flag for 32bit, now "value" is of range 0-4294967295.
if we were to translate this from 16bit, we'd need the high/low (split 16bit into two 8bit values) also N would need to reflect this as well, so if N was 2, now we gotta think it's 8bit, so the "position" would be 3 (because our 1st 16bit value is position 1-2, our 2nd 16bit position would be 3-4, etc...) If 32bit, everything doubles, now we need 4 8bit values to represent "value", and 4 positions to store these values...
N can have negative values, -1,-2,-3 etc.. these too need translated to positions in 8bit, this just specifies insert this data N values from the end.
here's a scripted version of the requested functionality:
Nbset {
if ($1 == -w || $1 == -l16) { var %bits = 16 }
elseif ($1 == -nw || $1 == -b16) { var %bits = -16 }
elseif ($1 == -l || $1 == -l32) { var %bits = 32 }
elseif ($1 == -nl || $1 == -b32) { var %bits = -32 }
if (%bits) {
if ($abs(%bits) == 16) {
if (%bits < 0) { bset $2 $iif($3 < 0,$max(1,$calc($bvar($2,0) + $3 * 2 + 1)),$calc(($3 - 1) * 2 + 1)) $regsubex($4-,/(\d+)/g,$calc(\t // 256) $calc(\t % 256)) }
else { bset $2 $iif($3 < 0,$max(1,$calc($bvar($2,0) + $3 * 2 + 1)),$calc(($3 - 1) * 2 + 1)) $regsubex($4-,/(\d+)/g,$calc(\t % 256) $calc(\t // 256)) }
}
elseif ($abs(%bits) == 32) {
if (%bits < 0) { bset $2 $iif($3 < 0,$max(1,$calc($bvar($2,0) + $3 * 4 + 1)),$calc(($3 - 1) * 4 + 1)) $regsubex($4-,/(\d+)/g,$calc($and(\t,4278190080) / 16777216) $calc($and(\t,16711680) / 65536) $calc($and(\t,65280) / 256) $and(\t,255)) }
else { bset $2 $iif($3 < 0,$max(1,$calc($bvar($2,0) + $3 * 4 + 1)),$calc(($3 - 1) * 4 + 1)) $regsubex($4-,/(\d+)/g,$and(\t,255) $calc($and(\t,65280) / 256) $calc($and(\t,16711680) / 65536) $calc($and(\t,4278190080) / 16777216)) }
}
}
else { bset $1- }
}
//nbset -w &a -1 256 | echo -a $bvar(&a,1-) is: $bvar(&a,1).word
0 1 is: 256
//nbset -nw &a -1 256 | echo -a $bvar(&a,1-) is: $bvar(&a,1).nword
1 0 is: 256
//nbset -l &a -1 256 | echo -a $bvar(&a,1-) is: $bvar(&a,1).long
0 1 0 0 is: 256
//nbset -nl &a -1 256 | echo -a $bvar(&a,1-) is: $bvar(&a,1).nlong
0 0 1 0 is: 256