1

after I wrote the assembly code, I have used NASM with 64bit and linker in linux to run the code. however, after I have tried to run the code, the segmentation error occurred.

segment .data:

file_name: db "haneens_texts.txt"
msg: db "Even if you’re on the right track, you’ll get run over if you just sit there"
len: equ $-msg

segment .bss:

segment .text:
global _start

_start:

mov edx,0777
mov ecx,2
mov ebx,file_name
mov eax,5
int 21H

mov eax,1 

mov ebx,file_name
mov ecx,msg
mov ebx,1
mov eax,4
int 21H

mov eax,1

mov eax,3
mov ebx,1
mov ecx,26
mov edx,26
int 21H

mov eax,6
mov ebx,1
int 21H

mov eax,1
mov ebx,0
int 21H
H W
  • 19
  • 1
  • sorry, it is a segmentation fault – H W Mar 29 '20 at 01:39
  • 1
    `int 21h` faults under Linux because Linux is not DOS. And it's *your program* that segfaults, not the linker. i.e. the segfault isn't "in linker". – Peter Cordes Mar 29 '20 at 01:46
  • Actually it looks like you're setting up register args for Linux system calls, so your code might just work if you change `int 21h` (DOS) to `int 80h` (32-bit Linux) – Peter Cordes Mar 29 '20 at 01:50
  • 1
    @PeterCordes Note that OP talks about writing 64 bit code in his introduction. I'm not quite sure what his exact setup is. – fuz Mar 29 '20 at 04:42

0 Answers0