• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/103

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

103 Cards in this Set

  • Front
  • Back
#
denotes constant
What is the size of a word instruction?
12 bits
What is the size of a data word?
8 bits
register W
accumulator
STATUS register
a
PC (Program Counter)
a
FSR (File Select Register)
a
IREAD
a
MODE register
a
How do you access a port's directional register?
!rportname
ex: !rb
Note: each bit in the 8-bit port register represents the respective i/o pin on that port
How do you set a port to be input or output?
mov !rportname, #constant
A 1 in binary represents an input; 0 an output
ex: mov !rb, #%11111111; set all of port b to input
How do you change logic levels of a port?
mov rportname, #constant
A 1 in binary represents high; 0 low
ex: mov rb, #00000000; set all of port b to logic level 0 (low)
nop
No Operation Performed
jmp
jump
used to jump to labels or different memory adresses
ex: jmp start; jumps to label start
clr
clear
clears a byte, or a bit of a byte
ex: clr rb; sets rb to 0
What can't clr be used with?
clearing a port directional register
ex: clr !rb; this won't work!
inc
increment
increments a register by 1
ex: inc w; w+1
What is compatability mode?
A directive in the device preprocessor statement; slows everything down so that the SX can run code written for other microcontrollers
add
Adds two registers together and stores them in the former
ex: add w,#3; w=w+3
What are local labels?
labels within labels
ex: label1
:label2; label2 is only visible within label1
How to you increment/decrement a register without modifying it?
You use mov w,++register or mov w,--register
ex: mov w,++reg; w=reg+1 reg==reg
mov w,--reg; w=reg-1 reg==reg
What are the watchdog prescaler values?
a
What must you do to keep the watchdog from resetting the SX unexpectedly?
Clear the watchdog periodically within it's time value
ex: clr !wdt; clears watchdog timer
setb
Set Bit
sets one bit in a register
ex: setb
What happens when you reset the SX while it's running?
All ports change back to inputs
xor
exclusive-or
XOR's one register with another, then stores the result in the former register
ex: xor reg,w; xor reg with w
#
constant
!
directional register
registers $00-$07
special
registers $08-$1F
general purpose
mov with anything other than w
w gets destroyed
jmp $+3
jump 3 instructions ahead
add pc,w
skip w steps
:
local label
dec 8
8-1==8
mov w,--8
8-1==w
8==8
equ
=
equate
ex: var1 equ 8
var1 points to register 8
ex: var1 equ $8
var1 holds the hex value $8
ds
reserve bytes for a variable
ex: var1 ds 2
var1 is now two bytes long
(put an org statement beforehand to use specific registers)
what's confusing about org?
Can refer to either data space or program space
What's wrong with this?

var1 ds 2
mov w,var2
Only the first byte of var1 is stored into w; use var1+1 to access the second byte of var1 (note: w is a one byte accumulator)
What's the difference between equ and = ?
when equ is used, the value of var1 cannot be changed

when = is used, the value of var1 can be changed
var.0
first bit of var
What's wrong with this?

mov var2,var1
mov var3,var1
Since there's no instruction to move one variable into another, var1 is moved into w, and then into the destination variable. Here, var1 is loaded into w twice, which is wasteful
mov var1-w
var1=var1-w
clc
clear carry bit of status register
clz
clear zero bit of status register
stc
set carry bit of status register
stz
set zero bit of status register
jb
jump if bit is set

ex: jb rb.0,test
will jump to label test when bit 0 of rb is 1
jc
jump if carry flag is set

ex: jc test
will jump to label test if the carry flag is set; else the program will continue as normal
jz
jump if zero flag is set

ex: jz test
will jump to label test if the zero flag is set; else the program will continue as normal
jnb
jump if bit is 0 (cleared)

ex: jnb rb.0,test
will jump to label test if bit 0 of rb is 0
jnz
jump if zero flag is 0 (cleared)

ex: jnz test
will jump to label test only if the z flag is 0
jnc
jump if carry flag is 0

ex: jnc test
test
tests for equality between two registers

ex: test var1,var2
basically it does var2-var1 and checks if the zero flag is set
djnz
decrements a register by 1 and stores the result back into the register, and if it's zero, jumps to the specified label
ijnz
increments a register by 1 and stores the result back into the register, and if it's zero, jumps to the specified label
and
and's var2 with var1 (or w), and stores it into var1 (or w). var2 can be replaced by a constant

uasge: and w,var2
or
or's var2 with var1 (or w), and stores it into var1 (or w). var2 can be replaced by a constant

uasge: or w,var2
xor
xor's var2 with var1 (or w), and stores it into var1 (or w). var2 can be replaced by a constant

uasge: xor w,var2
rl
rotate bits left (bit 7 shifts to carry flag, carry flag shifts to bit 0)
rr
rotate bits right (bit 0 shifts to carry flag, carry flag shifts to bit 7)
How do you multiply a register by 2?
shift the bits left 1
How do you divide a register by 2?
shift the bits right 1
jnb
jump if bit is 0 (cleared)

ex: jnb rb.0,test
will jump to label test if bit 0 of rb is 0
jnz
jump if zero flag is 0 (cleared)

ex: jnz test
will jump to label test only if the z flag is 0
jnc
jump if carry flag is 0

ex: jnc test
test
tests for equality between two registers

ex: test var1,var2
basically it does var2-var1 and checks if the zero flag is set
djnz
decrements a register by 1 and stores the result back into the register, and if it's zero, jumps to the specified label
ijnz
increments a register by 1 and stores the result back into the register, and if it's zero, jumps to the specified label
and
and's var2 with var1 (or w), and stores it into var1 (or w). var2 can be replaced by a constant

uasge: and w,var2
or
or's var2 with var1 (or w), and stores it into var1 (or w). var2 can be replaced by a constant

uasge: or w,var2
xor
xor's var2 with var1 (or w), and stores it into var1 (or w). var2 can be replaced by a constant

uasge: xor w,var2
rl
rotate bits left (bit 7 shifts to carry flag, carry flag shifts to bit 0)
rr
rotate bits right (bit 0 shifts to carry flag, carry flag shifts to bit 7)
How do you multiply a register by 2?
shift the bits left 1
How do you divide a register by 2?
shift the bits right 1
jnb
jump if bit is 0 (cleared)

ex: jnb rb.0,test
will jump to label test if bit 0 of rb is 0
jnz
jump if zero flag is 0 (cleared)

ex: jnz test
will jump to label test only if the z flag is 0
jnc
jump if carry flag is 0

ex: jnc test
test
tests for equality between two registers

ex: test var1,var2
basically it does var2-var1 and checks if the zero flag is set
djnz
decrements a register by 1 and stores the result back into the register, and if it's zero, jumps to the specified label
ijnz
increments a register by 1 and stores the result back into the register, and if it's zero, jumps to the specified label
and
and's var2 with var1 (or w), and stores it into var1 (or w). var2 can be replaced by a constant

uasge: and w,var2
or
or's var2 with var1 (or w), and stores it into var1 (or w). var2 can be replaced by a constant

uasge: or w,var2
xor
xor's var2 with var1 (or w), and stores it into var1 (or w). var2 can be replaced by a constant

uasge: xor w,var2
rl
rotate bits left (bit 7 shifts to carry flag, carry flag shifts to bit 0)
rr
rotate bits right (bit 0 shifts to carry flag, carry flag shifts to bit 7)
How do you multiply a register by 2?
shift the bits left 1
How do you divide a register by 2?
shift the bits right 1
jnb
jump if bit is 0 (cleared)

ex: jnb rb.0,test
will jump to label test if bit 0 of rb is 0
jnz
jump if zero flag is 0 (cleared)

ex: jnz test
will jump to label test only if the z flag is 0
jnc
jump if carry flag is 0

ex: jnc test
test
tests for equality between two registers

ex: test var1,var2
basically it does var2-var1 and checks if the zero flag is set
djnz
decrements a register by 1 and stores the result back into the register, and if it's zero, jumps to the specified label
ijnz
increments a register by 1 and stores the result back into the register, and if it's zero, jumps to the specified label
and
and's var2 with var1 (or w), and stores it into var1 (or w). var2 can be replaced by a constant

uasge: and w,var2
or
or's var2 with var1 (or w), and stores it into var1 (or w). var2 can be replaced by a constant

uasge: or w,var2
xor
xor's var2 with var1 (or w), and stores it into var1 (or w). var2 can be replaced by a constant

uasge: xor w,var2
rl
rotate bits left (bit 7 shifts to carry flag, carry flag shifts to bit 0)
rr
rotate bits right (bit 0 shifts to carry flag, carry flag shifts to bit 7)
How do you multiply a register by 2?
shift the bits left 1
How do you divide a register by 2?
shift the bits right 1