cat>filename
システムコールを使用して、Ubuntu 11.04 の NASM にコマンドを実装しようとしています。私のプログラムは正常にコンパイルされ、正常に実行されます (そう思われます)。しかし、cat filename
コマンドを起動しようとすると、「そのようなファイルまたはディレクトリはありません」と表示されますが、ディレクトリにファイルが存在することがわかります。ダブルクリックしてファイルを開こうとすると、「ファイルを開くために必要な権限がありません」と表示されます。私のコードのエラーを見つけるのを手伝ってくれませんか?
コードは次のとおりです。
section .data
msg: dd "%d",10,0
msg1: db "cat>",0
length: equ $-msg1
section .bss
a resb 100
len1 equ $-a
b resd 1
c resb 100
len2 equ $-c
section .txt
global main
main:
mov eax,4 ;;it will print cat>
mov ebx,1
mov ecx,msg1
mov edx,length
int 80h
start:
mov eax,3 ;;it will take the file name as input
mov ebx,0
mov ecx,a
mov edx,len1
int 80h
mov eax,5 ;;it will create the file by giving owner read/write/exec permission
mov ebx,a
mov ecx,0100
mov edx,1c0h
int 80h
cmp eax,0
jge inputAndWrite
jmp errorSegment
inputAndWrite:
mov [b],eax
mov eax,3 ;;take the input lines
mov ebx,0
mov ecx,c
mov edx,len2
int 80h
mov edx,eax ;;write the input lines in the file
mov eax,4
mov ebx,[b]
mov ecx,c
int 80h
jmp done
errorSegment:
jmp done
done:
mov eax, 1
xor ebx, ebx
int 80h
ps 上記のコードは、RageD からの提案を取り入れて再編集されています。それでも、私が作成したファイルには、「inputAndWrite」セグメントから与えられた入力行が含まれていません。私はあなたの提案を探しています。