Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

"Send lawyers, guns and money..." -- Lyrics from a Warren Zevon song


devel / comp.lang.asm.x86 / Re: seg keyword

SubjectAuthor
* seg keywordPaul Edwards
`* seg keywordAlexei A. Frounze
 `* seg keywordPaul Edwards
  `* seg keywordAlexei A. Frounze
   `- seg keywordPaul Edwards

1
seg keyword

<cb464472-472c-460d-83fd-e2b5bd57b4e3n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=832&group=comp.lang.asm.x86#832

  copy link   Newsgroups: comp.lang.asm.x86
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: mutazilah@nospicedham.gmail.com (Paul Edwards)
Newsgroups: comp.lang.asm.x86
Subject: seg keyword
Date: Sat, 19 Nov 2022 11:22:42 -0800 (PST)
Organization: A noiseless patient Spider
Lines: 36
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <cb464472-472c-460d-83fd-e2b5bd57b4e3n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Injection-Date: Sat, 19 Nov 2022 19:22:42 +0000
Injection-Info: reader01.eternal-september.org; posting-host="df5986395ad149a27958751bc0d35b2f";
logging-data="3460072"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+rU2AaRQI6ukriOsV+u36r29exS4pcdso="
User-Agent: G2/1.0
Cancel-Lock: sha1:ldsZYVv1m+wk7tQ94vqc3WqRuws=
 by: Paul Edwards - Sat, 19 Nov 2022 19:22 UTC

I have code like this:

extrn int0:proc

public handler0

mov bx, 0
push bx
pop es
cli
mov bx, offset handler0
mov es:[0h], bx
mov bx, seg handler0
mov es:[02h], bx

handler0 proc
push bp
push ax

as86 uses 16-bit a.out format, and I'm not sure it can
handle a reference to just "seg". ie half of an address
being fixed up (I think that's what it does).

Is there a better way of writing this code, more in line
with the simple a.out format?

Is it:

addr0 dd handler0

And then do an les of that?

Thanks. Paul.

Re: seg keyword

<a6cc1525-1f18-4a2c-a6d1-ae2c96890f55n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=833&group=comp.lang.asm.x86#833

  copy link   Newsgroups: comp.lang.asm.x86
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: alexfrunews@nospicedham.gmail.com (Alexei A. Frounze)
Newsgroups: comp.lang.asm.x86
Subject: Re: seg keyword
Date: Sat, 19 Nov 2022 14:05:14 -0800 (PST)
Organization: A noiseless patient Spider
Lines: 30
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <a6cc1525-1f18-4a2c-a6d1-ae2c96890f55n@googlegroups.com>
References: <cb464472-472c-460d-83fd-e2b5bd57b4e3n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Injection-Date: Sat, 19 Nov 2022 22:05:15 +0000
Injection-Info: reader01.eternal-september.org; posting-host="df5986395ad149a27958751bc0d35b2f";
logging-data="3485439"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/gNFw+bKPJ+STYDSbvh8/4w/Ay6P8HRJE="
User-Agent: G2/1.0
Cancel-Lock: sha1:ttQ+L3DXG1JtszQZnnBMA8oskg4=
 by: Alexei A. Frounze - Sat, 19 Nov 2022 22:05 UTC

On Saturday, November 19, 2022 at 11:23:06 AM UTC-8, Paul Edwards wrote:
> I have code like this:
....
> mov bx, offset handler0
> mov es:[0h], bx
> mov bx, seg handler0
> mov es:[02h], bx
....
> as86 uses 16-bit a.out format, and I'm not sure it can
> handle a reference to just "seg". ie half of an address
> being fixed up (I think that's what it does).
>
> Is there a better way of writing this code, more in line
> with the simple a.out format?
>
> Is it:
>
> addr0 dd handler0
>
> And then do an les of that?

I don't recall the a.out format supporting segmentation.

I found my way around the similar problem with the ELF
format by simply using 32-bit physical addresses,
which are then decomposed into 16-bit segment and
16-bit offset pairs whenever necessary.

Alex

Re: seg keyword

<6b8aa743-b485-453f-b962-5df2a57327c5n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=836&group=comp.lang.asm.x86#836

  copy link   Newsgroups: comp.lang.asm.x86
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: mutazilah@nospicedham.gmail.com (Paul Edwards)
Newsgroups: comp.lang.asm.x86
Subject: Re: seg keyword
Date: Sat, 19 Nov 2022 17:01:40 -0800 (PST)
Organization: A noiseless patient Spider
Lines: 21
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <6b8aa743-b485-453f-b962-5df2a57327c5n@googlegroups.com>
References: <cb464472-472c-460d-83fd-e2b5bd57b4e3n@googlegroups.com> <a6cc1525-1f18-4a2c-a6d1-ae2c96890f55n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Injection-Date: Sun, 20 Nov 2022 01:01:41 +0000
Injection-Info: reader01.eternal-september.org; posting-host="b5846c16533d14873fbbe79487aa8e77";
logging-data="3513911"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/R84oQ8MliBUhAe3JbPnghws0pnM0E1Ms="
User-Agent: G2/1.0
Cancel-Lock: sha1:fVZaxgaC3tHIKoaJOaoIfo9AIBc=
 by: Paul Edwards - Sun, 20 Nov 2022 01:01 UTC

On Sunday, November 20, 2022 at 6:08:16 AM UTC+8, Alexei A. Frounze wrote:

> > Is it:
> >
> > addr0 dd handler0
> >
> > And then do an les of that?

> I don't recall the a.out format supporting segmentation.
>
> I found my way around the similar problem with the ELF
> format by simply using 32-bit physical addresses,
> which are then decomposed into 16-bit segment and
> 16-bit offset pairs whenever necessary.

How do I use a 32-bit physical address?

Is it like above?

Thanks. Paul.

Re: seg keyword

<92d52cff-9ded-425a-9997-cc0bb6ef398bn@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=837&group=comp.lang.asm.x86#837

  copy link   Newsgroups: comp.lang.asm.x86
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: alexfrunews@nospicedham.gmail.com (Alexei A. Frounze)
Newsgroups: comp.lang.asm.x86
Subject: Re: seg keyword
Date: Sat, 19 Nov 2022 20:03:20 -0800 (PST)
Organization: A noiseless patient Spider
Lines: 57
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <92d52cff-9ded-425a-9997-cc0bb6ef398bn@googlegroups.com>
References: <cb464472-472c-460d-83fd-e2b5bd57b4e3n@googlegroups.com>
<a6cc1525-1f18-4a2c-a6d1-ae2c96890f55n@googlegroups.com> <6b8aa743-b485-453f-b962-5df2a57327c5n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Injection-Date: Sun, 20 Nov 2022 04:03:20 +0000
Injection-Info: reader01.eternal-september.org; posting-host="b5846c16533d14873fbbe79487aa8e77";
logging-data="3628728"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/KFWg1INutJmHwjhZaXCMRIFTKE+jFHAg="
User-Agent: G2/1.0
Cancel-Lock: sha1:R8IEuHUqR9/3QBwjB5Hbn99ARD4=
 by: Alexei A. Frounze - Sun, 20 Nov 2022 04:03 UTC

On Saturday, November 19, 2022 at 5:19:35 PM UTC-8, Paul Edwards wrote:
> On Sunday, November 20, 2022 at 6:08:16 AM UTC+8, Alexei A. Frounze wrote:
>
> > > Is it:
> > >
> > > addr0 dd handler0
> > >
> > > And then do an les of that?
>
> > I don't recall the a.out format supporting segmentation.
> >
> > I found my way around the similar problem with the ELF
> > format by simply using 32-bit physical addresses,
> > which are then decomposed into 16-bit segment and
> > 16-bit offset pairs whenever necessary.
> How do I use a 32-bit physical address?
>
> Is it like above?

Yes.

I used the assembler (NASM) in the 32-bit non-segmented mode,
where all addresses are simply 32-bit offsets.

The linker, startup code (AKA loader) and generated code then
convert these into seg16:ofs16 using 80386 32-bit instructions.

[This is SmallerC's huge memory model in a nutshell.]

While said conversion is conceptually trivial, only a few 8086
instructions (far call, far jump, lds/les) can consume 32 bits
of an address (seg16:ofs16). Everywhere else you have the far
address split into two 16-bit portions with some space (code)
between the two.

If you want to be able to use these 16-bit parts independently,
you need to produce two special kinds of relocation records,
one for the SEG keyword, the other for the OFS/OFFSET.
The latter is more or less trivial and already exists, but is
probably 32-bit in your assembler, whereas it needs to be 16-bit.
The former needs to be introduced.

The simplest is perhaps to restrict every object file to
two segments/sections (code and data), each at most 64KB
in size and 16-byte aligned and padded to a multiple of 16 bytes.
OFS/OFFSET would then be the subroutine/variable offset
from the beginning of its segment/section in the object file.
SEG would simply account for the cumulative size of all
the linked object files. In essence, you end up relocating
only the SEG part as the OFS/OFFSET part is fixed.

Otherwise you could dump all far pointers into the default
data segment and simply do lds/les as needed (naturally,
the pointer values must've been relocated by then).

Alex

Re: seg keyword

<5f3ae81b-6016-4a4b-accc-020cb48ec19an@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=838&group=comp.lang.asm.x86#838

  copy link   Newsgroups: comp.lang.asm.x86
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: mutazilah@nospicedham.gmail.com (Paul Edwards)
Newsgroups: comp.lang.asm.x86
Subject: Re: seg keyword
Date: Sun, 20 Nov 2022 04:23:09 -0800 (PST)
Organization: A noiseless patient Spider
Lines: 226
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <5f3ae81b-6016-4a4b-accc-020cb48ec19an@googlegroups.com>
References: <cb464472-472c-460d-83fd-e2b5bd57b4e3n@googlegroups.com>
<a6cc1525-1f18-4a2c-a6d1-ae2c96890f55n@googlegroups.com> <6b8aa743-b485-453f-b962-5df2a57327c5n@googlegroups.com>
<92d52cff-9ded-425a-9997-cc0bb6ef398bn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Injection-Date: Sun, 20 Nov 2022 12:23:09 +0000
Injection-Info: reader01.eternal-september.org; posting-host="b5846c16533d14873fbbe79487aa8e77";
logging-data="3701944"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18iemHYN/tT8cUVN2EDknEGLCvf+c6AkkI="
User-Agent: G2/1.0
Cancel-Lock: sha1:1Tmklv8S+kqupvPyyhF9yNgnIIY=
 by: Paul Edwards - Sun, 20 Nov 2022 12:23 UTC

On Sunday, November 20, 2022 at 12:05:21 PM UTC+8, Alexei A. Frounze wrote:

> > How do I use a 32-bit physical address?
> >
> > Is it like above?

> Yes.

Thanks. I just went ahead and tried that, but it didn't seem to work.

Any idea what I did wrong?

Here is the old (working) code:

; Released to the public domain by Matthew Parker on 4 December 1995
; Mods by Paul Edwards, also public domain.
; For different models just change the .model directive

% .model memodel, c

public instint

extrn int0:proc
extrn int1:proc
extrn int3:proc
extrn int20:proc
extrn int21:proc
extrn int25:proc
extrn int26:proc

public handler0
public handler1
public handler3
public handler20
public handler21
public handler25
public handler26

.code

instint proc uses bx es
mov bx, 0
push bx
pop es
cli
mov bx, offset handler0
mov es:[0h], bx
mov bx, seg handler0
mov es:[02h], bx
mov bx, offset handler1
mov es:[04h], bx
mov bx, seg handler1
mov es:[06h], bx
mov bx, offset handler3
mov es:[0ch], bx
mov bx, seg handler3
mov es:[0eh], bx
mov bx, offset handler20
mov es:[80h], bx
mov bx, seg handler20
mov es:[82h], bx
mov bx, offset handler21
mov es:[84h], bx
mov bx, seg handler21
mov es:[86h], bx
mov bx, offset handler25
mov es:[94h], bx
mov bx, seg handler25
mov es:[96h], bx
mov bx, offset handler26
mov es:[98h], bx
mov bx, seg handler26
mov es:[9Ah], bx
sti
ret
instint endp

; the stack will already have
; flags
; cs
; ip

handler0 proc
push bp
push ax
push ax ; dummy, actually cflag storage
push bx
push cx
push dx
push si
push di
push ds
push es

mov dx, DGROUP
mov ds, dx
mov ax, sp
push ss
push ax
call int0
add sp, 4

pop es
pop ds
pop di
pop si
pop dx
pop cx
pop bx
pop ax ; actually cflag

cmp ax, 0
je clear0
jmp notclear0
clear0:
pop ax
push bp
mov bp, sp
and word ptr [bp+6],0fffeh
pop bp
pop bp
iret
notclear0:
pop ax
push bp
mov bp, sp
or word ptr [bp+6],0001h
pop bp
pop bp
iret
handler0 endp

....

And here is the new code, which is now preventing PDOS/86
from booting:

; Released to the public domain by Matthew Parker on 4 December 1995
; Mods by Paul Edwards, also public domain.
; For different models just change the .model directive

% .model memodel, c

public instint

extrn int0:proc
extrn int1:proc
extrn int3:proc
extrn int20:proc
extrn int21:proc
extrn int25:proc
extrn int26:proc

public handler0
public handler1
public handler3
public handler20
public handler21
public handler25
public handler26

..data
addr0 dd handler0
addr1 dd handler1
addr3 dd handler3
addr20 dd handler20
addr21 dd handler21
addr25 dd handler25
addr26 dd handler26

.code

instint proc uses bx es ds
mov bx, 0
push bx
pop es
cli

lds bx, addr0
mov es:[0h], bx
mov es:[02h], ds

lds bx, addr1
mov es:[04h], bx
mov es:[06h], ds

lds bx, addr3
mov es:[0ch], bx
mov es:[0eh], ds

lds bx, addr20
mov es:[80h], bx
mov es:[82h], ds

lds bx, addr21
mov es:[84h], bx
mov es:[86h], ds

lds bx, addr25
mov es:[94h], bx
mov es:[96h], ds

lds bx, addr26
mov es:[98h], bx
mov es:[9Ah], ds

sti
ret
instint endp

; the stack will already have
; flags
; cs
; ip

handler0 proc
push bp
push ax
push ax ; dummy, actually cflag storage

....

Thanks. Paul.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor