flat assembler
Message board for the users of flat assembler.

Index > DOS > segment for uninitialized variables, MZ.

Author
Thread Post new topic Reply to topic
emc



Joined: 20 Aug 2011
Posts: 90
Location: France
emc
Hi

I am searching the name of the segment of uninitialized variable for the MZ format (If exists).
Or, the equivalent ELF .bss section for MZ format.

Thanks for attention.

_________________
;; emc
Post 20 Aug 2011, 13:18
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1901
DOS386
No need for a special segment, you can place your scratch area anywhere
(preferably to a place that "belongs" to you). There is no protection
in real mode. So the options are:

- Put some "db or "rb" at program end (bad "db" causes bloat)
- Hog some memory from DOS
- Reserve some memory as "heap" at program end (preferred).
Don't specify "heap 0", instead for example "heap $0100"
gives you 4 KiB. So in your only-one segment there will be
your code, the heap/scratch area and stack ("stack $1000"
gives 4 KiB). So the stack is in a separate segment by
default.

RTFM!!! (but not very verbose)

FYI, I personally use format binary for my MZ and PE executables.

You don't need segments at all (except your
code is > 64 KiB). Look at the (not many) examples
in MZ format.

http://board.flatassembler.net/topic.php?t=6735


Last edited by DOS386 on 20 Aug 2011, 14:11; edited 2 times in total
Post 20 Aug 2011, 13:43
View user's profile Send private message Reply with quote
emc



Joined: 20 Aug 2011
Posts: 90
Location: France
emc
Are you talking about the FASM manual or the MZ manual? (I don't seen any "serious" document about the MZ format on the Web, just the Wiki article)

Then declaring an uninitialized variable, I shall want get its pointer (to put into a register and increase or decrease it). Is it possible with the heap method?
Does its pointer will be DS?


Last edited by emc on 23 Aug 2011, 12:14; edited 1 time in total
Post 20 Aug 2011, 14:07
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1901
DOS386
> get its pointer (to put

There are no pointers in FASM Smile

Code:
   ...
   mov bx, blahvar ; Constant - fixed address - no PIC anymore
   ...
   mov ax, 0
   mov [bx], ax    ; Init
   ...
   inc word [bx]
   ...
   dec word [bx]
   ...
   ; rdrand eax ; Dangerous, commented out Very Happy
   ...
blahvar: rb 2 ; !!!
   ...
    


Only BX SI DI and BP are usable for memory operands.
BP defaults to SS instead of DS !!!
Post 20 Aug 2011, 14:22
View user's profile Send private message Reply with quote
emc



Joined: 20 Aug 2011
Posts: 90
Location: France
emc
Ok, I am understanding (but I have problems with ntdvm sometimes).

Another question:
The following line
Code:
mov [bx], ax    ; Init    

This line allows us to put 0 in blahvar ?
Post 20 Aug 2011, 18:13
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.