×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

putting data into array

putting data into array

putting data into array

(OP)
in assembly language how do i place numbers into an array

numarray   db   5 dup(?)
firstnum   db   0

mov    ah,1
int    21h
mov    firstnum,al
mov    bx,offset numarray
mov    [bx],firstnum

now i aint sure if a variable can be placed into an array like this.. does it have to come from a register like al?
if i wanted to take in 5 numbers how do i move through the array to place them in? do i just inc   bx ?

RE: putting data into array

Let's do a bit of a review.  the mov instruction can transfer:
register to register
register to memory
memory to register
constant to register
constant to memory
register to segment register
segment register to register
memory to segment register
segment register to memory

There is NO mov instruction that can transfer memory-to-memory.  mov [bx],firstnum IS NOT LEGAL because [bx] refers to a memory address (the memory address of the array) and firstnum refers to another memory address (the firstnum variable)

HOWEVER:
between mov bx,offset numarray and your attempted mov [bx],firstnum, al is NOT changed, which means you can do:
mov firstnum,al
mov bx,offset numarray
mov [bx],al

"Information has a tendency to be free.  Which means someone will always tell you something you don't want to know."

RE: putting data into array

(OP)
so if i wanted to put another variable in the next position do i increment bx?
inc   bx

also if i want bx to point to the first postion of the array do i
mov    bx,'0'
to repostion it at the start?
or
mov    bx,offset numarray
again


i just want to thank u have been a great help..

RE: putting data into array

(OP)
its ok i figured this one out.. thanks again AmkG

RE: putting data into array

mov bx, offset numarray

and

inc bx

are correct

NOTE!

if you use a word array:
numarray dw n dup (0)

make sure to consider the SIZE of each element when you increment/decrement bx!

i.e. words are two bytes long, so instead of inc bx, do add bx,2.  If your array elements are three bytes long, use add bx,3... etc.

Just a reminder!

"Information has a tendency to be free.  Which means someone will always tell you something you don't want to know."

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close