News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Solar Assembler location

Started by BogdanOntanu, May 22, 2012, 06:09:59 AM

Previous topic - Next topic

BogdanOntanu

Quote from: Gunther on February 09, 2015, 11:42:37 PM
Bogdan,

Quote from: BogdanOntanu on February 07, 2015, 10:59:10 AM
A few news:
- The site is there to stay from now on... I have payed it in advance for a long time.
- The site will get a nice redesign in the next months.
- Sol_Asm and Solar_Os are being re-worked/converted to 64 bits native
- The 32 bits versions will continue to be supported and kept in sync with the new 64 bits versions.

that's good news. Will SolAsm support AVX, AVX2, AVX512? If so, it could be a nice alternative to jWasm and it's under active development.

Gunther

Hi Gunther,

Yes Sol_Asm will support the latest instruction sets.

It does support quite a lot as it is now.

If you have any instructions that you want to see implemented fast ... then just let me know here and I will try to implement them  ASAP ;)

Best reagrds,
Bogdan
Ambition is a lame excuse for the ones not brave enough to be lazy, www.oby.ro

rrr314159

@Gunther
QuoteSure, but an alternative is not so bad. Furthermore, it seems to me that some parts of jWasm's AVX support is buggy.
Agree re alternatives - "Let a thousand flowers bloom". I'd rather see everyone together on the same project, though; assembler is a big job. Admire Bogdan, Habran, and all others working to support me :P Hope someday to help also. re AVX I've been using JWasm and MASM successfully, each has exactly one problem I know of, since Habran (I assume) fixed the square root. Both can be worked around. However I've exercised less than half the commands and haven't touched AVX2.

@BogdanOntanu,
Sorry don't mean to hijack your thread, thanks for Sol ASM, great project. Like that it compiles itself. Fixes a number of MASM's quirks, e.g. logical treatment of []. Many nice touches like REV, Olly symbol support, etc. Big project, 64 bits complicates things, apparently you're not "brave enough to be lazy"  :biggrin:
I am NaN ;)

Gunther

Quote from: rrr314159 on February 10, 2015, 01:36:42 PM
Agree re alternatives - "Let a thousand flowers bloom". I'd rather see everyone together on the same project, though; assembler is a big job. Admire Bogdan, Habran, and all others working to support me :P Hope someday to help also. re AVX I've been using JWasm and MASM successfully, each has exactly one problem I know of, since Habran (I assume) fixed the square root. Both can be worked around. However I've exercised less than half the commands and haven't touched AVX2.

Bogdan is a hard working man. He's developing SolAsm and SolOs since many years, both with success.

All my projects in the last 2 years have different versions: One for MASM/JWASM and the other for YASM/NASM. Since SolAsm is under active development, I could do a third SolAsm version. Why not?

Gunther
You have to know the facts before you can distort them.

BogdanOntanu

Quote from: rrr314159 on February 10, 2015, 01:36:42 PM
...
@BogdanOntanu,
Sorry don't mean to hijack your thread, thanks for Sol ASM, great project. Like that it compiles itself. Fixes a number of MASM's quirks, e.g. logical treatment of []. Many nice touches like REV, Olly symbol support, etc. Big project, 64 bits complicates things, apparently you're not "brave enough to be lazy"  :biggrin:

Sol_Asm already has 64 bits support. it can directly generate 64 bits code for PE, ELF, MSCOFF and binary (for OS development).

What I mean by "64 bits" is making Sol_Asm and 64 bits application itself (currently it is an 32 bits application)


Ambition is a lame excuse for the ones not brave enough to be lazy, www.oby.ro

K_F

'Sire, Sire!... the peasants are Revolting !!!'
'Yes, they are.. aren't they....'

BogdanOntanu

Quote from: K_F on April 08, 2016, 08:02:32 AM
Any more news here... ?
:biggrin:

There is a new version: v.0.36.16 released on 2016.03.30

- It fixes a bug in x64 REX prefix encoding
Ambition is a lame excuse for the ones not brave enough to be lazy, www.oby.ro

Vortex

Hi Bogdan,

What happened to the Solar Forums? I receive the following message :

QuoteNot Found

The requested URL /forum was not found on this server.

BogdanOntanu

Hi Vortex,

Yes, I have removed the forums since almost nobody was posting there anymore :D


Ambition is a lame excuse for the ones not brave enough to be lazy, www.oby.ro

jj2007

Quote from: hutch-- on February 06, 2015, 10:29:37 AMWish I had an extra life so I could do some work in SolAsm, its looking like an excellent tool.

I can echo that :t

BogdanOntanu

Quote from: jj2007 on April 09, 2016, 11:14:25 AM
Quote from: hutch-- on February 06, 2015, 10:29:37 AMWish I had an extra life so I could do some work in SolAsm, its looking like an excellent tool.

I can echo that :t

As always you guys are too kind ;) thank you.

Today I use SOL_ASM for all my asm projects hence it works.

However Sol_Asm needs some development. It is functional but still rough at edges (spaces) and has some quirks.
Until I reach version 1.0 I think that you are better suited by MASM/MASM32 or JWASM.

Unless you like to live on the edge ... and test new things... that is ;))

Ambition is a lame excuse for the ones not brave enough to be lazy, www.oby.ro

GoneFishing

Hi, Bogdan
Today I've downloaded and built ( on Linux x64 machine ) your latest version of SOL_ASM.
Lin32 sample has no problem when compiled as 32 bit and has the same problem that was mentioned in this post .
Could you , please,  provide a working Lin64 sample ? I guess I'm doing something wrong   :icon_confused:

Thanks

mineiro

hello Sir GoneFishing;
follow a simple native example 01.asm and some comments

section "text" class_code alias ".text"
.USE64
sys_exit equ 60
.text
.entry _start
_start:
mov rdi,77
mov rax,sys_exit
syscall

to assemble, suposing solasm on bin folder, if not, append a "./" before: sol32 01.asm 01.o -elf64
now, check object file with command "file 01.o", you will see that have x86_64 and i386 on header, we should change that by hand,
open hexadecimal editor, goto address 19 and change "03h" to "3eh", save and do a "file 01.o" again, it should work and ready to link.

I have created a script to do this instead of hexadecimal editor, change to your needs.
It works by isolating byte 19 of file object, but I'm using bash shell so it inserts an LF when I echo, this is why I remove again 1 byte from middle:
head --bytes=18 01.o > start
echo -e "\x3e" > middle
head --bytes=1 middle > middle 1
tail --bytes=+20 01.o > end
cat start middle1 end > 01.o

ld -m elf_x86_64 01.o -o 01
./01 ; echo $?

Now remove junk files ...

I have tested this way with shared libraries too and worked fine.
Follows a object.sh file, "chmod +x" on it and call it like "./object.sh 01.o"

head --bytes=18 $1 > start
echo -e "\x3e" > middle
head --bytes=1 middle > middle 1
tail --bytes=+20 $1 > end
cat start middle1 end > $1
rm start
rm middle
rm middle1
rm end

A last hint is appears to me that solasm like CRLF instead of LF on source code, setup your linux editor to handle this.
I'd rather be this ambulant metamorphosis than to have that old opinion about everything

GoneFishing

Hello MINEIRO,

Thanks for responding. On Linux we have a special utility  ELFEDIT for editing ELF headers , so one simple command does all the job:
Quoteelfedit  --output-mach x86-64  test.obj

You may check it with HEXDUMP and FILE utilities.

Talking about Lin64 sample I meant  example using shared libs  - for example puts, printf and exit functions of LIBC .
I can link it but it crashes with SEGFAULT .
I'll be much greatful if you'll post working Lin64 example using LIBC. 

P.S.: The example using only  exit function doesn't crash but ECHO $? doesn't show valid exit code - GUESS WHY ?

mineiro

#28
hello sir GoneFishing;
I can suppose that thats happening when you're linking the file or maybe an environment variable.
When I have started on linux I received many segmentation fault, I suppose that's because rsp register is not aligned before a call.
rsp=???????????????0
I can guess that happens if using 32 bits instead of 64 bits values (like printing an decimal interger instead of unsigned qword).
man 2 intro
man 2 syscall
man 2 syscalls
man 2 _syscall

You can try compile with gcc to have sure. I'm now on linux, so I can put more info.
I'm a hobbyst, don't expect much, but we can join forces, I can do some tests on this side if you need.
I linked with ld and with gcc this time, I try things with ld only but If I will release some software I will compile with gcc (exception handling).
If you need know whats happening behind the scene do a "-v" (verbose) on gcc comand line, this helped me to know how to use ld while trying a gtk samples using jwasm
I have used objdump -x on a generated file while reading gtk2 manual, because I do not know whats macro and whats functions.

um.asm

section "text" alias ".text" class_code
section "data" alias ".data" class_data

.USE64

stdout equ 1
sys_write equ 1
sys_exit equ 60

.data
msg_01 db 10,"Hello world",10
msg_len equ $-msg_01

.text
.entry _start
_start:

mov rdx,msg_len
mov rsi,offset msg_01
mov rdi,stdout
mov rax,sys_write
syscall

mov rdi,39
mov rax, sys_exit
syscall


mineiro@assembly:~/Assembly/solasm$ sol32 um.asm um.o -elf64

Solar Assembler version 0.36.12
Copyright (c) 2007,2012 Bogdan Valentin Ontanu, All rights reserved.
Build on 2012_11_5  at 21:44:54

Assembling file: um.asm
Assembler  pass: 1
Assembler  pass: 2
Assembler lines: 97
Output bytes   : 750
Assembler  time: 11 ms
-----------------------------
:~/Assembly/solasm$ file um.o
um.o: ELF 64-bit LSB  relocatable, Intel 80386, version 1 (SYSV), not stripped
:~/Assembly/solasm$ head --bytes=18 um.o > start
:~/Assembly/solasm$ echo -e "\x3e" > middle
:~/Assembly/solasm$ head --bytes=1 middle > middle1
:~/Assembly/solasm$ tail --bytes=+20 um.o > end
:~/Assembly/solasm$ cat start middle1 end > um.o
:~/Assembly/solasm$ file um.o
um.o: ELF 64-bit LSB  relocatable, x86-64, version 1 (SYSV), not stripped
:~/Assembly/solasm$ ld -m elf_x86_64 um.o -o um
:~/Assembly/solasm$ ./um ;echo $?

Hello world
39
:~/Assembly/solasm$ rm start
:~/Assembly/solasm$ rm middle
:~/Assembly/solasm$ rm middle1
:~/Assembly/solasm$ rm end
:~/Assembly/solasm$ gcc -nostartfiles um.o ; ./a.out ; echo $?

Hello world
39
:~/Assembly/solasm$ gcc -s -nostartfiles um.o ; ./a.out ; echo $?
:~/Assembly/solasm$ rm um.o

---------------------------------------------------------------------------------
man exit
different calling convention from native to library C functions, .

dois.asm

section "text" alias ".text" class_code
section "data" alias ".data" class_data

.USE64

extern exit
extern puts
extern printf

.entry _start

.data
msg db "hello world",10,0
msg_len equ $-msg

msg_fmt db 10,'message: %d %d %d %d %d %d %d %d %d %d %d %d %d',10,0

.text
_start:

push 15
push 14
push 13
push 12
push 11
push 10
push 9
push 8
mov r9,7
mov r8,6
mov rcx,5
mov rdx,4
mov rsi,3
mov rdi,offset msg_fmt
call printf
add rsp,8*8

mov rdi,msg
call puts

mov rdi,57
call exit


dois.sh

sol32 dois.asm dois.o -elf64
head --bytes=18 dois.o > start
echo -e "\x3e" > middle
head --bytes=1 middle > middle1
tail --bytes=+20 dois.o > end
cat start middle1 end > dois.o
ld -m elf_x86_64 -dynamic-linker /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 -L/lib/x86_64-linux-gnu -lc -o dois dois.o
rm start
rm middle
rm middle1
rm end
./dois ; echo $?



:~/Assembly/solasm$ ./dois.sh

Solar Assembler version 0.36.12
Copyright (c) 2007,2012 Bogdan Valentin Ontanu, All rights reserved.
Build on 2012_11_5  at 21:44:54

Assembling file: dois.asm
Assembler  pass: 1
Assembler  pass: 2
Assembler lines: 42
Output bytes   : 1041
Assembler  time: 10 ms
-----------------------------

message: 3 4 5 6 7 8 9 10 11 12 13 14 15
hello world

57
:~/Assembly/solasm$ gcc -nostartfiles dois.o ; ./a.out ; echo $?
message: 3 4 5 6 7 8 9 10 11 12 13 14 15
hello world
57
:~/Assembly/solasm$ ld -m elf_x86_64 -dynamic-linker /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 -L/lib/x86_64-linux-gnu -lc -o dois dois.o
:~/Assembly/solasm$ ./a.out ; echo $?
message: 3 4 5 6 7 8 9 10 11 12 13 14 15
hello world
57
:~/Assembly/solasm$

but look this, give to me errors
:~/Assembly/solasm$ ld -m elf_x86_64 -dynamic-linker -I/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 -L/lib/x86_64-linux-gnu -lc -o dois dois.o
:~/Assembly/solasm$ ./a.out ; echo $?
bash: ./a.out: Arquivo ou diretório não encontrado (like a file or folder not found) <-- Is this whats happening to you?
127
:~/Assembly/solasm$ ld -nostartfiles -m elf_x86_64 -dynamic-linker /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 -L/lib/x86_64-linux-gnu -lc -o dois dois.o
dois.o: na função `_start': <-- Is this whats happening to you?
(.text+0x4d): referência indefinida para `printf' (reference to printf not found) <-- Is this whats happening to you?
dois.o: na função `_start':
(.text+0x60): referência indefinida para `puts' (reference to puts not found)
dois.o: na função `_start':
(.text+0x6f): referência indefinida para `exit' (reference to exit not found)
:~/Assembly/solasm$ gcc -nostartfiles -dynamic-linker dois.o ; ./a.out ; echo $?
message: 3 4 5 6 7 8 9 10 11 12 13 14 15
hello world
57
:~/Assembly/solasm$


-------------edited------------
I have done an error, sub rsp,8*8 instead of add rsp,8*8, I corrected example above
I'd rather be this ambulant metamorphosis than to have that old opinion about everything

GoneFishing

Thanks MINEIRO,

Oh I'm sorry I didn't know that you're a hobbyst programmer just like me.
I'lll try to explain WHY :
SOL_ASM knows STDCALL, CDECL and WIN64/FASTCALL calling conventions .
For 32 bits STDCALL is default and WIN64/FASTCALL is default for 64 bits . When I specify option .use64 and declare extern exit SOL_ASM follows WIN64 ABI and places the first parameter in RCX while it should be placed in RDI accordingly to SYSV ABI and so on .

Your  Lin64 example uses workaround when you yourself care where to place each parameter - the only way ( for now) to emulate FASTCALL for Linux . The sad state of affairs is that you can't just write invoke exit, 42 etc. ( unless you substitute builtin INVOKE with your own macro like my FCALLTEST macro for JWASM ) 

Now, you execute these  5 shell commands :
Quote
head --bytes=18 dois.o > start
echo -e "\x3e" > middle
head --bytes=1 middle > middle1
tail --bytes=+20 dois.o > end
cat start middle1 end > dois.o
to achive the same effect that I get with a single line:
Quoteelfedit  --output-mach x86-64  test.obj

Try it  and compare the results - should be the same .

Don't worry I won't bother you asking for help or testing something because I'm too lazy , so lazy that I even got tired with my vacations  ;)

Good luck with your hobby  ...  and let's hope that some day SOL_ASM and maybe HJWASM will support SYSV ABI .