Compare commits

...

18 Commits

Author SHA1 Message Date
Piotr Fusik 9732817a0b Modernize the RPM spec. 2023-07-11 10:56:46 +02:00
Piotr Fusik 70c907bae6 Revert "Warn about a comment starting with a comma."
Breaks Jaskier's MPT player.
https://sourceforge.net/p/asap/bugs/32/

This reverts commit 7a666799ac.
2023-05-07 21:03:40 +02:00
Piotr Fusik 7a666799ac Warn about a comment starting with a comma. 2023-02-28 16:59:52 +01:00
Piotr Skamruk 95136d1546 Tune variable/func names after sequencing support added 2022-12-20 15:52:39 +01:00
Piotr Fusik ca5e88950f xasm 3.2.1 release. 2022-12-08 11:49:40 +01:00
Piotr Fusik 138331193a DMD seems to no longer append ".exe". 2022-12-08 09:53:32 +01:00
Piotr Fusik 30c96357bc Allow stdout for the listing and label table. 2022-12-08 09:27:19 +01:00
Jakub Husak 83d2f8ff1d Refactor LDA and STA with existing routines. 2022-12-02 15:23:07 +01:00
Adrian Matoga 9aae1ad4c4 Instruction pairing extended to more than two instructions. 2022-11-30 10:11:12 +01:00
Piotr Fusik f33c112ac6 Switch CI from Travis to GitHub Actions.
Close #10
2022-11-29 14:08:39 +01:00
Piotr Fusik 57661276c2 Fix "Error processing arguments: Missing value for argument --compiler=". 2022-11-29 14:04:51 +01:00
Piotr Fusik a4225b6128 GitHub Actions don't know gdc. 2022-11-29 14:01:33 +01:00
Piotr Fusik 1da9f77458 Add the missing part of GitHub Actions. 2022-11-29 13:59:41 +01:00
Piotr Fusik 2b7d21ae43 Continuous Integration with GitHub Actions. 2022-11-29 13:51:14 +01:00
Adrian Matoga 2f67b3bab4 Allow stdin/stdout instead of files for source and object. 2022-11-29 11:22:55 +01:00
Piotr Fusik afb9f7830e Update DEB packaging. 2022-07-23 11:45:14 +02:00
Piotr Fusik 95cb5ae592 install-scite non-executable. 2021-12-23 16:43:11 +01:00
Piotr Fusik 8f6621f079 Update DEB packaging. 2021-12-23 16:41:52 +01:00
11 changed files with 148 additions and 90 deletions

16
.github/workflows/test.yml vendored Normal file
View File

@ -0,0 +1,16 @@
name: tests
on: [push, pull_request]
jobs:
test:
strategy:
matrix:
os: [windows-latest, ubuntu-latest]
dc: [dmd-latest, ldc-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@main
- uses: dlang-community/setup-dlang@v1
with:
compiler: ${{ matrix.dc }}
- run: dub build
- run: dub test

View File

@ -1,5 +0,0 @@
language: d
d:
- dmd
- gdc
- ldc

View File

@ -1,14 +1,17 @@
VERSION = 3.2.0
VERSION = 3.2.1
prefix = /usr/local
bindir = $(prefix)/bin
mandir = $(prefix)/share/man/man1
ifeq ($(OS),Windows_NT)
EXEEXT = .exe
endif
SEVENZIP = 7z a -mx=9 -bd -bso0
all: xasm xasm.html
all: xasm$(EXEEXT) xasm.html
xasm: source/app.d
xasm$(EXEEXT): source/app.d
dmd -of$@ -O -release $<
xasm.html: xasm.1.asciidoc
@ -25,7 +28,7 @@ uninstall:
$(RM) $(DESTDIR)$(bindir)/xasm $(DESTDIR)$(mandir)/xasm.1
install-scite: xasm.properties
mkdir -p $(DESTDIR)$(prefix)/share/scite && install $< $(DESTDIR)$(prefix)/share/scite/xasm.properties
mkdir -p $(DESTDIR)$(prefix)/share/scite && install -m 644 $< $(DESTDIR)$(prefix)/share/scite/xasm.properties
uninstall-scite:
$(RM) $(DESTDIR)$(prefix)/share/scite/xasm.properties
@ -38,11 +41,11 @@ srcdist: MANIFEST
MANIFEST:
if test -e .git; then (git ls-files | grep -vF .gitignore && echo MANIFEST) | sort | dos2unix >$@ ; fi
../xasm-$(VERSION)-windows.zip: xasm xasm.html xasm.properties signed
../xasm-$(VERSION)-windows.zip: xasm.exe xasm.html xasm.properties signed
$(RM) $@ && $(SEVENZIP) -tzip $@ xasm.exe xasm.html xasm.properties
signed: xasm
signtool sign -d "xasm $(VERSION)" -n "Open Source Developer, Piotr Fusik" -tr http://time.certum.pl -fd sha256 -td sha256 xasm.exe && touch $@
signed: xasm$(EXEEXT)
signtool sign -d "xasm $(VERSION)" -n "Open Source Developer, Piotr Fusik" -tr http://time.certum.pl -fd sha256 -td sha256 $< && touch $@
deb:
debuild -b -us -uc

View File

@ -1,4 +1,4 @@
[![Build Status](https://travis-ci.com/pfusik/xasm.svg?branch=master)](https://travis-ci.com/github/pfusik/xasm)
[![GitHub Actions](https://github.com/pfusik/xasm/actions/workflows/test.yml/badge.svg)](https://github.com/pfusik/xasm/actions/workflows/test.yml)
xasm
====
@ -99,7 +99,7 @@ These rights, on this notice, rely.
Download
--------
[xasm 3.2.0](https://github.com/pfusik/xasm/releases) for Windows, macOS, Ubuntu and Fedora.
[xasm 3.2.1](https://github.com/pfusik/xasm/releases) for Windows, macOS, Ubuntu and Fedora.
Links
-----

6
debian/changelog vendored
View File

@ -1,3 +1,9 @@
xasm (3.2.1-1) UNRELEASED; urgency=low
* New release.
-- Piotr Fusik <fox@scene.pl> Thu, 8 Dec 2022 09:30:29 +0100
xasm (3.2.0-1) UNRELEASED; urgency=low
* New release.

2
debian/compat vendored
View File

@ -1 +1 @@
9
10

2
debian/control vendored
View File

@ -2,7 +2,7 @@ Source: xasm
Maintainer: Piotr Fusik <fox@scene.pl>
Section: devel
Priority: optional
Standards-Version: 3.9.3
Standards-Version: 4.6.0
Build-Depends: debhelper (>= 7), dmd (>= 2), asciidoc-base
Package: xasm

2
debian/copyright vendored
View File

@ -1,4 +1,4 @@
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Name: xasm
Source: https://github.com/pfusik/xasm

View File

@ -1,6 +1,6 @@
// xasm 3.2.0 by Piotr Fusik <fox@scene.pl>
// xasm 3.2.1 by Piotr Fusik <fox@scene.pl>
// http://xasm.atari.org
// Can be compiled with DMD v2.097.0.
// Can be compiled with DMD v2.101.0.
// Poetic License:
//
@ -25,19 +25,16 @@ import std.math;
import std.path;
import std.stdio;
import std.string;
import std.exception : assumeUnique;
import std.range : empty, front, popFront;
version (Windows) {
import core.sys.windows.windows;
}
int readByte(File *file) {
char c;
if (file.readf("%c", &c) != 1)
return -1;
return c;
}
const string TITLE = "xasm 3.2.1";
const string TITLE = "xasm 3.2.0";
File messageStream;
string sourceFilename = null;
bool[26] options;
@ -45,6 +42,7 @@ string[26] optionParameters;
string[] commandLineDefinitions = null;
string objectFilename = null;
string[] makeSources = null;
immutable(ubyte)[][string] sourceFiles;
int exitCode = 0;
@ -141,7 +139,7 @@ bool repeating; // line
int repeatCounter; // line
bool instructionBegin;
bool pairing;
bool sequencing;
bool willSkip;
bool skipping;
@ -176,13 +174,14 @@ File objectStream;
int objectBytes = 0;
bool getOption(char letter) {
assert(letter >= 'a' && letter <= 'z');
return options[letter - 'a'];
}
void warning(string msg, bool error = false) {
stdout.flush();
messageStream.flush();
version (Windows) {
HANDLE stderrHandle = GetStdHandle(STD_ERROR_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO csbi;
@ -1086,8 +1085,10 @@ File openInputFile(string filename) {
}
File openOutputFile(string filename, string msg) {
if (filename == "-")
return stdout;
if (!getOption('q'))
writeln(msg);
messageStream.writeln(msg);
try {
return File(filename, "wb");
} catch (Exception e) {
@ -1328,7 +1329,7 @@ void directive() {
noOpcode();
if (repeating)
throw new AssemblyError("Can't repeat this directive");
if (pairing)
if (sequencing)
throw new AssemblyError("Can't pair this directive");
}
@ -2302,7 +2303,6 @@ void assemblyIns() {
}
}
File stream = openInputFile(filename);
scope (exit) stream.close();
try {
stream.seek(offset, offset >= 0 ? SEEK_SET : SEEK_END);
} catch (Exception e) {
@ -2311,13 +2311,13 @@ void assemblyIns() {
if (inOpcode)
length = 1;
while (length != 0) {
int b = readByte(&stream);
if (b < 0) {
ubyte[1] b;
if (stream.rawRead(b).length != 1) {
if (length > 0)
throw new AssemblyError("File is too short");
break;
}
putByte(cast(ubyte) b);
putByte(b[0]);
if (length > 0) length--;
}
}
@ -2478,7 +2478,7 @@ void assemblyInstruction(string instruction) {
assemblyConditionalJump(0x50);
break;
case "LDA":
assemblyAccumulator(0xa0, 0, 0);
assemblyLda(0);
break;
case "LDX":
assemblyLdx(0);
@ -2601,7 +2601,7 @@ void assemblyInstruction(string instruction) {
assemblySkip(0x10);
break;
case "STA":
assemblyAccumulator(0x80, 0, 0);
assemblySta(0);
break;
case "STX":
assemblyStx(0);
@ -2660,24 +2660,29 @@ unittest {
== representation(hexString!"400100000000 401200000000 410123000000 441234567890 461234567890 3f5000000000 3f0300000000 3f1664534589 701000000000"));
}
void assemblyPair() {
void assemblySequence() {
assert(!inOpcode);
string instruction = readInstruction();
if (!eol() && line[column] == ':') {
pairing = true;
string[] extraInstructions;
while (!eol() && line[column] == ':') {
sequencing = true;
column++;
string instruction2 = readInstruction();
extraInstructions ~= readInstruction();
}
if (!extraInstructions.empty) {
int savedColumn = column;
if (willSkip)
warning("Skipping only the first instruction");
assemblyInstruction(instruction);
checkNoExtraCharacters();
column = savedColumn;
wereManyInstructions = false;
assemblyInstruction(instruction2);
wereManyInstructions = true;
foreach (nextInstruction; extraInstructions) {
column = savedColumn;
assemblyInstruction(nextInstruction);
wereManyInstructions = true;
}
} else {
pairing = false;
sequencing = false;
assemblyInstruction(instruction);
wereManyInstructions = false;
}
@ -2754,7 +2759,7 @@ void assemblyLine() {
int savedColumn = column;
for (repeatCounter = 0; repeatCounter < repeatLimit; repeatCounter++) {
column = savedColumn;
assemblyPair();
assemblySequence();
}
checkNoExtraCharacters();
listLine();
@ -2790,17 +2795,23 @@ void assemblyLine() {
listCommentLine();
return;
}
assemblyPair();
assemblySequence();
checkNoExtraCharacters();
listLine();
}
void assemblyFile(string filename) {
filename = filename.defaultExtension("asx");
if (getOption('p'))
filename = absolutePath(filename);
File stream = openInputFile(filename);
scope (exit) stream.close();
immutable(ubyte)[] source = sourceFiles.require(filename, {
File stream = stdin;
if (filename != "-") {
filename = filename.defaultExtension("asx");
if (getOption('p'))
filename = absolutePath(filename);
stream = openInputFile(filename);
}
return stream.byChunk(65536).joiner.array.assumeUnique;
}());
string oldFilename = currentFilename;
int oldLineNo = lineNo;
currentFilename = filename;
@ -2808,16 +2819,18 @@ void assemblyFile(string filename) {
foundEnd = false;
line = "";
readChar: while (!foundEnd) {
int b = readByte(&stream);
if (source.empty)
break;
ubyte b = source.front;
source.popFront;
switch (b) {
case -1:
break readChar;
case '\r':
assemblyLine();
line = "";
b = readByte(&stream);
if (b < 0)
if (source.empty)
break readChar;
b = source.front;
source.popFront;
if (b != '\n')
line ~= cast(char) b;
break;
@ -2838,6 +2851,16 @@ void assemblyFile(string filename) {
lineNo = oldLineNo;
}
unittest {
sourceFiles[""] = " lda:sne:ldy:inx $1234".representation;
assemblyFile("");
pass2 = true;
objectBuffer.length = 0;
assemblyFile("");
writefln!"%(%02x%)"(objectBuffer);
assert(objectBuffer == [0xad, 0x34, 0x12, 0xd0, 0x03, 0xac, 0x34, 0x12, 0xe8]);
}
void assemblyPass() {
origin = -1;
loadOrigin = -1;
@ -2944,10 +2967,17 @@ int main(string[] args) {
else {
if (sourceFilename is null)
exitCode = 3;
objectFilename = optionParameters['o' - 'a'];
if (objectFilename is null) {
objectFilename = sourceFilename == "-"
? "-"
: sourceFilename.setExtension("obx");
}
messageStream = objectFilename == "-" ? stderr : stdout;
if (!getOption('q'))
writeln(TITLE);
messageStream.writeln(TITLE);
if (exitCode != 0) {
write(
messageStream.write(
`Syntax: xasm SOURCE [OPTIONS]
-c Include false conditionals in listing
-d LABEL=VALUE Define a label
@ -2962,9 +2992,6 @@ int main(string[] args) {
`);
return exitCode;
}
objectFilename = optionParameters['o' - 'a'];
if (objectFilename is null)
objectFilename = sourceFilename.setExtension("obx");
try {
assemblyPass();
pass2 = true;
@ -2974,22 +3001,26 @@ int main(string[] args) {
} catch (AssemblyError e) {
warning(e.msg, true);
exitCode = 2;
objectStream.close();
core.stdc.stdio.remove(toStringz(objectFilename));
if (objectFilename != "-") {
objectStream.close();
core.stdc.stdio.remove(toStringz(objectFilename));
}
}
listingStream.close();
objectStream.close();
if (listingStream != stdout)
listingStream.close();
if (objectStream != stdout)
objectStream.close();
if (exitCode <= 1) {
if (!getOption('q')) {
writefln("%d lines of source assembled", totalLines);
messageStream.writefln("%d lines of source assembled", totalLines);
if (objectBytes > 0)
writefln("%d bytes written to the object file", objectBytes);
messageStream.writefln("%d bytes written to the object file", objectBytes);
}
if (getOption('m')) {
writef("%s:", makeEscape(objectFilename));
messageStream.writef("%s:", makeEscape(objectFilename));
foreach (filename; makeSources)
writef(" %s", makeEscape(filename));
write("\n\txasm");
messageStream.writef(" %s", makeEscape(filename));
messageStream.write("\n\txasm");
for (int i = 1; i < args.length; i++) {
string arg = args[i];
if (isOption(arg)) {
@ -3001,9 +3032,9 @@ int main(string[] args) {
break;
case 'o':
if (arg[0] == '/')
writef(" /%c:$@", arg[1]);
messageStream.writef(" /%c:$@", arg[1]);
else {
writef(" -%c $@", arg[1]);
messageStream.writef(" -%c $@", arg[1]);
++i;
}
break;
@ -3011,18 +3042,18 @@ int main(string[] args) {
if (arg[0] == '-'
&& (letter == 'd' || letter == 'l' || letter == 't')
&& i + 1 < args.length && !isOption(args[i + 1])) {
writef(" %s %s", arg, makeEscape(args[++i]));
messageStream.writef(" %s %s", arg, makeEscape(args[++i]));
}
else {
writef(" %s", makeEscape(arg));
messageStream.writef(" %s", makeEscape(arg));
}
break;
}
continue;
}
write(" $<");
messageStream.write(" $<");
}
writeln();
messageStream.writeln();
}
}
return exitCode;

View File

@ -16,6 +16,7 @@ DESCRIPTION
'SOURCE_FILE' is the name of the source file
(you may omit the default `.asx` extension).
Using '-' as 'SOURCE_FILE' makes *xasm* read from standard input.
When invoked without any options, *xasm* assembles 'SOURCE_FILE'
and writes the result to an object file named 'SOURCE_FILE'
with the extension changed to `.obx`.
@ -37,6 +38,7 @@ The listing file should exclude included files.
*-l* '[LISTING_FILE]'::
Generates a listing file.
Using '-' as 'LISTING_FILE' makes *xasm* write to standard output.
If 'LISTING_FILE' is omitted, the listing filename
is 'SOURCE_FILE' with the extension changed to `.lst`.
@ -46,12 +48,14 @@ First line of the rule lists 'OBJECT_FILE' as the target of the rule
and all source files (including the ones specified with `icl` and `ins`) as dependencies.
The second line contains the command line with 'OBJECT_FILE'
replaced by the *make* macro `$@` and 'SOURCE_FILE' replaced by the macro `$<`.
Dollars in the command line are doubled.
Dollar signs in the command line are doubled.
Your *make* or shell may require further escaping.
*-o* 'OBJECT_FILE'::
Sets output file name.
The default is 'SOURCE_FILE' with the extension changed to `.obx`.
Using '-' as 'OBJECT_FILE' makes *xasm* write to standard output.
The default is 'SOURCE_FILE' with the extension changed to `.obx`, or
standard output if standard input was specified as source.
[[new_fullpaths]]*-p*::
Prints absolute paths in listing and error messages.
@ -61,6 +65,7 @@ Quiet mode. Prevents *xasm* from printing its banner and compilation summary.
*-t* '[LABEL_FILE]'::
Generates a label table.
Using '-' as 'LABEL_FILE' makes *xasm* write to standard output.
If 'LABEL_FILE' is omitted then the table is appended at the end of the listing.
[[new_unlabels]]*-u*::
@ -157,7 +162,7 @@ to start a comment.
-------------------------------------------------------------
[[new_pairing]]
You may put two instructions in one line so they share their operand.
You may put two or more instructions in one line so they share their operand.
For example:
------------
eor:sta foo
@ -170,9 +175,9 @@ is equivalent to
Note that
------------
lda:tax #0
lda:tax:tay #0
------------
is allowed because `#0` is treated as a comment for `tax`.
is allowed because `#0` is treated as a comment for `tax` and `tay`.
EXPRESSIONS
-----------
@ -709,6 +714,12 @@ and pseudo commands, except for `MWA`, `MWX` and `MWY`:
HISTORY
-------
Version 3.2.1 (2022-12-08)
~~~~~~~~~~~~~~~~~~~~~~~~~~
- source can optionally be read from standard input, and object can be
written to standard output instead of files (by Adrian Matoga)
- <<new_pairing,any number of instructions in one line>> (by Adrian Matoga)
Version 3.2.0 (2021-06-22)
~~~~~~~~~~~~~~~~~~~~~~~~~~
- <<new_locallabel,local labels>> (contributed by Adrian Matoga)

View File

@ -1,13 +1,11 @@
Name: xasm
Version: 3.2.0
Version: 3.2.1
Release: 1
Summary: 6502 cross-assembler
License: Poetic
Group: Applications/Programming
Source: http://pfusik.github.io/xasm/xasm-%{version}.tar.gz
URL: https://github.com/pfusik/xasm
BuildRequires: dmd >= 2, asciidoc
BuildRoot: %{_tmppath}/%{name}-root
%description
xasm is a 6502 cross-assembler with original syntax extensions.
@ -21,18 +19,16 @@ xasm is a 6502 cross-assembler with original syntax extensions.
make xasm xasm.1
%install
rm -rf $RPM_BUILD_ROOT
make DESTDIR=$RPM_BUILD_ROOT prefix=%{_prefix} install
%clean
rm -rf $RPM_BUILD_ROOT
make DESTDIR=%{buildroot} prefix=%{_prefix} install
%files
%defattr(-,root,root)
%{_bindir}/xasm
%{_mandir}/man1/xasm.1.gz
%changelog
* Thu Dec 8 2022 Piotr Fusik <fox@scene.pl>
- 3.2.1-1
* Tue Jun 22 2021 Piotr Fusik <fox@scene.pl>
- 3.2.0-1