SHARE
TWEET

SGMJQF*ck interpreter by x0wl

a guest Jul 8th, 2012 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $code = $args[0] #quine: <s>g.[<+>[-]j][-]+++++++++++++.q
  2.  
  3. if($code -eq $null){break}
  4.  
  5. $code = $code.ToCharArray()
  6.  
  7. $meptr = 0
  8. $rwptr = 0
  9. $exptr = 0
  10. $exit = $false
  11.  
  12. $memarr = @([int]0) * 65536
  13. $codarr = $code + @([char][int]0) * 66536 + @([char]'q')
  14.  
  15. While($exit -eq $false){
  16.  
  17. $ccode = $codarr[$exptr]
  18.  
  19. switch($ccode){
  20.     '+' {$memarr[$meptr]++;if($memarr[$meptr] -lt 0){$memarr[$meptr] = 0};$exptr++}
  21.     '-' {$memarr[$meptr]--;if($memarr[$meptr] -lt 0){$memarr[$meptr] = 0};$exptr++}
  22.     '>' {$meptr++;if($meptr -lt 0){$meptr=0};$exptr++}
  23.     '<' {$meptr--;if($meptr -lt 0){$meptr=0};$exptr++}
  24.     '[' {
  25.    
  26.          $cchcode = ''
  27.          $cycptr = $exptr
  28.          $cyclelev = 1
  29.  
  30.          if($memarr[$meptr] -ne 0){$cyclelev = 0;$cycptr++}
  31.  
  32.          while ($cyclelev -ne 0){
  33.              $cycptr++
  34.              if($codarr[$cycptr] -eq '['){$cyclelev++}
  35.              if($codarr[$cycptr] -eq ']'){$cyclelev--}
  36.             }
  37.  
  38.          $exptr = $cycptr
  39.         }
  40.     ']' {
  41.          $cchcode = ''
  42.          $cycptr = $exptr
  43.          $cyclelev = 1
  44.  
  45.          if($memarr[$meptr] -eq 0){$cyclelev = 0;$cycptr++}
  46.  
  47.          while ($cyclelev -ne 0){
  48.              $cycptr--
  49.              if($codarr[$cycptr] -eq ']'){$cyclelev++}
  50.              if($codarr[$cycptr] -eq '['){$cyclelev--}
  51.             }
  52.  
  53.          $exptr = $cycptr
  54.         }
  55.     ',' {$memarr[$meptr] = [int]([Console]::ReadKey()).KeyChar; if($memarr[$meptr] -eq 13){''};$exptr++}
  56.     '.' {[Console]::Write([string][char]$memarr[$meptr]); if($memarr[$meptr] -eq 13){''};$exptr++}
  57.     's' {$rwptr = $memarr[$meptr];$exptr++}
  58.     'j' {$exptr = $memarr[$meptr]}
  59.     'm' {$codarr[$rwptr] = [char]$memarr[$meptr];$exptr++}
  60.     'g' {$memarr[$meptr] = [int]$codarr[$rwptr];$exptr++}
  61.     'q' {$exit = $true}
  62.     default {$exptr++}
  63.     }  
  64. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top