diff --git a/CHANGELOG b/CHANGELOG new file mode 100644 index 0000000..db95320 --- /dev/null +++ b/CHANGELOG @@ -0,0 +1,53 @@ ++ implement full getopt interface ++ full source restructuring, broken up into modules ++ allow 'X' for .byte ++ fix .org to auto-fill ++ add a .end directive ++ implement .fill ++ fix the symbol table stuff, added 'where' to them ++ add generating hex files for output ++ add << and >> operators in expressions ++ fix the ^ and / operators in expressions ++ fix the ! (NOT) operator, added the ~ alias ++ support '.', '*' and '$' for "current", not just @ ++ added "EQU" in addition to "=" ++ implement .binary (and .blob) for binary blob imports ++ add ".page [plen[,pwidth]" and ".title [str]" directives ++ add paged listing file ++ add .cpu directive and underlying multi-target support +- implement .nol option +- implement .sym option +- allow [] for expressions, not just () ++ implement multiple source files on command line ++ add generating .s19 et al (Motorola) files for output + +- Add C02/RC02/WC02/816, 68xx, 80xx et al support. + The basic infrastructure for multi-CPU support is in now in place; we can + start adding more processors and their (sub-)models in the backend files. + +- Filling, ORG and hex files. + We currently allow for filling spaces and auto-filling the .org directive + for use with straight-binary output files. This is, however, not necessary + if we are using hex (IntelHEX) or srec (Motorola SRecord) output files, as + those formats "know" that data does not have to be linear. For this to be + implemented properly, we will have to re-work the "generating output" code + to do it as it goes (in pass 2), and not only at the end of that pass. This + allows such "jumping" to be handled by those file formats. + ++ Reading raw source data. + We currently perform binary-mode reads on the input source files and all + included files. Although this works fine on Linux (and, assumedly, on all + such systems), it does not seem to behave the same way on Windows systems. + The problem is that while we do an ftell() to get the size of a file, that + will give us the "raw" size of the file, as it is on disk. We then allocate + a buffer for the file using that size, and then read the file's data into + the buffer using the fread(3) function. This is where things go wrong: EVEN + if we open the file in BINARY ("rb") mode, the fread() function will STILL + perform newline processing, resulting it it returning LESS data than we + requested: it has stripped off the CR characters.. This was confirmed to + be the case with both the MinGW-w64 (gcc) AND Microsoft's own Visual Studio + compilers. Since MinGW uses the actual runtime from Microsoft (relatively + old versions of the msvcrt.dll), this is most likely the source of it. + That said, reading text files in binary mode is not a good practice to + begin with, so most likely this problem will be fixed by changing the input + scanner to process all input files in ASCII (text) mode instead. DONE. diff --git a/LICENSE b/LICENSE index 5be04b0..47232a9 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,33 @@ -MIT License -Copyright (c) 2023 The VARCem Team + VASM VARCem Multi-Target Assembler. + A simple table-driven assembler for several 8-bit target + devices, like the 6502, 6800, 80x, Z80 et al series. The + code originated from Bernd B”ckmann's "asm6502" project. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: + This file is part of the VARCem Project. -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. + Authors: Fred N. van Kempen, + Bernd B”ckmann, -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. + Copyright 2023 Fred N. van Kempen. + Copyright 2022,2023 Bernd B”ckmann. + + MIT License Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation + files (the "Software"), to deal in the Software without + restriction, including without limitation the rights to use, + copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom + the Software is furnished to do so, subject to the following + condition: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..f756ea8 --- /dev/null +++ b/README.md @@ -0,0 +1,50 @@ +Welcome to **VARCem**, the Virtual Archaeological Computer EMulator. + +Vasm is a multi-target, table-driven cross assembler, part of the +VARCem8 emulator project. It implements a general assembler block +with the usual (and, some less usual) features, and then uses a +back-end specific for a given microprocessor to generate code for +that processor. + +HISTORY +------- +Vasm has its roots in the [asm6502](https://github.com/boeckmann/asm6502) project. + + +LICENSE +------- +Vasm is released under the MIT license, the same license as the +original project (see HISTORY above.) + +Author credits and specific copyrights can be found in each of +the source files. + +Obviously, where license terms of individual modules deviate from +the general project license terms, the terms of such an individual +module prevail. + + +Community and Support +--------------------- +Information, downloads, additional modules and such can be found on our +[Website](http://www.VARCem.com/). Live support and general help can +also be found on our [Discord server](https://discord.gg/TeubH2bxzT). We +no longer use the IRC network. + + +LEGAL +----- +"This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +It's free, it comes with all the sources, but it does not come with +any warranty whatsoever. You probably should not use this software to run +a business-critical piece of (old) software at work, for example. + +If there is a problem with the software, please open up a GIT issue so we +can work on it, and/or talk to us on the IRC channel. We cannot promise a +fix, but will try the best we can ! + + +Last Updated: 2023/04/11 diff --git a/tests/c64_basic.asm b/tests/c64_basic.asm new file mode 100644 index 0000000..952fbd6 --- /dev/null +++ b/tests/c64_basic.asm @@ -0,0 +1,15 @@ +; Preamble to create a C64 .PRG file. + +SYS = $9E ; basic SYS token number + +LOAD = $0801 ; load address + + .word LOAD ; .PRG header: load address + .org LOAD + +basic: ; BASIC code: 10 SYS 2062 + .word @end, 10 ; ptr to next basic line and line number 10 + .byte SYS, " 2062", 0 ; SYS token and address string of subroutine +@end .word 0 ; null ptr to indicate end of basic text + +; End of preamble code. diff --git a/tests/c64_hello.asm b/tests/c64_hello.asm new file mode 100644 index 0000000..ab86a99 --- /dev/null +++ b/tests/c64_hello.asm @@ -0,0 +1,20 @@ +; C64 Hello World +; assemble to .PRG file: vasm -o hello.prg c64.asm c64_hello.asm + +CHROUT = $FFD2 ; kernal function address +CR = 13 ; carrige return character +LF = %1010 ; line feed character + +main: ; this is at address 2062 ($080E) + ldx #0 +@l lda msg, x + jsr CHROUT + inx + cpx #len + bne @l + rts + +msg .byte "HELLO, WORLD!", CR, LF +len = @ - msg + +; End of file. diff --git a/tests/c64_hello.lst b/tests/c64_hello.lst new file mode 100644 index 0000000..f76376d --- /dev/null +++ b/tests/c64_hello.lst @@ -0,0 +1,52 @@ +VARCem VASM version 1.0.10 (Windows, x86) 04/11/23 00:34:32 Page 1 + File: h1.asm + + 1: ; Preamble to create a C64 .PRG file. + 2: + 3: SYS = $9E ; basic SYS token number + 4: + 5: LOAD = $0801 ; load address + 6: +0000 0000 01 08 7: .word LOAD ; .PRG header: load address + 8: .org LOAD + 9: + 10: basic: ; BASIC code: 10 SYS 2062 +0002 0801 0C 08 0A 11: .word @end, 10 ; ptr to next basic line and line number 10 +0006 0805 9E 20 32 ... 12: .byte SYS, " 2062", 0 ; SYS token and address string of subroutine +000D 080C 00 00 13: @end .word 0 ; null ptr to indicate end of basic text + 14: + 15: ; End of preamble code. + 1: ; C64 Hello World + 2: ; assemble to .PRG file: vasm -o hello.prg c64.asm c64_hello.asm + 3: + 4: CHROUT = $FFD2 ; kernal function address + 5: CR = 13 ; carrige return character + 6: LF = %1010 ; line feed character + 7: + 8: main: ; this is at address 2062 ($080E) +000F 080E A2 00 9: ldx #0 +0011 0810 BD 1C 08 10: @l lda msg, x +0014 0813 20 D2 FF 11: jsr CHROUT +0017 0816 E8 12: inx +0018 0817 E0 0F 13: cpx #len +001A 0819 D0 F5 14: bne @l +001C 081B 60 15: rts + 16: +001D 081C 48 45 4C ... 17: msg .byte "HELLO, WORLD!", CR, LF + 18: len = @ - msg + 19: + 20: ; End of file. + VARCem VASM version 1.0.10 (Windows, x86) 04/11/23 00:34:32 Page 2 +** SYMBOL TABLE ** File: h2.asm + +basic L 0801 W h1.asm:10 + @end 080C h1.asm:10 +CHROUT V FFD2 W h2.asm:4 +CR V 000D B h2.asm:5 +len V 000F W h2.asm:18 +LF V 000A B h2.asm:6 +LOAD V 0801 W h1.asm:5 +main L 080E W h2.asm:8 + @l 0810 h2.asm:8 +msg L 081C W h2.asm:17 +SYS V 009E B h1.asm:3 diff --git a/tests/c64_hello.prg b/tests/c64_hello.prg new file mode 100644 index 0000000..4525c05 Binary files /dev/null and b/tests/c64_hello.prg differ diff --git a/tests/correct/mos6502.bin b/tests/correct/mos6502.bin new file mode 100644 index 0000000..f70d172 Binary files /dev/null and b/tests/correct/mos6502.bin differ