Serious part
As pointed out in the comments you cannot load a program into modern computer memory by messing up with switches anymore, it must be in some form of media, in large sense, so that the firmware can load and execute it.
One may program a firmware in a ROM (or similar) with a programmer, this is as close as possible as writing zeros and ones into a computer memory. Note that usually machine code is written in hex rather than binary.
Inside a modern OS you can write machine code with any hex editor, the problem is that program binaries does not contains executable code only. They also contain headers and a lot of "meta" (let's call them this way) data. So you would have to construct a valid structure with all headers, sections and etc.
This is not impossible, it all boils down to some basic math and a good reference, it is just that it is very tedious.
Game part
As a game, If you want to feel the old thrill of writing programs in binary code you can follow the suggestion of Michael and use a boot program that let you write numbers into memory.
I wrote you one for IA32 (likely your architecture), you have to use NASM to assemble it and write the 512 byte output file to any bootable media (Google will help you). Then restart your computer.
Here some limitations (features?)
- You can only use 0, 1 and enter, every thing else is ignored.
- You cannot correct mistakes or overwrite previous written machine code.
- As soon as 8 bit are entered a byte is written in memory.
- Bytes are written one after the other in the order they are collected.
- You cannot write more then 3,5KiB of data if you need more you have to first write a new program for writing into memory and then use it.
- If you hit enter the program will execute the machine code you entered.
- If you hit enter before you have completed a byte, the bits inserted are discarded.
Here me inserting machine code for a program that write Hi on the screen.
Here is the code
BITS 16
jmp 07c0h:WORD __START__
__START__:
mov ax, cs
mov ss, ax
xor sp, sp
push cs
pop ds
push 0b800h
pop es
mov di, 200h ;Write binary code from 7c0h:200h to 7c0h:ffffh, i.e. 3,5KiB
.screen_input:
mov ax, 03h
int 10h
xor si, si
.byte_input:
mov cx, 0800h
.bit_input:
xor ah, ah
int 16h
cmp al, 0dh
je .jump
cmp al, '0'
jb .bit_input
cmp al, '1'
ja .bit_input
mov ah, 0ch
mov WORD [es:si], ax
add si, 02h
shr al, 1
rcl cl, 1
dec ch
jnz .bit_input
mov BYTE [di], cl
inc di
add si, 90h
cmp si, 0fa0h
jae .screen_input
jmp .byte_input
.jump:
jmp 7c0h:200h
TIMES 505-($-__START__) db 0
dw 0aa55h