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.

Register Log in

PIC Assembly: operations on variables larger than 1 byte

Status
Not open for further replies.

T3STY

Full Member level 4
Joined
Apr 17, 2012
Messages
239
Helped
24
Reputation
48
Reaction score
24
Trophy points
1,308
Activity points
3,715
I am having a delay routine that goes like this:
Code:
Delay
	ORG 0x0C
	_delay RES 3
	
	MOVLW	0x40
	MOVWF	_delay
	MOVLW	0x42
	MOVWF	_delay+1
	MOVLW	0x0F
	MOVWF	_delay+2
	
	_delay_loop
	DECFSZ _delay, f
	GOTO _delay_loop
RETURN
The whole value within the 3bytes is 1 million which from calculations it should waste 1 second on a 4MHz main clock (1MHz real). Although, when I run this code it will end before 1 million cycles (actually, pretty fast) and I suppose the DECFSZ instruction only works on the first byte of variable _delay.
Thus the question: operations on variables larger than 1 byte will affect only the first byte of the variable? If not, what's wrong in the code I wrote that makes it vanish so fast?
 

keith1200rs

Super Moderator
Staff member
Joined
Oct 9, 2009
Messages
10,877
Helped
2,064
Reputation
4,128
Reaction score
1,597
Trophy points
1,403
Location
Yorkshire, UK
Activity points
57,276
The 8 bit processors only operate on bytes. Unless you have a processor that can operate on pairs of bytes (some can do 16 bit arithmetic) you must manipulate larger numbers yourself.

Keith
 
  • Like
Reactions: T3STY

    T3STY

    points: 2
    Helpful Answer Positive Rating

T3STY

Full Member level 4
Joined
Apr 17, 2012
Messages
239
Helped
24
Reputation
48
Reaction score
24
Trophy points
1,308
Activity points
3,715
OK, thank you very much Keith!
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top