I can not fivd any sources explaining how tp write direct opcodes for ISA to work on CPU. Not Assembly, opcodes directly or "machine code".
-
Use the source code, Luke! (c)Borland http://flatassembler.net/download.php – STTR May 19 '13 at 23:53
-
1When you say ISA, can you clarify which ISA? – Scott Chamberlain May 19 '13 at 23:53
-
IA-32 and IA-64, including 16-bit opcodes on x86 architecture. – Dinosaur pawz May 20 '13 at 13:31
-
ISA in regards to what I'm describing would be Instruction Set Architecture. – Dinosaur pawz May 20 '13 at 13:32
1 Answers
You can, but you shouldn't.
You can take any binary file, open it in a text editor and change the bytes. Depending on your editor and OS, some bytes might be tougher to type than others. As long as the editor doesn't do anything extra while trying to read or write that file (because it's trying to treat the file as text) the results will depend entirely on you. You can also create a new file this way. With Windows, just save it with the right extension; on Unix, set the executable bit. The OS will run it, and something will happen.
You need a reference for the CPU that tells you how the operations are encoded. Many operations have several variations due to operand type and addressing mode. You also have to calculate jump offsets and so forth. All that is extremely tedious and error-prone, which is why people invented assemblers.
- 8,065
-
1Also FWIW it would be a lot easier to use a hex editor instead of a text editor (If you still refuse to use an assembler). – Scott Chamberlain May 19 '13 at 23:59
-
FWIW my first boss could program in machine code and generate the octal codes. It did help that the instruction set was small and simple (HP 2100, 16-bit minicomputer, circa 1970s). A lot of the early home computer users (e.g. MITS Altair) knew machine code, as the typical program entry was through the front panel switches! – sawdust May 20 '13 at 00:45
-
Ken, your post is erroneous. I am not writing Windows executables by opcodes, I only plan to write system software, and very limited, minimal sets of them; not for any OS at all, unless maybe my own. – Dinosaur pawz May 20 '13 at 13:34
-
I mentioned Windows and Unix only in their function as a program loader. You will need something to load the file from storage into memory, and pass control to it. Most people use an OS for this; but you could also for example store the code on a disk boot sector, and the BIOS/firmware will load that sector to a fixed addresses and run it there. – Ken May 20 '13 at 19:43