diff -N -r -u z80-asm-2.3/Makefile z80-asm-2.3.7/Makefile
--- z80-asm-2.3/Makefile 2005-06-06 17:51:56.000000000 +0200
+++ z80-asm-2.3.7/Makefile 2006-02-06 14:45:45.101322620 +0100
@@ -1,13 +1,14 @@
# Uncomment the one corresponding with your system
-#ZZZ=Z80_PORTS="\"$(HOME)/.Z80_ports\""
-ZZZ=Z80_PORTS="\"./.Z80_ports\""
+#ZZ=Z80_PORTS="\"$(HOME)/.Z80_ports\""
+ZZ=Z80_PORTS="\"./.Z80_ports\""
+ZZZ=Z80_PORTS="\"\\\"./.Z80_ports\"\\\""
#SYSTEM=DOS
SYSTEM=UNIX
-DEFINES=-DFURTHER_HARDWARE
-#DEFINES=-DFURTHER_HARDWARE -DZ80_CTC
-#DEFINES=-DFURTHER_HARDWARE -DZ80_CTC -DONLY_EXPLICIT_RESOLVED
+DEFINES=-DFURTHER_HARDWARE -DSSL_ZDS
+#DEFINES=-DFURTHER_HARDWARE -DZ80_CTC -DLOGIC_ANALYZER -DSSL_ZDS
+#DEFINES=-DFURTHER_HARDWARE -DZ80_CTC -DLOGIC_ANALYZER -DNEEDED
# set the appropriate install directories in your system
@@ -27,15 +28,16 @@
MONI=z80-mon.exe
endif
-CFLAGS=-O2 -Wall -D$(ZZZ) -D$(SYSTEM) $(DEFINES) -W -Wstrict-prototypes \
- -Wno-parentheses -fomit-frame-pointer -malign-functions=0
+CC= gcc
+CFLAGS=-O2 -Wall -D$(ZZ) -D$(SYSTEM) $(DEFINES) -W -Wstrict-prototypes \
+ -Wno-parentheses -fomit-frame-pointer -falign-functions=0
LDFLAGS=
all:
- cd hardware; $(MAKE) hard.a
+ cd hardware; $(MAKE) DEFINES="-D$(ZZZ) $(DEFINES)" hard.a
make $(ASM)
make $(MONI)
- cd hardware; $(MAKE)
+ cd hardware; $(MAKE) DEFINES="-D$(ZZZ) $(DEFINES)"
clean:
$(RM) *.o
@@ -43,6 +45,7 @@
$(RM) $(MONI)
$(RM) asm.a
$(RM) cpu.a
+ $(RM) .bus_proto
cd hardware; make clean
install:
@@ -53,20 +56,22 @@
z80-mon.o: z80-mon.c z80-cpu.h asm.h console.h console_token regs.h regs_token \
execute.h execute_token file.h memory.h interrupt.h help_layout \
- mini-display.h decode.h keyboard.h ports.h hash.h hardware/z80-ctc.h
+ mini-display.h decode.h keyboard.h ports.h hash.h z80-global \
+ hardware/includes
z80-asm.o: z80-asm.c hash.h asm.h file.h asm_token
-z80-cpu.o: z80-global z80-cpu.c hardware/quartz.h hardware/z80-ctc.h
+z80-cpu.o: z80-global z80-cpu.c hardware/quartz.h z80-mon.h hardware/includes \
+ hardware/system_wired hardware/bus_masters
decode.o: decode.c z80-cpu.h z80-mon.h decode-table.h execute.h execute_token \
- regs_token memory.h hardware/daisy_chain.h
+ regs_token memory.h z80-global hardware/daisy_chain.h
-instr.o: instr.c instr_token z80-cpu.h
+instr.o: instr.c instr_token z80-cpu.h z80-global
file.o: file.c file.h
-regs.o: regs.c regs_token z80-cpu.h
+regs.o: regs.c regs_token z80-cpu.h z80-global
compile.o: compile.c asm.h execute_token regs.h regs_token
@@ -75,21 +80,25 @@
hash.o: hash.c asm.h expression.h
asm.o: asm.c asm_interface.h instr.h z80-cpu.h hash.h compile.h execute_token \
- expression.h regs.h regs_token asm_token
+ expression.h regs.h regs_token asm_token z80-global
console.o: console.c console_token
-decode-table.o: decode-table.c z80-cpu.h execute.h execute_token regs.h regs_token
+decode-table.o: decode-table.c z80-cpu.h execute.h execute_token regs.h \
+ regs_token z80-global
execute.o: execute.c z80-cpu.h execute_token regs.h regs_token decode.h asm.h \
- memory.h ports.h hash.h
+ memory.h ports.h hash.h z80-global
ports.o: ports.c z80-cpu.h mini-display.h asm_interface.h keyboard.h memory.h \
- hardware/z80-ctc.h
+ hardware/port_buffer.h z80-global
-memory.o: memory.c z80-cpu.h
+memory.o: memory.c z80-cpu.h z80-global
-interrupt.o: interrupt.c z80-cpu.h decode.h z80-mon.h hardware/daisy_chain.h
+interrupt.o: interrupt.c z80-cpu.h decode.h z80-mon.h z80-global \
+ hardware/daisy_chain.h
+
+dummy.o: dummy.c
mini-display.o: mini-display.c console.h console_token
@@ -106,7 +115,7 @@
ar rcs cpu.a execute.o decode-table.o decode.o memory.o ports.o
-$(ASM): z80-asm.o asm.a $(HW)
- gcc -lc -o $(ASM) z80-asm.o asm.a $(HW)
+$(ASM): z80-asm.o dummy.o asm.a $(HW)
+ gcc -lc -o $(ASM) z80-asm.o dummy.o asm.a $(HW)
$(MONI): z80-mon.o cpu.a console.o asm.a $(HW)
gcc -lc -o $(MONI) z80-mon.o cpu.a console.o asm.a $(HW)
diff -N -r -u z80-asm-2.3/asm.c z80-asm-2.3.7/asm.c
--- z80-asm-2.3/asm.c 2005-06-01 11:43:45.000000000 +0200
+++ z80-asm-2.3.7/asm.c 2005-11-28 16:20:30.155610715 +0100
@@ -127,6 +127,7 @@
arg->is_label=0;
arg->is_resolved=1;
+arg->text=0;
/* nothing */
if (!*txt){arg->type=A_EMPTY;arg->value=0;return NIL;}
@@ -434,7 +435,7 @@
1<<1, 1<<1, 1<<1, 1<<1, 1<<1,
1<<0, 1<<0, 1<<0, 1<<0,
1<<1|1<<2, 1<<1, 1<<1|1<<2,
- 1<<1|1<<2, 1<<0, 1<<0|1<<1, 1<<0, 1<<0,
+ 1<<1|1<<2, 1<<1, 1<<0|1<<1, 1<<0, 1<<0,
1<<1, 1<<0, 1<<1, 1<<0, 1<<1, 1<<0, 1<<1, 1<<0,
1<<1, 1<<1, 1<<1, 1<<1,
1<<0, 1<<0, 1<<0,
diff -N -r -u z80-asm-2.3/decode.c z80-asm-2.3.7/decode.c
--- z80-asm-2.3/decode.c 2005-06-02 16:40:09.000000000 +0200
+++ z80-asm-2.3.7/decode.c 2006-06-30 16:58:34.876282757 +0200
@@ -57,20 +57,25 @@
void refresh_cycle(void)
-{ if (cpu_pin[wait]) return;
+{ if (cpu_is_in_disassemble) return;
R++; if (!(R&127)) R ^= 128;
+ ADDRESS= I<<8 | R;
+ set_cpu_pin(mreq,1);
+ set_cpu_pin(rfsh,1);
wait_tics(1);
+ set_cpu_pin(rfsh,0);
+ set_cpu_pin(mreq,0);
}
/* reads, decodes and call execution of instruction */
-/* exec: 0=disassemble instruction and print it *
- * 1=execute instruction *
- * 2=only adjust PC according to instruction length *
- * store_pc: pointer to set PC after calling instruction (PC untouched)*
- * or null if PC should increase */
+/* exec: 0=disassemble instruction and print it *
+ * 1=execute instruction *
+ * 2=only adjust PC according to instruction length *
+ * new_pc: pointer to a value to set PC after calling instruction *
+ (PC untouched) or null if PC should increase */
void
-decode(_ushort *store_pc,int exec)
+decode(_ushort *new_pc,int exec)
{
static struct instruction_type current_instr;
bit iy=0, ddfd_prefix=0, join=0;
@@ -78,18 +83,17 @@
_ushort a1,a2;
struct instruction_type *p;
- bit old_cpu_mode= cpu_pin[wait];
- cpu_pin[wait]= (exec != 1);
+ bit old_cpu_mode= cpu_is_in_disassemble;
+ cpu_is_in_disassemble= (exec != 1);
ddfdcb_reg=0;
- set_cpu_pin(m1,1);
- d= read_addr(PC);
+ d= read_opcode(PC,1);
switch (d)
{
case 0xcb: /* 0xcb, opcode */
p=instr_cb;
refresh_cycle();
PC++;
- d= read_addr(PC);
+ d= read_opcode(PC,1);
goto normal;
case 0xfd:
@@ -100,7 +104,7 @@
ddfd_prefix=1;
refresh_cycle();
PC++;
- d= read_addr(PC);
+ d= read_opcode(PC,1);
} while (d==0xdd || d==0xfd);
if (d==0xed)
{ ddfd_prefix=iy=0;
@@ -113,11 +117,10 @@
}
p=instr_cb;
refresh_cycle();
- set_cpu_pin(m1,0);
PC++;
- disp= read_addr(PC);
+ disp= read_opcode(PC,0);
PC++; /* no refresh generated for displacement fetch */
- d= read_addr(PC);
+ d= read_opcode(PC,0);
p+= (d&0xf8)|6;
ddfdcb_reg= (p->func!=f_bit?2+d&7:0); /* encoding for reg_str in regs.c */
PC++; /* no refresh generated for secondary opcode fetch */
@@ -142,7 +145,7 @@
p=instr_ed;
refresh_cycle();
PC++;
- d= read_addr(PC);
+ d= read_opcode(PC,1);
goto normal;
default: /* opcode */
@@ -151,13 +154,14 @@
normal:
p+=d;
refresh_cycle();
- set_cpu_pin(m1,0);
PC++;
current_instr.func=p->func;
current_instr.arg1=p->arg1;
current_instr.type1=p->type1;
current_instr.arg2=p->arg2;
current_instr.type2=p->type2;
+ if (p->func == f_djnz && !cpu_is_in_disassemble)
+ wait_tics(TICS_LATE_ALU);
if (ddfd_prefix && p->func != f_exx && (p->func != f_ex || p->type1 != A_REG))
{ if (iy)
join= tofd(¤t_instr.type1,
@@ -170,9 +174,9 @@
¤t_instr.type2,
¤t_instr.arg2);
if (current_instr.type1==A_PODLE_IY_PLUS||current_instr.type1==A_PODLE_IX_PLUS)
- { current_instr.arg1 = read_addr(PC); PC++; }
+ { current_instr.arg1 = read_opcode(PC,0); PC++; }
if (current_instr.type2==A_PODLE_IY_PLUS||current_instr.type2==A_PODLE_IX_PLUS)
- { current_instr.arg2 = read_addr(PC); PC++; }
+ { current_instr.arg2 = read_opcode(PC,0); PC++; }
}
break;
}
@@ -182,23 +186,25 @@
{
a1=0;
if (current_instr.arg1)
- { a1= read_addr(PC); PC++; }
+ { a1= read_opcode(PC,0); PC++; }
if (current_instr.arg1==2)
- { a1|= read_addr(PC)<<8; PC++; }
+ { a1|= read_opcode(PC,0)<<8; PC++; }
}
if (current_instr.type2==A_NUM||current_instr.type2==A_PODLE_NUM)
{
a2=0;
if (current_instr.arg2)
- { a2= read_addr(PC); PC++; }
+ { a2= read_opcode(PC,0); PC++; }
if (current_instr.arg2==2)
- { a2|= read_addr(PC)<<8; PC++; }
+ { a2|= read_opcode(PC,0)<<8; PC++; }
}
- if (store_pc) PC=*store_pc; /* instruction from user by monitor */
+ if (new_pc)
+ PC= *new_pc; /* instruction from user by monitor */
if (exec!=2)
{ if (exec==1)
- { cpu_pin[halt]=IFF0=0;
+ { set_cpu_pin(halt,0);
+ IFF0=0;
current_instr.func(a1,current_instr.type1,a2,current_instr.type2);
if (join)
{ if (iy) IY= IYh<<8|IYl;
@@ -208,8 +214,8 @@
else
print(current_instr.func(a1,current_instr.type1,a2,current_instr.type2));
}
- if (cpu_pin[wait] == (exec!=1))
- cpu_pin[wait]=old_cpu_mode;
+ if (cpu_is_in_disassemble == (exec!=1))
+ cpu_is_in_disassemble=old_cpu_mode;
return;
}
@@ -219,8 +225,8 @@
{
static _uchar tmp_memory[16];
_ushort new_PC;
- bit old_cpu_mode= cpu_pin[wait];
- cpu_pin[wait]= 0;
+ bit old_cpu_mode= cpu_is_in_disassemble;
+ cpu_is_in_disassemble= 0;
if (cpu_pin[halt]) PC+=1;
IFF2=0;
IFF1=0;
@@ -229,6 +235,9 @@
#else
set_cpu_pin(inter,0);
#endif
+/** busrequest was not early uneough */
+ set_cpu_pin(iorq,1);
+ set_cpu_pin(m1,1); /* iorq & m1 pin set to acknowledge interrupt */
wait_tics(2*TICS_WAIT); /* acknowledge interrupt cycles */
switch (IM)
{
@@ -250,11 +259,13 @@
*****************************/
io_address=tmp_memory;
PC=0;
- set_cpu_pin(iorq,1);
+#ifdef FURTHER_HARDWARE
DATA=read_request_to_peripheral();
+#endif
tmp_memory[0]= DATA; /* all pins high on bus ==> RST 38H */
decode(0,1);
set_cpu_pin(iorq,0);
+ io_address=0;
break;
case 1:
/***********************************
@@ -265,10 +276,10 @@
************************************/
io_address=tmp_memory;
PC=0;
- tmp_memory[0]= 0xff;
- set_cpu_pin(iorq,1);
+ tmp_memory[0]= 0xff; /* RST 38 H */
decode(0,1);
set_cpu_pin(iorq,0);
+ io_address=0;
break;
case 2:
/************************************
@@ -279,16 +290,22 @@
* M5: 3 T states: read high byte and jump to interrupt routine
*************************************/
set_cpu_pin(m1,1);
- wait_tics(TICS_MEMO); /* simulated opcode fetch */
- refresh_cycle();
+ wait_tics(TICS_MEMO); /* simulated opcode CALL fetch */
set_cpu_pin(m1,0);
+ refresh_cycle();
+#ifdef FURTHER_HARDWARE
DATA=read_request_to_peripheral();
- new_PC= (_ushort)(I<<8|DATA);
- wait_tics(2*TICS_MEMO); /* simulated operand fetch */
+#endif
+ if (cpu_pin[busrq]) acknowledge_bus_request();
+ wait_tics(TICS_MEMO); /* simulated operand fetch */
+ new_PC= (_ushort)(I<<8|DATA); /* DATA&1 must be zero! */
+ if (cpu_pin[busrq]) acknowledge_bus_request();
+ wait_tics(TICS_MEMO); /* simulated operand fetch */
f_call(new_PC,A_NUM,0,0);
+ set_cpu_pin(iorq,0);
break;
}
- cpu_pin[wait]= old_cpu_mode;
+ cpu_is_in_disassemble= old_cpu_mode;
}
@@ -300,23 +317,24 @@
* M2: 3 T states: write the high byte of PC to the stack and decrement SP
* M3: 3 T states: write the low byte of PC and jump to #0066.
********************************/
- bit old_cpu_mode= cpu_pin[wait];
- cpu_pin[wait]=0;
+ bit old_cpu_mode= cpu_is_in_disassemble;
+ cpu_is_in_disassemble=0;
IFF1=0; /* IFF2 not effected! */
if (cpu_pin[halt]) PC+=1;
set_cpu_pin(m1,1);
wait_tics(TICS_MEMO); /* simulated opcode fetch */
- refresh_cycle();
set_cpu_pin(m1,0);
+ refresh_cycle();
f_rst((_ushort)0x0066,A_EMPTY,0,0);
IFF3=0;
- cpu_pin[wait]= old_cpu_mode;
+ cpu_is_in_disassemble= old_cpu_mode;
}
void
reset_cpu(void)
{
+ cpu_is_in_disassemble=0;
PC=0;
I=0;R=0;
IFF0=IFF1=IFF2=IFF3=0;IM=0;
@@ -324,9 +342,13 @@
A=F=0xff;
wait_tics(TICS_MEMO);
set_tics(0);
- cpu_pin[halt]=0;
+ set_cpu_pin(halt,0);
+ set_cpu_pin(rd,0);
+ set_cpu_pin(wr,0);
+ set_cpu_pin(m1,0);
set_cpu_pin(iorq,0);
set_cpu_pin(mreq,0);
+ set_cpu_pin(rfsh,0);
set_cpu_pin(reset,0);
- cpu_pin[wait]=1;
+ cpu_is_in_disassemble=1;
}
diff -N -r -u z80-asm-2.3/doc/CHANGELOG z80-asm-2.3.7/doc/CHANGELOG
--- z80-asm-2.3/doc/CHANGELOG 2005-06-03 18:53:06.000000000 +0200
+++ z80-asm-2.3.7/doc/CHANGELOG 2006-07-03 13:39:13.858762771 +0200
@@ -185,3 +185,55 @@
* z80-mon.c: main: cpu_pins busrq and busack are now served
* z80-cpu.c/ports,c: Z80-CTC port access now wired at Z80-CPU
* BUG in ports.c: in_byte(): missing DATA bus assign from *data fixed!
+
+changes after version 2.3:
+ * BUG in Makefile: DEFINES are not put to in $(MAKE) hardware fixed!
+ * hardware: logic_analzyer implemented (to view the Z80 pins)
+ * in decode.c: refresh_cycle() mreq- and rfsh-pin used and I<<8|R onto ADDRESS
+ * in z80-cpu.c: machine cycle counter (triggered by wait_tics)
+ * BUG in asm.c: no_para[]: RST needs 1 Parameter, not 0 fixed!
+ * BUG in execute.c: cp_block: 3 tics missing fixed!
+ * in z80-mon.c: machine cycle counter displayed
+ * in z80-cpu.c: busrq is now acknowledged at beginning of each machine cycle
+ * with dummy.c print_ticks() reintroduced to mask it in non z80-mon programs
+ using acknowledge_bus_request()
+ * BUG in hardware/z80-ctc.c: read_word(): fp may be 0 fixed!!
+ * only if !cpu_is_in_disassemble then set_cpu_pin() , acknowledge_bus_request()
+ and ADDRESS are used (databus can be used if cpu_is_in_disassemble mode)
+ * port_buffer for OLD_STYLE port_access via Z80_PORTS put in hardware now
+ * z80-global im Makefile als dependence of z80-cpu.h
+ * SSL_ZDS trigger in hardware
+ * BUG in execute.c: f_inc/f_dec: 16 bit registers shouldn't change flags fixed!
+ * BUG in execute.c: f_rrd: lower nibble in accu set wrongly fixed!
+ * BUG in execute.c: f_adc16/f_sbc16: zero_flag wrongly calculated fixed!
+ * BUG in execute.c: f_inc/f_dec: PV_flag wrongly calculated fixed!
+ * in z80-asm.c und z80-mon.c option parsing simplified und equaly processed.
+ * BUG in execute.c: add,adc,sub,sbc,cp,f_adc16,f_sbc16: underflow check for
+ < -127 , < -32767 missing (V-Flag wrongly computed) fixed!
+ * BUG ins asm.c: convert_arg(): arg->text isn't initialized to 0. fixed!
+ * BUG in regs.h: missing #include "z80-global" to define seznam_type fixed!
+ * BUG in execute.c: f_neg: PV_flag wrongly calculated fixed!
+ * BUG in execute.c: f_neg: H_flag setiing typo: F_N must be F_NH fixed!
+ * BUG in execute.c: f_inc/f_dec: PV_flag wrongly calculated for 8-bit register
+ (last fix affected only 8-bit memory access) fixed!
+ * BUG in execute.c: add/adc/sub/sbc/cp/adc16/sbc16: V_flag inverted mapped on
+ P_flag fixed!
+ * in all Makefile: -malign-function=0 replaced by -falign-function=0 and
+ Makefile-Variable CC set to gcc.
+ * doc/execute_timing.tex to doc/execute_timing.txt renamed
+ * BUG in z80-mon.c: main: counter b & s for argv wrongly increased fixed!
+ * BUG in memory.c: init_banks: map must be 0-pointer for first realloc fixed!
+ * BUG in memory.c: init_banks: tok[3] must be tok[4] in two lines fixed!
+ * BUG in memory.c: init_banks: superfluious else prohibited bank[id].back_up
+ allocation. fixed!
+ * BUG in memory.c: init_banks: strtoul(..) needs check of *p if p is defined
+ after scanning tok2 and tok4 for numbers fixed!
+ * BUG in memory.c: _uchar memory_at: logic for bank_access is missing fixed!
+ * in hardware/banks-*: new bank-mask notation introduced
+ * in doc/man/z80-banks.5 default bank after reset/initialisation documentated.
+ * in memory.c bank-mask must now be a 2 hexadecimal number
+ * in doc/man/z80-mon.1 execution-mode preciser defined.
+ * in z80-cpu.c/z80-cpu.h: new cpu-flag cpu_is_in_x_mode defined
+ * in z80-mon.c: main: cpu_is_in_x_mode is set if 'Execute instruction'-Key
+ * in execute.c: cpu_is_in_x_mode used for jr/djnz/halt/cp-, ld-, out-, in-
+ block instructions used
diff -N -r -u z80-asm-2.3/doc/README z80-asm-2.3.7/doc/README
--- z80-asm-2.3/doc/README 2005-06-03 18:49:36.000000000 +0200
+++ z80-asm-2.3.7/doc/README 2006-07-03 15:02:43.203721588 +0200
@@ -1,4 +1,4 @@
-Version 2.3 of package Z80-asm from 2005-Jun-03
+Version 2.3.7 of package Z80-asm from 2006-Jul-03
[outdated: http://freshmeat.net/projects/z80-asm/]
@@ -24,4 +24,4 @@
(probably buggy) Z80-CTC emulation.
We hope you have fun ...
-2004-06-09
+2004-07-03
diff -N -r -u z80-asm-2.3/doc/SRC_FILES z80-asm-2.3.7/doc/SRC_FILES
--- z80-asm-2.3/doc/SRC_FILES 2005-05-24 18:35:41.000000000 +0200
+++ z80-asm-2.3.7/doc/SRC_FILES 2005-06-13 23:02:50.000000000 +0200
@@ -11,6 +11,7 @@
decode.h declarations to use data of simul.c
decode-table.c machine decoding tables for executing/disassembling purpose
decode-table.h declarations to use data of decode-table.c
+dummy.c to satisfy print_ticks() used by non z80-mon routines
execute.c execute or disassemble functions
execute.h declarations to use functions of execute.c
expression.c parser to evaluate labels, numbers and arithmetic expressions
@@ -46,9 +47,16 @@
z80-global global typedef and structs and defines
in hardware:
+analyzer.c logic analyzer to protocoll all CPU pins with tick-resolution
+analyzer.h declarations to use functions of analyzer.c
daisy_chain.c the hardware IO-circuit to handle interrupts correctly
daisy_chain.h declarations to use functions of daisy_chain.c
+port_buffer.c buffer for all 256 ports --- enables asychron access by others
+port_buffer.h declarations to use functions of port_buffer.c
+ssl_zds.c single_step_logic to trigger NMI after 2 m1_cycles
+ssl_zds.h declarations to use functions of ssl_zds.c
quartz.c oscillator
quartz.h declarations to use functions of quartz.c
z80-ctc.c a z80-ctc with channel 2 cascaded to channel 3
z80-ctc.h declarations to use variables of z80-ctc.c
+zds_token defines for use of zds-files
diff -N -r -u z80-asm-2.3/doc/TODO z80-asm-2.3.7/doc/TODO
--- z80-asm-2.3/doc/TODO 2005-06-02 13:36:42.000000000 +0200
+++ z80-asm-2.3.7/doc/TODO 2006-06-30 14:12:46.653194512 +0200
@@ -5,7 +5,7 @@
* STRING_LABELS for DEFM (predefined STRING_LABELS, &filename, &date, &time)
- * LABEL und STRING_LABEL defintion as option for z80-asm like -D PORT12=0x1234
+ * LABEL und STRING_LABEL definition as option for z80-asm like -D PORT12=0x1234
* set the (unused) 3rd and 5th bit of the F-register correctly
diff -N -r -u z80-asm-2.3/doc/execute_timing.tex z80-asm-2.3.7/doc/execute_timing.tex
--- z80-asm-2.3/doc/execute_timing.tex 2004-02-24 21:19:54.000000000 +0100
+++ z80-asm-2.3.7/doc/execute_timing.tex 1970-01-01 01:00:00.000000000 +0100
@@ -1,74 +0,0 @@
-TICS_IXY_PLUS or TICS_JR:
-
-(1 tic: select low registers) ; done during opcode decode
- 1 tic: LD [accu],destination_low ; destination one of PC, IX, IY
- LD [summand],displacement ; displacement is a signed 8-bit constant
- clear_carry
- 1 tic: ADC
- 1 tic: LD destination_low,[accu] ; destination one of PC, IX, IY
- 1 tic: if (carry) INC destination_high
- 1 tic: if (summand&128) DEC destination_high
-
-
-
-TICS_IXY_PLUS or TICS_JR:
-
-2 tics: LD [high,low], 16_bit-reg ; 16_bit-reg one of PC, IX, IY
- LD offlow, displacement ; displacement is a signed 8-bit constant
-
-2 tics: if (offlow&128) DEC high
- ADD low,offlow ; parallel to DEC high instruction
- if (carry) INC high
-1 tic: LD destination, [high,low] ; destination is either PC or ADDRESS
-
-
-
-TICS_ADD_SUB_16:
-
-(1 tic: select low registers) ; done during opcode decode
- 1 tic: LD [accu],destination_low ; destination one of HL, IX, IY
- LD [summand],source_low ; source one of HL,IX,IY,BC,DE,SP
- clear_carry
- 1 tic: ADC ; 8 bit addition
- 1 tic: LD destination_low,[accu] ; destination one of HL, IX, IY
- 1 tic: select high_registers
- 1 tic: LD [accu],destination_high ; destination one of HL, IX, IY
- LD [summand],source_high ; source one of HL,IX,IY,BC,DE,SP
- 1 tic: ADC ; 8 bit addition
- 1 tic: LD destination_high,[high] ; destination one of HL, IX, IY
-
-
-
-TICS_ADD_SUB_16:
-
-2 tics: LD [high,low],16_bit-reg ; 16_bit-reg one of HL, IX, IY
- LD [offhigh,offlow],source ; source one of HL,IX,IY,BC,DE,SP
- clear_carry
-4 tics: ADC ; 8 bit addition of low arguments
- switch high<->low
- ADC ; 8 bit addition of low arguments
- switch high<->low
-1 tics: LD 16_bit-reg,[high,low] ; 16_bit-reg one of HL, IX, IY
-
-
-
-timing of EX HL,(SP)
-
-(4 T refresh, read opcode) ; opcode is read and decoded
- 3 T LD accu,(SP)
- 3 T LD (SP++),L ; that's the reason pop is fast than push
- 1 T LD L,accu
- 3 T LD accu,(SP)
- 3 T LD (SP),H ; suppressed INC SP
- 1 T LD H,accu
- 1 T DEC SP
-
-
-timing of LDI
-
-(8 T refresh, 2 x read opcode) ; opcode is read and decoded
- 3 T LD accu,(HL)
- 0 T INC HL ; parallel to load
- 3 T LD (DE),accu ; HL latches flushed also
- 0 T INC DE ; parallel to load
- 2 T DEC BC ; DE latches flushed also
diff -N -r -u z80-asm-2.3/doc/execute_timing.txt z80-asm-2.3.7/doc/execute_timing.txt
--- z80-asm-2.3/doc/execute_timing.txt 1970-01-01 01:00:00.000000000 +0100
+++ z80-asm-2.3.7/doc/execute_timing.txt 2004-02-24 21:19:54.000000000 +0100
@@ -0,0 +1,74 @@
+TICS_IXY_PLUS or TICS_JR:
+
+(1 tic: select low registers) ; done during opcode decode
+ 1 tic: LD [accu],destination_low ; destination one of PC, IX, IY
+ LD [summand],displacement ; displacement is a signed 8-bit constant
+ clear_carry
+ 1 tic: ADC
+ 1 tic: LD destination_low,[accu] ; destination one of PC, IX, IY
+ 1 tic: if (carry) INC destination_high
+ 1 tic: if (summand&128) DEC destination_high
+
+
+
+TICS_IXY_PLUS or TICS_JR:
+
+2 tics: LD [high,low], 16_bit-reg ; 16_bit-reg one of PC, IX, IY
+ LD offlow, displacement ; displacement is a signed 8-bit constant
+
+2 tics: if (offlow&128) DEC high
+ ADD low,offlow ; parallel to DEC high instruction
+ if (carry) INC high
+1 tic: LD destination, [high,low] ; destination is either PC or ADDRESS
+
+
+
+TICS_ADD_SUB_16:
+
+(1 tic: select low registers) ; done during opcode decode
+ 1 tic: LD [accu],destination_low ; destination one of HL, IX, IY
+ LD [summand],source_low ; source one of HL,IX,IY,BC,DE,SP
+ clear_carry
+ 1 tic: ADC ; 8 bit addition
+ 1 tic: LD destination_low,[accu] ; destination one of HL, IX, IY
+ 1 tic: select high_registers
+ 1 tic: LD [accu],destination_high ; destination one of HL, IX, IY
+ LD [summand],source_high ; source one of HL,IX,IY,BC,DE,SP
+ 1 tic: ADC ; 8 bit addition
+ 1 tic: LD destination_high,[high] ; destination one of HL, IX, IY
+
+
+
+TICS_ADD_SUB_16:
+
+2 tics: LD [high,low],16_bit-reg ; 16_bit-reg one of HL, IX, IY
+ LD [offhigh,offlow],source ; source one of HL,IX,IY,BC,DE,SP
+ clear_carry
+4 tics: ADC ; 8 bit addition of low arguments
+ switch high<->low
+ ADC ; 8 bit addition of low arguments
+ switch high<->low
+1 tics: LD 16_bit-reg,[high,low] ; 16_bit-reg one of HL, IX, IY
+
+
+
+timing of EX HL,(SP)
+
+(4 T refresh, read opcode) ; opcode is read and decoded
+ 3 T LD accu,(SP)
+ 3 T LD (SP++),L ; that's the reason pop is fast than push
+ 1 T LD L,accu
+ 3 T LD accu,(SP)
+ 3 T LD (SP),H ; suppressed INC SP
+ 1 T LD H,accu
+ 1 T DEC SP
+
+
+timing of LDI
+
+(8 T refresh, 2 x read opcode) ; opcode is read and decoded
+ 3 T LD accu,(HL)
+ 0 T INC HL ; parallel to load
+ 3 T LD (DE),accu ; HL latches flushed also
+ 0 T INC DE ; parallel to load
+ 2 T DEC BC ; DE latches flushed also
diff -N -r -u z80-asm-2.3/doc/man/z80-banks.5 z80-asm-2.3.7/doc/man/z80-banks.5
--- z80-asm-2.3/doc/man/z80-banks.5 2004-02-27 15:36:29.000000000 +0100
+++ z80-asm-2.3.7/doc/man/z80-banks.5 2006-06-29 14:42:42.605231137 +0200
@@ -1,4 +1,4 @@
-.TH Z80-BANKS 5 "26 Feb 2004" "Z80-BANKS Version 2.1" "Bank layout format"
+.TH Z80-BANKS 5 "29 Jun 2006" "Z80-BANKS Version 2.3" "Bank layout format"
.SH NAME
description of file format used by z80-mon for bank layout
@@ -56,14 +56,13 @@
.B bank_name
must either indicate a readable file which contains the
machine code for the bank or the special value
-.I - \ \ \ (minus)
-which indicates either undefined storage, typi-
- cally RAM, or in the case of a virtuel bank no file
- name. If the corresponding file is smaller than the
- bank size the remaining bytes at the end of the bank
- will be undefined. If the file size is larger than the
- bank size only the first bytes in the file will be
- used.
+.I - (minus)
+ which indicates either undefined storage, typically RAM,
+ or in the case of a virtuel bank no file name. If the corres-
+ sponding file is smaller than the bank size the remaining
+ bytes at the end of the bank will be undefined. If the file
+ size is larger than the bank size only the first bytes in
+ the file will be used.
.B offset
is a 4 digit hexadecimal value telling the hardware the
@@ -83,14 +82,14 @@
must be 0.
.B mask
- is a hexadecimal byte value which covers the relevant
+ is a 2 digit hexadecimal byte value which covers the relevant
part of value send to the corresponding port. The
-.I \ \ \ port_no
-together with the given
+.I port_no
+ together with the given
.I mask
must have a unique
-.I \ \ \ offset
-respectively \fIbank_id\fR.
+.I offset
+ respectively \fIbank_id\fR.
Each used \fIbank_id\fR in a page description must be defined in a previous
bank description.
@@ -107,7 +106,9 @@
.I port_no
should have different
.I bank_id
-s for a unique mapping.
+s for a unique mapping. The default \fIbank_id\fR of a page is the one with
+the lowest \fIbank_id\fR. This is selected at hardware initialisation and after
+a bank reset.
.SH SEE ALSO
z80-memory(5)
diff -N -r -u z80-asm-2.3/doc/man/z80-mon.1 z80-asm-2.3.7/doc/man/z80-mon.1
--- z80-asm-2.3/doc/man/z80-mon.1 2005-05-03 12:28:37.000000000 +0200
+++ z80-asm-2.3.7/doc/man/z80-mon.1 2006-07-03 13:09:33.203665003 +0200
@@ -1,4 +1,4 @@
-.TH Z80-MON 1 "03 May 2005" "Z80-MON Version 2.2" "Z80 Monitor"
+.TH Z80-MON 1 "03 July 2006" "Z80-MON Version 2.3" "Z80 Monitor"
.SH NAME
z80-mon \- an interactive Z80 monitor with disassembler and emulator for UNIX,
@@ -165,7 +165,10 @@
Escape aborts disassembling and saving.
.B x - execute instruction
- Asks about instruction and executes it.
+ Asks about instruction and executes it. Except jump,
+ call and return instructions, the
+.I PC
+is not changed.
.B Enter - put instruction
Asks about instruction and puts it on address in
@@ -275,7 +278,7 @@
.I SIGHUP
will terminate z80-mon,
.I SIGABRT
-will set the CPU-wait pin active,
+will set the monitor in interactive dissamble mode (stops running CPU),
.I SIGUSR1
will cause a reset and
.I SIGUSR2
diff -N -r -u z80-asm-2.3/doc/man/z80-ports.5 z80-asm-2.3.7/doc/man/z80-ports.5
--- z80-asm-2.3/doc/man/z80-ports.5 2005-06-03 18:57:25.000000000 +0200
+++ z80-asm-2.3.7/doc/man/z80-ports.5 2005-06-08 15:06:34.000000000 +0200
@@ -1,4 +1,4 @@
-.TH Z80-PORTS 5 "12 Feb 2004" "Z80-PORTS Version 2.0" "Port mapping"
+.TH Z80-PORTS 5 "08 Jun 2005" "Z80-PORTS Version 2.3" "Port mapping"
.SH NAME
description of port mapping used by z80-mon for IN and OUT
@@ -7,11 +7,15 @@
Because the IN and OUT instructions communicate with the outside their effect
is environment/OS dependend.
-All effected ports by these instructions are realized as a binary
-file named
+Port access can be either directly clock synchron or asynchron and buffered.
+In the later case all effected ports by the IN and OUT instructions are
+realized as a binary file named
.I ".Z80_ports"
-for asynchron access.
-This file must be read- and writable and should contain 256 bytes.
+buffering the data.
+Then this file must be read- and writable and should contain 256 bytes.
+In the case, that only directly synchron port access by other hardware components is wanted, this file
+.I ".Z80_ports"
+should not exist, or must be at least nonreadable to not interfere with the system bus.
The user has the option to reserve some ports for bank switching.
diff -N -r -u z80-asm-2.3/doc/z80instructions.txt z80-asm-2.3.7/doc/z80instructions.txt
--- z80-asm-2.3/doc/z80instructions.txt 1970-01-01 01:00:00.000000000 +0100
+++ z80-asm-2.3.7/doc/z80instructions.txt 2005-06-11 21:28:38.000000000 +0200
@@ -0,0 +1,298 @@
+This file is from the book:
+Microprocessor Technology ISBN 0835943925
+
+Scan done by:
+Alvin Albrecht aralbrec@concentric.net
+
+OCR , retyping, and checking done by:
+Vaggelis Kapartzianis zx32@usa.net
+
+Thanks to you guys for this great work :-)
+
+
+
+
+ LEGEND
+ ======
+
+ IOD - internal CPU Operation displacement calculation
+ IOR - Operand Data Read and internal CPU Operation displacement calculation
+ IOJ - internal CPU Operation set PC
+ IO8 - internal CPU Operation with 8bit ALU
+ IOS - internal CPU Operation swap half bytes
+ MR - Memory Read
+ MRH - Memory Read of High Byte
+ MRL - Memory Read of Low Byte
+ MW - Memory Write
+ MWH - Memory Write of High Byte
+ MWL - Memory Write of Low Byte
+ OCF - Op Code Fetch and memory refresh
+ ODH - Operand Data Read of High Byte
+ ODL - Operand Data Read of Low Byte
+ PR - Port Read
+ PW - Port Write
+ SRH - Stack Read of High Byte
+ SRL - Stack Read of Low Byte
+ SWH - Stack Write of High Byte
+ SWL - Stack Write of Low byte
+ INTA- Interrupt Acknowledge
+ ( ) - Number of T-States in that Machine Cycle
+
+ Z80 INSTRUCTION BREAKDOWN BY MACHINE CODE
+ =========================================
+ MACHINE CYCLE
+ INSTRUCTION BYTES M1 M2 M3 M4 M5
+ TYPE
+ ====================================================================================================
+ LD r,s 1 OCF(4)
+
+ LD r,n 2 OCF(4) OD(3)
+
+ LD r,(HL) 1 OCF(4) MR(3)
+ LD (HL),r OCF(4) MW(3)
+
+ LD r,(IX+d) 3 OCF(4)/OCF(4) OD(3) IOD(5) MR(3)
+ LD (IX+d),r OCF(4)/OCF(4) OD(3) IOD(5) MW(3)
+
+ LD (HL),n 2 OCF(4) OD(3) MW(3)
+
+ LD (IX+d),n 4 OCF(4)/OCF(4) OD(3) IOR(5) MW(3)
+
+ BC
+ LD A,(DE) 1 OCF(4) MR(3)
+ BC
+ LD (DE),A OCF(4) MW(3)
+
+ LD A,(nn) 3 OCF(4) ODL(3) ODH(3) MR(3)
+ LD (nn),A OCF(4) ODL(3) ODH(3) MW(3)
+
+ I
+ LD A,R 2 OCF(4)/OCF(5)
+ I
+ LD R, A
+
+ LD dd,nn 3 OCF(4) ODL(3) ODH(3)
+
+ LD IX,nn 4 OCF(4)/OCF(4) ODL(3) ODH(3)
+
+ LD HL,(nn) 3 OCF(4) ODL(3) ODH(3) MRL(3) MRH(3)
+ LD (nn),HL OCF(4) ODL(3) ODH(3) MWL(3) MWH(3)
+
+ LD dd,(nn) 4 OCF(4)/OCF(4) ODL(3) ODH(3) MRL(3) MRH(3)
+ LD (nn),dd OCF(4)/OCF(4) ODL(3) ODH(3) MWL(3) MWH(3)
+ LD IX,(nn) OCF(4)/OCF(4) ODL(3) ODH(3) MRL(3) MRH(3)
+ LD (nn),IX OCF(4)/OCF(4) ODL(3) ODH(3) MWL(3) MWH(3)
+
+ LD SP,HL 1 OCF(6)
+
+ LD SP,IX 2 OCF(4)/OCF(6)
+
+ PUSH qq 1 OCF(5) SWH(3) SWL(3)
+ SP-1 ---> SP-1 --->
+
+ PUSH IX 2 OCF(4)/OCF(5) SWH(3) SWL(3)
+ SP-1 ---> SP-1 --->
+
+ POP qq 1 OCF(4) SRH(3) SRL(3)
+ SP+1 ---> SP+1 --->
+
+ POP IX 2 OCF(4)/OCF(4) SRH(3) SRL(3)
+ SP+1 ---> SP+1 --->
+
+ EX DE,HL 1 OCF(4)
+
+ EX AF,AF' 1 OCF(4)
+
+ EXX 1 OCF(4)
+
+ EX (SP),HL 1 OCF(4) SRL(3) SRH(4) SWH(3) SWL(5)
+ SP+1 ---> SP-1 --->
+
+ EX (SP),IX 2 OCF(4)/OCF(4) SRL(3) SRH(4) SWH(3) SWL(5)
+ SP+1 ---> SP-1 --->
+
+
+ LDI 2 OCF(4)/OCF(4) MR(3) MW(5)
+ LDD
+ CPI
+ CPD
+
+ LDIR 2 OCF(4)/OCF(4) MR(3) MW(5) IOJ(5)*
+ LDDR
+ CPIR *only if BC<>O
+ CPDR
+
+ ALU A,r 1 OCF(4)
+ ADD ADC
+ SUB SBC
+ AND OR
+ XOR CP
+
+ ALU A,n 2 OCF(4) OD(3)
+
+ ALU A,(HL) 1 OCF(4) MR(3)
+
+ ALU A,(IX+d) 3 OCF(4)/OCF(4) OD(3) IOD(5) MR(3)
+
+ DEC
+ INC r 1 OCF(4)
+
+ DEC
+ INC (HL) 1 OCF(4) MR(4) MW(3)
+
+ DEC
+ INC (IX+D) 2 OCF(4)/OCF(4) OD(3) IOD(5) MR(4) MW(3)
+
+ DAA 1 OCF(4)
+ CPL
+ CCF
+ SCF
+ NOP
+ HALT
+ DI
+ EI
+
+ NEG 2 OCF(4)/OCF(4)
+ IM0
+ IM1
+ IM2
+
+ ADD HL,ss 1 OCF(4) IO8(4) IO8(3)
+
+ ADC HL,ss 2 OCF(4)/OCF(4) IO8(4) IO8(3)
+ SBC HL,ss
+ ADD IX,pp
+
+ INC ss 1 OCF(6)
+ DEC ss
+
+ DEC IX 2 OCF(4)/OCF(6)
+ INC IX
+
+ RLCA 1 OCF(4)
+ RLA
+ RRCA
+ RRA
+
+ RLC r 2 OCF(4)/OCF(4)
+ RL
+ RRC
+ RR
+ SLA
+ SRA
+ SRL
+
+ RLC (HL) 2 OCF(4)/OCF(4) MR(4) MW(3)
+ RL
+ RRC
+ RR
+ SLA
+ SRA
+ SRL
+
+ RLC (IX+d) 4 OCF(4)/OCF(4) OD(3) IOR(5) MR(4) MW(3)
+ RL
+ RRC
+ RR
+ SLA
+ SRA
+ SRL
+
+ RLD 2 OCF(4)/OCF(4) MR(3) IOS(4) MW(3)
+ RRD
+
+ BIT b,r 2 OCF(4)/OCF(4)
+ SET
+ RES
+
+ BIT b,(HL) 2 OCF(4)/OCF(4) MR(4)
+
+ SET b,(HL) 2 OCF(4)/OCF(4) MR(4) MW(3)
+ RES
+
+ BIT b,(IX+d) 4 OCF(4)/OCF(4) OD(3) IOR(5) MR(4)
+
+ SET b,(IX+d) 4 OCF(4)/OCF(4) OD(3) IOR(5) MR(4) MW(3)
+ RES
+
+ JP nn 3 OCF(4) ODL(3) ODH(3)
+ JP cc, nn
+
+ JR e 2 OCF(4) OD(3) IOJ(5)
+
+ JR C,e 2 OCF(4) OD(3) IOJ(5)*
+ JR NC,e *If condition is met
+ JR Z,e
+ JR NZ,e
+
+ JP (HL) 1 OCF(4)
+
+ JP (IX) 2 OCF(4)/OCF(4)
+
+ DJNZ,e 2 OCF(5) OD(3) IOJ(5)*
+ * If B<>0
+
+ CALL nn 3 OCF(4) ODL(3) ODH(4) SWH(3) SWL(3)
+ CALL cc,nn SP-1 ---> SP-1 --->
+ cc true
+
+ CALL cc,nn 3 OCF(4) ODL(3) ODH(3)
+ cc false
+
+ RET 1 OCF(4) SRL(3) SRH(3)
+ SP+1 ---> SP+1 --->
+
+ RET cc 1 OCF(5) SRL(3)* SRH(3)*
+ * If cc is true
+ SP+1 ---> SP+1 --->
+
+ RETI 2 OCF(4)/OCF(4) SRL(3) SRH(3)
+ RETN SP+1 ---> SP+1 --->
+
+ RST p 1 OCF(5) SWH(3) SWL(3)
+ SP-1 ---> SP-1 --->
+
+ IN A,(n) 2 OCF(4) OD(3) PR(4)
+
+ IN r,(c) 2 OCF(4)/OCF(4) PR(4)
+
+ INI 2 OCF(4)/OCF(5) PR(4) MW(3)
+ IND
+
+ INIR 2 OCF(4)/OCF(5) PR(4) MW(3) IOJ(5)*
+ INDR *only if B<>O
+
+ OUT (n),A 2 OCF(4) OD(3) PW(4)
+
+ OUT (C),r 2 OCF(4)/OCF(4) PW(4)
+
+ OUTI 2 OCF(4)/OCF(5) MR(3) PW(4)
+ OUTD
+
+ OTIR 2 OCF(4)/OCF(5) MR(3) PW(4) IOJ(5)*
+ OTDR *only if B<>O
+
+
+ INTERRUPTS
+ ----------
+
+ NMI _ OCF(5)* SWH(3) SWL(3) *Op Code Ignored
+ SP-1 ---> SP-1 --->
+
+ MODE 0 - INTA(6) ODL(3) ODH(4) SWH(3) SWL(3)
+ (CALL INSERTED) SP-1 ---> SP-1 --->
+
+ - INTA(6) SWH(3) SWL(3)
+ (RST INSERTED)
+ SP-1 ---> SP-1 --->
+
+ MODE 1 INTA(7) SWH(3) SWL(3)
+ (RST 38H
+ INTERNAL)
+ SP-1 ---> SP-1 --->
+
+ MODE 2 - INTA(7) SWH(3) SWL(3) MRL(3) MRH(3)
+ (VECTOR
+ SUPPLIED)
+ SP-1 ---> SP-1 --->
+
diff -N -r -u z80-asm-2.3/dummy.c z80-asm-2.3.7/dummy.c
--- z80-asm-2.3/dummy.c 1970-01-01 01:00:00.000000000 +0100
+++ z80-asm-2.3.7/dummy.c 2005-06-07 12:12:54.000000000 +0200
@@ -0,0 +1,5 @@
+void
+print_ticks(void)
+{
+ /* dummy function for acknowledge_bus_request() in z80-cpu.c */
+}
diff -N -r -u z80-asm-2.3/execute.c z80-asm-2.3.7/execute.c
--- z80-asm-2.3/execute.c 2005-05-31 13:18:49.000000000 +0200
+++ z80-asm-2.3.7/execute.c 2006-07-03 14:26:18.641608270 +0200
@@ -150,41 +150,41 @@
static void
reg_str (char *str,_ushort arg,_uchar type)
-{int i;
- switch (type)
- {
- case A_REG:
- if (arg >= N_REGISTERS+1)
- exit( fprintf(stderr,"reg_str: invalid argument %u\n",arg) );
- sprintf(str,"%s",reg_name[arg]);
- return;
-
- case A_PODLE_REG:
- if (arg >= N_REGISTERS+1)
- exit( fprintf(stderr,"reg_str: invalid argument %u\n",arg) );
- sprintf(str,"(%s)",reg_name[arg]);
- return;
-
- case A_PODLE_IX_PLUS:
- i=sprintf(str,"(%s",reg_name[R_IX]);
- goto together;
-
- case A_PODLE_IY_PLUS:
- i=sprintf(str,"(%s",reg_name[R_IY]);
- together:
-
- if (MODE&2)
- {
- if ((signed char)arg < 0)
- sprintf(str+i,"-"), arg= -(signed char)arg;
- else
- sprintf(str+i,"+");
- sprintf(str+i+1,(MODE&1?"0x"HEX2")":HEXA")"),(unsigned)arg);
- }
- else
- sprintf(str+i,SDEC")",(int)(signed char)arg);
- return;
- }
+{ int i;
+ switch (type)
+ {
+ case A_REG:
+ if (arg >= N_REGISTERS+1)
+ exit( fprintf(stderr,"reg_str: invalid argument %u\n",arg) );
+ sprintf(str,"%s",reg_name[arg]);
+ return;
+
+ case A_PODLE_REG:
+ if (arg >= N_REGISTERS+1)
+ exit( fprintf(stderr,"reg_str: invalid argument %u\n",arg) );
+ sprintf(str,"(%s)",reg_name[arg]);
+ return;
+
+ case A_PODLE_IX_PLUS:
+ i=sprintf(str,"(%s",reg_name[R_IX]);
+ goto together;
+
+ case A_PODLE_IY_PLUS:
+ i=sprintf(str,"(%s",reg_name[R_IY]);
+ together:
+
+ if (MODE&2)
+ {
+ if ((signed char)arg < 0)
+ sprintf(str+i,"-"), arg= -(signed char)arg;
+ else
+ sprintf(str+i,"+");
+ sprintf(str+i+1,(MODE&1?"0x"HEX2")":HEXA")"),(unsigned)arg);
+ }
+ else
+ sprintf(str+i,SDEC")",(int)(signed char)arg);
+ return;
+ }
}
@@ -235,7 +235,8 @@
/* increase PC */
static void
add_to_pc(short incr)
-{ PC += incr;
+{ if (cpu_pin[busrq]) acknowledge_bus_request();
+ PC += incr;
wait_tics(TICS_JR);
}
@@ -244,6 +245,8 @@
static _ushort
ix_iy_disp(_ushort XY, _ushort a, int parallel)
{
+ if (!parallel)
+ if (cpu_pin[busrq]) acknowledge_bus_request();
/* displacement calculation could be parallel to 2nd operand fetch */
wait_tics(TICS_IXY_PLUS-(parallel?TICS_MEMO:0));
return XY+(signed char)a;
@@ -263,7 +266,7 @@
f_nop (_ushort a1,_uchar t1,_ushort a2,_uchar t2)
{
a1=a1;t1=t1;a2=a2;t2=t2;
- return cpu_pin[wait] ? dis(I_NOP) : 0;
+ return cpu_is_in_disassemble ? dis(I_NOP) : 0;
}
@@ -275,7 +278,7 @@
static char txt[32];
_ushort rval=0;
- if(cpu_pin[wait])
+ if(cpu_is_in_disassemble)
{
if(t1==A_PODLE_NUM)
{
@@ -477,7 +480,7 @@
_ushort addr=0;
t2=t2;
- if(cpu_pin[wait])
+ if(cpu_is_in_disassemble)
{int i;
if (t1==A_FLAG)
{
@@ -508,12 +511,12 @@
addr=a1;
break;
}
+ wait_tics(TICS_SP_DEC);
SP--;
write_memo(SP,PC>>8);
SP--;
write_memo(SP,PC&255);
PC=addr;
- wait_tics(TICS_SP_DEC);
}
return 0;
}
@@ -526,7 +529,7 @@
static char t[4];
a2=a2;t2=t2;t1=t1;
- if(cpu_pin[wait])
+ if(cpu_is_in_disassemble)
{
flag_str(t,a1);
sprintf(txt,"%s %s",dis(I_RET),t);
@@ -534,6 +537,7 @@
}
else
{
+ wait_tics(a1==F_EMPTY ? 0 : TICS_FLAG);
if (is_flag(a1)) /* empty flag is always set */
{
PC= read_memo(SP);
@@ -541,7 +545,6 @@
PC|= read_memo(SP)<<8;
SP++;
}
- wait_tics(a1==F_EMPTY ? 0 : TICS_FLAG);
}
return 0;
}
@@ -553,10 +556,10 @@
static char txt[16];
static char t[10];
_uchar *a, d;
- unsigned char z=is_flag(F_Z),s=is_flag(F_M),h=is_flag(F_H),v=0;
+ unsigned char z=is_flag(F_Z),s=is_flag(F_M),h=is_flag(F_H),v=0, calc_flags=0;
a2=a2;t2=t2;
- if(cpu_pin[wait])
+ if(cpu_is_in_disassemble)
{
reg_str(t,a1,t1);
sprintf(txt,"%s %s",dis(I_INC),t);
@@ -602,10 +605,11 @@
default:
a=reg_ptr(a1);
h=(((*a)&15)==15);
- v=(((signed)(*a)+1)>127)?1:0;
(*a)++;
+ v=(*a==128)?1:0;
z=!(*a);
s=((*a)&128);
+ calc_flags=1;
break;
}
break;
@@ -624,19 +628,23 @@
inc:
d= read_memo(ADDR);
h=((d&15)==15);
- v=(((signed)d+1)>127);
d++;
- write_memo(ADDR,d);
+ v=(d==0x80);
+ wait_tics(TICS_LATE_ALU);
z=!d;
s=(d&128);
- wait_tics(TICS_LATE_ALU);
+ write_memo(ADDR,d);
+ calc_flags=1;
break;
}
- set_flag(F_NN);
- set_flag(z?F_Z:F_NZ);
- set_flag(s?F_M:F_P);
- set_flag(h?F_H:F_NH);
- set_flag(v?F_PE:F_PO);
+ if (calc_flags)
+ {
+ set_flag(F_NN);
+ set_flag(z?F_Z:F_NZ);
+ set_flag(s?F_M:F_P);
+ set_flag(h?F_H:F_NH);
+ set_flag(v?F_PE:F_PO);
+ }
}
return 0;
}
@@ -648,10 +656,10 @@
static char txt[16];
static char t[10];
_uchar *a, d;
- unsigned char z=is_flag(F_Z),s=is_flag(F_M),h=is_flag(F_H),v=0;
+ unsigned char z=is_flag(F_Z),s=is_flag(F_M),h=is_flag(F_H),v=0, calc_flags=0;
a2=a2;t2=t2;
- if(cpu_pin[wait])
+ if(cpu_is_in_disassemble)
{
reg_str(t,a1,t1);
sprintf(txt,"%s %s",dis(I_DEC),t);
@@ -697,10 +705,11 @@
default:
a=reg_ptr(a1);
h=!((*a)&15);
- v=(((signed)(*a)-1)<128)?1:0;
+ v=(*a==128)?1:0;
(*a)--;
z=!(*a);
s=((*a)&128);
+ calc_flags=1;
break;
}
break;
@@ -719,19 +728,23 @@
dec:
d= read_memo(ADDR);
h=!(d&15);
- v=(((signed)d-1)<-128);
+ v=(d==0x80);
d--;
write_memo(ADDR,d);
z=!d;
s=(d&128);
wait_tics(TICS_LATE_ALU);
+ calc_flags=1;
break;
}
- set_flag(F_N);
- set_flag(z?F_Z:F_NZ);
- set_flag(s?F_M:F_P);
- set_flag(h?F_H:F_NH);
- set_flag(v?F_PE:F_PO);
+ if (calc_flags)
+ {
+ set_flag(F_N);
+ set_flag(z?F_Z:F_NZ);
+ set_flag(s?F_M:F_P);
+ set_flag(h?F_H:F_NH);
+ set_flag(v?F_PE:F_PO);
+ }
}
return 0;
}
@@ -742,7 +755,7 @@
char *str, void (*func)(void) )
{
a2=a2;t2=t2;a1=a1;t1=t1;
- if(cpu_pin[wait])
+ if(cpu_is_in_disassemble)
return str;
else
{
@@ -819,7 +832,7 @@
_uchar a=0;
a2=a2;t2=t2;
- if(cpu_pin[wait])
+ if(cpu_is_in_disassemble)
{
if (t2==A_EMPTY)
{
@@ -878,12 +891,13 @@
static _uchar add(_uchar a)
{
- int v,c,h;
- v=((int)A+(int)a)>127;
- c=((int)A+(int)a)>255;
+ int res,v,c,h;
+ res=(signed char)A+(signed char)a;
+ c=A>=256-a;
+ v=res>127 || res<-128;
h=((int)(A&15)+(a&15))>15;
- A+=a;
- set_flag(v?F_PO:F_PE);
+ A=(_uchar)res;
+ set_flag(v?F_PE:F_PO);
set_flag(c?F_C:F_NC);
set_flag(h?F_H:F_NH);
set_flag(F_NN);
@@ -892,12 +906,13 @@
static _uchar adc(_uchar a)
{
- int v,c,h;
- v=((int)A+(int)a+is_flag(F_C))>127;
- c=((int)A+(int)a+is_flag(F_C))>255;
+ int res,v,c,h;
+ res=(signed char)A+(signed char)a+(int)is_flag(F_C);
+ c=A>=256-a-(unsigned)is_flag(F_C);
+ v=res>127 || res<-128;
h=((int)(A&15)+(a&15)+is_flag(F_C))>15;
- A+=a+is_flag(F_C);
- set_flag(v?F_PO:F_PE);
+ A=(_uchar)res;
+ set_flag(v?F_PE:F_PO);
set_flag(c?F_C:F_NC);
set_flag(h?F_H:F_NH);
set_flag(F_NN);
@@ -906,12 +921,13 @@
static _uchar sbc(_uchar a)
{
- int v,c,h;
- v=((int)A-(int)a-is_flag(F_C))<-128;
- c=((int)A-(int)a-is_flag(F_C))<0;
+ int res,v,c,h;
+ res=(signed char)A-(signed char)a-(int)is_flag(F_C);
+ c=A127 || res<-128;
h=((int)(A&15)-(a&15)-is_flag(F_C))<0;
- A-=a+is_flag(F_C);
- set_flag(v?F_PO:F_PE);
+ A=(_uchar)res;
+ set_flag(v?F_PE:F_PO);
set_flag(c?F_C:F_NC);
set_flag(h?F_H:F_NH);
set_flag(F_N);
@@ -920,28 +936,31 @@
static _uchar sub(_uchar a)
{
- int v,c,h;
- v=((int)A-a)<-128;
- c=((int)A-a)<0;
+ int res,v,c,h;
+ res=(signed char)A-(signed char)a;
+ c=A127 || res<-128;
h=((int)(A&15)-(a&15))<0;
- set_flag(v?F_PO:F_PE);
+ A=(_uchar)res;
+ set_flag(v?F_PE:F_PO);
set_flag(c?F_C:F_NC);
set_flag(h?F_H:F_NH);
set_flag(F_N);
- return A-=a;
+ return A;
}
static _uchar cp(_uchar a)
{
- unsigned char v,c,h;
- v=((int)A-a)<-128;
- c=((int)A-a)<0;
+ int res,v,c,h;
+ res=(signed char)A-(signed char)a;
+ c=A127 || res<-128;
h=((int)(A&15)-(a&15))<0;
- set_flag(v?F_PO:F_PE);
+ set_flag(v?F_PE:F_PO);
set_flag(c?F_C:F_NC);
set_flag(h?F_H:F_NH);
set_flag(F_N);
- return A-a;
+ return (_uchar)res;
}
_uchar *
@@ -1010,7 +1029,7 @@
static char t[8],tt[8];
_ushort lv=0,rv=0;
- if(cpu_pin[wait])
+ if(cpu_is_in_disassemble)
{
reg_str(t,a1,t1);
reg_str(tt,a2,t2);
@@ -1052,6 +1071,8 @@
rv=SP;
break;
}
+ if (cpu_pin[busrq]) acknowledge_bus_request();
+ wait_tics(TICS_ADD_SUB_16_PRE);
switch(index)
{
case 0: /* HL */
@@ -1072,7 +1093,8 @@
IY=lv;
break;
}
- wait_tics(TICS_ADD_SUB_16);
+ if (cpu_pin[busrq]) acknowledge_bus_request();
+ wait_tics(TICS_ADD_SUB_16_POST);
}
return 0;
}
@@ -1099,16 +1121,16 @@
{
int c,h,v, res;
- res=(int)lv-(int)rv-is_flag(F_C);
+ res=(short)lv-(short)rv-(int)is_flag(F_C);
h=((int)(lv>>8&15)-(int)(rv>>8&15)-is_flag(F_C))<0;
- c=res<0;
- v=res<-32768;
+ c=lv32767||res<-32768;
set_flag(res&32768?F_M:F_P);
- set_flag(v?F_PO:F_PE);
+ set_flag(v?F_PE:F_PO);
set_flag(c?F_C:F_NC);
set_flag(h?F_H:F_NH);
- set_flag(res?F_NZ:F_Z);
+ set_flag((_ushort)res?F_NZ:F_Z);
set_flag(F_N);
return (_ushort) res;
}
@@ -1124,16 +1146,16 @@
{
int c,h,v, res;
- res=(int)lv+(int)rv+is_flag(F_C);
+ res=(short)lv+(short)rv+(int)is_flag(F_C);
h=((int)(lv>>8&15)+(int)(rv>>8&15)+is_flag(F_C))>15;
- c=res>65535;
- v=res>32767;
+ c=lv>=65536-rv-(unsigned)is_flag(F_C);
+ v=res>32767||res<-32768;
set_flag(res&32768?F_M:F_P);
- set_flag(v?F_PO:F_PE);
+ set_flag(v?F_PE:F_PO);
set_flag(c?F_C:F_NC);
set_flag(h?F_H:F_NH);
- set_flag(res?F_NZ:F_Z);
+ set_flag((_ushort)res?F_NZ:F_Z);
set_flag(F_NN);
return (_ushort) res;
}
@@ -1152,7 +1174,7 @@
static char txt[16];
t1=t1;t2=t2;a2=a2;
- if(cpu_pin[wait])
+ if(cpu_is_in_disassemble)
{int i;
i=sprintf(txt,"%s ",dis(I_DJNZ));
if (MODE&8)
@@ -1175,9 +1197,9 @@
}
else
{
+ if (cpu_is_in_x_mode) add_to_pc(2);
B--;
if (B) add_to_pc((short)(signed char)a1);
- wait_tics(TICS_LATE_ALU);
}
return 0;
}
@@ -1191,7 +1213,7 @@
_ushort addr=0;
t2=t2;
- if(cpu_pin[wait])
+ if(cpu_is_in_disassemble)
{int i;
switch (t1)
{
@@ -1270,7 +1292,7 @@
static char t[4];
t2=t2;
- if(cpu_pin[wait])
+ if(cpu_is_in_disassemble)
{int i;
if (t1==A_FLAG)
{
@@ -1301,7 +1323,9 @@
else
{
if (t1!=A_FLAG || is_flag(a1))
+ { if (cpu_is_in_x_mode) add_to_pc(2);
add_to_pc( (t1==A_FLAG) ? (signed char)a2 : (signed char)a1 );
+ }
}
return 0;
}
@@ -1314,7 +1338,7 @@
int h;
a1=a1;t1=t1;a2=a2;t2=t2;
- if(cpu_pin[wait])
+ if(cpu_is_in_disassemble)
return dis(I_DAA);
else
{
@@ -1347,7 +1371,7 @@
{
a1=a1;t1=t1;a2=a2;t2=t2;
- if(cpu_pin[wait])
+ if(cpu_is_in_disassemble)
return dis(I_CPL);
else
{
@@ -1364,7 +1388,7 @@
{
a1=a1;t1=t1;a2=a2;t2=t2;
- if(cpu_pin[wait])
+ if(cpu_is_in_disassemble)
return dis(I_SCF);
else
{
@@ -1381,7 +1405,7 @@
{
a1=a1;t1=t1;a2=a2;t2=t2;
- if(cpu_pin[wait])
+ if(cpu_is_in_disassemble)
return dis(I_CCF);
else
{
@@ -1396,12 +1420,12 @@
f_halt (_ushort a1,_uchar t1,_ushort a2,_uchar t2)
{
a1=a1;t1=t1;a2=a2;t2=t2;
- if (cpu_pin[wait])
+ if (cpu_is_in_disassemble)
return dis(I_HALT);
else
{
- cpu_pin[halt]=1;
- PC-=1;
+ set_cpu_pin(halt,1);
+ if (!cpu_is_in_x_mode) PC-=1;
}
return 0;
}
@@ -1414,7 +1438,7 @@
_uchar l,h;
a2=a2;t2=t2;
- if(cpu_pin[wait])
+ if(cpu_is_in_disassemble)
{
reg_str(t,a1,t1);
sprintf(txt,"%s %s",dis(I_POP),t);
@@ -1465,7 +1489,7 @@
_uchar l=0,h=0;
a2=a2;t2=t2;
- if(cpu_pin[wait])
+ if(cpu_is_in_disassemble)
{
reg_str(t,a1,t1);
sprintf(txt,"%s %s",dis(I_PUSH),t);
@@ -1515,18 +1539,18 @@
static char txt[16];
a2=a2;t2=t2;t1=t1;
- if(cpu_pin[wait])
+ if(cpu_is_in_disassemble)
{
sprintf(txt,"%s 0x"HEX2,dis(I_RST),a1);
return txt;
}
else
{
+ wait_tics(TICS_SP_DEC);
SP--;
write_memo(SP,PC>>8);
SP--;
write_memo(SP,PC&255);
- wait_tics(TICS_SP_DEC);
PC=a1;
}
return 0;
@@ -1540,7 +1564,7 @@
static char tf[5];
static char ts[4];
- if (cpu_pin[wait])
+ if (cpu_is_in_disassemble)
{
if (t1==A_PODLE_NUM)
sprintf(tf,((MODE&3)==3?"0x"HEX2:MODE&1?DECI:HEX2),a1);
@@ -1571,7 +1595,7 @@
static char tf[4];
static char ts[5];
- if (cpu_pin[wait])
+ if (cpu_is_in_disassemble)
{
if (t2==A_PODLE_NUM)
sprintf(ts,((MODE&3)==3?"0x"HEX2:MODE&1?DECI:HEX2),a2);
@@ -1609,7 +1633,7 @@
int a;
a1=a1;t1=t1;a2=a2;t2=t2;
- if(cpu_pin[wait])
+ if(cpu_is_in_disassemble)
return dis(I_EXX);
else
{
@@ -1631,7 +1655,7 @@
static char r1[8],r2[4];
_uchar x,y;
- if(cpu_pin[wait])
+ if(cpu_is_in_disassemble)
{
reg_str(r1,a1,t1);
reg_str(r2,a2,t2);
@@ -1658,33 +1682,41 @@
case R_HL:
x= read_memo(SP);
write_memo(SP,L);L=x;
+ wait_tics(TICS_INTERNAL_LD);
SP++;
x= read_memo(SP);
write_memo(SP,H);H=x;
+ wait_tics(TICS_INTERNAL_LD);
SP--;
+ wait_tics(TICS_SP_DEC);
break;
case R_IX:
x= read_memo(SP);
write_memo(SP,IX&255);
+ wait_tics(TICS_INTERNAL_LD);
SP++;
y= read_memo(SP);
write_memo(SP,IX>>8);
+ wait_tics(TICS_INTERNAL_LD);
SP--;
+ wait_tics(TICS_SP_DEC);
IX=x|(y<<8);
break;
case R_IY:
x= read_memo(SP);
write_memo(SP,IY&255);
+ wait_tics(TICS_INTERNAL_LD);
SP++;
y= read_memo(SP);
write_memo(SP,IY>>8);
+ wait_tics(TICS_INTERNAL_LD);
SP--;
+ wait_tics(TICS_SP_DEC);
IY=x|(y<<8);
break;
}
- wait_tics(TICS_SP_DEC+2*TICS_INTERNAL_LD);
break;
}
}
@@ -1696,7 +1728,7 @@
f_di (_ushort a1,_uchar t1,_ushort a2,_uchar t2)
{
a1=a1;t1=t1;a2=a2;t2=t2;
- if (cpu_pin[wait])
+ if (cpu_is_in_disassemble)
return dis(I_DI);
else
IFF1=IFF2=0;
@@ -1708,7 +1740,7 @@
f_ei (_ushort a1,_uchar t1,_ushort a2,_uchar t2)
{
a1=a1;t1=t1;a2=a2;t2=t2;
- if (cpu_pin[wait])
+ if (cpu_is_in_disassemble)
return dis(I_EI);
else
IFF0=1; /* IFF1=IFF2=1; */
@@ -1716,16 +1748,26 @@
}
+static _uchar tbit(_uchar a1,_uchar a2)
+{
+ set_flag(a1&(1<>4 | (a&15)<<4;
- write_memo(ADDR,a);
set_flag(F_NH);
set_flag(F_NN);
set_flag(A?F_NZ:F_Z);
set_flag((A&128)?F_M:F_P);
__parity(A);
wait_tics(TICS_HALVE_SWAP);
+ write_memo(ADDR,a);
}
return 0;
}
@@ -2045,7 +2081,7 @@
_uchar a, d;
a1=a1;t1=t1;a2=a2;t2=t2;
- if(cpu_pin[wait])
+ if(cpu_is_in_disassemble)
return dis(I_RLD);
else
{
@@ -2053,15 +2089,16 @@
a=A;
A&=0xf0;
d= read_memo(ADDR);
- A+=(d&0xf0)>>4;
+ if (cpu_pin[busrq]) acknowledge_bus_request();
+ A|=(d&0xf0)>>4;
a= d<<4 | (a&15);
- write_memo(ADDR,a);
set_flag(F_NH);
set_flag(F_NN);
set_flag(A?F_NZ:F_Z);
set_flag((A&128)?F_M:F_P);
__parity(A);
wait_tics(TICS_HALVE_SWAP);
+ write_memo(ADDR,a);
}
return 0;
}
@@ -2075,7 +2112,7 @@
a1=a1;a2=a2;t1=t1;t2=t2;
- if(cpu_pin[wait])
+ if(cpu_is_in_disassemble)
return str;
else
{
@@ -2091,8 +2128,8 @@
set_flag(F_NN);
set_flag(F_NH);
set_flag((B|C)?F_PE:F_PO);
- if (rep && (B|C)) add_to_pc(-2);
wait_tics(TICS_INC_DEC_16);
+ if (rep && (B|C) && !cpu_is_in_x_mode) add_to_pc(-2);
}
return 0;
}
@@ -2133,12 +2170,13 @@
a1=a1;a2=a2;t1=t1;t2=t2;
- if(cpu_pin[wait])
+ if(cpu_is_in_disassemble)
return str;
else
{
ADDR= H<<8|L;
a= read_memo(ADDR);
+ if (cpu_pin[busrq]) acknowledge_bus_request();
if (up > 0)
{ L++;H=L?H:H+1; }
else
@@ -2148,14 +2186,15 @@
h=((int)(A&15)-(a&15))<0;
z=!(A-a);
s=(A-a)&128;
+ wait_tics(TICS_CPDI);
set_flag(z?F_Z:F_NZ);
set_flag(s?F_M:F_P);
set_flag(h?F_H:F_NH);
set_flag(F_N);
set_flag((B|C)?F_PE:F_PO);
- if (rep && (B|C) && !z) add_to_pc(-2);
wait_tics(TICS_INC_DEC_16);
+ if (rep && (B|C) && !z && !cpu_is_in_x_mode) add_to_pc(-2);
}
return 0;
}
@@ -2193,7 +2232,7 @@
a1=a1;a2=a2;t1=t1;t2=t2;
- if(cpu_pin[wait])
+ if(cpu_is_in_disassemble)
return str;
else
{
@@ -2207,9 +2246,9 @@
B--;
set_flag(F_N);
set_flag(B&128?F_M:F_P);
- if (!B) set_flag(F_Z);
- else {set_flag(F_NZ);if(rep) add_to_pc(-2);}
wait_tics(TICS_LATE_ALU);
+ if (!B) set_flag(F_Z);
+ else {set_flag(F_NZ);if(rep && !cpu_is_in_x_mode) add_to_pc(-2);}
}
return 0;
}
@@ -2247,10 +2286,11 @@
a1=a1;a2=a2;t1=t1;t2=t2;
- if(cpu_pin[wait])
+ if(cpu_is_in_disassemble)
return str;
else
{
+ wait_tics(TICS_LATE_ALU);
ADDR= H<<8|L;
a= read_memo(ADDR);
out_byte(C,a);
@@ -2262,8 +2302,7 @@
set_flag(F_N);
set_flag(B&128?F_M:F_P);
if (!B)set_flag(F_Z);
- else {set_flag(F_NZ);if(rep) add_to_pc(-2);}
- wait_tics(TICS_LATE_ALU);
+ else {set_flag(F_NZ);if(rep && !cpu_is_in_x_mode) add_to_pc(-2);}
}
return 0;
}
@@ -2297,5 +2336,5 @@
f_nop2 (_ushort a1,_uchar t1,_ushort a2,_uchar t2)
{
a1=a1;t1=t1;a2=a2;t2=t2;
- return cpu_pin[wait] ? dis(I_ILLEGAL) : 0;
+ return cpu_is_in_disassemble ? dis(I_ILLEGAL) : 0;
}
diff -N -r -u z80-asm-2.3/execute_token z80-asm-2.3.7/execute_token
--- z80-asm-2.3/execute_token 2004-02-24 20:06:00.000000000 +0100
+++ z80-asm-2.3.7/execute_token 2005-06-07 11:40:44.000000000 +0200
@@ -16,15 +16,17 @@
/* special tics */
-#define TICS_LD_SP 2
-#define TICS_LD_IR 1
-#define TICS_SP_DEC 1
-#define TICS_HALVE_SWAP 4
-#define TICS_JR 5 /* calculate PC */
-#define TICS_INC_DEC_16 2
-#define TICS_IXY_PLUS 5 /* calculate IX+disp */
-#define TICS_FLAG 1
-#define TICS_LATE_ALU 1 /* dec/inc 8bit or rotate/shift in no refresh */
-#define TICS_ADD_SUB_16 (3+4)
-#define TICS_INTERNAL_LD 1 /* used by ex (sp), HL */
+#define TICS_LD_SP 2
+#define TICS_LD_IR 1
+#define TICS_SP_DEC 1
+#define TICS_CPDI 3 /* calculate flags & DEC 16 */
+#define TICS_HALVE_SWAP 4 /* calculate RRL RRD byte swap */
+#define TICS_JR 5 /* calculate PC */
+#define TICS_INC_DEC_16 2
+#define TICS_IXY_PLUS 5 /* calculate IX+disp */
+#define TICS_FLAG 1
+#define TICS_LATE_ALU 1 /* dec/inc 8bit or rotate/shift in no refresh */
+#define TICS_ADD_SUB_16_PRE 4
+#define TICS_ADD_SUB_16_POST 3
+#define TICS_INTERNAL_LD 1 /* used by ex (sp), HL */
#endif
diff -N -r -u z80-asm-2.3/expression.c z80-asm-2.3.7/expression.c
--- z80-asm-2.3/expression.c 2005-06-01 15:49:54.000000000 +0200
+++ z80-asm-2.3.7/expression.c 2005-06-08 12:13:51.000000000 +0200
@@ -393,11 +393,6 @@
{ if (!is_in_table(txt+a,t,value,lineno))
{ if (pruchod==1)
*value=get_current_address();
-#ifdef ONLY_EXPLICIT_RESOLVED
- else if (no_cycle_detected() &&
- !parse_expr(get_last_expr_from_table(), value))
- define_last_expr_in_table(*value);
-#endif
else
{ ret=-LBNO; goto finish; }
undef=1;
diff -N -r -u z80-asm-2.3/hardware/Makefile z80-asm-2.3.7/hardware/Makefile
--- z80-asm-2.3/hardware/Makefile 2005-04-25 10:39:25.000000000 +0200
+++ z80-asm-2.3.7/hardware/Makefile 2006-02-06 14:45:50.621202285 +0100
@@ -21,14 +21,18 @@
MON=monitor_cpu.exe
endif
-CFLAGS=-O2 -Wall -D$(SYSTEM) -W -Wstrict-prototypes -Wno-parentheses -fomit-frame-pointer -malign-functions=0
+CC= gcc
+CFLAGS=-O2 -Wall -D$(SYSTEM) $(DEFINES) -W -Wstrict-prototypes \
+ -Wno-parentheses -fomit-frame-pointer -falign-functions=0
LDFLAGS=
-all: $(CLK) $(LCD) $(MKP) $(IOP) $(MON) quartz.o daisy_chain.o z80-ctc.o
+all: $(CLK) $(LCD) $(MKP) $(IOP) $(MON) quartz.o daisy_chain.o z80-ctc.o \
+ port_buffer.o analyzer.o ssl_zds.o
-hard.a: quartz.o daisy_chain.o z80-ctc.o
+hard.a: quartz.o daisy_chain.o z80-ctc.o port_buffer.o analyzer.o ssl_zds.o
$(RM) hard.a
- ar rcs hard.a quartz.o daisy_chain.o z80-ctc.o
+ ar rcs hard.a quartz.o daisy_chain.o z80-ctc.o port_buffer.o analyzer.o \
+ ssl_zds.o
clean:
$(RM) hard.a
@@ -39,22 +43,28 @@
$(RM) $(IOP)
$(RM) $(MON)
-lcd_display.o: lcd_display.c ../console.h ../console_token ../z80-cpu.h
+lcd_display.o: lcd_display.c ../console.h ../console_token ../z80-cpu.h ../z80-global
-hardware_clock.o: hardware_clock.c ../z80-cpu.h
+hardware_clock.o: hardware_clock.c ../z80-cpu.h ../z80-global
-make_ports.o: make_ports.c ../z80-cpu.h
+make_ports.o: make_ports.c ../z80-cpu.h ../z80-global
-port_io.o: port_io.c ../z80-cpu.h
+port_io.o: port_io.c ../z80-cpu.h ../z80-global
quartz.o: quartz.c z80-ctc.h
-daisy_chain.o: daisy_chain.c ../z80-cpu.h
+daisy_chain.o: daisy_chain.c ../z80-cpu.h ../z80-global
z80-ctc.o: z80-ctc.c ../z80-global daisy_chain.h
-$(LCD): lcd_display.o ../cpu.a ../console.o ../asm.a hard.a
- gcc -lc -o $(LCD) lcd_display.o ../cpu.a ../console.o ../asm.a hard.a
+port_buffer.o: port_buffer.c ../z80-mon.h ../z80-cpu.h ../z80-global
+
+analyzer.o: analyzer.c ../z80-cpu.h ../z80-global
+
+ssl_zds.o: ssl_zds.c ../z80-cpu.h ../z80-global zds_token
+
+$(LCD): lcd_display.o ../dummy.o ../cpu.a ../console.o ../asm.a hard.a
+ gcc -lc -o $(LCD) lcd_display.o ../dummy.o ../cpu.a ../console.o ../asm.a hard.a
$(CLK): hardware_clock.o
gcc -lc -o $(CLK) hardware_clock.o
$(MKP): make_ports.o
diff -N -r -u z80-asm-2.3/hardware/README z80-asm-2.3.7/hardware/README
--- z80-asm-2.3/hardware/README 2005-06-02 18:24:58.000000000 +0200
+++ z80-asm-2.3.7/hardware/README 2005-06-10 18:51:58.000000000 +0200
@@ -1,23 +1,30 @@
Only in this directory hardware further auxilary programs may be maintained.
-If z80-mon is running, the files .CPU and .Z80_ports are updated by z80-mon.
-Thus, asynchronly other tasks/threads may use these files to read the Z80-CPU
-status via .CPU or even exchange data with the Z80-CPU or other hardware
+If z80-mon is running, the files .CPU and --- in the case hardware/port_buffer
+is linked to z80-mon --- .Z80_ports are updated by z80-mon.
+Asynchronly other tasks/threads may use these files to read the Z80-CPU status
+via .CPU or even exchange data with the Z80-CPU or other hardware
components via .Z80_ports . The following first five example programs
demonstrate this technique using this two interface files.
-In contrast the three last example sources are linked into z80-mon if this
+In contrast the five last example sources are linked into z80-mon if this
is enabled in the Makefile. They represent true real-world hardware which runs
-synchroniously with the z80-mon. Typically neccessary calls are included via
-#defines in z80-mon.c , z80-cpu.c and hardware/quartz.c .
+synchroniously with the z80-mon. Typically necessary calls are included via
+#defines in z80-mon.c , hardware/system_wired , hardware/includes and
+perhaps in hardware/quartz.c .
In z80-mon.c look at reset_cpu() also to initialize your special hardware if
necessary.
-In z80-cpu.c the function set_cpu_pin may be used for directly wired hardware.
+The file hardware/includes contains all necessary include files for z80-cpu.c
+and z80-mon.c .
+The file hardware/system_wired is appended at the end of the function
+ set_cpu_pin in z80-cpu.c for directly wired hardware.
In hardware/quartz.c the single clock ticks can be observed by your hardware!
Moreover the whole data-, address- and controlbus is accessable by including
- z80-cpu.h . Use the cpu-pins busrq and busack to get/release bus control.
+ z80-cpu.h in your special hardware emulation. Use the cpu-pins busrq and
+ busack to get/check bus control. To manipulate the busses put your code
+into hardware/bus_masters (don't forget to release bus_req if finished!).
-Firstly there are two example implementations of port usage:
+Firstly there are two example implementations of buffered port usage:
* hardware_clock uses ports 0x1c, 0x1d, 0x1e, 0x1f
to write the current time in seconds elapsed since z80 system start.
@@ -41,14 +48,18 @@
* banks-ti86 defines 16 ROM banks and 8 RAM banks on port 0x05 and 0x06.
-Finally, there are different hardware circuits for Z80-Systems:
+Finally, there are different hardware circuits for Z80-Systems directly wired:
* a quartz (the internal oscillator is a bit faked :)
- * a daisy_chain for interrupt queueing of different hardware compounends
+ * a port_buffer buffering the last value for each port (to enable asychcron
+ access by external programs)
+ * a daisy_chain for interrupt queueing of different hardware components
+
+ * a simple logic analyzer to observe the Z80-CPU pins with tick resolution
* a Z80-CTC: you should improve and debugg it [synchronized with quartz] :)
Have fun,
-2005-06-02
+2005-06-10
diff -N -r -u z80-asm-2.3/hardware/analyzer.c z80-asm-2.3.7/hardware/analyzer.c
--- z80-asm-2.3/hardware/analyzer.c 1970-01-01 01:00:00.000000000 +0100
+++ z80-asm-2.3.7/hardware/analyzer.c 2005-06-06 11:02:29.000000000 +0200
@@ -0,0 +1,41 @@
+#include
+#include "../z80-cpu.h"
+
+static FILE *fp;
+static unsigned m1_counter;
+static bool last_m1;
+
+static char* to_bin(unsigned value, unsigned len)
+{
+static char number[33];
+number[len]=0;
+while (len--)
+{
+ number[len]= value&1 ? '1' : '0';
+ value >>= 1;
+}
+return number;
+}
+
+unsigned reset_analyzer(char *filename)
+{
+fp = fopen(filename,"wb");
+return !fp;
+}
+
+void send_pulse_to_analyzer(void)
+{
+fprintf(fp,"%16s(%4x) ", to_bin(ADDRESS,16), (unsigned)ADDRESS );
+fprintf(fp,"%8s(%2x) %c%c%c%c%c ", to_bin(DATA,8), (unsigned)DATA,
+ '0'+cpu_pin[rd],
+ '0'+cpu_pin[wr], '0'+cpu_pin[mreq], '0'+cpu_pin[iorq], '0'+cpu_pin[m1] );
+fprintf(fp," %c%c %c%c%c %c%c %c ",
+ '0'+cpu_pin[busrq],'0'+cpu_pin[busack],'0'+cpu_pin[wait],'0'+cpu_pin[halt],
+ '0'+cpu_pin[reset],'0'+IFF3,'0'+cpu_pin[inter],'0'+cpu_pin[rfsh]);
+if (cpu_pin[m1] && !last_m1)
+ m1_counter++;
+last_m1=cpu_pin[m1];
+fprintf(fp," %7lu %6lu %6u",ticks,cycles-1,m1_counter);
+fprintf(fp,"\n");
+fflush(fp);
+}
diff -N -r -u z80-asm-2.3/hardware/analyzer.h z80-asm-2.3.7/hardware/analyzer.h
--- z80-asm-2.3/hardware/analyzer.h 1970-01-01 01:00:00.000000000 +0100
+++ z80-asm-2.3.7/hardware/analyzer.h 2005-06-04 15:19:31.000000000 +0200
@@ -0,0 +1,7 @@
+#ifndef __ANALZER_H
+#define __ANALZER_H
+
+extern void send_pulse_to_analyzer(void);
+extern unsigned reset_analyzer(char *filename);
+
+#endif
diff -N -r -u z80-asm-2.3/hardware/banks-sharp-pc-1600 z80-asm-2.3.7/hardware/banks-sharp-pc-1600
--- z80-asm-2.3/hardware/banks-sharp-pc-1600 2004-02-27 21:10:48.000000000 +0100
+++ z80-asm-2.3.7/hardware/banks-sharp-pc-1600 2006-06-28 19:21:16.169831693 +0200
@@ -10,9 +10,9 @@
r 10 14 pc1600_rom3b.bin
- xx 14 -
#addr port mask ids
- xx 3D 4 10,03
-4000 31 0E 00,01,02,03,04,05,06,07
-8000 31 70 00,01,02,03,04,05,06,07
+ xx 61 4 10,03
+4000 49 0E 00,01,02,03,04,05,06,07
+8000 49 70 00,01,02,03,04,05,06,07
# PORT 28 selects a bank into 0x8000-0xBFFF, bank 2+3 changable
diff -N -r -u z80-asm-2.3/hardware/banks-ti83 z80-asm-2.3.7/hardware/banks-ti83
--- z80-asm-2.3/hardware/banks-ti83 2004-02-27 15:39:10.000000000 +0100
+++ z80-asm-2.3.7/hardware/banks-ti83 2006-06-28 19:22:12.472522229 +0200
@@ -16,5 +16,5 @@
r 0E 14 ti83_romE.bin
r 0F 14 ti83_romF.bin
#addr port mask ids
- 0000 - 00 00
- 4000 05 0F 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F
+ 0000 - 00 00
+ 4000 5 0F 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F
diff -N -r -u z80-asm-2.3/hardware/banks-ti86 z80-asm-2.3.7/hardware/banks-ti86
--- z80-asm-2.3/hardware/banks-ti86 2004-02-27 21:28:18.000000000 +0100
+++ z80-asm-2.3.7/hardware/banks-ti86 2006-06-28 19:21:49.153064544 +0200
@@ -24,9 +24,9 @@
+ 46 14 -
+ 47 14 -
#addr port mask ids
- 0000 - 00 00
- 4000 05 4F 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,
+ 0000 - 00 00
+ 4000 5 4F 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,
40,41,42,43,44,45,46,47
- 8000 06 4F 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,
+ 8000 6 4F 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,
40,41,42,43,44,45,46,47
- C000 - 00 40
+ C000 - 00 40
diff -N -r -u z80-asm-2.3/hardware/includes z80-asm-2.3.7/hardware/includes
--- z80-asm-2.3/hardware/includes 1970-01-01 01:00:00.000000000 +0100
+++ z80-asm-2.3.7/hardware/includes 2005-06-13 22:02:19.000000000 +0200
@@ -0,0 +1,9 @@
+#ifdef Z80_CTC
+#include "z80-ctc.h"
+#endif
+#ifdef LOGIC_ANALYZER
+#include "analyzer.h"
+#endif
+#ifdef SSL_ZDS
+#include "ssl_zds.h"
+#endif
diff -N -r -u z80-asm-2.3/hardware/port_buffer.c z80-asm-2.3.7/hardware/port_buffer.c
--- z80-asm-2.3/hardware/port_buffer.c 1970-01-01 01:00:00.000000000 +0100
+++ z80-asm-2.3.7/hardware/port_buffer.c 2006-02-06 16:04:31.711597238 +0100
@@ -0,0 +1,53 @@
+#include
+#include "../z80-cpu.h"
+#include "../z80-mon.h"
+
+#ifdef OLD_STYLE
+static FILE *ports;
+static char buffer[256];
+#endif
+
+int
+init_port_buffer(void)
+{
+#ifdef OLD_STYLE
+ ports= fopen(Z80_PORTS,"r+b"); /* read_writable_binary file */
+ if (ports)
+ if (256 != fread(buffer,1,256,ports))
+ { fclose(ports), ports= (FILE*)0; }
+ return !ports;
+#else
+ return 0;
+#endif
+}
+
+
+#ifdef OLD_STYLE
+int close_port_buffer(void)
+{
+ return ports ? fclose(ports) : 0;
+}
+#endif
+
+
+void send_pulse_to_port_buffer(void)
+{
+#ifdef OLD_STYLE
+ if (!ports)
+ ;
+ else if (cpu_pin[iorq] && cpu_pin[wr])
+ { int id= ADDRESS&255, i;
+ if (buffer[id] != DATA)
+ { i=fseek(ports,(long)id,SEEK_SET);
+ if (i || 1 != fwrite(&DATA,1,1,ports))
+ error(i,"hardware malfunction","port write:");
+ else
+ buffer[id]=DATA;
+ fflush(ports);
+ }
+ }
+ else if (cpu_pin[iorq] && cpu_pin[rd])
+ { DATA= buffer[ADDRESS&255];
+ }
+#endif
+}
diff -N -r -u z80-asm-2.3/hardware/port_buffer.h z80-asm-2.3.7/hardware/port_buffer.h
--- z80-asm-2.3/hardware/port_buffer.h 1970-01-01 01:00:00.000000000 +0100
+++ z80-asm-2.3.7/hardware/port_buffer.h 2006-02-06 15:59:30.934034882 +0100
@@ -0,0 +1,14 @@
+#ifndef __PORT_BUFFER_H
+#define __PORT_BUFFER_H
+
+#include "../z80-global"
+
+
+extern int init_port_buffer(void);
+#ifdef OLD_STYLE
+extern int close_port_buffer(void);
+#endif
+
+extern void send_pulse_to_port_buffer(void);
+
+#endif
diff -N -r -u z80-asm-2.3/hardware/quartz.c z80-asm-2.3.7/hardware/quartz.c
--- z80-asm-2.3/hardware/quartz.c 2005-06-03 18:43:30.000000000 +0200
+++ z80-asm-2.3.7/hardware/quartz.c 2005-06-10 15:13:07.000000000 +0200
@@ -1,9 +1,16 @@
+#include "includes"
+
void clock_oscillator(void)
{ /* here we can send one tic to other (not CPU) hardware */
#ifdef Z80_CTC
-#include "z80-ctc.h"
send_pulse_to_ctc(clk);
#endif
+#ifdef LOGIC_ANALYZER
+ send_pulse_to_analyzer();
+#endif
+#ifdef PORT_BUFFER
+ send_pulse_to_port_buffer();
+#endif
}
diff -N -r -u z80-asm-2.3/hardware/ssl_zds.c z80-asm-2.3.7/hardware/ssl_zds.c
--- z80-asm-2.3/hardware/ssl_zds.c 1970-01-01 01:00:00.000000000 +0100
+++ z80-asm-2.3.7/hardware/ssl_zds.c 2005-06-14 13:06:47.000000000 +0200
@@ -0,0 +1,26 @@
+#include "../z80-cpu.h"
+#include "zds_token"
+
+static unsigned _m1_counter = 0;
+
+void set_ssl_trigger(void)
+{
+ _m1_counter = 3;
+}
+
+void reset_ssl_trigger(void)
+{
+ _m1_counter = 0;
+}
+
+void trigger_ssl(void)
+{
+ if (_m1_counter > 0)
+ if (--_m1_counter == 0)
+ IFF3 = 1;
+}
+
+bool is_ssl_port(unsigned char port)
+{
+ return port == SSL_PORT ;
+}
diff -N -r -u z80-asm-2.3/hardware/ssl_zds.h z80-asm-2.3.7/hardware/ssl_zds.h
--- z80-asm-2.3/hardware/ssl_zds.h 1970-01-01 01:00:00.000000000 +0100
+++ z80-asm-2.3.7/hardware/ssl_zds.h 2005-06-13 22:29:14.000000000 +0200
@@ -0,0 +1,11 @@
+#ifndef __SSL__ZDS_H
+#define __SSL__ZDS_H
+
+#include "../z80-global"
+
+extern void trigger_ssl(void);
+extern void reset_ssl_trigger(void);
+extern void set_ssl_trigger(void);
+extern bool is_ssl_port(unsigned char port);
+
+#endif
diff -N -r -u z80-asm-2.3/hardware/system_wired z80-asm-2.3.7/hardware/system_wired
--- z80-asm-2.3/hardware/system_wired 1970-01-01 01:00:00.000000000 +0100
+++ z80-asm-2.3.7/hardware/system_wired 2005-06-13 22:41:00.000000000 +0200
@@ -0,0 +1,18 @@
+#ifdef Z80_CTC
+ if (p == m1)
+ set_ctc_pin(ctc_m1,level);
+ if (p == reset)
+ set_ctc_pin(ctc_reset,level);
+ if (p == iorq && cpu_pin[wr] && is_ctc_port(ADDRESS&255) )
+ set_ctc_pin(ctc_rd,!level);
+#endif
+#ifdef PORT_BUFFER
+#endif
+#ifdef SSL_ZDS
+ if (p == m1 && level)
+ trigger_ssl();
+ if (p == reset && level)
+ reset_ssl_trigger();
+ if (p == iorq && cpu_pin[wr] && is_ssl_port(ADDRESS&255) && level)
+ set_ssl_trigger();
+#endif
diff -N -r -u z80-asm-2.3/hardware/z80-ctc.c z80-asm-2.3.7/hardware/z80-ctc.c
--- z80-asm-2.3/hardware/z80-ctc.c 2005-06-03 18:14:51.000000000 +0200
+++ z80-asm-2.3.7/hardware/z80-ctc.c 2005-06-08 17:42:22.000000000 +0200
@@ -1,4 +1,4 @@
-#define CTC_LOWEST_PORT 0xcc
+#define CTC_LOWEST_PORT (0xcc&~3)
#include
#include "../z80-cpu.h"
@@ -19,7 +19,7 @@
bool is_ctc_port(unsigned char port)
{
- return port >= CTC_LOWEST_PORT && port < CTC_LOWEST_PORT+4 ;
+ return port>>2 == CTC_LOWEST_PORT>>2 ; /* 4 successive ports */
}
@@ -70,32 +70,19 @@
}
-void send_pulse_to_ctc(unsigned channel)
-{
- if (channel >= 4)
- { int i;
- ticks_copy++;
- for (i=0;i<4;i++)
- if ((cbyte[i]&1) && !(cbyte[i]&64))
- if (--counter[i] == 0)
- action(i);
-
- }
- else if ((cbyte[channel]&1) && (cbyte[channel]&64))
- {
- if (--counter[channel] == 0)
- action(channel);
- }
-}
-
-
unsigned char read_word(unsigned char port)
{
unsigned char byte;
+#ifndef INDIRECT_CTC
+ byte= DATA;
+#else
+ if (!fp)
+ return 0xff;
fflush(fp);
if (fseek(fp,(long)port,SEEK_SET))
return 0xff; /* hardware malfunction */
fread(&byte,1,1,fp);
+#endif
return byte;
}
@@ -125,6 +112,27 @@
}
+void send_pulse_to_ctc(unsigned channel)
+{
+ if (channel >= 4)
+ { int i;
+ ticks_copy++;
+ for (i=0;i<4;i++)
+ if ((cbyte[i]&1) && !(cbyte[i]&64))
+ if (--counter[i] == 0)
+ action(i);
+
+ }
+ else if ((cbyte[channel]&1) && (cbyte[channel]&64))
+ {
+ if (--counter[channel] == 0)
+ action(channel);
+ }
+ if ((ADDRESS&255) == CTC_LOWEST_PORT+cs && cpu_pin[iorq] && !pin[ctc_rd])
+ react(read_word(CTC_LOWEST_PORT+cs));
+}
+
+
void set_ctc_pin(unsigned c_pin, bit level)
{
pin[c_pin&7] = level;
@@ -138,7 +146,7 @@
else
switch (c_pin)
{
- case ctc_rd: react(read_word(CTC_LOWEST_PORT+cs)); break;
+ case ctc_rd: break;
case ctc_m1: break;
case ctc_ce: break;
case ctc_iorq: break;
diff -N -r -u z80-asm-2.3/hardware/zds_token z80-asm-2.3.7/hardware/zds_token
--- z80-asm-2.3/hardware/zds_token 1970-01-01 01:00:00.000000000 +0100
+++ z80-asm-2.3.7/hardware/zds_token 2005-06-13 18:08:41.000000000 +0200
@@ -0,0 +1,21 @@
+#ifndef __ZDS_PORTS_H
+#define __ZDS_PORTS_H
+
+/* SIO B Data */
+#define TRM_DATA 0xe5
+
+/* SIO B Control */
+#define TRM_CTRL 0xe7
+
+/* NMI-Trigger for Single Step */
+#define SSL_PORT 0xee
+
+/* Floppy Motorport */
+#define FLP_MOT 0xd2
+
+/* Terminal Device
+ /dev/tty12 for SuSE, Novell
+ /dev/tty6 for Knoppix */
+#define TERM "/dev/tty12"
+
+#endif
diff -N -r -u z80-asm-2.3/hash.c z80-asm-2.3.7/hash.c
--- z80-asm-2.3/hash.c 2005-05-31 19:45:52.000000000 +0200
+++ z80-asm-2.3.7/hash.c 2005-06-08 12:13:20.000000000 +0200
@@ -162,7 +162,6 @@
if (value)
{ if (!just_ele->expr)
*value=just_ele->address;
-#ifndef ONLY_EXPLICIT_RESOLVED
else if (compile_pass() != 1)
{ if (just_ele->flag&1)
return 0;
@@ -175,7 +174,6 @@
free(just_ele->expr);
just_ele->expr=NULL;
}
-#endif
else
return 0;
}
@@ -190,34 +188,6 @@
}
-#ifdef ONLY_EXPLICIT_RESOLVED
-int
-no_cycle_detected(void)
-{
- if (just_ele->flag&1)
- return 0;
- just_ele->flag |= 1;
- return 1;
-}
-
-
-char*
-get_last_expr_from_table(void)
-{
- return just_ele->expr;
-}
-
-void
-define_last_expr_in_table(int value)
-{
- just_ele->flag &= ~1;
- just_ele->address= value;
- free(just_ele->expr);
- just_ele->expr=0;
-}
-#endif
-
-
/* initializes hash table */
void
diff -N -r -u z80-asm-2.3/hash.h z80-asm-2.3.7/hash.h
--- z80-asm-2.3/hash.h 2005-05-31 13:14:48.000000000 +0200
+++ z80-asm-2.3.7/hash.h 2005-06-08 12:13:28.000000000 +0200
@@ -31,11 +31,6 @@
extern bool last_label_reusable(void);
-#ifdef ONLY_EXPLICIT_RESOLVED
-extern char* get_last_expr_from_table(void);
-extern void define_last_expr_in_table(int value);
-#endif
-
/* initializes hash table */
extern void hash_table_init(void);
diff -N -r -u z80-asm-2.3/instr.c z80-asm-2.3.7/instr.c
--- z80-asm-2.3/instr.c 2005-05-27 12:17:55.000000000 +0200
+++ z80-asm-2.3.7/instr.c 2005-06-09 13:27:15.000000000 +0200
@@ -3,7 +3,8 @@
#include "z80-cpu.h"
#include "instr_token"
-/* Be sure table is in alphabetical order in its first attribute !!! */
+/* Be sure table is in alphabetical order in its first attribute !! */
+/* we need this feature for binary search in convert() in asm.c */
const struct seznam_type instruction[N_INSTRUCTIONS]={
{"ADC", I_ADC},
diff -N -r -u z80-asm-2.3/interrupt.c z80-asm-2.3.7/interrupt.c
--- z80-asm-2.3/interrupt.c 2005-06-02 15:53:39.000000000 +0200
+++ z80-asm-2.3.7/interrupt.c 2005-06-09 13:05:13.000000000 +0200
@@ -64,22 +64,22 @@
IFF0= a&1;
IFF1= a>>1&1;
IFF2= a>>2&1;
- /* set_cpu_pin(halt,a>>3&1); */
+ set_cpu_pin(halt,a>>3&1);
IM= a>>4 &3;
- /* set_cpu_pin(iorq,a>>6&1); */
- /* set_cpu_pin(inter,a>>7&1); */
+ /* set_cpu_pin(wait,a>>6&1); */
+ set_cpu_pin(inter,a>>7&1);
t = buffer[i++];
t |= buffer[i++]<<8;
t |= buffer[i++]<<16;
t |= buffer[i++]<<24;
set_tics(t);
j += fread(&a,1,1,fp);
- /* set_cpu_pin(rd,a>>0&1); */
- /* set_cpu_pin(wr,a>>1&1); */
- /* set_cpu_pin(m1,a>>2&1); */
- /* set_cpu_pin(mreq,a>>3&1); */
- /* set_cpu_pin(wait,a>>4&1); */
- /* set_cpu_pin(rfsh,a>>5&1); */
+ set_cpu_pin(rd,a>>0&1);
+ set_cpu_pin(wr,a>>1&1);
+ set_cpu_pin(iorq,a>>2&1);
+ set_cpu_pin(mreq,a>>3&1);
+ set_cpu_pin(m1,a>>4&1);
+ set_cpu_pin(rfsh,a>>5&1);
/* set_cpu_pin(busrq,a>>6&1); */
/* set_cpu_pin(busack,a>>7&1); */
return j != 33;
@@ -129,7 +129,7 @@
a= (IFF0&1) | (IFF1&1)<<1 | (IFF2&1)<<2;
a|= (cpu_pin[halt]&1) << 3;
a|= (IM&3) << 4;
- a|= (cpu_pin[iorq]&1) << 6;
+ a|= (cpu_pin[wait]&1) << 6;
a|= (cpu_pin[inter]&1) << 7;
i=0;
buffer[i++]= I;
@@ -143,9 +143,9 @@
j += fwrite(buffer,1,8,fp);
a = cpu_pin[rd]&1;
a|= (cpu_pin[wr]&1) << 1;
- a|= (cpu_pin[m1]&1) << 2;
+ a|= (cpu_pin[iorq]&1) << 2;
a|= (cpu_pin[mreq]&1) << 3;
- a|= (cpu_pin[wait]&1) << 4;
+ a|= (cpu_pin[m1]&1) << 4;
a|= (cpu_pin[rfsh]&1) << 5;
a|= (cpu_pin[busrq]&1) << 6;
a|= (cpu_pin[busack]&1) << 7;
@@ -177,6 +177,7 @@
signal(signo,interrupt_catcher);
}
+
void init_interrupt_handling(void)
{
int i;
@@ -196,6 +197,7 @@
{
}
+
void init_interrupt_handling(void)
{
inter_mask=0;
@@ -209,7 +211,7 @@
{
#ifdef UNIX
if (inter_mask & 1<= 256 || p || tok2[0]=='-' || tok2[0]=='+')
+ if (portno >= 256 || p && *p || tok2[0]=='-' || tok2[0]=='+')
{ fprintf(stderr,ERROR_MAP" invalid port_id\n",k);
continue;
}
@@ -337,11 +338,17 @@
{ fprintf(stderr,ERROR_MAP" offset/port_no not ascending sorted\n",k);
continue;
}
- mask = strtoul(tok3,&p,0);
- if (mask >= 256 || p || tok3[0]=='-' || tok3[0]=='+')
+ for (i=0;i<2;i++)
+ if (tok3[i] >= '0' && tok3[i] <= '9') continue;
+ else if (tok3[i] >= 'a' && tok3[i] <= 'f') continue;
+ else if (tok3[i] >= 'A' && tok3[i] <= 'F') continue;
+ else
+ break;
+ if (i != 2)
{ fprintf(stderr,ERROR_MAP" invalid mask\n",k);
continue;
}
+ sscanf(tok3,"%x",&mask);
for (j=0;tok4[j];j++)
if (j%3 == 2 && tok4[j]!=',')
break;
@@ -353,7 +360,7 @@
pre_id= 0;
for (j=0;j= 256 || (*p != ',' && p) || tok4[3*j]=='-' || tok4[3*j]=='+')
+ if (id >= 256 || (p && *p && *p != ',') || tok4[3*j]=='-' || tok4[3*j]=='+')
{ fprintf(stderr,ERROR_MAP" invalid %u-th bank_id\n",k,j+1);
break;
}
@@ -412,16 +419,19 @@
_uchar memory_at(unsigned short index)
{
- return memory[index];
+ return !no_maps ? memory[index] :
+ !all_readable && (access_type>>(2*(index>>delta))&1) ?
+ empty : *(address_map[index>>delta]+index) ;
}
_uchar read_memo(unsigned short index)
{
- ADDRESS=index;
+ if (cpu_pin[busrq]) acknowledge_bus_request();
+ if(!cpu_is_in_disassemble) ADDRESS=index;
set_cpu_pin(rd,1);
set_cpu_pin(mreq,1);
- if(!cpu_pin[wait]) wait_tics(TICS_MEMO);
+ if(!cpu_is_in_disassemble) wait_tics(TICS_MEMO);
DATA= (!no_maps ? memory[index] :
!all_readable && (access_type>>(2*(index>>delta))&1) ?
empty : *(address_map[index>>delta]+index)) ;
@@ -431,33 +441,40 @@
}
-_uchar read_addr(unsigned short index)
+_uchar read_opcode(unsigned short index, bool set_m1)
{
- ADDRESS=index;
+ if (cpu_pin[busrq]) acknowledge_bus_request();
+ if (set_m1) set_cpu_pin(m1,1);
+ if(!cpu_is_in_disassemble) ADDRESS=index;
set_cpu_pin(rd,1);
- if(!cpu_pin[wait]) wait_tics(TICS_MEMO);
- if (cpu_pin[iorq])
+ if (io_address)
+ {
DATA= *(io_address+index);
+ if(!cpu_is_in_disassemble) wait_tics(TICS_MEMO);
+ }
else
{
set_cpu_pin(mreq,1);
DATA= (!no_maps ? memory[index] :
!all_readable && (access_type>>(2*(index>>delta))&1) ?
empty : *(address_map[index>>delta]+index)) ;
+ if(!cpu_is_in_disassemble) wait_tics(TICS_MEMO);
set_cpu_pin(mreq,0);
}
set_cpu_pin(rd,0);
+ if (set_m1) set_cpu_pin(m1,0);
return DATA;
}
void write_memo(unsigned short index, unsigned char data)
{
- ADDRESS=index;
+ if (cpu_pin[busrq]) acknowledge_bus_request();
+ if(!cpu_is_in_disassemble) ADDRESS=index;
DATA=data;
set_cpu_pin(wr,1);
set_cpu_pin(mreq,1);
- if(!cpu_pin[wait]) wait_tics(TICS_MEMO);
+ if(!cpu_is_in_disassemble) wait_tics(TICS_MEMO);
if (!no_maps)
memory[index]=DATA;
else if (!(access_type>>(2*(index>>delta))&2))
@@ -471,7 +488,7 @@
{
_uchar previous;
set_cpu_pin(wr,1);
- if (cpu_pin[iorq])
+ if (io_address)
{ previous= *(io_address+index);
*(io_address+index) = data;
}
diff -N -r -u z80-asm-2.3/memory.h z80-asm-2.3.7/memory.h
--- z80-asm-2.3/memory.h 2005-05-21 21:32:01.000000000 +0200
+++ z80-asm-2.3.7/memory.h 2005-06-10 15:06:34.000000000 +0200
@@ -5,7 +5,7 @@
extern unsigned init_banks(char *rom_path);
extern void reset_banks(void);
-extern unsigned bank_port(unsigned char id);
+extern unsigned bank_port_index(unsigned char id);
extern void switch_bank(_uchar val, unsigned map_no);
extern void set_default_byte(_uchar);
@@ -14,8 +14,11 @@
extern _uchar* io_address;
extern _uchar memory_at(_ushort index);
extern _uchar read_memo(_ushort index);
-extern _uchar read_addr(_ushort index);
+extern _uchar read_opcode(_ushort index, bool set_m1);
extern void write_memo(_ushort index, _uchar data);
+
+/* used in asm.c by compile() respetively out()
+ when called from z80-mon in 'put instruction into memory' */
extern _uchar write_to_memory(_ushort index, _uchar data);
extern unsigned dma_write(_ushort offset, unsigned count, void *from);
diff -N -r -u z80-asm-2.3/ports.c z80-asm-2.3.7/ports.c
--- z80-asm-2.3/ports.c 2005-06-03 18:09:35.000000000 +0200
+++ z80-asm-2.3.7/ports.c 2005-06-10 18:41:45.000000000 +0200
@@ -4,10 +4,11 @@
#include "keyboard.h"
#include "asm_interface.h"
#include "memory.h"
+#include "hardware/port_buffer.h"
-#define TICS_PORT (TICS_MEMO+TICS_WAIT)
-
+#ifdef OLD_STYLE
static FILE *ports;
+#endif
static int fd_out;
static int fd_in;
@@ -16,35 +17,55 @@
int
init_ports(void)
{
+#ifdef OLD_STYLE
char buffer[256];
+#endif
fd_out=fileno(stdout);
fd_in=fileno(stdin);
+#ifdef OLD_STYLE
ports= fopen(Z80_PORTS,"r+b"); /* read_writable_binary file */
if (ports)
if (256 != fread(buffer,1,256,ports))
{ fclose(ports), ports= (FILE*)0; }
return !ports;
+#else
+ return init_port_buffer();
+#endif
}
void
out_byte(unsigned char id, unsigned char data)
{
- ADDRESS = (ADDRESS&~255) | id;
+#ifndef OLD_STYLE
+ int i;
+#endif
+ if (cpu_pin[busrq]) acknowledge_bus_request();
+ if (!cpu_is_in_disassemble) ADDRESS = (ADDRESS&~255) | id;
DATA= data;
set_cpu_pin(wr,1);
set_cpu_pin(iorq,1);
if (id == fd_out)
display_in_line(data);
+#ifdef OLD_STYLE
else if (ports)
{ int i=fseek(ports,(long)id,SEEK_SET);
if (i || 1 != fwrite(&data,1,1,ports))
error(i,"hardware malfunction","port write:");
fflush(ports);
- if (i=bank_port(id))
+ if (i=bank_port_index(id))
switch_bank(data,i);
}
- if (!cpu_pin[wait]) wait_tics(TICS_PORT);
+#else
+ else if (i=bank_port_index(id))
+ switch_bank(data,i);
+#endif
+ if (!cpu_is_in_disassemble)
+ { wait_tics(TICS_MEMO);
+ set_cpu_pin(wait,1);
+ wait_tics(TICS_WAIT);
+ set_cpu_pin(wait,0);
+ }
set_cpu_pin(iorq,0);
set_cpu_pin(wr,0);
}
@@ -52,19 +73,28 @@
void
in_byte(unsigned char id, unsigned char *data)
{
- ADDRESS = (ADDRESS&~255) | id;
+ if (cpu_pin[busrq]) acknowledge_bus_request();
+ if (!cpu_is_in_disassemble) ADDRESS = (ADDRESS&~255) | id;
set_cpu_pin(rd,1);
set_cpu_pin(iorq,1);
if (id == fd_in)
keystrobe(data);
+#ifdef OLD_STYLE
else if (ports)
{ int i; fflush(ports);
i=fseek(ports,(long)id,SEEK_SET);
if (i || 1 != fread(data,1,1,ports))
error(i,"hardware malfunction","port read:");
}
- if (!cpu_pin[wait]) wait_tics(TICS_PORT);
+#endif
DATA= *data;
+ if (!cpu_is_in_disassemble)
+ { wait_tics(TICS_MEMO);
+ set_cpu_pin(wait,1);
+ wait_tics(TICS_WAIT);
+ set_cpu_pin(wait,0);
+ }
+ *data= DATA;
set_cpu_pin(iorq,0);
set_cpu_pin(rd,0);
}
diff -N -r -u z80-asm-2.3/programs/Makefile z80-asm-2.3.7/programs/Makefile
--- z80-asm-2.3/programs/Makefile 2004-03-20 15:41:34.000000000 +0100
+++ z80-asm-2.3.7/programs/Makefile 2006-02-06 14:46:02.500943342 +0100
@@ -1,5 +1,6 @@
RM=rm -f
-CFLAGS=-O2 -Wall -W -Wstrict-prototypes -Wno-parentheses -fomit-frame-pointer -malign-functions=0
+CC= gcc
+CFLAGS=-O2 -Wall -W -Wstrict-prototypes -Wno-parentheses -fomit-frame-pointer -falign-functions=0
LDFLAGS=
all: make_header opcodes
diff -N -r -u z80-asm-2.3/regs.h z80-asm-2.3.7/regs.h
--- z80-asm-2.3/regs.h 2004-03-26 22:25:04.000000000 +0100
+++ z80-asm-2.3.7/regs.h 2006-02-06 12:32:25.303373431 +0100
@@ -3,6 +3,7 @@
#ifndef __REGS_H
#define __REGS_H
+#include "z80-global"
#include "regs_token"
extern unsigned char* const reg_adr[N_8BIT_REGS]; /* 8-bit register address */
diff -N -r -u z80-asm-2.3/z80-asm.c z80-asm-2.3.7/z80-asm.c
--- z80-asm-2.3/z80-asm.c 2005-05-29 12:07:53.000000000 +0200
+++ z80-asm-2.3.7/z80-asm.c 2005-07-15 14:43:53.000000000 +0200
@@ -128,26 +128,33 @@
}
int
-main(int argc,char**argv)
+main(int argc, char **argv)
{
FILE *output;
char *txt=0;
char line[512];
int s,a=0,b,cross=0;
+/* a is used as memory init value */
-for (s=1;s=argc || 1!=sscanf(argv[++s],"%2x",&a))
fprintf(stderr,"Error: option -f needs a hexadecimal argument\n");
+ else
+ b=0, s++;
}
- else if (!strcmp(argv[s]+1,"h")){usage(argv[0]);}
- else if (!strcmp(argv[s]+1,"?")){usage(argv[0]);}
- else if (!strcmp(argv[s]+1,"-")){s++;break;} /* in case filename equals option */
- else fprintf(stderr,"Error: unknown option -%s\n",argv[s]+1);
+ else if (*(argv[s]+b)=='h') {usage(argv[0]);}
+ else if (*(argv[s]+b)=='?') {usage(argv[0]);}
+ else if (*(argv[s]+b)=='-') {s++;break;} /* in case filename equals option */
+ else fprintf(stderr,"Error: unknown option -%s\n",argv[s]+b);
}
if (s == argc) return 0;
diff -N -r -u z80-asm-2.3/z80-cpu.c z80-asm-2.3.7/z80-cpu.c
--- z80-asm-2.3/z80-cpu.c 2005-06-03 18:31:15.000000000 +0200
+++ z80-asm-2.3.7/z80-cpu.c 2006-06-30 17:07:33.447818334 +0200
@@ -1,9 +1,8 @@
#include "z80-global"
+#include "z80-mon.h"
#ifdef FURTHER_HARDWARE
#include "hardware/quartz.h"
-#ifdef Z80_CTC
-#include "hardware/z80-ctc.h"
-#endif
+#include "hardware/includes"
#endif
_uchar F,A,B,C,D,E,H,L;
@@ -14,23 +13,32 @@
_uchar DATA; /* data pins */
_ushort ADDRESS; /* address pins */
bit IFF0, IFF1,IFF2, IFF3; /* internal EI-flipflop & interrupt flip flops */
-enum cpu_control_pin { rd, wr, iorq, mreq, m1, rfsh, halt, wait, inter, reset,
+enum cpu_control_pin { rd, wr, iorq, mreq, m1, inter, halt, wait, reset, rfsh,
busrq, busack };
bit cpu_pin[NO_CPU_CONTROL_PINS];
-unsigned long ticks; /* cycle counter attached to CPU */
+unsigned long ticks; /* clock tick counter attached to CPU */
+unsigned long cycles; /* machine cycle counter attached to CPU */
+
+bool cpu_is_in_disassemble;
+bool cpu_is_in_x_mode;
+static bool busreq_at_last_tick;
void set_tics(unsigned long t)
{ ticks=t;
+ if (!t) cycles=0;
}
void wait_tics(unsigned duration)
{
+ if (duration >= 3 && !cpu_pin[busack])
+ cycles++;
while (duration)
{ /* ONE TIC OCCURS */
+ busreq_at_last_tick = cpu_pin[busrq];
#ifdef FURTHER_HARDWARE
clock_oscillator();
#endif
@@ -42,15 +50,23 @@
void set_cpu_pin(unsigned p, bit level)
{
- if (p >= NO_CPU_CONTROL_PINS)
+ if (p >= NO_CPU_CONTROL_PINS || cpu_is_in_disassemble)
return;
cpu_pin[p]= level;
-#ifdef Z80_CTC
- if (p == m1)
- set_ctc_pin(ctc_m1,level);
- if (p == reset)
- set_ctc_pin(ctc_reset,level);
- if (p == iorq && cpu_pin[wr] && is_ctc_port(ADDRESS&255) )
- set_ctc_pin(ctc_rd,!level);
-#endif
+#include "hardware/system_wired"
+}
+
+
+void acknowledge_bus_request(void)
+{
+ if (cpu_is_in_disassemble || !busreq_at_last_tick)
+ return;
+ while (cpu_pin[busrq])
+ { set_cpu_pin(busack,1);
+#include "hardware/bus_masters"
+ wait_tics(TICS_WAIT);
+ print_ticks(); /** must be exported from z80-mon.c and dummy.c **/
+ }
+ wait_tics(TICS_WAIT);
+ set_cpu_pin(busack,0);
}
diff -N -r -u z80-asm-2.3/z80-cpu.h z80-asm-2.3.7/z80-cpu.h
--- z80-asm-2.3/z80-cpu.h 2005-06-03 18:27:41.000000000 +0200
+++ z80-asm-2.3.7/z80-cpu.h 2006-06-30 17:11:24.134469721 +0200
@@ -19,22 +19,24 @@
wr cpu wants to write data
iorq cpu signals to access external IO
mreq cpu signals to access memory
- m1 machine cycle one (opcode fetch)
+ m1 machine cycle one (together with iorq acknowledges interrupt)
+ inter maskable interrupt pending
halt cpu in halt instruction
wait cpu in wait state
- inter maskable interrupt pending
reset cpu reset requested
+ rfsh cpu signals memory refresh (if mreq is set)
busrq external hardware requests bus control
busack cpu acknowledges bus control
- rfsh cpu signals memory refresh (if mreq is set)
*********************/
-enum cpu_control_pin { rd, wr, iorq, mreq, m1, rfsh, halt, wait, inter, reset,
+enum cpu_control_pin { rd, wr, iorq, mreq, m1, inter, halt, wait, reset, rfsh,
busrq, busack };
-extern bit cpu_pin[NO_CPU_CONTROL_PINS];
+extern const bit cpu_pin[NO_CPU_CONTROL_PINS];
+extern const unsigned long ticks, cycles;
+extern bool cpu_is_in_disassemble, cpu_is_in_x_mode;
extern void set_cpu_pin(unsigned p, bit level);
-extern const unsigned long ticks;
extern void wait_tics(unsigned duration);
extern void set_tics(unsigned long t);
+extern void acknowledge_bus_request(void);
#endif
diff -N -r -u z80-asm-2.3/z80-global z80-asm-2.3.7/z80-global
--- z80-asm-2.3/z80-global 2005-06-02 15:48:28.000000000 +0200
+++ z80-asm-2.3.7/z80-global 2005-06-10 15:09:45.000000000 +0200
@@ -1,9 +1,11 @@
#ifndef __GLOBAL
#define __GLOBAL
+#ifdef OLD_STYLE
#ifndef Z80_PORTS
#define Z80_PORTS ".Z80_ports"
#endif
+#endif
#define _Z80HEADER "Z80ASM\032\n"
diff -N -r -u z80-asm-2.3/z80-mon.c z80-asm-2.3.7/z80-mon.c
--- z80-asm-2.3/z80-mon.c 2005-06-02 18:17:58.000000000 +0200
+++ z80-asm-2.3.7/z80-mon.c 2006-07-03 15:01:10.573843764 +0200
@@ -20,9 +20,7 @@
#include "keyboard.h"
#include "hash.h"
#include "expression.h"
-#ifdef Z80_CTC
-#include "hardware/z80-ctc.h"
-#endif
+#include "hardware/includes"
static _ushort MEMP;
@@ -56,7 +54,7 @@
#define KEYBOARD_MAP_FILE "keyboard_map"
-void warning(char* message)
+static void warning(char* message)
{
static char txt[512];
/* c_bell(); */
@@ -70,7 +68,7 @@
}
-void error_msg(char *line,char* message)
+static void error_msg(char *line,char* message)
{
static char txt[512];
c_bell();
@@ -105,7 +103,7 @@
}
-char
+static char
__printable(char c)
{
return (c>=32&&c<127)?c:'.';
@@ -163,7 +161,7 @@
}
-void
+static void
__print_r16(int x,int y,char *t,int R)
{
char txt[256];
@@ -177,7 +175,7 @@
}
-void
+static void
__print_rr(int x,int y,char *t,int R)
{
char txt[256];
@@ -191,7 +189,7 @@
}
-void
+static void
tobin(char *s,_uchar x)
{
int a;
@@ -201,7 +199,7 @@
}
-void
+static void
__print_x(int x,int y,char *t,_uchar R)
{
char txt[256];
@@ -217,7 +215,7 @@
}
-void
+static void
__print_r(int x,int y,char *t,_uchar R)
{
char txt[256];
@@ -239,7 +237,7 @@
}
-void
+static void
print_generell_regs(void)
{
__print_rr(46,2,"AF",(A<<8)+F);
@@ -273,7 +271,7 @@
}
-void
+static void
print_index_regs(void)
{
__print_r16(56,7,"IX",IX);
@@ -281,7 +279,7 @@
}
-void
+static void
print_sp_and_pc(void)
{
__print_r16(56,9,"SP",SP);
@@ -289,7 +287,7 @@
}
-void
+static void
print_special_regs(void)
{
__print_x(47,21,"I",I);
@@ -297,7 +295,7 @@
}
-void
+static void
print_regs(void)
{
print_generell_regs();
@@ -307,7 +305,7 @@
}
-void
+static void
print_flags(void)
{
char txt[256];
@@ -345,7 +343,7 @@
}
-void
+static void
print_instr(void)
{
_ushort old_pc=PC;
@@ -376,7 +374,7 @@
}
-void
+static void
print_stack(void)
{
char txt[256];
@@ -411,7 +409,7 @@
}
-void
+static void
print_mem(void)
{
char txt[256];
@@ -445,7 +443,7 @@
}
-void
+static void
print_speed(void)
{
c_setcolor(color[STATUS]);
@@ -467,14 +465,14 @@
}
-void
+static void
print_status(void)
{
c_goto(0,23);
c_setcolor(color[STATUS]);
c_print(follow?"FOLLOW ":" ");
c_goto(7,23);
- c_print(!cpu_pin[wait]?"RUN ":" ");
+ c_print(!cpu_is_in_disassemble?"RUN ":" ");
print_speed();
c_setcolor(color[STATUS]);
c_goto(20,23);
@@ -494,13 +492,19 @@
c_setcolor(color[DEFAULT]);
c_goto(41,10);
c_print(txt);
- c_setcolor(color[TOKEN]);
+ c_setcolor(cpu_pin[busack]?color[HOT]:color[TOKEN]);
c_print(" T");
last_ticks=ticks;
+ sprintf(txt,"%10lu",cycles);
+ c_setcolor(color[DEFAULT]);
+ c_goto(41,8);
+ c_print(txt);
+ c_setcolor(color[TOKEN]);
+ c_print(" M");
}
-void
+static void
print_breaks(void)
{
int i,j;
@@ -521,7 +525,7 @@
}
-void print_halt(void)
+static void print_halt(void)
{
c_setcolor(color[HOT]);
c_goto(78,0);
@@ -531,7 +535,7 @@
/* draw screen */
-void
+static void
print_panel(void)
{
print_regs();
@@ -546,7 +550,7 @@
}
-void
+static void
show_keys(void)
{
int i=0;
@@ -562,7 +566,7 @@
/* clear all general purpos registers and IX, IY, and SP */
-void
+static void
clear_user_regs(void)
{
A=0;B=0;C=0;D=0;E=0;F=0;H=0;L=0;
@@ -572,7 +576,7 @@
/* put SP to 0xFFFC and store 4 bytes starting at 0xFFFC */
-void
+static void
stack_halt(void)
{
_ushort d;
@@ -585,7 +589,7 @@
}
-void
+static void
ask_flag(void)
{
unsigned char c;
@@ -636,7 +640,7 @@
/* reads string from input (will be stored in pointer), writes prompt message */
/* string cannot be longer than max_len */
/* return value: 0=ok, 1=escape pressed */
-int
+static int
ask_str(char *pointer,char *message,int max_len)
{
unsigned char c;
@@ -689,26 +693,20 @@
/* tries to convert a string to an unsigned number */
/* on error returns ~0 */
-unsigned convert_to_uns(char *txt)
+static unsigned convert_to_uns(char *txt)
{
-#ifdef OLD_STYLE /* only 0x-Hexprefix or decimal numbers are allowed */
- char *p;
- unsigned val=strtoul(txt,&p,0);
- if (*p) return ~0;
-#else
unsigned i, j, val;
for (i=0;txt[i]==' '||txt[i]=='\t';i++);
if (!txt[i] || txt[i]=='+' || txt[i]=='-') return ~0;
j=test_number(txt+i,&val); /* Single character-representation '?' is allowed */
if (!j) return ~0;
-#endif
return val;
}
/* reads a non negative integer from input */
/* on escape or error returns ~0 */
-unsigned
+static unsigned
ask(char *str,unsigned init_val)
{
static char txt[256];
@@ -722,7 +720,7 @@
/* reads a non negative integer from input */
/* on escape or error returns ~0 */
-unsigned
+static unsigned
ask_x(char *str,unsigned init_val)
{
static char txt[256];
@@ -734,7 +732,7 @@
}
-void
+static void
ask_general_16_register(char *prompt, _uchar *high, _uchar *low)
{ unsigned x;
x=ask(prompt,*high<<8|*low);
@@ -743,12 +741,12 @@
else
{ *high= x>>8;
*low= x&255;
- cpu_pin[wait]=1;
+ cpu_is_in_disassemble=1;
}
}
-void
+static void
ask_special_16_register(char *prompt, _ushort *reg16)
{ unsigned x;
x=ask(prompt,*reg16);
@@ -756,12 +754,12 @@
{ c_bell();print_status(); }
else
{ *reg16= x;
- cpu_pin[wait]=1;
+ cpu_is_in_disassemble=1;
}
}
-void
+static void
ask_16bit_register(void)
{
unsigned char c;
@@ -814,7 +812,7 @@
}
-void
+static void
ask_8bit_register(char *prompt, _uchar *reg8)
{
unsigned x=ask(prompt,*reg8);
@@ -822,12 +820,12 @@
{ c_bell();print_status(); }
else
{ *reg8= x;
- cpu_pin[wait]=1;
+ cpu_is_in_disassemble=1;
}
}
-void
+static void
ask_register(void)
{
unsigned char c;
@@ -910,7 +908,7 @@
}
-void
+static void
protocol(void)
{
row = -1;
@@ -933,7 +931,7 @@
}
-int compare_addr(const struct info *left, const struct info *right)
+static int compare_addr(const struct info *left, const struct info *right)
{
return left->value == right->value ? 0 : left->value < right->value ? -1:1;
}
@@ -943,33 +941,38 @@
int
main(int argc,char **argv)
{
- unsigned char c, rom_path[128], emu;
+ unsigned char c, rom_path[128], emu=0;
unsigned short old_pc;
- int b,a;
+ int b,a,s;
unsigned short start;
unsigned x;
string[-1]=' '; /* that is ok! (prevents any label recognation in compile) */
+ strcpy(rom_path,"./");
- if (argc>1&&(!strcmp(argv[1],"-h")||!strcmp(argv[1],"--help")))
+ for (b=s=1;s ...]\n");
- return 0;
+ if (!*(argv[s]+b))
+ continue;
+ else if (*(argv[s]+b)=='E')
+ emu=1;
+ else if (*(argv[s]+b)=='R')
+ { if (s+1>=argc || 1!=sscanf(argv[s+1],"%127s",rom_path))
+ fprintf(stderr,"Error: option -R needs a path argument\n");
+ else
+ b=0, s++;
+ }
+ else if (*(argv[s]+b)=='h' || *(argv[s]+b)=='?')
+ {
+ printf("%s\n",msg1);
+ printf("Usage: z80-mon [-h] [-E] [-R path] [ ...]\n");
+ return 0;
+ }
}
-
clear_memory();
MEMP=0;
- a= emu= (argc>1&&!strcmp(argv[1],"-E"));
- if (argc>1+a&&!strcmp(argv[1+a],"-R"))
- { a++;
- sscanf(argv[1+a],"%127s",rom_path);
- a++;
- }
- else
- strcpy(rom_path,"./");
- for (b=1+a;b>16)
{ if (stream)protocol();
decode(0,1); /* here we decode and execute the current opcode */
- if (cpu_pin[wait] || speed <= 1) print_panel();
+ if (cpu_is_in_disassemble || speed <= 1) print_panel();
else if (speed==4)
{print_regs();print_ticks();print_halt();print_flags();}
else
@@ -1045,16 +1052,16 @@
}
}
else
- { cpu_pin[wait]=1; print_panel();
+ { cpu_is_in_disassemble=1; print_panel();
}
}
- if (cpu_pin[busack])
- c=no_key_code;
+ if (cpu_pin[busrq])
+ c=no_key_code; /* no keyboard input possible */
else
{
- if (cpu_pin[wait]) keyboard_disabled=0;
- c = !keyboard_disabled && c_kbhit() ? c_getkey() : no_key_code;
- if (cpu_pin[wait] && c != no_key_code) cpu_pin[halt]=0;
+ if (cpu_is_in_disassemble) keyboard_disabled=0;
+ c = !keyboard_disabled && c_kbhit() ? c_getkey() : no_key_code;
+ if (cpu_is_in_disassemble && c != no_key_code) set_cpu_pin(halt,0);
}
if (c != no_key_code)
switch(c)
@@ -1075,8 +1082,9 @@
case 'X':
string[0]=0;
ask_str(string,"Execute instruction: ",40);
- set_cpu_pin(iorq,1);
+ cpu_is_in_x_mode= 1;
io_address=tmp_memory;
+ set_cpu_pin(iorq,1);
old_pc=PC;
set_start_address(0);
disable_pseudo=1;
@@ -1085,6 +1093,8 @@
PC=0;
decode(&old_pc,1);
set_cpu_pin(iorq,0);
+ io_address=NULL;
+ cpu_is_in_x_mode= 0;
print_panel();
break;
@@ -1094,7 +1104,7 @@
break;
case K_BACKSPACE: /* exec one instruction */
- if (!cpu_pin[wait]) break;
+ if (!cpu_is_in_disassemble) break;
if (stream)protocol();
decode(0,1);
print_panel();
@@ -1113,7 +1123,7 @@
case 's': /* change SP */
x=ask_x("SP=",SP);
if (x>65535){c_bell();print_status();break;}
- cpu_pin[wait]=1;
+ cpu_is_in_disassemble=1;
SP=x;
print_panel();
break;
@@ -1126,14 +1136,14 @@
case '-': /* speed */
if (speed > 1) speed >>= 2;
- else if (cpu_pin[wait]) speed =0;
+ else if (cpu_is_in_disassemble) speed =0;
print_speed();
break;
case 'r': /* toggle cpu_wait/run */
case 'R':
- if (!cpu_pin[halt] || c=='R') cpu_pin[wait]^=1;
- if (!cpu_pin[wait] && !speed) speed=1;
+ if (!cpu_pin[halt] || c=='R') cpu_is_in_disassemble= !cpu_is_in_disassemble;
+ if (!cpu_is_in_disassemble && !speed) speed=1;
print_panel();
break;
@@ -1214,7 +1224,7 @@
case 'P':
x=ask_x("PC=",PC);
if (x>65535){c_bell();print_status();break;}
- cpu_pin[wait]=1;
+ cpu_is_in_disassemble=1;
PC=x;
print_panel();
break;
@@ -1402,15 +1412,13 @@
c_bell();
break;
}
- if (cpu_pin[wait]) emu=0; /* really finish emulation mode ?? */
- if (!cpu_pin[busrq] && cpu_pin[busack])
- set_cpu_pin(busack,0);
+ if (cpu_is_in_disassemble) emu=0; /* really finish emulation mode ?? */
if (IFF0)
IFF2=IFF1=1;
else if (cpu_pin[reset])
reset_cpu();
else if (cpu_pin[busrq])
- set_cpu_pin(busack,1);
+ /* don't serve interrupts */ ;
else if (IFF3)
nmi_handler();
else
diff -N -r -u z80-asm-2.3/z80-mon.h z80-asm-2.3.7/z80-mon.h
--- z80-asm-2.3/z80-mon.h 2004-03-11 11:21:39.000000000 +0100
+++ z80-asm-2.3.7/z80-mon.h 2005-06-07 12:01:00.000000000 +0200
@@ -3,6 +3,7 @@
extern void print(char *str); /* print instruction */
extern void error(int n,char *line,char* message);
+extern void print_ticks(void); /* print ticks and cycle counter */
extern void finish(int);
#endif