CATEGORII DOCUMENTE |
LAAP
'Limbaje de programare si automate programabile'
Automatica si informatica
Program 1) Declararea si utilizarea segmentelor individuale.Utilizarea modulului de adresare indexat.
Muta sirul sir1 la adresa simbolica sir1b si il afiseaza
Muta sirul sir2 la adresa simbolica sir2b si il afiseaza
dosseg
.model small
.stack
assume cs:cod1
stiva1 segment public
db 200h dup(0)
stiva1 ends
stiva2 segment public
db 200h dup(0)
stiva2 ends
dat1 segment public
sir1 db 'Universitatea Valahia',' '
lgsir1 db $-sir1
sir1b db $-sir1 dup(0)
dat1 ends
dat2 segment public
sir2 db 'Targoviste'
lgsir2 db $-sir2
sir2b db $-sir2 dup(0)
dat2 ends
cod1 segment public
assume ds:dat1,ss:stiva1
muta1 proc
assume ds:dat1
mov si,0
mov cl,lgsir1 ; 21
@1: mov dh,sir1[si]
mov sir1b[si],dh
inc si
dec cl
jnz @1
ret
muta1 endp
muta2 proc
assume ds:dat2
mov si,0
mov cl,lgsir2
@2: mov dh,sir2[si]
mov sir2b[si],dh
inc si
dec cl
jnz @2
ret
muta2 endp
disp1 proc
assume ds:dat1
mov cl,lgsir1
mov si,0
mov ah,02h
@3: mov dl,sir1b[si]
int 21h
inc si
dec cl
jnz @3
ret
disp1 endp
disp2 proc
assume ds:dat2
mov cl,lgsir2
mov si,0
mov ah,02h
@4: mov dl,sir2b[si]
int 21h
inc si
dec cl
jnz @4
ret
disp2 endp
start: assume ds:dat1
mov ax,dat1
mov ds,ax
mov ax,stiva1
mov ss,ax
call muta1
call disp1
assume ds:dat2
mov ax,dat2
mov ds,ax
mov ax,stiva2
mov ss,ax
call muta2
call disp2
mov ah,4ch
int 21h
cod1 ends
cod2 segment
mov ah,4ch
int 21h
cod2 ends
assume cs:cod2
end start
Program 2) Declararea si utilizarea segmentelor individuale. Utilizarea modului de adresare bazat-indexat.
Muta sirul sir1 la adresa simbolica sir1b si il afiseaza
Muta sirul sir2 la adresa simbolica sir2b si il afiseaza
dosseg
.model small
.stack
assume cs:cod1
stiva1 segment public
db 200h dup(0)
stiva1 ends
stiva2 segment public
db 200h dup(0)
stiva2 ends
dat1 segment public
sir1 db 'Universitatea Valahia',' '
lgsir1 dw $-sir1
sir1b dw $-sir1 dup(0)
ind1 dw 0
dat1 ends
dat2 segment public
sir2 db 'Targoviste'
lgsir2 dw $-sir2
sir2b dw $-sir2 dup(0)
ind2 dw 0
dat2 ends
cod1 segment public
assume ds:dat1,ss:stiva1
muta1 proc
assume ds:dat1
mov bx,offset sir1
mov cx,lgsir1
mov si,0
@1: mov dx bx+si]
mov sir1b[bx+si],dx
inc si
cmp si,cx
jne @1
ret
muta1 endp
muta2 proc
assume ds:dat2
mov bx,offset sir2
mov cx,lgsir2
mov si,0
@2: mov dx bx+si]
mov sir2b[bx+si],dx
inc si
cmp si,cx
jne @2
ret
muta2 endp
disp1 proc
assume ds:dat1
mov cx,lgsir1
mov si,0
mov ah,02h
@3: mov dx bx+si]
int 21h
inc si
cmp si,cx
jne @3
ret
disp1 endp
disp2 proc
assume ds:dat2
mov cx,lgsir2
mov si,0
mov ah,02h
@4: mov dx bx+si]
int 21h
inc si
cmp si,cx
jne @4
ret
disp2 endp
start: assume ds:dat1
mov ax,dat1
mov ds,ax
mov ax,stiva1
mov ss,ax
call muta1
call disp1
assume ds:dat2
mov ax,dat2
mov ds,ax
mov ax,stiva2
mov ss,ax
call muta2
call disp2
mov ah,4ch
int 21h
cod1 ends
cod2 segment
mov ah,4ch
int 21h
cod2 ends
assume cs:cod2
end start
Program 3)
Afisarea pozitiilor spatiilor dintr-un sir de caractere
dosseg
.model small
.stack 100h
.data
sir db 'Univ Valahia Tgv DB RO'
lg_sir dw $-sir
n10 dw 10
.code
conv proc
mov dx,0
div n10
cmp ax,0
jz gata
push dx
call conv
pop dx
gata: mov al,dl
add al,'0'
mov ah,14
int 10h
ret
conv endp
start: mov ax,@data
mov ds,ax
mov si,-1
@1: inc si
cmp si,lg_sir
je @2
mov cl,sir[si]
cmp cl,' '
jne @1
mov ax,si
call conv
cmp si,lg_sir
je @2
jne @1
@2: mov ah,4ch
int 21h
end start
Program 4)
Program afisare numere zecimale
dosseg
.model small
.stack 100h ;dimensiunea stivei = 100h
.data
n10 dw 10
.code
conv proc
mov dx,0 ;conversie 32 biti
div n10 ;determina cat si rest
cmp ax,0 ;cat = 0 ?
jz gata
push dx ;salvare rest in stiva
call conv
pop dx ;refacere rest
gata: mov al,dl ;(dl)=rest impartire
add al,'0'
mov ah,14
int 10h
ret
conv endp
start: mov ax,@data ;
mov ds,ax ;incarca adresa segmentului de date
mov ax,26531 ;introduce numarul de afisat
call conv
mov ah,4ch ;incarca functia sistem de returnare a promperului DOS
int 21h
end start
Problema 5)
Rezolvarea 2x-1; pentru valorile 1,2,3,4,5
dosseg
.model small
.stack 100h
.data
valx db 1,2,3,4,5
lg_valx dw $-valx
rez db ?
.code
start: mov ax,@data
mov ds,ax
mov si,0
@1: mov al
mul valx[si]
sub al,1
mov rez[si],al
inc si
cmp si,lg_valx
jne @1
mov si,0
mov ah,02h
@2: mov dl,rez[si]
add dl,30h
int 21h
inc si
cmp si,lg_valx
jne @2
mov ah,4ch
int 21h
end start
Program 6)
Procedura pentru ecuatia 2x -1 ; pentru valorile 1,2,3,4,5
dosseg
.model small
.data
val db 1,2,3,4,5
lg_val dw $-val
rez db ?
.code
afisare proc
mov ah, 2
mov si, 0
@3: mov dl, rez[si]
add dl, 30h
int 21h
mov dl, ' '
int 21h
inc si
cmp si, lg_val
jne @3
ret
afisare endp
calcul proc
mov si, 0
@2:
mov al, 2
mul val[si]
sub al, 1
mov rez[si], al
inc si
cmp si, lg_val
jne @2
ret
calcul endp
Problema 7)
Factorial
dosseg
.model small
.data
val db 3
rez db ?
.code
start: mov ax,@data
mov ds,ax
mov cl,0
mov al,1
@1: inc cl
mul cl
cmp cl,val
jne @1
mov rez,al
mov ah,02h
mov dl,rez
add dl,30h
int 21h
mov ah,4ch
int 21h
end start
Problema 8)
Afisarea primului character din sirul 'ABC'
dosseg
.model small
.stack 100h
.data
val db 1
sir db 'ABC'
.code
start: mov ax,@data
mov ds,ax
mov bl,offset sir
mov ah,02h
mov dx,[bx]
int 21h
mov ah,4ch
int 21h
end start
Problema 9)
Afisarea celui de al 3- lea character din sirul 'ABC'
dosseg
.model small
.stack 100h
.data
val db 1
sir db 'ABC'
.code
start: mov ax,@data
mov ds,ax
mov bl,offset sir
mov ah,02h
mov dx,[bx+2]
int 21h
mov ah,4ch
int 21h
end start
Problema 10)
Permutarea circulara al unori valori de octetla dreapta a sirului de caractere 'ABC'
dosseg
.model small
.stack 100h
.data
sir db 'ABC'
lg_sir dw $-sir
.code
start: mov ax,@data
mov ds,ax
mov dl,sir+2
mov al,sir+1
mov sir+2,al
mov al,sir
mov sir+1,al
mov sir,dl
mov si,0
mov ah,02h
@1: mov dl,sir[si]
int 21h
inc si
cmp si,lg_sir
jne @1
mov ah,4ch
int 21h
end start
Problema 11)
Afisarea unui sirului de caractere "Universitatea Valahia"
dosseg
.model small
.data
sir db 'Universitatea Valahia'
lg_sir dw $-sir
.code
start: mov ax,@data
mov ds,ax
mov si,0
mov ah,02h
@1: mov dl,sir[si]
int 21h
inc si
cmp si,lg_sir
jne @1
mov ah,4ch
int 21h
end start
Problema 12)
Rezolvarea problemei anterioara cu proceduri
dosseg
.model small
.data
sir db 'Universitatea Valahia'
lg_sir dw $-sir
.code
afsir proc
mov si,0
mov ah,02h
@1: mov dl,sir[si]
int 21h
inc si
cmp si,lg_sir
jne @1
ret
afsir endp
start: mov ax,@data
mov ds,ax
call afsir
mov ah,4ch
int 21h
end start
Problema 13)
Permutarea circulara al unori valori de octet la stanga a sirului de caractere 'ABC'
dosseg
.model small
.data
sir db 'abc'
.code
start: mov ax, @data
mov ds, ax
mov dl, sir
mov al, sir+1
mov sir, al
mov al, sir+2
mov sir+1, al
mov sir+2, dl
mov si, 0
mov ah, 02h
@1: mov dl, sir[si]
int 21h
inc si
cmp si, 3
jne @1
mov ah, 4ch
int 21h
end start
Problema 14)
Lungimea sirului
dosseg
.model small
.stack 100h
.data
val db 1
sir db 'ABCDEF'
lg_sir dw $-sir
.code
start: mov ax,@data
mov ds,ax
mov cx,0
mov bl,offset sir
mov ah,02h
@1: mov dx bx]
int 21h
inc cx
cmp cx,lg_sir
jne @1
mov ah,4ch
int 21h
end start
Problema 15)
dosseg
.model small
.stack
.data
numar dw 070B4h
.code
afis_AL proc
push ax
push cx
mov cx, ax
mov ah, 2 ; afisare
prima cifra din
mov dl, cl
shr dl, 4
cmp dl, 9
jng @al_j1
add dl, 7
@al_j1: add dl, 30h
mov ah, 2
int 21h ; afisare a
doua cifra din
mov dl, cl
shl dl, 4
shr dl, 4
cmp dl, 9
jng @al_j2
add dl, 7
@al_j2: add dl, 30h
mov ah, 2
int 21h
pop cx
pop ax
ret
afis_AL endp
Problema 16)
Spatiul liber in octeti
dosseg
.model small
.stack 100h
.data
lg_sir dw $-sir
n10 dw 10
.code
conv proc
mov dx,0
div n10
cmp ax,0
jz gata
push dx
call conv
pop dx
gata: mov al,dl
add al,'0'
mov ah,14
int 10h
ret
conv endp
start: mov ax,@data
mov ds,ax
mov ah,36h
mov dl,0
int 21h
call conv
mov ah,4ch
int 21h
end start
Politica de confidentialitate | Termeni si conditii de utilizare |
Vizualizari: 1814
Importanta:
Termeni si conditii de utilizare | Contact
© SCRIGROUP 2024 . All rights reserved