BUILDING AN ASSEMBLER step by step (1
Hi ya all ! This is my first attempt to create an assembler called Universal ASM. And I decided to do it step by step sharing with you all. Please appreciate this effort by voting for me and sending your feedback on this project....
AI
Shrnutí AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Zdrojový kód
<pre> ___________________________________________________________ | | BUILDING AN ASSEMBLER | Step By Step | (Session 1) | By Vivek Mohan | | Visit me at http://www.geocities.com/cppresources/ | or shoot me an email at [email protected] | | To join the mailing list for BUILDING AN ASSEMBLER | step by step, mail to [email protected] with the | subject field = join UASM mail with a little info about | yourself. |___________________________________________________________ {{{{ INTRODUCTION }}}} Hi there ! Firstly thanx for taking a look at this. Frankly speaking I'm no ASM Guru, but this is my first attempt towards creating an Assembler. I know very well that there are many people who are really interested in things like this, so I decided to develop step by step, uploading each step and waiting for your feedback on suggestions, bugs and stuff like that. And I hope you appreciate the whole effort by sending me you feedback on this project. You are always welcome to contribute to this project. {{{{ THE ASSEMBLER }}}} I've named the assembler UNIVERSAL ASSEMBLER or UASM. The first version of UASM will assemble for the 8086 intel architecture. UASM will be an integral part of OPOS the open source operating system under development. {{{{ STEP 1 }}}} By the end of this session.. 1. UASM will assemble two simple types of MOV instructions mov offset, accumulator regs mov regs , Imm8/16 2. UASM will assemble the two interrupt instructions int Imm8 int3 3. UASM will assemble the return instructions ret By the end of this session, using UASM we'll be able to use UASM to build a COM program which can print a message. {{ 1.1 }} As the first step I wrote a few file IO routines for parsing the source code. These routines can be found in the file fileio.c {{ 1.2 }} As the second step I wrote a few routines to convert between number systems as they are going to be very important. They can be found in the file math.c {{ 1.3 }} Then came a very important part of the assembler - The x86 instruction processing unit. This is where all the processing takes place. It can be found in the file x86.c. Functions like mmm(..) , rrr(...) return the bit values for corresponding functions and regs. The array x86[] holds the various x86 instructions, so far only the implemented ones. The function mov constructs the mov instruction when the right args are passed. Intr and Ret also do the same for int and ret instructions. Most of the functions have been well connected so you won't have trouble understanding. {{ 1.4 }} UASM.C is the main file. The getinstruction function is like the driver code for the whole thing. It reads the instruction and the corresponding operands. It then calls the right function with the right args passed. Thats enough of coding for the first session.... {{ 1.5 }} Compiling... (using DJGPP) gcc -o uasm.exe uasm.c {{ 1.6 }} Assembling the example1.asm file uasm.exe example1.asm example1.com run the file and you'll see the message 'Hi'; {{{{ Conclusion }}}} Looks like I've made a small working version of uasm. I hope there are no major errors or bugs but if you do find any please mail me. {{{{ Next Session }}}} In the next session the objectives will be to 1. include support for comments 2. support for all single byte instructions 3. support for a few more mov instructions Thats all for now,.... Vivek Mohan </pre> Upload
Původní komentáře (3)
Obnoveno z Wayback Machine