forked from shane-e945/Python-Assembly-Interpreter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.asm
More file actions
73 lines (60 loc) · 1.16 KB
/
test.asm
File metadata and controls
73 lines (60 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
; =============================================
; Simple Assembly Program for Demonstration
; =============================================
; Initialize registers
mov a, 10
mov b, 20
mov c, 0
mov d, 100
mov counter, 5
; Basic arithmetic operations
add a, 5
sub b, 3
mul c, 4
div d, 2
inc a
dec b
; Compare values
cmp a, 16
je equal_section
jmp not_equal_section
equal_section:
msg 'Values are equal (16 and 16)'
jmp end_comparison
not_equal_section:
msg 'Values are not equal'
end_comparison:
msg 'Comparison complete'
; Loop demonstration
msg 'Starting loop demonstration'
loop_start:
msg 'Counter: ', counter
dec counter
cmp counter, 0
jg loop_start
msg 'Loop finished'
; Function call
mov x, 2
mov y, 3
call multiply_function
msg 'Result of 2 * 3: ', z
; Memory operations
stw a, 1000
mvw temp, 1000
msg 'Memory value: ', temp
; Final output
msg '=== Program Results ==='
msg 'Register a: ', a
msg 'Register b: ', b
msg 'Register d: ', d
msg 'Memory temp: ', temp
msg 'Final counter: ', counter
msg '========================'
jmp end_of_program
; Multiply function
multiply_function:
mov z, x
mul z, y
ret
end_of_program:
end