|
CS 456 - Systems Programming
Spring 2024
|
Displaying ./code/mar27/helloNotes.c
#include <stdio.h>
#include <unistd.h>
int main(){
write(1, "Hello World!\n", 13);
/*
*
* In NASM Assembly, the above would like this:
*
* mov edx, 13 // number of bytes to write, third argument in write
mov ecx, msg // buffer, second argument in write
mov ebx, 1 // file descriptor, first argument in write
mov eax, 4 // opcode for write
int 80h
*
* write in C is structured like this
*
* write( file descriptor, the buffer with the text, how many bytes to write)
*
* and write returns number of bytes sucessfully written
*
* write has the opcode of 4 in 32 bit assembly
*
* eax - where the opcode (or what system call you are using goes)
*
* write takes three arguments, they go in ebx ecx and edx respectively
*
* ebx - file descriptor, first argument
* ecx - string buffer, the second argument
* edx - number of bytes to write, third argument
*
*
* /
}
|