??? 05/09/04 15:13 Read: times |
#70067 - Some more questions about the Main Loop Responding to: ???'s previous message |
In the code the next thing i would like to ask is:
1) when ever the power is ON for this controller to work firstly the stack is set but where, like #stack means. PWR_UP: MOV SP, #STACK ; set stack pointer 2) whats the use of DW , like it reserves 2 bytes also can be applied for code memory but what it can do like in the following case what it means: STATE_TABLE: DW MAIN_STATE_0 ; pointer to State 0 routine DW MAIN_STATE_1 ; pointer to State 1 routine DW MAIN_STATE_2 ; pointer to State 2 routine DW MAIN_STATE_3 ; pointer to State 3 routine STATE_CNT EQU ($ - STATE_TABLE)/2 ;number of states whats the last statement means i know it is explained where the example is shown but iam unable to gather any thing. I simply don;t understand what DW is doing over here? 3) Moving forward in the code; MAIN_LOOP: JNB Tick, MAIN_LOOP ; wait till a tick has gone by The above shows that the code is waiting for the first TICK to occur which was initialized at ths power on label. 4) considering that this is the first time the program is running; MOV A, SwitchNo ; fetch the state for the current this means that in Accumular 00000000B comes then; ADD A, #SwitchStates what does this means here? 5) And after that can some one please explain whats going on in the main loop of this code: MAIN_LOOP: JNB Tick, MAIN_LOOP ; wait till a tick has gone by ; CLR Tick ; clear bit once seen ; MOV A, SwitchNo ; fetch the state for the current ADD A, #SwitchStates ; switch MOV R0, A MOV A, @R0 CJNE A, #STATE_CNT,ML_A ; check for legal state number ML_A: JC ML_B ; state number OK CLR A ; reset to 0 if invalid MOV @R0, A ML_B: MOV DPTR, #STATE_TABLE ; point to state branch table CALL CALL_TABLE ; call to state routine ; MOV A, SwitchNo ; increment to next switch number INC A ANL A, #7 ; limit to 3 bits of switch number MOV SwitchNo, A ; JMP MAIN_LOOP ; go wait for next tick time JC is used to confirm whether a switch is really pressed or not , reset of the addition stuff please some one explain. |
Topic | Author | Date |
what these terms do in coding | 01/01/70 00:00 | |
RE: what these terms do in coding | 01/01/70 00:00 | |
RE: what these terms do in coding | 01/01/70 00:00 | |
RE: what these terms do in coding![]() | 01/01/70 00:00 | |
RE: what these terms do in coding | 01/01/70 00:00 | |
RE: what these terms do in coding | 01/01/70 00:00 | |
RE: what these terms do in coding | 01/01/70 00:00 | |
RE: what these terms do in coding | 01/01/70 00:00 | |
RE: what these terms do in coding | 01/01/70 00:00 | |
Some questions about the code | 01/01/70 00:00 | |
RE: Some questions about the code | 01/01/70 00:00 | |
Some questions about the code | 01/01/70 00:00 | |
Some more questions about the Main Loop | 01/01/70 00:00 |