TempleOSCD_140715.ISO

This commit is contained in:
Terry A. Davis authored and minexew committed 2018-09-08 21:46:09 +02:00
1 parent 7ef616a20e
commit 64f679eeb9
1095 files changed
+24814 -221011

No files matched your search

+17 -15
View File
@@ -1,18 +1,18 @@
/*
This is a JIT file, not AOT.
Asm labels can only be defined once
in a task. Hit F5 to spawn a new task
each time and run it.
/*Asm labels can only be defined once
in a task. <F5> will spawn a new task
each time, so you don't get redefine
error, like when repeatedly #including
it from the cmd line.
*/
//This is to demo glbl var access.
//Glbs defined elsewhere can accessed too, like sys_jiffies.
//Glbs defined elsewhere can accessed too, like cnts.jiffies.
I64 glbl_hz=400,glbl_hz_step=100,glbl_hz_base=100;
asm {
//Opcodes are slightly different to make writing my x86_64 assembler easier.
//See $LK,"::/Compiler/OpCodes.TXT"$.
USE64 //Defaults to 64, but this is a good habit.
JIFFIES_MSG: DU8 "Jiffies:",0;
@@ -20,15 +20,15 @@ JIFFIES_MSG: DU8 "Jiffies:",0;
//See $LK,"::/Kernel/Str1a.CPP",A="FL:::/Kernel/Str1a.CPP,1"$ and $LK,"::/Kernel/Utils1a.CPP"$.
_BEEPS2::
//You can clobber RAX,RBX,RCX,RDX,R8,R9
//You can clobber RAX,RBX,RCX,RDX,R8,R9. The compiler expects that.
PUSH RBP
MOV RBP,RSP
MOV RCX,U64 SF_ARG1[RBP] //$LK,"SF_ARG1",A="FF:::/Kernel/Adam1a.HPP,SF_ARG1"$
PUSH U64 [&sys_jiffies]
PUSH U64 [&cnts.jiffies]
@@05: PUSH RCX
//U0 Beep(I64 freq=500,Bool busy=FALSE)
//U0 $LK,"Beep",A="MN:Beep"$(I64 freq=500,Bool busy=FALSE)
PUSH FALSE //Do not busy (spin) wait
PUSH U64 [&glbl_hz] //evaluated at run time
CALL &Beep
@@ -41,7 +41,7 @@ _BEEPS2::
POP RSI
POP RAX
SUB RAX,U64 [&sys_jiffies]
SUB RAX,U64 [&cnts.jiffies]
NEG RAX
CALL PUT_HEX_U64
MOV RAX,'\n'
@@ -52,24 +52,26 @@ _BEEPS2::
}
//My convention is to put an underscore
//on C callable routines.
//on C callable asm routines.
_extern _BEEPS2 U0 Beeps2(I64 cnt);
U0 AsmAndC2()
{
I64 reg R15 i;
i=PmtI64("$$PURPLE$$\n\nNum of beeps 1-5 (%d):$$FG$$",3,1,5);
i=GetI64("$$PURPLE$$\n\nNum of beeps 1-5 (%d):$$FG$$",3,1,5);
Beeps2(i);
asm {
LIST
//You can clobber RAX,RBX,RCX,RDX, but preserve the rest.
USE64 //Defaults to 64, but this is a good habit.
MOV RCX,R15 //You can clobber RAX,RBX,RCX,RDX. Preserve the rest.
@@05: PUSH RCX
//U0 Snd(F64 freq);
//U0 $LK,"Snd",A="MN:Snd"$(F64 freq);
MOV RAX,RCX //freq=loop*100.0+100.0
IMUL2 RAX,glbl_hz_step //evaluated at compile ttime
@@ -80,7 +82,7 @@ USE64 //Defaults to 64, but this is a good habit.
CALL &Snd //We can skip IMPORT with & if JIT compiling.
MOV RCX,time_stamp_freq>>3 //JIT Const. Simple delay loop.
MOV RCX,cnts.time_stamp_freq>>3 //JIT Const. Simple delay loop.
@@10: LOOP @@10
POP RCX