Author Topic: [PROBABLY SOLVED] PIC ASM - I don't understand this memory location reference  (Read 2107 times)

0 Members and 1 Guest are viewing this topic.

Offline glossywhiteTopic starter

  • Regular Contributor
  • *
  • !
  • Posts: 241
[EDIT] My mistake, I think these references are individual BITs on the BYTE which is PORTA. It just looked confusing at first glance, until I put it into context by reading further down the code.

Thanks


Hello guys. it's me again, Mr confused. I don't understand the memory location references made under the heading "INPUTS". It is using memlocs that point to registers such as PCL and STATUS. I must be mis-understanding something here... or are these numbers being assigned just numeric values, and not actual reglocs?

Code: [Select]
list p=16f627
#include p16f627.inc

;THE LINES ABOVE JUST TELL THE COMPILER THAT WE'RE USING PIC16F627

__CONFIG _BODEN_ON & _CP_OFF & DATA_CP_OFF & _PWRTE_ON & _WDT_OFF & _LVP_OFF & _MCLRE_ON & _INTRC_OSC_NOCLKOUT

;======
;VARIABLE DEFS

;INPUTS
SW1 EQU 00H ;SW1 TRIGGERS RA0
SW2 EQU 01H ;SW2 TRIGGERS RA1
SW3 EQU 02H ;SW3 TRIGGERS RA2
SW4 EQU 03H ;SW4 TRIGGERS RA3

;TIMERS (USED FOR DELAY_ROUTINE)
TIMER1 EQU 20H
TIMER2 EQU 21H

;PATTERN
PATTERN EQU 22H

;SET VECTOR TO 0
ORG 0
GOTO RESET

;======
;DELAY ROUTINE - NESTED LOOPS
DELAY_ROUTINE MOVLW D'100'
     MOVWF TIMER2
DEL_LOOP1     MOVLW D'100'
     MOVWF TIMER1
DEL_LOOP2     BTFSC PORTA,SW1
     GOTO MENU
     BTFSC PORTA,SW1
     GOTO MENU
     BTFSC PORTA,SW3
     GOTO MENU
     BTFSC PORTA,SW4
     GOTO MENU
     DECFSZ TIMER1,F ;DECREMENT F, SKIP IF ZERO, STORE RESULT IN F REGISTER
     GOTO DEL_LOOP2
     DECFSZ TIMER2,F
     GOTO DEL_LOOP1
     RETLW 0

;MAIN INIT ROUTINE - SETUP PIC OPTIONS ETC
RESET MOVLW B'00000111'
      MOVWF CMCON
      BSF STATUS,RP0 ;SWITCH TO BANK 1
      MOVLW B'11010111' ;SET PIC OPTIONS
      MOVWF OPTION_REG ;WRITE PIC OPTIONS REGISTER
      CLRF INTCON ;DISBABLE ALL INTERRUPTS

;SET INPUTS AND OUTPUTS
;PORTB
      MOVLW B'11000000'
      MOVWF TRISB
;PORTA
      MOVLW B'11111111'
      MOVWF TRISB

;SWITCH BACK TO BANK 0
BCF STATUS,RP0

;CLEAR ALL PORTB OUTPUTS
CLRF PORTB

;DEFAULT TO EFFECT_4 ON BOOT
GOTO EFFECT_4

« Last Edit: January 26, 2011, 04:19:07 pm by glossywhite »
 

Offline Excavatoree

  • Frequent Contributor
  • **
  • Posts: 901
  • Country: us
Re: PIC ASM - I don't understand this memory location reference
« Reply #1 on: January 26, 2011, 04:16:30 pm »
You are correct.  the EQU assembler directive is just numeric value assigned to a label - not a memory location.

The MCU doesn't know or care - it's just for the humans reading the source code.

maybe someone else can explain better.
 

Offline glossywhiteTopic starter

  • Regular Contributor
  • *
  • !
  • Posts: 241
Re: PIC ASM - I don't understand this memory location reference
« Reply #2 on: January 26, 2011, 04:20:33 pm »
You are correct.  the EQU assembler directive is just numeric value assigned to a label - not a memory location.

The MCU doesn't know or care - it's just for the humans reading the source code.

maybe someone else can explain better.


No, I totally get that explanation - I already new that numeric values could be aliased in this way, I just didn't see it properly within the context of this code... until now :)

Thank you for helping.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf