EECE 340 Pratt Test 1

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

write a program to make all pins of port a 1

DDRA = input output command, if 0, input if one, push it out set ddra to all 1s, calling out command, says all pins are outputs then output porta of register 20 to push the acural values

what are the two kinds of jumps?

There are 2 kinds of Jump, both followed by a label Unconditional Jump: When CPU executes an unconditional jump, it jumps unconditionally (without checking any condition) to the target location. Example: RJMP and JMP instructions Conditional Jump: When CPU executes a conditional jump, it checks a condition, if the condition is true then it jumps to the target location; otherwise, it executes the next instruction. such as a certain flag being set on the sreg

what is the adc good for

add with carry

FLIP The following code gets the data present at the pins of port C and sends it to port B indefinitely, after adding the value 5 to it: .INCLUDE "M32DEF.INC" LDI R16,0x00 ;R16 = 00000000 (binary) OUT DDRC,R16 ;make Port C an input port LDI R16,0xFF ;R16 = 11111111 (binary) OUT DDRB,R16 ;make Port B an output port(1 for Out) L2: IN R16,PINC ;read data from Port C and put in R16 LDI R17,5 ADD R16,R17 ;add 5 to it OUT PORTB,R16 ;send it to Port B RJMP L2 ;continue forever

explain

***FLIP program counter gives first adress to execute the program, data bus reads in the first command located in 0 to the instruction decoder (31) , instruction decoder decodes the instruciton to read I/O 17 and to place it in register A adress bus gets 1 from the program counter, goes to 1 command locations, data bus reads command into instruction decoder, decoder deciphers to copy what is in a into b,

explain how this computer and it's components work

FLIP some of them use actual decimal values for register to binary, ldi uses r16 as 0 since it is only r-16-31

explain these avr instruction codes (pratts words)

FLIP $ = hex, these memory locations are special purpose registers, where 0 - 1F are general purpose registers could rename the i/o locations the first 32 or 0-31 are general purpose registers the next 64, 0x20-0x-5F are special purpose registers

explain this chart

what does pipelining do in an avr?

fetches instructions and executes at the same time. does not speed up processes, just doubles the amount of work done

explain ddrx

load value in register you want it to be if all are output = all 1 if all are input, all 0, always output ddr, just state the value using the ldi, just use it to state weather input or output

how to use lsl and lsr

logical shift right last bit stores in the carry flag

explain how delay works in a loop part 1 (1/frequency) = period or seconds

look at loop, times machine instructions times amount of times loops occur times the second type, which is 1/frequency

FLIP A<- [17], [] = memory location opcode = 001/operand = 10001 - the value of register 17 0001 0001 = 31 h, A<-- A + B opcode = 100/ operand = 00001, 01 = to register B, A is always assumed B <-- A opcode = 110/ operand = 0(01)(00) (01) = register b, (00)=a what youre moving to is the first two digits, what youre copying from is the second two 1100 0100 = C4 h,

look at the opcode chart and examples, and try to explain each one in blue,explaining the opcode and operand , also what the hex digits mean

if r17 holds the value ox77, describe what values when added or subtracted to and from r17 will set the z flag

z flag = arithmetic operation equals zero sets the flag if the value ox77 is subtracted from it, the z flag will set, and if -0x77 is added to it, the then the z flag will set also

load contents of ox130 into R18

LDI XL, 0x30 LDI XH, 0x01 LD R18, X

store contents of r23 to location 0x139F

LDI ZL, 0x9F LDI ZH, 0x13 ST Z, r23

what is code LDS?

LDS Rx, Addr load data to from memory to register load data from space space LDS R3, x60

Write a program that if R20 is equal to R21 then R22 increases.

SUB R20,R21 ;Z will be set if R20 == R21 BRNE NEXT ;if Not Equal jump to next INC R22

Write a program that if R26 < R24 then R22 increases.

SUB R26,R24 ;Z will be set if R20 == R21 BRCC L1 ;if Carry cleared jump to L1 INC R22

Write a program that if R26 >= R24 then R22 increases.

SUB R26,R24 ;Z will be set if R20 == R21 BRCS L1 ;if Carry set jump to L1 INC R22

how to subtract in an arithmetic operation? what is the format and it explained?

SUB Rd,Rs Rd = Rd - Rs Example: SUB R25, R9 R25 = R25 - R9 SUB R17,R30 R17 = R17 - R30

what is the realtion ship between adresses and andress lines?

ln base 2 (adresses) = adress lines, 2^x = adresses, 2^8adress line = 256 adresses

what are the logic instructions?

load in vallue, then and them together, if and, then if they are 0 and 1, the zeros go away comm is one register

what is the difference between rjmp and jmp?

rjmp = jumps relative to where instruction is 296 instructions before or after the instruction given jump = anywhere, but longer adress because can be in any register

difference between rjmp and jmp

rjmp = relative to where you are for shorter instruuction, but limited distance jmp = anywhere in memory, longer adress

difference between ram an dom

rom = fixed and permanent information ram - volatile, when turned off, or in relation to time, information changes with time, temporary

explain the different flags on an sreg

sub = a-b = 0, 0 flag turns to a 1 carry = a+b, greater than 8 bits, or a-b is used and a is smaller than be

what is the out command? exampl and formatting?

take somethign from register to I/O adress store contents to GPR from i/o adress

what is the in command? example and formatting?

take something from I/O adress to register

what are include statements?

tell the avr assembler to add the contents of a file to your program, includes different formats, and already known things such as ddr port and pin

explain prefixes from -9 to positive 9

-9 nano -6 micro 6 mega 9 giga

explain the structure of i/o pins

3 registers one ddr, one port, one pin

explain the amount of registers in an avr

32 gpr - 0-->1F 64 spr = 20 --> 5F all 8 bits memory adres or i/o locations

how many registers in an avr cpu by how many bits? what is the point of general purpose registers?

32, r0-r31, 8 bits, to temporarily store information, avr = microcontroller

50% duty cycle?

50% high, 50% low

how many i/o register are in an avr microcontroller? how many GPR? explain why these registers have distnict i/o and ram adresses

64 i/o adresses 32, r0-r31, 8 bits, to temporarily store information Without accessibility from data space (not "via SRAM") there would be no way to perform indexed/indirect addressing of registers, adding complexity to a large number of algorithms and programming methods. On the other hand, having I/O space allows IN and OUT to be single-word instructions, reducing the size and runtime of simple code. Register space is independent of SRAM space, and the SRAM is moved up the appropriate number of locations in data space to compensate. Having a unique address assigned to each port allows your computer to easily recognize and locate devices attached to your computer. Whether it is a keyboard, mouse, monitor, printer, or any other device, the computer can locate it by its I/O address. Because I/O addresses are controlled by the computer's motherboard, they do not use up any system memory, or RAM. talking about from the chart, how mem starts at $20, and i/o starts at $00 starts at ox20 = 32, which is after 0-31 of gpr, reach io register has a relative adress in comparison to the beginning of the i/o memory called the i/o adress

bit and location relationship

8 bit = 2^8 locations

what is a status register

8 bits, each bit represent something different (flag)

how do you add for arithmetic and logic operations? what is an example of the format, with the meaning explained?

ADD Rd,Rs Rd = Rd + Rs the value is stored back into that register defined, and the literal is combined with the value in the register ADD R25, R9 R25 = R25 + R9 ADD R17,R30 R17 = R17 + R30

**what are some of the pieces inside of a cpu? what does eahc one do?

ALU = number cruncing and computation register= memory location in CPU, uses values in register for computation, temporary instruction decoder- translates commands and decipher what intructions should do, Program counter = tells you when to move on from that program and move to next command, keeps track of intruction, point adress to next command to be executed, which instruction we are on

how do you increment a value vs decrement it?

INC Rd Rd = Rd + 1 Example: INC R25 R25 = R25 + 1 DEC Rd Rd = Rd - 1 Example: DEC R23 R23 = R23 - 1

what instruction code do you use for Loading values into the general purpose registers? what is an example of the format, with the meaning explained? what registers can ldi be used with?

LDI Rd, k put the literal value(k) into some register (RD) Example: LDI R16,53 R16 = 53 LDI R19,132 LDI R23,0x27 R23 = 0x27 the upper 16, r16-r31

what are the steps to execute and perform a function call?

Program counter gets pushed on stack so it knows how to return function takes up two lines because it has a long instruction call funcntion name Functioname: return

what is differnce bectween LDS and STS

STS =stores something from register to memory RTS = load data to from memory to register

what is code STS?

STS Addr, Rx stores something from register to memory store data to space from register STS x60, R3

FLIP i/o device 17, load in a copy a and put in b take whatever is adress 7 and put into a put a+b into A put a in memory location

Try to explain what this psuedo code means

dipslay one 1 on a 7 segment display for PortA

ddrc saying output all pins in porta porta command and ldi should come second because they actually output the values

equ vs set

cant change equ later on

what are .equ and .set

cant change equ later on, but you can .set .equ - defined a constant value for a fixed adress .equ - defined a constant value for a fixed adress in memory

what triggers carry bit vs half carry bit vs z flag

carry = carry beyond d7 bit half carry = carry from d3 to d4 bit z flag = arithmetic operation equals zero sets the flag

typical format of commands for avr cpu

command (destination - source) register or memory location closest to command is the destination it will end up in

what is the mov instruction?

copies register mov r23, r19 copiees r19 to r23

explain the opcode vs the operand

if x has [] = memory locations if none, it is a literal value

explain the purpose of a stack

impements a function, like an array, which

explain the use of the chart give an example

it gives the name and actual memory or i/o adress, and you can use the memory adress or the actial name when computing mathematical equations IN r15, Sreg Sreg = oxyy

whar are the conditional jump instructions? how do they work?

jumps to location or label only if the given condition is satisfied,

how do you call and write a function?

make sure your function always ends with return and ninitalize the stack point

what is the difference between a microprocessor and a microcontroller?

microprocessor- computer system with i/o and memory microcontroller - can do computing, but most functions are built into it, a to do io capabilities built into it, less powerful

how do you set a certian bit in a register? format (each register contains 8 bits

number will only be 0 -7, each port has 8 bits of info

what do you use to make a i/o device a input device vs an output

output = porta, ddra = 1111 1111, use out command(take somethign from register to I/O adress, out ox22, r19) input = pina, ddra = 0000 0000, use in command, (take something from I/O adress to register, in R19, ox22)

whats the difference between pina and porta?

pina = used for inputs porta = used for outputs

explain the push and pop on a stack

push = puts conents of register to memory relative to the stackpoint pop - take top of stacka nd put in register pushr22 - takes contents of r22 to top of stack, stack point is above pop r21- takes top of stack under stack point and puts in r21

what is a stack? what is the push and pop on a stack?

push a register on a stack point(dec pop a register off a stack point off (inc farhter from bottom? SP/stack port = says where you are on the stack like an array LIFO - last in first out, push takes a value from a register places it on the stack, where pop takes the highest value on the stack and places it in a register

read vs write with I/O

read I/O into the CPU (input) write from CPU into I/O (output)

explain the avr out instruction, its operands and how it is utilized compare to in

the out instruction tells the cpu to store the gpr to the io register. the io register will have hte same values as the gpr. for example , out portd, r10 copies the contents of r10 to portd, out (first operand = i/o location, second operand = register) utilized to output a value, such as for a 7 segment display in in struction tells the cpu to load one byte from an i/o register to a gpr, the gpr will have same value as i/o register. in (first operand = register, second operand = memory location)

in the book when do you use registers for certain operations?

the top half of registers, r16-31, are reserved to store values in an avr, for LDI only

how do you cjheck if a bit is one of a certain register, what does it do

this command skeps nnext instruciton

how do you check if a bit is 0 in a certain register?

this command skips next instruction

what are the spl and sph and how are they used?

type of i/o registers, stack point low and stack point high, used to attain lowest and highest value respectively in a general purpose register and later store in a stack, they define the stack point stack point high processes the high byte and the low processes th elower byte, The AVR 8-bits microcontroller stack pointer can either consist of a single I/O register SPL (Stack Pointer Low) or two (2) I/O registers SPL and SPH (Stack Pointer High). The size of the stack pointer depends on the amount of data memory a microntroller contains. If the entire data memory can be addressed using 8-bits then the stack pointer is 8-bits wide i.e. SPL only, otherwise the stack pointer is consist of SPL and SPH. initalize the stack using the stack point ldi r16, high (ramend) out, sph, r16 ldi r16, low (ramend) out spl, r16

what is indirect adressing? how do you use it?

use variables to sts and lds, no s, each variable represented by two registers xyz represent a memory location, you load the lower 8 bits into the lower of x, and the upper 8 bit into the upper of x, and can store registers to these memory location to access more memory load literals into high or low portion, do not use s on ld or st,

what is no op?

wastes operation of clock cycle


Set pelajaran terkait

7.2 - Methods of Blood Gas Analysis

View Set

"Θα σου κάνω μερικές ερωτήσεις και θα πρέπει να μου απαντήσεις με σωστή σύνταξη. Θα σου έχω πίσω από την ερώτηση πως θα πρέπει να είναι η απάντησή σου αν δυσκολευτείς."

View Set

pi kappa phi chapter 1 study notes

View Set