flat assembler
Message board for the users of flat assembler.

Index > Heap > hll vs fasm

Goto page Previous  1, 2, 3, 4, 5, 6  Next
Author
Thread Post new topic Reply to topic
HaHaAnonymous



Joined: 02 Dec 2012
Posts: 1180
Location: Unknown
HaHaAnonymous
[ Post removed by author. ]


Last edited by HaHaAnonymous on 28 Feb 2015, 20:03; edited 1 time in total
Post 26 Aug 2013, 22:56
View user's profile Send private message Reply with quote
uart777



Joined: 17 Jan 2012
Posts: 369
uart777
edfed: FASM does not equate to ASM (FASM!=ASM) or anyone's particular definition of "assembler". For me, FASM = Multi-language (FML, CML, JASM), multi-machine (X86+ARM+MIPS+Bytecode) and multi-OS (Windows, Linux, Mobile, GBA, RPI, PL110, AngelARM, RiscOS, etc).

* ASM: Human readable version of machine code
* FASM: Fastest, most powerful preprocessor+assemblers

FASM may be categorized as an "assembler", but it's NOT "just another assembler". It is unlike other assemblers. What makes FASM so special is the preprocessor.

Guru wrote:
Quote:
C is beautiful
FML is more beautiful Razz
Code:
try open name    
C Equivalent
Code:
FILE *fp;
if (!(fp=fopen(name, "rb"))) { 
  return 0; 
}    
Stupid Standard "Assembler" (Windoze Shit++)
Code:
invoke CreateFileA, name, GENERIC_READ \ 
 or GENERIC_WRITE, FILE_SHARE_READ, 0, \ 
 OPEN_EXISTING, 0, 0 
mov [fp], eax 
cmp eax, -1
je .r    
Professional Assembler
Code:
push name
call open
mov [fp], eax
cmp eax, -1
je .r    


Last edited by uart777 on 27 Aug 2013, 03:26; edited 1 time in total
Post 26 Aug 2013, 23:38
View user's profile Send private message Reply with quote
nyrtzi



Joined: 08 Jul 2006
Posts: 192
Location: Off the scale in the third direction
nyrtzi
uart777 wrote:
No. I write to macros for portability (X86+ARM+MIPS+Bytecode) and to increase production. No one understands me, what I'm doing or why, but you can make up your own reasons and believe them as if they were reality.


What are you trying to say? That no one other than you yourself understands why you write macros for increased code portability and productivity? Huh?

You call it "to increase production" and I call it a positive form "laziness" in terms of using macros to avoid writing code that the macros can generate for you. Are you trying to say that these two things are not the same thing just said in two different ways? The end result is the same. Less repetition in the code and less code overall by using macros.

nyrtzi wrote:
we shouldn't consider the language and the libraries as separate entities


uart777 wrote:

Do you understand the differences between a language/syntax and library (a collection of data/functions)?


What makes you think that I don't? Because I said that in that one specific context it makes more sense to not look at them separately?

uart777 wrote:

How many languages and libraries have you written?


How many programming languages (plus basic core libraries for them) I've written? Two usable ones and a bunch of toy languages.

How many libraries? If just plain normal libraries count then I'm afraid I've lost count. I've been a professional programmer for a long time after all.
Post 27 Aug 2013, 00:23
View user's profile Send private message Reply with quote
nyrtzi



Joined: 08 Jul 2006
Posts: 192
Location: Off the scale in the third direction
nyrtzi
AsmGuru62 wrote:
C is beautiful and not messy at all.
C++ is great language too -- used in its basic form.


C by itself could be pretty I guess. In practise people usually use the standard library and that is where the mess begins for example with the return value conventions.

Yes, a plain simple subset of C++ can be nice too. However even with that you can still end up reading STL error messages don't clearly tell you what went wrong. Instead people usually end up googling if someone else has understood what the darn thing means.
Post 27 Aug 2013, 00:32
View user's profile Send private message Reply with quote
nyrtzi



Joined: 08 Jul 2006
Posts: 192
Location: Off the scale in the third direction
nyrtzi
HaHaAnonymous wrote:

So you want me to re-construct a PE-Header (for example) bit by bit every time I need to create an ordinary Windows executable when fasm has an already built-in "macro" for this?
This is extreme stupidity and waste of time, in my opinion.


It seems you've completely misunderstood what I've said.

Here's what I said:
nyrtzi wrote:

Using a macro to lessen the amount typing required is a form of positive laziness.


What am I saying here? "Using a macro to lessen the amount of typing required" means what it says. Obviously that doesn't mean doing extra typing of code to re-construct a PE-header bit by bit every time one creates an ordinary Windows executable.

"is a form of positive laziness" also means what it says i.e. that something is good kind of laziness like for example using built-in functionality instead of writing up one's own when a built-in is available.

Did the "positive" throw you off?
Post 27 Aug 2013, 01:02
View user's profile Send private message Reply with quote
uart777



Joined: 17 Jan 2012
Posts: 369
uart777
"You" generally speaking, not you specifically.

When designing syntaxes, it makes sense to see them in the same content as 3 simple words, but when writing code, one must be aware of the exact differences...
Code:
try open name    
1. try is a keyword that calls a function and returns "false" if it does (error code and response can be set)
2. open is a library function, not related to syntax. OS-specific
3. name is the parameter, address of literal text
Post 27 Aug 2013, 01:40
View user's profile Send private message Reply with quote
nyrtzi



Joined: 08 Jul 2006
Posts: 192
Location: Off the scale in the third direction
nyrtzi
TmX wrote:
nyrtzi wrote:

Then again what is true about C is even worse with assembly. Even less support for static checks and so on out of the box.

Interesting. Could you explain more about this? Smile


I just meant that assembly languages usually don't have a lot of features that help keeping a big codebase consistent and error free. After all some languages do help maintaining big codebases more than others. How many assemblers support proper compile-time type checking with user defined types? C has more even though I don't think C has enough of them. With Java you can't fudge up pointer arithmetic because there isn't any. You can get a null pointer exception though. With C and assembly it would be just a segfault though. Java allows runtime type errors i.e. it's not smart or restrictive enough to catch all type errors at compile-time. It is better to catch as many errors as possible during compilation and development than later on during runtime especially after the software is already in production use. Haskell, ML languages and so on have a nice type system as far as catching errors early on goes (if I've understood correctly how they work).

Now of course someone might be able to come up with a way to do a type system with macros and so on but that would still be something the language itself wouldn't know how to force which makes mistakes possible and like HaHaAnonymous said it would be better to use a built-in than to write up one's own even if one slaps it into a library and reuses it from there every single time.

With Java you could simply write your code following some convention that would mitigate the possibility of a null pointer exception. You could for example use Null objects instead and wrap everything that produces plain nulls with code that does the "right thing" by giving a Null object instead. Then again that approach also has its own problems and it's possible to simply forget to wrap something and then you once again have a NPE. If you really want to make some class of errors go away from your codebase you need to have the language completely automate the matter in the background.

I'm not saying that writing big codebases is impossible in assembly. Of course it's possible. I'm just saying that some languages help more than others in working with a bigger codebase.
Post 27 Aug 2013, 05:47
View user's profile Send private message Reply with quote
TmX



Joined: 02 Mar 2006
Posts: 821
Location: Jakarta, Indonesia
TmX
Ah sorry I didn't read your post carefully. Must had been sleepy at that time.
Indeed C is permissive. The core language itself doesn't impose lots of checking.
And even worse, I think, the C standard library reflects the same thing.

I can image imagine when you are handling big projects in C (e.g Linux kernel), then a high coding discipline must be involved.

Very Happy
Post 27 Aug 2013, 06:30
View user's profile Send private message Reply with quote
nyrtzi



Joined: 08 Jul 2006
Posts: 192
Location: Off the scale in the third direction
nyrtzi
uart777 wrote:
"You" generally speaking, not you specifically.


What do you mean with this? Would you care to clarify? I'm trying hard not to make any weird assumptions here. The first impression I get from that is that you are trying to say that you didn't mean me specifically but instead talked about people in general. Is this correct? A simple Y/N would suffice.

uart777 wrote:

When designing syntaxes, it makes sense to see them in the same content as 3 simple words, but when writing code, one must be aware of the exact differences...


I prefer to consider them separate even when designing a syntax but then again to argue about this would be pointless nitpicking.

But OTOH (while coding) the syntax, the semantics and the library functions and so on all together are the context and the environment of your code. That context has a definite effect on what you can easily say (with your code) (using library functions and the language's built-in features) in it and what you must write yourself.

If you can't say something easily but instead have to spend time getting sidetracked trying to work around the limitations, quirks and missing features in the language and the libraries then your code will get cluttered with unnecessary details which make the code less abstract and more LLL-ish (low level language like).

To me your FML looks like an attempt to create a HLL because you seem to be aiming for a language which abstracts/hides away (with the language and the related libraries) the details you don't want to worry about when writing apps. After all assembly (and macro assembly in particular) can be a HLL for some purposes depending on how they've been implemented.

Are you going to implement any form of compile-time type checking in this FML?
Post 27 Aug 2013, 06:40
View user's profile Send private message Reply with quote
nyrtzi



Joined: 08 Jul 2006
Posts: 192
Location: Off the scale in the third direction
nyrtzi
TmX wrote:

I can image imagine when you are handling big projects in C (e.g Linux kernel), then a high coding discipline must be involved.

Very Happy


I've been lately thinking that discipline alone isn't enough. C is one of my favorites so I'd like to keep on using it but it doesn't feel safe enough.

Which is why I'm considering the idea of writing a something to C translator with some libraries which would prevent me from fudging things in terms of nulls, memory management and types. This something being an improved C with a Lispy syntax that would allow me to use some existing Lisp environment with its computational macros as a preprocessor for generating code. Having a full-blown general purpose language like Common Lisp as a macro preprocessor makes it a completely different kind of a ball game.

I could generate fasm instead of C but then I'd have to write code to do e.g. register allocation and all the other stuff the C compiler could do for me. Plus I'd be losing the ability to use a lot of tools written for debugging C code. This trade-off doesn't seem that attractive.

Then again it's probably exactly the kind of trade-off between online and offline code generation that gives offline debugging the edge in terms of having the generated source available which helps debugging. On the other hand if an online debugger can handle both the macro code and what it's expanded to by being able to show both of them then the advantage is gone. My memory fails me in this. Is fasm able to show you how and to what your macros got expanded to by dumping the macro-expanded source right before it translates it into machine code?
Post 27 Aug 2013, 07:01
View user's profile Send private message Reply with quote
uart777



Joined: 17 Jan 2012
Posts: 369
uart777
Quote:
How many assemblers support proper compile-time type checking with user defined types? ... Now of course someone might be able to come up with a way to do a type system with macros and so on
I've got type-safety working perfectly on X86 and partially* on ARM (* not with locals yet). For each name, it stores: type, size, sign, scope, array, structure, pointer. Information for data (movx/ldx), arithmetic (let), calls (f(a,b,c)), HL blocks (.if/.while/.repeat/.for/.loop/etc). Accurate error messages: 'Invalid assignment =', 'Invalid parameter #2: x', 'Invalid # of parameters', customizable for any language.
Post 27 Aug 2013, 07:13
View user's profile Send private message Reply with quote
uart777



Joined: 17 Jan 2012
Posts: 369
uart777
Quote:
How many programming languages (plus basic core libraries for them) I've written? Two usable ones and a bunch of toy languages.
Anyone can say this. Where are the languages/compilers/libraries you claim to have? Why don't you submit them?
Post 27 Aug 2013, 07:50
View user's profile Send private message Reply with quote
nyrtzi



Joined: 08 Jul 2006
Posts: 192
Location: Off the scale in the third direction
nyrtzi
uart777 wrote:
Quote:
How many programming languages (plus basic core libraries for them) I've written? Two usable ones and a bunch of toy languages.
Anyone can say this. Where are your languages/compilers/libraries? Why don't you submit them?


I came to this forum for a friendly discussion among programming enthusiasts. Not for debates with people who (without a proper reason) assume by default that I'm some kind of an ignorant idiot who doesn't even understand what he is talking about (or at least this is the attitude towards me I'm picking up from what you say). I could give you a link to a thesis I wrote (they are properly published after all) about a programming language I designed but then again your hostile "doubt everything he says" attitude towards me sucks and doesn't give me any incentive for doing you any favors or caring about your opinion enough to want to prove myself to you in any way.

Just out of curiosity I'm tempted to ask what is the logic behind you even asking this. Are you trying to say that only those who can show that they've written a language of their own can understand the difference between what a compiler and a runtime library do? I hope not. That kind of reasoning would be more than just plain questionable.
Post 27 Aug 2013, 08:19
View user's profile Send private message Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 8884
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 334455
sleepsleep
ego showing and trashing,
maybe these is all coded inside human dna,
the most executed branch of if,then,else
Post 27 Aug 2013, 09:01
View user's profile Send private message Reply with quote
nyrtzi



Joined: 08 Jul 2006
Posts: 192
Location: Off the scale in the third direction
nyrtzi
uart777 wrote:
Quote:
How many assemblers support proper compile-time type checking with user defined types? ... Now of course someone might be able to come up with a way to do a type system with macros and so on
I've got type-safety working perfectly on X86 and partially* on ARM (* not with locals yet). For each name, it stores: type, size, sign, scope, array, structure, pointer. Information for data (movx/ldx), arithmetic (let), calls (f(a,b,c)), HL blocks (.if/.while/.repeat/.for/.loop/etc). Accurate error messages: 'Invalid assignment =', 'Invalid parameter #2: x', 'Invalid # of parameters', customizable for any language.


Sounds like a nice improvement over plain assembly.
Static checking only? No RTTI nor dynamic checking?
Casting is allowed? No automatic type conversion?
Post 27 Aug 2013, 09:04
View user's profile Send private message Reply with quote
nyrtzi



Joined: 08 Jul 2006
Posts: 192
Location: Off the scale in the third direction
nyrtzi
sleepsleep wrote:
ego showing and trashing,
maybe these is all coded inside human dna,
the most executed branch of if,then,else


I'm really trying to do my best in order to not make things personal and to not assume that people are lying or contradicting themselves. If I see someone saying something that appears questionable I first double-check that I actually understood it correctly and if that doesn't fix it I then ask to confirm if I understood it correctly. I wish others would do the same too.
Post 27 Aug 2013, 09:07
View user's profile Send private message Reply with quote
uart777



Joined: 17 Jan 2012
Posts: 369
uart777
Quote:
your hostile "doubt everything he says" attitude towards me sucks
My hostility is directed at ASM-Writer and I accidentally misquoted you.

Quote:
Just out of curiosity I'm tempted to ask what is the logic behind you even asking this.
Anyone who comes in here and claims to be a language/compiler designer/creator should at least be *willing* to prove it to the community. You wouldn't be doing me any favors, I have my own code and 100s of programs.

Quote:
(or at least this is the attitude towards me I'm picking up from what you say)
Your impression.

Out of time.
Post 27 Aug 2013, 09:48
View user's profile Send private message Reply with quote
TmX



Joined: 02 Mar 2006
Posts: 821
Location: Jakarta, Indonesia
TmX
nyrtzi wrote:

This something being an improved C with a Lispy syntax that would allow me to use some existing Lisp environment with its computational macros as a preprocessor for generating code.


The closest thing I'm aware of is Scheme.
Gambit generates C code.

Or if you don't mind some Pascal/Python flavors, Nimrod is also an interesting choice.
Post 27 Aug 2013, 10:11
View user's profile Send private message Reply with quote
nyrtzi



Joined: 08 Jul 2006
Posts: 192
Location: Off the scale in the third direction
nyrtzi
uart777 wrote:

My hostility is directed at ASM-Writer and I accidentally misquoted you.


Ok, issue solved. That was an easy bugfix.

uart777 wrote:

Anyone who comes in here and claims to be a language/compiler designer/creator should at least be *willing* to prove it to the community.


I'm not claiming to be in the same category as Stroustroup, Wall or Guido. I haven't even written a complete compiler yet. In fact I don't think I've said more than that I'm thinking of and considering how to make a better version of C. A couple of years ago I was still thinking of how to make a better Lisp. That doesn't mean I haven't read a lot about the field. For writing my thesis I had to read a lot of books and research papers about it starting from the 60's papers about macros and language design and ending with MacroML, multi-stage programming and partial evaluation from more recent times.

Yes, I've been thinking and testing different ideas a lot but I don't have much to show for it yet. The majority of the stuff I've done are just simple prototypes testing specific ideas and language features. The only bigger toys I've built (I could actually use them for some practical stuff like playing with log files and simple scripting (I work inside a Debian box usually, for me Windows is strictly for games and video conferencing)) were the implementations of the language I wrote for my thesis.

That language is basically a mixture of Forth and Lisp that borrows something similar to prototype-based OOP for its internal runtime data model. I wrote implementations of the language's core functionality in Javascript, C and Python just to see what kind of challenges each of those platforms would lead into. It was a research oriented thesis after all so I wanted to know. I can give you a link if you want but it's written in Finnish which kind of limits the target audience. The title of the thesis is "an extensible programming language" which it certainly was. And also extremely painful to program with. Below a couple of pieces of example code.

The first line puts 1 on the parameter/data stack, calls the method "dup" of the stack with 0 arguments to create a duplicate of that 1 on the stack, then calls the method "+" on the topmost 1 on the stack which leaves a 2 on the stack and then prints it to stdout.

"dup" and "+" are actually methods of the prototype objects "stack" and "int" so to make them available globally as functions the code slaps them dynamic variables (special variables in the global scope thus making them available everywhere). And the last line then does the same thing as the first line but now with the newly created global functions.

Code:
1 @ps :0 dup :0 + pr ;

^0 code @ps :0 dup !'d dup pushwp
^1 @ps :0 dup ret
^0 popwp ;

^0 code @ps :0 dup !'d + pushwp
^1 :0 + ret
^0 popwp ;

1 dup + pr
    


Really readable huh? Nope, not really. Laughing Honestly it was and still is a bloody nightmare to program with. Powerful? Yes. Extensible? Yes. Easy to use? Nope.

And then two examples more. The next one is "Hello world!" shoved inside a closure that is slapped into a variable and called from there. The first line includes the macros for creating closures from the "block.p" source file. The lines in the middle create a closure inside which is a function that prints the string from the closure. The last line executes the function.

Code:
"block" lib ;

{ "hello world!" !' s
[ ^1 s pr ^0 ]
} !'d hello-world ;

hello-world
    


The last example shows an anonymous first class macro object which prints "Hello world!" put on the stack and stack and called to do it's thing.

Code:
code @ps :0 dup pushwp
^1 "hello world!" ret
^0 popwp $ pr
    


My goal is to write a programming language for myself that I would be comfortable with. I've been thinking for years about what kind of language that would be. So naturally I haven't committed myself to writing a compiler for it yet. I'd first need to know what I'm supposed to write, right? The current approach I'm considering and pondering is if I could make an improved version of C with ideas borrowed from Lisp and some more type-oriented functional languages.

I was planning on releasing the language I wrote for my thesis. I call the language "Phase" because of the weird way it uses hats (^n) to control to which phase of rewrites each piece of code belongs to. The whole algorithm behind how the language works is that of layering one's code into phases and then having the interpreter rewrite the source in memory one layer after another until done. But then I thought that this is probably one of those so called esoteric languages and that I should polish up the code before I release it to the wild. Never simply got around to doing that. I mean, I wrote the language and not even I like using it. Why would someone else? Or is this another ideal tool for obfuscated code contests?
Post 27 Aug 2013, 11:15
View user's profile Send private message Reply with quote
nyrtzi



Joined: 08 Jul 2006
Posts: 192
Location: Off the scale in the third direction
nyrtzi
TmX wrote:
nyrtzi wrote:

This something being an improved C with a Lispy syntax that would allow me to use some existing Lisp environment with its computational macros as a preprocessor for generating code.


The closest thing I'm aware of is Scheme.
Gambit generates C code.

Or if you don't mind some Pascal/Python flavors, Nimrod is also an interesting choice.


Gambit and Scheme. Hmmm. I'd rather not get involved with continuations.

Nope, I don't mind Pascal and Python at all. I rather like Python. Nimrod looks interesting.

As long as I could get the register allocation done I could just use fasm as a backend. Register allocation can't be that hard, right? (Famous last words...) Laughing

Previously in my experiments I've run into the problem that the C stack sometimes gets in the way. You also can't have really have two actual stacks in C. Which is (I guess) why Stackless Python is the way it is. Would I be digging my own grave by generating C if I later on would like to get rid of that hardware stack limitation for some weird reason? (And I do get funny ideas from time to time.)

I'll just call this new planned language of mine C2. Even if I were to use a Lisp syntax I'd have the problem that I wouldn't be able to just drop C2 code straight into the middle of Common Lisp code because the syntax has some fundamental differences. Common Lisp uses ; for comments and C2 uses it for type specifiers. I guess that just means that I'd need to write a parser and put that behind a reader macro which would allow me to embed C2 code into Common Lisp code.
Post 27 Aug 2013, 12:57
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3, 4, 5, 6  Next

< 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 can attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.