An 8088 instruction - PowerPoint PPT Presentation

1 / 12
About This Presentation
Title:

An 8088 instruction

Description:

Z ; the zero flag, ZF=1 if the result was 0 ; ... ADC and SBB include the carry flag in and - operations ... can examine each register and the flags after each step ... – PowerPoint PPT presentation

Number of Views:101
Avg rating:3.0/5.0
Slides: 13
Provided by: drmar
Category:

less

Transcript and Presenter's Notes

Title: An 8088 instruction


1
An 8088 instruction
  • Label Instruction_mnemonic dest, src
    comment

The label is optional. It must always begin
with a letter and may contain only letters and
digits. It cannot duplicate a register name or
instruction mnemonic.
A three- or four-letter mnemonic indicating the
instruction to be performed
register, registeror register, memoryor memory,
registerNOT memory, memory
the assembler ignores everything after the
semicolon
2
Classes of 8088 instructions
  • Load Accumulators or memory MOV, XCHG
  • No flags are changed
  • The source is unchanged
  • Arithmetic
  • ADD, ADC, SUB, SBB, MUL, DIV, INC, DEC, NEG,
    IMUL, IDIV
  • Shift and Rotate
  • ROL, ROR, RCL, RCR, SHL/SAL, SHR, SAR
  • Logical
  • AND, OR, XOR, NOT

3
More Classes of 8088 instructions
  • Controlling the execution flow
  • JMP, CALL, RET, LOOP, Jxx
  • I/O
  • IN, OUT
  • Changing the state of flags
  • CLC, STC, CMC, CLI, STI
  • Using data to set flags
  • CMP, TEST
  • Formatting data
  • CBW, CWD
  • Stack PUSH, POP

4
Fortran to Assembly
  • Sum 0
  • DO 19 I 1, 5
  • Sum Sum I
  • 19 CONTINUE

All Math occurs inside the 8088 For a variable,
either a memory location is dedicated, or a
register is dedicated
5
Fortran to Assembly
  • Sum 0
  • DO 19 I 1, 5
  • Sum Sum I
  • 19 CONTINUE

S the sign flag, the most significant bit of
the last result arithmetic, logical, shift and
rotate instructions CMP, TEST
Z the zero flag, ZF1 if the result was 0
arithmetic, logical, shift and rotate
instructions CMP, TEST
Note! Not all instructions change the flags.
For example, Mov does not change any flags.
6
Fortran to Assembly
  • Sum 0
  • DO 19 I 1, 5
  • Sum Sum I
  • 19 CONTINUE

C the carry flag, arithmetic, logical,
shift and rotate, CMP, ADC and SBB include
the carry flag in and - operations
O the overflow flag, OF1 if the last
arithmetic instruction resulted in an overflow
P the parity flag, PF1 if the last instruction
resulted in even parity (shown as e in D86)
7
Carry vs. Overflow
  • Be careful about the difference between carry and
    overflow with signed arithmetic
  • 00000011 3 11111101 -3
  • 00000000 0 CF 1 OF 0 SF 0 ZF1
  • 01111110 126
  • 00000011 3
  • 10000001 -127 CF0 OF1 SF1 ZF0

8
Fortran to Assembly
  • Sum 0
  • DO 19 I 1, 5
  • Sum Sum I
  • 19 CONTINUE

a basic looping structure mov cx, 5 number
of times through the loop L1 denotes the top of
the loop instructions inside the loop go
here loop L1 terminates loop (like 19
continue)
9
Fortran to Assembly
  • Sum 0
  • DO 19 I 1, 5
  • Sum Sum I
  • 19 CONTINUE

mov cx, 5 number of times through the
loop L1 loop L1 terminates loop (like 19
continue)
mov ax, 0 ax takes the role of sum
add ax,cx sum sum i
What are the contents of ax and cx at this
point? ax 5 4 3 2 1 15 cx 0
10
a86 assembler
  • gt a86 myfile.ext
  • output is myfile.com, the machine language
    executable
  • also myfile.sym the symbol names (like L1) for
    the debugger
  • if there are errors
  • error messages are written to myfile.ext
  • error messages are marked with a tilda ()
  • the error messages are removed by a86
  • the original source (unmarked) is saved in
    myfile.old
  • the assembler can catch syntax errors, but not
    logic errors

11
d86 debugger
  • gt d86 myfile (or gt d86 myfile.com)
  • NOT d86 myfile.asm
  • this command would be attempting to debug the
    ASCII text file, not the executable
  • F1 is single step
  • can examine each register and the flags after
    each step
  • Any assembly language command can be executed in
    the debugger by simply typing the command
  • Q to exit debugger

12
Homework for Th. Aug. 26
  • A) Write assembly language code to duplicate the
    function of the following Fortran
  • N 7
  • Sum 100
  • DO 19 J 1 , N
  • Sum Sum - JJ
  • 19 Continue
  • B) Assemble this program and examine execution
    of this program in the debugger. After exiting
    the loop, what arecx, SF, ZF, CF, OF, PF, and
    the register used for sum, ?
Write a Comment
User Comments (0)
About PowerShow.com