bug-gdb
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fw: [Nasm-bugs] Nasm & binutils opcode/ bug (not a big bug on gdb ;p)


From: Mike Deep
Subject: Fw: [Nasm-bugs] Nasm & binutils opcode/ bug (not a big bug on gdb ;p)
Date: Sun, 9 Nov 2003 16:36:37 +0100


Begin forwarded message:

Date: Sun, 9 Nov 2003 16:16:46 +0100
From: Mike Deep <address@hidden>
To: address@hidden
Cc: address@hidden
Subject: [Nasm-bugs] Nasm & binutils opcode/ bug


Hello,

According to the documentations Intel Architecture Software Developer's Manual 
(Vol'2), the instructions POPF/POPFD/POPA/POPAD are buged in NASM and all other 
software using the opcode/ map of binutils:


Instruction Set Reference :
61h = POPA
61h = POPAD
-
9Dh = POPF
9Dh = POPFD

The two opcodes are similar.  By definition, in the documentation Intel, when 
two opcodes are similar, it is necessary used the operand-size as instruction 
prefixe. Thus, one can distinguish between an instruction 16BITS or 32BITS. 
blah blah.....

The problem this is that NASM doesn't manage it !  
Look at folow : 

<snip>

global _start

section .text

_start:
        popfd
        popf
        nop
        popad
        popa
        mov eax, 1
        int 0x80

===========

08048080 <_start>:
 8048080:       9d                      popf  < ??? : Normaly popdf..
 8048081:       9d                      popf  < ?! : Normaly need the 66h 
prefixe.
 8048082:       90                      nop    
 8048083:       61                      popa  < !! same as up 
 8048084:       61                      popa  < !! same as up
 8048085:       b8 01 00 00 00          mov    $0x1,%eax
 804808a:       cd 80                   int    $0x80

</snip>

There, NASM would have placement the operand-size (66h) prefixe on POPF and 
POPA.  

Now I go added the prefixe manually, and I will launch the program.  

<snip>

global _start

section .text

_start:
        popfd
        db 0x66
        popf
        nop
        popad
        db 0x66
        popa
        mov eax, 1
        int 0x80

=========

# make
nasm -f elf TestOp.asm
gcc -o prog *.o -nostdlib
# ./prog 
# (ok, nice)

; now disassemble..

; Objdump
08048080 <_start>:
 8048080:       9d                      popf  < lol, normaly is POPFD 
 8048081:       66 9d                   popfw  < POPFW doesn't existe :) 
normally it's POPF :P
 8048083:       90                      nop    
 8048084:       61                      popa   < same as up
 8048085:       66 61                   popaw  < same as up
 8048087:       b8 01 00 00 00          mov    $0x1,%eax
 804808c:       cd 80                   int    $0x80

; gdb 

0x08048080 <_start+0>:  popf   
0x08048081 <_start+1>:  popfw  
0x08048083 <_start+3>:  nop    
0x08048084 <_start+4>:  popa   
0x08048085 <_start+5>:  popaw  
0x08048087 <_start+7>:  mov    $0x1,%eax
0x0804808c <_start+12>: int    $0x80

</snip>

Therefore:

- The program perfectly works and it corresponds to the documentation of Intel. 
 

- NASM does not add the prefixe 66H before POPF and POPA.  

- And objdump or gdb that uses (I believe) the dir opcode/ of binutils.  
Here, good luck.  

regards,
Mike Deep


-------------------------------------------------------
This SF.Net email sponsored by: ApacheCon 2003,
16-19 November in Las Vegas. Learn firsthand the latest
developments in Apache, PHP, Perl, XML, Java, MySQL,
WebDAV, and more! http://www.apachecon.com/
_______________________________________________
Nasm-bugs mailing list
address@hidden
https://lists.sourceforge.net/lists/listinfo/nasm-bugs




reply via email to

[Prev in Thread] Current Thread [Next in Thread]