I'm trying to figure out the concept of a buffer in ALP...never had to use such a thing in C++ or C#.
So what is it?
In this code I'm looking at a certain address say 1023000 is equated (using EQU) to BUFFER. Is this like assigning a variable so in future code you could use BUFFER instead of 1023000?
-whats the difference between using BUFFER and #BUFFER?
-does BUFFER + 1024 mean address 1023000 + 1024 = 1024024? I'm pretty sure it does but does this mean 1024 is in bytes not bits?
The concept of a buffer is not dependent on the language you're using. It's somewhere you put data temporarily; often it's used in some kind of streaming where the input and output data rates do not exactly match. For example in RS232 communications you might have lots of data to send from your program which can only be sent at a particular baud rate; the chances are your program would far exceed that rate if it tried to send the data directly. Also your program would have to become real-time so that it could send the data at exactly the right moment in time. So instead you write to a buffer, and the RS232 hardware reads from that buffer. It reads and sends while there is data in the buffer, and you store data into the buffer until (a) it's full or (b) you run out of data to send.
BUFFER EQU 1023000 is equivalent to char *buffer=1023000.
The difference between BUFFER and #BUFFER is that the latter takes the value 102300, because # (usually) means immediate value. The instruction MOVE A1,#BUFFER would set address register A1 to the value 1023000, but MOVE.B D1,(BUFFER) would read the first byte in the buffer, and MOVE.B (BUFFER),D1 would write the least significant byte of D1 to the buffer.
BUFFER+1024 would mean 1023000+1024, or 1024024, and that would be in bytes, not bits.
Interesting, thank you.
|All times are GMT +5.5. The time now is 23:13.|