Program to check whether a number is Even or Odd using Macro > Assembly Language

Program to check whether a number is Even or Odd using Macro > Assembly Language

Microprocessor


ASSUME CS:CODE,DS:DATA



DATA 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

PRINT MACRO MESSAGE
LEA DX,MESSAGE
MOV AH,09H
INT 21H
ENDM

PRINT MSG

MOV AH,01H
INT 21H

SAR AL,01
JC ODD

PRINT MSG1

JMP TERMINATE

ODD:
PRINT MSG2

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

Popular posts from this blog

Intermediate Code Generation > C Program