RProgN, 142 Bytes, Non-competing
function tostack 'b' asoc stack 'a' asoc 0 'v' asoc b pop byte 'o' asoc b len while [ v o b pop byte ] 'o' asoc - + 'v' asoc b len end [ v end
Non-competing, as the 'tostack' command was added after the discovery of this challenge (even though it has a terrible byte count)
function # Push the function between this and end to the stack
tostack 'b' asoc # Convert the implicit input to a stack, associate it with 'b'
0 'v' asoc # Push 0 to the stack, associate it with 'v'
b pop byte 'o' asoc # Pop the top value of b (The end of the input), get the byte value, associate it with 'o'.
b len # Push the size of b to the stack
while [ # While the top of the stack is truthy, pop the top of the stack
v # Push v to the stack
o # Push o to the stack
b pop byte # Pop the top value of b, push the byte value of that to the stack
] 'o' asoc # Push a copy of the top of the stack, associate it with 'o'
- # Subtract the top of the stack from one underneith that, In this case, the old value of o and the byte.
+ # Sum the top of the stack and underneith that, that is, the difference of the old value and new, and the total value
'v' asoc # Associate it with 'v'
b len # Push the size of b to the stack (which acts as the conditional for the next itteration)
end [ # Pop the top of the stack, which will likely be the left over size of b
v # Push the value of v to the top of the stack
end # Implicitely returned / printed
RProgN is an esoteric language I've been working on with Reverse Polish Notation in mind. It's currently pretty verbose, with it's variable assignment being 4 characters, and such, however I plan to in future add a bit of syntatic sugar.
Also, RProgN implicitly accesses arguments from the stack, and returns them the same way. Any string data left in the stack after the program has finished, is implicitly printed.