wiki:Sperimentazione 8

Version 2 (modified by Mattia Monga, 13 years ago) ( diff )

--

Assembly MINIX

  • Minix assembly (man 9 as)
.sect .text; .sect .rom; .sect .data; .sect .bss;
.define _main
.extern _printf, _scanf, exit
.sect .text
_main:
    push ebp
    mov ebp, esp

    push x
    push fmt
    call _scanf
    pop ecx
    pop ecx
   
    push (x)
    call quad
    pop ecx


    push eax 
    push s
    call _printf
    pop ecx
    poecx   

    push 0
    call _exit


    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.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.