The MASM Forum

General => The Campus => Topic started by: oex on June 27, 2015, 10:13:24 AM

Title: Build Problems
Post by: oex on June 27, 2015, 10:13:24 AM
Hey guys, it's been so long since I used MASM.

grrr too long, but making some headway again ::)
Title: Re: Build Problems
Post by: dedndave on June 27, 2015, 07:40:06 PM
hiya Peter - long time no see   :P
Title: Re: Build Problems
Post by: oex on June 28, 2015, 12:41:00 AM
Very slowly getting back into MASM....

The below is building ok but not running ok, not sure why? It has occassionally accepted input as shown which suggests to me a memory issue but memory doesnt serve me well on the first day back on MASM in over 4 years  :dazzled:

.586
.MMX
.K3D
.XMM

    .model  flat, stdcall
    option  casemap:none

    include   \masm32\include\windows.inc

    include \masm32\macros\macros.asm

x MACRO FuncName:REQ,args:VARARG
     arg equ <invoke FuncName> ;; construct invoke and function name
     FOR var,<args> ;; loop through all arguments
          arg CATSTR arg,<,reparg(var)> ;; replace quotes and append arg
     ENDM
     arg ;; write the invoke macro
ENDM

    xR MACRO FuncName:REQ,args:VARARG
      arg equ <x FuncName>         ;; construct invoke and function name
      FOR var,<args>                    ;; loop through all arguments
        arg CATSTR arg,<,reparg(var)>   ;; replace quotes and append arg
      ENDM
      arg                               ;; write the invoke macro
   EXITM <eax>
    ENDM

    uselib wsock32,user32,kernel32,gdi32,msvcrt,opengl32,glu32,winmm,shell32,Shlwapi,masm32

.const

.data

    CommandLine      dd   0
    hInstance      dd   0

.code

YN PROC   USES esi   String:DWORD

   x SetConsoleTitle, chr$("? Select")

TryAgain:

   print String

   mov esi, input("(Y/N): ")

   x SetConsoleTitle, chr$("Select")

   cmp BYTE PTR [esi], 'Y'
   jz Yes
   cmp BYTE PTR [esi], 'y'
   jz Yes

   cmp BYTE PTR [esi], 'N'
   jz No
   cmp BYTE PTR [esi], 'n'
   jz No

   jmp TryAgain

No:
   cmp BYTE PTR [esi], 'Y'

   mov eax, -1

   ret

Yes:

   mov eax, 0

   ret

YN ENDP

; --------------- Procedures Declarations
MainInit      PROTO   :DWORD,:DWORD,:DWORD,:DWORD

; --------------- Program start
start:

    mov hInstance, xR(GetModuleHandle,NULL)
    mov CommandLine, xR(GetCommandLine)
    x MainInit,hInstance,NULL,CommandLine,SW_SHOWDEFAULT
    invoke ExitProcess,1

; --------------- Program main inits
MainInit       PROC   USES esi edi hInst:DWORD,hPrevInst:DWORD,CmdLine:DWORD,CmdShow:DWORD

    mov eax, input("Enter number here ",62," ")

        print chr$("Hello")

   ;x SetConsoleTitle, chr$("cvdskjidjuifj")

   ;x YN, chr$("Hello")

   ret

MainInit       ENDP

end start
Title: Re: Build Problems
Post by: hutch-- on June 28, 2015, 12:47:03 AM
Peter,

Just make sure your build environment is working correctly first. Just see if you can build the examples. If so then its OK and you can see what is wrong with the app.
Title: Re: Build Problems
Post by: oex on June 28, 2015, 12:54:31 AM
Building win examples fine, have a working console example from the past that I wrote (which wont build now but that could be for any number of reasons, this was a fresh MASM install....

Is there a packaged console example with text input?

Will stop bugging you with stupid questions (I hope) once I can input/output to debug again  :biggrin:
Title: Re: Build Problems
Post by: Zen on June 28, 2015, 05:56:53 AM
Hi, PETER,
Your code compiles, but doesn't really do anything.
Title: Re: Build Problems
Post by: oex on June 28, 2015, 10:35:58 AM
    mov eax, input("Enter number here ",62," ")

        print chr$("Hello")

Isn't it meant to call for input and when entered print "Hello"?

It just falls through and quits for me
Title: Re: Build Problems
Post by: jj2007 on June 28, 2015, 04:03:58 PM
Quote from: oex on June 28, 2015, 10:35:58 AMIt just falls through and quits for me

Hi Peter,
most IDEs are not intelligent enough to realise that the user might want to see the output of a console app. Use inkey "hello world", or run the exe from a separate console window.
Title: Re: Build Problems
Post by: oex on June 28, 2015, 06:15:21 PM
It is running from a separate command prompt window, also tried inkey but still failed
Title: Re: Build Problems
Post by: jj2007 on June 28, 2015, 06:30:11 PM
Strange. I get this with your original, non-modified code:0

Enter number here > 123
Hello


It works. Do you get any error messages when building this? Which editor or IDE are you using? Command line options?
Title: Re: Build Problems
Post by: oex on June 28, 2015, 10:47:13 PM
Quote from: jj2007 on June 28, 2015, 06:30:11 PM
Strange. I get this with your original, non-modified code:0

Enter number here > 123
Hello


It works. Do you get any error messages when building this? Which editor or IDE are you using? Command line options?

It's the default QEditor Script I believe

?.qsc maybe when you click 'Build All'

Absolutely no build errors


Microsoft (R) Windows (R) Resource Compiler, Version 5.00.1823.1 - Build 1823
Copyright (C) Microsoft Corp. 1985-1998. All rights reserved.

Using codepage 936 as default
Creating rsrc.RES
RC: RCPP -CP 936 -f E:\masm32\x\RCa03464 -g E:\masm32\x\RDa03464 -DRC_INVOKED -D
_WIN32 -pc\:/ -E -I. -I .

rsrc.rc.
Writing ICON:1, lang:0x409,     size 744
Writing GROUP_ICON:100, lang:0x409,     size 20.
Writing 24:1,   lang:0x409,     size 369
Microsoft (R) Windows Resource To Object Converter Version 5.00.1736.1
Copyright (C) Microsoft Corp. 1992-1997. All rights reserved.

Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

Assembling: E:\masm32\x\X1.asm

***********
ASCII build
***********

Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

驱动器 E 中的卷没有标签。
卷的序列号是 0004-17DE

E:\masm32\x 的目录

2015/06/28  16:14             2,053 X1.asm
2015/06/28  20:49             4,608 X1.exe
2015/06/28  20:49             1,995 X1.obj
               3 个文件          8,656 字节
               0 个目录 194,047,303,680 可用字节
请按任意键继续. . .

Script continues to run (process in task manager) even though it falls through on the commandline

e:\masm32\x>x1

e:\masm32\x>x1

e:\masm32\x>
Title: Re: Build Problems
Post by: jj2007 on June 29, 2015, 02:42:45 AM
Peter,

Sometimes resource file and console mode are incompatible. Try building without resources.
Title: Re: Build Problems
Post by: oex on June 29, 2015, 02:49:16 AM
Turns out I'm a complete idiot, didnt select 'Console Build All' Just 'Build All'....

All working now, ty all, so much I have just forgotten :/
Title: Re: Build Problems
Post by: jj2007 on June 29, 2015, 02:55:19 AM
Quote from: oex on June 29, 2015, 02:49:16 AMTurns out I'm a complete idiot, didnt select 'Console Build All' Just 'Build All'....

Don't worry, most IDEs have no subsystem autodetect... not your fault ;-)
Title: Re: Build Problems
Post by: Zen on June 30, 2015, 04:17:05 AM
Quote from: PETER...Turns out I'm a complete idiot,...
We have something in common,...I do stuff like that all the time,...:bgrin:
Title: Re: Build Problems
Post by: hutch-- on June 30, 2015, 01:48:26 PM
Peter,

meant to ask, how old is that youngster of yours now ?

JJ,

> Don't worry, most IDEs have no subsystem autodetect... not your fault ;-)

Don't worry, some editors give YOU the choice so it is your fault.  :biggrin:
Title: Re: Build Problems
Post by: jj2007 on June 30, 2015, 04:41:16 PM
Quote from: hutch-- on June 30, 2015, 01:48:26 PM
JJ,

> Don't worry, most IDEs have no subsystem autodetect... not your fault ;-)

Don't worry, some editors give YOU the choice so it is your fault.  :biggrin:

In RichMasm, you can override the autodetect e.g. with an ; OPT_Susy Console for a GUI app with console.

We've had so many useless threads starting with inquiries about mysterious non-working apps and ending with explaining to noobs that Console build all is the solution - what about making that the default in a future qEditor release, with GUI build all as the second option?
Title: Re: Build Problems
Post by: hutch-- on June 30, 2015, 05:37:55 PM
 :biggrin:

Different target, MASM32 is aimed at producing assembler language programmers and was never an entry level SDK. If a new user does not know the difference between a Windows UI app and a console app, then they probably should be learning programming at an easier level. When they know how to use a compiler/linker/resource compiler and how to use a command prompt, then they are probably ready to start on assembler programming. QE will never be an interpreter, it is a pure ASCII editor and its default is to save plain ASCII text. Programmable menus allow for any option you like as long as you can set the option up and get it going.
Title: Re: Build Problems
Post by: oex on November 01, 2024, 09:02:49 PM
Quote from: hutch-- on June 30, 2015, 01:48:26 PMPeter,

meant to ask, how old is that youngster of yours now ?

He is now 11 and a budding programmer, my daughter 8 and just starting to read 'chapter' books ^^.

Sorry to reply a bit late, I missed that message.