Title: An 8088 instruction
1An 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
2Classes 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
3More 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
4Fortran 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
5Fortran 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.
6Fortran 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)
7Carry 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
8Fortran 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)
9Fortran 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
10a86 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
11d86 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
12Homework 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, ?