9 Replies - 2262 Views - Last Post: 10 August 2012 - 01:37 AM

#1 sameer khanna  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 11-July 12

design problem for Assembler for 8051 microcontroller

Posted 12 July 2012 - 12:12 AM

I want to write a one pass assambler for the 8051 microcontroller. So I need some example how this can be done.
I want to write assambler which can run on 8051 it's self.

Thankyou
Is This A Good Question/Topic? 0
  • +

Replies To: design problem for Assembler for 8051 microcontroller

#2 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3452
  • View blog
  • Posts: 10,653
  • Joined: 05-May 12

Re: design problem for Assembler for 8051 microcontroller

Posted 12 July 2012 - 12:20 AM

Post your code. If you don't have any code, post a general outline of how your assembler will work starting from reading a file, to maintaining a symbol table, to generating the binaries.
Was This Post Helpful? 1
  • +
  • -

#3 Salem_c  Icon User is offline

  • void main'ers are DOOMED
  • member icon

Reputation: 1621
  • View blog
  • Posts: 3,078
  • Joined: 30-May 10

Re: design problem for Assembler for 8051 microcontroller

Posted 12 July 2012 - 01:21 AM

Makes you wonder how much "research" people do, given the amount of information available for anyone with the nouse to go and look for it.

https://encrypted.go...+pass+assembler

And nouse is what you're going to need if you want to write code for an embedded controller. No friendly operating system or range of development tools will keep it challenging.
Was This Post Helpful? 1
  • +
  • -

#4 sameer khanna  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 11-July 12

Re: design problem for Assembler for 8051 microcontroller

Posted 12 July 2012 - 10:55 AM

I want to write code for assembler for the 8051 development board.There are many such development board are available, in which the user can write there program in assembly and also run the program. Some thing like Motorola buffalo monitor program for Motorola micro controller(68HC11F1). But i want to improve this idea.Some of development board available, having the external RAM and ROM. And user can insert there program using a keyboard interface with data bus of the micro controller. When i study them I found that ,When user enter the assembly instruction the inbuilt assembler convert the assembly program line by line and put the op code in to the external ram.I already know how to interface the ram and rom. But I don't no anything about the assembler.I don't have any code to post.
Was This Post Helpful? 0
  • +
  • -

#5 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3452
  • View blog
  • Posts: 10,653
  • Joined: 05-May 12

Re: design problem for Assembler for 8051 microcontroller

Posted 14 July 2012 - 12:57 AM

I would start out first with designing and writing a cross-assembler written in C that reads a file, assembles the program on your PC, and generates a .HEX file for the target processor. Presumably I already have tools that converts a .HEX file to raw bytes that get pushed to the RAM (and/or ROM). Obviously, I'll want to run any generated programs to make sure it works.

Once I have a working assembler, I would replace the file reading module and the .HEX file writing module to just read and write raw bytes from/to RAM. (Hopefully, I was practicing good engineering and writing my code in a modular manner.) Using an existing C cross compiler for the target processor, I would build a .HEX file and push that unto the device. Obviously, it would be time to test again and make sure that the code works.

Once I have a working assembler, then I will iteratively replace my C modules with assembly modules one at a time until I fully port my cross-assembler into a fully native assembler.

I'm under the impression that there are emulators for the target environment. I'd take full advantage of that all through out, but also do sanity checks by running on a real device.

The hard part is designing the assembler.
Was This Post Helpful? 0
  • +
  • -

#6 sameer khanna  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 11-July 12

Re: design problem for Assembler for 8051 microcontroller

Posted 15 July 2012 - 10:40 AM

Thank's all of you

But still I don't understand that inside these trainer there is no way to read a file. And when we just enter a line like "MOV A,R0" it generate equivalent opcode line by line and put them in to external RAM.

Thank you
Was This Post Helpful? 0
  • +
  • -

#7 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3452
  • View blog
  • Posts: 10,653
  • Joined: 05-May 12

Re: design problem for Assembler for 8051 microcontroller

Posted 15 July 2012 - 10:23 PM

This is why in my second paragraph in post #5, I said: "Once I have a working assembler, I would replace the file reading module and the .HEX file writing module to just read and write raw bytes from/to RAM."

Instead of opening a file to read the raw assembler, I would start reading from a memory address (or the device input port). Instead of creating a .HEX file to write the output, I would store the actual opcodes into a particular block of RAM.
Was This Post Helpful? 0
  • +
  • -

#8 sameer khanna  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 11-July 12

Re: design problem for Assembler for 8051 microcontroller

Posted 17 July 2012 - 09:35 AM

Thank you, I know the interfacing of ram and rom with 8051 in assembly and in C.Just I want to know how to convert the assembly program like "MOV A,R1; MOV A,R2;" in to hex file. In your post you told about the bin file generation and hex file generation, Symbol table. I know that when user enter any mnemonic.The one pass assembler uses symbol table to convert mnemonic to opcode. But I am not familiar with algo used for this.So for me a small example is sufficient
Thankyou
Was This Post Helpful? 0
  • +
  • -

#9 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3452
  • View blog
  • Posts: 10,653
  • Joined: 05-May 12

Re: design problem for Assembler for 8051 microcontroller

Posted 18 July 2012 - 12:23 AM

The 8051 opcodes are listed here: http://www.keil.com/...s51_opcodes.htm

You can first match the basic operation to narrow the search, and then look at the parameters to the operation to finalize which opcode is sent to the emitter. If the parameter involves an symbol name representing an offset into code or a memory address, look up or compute those values and send the value out to the emitter as well.
Was This Post Helpful? 0
  • +
  • -

#10 turboscrew  Icon User is offline

  • D.I.C Addict

Reputation: 100
  • View blog
  • Posts: 615
  • Joined: 03-April 12

Re: design problem for Assembler for 8051 microcontroller

Posted 10 August 2012 - 01:37 AM

Remember that 8051 has quite limited address space. The assembler needs to be quite space-efficient.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1