Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

The @data, whats that?

jawesfxjawesfx Member Posts: 15
Hey peeps I got a question in the code below:

mov ax, @data
mov ds, ax

or somethimes:

mov ax, @data
mov es, ax

I just know that these codes copy the OFFSET of data segment to DS and ES registers. BUt for what purpose? I hav these codes in my ASCII CHART program, and w/o it I will get ILLEGAL OPERATION on EXIT (running via dos box). Are these codes used for string operations, or just to access the offset of DS properly. Pls, explain this to me! Tnx! (or a little tutorial about this and other related stuff) Your help would be greatly appreciated!

PS: AsmGuru62, wer are u?? I'd been mailin' u, for about thrice, but no answer. Are u on vacation? Anyone can tell me where he is now? Tnx peeps

Cheers.

Comments

  • Broken SwordBroken Sword Member Posts: 3
    this is useful only for exe files, not for com ones (see why)
    @data - not an offset of the segment, but selector (if in RM we can name it so).
    When exe program loads into memory value of DS is not real. That's why you always must do it manual.


  • blipblip Member Posts: 756
    @data usually compiles as CS so MOV AX,@data would become MOV AX,CS.
  • Broken SwordBroken Sword Member Posts: 3
    : @data usually compiles as CS so MOV AX,@data would become MOV AX,CS.

    That's right, but only for tiny model. But what for in that case (for COM-files) do that trick ? It is absolutely unusable.

    For small model (exe-files) @data NEVER compiles to CS!


  • AsmGuru62AsmGuru62 Member Posts: 6,519
    : : @data usually compiles as CS so MOV AX,@data would become MOV AX,CS.
    :
    : That's right, but only for tiny model. But what for in that case (for COM-files) do that trick ? It is absolutely unusable.
    :
    : For small model (exe-files) @data NEVER compiles to CS!
    :
    :
    :
    [blue]Some tools (maybe MASM) will not need these instructions, but TASM needs them. The problem is that 'old' (DOS) EXE file header contains the values for registers (segments too) and TASM linker TLINK not setting them properly - they are set to PSP, EXE file data segment is usually different from PSP, so that is why these codes is usually used. Even in COM model you need the full address for CPU to access variables. If you write:

    mov ax, var1

    it means actually:

    mov ax, DS:var1

    so you need to set up DS anyhow...[/blue]
  • blipblip Member Posts: 756
    For any model EXEs it does put in "CS" in the code in the place of "@data" if that code that is within the first 64k of the loading area. COM files don't need it, but you probably could do it.
  • Broken SwordBroken Sword Member Posts: 3
    : For any model EXEs it does put in "CS" in the code in the place of "@data" if that code that is within the first 64k of the loading area. COM files don't need it, but you probably could do it.
    :
    Yes, I mean VALUE (!!!!) of CS register. You right in that case
  • Andre YoungAndre Young USAMember Posts: 0

    ____ || http://forcoder.org || free video tutorials and ebooks about | C++ Visual Basic .NET Java Python R Swift C Delphi Objective-C PHP Go Visual Basic PL/SQL Ruby C# JavaScript Perl Scratch MATLAB Assembly Crystal Julia Rust Erlang Clojure Logo ML VBScript SAS Dart Hack FoxPro Scheme Scala Prolog Alice Ada Apex Lua COBOL Awk ABAP Kotlin LabVIEW Bash Fortran Lisp F# Transact-SQL D | ________

Sign In or Register to comment.