News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

krad-uasm-wip 2.54.0 version

Started by KradMoonRa, April 26, 2021, 08:39:12 AM

Previous topic - Next topic

KradMoonRa

Hi.
This is my wip version of uasm.

* Added better platform preprocessor at compile time detection.
* TODO-Add missing and old compilers support in the preprocessor.
* Replicated calling convention consistencies in source builds, Windows-call-conventions-defaults=__vectorcall, Linux|Mach-call-convention-defaults=sysv_abi.
* Added options for SIMD platform instruction selection at compile time, source build hardening and optimizations, in Clang Linux Gcc Linux Clang OSX mak-files.
* Ubuntu debian build fixed to reflect mak-files changes.
* TODO-OSX not tested for the current Clang OSX mk file.
* Synced Jhon Terraspace/UASM/tree/v2.53 commit 8f8feb76a3fec91c5038bb09dfc304df804f5e16.
* Added build options for SIMD platform instruction selection at compile time for Windows x64/x86.
* Added versioning to reflect UASM compile time changes.
* TODO-Continue UASM sources optimization path, bringing optimized cpu intrinsic to .asm source files.
* Fixed and moved embedded uasm macros to include/uasm/macros .inc files types. This bring more control and consistency in assembling for target platforms.

To check for the macros, You can start with include macrolib.inc in your .asm file.

Now Windows Setup for 64bits and 32bits, add the necessary path environment variables, and MSBuild BuildCustomizations for VS2019.

For windows and Linux64 binaries go to: 2.54.0 release

Mac OSX still in TODO-List.

Linux installs to /usr/bin/uasm and inc files to /usr/include/uasm, so it can be used from bash or dash as usual gcc compiler.
Remember to pass (-I /usr/include/uasm) in uasm command to find the include files.

Linux ubuntu package manager Instructions: currently only done for focal 20.04 release.

add the sign key to your trusted keys
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key 10649EA8D069C51D
or
curl -fsSL https://apt.navegos.net/pub.key | sudo apt-key add -

Source Links:

Now you can try the uasm built with SIMD intrinsics. Simple change the link.
      SSE2=https://apt.navegos.net/ubuntu/uasm/
   AVX=https://apt.navegos.net/ubuntu/uasm-avx/
   AVX2=https://apt.navegos.net/ubuntu/uasm-avx2/
   AVX512=https://apt.navegos.net/ubuntu/uasm-avx512/


add package as sudo:
sudo add-apt-repository "deb [arch=amd64] https://apt.navegos.net/ubuntu/uasm/ $(lsb_release -cs) main"
or
echo "deb [arch=amd64] https://apt.navegos.net/ubuntu/uasm/ focal main" | sudo tee /etc/apt/sources.list.d/uasm.list

update and install
sudo apt-get update && sudo apt-get install uasm-dev uasm uasmd

debug symbols for uasmd
sudo apt-get install uasmd-dbgsym

to remove
sudo apt-get purge uasm-dev uasm uasmd uasmd-dbgsym
The uasmlib

lucho

Thank you for working on UASM! I could build it OK, but an old bug that was present also in the old version 2.49 is still there. The following code

.code
tst proc
.for (eax = 0: edx == 0: )
nop
.endfor
tst endp
end


when built with "uasm -elf -3 -mf -Fl -Sa test.s", results in this listing:

test.s
                            *   .model FLAT
00000000                    *   _TEXT segment DWORD FLAT PUBLIC 'CODE'
                            *   _TEXT ends
00000000                    *   _DATA segment DWORD FLAT PUBLIC 'DATA'
                            *   _DATA ends
                            *   assume cs:flat,ds:flat,ss:flat,es:flat,fs:ERROR,gs:ERROR
                                .code
00000000                    *   _TEXT segment
                            *   assume cs:FLAT
00000000                        tst proc
00000000                                .for (eax = 0: edx == 0: )
00000000  33C0              *    xor  eax, eax
00000002                    *   @C0001:
00000002  90                                    nop
00000003                                .endfor
00000003  EBFD              *    jmp @C0001
00000005                        tst endp
                                end
00000005                    *   _TEXT ends


As you see, there is no check for the condition. If I add a statement between the last ":" of the ".for" and the parenthesis:

.code
tst proc
        .for (eax = 0: edx == 0: edx = edx)
                nop
        .endfor
tst endp
end


then it does generate a code for the condition check:

test.s
                            *   .model FLAT
00000000                    *   _TEXT segment DWORD FLAT PUBLIC 'CODE'
                            *   _TEXT ends
00000000                    *   _DATA segment DWORD FLAT PUBLIC 'DATA'
                            *   _DATA ends
                            *   assume cs:flat,ds:flat,ss:flat,es:flat,fs:ERROR,gs:ERROR
                                .code
00000000                    *   _TEXT segment
                            *   assume cs:FLAT
00000000                        tst proc
00000000                                .for (eax = 0: edx == 0: edx = edx)
00000000  33C0              *    xor  eax, eax
00000002  EB03              *    jmp @C0002
00000004                    *   @C0001:
00000004  90                                    nop
00000005                                .endfor
00000005  8BD2              *    mov   edx,  edx
00000007                    *   @C0002:
00000007  85D2              *   test edx, edx
00000009  74F9              *   jz  @C0001
0000000B                        tst endp
                                end
0000000B                    *   _TEXT ends


The bug must be in the "hll.c" file between lines 1768 and 1909, but it's difficult for me to see it as I'm not familiar with the internals of this code. Please check it out.

tenkey

Quote from: lucho on May 02, 2021, 04:10:58 AM
Thank you for working on UASM! I could build it OK, but an old bug that was present also in the old version 2.49 is still there. The following code

.code
tst proc
.for (eax = 0: edx == 0: )
nop
.endfor
tst endp
end


when built with "uasm -elf -3 -mf -Fl -Sa test.s", results in this listing:

test.s
                            *   .model FLAT
00000000                    *   _TEXT segment DWORD FLAT PUBLIC 'CODE'
                            *   _TEXT ends
00000000                    *   _DATA segment DWORD FLAT PUBLIC 'DATA'
                            *   _DATA ends
                            *   assume cs:flat,ds:flat,ss:flat,es:flat,fs:ERROR,gs:ERROR
                                .code
00000000                    *   _TEXT segment
                            *   assume cs:FLAT
00000000                        tst proc
00000000                                .for (eax = 0: edx == 0: )
00000000  33C0              *    xor  eax, eax
00000002                    *   @C0001:
00000002  90                                    nop
00000003                                .endfor
00000003  EBFD              *    jmp @C0001
00000005                        tst endp
                                end
00000005                    *   _TEXT ends


As you see, there is no check for the condition.

The bug must be in the "hll.c" file

I have a version of hll.c that fixes the problem.

lucho

Quote from: tenkey on May 17, 2021, 04:59:36 AM
I have a version of hll.c that fixes the problem.

That's great! Could you please post a patch here? Thanks!

tenkey

#4
Here's the version of hll.c for kradmoonra's UASM code base (v. 2.54.0).
It fixes the .for-.endfor code generation bug.

lucho

Thank you very much! Just tested it and can confirm that it really fixes the bug. Hope that the other UASM branches take advantage of your fixed version too.