News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Syntax error in inkey

Started by skywalker, February 28, 2006, 02:48:02 PM

Previous topic - Next topic

skywalker

I am getting a syntax on the inkey line.

Thanks.

call CpuClockSpeed
    .IF eax
      push  eax
      push  eax
      fstp  QWORD PTR[esp]
      pop   eax
      pop   edx
      invoke crt_printf,chr$("%.2f MHz%c"),edx::eax,10
    .ENDIF 

    inkey "Press any key to exit..."
    exit

P1

Quote from: skywalker on February 28, 2006, 02:48:02 PM
    inkey "Press any key to exit..."
To begin with it's either call or invoke.

To help you, from what library are you getting inkey from ???  There's lots of them out there.

Regards,  P1  :8)

Mark Jones

In the latest official MASM32 release, "inkey" is a macro in macros.asm:


    ;; ------------------------------------------------------
    ;; display user defined text, default text or none if
    ;; NULL is specified and wait for a keystroke to continue
    ;; ------------------------------------------------------
    inkey MACRO user_text:VARARG
      IFDIF <user_text>,<NULL>                  ;; if user text not "NULL"
        IFNB <user_text>                        ;; if user text not blank
          print user_text                       ;; print user defined text
        ELSE                                    ;; else
          print "Press any key to continue ..." ;; print default text
        ENDIF
      ENDIF
      call wait_key
      print chr$(13,10)
    ENDM



the "wait_key" function however, is found in WAIT_KEY.asm:


; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

    .486                      ; force 32 bit code
    .model flat, stdcall      ; memory model & calling convention
    option casemap :none      ; case sensitive

    include \masm32\include\windows.inc
    include \masm32\include\kernel32.inc
    include \masm32\include\msvcrt.inc
    include \masm32\macros\macros.asm

    .code
proto wait_key
proto _wait_key

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

wait_key proc

    invoke FlushConsoleInputBuffer, rv(GetStdHandle,STD_INPUT_HANDLE)

  @@:
    invoke Sleep, 1
    call crt__kbhit
    test eax, eax
    jz @B

    call crt__getch     ; recover the character in the keyboard
                        ; buffer and return it in EAX
    ret

wait_key endp

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

_wait_key proc

    invoke FlushConsoleInputBuffer, rv(GetStdHandle,STD_INPUT_HANDLE)

  @@:
    invoke Sleep, 1
    call crt__kbhit
    test eax, eax
    jz @B

    call crt__getch     ; recover the character in the keyboard
                        ; buffer and return it in EAX
    ret

_wait_key endp


end


Maybe that's what others have? This never seemed to work right for me, likely due to my error somehow.
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

skywalker

Quote from: Mark Jones on February 28, 2006, 04:16:30 PM
In the latest official MASM32 release, "inkey" is a macro in macros.asm:


    ;; ------------------------------------------------------
    ;; display user defined text, default text or none if
    ;; NULL is specified and wait for a keystroke to continue
    ;; ------------------------------------------------------
    inkey MACRO user_text:VARARG
      IFDIF <user_text>,<NULL>                  ;; if user text not "NULL"
        IFNB <user_text>                        ;; if user text not blank
          print user_text                       ;; print user defined text
        ELSE                                    ;; else
          print "Press any key to continue ..." ;; print default text
        ENDIF
      ENDIF
      call wait_key
      print chr$(13,10)
    ENDM


Thanks.

So I can just paste this macro right before .data and it should assemble fine.


skywalker

Quote from: Mark Jones on February 28, 2006, 04:16:30 PM
In the latest official MASM32 release, "inkey" is a macro in macros.asm:


    ;; ------------------------------------------------------
    ;; display user defined text, default text or none if
    ;; NULL is specified and wait for a keystroke to continue
    ;; ------------------------------------------------------
    inkey MACRO user_text:VARARG
      IFDIF <user_text>,<NULL>                  ;; if user text not "NULL"
        IFNB <user_text>                        ;; if user text not blank
          print user_text                       ;; print user defined text
        ELSE                                    ;; else
          print "Press any key to continue ..." ;; print default text
        ENDIF
      ENDIF
      call wait_key
      print chr$(13,10)
    ENDM



the "wait_key" function however, is found in WAIT_KEY.asm:

Neither macro is in my macros.asm (SP 2) and I am waiting a while to test the new version.

I'll study it and see if I can correctly add the above macro in it. I'll rename it for my system's safety. :-)


zooba

Make sure you've included MASM32.LIB which (IIRC) contains the wait_key function. :U

skywalker

Quote from: zooba on March 01, 2006, 03:53:12 AM
Make sure you've included MASM32.LIB which (IIRC) contains the wait_key function. :U
i

My code contains macros used in Version 9.0 beta, so I'm dling it now.