Input four integer and get the output of multiply the 4 integer

Started by nick, May 08, 2012, 03:28:41 PM

Previous topic - Next topic

nick

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

jj2007

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

nick

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??


nick

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]

jj2007

Quote from: minsiong on May 08, 2012, 04:00:03 PM
Is there other method??

Plenty of, but yes, this code is a good start. Don't forget \Masm32\help\masmlib.chm, though, and the Forum instructions. When do you have to deliver?

nick

I nid to submit it day after 2mr.. hope can finish it tonite.. already discover it for few days.. really not good in MASM.. :'(

jj2007

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.

nick