[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Pgubook-readers] ending-address using base pointer addressing mode
From: |
Roger |
Subject: |
Re: [Pgubook-readers] ending-address using base pointer addressing mode |
Date: |
Fri, 6 Nov 2015 21:53:07 -0500 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
> On Fri, Nov 06, 2015 at 09:36:56PM -0200, William Rodrigues wrote:
> Hi everyone,
> I'm William from Brazil; this is my first participation on here. I am
> reading the 4th chapter from pgubook, but at
> one exercise of the third I'm at some difficulty. The text says to modify
> the maximum.s code and use an
> ending address rather than the number 0 to know when to stop.
>
> I tried this,
> **.section .data
>
> data_items:
> ** .long 3,62,14,20,35,49,74,55,0
>
> **.section .text
> **.globl _start
> _start:
> ** movl $data_items, %ecx******** # initialize %ecx with the address of
> data_items
> ** movl 4(%ecx), %ebx******************** # go to base pointer addressing
> mode, trying to get the value 62.
> ** movl $1, %eax
> ** int $0x80
>
> If %ecx has the (pointer) address of data_items. So, why the return value
> was 0 instead of 62 or 35?
> Thanks.
If I'm not mistaken, there are some minor mistakes within the book, or code
sections. Typos I think. You can either trace the code to find the error (as
I did when I first read the book a decade ago), or search using Google to find
the specific errors mentioned by others.
It is possible somebody has already compiled an errata listing by now for this
book!
Still, it is a great book, or great read, and you will not regret reading, nor
doing/performing each of the exercises as I have. Most programmers take little
time to understand how using their C/C++ routines use or effect the CPU. On
the flip, these programmers publish code by the handful on a daily basis.
--
Roger
http://rogerx.freeshell.org/