
; This program prints the square root of a number you put on the command line.
;
; Link this one with ARGC32, and enable CCHEKSTR.

        .386p
        jumps
code32  segment para public use32
        assume cs:code32, ds:code32, ss:code32

include start32.inc
include argc32.inc

public  _main

;ฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑ
; DATA
;ฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑ
syntaxmsg       db      'SYNTAX: EXAMPLE3 <hex number to root>$'
numbuf          db      32 dup(0)

;ฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑ
; CODE
;ฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑฑ

include sqrt.rt
include pdosstr.rt
include putnumtm.rt
include strltu.rt
include strhtn.rt

;-----------------------------------------------------------------------------
exiterr:
        mov edx,offset syntaxmsg
        call _putdosmsg
        jmp _exit

;อออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออออ
_main:
        xor al,al                       ; get number string from command line
        mov edx,offset numbuf
        call _cchekstr
        jc exiterr

        call _strltu                    ; lower to uppercase cuz strhtn needz
        call _strhtn                    ; it that way

        call _sqrt

        mov cl,7
        call _putnumtomem
        call _putdosstr                 ; buffer was all zeros before, so its
                                        ; already zero-terminated
        jmp _exit


code32  ends
        end

