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 )
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