Valhalla Legends Forums Archive | Assembly Language (any cpu) | ASM -> machine code question

AuthorMessageTime
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?
January 5, 2006, 3:40 PM
JoeTheOdd
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 [tt]mov 123460, 00[/tt].
January 6, 2006, 1:42 AM
Genova
[quote author=Joe link=topic=13797.msg140734#msg140734 date=1136511773]
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 [tt]mov 123460, 00[/tt].
[/quote]

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.
January 6, 2006, 2:19 AM
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
January 6, 2006, 3:57 PM
Kp
[quote author=Skywing link=topic=13797.msg140815#msg140815 date=1136563045]most have various small differences in syntax.[/quote]

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.
January 7, 2006, 2:38 AM
Quarantine
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.
January 7, 2006, 5:20 AM
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.
January 7, 2006, 5:15 PM
Quarantine
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.
January 7, 2006, 5:53 PM
JoeTheOdd
[quote author=Warrior link=topic=13797.msg140951#msg140951 date=1136656414]
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]

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.
January 7, 2006, 9:40 PM

Search