left click interrupt proc or macro

Started by bcddd214, December 07, 2011, 09:18:19 PM

Previous topic - Next topic

FORTRANS

Quote from: bcddd214 on December 12, 2011, 01:10:19 PM
still trying to figure out how to get rid of the error at line 93/94 with  shr cx, 3
what is shr and how do I use it correctly?

Hi,

   MASM defaults to the 8086/88 instruction set.  SHR CX,3 is then
illeagle.  You need to put a .386 (or .186 or similar) like MichaelW
did.  Or you can use three SHR CX,1 instead.  Fun eh?  SHR is
the SHift Right instruction.

HTH,

Steve N.

bcddd214

.186 errors really bad but .386 did better
I found another these on the form as possible solutions
.386p
.model      small,Flat,StdCALL
.stack      100h
OPTION CaseMap:None
.MMX
.XMM

but now getting really bad 32 bit errors. I am trying to stay in 16 bit for simplicity and can't figure out what is trying to flip me over to 32 bit and making my life even more difficult...   :)

Errors

Assembling: newDOS2.asm
newDOS2.asm(48) : error A2199: .STARTUP does not work with 32-bit segments
newDOS2.asm(119) : error A2198: .EXIT does not work with 32-bit segments
newDOS2.asm(54) : error A2022: instruction operands must be the same size
newDOS2.asm(69) : error A2022: instruction operands must be the same size
newDOS2.asm(113) : error A2022: instruction operands must be the same size

*********************************************************************

TITLE The New DOS

.386p
.model      small,Flat,StdCALL
.stack      100h
OPTION CaseMap:None
.MMX
.XMM

; Set the window variable framework
WINDESC      STRUCT
         upperRow      BYTE   ?
         leftCol         BYTE   ?
         lowerRow      BYTE   ?
         rightCol         BYTE   ?
         foreColor      BYTE   ?
         backColor      BYTE   ?
WINDESC      ENDS

; Not really sure about this one
exit      MACRO
         mov            ax, 4C00h
         int            21h
         ENDM

;set variables         
.data
   application   WINDESC         <05h, 05h, 15h, 45h, 07h, 10h>
    msgNoMouseDriver db "no mouse driver",13,10,"$"
    msgPressAnyKey   db "press any key to exit",13,10,"$"
;==============================================================================

    ;-------------------------------------------------------------------
    ; With MASM the mouse driver functions are called with the function
    ; number in AX, and depending on the function, the return values may
    ; be in AX, BX, CX, or DX.
    ;-------------------------------------------------------------------

    ;----------------------------------------------------------------------
    ; Check for a mouse driver. Use the DOS Get Interrupt Vector function
    ; to get the interrupt 33h vector. If the segment address is zero then
    ; the mouse driver is not installed.
    ;----------------------------------------------------------------------

.code

;mouse driver
.startup
         mov ax,3533h
         int 21h
         mov ax, es
         .IF ax == 0
            mov ah, 9
            mov dx, OFFSET msgNoMouseDriver
            int 21h
         jmp myExit
.ENDIF

    ;-------------------------------------------------------------------------
    ; Attempt to reset the mouse driver by calling the Mouse Reset And Status
    ; function. If the reset fails, indicated by the function returning zero,
    ; then the mouse driver is not installed.
    ;-------------------------------------------------------------------------

         xor ax, ax
         int 33h
         .IF ax == 0
            mov ah, 9
            mov dx, OFFSET msgNoMouseDriver
            int 21h
            jmp myExit
.ENDIF

    ;------------------------------------------------------------------
    ; Show the mouse cursor by calling the Mouse Show Cursor function.
    ;------------------------------------------------------------------

         mov ax, 1
         int 33h

    ;-----------------------------------------------------------------------
    ; Loop, calling the Mouse Get Button Status And Mouse Position function
    ; until the user presses the left mouse button with the mouse cursor
    ; at character coordinate 0,0 (the first character at the upper-left
    ; corner of screen). The function returns the button status in BX, the
    ; horizontal cursor coordinate in CX, and the vertical cursor coordinate
    ; in DX. The button status for the left mouse button is returned in
    ; bit 0 of BX, and the status for the right mouse button in bit 1, with
    ; the bit set if the button is pressed or cleared if the button is
    ; released. The cursor coordinates are returned as mouse-driver virtual-
    ; screen coordinates, where the virtual screen for most of the display
    ; modes is 640x200. For the 80x25 character (AKA "text") modes you
    ; convert the virtual-screen coordinates to character coordinates by
    ; simply dividing the virtual-screen coordinates by 8.
    ;-----------------------------------------------------------------------

  @@:
         mov ax, 3
         int 33h
         .IF bx & 1        ; left mouse button is pressed
            shr cx, 3
            shr dx, 3
         .IF cx || dx  ; mouse cursor not over character 0,0 so keep looping
            jmp @B
.ENDIF
.ELSE
         jmp @B        ; left mouse button not pressed so keep looping
.ENDIF

myExit:

         mov ah, 9
         mov dx, OFFSET msgPressAnyKey
         int 21h

         xor ah, ah
         int 16h

.exit
end


;setting the cursor position
curpos      PROC
         push         bp
         mov            bp, sp
         push         ax
         push         bx
         push         dx
         
         mov            ax, 0200h
         mov            bh, 0
         mov            dx, [bp+4]
; interrupt
         int            10h
         
         pop            dx
         pop            bx
         pop            ax
         pop            bp
         ret            2
curpos      ENDP


;still unused
putchar      PROC
         push         bp
         mov            bp, sp
         push         ax
         push         bx
         push         cx
         push         dx
         

         pop            dx
         pop            cx
         pop            bx
         pop            ax
         pop            bp
         ret            2
putchar      ENDP


getchar      PROC
         mov            ah,00h
         int            16h
         ret
getchar    ENDP

;window construction
makewin      PROC
         push         bp
         mov            bp, sp
         push         ax
         push         bx
         push         cx
         push         dx
         push         si
         
         mov            si, [bp+4]
         
         mov            ax, 0600h
         mov            bh, (WINDESC PTR[si]) .backColor
         mov            ch, (WINDESC PTR[si]) .upperRow
         mov            cl, (WINDESC PTR[si]) .leftCol
         mov            dh, (WINDESC PTR[si]) .lowerRow
         mov            dl, (WINDESC PTR[si]) .rightCol
;interrupt
         int            10h
         
         push         cx
         call         curpos
         
         pop            si
         pop            dx
         pop            cx
         pop            bx
         pop            ax
         pop            bp
         ret            2
;         jmp   short      main
makewin      ENDP

main      PROC
         mov            ax, @data
         mov            ds, ax
         
         mov            ax, OFFSET application
         push         ax
         call         makewin
         call         getchar
         exit
main      ENDP

         end            main

bcddd214

anyone know how to make shr or shift right work?

mineiro

TITLE The New DOS
.model      small
.386
.stack      100h


;mouse driver
mouse proc

         mov ax,3533h
         int 21h
         mov ax, es
         .IF ax == 0
            mov ah, 9
            mov dx, OFFSET msgNoMouseDriver
            int 21h
         jmp myExit
.ENDIF

    ;-------------------------------------------------------------------------
    ; Attempt to reset the mouse driver by calling the Mouse Reset And Status
    ; function. If the reset fails, indicated by the function returning zero,
    ; then the mouse driver is not installed.
    ;-------------------------------------------------------------------------

         xor ax, ax
         int 33h
         .IF ax == 0
            mov ah, 9
            mov dx, OFFSET msgNoMouseDriver
            int 21h
            jmp myExit
.ENDIF

    ;------------------------------------------------------------------
    ; Show the mouse cursor by calling the Mouse Show Cursor function.
    ;------------------------------------------------------------------

         mov ax, 1
         int 33h

    ;-----------------------------------------------------------------------
    ; Loop, calling the Mouse Get Button Status And Mouse Position function
    ; until the user presses the left mouse button with the mouse cursor
    ; at character coordinate 0,0 (the first character at the upper-left
    ; corner of screen). The function returns the button status in BX, the
    ; horizontal cursor coordinate in CX, and the vertical cursor coordinate
    ; in DX. The button status for the left mouse button is returned in
    ; bit 0 of BX, and the status for the right mouse button in bit 1, with
    ; the bit set if the button is pressed or cleared if the button is
    ; released. The cursor coordinates are returned as mouse-driver virtual-
    ; screen coordinates, where the virtual screen for most of the display
    ; modes is 640x200. For the 80x25 character (AKA "text") modes you
    ; convert the virtual-screen coordinates to character coordinates by
    ; simply dividing the virtual-screen coordinates by 8.
    ;-----------------------------------------------------------------------

  @@:
         mov ax, 3
         int 33h
         .IF bx & 1        ; left mouse button is pressed
            shr cx, 3
            shr dx, 3
         .IF cx || dx  ; mouse cursor not over character 0,0 so keep looping
            jmp @B
.ENDIF
.ELSE
         jmp @B        ; left mouse button not pressed so keep looping
.ENDIF

myExit:

         mov ah, 9
         mov dx, OFFSET msgPressAnyKey
         int 21h

         xor ah, ah
         int 16h

ret
;.exit
;end
mouse endp



main      PROC
         mov            ax, @data
         mov            ds, ax
         
         mov            ax, OFFSET application
         push         ax
         call         makewin
         call mouse
;         call         getchar
         exit
main      ENDP

         end            main



bcddd214

Here is my code:
http://pastebin.com/uWuTGrSv


and here is the same errors. I would really appreciate getting this to compile so I can move on...    :(


This is compiling in 32bit
Assembling: newDOS2.asm
newDOS2.asm(136) : error A2155: cannot use 16-bit register with a 32-bit address

newDOS2.asm(183) : error A2155: cannot use 16-bit register with a 32-bit address

newDOS2.asm(186) : error A2155: cannot use 16-bit register with a 32-bit address

newDOS2.asm(187) : error A2155: cannot use 16-bit register with a 32-bit address

newDOS2.asm(188) : error A2155: cannot use 16-bit register with a 32-bit address

newDOS2.asm(189) : error A2155: cannot use 16-bit register with a 32-bit address

newDOS2.asm(190) : error A2155: cannot use 16-bit register with a 32-bit address

newDOS2.asm(56) : error A2022: instruction operands must be the same size
newDOS2.asm(71) : error A2022: instruction operands must be the same size
newDOS2.asm(115) : error A2022: instruction operands must be the same size
newDOS2.asm(211) : error A2022: instruction operands must be the same size
newDOS2.asm(208) : error A2004: symbol type conflict

and this is in 16 bit

Assembling: newDOS2.asm
newDOS2.asm(136) : error A2155: cannot use 16-bit register with a 32-bit address

newDOS2.asm(183) : error A2155: cannot use 16-bit register with a 32-bit address

newDOS2.asm(186) : error A2155: cannot use 16-bit register with a 32-bit address

newDOS2.asm(187) : error A2155: cannot use 16-bit register with a 32-bit address

newDOS2.asm(188) : error A2155: cannot use 16-bit register with a 32-bit address

newDOS2.asm(189) : error A2155: cannot use 16-bit register with a 32-bit address

newDOS2.asm(190) : error A2155: cannot use 16-bit register with a 32-bit address

newDOS2.asm(56) : error A2022: instruction operands must be the same size
newDOS2.asm(71) : error A2022: instruction operands must be the same size
newDOS2.asm(115) : error A2022: instruction operands must be the same size
newDOS2.asm(211) : error A2022: instruction operands must be the same size
newDOS2.asm(208) : error A2178: invalid use of FLAT

FORTRANS

Hi,

   Look at the first code block in reply #18.  Compare to your
posted line 4.  .MODEL FLAT is incompatible with 16-bit code
(.MODEL SMALL).  Change to the code like that posted by
mineiro.  And *.COM programs are normally .TINY though
.SMALL is harmless.

Steve

bcddd214

Ok, major progress. I compile in 16 bit with this:


TITLE The New DOS

.386p
.model      small
.stack      100h
OPTION CaseMap:None
.MMX
.XMM


but I am getting mouse driver errors. I do not know this driver code enough to know what it wants re sized. I am guessing it barking at a frame size error? Who's frame is it drawing from?


Error:
C:\Users\wuzamarine\Desktop\asm\asm-progs>make16 newDOS2
Assembling: newDOS2.asm
newDOS2.asm(55) : error A2022: instruction operands must be the same size
newDOS2.asm(70) : error A2022: instruction operands must be the same size
newDOS2.asm(114) : error A2022: instruction operands must be the same size
newDOS2.asm(210) : error A2022: instruction operands must be the same size
Press any key to continue . . .

mineiro

Read this topic, one of the error are exactly yours. Follow the answers of Sr MichaelW.

bcddd214

I see half of what you are pointing at. My offset is off. It is looking for a different size. I am just not connecting the two...?   :(

dedndave

the processor ".386" directive should appear after the .MODEL directive
if you specify a 32-bit processor before the .MODEL directive, MASM tries to make a 32-bit program

furthermore - not sure you want .MXX and .XMM   :P
at least, not with a 386 processor

bcddd214

error free now but the mouse click still does not interrupt, only keyboard.

http://pastebin.com/SuZ8XzD1

dedndave

i don't see where the "mouse" proc is ever called   :P

bcddd214


dedndave


bcddd214

http://pastebin.com/qcN9RxWS

still no mouse click and the program hangs. no errors, just an inescapable hang.