flat assembler
Message board for the users of flat assembler.

Index > Projects and Ideas > A preprocessor for using operators like C--

Author
Thread Post new topic Reply to topic
SergeASM



Joined: 13 Nov 2015
Posts: 21
SergeASM 22 Nov 2015, 18:12
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: 3499
Location: Bulgaria
JohnFound 22 Nov 2015, 18:46
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: 21
SergeASM 22 Nov 2015, 20:32
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: 3499
Location: Bulgaria
JohnFound 22 Nov 2015, 22:03
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: 21
SergeASM 22 Nov 2015, 22:37
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: 3499
Location: Bulgaria
JohnFound 22 Nov 2015, 23:52
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: 48C0321ADDB2FE5F644BB5E3D58B0D58C35E5BCBC81D7CD333633FEDF1047914A534256478D9
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: 20445
Location: In your JS exploiting you and your system
revolution 23 Nov 2015, 00:35
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: 440
Location: Ukraine
idle 23 Nov 2015, 17:25
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 Reply with quote
SergeASM



Joined: 13 Nov 2015
Posts: 21
SergeASM 24 Nov 2015, 07:48
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: 20445
Location: In your JS exploiting you and your system
revolution 24 Nov 2015, 08:56
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: 3499
Location: Bulgaria
JohnFound 24 Nov 2015, 09:23
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: 670
system error 24 Nov 2015, 09:27
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
codestar 29 Nov 2015, 07:41
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 s, n   ; write to current file
  close        ; close after create
  open f       ; reopen
  read t, n    ; 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
bzt



Joined: 09 Nov 2018
Posts: 79
bzt 28 Nov 2018, 15:07
Sorry for posting in such an old topic, but I've finaly found it! Smile
JohnFound wrote:
C-- compiler?
Yes, Sphinx C-- was a DOS compiler with very low level capabilities. I wouldn't call it HLA, as it offers much more, it's a compiler of it's own right. I have used it a lot back in my DOS days, because it allowed me to be much efficient than with tasm or TurboC.

The original code was written by Peter Cellik, but his site is gone for long now. Luckily I've found a mirror (hurray Smile): http://c--sphinx.narod.ru/indexe.htm
It turned out the project wasn't dead for a long time (I lost track around version 0.192 when I switched to Linux). It has DPMI and Windows interface, and there are even OpenGL examples written in C--. The project although seems to be dead, latest update is from 2007.
Full source of the compiler on GitHub (a mirror from 2016) https://github.com/justdanpo/c--sphinx

IMPORTANT NOTE: this is NOT THE SAME C-- that Norman Ramsey wrote. https://en.wikipedia.org/wiki/C-- is a totally different project!

Cheers,
bzt
Post 28 Nov 2018, 15:07
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


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.