N
N
newuser88882020-10-17 11:54:11
assembler
newuser8888, 2020-10-17 11:54:11

The movsb gas syntax line instruction doesn't work, can anyone explain why?

.data
.bss
.lcomm source, 10
.lcomm dest, 10

.text

.global _start
_start:
  movq $source, %rsi
  movq $1, (%rsi)
  movq $2, 1(%rsi)
  movq $3, 2(%rsi)

  movq $dest, %rdi
  movq $3, %rcx
  cld
  rep movsb

  movq $60, %rax
  xorq %rdi, %rdi
  syscall
.end

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jcmvbkbc, 2020-10-17
@newuser8888

The original code works fine as is:

$ gcc -nostartfiles -static str.s -o str
$ gdb ./str
...
(gdb) b *0x40102f
Breakpoint 1 at 0x40102f
(gdb) r
Starting program: /home/jcmvbkbc/tmp/toster/str 

Breakpoint 1, 0x000000000040102f in _start ()
(gdb) x/3b $rsi - 3
0x402000 <source>:      1       2       3
(gdb) x/3b $rdi - 3
0x402010 <dest>:        1       2       3

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question