POINTER HELP REQUESTED<br><br>My first posting had some errors - I am still not sure of the exact structure I will be using. I hope this is correct.<br><br>I am an assembly language programmer - I also program in many other languages BUT, as many of you youngsters may not yet have learned, Knowledge has a short shelf life and my C/C++ has been on the shelf too long.
<br>In this - "long int" means 64 bit.<br><br>In assembly language there is no typing at all. A 32 bit quantity may be <br>1. an integer, <br>2. a sixteen bit number followed by a byte with no defined value and a
<br> character,<br>3. half of a double,<br>4. four bytes of program.<br>5. a pointer to something,<br>6. or a pointer to a pointer<br>and it is up to the programmer how something is interpreted and what alignment is used.
<br><br>I am converting a program, written in assembler to C/C++ and I am stuck over pointers. <br>This data structure is a linked list of variables.<br><br>A block of memory consists of records made up of<br><br>Byte No. Content
<br>(0..3) a 32 bit pointer to <br> a long int (8 Byte) <br> or a double <br> or (32 bit pointer and two 16 bit integers)<br>(4..11) followed by a long int or Double <br> or (32 bit pointer and two 16 bit integers)
<br>(12..15) followed by one byte made up of<br> 2 bits of flags, 4 bits of a number and two more bit flag<br> followed by an ASCIZ string of 4 n + 3 bytes long (n = 0..30)<br><br>Bytes 12..15 are anded with & 0x00 00 00 3c and then added to the address of this record to get the next record.
<br><br>First variable is a long int called "ten" and has the value 10 so the <br>first two bits of byte 12 have the value 0b01 and the record length is 20 <br>bytes the other two bit flags have the value 0b01 (0 means Not an array
<br>and the 1 bit says this variable has been initialised).<br><br>Abit of (obviously incorrect) code follows:<br><br> char * s = "ten";<br> void * blockaddr = malloc(varspace); // Check return value for NULL
<br> recptr = blockaddr; // get address of first record<br> * recptr = * recptr + 4; // insert into memory at blockaddr <br> // blockaddress + 4<br> recptr += 12; // pointer arithmetic point to byte 24
<br><br> * recptr = 1 | 20 | 0x80 // two bit flags | record length |<br> // initialised as a byte value<br> recptr++;<br> *recptr++ = *s; // recptr is a char *<br> char ch;
<br> do { <br> *recptr++ = ch = * (++ s);<br> } while( ch);<br> recptr +=3; // align on four byte - <br> // we are at the start of the next record.<br>
<br>