Hi everyone, I understand this is a very basic question, but I'm still very new to assembly. I would just basically like to understand what the the following means:
=> The F and A after the decfsz command.
=> how do I know how many time the loop will execute (Probably something to do with the above question).
Here is my code. I'm just trying to flash some LEDs with a period of 1s
P.S. I'm not really sure if the decfsz command is used correctly.
Mod edit: code tags
=> The F and A after the decfsz command.
=> how do I know how many time the loop will execute (Probably something to do with the above question).
Here is my code. I'm just trying to flash some LEDs with a period of 1s
P.S. I'm not really sure if the decfsz command is used correctly.
Code:
; -----------------------------------------------------------------------------
; EMK310
; Example code 1.1
; Basic assembler program structure
; Lecturer: Prof T Hanekom
; Date of last revision: February 2016
;------------------------------------------------------------------------------
; SIMULATION, i.e. use SIMULATOR
; Check list: 1*. Simulation (no physical hardware) vs Programmer (stand alone)
; vs Debugger (ICD functionality)
;------------------------------------------------------------------------------
; Functioning: We first load 0Fh into the working register (WREG) and then from
; the WREG into PORTA (address 0F80h). We then clear WREG by loading 0F00h into
; and it and then into PORTA. Does it work? Why?
;
; Notes:
; 1. Two different but equivalent ways of specifying hex numbers in code
; 80h (for any number starting with a number) = 0x80 (equivalent)
; 0F80h (if the number starts with a letter) = 0xf80 (equivalent)
; For WATCH window: use 0xF80
;
; 2. Directives
; Help Contents > Language Tools > MPASMX Toolchain > MPASM Assembler > Directives
; Read through the information in this help file to familiarise yourself
; with the nature and use of directives. Identify the directives in the
; code below and look up their typical use in the help files.
; -----------------------------------------------------------------------------
title "Our first Assembler program"
list P=PIC18F45K22 ; processor type - include in your test & exam
; code so we can see you selected the correct
; device
#include "p18f45K22.inc
; -------------
; PROGRAM START
; -------------
;
org 0h ; startup address = 0000h
start movlw 0xFF ; move 11111111b to W register
movwf PORTA ; move W to port A
movlw 0x00 ; move 00000000b to W register
movwf PORTA ; move W to port A
BRA delay
delay equ 0x0F
again nop ;1 Instruction cycle each
nop
nop
nop
decfsz delay, F, A
BRA start
BRA again ;2 Intruction cycles
end
Last edited by a moderator: