News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Capital R in .lst files in MASM 6

Started by saeeedah, June 08, 2010, 12:47:05 PM

Previous topic - Next topic

saeeedah

What does Capital R after some segments mean in .lst files in MASM 6 ?
for example(R
[/color] in this program):[/b]



Microsoft (R) Macro Assembler Version 6.11          06/07/10 11:32:18
sum.asm                          Page 1 - 1


0000            stseg   segment   stack   'stack'
0000  0040 [            db   64   dup(?)
        00
       ]
0040            stseg   ends
            ;-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
0000            dtseg   segment
0000 566A 3BC7 1DE6 234D      data   dw   566ah,3bc7h,1de6h,234dh
               org      10h
0010 0000            sum      dw   ?
0012            dtseg   ends
            ;-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
0000            cdseg   segment
0000               main   proc   far
                  assume   cs:cdseg,ds:dtseg,ss:stseg
0000  B8 ---- R            mov   ax,dtseg
0003  8E D8               mov ds,ax
0005  B9 0004               mov   cx,04h
0008  BB 0000               mov   bx,0000h
000B  BF 0000 R            mov   di,offset data
000E  03 1D         add_lp:   add   bx,[di]
0010  47               inc   di
0011  47               inc   di
0012  49               dec   cx
0013  75 F9               jnz   add_lp
0015  BE 0010 R            mov   si,offset sum
0018  89 1C               mov   [si],bx
001A  B4 4C               mov   ah,4ch
001C  CD 21               int   21h
001E               main   endp
001E            cdseg ends
                  end main
Microsoft (R) Macro Assembler Version 6.11          06/07/10 11:32:18
sum.asm                          Symbols 2 - 1




Segments and Groups:

                N a m e                 Size     Length   Align   Combine Class

cdseg  . . . . . . . . . . . . .   16 Bit    001E     Para     Private
dtseg  . . . . . . . . . . . . .   16 Bit    0012     Para     Private
stseg  . . . . . . . . . . . . .   16 Bit    0040     Para     Stack     'STACK'   


Procedures,  parameters and locals:

                N a m e                 Type     Value    Attr

main . . . . . . . . . . . . . .   P Far    0000     cdseg   Length= 001E Private


Symbols:

                N a m e                 Type     Value    Attr

add_lp . . . . . . . . . . . . .   L Near    000E     cdseg   
data . . . . . . . . . . . . . .   Word    0000     dtseg   
sum  . . . . . . . . . . . . . .   Word    0010     dtseg   

      0 Warnings
      0 Errors

clive

It indicates the field is relocatable (not known absolutely), and will be fixed either at link time, or by the loader.
It could be a random act of randomness. Those happen a lot as well.

saeeedah

Quote from: clive on June 08, 2010, 01:16:09 PM
It indicates the field is relocatable (not known absolutely), and will be fixed either at link time, or by the loader.
many thanks for fast answer. i need a little more description.
why some of them can be relocated?

clive

If you link in other objects or libraries the size of the code/data segments will expand. The ASSEMBLER doesn't not know where they will end up, the LINKER will have an overview of the entire executable, and the LOADER will determine where the executable ends up in memory.

If the address that the executable is not known until load time, the loader will need to patch/fixup some addresses and segment references to match the address the file is eventually loaded at. The 16-bit code you have, loaded under DOS, has an indeterminate address at assembly time, unless it is a COM file (100h), or a boot loader (07C0:0000, aka 7C00h)

Things like ROM BIOS images will have hard/known addresses, the right linker can make an "absolute" binary image for a fixed address. Such code can typically only be loaded at that one address, unless efforts were made to make it location independent.
It could be a random act of randomness. Those happen a lot as well.

saeeedah

Excuse me I have another question:
In Dos why we have to use STSEG Segment Stack'Stack' Instead of STSEG Segment to define a segment  ?

clive

Basically so the LINKER knows which segment you want to use for the STACK, and how big it should be.

Personally, I would use the following if I was using OLD MASM syntax, today it would be simpler with .MODEL/.DATA/.CODE

_text segment para public 'CODE'
_text ends

_data segment para public 'DATA'
_data ends

stack segment para stack 'STACK'
stack ends

dgroup group _data

assume cs:_text, ds:dgroup, es:dgroup, ss:stack


The fact your code and data segments aren't more explicitly defined is a function of the coder of the example being lazy. This might be fine for simple examples, but will likely result in issues if you expect the linker to use specific alignments, segment ordering, or code ordering.
It could be a random act of randomness. Those happen a lot as well.