A Level Microcontroller Architecture Instruction Set Memory ~ BSF and BCF >~ Call and Return< ~ COMF ~ Counting ~ Heater ~ INCF and BTFSC ~ INT0IF ~ LED Matrix ~ Motor ~ Stepper Motor |
Microcontroller ~ Call and Return |
|
When a subroutine is called, its return address is saved on the stack.
When the subroutine is complete, the code resumes at the saved address.
Interrupt subroutines work in much the same way.
The hardware calls the interrupt subtroutine and saves the return address to the stack.
When the interrupt code finishes, the program returns to its original task using the saved address.
Mistakes with the stack like forgetting to "RETURN" are a common cause of program crashes.
Try removing the last "RETURN" from this example and watch what happens.
|
||||||||||||||||||
NOP 0x0000 00 0000 0000 0000 00 0000 0xx0 0000 Cycles: 1 Flags: |
||||||||||||||||||
W REG000 0x00 00000000 Bank 0 From 0x00 to 0x7F PCL000 0x00 00000000 STATUS024 0x18 00011000 PORTA000 0x00 00000000 PORTB000 0x00 00000000 INTCON000 0x00 00000000 |
Stack 0000 0000 0000 0000 |
SP000 0x00 00000000 Bank 1 From 0x80 to 0xFF PCL000 0x00 00000000 STATUS024 0x18 00011000 TRISA111 0xFF 11111111 TRISB111 0xFF 11111111 INTCON000 0x00 00000000 |
||||||||||||||||
Bank 0 General Purpose File Registers from 0x20. |
0x20000 0x00 00000000 0x21000 0x00 00000000 0x22000 0x00 00000000 0x23000 0x00 00000000 |
0000 0000 0000 0000 |
0x24000 0x00 00000000 0x25000 0x00 00000000 0x26000 0x00 00000000 0x27000 0x00 00000000 |
|||||||||||||||
0x | 00 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 0A | 0B | 0C | 0D | 0E | 0F | ||
00 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 00 | |
10 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 10 | |
20 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 20 | |
30 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 30 | |
40 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 40 | |
50 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 50 | |
60 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 60 | |
70 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 70 | |
80 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 80 | |
90 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 90 | |
A0 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | A0 | |
B0 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | B0 | |
C0 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | C0 | |
D0 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | D0 | |
E0 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | E0 | |
F0 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | F0 |
Subject Name Level Topic Name Question Heading First Name Last Name Class ID User ID
Q: qNum of last_q Q ID: Question ID Score: num correct/num attempts Date Done
|
Question Text
image url
Help Link
Add Delete Clone Edit Hardness
Contact, Copyright, Cookies and Legalities: C Neil Bauers - reviseOmatic V4 - © 2016/17
Hosted at linode.com - London
Please report website problems to Neil