-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enh(armasm) support // and # style line comments (#2410)
* enh(armasm) support line comments // and # Fixes #2408. * fix(armasm) instructions should not include the space after * fix(armasm) symbols should not include prior newline * add generic test case * comment should not include whitespace at beginning * also accept tabs as white space
- Loading branch information
1 parent
fb6181a
commit a34abcb
Showing
3 changed files
with
62 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<span class="hljs-comment">//=================== YOUR CODE GOES IN THE SECTION BELOW ===================//</span> | ||
|
||
<span class="hljs-comment"># check for and handle zero</span> | ||
<span class="hljs-keyword">orr</span> <span class="hljs-built_in">r1</span>, <span class="hljs-built_in">r0</span>, <span class="hljs-number">#128</span> <span class="hljs-comment">// r1 = r0 | 128</span> | ||
<span class="hljs-keyword">cmp</span> <span class="hljs-built_in">r1</span>, <span class="hljs-number">#128</span> <span class="hljs-comment">// if r1 == 128 {</span> | ||
<span class="hljs-keyword">bne</span> notZero <span class="hljs-comment">// .</span> | ||
<span class="hljs-keyword">bl</span> zeroQuidFP2float <span class="hljs-comment">// zeroQuidFP2float() }</span> | ||
<span class="hljs-keyword">b</span> <span class="hljs-meta">end</span> <span class="hljs-comment">// else {</span> | ||
|
||
<span class="hljs-symbol">notZero:</span> <span class="hljs-comment">// .</span> | ||
<span class="hljs-comment"># extract fields from quidfp</span> | ||
<span class="hljs-keyword">and</span> <span class="hljs-built_in">r1</span>, <span class="hljs-built_in">r0</span>, <span class="hljs-number">#128</span> <span class="hljs-comment">// r1 = r0 & 128 // sign</span> | ||
<span class="hljs-keyword">and</span> <span class="hljs-built_in">r2</span>, <span class="hljs-built_in">r0</span>, <span class="hljs-number">#112</span> <span class="hljs-comment">// r2 = r0 & 112 // exponent</span> | ||
<span class="hljs-keyword">and</span> <span class="hljs-built_in">r3</span>, <span class="hljs-built_in">r0</span>, <span class="hljs-number">#15</span> <span class="hljs-comment">// r3 = r0 & 15 // mantissa</span> | ||
|
||
<span class="hljs-comment">// ...</span> | ||
|
||
<span class="hljs-comment"># combine into r0</span> | ||
<span class="hljs-keyword">orr</span> <span class="hljs-built_in">r0</span>, <span class="hljs-built_in">r1</span>, <span class="hljs-built_in">r2</span> <span class="hljs-comment">// r0 = r1 | r2</span> | ||
<span class="hljs-keyword">orr</span> <span class="hljs-built_in">r0</span>, <span class="hljs-built_in">r0</span>, <span class="hljs-built_in">r3</span> <span class="hljs-comment">// r0 = r0 | r3 }</span> | ||
|
||
<span class="hljs-symbol">end:</span> <span class="hljs-comment">// return r0</span> | ||
|
||
<span class="hljs-comment">//===========================================================================//</span> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//=================== YOUR CODE GOES IN THE SECTION BELOW ===================// | ||
|
||
# check for and handle zero | ||
orr r1, r0, #128 // r1 = r0 | 128 | ||
cmp r1, #128 // if r1 == 128 { | ||
bne notZero // . | ||
bl zeroQuidFP2float // zeroQuidFP2float() } | ||
b end // else { | ||
|
||
notZero: // . | ||
# extract fields from quidfp | ||
and r1, r0, #128 // r1 = r0 & 128 // sign | ||
and r2, r0, #112 // r2 = r0 & 112 // exponent | ||
and r3, r0, #15 // r3 = r0 & 15 // mantissa | ||
|
||
// ... | ||
|
||
# combine into r0 | ||
orr r0, r1, r2 // r0 = r1 | r2 | ||
orr r0, r0, r3 // r0 = r0 | r3 } | ||
|
||
end: // return r0 | ||
|
||
//===========================================================================// |