Xavier Maillard | 2 Aug 2004 23:10
X-Face
Picon

Re: Linux Assembly language programming.

On 16 jui 2004, miked wrote:

> Greetings,

Plop,

> I am interested in learning and programming in Assembly
> language in Linux environment. Are there any books that you can
> suggest to buy to learn it. Or any other web site or
> publication or whatever....etc Any ideas or helps would be
> appriciated. (I have progrmmed in MVS/S390 and Windows/DOS
> Programming environment using Asssembly). Thank you very much.
> Regards, Mike

As kt said, there is the absolutely wonderful linuxassembly.org
website.

I also purchased (months ago) a book on Assembly programming
targeted at Linux _only_.

This is:

Linux - Assembly Language Programming
by Bob Neveln
ISBN: 0-13-087940-1

Not that bad and very interesting as a "reference" book.

Regards,

(Continue reading)

Maciej Hrebien | 6 Aug 2004 11:25
Picon
Favicon

SMC article

Hi Karsten,

long time ago i had briefly looked at your SMC article placed at
linuxassembly.org but yesterday i opened it once again (by accident) and
read it more careful ;) The code is quite tricky i admire but i have one
small suggestion: you write only about .bss, placing the code in and
execute in it. It gives the illusion that SMC technique can only be used
in .bss. I think you should consider writing something about
un-mprotect-ing .text and doing SMC on it just to avoid this kind of
illusion. Let me illustrate what i mean:

.set PAGE_SZ, 4096
.set PROT_RD, 1
.set PROT_WR, 2
.set PROT_EX, 4

.text

.globl _start
_start:
        mov     $125,%eax         # change protection of code seg...
        mov     $_start,%ebx
        mov     $PAGE_SZ,%ecx
        and     $~(PAGE_SZ-1),%ebx
        mov     $(PROT_RD|PROT_WR|PROT_EX),%edx
        int     $0x80
hello:
        mov     $4,%eax           # write some text...
        mov     $1,%ebx
        mov     $msg,%ecx
(Continue reading)

Ankit Jain | 11 Aug 2004 11:00
Picon
Favicon

extended asm+pointers

hi

well i want to understand how assembler treats
pointers?

my code is:

      1	#include<inttypes.h>
      2
      3
      4 int main()
      5 {
      6   uint8_t
a[8]={1,2,3,4,5,6,7,8},b[8]={0,0,0,0,0,0},i;
      7   uint8_t *m,*m1;
      8 
      9   m=a;
     10   m1=b;         //i have pointed m1 to b
     11   for(i=0;i<8;i++)
     12      printf("%d ",a[i]);
     13   printf("\n");
     14   asm("movq (%1), %%mm0 \n"
     15       "movq %%mm0, (%0) \n"
     16       :"=r"(m1)
     17       :"r"(m)
     18       );
     19 
     20   for(i=0;i<8;i++)
     21      printf("%d ",b[i]);
     22   return 0;
(Continue reading)

sandeep | 11 Aug 2004 12:51

Re: extended asm+pointers

Ankit Jain wrote:
>       4 int main()
>       5 {
>       6   uint8_t
> a[8]={1,2,3,4,5,6,7,8},b[8]={0,0,0,0,0,0},i;
>       7   uint8_t *m,*m1;
>       8 
>       9   m=a;
>      10   m1=b;         //i have pointed m1 to b
>      11   for(i=0;i<8;i++)
>      12      printf("%d ",a[i]);
>      13   printf("\n");

>      14   asm("movq (%1), %%mm0 \n"
>      15       "movq %%mm0, (%0) \n"
>      16       :"=r"(m1)
>      17       :"r"(m)
>      18       );
this asm(...) is effectively achieving "m1=m;" you can verify this by printing 
m1[i] instead of a[i] and b[i]
>      19 
>      20   for(i=0;i<8;i++)
>      21      printf("%d ",b[i]);
>      22   return 0;
>      23 }
> well this problem is not solved yet. because when i
> display b array then it prints all 0's. according to
> me since i have initialised this m1 pointer then by b
> then b whould have all the values which i have moved
> 
(Continue reading)

sandeep | 11 Aug 2004 15:04

Re: extended asm+pointers

Yeah, on closer look, your code should achieve what you intended. May be 
something more has to be done in "asm ...." to get the correct code generated or 
  may be gcc (v 3.2.3 on i386) is not generating correct code.

I tried slightly modified version of your code (attached file 1.c)
also attaching the output of "gcc -S 1.c" (file 1.s - modified)

original assembly code generated for the "asm(...)" in the code was

#APP
     movq (%eax), %mm0
movq %mm0, (%eax)

#NO_APP

this code is not going to change things, as it is doing like "x=x".

On modifying the code to below (based on how variables were allocated for the test)

#APP
     movq (%eax), %mm0
     leal    -16(%ebp), %eax
movq %mm0, (%eax)

#NO_APP

"gcc 1.s" generates a.out that works the you expect.

Ankit Jain wrote:
> thanks. well i know it is effectively working for
(Continue reading)

Brian Raiter | 11 Aug 2004 20:33

Re: extended asm+pointers

>      14   asm("movq (%1), %%mm0 \n"
>      15       "movq %%mm0, (%0) \n"
>      16       :"=r"(m1)
>      17       :"r"(m)
>      18       );

I believe this code copies the contents of m to m1. (Actually, with
movq, I guess it will copy an extra four bytes in the process.) After
it runs, both m and m1 will point to b[].

I think part of your problem is that you're trying to treat an array
as an lvalue. gcc is decomposing your array into a pointer to the
first element, which is not a valid lvalue. So you're trying to do the
same thing via pointers. But it's not the same thing at all.

In other words, you're stumbling with how C treats arrays and
pointers, not the assembler.

Get rid of your m and m1 variables, and try doing this instead:

  asm("movq (%1), %%mm0 \n"
      "movq %%mm0, (%0) \n"
      : : "r"(b), "r"(a)
      );

(Note the lack of output operands. That's because we're not modifying
the "pointer" b. We're just modifying the array that b points to.)

I think this will do what you want.

(Continue reading)

Maciej Hrebien | 12 Aug 2004 08:00
Picon
Favicon

Re: SMC article

"Daniel R. Blair" wrote:
> 
> Do you have the URL of the original article?  I would really like to read
> it.. I am not sure exactly what SMC is.. but, if you could share, I'd be
> much appreciative.

SMC stands for Self-Modifying Code and the article is at:
http://linuxassembly.org/articles/smc.html

--

-- 
Maciej Hrebien

-
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

jeff | 13 Aug 2004 03:41

New Site for Desktop Assembly


New Site for Desktop Assembly
http://members/bsn1.net/jko <at> save-net.com/asm/

The DesktopLinuxAssembly site is being created and
presently has two projects, some code snippets
and information about desktop programming.

One project is registered at Sourceforge
http://sourceforge.net/projects/asmedit

Work on a library is scheduled for the future
along with code filter to transport source between
nasm and gas formats.  Participation or comments
are welcome.

-
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Ray | 13 Aug 2004 07:44

Re: New Site for Desktop Assembly

Forgot to CC to mailing list.

On Fri, Aug 13, 2004 at 01:42:52AM -0400, Ray wrote:
> On Thu, Aug 12, 2004 at 06:41:39PM -0700, jeff wrote:
> > New Site for Desktop Assembly
> > http://members/bsn1.net/jko <at> save-net.com/asm/
> 
> You mean: http://members.bsn1.net/jko <at> save-net.com/asm/
-
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

postmaster | 13 Aug 2004 08:43
Picon
Favicon

E-Mail-Virus / Dateisperre

Sehr geehrte E-Mail-Absenderin,
sehr geehrter E-Mail-Absender,

eine von Ihnen an die Stadtverwaltung Kassel verschickte eMail hat einen Virus oder eine aus
sicherheitsgründen nicht zulässige Anlage enthalten.

Der eventuell virenbefallene Teil der eMail oder die nicht zugelassene Anlage wurde aus der Nachricht vor
der Zustellung an die Empfängerin / den Empfänger entfernt. Die vollständige Übermittlung der
Nachricht incl. aller Anlagen kann nicht garantiert werden.

Weitere Informationen zu Art des Computervirus oder der gelöschten Anlage und dem Status Ihrer
Nachricht entnehmen Sie bitte dem unten angeführten Virenscan-Protokoll.

Mit freundlichen Grüßen
Ihre Internet- / E-Mail-Administration
der Stadtverwaltung Kassel

From: linux-assembly <at> vger.kernel.org
To: rika.westermann <at> stadt-kassel.de

File(s): wife.scr

Matching filename: *.scr

-
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

(Continue reading)


Gmane