0% found this document useful (0 votes)
124 views9 pages

A.C.Lab5 CerlatPavel FAF-192

This document is a lab report on string processing and code conversion tables in assembly language. It includes an example program that increments the values in an array and displays the result. It also includes an individual exercise that concatenates multiple strings into a single string using moves and loops. The listing section provides the assembly code and comments for both examples. The conclusion discusses consolidating assembly language concepts and further studying string manipulation commands and principles.

Uploaded by

Pavlic Cerlat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
124 views9 pages

A.C.Lab5 CerlatPavel FAF-192

This document is a lab report on string processing and code conversion tables in assembly language. It includes an example program that increments the values in an array and displays the result. It also includes an individual exercise that concatenates multiple strings into a single string using moves and loops. The listing section provides the assembly code and comments for both examples. The conclusion discusses consolidating assembly language concepts and further studying string manipulation commands and principles.

Uploaded by

Pavlic Cerlat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Raport

Arhitectura Calculatoarelor
Lucrarea de Laborator NR.4
Tema:,,PRELUCRAREA SIRURILOR
UTILIZAREA TABELELOR PENTRU CONVERSII DE CODURI’’

Elaborat: Cerlat Pavel FAF-192


Controlat: Postovan Dumitru
Exemplu:
INCLUDE Irvine32.inc
.data
N=5
mas byte 5 dup (3 dup (0))
.code
main proc
xor eax,eax
mov esi,0
mov ecx,N
go:
mov dl,mas[esi]
inc dl
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

loop show
quit:
call crlf
exit
main ENDP
END main

Listing:
INCLUDE Irvine32.inc
C ; Include file for Irvine32.lib (Irvine32.inc)
C
C ;OPTION CASEMAP:NONE
C
C INCLUDE SmallWin.inc
C .NOLIST
C .LIST
C
C INCLUDE VirtualKeys.inc
C ; VirtualKeys.inc
C .NOLIST
C .LIST
C
C
C .NOLIST
C .LIST
C
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 ;
Ex. Individual:
INCLUDE Irvine32.inc

holo MACRO ad1, ad2


mov edi,OFFSET ad1
add edi, ad2
inc ad2
ENDM

.data
string1 byte 'String 1 : ', 0
string2 byte 'String 2 :', 0
string3 byte 'String 3 : ', 0
string_final byte 'String 4 : ', 0

str1 byte 'Lab 5$', 0


str2 byte ' ass$embler', 0
str3 byte ' $$$$$$!', 0
str4 byte 30 dup(? )

.code
main PROC
cld
mov edx, offset string1
call WriteString
mov edx, offset str1
call WriteString
call Crlf

mov edx, offset string2


call WriteString
mov edx, offset str2
call WriteString
call Crlf

mov edx, offset string3


call WriteString
mov edx, offset str3
call WriteString
call Crlf

mov ecx, LENGTHOF str1


mov esi, offset str1
mov edi, offset str4
cond : movsb
loop cond

mov ecx, LENGTHOF str2


mov esi, offset str2
mov edi, offset str4
add edi, LENGTHOF str1
sub edi, 1
cond1: movsb
loop cond1

mov ecx, LENGTHOF str3


mov esi, offset str3
mov edi, offset str4
add edi, LENGTHOF str1
add edi, LENGTHOF str2
sub edi, 2
cond11: movsb
loop cond11

mov edi, offset str4


mov al, ' '
mov ecx, lengthof str4
cld
c1 :
mov al, ' '
scasb
je cond2
cmp ecx, 0
jz quit
loop c1

cond2 :
mov al, ' '
sub edi, 1
stosb
jmp c1

quit :
cld
mov ecx,LENGTHOF str4
mov esi,OFFSET str4
mov ebx,0
cycle:
mov al, [esi]
cmp al, '$'
jnz strdo
jmp exl
strdo:
holo str4, ebx
exl:
movsb
loop cycle
mov edx, offset string_final
call WriteString
mov edx, offset str4
call WriteString

call Crlf
call ReadChar
call ReadKey
exit
main ENDP
END main

Listing:
INCLUDE Irvine32.inc
C ; Include file for Irvine32.lib (Irvine32.inc)
C
C ;OPTION CASEMAP:NONE ; optional: make identifiers case-sensitive
C
C INCLUDE SmallWin.inc ; MS-Windows prototypes, structures, and constants
C .NOLIST
C .LIST
C
C INCLUDE VirtualKeys.inc
C ; VirtualKeys.inc
C .NOLIST
C .LIST
C
C
C .NOLIST
C .LIST
C

holo MACRO ad1, ad2


mov edi,OFFSET ad1
add edi, ad2
inc ad2
ENDM

00000000 .data
00000000 53 74 72 69 6E string1 byte 'String 1 : ', 0
67 20 31 20 3A
20 00
0000000C 53 74 72 69 6E string2 byte 'String 2 :', 0
67 20 32 20 3A
00
00000017 53 74 72 69 6E string3 byte 'String 3 : ', 0
67 20 33 20 3A
20 00
00000023 53 74 72 69 6E string_final byte 'String 4 : ', 0
67 20 34 20 3A
20 00

0000002F 4C 61 62 20 35 str1 byte 'Lab 5$', 0


24 00
00000036 20 61 73 73 24 str2 byte ' ass$embler', 0
65 6D 62 6C 65
72 00
00000042 20 24 24 24 24 str3 byte ' $$$$$$!', 0
24 24 21 00
0000004B 0000001E [ str4 byte 30 dup(? )
00
]

00000000 .code
00000000 main PROC
00000000 FC cld
00000001 BA 00000000 R mov edx, offset string1
00000006 E8 00000000 E call WriteString
0000000B BA 0000002F R mov edx, offset str1
00000010 E8 00000000 E call WriteString
00000015 E8 00000000 E call Crlf

0000001A BA 0000000C R mov edx, offset string2


0000001F E8 00000000 E call WriteString
00000024 BA 00000036 R mov edx, offset str2
00000029 E8 00000000 E call WriteString
0000002E E8 00000000 E call Crlf

00000033 BA 00000017 R mov edx, offset string3


00000038 E8 00000000 E call WriteString
0000003D BA 00000042 R mov edx, offset str3
00000042 E8 00000000 E call WriteString
00000047 E8 00000000 E call Crlf

0000004C B9 00000007 mov ecx, LENGTHOF str1


00000051 BE 0000002F R mov esi, offset str1
00000056 BF 0000004B R mov edi, offset str4
0000005B A4 cond : movsb
0000005C E2 FD loop cond

0000005E B9 0000000C mov ecx, LENGTHOF str2


00000063 BE 00000036 R mov esi, offset str2
00000068 BF 0000004B R mov edi, offset str4
0000006D 83 C7 07 add edi, LENGTHOF str1
00000070 83 EF 01 sub edi, 1
00000073 A4 cond1: movsb
00000074 E2 FD loop cond1

00000076 B9 00000009 mov ecx, LENGTHOF str3


0000007B BE 00000042 R mov esi, offset str3
00000080 BF 0000004B R mov edi, offset str4
00000085 83 C7 07 add edi, LENGTHOF str1
00000088 83 C7 0C add edi, LENGTHOF str2
0000008B 83 EF 02 sub edi, 2
0000008E A4 cond11: movsb
0000008F E2 FD loop cond11

00000091 BF 0000004B R mov edi, offset str4


00000096 B0 20 mov al, ' '
00000098 B9 0000001E mov ecx, lengthof str4
0000009D FC cld
0000009E c1 :
0000009E B0 20 mov al, ' '
000000A0 AE scasb
000000A1 74 07 je cond2
000000A3 83 F9 00 cmp ecx, 0
000000A6 74 0A jz quit
000000A8 E2 F4 loop c1

000000AA cond2 :
000000AA B0 20 mov al, ' '
000000AC 83 EF 01 sub edi, 1
000000AF AA stosb
000000B0 EB EC jmp c1

000000B2 quit :
000000B2 FC cld
000000B3 B9 0000001E mov ecx,LENGTHOF str4
000000B8 BE 0000004B R mov esi,OFFSET str4
000000BD BB 00000000 mov ebx,0
000000C2 cycle:
000000C2 8A 06 mov al, [esi]
000000C4 3C 24 cmp al, '$'
000000C6 75 02 jnz strdo
000000C8 EB 08 jmp exl
000000CA strdo:
holo str4, ebx
000000CA BF 0000004B R 1 mov edi,OFFSET str4
000000CF 03 FB 1 add edi, ebx
000000D1 43 1 inc ebx
000000D2 exl:
000000D2 A4 movsb
000000D3 E2 ED loop cycle
000000D5 BA 00000023 R mov edx, offset string_final
000000DA E8 00000000 E call WriteString
000000DF BA 0000004B R mov edx, offset str4
000000E4 E8 00000000 E call WriteString

000000E9 E8 00000000 E call Crlf


000000EE E8 00000000 E call ReadChar
000000F3 E8 00000000 E call ReadKey
exit
000000F8 6A 00 * push +000000000h
000000FA E8 00000000 E * call ExitProcess
000000FF main ENDP
END main

Concluzie: În această lucrare de laborator, unele aspecte ale limbajului de


asamblare au fost consolidate și studiate în continuare. În procesul de realizare a
lucrării, am studiat metodele și principiile de utilizare a comenzilor de manipulare
a șirurilor. Codul scris a arătat simplitatea de a lucra cu comenzi de prelucrare a
datelor cu minuscule.

You might also like