-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lab2b.s
66 lines (46 loc) · 1.58 KB
/
Lab2b.s
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
/* DO NOT MODIFY THIS --------------------------------------------*/
.text
.global AssemblyProgram
AssemblyProgram:
lea -40(%a7),%a7 /*Backing up data and address registers */
movem.l %d2-%d7/%a2-%a5,(%a7)
/*----------------------------------------------------------------*/
/******************************************************************/
/* General Information ********************************************/
/* File Name: Lab2.s *********************************************/
/* Names of Students: _________________ and ____________________ **/
/* Date: _________________ **/
/* General Description: **/
/* **/
/******************************************************************/
/*Write your program here******************************************/
clr.l %d3
move.l 0x2300000, %d4
sub.l #1, %d4
move.l 0x2300004, %a2
move.l 0x2300008, %a3
move.l 0x230000C, %a4
clr.l (%a4)
loop: move.l (%a3)+, %d3
add.l (%a3), %d3
move.l 4(%a2),%d5
sub.l (%a2)+, %d5
cmpi.l #2, %d5
blt next1
asl.l #1, %d3
next1: add.l %d3, (%a4)
sub.l #1, %d4
bne loop
move.l (%a4), %d3
asr.l #1, %d3
bcc next2
add.l #1, %d3
next2:
move.l 0x2300010, %a2
move.l %d3, (%a2)
/*End of program **************************************************/
/* DO NOT MODIFY THIS --------------------------------------------*/
movem.l (%a7),%d2-%d7/%a2-%a5 /*Restore data and address registers */
lea 40(%a7),%a7
rts
/*----------------------------------------------------------------*/