flat assembler
Message board for the users of flat assembler.
Index
> DOS > Little problem with Hello World! |
Author |
|
scientica 06 Sep 2003, 15:47
I'm no expert at this, but shouldn't there be an "org 100h"? (.COM needs it)
_________________ ... a professor saying: "use this proprietary software to learn computer science" is the same as English professor handing you a copy of Shakespeare and saying: "use this book to learn Shakespeare without opening the book itself. - Bradley Kuhn |
|||
06 Sep 2003, 15:47 |
|
prana 06 Sep 2003, 16:02
COM files! with segments. MZ can also be exe files as well, I believe.
I am a little confused honestly. And hence I am lookin for the COFF and MS COFF variations of the code too. |
|||
06 Sep 2003, 16:02 |
|
Tommy 06 Sep 2003, 16:15
You can't use the names code and data.... Use something else, such as text, _code or something....
|
|||
06 Sep 2003, 16:15 |
|
Tomasz Grysztar 06 Sep 2003, 17:25
Tommy is right, with such correction it should be OK.
And COFF format is suitable only for 32-bit code with flat addressing, you cannot define 16-bit segments there. |
|||
06 Sep 2003, 17:25 |
|
prana 06 Sep 2003, 17:41
Thanks guys!
The use32 directive has no meaning as used here then? MZ files can also be exe files. isn't it true? Privalov, in COFF and MS COFF, I use section directive. How this differs from segment directive? Please enlighten me. Also I changed the code as per your suggestion: ___________________ Code: format MZ entry _code:main stack 100h segment _data use32 msg db "Hello World!$",0 segment _code use32 main: mov ax,_data mov ds,ax mov dx,msg mov ah,9 int 21h mov ax,4c00h int 21h retf ____________________________________ This compiles, but my NTVDM cannot execute this, why? Do I need a real DOS box? And lastly, is there any end directive in FASM? Thanks for your help. |
|||
06 Sep 2003, 17:41 |
|
Tommy 06 Sep 2003, 18:02
Why are you using the use32-directive??? DOS-applications are 16-bits apps. (with some exceptions when we're talking about PM etc.)...
|
|||
06 Sep 2003, 18:02 |
|
prana 06 Sep 2003, 18:35
Ok then...my mistake.
What about my other questions? Could u pls help? |
|||
06 Sep 2003, 18:35 |
|
Tommy 06 Sep 2003, 19:06
Code: format MZ entry _code:main stack 100h segment _data msg db "Hello World!$",0 segment _code main: mov ax,_data mov ds,ax mov dx,msg mov ah,9 int 21h mov ax,4c00h int 21h Here's a version of working code... Your other question? Do you mean that one about the end-directive? |
|||
06 Sep 2003, 19:06 |
|
Vortex 06 Sep 2003, 20:30
Prana,
Did you check the Comdemo example from the FASM package? Code: ; fasm example of writing 16-bit COM program org 100h ; code starts at offset 100h use16 ; use 16-bit code display_text = 9 mov ah,display_text mov dx,hello int 21h int 20h hello db 'Hello world!',24h _________________ Code it... That's all... |
|||
06 Sep 2003, 20:30 |
|
prana 07 Sep 2003, 03:45
Sorry for the late reply.
Thanks Tommy, I've figured that out! Tommy, my other questions were: 1) The end directive 2) Is there any PROC macro, and an example of when and how this is used. 3) In COFF and MS COFF, FASM uses section directive. How this differs from segment directive? Vortex, thanks to you too, but I wanted to create an .exe file, not a .com file. However, some explanatory answers for the above questions would help a lot. |
|||
07 Sep 2003, 03:45 |
|
Tommy 07 Sep 2003, 06:58
Hi prana,
I'm not sure about all the questions, but conserning number 1: I don't think there is such a directive, and I don't think you need it in FASM either (I'm not sure how the end-directive you are talking about works, since I've always used FASM when programming in assembly - and that's just 2 years or something). Question number 2: There's a proc-macro for 32-bits applications, but not any for 16-bits apps. (as far as I know). That shouldn't be too hard to make, should it Privalov (I'll try to make one )? I think the smartest thing is to ask Privalov or someone else with a bit more experience than me (I'm only 16) about the last question - since they know more about FASM and assembly. So long! Tommy |
|||
07 Sep 2003, 06:58 |
|
Tomasz Grysztar 07 Sep 2003, 09:23
In very general, the section is just a part of segment, and 32-bit programs with flat addressing (and for such programs PE/COFF and ELF formats are designed) use only one large segment (of limit 4 GB) which contains whole addressing space, and many sections are mapped into this segment. In the 16-bit MZ format one segment has a limit of 64 KB, therefore you may need to use more segments for larger programs.
This is just a quick overview to give you idea of what is the difference between segments and sections, but if you want some really good information on such topics, I suggest waiting for my tutorial to be finished. I've started working more intensively on it, and the progress should be faster soon. |
|||
07 Sep 2003, 09:23 |
|
wanderer 07 Sep 2003, 10:00
prana wrote: 1) The end directive To point out entry point you can use "entry" directive instead. prana wrote: 2) Is there any PROC macro, and an example of when and how this is used. The "proc", "return" and "stdcall" macroses can be easily adapted for 16-bit programming: Code: ; macroinstructions for defining and invoking stdcall HLL procedures macro proc name,[arg] ; define procedure { common name: virtual at ebp+4 if ~ arg eq forward local ..arg ..arg dw ? arg equ ..arg common end if ..ret = $ - (ebp+4) end virtual local ..dynamic_data,..dynamic_size dynamic_data equ ..dynamic_data dynamic_size equ ..dynamic_size virtual at ebp - dynamic_size dynamic_data: } macro enter ; begin procedure instructions { rb (2 - ($-dynamic_data) and 1b) and 1b dynamic_size = $ - dynamic_data end virtual enter dynamic_size,0 } macro return ; return from procedure { leave ret ..ret } macro stdcall proc,[arg] ; call procedure { reverse push arg common call proc } The only disadvantage is that you you can use only words as parameters of procedure. _________________ Best regards, Antoch Victor |
|||
07 Sep 2003, 10:00 |
|
prana 07 Sep 2003, 12:05
What can I say, thank you all so much
And will be very eagerly waiting for Privalov's tutorial, it would definitely help me a lot. Just one more question regarding 4 GB mem limit. If I use segment registers along with paging, can't I get more memory addressing capability? Is there any way of doing that? |
|||
07 Sep 2003, 12:05 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.