You are on page 1of 11

,

SOFTWARE


5

: .

: . . TI-155

: .

2017

..

5.6
Debug

INCLUDE Irvine32.inc
.data
mes db 0ah,0dh,'String - ',0
mas db 10 dup (?),0 ;
i db 0
.code
main proc

xor eax,eax ; eax


mov ecx,10 ; ecx
mov esi,0 ; esi
go: ;
mov bh,i ;i bh
mov mas[esi],bh; i
inc i ; i
inc esi ;
loop go ;
;
mov edx,OFFSET mes
call WriteString

mov ecx,10
mov esi,0
show:
movsx eax,mas[esi] ; esi
call WriteInt
inc esi
loop show
quit:
call crlf
exit
main ENDP
END main

00000000 .data
00000000 0A 0D 53 74 72 mes db 0ah,0dh,'String - ',0
69 6E 67 20 2D
20 00
0000000C 0000000A [ mas db 10 dup (?),0
00
] 00
00000017 00 i db 0
00000000 .code
00000000 main proc

00000000 33 C0 xor eax,eax


00000002 B9 0000000A mov ecx,10
00000007 BE 00000000 mov esi,0
0000000C go:
0000000C 8A 3D 00000017 R mov bh,i
00000012 88 BE 0000000C R mov mas[esi],bh
00000018 FE 05 00000017 R inc i
0000001E 46 inc esi
0000001F E2 EB loop go
00000021 BA 00000000 R mov edx,OFFSET mes
00000026 E8 00000000 E call WriteString

0000002B B9 0000000A mov ecx,10


00000030 BE 00000000 mov esi,0
00000035 show:
00000035 0F BE 86 movsx eax,mas[esi]
0000000C R
0000003C E8 00000000 E call WriteInt
00000041 46 inc esi
00000042 E2 F1 loop show
00000044 quit:
00000044 E8 00000000 E call crlf
exit
00000049 6A 00 * push +000000000h
0000004B E8 00000000 E * call ExitProcess
00000050 main ENDP
END main

INCLUDE Irvine32.inc
.data ;
; :
mes1 db ' ne raven 0!',0ah,0dh,0
mes2 db ' raven 0!',0ah,0dh,0
mes3 db 0ah,0dh,'Element ',0
mas dw 2,7,0,0,1,9,3,6,0,8 ;
.code

main proc

xor eax,eax ; ax
prepare:
mov ecx,10 ; ecx
mov esi,0 ; esi
compare:
mov dx,mas[esi*2] ; dx
cmp dx,0 ; dx c 0
je equal ;, , zf=1
not_equal: ;
mov edx,OFFSET mes3
call WriteString ;

mov eax,esi;
call WriteDec ;

mov edx,OFFSET mes1


call WriteString

inc esi ;
dec ecx ;
jecxz quit ; ecx=0
jmp compare ;
equal: ; 0

mov edx,OFFSET mes3 ; mes3


call WriteString

mov eax,esi
call WriteDec

mov edx,OFFSET mes2 ; mes2


call WriteString

inc esi ;
dec ecx ; ?
jecxz quit
jmp compare
quit:
call crlf
exit
main ENDP
END main ;

00000000 .data
00000000 20 6E 65 20 72 mes1 db ' ne raven 0!',0ah,0dh,0
61 76 65 6E 20
30 21 0A 0D 00
0000000F 20 72 61 76 65 mes2 db ' raven 0!',0ah,0dh,0
6E 20 30 21 0A
0D 00
0000001B 0A 0D 45 6C 65 mes3 db 0ah,0dh,'Element ',0
6D 65 6E 74 20
00
00000026 0002 0007 0000 mas dw 2,7,0,0,1,9,3,6,0,8
0000 0001 0009
0003 0006 0000
0008
00000000 .code

00000000 main proc

00000000 33 C0 xor eax,eax


00000002 prepare:
00000002 B9 0000000A mov ecx,10
00000007 BE 00000000 mov esi,0
0000000C compare:
0000000C 66| 8B 14 75 mov dx,mas[esi*2]
00000026 R
00000014 66| 83 FA 00 cmp dx,0
00000018 74 21 je equal
0000001A not_equal:
0000001A BA 0000001B R mov edx,OFFSET mes3
0000001F E8 00000000 E call WriteString

00000024 8B C6 mov eax,esi


00000026 E8 00000000 E call WriteDec

0000002B BA 00000000 R mov edx,OFFSET mes1


00000030 E8 00000000 E call WriteString

00000035 46 inc esi


00000036 49 dec ecx
00000037 E3 23 jecxz quit
00000039 EB D1 jmp compare
0000003B equal:

0000003B BA 0000001B R mov edx,OFFSET mes3


00000040 E8 00000000 E call WriteString

00000045 8B C6 mov eax,esi


00000047 E8 00000000 E call WriteDec

0000004C BA 0000000F R mov edx,OFFSET mes2


00000051 E8 00000000 E call WriteString

00000056 46 inc esi


00000057 49 dec ecx
00000058 E3 02 jecxz quit
0000005A EB B0 jmp compare
0000005C quit:
0000005C E8 00000000 E call crlf
exit
00000061 6A 00 * push +000000000h
00000063 E8 00000000 E * call ExitProcess
00000068 main ENDP
END main

INCLUDE Irvine32.inc
.data ;
N=5 ;
mas byte 5 dup (3 dup (0))
.code ;
main proc ;

xor eax,eax ; eax


mov esi,0 ;0 esi
mov ecx,N ;N ecx
go:
mov dl,mas[esi]; dl
inc dl ; dl 1 ( )
mov mas[esi],dl;
add esi,3 ;
loop go ;
mov esi,0 ;
mov ecx,N
show: ;
;

movsx eax,mas[esi]
call WriteDec
add esi,3 esi+3

loop show
quit:
call crlf
exit ;
main ENDP
END main ;

00000000 .data
= 00000005 N=5
00000000 00000005 [ mas byte 5 dup (3 dup (0))
00000003 [
00
]
]
00000000 .code
00000000 main proc

00000000 33 C0 xor eax,eax


00000002 BE 00000000 mov esi,0
00000007 B9 00000005 mov ecx,N
0000000C go:
0000000C 8A 96 00000000 R mov dl,mas[esi]
00000012 FE C2 inc dl
00000014 88 96 00000000 R mov mas[esi],dl
0000001A 83 C6 03 add esi,3
0000001D E2 ED loop go
0000001F BE 00000000 mov esi,0
00000024 B9 00000005 mov ecx,N
00000029 show:
00000029 0F BE 86 movsx eax,mas[esi]
00000000 R
00000030 E8 00000000 E call WriteDec
00000035 83 C6 03 add esi,3

00000038 E2 EF loop show


0000003A quit:
0000003A E8 00000000 E call crlf
exit
0000003F 6A 00 * push +000000000h
00000041 E8 00000000 E * call ExitProcess
00000046 main ENDP
END main

5.7

1. , ,
. .

INCLUDE Irvine32.inc

search MACRO count


mov ecx,len
lea esi,mas1 ; lea
lea edi,mas2

loop1:
mov al,[esi]
cmp al,simv
je loop2
inc esi
jmp endl

loop2:
mov al,[esi + 1]
cmp al,simv
je equal
inc esi
jmp endl

equal: inc esi


inc count

endl: cmp al,0

loopne loop1 ;
ENDM

.data
mas1 db "xxxxe x yt xx xxxcfxx xxzs i.pxxl",0
mas2 db 30 dup(0)
len equ lengthof mas1
simv db 'x'
msg1 db "Your string: ", 0
msg2 db "xx = ",0
.code

main PROC
lea edx, msg1
call WriteString
lea edx, mas1
call WriteString
call Crlf

mov ebx, 0
search ebx

lea edx, msg2


call WriteString
mov eax, ebx
call WriteDec
call Crlf

exit
main ENDP
END main

search MACRO count


mov ecx,len
lea esi,mas1
lea edi,mas2

loop1:
mov al,[esi]
cmp al,simv
je loop2
inc esi
jmp endl

loop2:
mov al,[esi + 1]
cmp al,simv
je equal
inc esi
jmp endl

equal: inc esi


inc count

endl: cmp al,0

loopne loop1
ENDM

00000000 .data
00000000 78 78 78 78 65 mas1 db "xxxxe x yt xx xxxcfxx xxzs i.pxxl",0
20 78 20 79 74
20 78 78 20 78
78 78 63 66 78
78 20 78 78 7A
73 20 69 2E 70
78 78 6C 00
00000022 0000001E [ mas2 db 30 dup(0)
00
]
= 00000022 len equ lengthof mas1
00000040 78 simv db 'x'
00000041 59 6F 75 72 20 msg1 db "Your string: ", 0
73 74 72 69 6E
67 3A 20 00
0000004F 78 78 20 3D 20 msg2 db "xx = ",0
00
00000000 .code

00000000 main PROC


00000000 8D 15 00000041 R lea edx, msg1
00000006 E8 00000000 E call WriteString
0000000B 8D 15 00000000 R lea edx, mas1
00000011 E8 00000000 E call WriteString
00000016 E8 00000000 E call Crlf

0000001B BB 00000000 mov ebx, 0


search ebx
00000020 B9 00000022 1 mov ecx,len
00000025 8D 35 00000000 R 1 lea esi,mas1
0000002B 8D 3D 00000022 R 1 lea edi,mas2
00000031 1 loop1:
00000031 8A 06 1 mov al,[esi]
00000033 3A 05 00000040 R 1 cmp al,simv
00000039 74 03 1 je loop2
0000003B 46 1 inc esi
0000003C EB 10 1 jmp endl
0000003E 1 loop2:
0000003E 8A 46 01 1 mov al,[esi + 1]
00000041 3A 05 00000040 R 1 cmp al,simv
00000047 74 03 1 je equal
00000049 46 1 inc esi
0000004A EB 02 1 jmp endl
0000004C 46 1 equal: inc esi
0000004D 43 1 inc ebx
0000004E 3C 00 1 endl: cmp al,0
00000050 E0 DF 1 loopne loop1

00000052 8D 15 0000004F R lea edx, msg2


00000058 E8 00000000 E call WriteString
0000005D 8B C3 mov eax, ebx
0000005F E8 00000000 E call WriteDec
00000064 E8 00000000 E call Crlf

exit
00000069 6A 00 * push +000000000h
0000006B E8 00000000 E * call ExitProcess
00000070 main ENDP
END main

2. , ,
.
. .

INCLUDE Irvine32.inc

procedure MACRO ad1


mov byte ptr [edi-1],' '

ENDM

.data
seq1 byte 'Sequence1 : ', 0
seq2 byte 'Sequence2 : ', 0
seq3 byte 'Sequence3 : ', 0
fin_seq byte 'Final Sequence : ', 0
s1 byte 'Assembler', 0
s2 byte 'is', 0
s3 byte 'awesome', 0
s4 byte 30 dup(?)

.code
main PROC
cld
mov edx, offset seq1
call WriteString
mov edx, offset s1
call WriteString
call Crlf

mov edx, offset seq2


call WriteString
mov edx, offset s2
call WriteString
call Crlf

mov edx, offset seq3


call WriteString
mov edx, offset s3
call WriteString
call Crlf

mov ecx, LENGTHOF s1


mov esi, offset s1
mov edi, offset s4

copy1 : movsb
loop copy1

mov ecx, LENGTHOF s2


add ecx, 1
mov esi, offset s2
mov edi, offset s4
add edi, LENGTHOF s1

procedure s4

copy2: movsb
loop copy2
mov ecx, LENGTHOF s3

mov esi, offset s3


mov edi, offset s4
add edi, LENGTHOF s1
add edi, LENGTHOF s2

procedure s4

copy3: movsb
loop copy3
mov edi, offset s4
mov ecx, lengthof s4
mov al, ' '
cld

c1:
scasb
je c2
cmp ecx, 0
jz quit
loop c1

c2:
cld
sub edi, 1
stosb
jmp c1

quit:
mov ecx, LENGTHOF s4
mov esi, OFFSET s4
mov ebx, 0

cycle:
mov al, [esi]
jmp exl
exl:
movsb
loop cycle
mov edx, offset fin_seq
call WriteString
mov edx, offset s4
call WriteString

call Crlf
call ReadKey
call ReadChar

exit
main ENDP
END main

:

.
.
2 :
, $,
.
, ,
, .