News:

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

Main Menu

Quick play with UASM

Started by hutch--, July 21, 2019, 07:04:08 PM

Previous topic - Next topic

hutch--

Timo,

I think you have mixed up a couple of things, we all know that the entry point is set in the linker but the code for that entry point is in the source code that the assembler processes. Your original comment was a suggestion to use the CRT in the form mainCRTStartup, wmainCRTStartup, WinMainCRTStartup, wWinMainCRTStartup and I made you the comment that it is not needed in the source code of an assembler application.

Here is an example in another assembler, POASM.

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    ExitProcess PROTO :QWORD
    MessageBoxA PROTO :QWORD,:QWORD,:QWORD,:QWORD

    MessageBox equ <MessageBoxA>
    MB_OK equ <0>

    includelib \masm32\lib64\kernel32.lib
    includelib \masm32\lib64\user32.lib

    .data
      msg db "A MessageBox in POASM",0
      ttl db " About",0

    .code

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

entry_point proc

    add rsp, 8

    invoke MessageBox,0,ADDR msg,ADDR ttl,MB_OK

    invoke ExitProcess,0

entry_point endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    end

It is built with this batch file.

@echo off

set appname=app

if exist %appname%.obj del %appname%.obj
if exist %appname%.exe del %appname%.exe

\masm32\bin64\poasm.exe %appname%.asm

\masm32\bin64\polink.exe /SUBSYSTEM:WINDOWS /MACHINE:X64 /ENTRY:entry_point /nologo /LARGEADDRESSAWARE %appname%.obj

dir %appname%.*

pause

aw27

On one side people that has never used UASM in his life (but there is always a first time for everything) and on the other side people that has no clue at all about assembly language. Looks funny.  :skrewy:

hutch--

 :biggrin:

Yes you are right and with the amount of crap I have had to listen to in this topic I may not ever get there. Here is a tweaked version done in POASM. I am not really up to date with POASM but its has always been a decent tool

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    MessageBoxA PROTO :QWORD,:QWORD,:QWORD,:QWORD
    ExitProcess PROTO :QWORD

    MessageBox equ <MessageBoxA>
    MB_OK equ <0>

    includelib \masm32\lib64\kernel32.lib
    includelib \masm32\lib64\user32.lib

    t MACRO quoted
      LOCAL text
      LOCAL ptxt
      .data
        text db quoted,0
      .code
      EXITM <ADDR text>
    ENDM

    .code

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

entry_point proc

    sub rsp, 8

    invoke MessageBox,0,t("A MessageBox in POASM"),t(" About"),MB_OK

    invoke ExitProcess,0

entry_point endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    end

aw27

Note that it will build as well with UASM without modification. However to run properly you will need to add OPTION PROC:NONE (it is indeed mentioned in the documentation) or alternatively OPTION PROLOGUE:NONE

TimoVJL

Quote from: hutch-- on July 22, 2019, 05:29:25 AM
Timo,

I think you have mixed up a couple of things, we all know that the entry point is set in the linker but the code for that entry point is in the source code that the assembler processes. Your original comment was a suggestion to use the CRT in the form mainCRTStartup, wmainCRTStartup, WinMainCRTStartup, wWinMainCRTStartup and I made you the comment that it is not needed in the source code of an assembler application.

Steve,
not me, you can read from Microsoft linker documents about those predefined symbols.

May the source be with you

TimoVJL

#20
Quote from: felipe on July 22, 2019, 05:03:12 AM
Quote from: TimoVJL on July 22, 2019, 04:53:49 AM
It seems that i just waste my time here to teach some professionals to update their knowledge of some basic things.
I haven't been a professional programmer in my life, only a hobbyist, but some of my programs are still important part of production line in one factory.
My role was a IT support and a system expert person at that time.
I even created a C code to read Vertex Systems databases.

:biggrin: And you have never learned assembly language?
a joke?
after over 10 years making bug report to software company of bug finding with WinDBG, what you except ?
i think it need more than just assembly language, you must understand a whole system around it.
May the source be with you

fearless

Quote from: hutch-- on July 22, 2019, 04:27:09 AM
I was looking for some of the UASM folks who knew more of the reference material that I have yet to find. All I have so far is some old stuff from the data that Japheth wrote.
There is a pdf in the releases that contains the new stuff: uasm248_ext.pdf or similarly named.

The option for string literals is a nice handy feature

OPTION LITERALS:ON
Then should be able to do this:
invoke MessageBox, NULL, "Bare Bones MessageBox", "The UASM Assembler", MB_OK
Instead of using a macro - for convenience really, but could be useful

invoke MessageBox, NULL, t("Bare Bones MessageBox"), t("The UASM Assembler"), MB_OK
It also supports wide string literals when prefixed with L


The pdf manual does have a lot of interesting new features, lots to explore, and I'm sure they will be useful to many.

hutch--


hutch--

I did try the option but got this result.

UASM v2.49, Jun 21 2019, Masm-compatible assembler.
Portions Copyright (c) 1992-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.

UASM1.asm(44) : Error A2145: INVOKE argument type mismatch: argument 1
UASM1.asm(44) : Error A2145: INVOKE argument type mismatch: argument 2
UASM1.asm: 55 lines, 1 passes, 2 ms, 0 warnings, 2 errors
POLINK: fatal error: File not found: 'UASM1.obj'.
Volume in drive K is disk3_k
Volume Serial Number is 68C7-4DBB

Directory of K:\uasm\test1

File Not Found
Press any key to continue . . .

aw27

@Hutch

> For a string literal to be accepted as such, the corresponding procedure parameter must be defined as PTR.
MessageBoxA PROTO :qword,:ptr,:ptr,:dword

jj2007

Right. That was introduced when somebody tried to pass "a" as the immediate value 97.

hutch--


hutch--

I still have not got rid of the stack twiddle "sub rsp, 8". I have been scanning the PDF file but any FRAME attempt outputs an error.

In MASM I have automatic stack control so I can do this.

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    include \masm32\include64\masm64rt.inc

    .code

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

entry_point proc

    rcall MessageBox,0,"A MessageBox in 64 bit MASM", \
                        "MASM Pure And Simple",MB_OK
    .exit

entry_point endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    end

fearless

try adding the following:

option win64 : 11
option frame : auto
option stackbase : rsp


and although I don't think it's required anymore (except for older versions of UASM) I put a FRAME keyword after the PROC (just for that backward compatibility)

entry_point proc frame

hutch--

Thanks, that worked well.

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    OPTION CASEMAP:NONE
    OPTION LITERALS:ON
    OPTION FRAME:AUTO
    OPTION WIN64:11
    OPTION STACKBASE:RSP

    includelib \masm32\lib64\kernel32.lib
    includelib \masm32\lib64\user32.lib

    MessageBoxA PROTO :QWORD,:PTR,:PTR,:QWORD
    MessageBox equ <MessageBoxA>
    ExitProcess PROTO :QWORD

    close MACRO optvar:=<0>
      invoke ExitProcess,optvar
    ENDM

    MB_OK equ <0>
    NULL equ <0>

    .code

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

entry_point proc

    invoke MessageBox,NULL,"Bare Bones MessageBox"," The UASM Assembler",MB_OK

    close

entry_point endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    end