0% found this document useful (0 votes)
19 views

String Array-Stuff Plus Assignment

The document contains several assembly language code examples that demonstrate input/output operations, array manipulation, and numeric calculations. The code samples show how to: 1) Define arrays in memory and load input from the keyboard into array elements. 2) Loop through and output the contents of an array. 3) Search through an array to find and copy matching elements to another array. 4) Take numeric input from the keyboard, perform calculations, and output results.

Uploaded by

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

String Array-Stuff Plus Assignment

The document contains several assembly language code examples that demonstrate input/output operations, array manipulation, and numeric calculations. The code samples show how to: 1) Define arrays in memory and load input from the keyboard into array elements. 2) Loop through and output the contents of an array. 3) Search through an array to find and copy matching elements to another array. 4) Take numeric input from the keyboard, perform calculations, and output results.

Uploaded by

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

.

data

arr db 5 dup('A')

.code
main proc

mov ax,@data
mov ds,ax

xor bx,bx ;clear bx


xor cx,cx ;clear cx

lea bx,arr

;input values
while_:
mov ah,01h
int 21h
mov [bx],al
inc bx
inc cx

cmp al,0dh
je end_while
jmp while_

end_while:

mov ah,02h
mov dl,0dh
int 21h
mov dl,0ah
int 21h

;output
xor bx,bx
mov bx,offset arr

for_:
mov dl,[bx]
mov ah,02h
int 21h
inc bx
loop for_

main endp
end main

;array with string output


.data

arr db 'Monday$','Tuesday$','X$'

.code
main proc
mov ax,@data
mov ds,ax

xor si,si
mov si,-1
;mov bx,offset arr

;mov ah,09h
;lea dx,arr[1]
;int 21h

;loop and when we find $ we print


jmp print

for_:
inc si

cmp arr[si],'$'
je print

back:

jmp for_

print:
inc si

cmp arr[si],'X'
je end_if

jmp break

back_p:
mov ah,09h
lea dx,arr[si]
int 21h
jmp back

break:
mov ah,02h
mov dl,0ah
int 21h
mov dl,0dh
int 21h
jmp back_p

end_if:
mov ah,4ch
int 21h

main endp
end main
;correctly print a name
.data

arr db 25 dup('$')

.code
main proc

mov ax,@data
mov ds,ax

xor cx,cx
xor si,si

while_:
mov ah,01h
int 21h

cmp al,0dh
je end_while

inc cx

push ax
jmp while_

end_while:

mov dx,cx

pop_for:
pop ax
mov arr[si],al
inc si
loop pop_for

mov cx,dx
xor dx,dx

;new line
mov ah,02h
mov dl,0dh
int 21h
mov dl,0ah
int 21h

dec si
disp_Arr:
mov ah,02h
mov dl,arr[si]
int 21h
dec si
loop disp_Arr

end_if:
mov ah,4ch
int 21h

main endp
end main

;copy arrays

.model small
.stack 100h
.data

arz db 5 dup(0)

rr db 1,2,3,4,5,6,7,8,9,10

msg db 'Enter number : $'

.code
main proc

mov ax,@data
mov ds,ax

;print string
mov ah,09h
lea dx,msg
int 21h

;user input
;mov ah,01h
;int 21h

;and al,0fh

mov al,5

xor si,si
xor di,di
mov di,-1

mov cx,10

for_:
cmp rr[si],al
jae copy
back:
inc si
loop for_
jmp end_if

copy:
inc di
mov dl,rr[si]
mov arz[di],dl
jmp back

end_if:
mov ah,4ch
int 21h

main endp
end main

;first

.model small
.stack 100h
.data

msg db 'Enter number : $'

.code
main proc
mov ax,@data
mov ds,ax

xor cx,cx

while_:
mov ah,01h
int 21h

cmp al,0dh
je end_while

and al,0fh
push ax
inc cx
jmp while_

end_while:

mov ah,02h
mov dl,0dh
int 21h
mov dl,0ah
int 21h

pop_for:
pop ax
add bx,ax
loop pop_for

mov ah,02h
add bl,30h
mov dl,bl
int 21h
end_if:
mov ah,4ch
int 21h

main endp
end main

You might also like