Posted By : Murugan Andezuthu Dharmaratnam
Posted On : 15 November 2014
Keywords : Cube root, 8086 cube root of a number sample code, Assembly Lanugage 8086 cube root of a number sample code, Sample Code

Cube Root Of A Number Using Assembly Language

Cube Root Of A Number 8086

The sample code below is used to find the cube root of a number in 8086. The hexToAsc is a procedure to convert integer from hexa decimal to ascii



Sample Code


org 100h

main proc near
  MOV AX,X
  MOV BX,X
  MUL BX
 
  MUL BX
  MOV CUBE,AX
 
 
 
    mov ax,CUBE       ; AX Contains Hex 55H = 85 Decimal
    mov si,offset strHextToAsc  ;   SI Offset Where Converted
    call hexToAsc
    
    
    mov ah,,09h     ; Display String : Number Converted
    mov dx,offset strHextToAsc
    int 21h    
 
 
 
  MOV AH,4CH
  INT 21H
  
  
  X DW 04H
  CUBE DW ?   
endp  

hexToAsc proc near        ;AX input , si point result storage addres
        mov cx,00h
        mov bx,0ah
        hexloop1:
                mov dx,0
                div bx
                add dl,'0'
                push dx
                inc cx
                cmp ax,0ah
                jge hexloop1
                add al,'0'
                mov [si],al
        hexloop2:
                pop ax
                inc si
                mov [si],al
                loop hexloop2
                inc si
                mov al,'$'
                mov [si],al
                ret
endp   

message db "Cuberoot  =  $"        
strHextToAsc db "                 "

end main

ret

Running The Program


Launch Emu8086 & Run the Program



Output




To Find The Cube Root Of Another Number (Eg : 8)

Change In Code


X DW 08H ; Change from 04H to 08H



Murugan Andezuthu Dharmaratnam

Murugan is a technology leader with 14 years of hands-on experience in full life cycle systems design, development, implementation, and management. In addition to systems design and development, his core competencies include cloud design and architecture, interactive web applications and websites development, mobile computing, and Healthcare Information Technology. His experience is very diverse with a broad range of technologies within multiple industry settings including private, public, and non-profit. Coupled with his technology expertise, Murugan is a well-organized, result-oriented, and a highly analytical leader with proven track record in developing and implementing very complex systems.