/[cells]/cl-6502/hello-165.lisp
ViewVC logotype

Contents of /cl-6502/hello-165.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Sun May 8 12:46:56 2005 UTC (8 years, 11 months ago) by ktilton
Branch: MAIN
CVS Tags: HEAD
Introducing James Bielman's 6502 Assembler with Cells Inside(tm).
1 ;;;; -*- Mode: lisp; indent-tabs-mode: nil -*-
2 ;;;
3 ;;; tutor1.l65 --- A simple 6502 LAP assembly source file.
4 ;;;
5 ;;; Copyright (C) 2005, James Bielman <jamesjb@jamesjb.com>
6 ;;;
7 ;;; Permission is hereby granted, free of charge, to any person
8 ;;; obtaining a copy of this software and associated documentation
9 ;;; files (the "Software"), to deal in the Software without
10 ;;; restriction, including without limitation the rights to use, copy,
11 ;;; modify, merge, publish, distribute, sublicense, and/or sell copies
12 ;;; of the Software, and to permit persons to whom the Software is
13 ;;; furnished to do so, subject to the following conditions:
14 ;;;
15 ;;; The above copyright notice and this permission notice shall be
16 ;;; included in all copies or substantial portions of the Software.
17 ;;;
18 ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 ;;; DEALINGS IN THE SOFTWARE.
26 ;;;
27
28 (defmacro defconstant-asm (name value &optional doc)
29 "Define symbol NAME to have the constant value VALUE."
30 `(eval-when (:assemble)
31 (defconstant ,name ,value ,@(if doc (list doc)))))
32
33 (defconstant-asm +prg-load-address+ #x0801
34 "The load address to put in the PRG header.")
35
36 (defconstant-asm +sys-bytecode+ #x9e
37 "CBM BASIC bytecode for the SYS statement.")
38
39 (defmacro prg-header (start-label)
40 "Output the standard Commodore PRG header."
41 `(tagbody
42 (word +prg-load-address+)
43 (org +prg-load-address+)
44 (word @next 10)
45 (byte +sys-bytecode+ (format nil " ~D" ,start-label) 0)
46 next
47 (word 0)
48 (advance ,start-label)))
49
50 (defmacro asciiz (&rest things)
51 "Same as BYTE but adds a null terminator at the end."
52 `(byte ,@things 0))
53
54 (prg-header 2064)
55 (ldx :imm 0)
56 loop
57 (lda @hello x)
58 (beq @done)
59 (jsr #xffd2)
60 (inx)
61 (bne @loop)
62 done
63 (rts)
64
65 hello
66 (asciiz "HELLO, WORLD!")
67
68 ;;; vim: ft=lisp ts=3 et:

  ViewVC Help
Powered by ViewVC 1.1.5