Assembler Test Essay, Research Paper
Nick Robertson
Assembeler Class: Take home test
1.What are the four steps of CPU execution are:
1) Fetch op code or immeiate data
2) increment IP
3) decode op and or execute
4) go to step 1
2.List all the 8086 register state their prupose. Group them
by general purpose, pointing, and segment. They are:
General Registers:
axAccumilator (general purpose storage)
bxPointer to memory
cxCounting (input/output addresses)
dxData (store info about peripherals
The main purpose of the above started registers is to contain
the initaial data for, and the reslts of, arithmetic or logical
instructions.
Pointing Registers:
diDdiestintaion index
siSource index
spstack pointer
bpBase pointer
The main purpose of the above stated registers is to point
to other areas in memory.
Segment-
sc Code segment
dsData segment
ss Extra segment
The main purpose of the above stated registers is to hold
segments of information.
3) List all the 8086 flags and state their purpose. Group them by
by state or control, they are:
State Flags:
State flags are so named becouse their values are influenced
by the precious intructions and reflect some pecularities as a result.
AFAuxiliary CarryFlag
CFCarry Flag
OFOverflow Flag
PDParity Flag
SFSign Flag
ZFZero Flag
Control Flag:
Control Flags are so named becouse their pupose is to control
the execution of certain intructions.
IFInterrupt Flag
TFTrap Flag
DFDirection Flag
4) Define Ram and Rom
ROM – Read Only Memory
-Perminent
- non-volitale ( is kept at shut-down)
RAM – Random Access Memory
-Changable
-Volitable ( is not kept at shut-down)
5)State and define the three busses used by the CPU.
also state if the bus is unidirectional or bidirectional.
They are:
Address-Bidirectional
hardware
Data -Bidirectional
Sends info ( Carrys info as well)
Control-Unidirectional
Mouse, Keyboard, etc……
6)A program that will take a single digit numeric
input from the computer, convert it to BCD, ass the number,
and output the result to the monitor.
.Model
.stack 100h
.code
Start:
mov ah, 01h
Int 21h
mov ax, 001h
cmp al, 09h
Jnz convert; jnz = jump not zero
mov ax, 4C00h
int 21h
end start
Convert
add ax, 01h; add 1 if over 9
ret
7)State the difference between a macro and a procedure.
Macro – Copies code a compilating / inserts
Procedure – Jumps to in
8)Give exaples of the following addresing modes:
Register – mov ax, cx
Indirect – mov ax, 6000h
mov ds, ax
Direct – mov ax, [0123h]
Indexed – mov ax, [bx + di]
9)Define the following assembler directives:
Extern – External to current code
Public – Can be called (internal)
Global – Combination of both
10)For every ‘push’ there is a ‘pop’
11)Write a program that will encrypt a string by XORing one character
with the next character in the string.
.Model tiny
.Data
grab db “this”
.code
start:
mov ax, @ data
mov ds, ax
lea bx, grab
lea si, grab
stinc:
inc si
xor [bx][si];[T][H]
inc bx
comp si, 03h
jne stinc
mov ax 4ch
int 21
end start
12)Write a program that will decrypt the program you just wrote.
.Model tiny
.Data
grab db “this”
.code
start:
mov ax, @ data
mov ds, ax
lea bx, grab
lea si, grab
lea dx, toinc
add bx, 04h
add si, 04h
stinc
dec si
xor [bx][si]
dec bx
cmp si, dx
jne stinc
int 21
end start
13)State the address 5F32A of the next op-code as a segmented address, a logical address. Give the offset address and the segment address.
5F32and shift to right
500000= F32A
14)List all the base-pointers registers and give the segmants that they can use. Label the default segmen register with each. Don’t forget about IP
– Ip must pair with cs, sp with ss becouse these regiesters are involved in automatic CPU operations.Then you can pair the general-purpose data pointing registers BX, Di, and SI with the data segment register DS
– The IP offset register is always asses to the CS segment register when addressing code memory. There is override available to the programmer.
– The BP or SP offset register is automatically added to the SS segment register when stack opertions are in progress. The programmer may not override the automatic selection of SS with SP. The programmer may override the automatic selection of the DS register and use anyone of the other three segment registers CS, ES, or SS.
– Any offset quantity using registers BX, DI, and Si is automaticlly added to the DS base register. The programmer may override the automatic selection of the DS register and use any one of the other three segment registeres CS, ES, or SS.
– The offset register DI is automaticlly used with the ES base register when stringoperations are taking place. The programmer may not override the selection of Di with ES when string operations are done.
15)Give an example of a struct that will store the data for a person age,
height, and weight.
HEALTH STRUCT
age dw 0h
height+dw 0h
weight+dw 0h
health ends