flat assembler
Message board for the users of flat assembler.
Index
> Main > mz segments |
Author |
|
HyperVista 19 Sep 2006, 14:43
Hello Fegger, and welcome to the FASM board.
If you want to print a message to the screen, you can try this simple example: Code: org 100h jmp start ; Print Routine print: mov ah,9h int 21h ret print_wait: call print xor ax,ax ; pause screen until user hits any key int 16h jmp exit ; Message Text msg1 db 'x', 13, 10, '$' start: mov dx,msg1 call print_wait exit: mov ax, 4c00h int 21h No need for "MZ" or segments. I'm fairly new to asm programming and I've gotten lots of help, encouragement, and support on this forum. you're lucky to have found fasm. i know i am. NOTE: code example has not been tested |
|||
19 Sep 2006, 14:43 |
|
Feggger 19 Sep 2006, 15:03
Thank you, HyperVista, but i do not want to print a string.
I want to combine two segments of mz exe file with same name into one. |
|||
19 Sep 2006, 15:03 |
|
LocoDelAssembly 19 Sep 2006, 15:06
I think he wants to "reopen" a segment to add more data/code. I never used MZ format in FASM but I think it's not possible to do that. However you can use some macros like the ones included in fresh to define global data maybe.
|
|||
19 Sep 2006, 15:06 |
|
LocoDelAssembly 19 Sep 2006, 15:17
Code: ;********************************************** ; Macroses for global variables handling. ; This macro library is part of Fresh project. ; ; (C)2003, 2004 ; ; Authors: ; John Found ; Tomasz Grisztar ; ; usage: ; 1. Include this library in the begining ; of your source file. ; 2. Use it as blocks anywhere in the source. ; iglobal ; somelabel dd 1234h ; otherlabel RECT ; lbl3 db 12h ; endg ; ; 3. Data section must be at the end of the ; source file. Use 'IncludeAllGlobals' to ; really define variables. ; ;********************************************** macro _iglobal dummy { IGlobals equ IGlobals, macro __IGlobalBlock { } macro _uglobal dummy { UGlobals equ UGlobals, macro __UGlobalBlock { } iglobal fix _iglobal } _iglobal uglobal fix _uglobal } _uglobal endg fix } macro IncludeIGlobals { macro _iglobal dummy \{ \} macro _uglobal dummy \{ \} macro IGlobals dummy,[n] \{ __IGlobalBlock purge __IGlobalBlock \} match I, IGlobals \{ I \} } macro IncludeUGlobals { macro _iglobal dummy \{ \} macro _uglobal dummy \{ \} macro UGlobals dummy,[n] \{ \common \local begin, size begin = $ virtual at $ \forward __UGlobalBlock purge __UGlobalBlock \common size = $ - begin end virtual rb size \} match U, UGlobals \{ U \} } ;-------------------------------------------- ; constStr Str1, 'This is string constant' ;-------------------------------------------- macro constStr lbl, text { __StringsArray equ __StringsArray, lbl, text ; add to the list } macro __IncludeStringConstants dummy,[lbls, text] { forward if text eqtype 'A' lbls db text sizeof.#lbls = $ - lbls db 0 else if text eqtype 0 lbls = text end if end if } macro IncludeStringConstants { match strings, __StringsArray \{ __IncludeStringConstants strings \} } __StringsArray equ macro IncludeAllGlobals { local begin begin = $ IncludeIGlobals align 4 begin = $ IncludeStringConstants align 4 begin = $ IncludeUGlobals } iglobal endg uglobal endg format mz segment a mov ax, b mov ds, ax mov ah, 09h mov dx, msg1 iglobal msg1 db 'Hello world!!$',0 endg int $21 xor ax, ax int $16 mov ax, $4c00 int $21 segment b IncludeAllGlobals Seems to works fine. Hope that this is what you want |
|||
19 Sep 2006, 15:17 |
|
vid 19 Sep 2006, 20:44
what you want (merge segments with same name) is job of linker. when you use FASM to produce MZ file, you are omitting linking (FASM is assembler, not linker). So there are 3 segments created instead
|
|||
19 Sep 2006, 20:44 |
|
Feggger 20 Sep 2006, 08:15
But what about pe exe? In pe exe sections with same name merged.
Why this can't be done in mz exe? locodelassembly: thanks. I'll try now. |
|||
20 Sep 2006, 08:15 |
|
vid 20 Sep 2006, 08:57
Quote: But what about pe exe? In pe exe sections with same name merged. they are? are you sure? |
|||
20 Sep 2006, 08:57 |
|
Feggger 20 Sep 2006, 14:46
locodelassembly: Thank you. It works!
vid: You right. This is not supported This supported only with external linker... |
|||
20 Sep 2006, 14:46 |
|
Reverend 20 Sep 2006, 19:52
PE sections can have every name (but no longer than 8 bytes) and they are meaningless for working. You can name all sections '.code' or all sections 'fasm rox' . It doesn;t matter, but remember that every time you put section 'xxx' readable', etc. in your source, fasm creates another section. It doesn't merge anything.
|
|||
20 Sep 2006, 19:52 |
|
Feggger 21 Sep 2006, 16:33
Thanks all. This is my simplified version of Fresh macroses:
Code: macro .model [dummy] { common _segment text } macro _segment name { local mac __#name equ __#name, mac macro mac { } macro _end [segments] { common local mac macro mac dummy,[n] \{ n purge n \} forward Segment segments match I, __#segments \{ mac I \} } .end fix } _end .segment fix } _segment How to use: Code: format mz include 'mz.inc' .model small mov ax, msgs mov ds, ax mov ah, 09h mov dx, msg1 .segment msgs msg1 db 'Hello world!!$',0 .segment text int $21 xor ax, ax int $16 .segment msgs msg2 db 'message2', 0 .segment text mov ax, $4c00 int $21 .end text, msgs This version puts on result code data of forward, not reversed order. And easily can be written macroses for merging needed segments (analog of masm DGROUP). locodelassembly, thank you again. |
|||
21 Sep 2006, 16:33 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.