left click interrupt proc or macro

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

Previous topic - Next topic

bcddd214

playing around and trying to write my first operating system I figured out how to close my loop and curious how to write and interrupt to end the loop on left click?



TITLE The New DOS

.model          small
.stack          100h

WINDESC         STRUCT
                        upperRow                BYTE    ?
                        leftCol                 BYTE    ?
                        lowerRow                BYTE    ?
                        rightCol                        BYTE    ?
                        foreColor               BYTE    ?
                        backColor               BYTE    ?
WINDESC         ENDS

exit            MACRO
                        mov                             ax, 4C00h
                        int                             21h
                        ENDM

.data
application     WINDESC                 <05h, 05h, 15h, 45h, 07h, 10h>

.code

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

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

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
                        exit
main            ENDP

                        end                             main

mineiro

Quote from: bcddd214 on December 07, 2011, 09:18:19 PM
makewin proc
;.......
ret 2
;;;jmp     short           main
makewin         ENDP

main            PROC
;.....
call                    makewin
call                     getchar
exit
main            ENDP
end   main

getchar      PROC
   mov ah,00h
   int 16h       ;this int wait user press a key in keyboard
   ret
getchar endp

Not sure if this is what you have question, but have the same effect.
To assemble type:
ml /c /Cp newdos.asm
link16 newdos.obj
or
jwasm -mz newdos.asm

bcddd214

The interrupt is still not working.
I see you close my loop correctly. I am curious how your 'getchar' proc did that? I made a lucky guess on my 'jmp' previous code.
I am very curious how that worked.
and also curious how to get the first interrupt click to work.

PS, I am back on Irvine for now and winblows.


TITLE The New DOS

.model      small
.stack      100h

WINDESC      STRUCT
         upperRow      BYTE   ?
         leftCol         BYTE   ?
         lowerRow      BYTE   ?
         rightCol         BYTE   ?
         foreColor      BYTE   ?
         backColor      BYTE   ?
WINDESC      ENDS

exit      MACRO
         mov            ax, 4C00h
         int            21h
         ENDM
         
.data
application   WINDESC         <05h, 05h, 15h, 45h, 07h, 10h>

.code

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

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

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

mineiro

When you have inserted that "jump" to a place outside of that procedure, you are creating what we call spaghetti code. A code that is hard to maintain, prone to errors (avalanche), and very hard to find mistakes or bugs (in your 1st example, unbalanced stack). When you get it simple, using call's , you are doing what we call 'modular project', easy to find errors, easy to read and implement the code, ... .
The rules of modular project is; comment your code(what the procedure expect, what is changes, what is returned, what that procedure do), save registers,... .
If the program wait you press a key before ends, so that interruption have worked, but we do not have displayed the returned char to the screen.

TITLE The New DOS

.model      small
.stack      100h

WINDESC      STRUCT
         upperRow      BYTE   ?
         leftCol         BYTE   ?
         lowerRow      BYTE   ?
         rightCol         BYTE   ?
         foreColor      BYTE   ?
         backColor      BYTE   ?
WINDESC      ENDS

exit      MACRO
         mov            ax, 4C00h
         int            21h
         ENDM
         
.data
application   WINDESC         <05h, 05h, 15h, 45h, 07h, 10h>

.code ;here start our program
main      PROC ;main function
         mov            ax, @data
         mov            ds, ax
         call         makewin ;draw a box in screen
         xor dx,dx ;dh=row,dl=column
         call         curpos ;put cursor at row,column position
         call getchar ;wait and get a key
         exit ; give control back to ms-dos
main      ENDP

curpos      PROC
;input: dh = row (0 based)
;       dl = column (0 based)
;return: nothing
         push         ax
         push         bx
         push         dx
         mov            ax, 0200h
         mov            bh, 0 ;bh = video page
         int            10h
         pop            dx
         pop            bx
         pop            ax
         ret           
curpos      ENDP

getchar PROC
;wait user press a key
;input: nothing
;return:  ah, al
;destroy: ax
mov ah,00h
int 16h
ret
getchar endp

makewin      PROC

         push         ax
         push         bx
         push         cx
         push         dx
         push         si
         mov            si, OFFSET application
         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
         int            10h
         pop            si
         pop            dx
         pop            cx
         pop            bx
         pop            ax
         ret           
makewin      ENDP
end            main

MichaelW

You're trying to end the loop when the user clicks the left mouse button?
eschew obfuscation

bcddd214

Quote from: mineiro on December 08, 2011, 04:18:43 PM
When you have inserted that "jump" to a place outside of that procedure, you are creating what we call spaghetti code. A code that is hard to maintain, prone to errors (avalanche), and very hard to find mistakes or bugs (in your 1st example, unbalanced stack). When you

[/quote]

I am afraid that the app does not end (break) on click.
But I also do not understand your response. I am aware that it is spaghetti code but I am trying to understand the mechanics. Before I jump'ed it into an obvious loop but now the app runs to the end of main and I would think that it would quit on it's own because it reaches endmain??

Just looking for some clearity.
mouse click still does not break the loop.

mineiro

Is good know the mechanics bcddd214.
"end main" tell to masm where is the start point of your program, so when you run your .exe file, the first line of code that will be executed is what is inside "main proc". The flow of this program being executed by the processor is:
main      PROC ;main function
         mov            ax, @data  ;;here is the first line that will be executed when your program is loaded by the O.S.
         mov            ds, ax
         call         makewin ;this call enter inside makewin procedure, and inside that procedure have a ret, so, after return, the line of code below will be executed
         xor dx,dx             ;
         call         curpos ;if have a ret inside this procedure, so next line will be executed,
         call getchar ;
         exit ;this is the last line of code, program stop here.
main      ENDP

Your program will not end if user do not press a key in keyboard (the flow of your program stay freezed in that respective function of "int 16h").
If user press a key, "int 16h" is not more hibernated, and continue the flow of code, and inside that procedure(getchar) have a ret, and the flow of code will return to the next line of code (below the caller, in this example, the macro "exit").
When I have said about spaggethi, I like to talk that is one way to program that you know where your program start's, but do not know where it ends. And believe in me, I have done so many spaghetti code in the past.

In your first example, when you have inserted that jmp, you have done something like:
main      PROC ;main function
         mov            ax, @data  ;;here is the first line that will be executed when your program is loaded by the O.S.
         mov            ds, ax
         call         makewin ;this call enter inside makewin procedure, and inside that procedure do not have a ret,
                                    ;inside makewin proc, have a jump to main, and this is like the line below
jmp main     ;so program jump to entry point again, and never reach the end, stay in this loop forever.
         xor dx,dx             ;so, this line will never be executed, and lines below too, because line above jmp to start point again
         call         curpos ;never reach here too
         call getchar ;
         exit ;this program will never stop, because flow of execution never reach here
main      ENDP


The int 16h is an interruption that get one key of keyboard, but have many different functions, in that example  it waits user press a key (so, it's like a pause), if you don't like this,  have another function that uses int 16h that get a key of keyboard without wait.
I do not know if this answer your question, if not, feel free to post. Like you can see, english is not my mother language, and I have difficult in say what I'm thinking.

MichaelW

This is not very good but it does show how to use the mouse driver to get the mouse button status and character coordinates. It works under Windows 2000 and should work under Windows XP, but it may not under more recent version of Windows. To see the character-mode mouse cursor you must run the application full-screen (use Alt+Enter to toggle between windowed and full-screen, or right-click the EXE and set the properties).

;==============================================================================
.model small
.386
;==============================================================================
.stack
.data
    msgNoMouseDriver db "no mouse driver",13,10,"$"
    msgPressAnyKey   db "press any key to exit",13,10,"$"
.code
.startup
;==============================================================================

    ;-------------------------------------------------------------------
    ; 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.
    ;----------------------------------------------------------------------

    mov ax,3533h
    int 21h
    mov ax, es
    .IF ax == 0
        mov ah, 9
        mov dx, OFFSET msgNoMouseDriver
        int 21h
        jmp exit
    .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 exit
    .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

  exit:

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

    xor ah, ah
    int 16h

.exit
end


eschew obfuscation

bcddd214

Quote from: mineiro on December 09, 2011, 01:51:58 AM
Is good know the mechanics bcddd214.


Before in the makewin proc, when it got to ret 2, it just stopped. Now since the keyboard interrupt was put into place (I realize what you published was for keyboard and not mouse now), the blue box stays in a loop, why?
I can see what closed the loop?

I am working with your mouse software now, thank you.   :)

bcddd214

I am not sure why it gives these error?

Assembling: newDOS2.asm
newDOS2.asm(38) : error A2108: use of register assumed to ERROR
newDOS2.asm(47) : error A2108: use of register assumed to ERROR
newDOS2.asm(62) : error A2108: use of register assumed to ERROR
newDOS2.asm(91) : error A2070: invalid instruction operands
newDOS2.asm(92) : error A2070: invalid instruction operands
newDOS2.asm(93) : error A2108: use of register assumed to ERROR
newDOS2.asm(96) : error A2108: use of register assumed to ERROR
newDOS2.asm(98) : error A2108: use of register assumed to ERROR
newDOS2.asm(100) : error A2108: use of register assumed to ERROR
newDOS2.asm(42) : error A2107: cannot have implicit far jump or call to near lab
el
newDOS2.asm(46) : error A2148: invalid symbol type in expression : exit2
newDOS2.asm(57) : error A2107: cannot have implicit far jump or call to near lab
el
newDOS2.asm(61) : error A2148: invalid symbol type in expression : exit2
newDOS2.asm(90) : error A2107: cannot have implicit far jump or call to near lab
el
newDOS2.asm(93) : error A2107: cannot have implicit far jump or call to near lab
el
newDOS2.asm(94) : error A2006: undefined symbol : @@
newDOS2.asm(97) : error A2006: undefined symbol : @@
newDOS2.asm(39) : warning A4012: line number information for segment without cla
ss 'CODE' : _DATA


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

TITLE The New DOS

.model      small
.stack      100h

WINDESC      STRUCT
         upperRow      BYTE   ?
         leftCol         BYTE   ?
         lowerRow      BYTE   ?
         rightCol         BYTE   ?
         foreColor      BYTE   ?
         backColor      BYTE   ?
WINDESC      ENDS

exit2      MACRO
         mov            ax, 4C00h
         int            21h
         ENDM
         
.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.
    ;----------------------------------------------------------------------
      
.startup
         mov ax,3533h
         int 21h
         mov ax, es
         .IF ax == 0
            mov ah, 9
            mov dx, OFFSET msgNoMouseDriver
            int 21h
         jmp exit2
.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 exit2
.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

exit:

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

         xor ah, ah
         int 16h

.exit
end

.code

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

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

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

Gunner

surround your code in code tags!

you have code "outside" the code sections.

Right above curpos      PROC you have .code and above that you have code.  remove that .code and add it right above .startup
~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com

bcddd214

Thank you, I didn't see that.
now it is erroring on line 93 and 94 on the shr directive. I have never seen that one before so I would not even know were to begin.

Assembling: newDOS2.asm
newDOS2.asm(93) : error A2070: invalid instruction operands
newDOS2.asm(94) : error A2070: invalid instruction operands
newDOS2.asm(48) : error A2148: invalid symbol type in expression : exit2
newDOS2.asm(63) : error A2148: invalid symbol type in expression : exit2
Press any key to continue . . .


************************************
TITLE The New DOS

.model      small
.stack      100h

WINDESC      STRUCT
         upperRow      BYTE   ?
         leftCol         BYTE   ?
         lowerRow      BYTE   ?
         rightCol         BYTE   ?
         foreColor      BYTE   ?
         backColor      BYTE   ?
WINDESC      ENDS

exit2      MACRO
         mov            ax, 4C00h
         int            21h
         ENDM
         
.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
   
.startup
         mov ax,3533h
         int 21h
         mov ax, es
         .IF ax == 0
            mov ah, 9
            mov dx, OFFSET msgNoMouseDriver
            int 21h
         jmp exit2
.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 exit2
.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

exit:

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

         xor ah, ah
         int 16h

.exit
end

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

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

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

Quote from: bcddd214 on December 12, 2011, 03:15:27 AM
Thank you, I didn't see that.
now it is erroring on line 93 and 94 on the shr directive. I have never seen that one before so I would not even know were to begin.



One more question. I have a macro called main exit and the mouse driver appears to have a sub procedure called exit also. I don't think my exit macro is doing anything so I just renamed it as a quick fix. I am getting an error there too as you can see.
Obviously you can't have a macro and a routine both called exit, can you? What is the best way to handle this error free?

jj2007

Quote from: bcddd214 on December 12, 2011, 03:21:43 AM
I have a macro called main exit and the mouse driver appears to have a sub procedure called exit also. I don't think my exit macro is doing anything so I just renamed it as a quick fix. I am getting an error there too as you can see.
Obviously you can't have a macro and a routine both called exit, can you? What is the best way to handle this error free?

Apply "namespace sensitivity". Masm itself, plus Masm32, CRT, MasmBasic and similar libraries occupy a namespace, and you better try to avoid using the most common names for your own stuff:
print
exit
str$
for ... next
repeat ... until
... whatever - the list is long, see e.g. Appendix D, "MASM Reserved Words" of the Masm Programmer's guide.
The easiest rule is call it MyExit, not exit or EXIT or Exit.

bcddd214

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?