Generate a program to proof that the square root of 30 is 900 using NASM Simulator (DOSBox), Briefly explain the steps of your program execution.
.model small
.stack 64h
.data
msg db "The square root of 900 is 30", 13,10,'$'
x dw 900
y dw 30
.code
mov ax,@data
mov ds,ax
mov bx,y ; bx=30
mov ax,x ; al=900
div bl ; result = 900/30
cmp ax,bx ; check result
jnz fin ; if square root of 900 !=30 goto fin
; else print msg
lea dx,msg ; "The square root of 900 is 30"
mov ah,09h ; print string
int 21h
fin:
mov ah,04ch ; exit
int 21h
end
Comments
Leave a comment