Professional Documents
Culture Documents
Start DB DB DB DB Start: Simple Example Writes Hello World To The Output
Start DB DB DB DB Start: Simple Example Writes Hello World To The Output
Start DB DB DB DB Start: Simple Example Writes Hello World To The Output
; Simple example
2. ; Writes Hello World to the output
3.
4. JMP start
5. hello: DB "sin( 0)=" ; Variable
6. DB 0 ; String terminator
7. sudut: DB "3330272421181512 9 6 3"
8. sin: DB "-0.5 -0.87-1 -0.87-0.5 0 0.5 0.87 1 0.87 0.5 "
9.
10. start:
11. MOV C, hello ; Point to var
12. MOV D, 232 ; Point to output
13. CALL print
14. MOV A, 10
15. .loop3:
16. MOV B, 2
17. MOV C, sudut
18. MOV D, 0xEC
19. CALL printsudut
20.
21. MOV B, 5
22. MOV C, sin
23. MOV D, 0xF1
24. CALL printsudut
25. DEC A
26. JNZ .loop3
27. MOV A, 10
28. JMP .loop3
29.
30. HLT ; Stop execution
31.
32. print: ; print(C:*from, D:*to)
33. PUSH A
34. PUSH B
35. MOV B, 0
36. .loop:
37. MOV A, [C] ; Get char from var
38. MOV [D], A ; Write to output
39. INC C
40. INC D
41. CMP B, [C] ; Check if end
42. JNZ .loop ; jump if not
43.
44. POP B
45. POP A
46. RET
47.
48. printsudut: ; print(C:*from, D:*to)
49. PUSH A
50. PUSH B
51. PUSH C
52. PUSH D
53. MUL B
54. ADD A, C
55. .loop2:
56. MOV C,[A]
57. MOV [D],C
58. INC A
59. INC D
60. DEC B
61. JNZ .loop2
62. POP D
63. POP C
64. POP B
65. POP A
66. RET
67.