Author Topic: Another simple programs...  (Read 275 times)

felipe

  • Member
  • ***
  • Posts: 279
  • I love assembly language programming.
Another simple programs...
« on: May 02, 2017, 09:58:04 AM »
I hope there's no problems for posting so simple codes (i'm just learning) here, but if there is, please let me know.

So these two funny programs (at least they are funny for me) would do this: The program named 'left' would change your mouse buttons to a lefthand configuration. The program named 'right' would restore the default configuration (the opposed if you are a lefthand user with the 'normal' configuration of the mouse buttons already changed.)

Give it a try if you want, it's funny!  :biggrin:  :t  :icon14:  :icon13:   :lol:

LEFT:

Code: [Select]
             
                .386
                .model  flat,stdcall
                option  casemap:none
                include c:\masm32\include\windows.inc
                include c:\masm32\include\user32.inc
                include c:\masm32\include\kernel32.inc
                includelib c:\masm32\lib\kernel32.lib
                includelib c:\masm32\lib\user32.lib

                .data

                .code

start:
main            proc
                call    changebut
                call    ExitProcess
main            endp
               

changebut       proc
                push    SPIF_UPDATEINIFILE          ; Updates de user profile.   
                push    0                           ; Null.
                push    TRUE                        ; Change the meanings of the buttons.   
                push    SPI_SETMOUSEBUTTONSWAP      ; This it's what we want to do. 
                call    SystemParametersInfo        ; Windows will do it.
                ret 
changebut       endp

                end     main

RIGHT:

Code: [Select]
     
                .386
                .model  flat,stdcall
                option  casemap:none
                include c:\masm32\include\windows.inc
                include c:\masm32\include\user32.inc
                include c:\masm32\include\kernel32.inc
                includelib c:\masm32\lib\kernel32.lib
                includelib c:\masm32\lib\user32.lib

                .data

                .code

start:
main            proc
                call    changebut
                call    ExitProcess
main            endp
               

changebut       proc
                push    SPIF_UPDATEINIFILE          ; Updates de user profile.   
                push    0                           ; Null.
                push    FALSE                       ; Change the meanings of the buttons.   
                push    SPI_SETMOUSEBUTTONSWAP      ; This it's what we want to do. 
                call    SystemParametersInfo        ; Windows will do it.
                ret 
changebut       endp

                end     main
Felipe.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 4807
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Another simple programs...
« Reply #1 on: May 02, 2017, 11:59:54 AM »
Hi felipe,

No problems at all, you are doing it the right way, small examples that do one thing at a time with clear predictable results. I have one suggestion for you, unless you are using a very old machine, you don't have to restrict MASM to only using 386 instructions. Try this as it allows you to use the later instructions.

    .686p                           ; create 32 bit code
    .mmx
    .xmm
    .model flat, stdcall            ; 32 bit memory model
    option casemap :none            ; case sensitive

hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

felipe

  • Member
  • ***
  • Posts: 279
  • I love assembly language programming.
Re: Another simple programs...
« Reply #2 on: May 02, 2017, 10:33:28 PM »
Thanks a lot Hutch!  :t
Felipe.

jj2007

  • Member
  • *****
  • Posts: 7541
  • Assembler is fun ;-)
    • MasmBasic
Re: Another simple programs...
« Reply #3 on: May 03, 2017, 12:38:03 AM »
Minor point: Instead of
  c:\masm32\
use
  \masm32\

... so that people who are using e.g. D:\Masm can test your code immediately.

felipe

  • Member
  • ***
  • Posts: 279
  • I love assembly language programming.
Re: Another simple programs...
« Reply #4 on: May 03, 2017, 03:44:29 AM »
Good point JJ, thanks a lot!  :t
Felipe.