Author Topic: Quick play with UASM  (Read 2211 times)

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 6749
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Quick play with UASM
« Reply #15 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.

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
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

AW

  • Member
  • *****
  • Posts: 2431
  • Let's Make ASM Great Again!
Re: Quick play with UASM
« Reply #16 on: July 22, 2019, 05:49:14 AM »
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--

  • Administrator
  • Member
  • ******
  • Posts: 6749
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Quick play with UASM
« Reply #17 on: July 22, 2019, 05:55:43 AM »
 :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
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

AW

  • Member
  • *****
  • Posts: 2431
  • Let's Make ASM Great Again!
Re: Quick play with UASM
« Reply #18 on: July 22, 2019, 06:11:08 AM »
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

  • Member
  • ***
  • Posts: 476
Re: Quick play with UASM
« Reply #19 on: July 22, 2019, 06:33:50 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

  • Member
  • ***
  • Posts: 476
Re: Quick play with UASM
« Reply #20 on: July 22, 2019, 06:58:57 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.
« Last Edit: July 22, 2019, 04:53:36 PM by TimoVJL »
May the source be with you

fearless

  • Member
  • ***
  • Posts: 469
    • LetTheLightIn
Re: Quick play with UASM
« Reply #21 on: July 22, 2019, 08:00:05 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

Code: [Select]
OPTION LITERALS:ONThen should be able to do this:
Code: [Select]
invoke MessageBox, NULL, "Bare Bones MessageBox", "The UASM Assembler", MB_OKInstead of using a macro - for convenience really, but could be useful

Code: [Select]
invoke MessageBox, NULL, t("Bare Bones MessageBox"), t("The UASM Assembler"), MB_OKIt 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.
fearless

CM690II Case, HX1000 PSU, Asus Z97, Intel i7-4790K, Seidon 120v Cooler, 16GB DDR3, MSI GTX 980TI

My Github  Twitter

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 6749
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Quick play with UASM
« Reply #22 on: July 22, 2019, 10:28:09 AM »
fearless, Gratsie.  :thumbsup:
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 6749
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Quick play with UASM
« Reply #23 on: July 22, 2019, 04:38:09 PM »
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 . . .
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

AW

  • Member
  • *****
  • Posts: 2431
  • Let's Make ASM Great Again!
Re: Quick play with UASM
« Reply #24 on: July 22, 2019, 04:53:23 PM »
@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

  • Member
  • *****
  • Posts: 9782
  • Assembler is fun ;-)
    • MasmBasic
Re: Quick play with UASM
« Reply #25 on: July 22, 2019, 05:43:38 PM »
Right. That was introduced when somebody tried to pass "a" as the immediate value 97.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 6749
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Quick play with UASM
« Reply #26 on: July 22, 2019, 06:29:23 PM »
Works perfect, Gratsie.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 6749
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Quick play with UASM
« Reply #27 on: July 22, 2019, 07:01:24 PM »
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
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

fearless

  • Member
  • ***
  • Posts: 469
    • LetTheLightIn
Re: Quick play with UASM
« Reply #28 on: July 22, 2019, 07:43:57 PM »
try adding the following:

Code: [Select]
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)

Code: [Select]
entry_point proc frame
fearless

CM690II Case, HX1000 PSU, Asus Z97, Intel i7-4790K, Seidon 120v Cooler, 16GB DDR3, MSI GTX 980TI

My Github  Twitter

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 6749
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Quick play with UASM
« Reply #29 on: July 22, 2019, 08:59:37 PM »
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
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy: