Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

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;


Note that the above tables do not automatically define the various
mnemonics that may be used for addressing the special function
registers of the 8051. The user may wish to set up a file of
equates (EQU's) that can be included in the source file for this
purpose. The following illustrates some of the appropriate equates:


P0 .equ 080H ;Port 0
SP .equ 081H ;Stack pointer
DPL .equ 082H
DPH .equ 083H
PCON .equ 087H
TCON .equ 088H
TMOD .equ 089H
TL0 .equ 08AH
TL1 .equ 08BH
TH0 .equ 08CH
TH1 .equ 08DH
P1 .equ 090H ;Port 1
SCON .equ 098H
SBUF .equ 099H
P2 .equ 0A0H ;Port 2
IEC .equ 0A8H
P3 .equ 0B0H ;Port 3
IPC .equ 0B8H
PSW .equ 0D0H
ACC .equ 0E0H ;Accumulator
B .equ 0F0H ;Secondary Accumulator
;Now some bit addresses
P0.0 .equ 080H ;Port 0 bit 0
P0.1 .equ 081H ;Port 0 bit 1
P0.2 .equ 082H ;Port 0 bit 2
P0.3 .equ 083H ;Port 0 bit 3
P0.4 .equ 080H ;Port 0 bit 4
P0.5 .equ 081H ;Port 0 bit 5
P0.6 .equ 082H ;Port 0 bit 6
P0.7 .equ 083H ;Port 0 bit 7
ACC.0 .equ 0E0H ;Acc bit 0
ACC.1 .equ 0E1H ;Acc bit 1
ACC.2 .equ 0E2H ;Acc bit 2
ACC.3 .equ 0E3H ;Acc bit 3
ACC.4 .equ 0E4H ;Acc bit 4
ACC.5 .equ 0E5H ;Acc bit 5
ACC.6 .equ 0E6H ;Acc bit 6
ACC.7 .equ 0E7H ;Acc bit 7

See the manufacturer's data sheets for more information.

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.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top