flat assembler
Message board for the users of flat assembler.
Index
> Main > what does the flat mean in flat assembler |
Author |
|
Vertex78 13 Apr 2005, 02:48
Hello all, I am starting to learn assembly and I am curious what is meant by flat assembler?
|
|||
13 Apr 2005, 02:48 |
|
Tomasz Grysztar 13 Apr 2005, 08:09
From my Design Principles article:
Quote: (...) My assembler, generating the code in flat addressing space, was always outputting the code exactly in the same order, as it was defined in source. Thus came the name for it - flat assembler. |
|||
13 Apr 2005, 08:09 |
|
vid 13 Apr 2005, 10:00
it comes from times of 286, because it was limited to 64kb addresing, there were several modes:
tiny - all code and data in one address space (segment) 64kb large small - code and data are in separate segment, both 64kb medium - data is in 64kb semgnt, code can be in multiple segments compact - code in one segment, data in multiple segments large - both are in multiple segments huge - like large, but with FAR internal pointers, not important now. But then came 386 with 32bit stuff, so these 16bit (64kb) limitations were irrelevant. So new modes were to come. 386 could have at most 4gb of ram, which is addressable by 32bits, so first mode to come in mind was that all segments are pointed to one location (usually 0), so only offset part is used for real addressing. It is something like tiny mode, but with 4gb limit instead of 64kb (which ought to be enough for anyone by the way...). This way you dont have to care with segment pointers, you don't need to maintain both FAR and NEAR pointers etc. This model was called "flat". Other assemblers implemented it just by adding it to their segment-based philosophy, which results in some workaround needed to make simple flat model beheave like complex old 16bit modes. But FASM uses this model by default, it acts as if all code is in one address space, which is like flat model. I hope you got it now. |
|||
13 Apr 2005, 10:00 |
|
Vertex78 13 Apr 2005, 12:40
vid wrote:
So then you have 4gb of space to use for CS,DS,SS but you still are limited in real mode to the 64k window to lookat the data or has this been increased to? You say it acts like all code is in one address space, I am a little confused on that, how would the code not all be in the same address space? So then overall its called flat because you a have 4gb of address space for all your need that you can cover all of without using both near and far pointers, where as before you had different 64k for each segment and you had to jump around to use it all? Thanks for your help guys, I hope I am getting this right. The book I am using to learn is an older book but has really good explanations and questions at the end of each chapter, so hopefully I will not have much trouble applying what I learn to newer technology. |
|||
13 Apr 2005, 12:40 |
|
smiddy 13 Apr 2005, 18:19
Hi Vertex78,
In real mode you have segment:offset or 0000:0000 or 16-bit:16-bit. So, in order to see items outside of a corresponding segment, you would need to change your segment register and corresponding offset. Say for example, you have a data item at linear location 0x60000 (393,216 decimal). Simply saying 0000:FFFF would only allow you to see at maximum 0xFFFF (65,535 decimal). So in order to see it in real mode your segment has to change to anything within the 0xFFFF range. Thus the simplest segment is 6000:0000 (where the segment with an offset of 0, has a range of 0xFFFF or 6000:FFFF or linear 0x60000 to 0x6FFFF). At this point you might be seeing the correllation. Likewise, if you placed your segment at 0x5FFF, then to see your data at linear 0x60000, your offset would need to be 0x10 or 5FFF:0010. Now to answer your question, how can the code and data not be in the same address space? It is possible that your code is at say a lower 64kB area and your data is in a higher 64kB area. So your code is at 0050:0000 which limits it from linear addressing 0x500 to 0x104ff or 0050:FFFF. Then your data is at FFFF:0010 (the 1MB area), your range for your data linearly is 0x100000 - 0x10FFFF. Now, since your CS is at 0x50 and your DS is at 0xFFFF, the two aren't close to one another and can also use 16-bit references to each respective part without making FAR CALLs or FAR JMPs or FAR references to data, which are bigger that 16-bits (32-bits). The flatness vid was talking about is in reference to the entire 4GB address space being referenced from (for purposes of discussion) one segment (selector) and thus the instruction pointer and data pointers are the only registers needed in order to call or reference data. So, to answer your second question, yes, so you don't have to WORRY about jumping around (segmenting) your code and data. I hope this explains it more and gives you a clearer perspective. |
|||
13 Apr 2005, 18:19 |
|
tom tobias 15 Apr 2005, 12:28
flat, historically, suggesting SMOOTH, and more importantly, CONTINUOUS, as opposed to the older, obsolete, segmented model, (a result of the relatively high cost of memory in those days) which is DISCONTINUOUS. So, if "FLAT", annoys you, please think of ROUND, or curves, not only acceptable, but, in some contexts, preferable, to flat. You may even wish to create a new acronym: SMOOTH AND REALLY CURVACEOUS ASM, i.e. sarcasm
|
|||
15 Apr 2005, 12:28 |
|
WytRaven 08 May 2005, 17:43
tom tobias wrote: ...create a new acronym: SMOOTH AND REALLY CURVACEOUS ASM, i.e. sarcasm LMAO! _________________ All your opcodes are belong to us |
|||
08 May 2005, 17:43 |
|
THEWizardGenius 11 May 2005, 05:53
I always thought FASM was named after the so-called flat addressing mode on 386+ processors. However, if Privalov says something else, I for one think he would know, since he made FASM.
If you can imagine in your mind an assembler that works like MASM or TASM (A "middle-level" assembler) that has some higher-level features along with just plain assembly: if you can think of a program made out of this hybrid of features graphically, with the base (bottom part) being the low-level assembly and the higher-level parts being higher on the graph, like this: -Stage 1 (source file) Higher level - - - - -- - - - - Middle level _ _ _ __ _ __ ___ _ __ __ _ _ _ _ Lower level --------------------------------------------------Base -Stage 2 (Get rid of higher-level features, convert to middle level) Middle level __ __ __ ____ __ ___ _____ __ ___ ___ __ __ __ __ Lower level --------------------------------------------------Base -Stage 3 (Convert all middle-level to assembly code) Lower level ----------------------------------------------------------------Base MASM and TASM still use mostly lower-level features but they also have higher-level features (i.e., the type found in high-level or middle-level languages like C, *gasp* Pascal, and *HORRORS!* BASIC). But when they are assembled they "squash" all the higher-level features into lower-level ones: they make them lower-level and also take more code (horizontal space). In Flat Assembler you never have higher- or middle-level features, only lower-level ones, so there is nothing to squash (except maybe macroes and structures and such). Everything is "flat" (low-level) in the source file, and it stays flat in the output. Flat conversion. Machine Code = Assembly Language. No more Machine Code = Assembly Language = Middle-Level Code = Higher-Level Code. That's too many! I hope this makes sense. FASM is not what everyone wants (some people might want Visual C++ or <HORRORS!> Visual Basic, or something else...), but it's good for people who like simple. If you want high-level things like OOP, functions, arrays, strings, floating point math, and others, FASM probably isn't for you: you can do these things in FASM, but it's not that easy. However, it is much more simple, and fun. FASM lets you write fast, cool programs for many different operating systems (or you can even write your own operating system!) on the PC, with maybe just a little more thinking than in high-level languages. But the great thing is, with FASM you have WYSIWYG: The code you put in is the code that comes out, regardless of what operating system or commandline options you use. The instructions are in the code. That's why I like FASM. (Keep working on FASM, Privalov!) _________________ FASM Rules! OS Dev is fun! Pepsi tastes nasty! Some ants toot! It's over! |
|||
11 May 2005, 05:53 |
|
Adam Kachwalla 03 May 2006, 06:42
How can you implement a specific mode? On some assemblers, it looks like:
Code: model .small |
|||
03 May 2006, 06:42 |
|
vid 03 May 2006, 07:38
by the time you will find out how great it is, that there is nothing like those modes in FASM.
What would it be good for. What would such directive do to your code? |
|||
03 May 2006, 07:38 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.