/[cvs.andrew.net.au]/uni/COMP2300/assignment2/topics.txt
ViewVC logotype

Contents of /uni/COMP2300/assignment2/topics.txt

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations)
Tue May 18 12:27:28 2004 UTC (18 years, 8 months ago) by apollock
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +30 -25 lines
File MIME type: text/plain
Ready for submission

1 /* ---------------------------------------------------------------------
2
3 Name: Andrew Pollock
4 Student Number: 4137129
5 Unit: COMP2300
6 Assignment Number: 2
7 Name of this file: topics.txt
8 Lab Group: Tuesday 0900
9
10
11 I declare that the material I am submitting in this file is entirely
12 my own work. I have not collaborated with anyone to produce it, nor
13 have I copied it, in part or in full, from work produced by someone else.
14
15 --------------------------------------------------------------------- */
16
17 For all machines, it takes 6 bits to reference one of the 65536 memory cells.
18
19 Question 1:
20
21 Machine 1: ; dc is your friend
22
23 PUSH Mb
24 PUSH Mc
25 PUSH Md
26 MUL ; Top of stack now contains result of Mc * Md
27 ADD ; Top of stack now contains result of (Mc * Md) + Mb
28 PUSH Mb
29 PUSH Me
30 PUSH Mf
31 DIV ; Top of stack now contains result of Me / Mf
32 SUB ; Top of stack now contains result of Mb - (Me / Mf)
33 DIV ; Top of stack now contains result of formula
34 POP Ma ; Save top of stack in Ma
35
36 Machine 2:
37
38 LOAD Mc ; This is just like PeANUt
39 MUL Md
40 ADD Mb
41 STORE Mc
42 LOAD Me
43 DIV Mf
44 STORE Mf
45 LOAD Mb
46 SUB Mf
47 STORE Mf
48 LOAD Mc
49 DIV Mf
50 STORE Ma
51
52 Machine 3:
53
54 LOAD R0,Mb ; Load Mb into register 0
55 LOAD R1, Mc ; Load Mc into register 1
56 LOAD R2, Md ; Load Md into register 2
57 MUL R1, R2, R3 ; Multiply register 1 (Mc) and register 2 (Md) store in 3
58 ADD R3, R0, R1 ; Add register 3 (Mc*Md) and register 0 (Mb), store in register 1
59 LOAD R2, Me ; Load Me into register 2
60 LOAD R3, Mf ; Load Mf into register 3
61 DIV R2, R3, R4 ; Divide register 2 (Me) by register 3 (Mf), store in 4
62 SUB R0, R4, R2 ; Subtract register 4 (Me/Mf) from register 0, store in 2
63 DIV R1, R2, R0 ; Divide register 1 by register 2, store in register 0
64 STORE Ma, R0 ; Store register 0 in Ma
65
66 Machine 4:
67
68 MUL Mc, Md ; Mc contains Mc * Md
69 ADD Mc, Mb ; Mc contains Mc + Mb [ ((Mc * Md) + Mb ]
70 DIV Me, Mf ; Me contains Me / Mf
71 SUB Mb, Me ; Mb contains Mb - Me [ Mb - (Me / Mf) ]
72 DIV Mc, Mb ; Mc contains Mc / Mb
73 MOV Mc, Ma ; Store Mc in Ma
74
75 Question 2:
76
77 Machine 1:
78
79 I = instruction length
80 M = memory address size
81 P = pad to get to a 4 bit boundary
82
83 I M P
84 PUSH Mb 8 + 6 = 14 + 2 = 16
85 PUSH Mc 8 + 6 = 14 + 2 = 16
86 PUSH Md 8 + 6 = 14 + 2 = 16
87 MUL 8
88 ADD 8
89 PUSH Mb 8 + 6 = 14 + 2 = 16
90 PUSH Me 8 + 6 = 14 + 2 = 16
91 PUSH Mf 8 + 6 = 14 + 2 = 16
92 DIV 8
93 SUB 8
94 DIV 8
95 POP Ma 8 + 6 = 14 + 2 = 16
96
97 Machine 1 total memory used: 152 bytes
98
99 Machine 2:
100
101 LOAD Mc 8 + 6 = 14 + 2 = 16
102 MUL Md 8 + 6 = 14 + 2 = 16
103 ADD Mb 8 + 6 = 14 + 2 = 16
104 STORE Mc 8 + 6 = 14 + 2 = 16
105 LOAD Me 8 + 6 = 14 + 2 = 16
106 DIV Mf 8 + 6 = 14 + 2 = 16
107 STORE Mf 8 + 6 = 14 + 2 = 16
108 LOAD Mb 8 + 6 = 14 + 2 = 16
109 SUB Mf 8 + 6 = 14 + 2 = 16
110 STORE Mf 8 + 6 = 14 + 2 = 16
111 LOAD Mc 8 + 6 = 14 + 2 = 16
112 DIV Mf 8 + 6 = 14 + 2 = 16
113 STORE Ma 8 + 6 = 14 + 2 = 16
114
115 Machine 3 total memory used: 208 bytes
116
117 Machine 3:
118
119 LOAD R0,Mb 8 + 4 + 6 = 18 + 2 = 20
120 LOAD R1, Mc 8 + 4 + 6 = 18 + 2 = 20
121 LOAD R2, Md 8 + 4 + 6 = 18 + 2 = 20
122 MUL R1, R2, R3 8 + 4 + 4 + 4 = 20
123 ADD R3, R0, R1 8 + 4 + 4 + 4 = 20
124 LOAD R2, Me 8 + 4 + 6 = 18 + 2 = 20
125 LOAD R3, Mf 8 + 4 + 6 = 18 + 2 = 20
126 DIV R2, R3, R4 8 + 4 + 4 + 4 = 20
127 SUB R0, R4, R2 8 + 4 + 4 + 4 = 20
128 DIV R1, R2, R0 8 + 4 + 4 + 4 = 20
129 STORE Ma, R0 8 + 6 + 4 + 2 = 20
130
131 Machine 3 total memory used: 242 bytes
132
133 Machine 4:
134
135 MUL Mc, Md 8 + 6 + 6 = 20
136 ADD Mc, Mb 8 + 6 + 6 = 20
137 DIV Me, Mf 8 + 6 + 6 = 20
138 SUB Mb, Me 8 + 6 + 6 = 20
139 DIV Mc, Mb 8 + 6 + 6 = 20
140 MOV Mc, Ma 8 + 6 + 6 = 20
141
142 Machine 4 total memory used: 120 bytes

  ViewVC Help
Powered by ViewVC 1.1.22