Creating an executable file without a compiler
I came across an article a long while ago on how to write out a .com file directly without using any exte开发者_Python百科rnal tools. The method was to basically copy con myfile.com and then hit ctrl+alt+number for each instruction.
I've lost the url for the guide... Google isn't helping much either.
If you have the link, please could you post it.
You don't need an article for it; what you've described is the entire tail end of the process. Just make sure you use the keypad numbers and not the toprow numbers.
For the beginning, you'll need to hand-assemble the program. Unless you're into pain I recommend you find yourself an actual assembler or compiler instead.
Insipred by Ignacio Vazquez-Abrams I found this link, which uses ECHO
in stead of COPY CON
.
There's also debug.exe that comes with most versions of Windows before Vista. You can use it as an assembler, disassembler, debugger, etc. and also code COM executables with x86 assembly with it. It may or may not fit your definition of a "compiler".
The article Legion2000 SR iqlord's eXtreme coding describes the process, and has a list of the alt codes with related asm and hex values.
The article that got me interested in this topic was Bootstrapping a simple compiler from nothing. It looks like an interesting challenge, but I haven't tried it myself.
Scheme from Scratch is an example of someone working on the challenge of bootstrapping a compiler.
This is doable because .com programs aren't relocatable, so they don't need relocation tables, so the header is a fixed size. Not true for .exe files. I don't recall the header details off the top of my head (believe it or not, I used to!), but if you dig up one of the bibles of the old religion like "Undocumented DOS" or anything that talks about writing TSRs those should have info about the .com header.
精彩评论