.........................................................................
.;             >>>>> Please put the title here <<<<<
.laser
.topmargin 1"
.margin 1"
.bottommargin 1"
.hlt bold
.; pick one of the fonts, and comment out or erase the one you don't want
.;font helvetica
.font times
.point 9.4285
.leading 1
.; The following rulers work for Times-Roman and Helvetica
.; Three columns per page (2 1/16")
..................................<

.; Two columns per page (3 1/25")
......................................................<
AAA
BY SDH

.hlt bold
_Displaying System Date and Time_

  Hello  assemblers!  Welcome to the 12th submission of
the AAA! This month we  will  cover  quite  a  few  new
tricks.  We will learn a simple method on how to access
the system  date  and time and display this information
to  the  screen.  We will  also  cover  employing  some
pre-supplied subroutines that AMOS provides for us, and
even  learn  how to access them during assembly.  Let's
get started.
_Using a System Library Routine_
  AMOS   supplies  us  assemblers  with  some  standard
.hlt italic
_library_  routines  that  we  may  access.  One of these
.hlt bold
routines (think subroutine) will output the system date
and  time  for  us, and is labeled _$ODTIM_ (_$_ystem  call
_O_utput _D_ate and  _TIM_e).  Just  as we have written short
subroutines in earlier AAA programs and then used "CALL
ROUTINE", we can _CALL $ODTIM_ - even  though the library
routine's code is not contained within our program.
  Remember  in  the  December  '86  AAA  we  created  a
subroutine called MENU  that  typed  out  a menu to the
screen and waited for user input. When we accessed this
subroutine,  we  just  placed  in  the code _CALL  MENU_.
Further  down in the code was our routine  marked  with
the label  MENU:. This is how the assembler figured out
where to get  the  next  instruction(s).  When the MENU
routine was finished, we returned to the line below the
_CALL_.
  When you use a library routine like $ODTIM, you still
have the line of code _CALL $ODTIM_, but you  do _not_ have
a  label  $ODTIM:! AMOS will execute the code contained
in $ODTIM and then return you to your program. However,
how  does AMOS  know  where  to  get  the  instructions
contained in $ODTIM? The procedure is twofold.
  1) You must  first place in a line of code at the top
of your  program that looks like this: _AUTOEXTERN_. This
line informs  the assembler that any CALL or LABEL that
it can't find from  within  the  source code must exist
"externally". In other words, $ODTIM  exists externally
to the file. Since there is some source code "missing",
the  assembler  cannot  create  a  .LIT file  (the  dot
command).  Therefore, the assembler only  gets  through
Phase 2 of assembly, and creates an .OBJ file.
  2) To "link"  up  the external label or CALL with our
 .OBJ file from (1) above,  you use the _.LNKLIT_ command.
LNKLIT has many forms, but for  library  routines,  the
format  is  _.LNKLIT  object  program name_. This command
will then take our .OBJ file from (1) above and link in
the  external  library  code, creating our desired  dot
(.LIT) command. Simple enough,  no? 
_Format of $ODTIM_
  The  subroutine  $ODTIM has many  different  formats.
Again, this routine  will display the date and time for
us, but the display has many different looks. Below  is
the calling setup for $ODTIM. It requires registers D3,
D4,  D5,  and  A2 to be set up according to the desired
format  you  would  like  to  see  the time and/or date
displayed:

_D3_ : if 0, use system  time  and system date, egnor D4.
If  non-zero,  D3  contains  the date  you  would  like
displayed.
_D4_ : if D3 is zero, D4 is egnored,  else  D4  holds the
time you would like displayed.
_D5_ : contains "flags"  (set bits). Each of the first 16
bits  (lower word) of D5  represent  flags  to  dictate
$ODTIM's  output  (see the diagram below for each flags
purpose).  A special case exists if D5 contains a "-1".
If D5 contains a -1, the output looks like this:
.center Friday, February 20, 1987 02:15:53 PM
_A2_ : if non-zero, the date  and/or  time is returned to
the memory location  pointed  to  by  A2. If you do not
want the output to go to a memory location,  make  sure
A2 contains a zero.

.;ED - INSERT FROM SUPER DAVES DOODLES "TIME BITS" HERE

_Time for an Example Program_
  Let's employ  the  $ODTIM  call in a simplified clock
program. Below is a program called  CLOCK. This program
will display the current day to us and then continually
update the time of day. Here is CLOCK:

.;ED, PROGRAM IS CALLED CLOCK.M68[300,7]

_Line-by-Line, Byte-by-Byte (partial)_
SEARCH AAA. This is a non-AMOS universal  file  that we
have  been using over and over. This file contains  all
of our  slick  MACROs  that  we  have  created over the
series. This universal file is in the Assembler  PPN on
the  Network  [100,133]  and  is  also  listed  in  the
January  '87  AAA. Once we SEARCH this file, we may use
any or all of the MACROs contained within.
.;
AUTOEXTERN
This informs the assembler that there  is  some  source
code external to this file, and LNKLIT will need to  be
performed.
.;
DEFINE CLEAR = PRTTAB -1,0
DEFINE CUROFF = PRTTAB -1,29.
DEFINE CURON = PRTTAB -1,28.
This is really slick.  Since  AAA.UNV  from  our SEARCH
above  contains the MACRO "PRTTAB" (which is just  like
PRINT TAB (#,#) from within BASIC), we can create "new"
MACROs by  employing  the already defined PRTTAB MACRO.
This  is  a  very  nice  feature  of  the  Alpha  Micro
assembler, and it definately makes your programs really
easy to read.
.;
CLR D3
MOV #0,A2
This is where we setup $ODTIM's input parameters. Since
D3 contains a zero, we will be using the current system
time and date (and D4 will be egnored). Also, since the
output will be to the terminal, A2 must contain a zero.
.;
MOV #^H000002F6,D5
Move  the  32  bit  HEX value (#^H) 2F6 to register D5.
This is where we "set our flags". The binary equivalent
for  HEX 2F6 is 00000000000000000000001011111010.  This
flag  setting  will  produce the following using $ODTIM
(assuming the date is 02/20/87):
.center Friday, February 20, 1987
To see this, take the lower 16 bits of the above binary
equivalent  and  place these bits in the above diagram.
(If you are confused between binary,  hex,  and  octal,
get  a  program called _CONVRT.BAS_ off the Network,  PPN
[100,101].  This  program  lets you enter in any number
and see all the equivalents of every base. Also See the
November '85 Heyliger's Highlights).
.;
CLEAR
CUROFF
PRTTAB 3,20.
TYPE <Today is >
The above four lines clear the  screen,  turn  off  the
cursor,  tab  to  row  3,  column  20, and type out the
message contained in the <..>.  Notice how the 3 MACROs
above make for real easy programming!
.;
CALL $ODTIM
Here  is our library routine call. This will cause  the
$ODTIM routine to be executed and then after execution,
AMOS will  return  control  to  our program on the next
line below this CALL.
.;
PRTTAB 5,25.
TYPE <Current time is: >
CTC
These three lines  will first move the cursor to row 5,
column 25, type out  the  message contained between the
<...>,  and  then "set" control C (just  in  case  this
wasn't set before the user ran CLOCK).
.;
CLR  D3
MOV #H^00004801,D5
These two lines will set up $ODTIM to type out the time
to the users terminal in the following format:
.center hh:mm:ss AM/PM
The HEX value 4801 has the 32 bit  binary equivalent of
00000000000000000100100000000001. See  if you can place
the lower 16 bits of this number into the diagram above
to understand the flag settings!
.;
CTRLC  BYEBYE
PRTTAB 5,42.
CALL $ODTIM
SLEEP #5000.
The above  for  lines  are repeated over and over again
until the user hits a cC.  The  CTRLC line informs AMOS
to JMP to the label BYEBYE when a  user  hits a cC. The
PRTTAB  line  will place the cursor at the end  of  the
"Current  time  is: " line, then the $ODTIM  call  will
type out the time  of day for us. The SLEEP instruction
will cause the JOB to  sleep  for  1/2 second, at which
time the above four lines will be executed  again.  The
only way out of this infinate loop is via cC.
.;
CURON
CLEAR
EXIT
END
Finally,  CURON will cause the cursor to be turned back
on, CLEAR will  clear  the  screen, and EXIT will place
you  back at the dot. END informs  the  assembler  that
there is no more source code for this file.
_A Wrap_
  Not  bad!  This  assembly stuff is getting easier and
easier, isn't  it?  When  you  assemble  this  program,
remember that the assembler will only go through  Phase
2 (assuming no errors). Once Phase 2 is complete, enter
in _.LNKLIT CLOCK_. This will create CLOCK.LIT. Remember,
you  may order a compiled version of the first 10 AAA's
for only $10.00 via AMUS, so don't delay. Have fun with
CLOCK, and I'll see you next month or at AMUS '87.