flat assembler
Message board for the users of flat assembler.

Index > Main > satisfying feeling of freedom

Author
Thread Post new topic Reply to topic
sylware



Joined: 23 Oct 2020
Posts: 437
Location: Marseille/France
sylware 02 Dec 2021, 17:13
I have been working on my assembly project for a while now, and I cannot ignore this very satisfying feeling of freedom which assembly is giving me by not being dependent on those abominations which are gcc (above 4.7.4) and clang.
Post 02 Dec 2021, 17:13
View user's profile Send private message Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 926
Location: Russia
macomics 02 Dec 2021, 19:20
The problem with the fasm project is that it consists only of a compiler. Whereas for writing some projects, it would be nice to have a linker that builds a single executable from several binary files. Although at the script level, the fasm compiler can partially do such work on its own. That's just that even as examples, the fasm kit does not include any such solution. (And I don't mean the Linux build that uses the gcc/ld utility.)
And in general, fasm is flexible enough to feel completely free.
Simple example: source1 (boot sector code)
Code:
format binary as "BIN"
org 0x7C00
use16
  ...
    

source 2 (fasm as linker)
Code:
format binary as "IMG"
org 0
; Boot sector
struc assume base*, type& { if ~ type eq
    virtual at base
      . type
      .sizeof = $ - .
    end virtual
  else
    label . at base
    .sizeof = $ - .
  end if }
struc bpb_struc {
 .jump  db 3 dup ?
 .ImgName db 8 dup ?
 .BytesPerSector dw ?
 .SectorsPerCluster db ?
 .ReservedSectors dw ?
 .NumberOfFATs db ?
 .RootSize dw ?
 .TotalSectors dw ?
 .DiskType db ?
 .SectorsPerFAT dw ?
 .SectorsPerTrack dw ?
 .NumberOfHeads dw ?
}
bpb assume 0, bpb_struc

file "source1.BIN":0,512
load bps word from bpb.BytesPerSector
load res word from bpb.ReservedSectors
load nfat byte from bpb.NumberOfFATs
load spf word from bpb.SectorsPerFAT
load root word from bpb.RootSize
load spc byte from bpb.SectorsPerCluster
load siz word from bpb.TotalSectors
nres = res * bps
rb ( nres - 1 ) - (( $ + nres - 1 ) mod nres )

; FAT table
macro build_fat12 sfat, clus { while nfat
  db 0xF0, 0xFF, ( 3 * clus / 2 ) dup 0, ( 2 * ( clus and 1 )) dup 0
  rb ( sfat - 1 ) - (( $ - nres + sfat - 1 ) mod sfat )
end while }

macro build_fat16 sfat, clus { while nfat
  db 0xF0, 0xFF, 0xFF, 0xFF, ( 2 * clus ) dup 0
  rb ( sfat - 1 ) - (( $ - nres + sfat - 1 ) mod sfat )
end while }

build_fat12 ( bps * spf ), ( siz - 2 - res - ( nfat * spf ) - ( 32 * root + bps - 1 ) / bps )

; root directory
  rb 32 * root
  rb ( bps - 1 ) - (( $ + bps - 1 ) mod bps )

; clusters array
cbeg = $
bpc = spc * bpc
  file "data.bin"
  rb ( bpc - 1 ) - (( $ - cbeg + bpc - 1 ) mod bpc )

; create root / directory entry
...

; update FAT tables
...

; image align
total = siz * bps
  rb ( total - 1 ) - (( $ + total - 1 ) mod total )    
Post 02 Dec 2021, 19:20
View user's profile Send private message Reply with quote
sylware



Joined: 23 Oct 2020
Posts: 437
Location: Marseille/France
sylware 03 Dec 2021, 15:11
On top of this feeling of freedom, I have also this feeling of enpowerment. The more I "rationally" do remove, the better I feel. I guess those feelings are emergent from my knowledge/experience of the various critical software/hardware components needed to get code actually running.

We all know the current status quo in computer systems is still quite toxic plagued with technical scammers (apple/microsoft/much of GNU/etc), but deep down I feel being on the right "path"/"trajectory".
Will it last, no idea.
Post 03 Dec 2021, 15:11
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1619
Location: Toronto, Canada
AsmGuru62 03 Dec 2021, 16:32
So... what exactly turns you off from GCC/Microsoft compilers? Is it the EXE file size?
You can switch off the libraries and write some functions yourself, like strcpy(),atoi() and such (or you can LoadLibrary("MSVCRT.DLL") and get these functions from there).
Is it the "bloated" code? The optimized code from these compilers looks nice in disassembler -- nothing which should not be there.
The only thing I do not like is that when Windows API is called -- it goes through a JMP table and FASM does a direct call into IMPORT section -- I was not able to switch that off.
Other than that those compilers are OK in my opinion.
Post 03 Dec 2021, 16:32
View user's profile Send private message Send e-mail Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 926
Location: Russia
macomics 03 Dec 2021, 18:36
AsmGuru62 wrote:
The only thing I do not like is that when Windows API is called -- it goes through a JMP table and FASM does a direct call into IMPORT section -- I was not able to switch that off.
But this is due to the fact that in the fasm sections are defined and placed in the final file as is. And if it is necessary to generate and organize these sections separately, as other compilers do, it is more convenient to move through JMP. In general, this problem/crutch is all from the same topic with linking separate binary blocks into one final binary file. See .LIB file generation.

ADD: These JMP instructions are not in OBJ files. They appear in LIB files.


Last edited by macomics on 03 Dec 2021, 19:39; edited 1 time in total
Post 03 Dec 2021, 18:36
View user's profile Send private message Reply with quote
sylware



Joined: 23 Oct 2020
Posts: 437
Location: Marseille/France
sylware 03 Dec 2021, 19:18
gcc and clang 'backdoor injectors for all old/current/future CPUs'(irony?) are insanely and massively complex, and having my code not dependent on those (and their developers loving planned obsolescence), makes me experience the feelings I am talking about. It is objective facts about my emotional state. It is so obvious, I wanted to share it here.
But I know that time erodes anything, wonder how long those strong satisfying feelings will last.
As I said, the status quo is still nasty because of the scammers of computer systems, but oh dear!, it feels already so good to have that little part on the right path/trajectory.
Post 03 Dec 2021, 19:18
View user's profile Send private message Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 926
Location: Russia
macomics 03 Dec 2021, 19:45
In any case, if there was fair competition between at least large firms (the scammers of computer systems), this would not have happened. The introduction of universal approaches is doomed to degenerate into very inefficient solutions. Thus, the code created by third-party developers will be obviously worse than the one that is optimized for a specific platform.

While Steve Jobs was at the head of Apple, there was at least some competition. And now Apple has been turned into consumer goods, they have been accepted into a club of computer scammers.
Post 03 Dec 2021, 19:45
View user's profile Send private message Reply with quote
sylware



Joined: 23 Oct 2020
Posts: 437
Location: Marseille/France
sylware 03 Dec 2021, 20:08
For the story, I remember the time I had nokia first 'mini-tablet about to become a phone' (nokia 770), that with a super lean gnu/linux distro and a more than enough GTK+ based GUI software. It was great, they were about to add a mobile modem and telephony... then everything turned to 'you know what', nobody knew what was happening in nokia and why they were 'destroying' their future... and somewhat a bit later apple was releasing the iphone. A few convenient years later, we discovered that microsoft had been taking control of nokia, and in the end bought them when it was too obvious.
After some similar cases happening in other hightech domains, I understood something about international finance and the world we live in...


Last edited by sylware on 03 Dec 2021, 22:08; edited 1 time in total
Post 03 Dec 2021, 20:08
View user's profile Send private message Reply with quote
sts-q



Joined: 29 Nov 2018
Posts: 57
sts-q 03 Dec 2021, 20:39
AsmGuru62:
man -P cat gcc | wc -l
20351 lines, that is >300 manual pages
my K&R from 1983 is <250 pages
Confused
Post 03 Dec 2021, 20:39
View user's profile Send private message Visit poster's website Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 926
Location: Russia
macomics 03 Dec 2021, 22:56
sylware wrote:
For the story, I remember the time I had nokia first 'mini-tablet about to become a phone' (nokia 770) ...
In fact, modern devices have turned into expensive toys with Internet access, a camera and a payment interface. And also in the kit you get a bunch of additional functions, most of which cause a wow effect and are not used already on the second day of owning the device.

But every year a new toy is released to you, which differs from yours only in that it does not slow down and has a couple more functions that you do not need. Because of this, the new device is even more expensive than the previous one.
Post 03 Dec 2021, 22:56
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.