chrislee8 said:OK, I have can't-be-smaller-helloworld executable written in assembly.
How does it communicate with the kernel in Mac which is Darwin, i believe.
can someone explain that in theory to me?
thanks
.data ; section declaration - variables only
msg:
.ascii "Hello, world!\n\0"
len = . - msg ; length of our dear string
.text ; section declaration - begin code
.globl _main
_main:
# write our string to stdout
li r0, 4 ; syscall number (sys_write)
li r3, 1 ; first argument: file descriptor (stdout)
; second argument: pointer to message to write
lis r4, ha16(msg); load top 16 bits of &msg
addi r4, r4,lo16(msg) ; load bottom 16 bits
li r5, len ; third argument: message length
sc ; call kernel
# and exit
li r0, 1 ; syscall number (sys_exit)
li r3, 1 ; first argument: exit code
sc ; call kernel
chrislee8 said:where do I get to know more about the kernel function calls and the memory allocation, etc..
thanks
I got this helloworld program from http://www.timestocome.com/personal/mac.html
Code:.data ; section declaration - variables only msg: .ascii "Hello, world!\n\0" len = . - msg ; length of our dear string .text ; section declaration - begin code .globl _main _main: # write our string to stdout li r0, 4 ; syscall number (sys_write) li r3, 1 ; first argument: file descriptor (stdout) ; second argument: pointer to message to write lis r4, ha16(msg); load top 16 bits of &msg addi r4, r4,lo16(msg) ; load bottom 16 bits li r5, len ; third argument: message length sc ; call kernel # and exit li r0, 1 ; syscall number (sys_exit) li r3, 1 ; first argument: exit code sc ; call kernel
like I like to know in the program, the ascii "Hello World!\n", how does the OS know how to print them to the screen?
I want to start from here. thanks
csubear said:Which is a micro-kernel. Which it different from the rest of the world. But I would like to know what that means.
main {
printf("Hello World!\n");
}
chrislee8 said:the url provided is way too complicated for a newbie
It is not about flaming or lecturing anyone. If you want to program in assembly, then program in assembly. However, it should do you well to understand something very important about assembly language programming on RISC-based systems like the Mac.chrislee8 said:Kingjr, please don't start the 'which language you should learn' kinda thing.
I am not a programming newbie, but I am a Mac/Linux/Assembly newbie.
There is absolutely nothing wrong with starting computer programming with assembly.
In Windows' world, there s win32asm, there are thousand of tutorial to show how to program in window's platform with asm.
so please stop flaming 'newbie' and just answer the question if you know the answer.
Not try to be rude, just to be straight up. No time to waste on forum.
Flynnstone,
thanks for your advise, i have my own reason which is simple: get to know the core of what Mac is doing. It is a hobby, maybe never be a expert, just to learn.![]()
superbovine said:http://www-106.ibm.com/developerworks/linux/library/l-powarch/
http://www-3.ibm.com/chips/techlib/techlib.nsf/techdocs/852569B20050FF778525699600719DF2
http://www-3.ibm.com/chips/products/powerpc/
if you click around long enough you find the instruction set on ibm's site. i am to lazy to find it and i lost my bookmark.
chrislee8 said:OK, I have can't-be-smaller-helloworld executable written in assembly.
How does it communicate with the kernel in Mac which is Darwin, i believe.
can someone explain that in theory to me?
thanks