News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Help with converting ASM instructions to binary

Started by Swerve, June 01, 2008, 04:53:58 PM

Previous topic - Next topic

Swerve

Hi,

I am trying to convert the following line of code into machine code, but am stuck with one part.

The original instruction is:-

QuoteMOVE.L #$D3A5, D2

Starting with:-

Quote0000 0000 0000 0000

I added the MOVE part, leaving:-

Quote0000 0000 0000 0000

I then added the .L, leaving:-

Quote0010 0000 0000 0000

Then I added the destination address (D2):-

Quote0010 0100 0000 0000

But now I am stuck, I have the answer which is:-

Quote0010 0100 0011  1100

My problem is that I don't see how the remaining L#$D3A5 fits into the answer. I understand that I am moving the data it'self in Hex format, but unfortunately this isn't bridging my gap in knowledge.

Hope this is in the right forum, and thanks for any help!

Swerve.

PBrennick

Correct me if I am wrong, but I see that instruction as simply loading an imediate value into an address. If this IS the case, then the answer should be 1101001110100101. Since I do not understand the 'L' part perhaps I should keep my trap shut? By the way, that is an unsigned answer.

Paul
The GeneSys Project is available from:
The Repository or My crappy website

Swerve

Thanks Paul  :bg

Yes, the .L part is to state it is a Long Word being moved (32 bits). I am getting this from my notes, and have to be honest in that I don't fully understand more than - if not all of the 8 binary digits are used, the remaining most significant digits are set to 0.

I have done an easier question should that throw any insight into what I am doing:-

Original instruction :-

QuoteMOVE.L D3, D1

So starting from :-
Quote
0000 0000 0000 0000

I added the MOVE command:-

Quote0000 0000 0000 0000

Then added the .L :-

Quote0010 0000 0000 0000

Then added the source address ( D3):-
Quote
0010 0000 0000 0011

Then added the destination address:-
Quote
0010 0010 0000 0011

Which is the final answer.


 

BogdanOntanu


mov dword ptr [0D3A5h],0D2h


is encoded as:


C7 05 A5D30000 D2000000


Your solution does not look "final".
The encodings for x86 instructions are clearly explained in Intel manuals.
However it is a lot of reading and understanding to be done.

Ambition is a lame excuse for the ones not brave enough to be lazy.
http://www.oby.ro

tenkey

Quote from: Swerve on June 01, 2008, 04:53:58 PM
The original instruction is:-

QuoteMOVE.L #$D3A5, D2

... [deleted] ...

But now I am stuck, I have the answer which is:-

Quote0010 0100 0011 1100

My problem is that I don't see how the remaining L#$D3A5 fits into the answer. I understand that I am moving the data it'self in Hex format, but unfortunately this isn't bridging my gap in knowledge.

Had to pull out a 68000 reference card for this.

The MOVE immediate uses the general reg/mem to reg/mem format, so you need an address mode for the immediate value. The mode bits are 111 and the register bits are 100. The field order for the source "address" is mode-register, or 111 100. Reformatted to hex-friendly notation (and located at bits 5 to 0), that is 11 1100. The immediate data is the next 32 bits (remember it's a LONG data), after the first 16 bits.

That means the quoted "correct" answer is a partial answer.


p.s. The following is partially correct ...

QuoteThen I added the destination address (D2):-

Quote0010 0100 0000 0000

The destination address also includes the mode bits, so you really add six bits ...

Quote0010 0100 0000 0000


A programming language is low level when its programs require attention to the irrelevant.
Alan Perlis, Epigram #8