3) Write a program to print out a random number from 1..100.
USING ASSEMBLY LANGUAGE
CODE
DATA SEGMENT
MSG1 DB 10,13,'RANDOM NUMBERS ARE : $'
MSG2 DB 10,13,' $'
RES DB 10 DUP ('$')
DATA ENDS
CODE SEGMENT
ASSUME DS:DATA CS:CODE
START:
MOV AX,DATA
MOV DS,AX
LEA DX,MSG1
MOV AH,9
INT 21H
LEA DX,MSG2
MOV AH,9
INT 21H
NXT:
MOV AH,2CH ; Set time function
INT 21H
MOV AX,DX ; DH=seconds,DL=hundredths of second
XOR AH,AH
LEA SI,RES
CALL HEX2DEC
LEA DX,RES
MOV AH,9
INT 21H
LEA DX,MSG2
MOV AH,9
INT 21H
JMP NXT
MOV AH,4CH
INT 21H
CODE ENDS
HEX2DEC PROC NEAR
MOV CX,0
MOV BX,10
LOOP1: MOV DX,0
DIV BX
ADD DL,30H
PUSH DX
INC CX
CMP AX,9
JG LOOP1
ADD AL,30H
MOV [SI],AL
LOOP2: POP AX
INC SI
MOV [SI],AL
LOOP LOOP2
RET
HEX2DEC ENDP
END START
Get Answers For Free
Most questions answered within 1 hours.