krostif
Jr. Member
  
Karma: +0/-0
Offline
Posts: 11
Mi ankaw parolas esperanton.
|
Please find herewith a simpler and shorter version of syscall in RF/linux/linux.asm:
code 'syscall', _syscall
; syscalls can take a variable number of arguments, from 0 to 6. ; The args go in ebx, ecx, edx, esi, edi, ebp, in that order. ; (this is from the Linux Assembly HOWTO)
; At entry, the Forth stack holds args, argcount, syscall-number
; validate argcount, if > 6 return without changing the stack mov ecx, [esi] ; ecx = argcount cmp ecx, 6 ja .ret
lea edi, [esi+4 +4*ecx] ; compute data stack adjustment push edi ; save it push eax ; save syscall-number mov eax, esi ; esi modified when argcount>3 neg ecx lea ecx, [.0 +4*ecx] ; i.e. .0-4*argcount jmp ecx
.6: mov ebp, [eax+24] ; 3-bytes instruction nop ; 1-byte nop padding .5: mov edi, [eax+20] nop .4: mov esi, [eax+16] nop .3: mov edx, [eax+12] nop .2: mov ecx, [eax+8] nop .1: mov ebx, [eax+4] nop .0: pop eax ; restore syscall-number int 80h ; eax = syscall result pop esi ; restore adjusted data stack .ret: ret
|