Creating an Assembler File Using a Text Editor

One of the greatest features of assembly language is that it is text based and can be wrritten in virtually any test editor.

The .asm delineates the code as an assembler file.


;blink.asm
;This is a program which turns on and off pin B0
;Port A is set as an input and port B as an output
;The prescaler is set in the option register to 256 (to give timing pulse of 1/32 s)
;1s and 0.5 s time delays are created in the subroutines
;uses a 32768 Hz xtal
;*************************************************************
;EQUATES SECTION
   TMR0 	EQU 1 		;TMR0 means 1
   STATUS 	EQU 3 		;STATUS means 3
   PORTA 	EQU 5 		;PORTA means 5
   PORTB 	EQU 6 		;PORTB means 6
   ZEROBIT EQU 2 		;ZEROBIT means 2
   COUNT 	EQU 20H 	;COUNT means 20h
   OPT_REG EQU 81H 	;OPT_REG means 81h
;*************************************************************
 	PROCESSOR 16F628a 	;means we are using the 16F628a chip
   __CONFIG H'2168' 	;sets config bits
   ORG 0 				;the start address in program memory is 0
   GOTO START 			;go to START!
;*************************************************************
;SUBROUTINE SECTION
;1.0 SECOND DELAY
   DELAY1 	CLRF 	TMR0 			;sets the TMR0 register to 0
   LOOPA 	MOVF 	TMR0,W 			;moves the contents of TMR0 reg to W reg
   		SUBLW 	.32 			;the W reg is sub from 32 and result put in W reg
   		BTFSS 	STATUS,ZEROBIT 	;if ZEROBIT is 1(arith op is zero) then next op is skipped
   		GOTO 	LOOPA 			;GOTO LOOPA
   		RETLW 	0 				;return to main program with 0 in W reg
;0.5 SECOND DELAY
   DELAYP5 CLRF 	TMR0 			;sets the TMR0 register to 0
   LOOPB 	MOVF 	TMR0,W 			;moves the contents of TMR0 reg to W reg
   		SUBLW 	.16 			;the W reg is sub from 16 and result put in W reg
   		BTFSS 	STATUS,ZEROBIT 	;if ZEROBIT is 1(arith op is zero) then next op is skipped
   		GOTO 	LOOPB 			;GOTO LOOPB
   		RETLW 0 				;return to main program with 0 in W reg
;************************************************************
;CONFIGURATION SECTION
START 	BSF 	STATUS,5 	;activates addressing (of ram) to bank 1
 		MOVLW 	B'00011111' ;puts 00011111 into W reg
   	MOVWF 	PORTA 		;puts W reg into PORTA direction reg (input)
 		MOVLW 	B'00000000' ;puts 00000000 into W reg
   	MOVWF 	PORTB 		;puts W reg into PORTB direction reg (input)
 		MOVLW 	B'00000111' ;puts 00000111 into W reg
   	MOVWF 	OPT_REG 	;puts W reg into option reg to set prescaler
 		BCF 	STATUS,5 	;activates addressing (of ram) to bank 2
   	CLRF 	PORTA 		;sets PORTA data (input) status to 0's
   	CLRF 	PORTB 		;sets PORTB data (output) status to 0's
;*********************************************************
;PROGRAM STARTS NOW
BEGIN 	BSF 	PORTB,0 	;turns on B0
   	CALL 	DELAY1 		;delays 1.0 seconds
   	BCF 	PORTB,0 	;turns off B0
   	CALL 	DELAYP5 	;delays 0.5 seconds
   	GOTO 	BEGIN 		;loops to begin
 		END 				;must have an end statement

Technological Design Home