flat assembler
Message board for the users of flat assembler.

Index > Heap > Let's forget about 8080

Author
Thread Post new topic Reply to topic
booter



Joined: 08 Dec 2006
Posts: 67
booter
As I remember, Intel 8086 was designed to be backward compatible with 8080. Nowdays we have very powerful CPUs that still inherit its "microchip" nature. I mean packing commands by bits to make them shorter, commands relied on specifically designated registers, etc. As a result, x86/64 assembler always was and still is rather hard to use. I believe that's what pushed "C" to become a language of choise for "system programming".
I propose start "assembler" over, I mean without taking in consideration Intel's 8080-oriented language that was then expanded to support newer CPUs.
We don't really need support for "high-level" language constructions (like if-then-else), neither we are obligated to follow one-cpu-command per one code line paradigm. Things like
Code:
  cld
  repz stosb    
are just insult to humanity Smile
It's much better to have
Code:
  copyb [edi],[esi],ecx  ; at least you can see what's going on    

Summurizing, I propose new assembler, which would hide Intel's microchip trickery and provide kind of abstract CPU easy to code in assembler.
Obviously, this can be implemented in macros, but why would we still need them to expand to Intel's ugly stuff? Wouldn't it be better to compile directly into machine code (and disallow 8080-ugliness)? And finally, SSE and MMX capabilities would be automatically utilized by compiler.
Post 07 Mar 2010, 10:05
View user's profile Send private message Reply with quote
zhak



Joined: 12 Apr 2005
Posts: 490
Location: Belarus
zhak
booter wrote:
I propose new assembler, which would hide Intel's microchip trickery and provide kind of abstract CPU...
abstract cpu? that won't be assembler any more. what you propose is another mid-level language. Confused
Post 07 Mar 2010, 10:30
View user's profile Send private message Reply with quote
zhak



Joined: 12 Apr 2005
Posts: 490
Location: Belarus
zhak
there's HLA - high level assembler. you can check it if you'll like it
Post 07 Mar 2010, 10:33
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4240
Location: 2018
edfed
with fasm macro every CPU emulation is possible.


for example, i believe it is possible to generate 68k or PIC16fxx datas and code with x86 source, if a macro designed to do so is at the start of the source.
Post 07 Mar 2010, 13:13
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
booter, I think you meant this actually:
Code:
cld ; This is hardly needed. Typical convention is to use this instruction in the procedure that used sti(or set the DF flag with popf)
rep movsb ; The assembler here supports "rep movs byte[edi], byte[esi]" too    

The code above looks much more proximate to your copyb.
Post 07 Mar 2010, 17:21
View user's profile Send private message Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
rep stosb makes more sense, it says store string by bytes... btw, it does not "copy", that's what move string by bytes does (movsb).

repeat makes enough sense.

nothing wrong with it.

_________________
Previously known as The_Grey_Beast
Post 07 Mar 2010, 18:13
View user's profile Send private message Reply with quote
a115433



Joined: 05 Mar 2010
Posts: 144
a115433
I believe that's what pushed "C" to become a language of choise for "system programming".

hahahahaha
i knew they were incompetent Very Happy
Post 07 Mar 2010, 18:38
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
booter,

Non-Intel assembly language syntax? Well, you may give it a try. There are several already, from simple-to-parse AT&T/gas through somewhat cryptic Terse to eclectic OctAsm. HLA is too high-level to be considered as alternative syntax, I think.

Whenever I catch myself fiddling with an idea to replace add eax, [ebp+8] with eax += [ebp+8], the following exercise relieves me from that: try to apply that idea to some nontrivial instruction, like movsx, xadd or cmpxchg.
Post 07 Mar 2010, 19:58
View user's profile Send private message Reply with quote
booter



Joined: 08 Dec 2006
Posts: 67
booter
Thanks everybody for your interest and replies. Let me clarify some of my ideas.
I would prefer cleaner and simpler source code and let compiler to decide how to implement it in binary. In fact, most(all?) x86/64 asm compilers are doing it anyway, though I propose to ignore which binaries Intel consideres the same command and which it does not. Example
Code:
 inc eax
 add eax,1
 lea eax,[eax+1]    


Regarding Intel's "mov", I'm rather sceptical that "move" is the right word to describe duplication of the data. I would say "load" (mem to reg), "store" (reg to mem), and "copy" (mem to mem) sound better. I'm not sure about "reg to reg", though. Both "load" and "copy" sound OK to me.
Regarding HLA, to me assembler is a pure "go to"-language and let's leave it this way. Yes, "if"-macro is a "treason" in asm-world Smile
Sorry for "stosb". Of course, I meant movsb - just copied the code from a wrong place. BTW, with stosb it may be called "Fill".
I believe these ideas are mostly suitable to x64, which is the first "sane" CPU in this family Smile
Post 08 Mar 2010, 07:52
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
booter wrote:
I would prefer cleaner and simpler source code and let compiler to decide how to implement it in binary.
That's what C is for.

Imho a "pseudoassembly" is pretty useless - if you aren't going to do WYCIWYG, why do assembly programming at all?

_________________
Image - carpe noctem
Post 10 Mar 2010, 07:46
View user's profile Send private message Visit poster's website Reply with quote
zhak



Joined: 12 Apr 2005
Posts: 490
Location: Belarus
zhak
what's wrong with
Code:
inc eax
add eax, 1
lea eax, [eax+1]    

you want all of them to be replaced with 1 instruction?

use INC it when you want size optimization
use ADD when you need all flags updated
use LEA when you need all flags preserved

those are only some of the examples. real optimization goes much further and i don't believe that any compiler can automatically predict where each instruction should be placed in the code. at first you create the skeleton - working code, then you check it and optimize it.

who said that asm should be easy? for easy things one should refer to java or .net

p.s. i cannot imagine, how fast windows could be if all its critical code was rewritten and optimized in assembly... i really doubt that it's done this way
Post 10 Mar 2010, 08:46
View user's profile Send private message Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1607
Location: Ukraine
shoorick
what i really miss from 8080 - conditional calls and rets. all other compatibility are definetly useless, as there never were any possibility to run 8080 code on 8086 Smile but hard to forget - still have this stuff Wink


Description:
Filesize: 22.15 KB
Viewed: 2439 Time(s)

chips8bit_.jpg



_________________
UNICODE forever!
Post 10 Mar 2010, 12:24
View user's profile Send private message Visit poster's website 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 can attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.