Permalink
Browse files

Hand written binary strings for InputNum, OutputNum and OutputNewline…

… functions.

These binary strings were completely handwritten without any additional support
except the Intel x86_64 spec sheet and looking at the GCC generated binary disassembly
for the addressing mode used for indirect addressing of the %rsp register.

And why did I hand write this binary? Because I have gone mad. Totally gone mad! :D

On a more serious note, that was not an emotional imbalance ;-) It gives me this
immense pleasure, which I cannot put down in words, to do anything computer science.
It is my dream to be able to brag that I can do anything computer science/programming!
Be it writing web applications (which is seen as something easy or cheap today while it
is not), or be it writing Desktop applications or write a more system level stuff like
Filesystems, drivers etc. or writing real machine binaries!

Also, I love when I can be in total control of the machine! "The Master who is in control
of the machine" and I totally love it when I can issue the instructions to my machine.
This code is also a result of that. Computer is after all a machine!

In addition to all these I have been having this dream from quite a long time to
bootstrap my own compiler from step 1, i.e. handwrite binaries to build an assembler
and use it to build a compiler that compiles my own language. This is one step closer
to that dream! I hope I can take this further!
  • Loading branch information...
madhusudancs committed May 15, 2012
1 parent 734490b commit 66656d22638b5ebe4eb7a3ffb3ef61581405b0b1
Showing with 80 additions and 0 deletions.
  1. +80 −0 precompiled.py
@@ -28,3 +28,83 @@ def entry():
"""
call = CALL()
return call


def input_num():
"48 BF 00 00 00 00 00 00 00 00"

"48 8B F4"

"48 BA 0A 00 00 00 00 00 00 00"

"48 B8 00 00 00 00 00 00 00 00"
"0F 05"
"48 33 C0"
"48 BB 00 00 00 00 00 00 00 00"

"48 8B F4"
"48 8B 0E"

"48 81 F9 0A 00 00 00"
"0F 84 37 00 00 00"

"48 81 FB 0A 00 00 00"
"0F 8F 2A 00 00 00"
"48 81 E9 30 00 00 00"
"48 81 E1 FF 00 00 00"
"48 8B D0"
"48 C1 E0 03"
"48 D1 E2"
"48 03 C2"
"48 03 C1"

"48 FF C6"
"48 FF C3"
"E9 B9 FF FF FF"
"C3"



def output_num():

"48 33 D2"

"48 B9 00 00 00 00 00 00 00 00"
"48 8B C7"
"48 BB 0A 00 00 00 00 00 00 00"
"48 F7 F3"
"48 81 C2 30 00 00 00"
"52"

"48 FF C1"
"48 81 F8 00 00 00 00"
"0F 85 E2 FF FF FF"

"48 81 F9 00 00 00 00"
"0F 8E 2C 00 00 00"

"48 BA 01 00 00 00 00 00 00 00"

"48 8B F4"
"48 BF 01 00 00 00 00 00 00 00"

"48 B8 01 00 00 00 00 00 00 00"
"0F 05"
"48 FF C9"

"5B"
"E9 C7 FF FF FF"
"C3"


def output_newline():

"48 C7 04 24 0A 00 00 00"
"48 BF 01 00 00 00 00 00 00 00"
"48 8B F4"

"48 BA 01 00 00 00 00 00 00 00"

"48 B8 01 00 00 00 00 00 00 00"
"0F 05"
"c3"

0 comments on commit 66656d2

Please sign in to comment.