0% found this document useful (0 votes)
18 views4 pages

Program That Find The Circumference of A Circle Code:: Figueroa, Ma. Katrina CSO002L1 IT32FC3 Sir Avestro

The document contains an assembly language program that calculates the circumference and area of a circle given a radius input by the user. It prompts the user to enter a radius, then calls subroutines to calculate and display the area and circumference. The area is calculated by multiplying pi by the radius squared, and the circumference by multiplying pi by 2 times the radius.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views4 pages

Program That Find The Circumference of A Circle Code:: Figueroa, Ma. Katrina CSO002L1 IT32FC3 Sir Avestro

The document contains an assembly language program that calculates the circumference and area of a circle given a radius input by the user. It prompts the user to enter a radius, then calls subroutines to calculate and display the area and circumference. The area is calculated by multiplying pi by the radius squared, and the circumference by multiplying pi by 2 times the radius.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Figueroa, Ma.

Katrina CSO002L1
IT32FC3 Sir Avestro

Program that find the circumference of a circle
Code:


.MODEL SMALL
.STACK
.DATA
PIx100 EQU 314
MSG1 DB "Enter radius: ",'$'
MSG2 DB 0AH,0DH,"The area of the circle is: ",'$'
MSG3 DB 0AH,0DH,"and it's circumference is: ",'$'
AREA DW ?
CIRCUMFERENCE DW ?
VALUE DW ?
.CODE
start: MOV AX, @data
MOV DS, AX

MOV AH, 09H
LEA DX, MSG1
INT 21H
MOV AH, 3FH
LEA DX, VALUE
INT 21H
LEA SI, VALUE
CALL CHAR2INTR


MOV VALUE, AX
MUL VALUE
MOV BX, PIx100
MUL BX
MOV BX, 100
MUL BX
MOV BX, 100
DIV BX
MOV AREA, AX

MOV AX, VALUE
MOV BX, 2
MUL BX
MOV BX, PIx100
MUL BX
MOV BX, 100
MUL BX
MOV BX, 100
DIV BX
MOV CIRCUMFERENCE, AX

MOV AH, 09H
LEA DX, MSG2
INT 21H
MOV AX, AREA
CALL DISPLAYREAL

MOV AH, 09H
LEA DX, MSG3
INT 21H
MOV AX, CIRCUMFERENCE
CALL DISPLAYREAL


MOV AH, 4CH
INT 21H

CHAR2INTR PROC
PUSH BX
PUSH CX
PUSH DX
PUSH SI
PUSHF

MOV AX, 0000H
MOV CX, 0000H
CLOOP1: MOV AX, [SI]
CMP AL, '9'
JNLE XCLOOP1
CMP AL, '0'
JNGE XCLOOP1
INC CL
INC SI
SUB AL, 30H
PUSH AX
JMP CLOOP1

XCLOOP1: MOV BX, 0001H
MOV DX, 0000H
CLOOP2: CMP CL, 0
JE XCLOOP2
POP AX
MUL BL
ADD DX, AX
MOV AX, 10
MUL BL
XCHG AX, BX
DEC CX
JMP CLOOP2

XCLOOP2: MOV AX, DX
POPF
POP SI
POP DX
POP CX
POP BX
RET
CHAR2INTR ENDP

displayReal PROC
PUSH AX
PUSH BX
PUSH CX
PUSH DX
PUSHF
MOV BX, 10
MOV DX, 0000H
MOV CX, 0000H
.tryloop3: MOV DX, 0000H
DIV BX
PUSH DX
INC CX
CMP AX, 0
JNE .tryloop3

SUB CX, 2

.tryloop4: POP DX
ADD DX, 30H
MOV AH, 02H
INT 21H
LOOP .tryloop4

MOV DL, '.'
MOV AH, 02H
INT 21H
MOV CX, 0002H
.tryloop5: POP DX
ADD DX, 30H
MOV AH, 02H
INT 21H
LOOP .tryloop5
POPF
POP DX
POP CX
POP BX
POP AX
RET

END start


OUTPUT:



Enter Radius: 5
The area of the circle is: 78.5
And its circumference is: 3.14

You might also like