Condition: jumps if CF = 1 or ZF = 1. After CMP a, b a borrow means a < b and a zero result means a = b; either one gives a ≤ b for unsigned numbers. It is the exact opposite of JA, which is why the two pair up when a jump has to be inverted.
Combined with a subtraction it gives a one-compare range test. Here the question is whether a character is an uppercase letter: after subtracting "A", the letters become 0..25 and everything else, including characters below "A" that wrap around, is larger.
MOV AL, "Q"SUB AL, "A" ; "A".."Z" become 0..25CMP AL, "Z" - "A" ; 25MOV DL, "Y" ; MOV leaves the flags aloneJBE SHOW1 ; taken: DL stays "Y"MOV DL, "N"SHOW1:MOV AH, 02h ; DOS: print the character in DLINT 21h
For signed values the matching jump is JLE. Use JBE for characters, counts, sizes and addresses.
Range
On the 8086 JBE exists only in the SHORT form: two bytes, opcode 76h and a signed 8-bit displacement counted from the end of the instruction. The target must lie within −128..+127 bytes of that point. To go farther, invert the test and hop over an unconditional JMP, which can reach the whole segment. MASM 6 makes this rewrite itself when it finds the target out of range (its default OPTION LJMP), so the listing may show two instructions where you wrote one.
JA SKIP1 ; the opposite test, a short hopJMP FARAWAY ; any distance in the segmentSKIP1:
Later CPUs
The 80386 added a near form of every conditional jump, 0Fh 86h followed by a 16-bit displacement (32-bit in 32-bit code), so from the 386 on JBE can reach anywhere in the segment. Code for the 8086 must stay with the short form.