i am using the basic compiler in PIC Simulator IDE to write a program but i need to split a variable in half. i do not know how to do this this is what i mean:
i am using the basic compiler in PIC Simulator IDE to write a program but i need to split a variable in half. i do not know how to do this this is what i mean:
I've got no idea using basic but with assembler I would :
MOVLW b'00001111'
ANDWF byte, w ; Now w has the first half of the byte, do with it what you will
Then,
RRF byte, f
RRF byte, f
RRF byte, f
RRF byte, w ; Now, w has the second half of the byte
Edit: Actually, will have to add at the end:
ANDLW b'00001111'
If that wasn't added then you will sometimes get the wrong numbers because of the RRF instruction taking Bit 7 from the Carry bit.
Yes, the Swapf instruction makes it trivial - and is one of the instructions people tend to forget about - obviously in BASIC you're pretty stuffed though.
thanks for you help everyone. ill try that now and tell you the results. btw there is a function to use asm in the basic compiler so if it doesnt work i can try to use the code you have given me
thanks for you help everyone. ill try that now and tell you the results. btw there is a function to use asm in the basic compiler so if it doesnt work i can try to use the code you have given me
i am using a DS1307 Time RTC for a clock project and if you look at this datasheet : DS1307 and go to page 8 you will find that eg. seconds (00h) is split into seconds and 10 seconds and i need to split them up
i am using a DS1307 Time RTC for a clock project and if you look at this datasheet : DS1307 and go to page 8 you will find that eg. seconds (00h) is split into seconds and 10 seconds and i need to split them up