flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > Projects and Ideas > A preprocessor for using operators like C--

Author
Thread Post new topic Reply to topic
SergeASM



Joined: 13 Nov 2015
Posts: 18
A preprocessor for using operators like C--
In fact, assembler's code is hard to understand. Is there a preprosessor, that converts code like C-- in assembler?


Code:
section '.data'  ...
dd1 dd ?
...

section '.text' ...
...
if (eax+ebx & [dd1] > 10)
 { ecx=ebx+[dd1];
    ebx++;
 }
...



Serge
Post 22 Nov 2015, 18:12
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3436
Location: Bulgaria
C-- compiler?

BTW, assembly language code is not so hard to understand. But like any other language, it needs to be well learned first. Smile
Post 22 Nov 2015, 18:46
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
SergeASM



Joined: 13 Nov 2015
Posts: 18
Yes, but while asm programmer writes and debugs one big program, high-level language programmer writes and debugs 100 programs and earns 100 times more money. Smile
Post 22 Nov 2015, 20:32
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3436
Location: Bulgaria
Well, the ratio is far from such numbers. My estimation is that the code creation takes 2 times slower in ASM for small projects and close to 1 for big projects. But notice that the quality of the assembly language programs is much higher.
Post 22 Nov 2015, 22:03
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
SergeASM



Joined: 13 Nov 2015
Posts: 18
Try regexp search/replace in asm then in Perl. Smile
Post 22 Nov 2015, 22:37
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3436
Location: Bulgaria

SergeASM wrote:
Try regexp search/replace in asm then in Perl. Smile



It is a matter of libraries, not the "level" of the language itself. And who knows how many hours they wrote the library for regexp parsing?

For example, FreshLib contains parser for MarkDown-like markup language, so writing web sites that use it is pretty easy.

And IMHO, using regular expressions always ruins the quality of the code and is source of bugs.

_________________
Tox ID: A48DEF727DF44C3B5C2E576B65021F1A45D8FA52E2F8E257F1CAE148BBADB162FDF7820BD1F9
Post 22 Nov 2015, 23:52
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 15096
Location: The Unicomplex
Repeat this 10 times: Assembly code is not C code.

After one understands that then everything else goes smoothly.

Lets' see: If you want C code then perhaps you can write C code and use a C compiler. If you want assembly code then perhaps you can write assembly code and use an assembler. I don't see C coders trying to make their code look like assembly. So why should assembly coders try to make their code look like C?

In assembly "ebx++" is simply "inc ebx".
Post 23 Nov 2015, 00:35
View user's profile Send private message Visit poster's website Reply with quote
idle



Joined: 06 Jan 2011
Posts: 341
Location: ukraina
http://www.plantation-productions.com/Webster/HighLevelAsm/hla_examples/index.html ?
edit: i would, despite his odd behaviour sometimes, select z-lang/abakis macro extension by z3n/m3ntal
Post 23 Nov 2015, 17:25
View user's profile Send private message Send e-mail Reply with quote
SergeASM



Joined: 13 Nov 2015
Posts: 18
Thanks, idle, but I want simple replace asm opcodes to "human" operators:

mov - =
add - +
and - &
mul - *
...
jmp - goto

mov eax,[dd1]
add eax,10
cmp eax,100
ja .m1 ->

eax=[dd1];
if ((eax+=10) > 100) goto .m1
Post 24 Nov 2015, 07:48
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 15096
Location: The Unicomplex
For this line:

eax=[dd1];

You would have to make a macro and/or struc named "eax" and do all the processing inside that.

For the next line:

if ((eax+=10) > 100) goto .m1

The same applies, a macro and/or stuc named "if". But be aware that fasm also has an internal usage for "if".

BTW: You might also be interested in fasmg: http://board.flatassembler.net/topic.php?t=17952
Post 24 Nov 2015, 08:56
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3436
Location: Bulgaria

Quote:
Thanks, idle, but I want simple replace asm opcodes to "human" operators:


These are not "human" operators. These are "algebraic" actually. The assembly COPs are much more "human" operators because they describe exactly the steps of the data processing.

The FASM preprocessor is pretty powerful and can make such things, but this way you will lose all the advantages of the assembly language, without getting any of the advantages of the HLLs.

Better learn to think in assembly language and everything will be OK.
Post 24 Nov 2015, 09:23
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
system error



Joined: 01 Sep 2013
Posts: 652
This is a kind of brain damage normally caused by a HLL.
Post 24 Nov 2015, 09:27
View user's profile Send private message Reply with quote
codestar



Joined: 25 Dec 2014
Posts: 254

Quote:
idle wrote: i would, despite his odd behaviour sometimes, select ... abakis macro extension

Thanks. Anyone can use the macros in ABAKIS/<CPU>/LANGUAGE.INC.

Quote:
revolution wrote: So why should assembly coders try to make their code look like C?

A long time ago, I evolved from a simple one-dimensional "assembler coder" into a "custom multi-machine code generator" and am using TinyCC now. Not FASM/G anymore. My definition of "assembler" is any language that translates directly to machine code, binary 1s and 0s.

Why create/use macro languages? To make programs fast and easily, for high-volume production, OS portability, easier syntaxes (see example below), for conversion to/from C/C++, for fun, recreation, experimentation, testing algorithms, creating small utilities and games, to access machine code, for knowledge of semantics, for the ability to use BOTH "HL features" in addition to pure assembler and to do things which you can't do with a HL compiler. Using C style macro syntaxes is NOT the same as using a C compiler which doesn't have the power of FASM/G.

None of my macros prevent from writing 100% assembler like FreshLib's HL macro language does. IMO, the HL macro language included with FASM - struct, proc, invoke, .if, .while - is old, outdated and should be upgraded.

Try writing this in C, it will be much longer. What could be easier than this?

Code:
; Easiest file I/O example

include 'z.inc'

text t(128), f='LOG.TXT',\
  s='EXAMPLE TEXT DATA'
n=s.$

function main
  create f     ; create file
  write sn   ; write to current file
  close        ; close after create
  open f       ; reopen
  read tn    ; read to t
  say t        ; display text
  close        ; close after open
  execute f    ; execute maximize
endf

Post 29 Nov 2015, 07:41
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


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.