-2

I want to translate following lines from AT&T to Intel (nasm) :

This is my AT&T-Code:

   .equ BUFFEREND, 1
   .lcomm buffer, BUFFEREND
    cmpb $97, buffer

And here is my Intel-Code:

   BUFFEREND EQU 1
   buffer db BUFFEREND
   cmp BYTE [buffer], 97

What is wrong with my Translation? I have the lines from the following code. The AT&T-Code works. It translates all undercase characters in one file in uppercase characters and save it in a new file. :

.global _start

.equ BUFFEREND, 1
.lcomm buffer, BUFFEREND

_start:

movl %esp, %ebp

movl $5, %eax
movl 8(%ebp), %ebx
movl $0, %ecx
int $0x80

pushl %eax

movl $5, %eax
movl 12(%ebp), %ebx
movl $03101, %ecx
movl $0666, %edx
int $128

pushl %eax

loop:
movl -4(%ebp), %ebx
movl $3, %eax
movl $buffer, %ecx
movl $BUFFEREND, %edx
int $128

pushl %eax

cmpb $97, buffer
jl next_byte
cmpb $122, buffer
jg next_byte

subb $32, buffer

next_byte:

movl %eax, %edx
movl $4, %eax
movl -8(%ebp), %ebx
movl $buffer, %ecx
int $0x80

popl %eax

cmpl $BUFFEREND, %eax
jne loopexit

jmp loop

loopexit:
movl $1, %eax
movl $0, %ebx
int $0x80

The exact probleme is that my intel-file creates no outputfile

Shibumi
  • 635
  • 6
  • 17

1 Answers1

1

.lcomm creates a zero-initialized variable of the given size in the .bss section. As such, your buffer db BUFFEREND should be modified accordingly, as per the syntax of your assembler. Unfortunately you have forgotten to specify which one you use. For nasm the equivalent could be:

section .bss
buffer resb BUFFEREND

Also you have forgotten to mention what the exact problem is.

Jester
  • 56,577
  • 4
  • 81
  • 125