hschumann2/TempleOS-Source-Code
0838
1 2//Press F5 in the editor to compile and run.3 4--------Hello.HC.Z---------5"Hello World\n";6 7 8--------Hello.HC.Z---------9U0 Main()10{11 "Hello World\n";12}13Main;14 15 16--------Hello.HC.Z---------17U0 MyPrint(U8 *st)18{19 "%s",st;20}21MyPrint("Hello World\n");22 23 24--------Hello.HC.Z---------25U0 MyPrint2(U8 *st1,U8 *st2) //Any number of args.26{27 "%s %s\n",st1,st2; //Any number of args.28}29MyPrint2("Hello","World");30 31 32--------Hello.HC.Z---------33U0 MyPrint(U8 *st)34{35 "" st; //Empty with no comma means first is fmt str.36}37MyPrint("Hello World\n");38 39 40--------Hello.HC.Z---------41asm {42MSG: DU8 "Hello World\n",0;43 44//The convention is underscore on C callable.45//Two colons means exported symbol.46_HELLO_WORLD::47//You can only clobber RAX,RBX,RCX,RDX48 PUSH RSI49 MOV RSI,MSG50 CALL PUT_STR51 POP RSI52 RET53}54Call(_HELLO_WORLD);55 56 57--------Hello.HC.Z---------58asm {59_HELLO_WORLD::60//You can only clobber RAX,RBX,RCX,RDX61 MOV RAX,'Hello '62 CALL PUT_CHARS //Up to 8 chars packed into one 64-bit int.63 MOV RAX,'World\n'64 CALL PUT_CHARS65 RET66}67Call(_HELLO_WORLD);68 69 70--------Hello.HC.Z---------71asm {72_MY_PRINT::73//You can only clobber RAX,RBX,RCX,RDX74 PUSH RBP75 MOV RBP,RSP76 PUSH RSI77 MOV RSI,U64 SF_ARG1[RBP]78 CALL PUT_STR79 POP RSI80 POP RBP81 RET1 8 //Callee pops the stack to clear args.82}83_extern _MY_PRINT U0 MyPrint(U8 *st);84MyPrint("Hello World\n");85 86 87--------Hello.HC.Z---------88asm {89_MY_PRINT::90//You can only clobber RAX,RBX,RCX,RDX91 PUSH RBP92 MOV RBP,RSP93 PUSH U64 SF_ARG1[RBP]94 CALL &PutS //Callee pops the stack to clear args.95 POP RBP96 RET1 897}98_extern _MY_PRINT U0 MyPrint(U8 *st);99MyPrint("Hello World\n");100 101 