aboutsummaryrefslogtreecommitdiff
path: root/CS2771/Assmbly1.s
blob: 4719280f438d094107753cd5cf1c2128737fc106 (plain)
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
74
75
76
77
78
79
80
81
82
83
84
;Tucker Evans
;CS3871
;A collection of Assembly programs written from c code


;1
; char i,j;
;
; i=3;
; j = i+i;

start:
	MOV	A, #0
	MOV	R0, #3
	MOV	A, R0
	ADD	A, R0
	MOV	R1, A
	JMP start


;2
; char a,b;
;
; a=64;
; while (a > 0) {
;         b = a;
;         a--;
; }

start:
	MOV A, #64
test:
	JNZ loop
	JMP start


loop:
	MOV R0, A
	DEC A
	JMP test

;3
; char i,j,k;
; i=3;
; j=5;
; if (i == j)
;         k=8;
; else
;         k=9;

start:

	MOV R0, #3
	MOV	R1,	#5

	MOV A, R0
	MOV #40h, A
	CJNE R1, #40h, false
	MOV R3, #8
	JMP start

false:
	MOV R3, #9
	JMP start

;4
; char buf[64];
; char i;
;
; for (i=0; i<64; i++)
;         buf[i]=i;

start:
	MOV R0, #0
	MOV R1, #20h
	MOV A, R0
l1:
	CJNE A, #64, l2
	JMP start
l2:
	MOV @R1, A
	INC A
	INC R1
	JMP l1