Skip to content

Commit aafa0f6

Browse files
committed
Minor fixes/improvements, update copyright
1 parent fc95a30 commit aafa0f6

8 files changed

+60
-18
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
All book related files are
3-
(C) 2021 http://robertwinkler.com[Robert Winkler]
3+
(C) 2021-2022 http://robertwinkler.com[Robert Winkler]
44

55
Licensed under https://creativecommons.org/licenses/by-nc-sa/4.0/[Creative Commons].
66

book.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
= MIPS Assembly Programmming
44
Robert Winkler <[email protected]>
5-
v0.9.7, 2021-09-28: Beta
5+
v0.9.8, 2022-01-08: Beta
66
:toc:
77

88
//include::contents.adoc[]

ch7.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ it, even less than I would in a higher level language.
5050
. *Put the `.data` section at the top, similar to declaring globals in C.*
5151
+
5252
There are exceptions for this. When dealing with a larger program with lots
53-
of strings, it can be convienent to have multiple `.data` sections with the
53+
of strings, it can be convenient to have multiple `.data` sections with the
5454
strings you're using declared close to where you use them. The downside is
5555
you have to keep swapping back and forth between `.text` and `.data`.
5656

@@ -477,7 +477,7 @@ include::pseudo_equivalents_pdf.adoc[]
477477
endif::[]
478478

479479
You can see how you use the non-pseudoinstructions to match the same behavior, and
480-
there's often (usually) more than one way. Of all of them, the `ble` and `bge` are
480+
there's often (usually) more than one way. Of all of them, `ble` is
481481
the worst, because what was 1 instruction becomes 3, and you'll sometimes need an
482482
extra register to hold the "plus 1" value if you still need the original.
483483

info.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
== Info
22

3-
Copyright (C) 2021 http://robertwinkler.com[Robert Winkler]
3+
Copyright (C) 2021-2022 http://robertwinkler.com[Robert Winkler]
44

55
Licensed under https://creativecommons.org/licenses/by-nc-sa/4.0/[Creative Commons].
66

mips_book.html

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -521,8 +521,8 @@ <h1>MIPS Assembly Programmming</h1>
521521
<div class="details">
522522
<span id="author" class="author">Robert Winkler</span><br>
523523
<span id="email" class="email"><a href="mailto:[email protected]">[email protected]</a></span><br>
524-
<span id="revnumber">version 0.9.7,</span>
525-
<span id="revdate">2021-09-28</span>
524+
<span id="revnumber">version 0.9.8,</span>
525+
<span id="revdate">2022-01-08</span>
526526
<br><span id="revremark">Beta</span>
527527
</div>
528528
<div id="toc" class="toc">
@@ -599,7 +599,7 @@ <h1>MIPS Assembly Programmming</h1>
599599
<h2 id="_info">Info</h2>
600600
<div class="sectionbody">
601601
<div class="paragraph">
602-
<p>Copyright &#169; 2021 <a href="http://robertwinkler.com">Robert Winkler</a></p>
602+
<p>Copyright &#169; 2021-2022 <a href="http://robertwinkler.com">Robert Winkler</a></p>
603603
</div>
604604
<div class="paragraph">
605605
<p>Licensed under <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons</a>.</p>
@@ -4268,7 +4268,7 @@ <h3 id="_formatting">Formatting</h3>
42684268
<p><strong>Put the <code>.data</code> section at the top, similar to declaring globals in C.</strong></p>
42694269
<div class="paragraph">
42704270
<p>There are exceptions for this. When dealing with a larger program with lots
4271-
of strings, it can be convienent to have multiple <code>.data</code> sections with the
4271+
of strings, it can be convenient to have multiple <code>.data</code> sections with the
42724272
strings you&#8217;re using declared close to where you use them. The downside is
42734273
you have to keep swapping back and forth between <code>.text</code> and <code>.data</code>.</p>
42744274
</div>
@@ -5200,6 +5200,14 @@ <h3 id="_no_pseudoinstructions_allowed">No Pseudoinstructions Allowed</h3>
52005200
bne $t2, $0, label</pre>
52015201
</div>
52025202
</div>
5203+
<div class="literalblock">
5204+
<div class="content">
5205+
<pre># or if you're counting up and
5206+
# you know they'll be equal,
5207+
# you can simplify to
5208+
bne $t0, $t1, label</pre>
5209+
</div>
5210+
</div>
52035211
<hr></div></td>
52045212
</tr>
52055213
<tr>
@@ -5227,9 +5235,19 @@ <h3 id="_no_pseudoinstructions_allowed">No Pseudoinstructions Allowed</h3>
52275235
</div></div></td>
52285236
<td class="tableblock halign-left valign-top"><div class="content"><div class="literalblock">
52295237
<div class="content">
5230-
<pre># add 1 to change &lt;= to &lt;
5231-
addi $t1, $t1, 1
5238+
<pre># test for &lt; and = separately
52325239
slt $t2, $t0, $t1
5240+
bne $t2, $0, label
5241+
beq $t0, $t1, label</pre>
5242+
</div>
5243+
</div>
5244+
<div class="literalblock">
5245+
<div class="content">
5246+
<pre># or add 1 to change &lt;= to &lt;
5247+
# use a spare reg if you need
5248+
# to preserve the original value
5249+
addi $t3, $t1, 1
5250+
slt $t2, $t0, $t3
52335251
bne $t2, $0, label</pre>
52345252
</div>
52355253
</div>
@@ -5256,7 +5274,7 @@ <h3 id="_no_pseudoinstructions_allowed">No Pseudoinstructions Allowed</h3>
52565274
</table>
52575275
<div class="paragraph">
52585276
<p>You can see how you use the non-pseudoinstructions to match the same behavior, and
5259-
there&#8217;s often (usually) more than one way. Of all of them, the <code>ble</code> and <code>bge</code> are
5277+
there&#8217;s often (usually) more than one way. Of all of them, <code>ble</code> is
52605278
the worst, because what was 1 instruction becomes 3, and you&#8217;ll sometimes need an
52615279
extra register to hold the "plus 1" value if you still need the original.</p>
52625280
</div>
@@ -5514,8 +5532,8 @@ <h2 id="_references_and_useful_links">References and Useful Links</h2>
55145532
</div>
55155533
<div id="footer">
55165534
<div id="footer-text">
5517-
Version 0.9.7<br>
5518-
Last updated 2021-12-28 13:52:39 -0700
5535+
Version 0.9.8<br>
5536+
Last updated 2022-01-08 13:07:18 -0700
55195537
</div>
55205538
</div>
55215539
</body>

mips_book.pdf

3.26 KB
Binary file not shown.

pseudo_equivalents.adoc

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@
5353
slt $t2, $t0, $t1
5454
bne $t2, $0, label
5555

56+
# or if you're counting up and
57+
# you know they'll be equal,
58+
# you can simplify to
59+
bne $t0, $t1, label
60+
5661
'''
5762

5863
| Branch Greater Than |
@@ -69,10 +74,17 @@
6974

7075
ble $t0, $t1, label |
7176

72-
# add 1 to change <= to <
73-
addi $t1, $t1, 1
77+
# test for < and = separately
7478
slt $t2, $t0, $t1
7579
bne $t2, $0, label
80+
beq $t0, $t1, label
81+
82+
# or add 1 to change <= to <
83+
# use a spare reg if you need
84+
# to preserve the original value
85+
addi $t3, $t1, 1
86+
slt $t2, $t0, $t3
87+
bne $t2, $0, label
7688

7789
'''
7890

pseudo_equivalents_pdf.adoc

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@
4444
slt $t2, $t0, $t1
4545
bne $t2, $0, label
4646

47+
# or if you're counting up and
48+
# you know they'll be equal,
49+
# you can simplify to
50+
bne $t0, $t1, label
51+
4752
| Branch Greater Than |
4853

4954
bgt $t0, $t1, label |
@@ -56,10 +61,17 @@
5661

5762
ble $t0, $t1, label |
5863

59-
# add 1 to change <= to <
60-
addi $t1, $t1, 1
64+
# test for < and = separately
6165
slt $t2, $t0, $t1
6266
bne $t2, $0, label
67+
beq $t0, $t1, label
68+
69+
# or add 1 to change <= to <
70+
# use a spare reg if you need
71+
# to preserve the original value
72+
addi $t3, $t1, 1
73+
slt $t2, $t0, $t3
74+
bne $t2, $0, label
6375

6476
| Branch Greater Than or Equal |
6577

0 commit comments

Comments
 (0)