Recent Posts

Pages: [1] 2 3 ... 10
1
Game Development / Re: my 100% Assembly game development
« Last post by Siekmanski on Today at 10:01:08 AM »
About time.   :biggrin: :t
2
Game Development / Re: my 100% Assembly game development
« Last post by LordAdef on Today at 08:39:36 AM »
Hey lads, I’m back!
3
The Workshop / Re: Multiply two QWORDs
« Last post by nidud on Today at 07:48:49 AM »
It's an open test-bed Rui, so you can either past the code into an existing file or add a new one. To add a new open the timeit.cmd file and change the following:

procs  equ <for x,<4,0,1,2,3>> ; add functions to test...
...
info_3  db "_mul128",0
info_4  db "Multiply64by64_v3",0

The only external tool needed is Asmc.exe, assumed to be in a PATH folder. If not copy it to the test folder and run the timeit file.
4
The Workshop / Re: Multiply two QWORDs
« Last post by RuiLoureiro on Today at 07:22:07 AM »
Hi nidud,
            you are using the old code. This is the last code i posted tested in reply #30
Code: [Select]
OPTION PROLOGUE:NONE
OPTION EPILOGUE:NONE
Multiply64by64_v3       proc     pX64:DWORD, pY64:DWORD, pZ:DWORD
                        push     ebx
                     push     esi

                     mov      ebx, [esp+12]           ;pX64
                     mov      esi, [esp+16]           ;pY64
                     mov      ecx, [esp+20]           ;pZ

                  ; ----------------------
                  ;    IdxX0*IdxY0
                  ; ----------------------
                     mov      eax, [ebx+IdxX0]
                     mul      dword ptr [esi+IdxY0]
                     mov      [ecx+IdxZ0], eax
                     mov      [ecx+IdxZ1], edx

                  ; ----------------------
                  ;   IdxX0*IdxY1
                  ; ----------------------
                     mov      eax, [ebx+IdxX0]
                     mul      dword ptr [esi+IdxY1]

                     add      eax, [ecx+IdxZ1]
                     mov      [ecx+IdxZ1], eax
                  ;
                     adc      edx, 0
                     mov      [ecx+IdxZ2], edx

                      ; ----------------------
                  ;   IdxX1*IdxY0
                  ; ----------------------
                     mov      eax, [ebx+IdxX1]
                     mul      dword ptr [esi+IdxY0]

                     add      eax, [ecx+IdxZ1]
                     mov      [ecx+IdxZ1], eax
                  ;
                     adc      edx, [ecx+IdxZ2]
                     mov      [ecx+IdxZ2], edx

                  ; ----------------------
                  ;   IdxX1*IdxY1
                  ; ----------------------
                     mov      eax, [ebx+IdxX1]
                     mul      dword ptr [esi+IdxY1]

                     add      eax, [ecx+IdxZ2]
                     mov      [ecx+IdxZ2], eax
                  ;
                     adc      edx, 0
                     mov      [ecx+IdxZ3], edx

                     pop      esi
                     pop      ebx
                     ret      12
Multiply64by64_v3       endp
OPTION PROLOGUE:PrologueDef
OPTION EPILOGUE:EpilogueDef
5
The Workshop / Re: Multiply two QWORDs
« Last post by nidud on Today at 06:57:40 AM »
Here's a 32-bit benchmark test split in two where each algo is called with the same arguments and return value. They both use qword args and the extended version return value in a pointer to a 128-bit buffer.

I added the FPU version in the first test. It fails the evaluation test and the timing is rather slow.
Code: [Select]
Intel(R) Core(TM) i5-6500T CPU @ 2.50GHz (AVX2)
----------------------------------------------
error: 2.asm -- 8000000000000000 FFFFFFFFFFFFFFFE
error: 2.asm -- 8000000000000000 7FFFFFFFFFFFFFFD
hit any key to continue...
mul(2, 0x7FFFFFFFFFFFFFFF)
-- test(0)
    26152 cycles, rep(4000), code( 35) 0.asm: MultQQ
    29352 cycles, rep(4000), code( 52) 1.asm: Intel
  1223342 cycles, rep(4000), code( 25) 2.asm: *fmul
-- test(1)
    26135 cycles, rep(4000), code( 35) 0.asm: MultQQ
    29322 cycles, rep(4000), code( 52) 1.asm: Intel
  1219123 cycles, rep(4000), code( 25) 2.asm: *fmul
-- test(2)
    26106 cycles, rep(4000), code( 35) 0.asm: MultQQ
    28838 cycles, rep(4000), code( 52) 1.asm: Intel
  1220885 cycles, rep(4000), code( 25) 2.asm: *fmul

total [0 .. 2], 1++
    78393 cycles 0.asm: MultQQ
    87512 cycles 1.asm: Intel
  3663350 cycles 2.asm: *fmul
hit any key to continue...
mul(2, 2)
-- test(0)
    26313 cycles, rep(4000), code( 35) 0.asm: MultQQ
    19214 cycles, rep(4000), code( 52) 1.asm: Intel
   120348 cycles, rep(4000), code( 25) 2.asm: *fmul
-- test(1)
    26176 cycles, rep(4000), code( 35) 0.asm: MultQQ
    19242 cycles, rep(4000), code( 52) 1.asm: Intel
   113600 cycles, rep(4000), code( 25) 2.asm: *fmul
-- test(2)
    26126 cycles, rep(4000), code( 35) 0.asm: MultQQ
    19211 cycles, rep(4000), code( 52) 1.asm: Intel
   114309 cycles, rep(4000), code( 25) 2.asm: *fmul

total [0 .. 2], 1++
    57667 cycles 1.asm: Intel
    78615 cycles 0.asm: MultQQ
   348257 cycles 2.asm: *fmul
hit any key to continue...

Extended version:
Code: [Select]
Intel(R) Core(TM) i5-6500T CPU @ 2.50GHz (AVX2)
----------------------------------------------
mul(2, 2)
-- test(0)
   190192 cycles, rep(5000), code(228) 0.asm: doMul
    82247 cycles, rep(5000), code( 89) 1.asm: Multiply64by64
    75484 cycles, rep(5000), code( 89) 2.asm: u64_mul
    41003 cycles, rep(5000), code(102) 3.asm: _mul128
-- test(1)
   189909 cycles, rep(5000), code(228) 0.asm: doMul
    82896 cycles, rep(5000), code( 89) 1.asm: Multiply64by64
    75653 cycles, rep(5000), code( 89) 2.asm: u64_mul
    41025 cycles, rep(5000), code(102) 3.asm: _mul128
-- test(2)
   191044 cycles, rep(5000), code(228) 0.asm: doMul
    81820 cycles, rep(5000), code( 89) 1.asm: Multiply64by64
    75581 cycles, rep(5000), code( 89) 2.asm: u64_mul
    40820 cycles, rep(5000), code(102) 3.asm: _mul128

total [0 .. 2], 1++
   122848 cycles 3.asm: _mul128
   226718 cycles 2.asm: u64_mul
   246963 cycles 1.asm: Multiply64by64
   571145 cycles 0.asm: doMul
hit any key to continue...
mul(2, 0x7FFFFFFFFFFFFFFF)
-- test(0)
   184953 cycles, rep(5000), code(228) 0.asm: doMul
    81843 cycles, rep(5000), code( 89) 1.asm: Multiply64by64
    76369 cycles, rep(5000), code( 89) 2.asm: u64_mul
    72970 cycles, rep(5000), code(102) 3.asm: _mul128
-- test(1)
   185149 cycles, rep(5000), code(228) 0.asm: doMul
    83007 cycles, rep(5000), code( 89) 1.asm: Multiply64by64
    75424 cycles, rep(5000), code( 89) 2.asm: u64_mul
    72798 cycles, rep(5000), code(102) 3.asm: _mul128
-- test(2)
   185117 cycles, rep(5000), code(228) 0.asm: doMul
    82571 cycles, rep(5000), code( 89) 1.asm: Multiply64by64
    75739 cycles, rep(5000), code( 89) 2.asm: u64_mul
    72958 cycles, rep(5000), code(102) 3.asm: _mul128

total [0 .. 2], 1++
   218726 cycles 3.asm: _mul128
   227532 cycles 2.asm: u64_mul
   247421 cycles 1.asm: Multiply64by64
   555219 cycles 0.asm: doMul
hit any key to continue...
6
The Campus / Set Color On a Static When Mouse is Over It
« Last post by blue_devil on Today at 03:47:59 AM »
Hello

I want my static (a.k.a label) to get colored when mouse cursor is on it. But also i want it to be a hyperlink and change the arrow cursor to "hand" cursor.
So here is my code:
I changed @gunner's code for myself:
SubClass:
Code: [Select]
ColorTheStatic proc hSTC:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
LOCAL rect:RECT

.if uMsg==WM_MOUSEMOVE
    invoke  GetClientRect, hSTC, addr rect
invoke  GetCapture
;#####  Make sure the mouse is in our control
.if eax != hSTC
mov bMouseOver, TRUE
invoke  SetCapture, hSTC
.endif
mov edx,lParam
movzx eax,dx
shr edx,16
.if eax > rect.right || edx > rect.bottom
    ;#####  moved out of control
mov bMouseOver, FALSE
invoke  ReleaseCapture
.endif
invoke InvalidateRect,hSTC,NULL,TRUE
invoke UpdateWindow,hSTC
ret
.elseif uMsg==WM_LBUTTONUP
invoke InvalidateRect,hSTC,NULL,TRUE
invoke UpdateWindow,hSTC
invoke  GetWindowLong, hSTC, GWL_USERDATA
invoke  ShellExecute, hMain, offset szShellOpen, eax, NULL, NULL, SW_SHOWNORMAL
ret
.elseif uMsg==WM_SETCURSOR
invoke LoadCursor,NULL,IDC_HAND
invoke SetCursor, eax

.else
invoke CallWindowProc, lpPrevWndFunc, hSTC, uMsg, wParam, lParam
ret
.endif

xor eax, eax
ret

ColorTheStatic endp

The WindowProc:
Code: [Select]
PencereIslemi proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM

mov eax,hWin
mov hMain,eax
mov eax,uMsg
.if eax==WM_INITDIALOG
invoke GetDlgItem,hWin,IDC_STCMAIL
mov hStcMail,eax
invoke  SetWindowLong, eax, GWL_USERDATA, offset SCTemail
invoke SetWindowLong,hStcMail,GWL_WNDPROC,ADDR ColorTheStatic
mov lpPrevWndFunc,eax

invoke GetDlgItem,hWin,IDC_STCLNK
mov hStcLink,eax
invoke  SetWindowLong, eax, GWL_USERDATA, offset SCTweb
invoke SetWindowLong,hStcLink,GWL_WNDPROC,ADDR ColorTheStatic
mov lpPrevWndFunc,eax

    invoke  GetSysColorBrush,COLOR_HIGHLIGHT ; COLOR_3DFACE
    mov     hBrush, eax
.elseif eax==WM_COMMAND

.elseif eax==WM_CTLCOLORSTATIC
mov     ecx, hStcMail
mov     edx, hStcLink
.if ecx == lParam || edx == lParam
.if bMouseOver
mov eax, Red
.else
    mov     eax, Blue
.endif
invoke  SetTextColor, wParam, eax
invoke  SetBkMode, wParam, TRANSPARENT
mov eax, hBrush
.endif
INVOKE GetSysColor, COLOR_BTNFACE
mov hBrush,eax
INVOKE CreateSolidBrush, hBrush
ret
       
.elseif eax==WM_CLOSE
invoke  DeleteObject, hBrush
invoke EndDialog,hWin,0
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret

PencereIslemi endp

I also Attached my source : ColorStaticOnMouseOver.zip
And two other sources which are awesome and working.

My code is also working but i have questions?
1. Gunner sends WM_SETFONT message via SendMessage API. Instead i use InvalidateRect API. Because i don't want to change fonts. Is my code OK? (Please don't say"hey if it works dont ask why  :bgrin:")
Quote
https://www.dreamincode.net/forums/topic/241669-masm-creating-a-hyperlink/
2. If you check Hyperlink source, the subclass is big and very functional. It is ok to use but i need a simpler solution.I want a lightweight code to color the static when mouse is on it and de-color when mouse is not on it. Is the code above ok for it?
Quote
http://masm32.com/board/index.php?topic=1031.msg12171#msg12171
7
ASMC Development / Re: Large integers and floats
« Last post by nidud on September 19, 2018, 10:17:03 PM »
Added support for invoke(_int128) in syscall. OWORD will span registers and REAL16 (and floats) will use xmm.

    __int128    typedef oword
    __float128  typedef real16

Three 128-bit register arguments may be used:

p1  proc syscall a1:__int128, a2:__int128, a3:__int128

    mov rax,a1 ; RDI: high64 in RSI
    mov rax,a2 ; RDX: high64 in RCX
    mov rax,a3 ; R8:  high64 in R9
    ret
p1  endp


In addition to six 128-bit xmm arguments:
p2  proc syscall a1:__int128, a2:__int128, a3:__int128, a4:__float128, a5:__float128, a6:__float128

    p1(a1, a2, a3) ; no params set
    movaps xmm0,a4 ; xmm0
    movaps xmm0,a5 ; xmm1
    movaps xmm0,a6 ; xmm2
    ret
p2  endp


Spanning of args, const and memory. Negative values extends to HIGH64 if sign are used and value not zero:

    .data
    x __int128 0
...
    p1( 0, 1, 2 )
*    mov r8d, 2
*    xor r9d, r9d
*    mov edx, 1
*    xor ecx, ecx
*    xor edi, edi
*    xor esi, esi
    p1( 0x0000000000000000FFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF0000000000000000,
        0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF )
*    mov r8, low64 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
*    mov r9, high64 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
*    xor edx, edx
*    mov rcx, high64 0xFFFFFFFFFFFFFFFF0000000000000000
*    mov rdi, low64 0x0000000000000000FFFFFFFFFFFFFFFF
*    xor esi, esi
    p1( -0, -1, x )
*    mov r8, qword ptr x
*    mov r9, qword ptr x[8]
*    mov rdx, low64 -1
*    mov rcx, -1
*    xor edi, edi
*    xor esi, esi
8
The Soap Box / Re: Current Assembly Language Resources
« Last post by Raistlin on September 19, 2018, 08:50:34 PM »
OK here's some more FREE E-book/online resources, all written (republished and edited) after at-least 2006, ASM feasibility indistinct
but these with more of a GRAPHICS programming flair
- maybe activities by Siekmanski, AW27, fearless and daydreamer on the sub-forums is rubbing off on me.... :bgrin:

Michael Abrash's Graphics Programming Black Book - by Michael Abrash - Coriolis Group Books
https://github.com/jagregory/abrash-black-book

PC Assembly Language by Paul A. Carter
http://pacman128.github.io/pcasm/

OpenGL Programming Guide
http://www.glprogramming.com/red/

Programming Vertex, Geometry, and Pixel Shaders - by Wolfgang Engel, et al - Screenshots by Alan Wake - courtesy of Remedy Entertainment
https://www.academia.edu/24772316/Programming_Vertex_Geometry_and_Pixel_Shaders_Screenshots_of_Alan_Wake_courtesy_of_Remedy_Entertainment

Pixel Shaders: An Interactive Introduction to Graphics Programming
http://pixelshaders.com/

The Cg Tutorial: The Definitive Guide to Programmable Real-Time Graphics by Randima Fernando, Mark J. Kilgard
http://developer.download.nvidia.com/CgTutorial/cg_tutorial_chapter01.html

Learning Modern 3D Graphics Programming by Jason L. McKesson
http://www.cse.chalmers.se/edu/year/2017/course/TDA361/LearningModern3DGraphicsProgramming.pdf

Computer Graphics Edited by Nobuhiko Mukai
https://www.intechopen.com/books/computer-graphics

9
The Campus / Re: Need advice on learning 32-bit programming
« Last post by jj2007 on September 19, 2018, 07:16:29 PM »
Hi Michael,

I just discovered A Tiny Guide to Programming in 32-bit x86 Assembly Language by Adam Ferrari. Very old but very well written and absolutely valid for 32-bit assembly. For example, on page 15 you'll find a nice explanation of the stack frame. Enjoy ;-)
10
The Workshop / Re: Multiply two QWORDs
« Last post by AW on September 19, 2018, 03:39:16 PM »

    mov rax,0x1122334455667788
    mov rcx,0x99aabbccddeeff00
    mul rcx
    printf("%#I64x%I64x\n", rdx, rax)


Amazing serendipity after countless tries and fails! Congratulations!  :t
Pages: [1] 2 3 ... 10