| ??? 06/01/06 13:51 Modified: 06/01/06 15:02 Read: times |
#117504 - Finally Some Code Responding to: ???'s previous message |
Hello Guys, actually was already working on writing the code in assembly, so posting my first attempt. Also think in my post "NO not homework" I have givem an outline of my entire problem. And now my first attempt in Assembly follows:
ORG 0
MOV P3,#255 ;Making P3 and NOT P2 as INPUT Port
MOV 1,#255 ;Initilising memory locations for storing output
MOV 2,#255 ;from the 8 latches
MOV 3,#255 ;and loading them with initial values
MOV 4,#255 ;which indicate all signals are low
MOV 5,#255
MOV 6,#255
MOV 7,#255
MOV 8,#255
MOV R0,8 ;location R0 is Rlatch
MOV 10,8 ;location 10 is Rpin
POLL: MOV P1,10 ;write Rlatch to location P1
MOV A,P3 ;Reading data from P3
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 10,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
MOV 10,#8 ;ReInitialising Rpin value as 8 for next loop
DJNZ R0,POLL
MOV R0,#8 ;ReInitilising value of Rlatch as 8 for next loop
JMP POLL ;Getting back to work again after completing one loop
WRITE: MOV 20,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
MOV A,20 ;Returning A its original Value
JMP GETBAK
END
The code was assembled without errors in asem-51. What do you guys say? |
| 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 |



