Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Declaring variables in AT 89C51

Status
Not open for further replies.

yasser11

New Member
Hi,
I am working on a project in which I require to store last 8 count values in memory but I am not able to do so. I tried with these instructions:
store EQU 20H
&
DSEG at 20h
store: ds 8
but it is giving errors that unrecognized statements.
Plzz help me asap..
 
What is it that the assembler cannot recognize? Is it the EQU? is it the DSEG? Is it an instruction?

Please try to post the line which produced the error and the exact text of the error. It would also be helpful to know which assemble you are using>
 
What is the content of the line that produced the error?
What was the text of the error?

Most assemblers have rules for recognizing a symbol that begins in column 1. It may or may not be followed by a colon ( : ) character.
Second field on the line is usually either a machine instruction which has to match the instruction set you have chosen. The other fields are operands which also must match the instruction set you have chosen.

I'm not familiar with your TASM since there are at least two varieties.

1. This is the name of the assmebler that comes with the Borland C Compiler. It is designed to recognize the instructions for the 8086, 80186, 80286, 80386, and 80486. That it does not recognize the instructions for the 8051 is hardly a surprise. You just can't be expecting that -- can you?

2. This is also the name for a configurable, retargetable assembler. If it is configured to assemble 6805 code then it seems hardly surprising that it would not recognize 8051 instructions.

In any case I suspect operator error of some kind is at the root of your problem. When you choose to communicate sufficient additional useful information, maybe we can help you.
 
The 8051 microcontrollers have a memory space from 30h to 7Fh.

to store a byte of data to a memory space, simply use:

MOV <RAM address>,<data>

Here is a sample program that can answer your question. It basically stores numbers from 2 to 16 in memory locations 30h to 38h.


Code:
mov R0,30h
mov A,02h
mov @R0,A
inc R0
add A,02h
mov @R0,A
inc R0
add A,02h
mov @R0,A
inc R0
add A,02h
mov @R0,A
inc R0
add A,02h
mov @R0,A
inc R0
add A,02h
mov @R0,A
inc R0
add A,02h
mov @R0,A
inc R0
add A,02h
mov @R0,A
inc R0
add A,02h
There is a shorter way to do it.

By the way, I am using straight commands from Intel's 8051 instruction set. Your compiler may be different. the "h" at the end means the number is hexadecimal.
 
mstechca said:
The 8051 microcontrollers have a memory space from 30h to 7Fh.

You are mistaken. 8051 has internal RAM from 00h to 7Fh. It depends upon user how much RAM to allocate for stack, the rest is available for variables.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top