Author Topic: cant I just replace ml with uasm?  (Read 924 times)

daydreamer

  • Member
  • *****
  • Posts: 1156
  • I also want a stargate
Re: cant I just replace ml with uasm?
« Reply #15 on: February 09, 2020, 02:07:51 AM »
so in what way should I code this instead,so I can use movapd,well more important to be able to use addpd xmm0,compa,without error?
Quote from Flashdance
Nick  :  When you give up your dream, you die
*wears a flameproof asbestos suit*
Gone serverside programming p:  :D
I love assembly,because its legal to write
princess:lea eax,luke
:)

nidud

  • Member
  • *****
  • Posts: 1853
    • https://github.com/nidud/asmc
Re: cant I just replace ml with uasm?
« Reply #16 on: February 09, 2020, 02:33:14 AM »
The source is 64-bit (compa) and the target is 128-bit.

    movapd xmm0,xmmword ptr compa ; mov two 64-bit items from compa to xmm0
    addpd  xmm0,xmmword ptr compa

daydreamer

  • Member
  • *****
  • Posts: 1156
  • I also want a stargate
Re: cant I just replace ml with uasm?
« Reply #17 on: February 09, 2020, 04:24:16 AM »
The source is 64-bit (compa) and the target is 128-bit.

    movapd xmm0,xmmword ptr compa ; mov two 64-bit items from compa to xmm0
    addpd  xmm0,xmmword ptr compa

thanks it works
but isnt it also good to get habit to used xmmword type instead of several real8's or real4's?
LOADPD also would be nice to have
Quote from Flashdance
Nick  :  When you give up your dream, you die
*wears a flameproof asbestos suit*
Gone serverside programming p:  :D
I love assembly,because its legal to write
princess:lea eax,luke
:)

nidud

  • Member
  • *****
  • Posts: 1853
    • https://github.com/nidud/asmc
Re: cant I just replace ml with uasm?
« Reply #18 on: February 09, 2020, 04:45:20 AM »
They are normally defined by STRUCT and UNION

vector  struc
   a    real8 ?
   b    real8 ?
vector  ends

    .data
    v vector { 1.0, 2.0 }

    .code

    movapd xmm0,v
    movsd  xmm0,v.a

LOADPD correspond to _mm_load_pd() defined in emmintrin.h

daydreamer

  • Member
  • *****
  • Posts: 1156
  • I also want a stargate
Re: cant I just replace ml with uasm?
« Reply #19 on: February 09, 2020, 09:04:06 PM »
thanks
maybe use macros like FP8(3.14) could be an option making code more readable too
Quote from Flashdance
Nick  :  When you give up your dream, you die
*wears a flameproof asbestos suit*
Gone serverside programming p:  :D
I love assembly,because its legal to write
princess:lea eax,luke
:)

johnsa

  • Member
  • ****
  • Posts: 799
    • Uasm
Re: cant I just replace ml with uasm?
« Reply #20 on: February 12, 2020, 08:29:19 PM »
In UASM we have built-in structs already defined for _m128, _m256 which you can use as well.. for other asssemblers you'd have to just create those struct/unions yourself but would still be compatible.

daydreamer

  • Member
  • *****
  • Posts: 1156
  • I also want a stargate
Re: cant I just replace ml with uasm?
« Reply #21 on: February 12, 2020, 08:37:35 PM »
thanks johnsa
for loops wont work as I want
examples,I am used to C syntax
Code: [Select]
.for(ecx:ecx<Lmaxmem:ecx++)

.for(esi:esi<maxi:esi++)
Quote from Flashdance
Nick  :  When you give up your dream, you die
*wears a flameproof asbestos suit*
Gone serverside programming p:  :D
I love assembly,because its legal to write
princess:lea eax,luke
:)

habran

  • Member
  • *****
  • Posts: 1220
    • uasm
Re: cant I just replace ml with uasm?
« Reply #22 on: February 12, 2020, 09:26:38 PM »
.for(ecx=Lstartmem:ecx<Lmaxmem:ecx++)
  do something
.endfor


.for(esi=mini:esi<maxi:esi++)
  do something
.endfor

lea esi,mini
.for(:esi<maxi:esi++)
  do something
.endfor

.for(::)
  do something
  .break .if (!eax)
.endfor
Cod-Father

daydreamer

  • Member
  • *****
  • Posts: 1156
  • I also want a stargate
Re: cant I just replace ml with uasm?
« Reply #23 on: February 12, 2020, 10:06:36 PM »
thanks Habran
so variable stepping you just use ecx+stepping,for dwords,real4s,real8s,real10's
Quote from Flashdance
Nick  :  When you give up your dream, you die
*wears a flameproof asbestos suit*
Gone serverside programming p:  :D
I love assembly,because its legal to write
princess:lea eax,luke
:)

habran

  • Member
  • *****
  • Posts: 1220
    • uasm
Re: cant I just replace ml with uasm?
« Reply #24 on: February 12, 2020, 10:52:41 PM »
yes:
rcx+8
ecx+4
rsi+16
ecx--
ecx-4
you can use .continue or .break
.for loop is actually using built in .while but gives you more options to set up variables and increase or decrease counters.
You can use more vars at the same time, like:

.for (rsi=src,rdi=dest,ecx=count:ecx:rsi++,rdi++,ecx--)
   mov al,[rsi]
   mov [rdi],al
.endfor
you get this:
Code: [Select]
000000013F4851D4 48 8B 35 D5 B6 00 00 mov         rsi,qword ptr [src (013F4908B0h)] 
000000013F4851DB 48 8B 3D CE AE 00 00 mov         rdi,qword ptr [dest (013F4900B0h)] 
000000013F4851E2 8B 0D B0 63 00 00    mov         ecx,dword ptr [count (013F48B598h)] 
000000013F4851E8 EB 0C                jmp         WndProc+3Dh (013F4851F6h) 
000000013F4851EA 8A 06                mov         al,byte ptr [rsi] 
000000013F4851EC 88 07                mov         byte ptr [rdi],al 
000000013F4851EE 48 FF C6             inc         rsi 
000000013F4851F1 48 FF C7             inc         rdi 
000000013F4851F4 FF C9                dec         ecx 
000000013F4851F6 85 C9                test        ecx,ecx 
000000013F4851F8 75 F0                jne         WndProc+31h (013F4851EAh) 
Cod-Father

daydreamer

  • Member
  • *****
  • Posts: 1156
  • I also want a stargate
Re: cant I just replace ml with uasm?
« Reply #25 on: February 13, 2020, 12:20:32 AM »
thanks,for loop has always been my favourite loop,and its even better than C version
good,because otherwise before I used bare metal version about the same as code produced by the forloop
Quote from Flashdance
Nick  :  When you give up your dream, you die
*wears a flameproof asbestos suit*
Gone serverside programming p:  :D
I love assembly,because its legal to write
princess:lea eax,luke
:)

jj2007

  • Member
  • *****
  • Posts: 10113
  • Assembler is fun ;-)
    • MasmBasic
Re: cant I just replace ml with uasm?
« Reply #26 on: February 13, 2020, 01:33:28 AM »
I like the Basic one-liners :tongue:
Code: [Select]
  If_ Filter$(L$(), "MACRO", 1, 4) Then For_ each esi in L$(): PrintLine esi ; list all macros in \Masm32\macros\macros.asm

daydreamer

  • Member
  • *****
  • Posts: 1156
  • I also want a stargate
Re: cant I just replace ml with uasm?
« Reply #27 on: February 15, 2020, 07:31:49 AM »
I broke the code, too many switch,for loops???
http://masm32.com/board/index.php?topic=8222.15
 :sad:
Quote from Flashdance
Nick  :  When you give up your dream, you die
*wears a flameproof asbestos suit*
Gone serverside programming p:  :D
I love assembly,because its legal to write
princess:lea eax,luke
:)

habran

  • Member
  • *****
  • Posts: 1220
    • uasm
Re: cant I just replace ml with uasm?
« Reply #28 on: February 15, 2020, 01:40:18 PM »
If you are not using CSTYLE switch don't use .break
only if you specify  CSTYLE than you need it
option SWITCHSTYLE: CSTYLE

you don't need to use:
option SWITCHSTYLE : ASMSTYLE  because it is a default, which doesn't require .break

I did not test your code but with a quick look I saw that you calculate maxi and maxj, so you don't really know what you get and you don't know if numbers are positive or negative, I would at least check what I get and make sure it doesn't overwrite memory.

I would also avoid using several LOCAL variables in one line, I have noticed that assembler get confused there
I would use instead of:     LOCAL maxi:DWORD,maxj:DWORD,istep:DWORD,jstep:DWORD
LOCAL maxi:DWORD
LOCAL maxj:DWORD
LOCAL istep:DWORD
LOCAL jstep:DWORD

it is also more readable


Cod-Father

daydreamer

  • Member
  • *****
  • Posts: 1156
  • I also want a stargate
Re: cant I just replace ml with uasm?
« Reply #29 on: February 18, 2020, 08:11:11 PM »
I have somehow wrecked it
it stopped display assembled in 2 or 3 passes in millisecond
and linker complain about maybe corrupt .obj file
« Last Edit: February 18, 2020, 10:48:51 PM by daydreamer »
Quote from Flashdance
Nick  :  When you give up your dream, you die
*wears a flameproof asbestos suit*
Gone serverside programming p:  :D
I love assembly,because its legal to write
princess:lea eax,luke
:)