File: led_mod.asm

package info (click to toggle)
gpsim 0.32.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 16,640 kB
  • sloc: cpp: 121,258; asm: 54,223; ansic: 13,576; python: 9,708; sh: 4,695; makefile: 1,566; lex: 1,139; yacc: 854; pascal: 511; perl: 93; awk: 44; xml: 41
file content (59 lines) | stat: -rw-r--r-- 895 bytes parent folder | download | duplicates (11)
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
	list	p=16c84

	;; 
	;; led_mod.asm - a simple program to test gpsim's ability to interface
	;; to a 7-segment led module
	;; 
		
include "p16c84.inc"

  cblock  0x0d
	digit

  endc
	
	org	0

	;; Make all of portb I/O pins outputs
	clrw
	tris	PORTB	
	tris	PORTA
	
	;; Loop continuously and increment portb.
	;; It's assumed that a 7-segemnt is attached to the simulated pic.
	;; Port A bit0 controls the common cathode, while port B 0-6 control
	;; anodes of the 7 segments.

	clrf	PORTA
begin

	incf	digit,w
	andlw	0x0f
	movwf	digit
	
	call	decode_segments
	movwf	PORTB
	

	goto	begin

decode_segments
	addwf	PCL,f
	retlw	0x3f		; 0
	retlw	0x06		; 1
	retlw	0x5b		; 2
	retlw	0x4F		; 3
	retlw	0x66		; 4
	retlw	0x6d		; 5
	retlw	0x7c		; 6
	retlw	0x07		; 7
	retlw	0x7f		; 8
	retlw	0x67		; 9
	retlw	0x77		; A
	retlw	0x7c		; B
	retlw	0x58		; C
	retlw	0x5e		; D
	retlw	0x79		; E
	retlw	0x71		; F
	
	end