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


Groups > comp.os.msdos.programmer > #4108

Re: How to access stack-based data (strings) when SS <> DS ?

From "R.Wieser" <address@not.available>
Newsgroups comp.os.msdos.programmer
Subject Re: How to access stack-based data (strings) when SS <> DS ?
Date 2021-12-05 08:56 +0100
Organization Aioe.org NNTP Server
Message-ID <sohrd6$1091$1@gioia.aioe.org> (permalink)
References <sof888$9ts$3@gioia.aioe.org><20211204124741.b1f496ac76286c31c6ae57c6@127.0.0.1><sofvm9$1ruj$2@gioia.aioe.org><20211204161338.a5708b13977709eec973bba8@127.0.0.1><sog9d6$gc3$2@gioia.aioe.org> <20211204202814.b2dc2da60c070f5f4fc60bbf@127.0.0.1>

Show all headers | View raw


John,

> OTOH I rarely use /lea/.

In a nutshell : "lea" returns a pointer to somewhere.  "mov" copies to/from 
somewhere.

Although "lea ax,address" and "mov ax,offset address" return the same thing, 
"lea"s strength lies in that it can accept a relative part in the form of a 
register.

Like "lea ax, [si+4]".   Load ax with the address four bytes beyond what SI 
is pointing at.

> OK I'll bow out, I'm clearly not understanding your requirement.

I posted a small addendum. My mistake was that I assumed that "[stack 
based]" would be understood as referring to a procedure-local variable or 
buffer.   IOW, "[stack based]" translates, for my example, to "[bp-xxxx]"

To be honest, I have not ever heard someone storing / retrieving data using 
absolute adressing inside the SS segment.  Instead always relative to either 
BP or SP.

Code example :
- - - - - - - - - - - - - - - - - -

MyProc:
    push   bp
    mov    bp,sp
    sub    sp,0100h    ;<- create a local buffer.

    ...

    lea    dx,[bp-0100h]    ;<- Point to the buffer
    mov    ah,09h
    int    21h

- - - - - - - - - - - - - - - - - -

Now imagine that you're using a memory model where DS <> SS.  The problem 
than is that in the above code DX is relative to SS, but int 21, ah=09h 
expects it to be relative to DS.

What I was wondering is how this would be handled by/in professional 
software (compilers).


Than again, I think I painted myself in a corner.  :-|

Although I was thinking of some code which would allocate a stack segment 
and initialise SS:SP to it (causing SS to become different from DS), when I 
this morning looked at the different memory models Borlands Tasm offers I 
could only find one which /doesn't/ set up SS equal to DS.  and that one, 
"TPASCAL", isn't even a standard one.   I wonder why that is. :-)

Its like having 20/20 vision looking back.  If only I had something like 
that beforehand ...

Regards,
Rudy Wieser

Back to comp.os.msdos.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

How to access stack-based data (strings) when SS <>  DS ? "R.Wieser" <address@not.available> - 2021-12-04 08:56 +0100
  Re: How to access stack-based data (strings) when SS <>  DS ? "Kerr-Mudd, John" <admin@127.0.0.1> - 2021-12-04 12:47 +0000
    Re: How to access stack-based data (strings) when SS <>  DS ? "R.Wieser" <address@not.available> - 2021-12-04 15:57 +0100
      Re: How to access stack-based data (strings) when SS <>  DS ? "Kerr-Mudd, John" <admin@127.0.0.1> - 2021-12-04 16:13 +0000
        Re: How to access stack-based data (strings) when SS <>  DS ? "R.Wieser" <address@not.available> - 2021-12-04 18:41 +0100
          Re: How to access stack-based data (strings) when SS <>  DS ? "Kerr-Mudd, John" <admin@127.0.0.1> - 2021-12-04 20:28 +0000
            Re: How to access stack-based data (strings) when SS <>  DS ? "R.Wieser" <address@not.available> - 2021-12-05 08:56 +0100
              Re: How to access stack-based data (strings) when SS <>  DS ? "Kerr-Mudd, John" <admin@127.0.0.1> - 2021-12-05 10:32 +0000
                Re: How to access stack-based data (strings) when SS <>  DS ? "R.Wieser" <address@not.available> - 2021-12-05 13:11 +0100
                Re: How to access stack-based data (strings) when SS <>  DS ? "Kerr-Mudd, John" <admin@127.0.0.1> - 2021-12-05 12:21 +0000
                Re: How to access stack-based data (strings) when SS <>  DS ? "R.Wieser" <address@not.available> - 2021-12-05 14:59 +0100
        Re: How to access stack-based data (strings) when SS <>  DS ? "R.Wieser" <address@not.available> - 2021-12-04 19:00 +0100
  Re: How to access stack-based data (strings) when SS <>  DS ? JJ <jj4public@gmail.com> - 2021-12-05 14:27 +0700
    Re: How to access stack-based data (strings) when SS <>  DS ? "R.Wieser" <address@not.available> - 2021-12-05 12:43 +0100
  Re: How to access stack-based data (strings) when SS <> DS ? "Alexei A. Frounze" <alexfrunews@gmail.com> - 2021-12-05 22:25 -0800
    Re: How to access stack-based data (strings) when SS <> DS ? Mateusz Viste <mateusz@xyz.invalid> - 2021-12-06 09:30 +0100
    Re: How to access stack-based data (strings) when SS <> DS ? "R.Wieser" <address@not.available> - 2021-12-06 14:33 +0100
      Re: How to access stack-based data (strings) when SS <> DS ? Herbert Kleebauer <klee@unibwm.de> - 2021-12-06 19:01 +0100
        Re: How to access stack-based data (strings) when SS <> DS ? "R.Wieser" <address@not.available> - 2021-12-06 21:16 +0100
          Re: How to access stack-based data (strings) when SS <> DS ? Herbert Kleebauer <klee@unibwm.de> - 2021-12-07 00:19 +0100
            Re: How to access stack-based data (strings) when SS <> DS ? Mateusz Viste <mateusz@xyz.invalid> - 2021-12-07 09:31 +0100
            Re: How to access stack-based data (strings) when SS <> DS ? "R.Wieser" <address@not.available> - 2021-12-07 09:37 +0100
            Re: How to access stack-based data (strings) when SS <> DS ?   Newbie language. "R.Wieser" <address@not.available> - 2021-12-08 10:16 +0100
              Re: How to access stack-based data (strings) when SS <> DS ? Newbie language. Herbert Kleebauer <klee@unibwm.de> - 2021-12-08 17:39 +0100
                Re: How to access stack-based data (strings) when SS <> DS ? Newbie language. "Kerr-Mudd, John" <admin@127.0.0.1> - 2021-12-08 17:37 +0000
                Re: How to access stack-based data (strings) when SS <> DS ? Newbie language. Herbert Kleebauer <klee@unibwm.de> - 2021-12-08 22:31 +0100
                Re: How to access stack-based data (strings) when SS <> DS ? Newbie language. "Kerr-Mudd, John" <admin@127.0.0.1> - 2021-12-09 21:43 +0000
                Re: How to access stack-based data (strings) when SS <> DS ? Newbie language. "R.Wieser" <address@not.available> - 2021-12-08 22:19 +0100
      Re: How to access stack-based data (strings) when SS <> DS ? "Alexei A. Frounze" <alexfrunews@gmail.com> - 2021-12-06 22:40 -0800
        Re: How to access stack-based data (strings) when SS <> DS ? "R.Wieser" <address@not.available> - 2021-12-07 10:17 +0100

csiph-web