Saturday, October 11, 2008

QUESTION #6

Question:
Age Calculator: It will compute the age and prints how many months, weeks, days, hours and minutes old you are now.

Answer:
#include

/* Programmed by Harvey Losin *//* http://www.bikoy.com/harvey *//*
webmaster@bikoy.com */
main()
{ float years;
clrscr();
printf("Enter your age in years: ");scanf("%f",&years);
printf ("\nYou are %.0f months old", years * 12);
printf ("\nYou are %.0f weeks old", years * 48);
printf ("\nYou are %.0f days old", years * 365);
printf ("\nYou are %.0f hours old", years * 8760);
printf ("\nYou are %.0f minutes old", years * 525600);
getch();
}

Tuesday, October 7, 2008

QUESTION #5

Question: Research in the net the most recent assembler. Describe its history, nature and applications. Evaluate this assembler from its predecessor.
Answer:
HISTORY
Assembly languages are close to a one to one correspondence between symbolic instructions and executable machine codes. Assembly languages also include directives to the assembler, directives to the linker, directives for organizing data space, and macros. Macros can be used to combine several assembly language instructions into a high level language-like construct (as well as other purposes). There are cases where a symbolic instruction is translated into more than one machine instruction. But in general, symbolic assembly language instructions correspond to individual executable machine instructions.

Assembly language is much harder to program than high level languages. The programmer must pay attention to far more detail and must have an intimate knowledge of the processor in use. But high quality hand crafted assembly language programs can run much faster and use much less memory and other resources than a similar program written in a high level language. Speed increases of two to 20 times faster are fairly common, and increases of hundreds of times faster are occassionally possible.

NATURE
Nature procedural language with one to one correspondence between language mnemonics and executable machine instructions.
Assembler languages occupy a unique place in the computing world. Since most assembler-language statements are symbolic of individual machine-language instructions, the assembler-language programmer has the full power of the computer at his disposal in a way that users of other languages do not. Because of the direct relationship between assembler language and machine language, assembler language is used when high efficiency of programs is needed, and especially in areas of application that are so new and amorphous that existing program-oriented languages are ill-suited for describing the procedures to be followed.

There are a number of situations in which it is very desirable to use assembler language routines to do part of a job, and use some higher-level language for other parts. It makes sense to use higher-level languages such as Fortran, COBOL, or PL/I for parts of procedures for which they are well-suited, and supplement with assembler language routines for those parts of procedures for which the higher-level language is awkward or inefficient.

If one has a choice between assembly language and a high-level language, why choose assembly language? The fact that the amount of programming done in assembly language is quite small compared to the amount done in high-level languages indicates that one generally doesn’t choose assembly language. However, there are situations where it may not be convenient, efficient, or possible to write programs in hihg-level languages. … Programs to control and communicate with peripheral devices (input and output devices) are usually written in assembly language because they use special instructions that are not available in high-level languages, and they must be very efficient. Some systems programs are written in assembly language for similar reasons. In general, since high-level languages are designed without the features of a particular machine in mind and a compiler must do its job in a standardized way to accomodate all valid programs, there are situations where to take advantage of special features of a machine, to program some details that are inaccessible from a high-level language, or perhaps to increase the efficiency of a program, one may reasonably choose to write in assembly language.