Any c programers wiling to help me with a programing issue...

Any c programers wiling to help me with a programing issue? currently i need to read in the hex value ox1122334455667788 into an uint64_t a single byte at a time, I.E first read 0x11 then 0x22 then 0x33

Attached: ScreenshotforCS261prod1.png (1920x1200, 7K)

Can't you just right shift by decreasing amounts for each byte? Also, are you a cal student?

void read(uint64_t in)
{
for (int i = 56; i >= 0; i -= 8) {
uint8_t b = (in >> i) & 0xFF;
// do things with b
}
}

>m
this wont work as im working on a 32 bit machine and the largest required right shift is larger than 32 bits

If your machine is 32 bits then how is it holding the number in the first place? Can you split up the number and then right shift ?

the number isnt actually a full number it is an array of uint8_t bytes being read 1 by 1, so my array[specified location] = 11, and at specified location + 1 it is 22 exc exc

void read(uint64_t *in, uint8_t bytes[8])
{
uint8_t *p = (uint8_t *) in;
for (int i = 0; i < 8; i++) {
*(p + i) = bytes[7 - i];
}
}


something like that, for a little endian machine.

long hex = 0x1122334455667788;
char *byte = (char*) &hex;
int i;
for (i = 0; i < sizeof(long); i++)
printf("0x%02x\n", byte[i]);

uint32_t *i = (void*)uint8array;You may have to fill in the array in reverse, depending on endianness.

perhaps a screenshot will help clarify, im able to accsess the values individually so as you see my terminal prints 1122334455667788 one byte at a time, my issue is i ned to read the byte into ins->dest which is a uint64_t.

Attached: proj3.png (1920x1200, 270K)

the get_dest is the method im working in currently that is printing(1122334455667788 and 80000000, the 8000000 is a 31 point right shift, once i do a 32 point right shift the number returns to its original.

yes im aware i have to do it in reverse but ive taken care of that

you want the hex, e.g. 0x1234, to be interpreted as a memory address for dest? or you just want to assign a single byte to ->dest?

a memory address so in otherwords ins->dest must equal 0x1122334455667788

while im reading in the bytes as 11 then 22 then 33 then 44 exc

THE ABSOLUTE STATE OF COMPUTER """SCIENCE""" STUDENTS

Attached: Capture.png (453x389, 24K)

you'll need a local copy of the reversed bytes. and then you'll use that to assign dest. something like:
int i, j;
long hex = 0x1122334455667788;
long rev = 0;
char *byte = (char*) &hex;
for (i = sizeof(long) - 1, j = 0; i >= 0; i--, j++)
memcpy(((char*)&rev) + j, byte + i, 1);
printf("0x%08lx\n", rev);

kek

you could also just put each byte into `dest' as I did for `rev'.

uint64_t number:
for(int i = 7; i >= 0; i--) {
*((char*)number + i) = read_char();
}

Here's how to do it in assembly sort of :^)
MOV ESI, OFFSET a_hex
DEC ESI
MOV EBX, 0
MOV EDX, 0
MOV EAX, OFFSET hex_count
MOV ECX, [EAX]
CMP ECX, 1
JZ One_Char
INC ECX
PUSHAD

L_O:
POPAD

INC ESI
DEC ECX
MOV EDI, OFFSET valid_hex ;valid_hex = array of all valid hex characters

MOV DL, [ESI]

PUSHAD

MOV EAX, 0
MOV AL, stop_condition
CMP AL, DL
JZ Valid_Array

CMP ECX, 0
JZ Invalid_Array

MOV ECX, 0
MOV CL, valid_hex_size

L1:
MOV BL, [EDI]
CMP DL, BL
JZ L_O

ADD EDI, 1
DEC CL
CMP CL, 0
JNZ L1

JMP Invalid_Array

Valid_Array:
POPAD
CALL crlf
MOV EDX, OFFSET s_valid
CALL writestring
CALL crlf
RET

Invalid_Array:
POPAD
CALL crlf
MOV EDX, OFFSET s_invalid
CALL writestring
CALL crlf
RET

One_Char:
CALL crlf
MOV EDX, OFFSET s_invalid
CALL writestring
CALL crlf
RET

Attached: 1491272520827.jpg (577x384, 54K)