Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7986973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:00:39+00:00 2026-06-04T12:00:39+00:00

I have created this program that takes two inputs and prints them out (simple,

  • 0

I have created this program that takes two inputs and prints them out (simple, yes, but it’s for practise). It compiles, and runs fine, but it doesn’t do what I intended. Here is my code:

.386 
.model flat, stdcall 
option casemap :none 
include \masm32\include\windows.inc 
include \masm32\include\kernel32.inc 
include \masm32\include\masm32.inc 
includelib \masm32\lib\kernel32.lib 
includelib \masm32\lib\masm32.lib
.data 
   num1 db "Enter a number:", 0 
   num2 db "Enter another number:", 0
.data? 
       buffer1 dd 100 dup(?)
   buffer2 dd 100 dup(?)
.code 
start:
   lea eax, num1
   push eax
   call StdOut
   lea ebx, buffer1
   push ebx
   call StdIn
   hlt
   lea eax, num2
   push eax
   call StdOut
   lea edx, buffer2
   push edx
   call StdIn
   xor eax, eax
   xor ebx, ebx
   xor edx, edx
   lea eax, buffer1
   push eax
   call StdOut
   lea ebx, buffer2
   push ebx
   call StdOut
   push 0 
   call ExitProcess
end start 

It displays this output:

Enter a number: Enter another number:

It should do:

Enter a number:
; wait for input.
Enter another number:
; wait for input.
; continue with program.

Why does it print on one line? I tried putting halt in there to stop the process, but Windows stops the program from running, and says the program is not responding.

EDIT:

Here is the code that I said I would edit in:

xor eax, eax
xor ebx, ebx
xor edx, edx
lea eax, buffer1
push eax
call StdOut
lea ebx, buffer2
push ebx
call StdOut

When I run this with the previous code, it says "This program is not responding." Why is this?

Any help would be appreciated.

Regards,

Progrmr

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T12:00:41+00:00Added an answer on June 4, 2026 at 12:00 pm

    hlt will, plainly, halt execution. It should only be used to wait for the next hardware interrupt, and should only be used by the operating system.

    StdIn isn’t working for you, because you aren’t providing the length of buffer. So StdIn fails and the next StdOut is executed.

    Don’t use hlt, and push the length of buffer and then push the address to buffer.

    .386 
    .model flat, stdcall 
    option casemap :none 
    
    include \masm32\include\windows.inc 
    include \masm32\include\kernel32.inc 
    include \masm32\include\masm32.inc 
    include \masm32\include\msvcrt.inc 
    include \MASM32\INCLUDE\user32.inc
    
    includelib \masm32\lib\kernel32.lib 
    includelib \masm32\lib\masm32.lib
    includelib \masm32\lib\msvcrt.lib
    includelib \MASM32\LIB\user32.lib
    
    atoi PROTO C strptr:DWORD
    
    .data 
       num1 db "Enter a number:", 0 
       num2 db "Enter another number:", 0
       formatStr db "%s+%s=%d", 0
    
    .data? 
       buffer1 dw 100 dup(?)
       buffer2 dw 100 dup(?)
       buffer3 dw 100 dup(?)
    .code 
    start:
       lea eax, num1
       push eax
       call StdOut
    
       mov eax,100
       push eax
       lea eax, buffer1
       push eax
       call StdIn
    
       lea eax, num2
       push eax
       call StdOut
    
       mov eax,100
       push eax
       lea eax, buffer2
       push eax
       call StdIn
    
       lea eax, buffer1
       push eax
       call atoi
       mov ebx,eax
    
       lea eax, buffer2
       push eax
       call atoi 
       add eax,ebx
    
       push eax
       lea eax,buffer2
       push eax
       lea eax,buffer1
       push eax
       lea eax,formatStr
       push eax
       lea eax,buffer3
       push eax
       call wsprintf
    
    
       lea eax,buffer3
       push eax
       call StdOut
    
       push 0 
       call ExitProcess
    
    end start
    

    Output:
    Output

    stdcall dictates you push parameters from right to left.
    Also, you might benefit from reviewing the code for StdIn and StdOut:

    StdIn proc lpszBuffer:DWORD,bLen:DWORD
    
       LOCAL hInput :DWORD
       LOCAL bRead  :DWORD
    
       invoke GetStdHandle,STD_INPUT_HANDLE
       mov hInput, eax
    
       invoke SetConsoleMode,hInput,ENABLE_LINE_INPUT or \
                                    ENABLE_ECHO_INPUT or \
                                    ENABLE_PROCESSED_INPUT
    
       invoke ReadFile,hInput,lpszBuffer,bLen,ADDR bRead,NULL
    
       mov eax, bRead
    
       ret
    
    StdIn endp
    
    StdOut proc lpszText:DWORD
    
        LOCAL hOutPut  :DWORD
        LOCAL bWritten :DWORD
        LOCAL sl       :DWORD
    
        invoke GetStdHandle,STD_OUTPUT_HANDLE
        mov hOutPut, eax
    
        invoke StrLen,lpszText
        mov sl, eax
    
        invoke WriteFile,hOutPut,lpszText,sl,ADDR bWritten,NULL
    
        mov eax, bWritten
        ret
    
    StdOut endp
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Purpose: Create a program that takes two separate files, opens and reads them, assigns
I have a program that takes two files as an argument. The first file
I have made a program that scans rss feeds. This same program creates feeds
I have created a procedure with this structure but it doesn't work for datetime
I have created a static library following this link . But I am facing
I have a java program that generates an HTML file. The Java program takes
I have a program with two methods. The first method takes two arrays as
Using Windows XP, I created a batch-file that takes two files as arguments, and
I have a program that I can run in two ways: single-end or paired-end
In my vb program, I have two forms that work together to allow you

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.