Skip to content

jahan-addison/lionheart

Repository files navigation

Motorola MC6800 Assembler 💻
                 /\
   Lionheart  ( ;`~v/~~~ ;._
              ,/'"/^) ' < o\  '".~'\\\--,
            ,/",/W  u '`. ~  >,._..,   )'
          ,/'  w  ,U^v  ;//^)/')/^\;~)'
        ,/"'/   W` ^v  W |;         )/'
      ;''  |  v' v`" W }  \\
    "    .'\    v  `v/^W,) '\)\.)\/)
              `\   ,/,)'   ''')/^"-;'
                  \
                ".

Overview

The MC6800 ("sixty-eight hundred") is an 8-bit microprocessor designed and first manufactured by Motorola in 1974. The MC6800 microprocessor was part of the M6800 Microcomputer System that also included serial and parallel interface ICs, RAM, ROM and other support chips.

The MC6800 has a 16-bit address bus that can directly access 64 kB of memory and an 8-bit bi-directional data bus. It has 72 instructions with seven addressing modes for a total of 197 opcodes. The original MC6800 could have a clock frequency of up to 1 MHz. Later versions had a maximum clock frequency of 2 MHz.

Assembler

Usage:

./lionheart <input_file> [output_file]

Features

  • Excellent error handling, easy-to-extend parsing with cpp-peglib

Directives

  • ORG mnemonic to set program counter address
  • FDB mnemonic to set interrupt and reset vectors

Note: hexed.it is a great online hex editor to disassemble bytecode!

Example:

; Variables
DATA    = $F0

; Start of ROM
ORG $F000

RESET:
    ; Setup stack register (required)
    LDS #$00FF
    ; Clear accumulators (optional)
    CLR A
    CLR B
    ; Clear the index register (optional)
    LDX #$0000
    ; Enable interrupts
    CLI

MAIN:
		LDA A #$01
		BRA OUT
SAME:
		LDA B DATA
		ADD B #$10
		STA B DATA
		ASL A
OUT:
		LDX #$2F00
WAIT:
		DEX
		BNE WAIT
		TAB
		TST B
		BNE SAME
		LDA A #$01
		LDX $F0
		CPX #$C10F
		BNE OUT
		BRA MAIN

    ; Reset vector
    ORG $FFFE       ; The exact end of memory
    FDB RESET

Error messages:

  TST ; <-- bad


Build

cmake -Bbuild -DCMAKE_BUILD_TYPE=Debug -DUSE_SANITIZER="Address;Undefined" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DIWYU=ON
cmake --build build

Windows

cmake -Bbuild -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
cmake --build build

Or with ninja:

cmake -Bbuild -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
cmake --build build

Run the test suite:

./build/test_suite

Licensing

This project is dual-licensed under the Apache License, Version 2.0 and the GNU General Public License, Version 3.0 (or later).

You are free to choose the license that best fits your specific use case. For the full text of each license, please see LICENSE.Apache-v2 and LICENSE-GPL-v3.

About

Motorola MC6800 assembler 💻

Topics

Resources

License

Apache-2.0, GPL-3.0 licenses found

Licenses found

Apache-2.0
LICENSE.Apache-v2
GPL-3.0
LICENSE.GPL-v3

Stars

Watchers

Forks

Packages

 
 
 

Contributors