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.

But1 Equ 0x00

Status
Not open for further replies.

micropad

Member
Dear All,

Dummy equ 0x20

The above variable definition is clear to me , that mean name Dummy is given to 0x20 memory shell ( Register )in bank0 in GPR


Following I got from Nigel's PIC tutorials that is bit un clear
But1 Equ 0x00 ;numeric button ID's
But2 Equ 0x01
But3 Equ 0x02
But4 Equ 0x03
But5 Equ 0x04
But6 Equ 0x05
But7 Equ 0x06
But8 Equ 0x07
But9 Equ 0x08

Please guide me

Thanks in advance
 
Equ is basically just a text substitution instruction - so every occurrence of But1 will be replaced by 0x00 at assemble time.

PIC's, like all processors, don't 'speak' words, only numbers - all the words are only for your convenience, and are converted to numbers by the assembler.

You're not actually understanding the 'dummy' example you gave either, all that line does is replace every occurrence of Dummy by the value 0x20, it has nothing whatsoever to do with any registers, it's just a number. However, as the address 0x20 is a GPR, as long as you use the name Dummy in the correct place, program instructions referencing Dummy will access the GPR address 0x20.
 
Dear Nigel thanks for the reply and advice


program instructions referencing Dummy will access the GPR address 0x20.

This is what i need to verify and clear

But2 Equ 0x01 As per above this is what referencing
I couldn't understood it well
Could you please explain more

Thanks in advance
 
Dear Nigel thanks for the reply and advice




This is what i need to verify and clear

But2 Equ 0x01 As per above this is what referencing
I couldn't understood it well
Could you please explain more

Thanks in advance

But2 connects to a specific pin on the PIC, referenced by 0x01 - using an Equ to reference it makes it more legible, and allows you to simply alter the Equ if you move it to a different pin.
 
But2 connects to a specific pin on the PIC, referenced by 0x01 - using an Equ to reference it makes it more legible, and allows you to simply alter the Equ if you move it to a different pin.

YES I GOT IT

Thanks again and again
 
Last edited:
Dear Ian
I thought to ask another question for my understanding purpose

But2 Equ 0x01

Hera But2 = 0x01 ( 8bit ) I think

Let me know, where the 0x01 store, I mean program memory or data memory, I think Program memory

If program memory it consumes memory location in program memory

Am I write?

Please advice
Thank in advance
 
is not stored anywhere in a way that you could access it again, it usually becomes a part of the insturcion that manipulates it as an immediate operand after you assemble the source code.
ADD r1, But2 is the same thing as ADD r1, 0x01 (general syntax, I have no idea how pics have the instructions)
 
Dear All,

Let'w assume movlw b'11110000'

Hex code 30F0 - 30 for movlw anf b'11110000' for F0 that stored the Program memory

But

But equ 0x01 can't see anything in the program memory

Pleas advice
Thanks n advance
 
Maybe the assembler replaces it with some other instruction? Does the microcontrolle in question have something like a constant generator/register?
So, what do you see in the program memory instead?
 
So, what do you see in the program memory instead?[/QUOTE]

I didn't see nothing related to But equ 0x01 in the view program memory window

Please advice
 
hi micro,

The 'label' But is just so us humans can read the program listing easier.:D

So we give the numbers for the buttons a label or a name.

When the assembler assembles the program listing, when it it see a label it replaces it with the number it represents.

EDIT:
Look at these images
 

Attachments

  • AAesp02.gif
    AAesp02.gif
    2.1 KB · Views: 329
  • AAesp03.gif
    AAesp03.gif
    4.7 KB · Views: 320
Last edited:
hi micro,

The 'label' But is just so us humans can read the program listing easier.:D

So we give the numbers for the buttons a label or a name.

When the assembler assembles the program listing, when it it see a label it replaces it with the number it represents.

EDIT:
Look at these images

Yes thanks for the reply

movlw PORTD human can read which is human readable form

But machine code for movlw PORTD we can see in the listing file which is '3008'

But

BUT equ 0x01
we can not see anything related to this

Please advice
 
you need to make a very short program that only does the instruction you want to see, or use some debugger to step through the code and see what has the movlw instruction changed into.
 
Yes
Code:
#include <p16f877a.inc>
LIST p=16f877a
__config 3f39

			
but	equ		0x10
			org		0x00
Start		goto	main
main		call	sys_init

sys_init	
			clrf	PORTD
			banksel	TRISD
			[COLOR="#FF0000"]movlw	TRISD[/COLOR]
			banksel	PORTD
			movlw	0xff
			movwf	TRISD
			return
end

Code:
MPASM  5.49                    ROTATE_OFF.ASM   4-22-2013  0:17:07         PAGE  1


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

                      00001 
                      00002 #include <p16f877a.inc>
                      00001         LIST
                      00002 
                      00003 ;==========================================================================
                      00004 ;  MPASM PIC16F877A processor include
                      00005 ; 
                      00006 ;  (c) Copyright 1999-2013 Microchip Technology, All rights reserved
                      00007 ;==========================================================================
                      00008 
                      00566         LIST
Warning[205]: Found directive in column 1. (LIST)
                      00003 LIST p=16f877a
Warning[205]: Found directive in column 1. (__config)
2007   3F39           00004 __config 3f39
                      00005 
                      00006                         
 [COLOR="#FF0000"] 00000010            00007 but     equ             0x10[/COLOR]
0000                  00008                         org             0x00
0000   2801           00009 Start           goto    main
0001   2002           00010 main            call    sys_init
                      00011 
0002                  00012 sys_init        
0002   0188           00013                         clrf    PORTD
0003   1683 1303      00014                         banksel TRISD
[COLOR="#FF0000"]0005   3088           00015                         movlw   TRISD[/COLOR]
0006   1283 1303      00016                         banksel PORTD
0008   30FF           00017                         movlw   0xff
Message[302]: Register in operand not in bank 0.  Ensure that bank bits are correct.
0009   0088           00018                         movwf   TRISD
000A   0008           00019                         return
Warning[205]: Found directive in column 1. (end)
                      00020 end
MPASM  5.49                    ROTATE_OFF.ASM   4-22-2013  0:17:07         PAGE  2
 
micropad But [COLOR="#FF0000" said:
BUT equ 0x01[/COLOR]
we can not see anything related to this

Please advice


LOOK at the image the 01 and 02 are clearly visible

MOVLW 0x01 ; thats but0

MOVLW 0x02 ; thats but1
 

Attachments

  • AAesp03.gif
    AAesp03.gif
    4.9 KB · Views: 317
well since you don´t use that "but" definition anywhere in the code, it will not appear anywhere in the assembled file.
Normally assembler has directives like db and dw that store values in the program memory. The equ is just an alias, the same way like #define in C.
 
well since you don´t use that "but" definition anywhere in the code, it will not appear anywhere in the assembled file.
Normally assembler has directives like db and dw that store values in the program memory. The equ is just an alias, the same way like #define in C.

Dear Kubeek Thanks for the reply

Actually I need to know where the "but" value is stored in the program memory

If it is not stored in the program memory, How MCU should knows the value assigned to "but" in the source code

Please help
 
Last edited:
Dear Kubeek Thanks for the reply

Actually I need to know where the "but" value is stored in the program memory

If it is not stored in the program memory, How MCU should knows the value assigned to "but" in the source code

Please help

As before - READ ERIC'S POST #11 (and #16) - where he shows EXACTLY where it's 'stored', in program memory
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top