Other Programming Languages
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreOther Programming Languages

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 9th, 2011, 02:55 PM
BryanAdams BryanAdams is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2009
Posts: 27 BryanAdams User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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.

Reply With Quote
  #2  
Old February 9th, 2011, 06:31 PM
OmegaZero OmegaZero is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: May 2007
Posts: 737 OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 10 m 23 sec
Reputation Power: 928
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);

Reply With Quote
  #3  
Old February 9th, 2011, 07:35 PM
BryanAdams BryanAdams is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2009
Posts: 27 BryanAdams User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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?

Reply With Quote
  #4  
Old February 10th, 2011, 05:38 PM
OmegaZero OmegaZero is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: May 2007
Posts: 737 OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 10 m 23 sec
Reputation Power: 928
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)

Reply With Quote
  #5  
Old February 17th, 2011, 11:00 AM
BryanAdams BryanAdams is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2009
Posts: 27 BryanAdams User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreOther Programming Languages > Assembly - EMU8086 - Help converting 8-bit array to 16-bit array

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap