SlideShare a Scribd company logo
1 of 82
Design an algorithm in machine language to print from 0 to 4
Code in Python :-
x = 0
while ( x < 5 ):
print(x)
x = x + 1
x condition output
0 TRUE 0
1 TRUE 1
2 TRUE 2
3 TRUE 3
4 TRUE 4
5 FALSE
Output ( 0 - 1 - 2 - 3 - 4 )
Code in machine language
A1
A2
A4
A6
A8
AA
AC
AE
B0
0
2005
11A1
2201
B1B0
3100
5121
B0A8
C000
A1 contain the value of x
put ( 05 ) in register 0
put the value of address ( A1 ) in register 1
put ( 01 ) in register 2
jump to address B0 if the value of R1 equal the value of R0
print the value of R1 on screen
R1 = R1 + R2
jump to address A8 if the value of R0 equal the value of R0
End the program
R0 = 5
Code in machine language
A1
A2
A4
A6
A8
AA
AC
AE
B0
0
2005
11A1
2201
B1B0
3100
5121
B0A8
C000
A1 contain the value of x
put ( 05 ) in register 0
put the value of address ( A1 ) in register 1
put ( 01 ) in register 2
jump to address B0 if the value of R1 equal the value of R0
print the value of R1 on screen
R1 = R1 + R2
jump to address A8 if the value of R0 equal the value of R0
End the program
R0 = 5
R1 = 0
Code in machine language
A1
A2
A4
A6
A8
AA
AC
AE
B0
0
2005
11A1
2201
B1B0
3100
5121
B0A8
C000
A1 contain the value of x
put ( 05 ) in register 0
put the value of address ( A1 ) in register 1
put ( 01 ) in register 2
jump to address B0 if the value of R1 equal the value of R0
print the value of R1 on screen
R1 = R1 + R2
jump to address A8 if the value of R0 equal the value of R0
End the program
R0 = 5
R1 = 0
R2 = 1
Code in machine language
A1
A2
A4
A6
A8
AA
AC
AE
B0
0
2005
11A1
2201
B1B0
3100
5121
B0A8
C000
A1 contain the value of x
put ( 05 ) in register 0
put the value of address ( A1 ) in register 1
put ( 01 ) in register 2
jump to address B0 if the value of R1 equal the value of R0
print the value of R1 on screen
R1 = R1 + R2
jump to address A8 if the value of R0 equal the value of R0
End the program
R0 = 5
R1 = 0
R2 = 1
FALSE
Code in machine language
A1
A2
A4
A6
A8
AA
AC
AE
B0
0
2005
11A1
2201
B1B0
3100
5121
B0A8
C000
A1 contain the value of x
put ( 05 ) in register 0
put the value of address ( A1 ) in register 1
put ( 01 ) in register 2
jump to address B0 if the value of R1 equal the value of R0
print the value of R1 on screen
R1 = R1 + R2
jump to address A8 if the value of R0 equal the value of R0
End the program
R0 = 5
R1 = 0
R2 = 1
FALSE
0
Code in machine language
A1
A2
A4
A6
A8
AA
AC
AE
B0
0
2005
11A1
2201
B1B0
3100
5121
B0A8
C000
A1 contain the value of x
put ( 05 ) in register 0
put the value of address ( A1 ) in register 1
put ( 01 ) in register 2
jump to address B0 if the value of R1 equal the value of R0
print the value of R1 on screen
R1 = R1 + R2
jump to address A8 if the value of R0 equal the value of R0
End the program
R0 = 5
R1 = 1
R2 = 1
FALSE
0
Code in machine language
A1
A2
A4
A6
A8
AA
AC
AE
B0
0
2005
11A1
2201
B1B0
3100
5121
B0A8
C000
A1 contain the value of x
put ( 05 ) in register 0
put the value of address ( A1 ) in register 1
put ( 01 ) in register 2
jump to address B0 if the value of R1 equal the value of R0
print the value of R1 on screen
R1 = R1 + R2
jump to address A8 if the value of R0 equal the value of R0
End the program
R0 = 5
R1 = 1
R2 = 1
FALSE
0
TRUE
Code in machine language
A1
A2
A4
A6
A8
AA
AC
AE
B0
0
2005
11A1
2201
B1B0
3100
5121
B0A8
C000
A1 contain the value of x
put ( 05 ) in register 0
put the value of address ( A1 ) in register 1
put ( 01 ) in register 2
jump to address B0 if the value of R1 equal the value of R0
print the value of R1 on screen
R1 = R1 + R2
jump to address A8 if the value of R0 equal the value of R0
End the program
R0 = 5
R1 = 1
R2 = 1
FALSE
0
Code in machine language
A1
A2
A4
A6
A8
AA
AC
AE
B0
0
2005
11A1
2201
B1B0
3100
5121
B0A8
C000
A1 contain the value of x
put ( 05 ) in register 0
put the value of address ( A1 ) in register 1
put ( 01 ) in register 2
jump to address B0 if the value of R1 equal the value of R0
print the value of R1 on screen
R1 = R1 + R2
jump to address A8 if the value of R0 equal the value of R0
End the program
R0 = 5
R1 = 1
R2 = 1
FALSE
1
Code in machine language
A1
A2
A4
A6
A8
AA
AC
AE
B0
0
2005
11A1
2201
B1B0
3100
5121
B0A8
C000
A1 contain the value of x
put ( 05 ) in register 0
put the value of address ( A1 ) in register 1
put ( 01 ) in register 2
jump to address B0 if the value of R1 equal the value of R0
print the value of R1 on screen
R1 = R1 + R2
jump to address A8 if the value of R0 equal the value of R0
End the program
R0 = 5
R1 = 2
R2 = 1
FALSE
1
Code in machine language
A1
A2
A4
A6
A8
AA
AC
AE
B0
0
2005
11A1
2201
B1B0
3100
5121
B0A8
C000
A1 contain the value of x
put ( 05 ) in register 0
put the value of address ( A1 ) in register 1
put ( 01 ) in register 2
jump to address B0 if the value of R1 equal the value of R0
print the value of R1 on screen
R1 = R1 + R2
jump to address A8 if the value of R0 equal the value of R0
End the program
R0 = 5
R1 = 2
R2 = 1
FALSE
1
TRUE
Code in machine language
A1
A2
A4
A6
A8
AA
AC
AE
B0
0
2005
11A1
2201
B1B0
3100
5121
B0A8
C000
A1 contain the value of x
put ( 05 ) in register 0
put the value of address ( A1 ) in register 1
put ( 01 ) in register 2
jump to address B0 if the value of R1 equal the value of R0
print the value of R1 on screen
R1 = R1 + R2
jump to address A8 if the value of R0 equal the value of R0
End the program
R0 = 5
R1 = 2
R2 = 1
FALSE
1
Code in machine language
A1
A2
A4
A6
A8
AA
AC
AE
B0
0
2005
11A1
2201
B1B0
3100
5121
B0A8
C000
A1 contain the value of x
put ( 05 ) in register 0
put the value of address ( A1 ) in register 1
put ( 01 ) in register 2
jump to address B0 if the value of R1 equal the value of R0
print the value of R1 on screen
R1 = R1 + R2
jump to address A8 if the value of R0 equal the value of R0
End the program
R0 = 5
R1 = 2
R2 = 1
FALSE
2
Code in machine language
A1
A2
A4
A6
A8
AA
AC
AE
B0
0
2005
11A1
2201
B1B0
3100
5121
B0A8
C000
A1 contain the value of x
put ( 05 ) in register 0
put the value of address ( A1 ) in register 1
put ( 01 ) in register 2
jump to address B0 if the value of R1 equal the value of R0
print the value of R1 on screen
R1 = R1 + R2
jump to address A8 if the value of R0 equal the value of R0
End the program
R0 = 5
R1 = 3
R2 = 1
FALSE
2
Code in machine language
A1
A2
A4
A6
A8
AA
AC
AE
B0
0
2005
11A1
2201
B1B0
3100
5121
B0A8
C000
A1 contain the value of x
put ( 05 ) in register 0
put the value of address ( A1 ) in register 1
put ( 01 ) in register 2
jump to address B0 if the value of R1 equal the value of R0
print the value of R1 on screen
R1 = R1 + R2
jump to address A8 if the value of R0 equal the value of R0
End the program
R0 = 5
R1 = 3
R2 = 1
FALSE
2
TRUE
Code in machine language
A1
A2
A4
A6
A8
AA
AC
AE
B0
0
2005
11A1
2201
B1B0
3100
5121
B0A8
C000
A1 contain the value of x
put ( 05 ) in register 0
put the value of address ( A1 ) in register 1
put ( 01 ) in register 2
jump to address B0 if the value of R1 equal the value of R0
print the value of R1 on screen
R1 = R1 + R2
jump to address A8 if the value of R0 equal the value of R0
End the program
R0 = 5
R1 = 3
R2 = 1
FALSE
3
Code in machine language
A1
A2
A4
A6
A8
AA
AC
AE
B0
0
2005
11A1
2201
B1B0
3100
5121
B0A8
C000
A1 contain the value of x
put ( 05 ) in register 0
put the value of address ( A1 ) in register 1
put ( 01 ) in register 2
jump to address B0 if the value of R1 equal the value of R0
print the value of R1 on screen
R1 = R1 + R2
jump to address A8 if the value of R0 equal the value of R0
End the program
R0 = 5
R1 = 4
R2 = 1
FALSE
3
Code in machine language
A1
A2
A4
A6
A8
AA
AC
AE
B0
0
2005
11A1
2201
B1B0
3100
5121
B0A8
C000
A1 contain the value of x
put ( 05 ) in register 0
put the value of address ( A1 ) in register 1
put ( 01 ) in register 2
jump to address B0 if the value of R1 equal the value of R0
print the value of R1 on screen
R1 = R1 + R2
jump to address A8 if the value of R0 equal the value of R0
End the program
R0 = 5
R1 = 4
R2 = 1
FALSE
3
TRUE
Code in machine language
A1
A2
A4
A6
A8
AA
AC
AE
B0
0
2005
11A1
2201
B1B0
3100
5121
B0A8
C000
A1 contain the value of x
put ( 05 ) in register 0
put the value of address ( A1 ) in register 1
put ( 01 ) in register 2
jump to address B0 if the value of R1 equal the value of R0
print the value of R1 on screen
R1 = R1 + R2
jump to address A8 if the value of R0 equal the value of R0
End the program
R0 = 5
R1 = 4
R2 = 1
FALSE
3
Code in machine language
A1
A2
A4
A6
A8
AA
AC
AE
B0
0
2005
11A1
2201
B1B0
3100
5121
B0A8
C000
A1 contain the value of x
put ( 05 ) in register 0
put the value of address ( A1 ) in register 1
put ( 01 ) in register 2
jump to address B0 if the value of R1 equal the value of R0
print the value of R1 on screen
R1 = R1 + R2
jump to address A8 if the value of R0 equal the value of R0
End the program
R0 = 5
R1 = 4
R2 = 1
FALSE
4
Code in machine language
A1
A2
A4
A6
A8
AA
AC
AE
B0
0
2005
11A1
2201
B1B0
3100
5121
B0A8
C000
A1 contain the value of x
put ( 05 ) in register 0
put the value of address ( A1 ) in register 1
put ( 01 ) in register 2
jump to address B0 if the value of R1 equal the value of R0
print the value of R1 on screen
R1 = R1 + R2
jump to address A8 if the value of R0 equal the value of R0
End the program
R0 = 5
R1 = 5
R2 = 1
FALSE
4
Code in machine language
A1
A2
A4
A6
A8
AA
AC
AE
B0
0
2005
11A1
2201
B1B0
3100
5121
B0A8
C000
A1 contain the value of x
put ( 05 ) in register 0
put the value of address ( A1 ) in register 1
put ( 01 ) in register 2
jump to address B0 if the value of R1 equal the value of R0
print the value of R1 on screen
R1 = R1 + R2
jump to address A8 if the value of R0 equal the value of R0
End the program
R0 = 5
R1 = 5
R2 = 1
FALSE
4
TRUE
Code in machine language
A1
A2
A4
A6
A8
AA
AC
AE
B0
0
2005
11A1
2201
B1B0
3100
5121
B0A8
C000
A1 contain the value of x
put ( 05 ) in register 0
put the value of address ( A1 ) in register 1
put ( 01 ) in register 2
jump to address B0 if the value of R1 equal the value of R0
print the value of R1 on screen
R1 = R1 + R2
jump to address A8 if the value of R0 equal the value of R0
End the program
R0 = 5
R1 = 5
R2 = 1
true
4
END
Design an algorithm in machine language to get the same final result of this code in python :-
x = 0
while ( x < 5 ):
x = x + 1
Print( x )
Code in Python :-
x = 0
while ( x < 5 ):
x = x + 1
Print( x )
x condition output
0 TRUE
1 TRUE
2 TRUE
3 TRUE
4 TRUE
5 FALSE 5
output ( 5 )
Code in machine language
A1
A2
A4
A6
A8
AA
AC
AE
B0
0
2005
11A1
2201
B1B0
5121
B0A8
3100
C000
A1 contain the value of x
put ( 05 ) in register 0
put the value of address ( A1 ) in register 1
put ( 01 ) in register 2
jump to address B0 if the value of R1 equal the value of R0
R1 = R1 + R2
jump to address A8 if the value of R0 equal the value of R0
print the value of R1 on screen
End the program
R0 = 5
Code in machine language
A1
A2
A4
A6
A8
AA
AC
AE
B0
0
2005
11A1
2201
B1B0
5121
B0A8
3100
C000
A1 contain the value of x
put ( 05 ) in register 0
put the value of address ( A1 ) in register 1
put ( 01 ) in register 2
jump to address B0 if the value of R1 equal the value of R0
R1 = R1 + R2
jump to address A8 if the value of R0 equal the value of R0
print the value of R1 on screen
End the program
R0 = 5
R1 = 0
Code in machine language
A1
A2
A4
A6
A8
AA
AC
AE
B0
0
2005
11A1
2201
B1B0
5121
B0A8
3100
C000
A1 contain the value of x
put ( 05 ) in register 0
put the value of address ( A1 ) in register 1
put ( 01 ) in register 2
jump to address B0 if the value of R1 equal the value of R0
R1 = R1 + R2
jump to address A8 if the value of R0 equal the value of R0
print the value of R1 on screen
End the program
R0 = 5
R1 = 0
R2 = 1
Code in machine language
A1
A2
A4
A6
A8
AA
AC
AE
B0
0
2005
11A1
2201
B1B0
5121
B0A8
3100
C000
A1 contain the value of x
put ( 05 ) in register 0
put the value of address ( A1 ) in register 1
put ( 01 ) in register 2
jump to address B0 if the value of R1 equal the value of R0
R1 = R1 + R2
jump to address A8 if the value of R0 equal the value of R0
print the value of R1 on screen
End the program
R0 = 5
R1 = 0
R2 = 1
False
Code in machine language
A1
A2
A4
A6
A8
AA
AC
AE
B0
0
2005
11A1
2201
B1B0
5121
B0A8
3100
C000
A1 contain the value of x
put ( 05 ) in register 0
put the value of address ( A1 ) in register 1
put ( 01 ) in register 2
jump to address B0 if the value of R1 equal the value of R0
R1 = R1 + R2
jump to address A8 if the value of R0 equal the value of R0
print the value of R1 on screen
End the program
R0 = 5
R1 = 1
R2 = 1
False
Code in machine language
A1
A2
A4
A6
A8
AA
AC
AE
B0
0
2005
11A1
2201
B1B0
5121
B0A8
3100
C000
A1 contain the value of x
put ( 05 ) in register 0
put the value of address ( A1 ) in register 1
put ( 01 ) in register 2
jump to address B0 if the value of R1 equal the value of R0
R1 = R1 + R2
jump to address A8 if the value of R0 equal the value of R0
print the value of R1 on screen
End the program
R0 = 5
R1 = 1
R2 = 1
False
true
Code in machine language
A1
A2
A4
A6
A8
AA
AC
AE
B0
0
2005
11A1
2201
B1B0
5121
B0A8
3100
C000
A1 contain the value of x
put ( 05 ) in register 0
put the value of address ( A1 ) in register 1
put ( 01 ) in register 2
jump to address B0 if the value of R1 equal the value of R0
R1 = R1 + R2
jump to address A8 if the value of R0 equal the value of R0
print the value of R1 on screen
End the program
R0 = 5
R1 = 2
R2 = 1
False
Code in machine language
A1
A2
A4
A6
A8
AA
AC
AE
B0
0
2005
11A1
2201
B1B0
5121
B0A8
3100
C000
A1 contain the value of x
put ( 05 ) in register 0
put the value of address ( A1 ) in register 1
put ( 01 ) in register 2
jump to address B0 if the value of R1 equal the value of R0
R1 = R1 + R2
jump to address A8 if the value of R0 equal the value of R0
print the value of R1 on screen
End the program
R0 = 5
R1 = 2
R2 = 1
False
true
Code in machine language
A1
A2
A4
A6
A8
AA
AC
AE
B0
0
2005
11A1
2201
B1B0
5121
B0A8
3100
C000
A1 contain the value of x
put ( 05 ) in register 0
put the value of address ( A1 ) in register 1
put ( 01 ) in register 2
jump to address B0 if the value of R1 equal the value of R0
R1 = R1 + R2
jump to address A8 if the value of R0 equal the value of R0
print the value of R1 on screen
End the program
R0 = 5
R1 = 3
R2 = 1
False
Code in machine language
A1
A2
A4
A6
A8
AA
AC
AE
B0
0
2005
11A1
2201
B1B0
5121
B0A8
3100
C000
A1 contain the value of x
put ( 05 ) in register 0
put the value of address ( A1 ) in register 1
put ( 01 ) in register 2
jump to address B0 if the value of R1 equal the value of R0
R1 = R1 + R2
jump to address A8 if the value of R0 equal the value of R0
print the value of R1 on screen
End the program
R0 = 5
R1 = 3
R2 = 1
False
true
Code in machine language
A1
A2
A4
A6
A8
AA
AC
AE
B0
0
2005
11A1
2201
B1B0
5121
B0A8
3100
C000
A1 contain the value of x
put ( 05 ) in register 0
put the value of address ( A1 ) in register 1
put ( 01 ) in register 2
jump to address B0 if the value of R1 equal the value of R0
R1 = R1 + R2
jump to address A8 if the value of R0 equal the value of R0
print the value of R1 on screen
End the program
R0 = 5
R1 = 4
R2 = 1
False
Code in machine language
A1
A2
A4
A6
A8
AA
AC
AE
B0
0
2005
11A1
2201
B1B0
5121
B0A8
3100
C000
A1 contain the value of x
put ( 05 ) in register 0
put the value of address ( A1 ) in register 1
put ( 01 ) in register 2
jump to address B0 if the value of R1 equal the value of R0
R1 = R1 + R2
jump to address A8 if the value of R0 equal the value of R0
print the value of R1 on screen
End the program
R0 = 5
R1 = 4
R2 = 1
False
true
Code in machine language
A1
A2
A4
A6
A8
AA
AC
AE
B0
0
2005
11A1
2201
B1B0
5121
B0A8
3100
C000
A1 contain the value of x
put ( 05 ) in register 0
put the value of address ( A1 ) in register 1
put ( 01 ) in register 2
jump to address B0 if the value of R1 equal the value of R0
R1 = R1 + R2
jump to address A8 if the value of R0 equal the value of R0
print the value of R1 on screen
End the program
R0 = 5
R1 = 5
R2 = 1
False
Code in machine language
A1
A2
A4
A6
A8
AA
AC
AE
B0
0
2005
11A1
2201
B1B0
5121
B0A8
3100
C000
A1 contain the value of x
put ( 05 ) in register 0
put the value of address ( A1 ) in register 1
put ( 01 ) in register 2
jump to address B0 if the value of R1 equal the value of R0
R1 = R1 + R2
jump to address A8 if the value of R0 equal the value of R0
print the value of R1 on screen
End the program
R0 = 5
R1 = 5
R2 = 1
true
true
Code in machine language
A1
A2
A4
A6
A8
AA
AC
AE
B0
0
2005
11A1
2201
B1B0
5121
B0A8
3100
C000
A1 contain the value of x
put ( 05 ) in register 0
put the value of address ( A1 ) in register 1
put ( 01 ) in register 2
jump to address B0 if the value of R1 equal the value of R0
R1 = R1 + R2
jump to address A8 if the value of R0 equal the value of R0
print the value of R1 on screen
End the program
R0 = 5
R1 = 5
R2 = 1
true
true
5
Code in machine language
A1
A2
A4
A6
A8
AA
AC
AE
B0
0
2005
11A1
2201
B1B0
5121
B0A8
3100
C000
A1 contain the value of x
put ( 05 ) in register 0
put the value of address ( A1 ) in register 1
put ( 01 ) in register 2
jump to address B0 if the value of R1 equal the value of R0
R1 = R1 + R2
jump to address A8 if the value of R0 equal the value of R0
print the value of R1 on screen
End the program
R0 = 5
R1 = 5
R2 = 1
true
true
5
END
Design an algorithm in machine language to get the same final result of this code in python :-
x = 5
y = 7
temp = x
x = y
y = temp
print(x,y)
Code in Python :-
x = 5
y = 7
temp = x
x = y
y = temp
print(x,y)
x y temp
5 7 5
7 5
output ( x = 7 -- y = 5 )
A0
A1
A2
A4
A6
A8
AA
5
7
11A0
12A1
32A0
31A1
C000
Value of address A0 is ( 5 )
Value of address A1 is ( 7 )
put value of address A0 in Register 1
put value of address A1 in Register 2
Store value of Register 2 in address A0
Store value of Register 1 in address A1
END
5
7
A0
A1
A2
A4
A6
A8
AA
5
7
11A0
12A1
32A0
31A1
C000
Value of address A0 is ( 5 )
Value of address A1 is ( 7 )
put value of address A0 in Register 1
put value of address A1 in Register 2
Store value of Register 2 in address A0
Store value of Register 1 in address A1
END
5
7
R1 = 5
A0
A1
A2
A4
A6
A8
AA
5
7
11A0
12A1
32A0
31A1
C000
Value of address A0 is ( 5 )
Value of address A1 is ( 7 )
put value of address A0 in Register 1
put value of address A1 in Register 2
Store value of Register 2 in address A0
Store value of Register 1 in address A1
END
5
7
R1 = 5
R2 = 7
A0
A1
A2
A4
A6
A8
AA
5
7
11A0
12A1
32A0
31A1
C000
Value of address A0 is ( 5 )
Value of address A1 is ( 7 )
put value of address A0 in Register 1
put value of address A1 in Register 2
Store value of Register 2 in address A0
Store value of Register 1 in address A1
END
7
7
R1 = 5
R2 = 7
A0
A1
A2
A4
A6
A8
AA
5
7
11A0
12A1
32A0
31A1
C000
Value of address A0 is ( 5 )
Value of address A1 is ( 7 )
put value of address A0 in Register 1
put value of address A1 in Register 2
Store value of Register 2 in address A0
Store value of Register 1 in address A1
END
7
5
R1 = 5
R2 = 7
A0
A1
A2
A4
A6
A8
AA
5
7
11A0
12A1
32A0
31A1
C000
Value of address A0 is ( 5 )
Value of address A1 is ( 7 )
put value of address A0 in Register 1
put value of address A1 in Register 2
Store value of Register 2 in address A0
Store value of Register 1 in address A1
END
7
5
R1 = 5
R2 = 7
END
What is the purpose or function of the machine language program on the side? What does it do and how
does it do it?
What is the purpose or function of the machine language program on the side?
What does it do and how does it do it?
20
22
24
26
28
2A
2C
2E
30
32
34
2000
11A0
2280
8221
B230
234E
3300
B034
2350
3300
C000
To understand this question, Assume that the value of
A0 = 82
Note :
( 82 ) hexa = ( 10000010 ) binary
( 80 ) hexa = ( 10000000 ) binary
20
22
24
26
28
2A
2C
2E
30
32
34
2000
11A0
2280
8221
B230
234E
3300
B034
2350
3300
C000
put ( 0 ) in register 0
put Value of Cells (A0) in Register 1
put ( 80 ) in Register 2
Make ( AND ) Between Register ( 2 - 1 ) and put the result in R2
go to address 30 if R2 = R0
put ( 4E ) in Register 3
print value of R3 on screen
go to address 34 if R0 = R0
PUT ( 50 ) in Register 3
print value of R3 on screen
END
R0 = 00
A0 = ( 82 ) hexa
20
22
24
26
28
2A
2C
2E
30
32
34
2000
11A0
2280
8221
B230
234E
3300
B034
2350
3300
C000
put ( 0 ) in register 0
put Value of Cells (A0) in Register 1
put ( 80 ) in Register 2
Make ( AND ) Between Register ( 2 - 1 ) and put the result in R2
go to address 30 if R2 = R0
put ( 4E ) in Register 3
print value of R3 on screen
go to address 34 if R0 = R0
PUT ( 50 ) in Register 3
print value of R3 on screen
END
R0 = 00
R1 = 82
A0 = ( 82 ) hexa
20
22
24
26
28
2A
2C
2E
30
32
34
2000
11A0
2280
8221
B230
234E
3300
B034
2350
3300
C000
put ( 0 ) in register 0
put Value of Cells (A0) in Register 1
put ( 80 ) in Register 2
Make ( AND ) Between Register ( 2 - 1 ) and put the result in R2
go to address 30 if R2 = R0
put ( 4E ) in Register 3
print value of R3 on screen
go to address 34 if R0 = R0
PUT ( 50 ) in Register 3
print value of R3 on screen
END
R0 = 00
R1 = 82
R2 = 80
A0 = ( 82 ) hexa
20
22
24
26
28
2A
2C
2E
30
32
34
2000
11A0
2280
8221
B230
234E
3300
B034
2350
3300
C000
put ( 0 ) in register 0
put Value of Cells (A0) in Register 1
put ( 80 ) in Register 2
Make ( AND ) Between Register ( 2 - 1 ) and put the result in R2
go to address 30 if R2 = R0
put ( 4E ) in Register 3
print value of R3 on screen
go to address 34 if R0 = R0
PUT ( 50 ) in Register 3
print value of R3 on screen
END
R0 = 00
R1 = 82
R2 = 80
R2 = 80
A0 = ( 82 ) hexa
20
22
24
26
28
2A
2C
2E
30
32
34
2000
11A0
2280
8221
B230
234E
3300
B034
2350
3300
C000
put ( 0 ) in register 0
put Value of Cells (A0) in Register 1
put ( 80 ) in Register 2
Make ( AND ) Between Register ( 2 - 1 ) and put the result in R2
go to address 30 if R2 = R0
put ( 4E ) in Register 3
print value of R3 on screen
go to address 34 if R0 = R0
PUT ( 50 ) in Register 3
print value of R3 on screen
END
R0 = 00
R1 = 82
R2 = 80
R2 = 80
False
A0 = ( 82 ) hexa
20
22
24
26
28
2A
2C
2E
30
32
34
2000
11A0
2280
8221
B230
234E
3300
B034
2350
3300
C000
put ( 0 ) in register 0
put Value of Cells (A0) in Register 1
put ( 80 ) in Register 2
Make ( AND ) Between Register ( 2 - 1 ) and put the result in R2
go to address 30 if R2 = R0
put ( 4E ) in Register 3
print value of R3 on screen
go to address 34 if R0 = R0
PUT ( 50 ) in Register 3
print value of R3 on screen
END
R0 = 00
R1 = 82
R2 = 80
R2 = 80
False
R3 = 4E
A0 = ( 82 ) hexa
20
22
24
26
28
2A
2C
2E
30
32
34
2000
11A0
2280
8221
B230
234E
3300
B034
2350
3300
C000
put ( 0 ) in register 0
put Value of Cells (A0) in Register 1
put ( 80 ) in Register 2
Make ( AND ) Between Register ( 2 - 1 ) and put the result in R2
go to address 30 if R2 = R0
put ( 4E ) in Register 3
print value of R3 on screen
go to address 34 if R0 = R0
PUT ( 50 ) in Register 3
print value of R3 on screen
END
R0 = 00
R1 = 82
R2 = 80
R2 = 80
False
R3 = 4E
4E
A0 = ( 82 ) hexa
20
22
24
26
28
2A
2C
2E
30
32
34
2000
11A0
2280
8221
B230
234E
3300
B034
2350
3300
C000
put ( 0 ) in register 0
put Value of Cells (A0) in Register 1
put ( 80 ) in Register 2
Make ( AND ) Between Register ( 2 - 1 ) and put the result in R2
go to address 30 if R2 = R0
put ( 4E ) in Register 3
print value of R3 on screen
go to address 34 if R0 = R0
PUT ( 50 ) in Register 3
print value of R3 on screen
END
R0 = 00
R1 = 82
R2 = 80
R2 = 80
False
R3 = 4E
4E
True
END
A0 = ( 82 ) hexa
The purpose of this program know if the number is positive or negative by
1) Put ( 00 ) in hexa in register 0
2) Inserting the number in register 1
3) Put ( 80 ) in hexa in register 2
4) Make ( AND ) between register 1 – 2 and put the result in register 2
5) Compare R2 with R0
6) If ( R2 = R0 ) ,then number is positive
7) Put ( 50 ) in register 3
8) Print R3 ( note : 50 = “P” is ASCII )
9) If ( R2 != R0 ) ,then number is negative
10)Put ( 4E ) in register 3
11)Print R3 ( note : 4E = “N” is ASCII )
According to our example A0 = ( 82 )
R0 00000000R0 = 00
According to our example A0 = ( 82 )
R0 00000000
R1 10000010
R0 = 00
R1 = 82
According to our example A0 = ( 82 )
R0 00000000
R1 10000010
R2 10000000
R0 = 00
R1 = 82
R2 = 80
According to our example A0 = ( 82 )
R0 00000000
R1 10000010
R2 10000000
R0 = 00
R1 = 82
R2 = 80
MAKE AND BETWEEN R1 & R2
According to our example A0 = ( 82 )
R0 00000000
R1 10000010
R2 10000000
R2 10000000
R0 = 00
R1 = 82
R2 = 80
R2 = 80
MAKE AND BETWEEN R1 & R2
According to our example A0 = ( 82 )
R0 00000000
R1 10000010
R2 10000000
R2 10000000
R0 = 00
R1 = 82
R2 = 80
R2 = 80
MAKE AND BETWEEN R1 & R2
R2 != R0 , so the number is negative
Assume that a number is stored in memory cell number A0h as a floating point
number using the book's representation. Write a program that converts the
number to its absolute value and store in the same memory cell.
Code in Python :-
num = -127
if ( num < 0 ):
num *= -1
print(num)
Code in machine language :-
We Assume that floating point number in address ( A0 )h is :
( FF )h = ( 11111111 )b
A2
A4
A6
A8
AA
10A0
217F
8210
32A0
C000
put value of cells ( A0 ) in register 0
put ( 7F ) in register 1
Make ( AND ) Between Register ( 1 - 0 ) and put the result in R2
Store value of register ( 2 ) at cells ( A0 )
END
R0 = FF
Code in machine language :-
We Assume that floating point number in address ( A0 )h is :
( FF )h = ( 11111111 )b
A2
A4
A6
A8
AA
10A0
217F
8210
32A0
C000
put value of cells ( A0 ) in register 0
put ( 7F ) in register 1
Make ( AND ) Between Register ( 1 - 0 ) and put the result in R2
Store value of register ( 2 ) at cells ( A0 )
END
R0 = FF
R1 = 7F
Code in machine language :-
We Assume that floating point number in address ( A0 )h is :
( FF )h = ( 11111111 )b
A2
A4
A6
A8
AA
10A0
217F
8210
32A0
C000
put value of cells ( A0 ) in register 0
put ( 7F ) in register 1
Make ( AND ) Between Register ( 1 - 0 ) and put the result in R2
Store value of register ( 2 ) at cells ( A0 )
END
R0 = FF
R1 = 7F
R2 = 7F
Code in machine language :-
We Assume that floating point number in address ( A0 )h is :
( FF )h = ( 11111111 )b
A2
A4
A6
A8
AA
10A0
217F
8210
32A0
C000
put value of cells ( A0 ) in register 0
put ( 7F ) in register 1
Make ( AND ) Between Register ( 1 - 0 ) and put the result in R2
Store value of register ( 2 ) at cells ( A0 )
END
R0 = FF
R1 = 7F
R2 = 7F
A0 = 7F
Code in machine language :-
We Assume that floating point number in address ( A0 )h is :
( FF )h = ( 11111111 )b
A2
A4
A6
A8
AA
10A0
217F
8210
32A0
C000
put value of cells ( A0 ) in register 0
put ( 7F ) in register 1
Make ( AND ) Between Register ( 1 - 0 ) and put the result in R2
Store value of register ( 2 ) at cells ( A0 )
END
R0 = FF
R1 = 7F
R2 = 7F
A0 = 7F
END
According to our example A0 = ( FF )
R0 11111111
R1 01111111
R2 01111111
R0 = FF
R1 = 7F
R2 = 7F
MAKE AND BETWEEN R1 & R0
WE CONVERT VALUE OF ( A0 ) FROM ( -ve ) TO (+ve)
THIS PROGRAM GET ABSOLUTE OF ANY NUMBER
YOU CAN TEST THE PROGRAM WITH ANY
POSITIVE NUMBER
Ehab

More Related Content

What's hot

Passes of compilers
Passes of compilersPasses of compilers
Passes of compilersVairavel C
 
Numerical Algorithms
Numerical AlgorithmsNumerical Algorithms
Numerical AlgorithmsReva Narasimhan
 
02. chapter 3 lexical analysis
02. chapter 3   lexical analysis02. chapter 3   lexical analysis
02. chapter 3 lexical analysisraosir123
 
Regular expressions
Regular expressionsRegular expressions
Regular expressionsShiraz316
 
loaders and linkers
 loaders and linkers loaders and linkers
loaders and linkersTemesgen Molla
 
5. NFA & DFA.pdf
5. NFA & DFA.pdf5. NFA & DFA.pdf
5. NFA & DFA.pdfTANZINTANZINA
 
Map filter reduce in Python
Map filter reduce in PythonMap filter reduce in Python
Map filter reduce in PythonAdnan Siddiqi
 
Module 11
Module 11Module 11
Module 11bittudavis
 
Expression and Operartor In C Programming
Expression and Operartor In C Programming Expression and Operartor In C Programming
Expression and Operartor In C Programming Kamal Acharya
 
C language
C languageC language
C languagePriya698357
 
Solution manual of assembly language programming and organization of the ibm ...
Solution manual of assembly language programming and organization of the ibm ...Solution manual of assembly language programming and organization of the ibm ...
Solution manual of assembly language programming and organization of the ibm ...Tayeen Ahmed
 
Perspective in Informatics 3 - Assignment 2 - Answer Sheet
Perspective in Informatics 3 - Assignment 2 - Answer SheetPerspective in Informatics 3 - Assignment 2 - Answer Sheet
Perspective in Informatics 3 - Assignment 2 - Answer SheetHoang Nguyen Phong
 
Boolean algebra.pptx
Boolean algebra.pptxBoolean algebra.pptx
Boolean algebra.pptxMhhh7
 
Chapter 5The proessor status and the FLAGS registers
Chapter 5The proessor status and the FLAGS registersChapter 5The proessor status and the FLAGS registers
Chapter 5The proessor status and the FLAGS registerswarda aziz
 
Compiler Design LR parsing SLR ,LALR CLR
Compiler Design LR parsing SLR ,LALR CLRCompiler Design LR parsing SLR ,LALR CLR
Compiler Design LR parsing SLR ,LALR CLRRiazul Islam
 

What's hot (20)

Passes of compilers
Passes of compilersPasses of compilers
Passes of compilers
 
Binary parallel adder
Binary parallel adderBinary parallel adder
Binary parallel adder
 
Numerical Algorithms
Numerical AlgorithmsNumerical Algorithms
Numerical Algorithms
 
Assembly Language
Assembly LanguageAssembly Language
Assembly Language
 
02. chapter 3 lexical analysis
02. chapter 3   lexical analysis02. chapter 3   lexical analysis
02. chapter 3 lexical analysis
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
loaders and linkers
 loaders and linkers loaders and linkers
loaders and linkers
 
5. NFA & DFA.pdf
5. NFA & DFA.pdf5. NFA & DFA.pdf
5. NFA & DFA.pdf
 
Map filter reduce in Python
Map filter reduce in PythonMap filter reduce in Python
Map filter reduce in Python
 
Module 11
Module 11Module 11
Module 11
 
Lisp
LispLisp
Lisp
 
Expression and Operartor In C Programming
Expression and Operartor In C Programming Expression and Operartor In C Programming
Expression and Operartor In C Programming
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
C language
C languageC language
C language
 
Solution manual of assembly language programming and organization of the ibm ...
Solution manual of assembly language programming and organization of the ibm ...Solution manual of assembly language programming and organization of the ibm ...
Solution manual of assembly language programming and organization of the ibm ...
 
Perspective in Informatics 3 - Assignment 2 - Answer Sheet
Perspective in Informatics 3 - Assignment 2 - Answer SheetPerspective in Informatics 3 - Assignment 2 - Answer Sheet
Perspective in Informatics 3 - Assignment 2 - Answer Sheet
 
1.Role lexical Analyzer
1.Role lexical Analyzer1.Role lexical Analyzer
1.Role lexical Analyzer
 
Boolean algebra.pptx
Boolean algebra.pptxBoolean algebra.pptx
Boolean algebra.pptx
 
Chapter 5The proessor status and the FLAGS registers
Chapter 5The proessor status and the FLAGS registersChapter 5The proessor status and the FLAGS registers
Chapter 5The proessor status and the FLAGS registers
 
Compiler Design LR parsing SLR ,LALR CLR
Compiler Design LR parsing SLR ,LALR CLRCompiler Design LR parsing SLR ,LALR CLR
Compiler Design LR parsing SLR ,LALR CLR
 

Similar to Machine language

Computer archi&mp
Computer archi&mpComputer archi&mp
Computer archi&mpMSc CST
 
Arithmetic and Logic instructions in Embedded C
Arithmetic and Logic instructions in Embedded CArithmetic and Logic instructions in Embedded C
Arithmetic and Logic instructions in Embedded CVikas Dongre
 
Intel 8051 Programming in C
Intel 8051 Programming in CIntel 8051 Programming in C
Intel 8051 Programming in CSudhanshu Janwadkar
 
arithmetic instructions.pptx
arithmetic instructions.pptxarithmetic instructions.pptx
arithmetic instructions.pptxsavitasj
 
Machine Code from Appendix C Op- code Operand .docx
Machine Code from Appendix C Op-    code  Operand     .docxMachine Code from Appendix C Op-    code  Operand     .docx
Machine Code from Appendix C Op- code Operand .docxsmile790243
 

Similar to Machine language (6)

Computer archi&mp
Computer archi&mpComputer archi&mp
Computer archi&mp
 
Arithmetic and Logic instructions in Embedded C
Arithmetic and Logic instructions in Embedded CArithmetic and Logic instructions in Embedded C
Arithmetic and Logic instructions in Embedded C
 
Microcontroller- An overview
Microcontroller- An overviewMicrocontroller- An overview
Microcontroller- An overview
 
Intel 8051 Programming in C
Intel 8051 Programming in CIntel 8051 Programming in C
Intel 8051 Programming in C
 
arithmetic instructions.pptx
arithmetic instructions.pptxarithmetic instructions.pptx
arithmetic instructions.pptx
 
Machine Code from Appendix C Op- code Operand .docx
Machine Code from Appendix C Op-    code  Operand     .docxMachine Code from Appendix C Op-    code  Operand     .docx
Machine Code from Appendix C Op- code Operand .docx
 

Recently uploaded

Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 đź’ž Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 đź’ž Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 đź’ž Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 đź’ž Full Nigh...Pooja Nehwal
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxShobhayan Kirtania
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 

Recently uploaded (20)

Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 đź’ž Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 đź’ž Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 đź’ž Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 đź’ž Full Nigh...
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 

Machine language

  • 1.
  • 2.
  • 3. Design an algorithm in machine language to print from 0 to 4 Code in Python :- x = 0 while ( x < 5 ): print(x) x = x + 1 x condition output 0 TRUE 0 1 TRUE 1 2 TRUE 2 3 TRUE 3 4 TRUE 4 5 FALSE Output ( 0 - 1 - 2 - 3 - 4 )
  • 4. Code in machine language A1 A2 A4 A6 A8 AA AC AE B0 0 2005 11A1 2201 B1B0 3100 5121 B0A8 C000 A1 contain the value of x put ( 05 ) in register 0 put the value of address ( A1 ) in register 1 put ( 01 ) in register 2 jump to address B0 if the value of R1 equal the value of R0 print the value of R1 on screen R1 = R1 + R2 jump to address A8 if the value of R0 equal the value of R0 End the program R0 = 5
  • 5. Code in machine language A1 A2 A4 A6 A8 AA AC AE B0 0 2005 11A1 2201 B1B0 3100 5121 B0A8 C000 A1 contain the value of x put ( 05 ) in register 0 put the value of address ( A1 ) in register 1 put ( 01 ) in register 2 jump to address B0 if the value of R1 equal the value of R0 print the value of R1 on screen R1 = R1 + R2 jump to address A8 if the value of R0 equal the value of R0 End the program R0 = 5 R1 = 0
  • 6. Code in machine language A1 A2 A4 A6 A8 AA AC AE B0 0 2005 11A1 2201 B1B0 3100 5121 B0A8 C000 A1 contain the value of x put ( 05 ) in register 0 put the value of address ( A1 ) in register 1 put ( 01 ) in register 2 jump to address B0 if the value of R1 equal the value of R0 print the value of R1 on screen R1 = R1 + R2 jump to address A8 if the value of R0 equal the value of R0 End the program R0 = 5 R1 = 0 R2 = 1
  • 7. Code in machine language A1 A2 A4 A6 A8 AA AC AE B0 0 2005 11A1 2201 B1B0 3100 5121 B0A8 C000 A1 contain the value of x put ( 05 ) in register 0 put the value of address ( A1 ) in register 1 put ( 01 ) in register 2 jump to address B0 if the value of R1 equal the value of R0 print the value of R1 on screen R1 = R1 + R2 jump to address A8 if the value of R0 equal the value of R0 End the program R0 = 5 R1 = 0 R2 = 1 FALSE
  • 8. Code in machine language A1 A2 A4 A6 A8 AA AC AE B0 0 2005 11A1 2201 B1B0 3100 5121 B0A8 C000 A1 contain the value of x put ( 05 ) in register 0 put the value of address ( A1 ) in register 1 put ( 01 ) in register 2 jump to address B0 if the value of R1 equal the value of R0 print the value of R1 on screen R1 = R1 + R2 jump to address A8 if the value of R0 equal the value of R0 End the program R0 = 5 R1 = 0 R2 = 1 FALSE 0
  • 9. Code in machine language A1 A2 A4 A6 A8 AA AC AE B0 0 2005 11A1 2201 B1B0 3100 5121 B0A8 C000 A1 contain the value of x put ( 05 ) in register 0 put the value of address ( A1 ) in register 1 put ( 01 ) in register 2 jump to address B0 if the value of R1 equal the value of R0 print the value of R1 on screen R1 = R1 + R2 jump to address A8 if the value of R0 equal the value of R0 End the program R0 = 5 R1 = 1 R2 = 1 FALSE 0
  • 10. Code in machine language A1 A2 A4 A6 A8 AA AC AE B0 0 2005 11A1 2201 B1B0 3100 5121 B0A8 C000 A1 contain the value of x put ( 05 ) in register 0 put the value of address ( A1 ) in register 1 put ( 01 ) in register 2 jump to address B0 if the value of R1 equal the value of R0 print the value of R1 on screen R1 = R1 + R2 jump to address A8 if the value of R0 equal the value of R0 End the program R0 = 5 R1 = 1 R2 = 1 FALSE 0 TRUE
  • 11. Code in machine language A1 A2 A4 A6 A8 AA AC AE B0 0 2005 11A1 2201 B1B0 3100 5121 B0A8 C000 A1 contain the value of x put ( 05 ) in register 0 put the value of address ( A1 ) in register 1 put ( 01 ) in register 2 jump to address B0 if the value of R1 equal the value of R0 print the value of R1 on screen R1 = R1 + R2 jump to address A8 if the value of R0 equal the value of R0 End the program R0 = 5 R1 = 1 R2 = 1 FALSE 0
  • 12. Code in machine language A1 A2 A4 A6 A8 AA AC AE B0 0 2005 11A1 2201 B1B0 3100 5121 B0A8 C000 A1 contain the value of x put ( 05 ) in register 0 put the value of address ( A1 ) in register 1 put ( 01 ) in register 2 jump to address B0 if the value of R1 equal the value of R0 print the value of R1 on screen R1 = R1 + R2 jump to address A8 if the value of R0 equal the value of R0 End the program R0 = 5 R1 = 1 R2 = 1 FALSE 1
  • 13. Code in machine language A1 A2 A4 A6 A8 AA AC AE B0 0 2005 11A1 2201 B1B0 3100 5121 B0A8 C000 A1 contain the value of x put ( 05 ) in register 0 put the value of address ( A1 ) in register 1 put ( 01 ) in register 2 jump to address B0 if the value of R1 equal the value of R0 print the value of R1 on screen R1 = R1 + R2 jump to address A8 if the value of R0 equal the value of R0 End the program R0 = 5 R1 = 2 R2 = 1 FALSE 1
  • 14. Code in machine language A1 A2 A4 A6 A8 AA AC AE B0 0 2005 11A1 2201 B1B0 3100 5121 B0A8 C000 A1 contain the value of x put ( 05 ) in register 0 put the value of address ( A1 ) in register 1 put ( 01 ) in register 2 jump to address B0 if the value of R1 equal the value of R0 print the value of R1 on screen R1 = R1 + R2 jump to address A8 if the value of R0 equal the value of R0 End the program R0 = 5 R1 = 2 R2 = 1 FALSE 1 TRUE
  • 15. Code in machine language A1 A2 A4 A6 A8 AA AC AE B0 0 2005 11A1 2201 B1B0 3100 5121 B0A8 C000 A1 contain the value of x put ( 05 ) in register 0 put the value of address ( A1 ) in register 1 put ( 01 ) in register 2 jump to address B0 if the value of R1 equal the value of R0 print the value of R1 on screen R1 = R1 + R2 jump to address A8 if the value of R0 equal the value of R0 End the program R0 = 5 R1 = 2 R2 = 1 FALSE 1
  • 16. Code in machine language A1 A2 A4 A6 A8 AA AC AE B0 0 2005 11A1 2201 B1B0 3100 5121 B0A8 C000 A1 contain the value of x put ( 05 ) in register 0 put the value of address ( A1 ) in register 1 put ( 01 ) in register 2 jump to address B0 if the value of R1 equal the value of R0 print the value of R1 on screen R1 = R1 + R2 jump to address A8 if the value of R0 equal the value of R0 End the program R0 = 5 R1 = 2 R2 = 1 FALSE 2
  • 17. Code in machine language A1 A2 A4 A6 A8 AA AC AE B0 0 2005 11A1 2201 B1B0 3100 5121 B0A8 C000 A1 contain the value of x put ( 05 ) in register 0 put the value of address ( A1 ) in register 1 put ( 01 ) in register 2 jump to address B0 if the value of R1 equal the value of R0 print the value of R1 on screen R1 = R1 + R2 jump to address A8 if the value of R0 equal the value of R0 End the program R0 = 5 R1 = 3 R2 = 1 FALSE 2
  • 18. Code in machine language A1 A2 A4 A6 A8 AA AC AE B0 0 2005 11A1 2201 B1B0 3100 5121 B0A8 C000 A1 contain the value of x put ( 05 ) in register 0 put the value of address ( A1 ) in register 1 put ( 01 ) in register 2 jump to address B0 if the value of R1 equal the value of R0 print the value of R1 on screen R1 = R1 + R2 jump to address A8 if the value of R0 equal the value of R0 End the program R0 = 5 R1 = 3 R2 = 1 FALSE 2 TRUE
  • 19. Code in machine language A1 A2 A4 A6 A8 AA AC AE B0 0 2005 11A1 2201 B1B0 3100 5121 B0A8 C000 A1 contain the value of x put ( 05 ) in register 0 put the value of address ( A1 ) in register 1 put ( 01 ) in register 2 jump to address B0 if the value of R1 equal the value of R0 print the value of R1 on screen R1 = R1 + R2 jump to address A8 if the value of R0 equal the value of R0 End the program R0 = 5 R1 = 3 R2 = 1 FALSE 3
  • 20. Code in machine language A1 A2 A4 A6 A8 AA AC AE B0 0 2005 11A1 2201 B1B0 3100 5121 B0A8 C000 A1 contain the value of x put ( 05 ) in register 0 put the value of address ( A1 ) in register 1 put ( 01 ) in register 2 jump to address B0 if the value of R1 equal the value of R0 print the value of R1 on screen R1 = R1 + R2 jump to address A8 if the value of R0 equal the value of R0 End the program R0 = 5 R1 = 4 R2 = 1 FALSE 3
  • 21. Code in machine language A1 A2 A4 A6 A8 AA AC AE B0 0 2005 11A1 2201 B1B0 3100 5121 B0A8 C000 A1 contain the value of x put ( 05 ) in register 0 put the value of address ( A1 ) in register 1 put ( 01 ) in register 2 jump to address B0 if the value of R1 equal the value of R0 print the value of R1 on screen R1 = R1 + R2 jump to address A8 if the value of R0 equal the value of R0 End the program R0 = 5 R1 = 4 R2 = 1 FALSE 3 TRUE
  • 22. Code in machine language A1 A2 A4 A6 A8 AA AC AE B0 0 2005 11A1 2201 B1B0 3100 5121 B0A8 C000 A1 contain the value of x put ( 05 ) in register 0 put the value of address ( A1 ) in register 1 put ( 01 ) in register 2 jump to address B0 if the value of R1 equal the value of R0 print the value of R1 on screen R1 = R1 + R2 jump to address A8 if the value of R0 equal the value of R0 End the program R0 = 5 R1 = 4 R2 = 1 FALSE 3
  • 23. Code in machine language A1 A2 A4 A6 A8 AA AC AE B0 0 2005 11A1 2201 B1B0 3100 5121 B0A8 C000 A1 contain the value of x put ( 05 ) in register 0 put the value of address ( A1 ) in register 1 put ( 01 ) in register 2 jump to address B0 if the value of R1 equal the value of R0 print the value of R1 on screen R1 = R1 + R2 jump to address A8 if the value of R0 equal the value of R0 End the program R0 = 5 R1 = 4 R2 = 1 FALSE 4
  • 24. Code in machine language A1 A2 A4 A6 A8 AA AC AE B0 0 2005 11A1 2201 B1B0 3100 5121 B0A8 C000 A1 contain the value of x put ( 05 ) in register 0 put the value of address ( A1 ) in register 1 put ( 01 ) in register 2 jump to address B0 if the value of R1 equal the value of R0 print the value of R1 on screen R1 = R1 + R2 jump to address A8 if the value of R0 equal the value of R0 End the program R0 = 5 R1 = 5 R2 = 1 FALSE 4
  • 25. Code in machine language A1 A2 A4 A6 A8 AA AC AE B0 0 2005 11A1 2201 B1B0 3100 5121 B0A8 C000 A1 contain the value of x put ( 05 ) in register 0 put the value of address ( A1 ) in register 1 put ( 01 ) in register 2 jump to address B0 if the value of R1 equal the value of R0 print the value of R1 on screen R1 = R1 + R2 jump to address A8 if the value of R0 equal the value of R0 End the program R0 = 5 R1 = 5 R2 = 1 FALSE 4 TRUE
  • 26. Code in machine language A1 A2 A4 A6 A8 AA AC AE B0 0 2005 11A1 2201 B1B0 3100 5121 B0A8 C000 A1 contain the value of x put ( 05 ) in register 0 put the value of address ( A1 ) in register 1 put ( 01 ) in register 2 jump to address B0 if the value of R1 equal the value of R0 print the value of R1 on screen R1 = R1 + R2 jump to address A8 if the value of R0 equal the value of R0 End the program R0 = 5 R1 = 5 R2 = 1 true 4 END
  • 27.
  • 28. Design an algorithm in machine language to get the same final result of this code in python :- x = 0 while ( x < 5 ): x = x + 1 Print( x )
  • 29. Code in Python :- x = 0 while ( x < 5 ): x = x + 1 Print( x ) x condition output 0 TRUE 1 TRUE 2 TRUE 3 TRUE 4 TRUE 5 FALSE 5 output ( 5 )
  • 30. Code in machine language A1 A2 A4 A6 A8 AA AC AE B0 0 2005 11A1 2201 B1B0 5121 B0A8 3100 C000 A1 contain the value of x put ( 05 ) in register 0 put the value of address ( A1 ) in register 1 put ( 01 ) in register 2 jump to address B0 if the value of R1 equal the value of R0 R1 = R1 + R2 jump to address A8 if the value of R0 equal the value of R0 print the value of R1 on screen End the program R0 = 5
  • 31. Code in machine language A1 A2 A4 A6 A8 AA AC AE B0 0 2005 11A1 2201 B1B0 5121 B0A8 3100 C000 A1 contain the value of x put ( 05 ) in register 0 put the value of address ( A1 ) in register 1 put ( 01 ) in register 2 jump to address B0 if the value of R1 equal the value of R0 R1 = R1 + R2 jump to address A8 if the value of R0 equal the value of R0 print the value of R1 on screen End the program R0 = 5 R1 = 0
  • 32. Code in machine language A1 A2 A4 A6 A8 AA AC AE B0 0 2005 11A1 2201 B1B0 5121 B0A8 3100 C000 A1 contain the value of x put ( 05 ) in register 0 put the value of address ( A1 ) in register 1 put ( 01 ) in register 2 jump to address B0 if the value of R1 equal the value of R0 R1 = R1 + R2 jump to address A8 if the value of R0 equal the value of R0 print the value of R1 on screen End the program R0 = 5 R1 = 0 R2 = 1
  • 33. Code in machine language A1 A2 A4 A6 A8 AA AC AE B0 0 2005 11A1 2201 B1B0 5121 B0A8 3100 C000 A1 contain the value of x put ( 05 ) in register 0 put the value of address ( A1 ) in register 1 put ( 01 ) in register 2 jump to address B0 if the value of R1 equal the value of R0 R1 = R1 + R2 jump to address A8 if the value of R0 equal the value of R0 print the value of R1 on screen End the program R0 = 5 R1 = 0 R2 = 1 False
  • 34. Code in machine language A1 A2 A4 A6 A8 AA AC AE B0 0 2005 11A1 2201 B1B0 5121 B0A8 3100 C000 A1 contain the value of x put ( 05 ) in register 0 put the value of address ( A1 ) in register 1 put ( 01 ) in register 2 jump to address B0 if the value of R1 equal the value of R0 R1 = R1 + R2 jump to address A8 if the value of R0 equal the value of R0 print the value of R1 on screen End the program R0 = 5 R1 = 1 R2 = 1 False
  • 35. Code in machine language A1 A2 A4 A6 A8 AA AC AE B0 0 2005 11A1 2201 B1B0 5121 B0A8 3100 C000 A1 contain the value of x put ( 05 ) in register 0 put the value of address ( A1 ) in register 1 put ( 01 ) in register 2 jump to address B0 if the value of R1 equal the value of R0 R1 = R1 + R2 jump to address A8 if the value of R0 equal the value of R0 print the value of R1 on screen End the program R0 = 5 R1 = 1 R2 = 1 False true
  • 36. Code in machine language A1 A2 A4 A6 A8 AA AC AE B0 0 2005 11A1 2201 B1B0 5121 B0A8 3100 C000 A1 contain the value of x put ( 05 ) in register 0 put the value of address ( A1 ) in register 1 put ( 01 ) in register 2 jump to address B0 if the value of R1 equal the value of R0 R1 = R1 + R2 jump to address A8 if the value of R0 equal the value of R0 print the value of R1 on screen End the program R0 = 5 R1 = 2 R2 = 1 False
  • 37. Code in machine language A1 A2 A4 A6 A8 AA AC AE B0 0 2005 11A1 2201 B1B0 5121 B0A8 3100 C000 A1 contain the value of x put ( 05 ) in register 0 put the value of address ( A1 ) in register 1 put ( 01 ) in register 2 jump to address B0 if the value of R1 equal the value of R0 R1 = R1 + R2 jump to address A8 if the value of R0 equal the value of R0 print the value of R1 on screen End the program R0 = 5 R1 = 2 R2 = 1 False true
  • 38. Code in machine language A1 A2 A4 A6 A8 AA AC AE B0 0 2005 11A1 2201 B1B0 5121 B0A8 3100 C000 A1 contain the value of x put ( 05 ) in register 0 put the value of address ( A1 ) in register 1 put ( 01 ) in register 2 jump to address B0 if the value of R1 equal the value of R0 R1 = R1 + R2 jump to address A8 if the value of R0 equal the value of R0 print the value of R1 on screen End the program R0 = 5 R1 = 3 R2 = 1 False
  • 39. Code in machine language A1 A2 A4 A6 A8 AA AC AE B0 0 2005 11A1 2201 B1B0 5121 B0A8 3100 C000 A1 contain the value of x put ( 05 ) in register 0 put the value of address ( A1 ) in register 1 put ( 01 ) in register 2 jump to address B0 if the value of R1 equal the value of R0 R1 = R1 + R2 jump to address A8 if the value of R0 equal the value of R0 print the value of R1 on screen End the program R0 = 5 R1 = 3 R2 = 1 False true
  • 40. Code in machine language A1 A2 A4 A6 A8 AA AC AE B0 0 2005 11A1 2201 B1B0 5121 B0A8 3100 C000 A1 contain the value of x put ( 05 ) in register 0 put the value of address ( A1 ) in register 1 put ( 01 ) in register 2 jump to address B0 if the value of R1 equal the value of R0 R1 = R1 + R2 jump to address A8 if the value of R0 equal the value of R0 print the value of R1 on screen End the program R0 = 5 R1 = 4 R2 = 1 False
  • 41. Code in machine language A1 A2 A4 A6 A8 AA AC AE B0 0 2005 11A1 2201 B1B0 5121 B0A8 3100 C000 A1 contain the value of x put ( 05 ) in register 0 put the value of address ( A1 ) in register 1 put ( 01 ) in register 2 jump to address B0 if the value of R1 equal the value of R0 R1 = R1 + R2 jump to address A8 if the value of R0 equal the value of R0 print the value of R1 on screen End the program R0 = 5 R1 = 4 R2 = 1 False true
  • 42. Code in machine language A1 A2 A4 A6 A8 AA AC AE B0 0 2005 11A1 2201 B1B0 5121 B0A8 3100 C000 A1 contain the value of x put ( 05 ) in register 0 put the value of address ( A1 ) in register 1 put ( 01 ) in register 2 jump to address B0 if the value of R1 equal the value of R0 R1 = R1 + R2 jump to address A8 if the value of R0 equal the value of R0 print the value of R1 on screen End the program R0 = 5 R1 = 5 R2 = 1 False
  • 43. Code in machine language A1 A2 A4 A6 A8 AA AC AE B0 0 2005 11A1 2201 B1B0 5121 B0A8 3100 C000 A1 contain the value of x put ( 05 ) in register 0 put the value of address ( A1 ) in register 1 put ( 01 ) in register 2 jump to address B0 if the value of R1 equal the value of R0 R1 = R1 + R2 jump to address A8 if the value of R0 equal the value of R0 print the value of R1 on screen End the program R0 = 5 R1 = 5 R2 = 1 true true
  • 44. Code in machine language A1 A2 A4 A6 A8 AA AC AE B0 0 2005 11A1 2201 B1B0 5121 B0A8 3100 C000 A1 contain the value of x put ( 05 ) in register 0 put the value of address ( A1 ) in register 1 put ( 01 ) in register 2 jump to address B0 if the value of R1 equal the value of R0 R1 = R1 + R2 jump to address A8 if the value of R0 equal the value of R0 print the value of R1 on screen End the program R0 = 5 R1 = 5 R2 = 1 true true 5
  • 45. Code in machine language A1 A2 A4 A6 A8 AA AC AE B0 0 2005 11A1 2201 B1B0 5121 B0A8 3100 C000 A1 contain the value of x put ( 05 ) in register 0 put the value of address ( A1 ) in register 1 put ( 01 ) in register 2 jump to address B0 if the value of R1 equal the value of R0 R1 = R1 + R2 jump to address A8 if the value of R0 equal the value of R0 print the value of R1 on screen End the program R0 = 5 R1 = 5 R2 = 1 true true 5 END
  • 46.
  • 47. Design an algorithm in machine language to get the same final result of this code in python :- x = 5 y = 7 temp = x x = y y = temp print(x,y)
  • 48. Code in Python :- x = 5 y = 7 temp = x x = y y = temp print(x,y) x y temp 5 7 5 7 5 output ( x = 7 -- y = 5 )
  • 49. A0 A1 A2 A4 A6 A8 AA 5 7 11A0 12A1 32A0 31A1 C000 Value of address A0 is ( 5 ) Value of address A1 is ( 7 ) put value of address A0 in Register 1 put value of address A1 in Register 2 Store value of Register 2 in address A0 Store value of Register 1 in address A1 END 5 7
  • 50. A0 A1 A2 A4 A6 A8 AA 5 7 11A0 12A1 32A0 31A1 C000 Value of address A0 is ( 5 ) Value of address A1 is ( 7 ) put value of address A0 in Register 1 put value of address A1 in Register 2 Store value of Register 2 in address A0 Store value of Register 1 in address A1 END 5 7 R1 = 5
  • 51. A0 A1 A2 A4 A6 A8 AA 5 7 11A0 12A1 32A0 31A1 C000 Value of address A0 is ( 5 ) Value of address A1 is ( 7 ) put value of address A0 in Register 1 put value of address A1 in Register 2 Store value of Register 2 in address A0 Store value of Register 1 in address A1 END 5 7 R1 = 5 R2 = 7
  • 52. A0 A1 A2 A4 A6 A8 AA 5 7 11A0 12A1 32A0 31A1 C000 Value of address A0 is ( 5 ) Value of address A1 is ( 7 ) put value of address A0 in Register 1 put value of address A1 in Register 2 Store value of Register 2 in address A0 Store value of Register 1 in address A1 END 7 7 R1 = 5 R2 = 7
  • 53. A0 A1 A2 A4 A6 A8 AA 5 7 11A0 12A1 32A0 31A1 C000 Value of address A0 is ( 5 ) Value of address A1 is ( 7 ) put value of address A0 in Register 1 put value of address A1 in Register 2 Store value of Register 2 in address A0 Store value of Register 1 in address A1 END 7 5 R1 = 5 R2 = 7
  • 54. A0 A1 A2 A4 A6 A8 AA 5 7 11A0 12A1 32A0 31A1 C000 Value of address A0 is ( 5 ) Value of address A1 is ( 7 ) put value of address A0 in Register 1 put value of address A1 in Register 2 Store value of Register 2 in address A0 Store value of Register 1 in address A1 END 7 5 R1 = 5 R2 = 7 END
  • 55.
  • 56. What is the purpose or function of the machine language program on the side? What does it do and how does it do it? What is the purpose or function of the machine language program on the side? What does it do and how does it do it? 20 22 24 26 28 2A 2C 2E 30 32 34 2000 11A0 2280 8221 B230 234E 3300 B034 2350 3300 C000 To understand this question, Assume that the value of A0 = 82 Note : ( 82 ) hexa = ( 10000010 ) binary ( 80 ) hexa = ( 10000000 ) binary
  • 57. 20 22 24 26 28 2A 2C 2E 30 32 34 2000 11A0 2280 8221 B230 234E 3300 B034 2350 3300 C000 put ( 0 ) in register 0 put Value of Cells (A0) in Register 1 put ( 80 ) in Register 2 Make ( AND ) Between Register ( 2 - 1 ) and put the result in R2 go to address 30 if R2 = R0 put ( 4E ) in Register 3 print value of R3 on screen go to address 34 if R0 = R0 PUT ( 50 ) in Register 3 print value of R3 on screen END R0 = 00 A0 = ( 82 ) hexa
  • 58. 20 22 24 26 28 2A 2C 2E 30 32 34 2000 11A0 2280 8221 B230 234E 3300 B034 2350 3300 C000 put ( 0 ) in register 0 put Value of Cells (A0) in Register 1 put ( 80 ) in Register 2 Make ( AND ) Between Register ( 2 - 1 ) and put the result in R2 go to address 30 if R2 = R0 put ( 4E ) in Register 3 print value of R3 on screen go to address 34 if R0 = R0 PUT ( 50 ) in Register 3 print value of R3 on screen END R0 = 00 R1 = 82 A0 = ( 82 ) hexa
  • 59. 20 22 24 26 28 2A 2C 2E 30 32 34 2000 11A0 2280 8221 B230 234E 3300 B034 2350 3300 C000 put ( 0 ) in register 0 put Value of Cells (A0) in Register 1 put ( 80 ) in Register 2 Make ( AND ) Between Register ( 2 - 1 ) and put the result in R2 go to address 30 if R2 = R0 put ( 4E ) in Register 3 print value of R3 on screen go to address 34 if R0 = R0 PUT ( 50 ) in Register 3 print value of R3 on screen END R0 = 00 R1 = 82 R2 = 80 A0 = ( 82 ) hexa
  • 60. 20 22 24 26 28 2A 2C 2E 30 32 34 2000 11A0 2280 8221 B230 234E 3300 B034 2350 3300 C000 put ( 0 ) in register 0 put Value of Cells (A0) in Register 1 put ( 80 ) in Register 2 Make ( AND ) Between Register ( 2 - 1 ) and put the result in R2 go to address 30 if R2 = R0 put ( 4E ) in Register 3 print value of R3 on screen go to address 34 if R0 = R0 PUT ( 50 ) in Register 3 print value of R3 on screen END R0 = 00 R1 = 82 R2 = 80 R2 = 80 A0 = ( 82 ) hexa
  • 61. 20 22 24 26 28 2A 2C 2E 30 32 34 2000 11A0 2280 8221 B230 234E 3300 B034 2350 3300 C000 put ( 0 ) in register 0 put Value of Cells (A0) in Register 1 put ( 80 ) in Register 2 Make ( AND ) Between Register ( 2 - 1 ) and put the result in R2 go to address 30 if R2 = R0 put ( 4E ) in Register 3 print value of R3 on screen go to address 34 if R0 = R0 PUT ( 50 ) in Register 3 print value of R3 on screen END R0 = 00 R1 = 82 R2 = 80 R2 = 80 False A0 = ( 82 ) hexa
  • 62. 20 22 24 26 28 2A 2C 2E 30 32 34 2000 11A0 2280 8221 B230 234E 3300 B034 2350 3300 C000 put ( 0 ) in register 0 put Value of Cells (A0) in Register 1 put ( 80 ) in Register 2 Make ( AND ) Between Register ( 2 - 1 ) and put the result in R2 go to address 30 if R2 = R0 put ( 4E ) in Register 3 print value of R3 on screen go to address 34 if R0 = R0 PUT ( 50 ) in Register 3 print value of R3 on screen END R0 = 00 R1 = 82 R2 = 80 R2 = 80 False R3 = 4E A0 = ( 82 ) hexa
  • 63. 20 22 24 26 28 2A 2C 2E 30 32 34 2000 11A0 2280 8221 B230 234E 3300 B034 2350 3300 C000 put ( 0 ) in register 0 put Value of Cells (A0) in Register 1 put ( 80 ) in Register 2 Make ( AND ) Between Register ( 2 - 1 ) and put the result in R2 go to address 30 if R2 = R0 put ( 4E ) in Register 3 print value of R3 on screen go to address 34 if R0 = R0 PUT ( 50 ) in Register 3 print value of R3 on screen END R0 = 00 R1 = 82 R2 = 80 R2 = 80 False R3 = 4E 4E A0 = ( 82 ) hexa
  • 64. 20 22 24 26 28 2A 2C 2E 30 32 34 2000 11A0 2280 8221 B230 234E 3300 B034 2350 3300 C000 put ( 0 ) in register 0 put Value of Cells (A0) in Register 1 put ( 80 ) in Register 2 Make ( AND ) Between Register ( 2 - 1 ) and put the result in R2 go to address 30 if R2 = R0 put ( 4E ) in Register 3 print value of R3 on screen go to address 34 if R0 = R0 PUT ( 50 ) in Register 3 print value of R3 on screen END R0 = 00 R1 = 82 R2 = 80 R2 = 80 False R3 = 4E 4E True END A0 = ( 82 ) hexa
  • 65. The purpose of this program know if the number is positive or negative by 1) Put ( 00 ) in hexa in register 0 2) Inserting the number in register 1 3) Put ( 80 ) in hexa in register 2 4) Make ( AND ) between register 1 – 2 and put the result in register 2 5) Compare R2 with R0 6) If ( R2 = R0 ) ,then number is positive 7) Put ( 50 ) in register 3 8) Print R3 ( note : 50 = “P” is ASCII ) 9) If ( R2 != R0 ) ,then number is negative 10)Put ( 4E ) in register 3 11)Print R3 ( note : 4E = “N” is ASCII )
  • 66. According to our example A0 = ( 82 ) R0 00000000R0 = 00
  • 67. According to our example A0 = ( 82 ) R0 00000000 R1 10000010 R0 = 00 R1 = 82
  • 68. According to our example A0 = ( 82 ) R0 00000000 R1 10000010 R2 10000000 R0 = 00 R1 = 82 R2 = 80
  • 69. According to our example A0 = ( 82 ) R0 00000000 R1 10000010 R2 10000000 R0 = 00 R1 = 82 R2 = 80 MAKE AND BETWEEN R1 & R2
  • 70. According to our example A0 = ( 82 ) R0 00000000 R1 10000010 R2 10000000 R2 10000000 R0 = 00 R1 = 82 R2 = 80 R2 = 80 MAKE AND BETWEEN R1 & R2
  • 71. According to our example A0 = ( 82 ) R0 00000000 R1 10000010 R2 10000000 R2 10000000 R0 = 00 R1 = 82 R2 = 80 R2 = 80 MAKE AND BETWEEN R1 & R2 R2 != R0 , so the number is negative
  • 72.
  • 73. Assume that a number is stored in memory cell number A0h as a floating point number using the book's representation. Write a program that converts the number to its absolute value and store in the same memory cell.
  • 74. Code in Python :- num = -127 if ( num < 0 ): num *= -1 print(num)
  • 75. Code in machine language :- We Assume that floating point number in address ( A0 )h is : ( FF )h = ( 11111111 )b A2 A4 A6 A8 AA 10A0 217F 8210 32A0 C000 put value of cells ( A0 ) in register 0 put ( 7F ) in register 1 Make ( AND ) Between Register ( 1 - 0 ) and put the result in R2 Store value of register ( 2 ) at cells ( A0 ) END R0 = FF
  • 76. Code in machine language :- We Assume that floating point number in address ( A0 )h is : ( FF )h = ( 11111111 )b A2 A4 A6 A8 AA 10A0 217F 8210 32A0 C000 put value of cells ( A0 ) in register 0 put ( 7F ) in register 1 Make ( AND ) Between Register ( 1 - 0 ) and put the result in R2 Store value of register ( 2 ) at cells ( A0 ) END R0 = FF R1 = 7F
  • 77. Code in machine language :- We Assume that floating point number in address ( A0 )h is : ( FF )h = ( 11111111 )b A2 A4 A6 A8 AA 10A0 217F 8210 32A0 C000 put value of cells ( A0 ) in register 0 put ( 7F ) in register 1 Make ( AND ) Between Register ( 1 - 0 ) and put the result in R2 Store value of register ( 2 ) at cells ( A0 ) END R0 = FF R1 = 7F R2 = 7F
  • 78. Code in machine language :- We Assume that floating point number in address ( A0 )h is : ( FF )h = ( 11111111 )b A2 A4 A6 A8 AA 10A0 217F 8210 32A0 C000 put value of cells ( A0 ) in register 0 put ( 7F ) in register 1 Make ( AND ) Between Register ( 1 - 0 ) and put the result in R2 Store value of register ( 2 ) at cells ( A0 ) END R0 = FF R1 = 7F R2 = 7F A0 = 7F
  • 79. Code in machine language :- We Assume that floating point number in address ( A0 )h is : ( FF )h = ( 11111111 )b A2 A4 A6 A8 AA 10A0 217F 8210 32A0 C000 put value of cells ( A0 ) in register 0 put ( 7F ) in register 1 Make ( AND ) Between Register ( 1 - 0 ) and put the result in R2 Store value of register ( 2 ) at cells ( A0 ) END R0 = FF R1 = 7F R2 = 7F A0 = 7F END
  • 80. According to our example A0 = ( FF ) R0 11111111 R1 01111111 R2 01111111 R0 = FF R1 = 7F R2 = 7F MAKE AND BETWEEN R1 & R0 WE CONVERT VALUE OF ( A0 ) FROM ( -ve ) TO (+ve)
  • 81. THIS PROGRAM GET ABSOLUTE OF ANY NUMBER YOU CAN TEST THE PROGRAM WITH ANY POSITIVE NUMBER
  • 82. Ehab