Rizin
unix-like reverse engineering framework and cli tools
z80asm.h File Reference
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <ctype.h>
#include <stdarg.h>

Go to the source code of this file.

Classes

struct  label
 
struct  infile
 
struct  name
 
struct  includedir
 
struct  macro_arg
 
struct  macro_line
 
struct  macro
 
struct  stack
 
struct  reference
 

Macros

#define BUFLEN   300 /* size of readbuffer for file i/o */
 
#define MAX_INCLUDE   200 /* stack size for include command and macros */
 

Enumerations

enum  mnemonic {
  Z80_CALL , Z80_CPDR , Z80_CPIR , Z80_DJNZ ,
  Z80_HALT , Z80_INDR , Z80_INIR , Z80_LDDR ,
  Z80_LDIR , Z80_OTDR , Z80_OTIR , Z80_OUTD ,
  Z80_OUTI , Z80_PUSH , Z80_RETI , Z80_RETN ,
  Z80_RLCA , Z80_RRCA , Z80_DEFB , Z80_DEFW ,
  Z80_DEFS , Z80_DEFM , Z80_ADC , Z80_ADD ,
  Z80_AND , Z80_BIT , Z80_CCF , Z80_CPD ,
  Z80_CPI , Z80_CPL , Z80_DAA , Z80_DEC ,
  Z80_EQU , Z80_EXX , Z80_INC , Z80_IND ,
  Z80_INI , Z80_LDD , Z80_LDI , Z80_NEG ,
  Z80_NOP , Z80_OUT , Z80_POP , Z80_RES ,
  Z80_RET , Z80_RLA , Z80_RLC , Z80_RLD ,
  Z80_RRA , Z80_RRC , Z80_RRD , Z80_RST ,
  Z80_SBC , Z80_SCF , Z80_SET , Z80_SLA ,
  Z80_SLL , Z80_SLI , Z80_SRA , Z80_SRL ,
  Z80_SUB , Z80_XOR , Z80_ORG , Z80_CP ,
  Z80_DI , Z80_EI , Z80_EX , Z80_IM ,
  Z80_IN , Z80_JP , Z80_JR , Z80_LD ,
  Z80_OR , Z80_RL , Z80_RR , Z80_DB ,
  Z80_DW , Z80_DS , Z80_DM , Z80_INCLUDE ,
  Z80_INCBIN , Z80_IF , Z80_ELSE , Z80_ENDIF ,
  Z80_END , Z80_MACRO , Z80_ENDM , Z80_SEEK
}
 
enum  reftype {
  TYPE_BSR , TYPE_DS , TYPE_RST , TYPE_ABSW ,
  TYPE_ABSB , TYPE_RELB , TYPE_LABEL
}
 
enum  filetype { FILETYPE_ASM }
 

Functions

static void printerr (int error, const char *fmt,...)
 
static const char * delspc (const char *ptr)
 
static int rd_expr (const char **p, char delimiter, int *valid, int level, int print_errors)
 
static int rd_label (const char **p, int *exists, struct label **previous, int level, int print_errors)
 
static int rd_character (const char **p, int *valid, int print_errors)
 
static int compute_ref (struct reference *ref, int allow_invalid)
 

Macro Definition Documentation

◆ BUFLEN

#define BUFLEN   300 /* size of readbuffer for file i/o */

Definition at line 38 of file z80asm.h.

◆ MAX_INCLUDE

#define MAX_INCLUDE   200 /* stack size for include command and macros */

Definition at line 42 of file z80asm.h.

Enumeration Type Documentation

◆ filetype

enum filetype
Enumerator
FILETYPE_ASM 

Definition at line 77 of file z80asm.h.

78 {
80 };
@ FILETYPE_ASM
Definition: z80asm.h:79

◆ mnemonic

enum mnemonic
Enumerator
Z80_CALL 
Z80_CPDR 
Z80_CPIR 
Z80_DJNZ 
Z80_HALT 
Z80_INDR 
Z80_INIR 
Z80_LDDR 
Z80_LDIR 
Z80_OTDR 
Z80_OTIR 
Z80_OUTD 
Z80_OUTI 
Z80_PUSH 
Z80_RETI 
Z80_RETN 
Z80_RLCA 
Z80_RRCA 
Z80_DEFB 
Z80_DEFW 
Z80_DEFS 
Z80_DEFM 
Z80_ADC 
Z80_ADD 
Z80_AND 
Z80_BIT 
Z80_CCF 
Z80_CPD 
Z80_CPI 
Z80_CPL 
Z80_DAA 
Z80_DEC 
Z80_EQU 
Z80_EXX 
Z80_INC 
Z80_IND 
Z80_INI 
Z80_LDD 
Z80_LDI 
Z80_NEG 
Z80_NOP 
Z80_OUT 
Z80_POP 
Z80_RES 
Z80_RET 
Z80_RLA 
Z80_RLC 
Z80_RLD 
Z80_RRA 
Z80_RRC 
Z80_RRD 
Z80_RST 
Z80_SBC 
Z80_SCF 
Z80_SET 
Z80_SLA 
Z80_SLL 
Z80_SLI 
Z80_SRA 
Z80_SRL 
Z80_SUB 
Z80_XOR 
Z80_ORG 
Z80_CP 
Z80_DI 
Z80_EI 
Z80_EX 
Z80_IM 
Z80_IN 
Z80_JP 
Z80_JR 
Z80_LD 
Z80_OR 
Z80_RL 
Z80_RR 
Z80_DB 
Z80_DW 
Z80_DS 
Z80_DM 
Z80_INCLUDE 
Z80_INCBIN 
Z80_IF 
Z80_ELSE 
Z80_ENDIF 
Z80_END 
Z80_MACRO 
Z80_ENDM 
Z80_SEEK 

Definition at line 47 of file z80asm.h.

48 {
62 };
@ Z80_RET
Definition: z80asm.h:55
@ Z80_DI
Definition: z80asm.h:58
@ Z80_CCF
Definition: z80asm.h:53
@ Z80_RRCA
Definition: z80asm.h:51
@ Z80_CPIR
Definition: z80asm.h:49
@ Z80_SEEK
Definition: z80asm.h:61
@ Z80_RETN
Definition: z80asm.h:51
@ Z80_RRD
Definition: z80asm.h:56
@ Z80_DJNZ
Definition: z80asm.h:49
@ Z80_CPI
Definition: z80asm.h:53
@ Z80_RLA
Definition: z80asm.h:56
@ Z80_DM
Definition: z80asm.h:60
@ Z80_POP
Definition: z80asm.h:55
@ Z80_ELSE
Definition: z80asm.h:61
@ Z80_OTIR
Definition: z80asm.h:50
@ Z80_IN
Definition: z80asm.h:59
@ Z80_CPDR
Definition: z80asm.h:49
@ Z80_NEG
Definition: z80asm.h:55
@ Z80_RST
Definition: z80asm.h:56
@ Z80_SRA
Definition: z80asm.h:57
@ Z80_RLD
Definition: z80asm.h:56
@ Z80_OUTI
Definition: z80asm.h:51
@ Z80_EX
Definition: z80asm.h:59
@ Z80_RLC
Definition: z80asm.h:56
@ Z80_CPL
Definition: z80asm.h:53
@ Z80_DEC
Definition: z80asm.h:54
@ Z80_ORG
Definition: z80asm.h:58
@ Z80_INC
Definition: z80asm.h:54
@ Z80_EI
Definition: z80asm.h:58
@ Z80_DB
Definition: z80asm.h:60
@ Z80_SLA
Definition: z80asm.h:57
@ Z80_RRC
Definition: z80asm.h:56
@ Z80_OR
Definition: z80asm.h:59
@ Z80_DEFS
Definition: z80asm.h:52
@ Z80_SLI
Definition: z80asm.h:57
@ Z80_HALT
Definition: z80asm.h:49
@ Z80_LD
Definition: z80asm.h:59
@ Z80_INIR
Definition: z80asm.h:50
@ Z80_RETI
Definition: z80asm.h:51
@ Z80_RL
Definition: z80asm.h:59
@ Z80_DEFW
Definition: z80asm.h:52
@ Z80_SRL
Definition: z80asm.h:58
@ Z80_CP
Definition: z80asm.h:58
@ Z80_ADC
Definition: z80asm.h:52
@ Z80_ENDM
Definition: z80asm.h:61
@ Z80_DW
Definition: z80asm.h:60
@ Z80_XOR
Definition: z80asm.h:58
@ Z80_LDDR
Definition: z80asm.h:50
@ Z80_LDD
Definition: z80asm.h:54
@ Z80_RR
Definition: z80asm.h:60
@ Z80_SLL
Definition: z80asm.h:57
@ Z80_BIT
Definition: z80asm.h:53
@ Z80_DEFM
Definition: z80asm.h:52
@ Z80_SCF
Definition: z80asm.h:57
@ Z80_EQU
Definition: z80asm.h:54
@ Z80_SUB
Definition: z80asm.h:58
@ Z80_INDR
Definition: z80asm.h:49
@ Z80_AND
Definition: z80asm.h:53
@ Z80_RRA
Definition: z80asm.h:56
@ Z80_EXX
Definition: z80asm.h:54
@ Z80_OUT
Definition: z80asm.h:55
@ Z80_CALL
Definition: z80asm.h:49
@ Z80_CPD
Definition: z80asm.h:53
@ Z80_ADD
Definition: z80asm.h:52
@ Z80_LDIR
Definition: z80asm.h:50
@ Z80_DEFB
Definition: z80asm.h:52
@ Z80_PUSH
Definition: z80asm.h:51
@ Z80_ENDIF
Definition: z80asm.h:61
@ Z80_OUTD
Definition: z80asm.h:50
@ Z80_JP
Definition: z80asm.h:59
@ Z80_IM
Definition: z80asm.h:59
@ Z80_DS
Definition: z80asm.h:60
@ Z80_IND
Definition: z80asm.h:54
@ Z80_INI
Definition: z80asm.h:54
@ Z80_LDI
Definition: z80asm.h:55
@ Z80_IF
Definition: z80asm.h:61
@ Z80_JR
Definition: z80asm.h:59
@ Z80_SET
Definition: z80asm.h:57
@ Z80_RLCA
Definition: z80asm.h:51
@ Z80_SBC
Definition: z80asm.h:57
@ Z80_INCBIN
Definition: z80asm.h:60
@ Z80_END
Definition: z80asm.h:61
@ Z80_OTDR
Definition: z80asm.h:50
@ Z80_RES
Definition: z80asm.h:55
@ Z80_MACRO
Definition: z80asm.h:61
@ Z80_DAA
Definition: z80asm.h:53
@ Z80_INCLUDE
Definition: z80asm.h:60
@ Z80_NOP
Definition: z80asm.h:55

◆ reftype

enum reftype
Enumerator
TYPE_BSR 
TYPE_DS 
TYPE_RST 
TYPE_ABSW 
TYPE_ABSB 
TYPE_RELB 
TYPE_LABEL 

Definition at line 65 of file z80asm.h.

66 {
67  TYPE_BSR, /* bit value (0-7) for bit, set and res */
68  TYPE_DS, /* ds reference (byte count and value) */
69  TYPE_RST, /* rst reference: val & 0x38 == val */
70  TYPE_ABSW, /* absolute word (2 bytes) */
71  TYPE_ABSB, /* absolute byte */
72  TYPE_RELB, /* relative byte */
73  TYPE_LABEL /* equ expression */
74 };
@ TYPE_LABEL
Definition: z80asm.h:73
@ TYPE_RELB
Definition: z80asm.h:72
@ TYPE_RST
Definition: z80asm.h:69
@ TYPE_BSR
Definition: z80asm.h:67
@ TYPE_ABSB
Definition: z80asm.h:71
@ TYPE_ABSW
Definition: z80asm.h:70
@ TYPE_DS
Definition: z80asm.h:68

Function Documentation

◆ compute_ref()

static int compute_ref ( struct reference ref,
int  allow_invalid 
)
static

◆ delspc()

static const char* delspc ( const char *  ptr)
static

◆ printerr()

static void printerr ( int  error,
const char *  fmt,
  ... 
)
static

◆ rd_character()

static int rd_character ( const char **  p,
int valid,
int  print_errors 
)
static

◆ rd_expr()

static int rd_expr ( const char **  p,
char  delimiter,
int valid,
int  level,
int  print_errors 
)
static

◆ rd_label()

static int rd_label ( const char **  p,
int exists,
struct label **  previous,
int  level,
int  print_errors 
)
static