Write an interactive Deadfish interpreter

Perl 5, 90 bytes

do{print+(map{$?+=/i|x/-/d/;$?**=1+/s|k/;$?=~s/-1|^256$/0/;"$?
"x/o|c/}/./g),'>> '}while<>

Try it online!

Thanks to @xfix for his help on this previously! Saved 4 bytes thanks to @Xcali!


Haskell, 202

r=pure;-1%c=0%c;256%c=0%c;s%'o'=s<$print s;s%'c'=s%'o';s%'i'=r$s+1;s%'x'=s%'i'
s%'d'=r$s-1;s%'s'=r$s^2;s%'k'=s%'s';s%_=r s;n s(c:[])=s%c;n s(c:f)=s%c>>=(`n`f)
main=p 0;p s=putStr">> ">>getLine>>=n s>>=p

Powershell, 131 126 121 114 113

for($x=0){[char[]](read-host ">>")|%{switch -r($_){"i|x"{$x++}"d"{$x-=!!$x}"s|k"{$x*=$x}"o|c"{$x}}
$x*=$x-ne256}}
  • for($x=0){...} - set the accumulator to 0 and loop forever
  • read-host '>>' - get the user input with prompt >>
  • [char[]](...) - convert the user input to an array of characters
  • |%{...} - perform what's inside {} for each character
  • switch -r($_) - regex switch for each character
  • "i|x"{$x++} - match i or x - increase the accumulator
  • "d"{$x-=!!$x} - match d - decrease $x by !!$x, which will be 0 if $x is 0, and 1 otherwise. This makes sure the accumulator never reaches -1.
  • "s|k"{$x*=$x} - match s or k - square
  • "o|c"{$x} - match o or c - output the accumulator
  • $x*=$x-ne256 - multiply the accumulator by 0 if it is 256 or by 1 otherwise

Example output

>>: xiskso
0
>>: xiskisc
289
>>: ddddo ddddo
285
281
>>: ddddo ddddo
277
273
>>: dddddddo
266
>>: dddddddddo
257
>>: do
0
>>: do
0
>>: io
1
>>:

I guess the implementation of read-host is host specific, so this Powershell host (ConsoleHost) appends : to the specified prompt.