Other Programming Languages
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
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:
1200+ fellow developers rate and compare features of the top IDEs, like Visual Studio, Eclipse, RAD, Delphi and others, across 13 categories. Enjoy this FREE Download of the IDE User Satisfaction Study by Evans Data Corporation. Download Now!
  #1  
Old March 13th, 2007, 08:26 PM
imsangha imsangha is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2007
Location: Concord, California
Posts: 20 imsangha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 34 m 22 sec
Reputation Power: 0
Send a message via MSN to imsangha
Assembly Language beginner question.

Hi. I've been learning assembly languages for a couple weeks with Kip Irvine's book, and I was working on one exercise program and I could never figure out why program was doing this.

It starts like...

.data
array2 WORD 10, blah, blah, blah, blah
index WORD 0

.code
main PROC
mov bp, index
mov ax, array2[ bp ]

....
main ENDP
end main



The problem was that "mov ax, array[ bp ]" line tried to read out of the allocated memory. By default, the address of array2 was 00405000h, and the default value was 0012FFF0h.

First, I set bp value to 0(index). So EBP was 00120000h. However, Instead of reading array2[ 0000h ], it tried to read array[00120000h] and the error message "Tried to read 00525000h (which is the offset of array2 + ebp)" poped up. Do you have any idea why the program did this? I certainly wanted array2[bp], not array2[ebp].

Oh, when I used "movzx ebp, index" instead of "mov bp, index" the program worked just fine. I'm just wondering why it uses bp instead of ebp when compiling. The version of my assembler is MASM 8.0. Thanks for reading!

Reply With Quote
  #2  
Old March 13th, 2007, 08:37 PM
jwdonahue jwdonahue is offline
Bellevue WA, USA
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: May 2004
Location: Bellevue Washington, USA
Posts: 1,038 jwdonahue User rank is Second Lieutenant (5000 - 10000 Reputation Level)jwdonahue User rank is Second Lieutenant (5000 - 10000 Reputation Level)jwdonahue User rank is Second Lieutenant (5000 - 10000 Reputation Level)jwdonahue User rank is Second Lieutenant (5000 - 10000 Reputation Level)jwdonahue User rank is Second Lieutenant (5000 - 10000 Reputation Level)jwdonahue User rank is Second Lieutenant (5000 - 10000 Reputation Level)jwdonahue User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 6 Days 23 h 14 m 51 sec
Reputation Power: 66
This is an "Other programming languages" problem.

But I seem to remember something about real/protected modes and the two different sizes of the registers. I could be wrong, but my generally faulty memory tells me that ebp is "extended base pointer" register and bp is just "base pointer" register. I think the ebp is 32 bits (64 on the 64 bit processors?) and bp is 16 or 24 (again, faulty memory).

You should definitely consult a reference on x86 architectures.
__________________
It's not always a matter of what you can do with a language, but whether you should. [JwD]

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreOther Programming Languages > Assembly Language beginner question.


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 | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway