Download presentation
Presentation is loading. Please wait.
Published byOsborn Hensley Modified over 8 years ago
1
DAT2343 Implementing Standard Logic Flows with 80x86 Assembler © Alan T. Pinck / Algonquin College; 2003
2
Jumping Out of Sequence Basic Form JMP address “address” will normally be specified using a label reference (but could be specified as a literal numeric address)
3
Variance In Numeric Code for a JMP Samples of numeric code for various JMP instructions (from DEBUG) 0ADB:021A EB04 JMP 0220 0ADB:021C EBF2 JMP 0210 0ADB:021E E9FF00 JMP 0320 0ADB:0221 E9FCFE JMP 0120 0ADB:0224 EA2003480B JMP 0B48:0320 Short: address within -127 to +128 of IP value (1 byte address) Near: address within the same segment (2 byte address) Far: address within a different segment (4 byte address)
4
Basic 80x86 Flags & Conditional Jump Mnemonics Zero flag (NZ, ZR) JNZ …; JZ … Carry flag (NC, CY) JNC …; JC … Sign flag (PL, NG) JNS …; JS … Overflow flag (NV, OV) JNO …; JO …
5
Basic 80x86 Flags & Conditional Jump Mnemonics (2) Important Note: All conditional jumps are “short” There are 4 other flags (which we will not use in this course): Parity, Interrupt Enable, Direction, and Auxiliary Carry There are some additional conditional jump mnemonics (presented on later slides) which combine flag settings.
6
Instructions Which Modify The Flags Most arithmetic operations: ADD, SUB, INC, DEC, CMP Bit-level logical operations: AND, OR, XOR, NOT Shifts and Rotates SHL, SHR, ROL, ROR
7
Instructions Which Do NOT Modify The Flags Any instruction not identified on the previous slide; Specifically, the following do NOT modify the flags: MOV IN JMP/Jxx
8
Unsigned Comparisons Less than (before)JB Less than Or Equal toJBE Equal toJE (or JZ) Not Equal toJNE (or JNZ) Greater than (after) Or EqualJAE Greater thanJA
9
Signed Comparisons Less thanJL Less than Or Equal toJLE Equal toJE (or JZ) Not Equal toJNE (or JNZ) Greater than Or Equal toJGE Greater thanJG
10
Limitations on Conditional Jump Distance As noted earlier all conditional jumps must be short jumps; the address must be within +127 and -128 bytes of the instruction following the conditional jump. When the location is further away than this a reversed conditional jump over a near (or far) jump must be used: JNC SkipCarryError JMP CarryError ;more than 128 bytes away SkipCarryError:
11
Implementing the IF…ELSE Structure IF num1 < num2 THEN ….. ELSE …. ENDIF mov ax,num1 sub ax,num2 jc then jmp else then: …… jmp endif else: …… endif:
12
Implementing the WHILE Structure WHILE num1 < num2 DO ….. ENDWHILE while: mov ax,num1 sub ax,num2 jc do jmp endw do: ……. jmp while endw:
13
Calling a Near Sub-Procedure To call a procedure within the same segment as the call: CALL procName
14
Near Procedure Structure Must be coded within the same segment as any call to this procedure: procName PROC NEAR ; instructions required by procedure RET procNameENDP
15
Calling a Far Sub-Procedure To call a procedure “procName” within a segment called “segName”: CALL segName:procName
16
Far Procedure Structure segName SEGMENT ; … procName PROC FAR ; instructions required for proc RET ; (translated as RETF, ; return far) procName ENDP ; … segName ENDS
17
End of Lecture
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.