Pointers

Is there a way to "move" a point several bytes through memory? Like 200bytes "up"? You get the idea. If yes, how? I'm a newbie, so keep it basic please, ok?

Comments

  • : Is there a way to "move" a point several bytes through memory? Like 200bytes "up"? You get the idea. If yes, how? I'm a newbie, so keep it basic please, ok?
    :

    easy:

    [code]
    type
    ptrrec = record
    offs,seg:word
    end;

    var
    Point:pointer

    begin
    getmem(point,64000)
    ptrrec(point).offs=200 ; point now points at offset 200
    ptrrec
    freemem(point,64000)
    end.
    [/code]

    the syntax might be wrong a bit, its been a while since i did pascal, but the idea is there, ptrrec(point).ofs represents the low word of the 32bit VAR point

    structure of a pointer:
    BIT description
    0 to 15 16bit offset of pointer
    16 to 31 16bit segment of pointer

  • : Is there a way to "move" a point several bytes through memory? Like 200bytes "up"? You get the idea. If yes, how? I'm a newbie, so keep it basic please, ok?
    :

    well, the Borland compiler allows the use of Inc() and Dec() functions on (typed) pointers - much like C does ...
    [CODE]
    var
    str: array[0..9] of char;
    pstr: ^char;

    begin
    pstr := &str;
    pstr^ := 'A'; { set the first element to 'A' }
    inc(pstr, 9);
    pstr^ := 'B'; { ... and the last one to 'B' }
    end.
    [/CODE]


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories