Program to check whether a number is Even or Odd > Assembly Language
Program to check whether a number is Even or Odd > Assembly Language
Microprocessor
ASSUME CS:CODE,DS:DATADATA SEGMENT
MSG DB 10,13,'ENTER A NUMBER = $'
MSG1 DB 10,13,'NUMBER IS EVEN $'
MSG2 DB 10,13,'NUMBER IS ODD $'
DATA ENDS
CODE SEGMENT
START:
MOV BX,DATA
MOV DS,BX
LEA DX,MSG
MOV AH,09H
INT 21H
MOV AH,01H
INT 21H
SAR AL,01
JC ODD
LEA DX,MSG1
MOV AH,09H
INT 21H
JMP TERMINATE
ODD:
LEA DX,MSG2
MOV AH,09H
INT 21H
TERMINATE:
MOV AH,4CH
INT 21H
CODE ENDS
END START
/*
OUTPUT-------------
C:\Users\student>CD C:\Tasm 1.4\Tasm
C:\Tasm 1.4\Tasm>TASM ODDEVE
Turbo Assembler Version 3.0 Copyright (c) 1988, 1991 Borland Internationa
Assembling file: ODDEVE.ASM
Error messages: None
Warning messages: None
Passes: 1
Remaining memory: 460k
C:\TASM1~1.4\Tasm>TLINK ODDEVE
Turbo Link Version 2.0 Copyright (c) 1987, 1988 Borland International
Warning: no stack
C:\TASM1~1.4\Tasm>ODDEVE
ENTER A NUMBER = 2
NUMBER IS EVEN
C:\TASM1~1.4\Tasm>ODDEVE
ENTER A NUMBER = 1
NUMBER IS ODD
C:\TASM1~1.4\Tasm>
*/
Comments
Post a Comment