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
;############################################