ВУЗ: Не указан

Категория: Не указан

Дисциплина: Не указана

Добавлен: 14.06.2025

Просмотров: 988

Скачиваний: 0

ВНИМАНИЕ! Если данный файл нарушает Ваши авторские права, то обязательно сообщите нам.

Chapter 6 - Samples

Chapter 6 - Samples

Previous page

Table of contents

Chapter overview

webmaster.


Appendix A - Instruction Set

Previous page

Table of contents

Chapter overview

Next page

Appendix A

Instruction Set

Introduction

Appendix contains all instructions presented separately with examples for their use. Syntax, description and its effects on status bits are given for each instruction.

A.1 MOVLW

A.2 MOVWF

A.3 MOVF

A.4 CLRW

A.5 CLRF

A.6 SWAPF

A.7 ADDLW

A.8 ADDWF

A.9 SUBLW

A.10 SUBWF

A.11 ANDLW

A.12 ANDWF

A.13 IORLW

A.14 IORWF

A.15 XORLW

A.16 XORWF

A.17 INCF

A.18 DECF

A.19 RLF

A.20 RRF

A.21 COMF

A.22 BCF

A.23 BSF

A.24 BTFSC

A.25 BTFSS

A.26 INCFSZ

Appendix A - Instruction Set

A.27 DECFSZ

A.28 GOTO

A.29 CALL

A.30 RETURN

A.31 RETLW

A.32 RETFIE

A.33 NOP

A.34 CLRWDT

A.35 SLEEP

A.1 MOVLW Write constant in W register

A.2 MOVWF Copy W to f

Appendix A - Instruction Set

A.3 MOVF Copy f to d


Appendix A - Instruction Set

A.4 CLRW Write 0 in W

Appendix A - Instruction Set

A.5 Write 0 in f

A.6 SWAPF Copy the nibbles from f to d crosswise

Appendix A - Instruction Set

A.7 ADDLW Add W to a constant

Appendix A - Instruction Set

A.8 ADDWF Add W to f

A.9 SUBLW Subtract W from a constant

Appendix A - Instruction Set

A.10 SUBWF Subtract W from f

Appendix A - Instruction Set

A.11 ANDLW Logic AND W with constant

Appendix A - Instruction Set

A.12 ANDWF Logic AND W with f

Appendix A - Instruction Set

A.13 IORLW Logic OR W with constant

Appendix A - Instruction Set

A.14 IORWF Logic OR W with f

Appendix A - Instruction Set

A.15 XORLW Logic exclusive OR W with constant

Appendix A - Instruction Set

A.16 XORWF Logic exclusive OR W with f

Appendix A - Instruction Set

A.17 INCF

Increment f

Appendix A - Instruction Set

A.18 DECF

Decrement f

Appendix A - Instruction Set

A.19 RLF

Rotate f to the left through CARRY

Appendix A - Instruction Set

A.20 RRF

Rotate f to the right through CARRY

Appendix A - Instruction Set

A.21 COMF Complement f

Appendix A - Instruction Set

A.22 BCF

Reset bit b in f

Appendix A - Instruction Set

A.23 BSF

Set bit b in f

Appendix A - Instruction Set

A.24 BTFSC

Test bit b in f, skip if it = 0

Appendix A - Instruction Set

A.25 BTFSS

Test bit b in f, skip if =1


Appendix A - Instruction Set

A.26 INCFSZ

Increment f, skip if=0

Appendix A - Instruction Set

A.27 DECFSZ

Decrement f, skip if = 0

Appendix A - Instruction Set

A.28 GOTO Jump to address

Appendix A - Instruction Set

A.29 CALL

Call a program

A.30 RETURN

Return from a subprogram

A.31 RETLW Return from a subprogram with constant in W

Appendix A - Instruction Set

A.32 RETFIE

Return from interrupt routine

A.33 NOP No operation

Appendix A - Instruction Set

A.34 CLRWDT Initialize watchdog timer

A.35 SLEEP

Stand by mode

Appendix A - Instruction Set

Previous page

Table of contents

Chapter overview

webmaster.


Appendix B - Numeric Systems

Previous page

Table of contents

Chapter overview

Next page

Appendix B

Numeric Systems

Introduction

B.1 Decimal numeric system

B.2 Binary numeric system

B.3 Hexadecimal numeric system

Conclusion

Introduction

It was always difficult for people to accept the fact that some things differ from them or their way of thinking. That is probably one of the reasons why numeric systems which differ from a decimal are still hard to understand. Still, whether we want it or not, reality is different. Decimal numeric system that people use in everyday life is so far behind the binary system used by millions of computers around the world.

Each numeric system are based on some basis. With a decimal numeric system, that basis is 10, with binary 2, and with a hexadecimal system 16. The value of each decimal is determined by its position in relation to the whole number represented in the given numeric system. The sum of values of each decimal gives the value of the whole number. Binary and hexadecimal numeric systems are especially interesting for the subject of this book. Beside these, we will also discuss a decimal system, in order to compare it with the other two. Even though a decimal numeric system is a subject we are well acquainted with, we will discuss it here because of its relatedness to other numeric systems.

B.1 Decimal numeric system

Decimal numeric system is defined by its basis 10 and decimal space that is counted from right to left, and consists of numbers 0,1, 2, 3, 4, 5, 6, 7, 8, 9. That means that the end right digit of the total sum is multiplied by 1, next one by 10, next by 100, etc.

Appendix B - Numeric Systems

Example:

Operations of addition, subtraction, division, and multiplication in a decimal numeric system are used in a way that is already known to us, so we won't discuss it further.

B.2 Binary numeric system

Binary numeric system differs in many aspects from the decimal system we are used to in our everyday lives. Its numeric basis is 2, and each number can have only two values, '1' or '0'. Binary numeric system is used in computers and microcontrollers because it is far more suitable for processing than a decimal system. Usually, binary number consists of binary digits 8, 16 or 32, and it is not important in view of the contents of our book to discuss why. It will be enough for now to adopt this information.

Example:

10011011 binary number with 8 digits

In order to understand the logic of binary numbers, we will consider an example. Let's say that we have a small chest with four drawers, and that we need to tell someone to bring something from one of the drawers to us. Nothing is more simple, we will say left side, bottom (drawer), and the desired drawer is clearly defined. However, if we had to do this without the use of instructions like left, right, beneath, above, etc., then we would have a problem. There are many solution to this problem, but we should look for one that is most beneficent and practical! Lets designate rows with A, and types with B. If A=1, it refers to the upper row of drawers, and for A=0, bottom row. Similarly with columns, B=1 represents the left column, and B=0, the right (next picture). Now it is already easier to explain from which drawer we need something. We simply need to state one of the four combinations: 00, 01, 10 or 11. This characteristic naming of each drawer individually is nothing but binary numeric representation, or conversion of common numbers from a decimal into binary form. In other words, references like "first, second, third and fourth" are exchanged with "00,01, 10 and 11".