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

Accessing Array Elements in Assembly

The document provides assembly language code for accessing array elements using registers and stack operations. It demonstrates how to push and pop 16-bit values onto the stack, convert ASCII values to numeric digits, and print them. The code initializes an array and uses loops to push its elements onto the stack and then print them as ASCII characters.

Uploaded by

comedykhomedy
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)
6 views1 page

Accessing Array Elements in Assembly

The document provides assembly language code for accessing array elements using registers and stack operations. It demonstrates how to push and pop 16-bit values onto the stack, convert ASCII values to numeric digits, and print them. The code initializes an array and uses loops to push its elements onto the stack and then print them as ASCII characters.

Uploaded by

comedykhomedy
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

ACCESS ARRAY ELEMENTS : use [BX] as container , get the base address using

[offset],use [SI]=index
ARRAY ELEMENTS : [BX+SI]

PUSH AX [16 bit reg contents will be added in stack,8 bit reg not allowed]
POP AX [contents will come from stack and store in 16 bit reg , here AX used ,8 bit
reg not allowed]

AX=AH+AL
IF USE STORE 0 IN AH , and 8 bit contents in AL , WE CAN USE IT(AX) FOR 8 bit

ASCII TO NUMERIC DIGIT : ADD 48

.model small
.stack 100h
.data
ar db 1,1,2,2,3
.code
main proc
mov ax,@data
mov ds,ax

mov cx,5
mov bx,offset ar
mov si,0

push_loop:
mov dl,[bx+si]
mov dh,0
push dx
inc si

loop push_loop

mov cx,5
print_loop:
pop dx
add dl,48
mov ah,2
int 21h
loop print_loop

mov ah,4ch
int 21h

main endp
end main

You might also like