Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

PIC ASSEMBLY LANGUAGES QUESTION

Status
Not open for further replies.

ahmad

Member level 1
Joined
Jul 12, 2004
Messages
36
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,286
Location
malaysia
Activity points
354
Hi there,

| got question to you all, and hope you can give me the answer.

This is a simple delay program which i took from 16F84A PIC CDRom.

Delay
Movlw 0x07
movwf TEMP1 ; TEMP1 = 255
movwf TEMP2 ; TEMP2 = 255
movlw 0x07
movwf TEMP3 ; TEMP3 = 7
DLOOP
decfsz TEMP1, F
goto DLOOP

decfsz TEMP2, F
goto DLOOP

decfsz TEMP3, F
goto DLOOP

retlw 0x00
end

My question is :
1. Why the comment on line 3 say TEMP1 = 255 not 7 but at line 6 TEMP3 = 7

For your information TEMP1 = 0x08 (EEDATA REGISTER)
TEMP2 = 0x09 (EEADRS)
TEMP3 = 0X0A (PCLATH)

2. Why they used EEDATA, EEADRS AND PCLATH register not RAM ?

3. When I changed value of TEMP1 from 7 to FF then the frequency of
LED is become faster not slower as i expected. WHY ???

4. When I declare DATA equ 0x10 (RAM Location) at the top, the compiler say DATA is not declare at the beginning. WHy ??

Anyone please help.

Thanks.
 

checkmate

Advanced Member level 3
Joined
Feb 25, 2004
Messages
833
Helped
178
Reputation
356
Reaction score
125
Trophy points
1,323
Location
Toilet Seat
Activity points
7,815
Oh boy ... lesson time.
ahmad said:
Delay
Movlw 0x07 ; W = 0x07
movwf TEMP1 ; TEMP1 = W
movwf TEMP2 ; TEMP2 = W
movlw 0x07 ; W = 0x07
movwf TEMP3 ; TEMP3 = W
DLOOP
decfsz TEMP1, F ; TEMP1--; if (TEMP1==0) skip next cmd
goto DLOOP

decfsz TEMP2, F
goto DLOOP

decfsz TEMP3, F
goto DLOOP

retlw 0x00
end
Some pseudocode. Hope you can figure out the rest. Most probably, TEMP1, TEMP2 and TEMP3 are simply general purpose registers.
 

SphinX

Advanced Member level 3
Joined
Jan 25, 2002
Messages
822
Helped
58
Reputation
116
Reaction score
29
Trophy points
1,308
Location
EGYPT
Activity points
7,051
Salam ahmad

List the full program to help you.
What is the PIC16F84A clock value (4Mhz or 10Mhz) ?

Bye
 

glenjoy

Banned
Joined
Jan 1, 2004
Messages
963
Helped
72
Reputation
146
Reaction score
20
Trophy points
1,298
Location
Philippines
Activity points
0
ahmad said:
Hi there,

| got question to you all, and hope you can give me the answer.

This is a simple delay program which i took from 16F84A PIC CDRom.

Delay
Movlw 0x07
movwf TEMP1 ; TEMP1 = 255
movwf TEMP2 ; TEMP2 = 255
movlw 0x07
movwf TEMP3 ; TEMP3 = 7
DLOOP
decfsz TEMP1, F
goto DLOOP

decfsz TEMP2, F
goto DLOOP

decfsz TEMP3, F
goto DLOOP

retlw 0x00
end

My question is :
1. Why the comment on line 3 say TEMP1 = 255 not 7 but at line 6 TEMP3 = 7

For your information TEMP1 = 0x08 (EEDATA REGISTER)
TEMP2 = 0x09 (EEADRS)
TEMP3 = 0X0A (PCLATH)

2. Why they used EEDATA, EEADRS AND PCLATH register not RAM ?

3. When I changed value of TEMP1 from 7 to FF then the frequency of
LED is become faster not slower as i expected. WHY ???

4. When I declare DATA equ 0x10 (RAM Location) at the top, the compiler say DATA is not declare at the beginning. WHy ??

Anyone please help.

Thanks.


1.)
Movlw 0x07
movwf TEMP1 ; TEMP1 = 255
movwf TEMP2 ; TEMP2 = 255

After these commands, W = 0x07, therefore understood that TEMP1 = TEMP2 and their contents are 0x07, same with TEMP3.

2.) On what bank they were set? Please check the RP0 and RP1 bits.

3.) Cannot answer that if you will not give us the BANK Status.

4.) Please check your banking. Or DATA is not allowed to be used on the equate directive.
 

ahmad

Member level 1
Joined
Jul 12, 2004
Messages
36
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,286
Location
malaysia
Activity points
354
Hi there and salam to you sphinx,

Thanks for your respond. Someone came to me and explained everything together with references book from the internet. it really help.

Thanks
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top