usim

Check-in [9721679bb8]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Merge changes from trunk.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | ams/sdl1
Files: files | file ages | folders
SHA3-256: 9721679bb87bf4888aa48eca5f97c331cea15426c0cafb8940068d1fe023b770
User & Date: ams 2024-05-31 07:39:38
Context
2024-05-31
07:40
Merge changes from ams/cleanup. check-in: e3ef95ff7c user: ams tags: ams/sdl1
07:39
Merge changes from trunk. check-in: 9721679bb8 user: ams tags: ams/sdl1
05:08
sdl1.c: Random garbage. check-in: 73352d4384 user: ams tags: ams/sdl1
2024-05-28
15:02
uexec.c (advanceLC): Return new target; I'm going to regret this ... Leaf check-in: 8ac55b00b4 user: ams tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ucode.c.

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "utrace.h"

extern uint64_t p0;
extern uint64_t p1;
extern int p0_pc;
extern int p1_pc;

extern int no_exec_next;

size_t cycles;

int full_trace_lc = 0;
int full_trace_repeat_counter = 0;
int full_trace_last_lc = 0;


void
run(void)
{

	p1 = 0;
	p0_pc = 0;
	p1_pc = 0;
	no_exec_next = 0;
	write_phy_mem(0, 0);
	while (!halted) {

		if (cycles == 0) {
			p0 = p1 = 0;
			p1_pc = 0;
			no_exec_next = 0;
		}
		idle_check(cycles);
		disk_poll();
		if ((cycles & 0x0ffff) == 0) {
			iob_poll();
			tv_poll();
		}







|











<



|


<



|







19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

38
39
40
41
42
43

44
45
46
47
48
49
50
51
52
53
54
#include "utrace.h"

extern uint64_t p0;
extern uint64_t p1;
extern int p0_pc;
extern int p1_pc;

extern int inhibit;

size_t cycles;

int full_trace_lc = 0;
int full_trace_repeat_counter = 0;
int full_trace_last_lc = 0;


void
run(void)
{

	p1 = 0;
	p0_pc = 0;
	p1_pc = 0;
	inhibit = false;
	write_phy_mem(0, 0);
	while (!halted) {

		if (cycles == 0) {
			p0 = p1 = 0;
			p1_pc = 0;
			inhibit = false;
		}
		idle_check(cycles);
		disk_poll();
		if ((cycles & 0x0ffff) == 0) {
			iob_poll();
			tv_poll();
		}

Changes to uexec.c.

63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
 */

uint32_t opc;
uint32_t q;
uint32_t old_q;
int interrupt_control;

int no_exec_next;

int popj;

uint32_t new_md;
int new_md_delay;

int alu_carry;
uint32_t alu_out;

int oal;
int oah;

uint32_t out;


uint64_t
ir(int pos, int len)
{







|









|
|







63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
 */

uint32_t opc;
uint32_t q;
uint32_t old_q;
int interrupt_control;

bool inhibit;

int popj;

uint32_t new_md;
int new_md_delay;

int alu_carry;
uint32_t alu_out;

bool oal;
bool oah;

uint32_t out;


uint64_t
ir(int pos, int len)
{
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
	}
}

/*
 * Advance the LC register, following the rules; will read next VMA if
 * needed.
 */
void
advanceLC(int *ppc)
{
	int old_lc;

	record_lc_history();
	old_lc = mfmem[1] & 0377777777; /* LC is 26 bits. */
	if (should_dump_lc(old_lc)) {
		char buffer[256];







|
|







138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
	}
}

/*
 * Advance the LC register, following the rules; will read next VMA if
 * needed.
 */
int
advanceLC(int ppc)
{
	int old_lc;

	record_lc_history();
	old_lc = mfmem[1] & 0377777777; /* LC is 26 bits. */
	if (should_dump_lc(old_lc)) {
		char buffer[256];
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
		vmRead(old_lc >> 2, &new_md);
		new_md_delay = 2;
		DEBUG(TRACE_UCODE, "advanceLC() read vma %011o -> %011o\n", old_lc >> 2, new_md);
	} else {
		/*
		 * Force skipping 2 instruction (PF + SET-MD).
		 */
		if (ppc)
			*ppc |= 2;
		DEBUG(TRACE_UCODE, "advanceLC() no read; md = %011o\n", mfmem[030]);
	}
	{
		int lc0b;
		int lc1;
		int last_byte_in_word;








<
|







169
170
171
172
173
174
175

176
177
178
179
180
181
182
183
		vmRead(old_lc >> 2, &new_md);
		new_md_delay = 2;
		DEBUG(TRACE_UCODE, "advanceLC() read vma %011o -> %011o\n", old_lc >> 2, new_md);
	} else {
		/*
		 * Force skipping 2 instruction (PF + SET-MD).
		 */

		ppc |= 2;
		DEBUG(TRACE_UCODE, "advanceLC() no read; md = %011o\n", mfmem[030]);
	}
	{
		int lc0b;
		int lc1;
		int last_byte_in_word;

193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
		DEBUG(TRACE_UCODE, "lc0b %d, lc1 %d, last_byte_in_word %d\n", lc0b, lc1, last_byte_in_word);
		if (last_byte_in_word)
			/*
			 * Set NEED-FETCH.
			 */
			mfmem[1] |= (1UL << 31UL);
	}

}

uint32_t
mfread(int addr)
{
	int res;








|







192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
		DEBUG(TRACE_UCODE, "lc0b %d, lc1 %d, last_byte_in_word %d\n", lc0b, lc1, last_byte_in_word);
		if (last_byte_in_word)
			/*
			 * Set NEED-FETCH.
			 */
			mfmem[1] |= (1UL << 31UL);
	}
	return ppc;
}

uint32_t
mfread(int addr)
{
	int res;

315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
		mfmem[014] = data & 01777;
		break;
	case 015: /* MICRO-STACK-DATA-PUSH SPC data, push. */
		pushSPC(data);
		break;
	case 016: /* OA-REG-LO Next instruction modifier (lo). */
		mfmem[016] = data & 0377777777;
		oal = 1;
		DEBUG(TRACE_UCODE, "setting oa_reg lo %o\n", mfmem[016]);
		break;
	case 017: /* OA-REG-HI Next instruction modifier (hi). */
		mfmem[017] = data;
		oah = 1;
		DEBUG(TRACE_UCODE, "setting oa_reg hi %o\n", mfmem[017]);
		break;
	case 020: /* VMA VMA register (memory address). */
		mfmem[020] = data;
		break;
	case 021: /* VMA-START-READ VMA register, start main memory read. */
		mfmem[020] = data;







|




|







314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
		mfmem[014] = data & 01777;
		break;
	case 015: /* MICRO-STACK-DATA-PUSH SPC data, push. */
		pushSPC(data);
		break;
	case 016: /* OA-REG-LO Next instruction modifier (lo). */
		mfmem[016] = data & 0377777777;
		oal = true;
		DEBUG(TRACE_UCODE, "setting oa_reg lo %o\n", mfmem[016]);
		break;
	case 017: /* OA-REG-HI Next instruction modifier (hi). */
		mfmem[017] = data;
		oah = true;
		DEBUG(TRACE_UCODE, "setting oa_reg hi %o\n", mfmem[017]);
		break;
	case 020: /* VMA VMA register (memory address). */
		mfmem[020] = data;
		break;
	case 021: /* VMA-START-READ VMA register, start main memory read. */
		mfmem[020] = data;
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
		npc--;
	}
	/*
	 * Enable instruction sequence hardware.
	 */
	if (enable_ish) {
		DEBUG(TRACE_UCODE, "advancing LC due to DISPATCH\n");
		advanceLC((int *) 0);
	}
	if (n)
		no_exec_next = 1;
	if (p && r)
		return;
	if (p) {
		if (!n)
			pushSPC(npc);
		else
			pushSPC(npc - 1);
	}
	if (r) {
		target = popSPC();
		if ((target >> 14) & 1) {
			DEBUG(TRACE_UCODE, "advancing LC due to microcode stack bit 14\n");
			advanceLC(&target);
		}
		target &= 037777;
	}
	npc = target;
	popj = 0;
}








|


|












|







690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
		npc--;
	}
	/*
	 * Enable instruction sequence hardware.
	 */
	if (enable_ish) {
		DEBUG(TRACE_UCODE, "advancing LC due to DISPATCH\n");
		advanceLC(0);
	}
	if (n)
		inhibit = true;
	if (p && r)
		return;
	if (p) {
		if (!n)
			pushSPC(npc);
		else
			pushSPC(npc - 1);
	}
	if (r) {
		target = popSPC();
		if ((target >> 14) & 1) {
			DEBUG(TRACE_UCODE, "advancing LC due to microcode stack bit 14\n");
			target = advanceLC(target);
		}
		target &= 037777;
	}
	npc = target;
	popj = 0;
}

795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
		else
			pushSPC(npc - 1);
	}
	if (r && cond) {
		target = popSPC();
		if ((target >> 14) & 1) {
			DEBUG(TRACE_UCODE, "advancing LC due to microcode stack bit 14\n");
			advanceLC(&target);
		}
		target &= 037777;
	}
	if (cond) {
		if (n)
			no_exec_next = 1;
		npc = target;
		/*
		 * inhibit possible POPJ.
		 */
		popj = 0;
	}
}







|





|







794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
		else
			pushSPC(npc - 1);
	}
	if (r && cond) {
		target = popSPC();
		if ((target >> 14) & 1) {
			DEBUG(TRACE_UCODE, "advancing LC due to microcode stack bit 14\n");
			target = advanceLC(target);
		}
		target &= 037777;
	}
	if (cond) {
		if (n)
			inhibit = true;
		npc = target;
		/*
		 * inhibit possible POPJ.
		 */
		popj = 0;
	}
}
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931

	incNPC();
	if (new_md_delay) {
		new_md_delay--;
		if (new_md_delay == 0)
			mfmem[030] = new_md;
	}
	if (no_exec_next) {
		DEBUG(TRACE_MICROCODE, "no_exec_next; npc %o\n", npc);
		no_exec_next = 0;
		incNPC();
	}
	if (oal) {
		DEBUG(TRACE_MICROCODE, "merging oa lo %o\n", mfmem[016]);
		oal = 0;
		p0 |= mfmem[016];
	}
	if (oah) {
		DEBUG(TRACE_MICROCODE, "merging oa hi %o\n", mfmem[017]);
		oah = 0;
		p0 |= (uint64_t) mfmem[017] << 26;
	}
	trace_ucode();
	record_pc_history(p0_pc);
	popj = ir(42, 1);
	aaddr = ir(32, 10);
	maddr = ir(26, 5);







|
|
|


|

|


|

|







904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930

	incNPC();
	if (new_md_delay) {
		new_md_delay--;
		if (new_md_delay == 0)
			mfmem[030] = new_md;
	}
	if (inhibit == true) {
		DEBUG(TRACE_MICROCODE, "inhibit; npc %o\n", npc);
		inhibit = false;
		incNPC();
	}
	if (oal == true) {
		DEBUG(TRACE_MICROCODE, "merging oa lo %o\n", mfmem[016]);
		oal = false;
		p0 |= mfmem[016];
	}
	if (oah == true) {
		DEBUG(TRACE_MICROCODE, "merging oa hi %o\n", mfmem[017]);
		oah = false;
		p0 |= (uint64_t) mfmem[017] << 26;
	}
	trace_ucode();
	record_pc_history(p0_pc);
	popj = ir(42, 1);
	aaddr = ir(32, 10);
	maddr = ir(26, 5);
942
943
944
945
946
947
948
949
950
951
952
953
		int old_npc;

		DEBUG(TRACE_MICROCODE, "popj; ");
		old_npc = npc;
		npc = popSPC();
		if ((npc >> 14) & 1) {
			DEBUG(TRACE_UCODE, "advancing LC due to POPJ (old npc = #x%x, new npc = #x%x)\n", old_npc, npc);
			advanceLC(&npc);
		}
		npc &= 037777;
	}
}







|




941
942
943
944
945
946
947
948
949
950
951
952
		int old_npc;

		DEBUG(TRACE_MICROCODE, "popj; ");
		old_npc = npc;
		npc = popSPC();
		if ((npc >> 14) & 1) {
			DEBUG(TRACE_UCODE, "advancing LC due to POPJ (old npc = #x%x, new npc = #x%x)\n", old_npc, npc);
			npc = advanceLC(npc);
		}
		npc &= 037777;
	}
}