• Welcome to Valhalla Legends Archive.
 

ASM -> machine code question

Started by Genova, January 05, 2006, 09:40 AM

Previous topic - Next topic

Genova

Hi i was wondering what this asm code will look like in machine language.

mov [123456+0x4], 00

i was referring to the machine code in this format: poke 123456 xx xx xx xx ..etc

can anyone help? or is there any software to do the conversion?

Joe[x86]

If I remember correctly, PEEK and POKE are really old BASIC-kernel commands. Either that or they're Motorolla 68k or PPC assembly. I had no programming experience when I read a book that used them, but I think it was basic.

But yeah, use NASM (Netwide ASeMbler) to convert to machine code. By the way, you wouldn't use [123456+0x4], you'd probably simplify that to mov 123460, 00.
Quote from: brew on April 25, 2007, 07:33 PM
that made me feel like a total idiot. this entire thing was useless.

Genova

Quote from: Joe on January 05, 2006, 07:42 PM
If I remember correctly, PEEK and POKE are really old BASIC-kernel commands. Either that or they're Motorolla 68k or PPC assembly. I had no programming experience when I read a book that used them, but I think it was basic.

But yeah, use NASM (Netwide ASeMbler) to convert to machine code. By the way, you wouldn't use [123456+0x4], you'd probably simplify that to mov 123460, 00.

i need to have [123456+0x4] cause i'm implementing a pointer 123456 with offset 04 (hex). and i'm setting the value of the resolved address to 0.

Skywing

Keep in mind that the exact syntax you use depends on which assembler you use, most have various small differences in syntax.

Here are the encodings for either the byte or dword forms depending on whether you meant to write a single byte or zero extended 32-bit value:

0:000> a eip
7c901230 mov byte ptr [0n123456+4], 0
7c901237
0:000> u eip
ntdll!DbgBreakPoint:
7c901230 c60544e2010000   mov     byte ptr [0001e244],0x0

0:000> a eip
7c901230 mov dword ptr [0n123456+4], 0
7c90123a
0:000> u eip
ntdll!DbgBreakPoint:
7c901230 c70544e2010000000000 mov dword ptr [0001e244],0x0

Kp

Quote from: Skywing on January 06, 2006, 09:57 AMmost have various small differences in syntax.

Or if he goes the GNU route, some very large differences in syntax. :)  Among other things, GNU AS puts operands in the opposite order from most other assemblers, and has completely different semantics for specifying an absolute memory reference vs. an immediate value.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

Warrior

GAS....*shudders* I personally think (while being the syntax that in theory would make more sense since things like mov instructions are in order) that is one of the most horrible syntaxes I have ever used. I think I opted for just linking compiled NASM with my project instead of using gcc inline ASM which uses it.
Quote from: effect on March 09, 2006, 11:52 PM
Islam is a steaming pile of fucking dog shit. Everything about it is flawed, anybody who believes in it is a terrorist, if you disagree with me, then im sorry your wrong.

Quote from: Rule on May 07, 2006, 01:30 PM
Why don't you stop being American and start acting like a decent human?

Kp

It's not that bad.  Also, it's not GNU's fault.  They're just using the syntax AT&T pushed.  Everyone else is using Intel syntax.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

Warrior

I'd call it thier fault for using AT&T's hard to read syntax. Although it has gotten bearable after using it for a while and it beats the heck out of managing asm files. It will grow on me I guess.
Quote from: effect on March 09, 2006, 11:52 PM
Islam is a steaming pile of fucking dog shit. Everything about it is flawed, anybody who believes in it is a terrorist, if you disagree with me, then im sorry your wrong.

Quote from: Rule on May 07, 2006, 01:30 PM
Why don't you stop being American and start acting like a decent human?

Joe[x86]

Quote from: Warrior on January 07, 2006, 11:53 AM
I'd call it thier fault for using AT&T's hard to read syntax. Although it has gotten bearable after using it for a while and it beats the heck out of managing asm files. It will grow on me I guess.

What Darkness does is writes his ASM code, compiles it with NASM, and then references it from g++ or gcc. Or maybe that was you. I don't remember.
Quote from: brew on April 25, 2007, 07:33 PM
that made me feel like a total idiot. this entire thing was useless.