Skip to content

Instantly share code, notes, and snippets.

@kp96
Created June 30, 2015 14:18
Show Gist options
  • Save kp96/22673ccc75299bc45e18 to your computer and use it in GitHub Desktop.
Save kp96/22673ccc75299bc45e18 to your computer and use it in GitHub Desktop.
Alp programs
DATA SEGMENT
MSG1 DB 'NUMBER IS EVEN$' ;define byte
MSG2 DB 'NUMBER IS ODD$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA ;Initialize DS to address
MOV DS,AX
MOV AX,17H
TEST AX,01H
JNZ EXIT
LEA DX,MSG1
MOV AH,09H
INT 21H
JMP LAST
EXIT: LEA DX,MSG2 ;Declare it is Odd number.
MOV AH,09H ;display string function
INT 21H
LAST: MOV AH,4CH ;DOS function: Exit program
INT 21H ;display it
CODE ENDS
END START
To find the factorial of a given number
mov CX,0005H
MOV AX,0001H
CMP CX,AX
JC L1
L2:MUL CX
LOOP L2
L1:MOV [5000H],AX
HLT
To find the square root of a given number
MOV BL,51H
MOV CL,00H
L1:INC CL
MOV AL,CL
MUL AL
CMP AL,BL
JNZ L1
MOV [2000H],CL
HLT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment