0
votes

I have this code on Emu8086:

Mov Bx,0000h
Mov Cx,0ah 
Mov Si,0200h
Fillup:
Mov Ax,Array[bx]
Mov Ds:[Si],Ax
Inc Bx
inc si                           
loop FillUp

Array dw 28h,43h,0a4h,4ch,81h,21h,0ceh,0fh,2dh,87h

When emulating this happens:

Image

The memory table looks like this:

Address Value
0200 28
02001 00
02002 43
02003 00
02004 a4

Enter the digit every two steps, and I don't know why it happens.

I have tried many ways to cycle, but I can't find the solution.

One last qustion

How can I initialize an array of n elements at a specific memory address?

For example, how can I make my entire array of 10 elements that are from the address 0200h? Without moving from the array to the memory address.

2
What is it supposed to do? Note that your Array is an array of words (because of dw) and so Array itself contains the bytes 28h, 00h, 43h, 00h, a4h, 00h, etc. Is that what you wanted? Keep in mind x86 is little-endian and so dw 28h is the two bytes 28h,00h in that order.Nate Eldredge
It's true, obviously, more simpler impossible Many many many thanks :DCkris
One last question how to initialize an array of n elements at a specific memory address For example, how can I make my entire array of 10 elements that are from the address 0200h. Without moving from the array to the memory address. I hope I could have explained myself, thanksCkris

2 Answers

1
votes

Like most modern processors, it is byte addressable.  This means that each byte gets its own address, and when we group bytes to make larger word sizes, then that word in memory occupies multiple byte addresses.

We need to consistently tell the processor the same data sizes for the same data types.  The processor doesn't know about data declarations and remember their types the way high level languages do: it sees only instructions, and every instruction that manipulates data — in some sense — must tell the processor how many bytes the data occupies.

Here's a list of things that need to be consistent:

  • Pointer size increments — add 2 to pointer to access next word-sized data
  • Index scaling — scale an index by 2 for word-sized data
  • Data declaration — use dw for word-sized data
  • Load & store size — use word-sized loads & stores
    • by using word sized source or target register (e.g. ax, bx, vs. al, bl)
    • by using "word ptr" or "word" as per your assembly language
0
votes

The source is an array of words. Change 'dw' to 'db'.