Try an 8080 Simulator - Program Listing

Fig. 2. Program listing.

Begin Program

0000	31 FD 01		LXI SP,STACK+26		Initialize stack pointer
0003	CD 15 02		CALL LOC		Get starting address
0006	AF			XRA A			A=0
0007	32 E4 01		STA STACK+1		Put program into single step

        Begin Execution of Next Instruction, HL = Instruction Address

000A	31 F9 01	Next	LXI SP,STACK+22		Set stack pointer to PSW
000D	AF			XRA A			A=0
000E	32 1C 01		STA INST		Store NOP instruction
0011	32 1D 01		STA INST+1		Store NOP instruction
0014	7E			MOV A,M			Load instruction
0015	E6E7			ANI 0E7H		Zero out bits 3 and 4
0017	FE 22			CPI 22H
0019	CA FD 00		JZ THRB			Jump if LHLD, SHLD, LDA,
							   or STA
001C	7E			MOV A,M			Load instruction
001D	E6 CF			ANI 0CFH		Zero out bits 4 and 5
001F	FE 01			CPI 1
0021	CA FD 00		JZ THRB			Jump if LXI
0024	E6 C7			ANI 0C7H		Zero out bits 3, 4, and 5
0026	FE 06			CPI 6
0028	CA 02 01		JZ TWOB			Jump if MVI
002B	FE C7			CPI 0C7H
002D	CA F4 00		JZ ERST			Jump if RST
0030	FE C0			CPI 0C0H		One byte instruction?
0032	DA 07 01		JC ONEB			Jump if less than C0
0035	FE C6			CPI 0C6H
0037	CA 02 01		JZ TWOB			Jump if two byte 'immediate'
003A	7E			MOV A,M			Load Instruction
003B	FE F9			CPI 0F9H
003D	CA 07 01		JZ ONEB			Jump if SPHL
0040	FE E9			CPI 0E9H
0042	CA E8 00		JZ EPCHL		Jump if PCHL
0045	E6 F7			ANI 0F7H		Zero out bit 3
0047	FE D3			CPI 0D3H
0049	CA 02 01		JZ TWOB			Jump if IN or OUT
004C	E6 E7			ANI 0E7H		Zero out bits 3 and 4
004E	FE E3			CPI 0E3H
0050	CA 07 01		JZ ONEB			Jump if XCHG, XTHL, EI, or DI
0053	7E			MOV A,M			Load instruction
0054	E6 CB			ANI 0CBH		Zero out bits 2, 4, and 5
0056	FE C1			CPI 0C1H
0058	CA 07 01		JZ ONEB			Jump if POP or PUSH
005B	7E			MOV A,M			Load instruction
005C	FE C3			CPI 0C3H
005E	CA B7 00		JZ EXEC1		Jump if JMP
0061	FE CD			CPI 0CDH
0063	CA B7 00		JZ EXEC1		Jump if CALL
0066	FE C9			CPI 0C9H
0068	CA DA 00		JZ ERET			Jump if RET
006B	E6 38			ANI 38H			Zero out bits 0, 1, 2, 6, and 7
006D	0F			RRC
006E	4F			MOV C,A			Save in C
006F	0F			RRC
0070	81			ADD C			form values 0, 6, 12, ... 48 (decimal)
0071	4F			MOV C,A			Save in C
0072	06 00			MVI B,0			B=0
0074	EB			XCHG			Save PC value in DE
0075	21 7B 00		LXI H,COND		Load base address
0078	09			DAD B			Form relative address
0079	F1			POP PSW			Get flags
007A	E9			PCHL			Jump to relative address
007B	C2 B5 00	Cond	JNZ EXEC		whether to execute or skip it.
007E	C3 A8 00		JMP SKIP
0081	CA B5 00		JZ EXEC
0084	C3 A8 00		JMP SKIP
0087	D2 B5 00		JNC EXEC
008A	C3 A8 00		JMP SKIP
008D	DA B5 00		JC EXEC
0090	C3 A8 00		JMP SKIP
0093	E2 B5 00		JPO EXEC
0096	C3 A8 00		JMP SKIP
0099	EA B5 00		JPE EXEC
009C	C3 A8 00		JMP SKIP
009F	F2 B5 00		JP EXEC
00A2	C3 A8 00		JMP SKIP
00A5	FA B5 00		JM EXEC

   Condition not Met, Advance PC value to next Instruction

00A8	EB		Skip	XCHG			HL = PC value
00A9	7E			MOV A,M			Load instruction
00AA	E6 07			ANI 7
00AC	23			INX H			Increment PC value
00AD	CA EB 00		JZ EPCH1		Jump if return
00B0	23			INX H			Increment PC value
00B1	23			INX H			Increment PC value
00B2	C3 EB 00		JMP EPCH1

        Condition Met. Execute Instruction

00B5	EB		Exec	XCHG			HL = PC value
00B6	7E			MOV A,M			Load instruction
00B7	E6 06		Exec1	ANI 6
00B9	CA DA 00		JZ ERET			Jump if return
00BC	23			INX H			Increment PC value
00BD	5E			MOV E,M			Get address
00BE	23			INX H
00BF	56			MOV D,M
00C0	EB		Exec2	XCHG
00C1	22 F1 01		SHLD STACK+14		Store new PC value
00C4	31 EF 01		LXI SP,STACK+12		Load SP address for STOR
00C7	FE 02			CPI 2
00C9	CA 38 01		JZ STOR2		jump if jump instruction
00CC	2A EF 01		LHLD STACK+12		Get stack address
00CF	13			INX D			Increment return PC value
00D0	2B			DCX H			Decrement SP value
00D1	72			MOV M,D			Store return PC value in stack
00D2	2B			DCX H
00D3	73			MOV M,E
00D4	31 F1 01		LXI SP,STACK+14		Load SP address for STOR
00D7	C3 37 00		JMP STOR1

                          Process Return

00DA	2A EF 01	Eret	LHLD STACK+12		Get stack address
00DD	5E			MOV E,M			Get retun PC value
00DE	23			INX H
00DF	56			MOV D,M
00E0	23			INX H
00E1	31 F3 01		LXI SP,STACK+16
00E4	D5			PUSH D
00E5	C3 37 01		JMP STOR1		Store new PC value

               Process PCHL

00E8	2A F3 01	Epchl	LHLD STACK+16		Get HL value
00EB	22 F1 01	Epch1	SHLD STACK+14		Store new PC value
00EE	31 EF 01		LXI SP,STACK+12		Load SP for STOR 
00F1	C3 38 01		JMP STOR2

               Process RST

00F4	7E		Erst	MOV A,M			Load Instruction
00F5	E6 38			ANI 38H			Get RST address
00F7	5F			MOV E,A			Put new PC value into DE
00F8	16 00			MVI D,0
00FA	C3 C0 00		JMP EXEC2		Jump to EXEC to finish

               Process Sequential Instructions

00FD	7E		Thrb	MOV A,M			Get first byte 
00FE	32 1C 01		STA INST		Store byte
0101	23			INX H
0102	7E		Twob	MOV A,M			Get byte
0103	32 1D 01		STA INST+1		Store byte
0106	23			INX H
0107	7E		Oneb	MOV A,M			Get byte
0108	32 1E 01		STA INST+2		Store byte
010B	23			INX H
010C	22 F1 01		SHLD STACK+14		Store PC value
010F	2A EF 01		LHLD STACK+12		HL = SP value
0112	31 F5 01		LXI SP,STACK+18
0115	D1			POP D			DE = program value
0116	C1			POP B			BC = program value
0117	F1			POP PSW			A and flags = program value
0118	F9			SPHL			SP = program value
0119	2A F3 01		LHLD STACK+16		HL = program value
011C			Inst	DS 3			Execute instruction stored here
011F	22 F3 01		SHLD STACK+16		Store HL
0122	21 00 00		LXI H,0			HL = 0
0125	DA 2C 01		JC CARRY		Determine state of carry flag
0128	39			DAD SP			HL = program SP value
0129	C3 2E 01		JMP STOR
012C	39		Carry	DAD SP			HL= program value
012D	37			STC			Reset carry flag
012E	31 FB 01	Stor	LXI SP,STACK+24
0131	F5			PUSH PSW		Store A and flags
0132	C5			PUSH B			Store BC
0133	D5			PUSH D			Store DE
0134	31 F1 01 		LSI SP,STACK+14
0137	E5		Stor1	PUSH H			Store SP value
0138	3A E4 01	Stor2	LDA STACK+1		Load breakpoint mode indicator
013B	A7			ANA A			Set flags
013C	CA 54 01		JZ DSPY			Jump if not in breakpoint mode
013F	2A F1 01		LHLD STACK+14		Load current PC value
0142	3A E5 01		LDA STACK+2		Load lower byte of breakpoint address
0145	BD			CMP L
0146	C2 0A 00		JNZ NEXT		Jump if addresses not equal
0149	3A E6 01		LDA STACK+3		Load lower byte of breakpoint address
014C	BC			CMP H
014D	C2 0A 00		JNZ NEXT		Jump if addresses not equal
0150	AF			XRA A			A = 0
0151	32 E4 01		STA STACK+1		Breakpoint address reached, return to single step mode
0154	21 FA 01	Dspy 	LXI H,STACK+23		Load address of registers
0157	E5			PUSH H
0158	21 FD 01		LXI H,ASCII		Load address of headings
015B	0E 06			MVI C,6			C = loop count
015D	06 03		Dspy1	MVI B,3			B = output character count
015F	CD 4D 02		CALL OUTPT		Output heading
0162	E3			XTHL			Get register address
0163	CD 2E 02		CALL CONV		Output register value
0166	2B			DCX H
0167	CD 2E 02		CALL CONV		Output register value
016A	2B			DCX H
016B	06 03			MVI B,3			B = output character count
016D	79			MOV A,C			Check loop count
016E	1F			RAR
016F	D2 74 01		JNC DSPY2		Jump if no CR output
0172	06 04			MVI B,4			Increase character count for CR
0174	EB		Dspy2	XCHG
0175	21 10 02		LXI H,SPACE		Load output address
0178	CD 4D 02		CALL OUTPT
017B	E1			POP H			Get heading address
017C	D5			PUSH D			Store register address
017D	23			INX H
017E	0D			DCR C			Decrement loop count
017F	C2 5D 01		JNZ DSPY1		Jump if not finished
0182	D1			POP D			Get rid of address
0183	D1			POP D			DE = SP value
0184	E1			POP H			HL = PC value
0185	E5			PUSH H
0186	D5			PUSH D
0187	D5			PUSH D
0188	11 FA FF		LXI D,-6
018B	19			DAD D			HL = PC - 6
018C	0E 0C			MVI C,0CH		C = loop count
018E	EB			XCHG
018F	21 10 02	Dspy3	LXI H,SPACE		HL = output address
0192	79			MOV A,C			Check loop count
0193	FE 06			CPI 6
0195	C2 99 01		JNZ DSPY4		Jump if no asterisk output
0198	2B			DCX H			Change address for asterisk
0199	06 02		Dspy4	MVI B,2			Load output count
019B	CD 4D 02		CALL OUTPT
019E	EB			XCHG
019F	CD 2E 02		CALL CONV		Output PC value
01A2	23			INX H
01A3	EB			XCHG
01A4	06 03			MVI B,3			Load output count
01A6	21 10 02		LXI H,SPACE
01A9	CD 4D 02		CALL OUTPT		Output spaces
01AC	E1			POP H			Get address of SP
01AD	D5			PUSH D			Store address of PC
01AE	CD 2E 02		CALL CONV		Output SP value
01B1	23			INX H
01B2	CD 2E 02		CALL CONV
01B5	23			INX H
01B6	D1			POP D			Get PC address
01B7	E5			PUSH H			Store address of SP
01B8	06 01			MVI B,1			Load count for CR
01B	21 13 02		LXI H,SPACE+3		HL = address of CR 
01BD	CD 4D 02		CALL OUTPT		Output CR
01C0	0D			DCR C			Decrement loop count
01C1	C2 8F 01		JNZ DSPY3		Continue output?
01C4	CD 5C 02		CALL INP		Wait for input
01C7	FE 42			CPI 'B'			Breakpoint?
01C9	C2 DD 01		JNZ CONT		Jump if not breakpoint
01CC	32 E4 01		STA STACK+1		Change breakpoint indicator
01CF	CD 15 02		CALL LOC		Get breakpoint address
01D2	22 E5 01		SHLD STACK+2		Store breakpoint address
01D5	21 13 02		LXI H,SPACE+3		Load CR address
01D8	06 01			MVI B,1			Load output count
01DA	CD 4D 02 		CALL OUTPUT		Output CR
01DD	2A F1 01	Cont	LHLD STACK+14		HL = PC
01E0	C3 0A 00		JMP NEXT

              Register Storage

01E3			Stack	DS 26			Reserve 26 bytes for STACK

ASCII Headings

01FD	41 20		Ascii	DW 'A '
01FF	3D 42			DW '=B'
0201	43 3D			DW 'C='
0203	44 45			DW 'DE'
0205	3D 48			DW '=H'
0207	4C 3D			DW 'L='
0209	50 43			DW 'PC'
020B	3D 53			DW '=S'
020D	50 3D			DW 'P='
020F	2A			DB '*'
0210	20		Space	DB ' '
0211	20 20			DW '  '
0213	0D 0A			DW 0D0AH

This Routine gets a Four Digit ASCII Address from an Input Device, Converts
to Hex and Returns with Value in HL

0215	06 04		Loc	MVI B,4			Load loop count
0217	CD 5C 02	Loc1	CALL INP		Get character
021A	29			DAD H			Shift HL four places
021B	29			DAD H
021C	29			DAD H
021D	29			DAD H
021E	FE 40			CPI 40			Convert to hex
0220	DA 25 02		JC LOC2			Jump if number
0223	C6 09			ADI 9			Add bias to letter
0225	E6 0F		Loc2	ANI 0FH			Strip off upper bits
0227	B5			ORA L
0228	6F			MOV L,A			Move to HL register
0229	05			DCR B			Decrement loop count
022A	C2 17 02		JNZ LOC1
022D	C9			RET

This Routine Converts the Byte Pointed to by HL from Hex to ASCII and
Outputs the two Digits

022E	16 02		Conv	MVI D,2			Load loop count
0230	7E			MOV A,M			Get byte
0231	5F			MOV E,A			Store in E
0232	0F			RRC			Shift A four times
0233	0F			RRC
0234	0F			RRC
0235	0F			RRC
0236	E6 0F		Conv1	ANI 0FH			Mask out upper bits
0238	FE 0A			CPI 0AH
023A	DA 3F 02		JC CONV2		Jump if number
023D	C6 07			ADI 7			Add bias for letter
023F	C6 30		Conv2	ADI 30			Add bias for ASCII
0241	77			MOV M,A			Store character in memory
0242	04			INR B			B = 1
0243	CD 4D 02		CALL OUTPT		Output character
0246	7B			MOV A,E			Move character to A
0247	15			DCR D			Decrement loop count
0248	C2 36 02		JNZ CONV1		Jump if not finished
024B	73			MOV M,E			Restore character to memory
024C	C9			RET

This Routine Outputs a String of Characters, B = Number of Characters, HL
Points to the Characters

024D	DB 02		Outpt	IN 2			Get status
024F	17			RAL
0250	DA 4D 02		JC OUTPT		Jump if not ready
0253	7E			MOV A,M			Get output character
0254	D3 03			OUT 3			Output character
0256	05			DCR B			Decrement loop count
0257	C8			RZ			Return if done
0258	23			INX H			Advance pointer
0259	C3 4D 02		JMP OUTPT

This Routine Inputs one Character

025C	DB 02		Inp	IN 2			Get status
025E	0F			RRC
025F	DA 5C 02		JC INP			Jump if not ready
0262	DB 03			IN 3			Get character
0264	C9			RET 

Im Original-Listing sind mehrere Fehler enthalten:
AdresseFalschRichtig
0134LSILXI
01DAOUTPUTOUTPT
021E4040H
023F3030H

Korrigiertes Programm Listing.
[CP/M Quelle mit BDOS Ein-/Ausgabe]

Eingescanned von Werner Cirsovius
Februar 2014
© Microcomputing (kilobaud)