Changes between Initial Version and Version 1 of Sperimentazione 6


Ignore:
Timestamp:
Apr 20, 2010, 2:52:21 PM (14 years ago)
Author:
Mattia Monga
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Sperimentazione 6

    v1 v1  
     1 * Minix assembly
     2
     3{{{
     4#!asm
     5.sect .text; .sect .rom; .sect .data; .sect .bss;
     6.extern _main, _printf, _scanf
     7.sect .text
     8_main:
     9    push ebp
     10    mov ebp, esp
     11
     12    push x
     13    push fmt
     14    call _scanf
     15    add esp, 8
     16   
     17    push (x)
     18    call quad
     19    add esp, 4
     20
     21
     22    push eax
     23    push s
     24    call _printf
     25    add esp, 4   
     26
     27    mov esp, ebp
     28    pop ebp
     29    ret
     30
     31
     32quad: push ebp
     33      mov ebp, esp
     34
     35      mov eax, 8(ebp)
     36      imul eax, eax     
     37
     38      mov esp, ebp
     39      pop ebp
     40      ret
     41
     42
     43.sect .data
     44
     45x: .data4 0
     46
     47.sect .rom
     48s: .asciz "Il risultato: %d\n"
     49fmt: .asciz "%d"
     50}}}
     51
     52 * messaggi in Minix
     53
     54{{{
     55#!c
     56#include <ansi.h>
     57#include <minix/com.h>
     58#include <minix/ipc.h>
     59#include <sys/types.h>
     60#include <stdlib.h>
     61#include <alloca.h>
     62
     63int send(int, message*);
     64
     65
     66int main(void){
     67
     68    message *msg;       
     69    msg = (message*) malloc(sizeof(message));
     70    msg->m_source = 0;
     71    msg->m_type = M1;
     72    msg->m1_i1 = 42;
     73     
     74
     75    send(ANY, msg);     
     76    return 0;
     77}
     78}}}
     79
     80