0

I am attempting to learn the Assembly language and as a beginner, I am wondering if there is a good way to cmp and jump to a label only if the result of comparation is less than x and greater than y at the same time.

This is what I currently have:

print:
    pusha
    mov ah, 0x0e
    cmp al, 32
    jge print_stg2
    popa
    ret

print_stg2:
    cmp al, 126
    jle print_stg3

print_stg3:
    int 0x10
    jmp inputloop
  • 1
    Yes, sub/cmp/jbe (or ja) allow a range-check with only one conditional branch. [double condition checking in assembly](https://stackoverflow.com/a/5197264). (You'd want a tmp register to avoid messing up the original AL, though. Perhaps use AH, and only `mov ah, 0x0e` once you're about to execute `int 0x10`.) Also, `pusha`/`popa` around this tiny amount of code is really inefficient, and you're only modifying AH anyway. – Peter Cordes Aug 14 '21 at 20:13
  • @PeterCordes Thank you for your corrections. – Tigran's Tips Aug 14 '21 at 20:22

0 Answers0