Viewing code of Assembly cubing
// ------ Assembly cubing.CPP --------------
//--- Programmed By Rajesh -----
;################################################
;#
;# Q. Write an assembly language program that takes any number
;# from keyboard in ASCII format. Convert the number to binary
;# and perform some arithmetic operation on it, e.g. find its
;# factorial, or find its square, or add some value to it, etc.
;# Then display the result back in ASCII format on the screen.
;#
;###########################################################
;##
;# Programmed By
;# Name: Rajesh Pandey
;# Group: Computer Engineering
;# Roll: 22102 (20)
;####
;################################################
title Cubing any number
.model small
.stack 100
.data
NyInitialMessage db "This program calculates Cube root ","$"
enterprompt db 0dh,0ah," Enter Any Number for Cubing:","$"
outAscii dw 50 dup(' ') ,"$"
crlf db 0dh,0ah,"$"
binaryNum dw 0
multiply dw 1
namepar label byte
numlength db 2
numlen db ?
numAscii db 4 dup('')
;###################----Code----#############################
.code
main proc far
mov ax,@data
mov ds,ax
call welcome
call scan
call toBinary
call cubing
call toAscii
;### Exit to dos now #################
mov ax,4c00h
int 21h
main endp
;############# Program finished . Now definitions for subroutines
;############ Welcome message ########################
welcome proc near
mov ah,09h
lea dx,NyInitialMessage
int 21h
ret
welcome endp
;################# Scan Number ############################
scan proc near
mov ah,09h
lea dx,enterprompt
int 21h
lea dx,namepar
mov ah,0ah
int 21h
ret
scan endp
;#########------Cubing ----####################
cubing proc near
mov ax,binaryNum
mul ax
mul binaryNum
ret
cubing endp
;############### Convert TOASCII ##########################
toAscii proc near
mov cx,10
lea si,outAscii + 49
; lea si,outAscii
start2:
cmp ax, cx ;value < 10?
Jb next ;yes, exit
Xor dx, dx ;clear upper quotient
Div cx ;divide by 10
Or dl, 30H
; INC si
Mov [si], dl ;store ASCII character
dec si
; inc si
Jmp start2
Next:
Or al, 30h ;store last quotient
mov [si],al
mov ah,09
lea dx,crlf
int 21h
lea dx,outAscii
mov ah,09h
int 21h
RET
toAscii endp
;############### TO BINARY PROCEDURE #######################
toBinary proc near
mov bx, 10 ;mult factor
mov dl, numlen ;count for loop
mov cx,dx
lea di,numlen
lea SI, numAscii ;address of ASCIIVAL
start1:
mov al, [si] ;select ASCII character
and ax, 000FH ;remove 3-zone
mul multiply ;multiply by 10 factor
add binaryNum, ax ;add to binary
mov ax, multiply ;calculate next
mul bx ;10 factor
mov multiply, ax
dec si ;last ASCII character
dec cx
jnz start1
ret
toBinary endp
;###############################################################
end main
; Program terminates
;############################################
Home
Library Home:
- 1 1111
- 2 AVG_LINE
- 3 Assembly cubing
- 4 EX02_102
- 5 EX02_18
- 6 EX03_10A
- 7 EX03_11A
- 8 EX03_12A
- 9 EX03_9A
- 10 EX18A_R
- 11 EX1_8AR
- 12 EX2_102B
- 13 EX2_102C
- 14 EX2_Q4
- 15 EX3R9A
- 16 EX3_8A
- 17 EXCEQNO4
- 18 EXCSQ6A
- 19 EX_2_102
- 20 EX_CPLUS
- 21 FIB1
- 22 FIB2
- 23 FIB3
- 24 FIBONAC
- 25 FIB_NO_R
- 26 Fibonaci_without ercursion
- 27 MULTIRAJ
- 28 PALINDCT
- 29 PLDRM_N
- 30 Pointer matrix multiply
- 31 RAJ3
- 32 RAJAGE
- 33 RAJMAT1
- 34 RPBROKER
- 35 RPDIGIT
- 36 RPDIGIT1
- 37 RPKILOMETE
- 38 RPOVERTIME
- 39 RPRestaurantBilling
- 40 SRCOMP1
- 41 SRIIMP
- 42 STRUCTCW
- 43 socket programming