flat assembler
Message board for the users of flat assembler.
Index
> Main > Trouble with byte |
Author |
|
edfed 26 Jun 2008, 23:14
Code: value dd 33221100h ... mov byte[value+3],44h ... ;now, [value] is equal to 44221100h |
|||
26 Jun 2008, 23:14 |
|
bitRAKE 26 Jun 2008, 23:16
movzx edx,bl ; register byte to dword
Upper three bytes of EDX will be zero. Num dd "0123" mov edx,[Num] mov dl,"4" mov [Num],edx ; "0124" or mov edx,[Num] bswap edx mov dl,"4" bswap edx mov [Num],edx ; "4123" It's difficult to understand what you want exactly. _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
26 Jun 2008, 23:16 |
|
iic2 27 Jun 2008, 02:32
Thanks guys
edfed, I always wondered how you convert a string like 1230 to 33221100h. Would I use a string2Dword procedure. That's something else I will look into after I get past this problem. What I did for days was: mov byte [Num + 3], "4" results as expected 1234 I knew how to do this already. But I been trying to use an offset value (a one byte string from data section). I see this may be impossible so I'm wondering if there's a macro that can change or control what can be in a immediate value "4" with-out making code section writeable. But beggar can't be choosy. Straight from the .data section do not work: mov byte [Num + 3], string error = value out of range If this can be solved by a macro or something else it would be great. I like it because of size. Quote: It's difficult to understand what you want exactly. BitRAKE, The manuals and samples i seen over time say no ... but I know there got to be work-around so I'm just trying things out and want to know how to do the same as above using only registers with fewer lines as possible. This was my first objective. I got a lot of ways to do this with a string like EndofString proc but just to change a single byte at the end of a dword is not in the manuals as far as I know. It speaks of word, 2 bytes or dword. Your code change the first byte in a dword. I'm trying to change the last byte. My code with the zero threw you off. I want to do the same as above with edfed reminder code but I also want to know how to do the whole operation with the dword already in the registers waiting for the single byte string from the data section to be attached. Sound so simple but yet no mnemonic exist for this little thingy. Is there any hope??? mov ebx, [Num] (1237) or (123 ) mov eax, string (4) mov [ebx + 3 + pop bitRAKE magic],ahhh results ebx or eax = 1234 |
|||
27 Jun 2008, 02:32 |
|
bitRAKE 27 Jun 2008, 03:15
mov eax,[YourDword-1]
shrd eax,dword [YourByte],8 ...there are many ways... mov eax,[YourDword] movzx edx,[YourByte] and eax,$FFFFFF bswap edx add eax,edx ; or eax,edx There isn't a single instruction for registers unless SHRD can be made to work. _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
27 Jun 2008, 03:15 |
|
iic2 27 Jun 2008, 03:56
2 lines Wow!!! Thanks bitRAKE. This is going to take me far with asm. I will be reading and doing much this weekend. Thanks again
|
|||
27 Jun 2008, 03:56 |
|
iic2 27 Jun 2008, 05:02
i can't see where i'm going wrong here. I get a empty messagebox.
Code: format PE GUI 4.0 entry start include '\fasm\include\win32a.inc' section '.code' code readable executable start: ; ................................... not working ; mov eax,[TEMP_1] ; shrd eax,dword [string],8 ;invoke MessageBox,0,eax,0,0 ; ................................... empty MBox mov eax,[TEMP_1] mov edx,string shrd eax,dword edx,8 invoke MessageBox,0,eax,0,0 invoke ExitProcess,0 ; --------------------------------------------- ; --------------------------------------------- .DATA section '.data' data readable writeable string db "D" align 4 TEMP_1 dd "ABCZ" ; --------------------------------------------- ; --------------------------------------------- section '.idata' import data readable writeable library kernel32, 'KERNEL32.DLL',\ user32, 'USER32.DLL' include '\fasm\include\api\kernel32.inc' include '\fasm\include\api\user32.inc' |
|||
27 Jun 2008, 05:02 |
|
sinsi 27 Jun 2008, 05:19
bitRAKE wrote: mov eax,[YourDword-1] I know you would have to be unlucky, but that could cause an access violation. Code: invoke MessageBox,0,eax,0,0 MessageBox needs a pointer to a string in EAX, not just a number. |
|||
27 Jun 2008, 05:19 |
|
bitRAKE 27 Jun 2008, 05:23
okay, it's a little different - this works:
Code: include 'win32wx.inc' .end start start: mov eax,[TEMP-1] shld dword [string],eax,24 invoke MessageBoxA,0,string,0,0 invoke ExitProcess,0 string db "D",0,0,0,0 align 4 TEMP dd "ABCZ" _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
27 Jun 2008, 05:23 |
|
iic2 27 Jun 2008, 06:30
Yes it does. I see I got a lot to learn. Searching like crazy for the pass few hours lead me to places like this...
http://board.flatassembler.net/topic.php?t=6533 Math etc... How do you guys handle it all and all to come. Thanks again bitRAKE. I am happy for that one byte for the next few weeks . No way would i have figure that out any time soon. I been on this for weeks going no where. It's hard to give up. PS:Staff... I wonder what happen to my password. Easy as iic2 and never changed by me. Hello sinsi. I think that's where the bad luck begun than came 2 lines of the meanest code ever that is about to make a true assembler out of me ,,, |
|||
27 Jun 2008, 06:30 |
|
sinsi 27 Jun 2008, 07:30
Code: mov eax,[TEMP_1] mov dl,[string] bswap eax mov al,dl bswap eax Sorry bitRAKE, I just don't like the idea of going [var-1] Code: virtual at edi mydword rd 1 end virtual ... call [VirtualAlloc] mov edi,eax ... mov eax,[mydword-1] crash... |
|||
27 Jun 2008, 07:30 |
|
bitRAKE 27 Jun 2008, 13:34
sinsi, you are correct - there should be some kind of warning with that usage. I was merely attempting to answer the problem in as lazy a fashion as possible.
iic2, for me it is an adventure - a journey of discovery. Every instruction another piece to a puzzle with an undefined picture. Don't settle - never become content with what you have become. _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
27 Jun 2008, 13:34 |
|
Madis731 29 Jun 2008, 22:38
Code: ;"1230" to 33221100h (which in memory resides like 00h,11h,22h,33h mov eax,"1230" sub eax,30303030h ; 00030201h imul eax,1100h ; 33221100h What you are asking is a bit overly complicated. You may also need a BSWAP there if your order needs to be different. |
|||
29 Jun 2008, 22:38 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.