Example of Computer
Languages
C Source Code:
char name[40];
printf("Please enter your name\n");
scanf("%s", name);
printf("Hello %s", name);
Assembly Code:
push
offset string "Please enter your name\n"
(41364Ch)
call
dword ptr [__imp__printf (415194h)]
add
esp,4
lea
eax,[name]
push
eax
push
offset string "%s" (413648h)
call
dword ptr [__imp__scanf (41519Ch)]
add
esp,8
lea
eax,[name]
push
eax
push
offset string "Hello %s" (41363Ch)
call
dword ptr [__imp__printf (415194h)]
add
esp,8
Machine Code:
68 4C 36 41 00 FF 15 94 51 41 00 83 C4 04 8D 45 D8
50 68 48 36 41 00 FF 15 9C 51 41 00 83 C4 08 8D 45
D8 50 68 3C 36 41 00 FF 15 94 51 41 00 83 C4 08
NUMBER SYSTEM
A number system is a system of numbers used to count
things. Numbers are arranged to count things.
Types of Number System:
(1) Positional Number System:The number system in which
the weight of each digit depends on its relative position
within the number , is called positional number system.
(2) Non-Positional Number system: Such type of system is
used when human being counted with fingers, sticks etc.
Arithmetic operations are difficult to perform in such a
system.
Continued
Weight of n th digit of a number from right
hand side=nth digit x (Base)n-1
(6498)10=8x100+9x101+4x102+6x103
Quotient
Remainder
41/2=20
1(LSB)
20/2=10
10/2=5
5/2=2
2/2=1
=0
1(MSB)
Conversion Of D Fraction to B
Fraction (0.8125) 10=(0.1101)2
F
Fx2
New F
Integer
0.8125
1.625
0.625
1(MSB)
0.625
1.25
0.25
0.25
0.50
0.50
0.50
1.00
0.00(stop )
1(LSB)
Continued
In a particular case, it may be possible that
the fraction has not become zero and the
process will continue further. For such a
case ,an approximation is made. . Now
you can take your result upto 6 or desired
pure places after the binary point.
Exercise: (12.625)10=(?)2
Conversion of B fraction to D
fraction
(0.1101)2=1x2-1+1x2-2+0x2-3+1x2-4
=0.5+0.25+0+0.0625
=(0.8125)10
Quotient
Remainder
62/8=7
6(LSD)
7/8=0
7(MSD)
Fx8
Remainder Integer
F
0.96
7.68
0.68
7(MSD)
0.68
5.44
0.44
0.44
3.52
0.52
0.52
4.16
0.16
0.16
1.28
0.28
1(LSD)
Hexadecimal Number
The base in hexadecimal number system is 16. Its digits
from 0 to 9 are same as those used by decimal number
system. In that system 10 is represented by A,11 by B,12
by C,13 by D,14 by E and 15 by F. The decimal number
16 is represented by 10,17 by 11 and so on in
hexadecimal.
A hexadecimal digit is represented by four binary bits. For
example 5 is represented by 0101.
If a hexa-decimal number consists of more than 1 digit,
then each digit is represented by group of 4 binary bits.
(86)16=(1000 0110)2
Conversions
All conversions follow the same process as
that of octal .
Change 8 with 16 here.
Miscellaneous Conversions
Conversion of a binary number to Octal
Number:- For binary to octal conversion,
group of 3 binary bits each are formed in
the binary number. After forming the
groups, each group of 3 binary bits is
converted to its octal equivalent.
(101110)2=(101 110)=(56)8
Other Examples
(1101011)2= (1) (101) 011)
=(001)(101)(011)
=(153)8
(1011.1011)2=(1)(011).(101)(1)
=(001)(011).(101)(100)
=(13.54)8
Similarly, such conversions are made in
case of binary and hexadecimal numbers.