Assembly LAB: Find Smallest Number

  .MODEL SMALL

 .STACK 100H

 

 .DATA

    STR_1  DB  'Enter the First number : $'

    STR_2  DB  'Enter the Second  number : $'

    STR_3  DB  'The smallest  number is : $'

 

 .CODE

   MAIN PROC

     MOV AX, @DATA                ; initialize DS

     MOV DS, AX

 

     LEA DX,  STR_1             ; load and print  STR_1

     MOV AH, 9

     INT 21H

 

     MOV AH, 1                    ; read a character

     INT 21H

 

     MOV BL, AL                   ; save the input character into BL

 

     MOV AH, 2                    ; carriage return

     MOV DL, 0DH

     INT 21H

 

     MOV DL, 0AH                  ; line feed

     INT 21H

 

     LEA DX, STR_2             ; load and print STR_2 

     MOV AH, 9

     INT 21H

 

     MOV AH, 1                    ; read a character

     INT 21H

 

     MOV BH, AL                   ; save the input character into BH

 

     MOV AH, 2                    ; carriage return

     MOV DL, 0DH

     INT 21H

 

     MOV DL, 0AH                  ; line feed

     INT 21H

 

     LEA DX, STR_3             ; load and print STR_3

     MOV AH, 9

     INT 21H

 

     CMP BL, BH                   ; compare the BL and BH

 

     JNBE @ELSE                   ; jump to label @ELSE if BL>BH

 

     MOV DL, BL                   ; move first character into DL

     JMP @DISPLAY                 ; jump to label @DISPLAY

 

     @ELSE:                       ; jump label

       MOV DL, BH                 ; move second character into DL

 

     @DISPLAY:                    ; jump label

       MOV AH, 2                  ; print the character

       INT 21H

 

     MOV AH, 4CH                  ; return control to DOS

     INT 21H

   MAIN ENDP

 END MAIN

মন্তব্যসমূহ

এই ব্লগটি থেকে জনপ্রিয় পোস্টগুলি

Assembly LAB: Character Input Output

Assembly LAB: Print Alphabet(A-Z)