0% found this document useful (0 votes)
48 views1 page

Assembly Language String Operations Guide

The document contains code snippets in Assembly language that demonstrate various string manipulation and arithmetic operations, including: 1) Reading a string from the user, storing it, and displaying it on screen. 2) Comparing two strings and checking if they are equal. 3) Finding a word within a string. 4) Displaying characters from a string repeatedly on screen. 5) Calculating the frequency of a character in a string.

Uploaded by

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

Assembly Language String Operations Guide

The document contains code snippets in Assembly language that demonstrate various string manipulation and arithmetic operations, including: 1) Reading a string from the user, storing it, and displaying it on screen. 2) Comparing two strings and checking if they are equal. 3) Finding a word within a string. 4) Displaying characters from a string repeatedly on screen. 5) Calculating the frequency of a character in a string.

Uploaded by

Napster
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

SHFAQJA E KARAKTERIT TE

PERDORUR DERISA SHTYPET


HAPSIRA
Code segment
Assume cs:code
Start: mov ah,01h
Int 21h; presim char
Xor ah,ah
Psuh aax
Call shfaq
Char equ 2[bp]
Shfaq proc
Push bp
Mov bp,sp
Mov char,ax
Cmp char,20h
Je stop
Mov dl,char
Mov ah,02h
Int 21h
Pop ax
Pop bp
Jmp start
Shfaq endp
Stop: int 03h
Code ends end start
FUTTJA E NJE STRINGE NGA
PERSORUESI, RUAJTJA DHE
SHFAQJA NE EKRAN
.model small
.stack 100h
.data
Promt_1 DB jepni stringen: $
Promt_2 DB 0dh,0ah, stringa eshte: $
String DB 25 Dup(?); max 25 char
.code
Main proc
Mov ax,data
Mov ds,ax
Lea dx,promt_1
Mv ah,9
Int21
Lea di,string
Call read_str
Lea dx,promt_2
Mov ah,9
Int 21h
Lea si, string
Call disp_str
Mov ah,4ch
Int 21 h
Main endp
Read_str proc
Push ax
Push di
Cld
Xor bx,bx
@input_loop:
Mmov ah,1
Int 21h
Cmp al,0dh
Je @end_input
Cmp al,08h
Jne @not_BACKSPACE
CMP BX,0
JE@imput_error
Mov ah,2
Mov dl,20h

Mov dl,08h
Int 21h
Dec bx
Dec di
Jmp @input_loop
@input_error
Mov ah,2
Mov dl,07h
Int 21h
Jmp @input_loop
@not_backspace
Stosbx
Inc bx
Jmp @input_loop
@end_input
Pop di
Pop ax
Ret
Read_str end
Disp_str proc
Push ax
Push bx
Push cx
Push dx
Push si
Cld
Mov cx,bx
Mov ah,2
Jcxz @skip_output; jump if ecx is 0
@output_loop
Lodsb
Mov dl,al
Int 21h
loop@output_loop
@skip_output
Pop si
Pop dx
Pop cx
Pop bx
Pop ax
Ret
Dis_str endp
End main
LEXIMI DHE SHFAQJA E ORES
SE BIOSIT NE EKRAN
Data segment
Bufo db data e bios eshte: $
Buf db 8 dup (0), $
Data ends
Code ends
Code segment
Assume cs: code, cd: data
Start: mov ax,data
Mov ds,ax
Mov es,ax
Mov ax,0fffh
Mov ds,ax
Mov si, 0005h
Mov di,offset buf
Cld
Mov cx,08h
Next: lodsb
Sto sb
Loop next
Mov ab,09h
Mov bx, data
Mov ds,bx
Lea dx,bufo

Int 21h
Code ends
GERME E VOGEL NE GERME TE
MADHE
.model small
.stack 100h
.data
Promt_1 db jepni shkronjen e vogel: $
Promt_2 db 0dh,0ah, shkronja madhe
e: $
.code
Main proc
Mov ax,data
Mov ds,ax
Lea dx,promt_1
Mov ah,9
Int 21h
Mov ah,1
Int 21h
Mov bl,al
Lea dx,promt_2
Mov ah,9
Int 21h
And bl,0dfh
Mov ah,2
Mov dl,bl
Int 21h
Main endp
End main
KRAHASIMI I DY STRINGAVE
Data segment
String1 db kjo eshte nje stringe e pare
SL equ (string1)
Nequ stringat nk jan te =
Equ db stringat jane te =
Data ends
Extra segment
String2 db kjo eshte stringa e pare
Code segmend
Assume cs:code, ds:data, es: extra
Start: mov ax,data
Mov ds,ax
Mov ax, extra
Mov es,ax
Mov si, offset string1
Mov di, offset string2
Cld
Mov cx,sl; srting length
Rep cmppsb; krahasim byte per byte
Jz loop
Mov ah,09h
Mov dx,offset nequ
Int 21h
Jmp exit p
Loop: mov ah,09h
Mov dx, ooffset equ
Int 03h
Exitp:nop
Int 03h
Code ends
GJETJA E NJE FJALE BRENDA 1
STRINGE
LIST SW 66H,51H,29H, 62H,89H
Dest equ 1000h
Count equ 05h
Data ends
Code segment
Assume cs: code, ds:data

Start: mov ax,data


Mov ds,ax
Mov ax, 51h
Mov si, offset list
Mov di, dest
Mov cx,count
Mov ax,00
Cld
Rep scasw
Jz loop
Loop: mov [di],ax
Int 03h
Code ends
SHFAQJA 5 HERE E NJE
KARAKTERI TE 1 STRINGE
.model small
.data
Abc db vnrvjets $
.code
.startup
Mov cx,05h; load counter
X: mov ah,09h
Mov dx,offset abc
Int 21h; akses ne DOS
Call DIL; per shfaqjen ne ekran
Loop x
Exit; mbyllja funks DOS
DIL proc near
Mov ah,02h
Mov dl,0ah
Int 21h
Mov ah,02h
Mov dl,0dh
Innt 21h
Ret
DIL endp
End
SHPESHTESIA E 1 GERME NE
NJE STRINGE
DATA SEGMENT
STRING1 DB MIKROPROCESSOR
DATA ENDS
CODE SEGMENT
ASSUMME CS: CODE, DS: DATA
START: MOV AX,DATA
MOV DS,AX
LEA SI, STRING1
XOR DL,DL
MOV CX,20H
MOV BL, O
LOOP: MOV AL, [SI]
INC SI
DEC CX JNZ LOOP2
CMP AL,BL
JE LOOP3
LOOP3: INC DL
JNZ LOOP
LOOP2:NOP
INT 03H
CODE ENDS
END START
FSHIRJA E NJE FJALE TE NJE
STRINGE
data segment
String1 db shembulli fshirjes
Sl equ ($-string1)
Data ends
Extra segment

String2 SL-5 dup(0)


Extra ends
Assume: cd:code, ds:data, es:extra
Start: mov ax,data
Mov ds,ax
Mov ax,extra
Mov si, offset string1
Mov di,offset string2
Cld
Mov cx,13
Rep movsb
Cld
Mov si,18
Mov cx,12
Rep movsb
Int 03h
Code ends
SHTIMI I NJE FJALE BRENDA
NJE STRINGE
Data segment
String1 db stringe prove
Sl equ ($-string1)
Data ends
Extra segment
String2 db sl+5 dup(0)
Extra ends
Code segment
Assume cs:code, ds: data, es: extra
Start: mov ax, data
Mov ds,ax
Mov si, offset string1
Mov di, offset string2
Cld
Mov cx, 14; hap qe ze stringa 2
Rep movsb
Mmov dl,5
Back> mov ah,01
Stos string
Dec cl
Jnz back
Mov cx,1
Rep movsb
Int03h
Code ends
End start
SHVP E DY NR
Data segment
String db 25h
String2 db 28h
Data ends
Code segment
Assume cs:code, ds:data
Start: mov ax,data
Mov ds,ax
Xor ah,ah
Lea si, string1
Lea di, string2
Mov cl,ooh
Mov cl,ll
Mov dl, 00h
Mov al,[si]
Mov bh,al
Mov bl,[di]
Up: inc cl
Div bl
Cmp ah, dl
Jne up
Int 03h

Code ends end start


SHUMEZIMI I DY NR ME SHENJE
Data segment
Data1 db 0a5h
Data2 db 32h
Res dw 00h
Data ends
Code segment
Assume cs:code, ds:data
Start:mov ax,data
Sub ax,ax
Mov al, data1
Mov bl,data2
Imul bl
Mov es,aox
Int 03h
Code ends end start
MBLEDHJA E DY FJALEVE ME
GJATESI 5 BYTE
Dta segment
Data1 db 12h,13h,..16h
Data2 db 18h..22h
Res db dup(0)
Data ends
Code segment
Assume cs:code, ds:data
Start: mov ax, data
Mov ds, ax
Mov si, offset data1
Mov di, offset data 2
Mov cx,05
Sub ax,ax
Mov al,[si]
Mov dl,[di]
Add al,dl
Mov [bx],al
Up: inc si
Inc di
Inc bx
Mov al, [si]
Mov dl,[di]
Adc al,dl
Mov [bx],al
Loop up
Int 03h
Code ends
RRENJA KATRORE E NJE NR 8
BIT
Data segment
Data1 db 04h
Res db 0h
Data ends
Code segment
Assume cs:code, ds:data
Sart: mov ax, data
Mov ds,ax
Mov si, offset data1
Mov di, offset res
Mov cx, 0001
Mov bx,0
Mov al, [si]
Up: sub al, cl
Jl down
Inc bl
Add cl,02
Jnp up
Down: mov [di],bc
Int 03h

You might also like