User Tools

Site Tools


opus:summer2012:amorse15:asmpart2

asm Keywords

asm Keyword 1

Fetch-Execute Cycle

Definition

It is the process the computer goes through in order to complete instructions. It grabs the instruction at the memory address in the program counter, then the program counter is incremented to the next instruction to be executed, the control unit then decodes the instruction at the address, and then it executes the program.

asm Keyword 2

Registers (General Purpose, Floating Point, Accumulator, Data)

Definition

Registers are used as storage in computers, as an alternate to main memory which can take time to access and is not always most efficient. They are usually used by the CPU. There are several types of registers:

Accumulator: The accumulator is a register that stores results for arithmetic and logical operations. This is a useful register to have, because constantly using main memory to store and access something as commonly done as arithmetic or logical expressions would be very inefficient speed-wise.(Is a data register)

Data Registers: Contain integers, characters, and other primitive data types. They generally contain the information that will be accessed by RAM and that will be manipulated by the CPU.

General Purpose: They are used to store information such as data or memory addresses to data.

Floating Point: As the name would imply, they store floating point values.

Registers can be different sizes, and the choice is dependent on how much information you wish to store, for this project we used 8-bit registers.

asm Keyword 3

Registers (Stack Pointer, Program Counter, Flag)

Definition

Registers are used as storage in computers, as an alternate to main memory which can take time to access and is not always most efficient. They are usually used by the CPU. There are several more types of registers:

Stack Pointer: In order to execute instructions in the order that they are supposed to be, the sequence of instructions are put into a stack. The stack pointer register points to the top of the stack, which is the instruction or command that is currently being executed.

Program Counter: The purpose of this register is to store the location of the next instruction to be executed. This is the register that is used in the Fetch-Execute cycle that I have previously explained.

Flag: Flag registers, as the name would imply, are used to store the flag registers and their statues. The flag registers are registers that are used to indicate if an event has occurred. There are several types of flags, in our project we have: Decimal, Interrupt, Overflow, Carry, Parity, Sign, and Zero. The flags are either set at '1' or '0', '1' if the event occurred (e.g. we checked if the register was 0 and it was, so we set the zero flag) and '0' otherwise.

Registers can be different sizes, and the choice is dependent on how much information you wish to store, for this project we used 8-bit registers.

asm Keyword 4

Registers (Index/Pointer)

Definition

Registers are used as storage in computers, as an alternate to main memory which can take time to access and is not always most efficient. They are usually used by the CPU. There are several more types of registers:

Index: A register used for keeping track of and modifying operand addresses for memory. It is commonly used in Branch Instructions, though we don't seem to be using them in our project, since we are able to use indirect addressing.

Pointer: I think that this is just the general case of registers that are used to show the next/current/or recent instruction to be used or memory address where data is located. Special cases of pointers would be: A Stack Pointer and a Program Counter.

Registers can be different sizes, and the choice is dependent on how much information you wish to store, for this project we used predominately 8-bit registers, and a couple of 16-bit registers.

asm Keyword 5

Negated Logic Operartions (NOT, NAND, NOR, XNOR)

Definition

As the name would imply, you negate the operator that the Not is attached to.

Demonstration

The demonstration will take the form of a logical table.

X Y X(AND)Y X(OR)Y X(XOR)Y X(NOT) Y(NOT) X (NAND) Y X(NOR)Y X(XNOR)Y
T T T T F F F F F T
T F F T T F T T F F
F T F T T T F T F F
F F F F F T T T T T

asm Keyword 6

Control flow and Data flow

Definition

Data flow is the process of moving and manipulating data between different sources, so that it will ultimately end up in the desired destination.

Control flow is the process of executing different tasks in a specific order in order to retrieve a desired effect, which may involve manipulating data.

The main similarity is that both are processes used to achieve some desired outcome. The main difference being that Data flow acts on, as you would figure, data, while Control flow refers to processing tasks. Also, due to its function, Control flow is implemented in an “assembly line” fashion, where one task is going to be started and finished before moving on to the next, whereas data can be manipulated in different locations simultaneously.

Demonstration

My demonstration will take the form of pseudocode.


Control Flow:
print “Input your age”
user_age = input
if user_age > 0

  • print “You were born at some point”
  • goto(end)

else

  • print “You have not been born yet”

end


Data Flow:
Global variable favorite_color = “green”
print “What is your favorite color”
user_input = “input”
Global variable favorite_color = “input”
end

asm Keyword 7

Machine Word

Definition

A word is the number of bits in a group for different processor designs. Most general computers today have either 32 or 64-bit word sizes, though 8 or 16-bits aren't unheard of.

Our standard for this project is 8-bits per data or memory address.

Demonstration

For the demonstration, I will the different registers we have, and the amount of bits they are assigned to take.

a(accumulator):8-bits
x:8-bits
y:8-bits
f(flag):8-bits
s(stack):8-bits
pc(program counter):16-bits
mar(memory address register):16-bit
mbr(memory buffer register):8-bit
iom(input/output memory):8-bit
iob(input/output buffer):8-bit

asm Keyword 8

Subroutines

Definition

Subroutines is the name given to programs, scripts, or sections of code that are generally going to be used many times.
Since they are used frequently, programmers will generally have shortcuts to get to these code snippets.
For the 6502, there are two instructions used for code flow control.

  • RTS(Return From Subroutine)
  • JSR(Jump to a Subroutine)


Demonstration

The demonstration will be in the form of the unix scripts going to and returning from the subroutine.

# !/bin/bash
#
# INSTRUCTION:
#       RTS (0x60) - return from subroutine.
#
# FUNCTION:
#       Pull address off of stack and set program counter.
# ARGUMENTS:
#       ---------
#       Implied functionality - no arguments needed.
#
# FLAGS:
#       Does not impact any flags
#
 
# Initialize Simulator Environment
source ../etc/simvar.sh
 
# Increment S register (Stack Pointer)
java -cp ../../lib Increment s # hmm.. need to make sure no flags are adjusted.
 
# Convert top of stack to hexadecimal value (lower order byte)
PCLOWER="0x01`reg2hex strip < ${REGDIR}/s.reg`"
 
# Increment S register (Stack Pointer)
java -cp ../../lib Increment s # hmm.. need to make sure no flags are adjusted.
 
# Convert top of stack to hexadecimal value (upper order byte)
PCUPPER="0x01`reg2hex strip < ${REGDIR}/s.reg`"
 
# Set the program counter with data we just pulled off the stack
echo -n "${PCUPPER}${PCLOWER}" > ${REGDIR}/pc.reg
 
# Increment Program Counter register
java -cp ../../lib Increment pc # hmm.. need to make sure no flags are adjusted.
 
exit 0



# !/bin/bash
#
# INSTRUCTION:
#       JSR (0x20) - jump to subroutine.
#
# FUNCTION:
#       Push address onto stack and set program counter.
# ARGUMENTS:
#       ${1} - absolute address of routine we're jumping to
#
# FLAGS:
#       Does not impact any flags
#
 
# Initialize Simulator Environment
source ../etc/simvar.sh
 
# Convert upper order byte of PC to memory byte to put on stack
cat ${REGDIR}/pc.reg | cut -c0-7 > ${REGDIR}/tmp.reg
reg2bin strip < ${REGDIR}/tmp.reg > ${MEMDIR}/mbr.mem
STACKTOP="0x01`reg2hex strip < ${REGDIR}/s.reg`"
memput main mbr ${STACKTOP}
 
# Decrement S register (Stack Pointer)
java -cp ../../lib Decrement s # hmm.. need to make sure no flags are adjusted.
 
# Convert lower order byte of PC to memory byte to put on stack
cat ${REGDIR}/pc.reg | cut -c8-15 > ${REGDIR}/tmp.reg
reg2bin strip < ${REGDIR}/tmp.reg > ${MEMDIR}/mbr.mem
STACKTOP="0x01`reg2hex strip < ${REGDIR}/s.reg`"
memput main mbr ${STACKTOP}
 
# Decrement S register (Stack Pointer)
java -cp ../../lib Decrement s # hmm.. need to make sure no flags are adjusted.
 
# Set the program counter with data we just pulled off the stack
echo -n "${1}" > ${REGDIR}/tmp.txt
hex2reg < ${REGDIR}/tmp.txt > ${REGDIR}/pc.reg
## Need to check and perform any address sanitization
## Need to ensure hex2reg exists
## Need in ensure hex2reg supports and can operate on 8- and 16-bit values (input and output)
 
exit 0
opus/summer2012/amorse15/asmpart2.txt · Last modified: 2012/08/07 23:01 by amorse15