我已成功打开一个文件并将文件描述符(7)存储在FILE中,并且我还将文件大小(153kb)存储在SIZE中。话虽这么说,这个mmap系统调用返回-14。我不确定我做错了什么
push %esi #Save non-general-purpose registers
push %edi #Save non-general-purpose registers
push %ebp #Save non-general-purpose registers
movl FILE, %edi #Move file descriptor into edi
movl $0, %ebp #Offset to 0
movl $0x2, %esi #MAP_PRIVATE
movl $0x3, %edx #PROT_READ
movl FSIZE, %ecx #File length
movl $0, %ebx # *addr = NULL
movl $90, %eax #mmap Sys Call
int $0x80 #Call kernel
test %eax, %eax #Error check
js _error
答案 0 :(得分:1)
MMAP 90 = $ 5A
使用带有Intel-Syntax的NASM对帧缓冲设备fb0进行MMAP的示例
%define XRes 400h
%define YRes 300h
%define Mapsize (XRes*YRes*4) ; 1024x768x32
section .text
call MAP_FB ; mmap
;----------- Subroutine----
MAP_FB: mov eax, 5 ; syscall nr: open
xor edx, edx
mov ebx, DEVICE ; pointer/offset auf File/Device-Name
mov ecx, 2 ; /usr/include/bits/fcntl.h = O_RDWR
int 80h
mov [FD], eax ; File discriptor
mov ebx, MMAP
mov eax, 5Ah ; mmap(90)
int 80h
mov esi, eax ; pointer mmap-FRAMEBUFFER
ret
section .data
DEVICE DB "/dev/fb0", 0, 0, 0, 0
MMAP: DD 0 ; start - suggest memory address to allocate
DD Mapsize ; length
DD 3 ; prot (PROT_READ + PROT_WRITE)
DD 1 ; flags (MAP_SHARED = 1)
FD: DD 0 ; file discriptor(handle)
DD 0 ; offset into file to start reading