flat assembler
Message board for the users of flat assembler.
Index
> High Level Languages > [solved]how casting a *dword to *word works? |
Author |
|
DimonSoft 22 Feb 2018, 22:36
vivik wrote: I need to do something like this: Since the question is asked in “High Level Languages” section of the forum, I’ll ask what language do you want to use. |
|||
22 Feb 2018, 22:36 |
|
revolution 23 Feb 2018, 00:10
dword == long I presume? And word == short?
I think a good way to see what your compiler does with that code it to build it and then debug/disassemble it to see what it is doing. |
|||
23 Feb 2018, 00:10 |
|
rugxulo 23 Feb 2018, 05:15
Perhaps union?
|
|||
23 Feb 2018, 05:15 |
|
vivik 23 Feb 2018, 06:29
This worked:
*(unsigned short*)g_texture_thumb_cursor = 0xF1F2; g_texture_thumb_cursor = (DWORD*)((unsigned short*)g_texture_thumb_cursor + 1); Not very readable, huh? Had to google "void pointer increment". |
|||
23 Feb 2018, 06:29 |
|
vivik 23 Feb 2018, 06:46
I think I'll use these types:
https://msdn.microsoft.com/en-us/library/windows/desktop/aa383751(v=vs.85).aspx BYTE WORD DWORD INT8 INT16 INT32 UINT8 UINT16 UINT32 |
|||
23 Feb 2018, 06:46 |
|
DimonSoft 23 Feb 2018, 06:59
vivik wrote: I think I'll use these types: Might not be a good idea in terms of portability. |
|||
23 Feb 2018, 06:59 |
|
revolution 23 Feb 2018, 07:13
vivik wrote: This worked: Code: g_texture_thumb_cursor dw 0xF1F2,0 inc dword[g_texture_thumb_cursor] |
|||
23 Feb 2018, 07:13 |
|
vivik 24 Feb 2018, 08:24
Actually, it's much more simple if I just use char*.
char* pointer = (char*)malloc(1024); *(INT32*)pointer = 1; pointer += 4; *(INT32*)pointer = 2; pointer += 4; *(UINT16*)pointer = 1; pointer += 2; *(UINT16*)pointer = 2; pointer += 2; *(UINT16*)pointer = 3; pointer += 2; *(UINT16*)pointer = 4; pointer += 2; |
|||
24 Feb 2018, 08:24 |
|
DimonSoft 24 Feb 2018, 09:39
vivik wrote: Actually, it's much more simple if I just use char*. Why not define a struct and cast the pointer? |
|||
24 Feb 2018, 09:39 |
|
vivik 24 Feb 2018, 13:45
>Why not define a struct and cast the pointer?
Indeed why... I can merge the last four UINT16 into one struct at least. (Can't make everything into one structure, because the second INT32 is the amount of those UINT16.) I need to compare the assembly, later. |
|||
24 Feb 2018, 13:45 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.