Download Physics 121

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Physics 413
Chapter 8
IBM PC Assemblers
• An assembler is a program that takes your
assembly language program and converts the
instructions into op-codes that the
microprocessor can understand.
• The other job of the assembler is to calculate
the number of steps that the processor may
have to jump forward or backward if it
encounters a transfer of control instruction
like JNE or CALL. These two tasks are very
tedious for a human and are best relegated to
the assembler.
DEBUG & MASM
• The first one is a no-frills assembler called
DEBUG. It is easier for the beginner to use
and comes free with DOS for your IBM PC.
• The other is expensive and comes with too
many bells and whistles. It is called MASM
• DOS utility exe2 bin converts .exe to .com
• DEBUG cannot create .EXE (executable) files
• DEBUG is cheaper and easier to learn to use
for the beginner.
DEBUG
Type debug at the DOS prompt (C:>). All you will see
is _
Q
Exit from Debug
R
Displays the processor registers
R AX
Displays AX
A
Assemble. A 100 starts at CS:0100
D
Dump (display or list) 128 bytes of
memory
E 100
Enter data. Space bar for next byte!
F 100 120 AB
Fill 0100 through 0120 with AB
G = 100
Execute program starting 0100
P = 100
Single-step. Treats LOOP as a step
T = 100
Single-step. Not good for subroutine
U = 100
Unassemble displays mnemonics
Assembler Directives
• db is a directive that tells the assembler to store
the byte-size numbers
• db 2A 69 C4 5E will store these 4 bytes of data
• db “ hello ” will store ASCII codes of h, e, l, l, o
• equ assigns a value to a name
• stuff equ 7
What does MOV AL, TRICK do?
• Depends! The answer depends on how TRICK was
defined.
• If your program had a statement TRICK EQU 6D
then the number 6D will be copied into AL
• If TRICK was defined as TRICK DB 2BH, 57H, 8EH
then AL = 2B
MASM Program
.model small
.stack
.code
mov cx, 7h
mov si, offset mygoody
mov al, 0
again:add al, [si]
inc si
dec cx
jne again
.exit
.data
mygoody db 57h, a3h, 26h, 4bh, 69h, e5h, 7ch
end
What does MOV DX, offset TRICK do?
• offset is another directive
• If TRICK was defined as TRICK DB 2BH, 57H, 8EH
then DX = logical address of 2B
• If your program had a statement TRICK EQU 6D
then error
What does MOV DS, seg TRICK do?
• seg is another directive
• If TRICK was defined as TRICK DB 2BH, 57H, 8EH
then DS = segment of 2B
• If your program had a statement TRICK EQU 6D
then error