The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages - More
> Other Programming Languages
|
Assembly - EMU8086 - Help converting 8-bit array to 16-bit array
Discuss EMU8086 - Help converting 8-bit array to 16-bit array in the Other Programming Languages forum on Dev Shed. EMU8086 - Help converting 8-bit array to 16-bit array A place for discussing programming languages not covered in specific forums such as Assembler, COBOL, etc. - you get the idea.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

February 9th, 2011, 02:55 PM
|
|
Registered User
|
|
Join Date: Mar 2009
Posts: 27
Time spent in forums: 13 h 22 m 54 sec
Reputation Power: 0
|
|
|
Assembly - EMU8086 - Help converting 8-bit array to 16-bit array
I'm not new to programming, but I am fairly new to assembly and I am having a little bit of trouble converting over. I realize this is a simple process, but any and all help would be much appreciated.
I have two arrays declared:
array1 db 10h, 20h, 30h, 40h, 50h
array2 dw 5 dup(?)
I need to copy the data in the 8-bit array1 to the 16-bit array2.
I believe I need to store the data in one of the registers first, then transfer it over to array2. I am not sure the syntax to use for this or the correct process. Thanks.
|

February 9th, 2011, 06:31 PM
|
|
|
|
What have you tried / where are you stuck? If you have code that doesn't work post it here (surround it with [code][/code] tags to make it legible) as well as any error messages (or if its running what you expected to happen vs. what did happen).
If you haven't manage to write code yet, where are you stuck? Do you know how to create, assemble and run a program? How to move values between registers? between registers and memory? Can you code a loop?
As the sticky at the top of the forum says, no one here is going to do your homework for you, but if you show your efforts we can look for errors and point you in the right direction.
__________________
sub{*{$::{$_}}{CODE}==$_[0]&& print for(%:: )}->(\&Meh);
|

February 9th, 2011, 07:35 PM
|
|
Registered User
|
|
Join Date: Mar 2009
Posts: 27
Time spent in forums: 13 h 22 m 54 sec
Reputation Power: 0
|
|
Thanks OmegaZero, I would rather no one just give me the code as well. I'm a learn by doing person.
I understand how to create, assemble and run a program. The only program I've done is taking values from an array, and adding them together. I also implemented a simple loop to do this process. I understand how to move data using "mov".
I could use a little clarity on the "mov" function. Does "mov" transfer data to a specified location. And is there a different function that just transfers the address, acts as a pointer?
I've already declared the two arrays in the data section. And in the code segment, my professor has confirmed that this is the way he wants us to start:
Code:
lea bx, array1
lea si, array2
I could use a little help/pointers on how to increment between the values of the array.
Also, if I "mov array2, si" data from a register to an array, it will place that data into the array. If I then do the same process again, such as "mov array2, si" will it add the data to the array or replace what is already in the array?
|

February 10th, 2011, 05:38 PM
|
|
|
It sounds like you know about pointers from C. In which case this might help:
Code:
This assembler code
value dw 0
mov ax, value
lea bx, value
Looks like it is the same as the C
int value = 0;
ax = value;
bx = &value;
But is really
// 0x1234 is some place in memory that
// was initialized when the program was started
const int *value = 0x1234;
ax = *value;
bx = value;
(I.e. An identifier like "value" in "value db ..." is really just making a note of where in memory the ... starts)
Quote: | Originally Posted by BryanAdams I could use a little clarity on the "mov" function. Does "mov" transfer data to a specified location. And is there a different function that just transfers the address, acts as a pointer? |
'mov' transfers data from one of its operands to the other. Whether that's immediate->register register->register or memory->register, etc. depends on the operands you give it.
Code:
mov ax, 0
mov ax, bx
mov ax, [bx]
(guessing on the syntax your assembler uses here.)
'lea' moves an address into a register.
Quote: | Originally Posted by BryanAdams I could use a little help/pointers on how to increment between the values of the array.
Also, if I "mov array2, si" data from a register to an array, it will place that data into the array. If I then do the same process again, such as "mov array2, si" will it add the data to the array or replace what is already in the array? |
Arrays are nothing more than an address in memory of the first element. Any mov instruction with 'array2' will read/write the same location in memory. To read or write the next byte in memory you need "address-of-array2 + 1" (which should hopefully explain why your teacher is having you store the address in a register)
|

February 17th, 2011, 11:00 AM
|
|
Registered User
|
|
Join Date: Mar 2009
Posts: 27
Time spent in forums: 13 h 22 m 54 sec
Reputation Power: 0
|
|
|
Thanks OmegaZero, your explanations really helped out. My interpretations of the mov and lea function were slightly off in their purpose.
I figured out the rest of the program. My biggest problem was moving from the 1-byte to the 2-byte register. When I realized I could just use a 1-byte register such as "al" to store each value from the array then transfer them over, it was a very simple process.
Thanks again for the help, really gave me some clarity on the processes.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|