Skip to content
Permalink
Browse files

Merge pull request #157 from Prof9/master

Add test case + readme for exponential float literals.
  • Loading branch information...
sp1187 committed Sep 21, 2019
2 parents 0292c93 + 5f8bf14 commit b25f269fdfa6db261a0e74b0b676e71e1f0c7c46
Showing with 49 additions and 0 deletions.
  1. +2 −0 Readme.md
  2. +29 −0 Tests/Core/Exponential/Exponential.asm
  3. +18 −0 Tests/Core/Exponential/expected.txt
@@ -214,6 +214,8 @@ A few examples:

Three value types are supported: integers, floats and strings. Integers are defined by writing just a number in one of the supported bases as described above. A float is defined by an integer numerator, followed by a period, followed by the denominator, e.g. `2.5`. Floats can also use a different base prefix; in this case, both the numerator and denominator are evaluated using that base. For example, `11.5` is equivalent to `0xB.8`.

Alternatively, a float can also be defined by exponential notation. This is formatted as an integer, followed by the letter `e`, followed by (optionally) a plus or minus representing the exponent sign, followed by an integer representing the exponent. For example, `314e-2` is equivalent to `3.14`; `5e3` and `5e+3` are equivalent to `5000.0`.

Strings are defined by text wrapped in quotation marks (e.g. `"text"`). Quotation marks can be escaped by prefixing them with a backslash (`\`). Any backlash not followed by a quotation mark is kept as-is. If you want to use a backslash at the end of a string, prefix it by another backlash.
For example, to write a quotation mark followed by a backlash:

@@ -0,0 +1,29 @@
.gba
.create "output.bin",0

.definelabel label,1234
.definelabel e,5678

// Should be parsed as exponentials
.notice 314e2
.notice 314e+2
.notice 314e-2
.notice 314E2
.notice 314E+2
.notice 314E-2

// Should NOT be parsed as exponentials
.notice 0xE2
.notice 0xE+2
.notice 0xE-2
.notice 0xE+label
.notice 0xE-label
.notice 0xE
.notice 0Eh
.notice 0Eh+label
.notice 0Eh-label
.notice e
.notice e+2
.notice e-2

.close
@@ -0,0 +1,18 @@
Exponential.asm(8) notice: 31400.000000000000
Exponential.asm(9) notice: 31400.000000000000
Exponential.asm(10) notice: 3.1400000000000001
Exponential.asm(11) notice: 31400.000000000000
Exponential.asm(12) notice: 31400.000000000000
Exponential.asm(13) notice: 3.1400000000000001
Exponential.asm(16) notice: 226
Exponential.asm(17) notice: 16
Exponential.asm(18) notice: 12
Exponential.asm(19) notice: 1248
Exponential.asm(20) notice: -1220
Exponential.asm(21) notice: 14
Exponential.asm(22) notice: 14
Exponential.asm(23) notice: 1248
Exponential.asm(24) notice: -1220
Exponential.asm(25) notice: 5678
Exponential.asm(26) notice: 5680
Exponential.asm(27) notice: 5676

0 comments on commit b25f269

Please sign in to comment.
You can’t perform that action at this time.