News:

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

Main Menu

HASM 2.32 Release

Started by johnsa, May 16, 2017, 09:11:28 PM

Previous topic - Next topic

nidud

#15
deleted

mineiro

Quote from: nidud on May 18, 2017, 02:28:51 AM
Well, hopefully you now understand a bit more on how this works, and here's one of the argument for not using UTF-8 as a default for text mode or other applications where it's not needed:
hello nidud;
And here's one of the argument to use UTF-8 :badgrin: as default for text mode or gui mode on linux instead of windows O.S.
;--- assemble: hasm -elf64 -Fo=test.o test.asm
;--- link:     gcc test.o -o test
.x64
exit proto systemv status:dword
puts proto systemv pchar:ptr

.data
string db "utf8 rulez: áéíóúçãሴ⍅㑖噸枉",0

.code
main PROC SYSTEMV
    invoke puts, addr string
    invoke exit,0
main ENDP

end

We know that whats good to one person cannot be good to another.
I'd rather be this ambulant metamorphosis than to have that old opinion about everything

aw27

Is it possible for UASM to support the Intel MPX instructions?

For example it does not assemble the open source _chkstk.asm that comes with Visual Studio because does not understand
"bnd jb" and "bnd ret". MASM does understand.




jj2007

Bounds registers are exotic stuff, José. Do you have an idea how to use them? Looks interesting, but I'd like to see a concrete example.

Found a manual on MPX here.

BNDMK b, m
Creates LowerBound (LB) and UpperBound (
UB) in
bounds register b.
BNDCL b, r/m
Checks the address of a memory referen
ce or
address in r against the lower bound.
BNDCU b, r/m
Checks the address of a memory referen
ce or
address in r against the upper bound.
BNDCN b, r/m
Checks the address of a memory referen
ce or
address in r against the upper bound in one's
compliment.

johnsa

We added support for the basic BNDn registers and MPX specific instructions in 2.33
We've not really played with them test wise yet, if we've got a concrete example to test it with we can make sure that we've not missed anything, but given MPX only came out with Skylake it's probably not that useful yet in general practice.

BND in that case is a prefix which we've not added yet, but will in the next update.

Basically a range of instructions can use a BND prefix, for MPX enabled code all opcodes that can use BND should, unless you need to specifically override it with a NOBND.
I'm still thinking about how best to implement this particular change as we'll probably want a new OPTION BND:YES/NO from which point the BND is applied automatically.
For NOBND we'll probably want that to act as a new prefix as far as the parser is concerned.

aw27

Quote from: jj2007 on May 21, 2017, 05:44:16 PM
Bounds registers are exotic stuff, José. Do you have an idea how to use them? Looks interesting, but I'd like to see a concrete example.

I have a tiny idea, I would like to experiment more. But basically I just wanted the source of _chkstk to assemble without changes.

aw27

Quote from: johnsa on May 21, 2017, 07:05:17 PM
We added support for the basic BNDn registers and MPX specific instructions in 2.33
We've not really played with them test wise yet, if we've got a concrete example to test it with we can make sure that we've not missed anything, but given MPX only came out with Skylake it's probably not that useful yet in general practice.

BND in that case is a prefix which we've not added yet, but will in the next update.

Basically a range of instructions can use a BND prefix, for MPX enabled code all opcodes that can use BND should, unless you need to specifically override it with a NOBND.
I'm still thinking about how best to implement this particular change as we'll probably want a new OPTION BND:YES/NO from which point the BND is applied automatically.
For NOBND we'll probably want that to act as a new prefix as far as the parser is concerned.

The only concrete example I have is the _chkstk. I will experiment more when I can.

johnsa

We're busy looking into some details as well of exactly how it "should" work and which opcodes are applicable, we should have something for you to test in a day or so.

jj2007

Quote from: aw27 on May 21, 2017, 07:13:48 PMI just wanted the source of _chkstk to assemble without changes.

Where did you find that source? Nothing in my VC folders :(

Here is one but no MPX instructions.

aw27

Quote from: johnsa on May 22, 2017, 02:20:22 AM
We're busy looking into some details as well of exactly how it "should" work and which opcodes are applicable, we should have something for you to test in a day or so.
Great :t

aw27

Quote from: jj2007 on May 22, 2017, 03:20:26 AM
Quote from: aw27 on May 21, 2017, 07:13:48 PMI just wanted the source of _chkstk to assemble without changes.

Where did you find that source? Nothing in my VC folders :(

Here is one but no MPX instructions.
It is in the crt folder of the VC part. However, I pasted it in one of the last messages about the _alloca function.

jj2007

Quote from: aw27 on May 22, 2017, 03:53:06 AMIt is in the crt folder of the VC part. However, I pasted it in one of the last messages about the _alloca function.

There is a link to nidud's version here, but that's the only chkstk.asm I can see in that thread.

aw27

Quote from: jj2007 on May 22, 2017, 06:26:10 AM
but that's the only chkstk.asm I can see in that thread.
It is in message 28, inside the code section is the function _chkstk. Just paste that function in a new file and save it as chkstk.asm and you have it.  :t

jj2007

OK, got it - pasted "as is" below. This is the mysterious "bound jump":

    cmp ecx, eax             ; Is new TOS
    bnd jb cs20              ; in probed page?


If I understand the manual correctly, this would do the job, too:

    cmp ecx, eax         ; Is new TOS
    db 0F2h              ; bnd prefix
    jb cs20              ; in probed page?


QuoteLegacy code does not experience any change in its functionality. Instrumented applications can link with, call into, or be called from legacy software.
::)

_chkstk proc C

_alloca_probe    =  _chkstk

        push    ecx

; Calculate new TOS.

        lea     ecx, [esp] + 8 - 4      ; TOS before entering function + size for ret value
        sub     ecx, eax                ; new TOS (Top of Stack)

; Handle allocation size that results in wraparound.
; Wraparound will result in StackOverflow exception.

        sbb     eax, eax                ; 0 if CF==0, ~0 if CF==1
        not     eax                     ; ~0 if TOS did not wrapped around, 0 otherwise
        and     ecx, eax                ; set to 0 if wraparound

        mov     eax, esp                ; current TOS
        and     eax, not ( _PAGESIZE_ - 1) ; Round down to current page boundary

cs10:
        cmp     ecx, eax                ; Is new TOS
    bnd jb      short cs20              ; in probed page?
        mov     eax, ecx                ; yes.
        pop     ecx
        xchg    esp, eax                ; update esp
        mov     eax, dword ptr [eax]    ; get return address
        mov     dword ptr [esp], eax    ; and put it at new TOS
    bnd ret

; Find next lower page and probe
cs20:
        sub     eax, _PAGESIZE_         ; decrease by PAGESIZE
        test    dword ptr [eax],eax     ; probe page.
        jmp     short cs10

_chkstk endp

aw27

QuoteLegacy code does not experience any change in its functionality. Instrumented applications can link with, call into, or be called from legacy software.::)
That's the point, even if does not do anything I would like it to assemble  :badgrin: