How to define a byte and a bit in RAM?

Status
Not open for further replies.

sush

Member level 4
Joined
Aug 24, 2005
Messages
78
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,288
Activity points
1,946
hi frnds
m new to uc programming .m working on 89c51 & TASM .i know how to define a byte in RAM. ex. as given below

Code:
temperature	.EQU	40H	;value of temperature

i want to know how to define a bit in bit adrressable location of RAM. ex. should that also be done as given below.

Code:
heater		.EQU	50H	;bit to check status of heater on/off



and also if this code is correct then how to define the difference if the address are same as

Code:
temperature	.EQU	40H	;value of temperature


Code:
heater		.EQU	40H	;bit to check status of heater on/off

please help me out and tell me the way to write the code
thanks
 

Re: bit byte definition

Lets make something clear:
To define a constant you will use EQU, for example:
TEMP EQU 25h
willl asign the value of 25h to the constant TEMP, and this value is not stored in RAM ..
To define a variable in RAM you will use DATA, for example:
temperature DATA 40h
and this variable will be using location 50h in RAM ..
To define a bit (in the bit-adrtessable RAM area, in 8051-derivatives it is between 20h and 27h, and all common bits such as ACC0, ACC1, and so on) you will use BIT, for example:
Flags DATA 20h
Flag0 BIT Flags.0
Flag1 BIT Flags.1
and so on ..
See: **broken link removed** and exaple below ..
Regards,
IanP

Code:
; ========================================================
;                   			    	Definitions
; =========================================================

LF			EQU	0Ah		; Line Feed Character.
NR			EQU	0Dh		; Carriage Return Character.
ESC			EQU	1Bh		; Escape Character.
dir0			EQU	00h		; Internal RAM 00h
dir1			EQU	01h		; Internal RAM 01h
BitS			DATA	0Ah		; BitSet memory for 8255 diagnostics

RxBuffHead		DATA	08h
RxBuffTail		DATA	09h
TxBuffHead		DATA	0Ah
TxBuffTail		DATA	0Bh

RxBuff		DATA	0B0h
TxBuff		DATA	0E0h

RxBuffSize		EQU	2Fh
TxBuffSize		EQU	1Fh

Flags			DATA	20h		; State condition flags.
TOut			BIT	Flags.0		; Time Out for return of ACK by receiver
Any1			BIT	Flags.1		; 
Any2			BIT	Flags.2		;
 

    sush

    Points: 2
    Helpful Answer Positive Rating
Re: bit byte definition

Ianp that was really a good help, but i told u i'm using TASM and from a help file in TASM the below given text is extracted;



please check this, and file attached.
 

Re: bit byte definition

If you can, and it is not to late, I would suggest that you drop TASM assembler, and try the MetaLink Macro Assembler ..
It can be dowloaded from: **broken link removed**
and it includes nicely written manual; and it is free..

With the MetaLink assembler the BIT, DATA and EQU definitions are perfectly clear (as you could see in my previous post), and on top of that, using declaration such as $MOD52 (and other $MODXX) you will be able to use all additional features of 8052 (89C52) ..

Regards,
IanP
 

    sush

    Points: 2
    Helpful Answer Positive Rating
bit byte definition

really nice help IANP. One last question how do i use ASM51 and is there any free windows based compiler i'm using winXP.
 

Re: bit byte definition

Use WordPad as text editor and always save files as Plain Text files ..
Keep your files and ASEM51.exe in one subdirectory ..
If you want to create HEX and LST files, click on the ASM51.exe and in the DOS prompt type MyFile.txt and press ENTER ..

Also you can try evaluation version of "8051 Integrated Development Environment" ..
It can be downloaded from:
https://www.acebus.com/win8051.htm
The evaluation version should work with *.A51 or *.txt text files of up to 16kb and does not accept $NOPAGING, $xxxxx instructions ..

Regards,
IanP
 

Re: bit byte definition

just check the book "8051 uC" by scott mackenzie
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…