??? 06/02/06 08:49 Modified: 06/02/06 09:56 Read: times |
#117583 - Revised Code Responding to: ???'s previous message |
I revised the code/comments after suggestions from Jan:
DSEG AT 30h ;this tells the compiler to start placing data from 30h NrValues EQU 8 ;const nrvalues=8; OldValues: DS NrValues ;reserve space for OldValues RPin: DS 1 ;reserve space for RPin (a counter) AStore: DS 1 ;reserve space where A will be stored temporarily CSEG ;now we tell the compiler that we are going to write code ORG 0 MOV P3,#255 ;Making P3 Input Port MOV OldValues+0,#255 ;Initilising memory locations for storing output MOV OldValues+1,#255 ;from the 8 latches MOV OldValues+2,#255 ;and loading them with initial values MOV OldValues+3,#255 ;which indicate all signals are low MOV OldValues+4,#255 MOV OldValues+5,#255 MOV OldValues+6,#255 MOV OldValues+7,#255 ;three nested loops needed: one for the bits, ;one for the 8 bytes, one which repeats the all ;infinitely LOOP: MOV R0,#OldValues+7 ;location R0 is Rlatch POLL: MOV A,R0 ADD A,#-OldValues ;calculate latch Nr MOV P1,A ;set the latch Nr for the decoder MOV RPin,#8 ;there are 8 bits in a byte MOV A,P3 ;Reading data from Port3 ANL A,@R0 ;ANDing A with the locations 8 to 1 which will store CPL of P3 CHKPIN: RLC A ;Get the Pins thatwent form LOW to HIGH JC WRITE GETBAK: DJNZ RPin,CHKPIN MOV A,P3 ;Since the output is latched, it has not changed since last time CPL A MOV @R0,A ;Moving the data of the respective latches to the ;respective registers CJNE R0,#OldValues-1,POLL JMP LOOP ;repeat infinitely this loop WRITE: MOV AStore,A ;storing the value of A in 20 for further use MOV A,R0 ADD A,R0 ;Adding contents of R0 to A seven more times ADD A,R0 ;I read that using MUL always clears the flag ADD A,R0 ;And I dont want to do that ADD A,R0 ADD A,R0 ADD A,R0 ADD A,R0 ADD A,10 MOV P2,A ;Sending data to Output Port2 MOV A,AStore ;Returning A its original Value JMP GETBAK END |
Topic | Author | Date |
Another standard problm in Assembly Lang | 01/01/70 00:00 | |
many ways | 01/01/70 00:00 | |
lookup table? | 01/01/70 00:00 | |
yup | 01/01/70 00:00 | |
hummmm | 01/01/70 00:00 | |
algorithm! | 01/01/70 00:00 | |
OK | 01/01/70 00:00 | |
forget the lookup table | 01/01/70 00:00 | |
no language dependency | 01/01/70 00:00 | |
abstraction | 01/01/70 00:00 | |
Direct Test | 01/01/70 00:00 | |
did you take it at Grossmont? | 01/01/70 00:00 | |
Wrong mark | 01/01/70 00:00 | |
just wonder | 01/01/70 00:00 | |
homework | 01/01/70 00:00 | |
No not homework | 01/01/70 00:00 | |
Bit 3? | 01/01/70 00:00 | |
Depends | 01/01/70 00:00 | |
reverse bit numbering | 01/01/70 00:00 | |
reverse bit numbering: mirror | 01/01/70 00:00 | |
It's logical... | 01/01/70 00:00 | |
Thks | 01/01/70 00:00 | |
Unconventional | 01/01/70 00:00 | |
Yes, now I know | 01/01/70 00:00 | |
oops | 01/01/70 00:00 | |
Radix notation | 01/01/70 00:00 | |
Why "Standard"? | 01/01/70 00:00 | |
give it in C | 01/01/70 00:00 | |
Finally Some Code | 01/01/70 00:00 | |
formatted | 01/01/70 00:00 | |
Much nicer | 01/01/70 00:00 | |
OH boy | 01/01/70 00:00 | |
No I havent | 01/01/70 00:00 | |
edited | 01/01/70 00:00 | |
No Prob | 01/01/70 00:00 | |
Yes. | 01/01/70 00:00 | |
try & ask | 01/01/70 00:00 | |
OK | 01/01/70 00:00 | |
Many Questions | 01/01/70 00:00 | |
Q&A | 01/01/70 00:00 | |
Man! That just made my day! | 01/01/70 00:00 | |
Revised Code | 01/01/70 00:00 | |
hi abhishek!!!![]() | 01/01/70 00:00 |