Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > alt.os.development > #8291

Re: What form of executable or load module for your OS?

Path csiph.com!aioe.org!.POSTED!not-for-mail
From "Rod Pemberton" <boo@fasdfrewar.cdm>
Newsgroups alt.os.development
Subject Re: What form of executable or load module for your OS?
Date Sat, 04 Jul 2015 04:00:59 -0400
Organization Aioe.org NNTP Server
Lines 134
Message-ID <op.x08ojxp5yfako5@localhost> (permalink)
References <mme4i6$a6e$1@dont-email.me> <5bb535cc-0995-4fdd-ae16-a1217c4b8e92@googlegroups.com> <mn0c7p$q8n$1@dont-email.me> <c80bcbf7-a245-45a7-bb30-21e5660c2959@googlegroups.com> <mn3749$3nl$1@dont-email.me> <75acded2-9f64-4d9f-81c2-7ec73fd72e01@googlegroups.com> <mn5dto$q6c$1@dont-email.me> <1687b850-3c16-44ec-9bd9-4eb0dc2a201b@googlegroups.com> <mn5o0b$uv1$1@dont-email.me> <op.x07tovymyfako5@localhost> <mn6vm9$g5a$1@dont-email.me> <fe6d6902-6d1a-4452-94a6-233d89db24e1@googlegroups.com> <mn73e5$3hc$1@dont-email.me>
NNTP-Posting-Host n4wpt9zq8xR26Ttf9mo2BA.user.speranza.aioe.org
Mime-Version 1.0
Content-Type text/plain; charset=iso-8859-1; format=flowed; delsp=yes
Content-Transfer-Encoding 7bit
X-Complaints-To abuse@aioe.org
User-Agent Opera Mail/12.16 (Linux)
X-Notice Filtered by postfilter v. 0.8.2
Xref aioe.org alt.os.development:8291

Show key headers only | View raw


On Fri, 03 Jul 2015 18:48:56 -0400, James Harris  
<james.harris.1@gmail.com> wrote:
> "Alexei A. Frounze" <alexfrunews@gmail.com> wrote in message  
> news:fe6d6902-6d1a-4452-94a6-233d89db24e1@googlegroups.com...
>> On Friday, July 3, 2015 at 2:45:02 PM UTC-7, James Harris wrote:

>>> I don't know what he emits that is not 8086 compatible. Could it be  
>>> more
>>> than just a few instructions?
>
> ...
>
>> In 16-bit memory models (without long/32-bit types):
>> movsx/movzx
>> push imm
>> shl/shr/sar reg, imm>1
>> setcc
>> jcc rel16 (generated automatically by NASM where jcc rel8 isn't  
>> sufficient)
>
> They don't seem too bad.

They seem straightforward to me and I'm falling asleep ...

I just constructed these using NASM and an online x86 manual.
I didn't test these.  Obviously, "CPU 8086" for NASM will
flag some mistakes, i.e., non-8086 instructions.  You can
obviously post to CLAX too for additional solutions.  8086
has a unique variety of solutions for certain computations.

Sequences for PUSH imm8/16 instruction and SHL/SHR/SAR
instructions have "trivial" side-effects.  With NASM's
macro processor, it should be possible to work around
the side effect for SHL/SHR/SAR.


1) MOVSX

MOVSX reg16,r/m8

; where reg8 is low sub-register of reg16
MOV reg8,r/m8
CBW reg16

2) MOVZX

MOVZX reg16,r/m8

; where XOR reg8 is high sub-register corresponding
;  to low sub-register MOV reg8
MOV reg8,r/m8
XOR reg8,reg8  ; clear high

Alternately,

; where reg8 is low sub-register of reg16
XOR reg16,reg16
MOV reg8,r/m8

3) PUSH

3a) PUSH imm16

; this needs a register that can be destroyed, e.g., AX
MOV  reg16,imm16
PUSH reg16

3b) PUSH imm8   ; sign-extended to stack size 16/32-bits from imm8

; where reg8 is low sub-register of reg16
; this needs a register that can be destroyed, e.g., AX
MOV  reg8,imm8
CBW  reg16
PUSH reg16

Obviously, if you don't use the sign-extension and are only using
the lower 8-bits of the register, then that can be shortened by
eliminating the CBW.  The high 8-bits will be garbage, but unused.

Alternately,

; this needs a register that can be destroyed, e.g., AX
XOR reg16,reg16
ADD/OR reg16,imm8   ; imm8 is sign-extended to 16-bits
PUSH reg16

Either ADD or OR should work.  ADD and OR treat flags differently.

4) SHL/SHR/SAR

SHL/SHR/SAR r/m8/16,imm8

PUSH CX
MOV CL,imm8
SHL/SHR/SAR r/m8/16,CL
POP CX

Obviously, you should avoid selecting CL or CX to shift ...

5) SETcc

SETcc r/m8

MOV r/m8,1h
Jcc here
DEC r/m8
here:

6) NASM auto-generated long branches

6a) use old NASM 0.98.39
6b) set a NASM flag to not do that
6c) patch up SmallerC to not generate long branches
6d) generate short branch around long jump
6e) use indirect address in memory
etc

7) registers wider than 16 bits

If Alexei uses this, which he didn't list, then
the code would need to be reworked, since operand
and address size overrides came later.

8) PUSHA/POPA

These need to be expanded to full set of PUSHes or POPs.
They should probably preserve the stack order of PUSHA/POPA.


Rod Pemberton

-- 
Tolerance and socialism attracts intolerance and terrorism.  See:
France, United Kingdom, Germany, Denmark, Belgium, Netherlands, ...

Back to alt.os.development | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: What form of executable or load module for your OS? "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-06-25 21:20 -0700
  Re: What form of executable or load module for your OS? "James Harris" <james.harris.1@gmail.com> - 2015-07-01 10:36 +0100
    Re: What form of executable or load module for your OS? "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-07-01 21:07 -0700
      Re: What form of executable or load module for your OS? "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-07-02 23:35 -0700
        Re: What form of executable or load module for your OS? "James Harris" <james.harris.1@gmail.com> - 2015-07-03 08:35 +0100
          Re: What form of executable or load module for your OS? "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-07-03 02:49 -0700
            Re: What form of executable or load module for your OS? "James Harris" <james.harris.1@gmail.com> - 2015-07-03 11:27 +0100
              Re: What form of executable or load module for your OS? "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-07-03 16:54 -0400
                Re: What form of executable or load module for your OS? "James Harris" <james.harris.1@gmail.com> - 2015-07-03 22:45 +0100
                Re: What form of executable or load module for your OS? "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-07-03 17:56 -0400
                Re: What form of executable or load module for your OS? "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-07-03 15:28 -0700
                Re: What form of executable or load module for your OS? "James Harris" <james.harris.1@gmail.com> - 2015-07-03 23:48 +0100
                Re: What form of executable or load module for your OS? "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-07-03 21:52 -0700
                Re: What form of executable or load module for your OS? "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-07-04 04:00 -0400
                Re: What form of executable or load module for your OS? "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-07-04 04:42 -0700
                Re: What form of executable or load module for your OS? "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-07-05 02:12 -0400
                Re: What form of executable or load module for your OS? "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-07-05 00:47 -0700
                Re: What form of executable or load module for your OS? "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-07-05 05:28 -0400
                Re: What form of executable or load module for your OS? "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-07-05 02:58 -0700
                Re: What form of executable or load module for your OS? "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-07-06 06:21 -0400
                Re: What form of executable or load module for your OS? "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-07-07 01:44 -0700
                Re: What form of executable or load module for your OS? "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-07-07 05:40 -0400
                Re: What form of executable or load module for your OS? "Kerr Mudd-John" <admin@127.0.0.1> - 2015-07-07 14:02 +0100
                Re: What form of executable or load module for your OS? "wolfgang kern" <nowhere@never.at> - 2015-07-07 18:13 +0200
                Re: What form of executable or load module for your OS? "Kerr Mudd-John" <notsaying@invalid.org> - 2015-07-08 12:54 -0100
                Re: What form of executable or load module for your OS? "James Harris" <james.harris.1@gmail.com> - 2015-07-09 13:19 +0100
                Re: What form of executable or load module for your OS? "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-07-07 22:10 -0700
                Re: What form of executable or load module for your OS? "James Harris" <james.harris.1@gmail.com> - 2015-07-08 08:48 +0100
                Re: What form of executable or load module for your OS? "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-07-08 23:53 -0700
                Re: What form of executable or load module for your OS? "James Harris" <james.harris.1@gmail.com> - 2015-07-09 17:29 +0100
                Re: What form of executable or load module for your OS? "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-07-10 01:01 -0700
                Re: What form of executable or load module for your OS? "James Harris" <james.harris.1@gmail.com> - 2015-07-10 13:46 +0100
                Re: What form of executable or load module for your OS? "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-07-10 00:59 -0700
                Re: What form of executable or load module for your OS? "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-07-08 03:52 -0400
                Re: What form of executable or load module for your OS? "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-07-08 06:46 -0700
                Re: What form of executable or load module for your OS? "James Harris" <james.harris.1@gmail.com> - 2015-07-09 13:16 +0100
                Re: What form of executable or load module for your OS? "s_dubrovich@yahoo.com" <s_dubrovich@yahoo.com> - 2015-07-11 09:57 -0700
                Re: What form of executable or load module for your OS? "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-07-13 02:47 -0400
                Re: What form of executable or load module for your OS? "s_dubrovich@yahoo.com" <s_dubrovich@yahoo.com> - 2015-07-14 07:39 -0700
                Re: What form of executable or load module for your OS? "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-07-15 02:37 -0400
        Code insanity "Mike Gonta" <mikegonta@gmail.com> - 2015-07-03 03:47 -0400
          Re: Code insanity "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-07-03 02:57 -0700
          Re: Code insanity (was: What form of executable or load module for your OS?) "James Harris" <james.harris.1@gmail.com> - 2015-07-03 11:35 +0100

csiph-web