search
LoginSignup
2
Help us understand the problem. What are the problem?

posted at

updated at

令和からZ80を始める為のメモ

趣味の個人メモです

Z80を動かすための方法をまとめていく

参考書籍

一番わかりやすい

アセンブラ

Windows x64 なら以下のリンクから
https://k1.spdns.de/Develop/Projects/zasm/Distributions/zasm-4.4.9-Windows64.zip

>zasm.exe
–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
  zasm - 8080/z80/z180 assembler (c) 1994 - 2022 Günter Woigk.
  version 4.4.9, 2022-03-15, for Unix-Linux.
  homepage: https://k1.spdns.de/zasm/
  git repo: https://github.com/Megatokio/zasm

syntax:
  zasm [options] [-i] inputfile [[-l] listfile|dir] [[-o] outfile|dir]
  zasm [--version|--help]

  default output dir = source dir
  default list dir   = output dir

examples:
  zasm speccirom.asm
  zasm -uwy emuf_rom.asm rom_v2.0.1.rom

options:
  -u  --opcodes   include object code in list file
  -w  --labels    append label listing to list file
  -y  --cycles    include cpu clock cycles in list file
  -b  --bin       write output to binary file (default)
  -x  --hex       write output in intel hex format
  -s  --s19       write output in motorola s-record format
  -z  --clean     clear intermediate files, e.g. compiled c files
  -e  --compare   compare own output to existing output file
  -T  --test      run self test (requires test directory with test sources)
  -g  --cgi       prevent access to files outside the source dir
  --maxerrors=NN  set maximum for reported errors (default=30, max=999)
  --date=DATETIME for reproducible __date__ and __time__
  --target=ram    default to target 'ram' => cpu addresses in hex files
  -o0             don't write output file
  -l0             don't write list file
  --8080          target Intel 8080 (default if --asm8080)
  --z80           target Zilog Z80  (default except if --asm8080)
  --z180          target Zilog Z180 / Hitachi HD64180
  --asm8080       use 8080 assembler syntax
  --convert8080   convert 8080 assembler source to Z80
  -v[0,1,2]       verbosity of messages to stderr (0=off, 1=default, 2=more)
  --ixcbr2        enable illegal instructions like 'set b,(ix+d),r'
  --ixcbxh        enable illegal instructions like 'set b,xh'
  --dotnames      allow label names starting with a dot '.'
  --reqcolon      require colon ':' after program label definitions
                  => label definitions and instructions may start in any column
  --casefold      label names are case insensitive (implied if --asm8080)
  --flatops       no operator precedence: evaluate strictly from left to right
  -c [path/to/]cc declare or set path to c compiler (search in $PATH)
  -t path/to/dir  set path to temp dir for c compiler (default: output dir)
  -I path/to/dir  set path to c system header dir (default: compiler default)
  -L path/to/dir  set path to standard library dir (default: none)
–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––

>zasm.exe init8250.asm
assembled file: init8250.asm
    244 lines, 2 passes, 0.0025 sec.
    no errors

Z80 命令セット

  • PDF

  • WEB

目指すBASIC

  • NASCOM_BASIC_4.7

  • NASCOMについて

  • Tiny Basic

アセンブラの書き方

JP

0番地から始まりNOPを2回行った後にMAIN(0x0010)番地に飛んでHALTする

    .ORG $0000
INIT:           NOP
                NOP
            JP  MAIN
    .ORG $0010
MAIN:
        HALT

LD

LD A,xxx   XXXの値をAレジスタに保存
LD (xxxx),A   Aレジスタの値をXXXXに保存
LD A,(xxxx)   xxxxアドレスの値をAレジスタに保存(確認用)
JP xxxx   xxxx番地へジャンプ

.ORG $0000
INIT:           NOP
                NOP
            JP  MAIN
    .ORG $0010
MAIN:
    LD  A,0x76
    LD  (0x8000),A
    LD  A,(0x8000)
    JP  0x8000

IOとLOOP

Z80のIOモードはアドレスが下位8bitのみである(上位8bitにはIOのデータが載ってた)
LOOPの方法は他にもあるっぽい。

    .ORG $0000
INIT:           NOP
                NOP
            JP  MAIN

    .ORG $0010
MAIN:
    LD  A,0x12
    OUT (0x00),A
    NOP
    LD  B,0x05

LOOP:
    NOP
    DJNZ    LOOP
    
    LD  A,0x34
    OUT (0x00),A
    NOP
    JP MAIN

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
2
Help us understand the problem. What are the problem?