Recent Posts

Pages: [1] 2 3 ... 10
The Workshop / Re: My third 64 bit console app...
« Last post by felipe on Today at 04:15:23 AM »
Maybe it is worth using the fixed values, but not to cause every time the GetStdHandle function?

Sounds ok, but maybe a little risky?  :idea:

Now you know why I bothered to write an adjustable stackframe macro for procedure entry and exit.

I know is complicated now, even with a lot of help it will take me some time to handle this... :biggrin:

@mineiro: I liked your explanations. But i'm a little confused with how you are using the terms even and odd, there. I don't know how would be possible you get the rsp with an odd value, if is always decremented by 8 and it starts with a multiple of 8. Maybe you are using this terms to denote 16 byte aligned and not 16 byte aligned?  :idea:

Thanks to all.  :icon14:
Game Development / Re: Fast Multimedia Timer for Games and Demos
« Last post by Siekmanski on Today at 04:10:00 AM »
Game Development / Re: Fast Multimedia Timer for Games and Demos
« Last post by LordAdef on Today at 03:53:55 AM »
Hi Marinus!
So, I modified your first timing routine into a multi-timer for code profiling. It's still your original code,I simply made a structure from all globals so I could save individual timings in various part of the code. I intend to plot them later.
Would you review and polish it for me?
Game Development / Re: 64-bit DirectX 11
« Last post by LordAdef on Today at 03:48:30 AM »
Hi AW, nice!
Concerning your DMath lib, what do you use for 32 bits?
The Campus / Re: converting 32 bit code to 64 bit
« Last post by daydreamer on Today at 02:59:39 AM »
Isn't it best to start learn to code 64bit with new mindset, similar to have different mindset when coding SIMD?
And is it not easier to code a 64bit program. From beginning than think in terms of translate 32bit to 64bit?
Similar to you train English and at one point you start to think in English
(for us who don't have English as native language)
After enough 64bit exercises, you adapt to the 64bit ways
The Workshop / Re: cr0 register and assembler in line (VS C++)
« Last post by AW on Today at 01:38:54 AM »
That's what I thought.
The Campus / Re: converting 32 bit code to 64 bit
« Last post by zedd151 on Today at 01:33:06 AM »

From the main Masm include file ( in VS:
This is defined in included in the sample.

That's cheating.    :P     :lol:
Tools & Toys / Console version to set the exe sub system
« Last post by hutch-- on Today at 12:39:46 AM »
This is one of the apps I needed the word tokeniser for. As a console app most of the code is checking the command line arguments, changing the subsystem is in fact very simple.

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

    include \masm32\include64\


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

entry_point proc

    LOCAL pcmd  :QWORD
    LOCAL parr  :QWORD                      ; array pointer
    LOCAL arrm[256] :QWORD                  ; array memory
    LOCAL acnt  :QWORD
    LOCAL pfile :QWORD
    LOCAL pOpt  :QWORD
    LOCAL .r15  :QWORD
    LOCAL ssys  :QWORD
    LOCAL peImage :QWORD
    LOCAL flen  :QWORD
    LOCAL bwrt  :QWORD

    mov .r15, r15

    mov pcmd, rv(cmd_tail)                  ; get the command tail
    mov parr, ptr$(arrm)                    ; get array pointer

    .if len(pcmd) == 0                      ; test length for missing command line
      conout "Missing command line",lf
      rcall help
      waitkey                               ; pause to show error
      jmp bye

    rcall wordtok,pcmd,parr,44              ; tokenise text using ascii 44 ( , ) as delimiter
    mov acnt, rax                           ; get the arg count

    cmp acnt, 2                             ; exit on incorrect arg count
    je @F
    conout "Incorrect argument count",lf
    rcall help
    waitkey                                 ; pause to show error
    jmp bye

    mov r15, parr
    mrm pfile, QWORD PTR [r15]              ; load file name address into pointer
    rcall szTrim,pfile                      ; trim any junk

    test rv(exist,pfile), rax               ; test if the file exists
    jnz @F
    conout "Cannot find that file",lf
    rcall help
    waitkey                                 ; pause to show error
    jmp bye

    mrm pOpt, QWORD PTR [r15+8]             ; load the subsys option text
    rcall szUpper,pOpt                      ; set as upper case
    rcall szTrim,pOpt                       ; trim any junk

    test rv(szCmp,pOpt,"CONSOLE"), rax
    jz @F
    mov ssys, 3
    jmp setimage
    test rv(szCmp,pOpt,"WINDOWS"), rax
    jz invalid
    mov ssys, 2
    jmp setimage

    conout "Invalid subsystem option",lf
    rcall help
    waitkey                                 ; pause to show error
    jmp bye

    mov peImage, loadfile(pfile)            ; read file from disk
    mov flen, rcx
    rcall mod_pe,peImage,ssys               ; set the sub system
    mov bwrt, savefile(pfile,peImage,flen)  ; write file back to disk

    mfree peImage                           ; release the file memory

    .if ssys == 2
      conout pfile," set to subsys WINDOWS",lf
      conout pfile," set to subsys CONSOLE",lf

    mov r15, .r15

entry_point endp

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

 mod_pe proc pe_image:QWORD,subsys:QWORD

    mov r11, pe_image                                   ; load PE image into r11
    mov edx, (IMAGE_DOS_HEADER PTR [r11]).e_lfanew      ; get the PE header offset
    add r11, rdx                                        ; add it to r11

  ; ------------------------------------------
  ; change the optional header Subsystem value
  ; ------------------------------------------
    .if subsys == 2
      mov (IMAGE_NT_HEADERS PTR [r11]).OptionalHeader.Subsystem, 2    ; WINDOWS
      mov (IMAGE_NT_HEADERS PTR [r11]).OptionalHeader.Subsystem, 3    ; CONSOLE


 mod_pe endp

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

 help proc

      hlpmsg db 13,10,"subsys.exe - set PE subsystem",13,10
             db "  OPTIONS : 1. executable file name, file must exist",13,10
             db "            2. subsystem - either WINDOWS or CONSOLE",13,10,13,10
             db "  EXAMPLE : subsys yourfile.exe,CONSOLE",13,10,13,10
             db "     NOTE : the comma delimiter is required between",13,10
             db "            the file name and the subsystem option",13,10,0
      phelp dq hlpmsg

    conout phelp,lf


 help endp

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

Game Development / 64-bit DirectX 11
« Last post by AW on May 25, 2018, 11:49:29 PM »
I attach a 64-bit DirectX 11 demo with source.
It includes a 64-bit DirectX 11 library (probably the MASM first). It was inspired by Siekmanski excellent work for DirectX 9, 32-bit.
It includes also my DMath library in static form (which I had never published before this way). As we know it is not possible to use DirectXMath within MASM, so DMath is the best bet because it covers the whole DirectXMath and is completely compatible.

This is not a complete work, but I can't promise I will pursue it.
The demo is of middle level difficulty and is based on lesson 11 of

The Campus / Re: converting 32 bit code to 64 bit
« Last post by nidud on May 25, 2018, 11:31:38 PM »

From the main Masm include file ( in VS:

    rax equ <eax>
    rbx equ <ebx>
    rcx equ <ecx>
    rdx equ <edx>
    rdi equ <edi>
    rsi equ <esi>
    rbp equ <ebp>
    rsp equ <esp>

This is defined in included in the sample.
Pages: [1] 2 3 ... 10