Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  nodelist  faq  login

The Macintosh is Xerox technology at its best.


programming / alt.lang.asm / Re: tasm encoding

SubjectAuthor
* tasm encodingTavis Ormandy
+* Re: tasm encodingwolfgang kern
|`- Re: tasm encodingTavis Ormandy
`* Re: tasm encodingAlexei A. Frounze
 `- Re: tasm encodingTavis Ormandy

1
Subject: tasm encoding
From: Tavis Ormandy
Newsgroups: alt.lang.asm
Date: Mon, 22 Feb 2021 17:34 UTC
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!2.eu.feeder.erje.net!feeder.erje.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: tav...@gmail.com (Tavis Ormandy)
Newsgroups: alt.lang.asm
Subject: tasm encoding
Date: 22 Feb 2021 17:34:50 GMT
Lines: 27
Message-ID: <i9i89qFi8cgU1@mid.individual.net>
X-Trace: individual.net sLYGgfUgkGJntmE+CCbV3AJNQiQfPl3hQ96Z/1sH7hExdhrBRJ
Cancel-Lock: sha1:D4T/3d7rHe8WvNjpiFKEHjBgNXc=
User-Agent: slrn/pre1.0.4-5 (Linux)
View all headers

Hello, I'm trying to convince TASM to generate the sign extending form
of and r16,imm8, something like this:

    83 E7 FE        and di, 0fffeh

I've tried all ways I can think of writing it (not 1, -2, etc),
but it always generates

    81 E7 FE FF     and     di, 0FFFEh

Using "byte -2" seems to generate incorrect code, but maybe there's a
rationale I don't understand.

I thought perhaps a TASM expert knows a magic incantation or directive to
get the encoding I'm looking for? I'm not really a TASM programmer, I'm
trying to fix an old DOS driver.

Obviously I can just db it in there or use a macro, I'll do that if I
have to, but I think it might get messy.

Tavis.

--
 _o)            $ lynx lock.cmpxchg8b.com
 /\\  _o)  _o)  $ finger taviso@sdf.org
_\_V _( ) _( )  @taviso


Subject: Re: tasm encoding
From: wolfgang kern
Newsgroups: alt.lang.asm
Organization: Aioe.org NNTP Server
Date: Tue, 23 Feb 2021 04:16 UTC
References: 1
Path: i2pn2.org!i2pn.org!aioe.org!GIme4pBO6z5YdwsHkjACqg.user.gioia.aioe.org.POSTED!not-for-mail
From: nowh...@never.at (wolfgang kern)
Newsgroups: alt.lang.asm
Subject: Re: tasm encoding
Date: Tue, 23 Feb 2021 05:16:28 +0100
Organization: Aioe.org NNTP Server
Lines: 26
Message-ID: <s11viu$1rc6$1@gioia.aioe.org>
References: <i9i89qFi8cgU1@mid.individual.net>
NNTP-Posting-Host: GIme4pBO6z5YdwsHkjACqg.user.gioia.aioe.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Complaints-To: abuse@aioe.org
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:86.0) Gecko/20100101
Thunderbird/86.0
Content-Language: en-US
X-Notice: Filtered by postfilter v. 0.9.2
View all headers
On 22.02.2021 18:34, Tavis Ormandy wrote:
Hello, I'm trying to convince TASM to generate the sign extending form
of and r16,imm8, something like this:

     83 E7 FE        and di, 0fffeh

I've tried all ways I can think of writing it (not 1, -2, etc),
but it always generates

     81 E7 FE FF     and     di, 0FFFEh

Using "byte -2" seems to generate incorrect code, but maybe there's a
rationale I don't understand.

I thought perhaps a TASM expert knows a magic incantation or directive to
get the encoding I'm looking for? I'm not really a TASM programmer, I'm
trying to fix an old DOS driver.

Obviously I can just db it in there or use a macro, I'll do that if I
have to, but I think it might get messy.

it's several decades ago when I tried TASM, what I still remember is that "db" was the only option to get desired opcodes.
your example is just one of a lot unsupported code variants in TASM.
__
wolfgang


Subject: Re: tasm encoding
From: Tavis Ormandy
Newsgroups: alt.lang.asm
Date: Tue, 23 Feb 2021 05:00 UTC
References: 1 2
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news-peer.in.tum.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: tav...@gmail.com (Tavis Ormandy)
Newsgroups: alt.lang.asm
Subject: Re: tasm encoding
Date: 23 Feb 2021 05:00:43 GMT
Lines: 18
Message-ID: <i9jgfqFq070U1@mid.individual.net>
References: <i9i89qFi8cgU1@mid.individual.net> <s11viu$1rc6$1@gioia.aioe.org>
X-Trace: individual.net 4ZG43Xh8WDrFDIpQFsiDLAPFT0sxI1wViYi0UShAA/3c+A7jKw
Cancel-Lock: sha1:40/4You4UJdO1YY6RFsAlmsuMqY=
User-Agent: slrn/pre1.0.4-5 (Linux)
View all headers
On 2021-02-23, wolfgang kern wrote:
On 22.02.2021 18:34, Tavis Ormandy wrote:
Obviously I can just db it in there or use a macro, I'll do that if I
have to, but I think it might get messy.

it's several decades ago when I tried TASM, what I still remember is
that "db" was the only option to get desired opcodes.
your example is just one of a lot unsupported code variants in TASM.

I thought that might be the answer, thanks anyway!

Tavis.


--
 _o)            $ lynx lock.cmpxchg8b.com
 /\\  _o)  _o)  $ finger taviso@sdf.org
_\_V _( ) _( )  @taviso


Subject: Re: tasm encoding
From: Alexei A. Frounze
Newsgroups: alt.lang.asm
Date: Tue, 23 Feb 2021 08:41 UTC
References: 1
X-Received: by 2002:a37:9ecd:: with SMTP id h196mr8746951qke.387.1614069680190;
Tue, 23 Feb 2021 00:41:20 -0800 (PST)
X-Received: by 2002:aca:6205:: with SMTP id w5mr18808592oib.164.1614069679951;
Tue, 23 Feb 2021 00:41:19 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: alt.lang.asm
Date: Tue, 23 Feb 2021 00:41:19 -0800 (PST)
In-Reply-To: <i9i89qFi8cgU1@mid.individual.net>
Injection-Info: google-groups.googlegroups.com; posting-host=24.4.130.174; posting-account=r_UqYQoAAADroB0Qe_EzH25J5Oyuce4G
NNTP-Posting-Host: 24.4.130.174
References: <i9i89qFi8cgU1@mid.individual.net>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <481363e4-9fa0-4a16-b9c9-ca72cc482769n@googlegroups.com>
Subject: Re: tasm encoding
From: alexfrun...@gmail.com (Alexei A. Frounze)
Injection-Date: Tue, 23 Feb 2021 08:41:20 +0000
Content-Type: text/plain; charset="UTF-8"
View all headers
On Monday, February 22, 2021 at 9:34:53 AM UTC-8, Tavis Ormandy wrote:
Hello, I'm trying to convince TASM to generate the sign extending form
of and r16,imm8, something like this:

83 E7 FE and di, 0fffeh

I've tried all ways I can think of writing it (not 1, -2, etc),
but it always generates

81 E7 FE FF and di, 0FFFEh

Using "byte -2" seems to generate incorrect code, but maybe there's a
rationale I don't understand.

TASM 3.2 does it just fine. Here's a listing file I get:
----8<----
Turbo Assembler Version 3.2     02/22/21 10:58:12     Page 1
and.asm



      1      ;.8086
      2
      3 0000      code segment use16
      4      assume cs:code
      5      org 100h
      6
      7 0100      start:
      8 0100  83 E7 FE        and di, 0fffeh
      9 0103  83 E7 FE        and di, -2
     10 0106  83 E7 FF        and di, byte -2 ; generates 0ffh instead of 0feh
     11
     12 0109      code ends
     13      end start
....
----8<----

Throwing in .8086 didn't seem to make any effect, even though 083H is an encoding from a newer CPU, the 80386.

The 80286 knows these:
20 /r      AND eb,rb     2,mem=7    Logical-AND byte register into EA byte
21 /r      AND ew,rw     2,mem=7    Logical-AND word register into EA word
22 /r      AND rb,eb     2,mem=7    Logical-AND EA byte into byte register
23 /r      AND rw,ew     2,mem=7    Logical-AND EA word into word register
24 db      AND AL,db     3          Logical-AND immediate byte into AL
25 dw      AND AX,dw     3          Logical-AND immediate word into AX
80 /4 db   AND eb,db     3,mem=7    Logical-AND immediate byte into EA byte
81 /4 dw   AND ew,dw     3,mem=7    Logical-AND immediate word into EA word

The 80386 knows these:
20 /r AND r/m8,r8 2/7 AND byte register to r/m byte
21 /r AND r/m16,r16 2/7 AND word register to r/m word
21 /r AND r/m32,r32 2/7 AND dword register to r/m dword
22 /r AND r8,r/m8 2/6 AND r/m byte to byte register
23 /r AND r16,r/m16 2/6 AND r/m word to word register
23 /r AND r32,r/m32 2/6 AND r/m dword to dword register
24 ib AND AL,imm8 2 AND immediate byte to AL
25 iw AND AX,imm16 2 AND immediate word to AX
25 id AND EAX,imm32 2 AND immediate dword to EAX
80 /4 ib AND r/m8,imm8 2/7 AND immediate byte to r/m byte
81 /4 iw AND r/m16,imm16 2/7 AND immediate word to r/m word
81 /4 id AND r/m32,imm32 2/7 AND immediate dword to r/m dword
83 /4 ib AND r/m16,imm8 2/7 AND sign-extended immediate byte with r/m word
83 /4 ib AND r/m32,imm8 2/7 AND sign-extended immediate byte with r/m dword

So, either your TASM doesn't know the 80386 encodings or is somehow restricted to produce the pre-80386 ones.
HTH,
Alex


Subject: Re: tasm encoding
From: Tavis Ormandy
Newsgroups: alt.lang.asm
Date: Tue, 23 Feb 2021 14:55 UTC
References: 1 2
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.mixmin.net!newsreader4.netcologne.de!news.netcologne.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: tav...@gmail.com (Tavis Ormandy)
Newsgroups: alt.lang.asm
Subject: Re: tasm encoding
Date: 23 Feb 2021 14:55:01 GMT
Lines: 20
Message-ID: <i9kja4F22cpU1@mid.individual.net>
References: <i9i89qFi8cgU1@mid.individual.net>
<481363e4-9fa0-4a16-b9c9-ca72cc482769n@googlegroups.com>
X-Trace: individual.net Z76Qjj0r3AxLqD5lbdI9ywCzAnaFv/FxokWkSro/hVJ8W8etm1
Cancel-Lock: sha1:H4etRazBSOGtefwK+l66MD650Y8=
User-Agent: slrn/pre1.0.4-5 (Linux)
View all headers
On 2021-02-23, Alexei A. Frounze wrote:
81 E7 FE FF and di, 0FFFEh

Using "byte -2" seems to generate incorrect code, but maybe there's a
rationale I don't understand.

So, either your TASM doesn't know the 80386 encodings or is somehow restricted to produce the pre-80386 ones.

Ah-ha, you're right - it was because I was using the NOSMART directive.

Unfortunately turning that off breaks a different encoding! I'll have to
experiment, hopefully it's an easy fix :)

Thank you.


--
 _o)            $ lynx lock.cmpxchg8b.com
 /\\  _o)  _o)  $ finger taviso@sdf.org
_\_V _( ) _( )  @taviso


1
rocksolid light 0.7.2
clearneti2ptor