Terraspace / UASM

UASM - Macro Assembler
http://www.terraspace.co.uk/uasm.html
Other
221 stars 49 forks source link

Instruction encoding with address size override prefix is wrong #172

Closed Ringdingcoder closed 1 year ago

Ringdingcoder commented 2 years ago

The following file, when built with uasm -3 -bin -Fl

    .model  flat
    .code
mov edx, [bp+8]

will generate this listing:

UASM v2.55, Apr 24 2022, Masm-compatible assembler.

testcase.asm
                                        .model  flat
                                        .code
00000000  678B5008              mov edx, [bp+8]

But disassembly of the generated binary gives

00000000  678B5008          mov edx,[bx+si+0x8]

which is obviously something very different.

john-terraspace commented 2 years ago

If you want to generate proper 16bit effective addresses you can use:

option flat:1 .code USE16 mov edx, [bp+8]

or using traditional segment notation:

.model flat mycode segment para public use16 'code' assume cs:mycode mov edx, [bp+8] mycode ends

.code simplified directives are really only for 32bit+

Ringdingcoder commented 2 years ago

I actually wanted to generate 32 bit code to see if it works. In other assemblers, it does. The correct binary code would be 678B5608.

john-terraspace commented 2 years ago

Ah ok, I'll look into that then.

john-terraspace commented 2 years ago

Out of curiosity, is there an actual use-case for this, or more just because you should be able to ?

john-terraspace commented 2 years ago

Fixed in 2.56

Ringdingcoder commented 2 years ago

Use case, meaning that the assembled code needs to do something useful, no. But meaning, the assembler can be used as a tool for experimentation, absolutely ;). Investigating interesting behavior tends to get harder with the amount of misbehaving links in the chain.

john-terraspace commented 2 years ago

Got it 😊 Well it’s all sorted now, if you want to try and let me know then we can close this ticket.

From: Stefan Ring @.> Sent: Wednesday, November 2, 2022 12:09 PM To: Terraspace/UASM @.> Cc: John Hankinson @.>; Comment @.> Subject: Re: [Terraspace/UASM] Instruction encoding with address size override prefix is wrong (Issue #172)

Use case, meaning that the assembled code needs to do something useful, no. But meaning, the assembler can be used as a tool for experimentation, absolutely ;). Investigating interesting behavior tends to get harder with the amount of misbehaving links in the chain.

— Reply to this email directly, view it on GitHub https://github.com/Terraspace/UASM/issues/172#issuecomment-1300240948 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AEAZAVCLXEEMH2OGZSEGZSLWGJKWLANCNFSM5USRB67A . You are receiving this because you commented.Message ID: @.***>

Ringdingcoder commented 2 years ago

I verified that this is fixed.