Re: cFASM (calling FASM as a C function)



På Wed, 21 Mar 2007 19:54:12 +0100, skrev randyhyde@xxxxxxxxxxxxx <randyhyde@xxxxxxxxxxxxx>:

On Mar 20, 6:48 pm, "vid...@xxxxxxxxx" <vid...@xxxxxxxxx> wrote:
> If you go through the FASM source code, you'll find that it's
> written using a 386-era programming style. By that, I mean that Tomasz
> uses CISC instructions that get as much work done per byte of object
> code as possible. While that was an effective programming style at one
> time, on the modern "more-RISC-like" x86 CPUs you pay a heavy penalty
> for using that programming style. A classic example is how Tomasz uses
> the SCASD instruction to do nothing other than increment EDI by 4.
> Clever, if saving space is your prime concern, but certainly not the
> fastest way to add 4 to EDI. Given how heavily string instructions
> get used in the code, I wouldn't be surprised to find that you could
> double the speed of FASM by replacing those instructions.

In some discussions i recall, Tomasz was against lowlevel
optimizations that makes maintaining harder.

This isn't a debate I want to get into here, but if maintenance is a
concern, substituting descrete instructions for string instructions is
nothing compared with other issues I've found. For example, the
complete overlapping of function boundaries in the code is a real
maintenance nightmare. The fact that one procedure calls another, that
called procedure jumps back into the calling code, sometimes without
cleaning up the stack (intended or otherwise) make maintenance
difficult. Another issue: the almost exclusive use of "magic numbers"
in the source code (e.g., offsets into structs and the like) is a
*real* maintenance nightmare.

But ignoring some existing issues, I just don't see how using "add edi,
4" is going to make the code less readable and less maintainable than
employing a trick like "scasd" to do the same task.

Also, as you probably don't know, size is a concern here. Tomasz wants
to keep .COM version of FASM, but size of FASM is dangerously hitting
64KB. :)

Why keep a .com version? .EXE work fine in 16-bit code. Even if one
insists on keeping a 16-bit version active, there is no reasonable
argument for keeping a .com version in this day and age. Granted, a
"tiny model" program meshes well with FLAT code and nothing special
needs to be done to the source file, but that's the price to pay for
being able to maintain a 16-bit version.
Cheers,
Randy Hyde

Example of HEX only assembler

[Randy.Hide 0
Randy.Age 4
Randy.Pandy 8
Randy.IQ 12

SizeOf_Randy 16]

Sourcecode:
B8 SizeOf_Randy
E8 GetMem
C7 40 Randy.Age 50
E8 FreeMem

binary:
B8 10 00 00 00
E8 00 45 40 00
C7 40 04 50 00 00 00
E8 00 90 40 00

:)))

---* Compared to assembly (not to confuse with HLA)

main:
mov eax SizeOf_Randy | call GetMem | mov D$eax + Randy.Age 80

---* compared to Delphi

Program LIES;
Type
Randy = Record
hide, age, pandy, IQ : DWORD:
end;

begin
New(Randy);
Randy.Age := 80;
Dispose(Randy);
end;

May someone write the _complete_ HLA version? :D :D

It should be ovias, that the DELPHI code is _MUCH_ less readable then the HEX version and with some practise much easier to write read and maintain.

The Hex version has all the benefits this way. The record can be changed, without touching the code. It is smaller. It will compile faster, it will use less paper when printed. It will give faster loading times, running times and use less memory. It will allow you to use less webspace for publishing. It will teach you all the opcodes so it will be much easier to read other applications. I know I could learn to write HEX this way, and to make as large a program with that as I do with RosAsm. Probably I will learn more, as the asm sometimes actually hide certain information.

What do you say. Who will make me this hex-assembler ? Maybe I try myself.
I could figure it be easy to allow for each time a label is changed, at the routine point, to automatically optionally rename all calls to it.

Given that RosAsm has proved that much of the trouble with ASM is the poor tools, (MASM, TASM, HLA) I say the same thing about this hex thing. Give it a propper tool, and we can make programming in hex as easy as programming in Visual Basic.

dont you agree?

Seems fully logic to me. I think I found myself a project.


.



Relevant Pages

  • Re: "Mastering C Pointers"....
    ... A program is a stream of instructions (pretend they ... to store a word from a CPU register to memory. ... All the instructions only work on CPU registers. ... the programming world, which makes it very hard for novices. ...
    (comp.lang.c)
  • Re: question about tasks, multithreading and multi-cpu machines
    ... instructions ... then the sequence is really a sequence and I'm talking ... I would like to have seen Ada 2005 address parallel programming better, ... In addition to lightweight concurrent statements, ...
    (comp.lang.ada)
  • Re: Trivia Question
    ... This is what I meant by "ignorance". ... people's *existing* HLL knowledge to learn assembly language programming? ... Which I had such an assembler when starting with Delphi. ... After working with the needed instructions some times, repleatly, they tend to stick around in your memory. ...
    (alt.lang.asm)
  • Re: Keyless Entry Programming instructions
    ... trying to get hold of programming instructions for raw KEyless door ... find any site which has those instructions without going through these ... Ray O wrote: ... I need programming instructions for ToYota 01 Sienna with both Power ...
    (alt.autos.toyota)
  • Re: Pinball Machine Programming
    ... certain companies of machine choose or prefer a certain programming ... the earlier systems have a very basic OS and then the game rules are a ... assemble to native microprocessor M/L. ... this is the hex listing you refer to. ...
    (rec.games.pinball)