Jump to content
Welcome, welcome! Come in and register, and have some developer coffee. 👨‍💻 ×

A simple Linux x64 compiler


Recommended Posts

https://github.com/khanming/Pipit

What is Pipit?

Pipit is a new but simple programming language designed for Linux x64.
The compiler itself was written in Pascal.

Why another programming language?

It was a byproduct while the author was learning ELF64 binary file format and Linux system programming.
Moreover, Pipit is not a fully-fledged programming language, it is an experimental back-end compiler which accepts two I/O commands only.

How to use Pipit?

For Ubuntu and Debian, please enable permission to execute:
 

CODE
chmod u=rwx,g=rx,o=rx pipit



For Chrome OS, please enable file system permission:
 

CODE
sudo mount -o remount,rw -o exec ~

(~/Downloads contains pipit)

CODE
chmod u=rwx,g=rx,o=rx pipit



To run pipit, simply use the following example:
 

CODE
./pipit test.txt



Then, to run test, simply type:
 

CODE
./test



Example Code
 

CODE
WriteLine Hello World


 

CODE
WriteLine Press Enter to continue...
ReadLine



You can have up to 100 lines mixing ReadLine and WriteLine commands in a single source file.
If you want to change the upper bound limit, just change the pipit.pas and recompile using FPC 3.2.x for Linux x64.

Do you mind to elaborate a bit about the Pascal source code pipit.pas?

There is nothing cryptic about most part of this pipit.pas, maybe except the CPU machine code.

For each WriteLine and ReadLine, the following CPU instructions were translated to corresponding machine code.

WriteLine
 

CODE
MOV EDX, len
LEA RSI, [addr]
MOV EDI, 0x1     ;StdOut
MOV EAX, 0x1
SYSCALL



ReadLine
 

CODE
MOV EDX, len
LEA RSI, [addr]
XOR EDI, EDI    ;StdIn
XOR EAX, EAX
SYSCALL



You would not see the exact copy of CPU instructions above in pipit.pas. These CPU opcodes are assigned to the cs byte-array one hexadecimal number after another (prefixed with dollar sign).

Pipit_main.zip

Edited by Mussel
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...