Answer to Question #285684 in Assembler for Ahmed Ali

Question #285684

1)What is Jumps in Assembly Language 8086? Explain Conditional and Unconditional Jumps with examples using Emu8086.

Give at least 2 examples of Jump in assembly language using Emu8086.


1
Expert's answer
2022-01-09T02:21:18-0500

Unconditional jump Is performed by the JMP instruction.

JMP         label

 

Conditional jump is performed by a set of jump instructions j<condition> depending upon the condition. The conditional instructions transfer the control by breaking the sequential flow and they do it by changing the offset value in IP.

Example: If a non-numeric key (other than 0-9) is pressed, it jumps to the stop label, otherwise it jumps to the print label.

      ; read character in al:

      mov ah, 1

      int 21h

 

      cmp al, '0'

      jb stop

 

      cmp al, '9'

      ja stop

     jmp print

 

 

print:…

stop:…

 

There are numerous conditional jump instructions depending upon the condition and data.

JE/JZ               Jump Equal or Jump Zero

JNE/JNZ          Jump not Equal or Jump Not Zero

JG/JNLE          Jump Greater or Jump Not Less/Equal

JGE/JNL          Jump Greater/Equal or Jump Not Less

JL/JNGE          Jump Less or Jump Not Greater/Equal

JLE/JNG          Jump Less/Equal or Jump Not Greater

JA/JNBE          Jump Above or Jump Not Below/Equal

JAE/JNB          Jump Above/Equal or Jump Not Below

JB/JNAE          Jump Below or Jump Not Above/Equal

JBE/JNA          Jump Below/Equal or Jump Not Above


DATA SEGMENT
msgEnter    db "Enter char: $"
msgWrong    db 10,"The wrong input$"
msgUpper    db 10,"This is upper case letter$"
msgLower    db 10,"This is lower case letter$"
DATA ENDS

CODE SEGMENT
START:
    MOV AX,DATA
    MOV DS,AX    
    MOV ES,AX

    mov dx, offset msgEnter
    mov ah, 9
    int 21h    
    
; wait for any key press:
    mov ah, 0
    int 16h    
    mov     ah, 0eh
    int     10h  
    
; Check char
   cmp al,'A'
   jl _wrong            ; char < A
   cmp al,'z'
   jg _wrong            ; char > z
   cmp al,'Z'
   jg nextCheck        ; Z > char < a
   jmp displayMsg    

nextCheck:    
    cmp al, 'a'    
    jl  _wrong    ; Z < char < a

displayMsg:
; al = char
    cmp al, 'a'
    jge displayLow
;************************************

   mov dx, OFFSET msgUpper        ; address of string  
       mov ah, 9
    int 21h              ; writes a string
   jmp _quit

displayLow:
   mov dx, OFFSET msgLower        ; address of string  
    mov ah, 9
    int 21h      ; writes a string
   jmp _quit

 _wrong:
   mov dx, OFFSET msgWrong        ; address of string msgEnter
       mov ah, 9
    int 21h                  ; writes a string "The wr   "

 _quit:    
   MOV AH,1            ; Waiting for a key press
    INT 16H    

EXIT_PROG:            ; Program is terminated
     MOV AH,4CH
     INT 21H

CODE ENDS
END START

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS