1
0
mirror of https://github.com/pfusik/xasm.git synced 2024-06-08 03:29:30 +00:00

Compare commits

...

115 Commits

Author SHA1 Message Date
Piotr Fusik
8eb2a5ae6f Migrate to the new macOS notarization tool.
The old one no longer works.
2024-05-18 21:45:34 +02:00
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
Piotr Fusik
52982169df xasm 3.2.0 release. 2021-06-22 21:20:00 +02:00
Piotr Fusik
8c7ef1a922 Reword the manual. 2021-06-21 22:44:34 +02:00
Piotr Fusik
1a90ca04d3 Bump the copyright year. 2021-06-21 22:42:13 +02:00
Piotr Fusik
73b382f9b7 Fix macOS notarization. 2021-06-21 22:40:50 +02:00
Piotr Fusik
7ba3f9f597 Signed the Windows binary. 2021-06-20 19:01:53 +02:00
Piotr Fusik
b815a448cd Migrate to travis-ci.com. 2021-06-16 09:11:04 +02:00
Piotr Fusik
274dda9dd2 Wait for macOS notarization. 2021-06-04 21:50:23 +02:00
Piotr Fusik
da58ad7950 Sign and notarize the macOS binary. 2021-06-04 21:38:25 +02:00
Piotr Fusik
52ef8c05d6 OPT ?+ for MADS compatibility. 2021-03-25 09:03:23 +01:00
Piotr Fusik
6f25038d95 On macOS install in /usr/local/bin.
Close #8
2021-03-24 10:49:14 +01:00
Adrian Matoga
57ef9b5c83 Fix failed assertion when opt l+ is used 2021-03-15 07:18:15 +01:00
Adrian Matoga
8f06fec50c Enable simple local labels. 2021-03-14 19:46:09 +01:00
Piotr Fusik
d50d484e1f Update DEB packaging. 2020-10-29 20:07:35 +01:00
Piotr Fusik
65a2c1fbdd Deprecate DOS-style options. 2020-05-25 21:36:28 +02:00
Piotr Fusik
d3908ec95e Don't report error deleting the object file on error.
Most likely the file doesn't exist.
2020-05-21 19:38:49 +02:00
Piotr Fusik
647cf9f3cf Don't cast to arrays of mutable bytes. 2019-12-04 23:23:47 +01:00
Piotr Fusik
819701b9be Optimize moving negative immediate word. 2019-12-04 23:16:21 +01:00
Piotr Fusik
301b904f60 xasm 3.1.1 release. 2019-11-20 17:43:51 +01:00
Piotr Fusik
420a83a897 Adapt srcdist to new tools. 2019-10-29 20:16:03 +01:00
Piotr Fusik
2f8e97499d Fix unreachable statement. 2019-10-16 09:28:13 +02:00
Piotr Fusik
7ad066fc6f Remove the object file on error even if not written.
Close #4.
2019-10-16 09:24:36 +02:00
Piotr Fusik
a0bfe1366d Remove the object file on error.
Close #4.
2019-10-14 10:56:46 +02:00
Piotr Fusik
384643ab84 Test with GDC and LDC. 2019-10-06 18:46:12 +02:00
Piotr Fusik
177ece15fc Add Travis badge. 2019-10-06 17:35:21 +02:00
Piotr Fusik
99099938b5 Silence unit tests. 2019-10-06 17:24:59 +02:00
Piotr Fusik
cb92f715a9 Fix "dub test". 2019-10-06 17:07:42 +02:00
Piotr Fusik
110d2c4dad Introduce DUB. 2019-10-06 17:00:48 +02:00
Piotr Fusik
ce134af833 Cleanup .gitignore. 2019-08-24 09:47:52 +02:00
Piotr Fusik
92eac212cc Apply dos2unix. 2019-08-24 09:46:29 +02:00
Piotr Fusik
90276dbe86 std.conv is already imported. 2019-08-24 09:43:41 +02:00
maraflush
2e43507088 fix compilation issue
fix :
xasm.d(2655): Error: Built-in hex string literals are obsolete, use std.conv.hexString!"ea" instead.
xasm.d(2656): Error: Built-in hex string literals are obsolete, use std.conv.hexString!"18a2006105" instead.
xasm.d(2657): Error: Built-in hex string literals are obsolete, use std.conv.hexString!"a9cd8d3412a9ab8d3512" instead.
xasm.d(2658): Error: Built-in hex string literals are obsolete, use std.conv.hexString!"05a6efef8945" instead.
xasm.d(2660): Error: Built-in hex string literals are obsolete, use std.conv.hexString!"400100000000 401200000000 410123000000 441234567890 461234567890 3f5000000000 3f0300000000 3f1664534589 701000000000" instead.
2019-08-24 09:17:57 +02:00
Piotr Fusik
cc0eaf0e48 Rename the documentation so that GitHub formats it. 2019-03-26 23:48:10 +01:00
Piotr Fusik
2dad630a75 Update some links. 2019-03-26 23:34:56 +01:00
Piotr Fusik
36a4853b54 Fix whitespace. 2017-07-29 14:06:15 +02:00
Piotr Fusik
c4fc8ef51a License. 2017-07-28 21:36:10 +02:00
Piotr Fusik
ef297a78c7 Reword README slightly. 2017-02-08 19:59:22 +01:00
Piotr Fusik
061088aa62 Update for DMD v2.073. 2017-02-08 19:32:42 +01:00
Piotr Fusik
dd3466a947 SciTE: Fix the open filter. Add to the Language menu. 2016-12-15 20:43:40 +01:00
peterdell
d2bd24a128 Add .gitignore 2016-01-03 11:23:16 +01:00
peterdell
8d0870d1a1 Fix typo in readme 2016-01-03 11:21:17 +01:00
Piotr Fusik
d7c22cec84 Include label name in the unused label warning.
Close #1.
2016-01-03 08:47:19 +01:00
Piotr Fusik
b42f9dc2bf Support a:/f: modifiers on run/ini. 2014-12-31 14:30:09 +01:00
Piotr Fusik
5680efc7f5 Improve I/O performance on Windows (especially network drives).
Reported by Marek Pavlik.
2014-09-26 16:42:54 +02:00
Piotr Fusik
8c6ff185af vim-xasm 2014-07-22 10:22:17 +02:00
Piotr Fusik
5970a93423 xasm 3.1.0 release. 2014-07-20 19:10:41 +02:00
Piotr Fusik
389f7446e0 Exclude xasm.o from OS X distribution. 2014-07-20 17:39:35 +02:00
Piotr Fusik
3cec1c8ee8 Extend OS X compatibility: 32-bit binary for 10.6. 2014-07-20 17:14:36 +02:00
Piotr Fusik
60d28a5c24 xasm-scite DEB. 2014-06-12 21:19:11 +02:00
Piotr Fusik
de22438740 More details about the SciTE integration. 2014-06-12 17:24:51 +02:00
Piotr Fusik
cc5568795e RPM and tar.gz distributions. 2014-06-12 17:24:12 +02:00
Piotr Fusik
d1276f3d97 DEB distribution. 2014-06-11 14:41:49 +02:00
Piotr Fusik
2d8b3cde17 Update README. 2014-06-11 12:00:06 +02:00
Piotr Fusik
c357fba52c OS X distribution. 2014-06-10 13:50:42 +02:00
Piotr Fusik
61327c8e5b "opt u-" disables "/u" unused label warnings. 2014-04-30 09:19:49 +02:00
Piotr Fusik
167c441fed INS: optimize "opcode" if length not specified as one. 2014-04-04 20:26:33 +02:00
Piotr Fusik
3a845f9a4f INS: allow line repeating (suggested by Marek Pavlik), taking "opcode", skip/repeat branches. 2014-04-04 20:20:40 +02:00
Piotr Fusik
50bae061f7 Remove duplicate filenames for -M. 2014-02-21 23:29:58 +01:00
Piotr Fusik
520145268a If cannot open the file to be included, report error in the ICL line. 2014-02-21 23:06:03 +01:00
Piotr Fusik
059b631aab Generate manpage. 2013-10-02 13:24:57 +02:00
Piotr Fusik
f2e7796c87 6502 inflate is a separate project. 2013-10-02 13:16:42 +02:00
Piotr Fusik
61bffbb8ec README for GitHub. 2013-05-10 20:14:56 +02:00
Piotr Fusik
a2d6f9c864 DMD64 compilation errors reported by Vadim Akimov. 2013-03-19 11:13:26 +01:00
Piotr Fusik
3fc9b5c0f5 Get rid of the deprecated std.stream. 2013-03-19 11:12:12 +01:00
Piotr Fusik
406354e06c Updated to DMD 2.061. Implemented /p outside Windows. Restored blank lines in the listing. 2013-02-19 17:37:14 +01:00
Adrian Matoga
6992795f55 Upgraded to DMD 2.051. 2013-02-19 14:59:55 +01:00
Piotr Fusik
034b95ea83 xasm 3.0.2 release. 2013-01-07 12:07:32 +01:00
Piotr Fusik
fa25272ccd xasm 3.0.1 release. 2013-01-07 12:07:32 +01:00
Piotr Fusik
66501ef2fd xasm 3.0.0 release. 2013-01-07 12:07:31 +01:00
Piotr Fusik
7c81897091 xasm 2.6.1 release. 2013-01-07 12:07:31 +01:00
Piotr Fusik
f288e64747 xasm 2.6.1. 2013-01-07 12:07:31 +01:00
Piotr Fusik
aa5efc560f xasm 2.6.0 release. 2013-01-07 12:07:31 +01:00
Piotr Fusik
10c0c534ea xasm 2.6.0. 2013-01-07 12:07:31 +01:00
Piotr Fusik
a8f3501164 xasm 2.5.2 release. 2013-01-07 12:07:31 +01:00
Piotr Fusik
b32bd4a6ad xasm 2.5.2. 2013-01-07 12:07:31 +01:00
Piotr Fusik
49c7068598 xasm 2.5.1 release. 2013-01-07 12:07:31 +01:00
Piotr Fusik
4b099cbccc xasm 2.5.1. 2013-01-07 12:07:30 +01:00
Piotr Fusik
67621cb32c xasm 2.5 release. 2013-01-07 12:07:30 +01:00
Piotr Fusik
22438199b9 xasm 2.5. 2013-01-07 12:07:30 +01:00
Piotr Fusik
402b4b7a79 xasm 2.4.2 release prepared, but not published. 2013-01-07 12:07:30 +01:00
Piotr Fusik
97f39029d7 xasm 2.4.2. 2013-01-07 12:07:30 +01:00
Piotr Fusik
d85541b707 xasm 2.4.1 release. 2013-01-07 12:07:30 +01:00
Piotr Fusik
85c9d6a9c7 xasm 2.4.1. 2013-01-07 12:07:30 +01:00
Piotr Fusik
c46bf8a027 xasm 2.4 release. 2013-01-07 12:07:29 +01:00
Piotr Fusik
af437b3eaa xasm 2.4. 2013-01-07 12:07:29 +01:00
Piotr Fusik
a7279f7ea6 xasm 2.4.-2. 2013-01-07 12:07:29 +01:00
Piotr Fusik
f9a11b10e3 xasm 2.4.-3. 2013-01-07 12:07:29 +01:00
Piotr Fusik
4d04b07860 xasm 2.4.-4. 2013-01-07 12:07:29 +01:00
Piotr Fusik
cd7b15669a xasm 2.4.-5. 2013-01-07 12:07:29 +01:00
Piotr Fusik
fc969d9263 xasm 2.4.-6. 2013-01-07 12:07:29 +01:00
Piotr Fusik
323634d856 xasm 2.4.-7. 2013-01-07 12:07:29 +01:00
Piotr Fusik
e22a4aadc3 X-LOAD 1.1. 2013-01-07 12:07:29 +01:00
Piotr Fusik
5b92221d87 xasm 2.4.-8. 2013-01-07 12:07:29 +01:00
Piotr Fusik
4102fd8bb0 X-Assembler 2.3 release (missing source code of the assembler). 2013-01-07 12:07:28 +01:00
Piotr Fusik
88362dba94 X-BOOT 5.0. 2013-01-07 12:07:28 +01:00
Piotr Fusik
6a5daaff83 X-BOOT 4.1.-9. 2013-01-07 12:07:28 +01:00
Piotr Fusik
83d6d7d0ac X-Assembler 2.3.-5. 2013-01-07 12:07:28 +01:00
37 changed files with 4341 additions and 6398 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

10
.gitignore vendored Normal file
View File

@ -0,0 +1,10 @@
/xasm
/xasm.exe
/xasm.obj
/xasm.html
/xasm.1
/xasm-test-*
/MANIFEST
/.dub
/.project
/signed

74
Makefile Normal file
View File

@ -0,0 +1,74 @@
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$(EXEEXT) xasm.html
xasm$(EXEEXT): source/app.d
dmd -of$@ -O -release $<
xasm.html: xasm.1.asciidoc
asciidoc -o - $< | sed -e "s/527bbd;/20a0a0;/" >$@
xasm.1: xasm.1.asciidoc
a2x -f manpage $<
install: xasm xasm.1
mkdir -p $(DESTDIR)$(bindir) && install xasm $(DESTDIR)$(bindir)/xasm
mkdir -p $(DESTDIR)$(mandir) && install -m 644 xasm.1 $(DESTDIR)$(mandir)/xasm.1
uninstall:
$(RM) $(DESTDIR)$(bindir)/xasm $(DESTDIR)$(mandir)/xasm.1
install-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
dist: srcdist ../xasm-$(VERSION)-windows.zip
srcdist: MANIFEST
$(RM) ../xasm-$(VERSION).tar.gz && /usr/bin/tar -c --numeric-owner --owner=0 --group=0 --mode=644 -T MANIFEST --transform=s,,xasm-$(VERSION)/, | $(SEVENZIP) -tgzip -si ../xasm-$(VERSION).tar.gz
MANIFEST:
if test -e .git; then (git ls-files | grep -vF .gitignore && echo MANIFEST) | sort | dos2unix >$@ ; fi
../xasm-$(VERSION)-windows.zip: xasm.exe xasm.html xasm.properties signed
$(RM) $@ && $(SEVENZIP) -tzip $@ xasm.exe xasm.html xasm.properties
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
osx: ../xasm-$(VERSION)-macos.dmg
../xasm-$(VERSION)-macos.dmg: osx/xasm osx/bin
ifdef PORK_CODESIGNING_IDENTITY
codesign --options runtime -f -s $(PORK_CODESIGNING_IDENTITY) osx/xasm
endif
hdiutil create -volname xasm-$(VERSION)-macos -srcfolder osx -format UDBZ -fs HFS+ -imagekey bzip2-level=3 -ov $@
/Applications/Xcode.app/Contents/Developer/usr/bin/notarytool submit --wait --keychain-profile recoilnotarization $@
osx/xasm: source/app.d
mkdir -p osx && dmd -of$@ -O -release $< && rm -f osx/xasm.o
osx/bin:
mkdir -p osx && ln -s /usr/local/bin $@
clean:
$(RM) xasm xasm.exe xasm.obj xasm.html xasm.1 signed
rm -rf osx
.PHONY: all install uninstall install-scite uninstall-scite dist srcdist MANIFEST deb osx clean
.DELETE_ON_ERROR:

112
README.md Normal file
View File

@ -0,0 +1,112 @@
[![GitHub Actions](https://github.com/pfusik/xasm/actions/workflows/test.yml/badge.svg)](https://github.com/pfusik/xasm/actions/workflows/test.yml)
xasm
====
xasm is a 6502 cross-assembler with original syntax extensions.
By default it generates binaries
for [Atari 8-bit computers](http://en.wikipedia.org/wiki/Atari_8-bit_family).
Syntax
------
6502 assembly code is full of LDA, STA, LDA, STA sequences.
With xasm you can use MVA as a shortcut for an LDA/STA pair or even MWA for 16-bit transfers.
Short branches can be replaced with conditional skip and repeat pseudo-instructions.
You can use a pair of instructions with a shared argument.
These are just some of the features that help you program in a more concise way.
Let's look at typical 6502 code (which is also valid in xasm):
lda #<dest
sta ptr
lda #>dest
sta ptr+1
ldx #192
do_line
ldy #39
do_byte
lda pattern,y
sta (ptr),y
dey
bpl do_byte
lda #40
clc
adc ptr
sta ptr
bcc skip
inc ptr+1
skip
dex
bne do_line
Using xasm's features this code can be rewritten to:
mwa #dest ptr
ldx #192
do_line
ldy #39
mva:rpl pattern,y (ptr),y-
lda #40
add:sta ptr
scc:inc ptr+1
dex:bne do_line
xasm syntax is an extension of Quick Assembler's (created in 1991 for Atari 8-bit).
Accumulator shifts should be written as in `asl @`.
Whitespace is important: it is required before the instruction
and disallowed in the operands, because it separates a comment from the operand, e.g.
lda #0 this is a comment, no need for a semicolon
This may look weird at first, but it enables nice features such as instruction pairs
and two-argument pseudo-instructions.
Usage
-----
xasm is a command-line tool.
Therefore you additionally need a programmer's text editor.
I use [SciTE](http://www.scintilla.org/SciTE.html).
To install xasm syntax highlighting and single-keystroke compilation,
copy `xasm.properties` to the SciTE directory.
For single source file programs, press Ctrl+F7 to compile.
You can double-click error messages to go to the incorrect line.
Press F5 to run the program in the emulator.
For larger projects, I use GNU Make. Press F7 to build (and possibly run)
a project as described in the `Makefile`. You can find my Makefiles in
[my repositories](https://github.com/pfusik?tab=repositories) on GitHub.
If you prefer VIM, see a link below.
Poetic License
--------------
This work 'as-is' we provide.
No warranty express or implied.
We've done our best,
to debug and test.
Liability for damages denied.
Permission is granted hereby,
to copy, share, and modify.
Use as is fit,
free or for profit.
These rights, on this notice, rely.
Download
--------
[xasm 3.2.1](https://github.com/pfusik/xasm/releases) for Windows, macOS, Ubuntu and Fedora.
Links
-----
* [Atari800](https://atari800.github.io/) - portable emulator of Atari 8-bit computers
* [Atari XL/XE Source Archive](http://sources.pigwa.net/) - source code of Atari demos, utilities and games
* [cc65](https://cc65.github.io/) - C cross-compiler targeting 6502-based systems
* [MADS](http://mads.atari8.info/) - another 6502/65816 cross-assembler, partially supporting xasm's syntax
* [vim-xasm](https://github.com/lybrown/vim-xasm) - VIM syntax highlighting for xasm
* [WUDSN IDE](http://wudsn.com/) - Eclipse plugin, front-end to several 6502 cross-assemblers, including xasm

View File

@ -1,274 +0,0 @@
; COMpack
; b. Fox
IDEAL
P386
MODEL TINY
CODESEG
ORG 100h
include 'fox.mak'
start:
; db 1024 dup(0) ;4 self-packing
inplen = 24000
outlen = 27000
print hello
mov di, 81h
movzx cx, [di-1]
jcxz usg
mov al, ' '
repe scasb
je usg
push cx di
dec di
inc cx
mov al, '?'
repne scasb
pop di cx
jne nousg
usg: print usgtxt
int 20h
getfil: lea si, [di-1]
mov al, ' '
repne scasb
jne noout1
dec di
noout1: mov cx, di
sub cx, si
mov di, offset fname
rep movsb
mov bx, di
srchex: dec bx
cmp [byte bx], '\'
je addext
cmp [byte bx], '.'
je extexs
cmp bx, offset fname
ja srchex
addext: mov ax, 'c.'
stosw
mov ax, 'mo'
stosw
extexs: mov [word di], 0a0dh
mov [byte di+2], '$'
print namtxt
print fname
mov [byte di], 0
rts: ret
smartdisk
nousg: print srctxt
call getfil
push si
fopen
mov cx, inplen
fread inpbuf
mov dx, offset lontxt
cmp ax, inplen
je panic
push ax
add [filend], ax
fclose
pop cx
mov dx, offset emptxt
jcxz panic
mov di, offset inpbuf
xor al, al
repe scasb
jne spox
panic: print
int 20h
spox: dec di
push di
mov [filbgn], di
sub di, offset inpbuf
add [destad], di
add [reljad], di
lda cx
inc ax
call prilen
pop bx
mov si, offset firflg
mov di, offset outbuf
pack1: push si di
mov ax, 1
mov bp, [filend]
lea si, [bx-0ffh]
cmp si, [filbgn]
jnb pack2
mov si, [filbgn]
cmp si, bx
je packn
pack2: mov di, bx
mov cx, bp
sub cx, bx
push si
repe cmpsb
pop si
je pack3
dec di
pack3: mov cx, di
sub cx, bx
cmp cx, ax
jbe pack4
lda cx
mov dx, si
pack4: inc si
cmp si, bx
jb pack2
packn: pop di si
mov bp, ax
sta cx
mov ax, 1
putfl1: cmp cx, 2
rcl [byte si], 1
jnc putfl2
mov si, di
stosb
putfl2: loop putfl1
cmp bp, ax
mov al, [bx]
je putbyt
mov al, dl
sub al, bl
putbyt: stosb
mov ah, 1
cmp [si], ah
jne swpflg
mov [si], ax
inc si
swpflg: add bx, bp
cmp bx, [filend]
jb pack1
shl [byte si], 1
jnc corfl1
mov al, 80h
stosb
jmp corfl3
corfl1: stc
corfl2: rcl [byte si], 1
jnc corfl2
corfl3: rcl [firflg], 1 ;+
xor al, al
stosb
sub di, offset depack
mov [filend], di
print pkdtxt
pop di
mov cx, 81h
add cl, [80h]
sub cx, di
jz nowri
mov al, ' '
repe scasb
je nowri
mov ax, [filend]
inc ah
cmp ax, [destad]
ja nospac
call getfil
fcreate
mov cx, [filend]
fwrite depack
fclose
nowri: mov ax, [filend]
prilen: mov di, offset lenlst
mov bx, 10
outnm1: xor dx, dx
div bx
add dl, '0'
outnm2: mov [di], dl
dec di
test ax, ax
jnz outnm1
mov dl, ' '
cmp di, offset lennum
jnb outnm2
print lentxt
ret
nospac: mov dx, offset zertxt
dos 9
jmp nowri
hello db 'COMpack 1.0 by Fox/Taquart',eot
usgtxt db 'This is FREEWARE packer for .COM programs.',eol
db 'Syntax:',eol
db 'COMPACK inpfile [outfile]',eol
db '"inpfile" specifies source path\filename',eol
db '"outfile" specifies target path\filename',eol
db 'The ".COM" extension of filename is default and you don''t have to write it',eol
db 'If you don''t give "outfile" parameter, no file will be saved',eol
db 'and you can only watch the results of packing',eol
zertxt db 'If you want the file saved, you must compile some zero bytes at the beginning',eol
db 'of file to reserve the space for packed data. The code should immediately',eol
db 'follow the zeros.',eot
srctxt db 'Source file:',eot
pkdtxt db 'Packed file:',eot
namtxt db ' Name: $'
lentxt db 'Length: '
lennum db ' '
lenlst db ' bytes',eot
emptxt db 'File is empty!',eot
lontxt db 'File is too long!',eot
smarterr
filbgn dw inpbuf
filend dw inpbuf
depack: mov si, offset packed-depack+100h
mov di, 100h
destad = word $-2
mov al, 1
firflg = byte $-1
xor cx, cx
dep1: movsb
dec cx
dep2: inc cx
dep3: add al, al
jnz dep4
lodsb
adc al, al ;+
dep4: jnc dep2
jcxz dep1
sbb bx, bx ;+
and bl, [si]
db 0fh,84h ;jz near
reljad dw depack-reljmp
reljmp: inc si
inc cx
push si
lea si, [di+bx]
rep movsb
pop si
jmp dep3
packed:
outbuf db outlen dup(?)
fname:
inpbuf db inplen dup(?)
ENDS
END start

23
debian/changelog vendored Normal file
View File

@ -0,0 +1,23 @@
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.
-- Piotr Fusik <fox@scene.pl> Tue, 22 Jun 2021 20:59:45 +0200
xasm (3.1.1-1) UNRELEASED; urgency=low
* New release.
-- Piotr Fusik <fox@scene.pl> Wed, 20 Nov 2019 13:30:11 +0100
xasm (3.1.0-1) UNRELEASED; urgency=low
* First deb packaging.
-- Piotr Fusik <fox@scene.pl> Sun, 20 Jul 2014 19:08:15 +0200

1
debian/compat vendored Normal file
View File

@ -0,0 +1 @@
10

16
debian/control vendored Normal file
View File

@ -0,0 +1,16 @@
Source: xasm
Maintainer: Piotr Fusik <fox@scene.pl>
Section: devel
Priority: optional
Standards-Version: 4.6.0
Build-Depends: debhelper (>= 7), dmd (>= 2), asciidoc-base
Package: xasm
Architecture: any
Depends: ${shlibs:Depends}
Description: 6502 cross-assembler with original syntax extensions.
Package: xasm-scite
Architecture: all
Depends: scite
Description: xasm syntax highlighting and single keystroke compilation for SciTE.

7
debian/copyright vendored Normal file
View File

@ -0,0 +1,7 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Name: xasm
Source: https://github.com/pfusik/xasm
Files: *
Copyright: 1998-2021 Piotr Fusik <fox@scene.pl>
License: Poetic

6
debian/rules vendored Normal file
View File

@ -0,0 +1,6 @@
#!/usr/bin/make -f
%:
dh $@
override_dh_auto_install:
$(MAKE) DESTDIR=$$(pwd)/debian/tmp prefix=/usr install install-scite

1
debian/xasm-scite.install vendored Normal file
View File

@ -0,0 +1 @@
usr/share/scite/xasm.properties

2
debian/xasm.install vendored Normal file
View File

@ -0,0 +1,2 @@
usr/bin/xasm
usr/share/man/man1/xasm.1

Binary file not shown.

Before

Width:  |  Height:  |  Size: 592 B

View File

@ -1,99 +0,0 @@
* This program detects 6502 bugs.
* Please read text after program first.
icmd equ $342
ibuf equ $344
ilen equ $348
ciomain equ $e456
org $8000
dta h(*) Buggy jump fetches this byte...
lda #$ff ... and jumps to this location
jmp cont
start lda #11 Clear screen
ldx <clstxt
ldy #1
jsr callio
* Check ADC bug
sed
lda #$99 BCD 99+01=00
add #1
cld
seq Z flag set: no bug
lda #$ff
ldx <adctxt
jsr print
* Check BRK bug
sei Disable IRQs
inc ^4e Disable NMIs
mva #$fe ^31 Disable ROM
mwa #nmi $fffa Set my NMI vector
mwa #irq $fffe Set my IRQ vector
lsr ^4e Enable VBLKI
irq brk BRK interrupt - infinite loop, so...
nmi inc ^31 NMI always occurs on BRK
cli
pla:pla
sub <irq
seq Return adr points BRK: no bug
lda #$ff
ldx <brktxt
jsr print
* Check JMP bug
jmp (jmpptr) You'll receive a warning from X-Asm here!
cont ldx <jmptxt
jsr print
jmp * Halt CPU
* Print results (A=$ff:bug or 0:no_bug, X=<cmdtxt)
print pha Save A
lda #11 CIO write command
ldy #3 Print 3 letters
jsr callio
ldx <nobtxt
pla Restore A
seq A=0: X=<nobtxt
ldx <bugtxt A<>0: X=<bugtxt
lda #9 CIO write_to_eol command
ldy #$ff Limit of printed characters
callio sta icmd Call "E:" CIO: A-cmd X-<buf Y-len
stx ibuf
mva >* ibuf+1
sty ilen
mvx #0 ilen+1 Channel 0, length<256
jmp ciomain
clstxt dta b(125) Clear screen control code
adctxt dta c'ADC'
brktxt dta c'BRK'
jmptxt dta c'JMP'
bugtxt dta c' bug detected!',b($9b)
nobtxt dta c' bug NOT detected.',b($9b)
ert *>start|$ff Program should fit on one page
org *|$ff
jmpptr dta a(jmp1)
jmp1 lda #0 JMP bug not detected
jmp cont
run start
end
The program above detects 3 bugs:
- 'ADC bug'
Flags N,V,Z are not properly set after ADC or SBC in decimal mode.
You can't rely on these flags after BCD operation.
- 'BRK bug'
If an interrupt occurs on a BRK, it is executed with BRK-like values on stack.
This means a BRK is simply passed-by if a NMI occurs.
Beware of using BRK with other interrupts.
- 'JMP bug' - JMP ($xxff) fetches address from $xxff and $xx00.
X-Asm warns you of using such a jump.
All these bugs are supposedly fixed in CMOS chips.

View File

@ -1,51 +0,0 @@
<HTML>
<HEAD>
<TITLE>GR0 1.1 Manual</TITLE>
</HEAD>
<BODY BACKGROUND="6502proc.gif">
<CENTER>
<H1>GR0 version 1.1</H1>
by <A HREF="mailto:pfusik@elka.pw.edu.pl">Fox/Taquart</A><P>
<HR>
</CENTER>
<H2>INTRODUCTION</H2>
GR0 is a simple tool that can change colors and font of DOS screen.
It can setup it to look similar to Atari text mode.
<H3>CHANGES</H3>
<H4>Version 1.1</H4>
<UL>
<LI> first release
</UL>
<HR>
<H2>USAGE</H2>
You can run GR0 without any parameters to see available options. They are:
<DL>
<DT><TT>/a</TT>
<DD>Set Atari scheme. It is equivalent to options <TT>/b:1 /c:7 /n /l /x</TT><P>
<DT><TT>/b:nn</TT>
<DD>Set background color nn, where nn is decimal number of range 0-15<P>
<DT><TT>/c:nn</TT>
<DD>Set foreground (letters) color nn, where nn is decimal number of range 0-15<P>
<DT><TT>/d</TT>
<DD>Set default PC font. Resets all characters.<P>
<DT><TT>/f:fname</TT>
<DD>Set external Atari font. Reads characters 0-127 from standard Atari font file
(8*8*128). In 25 lines mode, font is resized. Default extension .FNT will be added
to filename, if none given.<P>
<DT><TT>/i</TT>
<DD>Set characters 128-255 to inverse of 0-127.
<TT>/i</TT> can only be used with <TT>/a</TT>, <TT>/f</TT> or <TT>/x</TT>.<P>
<DT><TT>/l</TT>
<DD>Select 50 lines font. Without this option, 25 lines font is selected.<P>
<DT><TT>/n</TT>
<DD>Initialize text mode. Clears screen and restores default font and colors.<P>
<DT><TT>/x</TT>
<DD>Set Atari built-in font. Sets characters 0-127 to standard Atari font.
It looks better with /l option.<P>
</DL>
In Windows, font changes only in full-screen mode. Colors and number of lines change
also in a window.
</BODY>
</HTML>

View File

@ -1,221 +0,0 @@
<HTML>
<HEAD>
<TITLE>GTIA Documentation</TITLE>
</HEAD>
<BODY BACKGROUND="6502proc.gif">
<CENTER>
<H1>GTIA Documentation</H1>
by <A HREF="mailto:pfusik@elka.pw.edu.pl">Fox/Taquart</A><P>
<HR>
<P>
<H2>Registers</H2>
<TABLE BORDER>
<TR>
<TD><I>&nbsp;Address&nbsp;</I></TD><TD><I>&nbsp;Read register&nbsp;</I></TD><TD><I>&nbsp;Write register&nbsp;</I></TD>
<TD><I>&nbsp;Address&nbsp;</I></TD><TD><I>&nbsp;Read register&nbsp;</I></TD><TD><I>&nbsp;Write register&nbsp;</I></TD>
</TR><TR>
<TD ALIGN=center><TT>^00</TT></TD><TD><A HREF="#kolmxpf">KOLM0PF</A></TD><TD><A HREF="#hpospx">HPOSP0</A></TD>
<TD ALIGN=center><TT>^10</TT></TD><TD><A HREF="#trigx">TRIG0</A></TD><TD><A HREF="#grafpx">GRAFP3</A></TD>
</TR><TR>
<TD ALIGN=center><TT>^01</TT></TD><TD><A HREF="#kolmxpf">KOLM1PF</A></TD><TD><A HREF="#hpospx">HPOSP1</A></TD>
<TD ALIGN=center><TT>^11</TT></TD><TD><A HREF="#trigx">TRIG1</A></TD><TD><A HREF="#grafm">GRAFPM</A></TD>
</TR><TR>
<TD ALIGN=center><TT>^02</TT></TD><TD><A HREF="#kolmxpf">KOLM2PF</A></TD><TD><A HREF="#hpospx">HPOSP2</A></TD>
<TD ALIGN=center><TT>^12</TT></TD><TD>unused</TD><TD><A HREF="#colpmx">COLPM0</A></TD>
</TR><TR>
<TD ALIGN=center><TT>^03</TT></TD><TD><A HREF="#kolmxpf">KOLM3PF</A></TD><TD><A HREF="#hpospx">HPOSP3</A></TD>
<TD ALIGN=center><TT>^13</TT></TD><TD><A HREF="#trigx">TRIG3</A></TD><TD><A HREF="#colpmx">COLPM1</A></TD>
</TR><TR>
<TD ALIGN=center><TT>^04</TT></TD><TD><A HREF="#kolpxpf">KOLP0PF</A></TD><TD><A HREF="#hposmx">HPOSM0</A></TD>
<TD ALIGN=center><TT>^14</TT></TD><TD><A HREF="#pal">PAL</A></TD><TD><A HREF="#colpmx">COLPM2</A></TD>
</TR><TR>
<TD ALIGN=center><TT>^05</TT></TD><TD><A HREF="#kolpxpf">KOLP1PF</A></TD><TD><A HREF="#hposmx">HPOSM1</A></TD>
<TD ALIGN=center><TT>^15</TT></TD><TD>unused</TD><TD><A HREF="#colpmx">COLPM3</A></TD>
</TR><TR>
<TD ALIGN=center><TT>^06</TT></TD><TD><A HREF="#kolpxpf">KOLP2PF</A></TD><TD><A HREF="#hposmx">HPOSM2</A></TD>
<TD ALIGN=center><TT>^16</TT></TD><TD>unused</TD><TD><A HREF="#colpfx">COLPF0</A></TD>
</TR><TR>
<TD ALIGN=center><TT>^07</TT></TD><TD><A HREF="#kolpxpf">KOLP3PF</A></TD><TD><A HREF="#hposmx">HPOSM3</A></TD>
<TD ALIGN=center><TT>^17</TT></TD><TD>unused</TD><TD><A HREF="#colpfx">COLPF1</A></TD>
</TR><TR>
<TD ALIGN=center><TT>^08</TT></TD><TD><A HREF="#kolmxp">KOLM0P</A></TD><TD><A HREF="#sizepx">SIZEP0</A></TD>
<TD ALIGN=center><TT>^18</TT></TD><TD>unused</TD><TD><A HREF="#colpfx">COLPF2</A></TD>
</TR><TR>
<TD ALIGN=center><TT>^09</TT></TD><TD><A HREF="#kolmxp">KOLM1P</A></TD><TD><A HREF="#sizepx">SIZEP1</A></TD>
<TD ALIGN=center><TT>^19</TT></TD><TD>unused</TD><TD><A HREF="#colpfx">COLPF3</A></TD>
</TR><TR>
<TD ALIGN=center><TT>^0A</TT></TD><TD><A HREF="#kolmxp">KOLM2P</A></TD><TD><A HREF="#sizepx">SIZEP2</A></TD>
<TD ALIGN=center><TT>^1A</TT></TD><TD>unused</TD><TD><A HREF="#colbak">COLBAK</A></TD>
</TR><TR>
<TD ALIGN=center><TT>^0B</TT></TD><TD><A HREF="#kolmxp">KOLM3P</A></TD><TD><A HREF="#sizepx">SIZEP3</A></TD>
<TD ALIGN=center><TT>^1B</TT></TD><TD>unused</TD><TD><A HREF="#gtiactl">GTIACTL</A></TD>
</TR><TR>
<TD ALIGN=center><TT>^0C</TT></TD><TD><A HREF="#kolpxp">KOLP0P</A></TD><TD><A HREF="#sizem">SIZEM</A></TD>
<TD ALIGN=center><TT>^1C</TT></TD><TD>unused</TD><TD><A HREF="#vdelay">VDELAY</A></TD>
</TR><TR>
<TD ALIGN=center><TT>^0D</TT></TD><TD><A HREF="#kolpxp">KOLP1P</A></TD><TD><A HREF="#grafpx">GRAFP0</A></TD>
<TD ALIGN=center><TT>^1D</TT></TD><TD>unused</TD><TD><A HREF="#pmcntl">PMCNTL</A></TD>
</TR><TR>
<TD ALIGN=center><TT>^0E</TT></TD><TD><A HREF="#kolpxp">KOLP2P</A></TD><TD><A HREF="#grafpx">GRAFP1</A></TD>
<TD ALIGN=center><TT>^1E</TT></TD><TD>unused</TD><TD><A HREF="#hitclr">HITCLR</A></TD>
</TR><TR>
<TD ALIGN=center><TT>^0F</TT></TD><TD><A HREF="#kolpxp">KOLP3P</A></TD><TD><A HREF="#grafpx">GRAFP2</A></TD>
<TD ALIGN=center><TT>^1F</TT></TD><TD><A HREF="#consol">CONSOL</A></TD><TD><A HREF="#consol">CONSOL</A></TD>
</TR>
</TABLE>
<P>
<HR>
<P>
<H2>Description</H2>
</CENTER>
<A NAME="colbak"><U>COLBAK</U>
- <B>Color of background</B><BR>
bit 0 - unused<BR>
bits 3-1 - luminace<BR>
bits 7-4 - hue<P>
<A NAME="colpfx"><U>COLPF0</U> <U>COLPF1</U> <U>COLPF2</U> <U>COLPF3</U>
- <B>Colors of player field</B><BR>
bit 0 - unused<BR>
bits 3-1 - luminace<BR>
bits 7-4 - hue<P>
<A NAME="colpmx"><U>COLPM0</U> <U>COLPM1</U> <U>COLPM2</U> <U>COLPM3</U>
- <B>Colors of players and missiles</B><BR>
bit 0 - unused<BR>
bits 3-1 - luminace<BR>
bits 7-4 - hue<P>
<A NAME="consol"><U>CONSOL</U>
- <B>Consol keys</B><BR>
This is the only read/write register in GTIA.
Value written is negated on read. Bits 0-2 are ANDed
with keys status. Reset bit means key pressed.<BR>
bit 0 - START key<BR>
bit 1 - SELECT key<BR>
bit 2 - OPTION key<BR>
bit 3 - click sound<BR>
bits 4-7 - unused (=0)<P>
<A NAME="grafm"><U>GRAFM</U>
- <B>Graphics of missiles</B><BR>
bits 1,0 - graphics of missile 0<BR>
bits 3,2 - graphics of missile 1<BR>
bits 5,4 - graphics of missile 2<BR>
bits 7,6 - graphics of missile 3<P>
<A NAME="grafpx"><U>GRAFP0</U> <U>GRAFP1</U> <U>GRAFP2</U> <U>GRAFP3</U>
- <B>Graphics of players</B><P>
<A NAME="gtiactl"><U>GTIACTL</U>
- <B>GTIA control</B><BR>
bits 3-0 - priorities of players and missiles<BR>
0001 - P0, P1, P2, P3, PF0, PF1, PF2, PF3, BAK<BR>
0010 - P0, P1, PF0, PF1, PF2, PF3, P2, P3, BAK<BR>
0100 - PF0, PF1, PF2, PF3, P0, P1, P2, P3, BAK<BR>
1000 - PF0, PF1, P0, P1, P2, P3, PF2, PF3, BAK<BR>
Players/missiles and playfields are mentioned from highest to lowest priority.<BR>
Other combinations of bits 3-0 cause strange side effects.<BR>
bit 4 - set all missiles color to COLPF3<BR>
bit 5 - enable ORing colors P0 with P1 and P2 with P3 on common areas<BR>
bits 7,6 - GTIA extra graphics mode<BR>
00 - off<BR>
01 - 16 luminaces<BR>
10 - 9 colors<BR>
11 - 16 hues<P>
<A NAME="hitclr"><U>HITCLR</U>
- <B>Clear collision registers</B><BR>
Any value written to this register causes collision registers to be reset.<P>
<A NAME="hposmx"><U>HPOSM0</U> <U>HPOSM1</U> <U>HPOSM2</U> <U>HPOSM3</U>
- <B>Horizontal positions of missiles</B><P>
<A NAME="hpospx"><U>HPOSP0</U> <U>HPOSP1</U> <U>HPOSP2</U> <U>HPOSP3</U>
- <B>Horizontal positions of players</B><P>
<A NAME="kolmxp"><U>KOLM0P</U> <U>KOLM1P</U> <U>KOLM2P</U> <U>KOLM3P</U>
- <B>Collisions of missiles with players</B><BR>
bit 0 - collision with player 0<BR>
bit 1 - collision with player 1<BR>
bit 2 - collision with player 2<BR>
bit 3 - collision with player 3<BR>
bits 4-7 - unused (=0)<P>
<A NAME="kolmxpf"><U>KOLM0PF</U> <U>KOLM1PF</U> <U>KOLM2PF</U> <U>KOLM3PF</U>
- <B>Collisions of missiles with playfield</B><BR>
bit 0 - collision with playfield 0<BR>
bit 1 - collision with playfield 1<BR>
bit 2 - collision with playfield 2<BR>
bit 3 - collision with playfield 3<BR>
bits 4-7 - unused (=0)<P>
<A NAME="kolpxp"><U>KOLP0P</U> <U>KOLP1P</U> <U>KOLP2P</U> <U>KOLP3P</U>
- <B>Collisions of players with players</B><BR>
bit 0 - collision with player 0<BR>
bit 1 - collision with player 1<BR>
bit 2 - collision with player 2<BR>
bit 3 - collision with player 3<BR>
bits 4-7 - unused (=0)<P>
<A NAME="kolpxpf"><U>KOLP0PF</U> <U>KOLP1PF</U> <U>KOLP2PF</U> <U>KOLP3PF</U>
- <B>Collisions of players with playfield</B><BR>
bit 0 - collision with playfield 0<BR>
bit 1 - collision with playfield 1<BR>
bit 2 - collision with playfield 2<BR>
bit 3 - collision with playfield 3<BR>
bits 4-7 - unused (=0)<P>
<A NAME="pal"><U>PAL</U>
- <B>PAL system flag</B><BR>
bit 0 - unused<BR>
bits 1-3 - 000 if TV system is PAL. Else it is NTSC<BR>
bits 4-7 - unused (=0)<P>
<A NAME="pmctl"><U>PMCTL</U>
- <B>Player/Missile Control</B><BR>
bit 0 - get missiles data from ANTIC<BR>
bit 1 - get players data from ANTIC<BR>
bit 2 - lock triggers when pressed<BR>
bits 3-7 - unused<P>
<A NAME="sizem"><U>SIZEM</U>
- <B>Sizes of missiles</B><BR>
Two bits set size of each missile:<BR>
00 - single size<BR>
01 - double size<BR>
10 - single size<BR>
11 - quad size<BR>
bits 1,0 - size of missile 0<BR>
bits 3,2 - size of missile 1<BR>
bits 5,4 - size of missile 2<BR>
bits 7,6 - size of missile 3<P>
<A NAME="sizepx"><U>SIZEP0</U> <U>SIZEP1</U> <U>SIZEP2</U> <U>SIZEP3</U>
- <B>Sizes of players</B><BR>
bits 1,0 - size of player (see <A HREF="#sizem">SIZEM</A>)<BR>
bits 2-7 - unused<P>
<A NAME="trigx"><U>TRIG0</U> <U>TRIG1</U> <U>TRIG3</U>
- <B>Triggers</B><BR>
TRIG0 and TRIG1 contain trigger status of two joysticks.
TRIG3 contains presence of cartridge.<BR>
bit 0 - reset if trigger pressed<BR>
bits 1-7 - unused (=0)<P>
<A NAME="vdelay"><U>VDELAY</U>
- <B>Vertical delay of players and missiles</B><BR>
Causes players and missiles to be displayed one scanline lower.
Works only in two-line resolution.<BR>
bit 0 - delay missile 0<BR>
bit 1 - delay missile 1<BR>
bit 2 - delay missile 2<BR>
bit 3 - delay missile 3<BR>
bit 4 - delay player 0<BR>
bit 5 - delay player 1<BR>
bit 6 - delay player 2<BR>
bit 7 - delay player 3<P>
</BODY>
</HTML>

View File

@ -1,33 +0,0 @@
<HTML>
<HEAD>
<TITLE>X-ASM 2.2 Package Documentation</TITLE>
</HEAD>
<BODY BACKGROUND="6502proc.gif">
<CENTER>
<H1>X-ASM Package version 2.2</H1>
by <A HREF="mailto:pfusik@elka.pw.edu.pl">Fox/Taquart</A><P>
<HR>
<P>
Manuals of utilities:<P>
<TABLE>
<TR><TD><A HREF="xasm.htm">X-Assembler</A></TD><TD>6502 cross-assembler</TD></TR>
<TR><TD><A HREF="xboot.htm">X-BOOT</A></TD><TD>Atari executable -&gt; disk image converter</TD></TR>
<TR><TD><A HREF="xhead.htm">X-HEAD</A></TD><TD>Simple Atari executable analyzer</TD></TR>
<TR><TD><A HREF="xload.htm">X-LOAD</A></TD><TD>SIO2PC interface Atari executable loader</TD></TR>
<TR><TD><A HREF="gr0.htm">GR0</A></TD><TD>DOS screen adjuster</TD></TR>
</TABLE>
<P>
<HR>
<P>
Atari XL/XE documentation (under construction):<P>
<TABLE>
<TR><TD><A HREF="gtia.htm">GTIA</A></TD><TD>GTIA chip documentation</TD></TR>
<TR><TD><A HREF="cpubugs.asx">CPUBUGS.ASX</A></TD><TD>6502 bugs detector source</TD</TR>
</TABLE>
<P>
<HR>
<P>
All programs are <I>freeware</I>. Copyright (c) Taquart 1999.
</CENTER>
</BODY>
</HTML>

View File

@ -1,714 +0,0 @@
<HTML>
<HEAD>
<TITLE>X-Assembler 2.2 Manual</TITLE>
</HEAD>
<BODY BACKGROUND="6502proc.gif">
<CENTER>
<H1>X-Assembler version 2.2</H1>
by <A HREF="mailto:pfusik@elka.pw.edu.pl">Fox/Taquart</A><P>
</CENTER>
<HR></P><A NAME="intro">
<H2>INTRODUCTION
&nbsp;<A HREF="#usage">USAGE</A>
&nbsp;<A HREF="#syntax">SYNTAX</A>
&nbsp;<A HREF="#faq">FAQ</A>
&nbsp;<A HREF="index.htm">BACK</A>
</H2>
The X-Assembler is an cross-assembler, which generates code for the 6502 processor.
It is 99% compatible with Quick Assembler on 8-bit Atari.
<BR>
<H3>CHANGES</H3>
<H4>Version 2.2</H4>
<UL>
<LI> invalid absolute <TT>CPX</TT> and <TT>CPY</TT> op-codes bug fixed
<LI> branch addressing mode not checking bug fixed
<LI> <TT>ICL</TT> in last line bug fixed
<LI> <TT>OPT H-H+</TT> bug fixed
<LI> first <TT>ORG *</TT> bug fixed
<LI> origin setting not required until not used
<LI> Unix ($0a), Macintosh ($0d) and Atari ($9b) EOLs allowed in source
<LI> value of 'true' changed to 1
<LI> <A HREF="#new_environment">
setting environment variables on error option</A>
<LI> <A HREF="#new_newer">
assembling only if source newer than object option</A>
<LI> <A HREF="#new_opcode">op-code extracting</A>
<LI> <A HREF="#new_linerep">line repeating</A>
<LI> <A HREF="#new_pairing">instructions pairing</A>
<LI> <A HREF="#new_repskip">conditional repeat and skip pseudo commands</A>
<LI> <A HREF="#new_adrmodes">
<TT>(),0+</TT> and <TT>(),0-</TT> pseudo addressing modes</A>
</UL>
<H4>Version 2.0</H4>
<UL>
<LI> truncating name of object bug fixed
<LI> <TT>EQU</TT> and <TT>DTA</TT> forward reference bugs fixed
<LI> hex number recognizing bug fixed
<LI> now <TT>.OBX</TT> is default extension for Atari executables
<LI> assembling options (switches and <TT>OPT</TT> directive)
<LI> listing generation
<LI> label table generation
<LI> conditional assembling
<LI> user errors
<LI> warnings
<LI> improved headers generation
<LI> improved expressions - 19 operators and brackets, 32-bit arithmetic
<LI> improved signed numbers
<LI> 6 new pseudo commands (memory-to-memory move)
<LI> 8 pseudo addressing modes
<LI> indirect conditional jumps
<LI> Atari floating-point numbers generation
<LI> improved <TT>INS</TT>: inserting specified part of file
</UL>
<H4>Version 1.2</H4>
<UL>
<LI> first release
</UL>
<HR></P><A NAME="usage">
<H2><A HREF="#intro">INTRODUCTION</A>
&nbsp;USAGE
&nbsp;<A HREF="#syntax">SYNTAX</A>
&nbsp;<A HREF="#faq">FAQ</A>
&nbsp;<A HREF="index.htm">BACK</A>
</H2>
<H3>System requirements</H3>
<UL>
<LI> a PC compatible computer with 386 or better CPU
<LI> a MS-DOS compatible OS
<LI> a numeric coprocessor for generating sinus tables.
Your CPU probably has a built-in coprocessor.
</UL>
<H3>Creating a source program</H3>
Source file should be plain ASCII file. Although different EOLs are supported,
you would probably prefer CR/LF EOLs because of text editor.<BR>
Single line of source should not be longer than 256 characters.
There is no limitation on the length of the file.<BR>
Source may contain tabulators, which are treated as spaces.<BR>
Assembler is not case-sensitive.
<BR>
<H3>Converting Quick Assembler files</H3>
You must convert Atari text file into PC text file (EOL's from $9b to $0d/$0a),
ATASCII 0-31 and 128-255 characters should be replaced with standard ASCII
characters, using QAsm expressions.<BR>
You also have to change all <TT>OPT</TT> directives,
but usually you needn't them at all.
<BR>
<H3>Assembling a source program</H3>
You run assembler from DOS prompt with following syntax:<BR>
<PRE>XASM source [options]
</PRE><TT>source</TT> is name of source file.
If no extension given, the .ASX is added by default.<P>
Optional options are:
<DL>
<DT><TT>/c</TT>
<DD>Enable listing false conditionals.<BR>
By default lines skipped because of false condition are not listed.<P>
<A NAME="new_environment">
<DT><TT>/e</TT>
<DD>Enable setting environment variables when error occurs.<BR>
With this option, X-Asm sets two environment variables: ERRFILE and ERRLINE.
They may be used in a batch file to locate error and set editor on it.
For example, in my batch file I use such construction:
<PRE>XASM %1 /e
IF NOT ERRORLEVEL 1 GOTO ok
NCE +%ERRLINE% %ERRFILE%
</PRE>
NCE stands for Norton Classic Editor.<P>
If there was no error, variables point at last warning.
If no warning occured, they are removed from the environment.<P>
<DT><TT>/i</TT>
<DD>Disable listing included source.<BR>
Only main source file will be listed.<P>
<DT><TT>/l[:fname]</TT>
<DD>Enable generating listing.
If no <TT>fname</TT> given, listing is written to <TT>source.lst.</TT><P>
<A NAME="new_newer">
<DT><TT>/n</TT>
<DD>Check source and object modification times and assemble only
if source is newer than object file. X-Asm does NOT check included
nor inserted files but only main source, so be careful with this option.<P>
<DT><TT>/o:fname</TT>
<DD>Specify object name. Default is <TT>source.obx</TT>.<P>
<DT><TT>/s</TT>
<DD>Disable converting spaces to tabs in listing.
Using tabs makes listing file shorter.<BR>
Tab stops are assumed to be every 8 characters.<P>
<DT><TT>/t[:fname]</TT>
<DD>List label table.
If no <TT>fname</TT> given, table is written at the end of listing.<P>
</DL>
If source is incorrect, X-Asm stops on first encountered error.<P>
Errorlevels returned by X-Asm:<BR>
3 = bad parameters, assembling not started<BR>
2 = error occured<BR>
1 = warning(s) only<BR>
0 = no errors, no warnings<BR>
<H3>Listing structure</H3>
Line of listing includes:
<UL>
<LI> decimal number of line of source file (if source is different than in
previous listed line, appropriate message line is generated)
<LI> hexadecimal origin
<LI> hexadecimal bytes written to object file<BR>
Listed are also generated headers. A <TT>xxxx-yyyy&gt;</TT> in place of origin
represents generated header: <TT>$xxxx</TT> is the first and <TT>$yyyy</TT>
is the last byte of the block.
A <TT>FFFF&gt;</TT> represents two $ff bytes written as a header prefix.<BR>
A plus sign placed after hex numbers stands for more bytes written to object
in this line, not listed through lack of space.
<LI> remaining part of listing line is a copy of source line
</UL>
<H3>Label table structure</H3>
Line of label table includes:
<UL>
<LI> some label attributes:<BR>
<TT>n</TT> - label defined but not used elsewhere<BR>
<TT>2</TT> - label value known in pass 2 only (label definition uses forward
reference and thus you can't do forward references to that label)
<LI> hexadecimal value of the label
<LI> name of the label
</UL>
<HR></P><A NAME="syntax">
<H2><A HREF="#intro">INTRODUCTION</A>
&nbsp;<A HREF="#usage">USAGE</A>
&nbsp;SYNTAX
&nbsp;<A HREF="#faq">FAQ</A>
&nbsp;<A HREF="index.htm">BACK</A>
</H2>
Lines of source code may be:
<UL>
<LI> empty lines - ignored, of course
<LI> comments - ignored, too
<LI> statements - not ignored :-)
</UL>
Comment lines must have one of the following characters in the FIRST column
of the line: <TT>* ; |</TT>
</P><A NAME="expressions">
<H3>Expressions &nbsp;<A HREF="#statements">Statements</A></H3>
Expressions are numbers combined with operators and brackets.
You should use square brackets, because parentheses are reserved
for 6502 indirect addressing.
<H4>Numbers</H4>
Numbers are 32-bit signed integers, in the range of -$7fffffff..$7fffffff.
A number can be:
<TABLE>
<TR><TD WIDTH=300><UL><LI> a decimal number</TD><TD><TT>-12345</TT></TD></TR>
<TR><TD><UL><LI> a hexadedecimal number</TD><TD><TT>$abcd</TT></TD></TR>
<TR><TD><UL><LI> a binary number</TD><TD><TT>%10100101</TT></TD></TR>
<TR><TD><UL><LI> an ASCII character</TD><TD><TT>'a'</TT> or <TT>"a"</TT></TD></TR>
<TR><TD><UL><LI> an origin counter</TD><TD><TT>*</TT></TD></TR>
<TR><TD><UL><LI> a hardware register</TD><TD><TT>^31</TT></TD></TR>
</UL></TABLE>
<DIV STYLE="MARGIN-LEFT: 54">
An abbreviation of Atari hardware register:<BR>
<TT>^0x</TT> means <TT>$d00x</TT><BR>
<TT>^1x</TT> means <TT>$d01x</TT><BR>
<TT>^2x</TT> means <TT>$d20x</TT><BR>
<TT>^3x</TT> means <TT>$d30x</TT><BR>
<TT>^4x</TT> means <TT>$d40x</TT><BR>
where x is a hexadecimal digit.
</DIV>
<A NAME="new_opcode">
<TABLE>
<TR><TD WIDTH=300><UL><LI> an op-code</TD><TD><TT>{lda #0}</TT></TD></TR>
</UL></TABLE>
<DIV STYLE="MARGIN-LEFT: 54">
Byte op-code of instruction inside braces. Operand is discarded
and is necessary only for identifying addressing mode.
Instruction should begin right after left brace and right brace should
immediately follow the operand or the command in implied addressing mode.
</DIV>
<P>
<H4>Operators</H4>
Currently there are 19 operators:<P>
<TABLE>
<TR><TD><TT>+ </TT></TD><TD>Addition</TD></TR>
<TR><TD><TT>- </TT></TD><TD>Subtraction</TD></TR>
<TR><TD><TT>* </TT></TD><TD>Multiplication</TD></TR>
<TR><TD><TT>/ </TT></TD><TD>Division</TD></TR>
<TR><TD><TT>% </TT></TD><TD>Remainder</TD></TR>
<TR><TD><TT>& </TT></TD><TD>Bitwise and</TD></TR>
<TR><TD><TT>| </TT></TD><TD>Bitwise or</TD></TR>
<TR><TD><TT>^ </TT></TD><TD>Bitwise xor</TD></TR>
<TR><TD><TT>&lt;&lt; </TT></TD><TD>Arithmetic shift left</TD></TR>
<TR><TD><TT>&gt;&gt; </TT></TD><TD>Arithmetic shift right</TD></TR>
<TR><TD><TT>= </TT></TD><TD>Equal</TD></TR>
<TR><TD><TT>&lt;&gt; </TT></TD><TD>Not equal</TD></TR>
<TR><TD><TT>!= </TT></TD><TD>Not equal (same as <TT>&lt;&gt;</TT>)</TD></TR>
<TR><TD><TT>&lt; </TT></TD><TD>Less than</TD></TR>
<TR><TD><TT>&gt; </TT></TD><TD>Greater than</TD></TR>
<TR><TD><TT>&lt;= </TT></TD><TD>Less or equal</TD></TR>
<TR><TD><TT>&gt;= </TT></TD><TD>Greater or equal</TD></TR>
<TR><TD><TT>&& </TT></TD><TD>Logical and</TD></TR>
<TR><TD><TT>|| </TT></TD><TD>Logical or</TD></TR>
</TABLE>
<P>
Operator precedence:
<TABLE>
<TR><TD>first</TD><TD><TT>[]</TT></TD></TR>
<TR><TD> </TD><TD><TT>* / % & &lt;&lt; &gt;&gt;</TT></TD></TR>
<TR><TD> </TD><TD><TT>+ - | ^</TT></TD></TR>
<TR><TD> </TD><TD><TT>= &lt;&gt; != &lt; &gt; &lt;= &gt;=</TT></TD></TR>
<TR><TD> </TD><TD><TT>&&</TT></TD></TR>
<TR><TD>last </TD><TD><TT>||</TT></TD></TR>
</TABLE>
<P>
Compare and logical operators assume that zero is false and non-zero is true.
They return 1 for true.<P>
When calculating expression, 32-bit arithmetic is used. When range of 32 bits
is exceeded, <TT>'Arithmetic overflow'</TT> error is generated.<P>
</P><A NAME="statements">
<H3><A HREF="#expressions">Expressions</A> &nbsp;Statements</H3>
A statement is divided into fields:
<UL>
<LI> <A HREF="#label">label field</A>
<LI> <A HREF="#operation">operation field</A>
<LI> <A HREF="#operand">one or two operand fields</A>
<LI> <A HREF="#comment">comment field</A>
</UL>
There should be at least one space between every two fields
and there can't be any space within a field excluding strings.
</P><A NAME="label"><H4>Label field</H4>
This field is optional. It starts from first character of line, without
any blank characters before. It has two applications:
<UL>
<LI> Defining a label.<BR>
Label is a symbol representing an integer of range -$ffff..$ffff.<BR>
Name of a label can contain letters, digits and underscores (<TT>_</TT>).
Digit can't be label's first character.
Name of a label can be as long as you want and all the characters
are meaningful. In Quick Assembler only 6 leading characters were recognized
and some programs may not compile under X-Asm for this reason.<BR>
Defining a label without using <TT>EQU</TT> makes it equal to current value
of the origin counter.<BR>
Label can't be redefined.<P>
<A NAME="new_linerep">
<LI> Repeating the line.<BR>
Repeating means assembling single line several times as if
there were several identical lines. Note it is not just duplicating
bytes written to object.<BR>
Repeat count, which can be any valid expression, has to be preceded
with a colon.<BR>
Examples:
<PRE>:4 asl @
:2 dta a(*)
</PRE>
In the latter example each <TT>DTA</TT> has different operand value.<BR>
If repeat count equals zero, remaining part of line is not assembled.
This allows conditional assembly on single line to be more compact.
</UL>
You can not define a label in line which you repeat.<P>
<A NAME="new_pairing">
</P><A NAME="operation"><H4>Operation field</H4>
Operation field is the only field which is always required.
You have to put one or more spaces or tab characters between label
and operation field. If no label is defined, line must start with a blank
character. Operation field consists of one or two instructions.
The latter case is called instructions pairing, because a pair
of instructions have shared operand. You separate instructions
with a colon.<BR>
Example:
<PRE> adc:sta $80
</PRE>is equivalent to
<PRE> adc $80
sta $80
</PRE>
Single instruction always consists of 3 letters. It can be:
<OL TYPE=a>
<LI><I> 6502 command</I><BR>
One of 56 well known processor commands.<BR><BR>
<LI><I> compiler directive</I><BR>
One of the following:<P>
<DL>
<DT><TT><B>EQU</B></TT> - assign a value of expression to the label
<DD>Note that label represents a number, not a text macro.<BR>
Examples:
<PRE>five equ 5
here equ *
</PRE>
<DT><TT><B>OPT</B></TT> - set assembling options
<DD>Currently there are two options: listing generating and headers generating.
You can turn any of these on or off.<BR>
Default (if no <TT>OPT</TT> specified) is <TT>opt l+h+</TT>.<BR>
Examples:
<PRE> opt l- listing off
opt h- headers off
opt l+h- listing on, headers off
</PRE>
<DT><TT><B>ORG</B></TT> - set new origin counter
<DD>You can set some options applied to new header (if headers are on):
<UL>
<LI><TT>a:</TT> tells X-Asm to always make a header, even it is unnecessary,
like in <TT>ORG *</TT>.
<LI><TT>f:</TT> works same as <TT>a:</TT>, but additionally tells to generate
a $ff,$ff prefix before header. X-Asm adds it to the first header in file
by default, so use this option only if you want the $ff's somewhere inside.<BR>
</UL>
Examples:
<PRE> org $600
org f:$700
table org *+100
</PRE>
In the latter example <TT>table</TT> points to 100 bytes
of uninitialized data (note label is assigned to <TT>*</TT>
before <TT>ORG</TT> directive is executed).<P>
<DT><TT><B>DTA</B></TT> - define data
<DD>There are various data types:
<UL>
<LI> numbers
<UL>
<LI> bytes: <TT>b(200)</TT>
<LI> words: <TT>a(10000)</TT>
<LI> low bytes of words: <TT>l(511)</TT> defines byte 255
<LI> high bytes of words: <TT>h(511)</TT> defines byte 1<BR>
You may enter many expressions in parentheses and combine different types
of data in single line, separating things with commas.<BR>
You may also define a sinus table. Syntax is:<BR>
<TT>sin(centre,amp,size,first,last)</TT><BR>
where:
<UL>
<LI> <TT>centre</TT> is a number which is added to every sinus value
<LI> <TT>amp</TT> is the amplitude of sinus
<LI> <TT>size</TT> is the period of sinus
<LI> <TT>first,last</TT> define range of values in the table.
They are optional. Default are <TT>0,size-1</TT>.
</UL>
Example: <TT>dta a(sin(0,1000,256,0,63))</TT> defines table of 64 words
representing a quarter of sinus with amplitude of 1000.<P>
<LI> real numbers: <TT>r(-1.23456e12)</TT><BR>
Real numbers are written in 6-byte Atari Floating-Point format. You can't
combine reals with operators, as you can integers.<P>
</UL>
<LI> text strings
<UL>
<LI> ASCII strings: <TT>c'Text'</TT> or <TT>c"Text"</TT>
<LI> ANTIC strings: <TT>d'Text'</TT> or <TT>d"Text"</TT>
</UL>
A character string consists of any of characters surrounded by quotation
marks. Within a string, a single quotation mark character is
represented by two succesive quotation marks.<BR>
Placing a <TT>*</TT> character after a string inverts
high bit in every byte of string.<P>
</UL>
Examples of <TT>DTA</TT>:
<PRE>
dta b(2,5),a(1000,-1),l(12345,sin(0,127,256))
dta d"ANTIC"*,c'It''s a string',b(155)
</PRE>
<DT><TT><B>ICL</B></TT> - include another source file
<DD>Specifies another file to be included in the assembly as if the contests of
the referenced file appeared in place of the <TT>ICL</TT> statement.
The included file may contain other <TT>ICL</TT> statements.
The <TT>.ASX</TT> extension is added if none given.<P>
Examples:
<PRE>
icl 'macros.asx'
icl 'c:\atari\xasm\fileio'
</PRE>
<DT><TT><B>END</B></TT> - end assembling file
<DD>Remaining part of the file is not assembled. If this statement does
not occur, assembler stops assembling when encounters end of file.<BR>
Example:
<PRE>
end
</PRE>
<DT><TT><B>INS</B></TT> - insert contents of file
<DD>Copies every byte of specified file into object file and moves origin
counter, as if these bytes were defined with <TT>DTA</TT>.<BR>
You may specify range of inserted file. Syntax is:
<PRE>
ins 'file'[,offset[,length]]
</PRE>
First byte in file has offset 0.<BR>
If offset is negative, it is counted from the end of file.<BR>
Examples:
<PRE>
ins 'picture.raw'
ins 'file',-256 insert last 256 bytes of file
ins 'file',10,10 insert bytes 10..19 of file
</PRE>
<DT><TT><B>RUN</B></TT> - generate run address
<DD>The Atari executable program should have run address specified.
A program may be loaded in many areas of memory and started from any address.
<PRE> run addr
</PRE>
is equivalent to:
<PRE> org $2e0
dta a(addr)
</PRE>
Examples:
<PRE> run start
run program
</PRE>
<DT><TT><B>INI</B></TT> - generate init address
<DD>The Atari executable program may have some routines which are executed
during loading process. There may be many init blocks in one file.<BR>
Examples:
<PRE> ini init
ini showpic
</PRE>
<DT><TT><B>ERT</B></TT> - generate error if expression is true
<DD>Examples:
<PRE> ert *&gt;$c000
ert len1&gt;$ff||len2&gt;$ff
</PRE>
<DT><TT><B>IFT</B></TT> - assemble if expression is true<BR>
<TT><B>ELS</B></TT> - else<BR>
<TT><B>EIF</B></TT> - end if<BR>
<DD>With these directives you can construct fragments which
are assembled when a condition is met.
Conditional constructions can be nested.<BR>
Example:
<PRE>noscr equ 1
ift noscr
lda #0
els
lda #$22
eif
sta $22f
</PRE>
Above example can be rewritten using line repeating feature:
<PRE>noscr equ 1
:noscr<>0 lda #0
:noscr=0 lda #$22
sta $22f
</PRE>
</DL>
<LI><I> pseudo-command</I><BR>
It is something like built-in macro.
Note that it is not an illegal instruction and works on typical 6502.<P>
<DL>
<DT><TT><B>ADD</B></TT> - addition without carry
<DD>If you ever programmed 6502, you must have noticed that you had
to use a <TT>CLC</TT> before <TT>ADC</TT> for every simple addition.<BR>
X-Asm can do it for you. <TT>ADD</TT> replaces two instructions:
<TT>CLC</TT> and <TT>ADC</TT>.<P>
<DT><TT><B>SUB</B></TT> - subtraction
<DD>It is <TT>SEC</TT> and <TT>SBC</TT>.<P>
<A NAME="new_repskip">
<DT><TT><B>RCC, RCS, REQ, RMI, RNE, RPL, RVC, RVS</B></TT> - conditional repeat
<DD>They are branches to the previous instruction.
They take no operand, because the branch target
is the address of previously assembled instruction.<BR>
Example:
<PRE> ldx #0
mva:rne $500,x $600,x+
</PRE>
The example code copies memory $500-$5ff to $600-$6ff.
With standard 6502 commands only it would be:
<PRE> ldx #0
loop lda $500,x
sta $600,x
inx
bne loop
</PRE>
<DT><TT><B>SCC, SCS, SEQ, SMI, SNE, SPL, SVC, SVS</B></TT> - conditional skip
<DD>They are branches over the next instructions. No operand is required,
because the target is the address of instruction following
the next instruction.<BR>
Example:
<PRE> lda #40
add:sta $80
scc:inc $81
</PRE>
In the above example word variable $80 is incremented by 40.<BR>
Nor conditional repeat nor skip pseudo-commands require operand,
thus they can be paired with any other command.<P>
<DT><TT><B>JCC, JCS, JEQ, JMI, JNE, JPL, JVC, JVS</B></TT> - conditional jumps
<DD>They are a kind of 'long' branches. While standard branches
(<TT>BNE, BEQ</TT>) have range of -128..+127, these jumps have range
of all 64 kB.<BR>
Example:
<PRE> jne dest
</PRE>is equivalent to:
<PRE> seq:jmp dest
</PRE>
<DT><TT><B>INW</B></TT> - increment word
<DD>It is a 16-bit memory increment command.<BR>
Example:
<PRE> inw dest
</PRE>is equivalent to:
<PRE> inc dest
sne:inc dest+1
</PRE>
<DT><TT><B>MVA, MVX, MVY</B></TT> - move byte using accumulator, X or Y
<DD>Any of these pseudo-commands requires two operands
and substitutes two commands:
<PRE> mva source dest = lda source : sta dest
mvx source dest = ldx source : stx dest
mvy source dest = ldy source : sty dest
</PRE>
<DT><TT><B>MWA, MWX, MWY</B></TT> - move word using accumulator, X or Y
<DD>They also require two operands
and are combinations of two <TT>MV*</TT>'s:
one to move low byte, and the other to move high byte.<BR>
You can't use indirect nor pseudo addressing modes with <TT>MW*</TT>.
Destination must be absolute address (indexed or not).<BR>
When source is also absolute, a <TT>MW* SOURCE DEST</TT> will be:
<PRE> mv* source dest
mv* source+1 dest+1
</PRE>
When source is immediate, a <TT>MW* #IMMED DEST</TT> will be:
<PRE> mv* &lt;immed dest
mv* &gt;immed dest+1
</PRE>
When <TT>&lt;immed</TT> equals <TT>&gt;immed</TT> and <TT>immed</TT>
is not forward-referenced, X-Asm uses optimization:
<PRE> mv* &lt;immed dest
st* dest+1
</PRE>
</DL>
</OL>
</P><A NAME="operand"><H4>Operand</H4>
It depends on the operation field. Some statements don't need any operand,
other need two operands.<P>
6502 commands require operand depending on the addressing mode.
Addressing modes should be entered in standard convention except
the accumulator addressing mode, which should be marked with a
<TT>@</TT> character (as in Quick Assembler).<P>
There are two extra immediate addressing modes:
<TT>&lt;</TT> and <TT>&gt;</TT>,
which use low/high byte of word rather than byte value.<P>
In absolute addressing modes, X-Asm examines expression and uses zero-page
addressing mode if it thinks it is possible to do it. You may override it
with <TT>a:</TT> and <TT>z:</TT> prefixes.<P>
Examples:
<PRE>
nop
asl @
lda &gt;$1234 assembles to lda #$12
lda $100,x
lda a:0 generates 16-bit address
jmp ($0a)
lda ($80),y
</PRE>
There are also pseudo addressing modes, which are similar to
pseudo-commands. You may use them as standard addressing modes
in all 6502 commands and pseudo-commands excluding
<TT>MWA</TT>, <TT>MWX</TT> and <TT>MWY</TT> only:
<PRE> cmd a,x+ = cmd a,x : inx
cmd a,x- = cmd a,x : dex
cmd a,y+ = cmd a,y : iny
cmd a,y- = cmd a,y : dey
cmd (z),y+ = cmd (z),y : iny
cmd (z),y- = cmd (z),y : dey
cmd (z,0) = ldx #0 : cmd (z,x)
cmd (z),0 = ldy #0 : cmd (z),y
<A NAME="new_adrmodes"> cmd (z),0+ = ldy #0 : cmd (z),y : iny
cmd (z),0- = ldy #0 : cmd (z),y : dey
</PRE>
</P><A NAME="comment"><H4>Comment</H4>
Comment in a statement does not start from any special character
like <TT>;</TT> for example. Comment field is implied when appropriate
number of operands was taken.<P>
<HR></P><A NAME="faq">
<H2><A HREF="#intro">INTRODUCTION</A>
&nbsp;<A HREF="#usage">USAGE</A>
&nbsp;<A HREF="#syntax">SYNTAX</A>
&nbsp;FAQ
&nbsp;<A HREF="index.htm">BACK</A>
</H2>
<UL>
<LI><B>Q:</B> Why does X-Asm ignore <TT>+2</TT> in following line?
<PRE>label equ 1 +2
</PRE>
<B>A:</B> X-Asm treats space as operand terminator. Remaining part of line
is a comment. You should write <TT>1+2</TT> without any spaces.<P>
<LI><B>Q:</B> Why does <TT>lda #&lt;table</TT> not work?<P>
<B>A:</B> <TT>&lt;</TT> and <TT>&gt;</TT> represent addressing modes
rather than LOW and HIGH operators.<BR>
You specify <TT>lda &lt;table</TT>, not <TT>lda #&lt;table</TT>
like in most 6502 assemblers.<P>
<LI><B>Q:</B> What's wrong with <TT>asl a</TT> ?<P>
<B>A:</B> You should use <TT>@</TT> for accumulator addressing mode.<P>
<LI><B>Q:</B> What's wrong in following line?
<PRE>label: lda #0
</PRE>
<B>A:</B> Label definition can not include a colon.<P>
<LI><B>Q:</B> I wrote <TT>end start</TT>, where <TT>start</TT> points
to program beginning, but program seems not to start there. Why?<P>
<B>A:</B> You should have explicit run address specified.
Use <TT>run start</TT> directive. <TT>end</TT> takes no operand.<P>
<LI><B>Q:</B> Why this construction does not work:
<PRE>three equ one+two
two equ one+one
one equ 1
</PRE>
while this does:
<PRE>
two equ one+one
one equ 1
</PRE>
<B>A:</B> X-Asm reads source twice (in pass 1 and pass 2)
from the beginning until the end.<BR>
This allows forward references, but not too complex.<BR>
Keep in mind that assembler should know all the values in second pass.<P>
Example:
<PRE>two equ one+one This value is known in 2nd pass only
one equ 1 This value is known as early as in 1st pass
</PRE>
These values can be fixed in two passes.<BR>
If you insert following statement as first line:
<PRE>three equ one+two
</PRE>
X-Asm will generate an error because it can't fix
the value of <TT>three</TT> in second pass.<P>
<LI><B>Q:</B> X-Asm displayed single error while assembling my program.
When I fixed it, another error appeared. Why?<P>
<B>A:</B> X-Asm displays only first error.<BR>
When you were assembling for the first time, both errors might exist,
but X-Asm stopped assembling on the first one.<P>
<LI> If you have other questions/problems,
<A HREF=mailto:pfusik@elka.pw.edu.pl>write to me</A>.
</UL>
</BODY>
</HTML>

View File

@ -1,68 +0,0 @@
<HTML>
<HEAD>
<TITLE>X-BOOT 4.0 Manual</TITLE>
</HEAD>
<BODY BACKGROUND="6502proc.gif">
<CENTER>
<H1>X-BOOT version 4.0</H1>
by <A HREF="mailto:pfusik@elka.pw.edu.pl">Fox/Taquart</A><P>
<HR>
</CENTER>
<H2>INTRODUCTION</H2>
This tool converts Atari executable file (.OBX) into Atari disk image (.ATR),
which can be used in emulator. For loading executable into real Atari
you need no .ATR, try using <A HREF="xload.htm">X-LOAD</A>.
<H3>CHANGES</H3>
<H4>Version 4.0</H4>
<UL>
<LI> wildcards support - now you can convert a set of files
<LI> .ATR name not required - name can be taken from executable
<LI> no length limit - files longer than 60k allowed
<LI> truncated executables handling
<LI> checking for memory conflicts
<LI> better errors handling
</UL>
<H4>Version 3.2</H4>
<UL>
<LI> .OBX is default extension of Atari executable
</UL>
<H4>Version 3.1</H4>
<UL>
<LI> first release
</UL>
<HR>
<H2>USAGE</H2>
There are two ways of running X-BOOT:
<UL>
<LI><TT>XBOOT [/p] obxfile [atrfile]</TT>
<LI><TT>XBOOT [/p] obxfiles [atrpath]</TT>
</UL>
The former converts single file, the latter a set of files.<P>
Parameters in brackets are optional.<P>
<TT>/p</TT> switch forces writing 'professional loader', which allows you to load
code/data under ROM and disables ROM and interrupts while starting program.
By default, standard loader is used, which can load any Atari executable
not demanding DOS or any special loader.<P>
Both loaders disable Atari Basic, so you needn't hold OPTION key while
booting.<P>
<HR>
<H2>DETAILS</H2>
Produced ATR is single density and as short as possible.
Loader occupies one boot sector.<P>
X-BOOT does not write executable in ATR as Atari file.
You can't read it from DOS or extract it somehow or other.
You can only run it by booting.<P>
For more details, view sources of loaders:
<UL>
<LI>Standard: <A HREF="xbootstd.asx">XBOOTSTD.ASX</A>
<LI>Professional: <A HREF="xbootpro.asx">XBOOTPRO.ASX</A>
</UL>
Loaders are so simple that they even do not detect end of file. Instead,
they are modified when end of file is reached: disk image contains one
additional block, which doesn't belong to executable file, but changes
loader to run program instead of initializing.
</BODY>
</HTML>

View File

@ -1,64 +0,0 @@
* Boot executable file loader coded by Fox/Taquart
* Reads file from ATR prepared with X-BOOT.
* Professional version - can load file under ROM.
* Interrupts and ROM are disabled when running loaded program.
opt h-
org $480
bufr equ $400 128-byte buffer
tp equ $43 Temporary byte
vc equ $44 Start and end vectors (4 bytes)
* Boot code
boot dta b(0,1),a(boot,$e477) Boot header
mva #0 $22f Make screen blank...
mva #$52 $2c8 ... and pink ;)
lda 20 Wait for VBLK
cmp:req 20
mwa #rts $2e0 Set default run vector
dta b({lda a:0}) Skip two bytes
secrts sec Return with error
rts rts
mva:pha >rts $2e3 Set init address...
mva:pha <rts $2e2 ... and put return address on stack
ldx #-5 Load header
hput sta vc+4,x+ Store byte of header
stx tp
next inc bufx Increment buffer index
bpl getx Branch if within buffer
inw $30a Increment sector number
mva #$ff ^31 Turn ROM on
lsr ^4e Enable NMI interrupts
cli Enable IRQ interrupts
jsr $e453 Read sector
bmi secrts Exit on error
sei Disable IRQ interrupts
inc ^4e Disable NMI interrupts
dec ^31 Turn ROM off
asl bufx Change $80 to $00
getx lda bufr+$7f Get byte from buffer
bufx equ *-2 Buffer index
ldx tp Check if header or block data
bne hput Branch to store header
sta (vc,x) Store block data
inw vc Increment vector
lda vc+2 Check if end of block reached
cmp vc
lda vc+3
sbc vc+1
bcs next No: read next byte
mva #3 ^2f Yes: Reset POKEY...
init jmp ($2e2) ... and call init routine
dta c'4.0p' Unused boot sector space
ert *<>boot+$80 Exactly 128 bytes should be used
* X-BOOT adds this block at the end of loaded file
* It changes jmp ($2e2) to jmp ($2e0)
opt h+
org init+1
dta l($2e0)
end

View File

@ -1,63 +0,0 @@
* Boot executable file loader coded by Fox/Taquart
* Reads file from ATR prepared with X-BOOT.
* Standard loader - ROM and interrupts enabled.
opt h-
org $780
bufr equ $700 128-byte buffer
tp equ $43 Temporary byte
vc equ $44 Start and end vectors (4 bytes)
* Boot code
boot dta b(0,1),a(boot,$e477) Boot header
txtpos equ 215
ldy #txtpos Print text
print mva text-txtpos,y ($58),y+
cpy #txtpos+txtlen
bcc print
mwa #rts $2e0 Set default run vector
mva >bufr $305 Set buffer address
mva #$ff ^31 Turn BASIC off
dta b({lda a:0}) Skip two bytes
secrts sec Return with error
rts rts
mva:pha >rts $2e3 Set init address...
mva:pha <rts $2e2 ... and put return address on stack
ldx #-5 Load header
hput sta vc+4,x+ Store byte of header
stx tp
next inc bufx Increment buffer index
bpl getx Branch if within buffer
inw $30a Increment sector number
jsr $e453 Read sector
bmi secrts Exit on error
asl bufx Change $80 to $00
getx lda bufr+$7f Get byte from buffer
bufx equ *-2 Buffer index
ldx tp Check if header or block data
bne hput Branch to store header
sta (vc,x) Store block data
inw vc Increment vector
lda vc+2 Check if end of block reached
cmp vc
lda vc+3
sbc vc+1
bcs next No: read next byte
mva #3 ^2f Yes: Reset POKEY...
init jmp ($2e2) ... and call init routine
text dta d'Loading... '
txtlen equ *-text
dta c'4.0' Unused boot sector space
ert *<>boot+$80 Exactly 128 bytes should be used
* X-BOOT adds this block at the end of loaded file
* It changes jmp ($2e2) to jmp ($2e0)
opt h+
org init+1
dta l($2e0)
end

View File

@ -1,42 +0,0 @@
<HTML>
<HEAD>
<TITLE>X-HEAD 1.1 Manual</TITLE>
</HEAD>
<BODY BACKGROUND="6502proc.gif">
<CENTER>
<H1>X-HEAD version 1.1</H1>
by <A HREF="mailto:pfusik@elka.pw.edu.pl">Fox/Taquart</A><P>
<HR>
</CENTER>
<H2>INTRODUCTION</H2>
This tool prints headers of Atari executable.
You can examine which memory locations file loads into.
X-HEAD also shows init and run addresses.
<H3>CHANGES</H3>
<H4>Version 1.1</H4>
<UL>
<LI> .OBX is default extension of Atari executable
</UL>
<H4>Version 1.0</H4>
<UL>
<LI> first release
</UL>
<HR>
<H2>USAGE</H2>
Simply run X-HEAD with executable filename. No options are supported yet.<P>
X-HEAD will read the file and display its headers in following format:
<PRE> bbbb-eeee xxxx</PRE>
where <TT>bbbb</TT> is the begin, <TT>eeee</TT> - the end of the block,
and <TT>xxxx</TT> is the execution address (init or run vector).<P>
The summary includes:<BR>
<TT>xxxx bytes</TT> - length of file, including headers<BR>
<TT>xxxx blocks</TT> - number of headers<BR>
<TT>xxxx inits</TT> - number of init blocks (<TT>02e2-02e3</TT>)<BR>
<TT>xxxx modules</TT> - number of <TT>FFFF</TT> headers (one at the beginning is required)<P>
All displayed numbers are hexadecimal, of course.<P>
You can redirect output to a file, for example:
<PRE>XHEAD TEST &gt;TEST.HDR
</BODY>
</HTML>

View File

@ -1,81 +0,0 @@
<HTML>
<HEAD>
<TITLE>X-LOAD 1.0 Manual</TITLE>
</HEAD>
<BODY BACKGROUND="6502proc.gif">
<CENTER>
<H1>X-LOAD version 1.0</H1>
by <A HREF="mailto:pfusik@elka.pw.edu.pl">Fox/Taquart</A><P>
<HR>
</CENTER>
<H2>INTRODUCTION</H2>
This tool can be used for loading executable files from PC into real
Atari computer via SIO2PC interface. Only input and output lines are
used, so that X-LOAD should work with all types of interface.<P>
However, it is experimental version. I'm not sure if it will work
with every hardware. I've noticed it is not stable and sometimes
transmission can hang or distortions in loaded data may appear.
The reason is that there is no error-checking, while transmission is
fast (57.6 kbits/sec).<P>
<H3>CHANGES</H3>
<H4>Version 1.0</H4>
<UL>
<LI> first release
</UL>
<HR>
<H2>USAGE</H2>
You run X-LOAD from DOS prompt with executable filename and optional
options:<P>
<DL>
<DT><TT>/1</TT> - <TT>/4</TT>
<DD>Specify COM port number, which interface is attached to.
Default is COM2.<P>
<DT><TT>/p</TT>
<DD>Force using 'professional loader', which allows you to load
code/data under ROM and disables ROM and interrupts while starting program.
By default, standard loader is used, which can load any Atari executable
not demanding DOS or any special loader.<P>
</DL>
After you run X-LOAD, you only have to boot your Atari and the program
will be loaded and run.<P>
While loading, you can watch on your PC memory locations, which program
loads to.<P>
After program was loaded and run, X-LOAD terminates. You may exit it
earlier at any time by pressing ESC key.<P>
<HR>
<H2>DETAILS</H2>
First X-LOAD sends a byte to Atari and then waits until Atari is booted.
That byte can be used to detect from Atari, that PC is ready for transmission.
When you are testing your program, you may code periodic checking
if a byte was received, and performing cold reset in that case.
So that you needn't touch your Atari to run program on it.<P>
While booting, X-LOAD accepts two commands for disk drive 1:<P>
<UL>
<LI> <TT>'S'</TT> - read status. Used for checking presence of disk drive.
<LI> <TT>'R'</TT> - read sector (only first). Used for reading boot program.
</UL>
After Atari receives and runs its loader, the transmission runs at 57600
bits/sec. You can not hear any transmission sound, because the frequency
is too high for a human.<P>
Transmission protocol is very simple: Atari sends a byte to inform that
it is ready for receiving data. Then PC sends a 3-byte header and a block
of data. First two bytes of header are high and low byte of address
of last block byte minus $ff. Third byte equals low byte of
($100-block_length). Then come block data, which are loaded directly
into their memory location.
For more details, view sources of loaders:
<UL>
<LI>Standard: <A HREF="xloadstd.asx">XLOADSTD.ASX</A>
<LI>Professional: <A HREF="xloadpro.asx">XLOADPRO.ASX</A>
</UL>
You may have noticed that X-LOAD is somehow similar to X-BOOT, which also
has two loaders. The main difference is that X-BOOT loaders use system
routines to get sectors at regular speed of 19200 bits/sec.
They use sector buffer and require some low memory locations not to be changed
because of operating system. In this respect X-LOAD loaders are better, because
allow loading into whole memory except for loader code.
</BODY>
</HTML>

View File

@ -1,60 +0,0 @@
* Boot executable file loader coded by Fox/Taquart
* Receives file from X-LOAD via SIO2PC interface.
* Professional version - can load file under ROM.
* Interrupts and ROM are disabled when running loaded program.
opt h-
org $400
* Boot code
boot dta b(0,1),a(boot) Boot header
arts dta a(rts)
dta b({lda #$60}) Skip rts
rts rts
sei Disable interrupts
inc ^4e
inc ^40 Make screen blank
mva #$08 ^24 Set transmission speed
mva #$00 ^26
mva #$28 ^28
sta ^29 Reset counters
mva #$23 ^2f Send enable
sta ^2d Send a byte
wait sta ^4a Wait until sent
asl @
bcc wait
mva #$13 ^2f Receive enable
ldy #2
head jsr get Receive address (high/low byte)
sta stor,y
mva arts-1,y $2e2-1,y Set init address
pha Put return address on stack
dey
bne head
jsr get Receive length (one byte)
tax
load jsr get Receive data
stor sta a:0,x+ Store in memory
bne load
mva $10 ^2e Reset POKEY
mva #3 ^2f
init jmp ($2e2) Call init routine
get lda #$20 Function: Receive one byte
sta ^2e Enable receive interrupt
bit:rne ^2e Wait for interrupt request
sty ^2e Disable receive interrupt
lda ^2d Get byte
rts
:boot+$80-* dta b(0) Padd with zeros to full sector
* X-LOAD adds this block at the end of loaded file
* It changes jmp ($2e2) to jmp ($2e0)
opt h+
org init+1
dta l($2e0)
end

View File

@ -1,60 +0,0 @@
* Boot executable file loader coded by Fox/Taquart
* Receives file from X-LOAD via SIO2PC interface.
* Standard loader - ROM and interrupts enabled while running loaded program.
opt h-
org $700
* Boot code
boot dta b(0,1),a(boot) Boot header
arts dta a(rts)
dta b({lda #$60}) Skip rts
rts rts
sei Disable interrupts
inc ^4e
mva #$08 ^24 Set transmission speed
mva #$00 ^26
mva #$28 ^28
sta ^29 Reset counters
mva #$23 ^2f Send enable
sta ^2d Send a byte
wait sta ^4a Wait until sent
asl @
bcc wait
mva #$13 ^2f Receive enable
ldy #2
head jsr get Receive address (high/low byte)
sta stor,y
mva arts-1,y $2e2-1,y Set init address
pha Put return address on stack
dey
bne head
jsr get Receive length (one byte)
tax
load jsr get Receive data
stor sta a:0,x+ Store in memory
bne load
mva $10 ^2e Reset POKEY
mva #3 ^2f
lsr ^4e Enable interrupts
cli
init jmp ($2e2) Call init routine
get lda #$20 Function: Receive one byte
sta ^2e Enable receive interrupt
bit:rne ^2e Wait for interrupt request
sty ^2e Disable receive interrupt
lda ^2d Get byte
rts
:boot+$80-* dta b(0) Padd with zeros to full sector
* X-LOAD adds this block at the end of loaded file
* It changes jmp ($2e2) to jmp ($2e0)
opt h+
org init+1
dta l($2e0)
end

5
dub.sdl Normal file
View File

@ -0,0 +1,5 @@
name "xasm"
description "6502 cross-assembler with original syntax extensions"
authors "Piotr Fusik"
copyright "Copyright © 1998-2021, Piotr Fusik"
license "poetic"

248
fox.mak
View File

@ -1,248 +0,0 @@
;b. Fox/Tqa
eol equ 13,10
eot equ 13,10,'$'
;±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
MACRO lda _rg ;shorter than 'mov (e)ax, _rg'
_rge SUBSTR <_rg>, 1, 1
IFIDNI _rge, <e>
xchg eax, _rg
ELSE
xchg ax, _rg
ENDIF
ENDM
MACRO sta _rg ;shorter than 'mov _rg, (e)ax'
_rge SUBSTR <_rg>, 1, 1
IFIDNI _rge, <e>
xchg _rg, eax
ELSE
xchg _rg, ax
ENDIF
ENDM
;±±±±±±± DOS / FILE I/O ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
MACRO dos _func
IFNB <_func>
IF _func and 0ff00h
mov ax, _func
ELSE
mov ah, _func
ENDIF
ENDIF
int 21h
ENDM
MACRO file _func
IFNB <_func>
IF _func and 0ff00h
mov ax, _func
ELSE
mov ah, _func
ENDIF
ENDIF
IFDEF smartio
call xdisk
ELSE
int 21h
ENDIF
ENDM
MACRO smartdisk
smartio = 1
xdisk: dos
IFDEF rts
jnc rts
ELSE
jc _derr
ret
_derr:
ENDIF
mov dx, offset errtxt
jmp panic
ENDM
MACRO smarterr
errtxt db 'Disk error!',eot
ENDM
MACRO fcreate _fname ; ENTRY: DS:_fname|dx = ASCIIZ fname, RETURN: bx = handle
IFNB <_fname>
mov dx, offset _fname
ENDIF
xor cx, cx
file 3ch
sta bx
ENDM
MACRO fopen _fname ; ENTRY: DS:_fname|dx = ASCIIZ fname, RETURN: bx = handle
IFNB <_fname>
mov dx, offset _fname
ENDIF
file 3d00h
sta bx
ENDM
MACRO fupdate _fname ; ENTRY: DS:_fname|dx = ASCIIZ fname, RETURN: bx = handle
IFNB <_fname>
mov dx, offset _fname
ENDIF
file 3d02h
sta bx
ENDM
MACRO fclose ; ENTRY: bx = handle
file 3eh
ENDM
MACRO fread _fbufr ; ENTRY: DS:_fbufr = buffer, cx = no. of bytes
IFNB <_fbufr>
mov dx, offset _fbufr
ENDIF
file 3fh
ENDM
MACRO fwrite _fbufr ; ENTRY: DS:_fbufr = buffer, cx = no. of bytes
IFNB <_fbufr>
mov dx, offset _fbufr
ENDIF
file 40h
ENDM
;±±±±±±± PRINT ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
MACRO print _text
IFNB <_text>
mov dx, offset _text
ENDIF
dos 9
ENDM
MACRO PEOL
mov dl, 13
dos 2
mov dl, 10
dos 2
ENDM
MACRO PrintAXdec
LOCAL _outn1,_outn2,_dectxt,_cont
mov di, offset _dectxt+4
mov bx, 10
_outn1: xor dx, dx
div bx
add dl, '0'
_outn2: mov [di], dl
dec di
test ax, ax
jnz _outn1
mov dl, ' '
cmp di, offset _dectxt
jnb _outn2
print _dectxt
jmp _cont
_dectxt db 5 dup(' '),eot
_cont:
ENDM
MACRO PrintEAXdec
LOCAL _outn1,_outn2,_dectxt,_cont
mov di, offset _dectxt+9
mov ebx, 10
_outn1: xor edx, edx
div ebx
add dl, '0'
_outn2: mov [di], dl
dec di
test eax, eax
jnz _outn1
mov dl, ' '
cmp di, offset _dectxt
jnb _outn2
print _dectxt
jmp _cont
_dectxt db 10 dup(' '),eot
_cont:
ENDM
MACRO D2A
cmp al, 10
sbb al, 69h
das
ENDM
MACRO Printdig
d2a
sta dx
dos 2
ENDM
MACRO PrintAL
push ax
shr al, 4
PrintDig
pop ax
and al, 0fh
PrintDig
ENDM
MACRO PrintAX
push ax
mov al, ah
PrintAL
pop ax
PrintAL
ENDM
MACRO PrintEAX
push ax
shr eax, 16
PrintAX
pop ax
PrintAX
ENDM
;±±±±±±± GFX ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
MACRO setgfx _gmode
mov ax, _gmode
int 10h
ENDM
MACRO bar _jaki
IFDEF bars
mov dx, 3c8h
mov al, 0
out dx, al
inc dx
mov al, _jaki
out dx, al
out dx, al
out dx, al
ENDIF
ENDM
MACRO EndVBl
LOCAL w1,w2
mov dx, 3dah
w1: in al, dx
test al, 8
jz w1
w2: in al, dx
test al, 8
jnz w2
ENDM
MACRO StartVBL
LOCAL w1,w2
mov dx, 3dah
w1: in al, dx
test al, 8
jnz w1
w2: in al, dx
test al, 8
jz w2
ENDM

357
gr0.asm
View File

@ -1,357 +0,0 @@
IDEAL
P386
MODEL TINY
CODESEG
ORG 100h
include 'fox.mak'
smartio = 1
start:
db 2048 dup(0) ;compack
o_a = 1
o_b = 2
o_c = 4
o_d = 8
o_f = 10h
o_i = 20h
o_l = 40h
o_n = 80h
o_x = 100h
MACRO topt _op
testflag dx, _op
ENDM
mov si, 81h
mov bx, 0ff00h ;bh=attr mask, bl=attr set
xor dx, dx ;dx=options
gsw1: lodsb
cmp al, ' '
je gsw1
cmp al, 9
je gsw1
cmp al, 0dh
je gswx
cmp al, '/'
je gsw2
cmp al, '-'
je gsw2
usage: mov dx, offset usgtxt
panic: print
int 20h
smartdisk
rdpage: mov cx, 100h
fread
cmp ax, cx
jb _derr
ret
rdnum: lodsb
cmp al, ':'
jne usage
lodsw
sub ax, '00'
cmp al, 10
jae usage
cmp ah, 10
jae rdnum1
xchg al, ah
aad ;al:=10*ah+al
cmp al, 15
ja usage
ret
rdnum1: dec si
ret
gsw2: lodsb
and al, 0dfh
mov di, offset swilet
mov cx, 9
repne scasb
jne usage
bts dx, cx
jc usage
cmp al, 'B'
je sw_b
cmp al, 'C'
je sw_c
cmp al, 'F'
je sw_f
jmp gsw1
sw_b: call rdnum
shl al, 4
and bh, 0fh
or bl, al
jmp gsw1
sw_c: call rdnum
and bh, 0f0h
or bl, al
jmp gsw1
sw_f: cmp [byte si], ':'
jne usage
mov di, offset fname-1
swf1: movsb
cmp [byte si], ' '
je swf2
cmp [byte si], 9
je swf2
cmp [byte si], 0dh
jne swf1
swf2: pusha
mov bx, di
mov cx, di
sub cx, offset fname
je short jusage
adex1: dec bx
cmp [byte bx], '.'
je adexn
cmp [byte bx], '\'
loopne adex1
adex2: mov eax, 'TNF.'
stosd
adexn: mov [byte di], 0
fopen fname
mov dx, offset font+100h ;digits
call rdpage
mov dx, offset font+200h ;letters
call rdpage
mov dx, offset font ;controls
call rdpage
mov dx, offset font+300h ;low letters
call rdpage
fclose
popa
jmp gsw1
gswx: test dx, dx
jz jusage
topt o_a ;obsluz opcje a
jz atrok
setflag dx, o_n+o_l
topt o_b
jnz anob
and bx, 0f0fh
or bl, 10h
anob: topt o_c
jnz anoc
and bx, 0f0f0h
or bl, 7
anoc: topt o_d+o_f+o_x
jnz atrok
setflag dx, o_x
atrok:
mov ax, dx ;sprawdz opcje fontu
and ax, o_d+o_f+o_x
jz nofnt
bsf cx, ax ;dozwolona max 1 z opcji d,f,x
btr ax, cx
test ax, ax
jz fntok
jusage: jmp usage
nofnt: topt o_l ;jezeli l i zadna z d,f,x, to ustaw d
jz fntok
setflag dx, o_d
fntok: topt o_i
jz noinv0
topt o_f+o_x ;i tylko razem z f lub x
jz jusage
noinv0:
push bx
; inicjuj tryb tekstowy
topt o_n
jz noini
push dx
mov ax, 3
int 10h
pop dx
noini:
; wczytaj font domyslny
topt o_d+o_f+o_x
jz nodef
mov ax, 1112h
topt o_l
jnz def50
mov al, 14h
def50: push dx
xor bl, bl
int 10h
pop dx
nodef:
; wczytaj font uzytkownika
topt o_f+o_x
jz nocust
; ustaw odpowiedni font
mov cx, 128
topt o_i
jz noinv
; inwertuj znaki 0-127 na 128-255
mov si, offset font
mov di, offset ifont
mov cx, 1024
mkinv: lodsb
not al
stosb
loop mkinv
mov cx, 256
noinv: mov bp, offset font
mov bx, 800h
topt o_l
jnz nodbl
; rob font o podwojonej wysokosci
mov si, offset font
mov di, offset dfont
push cx
mov cx, 2048
mkdbl: lodsb
mov ah, al
stosw
loop mkdbl
pop cx
mov bp, offset dfont
mov bh, 16
nodbl: push dx
xor dx, dx
mov ax, 1110h
int 10h
pop dx
nocust:
; jezeli przelaczylismy 50->25 to skorygowac polozenie kursora
topt o_l
jnz nococu
topt o_d+o_f+o_x
jz nococu
xor bh, bh
mov ah, 3
int 10h ;wez pozycje kursora
sub dh, 25
jb nococu
xor bh, bh
mov ah, 2
int 10h ;ustaw kursor
mov ax, 0b800h ;przesuwa dolna polowke ekranu do gory
mov ds, ax
mov es, ax
mov si, 2*80*25
xor di, di
mov cx, si
rep movsb
mov ax, [di] ;czysci dolna polowke
mov al, ' '
mov cx, 80*25
rep stosw
push cs
pop ds
push cs
pop ds
nococu:
; ustaw kolory
pop bx
cmp bh, 0ffh
je nocol
push 0b800h
pop es
xor di, di
mov cx, 80*50
cls: inc di
and [es:di], bh
or [es:di], bl
inc di
loop cls
nocol: ret
swilet db 'XNLIFDCBA'
usgtxt db 'GR0 version 1.1 by Fox/Taquart',eol
db 'Customizes DOS screen.',eol
db 'Available options:',eol
db '/a Set Atari scheme = /b:1 /c:7 /n /l /x',eol
db '/b:nn Set background color 0-15',eol
db '/c:nn Set foreground color 0-15',eol
db '/d Set default PC font',eol
db '/f:fname Set external Atari font',eol
db '/i Set characters 128-255 to inverse',eol
db '/l Select 50 lines font',eol
db '/n Initialize text mode (clears screen)',eol
db '/x Set Atari built-in font',eot
smarterr
font db 0,54,127,127,62,28,8,0,24,24,24,31,31,24,24,24,3
db 3,3,3,3,3,3,3,24,24,24,248,248,0,0,0,24,24,24
db 248,248,24,24,24,0,0,0,248,248,24,24,24,3,7,14,28,56
db 112,224,192,192,224,112,56,28,14,7,3,1,3,7,15,31,63,127
db 255,0,0,0,0,15,15,15,15,128,192,224,240,248,252,254,255,15
db 15,15,15,0,0,0,0,240,240,240,240,0,0,0,0,255,255,0
db 0,0,0,0,0,0,0,0,0,0,0,255,255,0,0,0,0,240
db 240,240,240,0,28,28,119,119,8,28,0,0,0,0,31,31,24,24
db 24,0,0,0,255,255,0,0,0,24,24,24,255,255,24,24,24,0
db 0,60,126,126,126,60,0,0,0,0,0,255,255,255,255,192,192,192
db 192,192,192,192,192,0,0,0,255,255,24,24,24,24,24,24,255,255
db 0,0,0,240,240,240,240,240,240,240,240,24,24,24,31,31,0,0
db 0,120,96,120,96,126,24,30,0,0,24,60,126,24,24,24,0,0
db 24,24,24,126,60,24,0,0,24,48,126,48,24,0,0,0,24,12
db 126,12,24,0,0,0,0,0,0,0,0,0,0,0,24,24,24,24
db 0,24,0,0,102,102,102,0,0,0,0,0,102,255,102,102,255,102
db 0,24,62,96,60,6,124,24,0,0,102,108,24,48,102,70,0,28
db 54,28,56,111,102,59,0,0,24,24,24,0,0,0,0,0,14,28
db 24,24,28,14,0,0,112,56,24,24,56,112,0,0,102,60,255,60
db 102,0,0,0,24,24,126,24,24,0,0,0,0,0,0,0,24,24
db 48,0,0,0,126,0,0,0,0,0,0,0,0,0,24,24,0,0
db 6,12,24,48,96,64,0,0,60,102,110,118,102,60,0,0,24,56
db 24,24,24,126,0,0,60,102,12,24,48,126,0,0,126,12,24,12
db 102,60,0,0,12,28,60,108,126,12,0,0,126,96,124,6,102,60
db 0,0,60,96,124,102,102,60,0,0,126,6,12,24,48,48,0,0
db 60,102,60,102,102,60,0,0,60,102,62,6,12,56,0,0,0,24
db 24,0,24,24,0,0,0,24,24,0,24,24,48,6,12,24,48,24
db 12,6,0,0,0,126,0,0,126,0,0,96,48,24,12,24,48,96
db 0,0,60,102,12,24,0,24,0,0,60,102,110,110,96,62,0,0
db 24,60,102,102,126,102,0,0,124,102,124,102,102,124,0,0,60,102
db 96,96,102,60,0,0,120,108,102,102,108,120,0,0,126,96,124,96
db 96,126,0,0,126,96,124,96,96,96,0,0,62,96,96,110,102,62
db 0,0,102,102,126,102,102,102,0,0,126,24,24,24,24,126,0,0
db 6,6,6,6,102,60,0,0,102,108,120,120,108,102,0,0,96,96
db 96,96,96,126,0,0,99,119,127,107,99,99,0,0,102,118,126,126
db 110,102,0,0,60,102,102,102,102,60,0,0,124,102,102,124,96,96
db 0,0,60,102,102,102,108,54,0,0,124,102,102,124,108,102,0,0
db 60,96,60,6,6,60,0,0,126,24,24,24,24,24,0,0,102,102
db 102,102,102,126,0,0,102,102,102,102,60,24,0,0,99,99,107,127
db 119,99,0,0,102,102,60,60,102,102,0,0,102,102,60,24,24,24
db 0,0,126,12,24,48,96,126,0,0,30,24,24,24,24,30,0,0
db 64,96,48,24,12,6,0,0,120,24,24,24,24,120,0,0,8,28
db 54,99,0,0,0,0,0,0,0,0,0,255,0,0,24,60,126,126
db 60,24,0,0,0,60,6,62,102,62,0,0,96,96,124,102,102,124
db 0,0,0,60,96,96,96,60,0,0,6,6,62,102,102,62,0,0
db 0,60,102,126,96,60,0,0,14,24,62,24,24,24,0,0,0,62
db 102,102,62,6,124,0,96,96,124,102,102,102,0,0,24,0,56,24
db 24,60,0,0,6,0,6,6,6,6,60,0,96,96,108,120,108,102
db 0,0,56,24,24,24,24,60,0,0,0,102,127,127,107,99,0,0
db 0,124,102,102,102,102,0,0,0,60,102,102,102,60,0,0,0,124
db 102,102,124,96,96,0,0,62,102,102,62,6,6,0,0,124,102,96
db 96,96,0,0,0,62,96,60,6,124,0,0,24,126,24,24,24,14
db 0,0,0,102,102,102,102,62,0,0,0,102,102,102,60,24,0,0
db 0,99,107,127,62,54,0,0,0,102,60,24,60,102,0,0,0,102
db 102,102,62,12,120,0,0,126,12,24,48,126,0,0,24,60,126,126
db 24,60,0,24,24,24,24,24,24,24,24,0,126,120,124,110,102,6
db 0,8,24,56,120,56,24,8,0,16,24,28,30,28,24,16,0
fname:
ifont db 1024 dup(?)
dfont db 4096 dup(?)
ENDS
END start

3061
source/app.d Normal file

File diff suppressed because it is too large Load Diff

925
xasm.1.asciidoc Normal file
View File

@ -0,0 +1,925 @@
XASM (1)
========
:doctype: manpage
NAME
----
xasm - 6502 cross-assembler
SYNOPSIS
--------
*xasm* '[OPTIONS] SOURCE_FILE'
DESCRIPTION
-----------
*xasm* is a cross-assembler for the 6502 family processors.
'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`.
OPTIONS
-------
*-c*::
The listing should include conditionally skipped lines.
[[new_deflabel]]*-d* 'LABEL'='VALUE'::
Defines a label.
'LABEL' should be a valid label name.
'VALUE' may be any expression (potentially referencing labels defined in source files).
You may use several *-d* options to define many labels on the command line.
*-i*::
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`.
[[new_makefile]]*-M*::
Prints a `Makefile` rule.
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 `$<`.
Dollar signs in the command line are doubled.
Your *make* or shell may require further escaping.
*-o* 'OBJECT_FILE'::
Sets output file name.
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.
[[new_quiet]]*-q*::
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*::
Issues warnings for unreferenced labels.
Alternatively, you may use DOS-style options, for example:
-----------------------------------------------------------
xasm /i /d:DEBUG=1 /l:listing.lst source.asx
-----------------------------------------------------------
These are deprecated because they are incompatible with https://www.msys2.org[MSYS2].
SYNTAX
------
Source files should be plain ASCII files.
LF, CR, CR/LF and Atari ($9b) line terminators are supported.
Labels and instructions are case-insensitive.
*xasm* is backward compatible with Quick Assembler.
To compile QA sources with *xasm*, simply replace ATASCII characters
in string literals with the corresponding integers.
Also update all `OPT` directives, but often you can omit them.
A 'label' is a symbol that represents a signed 32-bit integer.
You define a label by putting its name at the beginning of a line
(with no spaces before).
The label will be assigned the current value of the 'origin counter'
(that is, the address of the compiled instruction),
unless you use it with the `EQU` directive to assign the specified value.
[[new_locallabel]]
Any label name starting with a `?` (question mark) is a 'local label'.
It is implicitly prefixed with the name of the most recently defined
'global label' (that is, a label without any `?` in name),
and remains visible until another global label is defined.
It is still possible to access a local label from anywhere in the source
by specifying its full name.
Local labels provide a way to reuse common, short label names while keeping
them unique.
Example:
----
foo ldy #0
?loop lda data,y ; full label name is FOO?LOOP
beq ?ret
jsr sendByte
iny:bne ?loop
?ret rts
bar lda baz
beq foo?ret ; ok
bne ?loop ; ERROR: Undeclared label: BAR?LOOP
----
'Instructions' and 'directives' must be preceded with some whitespace.
Without leading whitespace they are treated as label names.
For example:
----
nop
----
is a 6502 instruction, whereas
----
nop
----
(without leading space) defines a label called `nop`.
Whole-line comments must start with a semicolon, an asterisk or a pipe,
with an optional label definition and spaces before.
Here are examples of whole-line comments:
--------------------
; this is a comment
* so it is
label | and this too
--------------------
[[new_linerep]]
Lines with instructions (and selected directives) may be 'repeated'.
To assemble a single line several times,
precede the repeat count with a colon, for example:
-----------------
:4 asl @
mask_lookup :32 dta $80,$40,$20,$10,$08,$04,$02,$01
-----------------
In lines with instructions or directives, a comment starts immediately
after the instruction/directive has been successfully parsed.
That is, in such lines *xasm* does 'not' require any special character
to start a comment.
-------------------------------------------------------------
lda foo ; this is a comment
sta bar this too
tax #0 tax has no operand, therefore #0 starts this comment
-------------------------------------------------------------
[[new_pairing]]
You may put two or more instructions in one line so they share their operand.
For example:
------------
eor:sta foo
------------
is equivalent to
------------
eor foo
sta foo
------------
Note that
------------
lda:tax:tay #0
------------
is allowed because `#0` is treated as a comment for `tax` and `tay`.
EXPRESSIONS
-----------
Expressions are numbers combined with operators and brackets.
You should use square brackets, because parentheses are reserved
for 6502 indirect addressing.
A number is:
- a 32-bit decimal integer, e.g. `12345`
- a 32-bit hexadecimal integer, e.g. `$abcd`
- a 32-bit binary integer, e.g. `%10100101`
- an ASCII character, e.g. `'a'` or `"a"`
- the current value of the origin counter: `*`
- a hardware register (see below), e.g. `^4e`
- [[new_opcode]]an opcode (see below), e.g. `{lda #0}` is `$a9`
- [[new_linecnt]]the current value of the line repeat counter (see below): `#`
Abbreviations of Atari hardware registers are provided
to save two characters (`$d40e` vs `^4e`)
and to facilitate porting software between Atari 8-bit computers
and the Atari 5200 console.
These are very similar machines, one of the biggest differences
is the location of hardware registers.
[cols="^m,^d,^m,^d",options="header"]
|================================================
|Syntax|Chip |Value|Value in Atari 5200 mode (`opt g+`)
| ^0x |GTIA |$D00x|`$C00x`
| ^1x |GTIA |$D01x|`$C01x`
| ^2x |POKEY|$D20x|`$E80x`
| ^3x |PIA |$D30x|'error (there's no PIA chip)'
| ^4x |ANTIC|$D40x|`$D40x`
|================================================
The opcode syntax represents the opcode byte of the instruction inside braces.
The operand of the instruction is discarded and is needed only to recognize
the addressing mode. The instruction should begin right after the left brace
and the right brace should immediately follow the operand 'or' the instruction.
[[new_op_op]]You can skip the operand if the addressing mode is fixed.
Examples: `{lda #}`, `{jsr}`, `{bne}`, `{jmp ()}`, `{sta a:,x}`.
You can use the line repeat counter (`#`) in the repeated lines.
It counts the iterations starting from zero. Examples:
----------------------------------------------------
:3 dta # ; generates three bytes: 0, 1, 2.
line_lo :192 dta l(screen+40*#)
line_hi :192 dta h(screen+40*#)
dl :59 dta $4f,a(screen+40*#),0,$4f,a(screen+40*#),0
----------------------------------------------------
The following 'binary operators' are supported:
- `+` Addition
- `-` Subtraction
- `*` Multiplication
- `/` Division
- `%` Remainder
- `&` Bitwise AND
- `|` Bitwise OR
- `^` Bitwise XOR
- `<<` Arithmetic shift left
- `>>` Arithmetic shift right
- `==` Equal
- `=` Equal (same as `==`)
- `!=` Not equal
- `<>` Not equal (same as `!=`)
- `<` Less than
- `>` Greater than
- `<=` Less or equal
- `>=` Greater or equal
- `&&` Logical AND
- `||` Logical OR
[[new_unary]]
The following 'unary operators' are supported:
- `+` Plus (no operation)
- `-` Minus (changes the sign)
- `~` Bitwise NOT (complements all bits)
- `!` Logical NOT (changes true to false and vice versa)
- `<` Low (extracts the low byte)
- `>` High (extracts the high byte)
Although the operators are similar to those used in C, C++, C# and Java,
their precedence is different:
- first: `[]` (brackets)
- `+ - ~ < >` (unary)
- `* / % & << >>` (binary)
- `+ - | ^` (binary)
- `= == <> != < > <= >=` (binary)
- `!` (unary)
- `&&` (binary)
- last: `||` (binary)
The compare and logical operators assume that zero is false
and a non-zero is true. They return 1 for true.
Expressions are calculated in signed 32-bit arithmetic.
An overflow is signalled with an "Arithmetic overflow" error.
DIRECTIVES
----------
*EQU* - assign the value of an expression to a label::
Examples:
+
----------
five equ 5
here equ *
----------
[[new_opt]]*OPT* - set assembler options::
Six options are available:
- `F` - fill the space between noncontiguous memory areas with `$FF` bytes
- `G` - Atari 5200 mode for hardware register abbreviations (`^xx`)
- `H` - generate Atari executable headers
- `L` - write the listing
- `O` - write the object file
- `U` - warn of unused labels
+
You can turn any of these on or off.
The default (before the first `OPT`) is `opt f-g-h+l+o+u+`.
For compatibility with MADS, `opt ?+` is accepted and ignored.
Examples:
+
------------------------------------------------------------------------------
opt l- listing off
opt l+o- listing on, object file off
opt f+g+h- useful for Atari 5200 cartridges - raw output, 5200 hw regs
opt ?+ MADS compatibility, no effect
------------------------------------------------------------------------------
*ORG* - set the origin counter::
If Atari executable headers are enabled (`opt h+`), you can include an operand prefix:
- `a:` starts a new block even if it's superfluous
because the new address equals the current address.
- `f:` is same as `a:`, but additionally generates a double `$FF` prefix
before the new header. This prefix is automatically generated
at the beginning of the file (no need to include `f:` in the first `ORG`).
+
Examples:
+
---------------
org $600
org f:$700
table org *+100
---------------
+
In the latter example `table` points to 100 bytes
of uninitialized data (label is assigned with `*`
before the `ORG` directive is executed).
+
[[new_orgr]]*xasm* supports code that is relocated at run time.
Let's say you want your code to be located on page zero for best performance.
You can't safely load it directly into this place,
so you load it at a different address and then move in your program.
`org r:` changes the address that it used for code generation
but not the address used for generating Atari executable headers.
Example:
+
--------------------------------------
org $8000
ldx #code_length-1
mva:rpl code_loaded,x z:code_zpage,x-
jmp code_zpage
code_loaded
org r:$30
code_zpage
jmp * ; ... or something more sensible
code_length equ *-code_zpage
--------------------------------------
+
Note that both `*` and label definitions use the counter used
for code generation. There is no direct access to the other counter.
You can only calculate it:
+
---------------------------------------
where_am_i equ *-code_zpage+code_loaded
---------------------------------------
[[new_dta]]*DTA* - define data::
- integers
+
--
* bytes: `b(200)` or simply `200`
* words: `a(10000)`
* low bytes of words: `l(511)` (byte 255)
* high bytes of words: `h(511)` (byte 1)
You may enter many expressions in parentheses and combine different types
of data in single line, separating things with commas.
You may also build a sine lookup table. The syntax is:
-------------------------------
sin(center,amp,period,first,last)
-------------------------------
where:
* `center` is an integer which is added to every sine value
* `amp` is the sine amplitude
* `period` is the number of values per sine period
* `first,last` define the range of sine arguments.
They are optional. The default are `0,period-1`.
Example:
----------------------------
dta a(sin(0,1000,256,0,63))
----------------------------
defines a table of 64 words representing a quarter of sine with the amplitude of 1000.
--
- real numbers: `r(-1.23456e12)`
+
Real numbers are stored in the 6-byte Atari Floating-Point format.
- text strings
+
--
* ASCII strings: `c'Text'` or `c"Text"`
* ANTIC strings: `d'Text'` or `d"Text"`
A character string consists of any number of characters surrounded by quotation
marks. You can include the quotation marks in the string by doubling them.
Placing a `*` character after a string inverts
the highest bit in every byte of the string.
--
+
Examples of `DTA`:
+
------------------------------------------------
dta b(1,2),3,a(1000,-1),l(12345,sin(0,127,256))
dta d"ANTIC"*,c'It''s a string',$9b
------------------------------------------------
*ICL* - include another source file::
Specifies another file to be included in the assembly as if the contents
of the referenced file appeared in place of the `ICL` statement.
The included file may contain other `ICL` statements.
The `.asx` extension is added if none given.
Examples:
+
-----------------
icl 'macros.asx'
icl 'lib/fileio'
-----------------
+
NOTE: For Windows/macOS/Linux portability use relative paths
and slashes as path separators.
*END* - end this source file::
May be used if the source file ends with something which shouldn't
be read by *xasm* (e.g. your notes).
*INS* - insert binary file contents::
Copies every byte of the specified file into the object file and updates
the origin counter, as if these bytes were specified in a `DTA`.
You may specify a range of the file to insert. The syntax is:
+
-----------------------------
ins 'file'[,offset[,length]]
-----------------------------
+
The first byte in a file has the offset of zero.
If the offset is negative, it counts from the end of the file.
Examples:
+
-----------------------------------------------
ins 'picture.raw'
ins 'file',-256 ; insert last 256 bytes of file
ins 'file',10,10 ; insert bytes 10..19 of file
-----------------------------------------------
*RUN* - set the Atari executable run address::
+
---------
run main
---------
+
is equivalent to:
+
------------
org $2e0
dta a(main)
------------
*INI* - set the Atari executable init address::
Example:
+
------------
ini showloadingpic
------------
*ERT* - abort the assembly with an error if an expression is true::
Examples:
+
-----------------------
ert *>$c000
ert len1>$ff||len2>$ff
-----------------------
[[new_eli]]*IFT* - assemble if expression is true::
*ELI* - else if::
*ELS* - else::
*EIF* - end if::
With these directives you can construct fragments which
are assembled only when a condition is met.
Conditional constructions can be nested.
Example:
+
-------------
noscr equ 1
widescr equ 1
ift noscr
lda #0
eli widescr
lda #$23
els
lda #$22
eif
sta $22f
-------------
+
NOTE: Alternatively, the above example can be written using the 'repeat line' feature:
+
--------------------------
noscr equ 1
widescr equ 1
:noscr lda #0
:!noscr&&widescr lda #$23
:!noscr&&!widescr lda #$22
sta $22f
--------------------------
PSEUDO COMMANDS
---------------
'Pseudo commands' are built-in macros. There are 'no' user-defined macros in *xasm*.
*ADD* - add without carry::
If you have ever programmed a 6502, you must have noticed that you had
to use a `CLC` before `ADC` for every simple addition.
+
*xasm* can do it for you. `ADD` replaces two instructions: `CLC` and `ADC`.
*SUB* - subtract::
It is `SEC` followed by `SBC`.
[[new_repskip]]*RCC, RCS, REQ, RMI, RNE, RPL, RVC, RVS* - conditional repeat::
These are branches to the previous instruction.
They take no operand, because the branch target is the address
of the previously assembled instruction or pseudo command.
Example:
+
-----------------------
ldx #0
mva:rne $500,x $600,x+
-----------------------
+
The above code copies a 256-byte memory block from $500 to $600.
Here is the same written with standard 6502 commands only:
+
--------------------
ldx #0
copy_loop lda $500,x
sta $600,x
inx
bne copy_loop
--------------------
*SCC, SCS, SEQ, SMI, SNE, SPL, SVC, SVS* - conditional skip::
These are branches over the next instruction. No operand is required,
because the target is the address of the instruction following
the next instruction.
Example:
+
--------------
lda #40
add:sta ptr
scc:inc ptr+1
--------------
+
In the above example the 16-bit variable `ptr` is incremented by 40.
*JCC, JCS, JEQ, JMI, JNE, JPL, JVC, JVS* - conditional jump::
These are long branches. While standard branches (such as `BNE`)
have range of -128..+127 bytes, these jumps have range of 64 KB.
For example:
+
---------
jne dest
---------
+
is equivalent to:
+
-------------
seq:jmp dest
-------------
*INW* - increment word::
Increments a 16-bit word in the memory.
Example:
+
---------
inw dest
---------
+
is equivalent to:
+
---------------
inc dest
sne:inc dest+1
---------------
*MVA, MVX, MVY* - move a byte using the accumulator, X or Y::
Each of these pseudo commands requires two operands
and substitutes two commands:
+
----------------------------------------
mva source dest = lda source : sta dest
mvx source dest = ldx source : stx dest
mvy source dest = ldy source : sty dest
----------------------------------------
[[new_mwinde]]*MWA, MWX, MWY* - move word using accumulator, X or Y::
These pseudo commands require two operands and are combinations of two `MVA`/`MVX`/`MWY`:
one to move the low byte, and the other to move the high byte.
You can't use indirect nor pseudo addressing mode with `MWA`/`MWX`/`MWY`.
Destination must be an absolute or zeropage address, optionally indexed.
When source is also an absolute or zeropage address, an `mwa source dest` expands to:
+
--------------------
mva source dest
mva source+1 dest+1
--------------------
+
When source is an immediate value, an `mwa #immed dest` expands to:
+
------------------
mva <immed dest
mva >immed dest+1
------------------
+
When `<immed` equals `>immed` and `immed` is not forward-referenced,
*xasm* skips the second `LDA`, generating the following code:
+
----------------
mva <immed dest
sta dest+1
----------------
+
If possible, `MWX` and `MWY` use increment/decrement instructions.
For example, `mwx #1 dest` expands to:
+
-----------
ldx #1
stx dest
dex
stx dest+1
-----------
ADDRESSING MODES
----------------
Addressing modes are entered in the standard 6502 convention.
An exception is the accumulator mode marked with the `@` character
for compatibility with Quick Assembler.
Also for Quick Assembler compatibility there are two extra immediate
addressing modes: `<` and `>`, which use the low/high byte of a 16-bit word constant.
Unlike in Quick Assembler, you can alternatively use
the more common syntax: `#<` and `#>`.
Note the difference:
-------------------------------
lda >$ff+5 ; loads 1 (>$104)
lda #>$ff+5 ; loads 5 (0+5)
-------------------------------
You can explicitly specify absolute (`a:`) and zero-page (`z:`) addressing modes.
Examples:
--------------------------------------
nop
asl @
lda >$1234 assembles to lda #$12
lda $100,x
lda 0 zero-page (8-bit address)
lda a:0 absolute (16-bit address)
jmp ($0a)
lda ($80),y
--------------------------------------
[[new_adrmodes]]
There are 'pseudo addressing modes', which are similar to pseudo commands.
You may use them just like standard addressing modes in all 6502 commands
and pseudo commands, except for `MWA`, `MWX` and `MWY`:
------------------------------------------
cmd a,x+ = cmd a,x : inx
cmd a,x- = cmd a,x : dex
cmd a,y+ = cmd a,y : iny
cmd a,y- = cmd a,y : dey
cmd (z),y+ = cmd (z),y : iny
cmd (z),y- = cmd (z),y : dey
cmd (z,0) = ldx #0 : cmd (z,x)
cmd (z),0 = ldy #0 : cmd (z),y
cmd (z),0+ = ldy #0 : cmd (z),y : iny
cmd (z),0- = ldy #0 : cmd (z),y : dey
------------------------------------------
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)
- fixed emitted bytes not shown in the listing after `OPT L+` (by Adrian Matoga)
- emit shorter code for moving a negative immediate value with `MWX`/`MWY`
- Windows binary signed
- macOS binary signed, notarized, installed in `/usr/local/bin`
Version 3.1.1 (2019-11-20)
~~~~~~~~~~~~~~~~~~~~~~~~~~
- remove partial object file on error (requested by Bill Kendrick)
- report label name in the unused label warning (requested by Peter Dell)
- support `a:`/`f:` modifiers for `RUN`/`INI`
- improved performance with network drives (reported by Marek Pavlik)
Version 3.1.0 (2014-07-20)
~~~~~~~~~~~~~~~~~~~~~~~~~~
- OS X, Ubuntu and Fedora distributions
- `INS` can be repeated (suggested by Marek Pavlik) and taken "opcode" of
- `OPT U-` disables <<new_unlabels,*/u*>> unused label warnings
(suggested by Marek Pavlik)
- if the file to be included cannot be opened, report an error in the `ICL` line
(suggested by Peter Dell)
- removed duplicate filenames for <<new_makefile,*/M*>>
- implemented <<new_fullpaths,*/p*>> outside Windows
- source code updated from D1 to D2
- project moved to GitHub
Version 3.0.2 (2009-10-17)
~~~~~~~~~~~~~~~~~~~~~~~~~~
- fixed "Branch out of range" error message - was overstated by 256 bytes
for backward branches
- <<new_makefile,new command-line option */M* prints a Makefile rule>>
- command-line options are now case-insensitive
- on Windows, error messages are printed in red, warnings in yellow
Version 3.0.1 (2007-04-22)
~~~~~~~~~~~~~~~~~~~~~~~~~~
- fixed a bug in `OPT H-` mode
- made *xasm* compilable with the latest D compiler v1.010
(there were incompatible changes in the D language and library)
Version 3.0.0 (2005-05-22)
~~~~~~~~~~~~~~~~~~~~~~~~~~
- rewritten from the x86 assembly language to the
http://dlang.org/[D programming language] - Linux version
is now available and DOS is no longer supported
- no limits on line length, number of `ICLs`, `ORGs`,`IFTs` and labels
- Unix-style command-line options are supported
- the */e* option is removed
- the label table is now sorted alphabetically
Version 2.6.1 (2005-05-21)
~~~~~~~~~~~~~~~~~~~~~~~~~~
- no more "Arithmetic overflow" and "Division by zero" errors for correct
use of forward-referenced labels (bug found by Marcin Lewandowski)
- an error was reported in the following correct code:
+
---------
ift 0
foo equ 1
ift foo
eif
eif
---------
+
(bug found by Adrian Matoga)
- errors for non-existing `INC @` and `DEC @`
- negative numbers fixed in the listing
Version 2.6.0 (2005-02-07)
~~~~~~~~~~~~~~~~~~~~~~~~~~
- long file names are supported under Windows
- <<new_orgr,support for code relocated at runtime>>
- <<new_linecnt,line repeat counter>>
- label values are now 32-bit, not just 17-bit
- command-line options */n* and */s* are no longer supported
- fatal I/O errors no longer print the annoying "Abort, Retry, Ignore" message
Version 2.5.2 (2002-10-03)
~~~~~~~~~~~~~~~~~~~~~~~~~~
- version 2.5.1 broke Unix EOLs - fixed
- version 2.5.1 omitted all blank/comment/label lines, unless */c* was used
Version 2.5.1 (2002-08-21)
~~~~~~~~~~~~~~~~~~~~~~~~~~
- fixed assembling sources with Atari EOLs
- blank/comment/label lines in false conditionals are now correctly omitted
in listing
Version 2.5 (2002-07-08)
~~~~~~~~~~~~~~~~~~~~~~~~
- fixed another bug similar to the previous one, for example:
+
----------
ift 0
:label nop
eif
----------
+
reported "Label not defined before" error for the repeat count
- <<new_opt,`OPT F+` causes `ORG` to fill the space
between the old and the new location with `$FFs`>>
- <<new_opt,`OPT G+` enables Atari 5200 mode for hardware
register abbreviations>>
Version 2.4.1 (2002-06-27)
~~~~~~~~~~~~~~~~~~~~~~~~~~
- fixed a bug related to label definitions in conditionally skipped code,
e.g.
+
----------
ift 0
label
eif
----------
+
reported "No ORG specified" error for the label definition
Version 2.4 (2002-05-22)
~~~~~~~~~~~~~~~~~~~~~~~~
- fixed incorrect unary operator precedence
- fixed wrong label value after a skip pseudo command
- the assembler is an .EXE (.COM caused problems with DJGPP *make* due
to a bug in the DJGPP runtime)
- the assembler executable is no longer compressed
- improved command-line parsing: options may be used before the source file name,
tab is a valid separator, slash may be used as a directory separator
- error and warning messages are written to stderr, not stdout
- added `==` (equals) operator, equivalent to `=`, but familiar to C/C++/Java programmers
- <<new_deflabel,added `/d:label=value` option: define a label>>
- <<new_fullpaths,added `/p` option: print full paths
in listing and error messages>>
- <<new_quiet,added `/q` option: quiet mode>>
- <<new_unlabels,added `/u` option: warn of unused labels>>
- <<new_opt,writing to the object file may be suppressed with `OPT O-`>>
- <<new_eli,added `ELI` (else if) directive>>
- <<new_mwinde,`MWX` and `MWY` may use `INX`/`DEX` and `INY`/`DEY`,
respectively, for generating shorter code>>
Version 2.3 (2002-02-10)
~~~~~~~~~~~~~~~~~~~~~~~~
- fixed double skip (e.g. `SCC:SNE`)
- fixed real numbers with two-digit exponent
- trailing spaces are trimmed from listing lines
- label definitions allowed in blank, comment and repeated lines
- <<new_unary,unary operators>>
- <<new_dta,`DTA` implied byte mode>>
- <<new_op_op,operand can be skipped for some opcodes>>
Version 2.2 (1999-09-10)
~~~~~~~~~~~~~~~~~~~~~~~~
- fixed invalid opcodes of absolute `CPX` and `CPY`
- fixed: addressing mode not checked for branch commands
- fixed `ICL` in last line
- fixed `OPT H-H+`
- fixed first `ORG *`
- no need to set the origin counter until it's needed
- allow Unix, Macintosh and Atari EOLs
- value of 'true' changed to 1
- command-line option to set environment variables on error
- commane-line option to assemble only if the source is newer than the object file
- <<new_opcode,opcode extracting>>
- <<new_linerep,repeat line>>
- <<new_pairing,two instructions in line>>
- <<new_repskip,conditional repeat and skip pseudo commands>>
- <<new_adrmodes,`(),0+` and `(),0-` pseudo addressing modes>>
Version 2.0 (1998-11-12)
~~~~~~~~~~~~~~~~~~~~~~~~
- fixed: object filename was truncated
- fixed forward references in `EQU` and `DTA`
- fixed hex numbers
- `.OBX` is now the default extension for the object file
- options (command-line switches and `OPT`)
- listing
- label table
- conditional assembly
- user errors (`ERT`)
- warnings
- 6 new pseudo commands (memory-to-memory move)
- 8 pseudo addressing modes
- indirect conditional jumps
- Atari floating-point numbers
- object file headers optimization
- improved expressions - 19 operators and brackets, 32-bit arithmetic
- improved signed numbers
- improved `INS`: inserting specified part of file
Version 1.2 (1998-08-14)
~~~~~~~~~~~~~~~~~~~~~~~~
- first release
AUTHOR
------
Piotr Fusik <fox@scene.pl>
SEE ALSO
--------
Website: https://github.com/pfusik/xasm[]

2788
xasm.asm

File diff suppressed because it is too large Load Diff

42
xasm.properties Normal file
View File

@ -0,0 +1,42 @@
# xasm settings for SciTE (http://www.scintilla.org/SciTE.html)
file.patterns.xasm=*.asx
filter.xasm=xasm (asx)|$(file.patterns.xasm)|
*filter.xasm=$(filter.xasm)
lexer.$(file.patterns.xasm)=asm
*language.xasm=xasm|asx||
keywords.$(file.patterns.xasm)= \
adc add and asl bcc bcs beq bit \
bmi bne bpl brk bvc bvs clc cld \
cli clv cmp cpx cpy dec dex dey \
dta eif eli els end eor equ ert \
icl ift inc ini ins inw inx iny \
jcc jcs jeq jmi jmp jne jpl jsr \
jvc jvs lda ldx ldy lsr mva mvx \
mvy mwa mwx mwy nop opt ora org \
pha php pla plp rcc rcs req rmi \
rne rol ror rpl rti rts run rvc \
rvs sbc scc scs sec sed sei seq \
smi sne spl sta stx sty sub svc \
svs tax tay tsx txa txs tya
comment.block.asm=;
style.asm.32=
style.asm.1=$(colour.code.comment.line)
style.asm.2=
style.asm.3=$(colour.string)
style.asm.4=$(colour.operator)
style.asm.5=
style.asm.6=$(colour.keyword)
style.asm.7=
style.asm.12=$(colour.char)
style.asm.13=$(colour.error)
command.compile.$(file.patterns.xasm)=xasm /o:$(FileName).xex $(FilePath)
command.build.$(file.patterns.xasm)=make
if PLAT_WIN
command.go.$(file.patterns.xasm)=start $(FileName).xex
if PLAT_GTK
command.go.$(file.patterns.xasm)=atari800 -run $(FileName).xex

40
xasm.spec Normal file
View File

@ -0,0 +1,40 @@
Name: xasm
Version: 3.2.1
Release: 1
Summary: 6502 cross-assembler
License: Poetic
Source: http://pfusik.github.io/xasm/xasm-%{version}.tar.gz
URL: https://github.com/pfusik/xasm
BuildRequires: dmd >= 2, asciidoc
%description
xasm is a 6502 cross-assembler with original syntax extensions.
%global debug_package %{nil}
%prep
%setup -q
%build
make xasm xasm.1
%install
make DESTDIR=%{buildroot} prefix=%{_prefix} install
%files
%{_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
* Wed Nov 20 2019 Piotr Fusik <fox@scene.pl>
- 3.1.1-1
* Sun Jul 20 2014 Piotr Fusik <fox@scene.pl>
- 3.1.0-1
- Initial packaging

485
xboot.asm
View File

@ -1,485 +0,0 @@
; ><-B00T IV b. Fox
IDEAL
P386
MODEL TINY
CODESEG
zero db 100h dup(?)
blen = 60*1024
m_pro = 1 ; /p switch
m_wild = 2 ; obx has wild char
m_errs = 4 ; error/warning occured while current file
m_donta = 8 ; don't change output ext to atr
ffnam = 80h+1eh
eol equ 13,10
eot equ 13,10,'$'
MACRO lda _rg ;shorter than 'mov (e)ax, _rg'
_rge SUBSTR <_rg>, 1, 1
IFIDNI _rge, <e>
xchg eax, _rg
ELSE
xchg ax, _rg
ENDIF
ENDM
MACRO sta _rg ;shorter than 'mov _rg, (e)ax'
_rge SUBSTR <_rg>, 1, 1
IFIDNI _rge, <e>
xchg _rg, eax
ELSE
xchg _rg, ax
ENDIF
ENDM
MACRO dos _func
IFNB <_func>
IF _func and 0ff00h
mov ax, _func
ELSE
mov ah, _func
ENDIF
ENDIF
int 21h
ENDM
MACRO file _func
IFNB <_func>
IF _func and 0ff00h
mov ax, _func
ELSE
mov ah, _func
ENDIF
ENDIF
call xdisk
ENDM
MACRO jfile _func
IFNB <_func>
IF _func and 0ff00h
mov ax, _func
ELSE
mov ah, _func
ENDIF
ENDIF
jmp xdisk
ENDM
MACRO print _text
IFNB <_text>
mov dx, offset _text
ENDIF
dos 9
ENDM
start:
db 1536 dup(0) ; COMpack sux
mov [spt], sp
print hello
mov si, 81h ; pobierz argumenty
mov di, offset obxnam
mov ch, -1
arg1: lodsb
cmp al, ' '
je arg1 ; spacje omijamy
cmp al, '/'
jne nswit
lodsb ; '/' - switch
and al, 0dfh
cmp al, 'P'
jne usg
or [flags], m_pro ; '/P'
jmp arg1
nswit: cmp al, 0dh
je argx
cmp di, offset atrnam
ja usg ; byly juz dwie nazwy
spath: mov dl, -1 ; dolaczaj rozsz.
cmp di, offset atrnam
jnb snam1
and [flags], not m_wild
mov [onam], di ; onam - adres nazwy PLIKU .obx
snam1: cmp di, offset atrnam
ja snam2
cmp al, '*' ; w obx sprawdzaj wildy
je wildch
cmp al, '?'
jne snam2
wildch: or [flags], m_wild
snam2: cmp al, '.'
jne npoint
xor dl, dl ; jest rozszerzenie - nie dolaczaj .obx
npoint: stosb ; przepisz nazwe
lodsb
cmp al, ' ' ; spacja lub eol konczy
je snamx
cmp al, 0dh
je snamx
cmp al, '/'
je snamx ; '/' tez konczy
cmp [byte di-1], '\'
je spath
jmp snam1
usg: print usgtxt
dos 4c03h
snamx: mov eax, 'XBO.'
cmp di, offset atrnam
jb adobx
test [flags], m_wild
jz atrnwl
mov al, '\'
cmp al, [di-1]
je panam
stosb
panam: mov [anam], di
jmp nadext
atrnwl: test dl, dl
jz adatr ; jest podane rozszerzenie -
or [flags], m_donta ; nie zmieniaj go na atr
adatr: mov eax, 'RTA.'
adobx: test dl, dl
jz nadext
stosd
nadext: xor al, al
stosb
mov [nfin], di
dec si
cmp di, offset atrnam
mov di, offset atrnam
jb jarg1
inc di
jarg1: jmp arg1
argx: cmp di, offset atrnam
jb usg ; nie ma nazwy
ja jesatr
mov cx, [nfin]
test [flags], m_wild
jz nowil1 ; jak jeden plik, to przepiszemy cala nazwe
mov cx, [onam] ; jak wiele, to tylko sciezke
nowil1: mov si, offset obxnam
sub cx, si
rep movsb
mov [nfin], di
jesatr:
test [flags], m_wild
jz nowild
xor cx, cx
mov dx, offset obxnam
mov ah, 4eh ; jak wiele, to szukamy
main1: and [flags], not m_errs
mov [ohand], 0
mov [ahand], 0
mov [len], lodlen+endlen
dos
jc fin
mov si, 80h+1eh
mov di, [anam]
mov bx, [onam]
mona1: lodsb
stosb
mov [bx], al
inc bx
test al, al
jnz mona1
mov [nfin], di
nowild: mov si, offset obxnam
call printz ; file.obx
mov dx, offset obxnam
mov bp, offset e_open
file 3d00h ; open for reading
mov [ohand], ax
call xreadh
jb enate
cmp [head], -1
jne enate
mov dx, offset head
mov cx, 4
call xread
jnb nenate
enate: mov dx, offset e_nota
jmp error
nenate:
mov ax, [head]
mov [l1runl], al
mov [l2runl], al
mov [l1runh], ah
mov [l2runh], ah
print arrow ; ->
test [flags], m_donta
jnz jatrex
mov di, [nfin]
mov si, di
cetatr: dec si
cmp [byte si], '\'
je cetafn
cmp [byte si], '.'
jne cetatr
mov di, si
cetafn: mov eax, 'RTA.'
stosd
mov [byte di], 0
jatrex:
mov si, offset atrnam
call printz ; file.atr
xor cx, cx
mov dx, offset atrnam
mov bp, offset e_creat
file 3ch ; create
mov [ahand], ax
print kropki ; ...
mov cx, beglen
mov dx, offset begin
call xwrite
mov cx, lodlen
mov dx, offset stdlod
test [flags], m_pro
jz stlo
mov dx, offset prolod
stlo: call xwrite
jmp firs
skff:
call xreadh
jb chtrun
cmp [head], -1
je skff
mov dx, offset head+2
call xread2
jb trunca
firs: mov cx, [head+2]
sub cx, [head]
jb einva
inc cx
cmp cx, blen
ja einva
mov dx, offset blok
call xread
jb trunc
call xwrihd
jmp skff
einva: mov dx, offset e_head
jmp error
chtrun: test ax, ax
jnz trunca
jmp finfil
trunc: test ax, ax
jz finfil
dec ax
push ax
add ax, [head]
mov [head+2], ax
pop ax
call xwrihd
trunca: mov dx, offset w_trunc
call warni
finfil: mov dx, offset endseq1
test [flags], m_pro
jz endst
mov dx, offset endseq2
endst: mov cx, endlen
call xwrite
mov cx, 40h
xor ax, ax
mov di, offset head
rep stosw
sta cx
sub cl, [byte len]
and ecx, 7fh
jz fuls
call xwrith
fuls: xor cx, cx ; seek back to para's atr header field
mov dx, 2
mov bp, offset e_write
file 4200h
shr [len], 4
mov cx, 2
mov dx, offset len
call xwrite
shut: mov bx, [ahand]
mov bp, offset e_write
call xclose
mov bx, [ohand]
mov bp, offset e_read
call xclose
test [flags], m_errs
jnz nook
print oktxt
nook: print eoltxt
test [flags], m_wild
jz fin
mov ah, 4fh
jmp main1
fin: mov ax, [exitcod]
dos
xdisk: push bp
dos
pop dx
jnc rts
error: mov sp, [spt]
mov [byte exitcod], 2
or [flags], m_errs
print
jmp shut
warni: cmp [byte exitcod], 1
jae nwacod
mov [byte exitcod], 1
nwacod: or [flags], m_errs
print
ret
xreadh: mov dx, offset head
xread2: mov cx, 2
xread: mov bx, [ohand]
mov bp, offset e_read
file 3fh
cmp ax, cx
rts: ret
xwrihd: add ax, 4
movzx ecx, ax
mov ax, [head]
mov dx, [head+2]
test [flags], m_pro
jnz chkpro
cmp ah, 8
jae chkst1
cmp dh, 7
jae ememc
chkst1: cmp dh, 0c0h
jb xwrith
cmp dh, 0d0h
jb eproc
cmp ah, 0d8h
jb xwrith
eproc: mov dx, offset w_prof
jmp xwwarn
chkpro: cmp ah, 5
jae xwrith
cmp dh, 4
jb xwrith
ememc: mov dx, offset w_mem
xwwarn: push ecx
call warni
pop ecx
xwrith: mov dx, offset head
xwritl: add [len], ecx
xwrite: mov bx, [ahand]
mov bp, offset e_write
jfile 40h
xclose: test bx, bx
jz rts
jfile 3eh
pnam1: sta dx
dos 2
printz: lodsb
test al, al
jnz pnam1
ret
hello db 'X-BOOT 4.0 by Fox/Taquart',eot
usgtxt db 'XBOOT [/p] obxfile [atrfile]',eol
db ' Convert single Atari 8-bit executable into .ATR disk image.',eol
db 'XBOOT [/p] obxfiles [atrpath]',eol
db ' Convert many files - wildcards allowed.',eol
db '/p switch',eol
db ' Write professional loader rather than standard.'
eoltxt db eot
arrow db ' -> $'
kropki db ' ... $'
oktxt db 'OK$'
w_mem db eol,' WARNING: Memory conflict$'
w_prof db eol,' WARNING: Professional loader needed$'
w_trunc db eol,' WARNING: File is truncated$'
e_nota db eol,' ERROR: Not Atari executable$'
e_head db eol,' ERROR: Invalid header$'
e_open db eol,' ERROR: Can''t open file$'
e_read db eol,' ERROR: Disk read error$'
e_creat db eol,' ERROR: Can''t create file$'
e_write db eol,' ERROR: Disk write error$'
; ATR Header
begin dw 296h,0,80h,5 dup(0)
beglen = $-begin
; Loader #1 (std)
stdlod db 0,1,128,7,119,228,160,215,185,27,7,145,88,200,192,226,144
db 246,169
l1runl db 168,141,224,2,169
l1runh db 7,141,225,2,169,7,141,5,3,169,255
db 141,1,211,173,56,96,169,7,141,227,2,72,169,168,141,226,2,72
db 162,251,149,72,232,134,67,238,210,7,16,16,238,10,3,208,3,238
db 11,3,32,83,228,48,217,14,210,7,173,127,7,166,67,208,223,129
db 68,230,68,208,2,230,69,165,70,197,68,165,71,229,69,176,210,169
db 3,141,15,210,108,226,2,44,111,97,100,105,110,103,14,14,14,0
db 52,46,48
lodlen = $-stdlod
; Ending Header for loader #1
endseq1 db 240,7,240,7,224
endlen = $-endseq1
; Loader #2 (rom)
prolod db 0,1,128,4,119,228,169,0,141,47,2,169,82,141,200,2,165
db 20,197,20,240,252,169
l2runl db 162,141,224,2,169
l2runh db 4,141,225,2,173,56,96
db 169,4,141,227,2,72,169,162,141,226,2,72,162,251,149,72,232,134
db 67,238,220,4,16,32,238,10,3,208,3,238,11,3,169,255,141,1
db 211,78,14,212,88,32,83,228,48,208,120,238,14,212,206,1,211,14
db 220,4,173,127,4,166,67,208,207,129,68,230,68,208,2,230,69,165
db 70,197,68,165,71,229,69,176,194,169,3,141,15,210,108,226,2,52
db 46,48,112
; Ending Header for loader #2
endseq2 db 250,4,250,4,224
exitcod dw 4c00h
flags db 0
len dd lodlen+endlen
ohand dw 0
ahand dw 0
anam dw atrnam
onam dw ?
nfin dw ?
spt dw ?
obxnam db 100h dup(?)
atrnam db 100h dup(?)
head dw ?,?
blok db blen dup(?)
ENDS
END start

152
xhead.asm
View File

@ -1,152 +0,0 @@
IDEAL
P386
MODEL TINY
CODESEG
ORG 100h
include 'fox.mak'
smartio = 1
start: print hello
mov di, 81h
movzx cx, [di-1]
jcxz usg
mov al, ' '
repe scasb
je usg
push cx di
dec di
inc cx
mov al, '?'
repne scasb
pop di cx
jne nousg
usg: mov dx, offset usgtxt
panic: print
int 20h
smartdisk
read: mov cx, 2
fread addr
cmp ax, 2
mov ax, [addr]
ret
nousg: lea dx, [di-1]
mov al, ' '
repne scasb
jne okend
dec di
okend: mov si, di
mov cx, di
sub cx, dx
adex1: dec si
cmp [byte si], '.'
je adexn
cmp [byte si], '\'
loopne adex1
adex2: mov eax, 'XBO.'
stosd
adexn: mov [byte di], 0
fopen
call read
mov dx, offset notbin
inc ax
jnz panic
head1: inc [mods]
call read
jb eof
cmp ax, 0ffffh
je head1
inc [blox]
dec [mods]
mov [begn], ax
mov dl, ' '
dos 2
mov ax, [begn]
call prword
mov dl, '-'
dos 2
call read
mov dx, ax
sub dx, [begn]
inc dx
call prword
cmp dx, 2
jne skip
cmp [begn], 2e0h
je pexec
cmp [begn], 2e2h
jne skip
inc [inits]
pexec: mov dl, ' '
dos 2
call read
call prword
jmp heade
skip: xor cx, cx
file 4201h
heade: PEOL
jmp head1
eof: xor cx, cx
xor dx, dx
file 4202h
push ax
mov al, dl
call pbyte
pop ax
call prword
print byttxt
mov ax, [blox]
call prword
print blotxt
mov ax, [inits]
call prword
print initxt
mov ax, [mods]
call prword
print modtxt
fclose
ret
prword: push ax
mov al, ah
call pbyte
pop ax
pbyte: ror ax, 4
and al, 0fh
call pdig
shr ax, 12
pdig: d2a
pusha
sta dx
dos 2
popa
ret
hello db 'X-HEAD 1.1 by Fox/Taquart',eot
usgtxt db 'Syntax: XHEAD obxfile',eot
notbin db 'File is not an Atari executable!',eot
smarterr
byttxt db ' bytes',eot
blotxt db ' blocks',eot
initxt db ' inits',eot
modtxt db ' modules',eot
blox dw 0
inits dw 0
mods dw 0
addr dw ?
begn dw ?
ENDS
END start

446
xload.asm
View File

@ -1,446 +0,0 @@
IDEAL
P386
MODEL TINY
CODESEG
zero db 100h dup(?)
ratio equ 671/1000
timeAnswer = 2500*ratio
timeChecksum = 1500*ratio
timeSending = 600*ratio
timeNormal = 900*ratio
timeBefore = 1500*ratio
timeBetween = 600*ratio
timeUltra = 310*ratio
eol equ 13,10
eot equ 13,10,'$'
MACRO lda _rg ;shorter than 'mov (e)ax, _rg'
_rge SUBSTR <_rg>, 1, 1
IFIDNI _rge, <e>
xchg eax, _rg
ELSE
xchg ax, _rg
ENDIF
ENDM
MACRO sta _rg ;shorter than 'mov _rg, (e)ax'
_rge SUBSTR <_rg>, 1, 1
IFIDNI _rge, <e>
xchg _rg, eax
ELSE
xchg _rg, ax
ENDIF
ENDM
MACRO dos _func
IFNB <_func>
IF _func and 0ff00h
mov ax, _func
ELSE
mov ah, _func
ENDIF
ENDIF
int 21h
ENDM
MACRO file _func
IFNB <_func>
IF _func and 0ff00h
mov ax, _func
ELSE
mov ah, _func
ENDIF
ENDIF
call xdisk
ENDM
MACRO fread _fbufr
mov dx, offset _fbufr
call xread
ENDM
MACRO print _text
IFNB <_text>
mov dx, offset _text
ENDIF
dos 9
ENDM
start:
db 1536 dup(0) ;compack
print hello
mov si, 81h
mov di, offset obxnam
arg1: lodsb
cmp al, ' '
je arg1
cmp al, '/'
jne nswit
lodsb
cmp al, '4'
ja ndigt
sub al, '1'
jb usg
mov [byte port], al
jmp arg1
ndigt: and al, 0dfh
cmp al, 'P'
jne usg
mov [prof], al
jmp arg1
nswit: cmp al, 0dh
je argx
cmp di, offset obxnam
ja usg
mnam1: stosb
lodsb
cmp al, ' '
je mnam2
cmp al, '/'
je mnam2
cmp al, 0dh
jne mnam1
mnam2: dec si
mov bx, di
lea cx, [di+zero-obxnam]
adex1: dec bx
cmp [byte bx], '.'
je adexn
cmp [byte bx], '\'
loopne adex1
mov eax, 'XBO.'
stosd
adexn: mov [byte di], 0
jmp arg1
usg: print usgtxt
dos 4c03h
noport: mov dx, offset nocom
jmp panic
nobin: mov dx, offset e_nota
jmp panic
xdisk: push bp
dos
pop dx
jc panic
ret
panic: print
dos 4c02h
xread: mov bp, offset e_read
file 3fh
cmp ax, cx
ret
argx: cmp di, offset obxnam
jbe usg
mov bx, [port]
add [comnum1], bl
add [comnum2], bl
add bx, bx
push ds
push 40h
pop ds
mov cx, [bx]
pop ds
jcxz noport
mov [port], cx
mov dx, offset obxnam
mov bp, offset e_open
file 3d00h ; open for reading
sta bx
mov cx, 2
fread dcb
cmp [word dcb], 0ffffh
jne nobin
mov dx, [port]
mov al, 3
add dl, al
out dx, al
and dl, 0feh
xor al, al
out dx, al
print rboot
mov dx, [port]
mov cx, 6
call speed
and dl, 0f8h
mov al, 5
out dx, al
in al, dx
mov di, offset dcb
main: mov dx, [port]
in al, 60h
cmp al, 1
je byebye
add dl, 5
in al, dx
test al, 1
jz main
and dl, 0f8h
in al, dx
mov [di+5], al
stosb
cmp di, offset dcb+5
jb sk1
mov di, offset dcb
sk1: cmp [byte di], 31h
jne main
cmp [byte di+1], 'R'
je xcom_r
cmp [byte di+1], 'S'
jne main
xcom_s: call ack
mov si, offset statdat
mov cx, 5
call send
print booting
jmp main
xcom_r: cmp [word di+2], 1
jne main
call ack
mov si, offset bootstd
test [prof], 0ffh
jz sk3
mov si, offset bootpro
sk3: mov cx, 129
call send
call wate
mov cx, 2
call speed
mov [trtime], timeUltra
test [prof], 0ffh
jz nodrom
call wtblok
mov si, offset bankdat
mov cx, 4
call send
nodrom:
call wtblok
ffff: mov cx, 2
fread head
jb kpliq
cmp [head], 0ffffh
je ffff
mov cx, 2
fread head+2
jb kpliq
mov di, offset hexnum
mov ax, [head]
call hexw
inc di
mov ax, [head+2]
call hexw
print loading
mov ax, [head]
dec ax
sub [head+2], ax
dalej: mov ax, [head+2]
cmp ax, 100h
jbe sk2
mov ax, 100h
sk2: sub [head+2], ax
sta cx
fread buf+3
mov cx, ax
jcxz kpliq
mov si, offset buf
add ax, [head]
dec ah
xchg al, ah
mov [si], ax
mov al, cl
neg al
mov [si+2], al
add cx, 3
call send
inc [byte high head]
call wtblok
cmp [head+2], 0
jnz dalej
jmp ffff
kpliq:
mov si, offset runstd
test [prof], 0ffh
jz sk4
mov si, offset runpro
sk4: mov cx, 4
call send
mov bp, offset e_read
file 3eh ; close file
print done
byebye: dos 4c00h
wtblok: in al, 60h
cmp al, 1
je byebye
and dl, 0f8h
add dl, 5
in al, dx
test al, 1
jz wtblok
and dl, 0f8h
in al, dx
mov si, offset bttime
jmp wate
speed: and dl, 0f8h
add dl, 3
in al, dx
push ax
or al, 80h
out dx, al
and dl, 0f8h
mov ax, cx
out dx, ax
add dl, 3
pop ax
out dx, al
ret
send: push si
mov si, offset trtime
call wate
pop si
mov dx, [port]
outsb
loop send
ret
ack: mov si, offset ackdat
call wate
outsb
call wate
outsb
wate: in al, 61h
and al, 0fch
out 61h, al
mov ah, al
mov al, 0b0h
out 43h, al
lodsb
out 42h, al
lodsb
out 42h, al
mov al, 1
or al, ah
out 61h, al
mov al, 080h
out 43h, al
wate1: in al, 42h
in al, 42h
cmp al, 255
je wate1
wate2: in al, 42h
in al, 42h
cmp al, 255
jne wate2
mov al, ah
out 61h, al
ret
hexw: push ax
mov al, ah
call hexb
pop ax
hexb: aam 10h
cmp al, 10
sbb al, 69h
das
xchg al, ah
cmp al, 10
sbb al, 69h
das
stosw
ret
ackdat: dw timeAnswer
db 'A'
dw timeChecksum
db 'A'
dw timeSending
statdat db 098h,0FFh,001h,000h,099h
bankdat db 0D2h,002h,0FFh,0FEh
runstd db 006h,060h,0FFh,0E0h
runpro db 003h,05Fh,0FFh,0E0h
bootstd:
db 000h,001h,000h,007h,007h,007h,0A9h,060h,078h,0EEh,00Eh,0D4h,0A9h,008h,08Dh,004h
db 0D2h,0A9h,000h,08Dh,006h,0D2h,0A9h,028h,08Dh,008h,0D2h,08Dh,009h,0D2h,0A9h,023h
db 08Dh,00Fh,0D2h,08Dh,00Dh,0D2h,08Dh,00Ah,0D4h,00Ah,090h,0FAh,0A9h,013h,08Dh,00Fh
db 0D2h,0A0h,002h,020h,061h,007h,099h,04Ah,007h,0B9h,003h,007h,099h,0E1h,002h,048h
db 088h,0D0h,0F0h,020h,061h,007h,0AAh,020h,061h,007h,09Dh,000h,000h,0E8h,0D0h,0F7h
db 0A5h,010h,08Dh,00Eh,0D2h,0A9h,003h,08Dh,00Fh,0D2h,04Eh,00Eh,0D4h,058h,06Ch,0E2h
db 002h,0A9h,020h,08Dh,00Eh,0D2h,02Ch,00Eh,0D2h,0D0h,0FBh,08Ch,00Eh,0D2h,0ADh,00Dh
db 0D2h,060h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h
db 089h
dw timeBefore
bootpro:
db 000h,001h,000h,004h,007h,004h,0A9h,060h,078h,0EEh,00Eh,0D4h,0EEh,000h,0D4h,0A9h
db 008h,08Dh,004h,0D2h,0A9h,000h,08Dh,006h,0D2h,0A9h,028h,08Dh,008h,0D2h,08Dh,009h
db 0D2h,0A9h,023h,08Dh,00Fh,0D2h,08Dh,00Dh,0D2h,08Dh,00Ah,0D4h,00Ah,090h,0FAh,0A9h
db 013h,08Dh,00Fh,0D2h,0A0h,002h,020h,060h,004h,099h,04Dh,004h,0B9h,003h,004h,099h
db 0E1h,002h,048h,088h,0D0h,0F0h,020h,060h,004h,0AAh,020h,060h,004h,09Dh,000h,000h
db 0E8h,0D0h,0F7h,0A5h,010h,08Dh,00Eh,0D2h,0A9h,003h,08Dh,00Fh,0D2h,06Ch,0E2h,002h
db 0A9h,020h,08Dh,00Eh,0D2h,02Ch,00Eh,0D2h,0D0h,0FBh,08Ch,00Eh,0D2h,0ADh,00Dh,0D2h
db 060h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h
db 0AEh
dw timeBefore
hello db 'X-LOAD 1.0 by Fox/Taquart',eot
usgtxt db 'Syntax: XLOAD obxfile [options]',eol
db '/1 - /4 Specify COM port (default COM2)',eol
db '/p Professional loader',eot
nocom db 'COM'
comnum1 db '1 not found!',eot
rboot db 'Ready for booting Atari at COM'
comnum2 db '1...',eot
booting db 'Booting...',eot
loading db 'Loading '
hexnum db ' - ',eot
done db 'Done.',eot
e_nota db 'ERROR: Not Atari executable',eot
e_open db 'ERROR: Can''t open file',eot
e_read db 'ERROR: Disk read error',eot
prof db 0
port dw 1
trtime dw timeNormal
bttime dw timeBetween
dcb db 5 dup(0),5 dup(?)
head dw ?,?
buf db 103h dup(?)
obxnam:
ENDS
END start

View File

@ -1,92 +0,0 @@
IDEAL
P386
MODEL TINY
CODESEG
ORG 100h
include 'fox.mak'
start: mov [csum], 0
fopen inpfile
mov [ihand], bx
fcreate outfile
mov [ohand], bx
mov cx, 8
main: push cx
mov bx, [ihand]
mov cx, 16
fread buf
mov si, offset buf
mov di, offset data
mov cx, 16
jmp c0
c1: mov al, ','
stosb
c0: mov al, '0'
stosb
mov al, [si]
add [csum], al
adc [csum], 0
shr al, 4
d2a
stosb
lodsb
and al, 0fh
d2a
stosb
mov al, 'h'
stosb
loop c1
mov ax, 0a0dh
stosw
mov bx, [ohand]
mov cx, 85
fwrite line
pop cx
loop main
mov bx, [ihand]
fclose
mov bx, [ohand]
mov di, offset data+1
mov al, [csum]
shr al, 4
d2a
stosb
mov al, [csum]
and al, 0fh
d2a
stosb
mov al, 'h'
stosb
mov ax, 0a0dh
stosw
mov cx, 10
fwrite line
fclose
mov eax, '.orp'
cmp eax, [dword typ1]
je wroc
mov [dword typ1], eax
mov [dword typ2], eax
jmp start
wroc: ret
inpfile db '\atari\xasm\xload'
typ1 db 'std.obx',0
outfile db 'xload'
typ2 db 'std.db',0
line db ' db '
data db 81 dup(?)
ihand dw ?
ohand dw ?
buf db 16 dup(?)
csum db ?
ENDS
END start