Changes between Version 1 and Version 2 of Sperimentazione 8


Ignore:
Timestamp:
May 12, 2011, 5:08:24 PM (9 years ago)
Author:
monga
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Sperimentazione 8

    v1 v2  
    1 == Creazione di una system call gestita da PM ==
     1== Assembly MINIX ==
     2
     3 * Minix assembly (man 9 as)
    24
    35
    4 * aggiunta della syscall {{{foo}}} diff:tags/minix-3.1.2a//tags/syscall-add-simple-foo
    5    [[IncludeSource(tags/syscall-add-simple-foo/test/testfoo.c, line_numbers=0)]]
    6    * aggiunta della syscall {{{foo}}} con un parametro intero diff:tags/syscall-add-simple-foo//tags/syscall-add-foo-with-arg
    7    [[IncludeSource(tags/syscall-add-foo-with-arg/test/testfoo.c, line_numbers=0)]]
     6{{{
     7#!asm
     8.sect .text; .sect .rom; .sect .data; .sect .bss;
     9.define _main
     10.extern _printf, _scanf, exit
     11.sect .text
     12_main:
     13    push ebp
     14    mov ebp, esp
     15
     16    push x
     17    push fmt
     18    call _scanf
     19    pop ecx
     20    pop ecx
     21   
     22    push (x)
     23    call quad
     24    pop ecx
     25
     26
     27    push eax
     28    push s
     29    call _printf
     30    pop ecx
     31    poecx   
     32
     33    push 0
     34    call _exit
     35
     36
     37    mov esp, ebp
     38    pop ebp
     39    ret
     40
     41
     42quad: push ebp
     43      mov ebp, esp
     44
     45      mov eax, 8(ebp)
     46      imul eax, eax     
     47
     48      mov esp, ebp
     49      pop ebp
     50      ret
     51
     52
     53.sect .data
     54
     55x: .data4 0
     56
     57.sect .rom
     58s: .asciz "Il risultato: %d\n"
     59fmt: .asciz "%d"
     60}}}
     61
     62 * messaggi in Minix
     63
     64{{{
     65#!c
     66#include <ansi.h>
     67#include <minix/com.h>
     68#include <minix/ipc.h>
     69#include <sys/types.h>
     70#include <stdlib.h>
     71#include <alloca.h>
     72
     73int send(int, message*);
     74
     75
     76int main(void){
     77
     78    message msg;       
     79    msg.m_source = 0;
     80    msg.m_type = M1;
     81    msg.m1_i1 = 42;
     82     
     83
     84    send(ANY, &msg);     
     85    return 0;
     86}
     87}}}
     88
     89
     90
     91