Main program to test the basic operations, C/C++ Programming

The Main program is slightly more complicated and you need to think about the I/O process. First of all, for most applications you do not call the low level routines GetChar and PutChar. They are used by the higher level I/O subroutines that you wrote for reading and writing strings and numbers.

Secondly, you cannot just call an input routine like GetStr or GetNum on its own. Think carefully about what would happen. Let's say at some point in your program you want to read a number from the keyboard and place it in a memory location. Consider the following code fragment:

MyNum: dw

Main:
...
...
call GetNum
mov MyNum1, ax

This code will assemble and run and when you enter a number and press ‘Enter' it will store the number at location MyNum. However, how does the person running the program know when to enter a number, or whether to enter a number or a string? When subroutine GetNum is called it will simply wait for input from the keyboard. But the program gives no indication that it is waiting for input! The simple answer is that you must always first write a string to the screen asking for the kind of input you want the user to enter, then call the appropriate input routine. So, our revised program should look like this:

Prompt1: db ‘Enter a number less than 65536:

MyNum: dw
Main:
...
...
Mov ax, Prompt1
Call PutStr
call GetNum
mov MyNum1, ax

Now when the program runs it first prints a message asking for a number and then waits for input. Try this out - if you have written your routines correctly, I think you will like the way this works.

Posted Date: 3/26/2013 2:04:54 AM | Location : United States







Related Discussions:- Main program to test the basic operations, Assignment Help, Ask Question on Main program to test the basic operations, Get Answer, Expert's Help, Main program to test the basic operations Discussions

Write discussion on Main program to test the basic operations
Your posts are moderated
Related Questions
Goals For this assignment you will write programs in C and LC-3 assembly code. Both programs will perform the identical recursive algorithm. The goals of this programming assignmen

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

The program reads two numbers and a character (operator). If the character is "+" then sum is displayed. If it is "-"then difference is displayed. If it is "*" then product is disp

Define External Storage Class - computer programming? When a variable is declared outside a function the storage is permanently assigned to it and its storage class is 'extern'

Operators The variables, which are declared and explained, are the operands, which are operated upon by the operators. Operators specify what operations are to be performed on

Define Polymorphism? A: Polymorphism let a client to treat di_erent objects in the simialr way even if they were developed from di_erent classes and exhibit di_erent behaviors.

I need Website with built in scraper Project Description: The coding skills mentioned above are just possibly ones that will be used. Skills required are ASP, C++ Programm

At a shop of marbles, packs of marbles are prepared. Packets are named A, B, C, D, E …….. All packets are kept in a VERTICAL SHELF in random order. Any numbers of packets with thes

For the circuit shown in Figure, verify the p.d. across resistor R3. If the total resistance of the circuit is 100Ω, verify the current flowing by resistor R1. Find also the

A: this is a procedure during exception handling while the destructor is called for all local objects in the stack among the place where the exception was thrown & where this is ca