1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Buffer

Discussion in 'Assembly Language Programming (ALP) Forum' started by Shafqat, Dec 3, 2008.

  1. Shafqat

    Shafqat New Member

    Joined:
    Nov 27, 2008
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    0
    Hi,

    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?

    Also:

    -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?

    Thanks
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    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.
     
  3. Shafqat

    Shafqat New Member

    Joined:
    Nov 27, 2008
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    0
    Interesting, thank you.
     

Share This Page