Skip to content

ConorOBrien-Foxx/ntfjc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

NTFJC

An implementation in C of the NTFJ language.

The following is copied from the NTFJ README.

NTFJ is a stack-based language that implements a few commands intrinsic to logic. The name comes from the first letters of the original four commands: NAND, TRUE, FALSE, JUMP.

Commands

  • | - NAND - pops two values A and B and pushes A NAND B; if A and B are both bits, it pushes 1-(A&B); otherwise, it pushes 255-(A&B).
  • ~ - FALSE - pushes 0 to the stack.
  • # - TRUE - pushes 1 to the stack.
  • ^ - JUMP - pops N, and moves the index pointer to the Nth command.
  • * - OUT - pops N, and outputs the character whose char code is N.
  • @ - BYTE - pops eight values V1...V8 and pushes the number V1*(2^8) + ... + V8*(2^1) OR, if V1 > 1, pushes the bits in that number.
  • ( - PEEK - if the top value of the stack is zero, jumps to the next ). (Nested loops are not supported as of now.)
  • ) - ENDPEEK - marks the point at which to continue for zero values.
  • $ - DROP - drops the top value of the stack.
  • : - DUP - duplicates the top value of the stack.
  • / - LENGTH - pushes the number of items in the stack.
  • { - ROTATE - pops N; shifts the stack and pushes it to the front N times.
  • } - REV ROTATE - pops N; pops from the stack and unshifts it N times.
  • ` - debugging tool; logs the state of the stack to the console.

Mnemonics

(We will denote the stack's top element as B, and the second-to-top element as A.)

  • Negate top of stack: :|.
    • (start) A B.
    • (:) A B B.
    • (|) A (B NAND B) = A (NOT B).
  • Conjunction (and): |:|.
    • (start) A B.
    • (|) A NAND B.
    • (:|) NOT(A NAND B) = A AND B.
  • Disjunction (or): :|%:||
    • Because A OR B = (NOT A) NAND (NOT B).

About

C implementation of NTFJ.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages