Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Developing an assembler

Developing an assembler

Developing an assembler

      Does any one here has experience in implementing an assembler?. I need to implement an 8086 asssembler as a part of my college project, i have no choice.
Please send any pointers,suggestions to me

RE: Developing an assembler

Most of the lists of instruction opcodes you will find will be in hex.  I suggest you convert them to binary so that you will see some special relationships between certain instructions.  Better yet, find one with those relationships already shown in the binary code numbers.  I have a manual for Masm v.5.00 and it contains that info.

I suggest you limit yourself to assembly into DOS *.com format.

Implement a memory-based database with the following characteristics:
Three fields:
Text Field (variable-length!!!)
Type Field (one byte will do)
Numeric Field (Four bytes, one dword)
This database will contain the labels of the assembly file.  Text Field will contain the name of the label, Type Field the type, Numeric Field the value.

Make sure you know what types your label might be.  Is it an address?
address db 12 ;data address
address: ;code address

A numeric constant value?
constant EQU 32

A string constant value?
s-constant EQU <string>

mov ax,label

can assemble to two different things!  It might mean, load the value of label into ax (since it was defined as EQU), or load the memory area pointed to by label into ax (since it was defined using db or dw or whatnot).

Assign each type you can think of with a separate value for the Type Field of your label database.  Mind you, the label database NEEDS a variable length Text Field.

TIME.  Give yourself that.  Don't tell me you need it in a month, unless you cheat and get someone else's assembler, you can't do that.  Give yourself some three months at the least, maybe more if you feel it difficult.

Good Luck and Have Fun!

"Information has a tendency to be free.  Which means someone will always tell you something you don't want to know."

RE: Developing an assembler

Developing an assembler is sure not an easy task, you need a full idea and knowledge of assembly language and you will also need all the developers manual from Intel. i am not breaking you down but i have tried writing one myself and it ended up in the garbage maybe i'm not too good with it but i strongly suggest you write one for dos and NOT windows do some research online and see where you can get an open source assembler.

RE: Developing an assembler

here is my ten pence worth:

I would use free format (ie text editor) to for the source code.

forget about labels to start

I would create a database for all the command opcodes.

then I would implement a usage database, basically each opcode changes (certain bits) depending on usage ie difference between 'inc eax' and 'inc ebx' etc

each line will decode the text into an opcode then you know how to imterpret the operand.

must go, do later

The people who have nothing to say and say it too loud have little knowledge, It's the quiet ones you need to worry about!

RE: Developing an assembler

i'm back,

the operand field should be quite easy at it is a number of either 8,16,or 32 bits.

Once you have this working you can then concentrait on the labels. All a label does is reference a point within the program. Usually an assembler makes serveral passes over the source code. The first pass produces the opcodes  and calculate the number of bytes each command uses and allowing it to resolve all labels ie give them a number (offset address from start). on the last pass the assembler can calculate the exact value it needs to put into the operand by using the label values and performing adjustments.

lets recap
1st pass the assembler determins opcode and size of command building the basic results and determins program size.
2nd pass the assembler calculates the offset address for all labels defined.
3rd pass the assembler places the calculated value into all the operand where labels have been referenced.

Obviously there are many more apsects to creating an assembler but this should get you going for now.


The people who have nothing to say and say it too loud have little knowledge, It's the quiet ones you need to worry about!

RE: Developing an assembler

You can put things into two simple passes:
First pass - Assemble, but if you encounter an unknown label, make assumptions.  Do NOT generate code.  In the first pass all you're interested in is to get all the labels.  This means you want to keep your program counter ($) updated for 'label:' and 'label proc' type labels.  E.g.
mov al,label1 ;leave one byte for label1 to go into.
jmp label2 ;leave two bytes and assume it's a near jump

Second pass - assemble for real.  Generate code.  If you encounter an unknown label here, tell the user he is stupid.  No, wait, tell him there's an error instead.  Since in the first pass you already made sure the labels are there, there should be no more unknown labels.

More on the label database:
Label database requires simply a record-ADDING routine.  No delete routine is required because we assume labels cannot be removed.  This allows us to use variable sized records more easily.  Each record can be something like this:
byte 0-3: value
byte 4:type
byte 5:label length
byte 6-n:label itself.

"Information has a tendency to be free.  Which means someone will always tell you something you don't want to know."

RE: Developing an assembler

We need 8086 source for assembly language programming... it's very very important for us. If you want to help us send projects at


THANK YOU!!!! )))

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close