The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: nick on May 08, 2012, 03:28:41 PM

Title: Input four integer and get the output of multiply the 4 integer
Post by: nick on May 08, 2012, 03:28:41 PM
Hii.. i m new to dis MASM32.. erm.. i would like to do the coding to let user input four integer..den can output the multiplication of the four integer..can anyone help me create a code for this?? i really no idea with it...
Title: Re: Input four integer and get the output of multiply the 4 integer
Post by: jj2007 on May 08, 2012, 03:42:05 PM
That is challenging :bg
Here is a working example, exe attached. It's Genuine MasmTM, although your teacher might be a bit surprised ::)

include \masm32\MasmBasic\MasmBasic.inc   ; download (http://www.masm32.com/board/index.php?topic=12460)
   Init
   .Repeat
      push Val(Input$("1st integer: ", "123"))
      fild stack
      push Val(Input$("2nd integer: ", "1"))
      fimul stack
      push Val(Input$("3rd integer: ", "1"))
      fimul stack
      MovVal f:xmm0, Input$("and 1 float: ", "0.01")
      movlps REAL8 PTR [esp], xmm0
      fmul REAL8 PTR [esp]
      add esp, 3*DWORD
      Inkey Str$("The result is %f - one more (y)?\n\n", ST(0))
      fstp st
   .Until eax!="y"
   Exit
end start
Title: Re: Input four integer and get the output of multiply the 4 integer
Post by: nick on May 08, 2012, 03:50:06 PM
But it appear fatal error A1000:cannot open file: \ masm32\MasmBasic\MasmBasic.inc Init
Assembly error....

What should i do?? izit any plc i did wrong??
Title: Re: Input four integer and get the output of multiply the 4 integer
Post by: jj2007 on May 08, 2012, 03:53:40 PM
Click on "download" above after MasmBasic.inc...
Title: Re: Input four integer and get the output of multiply the 4 integer
Post by: nick on May 08, 2012, 04:00:03 PM
Is there other method??

I trying to edit this coding... can help?? :dazzled:

include \masm32\include\masm32rt.inc
.code

SIZE_OF_BUFFER = 100


.data
output1     db 'Please Enter Your Name : ',0
output2     db 13,10, 'Your name is %s',0

.data?
buffer      db SIZE_OF_BUFFER dup(?)

.code
start:

    invoke crt_printf,ADDR output1
    invoke StdIn,ADDR buffer, SIZE_OF_BUFFER
    invoke crt_printf,ADDR output2,ADDR buffer
    invoke  ExitProcess,0

END start[/color]
Title: Re: Input four integer and get the output of multiply the 4 integer
Post by: jj2007 on May 08, 2012, 04:06:29 PM
Quote from: minsiong on May 08, 2012, 04:00:03 PM
Is there other method??

Plenty of, but yes, this code (http://www.masm32.com/board/index.php?topic=10123.0) is a good start. Don't forget \Masm32\help\masmlib.chm, though, and the Forum instructions (http://www.masm32.com/board/index.php?topic=1295.0). When do you have to deliver?
Title: Re: Input four integer and get the output of multiply the 4 integer
Post by: nick on May 08, 2012, 04:18:52 PM
I nid to submit it day after 2mr.. hope can finish it tonite.. already discover it for few days.. really not good in MASM.. :'(
Title: Re: Input four integer and get the output of multiply the 4 integer
Post by: jj2007 on May 08, 2012, 06:29:28 PM
Good luck. Check atodw in \Masm32\help\masmlib.chm, you will need it. Re the multiply, you can use the method shown in the MasmBasic example above, i.e. use the FPU, otherwise mul is your choice.
Title: Re: Input four integer and get the output of multiply the 4 integer
Post by: nick on May 09, 2012, 01:46:59 AM
Can u give me the download link for the MASMBasic??
Title: Re: Input four integer and get the output of multiply the 4 integer
Post by: dedndave on May 09, 2012, 01:58:27 AM
http://www.masm32.com/board/index.php?topic=12460.msg95703#msg95703