wiki:Sperimentazione 6

Version 1 (modified by Mattia Monga, 15 years ago) ( diff )

--

  • Minix assembly
.sect .text; .sect .rom; .sect .data; .sect .bss;
.extern _main, _printf, _scanf
.sect .text
_main:
    push ebp
    mov ebp, esp

    push x
    push fmt
    call _scanf
    add esp, 8
   
    push (x)
    call quad
    add esp, 4


    push eax 
    push s
    call _printf
    add esp, 4   

    mov esp, ebp
    pop ebp
    ret


quad: push ebp
      mov ebp, esp

      mov eax, 8(ebp)
      imul eax, eax      

      mov esp, ebp
      pop ebp
      ret


.sect .data

x: .data4 0

.sect .rom
s: .asciz "Il risultato: %d\n"
fmt: .asciz "%d"
  • messaggi in Minix
#include <ansi.h>
#include <minix/com.h>
#include <minix/ipc.h>
#include <sys/types.h>
#include <stdlib.h>
#include <alloca.h>

int send(int, message*);


int main(void){

    message *msg;       
    msg = (message*) malloc(sizeof(message));
    msg->m_source = 0;
    msg->m_type = M1;
    msg->m1_i1 = 42;
     

    send(ANY, msg);     
    return 0;
}
Note: See TracWiki for help on using the wiki.