-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlengthofstring.asm
More file actions
67 lines (54 loc) · 1.24 KB
/
lengthofstring.asm
File metadata and controls
67 lines (54 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
org 100h
main proc near
mov dx,offset message ; String in dx
call stringLength ; returns length in cx
mov ax,cx
mov si,offset strHextToAsc ; Convert Length to ascii
call hexToAsc
mov ah,09 ; Display Length
mov dx,offset strHextToAsc
int 21h
mov ah,4ch ; Terminate and return to dos
mov al,00
int 21h
endp
stringLength proc near
mov si,dx
dec si
mov cx,0
loop_String_Length:
inc si
inc cx
cmp [si],'$'
jne loop_String_Length
dec cx
dec cx
ret
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 "Hello World$"
strHextToAsc db " $"
end main
ret