Skip to content

Commit 5fe07e5

Browse files
committed
restore v1.0.2
1 parent 74229e2 commit 5fe07e5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1224
-479
lines changed

examples/Defines.nsl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
OutFile("Defines.exe");
2+
ShowInstDetails("show");
23
XPStyle("on");
34
RequestExecutionLevel("admin");
4-
ShowInstDetails("show");
55

66
section Test()
77
{

examples/Factorial.nsl

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
OutFile("Test.exe");
1+
OutFile("Factorial.exe");
22
ShowInstDetails("show");
3+
XPStyle("on");
4+
RequestExecutionLevel("admin");
35

46
/*
57
Modified from http://introcs.cs.princeton.edu/23recursion/Fibonacci.java.html

examples/Fibonacci.nsl

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
OutFile("Test.exe");
1+
OutFile("Fibonacci.exe");
22
ShowInstDetails("show");
3+
XPStyle("on");
4+
RequestExecutionLevel("admin");
35

46
/*
57
Modified from http://introcs.cs.princeton.edu/23recursion/Fibonacci.java.html

examples/Gcd.nsl

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
OutFile("Test.exe");
1+
OutFile("Gcd.exe");
22
ShowInstDetails("show");
3+
XPStyle("on");
4+
RequestExecutionLevel("admin");
35

46
/*
57
Modified from http://en.wikipedia.org/wiki/Binary_GCD_algorithm

examples/Install.nsl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#define Version '1.0.1'
1+
#define Version '1.0.2'
22

33
Name("nsL Assembler ".Version." (Alpha)");
44
OutFile("nsL-Assembler-".Version.".exe");

examples/Logic.nsl

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
OutFile("Logic.exe");
2+
ShowInstDetails("show");
3+
XPStyle("on");
4+
RequestExecutionLevel("admin");
5+
6+
section Test()
7+
{
8+
if (!((MessageBox("MB_YESNO", "Click a button!") == "IDYES") == false))
9+
DetailPrint("1. You clicked Yes");
10+
else
11+
DetailPrint("1. You clicked No");
12+
13+
// Should be true
14+
$R0 = 0;
15+
$R1 = 5;
16+
if ($R0 > 0 || $R1 > 0)
17+
DetailPrint("2. $R0 > 0 || $R1 > 0");
18+
else
19+
DetailPrint("2. false");
20+
21+
// Should be true
22+
$R0 = 5;
23+
$R1 = 0;
24+
if ($R0 > 0 || $R1 > 0)
25+
DetailPrint("3. $R0 > 0 || $R1 > 0");
26+
else
27+
DetailPrint("3. false");
28+
29+
// Should be false
30+
$R0 = 0;
31+
$R1 = 0;
32+
if ($R0 > 0 || $R1 > 0)
33+
DetailPrint("4. $R0 > 0 || $R1 > 0");
34+
else
35+
DetailPrint("4. false");
36+
37+
// Should be true
38+
$R0 = 3;
39+
$R1 = 1;
40+
if ($R0 > 0 || $R1 > 0 && $R0 == 3)
41+
DetailPrint("5. $R0 > 0 || $R1 > 0 && $R0 == 3");
42+
else
43+
DetailPrint("5. false");
44+
45+
// Should be false
46+
$R0 = 3;
47+
$R1 = 0;
48+
if (($R0 == 0 || $R1 > 0) && $R0 == 3)
49+
DetailPrint("6. ($R0 == 0 || $R1 > 0) && $R0 == 3");
50+
else
51+
DetailPrint("6. false");
52+
53+
// Should be true
54+
$R0 = 3;
55+
$R1 = 5;
56+
if (($R0 == 0 || $R1 > 0) && $R0 == 3 && !($R1 == 4 || $R0 == 2))
57+
DetailPrint("7. ($R0 == 0 || $R1 > 0) && $R0 == 3 && !($R1 == 4 || $R0 == 2)");
58+
else
59+
DetailPrint("7. false");
60+
61+
// Should be true
62+
$R0 = 3;
63+
$R1 = 5;
64+
if (($R0 == 0 || $R1 > 0) && $R0 == 3 && ($R1 == 4 || $R0 == 3))
65+
DetailPrint("8. ($R0 == 0 || $R1 > 0) && $R0 == 3 && ($R1 == 4 || $R0 == 3)");
66+
else
67+
DetailPrint("8. false");
68+
69+
// Should be false
70+
$R0 = 3;
71+
$R1 = 5;
72+
if (($R0 == 0 || $R1 > 0) && $R0 == 3 && !($R1 == 4 || $R0 == 3))
73+
DetailPrint("9. ($R0 == 0 || $R1 > 0) && $R0 == 3 && !($R1 == 4 || $R0 == 3)");
74+
else
75+
DetailPrint("9. false");
76+
77+
// Should be false
78+
$R0 = 3;
79+
$R1 = 5;
80+
if (($R0 == 0 || $R1 > 5) && $R0 == 3 || $R1 <= 5 && ($R1 == 4 || $R0 == 2))
81+
DetailPrint("10. ($R0 == 0 || $R1 > 0) && $R0 == 3 || $R1 <= 5 && ($R1 == 5 || $R0 == 2)");
82+
else
83+
DetailPrint("10. false");
84+
}

examples/Loops.nsl

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
OutFile("Loops.exe");
2+
ShowInstDetails("show");
3+
XPStyle("on");
4+
RequestExecutionLevel("admin");
5+
6+
section Loops()
7+
{
8+
DetailPrint("For Loop 1");
9+
for ($i = 0, $j = 10; $i < 5 || $j > 0; $i++, $j--)
10+
{
11+
DetailPrint("$i = ".$i." and $j = ".$j);
12+
}
13+
14+
DetailPrint("For Loop 2");
15+
for ($i = 0, $j = 10; $i < 5 && $j > 0; $i++, $j--)
16+
{
17+
DetailPrint("$i = ".$i." and $j = ".$j);
18+
}
19+
20+
/* Currently even though the code below is not assembled, $k will
21+
* still get declared and if $k is not used elsewhere in the script,
22+
* $k will be wasting run-time memory. To fix, the assembler will need
23+
* to remove $k from the variables list if it is not already used
24+
* prior to its use here.
25+
*/
26+
DetailPrint("For Loop 3 (never gets assembled)");
27+
for ($k = 0; true && false; $k++)
28+
{
29+
DetailPrint("$k = ".$k);
30+
}
31+
32+
DetailPrint("For Loop 4");
33+
$m = 5;
34+
for (; $m >= 0;)
35+
{
36+
DetailPrint("$m = ".$m);
37+
if (true)
38+
$m--;
39+
}
40+
41+
DetailPrint("For Loop 5 (same as Loop 4)");
42+
$m = 5;
43+
for (;;)
44+
{
45+
DetailPrint("$m = ".$m);
46+
if ($m > 0)
47+
{
48+
$m--;
49+
continue;
50+
}
51+
break;
52+
}
53+
54+
DetailPrint("While Loop 1");
55+
$i = 0;
56+
while ($i < 9)
57+
{
58+
DetailPrint("$i = ".$i);
59+
$i++;
60+
}
61+
62+
/* Currently this IS assembled even though it will never execute.
63+
* Further optimisations could be done here if there are no
64+
* assignments or function calls on the left hand side of the && (as
65+
* is the case). That however would require a walk of its parse tree
66+
* or new code to propogate down the parse tree that there are
67+
* assignments or method calls within the tree.
68+
*/
69+
DetailPrint("While Loop 2");
70+
while ($i < 9 && false)
71+
{
72+
DetailPrint("$i = ".$i);
73+
$i++;
74+
}
75+
76+
DetailPrint("Do While Loop 1");
77+
$i = 0;
78+
do
79+
{
80+
DetailPrint("$i = ".$i);
81+
$i++;
82+
}
83+
while ($i < 5);
84+
85+
/* Because this only executes once we end up with an unused go-to
86+
* label at the top. We cannot simply remove it because of
87+
* while(false), as there may well be a 'continue' statement inside
88+
* that wants to use the label. Because the assembler writes the
89+
* output in a single pass, it is not possible to back-track and
90+
* remove the label at a later date. Instead, and because the makensis
91+
* compiler issues a "label not used" message, we are forced to
92+
* reference the label with StrCmp "" "" 0 [label]. The zero-jump will
93+
* always be taken of course.
94+
*/
95+
DetailPrint("Do While Loop 2");
96+
$i = 0;
97+
do
98+
{
99+
DetailPrint("This appears once only");
100+
}
101+
while (false);
102+
}

examples/Macros.nsl

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
OutFile("Macros.exe");
2+
ShowInstDetails("show");
23
XPStyle("on");
34
RequestExecutionLevel("admin");
4-
ShowInstDetails("show");
55

66
section Test()
77
{
@@ -44,9 +44,9 @@ section Test()
4444

4545
// Tests return values that are jump instructions.
4646
if (AskQuestion("Click Yes or No?"))
47-
DetailPrint("You clicked yes!");
47+
DetailPrint("You clicked Yes!");
4848
else
49-
DetailPrint("You clicked no!");
49+
DetailPrint("You clicked No!");
5050

5151
// Sets all registers being assigned to to 0. The number of registers
5252
// being assigned to is stored in the assembler-defined Returns macro

examples/Optimisations.nsl

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
OutFile("Optimisations.exe");
2+
ShowInstDetails("show");
3+
XPStyle("on");
4+
RequestExecutionLevel("admin");
5+
6+
section Test()
7+
{
8+
$R0 = 99 * 5 + 9 / 3 * 2;
9+
DetailPrint("1. $R0 = ".$R0);
10+
11+
$R0 = false && true || false && false || true;
12+
DetailPrint("2. $R0 = ".$R0);
13+
14+
$R0 = MessageBox("MB_YESNO", "Hello");
15+
DetailPrint("3. $R0 = ".$R0);
16+
17+
$R0 = (MessageBox("MB_YESNO", "Hello") == "IDYES") == true;
18+
DetailPrint("4. $R0 = ".$R0);
19+
20+
if (MessageBox("MB_YESNO", "Hello") == "IDYES")
21+
DetailPrint("5. You clicked Yes");
22+
else
23+
DetailPrint("5. You clicked No");
24+
}

examples/Switches.nsl

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
OutFile("Switches.exe");
2+
ShowInstDetails("show");
3+
XPStyle("on");
4+
RequestExecutionLevel("admin");
5+
6+
section Test()
7+
{
8+
$R0 = 1;
9+
switch ($R0)
10+
{
11+
case 0:
12+
DetailPrint("$R0 is 0");
13+
case 1:
14+
DetailPrint("$R0 is 0 or 1");
15+
break;
16+
default:
17+
DetailPrint("$R0 is neither 0 or 1");
18+
break;
19+
}
20+
21+
switch (MessageBox("MB_YESNOCANCEL", "hello"))
22+
{
23+
case "IDYES":
24+
DetailPrint("IDYES");
25+
break;
26+
case "IDNO":
27+
DetailPrint("IDNO");
28+
break;
29+
default:
30+
DetailPrint("IDCANCEL");
31+
break;
32+
}
33+
34+
switch (Silent() == true)
35+
{
36+
case true:
37+
DetailPrint(true);
38+
break;
39+
case false:
40+
DetailPrint(false);
41+
break;
42+
}
43+
}

0 commit comments

Comments
 (0)