File: it.asm

package info (click to toggle)
gpsim 0.32.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 16,644 kB
  • sloc: cpp: 121,258; asm: 54,223; ansic: 13,576; python: 9,708; sh: 4,695; makefile: 1,575; lex: 1,139; yacc: 854; pascal: 511; perl: 93; awk: 44; xml: 41
file content (616 lines) | stat: -rw-r--r-- 5,994 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
57
58
59
60
61
62
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
	;; it.asm
	;;
	;; The purpose of this program is to test how well gpsim can simulate
	;; a pic. Nothing useful is performed - this program is only used to
	;; debug gpsim.

	list	p=16c84
	
include "p16c84.inc"

  cblock  0x0c

	temp,temp1,temp2
  endc
	
	org 0


	clrf	temp1		;Assume clrf works...
				;
	;;
	;; map tmr0 to the internal clock 
	;; 
	clrw
	option			;initialize tmr0

start:	
	;; Perform some basic tests on some important instructions

	setc			;set the Carry flag
	skpc			;and verify that it happened
	 goto	$

	clrc			;Now try clearing the carry
	skpnc
	 goto	$

	setz			;set the Zero flag
	skpz			;and verify that it happened
	 goto	$

	clrz			;Now try clearing it
	skpnz
	 goto	$
	
	setdc			;set the Digit Carry flag
	skpdc			;and verify that it happened
	 goto	$

	clrdc			;Now try clearing it
	skpndc
	 goto	$

	movlw	1
	movwf	temp
	movf	temp,f
	skpnz
	 goto   $

	movlw	0
	movwf	temp
	movf	temp,f
	skpz
	 goto   $
	
	clrf	temp		;Clear a register
	skpz			;and verify that the Z bit in the
	 goto	$		;status register was set.

	movf	temp,w		;Read the register that was just
	skpz			;cleared, and again verify that Z
	 goto	$		;was set

	incf	temp,w		;Now this should cause the Z bit to
	skpnz			;get cleared.
	 goto	$

	movlw	0xff
	movwf	temp
	incf	temp

	skpz
	 goto	$

	;;
	;; incfsz
	;;

	movlw	0xff
	movwf	temp
	movf	temp,f		;Should clear Z
	incfsz	temp,w
	 goto	$

	skpnz			;incfsz shouldn't affect Z
	 goto	$

	incfsz	temp,f		;temp should now be zero
	 goto	$

	incfsz	temp,w		;the following inst. shouldn't be skipped
	 skpnz			;Z should be clear from above.
	  goto	$
		
	
	;; 	addlw	0xaa

	;; 
	;; addwf test:
	;;
	;; The purpose of this test is to a) verify that the addwf instruction
	;; adds correctly and b) that the appropriate status register bits are
	;; set correctly.

	clrw
	clrf	temp
	
	addwf	temp,w		; 0+0
	skpnc
	 goto	$
	skpz
	 goto	$
	skpndc
	 goto	$

	movlw	1		; 0+1
	addwf	temp,w
	
	skpnc
	 goto	$
	skpnz
	 goto	$
	skpndc
	 goto	$

	movlw	8		; 8+8
	movwf	temp
	addwf	temp,w
	
	skpnc
	 goto	$
	skpnz
	 goto	$
	skpdc
	 goto	$

	movlw	0x88		; 0x88+0x88
	movwf	temp
	addwf	temp,w
	
	skpc
	 goto	$
	skpnz
	 goto	$
	skpdc
	 goto	$

	movlw	0x80		; 0x80+0x80
	movwf	temp
	addwf	temp,w
	
	skpc
	 goto	$
	skpz
	 goto	$
	skpndc
	 goto	$

	movlw	1
	movwf	temp
	movlw	0xff
	addwf	temp,w

	skpc
	 goto	$
	skpz
	 goto	$
	skpdc
	 goto	$


	clrc
	clrdc
		
	;;
	;; andwf test:
	;;
	clrf	temp
	movlw	1
	andwf	temp,f

	skpz
	 goto	$

	skpc
	 skpndc
	  goto  $

	andwf	temp,w

	skpz
	 goto	$

	skpc
	 skpndc
	  goto  $

	movlw	1
	movwf	temp
	andwf	temp,f

	skpnz
	 goto	$

	skpc
	 skpndc
	  goto  $

	movlw	0xff
	andwf	temp,f		;1 & 0xff should = 1

	skpnz
	 goto	$

	skpc
	 skpndc
	  goto  $

	movlw	0xff		;Now add 0xff to see if temp
	addwf	temp,f		;really is 1. (should cause a carry)

	skpnz
	 skpc
	  goto	$

	;;
	;; iorwf
	;;

	movlw	0
	movwf	temp
	iorwf	temp,f
	skpz
	 goto	$

	movlw	1
	iorwf	temp,f
	skpnz
	 goto	$

	movlw	0xff
	addwf	temp,f
	skpnz
	 skpc
	  goto	$


	;;
	;; rlf
	;;

	clrdc
	clrf	temp
	clrc
	rlf	temp,w
	
	skpdc
	 skpnc
	  goto	$

	skpz
	 goto	$

	setc
	rlf	temp,f

	skpdc
	 skpnc
	  goto	$

	skpz
	 goto	$

	movlw	0xff
	addwf	temp,f
	skpnz
	 skpc
	  goto	$

	rlf	temp,f
	skpnc
	 goto	$
	
	movlw	0x80
	movwf	temp
	rlf	temp,w

	skpc
	 goto	$
	movwf	temp
	addwf	temp,w
	skpz
	 goto	$

	;;
	;; rrf
	;;

	clrdc
	clrf	temp
	clrc
	rrf	temp,w
	
	skpdc
	 skpnc
	  goto	$

	skpz
	 goto	$

	setc
	rrf	temp,f

	skpdc
	 skpnc
	  goto	$

	skpz
	 goto	$

	movlw	0x80
	addwf	temp,f
	skpnz
	 skpc
	  goto	$

	rrf	temp,f
	skpnc
	 goto	$
	
	movlw	1
	movwf	temp
	rrf	temp,w

	skpc
	 goto	$
	movwf	temp
	addwf	temp,w
	skpz
	 goto	$


	;; 
	;; subwf test:
	;;

	clrw
	clrf	temp
	
	subwf	temp,w		; 0-0
	skpc
	 goto	$
	skpz
	 goto	$
	skpdc
	 goto	$

	movlw	1		; 0-1
	subwf	temp,w
	
	skpnc
	 goto	$
	skpnz
	 goto	$
	skpndc
	 goto	$

	movlw	0x10		; 0x10-0x10
	movwf	temp
	subwf	temp,w
	
	skpc
	 goto	$
	skpz
	 goto	$
	skpdc
	 goto	$

	movlw	0x88		; 0x88-0x88
	movwf	temp
	subwf	temp,w
	
	skpc
	 goto	$
	skpz
	 goto	$
	skpdc
	 goto	$

	clrf	temp
	movlw	0x80		; 0 - 0x80
	subwf	temp,f
	
	skpnc
	 goto	$
	skpnz
	 goto	$
	skpdc
	 goto	$

	movlw	0		; 0x80 - 0
	subwf	temp,w

	skpc
	 goto	$
	skpnz
	 goto	$
	skpdc
	 goto	$

	movlw	1		; 0x80 - 1
	subwf	temp,w

	skpc
	 goto	$
	skpnz
	 goto	$
	skpndc
	 goto	$
	

	clrc
	clrdc

	;; 
	;; xorwf
	;;

	clrf	temp
	movlw	0xff
	xorwf	temp,f

	skpc
	 skpndc
	  goto	$

	skpnz
	 goto	$

	xorwf	temp,f

	skpz
	 goto	$

	xorwf	temp,f
	incfsz	temp,f
	 goto	$

	;;
	;; swapf
	;;

	movlw	0x0f
	movwf	temp
	swapf	temp,f
	xorwf	temp,f
	incfsz	temp,f
	 goto	$

	decf	temp1,f
	incfsz	temp1,w
	 goto	done

	;; repeat the test with in the next bank
	
	bsf	status,rp0
	goto	start
	
done:
	bcf	status,rp0
	
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	
	goto	$
	
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
		
	andlw	0xaa
	andwf	temp,w
	bcf	temp,5
	bsf	temp,5
	btfsc	temp,5
	btfss	temp,5
	call	routine
	clrf	temp
	clrw
	clrwdt
	comf	temp,w
	decf	temp,w
	decfsz	temp,w

	goto	l1
	nop
	nop
	nop
l1:	
	incf	temp,w
	incfsz	temp,w
	iorlw	0xaa
	iorwf	temp,w
	movlw	0xaa
	movf	temp,w
	movwf	temp
	nop
	option


	goto	r1
		
	retfie
	retlw   0xaa
routine
	return
r1:

	rlf	temp,w
	rrf	temp,w
	sleep
	sublw	0xaa
	subwf	temp,w
	swapf	temp,w
	tris	5
	xorlw	0xaa
	xorwf	temp,w
	

	;;
	;; Test indirect branching
	;;
test_pcl:
	
	clrf	temp
	clrf	temp1

tt1:
	movf	temp,w
	call	table_test

	xorwf	temp,w
	skpz
	 bsf	temp1,0

	incf	temp,f
	btfss	temp,4
	 goto	tt1

	goto	test_pcl2
table_test:
	addwf	pcl,f
table:
	retlw	0
	retlw	1
	retlw	2
	retlw	3
	retlw	4
	retlw	5
	retlw	6
	retlw	7
	retlw	8
	retlw	9
	retlw	10
	retlw	11
	retlw	12
	retlw	13
	retlw	14
	retlw	15

test_pcl2:
	
	btfsc	temp2,0
	 goto	test_pcl3
        movlw   0x20
        movwf   fsr
next    clrf    indf
        incf    fsr,1
        btfss   fsr,4
        goto    next

	bsf	temp2,0
        clrf    pcl

test_pcl3:

	movlw	ly
	movwf	pcl		; == goto ly
lx
	goto	test_pcl4
ly
	movlw	lx
	movwf	pcl

test_pcl4:
	
	goto	$
	end