Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposed updates #89

Merged
merged 173 commits into from
Oct 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
173 commits
Select commit Hold shift + click to select a range
e2b2a19
Seg fault if last line of basic file unterminated
mungre May 26, 2018
beef190
Document COPYBLOCK
mungre May 31, 2018
3ee1e6a
Buffer overflow if BASIC file ends with 2 blank lines
mungre May 31, 2018
61ffb43
Fix typo in README.md
ZornsLemma May 31, 2018
261721f
Change version from v1.09 to v1.10-pre
ZornsLemma May 31, 2018
c198513
Merge pull request #4 from stardot/master
ZornsLemma Apr 16, 2020
229ee57
Add test cases for issue #38
ZornsLemma Apr 16, 2020
75ffa1c
Don't completely ignore blank lines in macros
ZornsLemma Apr 16, 2020
5077c10
Add description of fix for issue #38 to README.md
ZornsLemma Apr 16, 2020
7d73c21
streampos in std namespace, not ifstream.
cpu6502 Apr 25, 2020
322619d
Report error for badly formed decimal number
mungre Sep 12, 2020
6cde898
Fix tokenisation of pseudo-vars on rhs in PUTBASIC
ZornsLemma Apr 5, 2021
573da4e
Add .editorconfig
ZornsLemma Apr 5, 2021
c27168f
Merge branch 'master' into proposed-updates
ZornsLemma Apr 5, 2021
cfaebd0
Merge pull request #51 from ZornsLemma/editorconfig
ZornsLemma Apr 5, 2021
33f0a04
Merge branch 'cpu6502-bug-streampos' into proposed-updates
ZornsLemma Apr 5, 2021
a6bfbbc
Document "$" and "%" literal prefixes
ZornsLemma Apr 5, 2021
0634f75
Merge remote-tracking branch 'origin/mungre/badfpfix' into mungre-bad…
ZornsLemma Apr 5, 2021
fb04ba3
Document fix for "JMP .label" problem
ZornsLemma Apr 5, 2021
8b217f6
Merge branch 'proposed-updates' of github.com:stardot/beebasm into pr…
ZornsLemma Apr 5, 2021
612a326
Allow -h, -help or --help to generate help
ZornsLemma Apr 5, 2021
a47328b
Merge branch 'rhs-token-fix' of https://github.com/ZornsLemma/beebasm…
ZornsLemma Apr 5, 2021
4d557b2
Add more changes to README.md
ZornsLemma Apr 5, 2021
0645746
Merge branch 'proposed-updates' into incorrect-line-number
ZornsLemma Apr 5, 2021
fec0232
Merge pull request #52 from ZornsLemma/incorrect-line-number
ZornsLemma Apr 5, 2021
0df9fe5
Tweak README.md changelog
ZornsLemma Apr 5, 2021
dfeb1dd
Fix incorrect line numbers from PUTBASIC
ZornsLemma Apr 5, 2021
9ec41f5
Document PUTBASIC line number fix in README.md
ZornsLemma Apr 5, 2021
04a6221
Thank Richard for advice on pseudo-variables.
ZornsLemma Apr 5, 2021
9ea20f5
Update .editorconfig with tab width 4
ZornsLemma Apr 6, 2021
82ae5d2
Factor out error filename/line number formatting
ZornsLemma Apr 6, 2021
4560f3d
Add FILELINE$
ZornsLemma Apr 6, 2021
4c9dee7
Add CALLSTACK$
ZornsLemma Apr 6, 2021
4aa5ff3
Document FILELINE$ and CALLSTACK$
ZornsLemma Apr 6, 2021
67eef81
Add -writes option
ZornsLemma Apr 8, 2021
16ab49e
Merge branch 'ZornsLemma/tricky-fileline-callstack' into ZornsLemma/t…
ZornsLemma Apr 8, 2021
3b473cc
Add -dd and -labels
ZornsLemma Apr 8, 2021
54bd211
Remove minor C++11 feature use
ZornsLemma Apr 8, 2021
ec52a02
Add missing #include <algorithm>
ZornsLemma Apr 8, 2021
301bda6
Fix typo
ZornsLemma Apr 10, 2021
cadaaa0
Merge pull request #53 from stardot/ZornsLemma/tricky-misc
ZornsLemma May 21, 2021
d1693c2
Add man page
davel Jun 17, 2021
420cb2a
Add cmake configuration
davel Jun 17, 2021
ea1cf4a
Add workflow to check both build systems
davel Jun 17, 2021
f77cdb5
Merge pull request #54 from davel/davel/cmake
ZornsLemma Jun 20, 2021
c937951
Retire Ubuntu 16.04
davel Jun 20, 2021
a5b265d
Also supply CXXFLAGS
davel Jun 20, 2021
a90f8e3
Merge remote-tracking branch 'origin/proposed-updates' into davel/ret…
davel Jun 20, 2021
0168833
Merge commit 'f77cdb5de217c9e7e327eeaf7557c323e840de11' into davel/re…
davel Jun 20, 2021
d3f6f18
Fix warning from clang
davel Jun 20, 2021
86d9c09
Merge pull request #55 from davel/davel/retire-ubuntu-16.04
ZornsLemma Jun 20, 2021
a78153a
Update README.md with Dave Lambley's changes
ZornsLemma Jun 20, 2021
3fdf8d8
Added string values. They can be concatenated.
mungre Jun 30, 2021
c6ee0f4
VAL (string to number) and STR$ (number to string)
mungre Jun 30, 2021
2f915e6
LEN, CHR$, ASC, MID$, STRING$
mungre Jun 30, 2021
9cbadea
Removed superfluous class name prefixes in header
mungre Jul 1, 2021
c214f07
Signed/unsigned mismatch causing build failure
mungre Jul 1, 2021
d1666cf
Missing include
mungre Jul 1, 2021
b8ad653
Included <cstring> rather than <string.h>
mungre Jul 1, 2021
88aad92
Define string symbols on the command-line with -S
mungre Jul 1, 2021
7b22c1b
Support symbol names ending in a '$'
mungre Jul 1, 2021
b8b2021
Typos in README.md
mungre Jul 1, 2021
b60bb1a
ASM command to assemble from strings
mungre Jul 1, 2021
acf6fb3
Change stricmp to _stricmp
mungre Jul 1, 2021
94fe423
stricmp is MS-specific. Use a loop.
mungre Jul 1, 2021
024ff75
UPPER and LOWER. Stub for EVAL.
mungre Jul 2, 2021
4f997dd
ASM now takes a single string parameter.
mungre Jul 2, 2021
c69d5c6
EVAL
mungre Jul 2, 2021
72ebafd
Removed redundant comments
mungre Jul 2, 2021
3d3ce4b
Added STR$~(), renamed funcs to UPPER$ and LOWER$
mungre Jul 3, 2021
3147227
Replaced ad hoc string parsers with EvaluateExpressionAsString
mungre Jul 3, 2021
5df1b16
Improved ASM error message for missing instruction
mungre Jul 3, 2021
687e833
Parsing of TIME$ swallowed an extra character
mungre Jul 3, 2021
f004af8
stringfunctions.6502 has example/test code
mungre Jul 3, 2021
4e760c3
Make filename parameter to SAVE optional again
mungre Jul 3, 2021
7390eb8
Failed recovery from undefined symbol in function in list
mungre Jul 3, 2021
60be891
Updated credits in README
mungre Jul 3, 2021
c6299d5
Testing - README.md, testrunner.py and existing examples
mungre Jul 5, 2021
79bdd12
Changed testrunner to unix line endings
mungre Jul 6, 2021
fb1c6c2
GitHub action: automatically run test after build
mungre Jul 6, 2021
1eb8d8a
Run tests from make or cmake
mungre Jul 6, 2021
096c368
Redirect test stderr to stdout to avoid interleaving issues
mungre Jul 6, 2021
1cecb13
Rename output ssds to test.ssd and add to .gitignore
mungre Jul 7, 2021
e5a515e
Make testing not verbose by default
mungre Jul 7, 2021
acc1849
Rename ssds produced for gold testing to test.ssd
mungre Jul 7, 2021
8f1e676
Compare beebasm printed output to .gold.txt files
mungre Jul 7, 2021
0112a6a
Rearranged tests into rough priority order
mungre Jul 8, 2021
ba0b4cc
Simple tests for all the operators
mungre Jul 8, 2021
07ea3be
cmake on github - show verbose test output when test fails
mungre Jul 8, 2021
c023505
Delete pseudo-test cases from examples directory
ZornsLemma Jul 9, 2021
64e9ffd
Include "sphere" demo as a test case
ZornsLemma Jul 9, 2021
d0902e7
Add gold ssd for test-local-forward-branch-5
ZornsLemma Jul 9, 2021
c9efec4
Add gold ssd for basicrhstoken test
ZornsLemma Jul 9, 2021
d9a78b9
Random number generator using 32-bit ints
mungre Jul 12, 2021
b6ec0f5
Previous RNG fix did not change type of constants
mungre Jul 12, 2021
8317a33
RNG - the values are 32-bit but the calculation is 64-bit
mungre Jul 13, 2021
5acee16
Add gold ssds for all the productive tests
mungre Jul 13, 2021
1a714a7
Catch all errors parsing hex constants
mungre Jul 13, 2021
2b0c19d
Simple tests of value parsing
mungre Jul 13, 2021
0368ca5
Typo of STRINGS$ in README.md
mungre Jul 13, 2021
d04f5fb
LEFT$ and RIGHT$
mungre Jul 13, 2021
4d3f41d
Undefined behaviour in EvalShiftLeft and EvalShiftRight
mungre Jul 13, 2021
bb9403b
Shift tests with negative values and shifts
mungre Jul 13, 2021
d7dd6f5
Don't print 32-bit integers in scientific notation
mungre Jul 13, 2021
ba1335e
Comment explaining local-forward-branch-3 test
mungre Jul 13, 2021
709d3a1
Removed use of fmod when converting values to strings
mungre Jul 13, 2021
95dd0f8
Binary literals - always positive, validate length
mungre Jul 13, 2021
c4767a8
Binary literals - fix signed/unsigned mismatch
mungre Jul 14, 2021
5ad3d0a
Fixed comment in binary constant test
mungre Jul 14, 2021
eb847f2
Tests for all opcodes/addressing modes
mungre Jul 14, 2021
6f47f7c
Test for recovery from undefined value error in list
mungre Jul 14, 2021
497d403
Tests for the various syntax permutations of SAVE
mungre Jul 14, 2021
d4f68cf
SAVE parser - missing EOL check in test for comma
mungre Jul 14, 2021
8fdf766
SAVE parser - missing EOL check in test for comma
mungre Jul 14, 2021
23461b4
GetTokenAndAdvanceColumn - missing EOL check
mungre Jul 14, 2021
57b982c
SKIP tests
mungre Jul 14, 2021
0e183c8
Typo in all65C02.6502
mungre Jul 14, 2021
91650f8
Additional SKIP test
mungre Jul 14, 2021
1d560ac
SKIPTO tests
mungre Jul 14, 2021
11c8f4e
CLEAR tests
mungre Jul 14, 2021
c89388e
Typo in unexpected comma message
mungre Jul 14, 2021
620e84f
Update test/README.md with .gold.txt feature
mungre Jul 14, 2021
adaafd7
The symbol VERBOSE controls verbose output
mungre Jul 15, 2021
6ea779e
INCBIN tests
mungre Jul 23, 2021
04269a3
MAPCHAR tests
mungre Jul 23, 2021
bef2416
Better error reporting for COPYBLOCK assembly errors
mungre Jul 23, 2021
54bbcd2
Execute COPYBLOCK on both passes
mungre Jul 23, 2021
ef47d95
COPYBLOCK tests
mungre Jul 23, 2021
dad0a3e
PUTFILE and PUTTEXT tests
mungre Jul 23, 2021
4a06386
Missing EOL test in PUTFILE/PUTTEXT argument parser
mungre Jul 23, 2021
f62b5cf
File name in test should have been in lower case
mungre Jul 23, 2021
f28977f
Automatically create release when a 'v*' tag is pushed
mungre Jul 23, 2021
3252f97
GitHub actions - include Windows in build and test
mungre Jul 24, 2021
f7e4cbc
GitHub actions - include verbose flag in Windows test
mungre Jul 24, 2021
79089d5
Tests for handling undefined symbols in directives
mungre Jul 26, 2021
5292a63
ArgListParser simplifies argument list parsing
mungre Jul 25, 2021
2f7263e
Remove beebasm.exe, fix line-ending clash
mungre Jul 26, 2021
eeb7d28
Fix template<> and typename errors and warnings for gcc
mungre Jul 26, 2021
9c01bc7
add jump_table_at_end.6502 (#61)
JulieMontoya Aug 2, 2021
0c4ef18
Merge pull request #56 from stardot/mungre/strings
mungre Aug 10, 2021
725217c
Merge branch 'mungre/strings' into mungre/testing
mungre Aug 10, 2021
2761616
Merge pull request #57 from stardot/mungre/testing
mungre Aug 10, 2021
050ef89
Merge pull request #60 from mungre/mungre/auto-release
mungre Aug 10, 2021
31d0ef5
Merge remote-tracking branch 'origin/mungre/strings' into proposed-up…
mungre Aug 10, 2021
50ceb13
Merge remote-tracking branch 'origin/mungre/testing' into proposed-up…
mungre Aug 10, 2021
44a569e
Merge branch 'proposed-updates' into mungre/verbose
mungre Aug 10, 2021
5318636
Issue #66 - Handle out of range integer conversions
mungre Feb 19, 2022
efa6da4
Forgot to #include <climits>
mungre Feb 19, 2022
b06d1ba
Fix ArgListParser to use ConvertDoubleToInt
mungre Feb 22, 2022
2e3ce0e
Merge pull request #69 from stardot/mungre/integer-range
mungre Aug 16, 2022
a829b15
Underscores in numeric literals. Fixes #36, #48.
mungre Aug 18, 2022
1bcf83d
Underscores in numeric literals - update README
mungre Aug 19, 2022
d325f2b
Don't mistake an EOR for an exponent in e.g. 2EOR3
mungre Aug 19, 2022
90f393c
Underscores in numeric literals - beebasm -D tests
mungre Aug 19, 2022
b001acf
Merge pull request #73 from stardot/mungre/literals2
mungre Aug 19, 2022
fd3fdd9
Merge pull request #59 from stardot/mungre/verbose
mungre Aug 19, 2022
60e697e
First pass of COPYBLOCK marks dest as USED. Fixes #75.
mungre Aug 25, 2022
5d1e985
Change -writes to -cycle (issue #74)
ZornsLemma Aug 26, 2022
40f12f5
Merge pull request #77 from stardot/issue-74c
chriskillpack Aug 27, 2022
8be43ef
Suppress unsaved warning if no memory used. Fixes #78.
mungre Aug 27, 2022
d51b8d9
Issue 78 - signed/unsigned comparison caused test failure
mungre Aug 27, 2022
a8d5253
Merge pull request #79 from stardot/issue-78
chriskillpack Aug 28, 2022
99be22c
Default and negative -D values broken. Fixes #83.
mungre Aug 31, 2022
9cb5e15
Report missing -D value on command-line
mungre Aug 31, 2022
7033393
Merge pull request #84 from stardot/issue-83
mungre Aug 31, 2022
b3df7af
Run tests on Ubuntu 22.04 and 20.04 and macOS 12
mungre Aug 31, 2022
c01aa48
Revert "Run tests on Ubuntu 22.04 and 20.04 and macOS 12"
mungre Aug 31, 2022
c5a0a3c
Run tests on Ubuntu 22.04 and 20.04 and macOS 12
mungre Aug 31, 2022
72c6801
Modify string initialisation to placate the new compiler
mungre Aug 31, 2022
e02afea
Merge pull request #87 from stardot/mungre/update-test-runners3
mungre Sep 2, 2022
c6fdb1f
Promote to v1.10
chriskillpack Oct 4, 2022
5c9bb55
Update README changelog
chriskillpack Oct 8, 2022
b2c3a53
README - updated version, copyright, date and formatting
mungre Oct 8, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# https://editorconfig.org/

root = true

[*]
end_of_line = crlf
insert_final_newline = true

[*.{c,h,cpp}]
indent_style = tab
tab_width = 4
43 changes: 43 additions & 0 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Build and run tests

on: [push, pull_request]

jobs:
cmake:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ['ubuntu-22.04', 'macos-12', 'ubuntu-20.04']
cc: [ 'gcc', 'clang' ]
name: Compile via CMakeLists.txt on ${{ matrix.os }} using ${{ matrix.cc }}
env:
CFLAGS: '-Wextra -Werror'
CXXFLAGS: '-Wextra -Werror'
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cc }}
steps:
- uses: actions/checkout@v2
- run: cmake .
- run: make
- run: make test CTEST_OUTPUT_ON_FAILURE=TRUE
make:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ['ubuntu-22.04', 'macos-12', 'ubuntu-20.04']
name: Compile via Makefile on ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- run: make -C src all VERBOSE=1
msbuild:
runs-on: windows-2019
name: Compile via msbuild on Windows
steps:
- name: Add msbuild to PATH
uses: microsoft/[email protected]
- uses: actions/checkout@v2
- name: Build Binary
shell: cmd
working-directory: .\src\VS2010
run: call .\build.cmd
- run: python test\testrunner.py -v
52 changes: 52 additions & 0 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Create Release

on:
push:
tags:
- 'v*'

jobs:
create_release:
name: Create GitHub Release
runs-on: windows-2019
defaults:
run:
working-directory: .\src\VS2010

steps:
- name: Add msbuild to PATH
uses: microsoft/[email protected]

- uses: actions/checkout@v2

- name: Build Binary
shell: cmd
run: call .\build.cmd

- name: Package Binary
shell: cmd
run: call .\package.cmd

- name: Create Release
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: |
Automated Release by GitHub Action CI
draft: false
prerelease: true

- name: Upload Release Asset (Windows x86)
id: upload-release-asset-x86
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./src/VS2010/beebasm-win32.zip
asset_name: beebasm-win32.zip
asset_content_type: application/zip
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@
*.swp
/beebasm
/src/objects
test/testlog.txt
test/**/test
test/**/test.ssd
test/**/testgold.txt
22 changes: 22 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
cmake_minimum_required(VERSION 3.10)

project(beebasm)

add_compile_options(-Wall -W -Wcast-qual -Wshadow -Wcast-align -Wold-style-cast -Woverloaded-virtual)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Existing Makefile does a glob to find source files, so we do the same.
FILE(GLOB CPPSources src/*.cpp)

add_executable(beebasm ${CPPSources})
target_link_libraries(beebasm stdc++ m)

install(TARGETS beebasm DESTINATION bin)
install(FILES ${CMAKE_SOURCE_DIR}/beebasm.1 DESTINATION share/man/man1)

enable_testing()

add_test(NAME Runs COMMAND ./beebasm -i demo.6502 -do demo.ssd -boot Code -v)
add_test(NAME Tests COMMAND python3 test/testrunner.py -v)
108 changes: 84 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# BeebAsm
**Version V1.09**
**Version V1.10**

A portable 6502 assembler with BBC Micro style syntax

Copyright (C) Rich Talbot-Watkins 2007-2012
Copyright (C) Rich Talbot-Watkins and the contributors 2007-2022
<[email protected]>

This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -135,13 +135,22 @@ If specified, this sets the disc option of the generated disc image (i.e. the `*

If specified, this sets the disc title of the generated disc image (i.e. the string set by `*TITLE`) to the value specified.

`-cycle <n>`

If specified, this sets the cycle for the generated disc image (i.e. the number shown next to the title in the disc catalogue) to the value specified.

`-di <filename>`

If specified, BeebAsm will use this disc image as a template for the new disc image, rather than creating a new blank one. This is useful if you have a BASIC loader which you want to run before your executable. Note this cannot be the same as the `-do` filename!

`-v`

Verbose output. Assembled code will be output to the screen.
Force verbose output. Assembled code will be output to the screen. The VERBOSE symbol will be ignored.

`-q`

Force quiet (non-verbose) output. The VERBOSE symbol will be ignored. If neither `-v` or `-q` is used then verbose
output can be controlled by setting `VERBOSE=0` or `VERBOSE=1`. The value can be changed only in a new scope.

`-vc`

Expand All @@ -151,6 +160,14 @@ Use Visual C++-style error messages.

Dumps all global symbols in Swift-compatible format after assembly. This is used internally by Swift, and is just documented for completeness.

`-dd`

Dumps all global and local symbols in Swift-compatible format after assembly.

`-labels <file>`

Write the output of `-d` or `-dd` to the specified file instead of standard output.

`-w`

If specified, there must be whitespace between opcodes and their labels. This introduces an incompatibility with the BBC BASIC assembler, which allows things like `ck_axy=&70:stack_axy` (i.e. `STA &70`), but makes it possible for macros to have names which begin with an opcode name, e.g.:
Expand All @@ -167,10 +184,12 @@ Things like `STA&4000` are permitted with or without `-w`.

`-D <symbol>=<value>`

`-S <symbol>=<string>`

Define `<symbol>` before starting to assemble. If `<value>` is not given, `-1` (`TRUE`)
will be used by default. Note that there must be a space between `-D` and the symbol. `<value>` may be in decimal, hexadecimal (prefixed with $, & or 0x) or binary (prefixed with %).
will be used by default. Note that there must be a space between `-D` or `-S` and the symbol. `<value>` may be in decimal, hexadecimal (prefixed with $, & or 0x) or binary (prefixed with %). `<string>` may be quoted.

`-D` can be used in conjunction with conditional assignment to provide default values within the source which can be overridden from the command line.
`-D` and `-S` can be used in conjunction with conditional assignment to provide default values within the source which can be overridden from the command line.

## 5. SOURCE FILE SYNTAX

Expand All @@ -182,7 +201,7 @@ Instructions can be written one-per-line, or many on one line, separated by colo

Comments are introduced by a semicolon or backslash. Unlike the BBC Micro assembler, these continue to the end of the line, and are not terminated by a colon (because this BBC Micro feature is horrible!).

Numeric literals are in decimal by default, and can be integers or reals. Hex literals are prefixed with `"&"`. A character in single quotes (e.g. `'A'`) returns its ASCII code.
Numeric literals are in decimal by default, and can be integers or reals. Scientific notation can be used, e.g. `1.2E10` or `1e-7`. Hex literals are prefixed with `"&"` or `"$"`, binary literals are prefixed with `"%"`. Digits can be separated with an underscore to improve readability, e.g. `1_000_000` or `$1_0000`. A character in single quotes (e.g. `'A'`) returns its ASCII code.

BeebAsm can accept complex expressions, using a wide variety of operators and functions. Here's a summary:

Expand Down Expand Up @@ -223,8 +242,29 @@ NOT(val) Return the bitwise 1's complement of val
LOG(val) Return the base 10 log of val
LN(val) Return the natural log of val
EXP(val) Return e raised to the power of val
VAL(str) Return the value of a decimal number in a string
EVAL(str) Return the value of an expression in a string
STR$(val) Return the number val converted to a string
STR$~(val) Return the number val converted to a string in hexadecimal
LEN(str) Return the length of str
CHR$(val) Return a string with a single character with ASCII value val
ASC(str) Return the ASCII value of the first character of str
MID$(str,index,length)
Return length characters of str starting at (one-based) index
LEFT$(str,length) Return the first length characters of str
RIGHT$(str,length) Return the last length characters of str
STRING$(count,str)
Return str repeated count times
LOWER$(str) Return str converted to lowercase
UPPER$(str) Return str converted to uppercase
TIME$ Return assembly date/time in format "Day,DD Mon Year.HH:MM:SS"
TIME$("fmt") Return assembly date/time in a format determined by "fmt", which
is the same format used by the C library strftime()
```

The assembly date/time is constant throughout the assembly; every use of `TIME$`
will return the same date/time.

Also, some constants are defined:

```
Expand All @@ -236,25 +276,13 @@ TRUE Returns -1
CPU The value set by the CPU assembler directive (see below)
```

Within `EQUB/EQUS` only you can also use the expressions:

```
TIME$ Return assembly date/time in format "Day,DD Mon Year.HH:MM:SS"
TIME$("fmt") Return assembly date/time in a format determined by "fmt", which
is the same format used by the C library strftime().
```

The assembly date/time is constant throughout the assembly; every use of `TIME$`
will return the same date/time.

Variables can be defined at any point using the BASIC syntax, i.e. `addr = &70`.
Variables can be defined at any point using the BASIC syntax, i.e. `addr = &70` or `name = "Bob"`. Quotes in strings are quoted by doubling, e.g. `"a""b"` for the string `a"b`.

Note that it is not possible to reassign variables once defined. However `FOR...NEXT` blocks have their own scope (more on this later).

Variables can be defined if they are not already defined using the conditional assignment syntax `=?`, e.g. `addr =? &70`. This is useful in conjunction with the `-D` command line option to provide default values for variables in the source while allowing them to be overridden on the command line. (Because variables cannot be reassigned once defined, it is not possible to define a variable with `-D` *and* with non-conditional assignment.)

(Thanks to Stephen Harris <[email protected]> and "ctr" for the `-D`/conditional assignment support.)
(Thanks to Stephen Harris <[email protected]> and Charles Reilly for the `-D`/conditional assignment support.)


## 6. ASSEMBLER DIRECTIVES
Expand Down Expand Up @@ -288,6 +316,11 @@ Moves the address pointer to the specified address. An error is generated if th
Used to align the address pointer to the next boundary, e.g. use `ALIGN &100` to move to the next page (useful perhaps for positioning a table at a page boundary so that index accesses don't incur a "page crossed" penalty.


`COPYBLOCK <start>,<end>,<dest>`

Copies a block of assembled data from one location to another. This is useful to copy code assembled at one location into a program's data area for relocation at run-time.


`INCLUDE "filename"`

Includes the specified source file in the code at this point.
Expand Down Expand Up @@ -358,9 +391,9 @@ Puts a 'guard' on the specified address which will cause an error if you attempt
Clears all guards between the `<start>` and `<end`> addresses specified. This can also be used to reset a section of memory which has had code assembled in it previously. BeebAsm will complain if you attempt to assemble code over previously assembled code at the same address without having `CLEAR`ed it first.


`SAVE "filename", start, end [, exec [, reload] ]`
`SAVE ["filename"], start, end [, exec [, reload] ]`

Saves out object code to either a DFS disc image (if one has been specified), or to the current directory as a standalone file. A source file must have at least one SAVE statement in it, otherwise nothing will be output. BeebAsm will warn if this is the case.
Saves out object code to either a DFS disc image (if one has been specified), or to the current directory as a standalone file. The filename is optional only if a name is specified with `-o` on the command line. A source file must have at least one SAVE statement in it, otherwise nothing will be output. BeebAsm will warn if this is the case.

`'exec'` can be optionally specified as the execution address of the file when saved to a disc image.

Expand All @@ -378,6 +411,8 @@ Examples:
PRINT "Value of label 'start' =", ~start
PRINT "numdots =", numdots, "dottable size =", dotend-dotstart
```

You can use `FILELINE$` in PRINT commands to show the current file and line number. `CALLSTACK$` will do the same but for all the parent macro and include files as well. See `examples/filelinecallstackdemo.6502` for an example of their use.

`ERROR "message"`

Expand Down Expand Up @@ -608,6 +643,10 @@ Abort assembly if any of the expressions is false.

Seed the random number generator used by the RND() function. If this is not used, the random number generator is seeded based on the current time and so each build of a program using `RND()` will be different.

`ASM <str>`

Assemble the supplied assembly language string. For example `ASM "LDA #&41"`.

## 7. TIPS AND TRICKS

BeebAsm's approach of treating memory as a canvas which can be written to, saved, and rewritten if desired makes it very easy to create certain types of applications.
Expand Down Expand Up @@ -693,20 +732,41 @@ There is also a demo called `"relocdemo.asm"`, which shows how the 'reload addre

## 9. VERSION HISTORY
```
09/10/2022 1.10 (Potentially breaking) Random number generator now uses 32-bit ints.
Documented "$" and "%" as literal prefixes (thanks to cardboardguru76 for pointing this out).
Fixed silently treating label references starting with "."
as 0 (thanks to Charles Reilly for this fix).
Allowed "-h" and "-help" options to see help.
Fixed tokenisation of BASIC pseudo-variables in some cases. (Thanks to Richard Russell advice on this.)
Fixed incorrect line number for errors inside macros with
blank lines inside them.
Fixed incorrect line numbers from PUTBASIC in some cases.
Fixed crashes in PUTBASIC caused by edge cases in end-of-file handling.
Added FILELINE$ and CALLSTACK$ (thanks to tricky for this)
Added -cycle, -dd and -labels options (thanks to tricky for these)
Added CMake support and man page (thanks to Dave Lambley)
Added string values and VAL, EVAL, STR$, LEN, CHR$, ASC, MID$,
LEFT$, RIGHT$, STRING$, LOWER$, UPPER$, ASM. (Charles Reilly with
thanks to Steven Flintham.)
Support underscore separators in numeric literals. C++'s built-in
parsing was used previously so beebasm's numeric syntax varied
between compilers and platforms; this is fixed.
Improved literal exponent parsing.
Error on out of range integer conversions.
12/05/2018 1.09 Added ASSERT
Added CPU (as a constant)
Added PUTTEXT
Added RANDOMIZE
Added TIME$
Added command line options: -title, -vc, -w, -D
Added conditional assignment (=?)
Added conditional assignment (=?)
Improved error handling in PUTFILE/PUTBASIC
Added optional automatic line numbering for PUTBASIC
Show a call stack when an error occurs inside a macro
Allow label scope-jumping using '.*label' and '.^label'
Allow high bits to be set on load/execution addresses
Show branch displacement when "Branch out of range" occurs
Fixed bugs in duplicate filename direction on disc image
Fixed bugs in duplicate filename detection on disc image
Fixed spurious "Branch out of range" error in rare case
19/01/2012 1.08 Fixed makefile for GCC (MinGW) builds.
Added COPYBLOCK command to manage blocks of memory.
Expand Down
Loading