max_stars_repo_path
stringlengths 4
261
| max_stars_repo_name
stringlengths 6
106
| max_stars_count
int64 0
38.8k
| id
stringlengths 1
6
| text
stringlengths 7
1.05M
|
---|---|---|---|---|
Task/Morse-code/Ada/morse-code-2.ada | LaudateCorpus1/RosettaCodeData | 1 | 29651 | with Ada.Strings.Maps, Ada.Characters.Handling, Interfaces.C;
use Ada, Ada.Strings, Ada.Strings.Maps, Interfaces;
package body Morse is
Dit, Dah, Lettergap, Wordgap : Duration; -- in seconds
Dit_ms, Dah_ms : C.unsigned; -- durations expressed in ms
Freq : constant C.unsigned := 1280; -- in Herz
Morse_Sequence : constant Character_Sequence :=
" ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
Morse_charset : constant Character_Set := To_Set (Morse_Sequence);
function Convert (Input : String) return Morse_Str is
Cap_String : constant String := Characters.Handling.To_Upper (Input);
Result : Morse_Str (1 .. 7 * Input'Length); -- Upper Capacity
First, Last : Natural := 0;
Char_code : Codings;
begin
for I in Cap_String'Range loop
if Is_In (Cap_String (I), Morse_charset) then
First := Last + 1;
if Cap_String (I) = ' ' then
Result (First) := ' ';
Last := Last + 1;
else
Char_code := Table (Reschars (Cap_String (I)));
Last := First + Char_code.L - 1;
Result (First .. Last) := Char_code.Code (1 .. Char_code.L);
Last := Last + 1;
Result (Last) := Nul;
end if;
end if;
end loop;
if Result (Last) /= ' ' then
Last := Last + 1;
Result (Last) := ' ';
end if;
return Result (1 .. Last);
end Convert;
procedure Morsebeep (Input : Morse_Str) is
-- Beep is not portable : adapt to your OS/sound board
-- Implementation for Windows XP / interface to fn in stdlib
procedure win32xp_beep
(dwFrequency : C.unsigned;
dwDuration : C.unsigned);
pragma Import (C, win32xp_beep, "_beep");
begin
for I in Input'Range loop
case Input (I) is
when Nul =>
delay Lettergap;
when Dot =>
win32xp_beep (Freq, Dit_ms);
delay Dit;
when Dash =>
win32xp_beep (Freq, Dah_ms);
delay Dit;
when ' ' =>
delay Wordgap;
end case;
end loop;
end Morsebeep;
begin
Dit := 0.20;
Lettergap := 2 * Dit;
Dah := 3 * Dit;
Wordgap := 4 * Dit;
Dit_ms := C.unsigned (Integer (Dit * 1000));
Dah_ms := C.unsigned (Integer (Dah * 1000));
end Morse;
|
Take Home Test/Kamal_Faheem_Code/Kamal_Faheem_2.72.asm | FaheemAKamal/CS342Projects | 0 | 87613 | .data
i: .word 100
k: .word 100
save: .word 0-100
.text
lw $s3, i
lw $s5, k
la $s6, save
Loop: sll $t1, $s3, 2
add $t1, $t1, $s6
lw $t0, 0($t1)
bne $t0, $s5, Exit
addi $s3, $s3, 1
j Loop
Exit:
|
programs/oeis/103/A103623.asm | karttu/loda | 0 | 162206 | ; A103623: n^9 + n^8 + n^7 + n^6 + n^5 + n^4 + n^3 + n^2 + n + 1.
; 1,10,1023,29524,349525,2441406,12093235,47079208,153391689,435848050,1111111111,2593742460,5628851293,11488207654,22250358075,41189313616,73300775185,125999618778,210027483919,340614792100,538947368421,833994048910,1264758228163
mov $2,$0
mov $3,10
lpb $3,1
mul $1,$2
add $1,8
sub $3,1
lpe
sub $1,8
div $1,8
add $1,1
|
bb-runtimes/runtimes/ravenscar-full-stm32g474/gnat/a-stwiun.adb | JCGobbi/Nucleo-STM32G474RE | 0 | 7534 | <gh_stars>0
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . S T R I N G S . W I D E _ U N B O U N D E D --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2021, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Ada.Strings.Wide_Fixed;
with Ada.Strings.Wide_Search;
with Ada.Unchecked_Deallocation;
package body Ada.Strings.Wide_Unbounded is
---------
-- "&" --
---------
function "&"
(Left : Unbounded_Wide_String;
Right : Unbounded_Wide_String) return Unbounded_Wide_String
is
L_Length : constant Natural := Left.Last;
R_Length : constant Natural := Right.Last;
Result : Unbounded_Wide_String;
begin
Result.Last := L_Length + R_Length;
Result.Reference := new Wide_String (1 .. Result.Last);
Result.Reference (1 .. L_Length) :=
Left.Reference (1 .. Left.Last);
Result.Reference (L_Length + 1 .. Result.Last) :=
Right.Reference (1 .. Right.Last);
return Result;
end "&";
function "&"
(Left : Unbounded_Wide_String;
Right : Wide_String) return Unbounded_Wide_String
is
L_Length : constant Natural := Left.Last;
Result : Unbounded_Wide_String;
begin
Result.Last := L_Length + Right'Length;
Result.Reference := new Wide_String (1 .. Result.Last);
Result.Reference (1 .. L_Length) := Left.Reference (1 .. Left.Last);
Result.Reference (L_Length + 1 .. Result.Last) := Right;
return Result;
end "&";
function "&"
(Left : Wide_String;
Right : Unbounded_Wide_String) return Unbounded_Wide_String
is
R_Length : constant Natural := Right.Last;
Result : Unbounded_Wide_String;
begin
Result.Last := Left'Length + R_Length;
Result.Reference := new Wide_String (1 .. Result.Last);
Result.Reference (1 .. Left'Length) := Left;
Result.Reference (Left'Length + 1 .. Result.Last) :=
Right.Reference (1 .. Right.Last);
return Result;
end "&";
function "&"
(Left : Unbounded_Wide_String;
Right : Wide_Character) return Unbounded_Wide_String
is
Result : Unbounded_Wide_String;
begin
Result.Last := Left.Last + 1;
Result.Reference := new Wide_String (1 .. Result.Last);
Result.Reference (1 .. Result.Last - 1) :=
Left.Reference (1 .. Left.Last);
Result.Reference (Result.Last) := Right;
return Result;
end "&";
function "&"
(Left : Wide_Character;
Right : Unbounded_Wide_String) return Unbounded_Wide_String
is
Result : Unbounded_Wide_String;
begin
Result.Last := Right.Last + 1;
Result.Reference := new Wide_String (1 .. Result.Last);
Result.Reference (1) := Left;
Result.Reference (2 .. Result.Last) :=
Right.Reference (1 .. Right.Last);
return Result;
end "&";
---------
-- "*" --
---------
function "*"
(Left : Natural;
Right : Wide_Character) return Unbounded_Wide_String
is
Result : Unbounded_Wide_String;
begin
Result.Last := Left;
Result.Reference := new Wide_String (1 .. Left);
for J in Result.Reference'Range loop
Result.Reference (J) := Right;
end loop;
return Result;
end "*";
function "*"
(Left : Natural;
Right : Wide_String) return Unbounded_Wide_String
is
Len : constant Natural := Right'Length;
K : Positive;
Result : Unbounded_Wide_String;
begin
Result.Last := Left * Len;
Result.Reference := new Wide_String (1 .. Result.Last);
K := 1;
for J in 1 .. Left loop
Result.Reference (K .. K + Len - 1) := Right;
K := K + Len;
end loop;
return Result;
end "*";
function "*"
(Left : Natural;
Right : Unbounded_Wide_String) return Unbounded_Wide_String
is
Len : constant Natural := Right.Last;
K : Positive;
Result : Unbounded_Wide_String;
begin
Result.Last := Left * Len;
Result.Reference := new Wide_String (1 .. Result.Last);
K := 1;
for J in 1 .. Left loop
Result.Reference (K .. K + Len - 1) :=
Right.Reference (1 .. Right.Last);
K := K + Len;
end loop;
return Result;
end "*";
---------
-- "<" --
---------
function "<"
(Left : Unbounded_Wide_String;
Right : Unbounded_Wide_String) return Boolean
is
begin
return
Left.Reference (1 .. Left.Last) < Right.Reference (1 .. Right.Last);
end "<";
function "<"
(Left : Unbounded_Wide_String;
Right : Wide_String) return Boolean
is
begin
return Left.Reference (1 .. Left.Last) < Right;
end "<";
function "<"
(Left : Wide_String;
Right : Unbounded_Wide_String) return Boolean
is
begin
return Left < Right.Reference (1 .. Right.Last);
end "<";
----------
-- "<=" --
----------
function "<="
(Left : Unbounded_Wide_String;
Right : Unbounded_Wide_String) return Boolean
is
begin
return
Left.Reference (1 .. Left.Last) <= Right.Reference (1 .. Right.Last);
end "<=";
function "<="
(Left : Unbounded_Wide_String;
Right : Wide_String) return Boolean
is
begin
return Left.Reference (1 .. Left.Last) <= Right;
end "<=";
function "<="
(Left : Wide_String;
Right : Unbounded_Wide_String) return Boolean
is
begin
return Left <= Right.Reference (1 .. Right.Last);
end "<=";
---------
-- "=" --
---------
function "="
(Left : Unbounded_Wide_String;
Right : Unbounded_Wide_String) return Boolean
is
begin
return
Left.Reference (1 .. Left.Last) = Right.Reference (1 .. Right.Last);
end "=";
function "="
(Left : Unbounded_Wide_String;
Right : Wide_String) return Boolean
is
begin
return Left.Reference (1 .. Left.Last) = Right;
end "=";
function "="
(Left : Wide_String;
Right : Unbounded_Wide_String) return Boolean
is
begin
return Left = Right.Reference (1 .. Right.Last);
end "=";
---------
-- ">" --
---------
function ">"
(Left : Unbounded_Wide_String;
Right : Unbounded_Wide_String) return Boolean
is
begin
return
Left.Reference (1 .. Left.Last) > Right.Reference (1 .. Right.Last);
end ">";
function ">"
(Left : Unbounded_Wide_String;
Right : Wide_String) return Boolean
is
begin
return Left.Reference (1 .. Left.Last) > Right;
end ">";
function ">"
(Left : Wide_String;
Right : Unbounded_Wide_String) return Boolean
is
begin
return Left > Right.Reference (1 .. Right.Last);
end ">";
----------
-- ">=" --
----------
function ">="
(Left : Unbounded_Wide_String;
Right : Unbounded_Wide_String) return Boolean
is
begin
return
Left.Reference (1 .. Left.Last) >= Right.Reference (1 .. Right.Last);
end ">=";
function ">="
(Left : Unbounded_Wide_String;
Right : Wide_String) return Boolean
is
begin
return Left.Reference (1 .. Left.Last) >= Right;
end ">=";
function ">="
(Left : Wide_String;
Right : Unbounded_Wide_String) return Boolean
is
begin
return Left >= Right.Reference (1 .. Right.Last);
end ">=";
------------
-- Adjust --
------------
procedure Adjust (Object : in out Unbounded_Wide_String) is
begin
-- Copy string, except we do not copy the statically allocated null
-- string, since it can never be deallocated. Note that we do not copy
-- extra string room here to avoid dragging unused allocated memory.
if Object.Reference /= Null_Wide_String'Access then
Object.Reference :=
new Wide_String'(Object.Reference (1 .. Object.Last));
end if;
end Adjust;
------------
-- Append --
------------
procedure Append
(Source : in out Unbounded_Wide_String;
New_Item : Unbounded_Wide_String)
is
begin
Realloc_For_Chunk (Source, New_Item.Last);
Source.Reference (Source.Last + 1 .. Source.Last + New_Item.Last) :=
New_Item.Reference (1 .. New_Item.Last);
Source.Last := Source.Last + New_Item.Last;
end Append;
procedure Append
(Source : in out Unbounded_Wide_String;
New_Item : Wide_String)
is
begin
Realloc_For_Chunk (Source, New_Item'Length);
Source.Reference (Source.Last + 1 .. Source.Last + New_Item'Length) :=
New_Item;
Source.Last := Source.Last + New_Item'Length;
end Append;
procedure Append
(Source : in out Unbounded_Wide_String;
New_Item : Wide_Character)
is
begin
Realloc_For_Chunk (Source, 1);
Source.Reference (Source.Last + 1) := New_Item;
Source.Last := Source.Last + 1;
end Append;
-----------
-- Count --
-----------
function Count
(Source : Unbounded_Wide_String;
Pattern : Wide_String;
Mapping : Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity)
return Natural
is
begin
return
Wide_Search.Count
(Source.Reference (1 .. Source.Last), Pattern, Mapping);
end Count;
function Count
(Source : Unbounded_Wide_String;
Pattern : Wide_String;
Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Natural
is
begin
return
Wide_Search.Count
(Source.Reference (1 .. Source.Last), Pattern, Mapping);
end Count;
function Count
(Source : Unbounded_Wide_String;
Set : Wide_Maps.Wide_Character_Set) return Natural
is
begin
return
Wide_Search.Count
(Source.Reference (1 .. Source.Last), Set);
end Count;
------------
-- Delete --
------------
function Delete
(Source : Unbounded_Wide_String;
From : Positive;
Through : Natural) return Unbounded_Wide_String
is
begin
return
To_Unbounded_Wide_String
(Wide_Fixed.Delete
(Source.Reference (1 .. Source.Last), From, Through));
end Delete;
procedure Delete
(Source : in out Unbounded_Wide_String;
From : Positive;
Through : Natural)
is
begin
if From > Through then
null;
elsif From < Source.Reference'First or else Through > Source.Last then
raise Index_Error;
else
declare
Len : constant Natural := Through - From + 1;
begin
Source.Reference (From .. Source.Last - Len) :=
Source.Reference (Through + 1 .. Source.Last);
Source.Last := Source.Last - Len;
end;
end if;
end Delete;
-------------
-- Element --
-------------
function Element
(Source : Unbounded_Wide_String;
Index : Positive) return Wide_Character
is
begin
if Index <= Source.Last then
return Source.Reference (Index);
else
raise Strings.Index_Error;
end if;
end Element;
--------------
-- Finalize --
--------------
procedure Finalize (Object : in out Unbounded_Wide_String) is
procedure Deallocate is
new Ada.Unchecked_Deallocation (Wide_String, Wide_String_Access);
begin
-- Note: Don't try to free statically allocated null string
if Object.Reference /= Null_Wide_String'Access then
Deallocate (Object.Reference);
Object.Reference := Null_Unbounded_Wide_String.Reference;
Object.Last := 0;
end if;
end Finalize;
----------------
-- Find_Token --
----------------
procedure Find_Token
(Source : Unbounded_Wide_String;
Set : Wide_Maps.Wide_Character_Set;
From : Positive;
Test : Strings.Membership;
First : out Positive;
Last : out Natural)
is
begin
Wide_Search.Find_Token
(Source.Reference (From .. Source.Last), Set, Test, First, Last);
end Find_Token;
procedure Find_Token
(Source : Unbounded_Wide_String;
Set : Wide_Maps.Wide_Character_Set;
Test : Strings.Membership;
First : out Positive;
Last : out Natural)
is
begin
Wide_Search.Find_Token
(Source.Reference (1 .. Source.Last), Set, Test, First, Last);
end Find_Token;
----------
-- Free --
----------
procedure Free (X : in out Wide_String_Access) is
procedure Deallocate is
new Ada.Unchecked_Deallocation (Wide_String, Wide_String_Access);
begin
-- Note: Do not try to free statically allocated null string
if X /= Null_Unbounded_Wide_String.Reference then
Deallocate (X);
end if;
end Free;
----------
-- Head --
----------
function Head
(Source : Unbounded_Wide_String;
Count : Natural;
Pad : Wide_Character := Wide_Space) return Unbounded_Wide_String
is
begin
return To_Unbounded_Wide_String
(Wide_Fixed.Head (Source.Reference (1 .. Source.Last), Count, Pad));
end Head;
procedure Head
(Source : in out Unbounded_Wide_String;
Count : Natural;
Pad : Wide_Character := Wide_Space)
is
Old : Wide_String_Access := Source.Reference;
begin
Source.Reference :=
new Wide_String'
(Wide_Fixed.Head (Source.Reference (1 .. Source.Last), Count, Pad));
Source.Last := Source.Reference'Length;
Free (Old);
end Head;
-----------
-- Index --
-----------
function Index
(Source : Unbounded_Wide_String;
Pattern : Wide_String;
Going : Strings.Direction := Strings.Forward;
Mapping : Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity)
return Natural
is
begin
return
Wide_Search.Index
(Source.Reference (1 .. Source.Last), Pattern, Going, Mapping);
end Index;
function Index
(Source : Unbounded_Wide_String;
Pattern : Wide_String;
Going : Direction := Forward;
Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Natural
is
begin
return
Wide_Search.Index
(Source.Reference (1 .. Source.Last), Pattern, Going, Mapping);
end Index;
function Index
(Source : Unbounded_Wide_String;
Set : Wide_Maps.Wide_Character_Set;
Test : Strings.Membership := Strings.Inside;
Going : Strings.Direction := Strings.Forward) return Natural
is
begin
return Wide_Search.Index
(Source.Reference (1 .. Source.Last), Set, Test, Going);
end Index;
function Index
(Source : Unbounded_Wide_String;
Pattern : Wide_String;
From : Positive;
Going : Direction := Forward;
Mapping : Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity)
return Natural
is
begin
return
Wide_Search.Index
(Source.Reference (1 .. Source.Last), Pattern, From, Going, Mapping);
end Index;
function Index
(Source : Unbounded_Wide_String;
Pattern : Wide_String;
From : Positive;
Going : Direction := Forward;
Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Natural
is
begin
return
Wide_Search.Index
(Source.Reference (1 .. Source.Last), Pattern, From, Going, Mapping);
end Index;
function Index
(Source : Unbounded_Wide_String;
Set : Wide_Maps.Wide_Character_Set;
From : Positive;
Test : Membership := Inside;
Going : Direction := Forward) return Natural
is
begin
return
Wide_Search.Index
(Source.Reference (1 .. Source.Last), Set, From, Test, Going);
end Index;
function Index_Non_Blank
(Source : Unbounded_Wide_String;
Going : Strings.Direction := Strings.Forward) return Natural
is
begin
return
Wide_Search.Index_Non_Blank
(Source.Reference (1 .. Source.Last), Going);
end Index_Non_Blank;
function Index_Non_Blank
(Source : Unbounded_Wide_String;
From : Positive;
Going : Direction := Forward) return Natural
is
begin
return
Wide_Search.Index_Non_Blank
(Source.Reference (1 .. Source.Last), From, Going);
end Index_Non_Blank;
----------------
-- Initialize --
----------------
procedure Initialize (Object : in out Unbounded_Wide_String) is
begin
Object.Reference := Null_Unbounded_Wide_String.Reference;
Object.Last := 0;
end Initialize;
------------
-- Insert --
------------
function Insert
(Source : Unbounded_Wide_String;
Before : Positive;
New_Item : Wide_String) return Unbounded_Wide_String
is
begin
return
To_Unbounded_Wide_String
(Wide_Fixed.Insert
(Source.Reference (1 .. Source.Last), Before, New_Item));
end Insert;
procedure Insert
(Source : in out Unbounded_Wide_String;
Before : Positive;
New_Item : Wide_String)
is
begin
if Before not in Source.Reference'First .. Source.Last + 1 then
raise Index_Error;
end if;
Realloc_For_Chunk (Source, New_Item'Length);
Source.Reference
(Before + New_Item'Length .. Source.Last + New_Item'Length) :=
Source.Reference (Before .. Source.Last);
Source.Reference (Before .. Before + New_Item'Length - 1) := New_Item;
Source.Last := Source.Last + New_Item'Length;
end Insert;
------------
-- Length --
------------
function Length (Source : Unbounded_Wide_String) return Natural is
begin
return Source.Last;
end Length;
---------------
-- Overwrite --
---------------
function Overwrite
(Source : Unbounded_Wide_String;
Position : Positive;
New_Item : Wide_String) return Unbounded_Wide_String
is
begin
return
To_Unbounded_Wide_String
(Wide_Fixed.Overwrite
(Source.Reference (1 .. Source.Last), Position, New_Item));
end Overwrite;
procedure Overwrite
(Source : in out Unbounded_Wide_String;
Position : Positive;
New_Item : Wide_String)
is
NL : constant Natural := New_Item'Length;
begin
if Position <= Source.Last - NL + 1 then
Source.Reference (Position .. Position + NL - 1) := New_Item;
else
declare
Old : Wide_String_Access := Source.Reference;
begin
Source.Reference := new Wide_String'
(Wide_Fixed.Overwrite
(Source.Reference (1 .. Source.Last), Position, New_Item));
Source.Last := Source.Reference'Length;
Free (Old);
end;
end if;
end Overwrite;
-----------------------
-- Realloc_For_Chunk --
-----------------------
procedure Realloc_For_Chunk
(Source : in out Unbounded_Wide_String;
Chunk_Size : Natural)
is
Growth_Factor : constant := 32;
-- The growth factor controls how much extra space is allocated when
-- we have to increase the size of an allocated unbounded string. By
-- allocating extra space, we avoid the need to reallocate on every
-- append, particularly important when a string is built up by repeated
-- append operations of small pieces. This is expressed as a factor so
-- 32 means add 1/32 of the length of the string as growth space.
Min_Mul_Alloc : constant := Standard'Maximum_Alignment;
-- Allocation will be done by a multiple of Min_Mul_Alloc This causes
-- no memory loss as most (all?) malloc implementations are obliged to
-- align the returned memory on the maximum alignment as malloc does not
-- know the target alignment.
S_Length : constant Natural := Source.Reference'Length;
begin
if Chunk_Size > S_Length - Source.Last then
declare
New_Size : constant Positive :=
S_Length + Chunk_Size + (S_Length / Growth_Factor);
New_Rounded_Up_Size : constant Positive :=
((New_Size - 1) / Min_Mul_Alloc + 1) * Min_Mul_Alloc;
Tmp : constant Wide_String_Access :=
new Wide_String (1 .. New_Rounded_Up_Size);
begin
Tmp (1 .. Source.Last) := Source.Reference (1 .. Source.Last);
Free (Source.Reference);
Source.Reference := Tmp;
end;
end if;
end Realloc_For_Chunk;
---------------------
-- Replace_Element --
---------------------
procedure Replace_Element
(Source : in out Unbounded_Wide_String;
Index : Positive;
By : Wide_Character)
is
begin
if Index <= Source.Last then
Source.Reference (Index) := By;
else
raise Strings.Index_Error;
end if;
end Replace_Element;
-------------------
-- Replace_Slice --
-------------------
function Replace_Slice
(Source : Unbounded_Wide_String;
Low : Positive;
High : Natural;
By : Wide_String) return Unbounded_Wide_String
is
begin
return To_Unbounded_Wide_String
(Wide_Fixed.Replace_Slice
(Source.Reference (1 .. Source.Last), Low, High, By));
end Replace_Slice;
procedure Replace_Slice
(Source : in out Unbounded_Wide_String;
Low : Positive;
High : Natural;
By : Wide_String)
is
Old : Wide_String_Access := Source.Reference;
begin
Source.Reference := new Wide_String'
(Wide_Fixed.Replace_Slice
(Source.Reference (1 .. Source.Last), Low, High, By));
Source.Last := Source.Reference'Length;
Free (Old);
end Replace_Slice;
-------------------------------
-- Set_Unbounded_Wide_String --
-------------------------------
procedure Set_Unbounded_Wide_String
(Target : out Unbounded_Wide_String;
Source : Wide_String)
is
begin
Target.Last := Source'Length;
Target.Reference := new Wide_String (1 .. Source'Length);
Target.Reference.all := Source;
end Set_Unbounded_Wide_String;
-----------
-- Slice --
-----------
function Slice
(Source : Unbounded_Wide_String;
Low : Positive;
High : Natural) return Wide_String
is
begin
-- Note: test of High > Length is in accordance with AI95-00128
if Low > Source.Last + 1 or else High > Source.Last then
raise Index_Error;
else
return Source.Reference (Low .. High);
end if;
end Slice;
----------
-- Tail --
----------
function Tail
(Source : Unbounded_Wide_String;
Count : Natural;
Pad : Wide_Character := Wide_Space) return Unbounded_Wide_String is
begin
return To_Unbounded_Wide_String
(Wide_Fixed.Tail (Source.Reference (1 .. Source.Last), Count, Pad));
end Tail;
procedure Tail
(Source : in out Unbounded_Wide_String;
Count : Natural;
Pad : Wide_Character := Wide_Space)
is
Old : Wide_String_Access := Source.Reference;
begin
Source.Reference := new Wide_String'
(Wide_Fixed.Tail (Source.Reference (1 .. Source.Last), Count, Pad));
Source.Last := Source.Reference'Length;
Free (Old);
end Tail;
------------------------------
-- To_Unbounded_Wide_String --
------------------------------
function To_Unbounded_Wide_String
(Source : Wide_String)
return Unbounded_Wide_String
is
Result : Unbounded_Wide_String;
begin
Result.Last := Source'Length;
Result.Reference := new Wide_String (1 .. Source'Length);
Result.Reference.all := Source;
return Result;
end To_Unbounded_Wide_String;
function To_Unbounded_Wide_String
(Length : Natural) return Unbounded_Wide_String
is
Result : Unbounded_Wide_String;
begin
Result.Last := Length;
Result.Reference := new Wide_String (1 .. Length);
return Result;
end To_Unbounded_Wide_String;
-------------------
-- To_Wide_String --
--------------------
function To_Wide_String
(Source : Unbounded_Wide_String)
return Wide_String
is
begin
return Source.Reference (1 .. Source.Last);
end To_Wide_String;
---------------
-- Translate --
---------------
function Translate
(Source : Unbounded_Wide_String;
Mapping : Wide_Maps.Wide_Character_Mapping)
return Unbounded_Wide_String
is
begin
return
To_Unbounded_Wide_String
(Wide_Fixed.Translate
(Source.Reference (1 .. Source.Last), Mapping));
end Translate;
procedure Translate
(Source : in out Unbounded_Wide_String;
Mapping : Wide_Maps.Wide_Character_Mapping)
is
begin
Wide_Fixed.Translate (Source.Reference (1 .. Source.Last), Mapping);
end Translate;
function Translate
(Source : Unbounded_Wide_String;
Mapping : Wide_Maps.Wide_Character_Mapping_Function)
return Unbounded_Wide_String
is
begin
return
To_Unbounded_Wide_String
(Wide_Fixed.Translate
(Source.Reference (1 .. Source.Last), Mapping));
end Translate;
procedure Translate
(Source : in out Unbounded_Wide_String;
Mapping : Wide_Maps.Wide_Character_Mapping_Function)
is
begin
Wide_Fixed.Translate (Source.Reference (1 .. Source.Last), Mapping);
end Translate;
----------
-- Trim --
----------
function Trim
(Source : Unbounded_Wide_String;
Side : Trim_End) return Unbounded_Wide_String
is
begin
return
To_Unbounded_Wide_String
(Wide_Fixed.Trim (Source.Reference (1 .. Source.Last), Side));
end Trim;
procedure Trim
(Source : in out Unbounded_Wide_String;
Side : Trim_End)
is
Old : Wide_String_Access := Source.Reference;
begin
Source.Reference :=
new Wide_String'
(Wide_Fixed.Trim (Source.Reference (1 .. Source.Last), Side));
Source.Last := Source.Reference'Length;
Free (Old);
end Trim;
function Trim
(Source : Unbounded_Wide_String;
Left : Wide_Maps.Wide_Character_Set;
Right : Wide_Maps.Wide_Character_Set)
return Unbounded_Wide_String
is
begin
return
To_Unbounded_Wide_String
(Wide_Fixed.Trim
(Source.Reference (1 .. Source.Last), Left, Right));
end Trim;
procedure Trim
(Source : in out Unbounded_Wide_String;
Left : Wide_Maps.Wide_Character_Set;
Right : Wide_Maps.Wide_Character_Set)
is
Old : Wide_String_Access := Source.Reference;
begin
Source.Reference :=
new Wide_String'
(Wide_Fixed.Trim
(Source.Reference (1 .. Source.Last), Left, Right));
Source.Last := Source.Reference'Length;
Free (Old);
end Trim;
---------------------
-- Unbounded_Slice --
---------------------
function Unbounded_Slice
(Source : Unbounded_Wide_String;
Low : Positive;
High : Natural) return Unbounded_Wide_String
is
begin
if Low > Source.Last + 1 or else High > Source.Last then
raise Index_Error;
else
return To_Unbounded_Wide_String (Source.Reference.all (Low .. High));
end if;
end Unbounded_Slice;
procedure Unbounded_Slice
(Source : Unbounded_Wide_String;
Target : out Unbounded_Wide_String;
Low : Positive;
High : Natural)
is
begin
if Low > Source.Last + 1 or else High > Source.Last then
raise Index_Error;
else
Target :=
To_Unbounded_Wide_String (Source.Reference.all (Low .. High));
end if;
end Unbounded_Slice;
end Ada.Strings.Wide_Unbounded;
|
programs/oeis/039/A039825.asm | neoneye/loda | 22 | 179006 | <filename>programs/oeis/039/A039825.asm
; A039825: a(n) = floor((n^2 + n + 8) / 4).
; 2,3,5,7,9,12,16,20,24,29,35,41,47,54,62,70,78,87,97,107,117,128,140,152,164,177,191,205,219,234,250,266,282,299,317,335,353,372,392,412,432,453,475,497,519,542,566,590,614,639
add $0,2
bin $0,2
div $0,2
add $0,2
|
data/inc/page_00_inc.asm | alttpo/go65c816 | 6 | 170068 | <reponame>alttpo/go65c816
; page_00.asm
; Direct Page Addresses
;
;* Addresses are the byte AFTER the block. Use this to confirm block locations and check for overlaps
BANK0_BEGIN = $000000 ;Start of bank 0 and Direct page
TMPPTR1 = $000000 ; 4 byte temporary pointer
TMPPTR2 = $000004 ; 4 byte temporary pointer
OPL2_ADDY_PTR_LO = $000008 ; THis Points towards the Instruments Database
OPL2_ADDY_PTR_MD = $000009
OPL2_ADDY_PTR_HI = $00000A
SCREENBEGIN = $00000C ;3 Bytes Start of screen in video RAM. This is the upper-left corrner of the current video page being written to. This may not be what's being displayed by VICKY. Update this if you change VICKY's display page.
COLS_VISIBLE = $00000F ;2 Bytes Columns visible per screen line. A virtual line can be longer than displayed, up to COLS_PER_LINE long. Default = 80
COLS_PER_LINE = $000011 ;2 Bytes Columns in memory per screen line. A virtual line can be this long. Default=128
LINES_VISIBLE = $000013 ;2 Bytes The number of rows visible on the screen. Default=25
LINES_MAX = $000015 ;2 Bytes The number of rows in memory for the screen. Default=64
CURSORPOS = $000017 ;3 Bytes The next character written to the screen will be written in this location.
CURSORX = $00001A ;2 Bytes This is where the blinking cursor sits. Do not edit this direectly. Call LOCATE to update the location and handle moving the cursor correctly.
CURSORY = $00001C ;2 Bytes This is where the blinking cursor sits. Do not edit this direectly. Call LOCATE to update the location and handle moving the cursor correctly.
CURCOLOR = $00001E ;1 Byte Color of next character to be printed to the screen.
COLORPOS = $00001F ;3 Byte address of cursor's position in the color matrix
STACKBOT = $000022 ;2 Bytes Lowest location the stack should be allowed to write to. If SP falls below this value, the runtime should generate STACK OVERFLOW error and abort.
STACKTOP = $000024 ;2 Bytes Highest location the stack can occupy. If SP goes above this value, the runtime should generate STACK OVERFLOW error and abort.
; OPL2 Library Variable (Can be shared if Library is not used)
; THis will need to move eventually
OPL2_OPERATOR = $000026 ;
OPL2_CHANNEL = $000027 ;
OPL2_REG_REGION = $000028 ; Offset to the Group of Registers
OPL2_REG_OFFSET = $00002A ; 2 Bytes (16Bits)
OPL2_IND_ADDY_LL = $00002C ; 2 Bytes Reserved (Only need 3)
OPL2_IND_ADDY_HL = $00002E ; 2 Bytes Reserved (Only need 3)
OPL2_NOTE = $000030 ; 1 Byte
OPL2_OCTAVE = $000031 ; 1 Byte
OPL2_PARAMETER0 = $000032 ; 1 Byte - Key On/Feedback
OPL2_PARAMETER1 = $000033 ; 1 Byte
OPL2_PARAMETER2 = $000034 ; 1 Byte
OPL2_PARAMETER3 = $000035 ; 1 Byte
OPL2_LOOP = $000036 ;
OPL2_BLOCK = $000036
; SD Card (CH376S) Variables
SDCARD_FILE_PTR = $000038 ; 3 Bytes Pointer to Filename to open
SDCARD_BYTE_NUM = $00003C ; 2Bytes
SDCARD_PRSNT_MNT = $00003F ; 1 Byte, Indicate that the SDCard is Present and that it is Mounted
; Command Line Parser Variables
; CMD_PARSER_TMPX = $000040 ; <<< Command Parser 2Bytes
; CMD_PARSER_TMPY = $000042 ; <<< Command Parser 2Bytes
; CMD_LIST_PTR = $000044 ; <<< Command Parser 3 Bytes
; CMD_PARSER_PTR = $000048 ; <<< Command Parser 3 Bytes
; CMD_ATTRIBUTE = $00004B ; <<< Command Parser 2 Bytes (16bits Attribute Field)
; CMD_EXEC_ADDY = $00004D ; <<< Command Parser 3 Bytes 24 Bits Address Jump to execute the Command
; CMD_VARIABLE_TMP = $000050 ;
; CMD_ARG_DEV = $000052 ;
; CMD_ARG_SA = $000053 ;
; CMD_ARG_EA = $000056 ;
; CMD_VALID = $00005A ;
; Bitmap Clear Routine
BM_CLEAR_SCRN_X = $000040
BM_CLEAR_SCRN_Y = $000042
; RAD File Player
RAD_STARTLINE = $000040 ; 1 Byte
RAD_PATTERN_IDX = $000041 ; 1 Byte
RAD_LINE = $000042 ; 1 Byte
RAD_LINENUMBER = $000043 ; 1 Byte
RAD_CHANNEL_NUM = $000044 ; 1 Byte
RAD_ISLASTCHAN = $000045 ; 1 Byte
RAD_Y_POINTER = $000046 ; 2 Bytes
RAD_TICK = $000048
RAD_CHANNEL_DATA = $00004A ; 2 Bytes
RAD_CHANNE_EFFCT = $00004C
RAD_TEMP = $00004D
RAD_ADDR = $000050 ; 3 bytes to avoid OPL2 errors.
RAD_PATTRN = $000053 ; 1 bytes - offset to patter
RAD_PTN_DEST = $000054 ; 3 bytes - where to write the pattern data
RAD_CHANNEL = $000057 ; 2 bytes - 0 to 8
RAD_LAST_NOTE = $000059 ; 1 if this is the last note
RAD_LINE_PTR = $00005A ; 2 bytes - offset to memory location
; BMP File Parser Variables (Can be shared if BMP Parser not used)
; Used for Command Parser Mainly
BMP_X_SIZE = $000040 ; 2 Bytes
BMP_Y_SIZE = $000042 ; 2 Bytes
BMP_PRSE_SRC_PTR = $000044 ; 3 Bytes
BMP_PRSE_DST_PTR = $000048 ; 3 Bytes
BMP_COLOR_PALET = $00004C ; 2 Bytes
SCRN_X_STRIDE = $00004E ; 2 Bytes, Basically How many Pixel Accross in Bitmap Mode
BMP_FILE_SIZE = $000050 ; 4 Bytes
BMP_POSITION_X = $000054 ; 2 Bytes Where, the BMP will be position on the X Axis
BMP_POSITION_Y = $000056 ; 2 Bytes Where, the BMP will be position on the Y Axis
BMP_PALET_CHOICE = $000058 ;
;Empty Region
;XXX = $000060
;..
;..
;..
;YYY = $0000EE
MOUSE_PTR = $0000E0
MOUSE_POS_X_LO = $0000E1
MOUSE_POS_X_HI = $0000E2
MOUSE_POS_Y_LO = $0000E3
MOUSE_POS_Y_HI = $0000E4
USER_TEMP = $0000F0 ;32 Bytes Temp space for user programs
;;///////////////////////////////////////////////////////////////
;;; NO CODE or Variable ought to be Instantiated in this REGION
;; BEGIN
;;///////////////////////////////////////////////////////////////
GAVIN_BLOCK = $000100 ;256 Bytes Gavin reserved, overlaps debugging registers at $1F0
; Reserved
INT_CONTROLLER = $000140 ; $000140...$00015F Interrupt Controller
TIMER_CONTROLLER = $000160 ; $000160...$00017F Timer0/Timer1/Timer2 Block
TIMER_CTRL_REGLL = $000160 ;
TIMER_CTRL_REGLH = $000161 ;
TIMER_CTRL_REGHL = $000162 ;
TIMER_CTRL_REGHH = $000163 ;
;;///////////////////////////////////////////////////////////////
;;; NO CODE or Variable ought to be Instatied in this REGION
;; END
;;///////////////////////////////////////////////////////////////
CPU_REGISTERS = $000240 ; Byte
CPUPC = $000240 ;2 Bytes Program Counter (PC)
CPUPBR = $000242 ;2 Bytes Program Bank Register (K)
CPUA = $000244 ;2 Bytes Accumulator (A)
CPUX = $000246 ;2 Bytes X Register (X)
CPUY = $000248 ;2 Bytes Y Register (Y)
CPUSTACK = $00024A ;2 Bytes Stack Pointer (S)
CPUDP = $00024C ;2 Bytes Direct Page Register (D)
CPUDBR = $00024E ;1 Byte Data Bank Register (B)
CPUFLAGS = $00024F ;1 Byte Flags (P)
MONITOR_VARS = $000250 ; Byte MONITOR Variables. BASIC variables may overlap this space
MCMDADDR = $000250 ;3 Bytes Address of the current line of text being processed by the command parser. Can be in display memory or a variable in memory. MONITOR will parse up to MTEXTLEN characters or to a null character.
MCMP_TEXT = $000253 ;3 Bytes Address of symbol being evaluated for COMPARE routine
MCMP_LEN = $000256 ;2 Bytes Length of symbol being evaluated for COMPARE routine
MCMD = $000258 ;3 Bytes Address of the current command/function string
MCMD_LEN = $00025B ;2 Bytes Length of the current command/function string
MARG1 = $00025D ;4 Bytes First command argument. May be data or address, depending on command
MARG2 = $000261 ;4 Bytes First command argument. May be data or address, depending on command. Data is 32-bit number. Address is 24-bit address and 8-bit length.
MARG3 = $000265 ;4 Bytes First command argument. May be data or address, depending on command. Data is 32-bit number. Address is 24-bit address and 8-bit length.
MARG4 = $000269 ;4 Bytes First command argument. May be data or address, depending on command. Data is 32-bit number. Address is 24-bit address and 8-bit length.
MARG5 = $00026D ;4 Bytes First command argument. May be data or address, depending on command. Data is 32-bit number. Address is 24-bit address and 8-bit length.
MARG6 = $000271 ;4 Bytes First command argument. May be data or address, depending on command. Data is 32-bit number. Address is 24-bit address and 8-bit length.
MARG7 = $000275 ;4 Bytes First command argument. May be data or address, depending on command. Data is 32-bit number. Address is 24-bit address and 8-bit length.
MARG8 = $000279 ;4 Bytes First command argument. May be data or address, depending on command. Data is 32-bit number. Address is 24-bit address and 8-bit length.
LOADFILE_VARS = $000300 ; Byte
LOADFILE_NAME = $000300 ;3 Bytes (addr) Name of file to load. Address in Data Page
LOADFILE_LEN = $000303 ;1 Byte Length of filename. 0=Null Terminated
LOADPBR = $000304 ;1 Byte First Program Bank of loaded file ($05 segment)
LOADPC = $000305 ;2 Bytes Start address of loaded file ($05 segment)
LOADDBR = $000307 ;1 Byte First data bank of loaded file ($06 segment)
LOADADDR = $000308 ;2 Bytes FIrst data address of loaded file ($06 segment)
LOADFILE_TYPE = $00030A ;3 Bytes (addr) File type string in loaded data file. Actual string data will be in Bank 1. Valid values are BIN, PRG, P16
BLOCK_LEN = $00030D ;2 Bytes Length of block being loaded
BLOCK_ADDR = $00030F ;2 Bytes (temp) Address of block being loaded
BLOCK_BANK = $000311 ;1 Byte (temp) Bank of block being loaded
BLOCK_COUNT = $000312 ;2 Bytes (temp) Counter of bytes read as file is loaded
; Floppy drive code variables
FDC_DRIVE = $000300 ;1 byte - The number of the selected drive
FDC_HEAD = $000301 ;1 byte - The head number (0 or 1)
FDC_CYLINDER = $000302 ;1 byte - The cylinder number
FDC_SECTOR = $000303 ;1 byte - The sector number
FDC_SECTOR_SIZE = $000304 ;1 byte - The sector size code (2 = 512)
FDC_SECPERTRK = $000305 ;1 byte - The number of sectors per track (18 for 1.44 MB floppy)
FDC_ST0 = $000306 ;1 byte - Status Register 0
FDC_ST1 = $000307 ;1 byte - Status Register 1
FDC_ST2 = $000308 ;1 byte - Status Register 2
FDC_ST3 = $000309 ;1 byte - Status Register 3
FDC_PCN = $00030A ;1 byte - Present Cylinder Number
FDC_STATUS = $00030B ;1 byte - Status of what we think is going on with the FDC:
; $80 = motor is on
DIVIDEND = $00030C ;4 bytes - Dividend for 32-bit division
DIVISOR = $000310 ;4 bytes - Divisor for 32-bit division
REMAINDER = $000314 ;4 bytes - Remainder for 32-bit division
; $00:0320 to $00:06FF - Reserved for block device access and FAT file system support
; Low-level (BIOS) sector access variables
SDOS_VARIABLES = $000320
BIOS_STATUS = $000320 ; 1 byte - Status of any BIOS operation
BIOS_DEV = $000321 ; 1 byte - Block device number for block operations
BIOS_LBA = $000322 ; 4 bytes - Address of block to read/write (this is the physical block, w/o reference to partition)
BIOS_BUFF_PTR = $000326 ; 4 bytes - 24-bit pointer to memory for read/write operations
BIOS_FIFO_COUNT = $00032A ; 2 bytes - The number of bytes read on the last block read
BIOS_FLAGS = $00032C ; 1 byte - Flags for various BIOSy things:
; $80 = time out flag: if set, a timeout has occurred (see ISETTIMEOUT)
BIOS_TIMER = $00032D ; 1 byte - the number of 1/60 ticks for a time out
; FAT (cluster level) access
DOS_STATUS = $00032E ; 1 byte - The error code describing any error with file access
DOS_CLUS_ID = $000330 ; 4 bytes - The cluster desired for a DOS operation
DOS_DIR_PTR = $000338 ; 4 bytes - Pointer to a directory entry (assumed to be within DOS_SECTOR)
DOS_BUFF_PTR = $00033C ; 4 bytes - A pointer for DOS cluster read/write operations
DOS_FD_PTR = $000340 ; 4 bytes - A pointer to a file descriptor
DOS_FAT_LBA = $000344 ; 4 bytes - The LBA for a sector of the FAT we need to read/write
DOS_TEMP = $000348 ; 4 bytes - Temporary storage for DOS operations
DOS_FILE_SIZE = $00034C ; 4 bytes - The size of a file
DOS_SRC_PTR = $000350 ; 4 bytes - Pointer for transferring data
DOS_DST_PTR = $000354 ; 4 bytes - Pointer for transferring data
DOS_END_PTR = $000358 ; 4 bytes - Pointer to the last byte to save
DOS_RUN_PTR = $00035C ; 4 bytes - Pointer for starting a loaded program
DOS_RUN_PARAM = $000360 ; 4 bytes - Pointer to the ASCIIZ string for arguments in loading a program
DOS_STR1_PTR = $000364 ; 4 bytes - pointer to a string
DOS_STR2_PTR = $000368 ; 4 bytes - pointer to a string
DOS_SCRATCH = $00036B ; 4 bytes - general purpose short term storage
DOS_PATH_BUFF = $000400 ; 256 bytes - A buffer for path names
FDC_PARAMETERS = $000500 ; 16 bytes - a buffer of parameter data for the FDC
FDC_RESULTS = $000510 ; 16 bytes - Buffer for results of FDC commands
FDC_PARAM_NUM = $000530 ; 1 byte - The number of parameters to send to the FDC (including command)
FDC_RESULT_NUM = $000532 ; 1 byte - The number of results expected
FDC_EXPECT_DAT = $000533 ; 1 byte - 0 = the command expects no data, otherwise expects data
FDC_CMD_RETRY = $000534 ; 1 byte - a retry counter for commands
;
; Channel, UART variables, and Timer
;
CURRUART = $000700 ; 3-bytes: the base address of the current UART
CHAN_OUT = $000703 ; 1-byte: the number of the current output channel (for PUTC, etc.)
CHAN_IN = $000704 ; 1-byte: the number of the current input channel (for GETCH, etc.)
TIMERFLAGS = $000705 ; 1-byte: flags to indicate that one of the timer interupts has triggered
TIMER0TRIGGER = $80
TIMER1TRIGGER = $40
TIMER2TRIGGER = $20
; COMMAND PARSER Variables
; Command Parser Stuff between $000F00 -> $000F84 (see CMD_Parser.asm)
KEY_BUFFER = $000F00 ; 64 Bytes keyboard buffer
KEY_BUFFER_SIZE = $0080 ;128 Bytes (constant) keyboard buffer length
KEY_BUFFER_END = $000F7F ; 1 Byte Last byte of keyboard buffer
KEY_BUFFER_CMD = $000F83 ; 1 Byte Indicates the Command Process Status
COMMAND_SIZE_STR = $000F84 ; 1 Byte
COMMAND_COMP_TMP = $000F86 ; 2 Bytes
KEYBOARD_SC_FLG = $000F87 ; 1 Bytes that indicate the Status of Left Shift, Left CTRL, Left ALT, Right Shift
KEYBOARD_SC_TMP = $000F88 ; 1 Byte, Interrupt Save Scan Code while Processing
KEYBOARD_LOCKS = $000F89 ; 1 Byte, the status of the various lock keys
KEYFLAG = $000F8A ; 1 Byte, flag to indicate if CTRL-C has been pressed
KEY_BUFFER_RPOS = $000F8B ; 2 Byte, position of the character to read from the KEY_BUFFER
KEY_BUFFER_WPOS = $000F8D ; 2 Byte, position of the character to write to the KEY_BUFFER
KERNEL_JMP_BEGIN = $001000 ; Reserved for the Kernel jump table
KERNEL_JMP_END = $001FFF
TEST_BEGIN = $002000 ;28672 Bytes Test/diagnostic code for prototype.
TEST_END = $007FFF ;0 Byte
STACK_BEGIN = $008000 ;32512 Bytes The default beginning of stack space
STACK_END = $00FEFF ;0 Byte End of stack space. Everything below this is I/O space
.if TARGET = TARGET_RAM
ISR_BEGIN = $00FF00 ; Byte Beginning of CPU vectors in Direct page
HRESET = $00FF00 ;16 Bytes Handle RESET asserted. Reboot computer and re-initialize the kernel.
HCOP = $00FF10 ;16 Bytes Handle the COP instruction. Program use; not used by OS
HBRK = $00FF20 ;16 Bytes Handle the BRK instruction. Returns to BASIC Ready prompt.
HABORT = $00FF30 ;16 Bytes Handle ABORT asserted. Return to Ready prompt with an error message.
HNMI = $00FF40 ;32 Bytes Handle NMI
HIRQ = $00FF60 ;32 Bytes Handle IRQ
Unused_FF80 = $00FF80 ;End of direct page Interrrupt handlers
VECTORS_BEGIN = $00FFE0 ;0 Byte Interrupt vectors
JMP_READY = $00FFE0 ;4 Bytes Jumps to ROM READY routine. Modified whenever alternate command interpreter is loaded.
VECTOR_COP = $00FFE4 ;2 Bytes Native COP Interrupt vector
VECTOR_BRK = $00FFE6 ;2 Bytes Native BRK Interrupt vector
VECTOR_ABORT = $00FFE8 ;2 Bytes Native ABORT Interrupt vector
VECTOR_NMI = $00FFEA ;2 Bytes Native NMI Interrupt vector
VECTOR_RESET = $00FFEC ;2 Bytes Unused (Native RESET vector)
VECTOR_IRQ = $00FFEE ;2 Bytes Native IRQ Vector
RETURN = $00FFF0 ;4 Bytes RETURN key handler. Points to BASIC or MONITOR subroutine to execute when RETURN is pressed.
VECTOR_ECOP = $00FFF4 ;2 Bytes Emulation mode interrupt handler
VECTOR_EBRK = $00FFF6 ;2 Bytes Emulation mode interrupt handler
VECTOR_EABORT = $00FFF8 ;2 Bytes Emulation mode interrupt handler
VECTOR_ENMI = $00FFFA ;2 Bytes Emulation mode interrupt handler
VECTOR_ERESET = $00FFFC ;2 Bytes Emulation mode interrupt handler
VECTOR_EIRQ = $00FFFE ;2 Bytes Emulation mode interrupt handler
VECTORS_END = $010000 ;*End of vector space
.elsif TARGET = TARGET_FLASH
.if TARGET_SYS = SYS_C256_FMX
ISR_BEGIN = $38FF00 ; Byte Beginning of CPU vectors in Direct page
HRESET = $38FF00 ;16 Bytes Handle RESET asserted. Reboot computer and re-initialize the kernel.
HCOP = $38FF10 ;16 Bytes Handle the COP instruction. Program use; not used by OS
HBRK = $38FF20 ;16 Bytes Handle the BRK instruction. Returns to BASIC Ready prompt.
HABORT = $38FF30 ;16 Bytes Handle ABORT asserted. Return to Ready prompt with an error message.
HNMI = $38FF40 ;32 Bytes Handle NMI
HIRQ = $38FF60 ;32 Bytes Handle IRQ
Unused_FF80 = $38FF80 ;End of direct page Interrrupt handlers
VECTORS_BEGIN = $38FFE0 ;0 Byte Interrupt vectors
JMP_READY = $38FFE0 ;4 Bytes Jumps to ROM READY routine. Modified whenever alternate command interpreter is loaded.
VECTOR_COP = $38FFE4 ;2 Bytes Native COP Interrupt vector
VECTOR_BRK = $38FFE6 ;2 Bytes Native BRK Interrupt vector
VECTOR_ABORT = $38FFE8 ;2 Bytes Native ABORT Interrupt vector
VECTOR_NMI = $38FFEA ;2 Bytes Native NMI Interrupt vector
VECTOR_RESET = $38FFEC ;2 Bytes Unused (Native RESET vector)
VECTOR_IRQ = $38FFEE ;2 Bytes Native IRQ Vector
RETURN = $38FFF0 ;4 Bytes RETURN key handler. Points to BASIC or MONITOR subroutine to execute when RETURN is pressed.
VECTOR_ECOP = $38FFF4 ;2 Bytes Emulation mode interrupt handler
VECTOR_EBRK = $38FFF6 ;2 Bytes Emulation mode interrupt handler
VECTOR_EABORT = $38FFF8 ;2 Bytes Emulation mode interrupt handler
VECTOR_ENMI = $38FFFA ;2 Bytes Emulation mode interrupt handler
VECTOR_ERESET = $38FFFC ;2 Bytes Emulation mode interrupt handler
VECTOR_EIRQ = $38FFFE ;2 Bytes Emulation mode interrupt handler
VECTORS_END = $400000 ;*End of vector space
.else
ISR_BEGIN = $18FF00 ; Byte Beginning of CPU vectors in Direct page
HRESET = $18FF00 ;16 Bytes Handle RESET asserted. Reboot computer and re-initialize the kernel.
HCOP = $18FF10 ;16 Bytes Handle the COP instruction. Program use; not used by OS
HBRK = $18FF20 ;16 Bytes Handle the BRK instruction. Returns to BASIC Ready prompt.
HABORT = $18FF30 ;16 Bytes Handle ABORT asserted. Return to Ready prompt with an error message.
HNMI = $18FF40 ;32 Bytes Handle NMI
HIRQ = $18FF60 ;32 Bytes Handle IRQ
Unused_FF80 = $18FF80 ;End of direct page Interrrupt handlers
VECTORS_BEGIN = $18FFE0 ;0 Byte Interrupt vectors
JMP_READY = $18FFE0 ;4 Bytes Jumps to ROM READY routine. Modified whenever alternate command interpreter is loaded.
VECTOR_COP = $18FFE4 ;2 Bytes Native COP Interrupt vector
VECTOR_BRK = $18FFE6 ;2 Bytes Native BRK Interrupt vector
VECTOR_ABORT = $18FFE8 ;2 Bytes Native ABORT Interrupt vector
VECTOR_NMI = $18FFEA ;2 Bytes Native NMI Interrupt vector
VECTOR_RESET = $18FFEC ;2 Bytes Unused (Native RESET vector)
VECTOR_IRQ = $18FFEE ;2 Bytes Native IRQ Vector
RETURN = $18FFF0 ;4 Bytes RETURN key handler. Points to BASIC or MONITOR subroutine to execute when RETURN is pressed.
VECTOR_ECOP = $18FFF4 ;2 Bytes Emulation mode interrupt handler
VECTOR_EBRK = $18FFF6 ;2 Bytes Emulation mode interrupt handler
VECTOR_EABORT = $18FFF8 ;2 Bytes Emulation mode interrupt handler
VECTOR_ENMI = $18FFFA ;2 Bytes Emulation mode interrupt handler
VECTOR_ERESET = $18FFFC ;2 Bytes Emulation mode interrupt handler
VECTOR_EIRQ = $18FFFE ;2 Bytes Emulation mode interrupt handler
VECTORS_END = $200000 ;*End of vector space
.endif
.endif
BANK0_END = $00FFFF ;End of Bank 00 and Direct page
;
|
Transynther/x86/_processed/AVXALIGN/_st_/i9-9900K_12_0xca_notsx.log_21829_1435.asm | ljhsiun2/medusa | 9 | 14140 | <gh_stars>1-10
.global s_prepare_buffers
s_prepare_buffers:
push %r15
push %r8
push %r9
push %rax
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_normal_ht+0x17e36, %rsi
lea addresses_D_ht+0x84ae, %rdi
nop
nop
nop
nop
nop
add $20287, %r15
mov $88, %rcx
rep movsw
nop
nop
dec %rax
lea addresses_A_ht+0x8b3e, %rax
nop
nop
nop
nop
nop
dec %r8
movb (%rax), %cl
nop
nop
nop
nop
nop
xor %rsi, %rsi
lea addresses_WT_ht+0x296, %rcx
nop
cmp $1397, %r8
movups (%rcx), %xmm2
vpextrq $0, %xmm2, %r15
nop
nop
nop
dec %r8
lea addresses_A_ht+0x696, %rcx
nop
add $3943, %rdi
mov (%rcx), %rsi
nop
nop
nop
nop
cmp %rsi, %rsi
lea addresses_normal_ht+0x12c96, %rsi
nop
nop
xor $11292, %rbp
movw $0x6162, (%rsi)
cmp %rsi, %rsi
lea addresses_UC_ht+0x15e96, %rsi
lea addresses_UC_ht+0x118ee, %rdi
nop
nop
nop
nop
nop
xor $2830, %r8
mov $88, %rcx
rep movsw
inc %rdi
lea addresses_A_ht+0x3116, %rax
nop
nop
nop
nop
nop
dec %rsi
movl $0x61626364, (%rax)
nop
xor $16151, %rax
lea addresses_D_ht+0x1a696, %rcx
nop
inc %rsi
movups (%rcx), %xmm0
vpextrq $1, %xmm0, %r8
nop
nop
and %r8, %r8
lea addresses_WT_ht+0x27fd, %rbp
nop
nop
nop
nop
nop
add %rcx, %rcx
mov (%rbp), %r15d
nop
dec %rdi
lea addresses_A_ht+0x13296, %rsi
lea addresses_D_ht+0xce96, %rdi
nop
nop
nop
nop
nop
and $110, %r9
mov $69, %rcx
rep movsw
sub $9115, %rbp
lea addresses_UC_ht+0xea56, %rsi
nop
nop
nop
nop
nop
dec %rdi
movw $0x6162, (%rsi)
nop
nop
and $63750, %rdi
lea addresses_WT_ht+0x8296, %rsi
nop
nop
nop
add %rax, %rax
mov (%rsi), %r9w
nop
nop
nop
nop
nop
and %rcx, %rcx
lea addresses_A_ht+0x8cd6, %rsi
lea addresses_WC_ht+0xde96, %rdi
nop
nop
nop
nop
sub %r15, %r15
mov $29, %rcx
rep movsl
nop
cmp $15715, %r8
lea addresses_normal_ht+0x183e6, %rsi
lea addresses_A_ht+0x1ae96, %rdi
nop
nop
nop
nop
nop
and $64720, %rax
mov $83, %rcx
rep movsw
nop
nop
nop
nop
dec %r8
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %rax
pop %r9
pop %r8
pop %r15
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r13
push %r14
push %r9
push %rbp
push %rsi
// Store
lea addresses_A+0xa296, %rbp
nop
add $52792, %r12
mov $0x5152535455565758, %r13
movq %r13, %xmm4
movups %xmm4, (%rbp)
nop
nop
nop
nop
nop
xor $57249, %rsi
// Faulty Load
lea addresses_RW+0x8e96, %rsi
nop
nop
nop
dec %r12
mov (%rsi), %bp
lea oracles, %r14
and $0xff, %rbp
shlq $12, %rbp
mov (%r14,%rbp,1), %rbp
pop %rsi
pop %rbp
pop %r9
pop %r14
pop %r13
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_RW', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_A', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 10}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_RW', 'NT': False, 'AVXalign': True, 'size': 2, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'same': False, 'congruent': 3, 'type': 'addresses_normal_ht'}, 'dst': {'same': True, 'congruent': 1, 'type': 'addresses_D_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 3}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 8}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 8}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 7}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 10, 'type': 'addresses_UC_ht'}, 'dst': {'same': False, 'congruent': 3, 'type': 'addresses_UC_ht'}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 5}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 8}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 10, 'type': 'addresses_A_ht'}, 'dst': {'same': False, 'congruent': 5, 'type': 'addresses_D_ht'}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': True, 'size': 2, 'congruent': 6}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': True, 'size': 2, 'congruent': 9}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 4, 'type': 'addresses_A_ht'}, 'dst': {'same': False, 'congruent': 10, 'type': 'addresses_WC_ht'}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 3, 'type': 'addresses_normal_ht'}, 'dst': {'same': False, 'congruent': 11, 'type': 'addresses_A_ht'}}
{'32': 21829}
32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
*/
|
agda-stdlib/src/Text/Tabular/Vec.agda | DreamLinuxer/popl21-artifact | 5 | 14882 | ------------------------------------------------------------------------
-- The Agda standard library
--
-- Fancy display functions for Vec-based tables
------------------------------------------------------------------------
{-# OPTIONS --safe --without-K #-}
module Text.Tabular.Vec where
open import Data.List.Base using (List)
open import Data.Product as Prod using (uncurry)
open import Data.String.Base using (String; rectangle; fromAlignment)
open import Data.Vec.Base
open import Function.Base
open import Text.Tabular.Base
display : ∀ {m n} → TabularConfig → Vec Alignment n → Vec (Vec String n) m →
List String
display c a = unsafeDisplay c
∘ toList
∘ map toList
∘ transpose
∘ map (uncurry rectangle ∘ unzip)
∘ transpose
∘ map (zip (map fromAlignment a))
|
PrimeTime.ada | SmashedSquirrel/AdaPrimes | 0 | 9561 |
with Interface_Pkg;
procedure Main_Proc is
begin
Interface_Pkg.Find_Prime;
end Main_Proc;
|
Task/Maximum-triangle-path-sum/Ada/maximum-triangle-path-sum.ada | LaudateCorpus1/RosettaCodeData | 1 | 2613 | with Ada.Text_Io; use Ada.Text_Io;
procedure Max_Sum is
Triangle : array (Positive range <>) of integer :=
(55,
94, 48,
95, 30, 96,
77, 71, 26, 67,
97, 13, 76, 38, 45,
07, 36, 79, 16, 37, 68,
48, 07, 09, 18, 70, 26, 06,
18, 72, 79, 46, 59, 79, 29, 90,
20, 76, 87, 11, 32, 07, 07, 49, 18,
27, 83, 58, 35, 71, 11, 25, 57, 29, 85,
14, 64, 36, 96, 27, 11, 58, 56, 92, 18, 55,
02, 90, 03, 60, 48, 49, 41, 46, 33, 36, 47, 23,
92, 50, 48, 02, 36, 59, 42, 79, 72, 20, 82, 77, 42,
56, 78, 38, 80, 39, 75, 02, 71, 66, 66, 01, 03, 55, 72,
44, 25, 67, 84, 71, 67, 11, 61, 40, 57, 58, 89, 40, 56, 36,
85, 32, 25, 85, 57, 48, 84, 35, 47, 62, 17, 01, 01, 99, 89, 52,
06, 71, 28, 75, 94, 48, 37, 10, 23, 51, 06, 48, 53, 18, 74, 98, 15,
27, 02, 92, 23, 08, 71, 76, 84, 15, 52, 92, 63, 81, 10, 44, 10, 69, 93);
Last : Integer := Triangle'Length;
Tn : Integer := 1;
begin
while (Tn * (Tn + 1) / 2) < Last loop
Tn := Tn + 1;
end loop;
for N in reverse 2 .. Tn loop
for I in 2 .. N loop
Triangle (Last - N) := Triangle (Last - N) +
Integer'Max(Triangle (Last - 1), Triangle (Last));
Last := Last - 1;
end loop;
Last := Last - 1;
end loop;
Put_Line(Integer'Image(Triangle(1)));
end Max_Sum;
|
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c8/c87b23a.ada | best08618/asylo | 7 | 12258 | <reponame>best08618/asylo<gh_stars>1-10
-- C87B23A.ADA
-- Grant of Unlimited Rights
--
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- released technical data and computer software in whole or in part, in
-- any manner and for any purpose whatsoever, and to have or permit others
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- CHECK THAT OVERLOADING RESOLUTION USES THE RULE THAT:
--
-- FOR AN INDEXED COMPONENT OF AN ARRAY, THE PREFIX MUST BE
-- APPROPRIATE FOR AN ARRAY TYPE. EACH EXPRESSION FOR THE INDEXED
-- COMPONENT MUST BE OF THE TYPE OF THE CORRESPONDING INDEX AND
-- THERE MUST BE ONE SUCH EXPRESSION FOR EACH INDEX POSITION OF THE
-- ARRAY TYPE.
-- TRH 15 SEPT 82
-- DSJ 07 JUNE 83
WITH REPORT; USE REPORT;
PROCEDURE C87B23A IS
SUBTYPE CHAR IS CHARACTER;
TYPE GRADE IS (A, B, C, D, F);
TYPE NOTE IS (A, B, C, D, E, F, G);
TYPE INT IS NEW INTEGER;
TYPE POS IS NEW INTEGER RANGE 1 .. INTEGER'LAST;
TYPE NAT IS NEW POS;
TYPE BOOL IS NEW BOOLEAN;
TYPE BIT IS NEW BOOL;
TYPE LIT IS (FALSE, TRUE);
TYPE FLAG IS (PASS, FAIL);
TYPE NUM2 IS DIGITS(2);
TYPE NUM3 IS DIGITS(2);
TYPE NUM4 IS DIGITS(2);
TYPE A1 IS ARRAY (POS'(1)..5, NOTE'(A)..D, BOOL'(FALSE)..TRUE)
OF FLOAT;
TYPE A2 IS ARRAY (INT'(1)..5, NOTE'(A)..D, BIT'(FALSE)..TRUE)
OF NUM2;
TYPE A3 IS ARRAY (POS'(1)..5, GRADE'(A)..D, BOOL'(FALSE)..TRUE)
OF NUM3;
TYPE A4 IS ARRAY (NAT'(1)..5, NOTE'(A)..D, LIT'(FALSE)..TRUE)
OF NUM4;
OBJ1 : A1 := (OTHERS => (OTHERS => (OTHERS => 0.0)));
OBJ2 : A2 := (OTHERS => (OTHERS => (OTHERS => 0.0)));
OBJ3 : A3 := (OTHERS => (OTHERS => (OTHERS => 0.0)));
OBJ4 : A4 := (OTHERS => (OTHERS => (OTHERS => 0.0)));
GENERIC
TYPE T IS PRIVATE;
ARG : IN T;
STAT : IN FLAG;
FUNCTION F1 RETURN T;
FUNCTION F1 RETURN T IS
BEGIN
IF STAT = FAIL THEN
FAILED ("PREFIX OR INDEX IS NOT APPROPRIATE FOR" &
" INDEXED COMPONENT");
END IF;
RETURN ARG;
END F1;
FUNCTION A IS NEW F1 (A1, OBJ1, PASS);
FUNCTION A IS NEW F1 (A2, OBJ2, FAIL);
FUNCTION A IS NEW F1 (A3, OBJ3, FAIL);
FUNCTION A IS NEW F1 (A4, OBJ4, FAIL);
BEGIN
TEST ("C87B23A","OVERLOADED ARRAY INDEXES");
DECLARE
F1 : FLOAT := A (3, C, TRUE);
BEGIN
NULL;
END;
RESULT;
END C87B23A;
|
programs/oeis/137/A137823.asm | neoneye/loda | 22 | 242393 | ; A137823: Numbers occurring in A137822 : first differences of numbers n such that 3 | sum( Catalan(k), k=1..2n).
; 1,2,3,7,8,21,61,62,183,547,548,1641,4921,4922,14763,44287,44288,132861,398581,398582,1195743,3587227,3587228,10761681,32285041,32285042,96855123,290565367,290565368,871696101,2615088301,2615088302
mul $0,2
mov $1,$0
lpb $1
sub $0,$1
mul $0,3
add $0,$1
sub $1,3
lpe
div $0,2
add $0,1
|
evernote/notebook_create.applescript | kinshuk4/evernote-automation | 4 | 1707 | on run {notebook_name}
run script (POSIX file "/Users/IceHe/Documents/AppleScript/Evernote/evernote_launch.applescript")
tell application "Evernote"
if not (notebook named notebook_name) exists then
create notebook notebook_name
return true
end if
return false
end tell
end run |
src/x86/cdef16_sse.asm | EwoutH/rav1e | 2,877 | 161154 | ; Copyright (c) 2017-2021, The rav1e contributors
; Copyright (c) 2021, <NAME>
; All rights reserved.
;
; Redistribution and use in source and binary forms, with or without
; modification, are permitted provided that the following conditions are met:
;
; 1. Redistributions of source code must retain the above copyright notice, this
; list of conditions and the following disclaimer.
;
; 2. Redistributions in binary form must reproduce the above copyright notice,
; this list of conditions and the following disclaimer in the documentation
; and/or other materials provided with the distribution.
;
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
; ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
%include "config.asm"
%include "ext/x86/x86inc.asm"
SECTION_RODATA
dir_shift: times 4 dw 0x4000
times 4 dw 0x1000
pw_128: times 4 dw 128
cextern cdef_dir_8bpc_ssse3.main
cextern cdef_dir_8bpc_sse4.main
cextern shufw_6543210x
SECTION .text
%macro REPX 2-*
%xdefine %%f(x) %1
%rep %0 - 1
%rotate 1
%%f(%1)
%endrep
%endmacro
%macro CDEF_DIR 0
%if ARCH_X86_64
cglobal cdef_dir_16bpc, 4, 7, 16, src, stride, var, bdmax
lea r6, [dir_shift]
shr bdmaxd, 11 ; 0 for 10bpc, 1 for 12bpc
movddup m7, [r6+bdmaxq*8]
lea r6, [strideq*3]
mova m0, [srcq+strideq*0]
mova m1, [srcq+strideq*1]
mova m2, [srcq+strideq*2]
mova m3, [srcq+r6 ]
lea srcq, [srcq+strideq*4]
mova m4, [srcq+strideq*0]
mova m5, [srcq+strideq*1]
mova m6, [srcq+strideq*2]
REPX {pmulhuw x, m7}, m0, m1, m2, m3, m4, m5, m6
pmulhuw m7, [srcq+r6 ]
pxor m8, m8
packuswb m9, m0, m1
packuswb m10, m2, m3
packuswb m11, m4, m5
packuswb m12, m6, m7
REPX {psadbw x, m8}, m9, m10, m11, m12
packssdw m9, m10
packssdw m11, m12
packssdw m9, m11
jmp mangle(private_prefix %+ _cdef_dir_8bpc %+ SUFFIX).main
%else
cglobal cdef_dir_16bpc, 2, 4, 8, 96, src, stride, var, bdmax
mov bdmaxd, bdmaxm
LEA r2, dir_shift
shr bdmaxd, 11
movddup m7, [r2+bdmaxq*8]
lea r3, [strideq*3]
pmulhuw m3, m7, [srcq+strideq*0]
pmulhuw m4, m7, [srcq+strideq*1]
pmulhuw m5, m7, [srcq+strideq*2]
pmulhuw m6, m7, [srcq+r3 ]
movddup m1, [r2-dir_shift+pw_128]
lea srcq, [srcq+strideq*4]
pxor m0, m0
packuswb m2, m3, m4
psubw m3, m1
psubw m4, m1
mova [esp+0x00], m3
mova [esp+0x10], m4
packuswb m3, m5, m6
psadbw m2, m0
psadbw m3, m0
psubw m5, m1
psubw m6, m1
packssdw m2, m3
mova [esp+0x20], m5
mova [esp+0x50], m6
pmulhuw m4, m7, [srcq+strideq*0]
pmulhuw m5, m7, [srcq+strideq*1]
pmulhuw m6, m7, [srcq+strideq*2]
pmulhuw m7, [srcq+r3 ]
packuswb m3, m4, m5
packuswb m1, m6, m7
psadbw m3, m0
psadbw m1, m0
packssdw m3, m1
movddup m1, [r2-dir_shift+pw_128]
LEA r2, shufw_6543210x
jmp mangle(private_prefix %+ _cdef_dir_8bpc %+ SUFFIX).main
%endif
%endmacro
INIT_XMM ssse3
CDEF_DIR
INIT_XMM sse4
CDEF_DIR
|
home/copy2.asm | Dev727/ancientplatinum | 28 | 19319 | CopyBytes::
; copy bc bytes from hl to de
inc b ; we bail the moment b hits 0, so include the last run
inc c ; same thing; include last byte
jr .HandleLoop
.CopyByte:
ld a, [hli]
ld [de], a
inc de
.HandleLoop:
dec c
jr nz, .CopyByte
dec b
jr nz, .CopyByte
ret
SwapBytes::
; swap bc bytes between hl and de
.Loop:
; stash [hl] away on the stack
ld a, [hl]
push af
; copy a byte from [de] to [hl]
ld a, [de]
ld [hli], a
; retrieve the previous value of [hl]; put it in [de]
pop af
ld [de], a
inc de
; handle loop stuff
dec bc
ld a, b
or c
jr nz, .Loop
ret
ByteFill::
; fill bc bytes with the value of a, starting at hl
inc b ; we bail the moment b hits 0, so include the last run
inc c ; same thing; include last byte
jr .HandleLoop
.PutByte:
ld [hli], a
.HandleLoop:
dec c
jr nz, .PutByte
dec b
jr nz, .PutByte
ret
GetFarByte::
; retrieve a single byte from a:hl, and return it in a.
; bankswitch to new bank
ldh [hBuffer], a
ldh a, [hROMBank]
push af
ldh a, [hBuffer]
rst Bankswitch
; get byte from new bank
ld a, [hl]
ldh [hBuffer], a
; bankswitch to previous bank
pop af
rst Bankswitch
; return retrieved value in a
ldh a, [hBuffer]
ret
GetFarHalfword::
; retrieve a halfword from a:hl, and return it in hl.
; bankswitch to new bank
ldh [hBuffer], a
ldh a, [hROMBank]
push af
ldh a, [hBuffer]
rst Bankswitch
; get halfword from new bank, put it in hl
ld a, [hli]
ld h, [hl]
ld l, a
; bankswitch to previous bank and return
pop af
rst Bankswitch
ret
FarCopyWRAM::
ldh [hBuffer], a
ldh a, [rSVBK]
push af
ldh a, [hBuffer]
ldh [rSVBK], a
call CopyBytes
pop af
ldh [rSVBK], a
ret
GetFarWRAMByte::
ldh [hBuffer], a
ldh a, [rSVBK]
push af
ldh a, [hBuffer]
ldh [rSVBK], a
ld a, [hl]
ldh [hBuffer], a
pop af
ldh [rSVBK], a
ldh a, [hBuffer]
ret
GetFarWRAMWord::
ldh [hBuffer], a
ldh a, [rSVBK]
push af
ldh a, [hBuffer]
ldh [rSVBK], a
ld a, [hli]
ld h, [hl]
ld l, a
pop af
ldh [rSVBK], a
ret
|
legend-engine-language-pure-dsl-data-space/src/main/antlr4/org/finos/legend/engine/language/pure/grammar/from/antlr4/DataSpaceLexerGrammar.g4 | AFine-gs/legend-engine | 0 | 2403 | <filename>legend-engine-language-pure-dsl-data-space/src/main/antlr4/org/finos/legend/engine/language/pure/grammar/from/antlr4/DataSpaceLexerGrammar.g4<gh_stars>0
lexer grammar DataSpaceLexerGrammar;
import CoreLexerGrammar;
// ------------------------------------ KEYWORD --------------------------------------
STEREOTYPES: 'stereotypes';
TAGS: 'tags';
DATA_SPACE: 'DataSpace';
DATA_SPACE_GROUP_ID: 'groupId';
DATA_SPACE_ARTIFACT_ID: 'artifactId';
DATA_SPACE_VERSION_ID: 'versionId';
DATA_SPACE_MAPPING: 'mapping';
DATA_SPACE_RUNTIME: 'runtime';
DATA_SPACE_DESCRIPTION: 'description';
DATA_SPACE_DIAGRAMS: 'diagrams';
DATA_SPACE_SUPPORT_EMAIL: 'supportEmail'; |
libsrc/_DEVELOPMENT/arch/sms/vdp/c/sdcc/sms_vdp_init.asm | jpoikela/z88dk | 640 | 165984 | ; void sms_vdp_init(void *vdp_register_array)
SECTION code_clib
SECTION code_arch
PUBLIC _sms_vdp_init
EXTERN _sms_vdp_init_fastcall
_sms_vdp_init:
pop af
pop hl
push hl
push af
jp _sms_vdp_init_fastcall
|
out/PCF/Signature.agda | JoeyEremondi/agda-soas | 39 | 13137 | <gh_stars>10-100
{-
This second-order signature was created from the following second-order syntax description:
syntax PCF
type
N : 0-ary
_↣_ : 2-ary | r30
B : 0-ary
term
app : α ↣ β α -> β | _$_ l20
lam : α.β -> α ↣ β | ƛ_ r10
tr : B
fl : B
ze : N
su : N -> N
pr : N -> N
iz : N -> B | 0?
if : B α α -> α
fix : α.α -> α
theory
(ƛβ) b : α.β a : α |> app (lam(x.b[x]), a) = b[a]
(ƛη) f : α ↣ β |> lam (x. app(f, x)) = f
(zz) |> iz (ze) = tr
(zs) n : N |> iz (su (n)) = fl
(ps) n : N |> pr (su (n)) = n
(ift) t f : α |> if (tr, t, f) = t
(iff) t f : α |> if (fl, t, f) = f
(fix) t : α.α |> fix (x.t[x]) = t[fix (x.t[x])]
-}
module PCF.Signature where
open import SOAS.Context
-- Type declaration
data PCFT : Set where
N : PCFT
_↣_ : PCFT → PCFT → PCFT
B : PCFT
infixr 30 _↣_
open import SOAS.Syntax.Signature PCFT public
open import SOAS.Syntax.Build PCFT public
-- Operator symbols
data PCFₒ : Set where
appₒ lamₒ : {α β : PCFT} → PCFₒ
trₒ flₒ zeₒ suₒ prₒ izₒ : PCFₒ
ifₒ fixₒ : {α : PCFT} → PCFₒ
-- Term signature
PCF:Sig : Signature PCFₒ
PCF:Sig = sig λ
{ (appₒ {α}{β}) → (⊢₀ α ↣ β) , (⊢₀ α) ⟼₂ β
; (lamₒ {α}{β}) → (α ⊢₁ β) ⟼₁ α ↣ β
; trₒ → ⟼₀ B
; flₒ → ⟼₀ B
; zeₒ → ⟼₀ N
; suₒ → (⊢₀ N) ⟼₁ N
; prₒ → (⊢₀ N) ⟼₁ N
; izₒ → (⊢₀ N) ⟼₁ B
; (ifₒ {α}) → (⊢₀ B) , (⊢₀ α) , (⊢₀ α) ⟼₃ α
; (fixₒ {α}) → (α ⊢₁ α) ⟼₁ α
}
open Signature PCF:Sig public
|
hammerspoon/umount.applescript | marcusvb/dotfiles | 4 | 3698 | <reponame>marcusvb/dotfiles<filename>hammerspoon/umount.applescript
tell application "Finder"
try
eject disk "fileshare"
eject disk "media"
end try
end tell
|
linux/include/asm-generic/Kbuild.asm | bradchesney79/illacceptanything | 55 | 9546 | <filename>linux/include/asm-generic/Kbuild.asm
include include/uapi/asm-generic/Kbuild.asm
|
Transynther/x86/_processed/US/_st_4k_sm_/i7-7700_9_0xca.log_21829_965.asm | ljhsiun2/medusa | 9 | 240412 | .global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r14
push %r8
push %r9
push %rbp
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_WT_ht+0x385f, %r14
clflush (%r14)
nop
nop
and %rbp, %rbp
mov $0x6162636465666768, %rbx
movq %rbx, (%r14)
nop
add %r8, %r8
lea addresses_WC_ht+0x7f1f, %rdx
nop
sub $10969, %r9
movb (%rdx), %r11b
nop
xor $30243, %r11
lea addresses_A_ht+0x2371, %r8
nop
nop
nop
add %r11, %r11
movw $0x6162, (%r8)
nop
nop
add %rbx, %rbx
lea addresses_WT_ht+0x2b5f, %r14
nop
and %rdx, %rdx
mov $0x6162636465666768, %r11
movq %r11, %xmm7
movups %xmm7, (%r14)
nop
nop
nop
nop
cmp $6011, %rbp
lea addresses_A_ht+0x141ff, %r8
nop
add $63778, %rbx
movups (%r8), %xmm3
vpextrq $0, %xmm3, %rbp
nop
nop
inc %r11
lea addresses_WT_ht+0x165f, %r11
nop
nop
dec %rbp
movb $0x61, (%r11)
nop
and $62590, %r11
lea addresses_WC_ht+0x1847, %rdx
sub $11011, %r9
and $0xffffffffffffffc0, %rdx
movaps (%rdx), %xmm2
vpextrq $1, %xmm2, %rbx
nop
nop
nop
sub $38746, %rdx
lea addresses_A_ht+0x1795b, %rsi
lea addresses_D_ht+0x53c1, %rdi
nop
xor $32876, %r11
mov $58, %rcx
rep movsb
nop
nop
nop
nop
xor $35931, %r9
lea addresses_UC_ht+0x1465f, %rbp
nop
nop
nop
add %rdi, %rdi
movw $0x6162, (%rbp)
nop
nop
nop
xor $19982, %r8
lea addresses_WT_ht+0x14241, %rdx
nop
nop
nop
inc %rdi
mov (%rdx), %ebx
nop
mfence
lea addresses_WC_ht+0x6ebf, %r14
nop
nop
xor $56093, %rbx
mov $0x6162636465666768, %r8
movq %r8, (%r14)
nop
and %rcx, %rcx
lea addresses_normal_ht+0x161a7, %rsi
lea addresses_WT_ht+0x10a5f, %rdi
xor %r8, %r8
mov $46, %rcx
rep movsl
nop
cmp %r11, %r11
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %r9
pop %r8
pop %r14
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r12
push %r13
push %r14
push %r9
push %rbp
push %rdi
// Store
lea addresses_US+0x13a5f, %rbp
nop
nop
nop
nop
nop
add %r9, %r9
movl $0x51525354, (%rbp)
nop
nop
nop
nop
nop
xor %r12, %r12
// Store
lea addresses_D+0x425f, %r14
nop
nop
nop
add $12528, %rbp
mov $0x5152535455565758, %rdi
movq %rdi, %xmm1
movntdq %xmm1, (%r14)
nop
nop
nop
add %r14, %r14
// Load
lea addresses_normal+0x19c5f, %r10
nop
add $52780, %r9
vmovups (%r10), %ymm6
vextracti128 $1, %ymm6, %xmm6
vpextrq $1, %xmm6, %r14
nop
nop
nop
sub %rbp, %rbp
// Store
mov $0x1df, %r14
nop
xor %r9, %r9
movw $0x5152, (%r14)
sub $25018, %r9
// Load
lea addresses_RW+0x22f3, %rbp
nop
nop
dec %r13
movb (%rbp), %r12b
nop
nop
nop
nop
nop
xor %r10, %r10
// Faulty Load
lea addresses_US+0x13a5f, %r12
nop
sub $58835, %rdi
movb (%r12), %r10b
lea oracles, %r13
and $0xff, %r10
shlq $12, %r10
mov (%r13,%r10,1), %r10
pop %rdi
pop %rbp
pop %r9
pop %r14
pop %r13
pop %r12
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_US'}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 4, 'NT': False, 'type': 'addresses_US'}}
{'OP': 'STOR', 'dst': {'congruent': 11, 'AVXalign': False, 'same': False, 'size': 16, 'NT': True, 'type': 'addresses_D'}}
{'src': {'congruent': 9, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_normal'}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'congruent': 7, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_P'}}
{'src': {'congruent': 2, 'AVXalign': True, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_RW'}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 1, 'NT': False, 'type': 'addresses_US'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'congruent': 9, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_WT_ht'}}
{'src': {'congruent': 6, 'AVXalign': False, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_WC_ht'}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'congruent': 0, 'AVXalign': True, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_A_ht'}}
{'OP': 'STOR', 'dst': {'congruent': 6, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_WT_ht'}}
{'src': {'congruent': 5, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_A_ht'}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'congruent': 8, 'AVXalign': False, 'same': False, 'size': 1, 'NT': True, 'type': 'addresses_WT_ht'}}
{'src': {'congruent': 3, 'AVXalign': True, 'same': False, 'size': 16, 'NT': True, 'type': 'addresses_WC_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 0, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'dst': {'congruent': 0, 'same': False, 'type': 'addresses_D_ht'}}
{'OP': 'STOR', 'dst': {'congruent': 10, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_UC_ht'}}
{'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'congruent': 1, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_WC_ht'}}
{'src': {'congruent': 2, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'congruent': 10, 'same': False, 'type': 'addresses_WT_ht'}}
{'54': 21829}
54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54
*/
|
asm_example/jump.asm | ChrisitianFotso/DLX | 0 | 95072 | <reponame>ChrisitianFotso/DLX<gh_stars>0
addi r1, r0, 6 # r1 = 6
addi r2, r0, 7 # r2 = 7
j fine
add r3, r2, r1
nop
subi r1, r0, 6
addi r2, r0, 7
sle r3,r1,r2
slt r4,r1,r2
fine:
sub r3, r2, r1 # r3 = 1
nop
nop
nop
nop
nop
nop
nop
nop
|
other.7z/SFC.7z/SFC/ソースデータ/srd13-SFCマリオコレクション/export/mario-z/linkp/mario_n2/mn_hp_smtitle.asm | prismotizm/gigaleak | 0 | 82098 | Name: mn_hp_smtitle.asm
Type: file
Size: 15698
Last-Modified: '1993-08-25T02:45:14Z'
SHA-1: 861F7E5666C80824FC080AE4451C90EE1CD6770B
Description: null
|
test/fail/Negative4.agda | asr/agda-kanso | 1 | 13374 | <reponame>asr/agda-kanso<gh_stars>1-10
module Negative4 where
data Empty : Set where
data NSPos : Set where
c : ((NSPos -> Empty) -> NSPos) -> NSPos
|
src/agda/FRP/JS/Bool.agda | agda/agda-frp-js | 63 | 6808 | <gh_stars>10-100
module FRP.JS.Bool where
open import FRP.JS.Primitive public using ( Bool ; true ; false )
not : Bool → Bool
not true = false
not false = true
{-# COMPILED_JS not function(x) { return !x; } #-}
_≟_ : Bool → Bool → Bool
true ≟ b = b
false ≟ b = not b
{-# COMPILED_JS _≟_ function(x) { return function(y) { return x === y; }; } #-}
if_then_else_ : ∀ {α} {A : Set α} → Bool → A → A → A
if true then t else f = t
if false then t else f = f
{-# COMPILED_JS if_then_else_ function(a) { return function(A) { return function(x) {
if (x) { return function(t) { return function(f) { return t; }; }; }
else { return function(t) { return function(f) { return f; }; }; }
}; }; } #-}
_∧_ : Bool → Bool → Bool
true ∧ b = b
false ∧ b = false
{-# COMPILED_JS _∧_ function(x) { return function(y) { return x && y; }; } #-}
_∨_ : Bool → Bool → Bool
true ∨ b = true
false ∨ b = b
{-# COMPILED_JS _∨_ function(x) { return function(y) { return x || y; }; } #-}
_xor_ : Bool → Bool → Bool
true xor b = not b
false xor b = b
_≠_ = _xor_
{-# COMPILED_JS _xor_ function(x) { return function(y) { return x !== y; }; } #-}
{-# COMPILED_JS _≠_ function(x) { return function(y) { return x !== y; }; } #-}
|
TokenRegexIt.g4 | linonetwo/token-regex | 1 | 4265 | grammar TokenRegexIt;
refinement: '<' STRING '>';
tokenRegex: tokenRegexBlock tokenRegex | EOF;
tokenRegexBlock:
'#' STRING (refinement)? # posTag
| STRING ':' tokenRegexBlock # namedCapture
| '(' tokenRegex ')' # group
| STRING # literal
| tokenRegexBlock '|' tokenRegexBlock # or
| tokenRegexBlock '?' # optional;
// skip spaces, tabs, newlines, note that \v is not suppoted in antlr
WHITESPACE: [ \t\r\n\f]+ -> skip;
// premitives
STRING: (ESCAPED_CHAR | [0-9a-zA-Z] | CHINESE)+;
INT: [0-9]+;
fragment ESCAPED_CHAR: '\\' (["\\/bfnrt] | UNICODE);
fragment UNICODE: 'u' HEX HEX HEX HEX;
fragment HEX: [0-9a-fA-F];
fragment CHINESE: [\u3006\u3007\u3021-\u3029\u3038-\u303A\u3400-\u4DB5\u4E00-\u9FEA\uF900-\uFA6D\uFA70-\uFAD9]; |
oeis/256/A256281.asm | neoneye/loda-programs | 11 | 97019 | ; A256281: Inverse Moebius transform of Pell numbers.
; Submitted by <NAME>
; 1,3,6,15,30,78,170,423,991,2410,5742,13950,33462,80954,195060,471255,1136690,2745273,6625110,15996850,38614140,93228102,225058682,543354078,1311738151,3166849426,7645371036,18457637018,44560482150,107578717860,259717522850,627014037303,1513744660692,3654504012630
add $0,1
mov $2,$0
lpb $0
mov $3,$2
dif $3,$0
sub $0,1
cmp $3,$2
sub $3,$1
mov $1,$4
add $4,1
sub $4,$3
add $1,$4
lpe
mov $0,$4
add $0,1
|
public/wintab/wintabx/phnext.asm | DannyParker0001/Kisak-Strike | 252 | 81310 | <filename>public/wintab/wintabx/phnext.asm<gh_stars>100-1000
include xlibproc.inc
include Wintab.inc
PROC_TEMPLATE WTMgrPacketHookNext, 5, Wintab, -, 205
|
Code/CustomControl/SpreadSheet/SprShtDLL/SprMisc.asm | CherryDT/FbEditMOD | 11 | 25469 | <gh_stars>10-100
.code
StrLen proc lpSrc:DWORD
mov edx,lpSrc
dec edx
xor al,al
@@:
inc edx
cmp al,[edx]
jne @b
mov eax,edx
sub eax,lpSrc
ret
StrLen endp
StrCpy proc uses esi edi,lpDst:DWORD,lpSrc:DWORD
mov esi,lpSrc
mov edi,lpDst
@@:
mov al,[esi]
mov [edi],al
inc esi
inc edi
or al,al
jne @b
ret
StrCpy endp
MemMove proc uses ebx esi edi,lpSheet:DWORD,lpWhere:DWORD,nLen:DWORD
mov ebx,lpSheet
mov eax,nLen
or eax,eax
je Ex
js @f
;Grow
mov esi,[ebx].SHEET.lprow
add eax,[esi].ROWDTA.len
add eax,32
.if eax>[esi].ROWDTA.maxlen
shr eax,12
inc eax
shl eax,12
mov [esi].ROWDTA.maxlen,eax
invoke GlobalAlloc,GMEM_FIXED or GMEM_ZEROINIT,eax
push eax
mov edi,eax
mov ecx,[esi].ROWDTA.len
rep movsb
pop esi
mov eax,esi
sub eax,[ebx].SHEET.lprow
add lpWhere,eax
.if [ebx].SHEET.lpcol
add [ebx].SHEET.lpcol,eax
.endif
invoke GlobalFree,[ebx].SHEET.lprow
movzx ecx,[esi].ROWDTA.rown
mov eax,[ebx].SHEET.lprowmem
lea eax,[eax+ecx*4]
mov [eax],esi
mov [ebx].SHEET.lprow,esi
.endif
mov eax,nLen
add esi,[esi].ROWDTA.len
mov edi,esi
add edi,eax
mov ecx,esi
sub ecx,lpWhere
inc ecx
mov eax,3
std
.if ecx>eax
push ecx
shr ecx,2
sub esi,eax
sub edi,eax
rep movsd
add edi,eax
add esi,eax
pop ecx
.endif
and ecx,eax
.if ecx
rep movsb
.endif
cld
jmp Ex
@@:
;Shrink
mov edi,lpWhere
mov esi,edi
sub esi,eax
mov ecx,[ebx].SHEET.lprow
add ecx,[ecx]
sub ecx,edi
mov eax,3
.if ecx>eax
push ecx
shr ecx,2
rep movsd
pop ecx
.endif
and ecx,eax
.if ecx
rep movsb
.endif
Ex:
mov eax,nLen
mov edx,[ebx].SHEET.lprow
.if edx
add [edx].ROWDTA.len,eax
.endif
mov edx,[ebx].SHEET.lpcol
.if edx
add [edx].COLDTA.len,ax
.endif
mov eax,lpWhere
ret
MemMove endp
|
programs/oeis/177/A177176.asm | jmorken/loda | 1 | 27614 | <filename>programs/oeis/177/A177176.asm
; A177176: Partial sums of round(n^2/13).
; 0,0,0,1,2,4,7,11,16,22,30,39,50,63,78,95,115,137,162,190,221,255,292,333,377,425,477,533,593,658,727,801,880,964,1053,1147,1247,1352,1463,1580,1703,1832,1968,2110,2259,2415,2578,2748,2925,3110,3302,3502,3710,3926,4150,4383,4624,4874,5133,5401,5678,5964,6260,6565,6880,7205,7540,7885,8241,8607,8984,9372,9771,10181,10602,11035,11479,11935,12403,12883,13375,13880,14397,14927,15470,16026,16595,17177,17773,18382,19005,19642,20293,20958,21638,22332,23041,23765,24504,25258,26027,26812,27612,28428,29260,30108,30972,31853,32750,33664,34595,35543,36508,37490,38490,39507,40542,41595,42666,43755,44863,45989,47134,48298,49481,50683,51904,53145,54405,55685,56985,58305,59645,61006,62387,63789,65212,66656,68121,69607,71115,72644,74195,75768,77363,78980,80620,82282,83967,85675,87406,89160,90937,92738,94562,96410,98282,100178,102098,104043,106012,108006,110025,112069,114138,116232,118352,120497,122668,124865,127088,129337,131613,133915,136244,138600,140983,143393,145830,148295,150787,153307,155855,158431,161035,163668,166329,169019,171738,174486,177263,180069,182905,185770,188665,191590,194545,197530,200546,203592,206669,209777,212916,216086,219287,222520,225784,229080,232408,235768,239160,242585,246042,249532,253055,256611,260200,263822,267478,271167,274890,278647,282438,286263,290123,294017,297946,301910,305909,309943,314012,318117,322257,326433,330645,334893,339177,343498,347855,352249,356680,361148,365653,370195,374775,379392,384047,388740,393471,398240
mov $7,$0
mov $9,$0
lpb $7
mov $0,$9
sub $7,1
sub $0,$7
pow $0,2
mov $2,$0
mov $5,3
mov $8,6
lpb $2
mov $3,$5
mov $4,2
lpb $4
cmp $0,$4
add $3,$2
add $3,1
add $8,7
div $3,$8
div $4,$4
pow $6,$0
gcd $2,$6
lpe
lpe
add $1,$3
lpe
|
src/lesson04b/kernel8.asm | rohanrajnair/p1-kernel | 11 | 12328 |
build/kernel8.elf: file format elf64-littleaarch64
Disassembly of section .text.boot:
0000000000080000 <_start>:
.section ".text.boot"
.globl _start
_start:
mrs x0, mpidr_el1
80000: d53800a0 mrs x0, mpidr_el1
and x0, x0,#0xFF // Check processor id
80004: 92401c00 and x0, x0, #0xff
cbz x0, master // Hang for all non-primary CPU
80008: b4000060 cbz x0, 80014 <master>
b proc_hang
8000c: 14000001 b 80010 <proc_hang>
0000000000080010 <proc_hang>:
proc_hang:
b proc_hang
80010: 14000000 b 80010 <proc_hang>
0000000000080014 <master>:
master:
ldr x0, =SCTLR_VALUE_MMU_DISABLED // System control register
80014: 58000220 ldr x0, 80058 <el1_entry+0x20>
msr sctlr_el1, x0
80018: d5181000 msr sctlr_el1, x0
ldr x0, =HCR_VALUE // Hypervisor Configuration (EL2)
8001c: 58000220 ldr x0, 80060 <el1_entry+0x28>
msr hcr_el2, x0
80020: d51c1100 msr hcr_el2, x0
#ifdef USE_QEMU // xzl: qemu boots from EL2. cannot do things to EL3
ldr x0, =SPSR_VALUE
80024: 58000220 ldr x0, 80068 <el1_entry+0x30>
msr spsr_el2, x0
80028: d51c4000 msr spsr_el2, x0
adr x0, el1_entry
8002c: 10000060 adr x0, 80038 <el1_entry>
msr elr_el2, x0
80030: d51c4020 msr elr_el2, x0
adr x0, el1_entry
msr elr_el3, x0
#endif
eret
80034: d69f03e0 eret
0000000000080038 <el1_entry>:
el1_entry:
adr x0, bss_begin
80038: 10019e00 adr x0, 833f8 <bss_begin>
adr x1, bss_end
8003c: 10405e81 adr x1, 100c0c <bss_end>
sub x1, x1, x0
80040: cb000021 sub x1, x1, x0
bl memzero
80044: 94000b75 bl 82e18 <memzero>
mov sp, #LOW_MEMORY
80048: b26a03ff mov sp, #0x400000 // #4194304
bl kernel_main
8004c: 94000215 bl 808a0 <kernel_main>
b proc_hang // should never come here
80050: 17fffff0 b 80010 <proc_hang>
80054: 00000000 .inst 0x00000000 ; undefined
80058: 30d00800 .word 0x30d00800
8005c: 00000000 .word 0x00000000
80060: 80000000 .word 0x80000000
80064: 00000000 .word 0x00000000
80068: 000001c5 .word 0x000001c5
8006c: 00000000 .word 0x00000000
Disassembly of section .text:
0000000000080800 <process>:
#include "fork.h"
#include "sched.h"
#include "mini_uart.h"
void process(char *array)
{
80800: a9bd7bfd stp x29, x30, [sp, #-48]!
80804: 910003fd mov x29, sp
80808: f9000fa0 str x0, [x29, #24]
while (1) {
for (int i = 0; i < 5; i++){
8080c: b9002fbf str wzr, [x29, #44]
80810: 1400000c b 80840 <process+0x40>
uart_send(array[i]);
80814: b9802fa0 ldrsw x0, [x29, #44]
80818: f9400fa1 ldr x1, [x29, #24]
8081c: 8b000020 add x0, x1, x0
80820: 39400000 ldrb w0, [x0]
80824: 940000a5 bl 80ab8 <uart_send>
delay(5000000);
80828: d2896800 mov x0, #0x4b40 // #19264
8082c: f2a00980 movk x0, #0x4c, lsl #16
80830: 940004b4 bl 81b00 <delay>
for (int i = 0; i < 5; i++){
80834: b9402fa0 ldr w0, [x29, #44]
80838: 11000400 add w0, w0, #0x1
8083c: b9002fa0 str w0, [x29, #44]
80840: b9402fa0 ldr w0, [x29, #44]
80844: 7100101f cmp w0, #0x4
80848: 54fffe6d b.le 80814 <process+0x14>
8084c: 17fffff0 b 8080c <process+0xc>
0000000000080850 <process2>:
}
}
}
void process2(char *array)
{
80850: a9bd7bfd stp x29, x30, [sp, #-48]!
80854: 910003fd mov x29, sp
80858: f9000fa0 str x0, [x29, #24]
while (1) {
for (int i = 0; i < 5; i++){
8085c: b9002fbf str wzr, [x29, #44]
80860: 1400000c b 80890 <process2+0x40>
uart_send(array[i]);
80864: b9802fa0 ldrsw x0, [x29, #44]
80868: f9400fa1 ldr x1, [x29, #24]
8086c: 8b000020 add x0, x1, x0
80870: 39400000 ldrb w0, [x0]
80874: 94000091 bl 80ab8 <uart_send>
delay(5000000);
80878: d2896800 mov x0, #0x4b40 // #19264
8087c: f2a00980 movk x0, #0x4c, lsl #16
80880: 940004a0 bl 81b00 <delay>
for (int i = 0; i < 5; i++){
80884: b9402fa0 ldr w0, [x29, #44]
80888: 11000400 add w0, w0, #0x1
8088c: b9002fa0 str w0, [x29, #44]
80890: b9402fa0 ldr w0, [x29, #44]
80894: 7100101f cmp w0, #0x4
80898: 54fffe6d b.le 80864 <process2+0x14>
8089c: 17fffff0 b 8085c <process2+0xc>
00000000000808a0 <kernel_main>:
}
}
}
void kernel_main(void)
{
808a0: a9be7bfd stp x29, x30, [sp, #-32]!
808a4: 910003fd mov x29, sp
uart_init();
808a8: 940000bd bl 80b9c <uart_init>
init_printf(0, putc);
808ac: f0000000 adrp x0, 83000 <cpu_switch_to+0x1d8>
808b0: f940a400 ldr x0, [x0, #328]
808b4: aa0003e1 mov x1, x0
808b8: d2800000 mov x0, #0x0 // #0
808bc: 940003d6 bl 81814 <init_printf>
printf("kernel boots\n");
808c0: d0000000 adrp x0, 82000 <vectors>
808c4: 9139e000 add x0, x0, #0xe78
808c8: 940003e1 bl 8184c <tfp_printf>
irq_vector_init();
808cc: 94000490 bl 81b0c <irq_vector_init>
generic_timer_init();
808d0: 94000470 bl 81a90 <generic_timer_init>
enable_interrupt_controller();
808d4: 94000024 bl 80964 <enable_interrupt_controller>
enable_irq();
808d8: 94000490 bl 81b18 <enable_irq>
int res = copy_process((unsigned long)&process, (unsigned long)"12345");
808dc: 90000000 adrp x0, 80000 <_start>
808e0: 91200002 add x2, x0, #0x800
808e4: d0000000 adrp x0, 82000 <vectors>
808e8: 913a2000 add x0, x0, #0xe88
808ec: aa0003e1 mov x1, x0
808f0: aa0203e0 mov x0, x2
808f4: 94000199 bl 80f58 <copy_process>
808f8: b9001fa0 str w0, [x29, #28]
if (res != 0) {
808fc: b9401fa0 ldr w0, [x29, #28]
80900: 7100001f cmp w0, #0x0
80904: 540000a0 b.eq 80918 <kernel_main+0x78> // b.none
printf("error while starting process 1");
80908: d0000000 adrp x0, 82000 <vectors>
8090c: 913a4000 add x0, x0, #0xe90
80910: 940003cf bl 8184c <tfp_printf>
return;
80914: 14000012 b 8095c <kernel_main+0xbc>
}
res = copy_process((unsigned long)&process2, (unsigned long)"abcde");
80918: 90000000 adrp x0, 80000 <_start>
8091c: 91214002 add x2, x0, #0x850
80920: d0000000 adrp x0, 82000 <vectors>
80924: 913ac000 add x0, x0, #0xeb0
80928: aa0003e1 mov x1, x0
8092c: aa0203e0 mov x0, x2
80930: 9400018a bl 80f58 <copy_process>
80934: b9001fa0 str w0, [x29, #28]
if (res != 0) {
80938: b9401fa0 ldr w0, [x29, #28]
8093c: 7100001f cmp w0, #0x0
80940: 540000a0 b.eq 80954 <kernel_main+0xb4> // b.none
printf("error while starting process 2");
80944: d0000000 adrp x0, 82000 <vectors>
80948: 913ae000 add x0, x0, #0xeb8
8094c: 940003c0 bl 8184c <tfp_printf>
return;
80950: 14000003 b 8095c <kernel_main+0xbc>
}
while (1){
schedule();
80954: 9400013a bl 80e3c <schedule>
80958: 17ffffff b 80954 <kernel_main+0xb4>
}
}
8095c: a8c27bfd ldp x29, x30, [sp], #32
80960: d65f03c0 ret
0000000000080964 <enable_interrupt_controller>:
"FIQ_INVALID_EL0_32",
"ERROR_INVALID_EL0_32"
};
void enable_interrupt_controller()
{
80964: a9bf7bfd stp x29, x30, [sp, #-16]!
80968: 910003fd mov x29, sp
// Enables Core 0 Timers interrupt control for the generic timer
put32(TIMER_INT_CTRL_0, TIMER_INT_CTRL_0_VALUE);
8096c: 52800041 mov w1, #0x2 // #2
80970: d2800800 mov x0, #0x40 // #64
80974: f2a80000 movk x0, #0x4000, lsl #16
80978: 9400045e bl 81af0 <put32>
}
8097c: d503201f nop
80980: a8c17bfd ldp x29, x30, [sp], #16
80984: d65f03c0 ret
0000000000080988 <show_invalid_entry_message>:
void show_invalid_entry_message(int type, unsigned long esr, unsigned long address)
{
80988: a9bd7bfd stp x29, x30, [sp, #-48]!
8098c: 910003fd mov x29, sp
80990: b9002fa0 str w0, [x29, #44]
80994: f90013a1 str x1, [x29, #32]
80998: f9000fa2 str x2, [x29, #24]
printf("%s, ESR: %x, address: %x\r\n", entry_error_messages[type], esr, address);
8099c: f0000000 adrp x0, 83000 <cpu_switch_to+0x1d8>
809a0: 9105c000 add x0, x0, #0x170
809a4: b9802fa1 ldrsw x1, [x29, #44]
809a8: f8617801 ldr x1, [x0, x1, lsl #3]
809ac: f0000000 adrp x0, 83000 <cpu_switch_to+0x1d8>
809b0: 91016000 add x0, x0, #0x58
809b4: f9400fa3 ldr x3, [x29, #24]
809b8: f94013a2 ldr x2, [x29, #32]
809bc: 940003a4 bl 8184c <tfp_printf>
}
809c0: d503201f nop
809c4: a8c37bfd ldp x29, x30, [sp], #48
809c8: d65f03c0 ret
00000000000809cc <handle_irq>:
void handle_irq(void)
{
809cc: a9be7bfd stp x29, x30, [sp, #-32]!
809d0: 910003fd mov x29, sp
// Each Core has its own pending local intrrupts register
unsigned int irq = get32(INT_SOURCE_0);
809d4: d2800c00 mov x0, #0x60 // #96
809d8: f2a80000 movk x0, #0x4000, lsl #16
809dc: 94000447 bl 81af8 <get32>
809e0: b9001fa0 str w0, [x29, #28]
switch (irq) {
809e4: b9401fa0 ldr w0, [x29, #28]
809e8: 7100081f cmp w0, #0x2
809ec: 54000061 b.ne 809f8 <handle_irq+0x2c> // b.any
case (GENERIC_TIMER_INTERRUPT):
handle_generic_timer_irq();
809f0: 9400042f bl 81aac <handle_generic_timer_irq>
break;
809f4: 14000005 b 80a08 <handle_irq+0x3c>
default:
printf("Unknown pending irq: %x\r\n", irq);
809f8: f0000000 adrp x0, 83000 <cpu_switch_to+0x1d8>
809fc: 9101e000 add x0, x0, #0x78
80a00: b9401fa1 ldr w1, [x29, #28]
80a04: 94000392 bl 8184c <tfp_printf>
}
80a08: d503201f nop
80a0c: a8c27bfd ldp x29, x30, [sp], #32
80a10: d65f03c0 ret
0000000000080a14 <get_free_page>:
#include "mm.h"
static unsigned short mem_map [ PAGING_PAGES ] = {0,};
unsigned long get_free_page()
{
80a14: d10043ff sub sp, sp, #0x10
for (int i = 0; i < PAGING_PAGES; i++){
80a18: b9000fff str wzr, [sp, #12]
80a1c: 14000014 b 80a6c <get_free_page+0x58>
if (mem_map[i] == 0){
80a20: f0000000 adrp x0, 83000 <cpu_switch_to+0x1d8>
80a24: 910fe000 add x0, x0, #0x3f8
80a28: b9800fe1 ldrsw x1, [sp, #12]
80a2c: 78617800 ldrh w0, [x0, x1, lsl #1]
80a30: 7100001f cmp w0, #0x0
80a34: 54000161 b.ne 80a60 <get_free_page+0x4c> // b.any
mem_map[i] = 1;
80a38: f0000000 adrp x0, 83000 <cpu_switch_to+0x1d8>
80a3c: 910fe000 add x0, x0, #0x3f8
80a40: b9800fe1 ldrsw x1, [sp, #12]
80a44: 52800022 mov w2, #0x1 // #1
80a48: 78217802 strh w2, [x0, x1, lsl #1]
return LOW_MEMORY + i*PAGE_SIZE;
80a4c: b9400fe0 ldr w0, [sp, #12]
80a50: 11100000 add w0, w0, #0x400
80a54: 53144c00 lsl w0, w0, #12
80a58: 93407c00 sxtw x0, w0
80a5c: 1400000a b 80a84 <get_free_page+0x70>
for (int i = 0; i < PAGING_PAGES; i++){
80a60: b9400fe0 ldr w0, [sp, #12]
80a64: 11000400 add w0, w0, #0x1
80a68: b9000fe0 str w0, [sp, #12]
80a6c: b9400fe1 ldr w1, [sp, #12]
80a70: 529d7fe0 mov w0, #0xebff // #60415
80a74: 72a00060 movk w0, #0x3, lsl #16
80a78: 6b00003f cmp w1, w0
80a7c: 54fffd2d b.le 80a20 <get_free_page+0xc>
}
}
return 0;
80a80: d2800000 mov x0, #0x0 // #0
}
80a84: 910043ff add sp, sp, #0x10
80a88: d65f03c0 ret
0000000000080a8c <free_page>:
void free_page(unsigned long p){
80a8c: d10043ff sub sp, sp, #0x10
80a90: f90007e0 str x0, [sp, #8]
mem_map[(p - LOW_MEMORY) / PAGE_SIZE] = 0;
80a94: f94007e0 ldr x0, [sp, #8]
80a98: d1500000 sub x0, x0, #0x400, lsl #12
80a9c: d34cfc01 lsr x1, x0, #12
80aa0: f0000000 adrp x0, 83000 <cpu_switch_to+0x1d8>
80aa4: 910fe000 add x0, x0, #0x3f8
80aa8: 7821781f strh wzr, [x0, x1, lsl #1]
}
80aac: d503201f nop
80ab0: 910043ff add sp, sp, #0x10
80ab4: d65f03c0 ret
0000000000080ab8 <uart_send>:
#include "utils.h"
#include "peripherals/mini_uart.h"
#include "peripherals/gpio.h"
void uart_send ( char c )
{
80ab8: a9be7bfd stp x29, x30, [sp, #-32]!
80abc: 910003fd mov x29, sp
80ac0: 39007fa0 strb w0, [x29, #31]
while(1) {
if(get32(AUX_MU_LSR_REG)&0x20)
80ac4: d28a0a80 mov x0, #0x5054 // #20564
80ac8: f2a7e420 movk x0, #0x3f21, lsl #16
80acc: 9400040b bl 81af8 <get32>
80ad0: 121b0000 and w0, w0, #0x20
80ad4: 7100001f cmp w0, #0x0
80ad8: 54000041 b.ne 80ae0 <uart_send+0x28> // b.any
80adc: 17fffffa b 80ac4 <uart_send+0xc>
break;
80ae0: d503201f nop
}
put32(AUX_MU_IO_REG,c);
80ae4: 39407fa0 ldrb w0, [x29, #31]
80ae8: 2a0003e1 mov w1, w0
80aec: d28a0800 mov x0, #0x5040 // #20544
80af0: f2a7e420 movk x0, #0x3f21, lsl #16
80af4: 940003ff bl 81af0 <put32>
}
80af8: d503201f nop
80afc: a8c27bfd ldp x29, x30, [sp], #32
80b00: d65f03c0 ret
0000000000080b04 <uart_recv>:
char uart_recv ( void )
{
80b04: a9bf7bfd stp x29, x30, [sp, #-16]!
80b08: 910003fd mov x29, sp
while(1) {
if(get32(AUX_MU_LSR_REG)&0x01)
80b0c: d28a0a80 mov x0, #0x5054 // #20564
80b10: f2a7e420 movk x0, #0x3f21, lsl #16
80b14: 940003f9 bl 81af8 <get32>
80b18: 12000000 and w0, w0, #0x1
80b1c: 7100001f cmp w0, #0x0
80b20: 54000041 b.ne 80b28 <uart_recv+0x24> // b.any
80b24: 17fffffa b 80b0c <uart_recv+0x8>
break;
80b28: d503201f nop
}
return(get32(AUX_MU_IO_REG)&0xFF);
80b2c: d28a0800 mov x0, #0x5040 // #20544
80b30: f2a7e420 movk x0, #0x3f21, lsl #16
80b34: 940003f1 bl 81af8 <get32>
80b38: 12001c00 and w0, w0, #0xff
}
80b3c: a8c17bfd ldp x29, x30, [sp], #16
80b40: d65f03c0 ret
0000000000080b44 <uart_send_string>:
void uart_send_string(char* str)
{
80b44: a9bd7bfd stp x29, x30, [sp, #-48]!
80b48: 910003fd mov x29, sp
80b4c: f9000fa0 str x0, [x29, #24]
for (int i = 0; str[i] != '\0'; i ++) {
80b50: b9002fbf str wzr, [x29, #44]
80b54: 14000009 b 80b78 <uart_send_string+0x34>
uart_send((char)str[i]);
80b58: b9802fa0 ldrsw x0, [x29, #44]
80b5c: f9400fa1 ldr x1, [x29, #24]
80b60: 8b000020 add x0, x1, x0
80b64: 39400000 ldrb w0, [x0]
80b68: 97ffffd4 bl 80ab8 <uart_send>
for (int i = 0; str[i] != '\0'; i ++) {
80b6c: b9402fa0 ldr w0, [x29, #44]
80b70: 11000400 add w0, w0, #0x1
80b74: b9002fa0 str w0, [x29, #44]
80b78: b9802fa0 ldrsw x0, [x29, #44]
80b7c: f9400fa1 ldr x1, [x29, #24]
80b80: 8b000020 add x0, x1, x0
80b84: 39400000 ldrb w0, [x0]
80b88: 7100001f cmp w0, #0x0
80b8c: 54fffe61 b.ne 80b58 <uart_send_string+0x14> // b.any
}
}
80b90: d503201f nop
80b94: a8c37bfd ldp x29, x30, [sp], #48
80b98: d65f03c0 ret
0000000000080b9c <uart_init>:
void uart_init ( void )
{
80b9c: a9be7bfd stp x29, x30, [sp, #-32]!
80ba0: 910003fd mov x29, sp
unsigned int selector;
selector = get32(GPFSEL1);
80ba4: d2800080 mov x0, #0x4 // #4
80ba8: f2a7e400 movk x0, #0x3f20, lsl #16
80bac: 940003d3 bl 81af8 <get32>
80bb0: b9001fa0 str w0, [x29, #28]
selector &= ~(7<<12); // clean gpio14
80bb4: b9401fa0 ldr w0, [x29, #28]
80bb8: 12117000 and w0, w0, #0xffff8fff
80bbc: b9001fa0 str w0, [x29, #28]
selector |= 2<<12; // set alt5 for gpio14
80bc0: b9401fa0 ldr w0, [x29, #28]
80bc4: 32130000 orr w0, w0, #0x2000
80bc8: b9001fa0 str w0, [x29, #28]
selector &= ~(7<<15); // clean gpio15
80bcc: b9401fa0 ldr w0, [x29, #28]
80bd0: 120e7000 and w0, w0, #0xfffc7fff
80bd4: b9001fa0 str w0, [x29, #28]
selector |= 2<<15; // set alt5 for gpio15
80bd8: b9401fa0 ldr w0, [x29, #28]
80bdc: 32100000 orr w0, w0, #0x10000
80be0: b9001fa0 str w0, [x29, #28]
put32(GPFSEL1,selector);
80be4: b9401fa1 ldr w1, [x29, #28]
80be8: d2800080 mov x0, #0x4 // #4
80bec: f2a7e400 movk x0, #0x3f20, lsl #16
80bf0: 940003c0 bl 81af0 <put32>
put32(GPPUD,0);
80bf4: 52800001 mov w1, #0x0 // #0
80bf8: d2801280 mov x0, #0x94 // #148
80bfc: f2a7e400 movk x0, #0x3f20, lsl #16
80c00: 940003bc bl 81af0 <put32>
delay(150);
80c04: d28012c0 mov x0, #0x96 // #150
80c08: 940003be bl 81b00 <delay>
put32(GPPUDCLK0,(1<<14)|(1<<15));
80c0c: 52980001 mov w1, #0xc000 // #49152
80c10: d2801300 mov x0, #0x98 // #152
80c14: f2a7e400 movk x0, #0x3f20, lsl #16
80c18: 940003b6 bl 81af0 <put32>
delay(150);
80c1c: d28012c0 mov x0, #0x96 // #150
80c20: 940003b8 bl 81b00 <delay>
put32(GPPUDCLK0,0);
80c24: 52800001 mov w1, #0x0 // #0
80c28: d2801300 mov x0, #0x98 // #152
80c2c: f2a7e400 movk x0, #0x3f20, lsl #16
80c30: 940003b0 bl 81af0 <put32>
put32(AUX_ENABLES,1); //Enable mini uart (this also enables access to it registers)
80c34: 52800021 mov w1, #0x1 // #1
80c38: d28a0080 mov x0, #0x5004 // #20484
80c3c: f2a7e420 movk x0, #0x3f21, lsl #16
80c40: 940003ac bl 81af0 <put32>
put32(AUX_MU_CNTL_REG,0); //Disable auto flow control and disable receiver and transmitter (for now)
80c44: 52800001 mov w1, #0x0 // #0
80c48: d28a0c00 mov x0, #0x5060 // #20576
80c4c: f2a7e420 movk x0, #0x3f21, lsl #16
80c50: 940003a8 bl 81af0 <put32>
put32(AUX_MU_IER_REG,0); //Disable receive and transmit interrupts
80c54: 52800001 mov w1, #0x0 // #0
80c58: d28a0880 mov x0, #0x5044 // #20548
80c5c: f2a7e420 movk x0, #0x3f21, lsl #16
80c60: 940003a4 bl 81af0 <put32>
put32(AUX_MU_LCR_REG,3); //Enable 8 bit mode
80c64: 52800061 mov w1, #0x3 // #3
80c68: d28a0980 mov x0, #0x504c // #20556
80c6c: f2a7e420 movk x0, #0x3f21, lsl #16
80c70: 940003a0 bl 81af0 <put32>
put32(AUX_MU_MCR_REG,0); //Set RTS line to be always high
80c74: 52800001 mov w1, #0x0 // #0
80c78: d28a0a00 mov x0, #0x5050 // #20560
80c7c: f2a7e420 movk x0, #0x3f21, lsl #16
80c80: 9400039c bl 81af0 <put32>
put32(AUX_MU_BAUD_REG,270); //Set baud rate to 115200
80c84: 528021c1 mov w1, #0x10e // #270
80c88: d28a0d00 mov x0, #0x5068 // #20584
80c8c: f2a7e420 movk x0, #0x3f21, lsl #16
80c90: 94000398 bl 81af0 <put32>
put32(AUX_MU_CNTL_REG,3); //Finally, enable transmitter and receiver
80c94: 52800061 mov w1, #0x3 // #3
80c98: d28a0c00 mov x0, #0x5060 // #20576
80c9c: f2a7e420 movk x0, #0x3f21, lsl #16
80ca0: 94000394 bl 81af0 <put32>
}
80ca4: d503201f nop
80ca8: a8c27bfd ldp x29, x30, [sp], #32
80cac: d65f03c0 ret
0000000000080cb0 <putc>:
// This function is required by printf function
void putc ( void* p, char c)
{
80cb0: a9be7bfd stp x29, x30, [sp, #-32]!
80cb4: 910003fd mov x29, sp
80cb8: f9000fa0 str x0, [x29, #24]
80cbc: 39005fa1 strb w1, [x29, #23]
uart_send(c);
80cc0: 39405fa0 ldrb w0, [x29, #23]
80cc4: 97ffff7d bl 80ab8 <uart_send>
}
80cc8: d503201f nop
80ccc: a8c27bfd ldp x29, x30, [sp], #32
80cd0: d65f03c0 ret
0000000000080cd4 <preempt_disable>:
struct task_struct * task[NR_TASKS] = {&(init_task), };
int nr_tasks = 1;
void preempt_disable(void)
{
current->preempt_count++;
80cd4: f0000000 adrp x0, 83000 <cpu_switch_to+0x1d8>
80cd8: 9107c000 add x0, x0, #0x1f0
80cdc: f9400000 ldr x0, [x0]
80ce0: f9404001 ldr x1, [x0, #128]
80ce4: 91000421 add x1, x1, #0x1
80ce8: f9004001 str x1, [x0, #128]
}
80cec: d503201f nop
80cf0: d65f03c0 ret
0000000000080cf4 <preempt_enable>:
void preempt_enable(void)
{
current->preempt_count--;
80cf4: f0000000 adrp x0, 83000 <cpu_switch_to+0x1d8>
80cf8: 9107c000 add x0, x0, #0x1f0
80cfc: f9400000 ldr x0, [x0]
80d00: f9404001 ldr x1, [x0, #128]
80d04: d1000421 sub x1, x1, #0x1
80d08: f9004001 str x1, [x0, #128]
}
80d0c: d503201f nop
80d10: d65f03c0 ret
0000000000080d14 <_schedule>:
void _schedule(void)
{
80d14: a9bd7bfd stp x29, x30, [sp, #-48]!
80d18: 910003fd mov x29, sp
/* ensure no context happens in the following code region
80d1c: 97ffffee bl 80cd4 <preempt_disable>
we still leave irq on, because irq handler may set a task to be TASK_RUNNING, which
will be picked up by the scheduler below */
preempt_disable();
int next,c;
80d20: 12800000 mov w0, #0xffffffff // #-1
80d24: b9002ba0 str w0, [x29, #40]
struct task_struct * p;
80d28: b9002fbf str wzr, [x29, #44]
while (1) {
80d2c: b90027bf str wzr, [x29, #36]
80d30: 1400001a b 80d98 <_schedule+0x84>
c = -1; // the maximum counter of all tasks
80d34: f0000000 adrp x0, 83000 <cpu_switch_to+0x1d8>
80d38: 9107e000 add x0, x0, #0x1f8
80d3c: b98027a1 ldrsw x1, [x29, #36]
80d40: f8617800 ldr x0, [x0, x1, lsl #3]
80d44: f9000fa0 str x0, [x29, #24]
next = 0;
80d48: f9400fa0 ldr x0, [x29, #24]
80d4c: f100001f cmp x0, #0x0
80d50: 540001e0 b.eq 80d8c <_schedule+0x78> // b.none
80d54: f9400fa0 ldr x0, [x29, #24]
80d58: f9403400 ldr x0, [x0, #104]
80d5c: f100001f cmp x0, #0x0
80d60: 54000161 b.ne 80d8c <_schedule+0x78> // b.any
80d64: f9400fa0 ldr x0, [x29, #24]
80d68: f9403801 ldr x1, [x0, #112]
80d6c: b9802ba0 ldrsw x0, [x29, #40]
80d70: eb00003f cmp x1, x0
80d74: 540000cd b.le 80d8c <_schedule+0x78>
80d78: f9400fa0 ldr x0, [x29, #24]
80d7c: f9403800 ldr x0, [x0, #112]
80d80: b9002ba0 str w0, [x29, #40]
/* Iterates over all tasks and tries to find a task in
80d84: b94027a0 ldr w0, [x29, #36]
80d88: b9002fa0 str w0, [x29, #44]
while (1) {
80d8c: b94027a0 ldr w0, [x29, #36]
80d90: 11000400 add w0, w0, #0x1
80d94: b90027a0 str w0, [x29, #36]
80d98: b94027a0 ldr w0, [x29, #36]
80d9c: 7100fc1f cmp w0, #0x3f
80da0: 54fffcad b.le 80d34 <_schedule+0x20>
TASK_RUNNING state with the maximum counter. If such
a task is found, we immediately break from the while loop
and switch to this task. */
80da4: b9402ba0 ldr w0, [x29, #40]
80da8: 7100001f cmp w0, #0x0
80dac: 54000341 b.ne 80e14 <_schedule+0x100> // b.any
for (int i = 0; i < NR_TASKS; i++){
p = task[i];
80db0: b90023bf str wzr, [x29, #32]
80db4: 14000014 b 80e04 <_schedule+0xf0>
if (p && p->state == TASK_RUNNING && p->counter > c) {
80db8: f0000000 adrp x0, 83000 <cpu_switch_to+0x1d8>
80dbc: 9107e000 add x0, x0, #0x1f8
80dc0: b98023a1 ldrsw x1, [x29, #32]
80dc4: f8617800 ldr x0, [x0, x1, lsl #3]
80dc8: f9000fa0 str x0, [x29, #24]
c = p->counter;
80dcc: f9400fa0 ldr x0, [x29, #24]
80dd0: f100001f cmp x0, #0x0
80dd4: 54000120 b.eq 80df8 <_schedule+0xe4> // b.none
next = i;
80dd8: f9400fa0 ldr x0, [x29, #24]
80ddc: f9403800 ldr x0, [x0, #112]
80de0: 9341fc01 asr x1, x0, #1
80de4: f9400fa0 ldr x0, [x29, #24]
80de8: f9403c00 ldr x0, [x0, #120]
80dec: 8b000021 add x1, x1, x0
80df0: f9400fa0 ldr x0, [x29, #24]
80df4: f9003801 str x1, [x0, #112]
p = task[i];
80df8: b94023a0 ldr w0, [x29, #32]
80dfc: 11000400 add w0, w0, #0x1
80e00: b90023a0 str w0, [x29, #32]
80e04: b94023a0 ldr w0, [x29, #32]
80e08: 7100fc1f cmp w0, #0x3f
80e0c: 54fffd6d b.le 80db8 <_schedule+0xa4>
int next,c;
80e10: 17ffffc4 b 80d20 <_schedule+0xc>
80e14: d503201f nop
}
}
if (c) {
break;
80e18: f0000000 adrp x0, 83000 <cpu_switch_to+0x1d8>
80e1c: 9107e000 add x0, x0, #0x1f8
80e20: b9802fa1 ldrsw x1, [x29, #44]
80e24: f8617800 ldr x0, [x0, x1, lsl #3]
80e28: 9400000f bl 80e64 <switch_to>
}
80e2c: 97ffffb2 bl 80cf4 <preempt_enable>
80e30: d503201f nop
80e34: a8c37bfd ldp x29, x30, [sp], #48
80e38: d65f03c0 ret
0000000000080e3c <schedule>:
/* If no such task is found, this is either because i) no
task is in TASK_RUNNING state or ii) all such tasks have 0 counters.
in our current implemenation which misses TASK_WAIT, only condition ii) is possible.
80e3c: a9bf7bfd stp x29, x30, [sp, #-16]!
80e40: 910003fd mov x29, sp
Hence, we recharge counters. Bump counters for all tasks once. */
80e44: f0000000 adrp x0, 83000 <cpu_switch_to+0x1d8>
80e48: 9107c000 add x0, x0, #0x1f0
80e4c: f9400000 ldr x0, [x0]
80e50: f900381f str xzr, [x0, #112]
80e54: 97ffffb0 bl 80d14 <_schedule>
for (int i = 0; i < NR_TASKS; i++) {
80e58: d503201f nop
80e5c: a8c17bfd ldp x29, x30, [sp], #16
80e60: d65f03c0 ret
0000000000080e64 <switch_to>:
p = task[i];
if (p) {
p->counter = (p->counter >> 1) + p->priority;
80e64: a9bd7bfd stp x29, x30, [sp, #-48]!
80e68: 910003fd mov x29, sp
80e6c: f9000fa0 str x0, [x29, #24]
}
80e70: f0000000 adrp x0, 83000 <cpu_switch_to+0x1d8>
80e74: 9107c000 add x0, x0, #0x1f0
80e78: f9400000 ldr x0, [x0]
80e7c: f9400fa1 ldr x1, [x29, #24]
80e80: eb00003f cmp x1, x0
80e84: 540001a0 b.eq 80eb8 <switch_to+0x54> // b.none
}
}
80e88: f0000000 adrp x0, 83000 <cpu_switch_to+0x1d8>
80e8c: 9107c000 add x0, x0, #0x1f0
80e90: f9400000 ldr x0, [x0]
80e94: f90017a0 str x0, [x29, #40]
switch_to(task[next]);
80e98: f0000000 adrp x0, 83000 <cpu_switch_to+0x1d8>
80e9c: 9107c000 add x0, x0, #0x1f0
80ea0: f9400fa1 ldr x1, [x29, #24]
80ea4: f9000001 str x1, [x0]
preempt_enable();
80ea8: f9400fa1 ldr x1, [x29, #24]
80eac: f94017a0 ldr x0, [x29, #40]
80eb0: 940007de bl 82e28 <cpu_switch_to>
80eb4: 14000002 b 80ebc <switch_to+0x58>
}
80eb8: d503201f nop
}
80ebc: a8c37bfd ldp x29, x30, [sp], #48
80ec0: d65f03c0 ret
0000000000080ec4 <schedule_tail>:
void schedule(void)
80ec4: a9bf7bfd stp x29, x30, [sp, #-16]!
80ec8: 910003fd mov x29, sp
{
80ecc: 97ffff8a bl 80cf4 <preempt_enable>
current->counter = 0;
80ed0: d503201f nop
80ed4: a8c17bfd ldp x29, x30, [sp], #16
80ed8: d65f03c0 ret
0000000000080edc <timer_tick>:
_schedule();
}
void switch_to(struct task_struct * next)
80edc: a9bf7bfd stp x29, x30, [sp, #-16]!
80ee0: 910003fd mov x29, sp
{
80ee4: f0000000 adrp x0, 83000 <cpu_switch_to+0x1d8>
80ee8: 9107c000 add x0, x0, #0x1f0
80eec: f9400000 ldr x0, [x0]
80ef0: f9403801 ldr x1, [x0, #112]
80ef4: d1000421 sub x1, x1, #0x1
80ef8: f9003801 str x1, [x0, #112]
if (current == next)
80efc: f0000000 adrp x0, 83000 <cpu_switch_to+0x1d8>
80f00: 9107c000 add x0, x0, #0x1f0
80f04: f9400000 ldr x0, [x0]
80f08: f9403800 ldr x0, [x0, #112]
80f0c: f100001f cmp x0, #0x0
80f10: 540001ec b.gt 80f4c <timer_tick+0x70>
80f14: f0000000 adrp x0, 83000 <cpu_switch_to+0x1d8>
80f18: 9107c000 add x0, x0, #0x1f0
80f1c: f9400000 ldr x0, [x0]
80f20: f9404000 ldr x0, [x0, #128]
80f24: f100001f cmp x0, #0x0
80f28: 5400012c b.gt 80f4c <timer_tick+0x70>
return;
struct task_struct * prev = current;
current = next;
80f2c: f0000000 adrp x0, 83000 <cpu_switch_to+0x1d8>
80f30: 9107c000 add x0, x0, #0x1f0
80f34: f9400000 ldr x0, [x0]
80f38: f900381f str xzr, [x0, #112]
cpu_switch_to(prev, next);
80f3c: 940002f7 bl 81b18 <enable_irq>
}
80f40: 97ffff75 bl 80d14 <_schedule>
80f44: 940002f7 bl 81b20 <disable_irq>
80f48: 14000002 b 80f50 <timer_tick+0x74>
return;
80f4c: d503201f nop
void schedule_tail(void) {
80f50: a8c17bfd ldp x29, x30, [sp], #16
80f54: d65f03c0 ret
0000000000080f58 <copy_process>:
#include "mm.h"
#include "sched.h"
#include "entry.h"
int copy_process(unsigned long fn, unsigned long arg)
{
80f58: a9bd7bfd stp x29, x30, [sp, #-48]!
80f5c: 910003fd mov x29, sp
80f60: f9000fa0 str x0, [x29, #24]
80f64: f9000ba1 str x1, [x29, #16]
preempt_disable();
80f68: 97ffff5b bl 80cd4 <preempt_disable>
struct task_struct *p;
p = (struct task_struct *) get_free_page();
80f6c: 97fffeaa bl 80a14 <get_free_page>
80f70: f90017a0 str x0, [x29, #40]
if (!p)
80f74: f94017a0 ldr x0, [x29, #40]
80f78: f100001f cmp x0, #0x0
80f7c: 54000061 b.ne 80f88 <copy_process+0x30> // b.any
return 1;
80f80: 52800020 mov w0, #0x1 // #1
80f84: 1400002d b 81038 <copy_process+0xe0>
p->priority = current->priority;
80f88: f0000000 adrp x0, 83000 <cpu_switch_to+0x1d8>
80f8c: f9409800 ldr x0, [x0, #304]
80f90: f9400000 ldr x0, [x0]
80f94: f9403c01 ldr x1, [x0, #120]
80f98: f94017a0 ldr x0, [x29, #40]
80f9c: f9003c01 str x1, [x0, #120]
p->state = TASK_RUNNING;
80fa0: f94017a0 ldr x0, [x29, #40]
80fa4: f900341f str xzr, [x0, #104]
p->counter = p->priority;
80fa8: f94017a0 ldr x0, [x29, #40]
80fac: f9403c01 ldr x1, [x0, #120]
80fb0: f94017a0 ldr x0, [x29, #40]
80fb4: f9003801 str x1, [x0, #112]
p->preempt_count = 1; //disable preemtion until schedule_tail
80fb8: f94017a0 ldr x0, [x29, #40]
80fbc: d2800021 mov x1, #0x1 // #1
80fc0: f9004001 str x1, [x0, #128]
p->cpu_context.x19 = fn;
80fc4: f94017a0 ldr x0, [x29, #40]
80fc8: f9400fa1 ldr x1, [x29, #24]
80fcc: f9000001 str x1, [x0]
p->cpu_context.x20 = arg;
80fd0: f94017a0 ldr x0, [x29, #40]
80fd4: f9400ba1 ldr x1, [x29, #16]
80fd8: f9000401 str x1, [x0, #8]
p->cpu_context.pc = (unsigned long)ret_from_fork;
80fdc: f0000000 adrp x0, 83000 <cpu_switch_to+0x1d8>
80fe0: f940a801 ldr x1, [x0, #336]
80fe4: f94017a0 ldr x0, [x29, #40]
80fe8: f9003001 str x1, [x0, #96]
p->cpu_context.sp = (unsigned long)p + THREAD_SIZE;
80fec: f94017a0 ldr x0, [x29, #40]
80ff0: 91400401 add x1, x0, #0x1, lsl #12
80ff4: f94017a0 ldr x0, [x29, #40]
80ff8: f9002c01 str x1, [x0, #88]
int pid = nr_tasks++;
80ffc: f0000000 adrp x0, 83000 <cpu_switch_to+0x1d8>
81000: f9409c00 ldr x0, [x0, #312]
81004: b9400000 ldr w0, [x0]
81008: 11000402 add w2, w0, #0x1
8100c: d0000001 adrp x1, 83000 <cpu_switch_to+0x1d8>
81010: f9409c21 ldr x1, [x1, #312]
81014: b9000022 str w2, [x1]
81018: b90027a0 str w0, [x29, #36]
task[pid] = p;
8101c: d0000000 adrp x0, 83000 <cpu_switch_to+0x1d8>
81020: f940a000 ldr x0, [x0, #320]
81024: b98027a1 ldrsw x1, [x29, #36]
81028: f94017a2 ldr x2, [x29, #40]
8102c: f8217802 str x2, [x0, x1, lsl #3]
preempt_enable();
81030: 97ffff31 bl 80cf4 <preempt_enable>
return 0;
81034: 52800000 mov w0, #0x0 // #0
}
81038: a8c37bfd ldp x29, x30, [sp], #48
8103c: d65f03c0 ret
0000000000081040 <ui2a>:
}
#endif
static void ui2a(unsigned int num, unsigned int base, int uc,char * bf)
{
81040: d100c3ff sub sp, sp, #0x30
81044: b9001fe0 str w0, [sp, #28]
81048: b9001be1 str w1, [sp, #24]
8104c: b90017e2 str w2, [sp, #20]
81050: f90007e3 str x3, [sp, #8]
int n=0;
81054: b9002fff str wzr, [sp, #44]
unsigned int d=1;
81058: 52800020 mov w0, #0x1 // #1
8105c: b9002be0 str w0, [sp, #40]
while (num/d >= base)
81060: 14000005 b 81074 <ui2a+0x34>
d*=base;
81064: b9402be1 ldr w1, [sp, #40]
81068: b9401be0 ldr w0, [sp, #24]
8106c: 1b007c20 mul w0, w1, w0
81070: b9002be0 str w0, [sp, #40]
while (num/d >= base)
81074: b9401fe1 ldr w1, [sp, #28]
81078: b9402be0 ldr w0, [sp, #40]
8107c: 1ac00820 udiv w0, w1, w0
81080: b9401be1 ldr w1, [sp, #24]
81084: 6b00003f cmp w1, w0
81088: 54fffee9 b.ls 81064 <ui2a+0x24> // b.plast
while (d!=0) {
8108c: 1400002f b 81148 <ui2a+0x108>
int dgt = num / d;
81090: b9401fe1 ldr w1, [sp, #28]
81094: b9402be0 ldr w0, [sp, #40]
81098: 1ac00820 udiv w0, w1, w0
8109c: b90027e0 str w0, [sp, #36]
num%= d;
810a0: b9401fe0 ldr w0, [sp, #28]
810a4: b9402be1 ldr w1, [sp, #40]
810a8: 1ac10802 udiv w2, w0, w1
810ac: b9402be1 ldr w1, [sp, #40]
810b0: 1b017c41 mul w1, w2, w1
810b4: 4b010000 sub w0, w0, w1
810b8: b9001fe0 str w0, [sp, #28]
d/=base;
810bc: b9402be1 ldr w1, [sp, #40]
810c0: b9401be0 ldr w0, [sp, #24]
810c4: 1ac00820 udiv w0, w1, w0
810c8: b9002be0 str w0, [sp, #40]
if (n || dgt>0 || d==0) {
810cc: b9402fe0 ldr w0, [sp, #44]
810d0: 7100001f cmp w0, #0x0
810d4: 540000e1 b.ne 810f0 <ui2a+0xb0> // b.any
810d8: b94027e0 ldr w0, [sp, #36]
810dc: 7100001f cmp w0, #0x0
810e0: 5400008c b.gt 810f0 <ui2a+0xb0>
810e4: b9402be0 ldr w0, [sp, #40]
810e8: 7100001f cmp w0, #0x0
810ec: 540002e1 b.ne 81148 <ui2a+0x108> // b.any
*bf++ = dgt+(dgt<10 ? '0' : (uc ? 'A' : 'a')-10);
810f0: b94027e0 ldr w0, [sp, #36]
810f4: 7100241f cmp w0, #0x9
810f8: 5400010d b.le 81118 <ui2a+0xd8>
810fc: b94017e0 ldr w0, [sp, #20]
81100: 7100001f cmp w0, #0x0
81104: 54000060 b.eq 81110 <ui2a+0xd0> // b.none
81108: 528006e0 mov w0, #0x37 // #55
8110c: 14000004 b 8111c <ui2a+0xdc>
81110: 52800ae0 mov w0, #0x57 // #87
81114: 14000002 b 8111c <ui2a+0xdc>
81118: 52800600 mov w0, #0x30 // #48
8111c: b94027e1 ldr w1, [sp, #36]
81120: 12001c22 and w2, w1, #0xff
81124: f94007e1 ldr x1, [sp, #8]
81128: 91000423 add x3, x1, #0x1
8112c: f90007e3 str x3, [sp, #8]
81130: 0b020000 add w0, w0, w2
81134: 12001c00 and w0, w0, #0xff
81138: 39000020 strb w0, [x1]
++n;
8113c: b9402fe0 ldr w0, [sp, #44]
81140: 11000400 add w0, w0, #0x1
81144: b9002fe0 str w0, [sp, #44]
while (d!=0) {
81148: b9402be0 ldr w0, [sp, #40]
8114c: 7100001f cmp w0, #0x0
81150: 54fffa01 b.ne 81090 <ui2a+0x50> // b.any
}
}
*bf=0;
81154: f94007e0 ldr x0, [sp, #8]
81158: 3900001f strb wzr, [x0]
}
8115c: d503201f nop
81160: 9100c3ff add sp, sp, #0x30
81164: d65f03c0 ret
0000000000081168 <i2a>:
static void i2a (int num, char * bf)
{
81168: a9be7bfd stp x29, x30, [sp, #-32]!
8116c: 910003fd mov x29, sp
81170: b9001fa0 str w0, [x29, #28]
81174: f9000ba1 str x1, [x29, #16]
if (num<0) {
81178: b9401fa0 ldr w0, [x29, #28]
8117c: 7100001f cmp w0, #0x0
81180: 5400012a b.ge 811a4 <i2a+0x3c> // b.tcont
num=-num;
81184: b9401fa0 ldr w0, [x29, #28]
81188: 4b0003e0 neg w0, w0
8118c: b9001fa0 str w0, [x29, #28]
*bf++ = '-';
81190: f9400ba0 ldr x0, [x29, #16]
81194: 91000401 add x1, x0, #0x1
81198: f9000ba1 str x1, [x29, #16]
8119c: 528005a1 mov w1, #0x2d // #45
811a0: 39000001 strb w1, [x0]
}
ui2a(num,10,0,bf);
811a4: b9401fa0 ldr w0, [x29, #28]
811a8: f9400ba3 ldr x3, [x29, #16]
811ac: 52800002 mov w2, #0x0 // #0
811b0: 52800141 mov w1, #0xa // #10
811b4: 97ffffa3 bl 81040 <ui2a>
}
811b8: d503201f nop
811bc: a8c27bfd ldp x29, x30, [sp], #32
811c0: d65f03c0 ret
00000000000811c4 <a2d>:
static int a2d(char ch)
{
811c4: d10043ff sub sp, sp, #0x10
811c8: 39003fe0 strb w0, [sp, #15]
if (ch>='0' && ch<='9')
811cc: 39403fe0 ldrb w0, [sp, #15]
811d0: 7100bc1f cmp w0, #0x2f
811d4: 540000e9 b.ls 811f0 <a2d+0x2c> // b.plast
811d8: 39403fe0 ldrb w0, [sp, #15]
811dc: 7100e41f cmp w0, #0x39
811e0: 54000088 b.hi 811f0 <a2d+0x2c> // b.pmore
return ch-'0';
811e4: 39403fe0 ldrb w0, [sp, #15]
811e8: 5100c000 sub w0, w0, #0x30
811ec: 14000014 b 8123c <a2d+0x78>
else if (ch>='a' && ch<='f')
811f0: 39403fe0 ldrb w0, [sp, #15]
811f4: 7101801f cmp w0, #0x60
811f8: 540000e9 b.ls 81214 <a2d+0x50> // b.plast
811fc: 39403fe0 ldrb w0, [sp, #15]
81200: 7101981f cmp w0, #0x66
81204: 54000088 b.hi 81214 <a2d+0x50> // b.pmore
return ch-'a'+10;
81208: 39403fe0 ldrb w0, [sp, #15]
8120c: 51015c00 sub w0, w0, #0x57
81210: 1400000b b 8123c <a2d+0x78>
else if (ch>='A' && ch<='F')
81214: 39403fe0 ldrb w0, [sp, #15]
81218: 7101001f cmp w0, #0x40
8121c: 540000e9 b.ls 81238 <a2d+0x74> // b.plast
81220: 39403fe0 ldrb w0, [sp, #15]
81224: 7101181f cmp w0, #0x46
81228: 54000088 b.hi 81238 <a2d+0x74> // b.pmore
return ch-'A'+10;
8122c: 39403fe0 ldrb w0, [sp, #15]
81230: 5100dc00 sub w0, w0, #0x37
81234: 14000002 b 8123c <a2d+0x78>
else return -1;
81238: 12800000 mov w0, #0xffffffff // #-1
}
8123c: 910043ff add sp, sp, #0x10
81240: d65f03c0 ret
0000000000081244 <a2i>:
static char a2i(char ch, char** src,int base,int* nump)
{
81244: a9bc7bfd stp x29, x30, [sp, #-64]!
81248: 910003fd mov x29, sp
8124c: 3900bfa0 strb w0, [x29, #47]
81250: f90013a1 str x1, [x29, #32]
81254: b9002ba2 str w2, [x29, #40]
81258: f9000fa3 str x3, [x29, #24]
char* p= *src;
8125c: f94013a0 ldr x0, [x29, #32]
81260: f9400000 ldr x0, [x0]
81264: f9001fa0 str x0, [x29, #56]
int num=0;
81268: b90037bf str wzr, [x29, #52]
int digit;
while ((digit=a2d(ch))>=0) {
8126c: 14000010 b 812ac <a2i+0x68>
if (digit>base) break;
81270: b94033a1 ldr w1, [x29, #48]
81274: b9402ba0 ldr w0, [x29, #40]
81278: 6b00003f cmp w1, w0
8127c: 5400026c b.gt 812c8 <a2i+0x84>
num=num*base+digit;
81280: b94037a1 ldr w1, [x29, #52]
81284: b9402ba0 ldr w0, [x29, #40]
81288: 1b007c20 mul w0, w1, w0
8128c: b94033a1 ldr w1, [x29, #48]
81290: 0b000020 add w0, w1, w0
81294: b90037a0 str w0, [x29, #52]
ch=*p++;
81298: f9401fa0 ldr x0, [x29, #56]
8129c: 91000401 add x1, x0, #0x1
812a0: f9001fa1 str x1, [x29, #56]
812a4: 39400000 ldrb w0, [x0]
812a8: 3900bfa0 strb w0, [x29, #47]
while ((digit=a2d(ch))>=0) {
812ac: 3940bfa0 ldrb w0, [x29, #47]
812b0: 97ffffc5 bl 811c4 <a2d>
812b4: b90033a0 str w0, [x29, #48]
812b8: b94033a0 ldr w0, [x29, #48]
812bc: 7100001f cmp w0, #0x0
812c0: 54fffd8a b.ge 81270 <a2i+0x2c> // b.tcont
812c4: 14000002 b 812cc <a2i+0x88>
if (digit>base) break;
812c8: d503201f nop
}
*src=p;
812cc: f94013a0 ldr x0, [x29, #32]
812d0: f9401fa1 ldr x1, [x29, #56]
812d4: f9000001 str x1, [x0]
*nump=num;
812d8: f9400fa0 ldr x0, [x29, #24]
812dc: b94037a1 ldr w1, [x29, #52]
812e0: b9000001 str w1, [x0]
return ch;
812e4: 3940bfa0 ldrb w0, [x29, #47]
}
812e8: a8c47bfd ldp x29, x30, [sp], #64
812ec: d65f03c0 ret
00000000000812f0 <putchw>:
static void putchw(void* putp,putcf putf,int n, char z, char* bf)
{
812f0: a9bc7bfd stp x29, x30, [sp, #-64]!
812f4: 910003fd mov x29, sp
812f8: f90017a0 str x0, [x29, #40]
812fc: f90013a1 str x1, [x29, #32]
81300: b9001fa2 str w2, [x29, #28]
81304: 39006fa3 strb w3, [x29, #27]
81308: f9000ba4 str x4, [x29, #16]
char fc=z? '0' : ' ';
8130c: 39406fa0 ldrb w0, [x29, #27]
81310: 7100001f cmp w0, #0x0
81314: 54000060 b.eq 81320 <putchw+0x30> // b.none
81318: 52800600 mov w0, #0x30 // #48
8131c: 14000002 b 81324 <putchw+0x34>
81320: 52800400 mov w0, #0x20 // #32
81324: 3900dfa0 strb w0, [x29, #55]
char ch;
char* p=bf;
81328: f9400ba0 ldr x0, [x29, #16]
8132c: f9001fa0 str x0, [x29, #56]
while (*p++ && n > 0)
81330: 14000004 b 81340 <putchw+0x50>
n--;
81334: b9401fa0 ldr w0, [x29, #28]
81338: 51000400 sub w0, w0, #0x1
8133c: b9001fa0 str w0, [x29, #28]
while (*p++ && n > 0)
81340: f9401fa0 ldr x0, [x29, #56]
81344: 91000401 add x1, x0, #0x1
81348: f9001fa1 str x1, [x29, #56]
8134c: 39400000 ldrb w0, [x0]
81350: 7100001f cmp w0, #0x0
81354: 54000120 b.eq 81378 <putchw+0x88> // b.none
81358: b9401fa0 ldr w0, [x29, #28]
8135c: 7100001f cmp w0, #0x0
81360: 54fffeac b.gt 81334 <putchw+0x44>
while (n-- > 0)
81364: 14000005 b 81378 <putchw+0x88>
putf(putp,fc);
81368: f94013a2 ldr x2, [x29, #32]
8136c: 3940dfa1 ldrb w1, [x29, #55]
81370: f94017a0 ldr x0, [x29, #40]
81374: d63f0040 blr x2
while (n-- > 0)
81378: b9401fa0 ldr w0, [x29, #28]
8137c: 51000401 sub w1, w0, #0x1
81380: b9001fa1 str w1, [x29, #28]
81384: 7100001f cmp w0, #0x0
81388: 54ffff0c b.gt 81368 <putchw+0x78>
while ((ch= *bf++))
8138c: 14000005 b 813a0 <putchw+0xb0>
putf(putp,ch);
81390: f94013a2 ldr x2, [x29, #32]
81394: 3940dba1 ldrb w1, [x29, #54]
81398: f94017a0 ldr x0, [x29, #40]
8139c: d63f0040 blr x2
while ((ch= *bf++))
813a0: f9400ba0 ldr x0, [x29, #16]
813a4: 91000401 add x1, x0, #0x1
813a8: f9000ba1 str x1, [x29, #16]
813ac: 39400000 ldrb w0, [x0]
813b0: 3900dba0 strb w0, [x29, #54]
813b4: 3940dba0 ldrb w0, [x29, #54]
813b8: 7100001f cmp w0, #0x0
813bc: 54fffea1 b.ne 81390 <putchw+0xa0> // b.any
}
813c0: d503201f nop
813c4: a8c47bfd ldp x29, x30, [sp], #64
813c8: d65f03c0 ret
00000000000813cc <tfp_format>:
void tfp_format(void* putp,putcf putf,char *fmt, va_list va)
{
813cc: a9ba7bfd stp x29, x30, [sp, #-96]!
813d0: 910003fd mov x29, sp
813d4: f9000bf3 str x19, [sp, #16]
813d8: f9001fa0 str x0, [x29, #56]
813dc: f9001ba1 str x1, [x29, #48]
813e0: f90017a2 str x2, [x29, #40]
813e4: aa0303f3 mov x19, x3
char bf[12];
char ch;
while ((ch=*(fmt++))) {
813e8: 140000fd b 817dc <tfp_format+0x410>
if (ch!='%')
813ec: 39417fa0 ldrb w0, [x29, #95]
813f0: 7100941f cmp w0, #0x25
813f4: 540000c0 b.eq 8140c <tfp_format+0x40> // b.none
putf(putp,ch);
813f8: f9401ba2 ldr x2, [x29, #48]
813fc: 39417fa1 ldrb w1, [x29, #95]
81400: f9401fa0 ldr x0, [x29, #56]
81404: d63f0040 blr x2
81408: 140000f5 b 817dc <tfp_format+0x410>
else {
char lz=0;
8140c: 39017bbf strb wzr, [x29, #94]
#ifdef PRINTF_LONG_SUPPORT
char lng=0;
#endif
int w=0;
81410: b9004fbf str wzr, [x29, #76]
ch=*(fmt++);
81414: f94017a0 ldr x0, [x29, #40]
81418: 91000401 add x1, x0, #0x1
8141c: f90017a1 str x1, [x29, #40]
81420: 39400000 ldrb w0, [x0]
81424: 39017fa0 strb w0, [x29, #95]
if (ch=='0') {
81428: 39417fa0 ldrb w0, [x29, #95]
8142c: 7100c01f cmp w0, #0x30
81430: 54000101 b.ne 81450 <tfp_format+0x84> // b.any
ch=*(fmt++);
81434: f94017a0 ldr x0, [x29, #40]
81438: 91000401 add x1, x0, #0x1
8143c: f90017a1 str x1, [x29, #40]
81440: 39400000 ldrb w0, [x0]
81444: 39017fa0 strb w0, [x29, #95]
lz=1;
81448: 52800020 mov w0, #0x1 // #1
8144c: 39017ba0 strb w0, [x29, #94]
}
if (ch>='0' && ch<='9') {
81450: 39417fa0 ldrb w0, [x29, #95]
81454: 7100bc1f cmp w0, #0x2f
81458: 54000189 b.ls 81488 <tfp_format+0xbc> // b.plast
8145c: 39417fa0 ldrb w0, [x29, #95]
81460: 7100e41f cmp w0, #0x39
81464: 54000128 b.hi 81488 <tfp_format+0xbc> // b.pmore
ch=a2i(ch,&fmt,10,&w);
81468: 910133a1 add x1, x29, #0x4c
8146c: 9100a3a0 add x0, x29, #0x28
81470: aa0103e3 mov x3, x1
81474: 52800142 mov w2, #0xa // #10
81478: aa0003e1 mov x1, x0
8147c: 39417fa0 ldrb w0, [x29, #95]
81480: 97ffff71 bl 81244 <a2i>
81484: 39017fa0 strb w0, [x29, #95]
if (ch=='l') {
ch=*(fmt++);
lng=1;
}
#endif
switch (ch) {
81488: 39417fa0 ldrb w0, [x29, #95]
8148c: 71018c1f cmp w0, #0x63
81490: 540011c0 b.eq 816c8 <tfp_format+0x2fc> // b.none
81494: 71018c1f cmp w0, #0x63
81498: 5400010c b.gt 814b8 <tfp_format+0xec>
8149c: 7100941f cmp w0, #0x25
814a0: 54001940 b.eq 817c8 <tfp_format+0x3fc> // b.none
814a4: 7101601f cmp w0, #0x58
814a8: 54000b60 b.eq 81614 <tfp_format+0x248> // b.none
814ac: 7100001f cmp w0, #0x0
814b0: 54001a80 b.eq 81800 <tfp_format+0x434> // b.none
putchw(putp,putf,w,0,va_arg(va, char*));
break;
case '%' :
putf(putp,ch);
default:
break;
814b4: 140000c9 b 817d8 <tfp_format+0x40c>
switch (ch) {
814b8: 7101cc1f cmp w0, #0x73
814bc: 54001440 b.eq 81744 <tfp_format+0x378> // b.none
814c0: 7101cc1f cmp w0, #0x73
814c4: 5400008c b.gt 814d4 <tfp_format+0x108>
814c8: 7101901f cmp w0, #0x64
814cc: 540005c0 b.eq 81584 <tfp_format+0x1b8> // b.none
break;
814d0: 140000c2 b 817d8 <tfp_format+0x40c>
switch (ch) {
814d4: 7101d41f cmp w0, #0x75
814d8: 54000080 b.eq 814e8 <tfp_format+0x11c> // b.none
814dc: 7101e01f cmp w0, #0x78
814e0: 540009a0 b.eq 81614 <tfp_format+0x248> // b.none
break;
814e4: 140000bd b 817d8 <tfp_format+0x40c>
ui2a(va_arg(va, unsigned int),10,0,bf);
814e8: b9401a60 ldr w0, [x19, #24]
814ec: f9400261 ldr x1, [x19]
814f0: 7100001f cmp w0, #0x0
814f4: 540000eb b.lt 81510 <tfp_format+0x144> // b.tstop
814f8: aa0103e0 mov x0, x1
814fc: 91002c00 add x0, x0, #0xb
81500: 927df000 and x0, x0, #0xfffffffffffffff8
81504: f9000260 str x0, [x19]
81508: aa0103e0 mov x0, x1
8150c: 1400000f b 81548 <tfp_format+0x17c>
81510: 11002002 add w2, w0, #0x8
81514: b9001a62 str w2, [x19, #24]
81518: b9401a62 ldr w2, [x19, #24]
8151c: 7100005f cmp w2, #0x0
81520: 540000ed b.le 8153c <tfp_format+0x170>
81524: aa0103e0 mov x0, x1
81528: 91002c00 add x0, x0, #0xb
8152c: 927df000 and x0, x0, #0xfffffffffffffff8
81530: f9000260 str x0, [x19]
81534: aa0103e0 mov x0, x1
81538: 14000004 b 81548 <tfp_format+0x17c>
8153c: f9400661 ldr x1, [x19, #8]
81540: 93407c00 sxtw x0, w0
81544: 8b000020 add x0, x1, x0
81548: b9400000 ldr w0, [x0]
8154c: 910143a1 add x1, x29, #0x50
81550: aa0103e3 mov x3, x1
81554: 52800002 mov w2, #0x0 // #0
81558: 52800141 mov w1, #0xa // #10
8155c: 97fffeb9 bl 81040 <ui2a>
putchw(putp,putf,w,lz,bf);
81560: b9404fa0 ldr w0, [x29, #76]
81564: 910143a1 add x1, x29, #0x50
81568: aa0103e4 mov x4, x1
8156c: 39417ba3 ldrb w3, [x29, #94]
81570: 2a0003e2 mov w2, w0
81574: f9401ba1 ldr x1, [x29, #48]
81578: f9401fa0 ldr x0, [x29, #56]
8157c: 97ffff5d bl 812f0 <putchw>
break;
81580: 14000097 b 817dc <tfp_format+0x410>
i2a(va_arg(va, int),bf);
81584: b9401a60 ldr w0, [x19, #24]
81588: f9400261 ldr x1, [x19]
8158c: 7100001f cmp w0, #0x0
81590: 540000eb b.lt 815ac <tfp_format+0x1e0> // b.tstop
81594: aa0103e0 mov x0, x1
81598: 91002c00 add x0, x0, #0xb
8159c: 927df000 and x0, x0, #0xfffffffffffffff8
815a0: f9000260 str x0, [x19]
815a4: aa0103e0 mov x0, x1
815a8: 1400000f b 815e4 <tfp_format+0x218>
815ac: 11002002 add w2, w0, #0x8
815b0: b9001a62 str w2, [x19, #24]
815b4: b9401a62 ldr w2, [x19, #24]
815b8: 7100005f cmp w2, #0x0
815bc: 540000ed b.le 815d8 <tfp_format+0x20c>
815c0: aa0103e0 mov x0, x1
815c4: 91002c00 add x0, x0, #0xb
815c8: 927df000 and x0, x0, #0xfffffffffffffff8
815cc: f9000260 str x0, [x19]
815d0: aa0103e0 mov x0, x1
815d4: 14000004 b 815e4 <tfp_format+0x218>
815d8: f9400661 ldr x1, [x19, #8]
815dc: 93407c00 sxtw x0, w0
815e0: 8b000020 add x0, x1, x0
815e4: b9400000 ldr w0, [x0]
815e8: 910143a1 add x1, x29, #0x50
815ec: 97fffedf bl 81168 <i2a>
putchw(putp,putf,w,lz,bf);
815f0: b9404fa0 ldr w0, [x29, #76]
815f4: 910143a1 add x1, x29, #0x50
815f8: aa0103e4 mov x4, x1
815fc: 39417ba3 ldrb w3, [x29, #94]
81600: 2a0003e2 mov w2, w0
81604: f9401ba1 ldr x1, [x29, #48]
81608: f9401fa0 ldr x0, [x29, #56]
8160c: 97ffff39 bl 812f0 <putchw>
break;
81610: 14000073 b 817dc <tfp_format+0x410>
ui2a(va_arg(va, unsigned int),16,(ch=='X'),bf);
81614: b9401a60 ldr w0, [x19, #24]
81618: f9400261 ldr x1, [x19]
8161c: 7100001f cmp w0, #0x0
81620: 540000eb b.lt 8163c <tfp_format+0x270> // b.tstop
81624: aa0103e0 mov x0, x1
81628: 91002c00 add x0, x0, #0xb
8162c: 927df000 and x0, x0, #0xfffffffffffffff8
81630: f9000260 str x0, [x19]
81634: aa0103e0 mov x0, x1
81638: 1400000f b 81674 <tfp_format+0x2a8>
8163c: 11002002 add w2, w0, #0x8
81640: b9001a62 str w2, [x19, #24]
81644: b9401a62 ldr w2, [x19, #24]
81648: 7100005f cmp w2, #0x0
8164c: 540000ed b.le 81668 <tfp_format+0x29c>
81650: aa0103e0 mov x0, x1
81654: 91002c00 add x0, x0, #0xb
81658: 927df000 and x0, x0, #0xfffffffffffffff8
8165c: f9000260 str x0, [x19]
81660: aa0103e0 mov x0, x1
81664: 14000004 b 81674 <tfp_format+0x2a8>
81668: f9400661 ldr x1, [x19, #8]
8166c: 93407c00 sxtw x0, w0
81670: 8b000020 add x0, x1, x0
81674: b9400004 ldr w4, [x0]
81678: 39417fa0 ldrb w0, [x29, #95]
8167c: 7101601f cmp w0, #0x58
81680: 1a9f17e0 cset w0, eq // eq = none
81684: 12001c00 and w0, w0, #0xff
81688: 2a0003e1 mov w1, w0
8168c: 910143a0 add x0, x29, #0x50
81690: aa0003e3 mov x3, x0
81694: 2a0103e2 mov w2, w1
81698: 52800201 mov w1, #0x10 // #16
8169c: 2a0403e0 mov w0, w4
816a0: 97fffe68 bl 81040 <ui2a>
putchw(putp,putf,w,lz,bf);
816a4: b9404fa0 ldr w0, [x29, #76]
816a8: 910143a1 add x1, x29, #0x50
816ac: aa0103e4 mov x4, x1
816b0: 39417ba3 ldrb w3, [x29, #94]
816b4: 2a0003e2 mov w2, w0
816b8: f9401ba1 ldr x1, [x29, #48]
816bc: f9401fa0 ldr x0, [x29, #56]
816c0: 97ffff0c bl 812f0 <putchw>
break;
816c4: 14000046 b 817dc <tfp_format+0x410>
putf(putp,(char)(va_arg(va, int)));
816c8: b9401a60 ldr w0, [x19, #24]
816cc: f9400261 ldr x1, [x19]
816d0: 7100001f cmp w0, #0x0
816d4: 540000eb b.lt 816f0 <tfp_format+0x324> // b.tstop
816d8: aa0103e0 mov x0, x1
816dc: 91002c00 add x0, x0, #0xb
816e0: 927df000 and x0, x0, #0xfffffffffffffff8
816e4: f9000260 str x0, [x19]
816e8: aa0103e0 mov x0, x1
816ec: 1400000f b 81728 <tfp_format+0x35c>
816f0: 11002002 add w2, w0, #0x8
816f4: b9001a62 str w2, [x19, #24]
816f8: b9401a62 ldr w2, [x19, #24]
816fc: 7100005f cmp w2, #0x0
81700: 540000ed b.le 8171c <tfp_format+0x350>
81704: aa0103e0 mov x0, x1
81708: 91002c00 add x0, x0, #0xb
8170c: 927df000 and x0, x0, #0xfffffffffffffff8
81710: f9000260 str x0, [x19]
81714: aa0103e0 mov x0, x1
81718: 14000004 b 81728 <tfp_format+0x35c>
8171c: f9400661 ldr x1, [x19, #8]
81720: 93407c00 sxtw x0, w0
81724: 8b000020 add x0, x1, x0
81728: b9400000 ldr w0, [x0]
8172c: 12001c00 and w0, w0, #0xff
81730: f9401ba2 ldr x2, [x29, #48]
81734: 2a0003e1 mov w1, w0
81738: f9401fa0 ldr x0, [x29, #56]
8173c: d63f0040 blr x2
break;
81740: 14000027 b 817dc <tfp_format+0x410>
putchw(putp,putf,w,0,va_arg(va, char*));
81744: b9404fa5 ldr w5, [x29, #76]
81748: b9401a60 ldr w0, [x19, #24]
8174c: f9400261 ldr x1, [x19]
81750: 7100001f cmp w0, #0x0
81754: 540000eb b.lt 81770 <tfp_format+0x3a4> // b.tstop
81758: aa0103e0 mov x0, x1
8175c: 91003c00 add x0, x0, #0xf
81760: 927df000 and x0, x0, #0xfffffffffffffff8
81764: f9000260 str x0, [x19]
81768: aa0103e0 mov x0, x1
8176c: 1400000f b 817a8 <tfp_format+0x3dc>
81770: 11002002 add w2, w0, #0x8
81774: b9001a62 str w2, [x19, #24]
81778: b9401a62 ldr w2, [x19, #24]
8177c: 7100005f cmp w2, #0x0
81780: 540000ed b.le 8179c <tfp_format+0x3d0>
81784: aa0103e0 mov x0, x1
81788: 91003c00 add x0, x0, #0xf
8178c: 927df000 and x0, x0, #0xfffffffffffffff8
81790: f9000260 str x0, [x19]
81794: aa0103e0 mov x0, x1
81798: 14000004 b 817a8 <tfp_format+0x3dc>
8179c: f9400661 ldr x1, [x19, #8]
817a0: 93407c00 sxtw x0, w0
817a4: 8b000020 add x0, x1, x0
817a8: f9400000 ldr x0, [x0]
817ac: aa0003e4 mov x4, x0
817b0: 52800003 mov w3, #0x0 // #0
817b4: 2a0503e2 mov w2, w5
817b8: f9401ba1 ldr x1, [x29, #48]
817bc: f9401fa0 ldr x0, [x29, #56]
817c0: 97fffecc bl 812f0 <putchw>
break;
817c4: 14000006 b 817dc <tfp_format+0x410>
putf(putp,ch);
817c8: f9401ba2 ldr x2, [x29, #48]
817cc: 39417fa1 ldrb w1, [x29, #95]
817d0: f9401fa0 ldr x0, [x29, #56]
817d4: d63f0040 blr x2
break;
817d8: d503201f nop
while ((ch=*(fmt++))) {
817dc: f94017a0 ldr x0, [x29, #40]
817e0: 91000401 add x1, x0, #0x1
817e4: f90017a1 str x1, [x29, #40]
817e8: 39400000 ldrb w0, [x0]
817ec: 39017fa0 strb w0, [x29, #95]
817f0: 39417fa0 ldrb w0, [x29, #95]
817f4: 7100001f cmp w0, #0x0
817f8: 54ffdfa1 b.ne 813ec <tfp_format+0x20> // b.any
}
}
}
abort:;
817fc: 14000002 b 81804 <tfp_format+0x438>
goto abort;
81800: d503201f nop
}
81804: d503201f nop
81808: f9400bf3 ldr x19, [sp, #16]
8180c: a8c67bfd ldp x29, x30, [sp], #96
81810: d65f03c0 ret
0000000000081814 <init_printf>:
void init_printf(void* putp,void (*putf) (void*,char))
{
81814: d10043ff sub sp, sp, #0x10
81818: f90007e0 str x0, [sp, #8]
8181c: f90003e1 str x1, [sp]
stdout_putf=putf;
81820: f00003e0 adrp x0, 100000 <bss_begin+0x7cc08>
81824: 912fe000 add x0, x0, #0xbf8
81828: f94003e1 ldr x1, [sp]
8182c: f9000001 str x1, [x0]
stdout_putp=putp;
81830: f00003e0 adrp x0, 100000 <bss_begin+0x7cc08>
81834: 91300000 add x0, x0, #0xc00
81838: f94007e1 ldr x1, [sp, #8]
8183c: f9000001 str x1, [x0]
}
81840: d503201f nop
81844: 910043ff add sp, sp, #0x10
81848: d65f03c0 ret
000000000008184c <tfp_printf>:
void tfp_printf(char *fmt, ...)
{
8184c: a9b67bfd stp x29, x30, [sp, #-160]!
81850: 910003fd mov x29, sp
81854: f9001fa0 str x0, [x29, #56]
81858: f90037a1 str x1, [x29, #104]
8185c: f9003ba2 str x2, [x29, #112]
81860: f9003fa3 str x3, [x29, #120]
81864: f90043a4 str x4, [x29, #128]
81868: f90047a5 str x5, [x29, #136]
8186c: f9004ba6 str x6, [x29, #144]
81870: f9004fa7 str x7, [x29, #152]
va_list va;
va_start(va,fmt);
81874: 910283a0 add x0, x29, #0xa0
81878: f90023a0 str x0, [x29, #64]
8187c: 910283a0 add x0, x29, #0xa0
81880: f90027a0 str x0, [x29, #72]
81884: 910183a0 add x0, x29, #0x60
81888: f9002ba0 str x0, [x29, #80]
8188c: 128006e0 mov w0, #0xffffffc8 // #-56
81890: b9005ba0 str w0, [x29, #88]
81894: b9005fbf str wzr, [x29, #92]
tfp_format(stdout_putp,stdout_putf,fmt,va);
81898: f00003e0 adrp x0, 100000 <bss_begin+0x7cc08>
8189c: 91300000 add x0, x0, #0xc00
818a0: f9400004 ldr x4, [x0]
818a4: f00003e0 adrp x0, 100000 <bss_begin+0x7cc08>
818a8: 912fe000 add x0, x0, #0xbf8
818ac: f9400005 ldr x5, [x0]
818b0: 910043a2 add x2, x29, #0x10
818b4: 910103a3 add x3, x29, #0x40
818b8: a9400460 ldp x0, x1, [x3]
818bc: a9000440 stp x0, x1, [x2]
818c0: a9410460 ldp x0, x1, [x3, #16]
818c4: a9010440 stp x0, x1, [x2, #16]
818c8: 910043a0 add x0, x29, #0x10
818cc: aa0003e3 mov x3, x0
818d0: f9401fa2 ldr x2, [x29, #56]
818d4: aa0503e1 mov x1, x5
818d8: aa0403e0 mov x0, x4
818dc: 97fffebc bl 813cc <tfp_format>
va_end(va);
}
818e0: d503201f nop
818e4: a8ca7bfd ldp x29, x30, [sp], #160
818e8: d65f03c0 ret
00000000000818ec <putcp>:
static void putcp(void* p,char c)
{
818ec: d10043ff sub sp, sp, #0x10
818f0: f90007e0 str x0, [sp, #8]
818f4: 39001fe1 strb w1, [sp, #7]
*(*((char**)p))++ = c;
818f8: f94007e0 ldr x0, [sp, #8]
818fc: f9400000 ldr x0, [x0]
81900: 91000402 add x2, x0, #0x1
81904: f94007e1 ldr x1, [sp, #8]
81908: f9000022 str x2, [x1]
8190c: 39401fe1 ldrb w1, [sp, #7]
81910: 39000001 strb w1, [x0]
}
81914: d503201f nop
81918: 910043ff add sp, sp, #0x10
8191c: d65f03c0 ret
0000000000081920 <tfp_sprintf>:
void tfp_sprintf(char* s,char *fmt, ...)
{
81920: a9b77bfd stp x29, x30, [sp, #-144]!
81924: 910003fd mov x29, sp
81928: f9001fa0 str x0, [x29, #56]
8192c: f9001ba1 str x1, [x29, #48]
81930: f90033a2 str x2, [x29, #96]
81934: f90037a3 str x3, [x29, #104]
81938: f9003ba4 str x4, [x29, #112]
8193c: f9003fa5 str x5, [x29, #120]
81940: f90043a6 str x6, [x29, #128]
81944: f90047a7 str x7, [x29, #136]
va_list va;
va_start(va,fmt);
81948: 910243a0 add x0, x29, #0x90
8194c: f90023a0 str x0, [x29, #64]
81950: 910243a0 add x0, x29, #0x90
81954: f90027a0 str x0, [x29, #72]
81958: 910183a0 add x0, x29, #0x60
8195c: f9002ba0 str x0, [x29, #80]
81960: 128005e0 mov w0, #0xffffffd0 // #-48
81964: b9005ba0 str w0, [x29, #88]
81968: b9005fbf str wzr, [x29, #92]
tfp_format(&s,putcp,fmt,va);
8196c: 910043a2 add x2, x29, #0x10
81970: 910103a3 add x3, x29, #0x40
81974: a9400460 ldp x0, x1, [x3]
81978: a9000440 stp x0, x1, [x2]
8197c: a9410460 ldp x0, x1, [x3, #16]
81980: a9010440 stp x0, x1, [x2, #16]
81984: 910043a2 add x2, x29, #0x10
81988: 90000000 adrp x0, 81000 <copy_process+0xa8>
8198c: 9123b001 add x1, x0, #0x8ec
81990: 9100e3a0 add x0, x29, #0x38
81994: aa0203e3 mov x3, x2
81998: f9401ba2 ldr x2, [x29, #48]
8199c: 97fffe8c bl 813cc <tfp_format>
putcp(&s,0);
819a0: 9100e3a0 add x0, x29, #0x38
819a4: 52800001 mov w1, #0x0 // #0
819a8: 97ffffd1 bl 818ec <putcp>
va_end(va);
}
819ac: d503201f nop
819b0: a8c97bfd ldp x29, x30, [sp], #144
819b4: d65f03c0 ret
00000000000819b8 <timer_init>:
/* These are for Arm generic timer.
They are fully functional on both QEMU and Rpi3
Recommended.
*/
void generic_timer_init ( void )
819b8: a9bf7bfd stp x29, x30, [sp, #-16]!
819bc: 910003fd mov x29, sp
{
819c0: d2860080 mov x0, #0x3004 // #12292
819c4: f2a7e000 movk x0, #0x3f00, lsl #16
819c8: 9400004c bl 81af8 <get32>
819cc: 2a0003e1 mov w1, w0
819d0: f00003e0 adrp x0, 100000 <bss_begin+0x7cc08>
819d4: 91302000 add x0, x0, #0xc08
819d8: b9000001 str w1, [x0]
gen_timer_init();
819dc: f00003e0 adrp x0, 100000 <bss_begin+0x7cc08>
819e0: 91302000 add x0, x0, #0xc08
819e4: b9400001 ldr w1, [x0]
819e8: 5281a800 mov w0, #0xd40 // #3392
819ec: 72a00060 movk w0, #0x3, lsl #16
819f0: 0b000021 add w1, w1, w0
819f4: f00003e0 adrp x0, 100000 <bss_begin+0x7cc08>
819f8: 91302000 add x0, x0, #0xc08
819fc: b9000001 str w1, [x0]
gen_timer_reset();
81a00: f00003e0 adrp x0, 100000 <bss_begin+0x7cc08>
81a04: 91302000 add x0, x0, #0xc08
81a08: b9400000 ldr w0, [x0]
81a0c: 2a0003e1 mov w1, w0
81a10: d2860200 mov x0, #0x3010 // #12304
81a14: f2a7e000 movk x0, #0x3f00, lsl #16
81a18: 94000036 bl 81af0 <put32>
}
81a1c: d503201f nop
81a20: a8c17bfd ldp x29, x30, [sp], #16
81a24: d65f03c0 ret
0000000000081a28 <handle_timer_irq>:
void handle_generic_timer_irq( void )
{
81a28: a9bf7bfd stp x29, x30, [sp, #-16]!
81a2c: 910003fd mov x29, sp
gen_timer_reset();
81a30: f00003e0 adrp x0, 100000 <bss_begin+0x7cc08>
81a34: 91302000 add x0, x0, #0xc08
81a38: b9400001 ldr w1, [x0]
81a3c: 5281a800 mov w0, #0xd40 // #3392
81a40: 72a00060 movk w0, #0x3, lsl #16
81a44: 0b000021 add w1, w1, w0
81a48: f00003e0 adrp x0, 100000 <bss_begin+0x7cc08>
81a4c: 91302000 add x0, x0, #0xc08
81a50: b9000001 str w1, [x0]
timer_tick();
81a54: f00003e0 adrp x0, 100000 <bss_begin+0x7cc08>
81a58: 91302000 add x0, x0, #0xc08
81a5c: b9400000 ldr w0, [x0]
81a60: 2a0003e1 mov w1, w0
81a64: d2860200 mov x0, #0x3010 // #12304
81a68: f2a7e000 movk x0, #0x3f00, lsl #16
81a6c: 94000021 bl 81af0 <put32>
}
81a70: 52800041 mov w1, #0x2 // #2
81a74: d2860000 mov x0, #0x3000 // #12288
81a78: f2a7e000 movk x0, #0x3f00, lsl #16
81a7c: 9400001d bl 81af0 <put32>
81a80: 97fffd17 bl 80edc <timer_tick>
/*
81a84: d503201f nop
81a88: a8c17bfd ldp x29, x30, [sp], #16
81a8c: d65f03c0 ret
0000000000081a90 <generic_timer_init>:
These are for "System Timer". They are NOT in use by this project.
I leave the code here FYI.
Rpi3: System Timer works fine. Can generate intrerrupts and be used as a counter for timekeeping.
81a90: a9bf7bfd stp x29, x30, [sp, #-16]!
81a94: 910003fd mov x29, sp
QEMU: System Timer can be used for timekeeping. Cannot generate interrupts.
81a98: 9400000c bl 81ac8 <gen_timer_init>
See our documentation:
81a9c: 9400000e bl 81ad4 <gen_timer_reset>
https://fxlin.github.io/p1-kernel/lesson03/rpi-os/#fyi-other-timers-on-rpi3
81aa0: d503201f nop
81aa4: a8c17bfd ldp x29, x30, [sp], #16
81aa8: d65f03c0 ret
0000000000081aac <handle_generic_timer_irq>:
*/
const unsigned int interval = 200000;
81aac: a9bf7bfd stp x29, x30, [sp, #-16]!
81ab0: 910003fd mov x29, sp
unsigned int curVal = 0;
81ab4: 94000008 bl 81ad4 <gen_timer_reset>
81ab8: 97fffd09 bl 80edc <timer_tick>
void timer_init ( void )
81abc: d503201f nop
81ac0: a8c17bfd ldp x29, x30, [sp], #16
81ac4: d65f03c0 ret
0000000000081ac8 <gen_timer_init>:
* https://developer.arm.com/docs/ddi0487/ca/arm-architecture-reference-manual-armv8-for-armv8-a-architecture-profile
*/
.globl gen_timer_init
gen_timer_init:
mov x0, #1
81ac8: d2800020 mov x0, #0x1 // #1
msr CNTP_CTL_EL0, x0
81acc: d51be220 msr cntp_ctl_el0, x0
ret
81ad0: d65f03c0 ret
0000000000081ad4 <gen_timer_reset>:
.globl gen_timer_reset
gen_timer_reset:
mov x0, #1
81ad4: d2800020 mov x0, #0x1 // #1
lsl x0, x0, #24
81ad8: d3689c00 lsl x0, x0, #24
msr CNTP_TVAL_EL0, x0
81adc: d51be200 msr cntp_tval_el0, x0
81ae0: d65f03c0 ret
0000000000081ae4 <get_el>:
.globl get_el
get_el:
mrs x0, CurrentEL
81ae4: d5384240 mrs x0, currentel
lsr x0, x0, #2
81ae8: d342fc00 lsr x0, x0, #2
ret
81aec: d65f03c0 ret
0000000000081af0 <put32>:
.globl put32
put32:
str w1,[x0]
81af0: b9000001 str w1, [x0]
ret
81af4: d65f03c0 ret
0000000000081af8 <get32>:
.globl get32
get32:
ldr w0,[x0]
81af8: b9400000 ldr w0, [x0]
ret
81afc: d65f03c0 ret
0000000000081b00 <delay>:
.globl delay
delay:
subs x0, x0, #1
81b00: f1000400 subs x0, x0, #0x1
bne delay
81b04: 54ffffe1 b.ne 81b00 <delay> // b.any
ret
81b08: d65f03c0 ret
0000000000081b0c <irq_vector_init>:
.globl irq_vector_init
irq_vector_init:
adr x0, vectors // load VBAR_EL1 with virtual
81b0c: 100027a0 adr x0, 82000 <vectors>
msr vbar_el1, x0 // vector table address
81b10: d518c000 msr vbar_el1, x0
ret
81b14: d65f03c0 ret
0000000000081b18 <enable_irq>:
.globl enable_irq
enable_irq:
msr daifclr, #2
81b18: d50342ff msr daifclr, #0x2
ret
81b1c: d65f03c0 ret
0000000000081b20 <disable_irq>:
.globl disable_irq
disable_irq:
msr daifset, #2
81b20: d50342df msr daifset, #0x2
ret
81b24: d65f03c0 ret
...
0000000000082000 <vectors>:
* Exception vectors.
*/
.align 11
.globl vectors
vectors:
ventry sync_invalid_el1t // Synchronous EL1t
82000: 140001e1 b 82784 <sync_invalid_el1t>
82004: d503201f nop
82008: d503201f nop
8200c: d503201f nop
82010: d503201f nop
82014: d503201f nop
82018: d503201f nop
8201c: d503201f nop
82020: d503201f nop
82024: d503201f nop
82028: d503201f nop
8202c: d503201f nop
82030: d503201f nop
82034: d503201f nop
82038: d503201f nop
8203c: d503201f nop
82040: d503201f nop
82044: d503201f nop
82048: d503201f nop
8204c: d503201f nop
82050: d503201f nop
82054: d503201f nop
82058: d503201f nop
8205c: d503201f nop
82060: d503201f nop
82064: d503201f nop
82068: d503201f nop
8206c: d503201f nop
82070: d503201f nop
82074: d503201f nop
82078: d503201f nop
8207c: d503201f nop
ventry irq_invalid_el1t // IRQ EL1t
82080: 140001da b 827e8 <irq_invalid_el1t>
82084: d503201f nop
82088: d503201f nop
8208c: d503201f nop
82090: d503201f nop
82094: d503201f nop
82098: d503201f nop
8209c: d503201f nop
820a0: d503201f nop
820a4: d503201f nop
820a8: d503201f nop
820ac: d503201f nop
820b0: d503201f nop
820b4: d503201f nop
820b8: d503201f nop
820bc: d503201f nop
820c0: d503201f nop
820c4: d503201f nop
820c8: d503201f nop
820cc: d503201f nop
820d0: d503201f nop
820d4: d503201f nop
820d8: d503201f nop
820dc: d503201f nop
820e0: d503201f nop
820e4: d503201f nop
820e8: d503201f nop
820ec: d503201f nop
820f0: d503201f nop
820f4: d503201f nop
820f8: d503201f nop
820fc: d503201f nop
ventry fiq_invalid_el1t // FIQ EL1t
82100: 140001d3 b 8284c <fiq_invalid_el1t>
82104: d503201f nop
82108: d503201f nop
8210c: d503201f nop
82110: d503201f nop
82114: d503201f nop
82118: d503201f nop
8211c: d503201f nop
82120: d503201f nop
82124: d503201f nop
82128: d503201f nop
8212c: d503201f nop
82130: d503201f nop
82134: d503201f nop
82138: d503201f nop
8213c: d503201f nop
82140: d503201f nop
82144: d503201f nop
82148: d503201f nop
8214c: d503201f nop
82150: d503201f nop
82154: d503201f nop
82158: d503201f nop
8215c: d503201f nop
82160: d503201f nop
82164: d503201f nop
82168: d503201f nop
8216c: d503201f nop
82170: d503201f nop
82174: d503201f nop
82178: d503201f nop
8217c: d503201f nop
ventry error_invalid_el1t // Error EL1t
82180: 140001cc b 828b0 <error_invalid_el1t>
82184: d503201f nop
82188: d503201f nop
8218c: d503201f nop
82190: d503201f nop
82194: d503201f nop
82198: d503201f nop
8219c: d503201f nop
821a0: d503201f nop
821a4: d503201f nop
821a8: d503201f nop
821ac: d503201f nop
821b0: d503201f nop
821b4: d503201f nop
821b8: d503201f nop
821bc: d503201f nop
821c0: d503201f nop
821c4: d503201f nop
821c8: d503201f nop
821cc: d503201f nop
821d0: d503201f nop
821d4: d503201f nop
821d8: d503201f nop
821dc: d503201f nop
821e0: d503201f nop
821e4: d503201f nop
821e8: d503201f nop
821ec: d503201f nop
821f0: d503201f nop
821f4: d503201f nop
821f8: d503201f nop
821fc: d503201f nop
ventry sync_invalid_el1h // Synchronous EL1h
82200: 140001c5 b 82914 <sync_invalid_el1h>
82204: d503201f nop
82208: d503201f nop
8220c: d503201f nop
82210: d503201f nop
82214: d503201f nop
82218: d503201f nop
8221c: d503201f nop
82220: d503201f nop
82224: d503201f nop
82228: d503201f nop
8222c: d503201f nop
82230: d503201f nop
82234: d503201f nop
82238: d503201f nop
8223c: d503201f nop
82240: d503201f nop
82244: d503201f nop
82248: d503201f nop
8224c: d503201f nop
82250: d503201f nop
82254: d503201f nop
82258: d503201f nop
8225c: d503201f nop
82260: d503201f nop
82264: d503201f nop
82268: d503201f nop
8226c: d503201f nop
82270: d503201f nop
82274: d503201f nop
82278: d503201f nop
8227c: d503201f nop
ventry el1_irq // IRQ EL1h
82280: 140002b8 b 82d60 <el1_irq>
82284: d503201f nop
82288: d503201f nop
8228c: d503201f nop
82290: d503201f nop
82294: d503201f nop
82298: d503201f nop
8229c: d503201f nop
822a0: d503201f nop
822a4: d503201f nop
822a8: d503201f nop
822ac: d503201f nop
822b0: d503201f nop
822b4: d503201f nop
822b8: d503201f nop
822bc: d503201f nop
822c0: d503201f nop
822c4: d503201f nop
822c8: d503201f nop
822cc: d503201f nop
822d0: d503201f nop
822d4: d503201f nop
822d8: d503201f nop
822dc: d503201f nop
822e0: d503201f nop
822e4: d503201f nop
822e8: d503201f nop
822ec: d503201f nop
822f0: d503201f nop
822f4: d503201f nop
822f8: d503201f nop
822fc: d503201f nop
ventry fiq_invalid_el1h // FIQ EL1h
82300: 1400019e b 82978 <fiq_invalid_el1h>
82304: d503201f nop
82308: d503201f nop
8230c: d503201f nop
82310: d503201f nop
82314: d503201f nop
82318: d503201f nop
8231c: d503201f nop
82320: d503201f nop
82324: d503201f nop
82328: d503201f nop
8232c: d503201f nop
82330: d503201f nop
82334: d503201f nop
82338: d503201f nop
8233c: d503201f nop
82340: d503201f nop
82344: d503201f nop
82348: d503201f nop
8234c: d503201f nop
82350: d503201f nop
82354: d503201f nop
82358: d503201f nop
8235c: d503201f nop
82360: d503201f nop
82364: d503201f nop
82368: d503201f nop
8236c: d503201f nop
82370: d503201f nop
82374: d503201f nop
82378: d503201f nop
8237c: d503201f nop
ventry error_invalid_el1h // Error EL1h
82380: 14000197 b 829dc <error_invalid_el1h>
82384: d503201f nop
82388: d503201f nop
8238c: d503201f nop
82390: d503201f nop
82394: d503201f nop
82398: d503201f nop
8239c: d503201f nop
823a0: d503201f nop
823a4: d503201f nop
823a8: d503201f nop
823ac: d503201f nop
823b0: d503201f nop
823b4: d503201f nop
823b8: d503201f nop
823bc: d503201f nop
823c0: d503201f nop
823c4: d503201f nop
823c8: d503201f nop
823cc: d503201f nop
823d0: d503201f nop
823d4: d503201f nop
823d8: d503201f nop
823dc: d503201f nop
823e0: d503201f nop
823e4: d503201f nop
823e8: d503201f nop
823ec: d503201f nop
823f0: d503201f nop
823f4: d503201f nop
823f8: d503201f nop
823fc: d503201f nop
ventry sync_invalid_el0_64 // Synchronous 64-bit EL0
82400: 14000190 b 82a40 <sync_invalid_el0_64>
82404: d503201f nop
82408: d503201f nop
8240c: d503201f nop
82410: d503201f nop
82414: d503201f nop
82418: d503201f nop
8241c: d503201f nop
82420: d503201f nop
82424: d503201f nop
82428: d503201f nop
8242c: d503201f nop
82430: d503201f nop
82434: d503201f nop
82438: d503201f nop
8243c: d503201f nop
82440: d503201f nop
82444: d503201f nop
82448: d503201f nop
8244c: d503201f nop
82450: d503201f nop
82454: d503201f nop
82458: d503201f nop
8245c: d503201f nop
82460: d503201f nop
82464: d503201f nop
82468: d503201f nop
8246c: d503201f nop
82470: d503201f nop
82474: d503201f nop
82478: d503201f nop
8247c: d503201f nop
ventry irq_invalid_el0_64 // IRQ 64-bit EL0
82480: 14000189 b 82aa4 <irq_invalid_el0_64>
82484: d503201f nop
82488: d503201f nop
8248c: d503201f nop
82490: d503201f nop
82494: d503201f nop
82498: d503201f nop
8249c: d503201f nop
824a0: d503201f nop
824a4: d503201f nop
824a8: d503201f nop
824ac: d503201f nop
824b0: d503201f nop
824b4: d503201f nop
824b8: d503201f nop
824bc: d503201f nop
824c0: d503201f nop
824c4: d503201f nop
824c8: d503201f nop
824cc: d503201f nop
824d0: d503201f nop
824d4: d503201f nop
824d8: d503201f nop
824dc: d503201f nop
824e0: d503201f nop
824e4: d503201f nop
824e8: d503201f nop
824ec: d503201f nop
824f0: d503201f nop
824f4: d503201f nop
824f8: d503201f nop
824fc: d503201f nop
ventry fiq_invalid_el0_64 // FIQ 64-bit EL0
82500: 14000182 b 82b08 <fiq_invalid_el0_64>
82504: d503201f nop
82508: d503201f nop
8250c: d503201f nop
82510: d503201f nop
82514: d503201f nop
82518: d503201f nop
8251c: d503201f nop
82520: d503201f nop
82524: d503201f nop
82528: d503201f nop
8252c: d503201f nop
82530: d503201f nop
82534: d503201f nop
82538: d503201f nop
8253c: d503201f nop
82540: d503201f nop
82544: d503201f nop
82548: d503201f nop
8254c: d503201f nop
82550: d503201f nop
82554: d503201f nop
82558: d503201f nop
8255c: d503201f nop
82560: d503201f nop
82564: d503201f nop
82568: d503201f nop
8256c: d503201f nop
82570: d503201f nop
82574: d503201f nop
82578: d503201f nop
8257c: d503201f nop
ventry error_invalid_el0_64 // Error 64-bit EL0
82580: 1400017b b 82b6c <error_invalid_el0_64>
82584: d503201f nop
82588: d503201f nop
8258c: d503201f nop
82590: d503201f nop
82594: d503201f nop
82598: d503201f nop
8259c: d503201f nop
825a0: d503201f nop
825a4: d503201f nop
825a8: d503201f nop
825ac: d503201f nop
825b0: d503201f nop
825b4: d503201f nop
825b8: d503201f nop
825bc: d503201f nop
825c0: d503201f nop
825c4: d503201f nop
825c8: d503201f nop
825cc: d503201f nop
825d0: d503201f nop
825d4: d503201f nop
825d8: d503201f nop
825dc: d503201f nop
825e0: d503201f nop
825e4: d503201f nop
825e8: d503201f nop
825ec: d503201f nop
825f0: d503201f nop
825f4: d503201f nop
825f8: d503201f nop
825fc: d503201f nop
ventry sync_invalid_el0_32 // Synchronous 32-bit EL0
82600: 14000174 b 82bd0 <sync_invalid_el0_32>
82604: d503201f nop
82608: d503201f nop
8260c: d503201f nop
82610: d503201f nop
82614: d503201f nop
82618: d503201f nop
8261c: d503201f nop
82620: d503201f nop
82624: d503201f nop
82628: d503201f nop
8262c: d503201f nop
82630: d503201f nop
82634: d503201f nop
82638: d503201f nop
8263c: d503201f nop
82640: d503201f nop
82644: d503201f nop
82648: d503201f nop
8264c: d503201f nop
82650: d503201f nop
82654: d503201f nop
82658: d503201f nop
8265c: d503201f nop
82660: d503201f nop
82664: d503201f nop
82668: d503201f nop
8266c: d503201f nop
82670: d503201f nop
82674: d503201f nop
82678: d503201f nop
8267c: d503201f nop
ventry irq_invalid_el0_32 // IRQ 32-bit EL0
82680: 1400016d b 82c34 <irq_invalid_el0_32>
82684: d503201f nop
82688: d503201f nop
8268c: d503201f nop
82690: d503201f nop
82694: d503201f nop
82698: d503201f nop
8269c: d503201f nop
826a0: d503201f nop
826a4: d503201f nop
826a8: d503201f nop
826ac: d503201f nop
826b0: d503201f nop
826b4: d503201f nop
826b8: d503201f nop
826bc: d503201f nop
826c0: d503201f nop
826c4: d503201f nop
826c8: d503201f nop
826cc: d503201f nop
826d0: d503201f nop
826d4: d503201f nop
826d8: d503201f nop
826dc: d503201f nop
826e0: d503201f nop
826e4: d503201f nop
826e8: d503201f nop
826ec: d503201f nop
826f0: d503201f nop
826f4: d503201f nop
826f8: d503201f nop
826fc: d503201f nop
ventry fiq_invalid_el0_32 // FIQ 32-bit EL0
82700: 14000166 b 82c98 <fiq_invalid_el0_32>
82704: d503201f nop
82708: d503201f nop
8270c: d503201f nop
82710: d503201f nop
82714: d503201f nop
82718: d503201f nop
8271c: d503201f nop
82720: d503201f nop
82724: d503201f nop
82728: d503201f nop
8272c: d503201f nop
82730: d503201f nop
82734: d503201f nop
82738: d503201f nop
8273c: d503201f nop
82740: d503201f nop
82744: d503201f nop
82748: d503201f nop
8274c: d503201f nop
82750: d503201f nop
82754: d503201f nop
82758: d503201f nop
8275c: d503201f nop
82760: d503201f nop
82764: d503201f nop
82768: d503201f nop
8276c: d503201f nop
82770: d503201f nop
82774: d503201f nop
82778: d503201f nop
8277c: d503201f nop
ventry error_invalid_el0_32 // Error 32-bit EL0
82780: 1400015f b 82cfc <error_invalid_el0_32>
0000000000082784 <sync_invalid_el1t>:
sync_invalid_el1t:
handle_invalid_entry SYNC_INVALID_EL1t
82784: d10443ff sub sp, sp, #0x110
82788: a90007e0 stp x0, x1, [sp]
8278c: a9010fe2 stp x2, x3, [sp, #16]
82790: a90217e4 stp x4, x5, [sp, #32]
82794: a9031fe6 stp x6, x7, [sp, #48]
82798: a90427e8 stp x8, x9, [sp, #64]
8279c: a9052fea stp x10, x11, [sp, #80]
827a0: a90637ec stp x12, x13, [sp, #96]
827a4: a9073fee stp x14, x15, [sp, #112]
827a8: a90847f0 stp x16, x17, [sp, #128]
827ac: a9094ff2 stp x18, x19, [sp, #144]
827b0: a90a57f4 stp x20, x21, [sp, #160]
827b4: a90b5ff6 stp x22, x23, [sp, #176]
827b8: a90c67f8 stp x24, x25, [sp, #192]
827bc: a90d6ffa stp x26, x27, [sp, #208]
827c0: a90e77fc stp x28, x29, [sp, #224]
827c4: d5384036 mrs x22, elr_el1
827c8: d5384017 mrs x23, spsr_el1
827cc: a90f5bfe stp x30, x22, [sp, #240]
827d0: f90083f7 str x23, [sp, #256]
827d4: d2800000 mov x0, #0x0 // #0
827d8: d5385201 mrs x1, esr_el1
827dc: d5384022 mrs x2, elr_el1
827e0: 97fff86a bl 80988 <show_invalid_entry_message>
827e4: 1400018c b 82e14 <err_hang>
00000000000827e8 <irq_invalid_el1t>:
irq_invalid_el1t:
handle_invalid_entry IRQ_INVALID_EL1t
827e8: d10443ff sub sp, sp, #0x110
827ec: a90007e0 stp x0, x1, [sp]
827f0: a9010fe2 stp x2, x3, [sp, #16]
827f4: a90217e4 stp x4, x5, [sp, #32]
827f8: a9031fe6 stp x6, x7, [sp, #48]
827fc: a90427e8 stp x8, x9, [sp, #64]
82800: a9052fea stp x10, x11, [sp, #80]
82804: a90637ec stp x12, x13, [sp, #96]
82808: a9073fee stp x14, x15, [sp, #112]
8280c: a90847f0 stp x16, x17, [sp, #128]
82810: a9094ff2 stp x18, x19, [sp, #144]
82814: a90a57f4 stp x20, x21, [sp, #160]
82818: a90b5ff6 stp x22, x23, [sp, #176]
8281c: a90c67f8 stp x24, x25, [sp, #192]
82820: a90d6ffa stp x26, x27, [sp, #208]
82824: a90e77fc stp x28, x29, [sp, #224]
82828: d5384036 mrs x22, elr_el1
8282c: d5384017 mrs x23, spsr_el1
82830: a90f5bfe stp x30, x22, [sp, #240]
82834: f90083f7 str x23, [sp, #256]
82838: d2800020 mov x0, #0x1 // #1
8283c: d5385201 mrs x1, esr_el1
82840: d5384022 mrs x2, elr_el1
82844: 97fff851 bl 80988 <show_invalid_entry_message>
82848: 14000173 b 82e14 <err_hang>
000000000008284c <fiq_invalid_el1t>:
fiq_invalid_el1t:
handle_invalid_entry FIQ_INVALID_EL1t
8284c: d10443ff sub sp, sp, #0x110
82850: a90007e0 stp x0, x1, [sp]
82854: a9010fe2 stp x2, x3, [sp, #16]
82858: a90217e4 stp x4, x5, [sp, #32]
8285c: a9031fe6 stp x6, x7, [sp, #48]
82860: a90427e8 stp x8, x9, [sp, #64]
82864: a9052fea stp x10, x11, [sp, #80]
82868: a90637ec stp x12, x13, [sp, #96]
8286c: a9073fee stp x14, x15, [sp, #112]
82870: a90847f0 stp x16, x17, [sp, #128]
82874: a9094ff2 stp x18, x19, [sp, #144]
82878: a90a57f4 stp x20, x21, [sp, #160]
8287c: a90b5ff6 stp x22, x23, [sp, #176]
82880: a90c67f8 stp x24, x25, [sp, #192]
82884: a90d6ffa stp x26, x27, [sp, #208]
82888: a90e77fc stp x28, x29, [sp, #224]
8288c: d5384036 mrs x22, elr_el1
82890: d5384017 mrs x23, spsr_el1
82894: a90f5bfe stp x30, x22, [sp, #240]
82898: f90083f7 str x23, [sp, #256]
8289c: d2800040 mov x0, #0x2 // #2
828a0: d5385201 mrs x1, esr_el1
828a4: d5384022 mrs x2, elr_el1
828a8: 97fff838 bl 80988 <show_invalid_entry_message>
828ac: 1400015a b 82e14 <err_hang>
00000000000828b0 <error_invalid_el1t>:
error_invalid_el1t:
handle_invalid_entry ERROR_INVALID_EL1t
828b0: d10443ff sub sp, sp, #0x110
828b4: a90007e0 stp x0, x1, [sp]
828b8: a9010fe2 stp x2, x3, [sp, #16]
828bc: a90217e4 stp x4, x5, [sp, #32]
828c0: a9031fe6 stp x6, x7, [sp, #48]
828c4: a90427e8 stp x8, x9, [sp, #64]
828c8: a9052fea stp x10, x11, [sp, #80]
828cc: a90637ec stp x12, x13, [sp, #96]
828d0: a9073fee stp x14, x15, [sp, #112]
828d4: a90847f0 stp x16, x17, [sp, #128]
828d8: a9094ff2 stp x18, x19, [sp, #144]
828dc: a90a57f4 stp x20, x21, [sp, #160]
828e0: a90b5ff6 stp x22, x23, [sp, #176]
828e4: a90c67f8 stp x24, x25, [sp, #192]
828e8: a90d6ffa stp x26, x27, [sp, #208]
828ec: a90e77fc stp x28, x29, [sp, #224]
828f0: d5384036 mrs x22, elr_el1
828f4: d5384017 mrs x23, spsr_el1
828f8: a90f5bfe stp x30, x22, [sp, #240]
828fc: f90083f7 str x23, [sp, #256]
82900: d2800060 mov x0, #0x3 // #3
82904: d5385201 mrs x1, esr_el1
82908: d5384022 mrs x2, elr_el1
8290c: 97fff81f bl 80988 <show_invalid_entry_message>
82910: 14000141 b 82e14 <err_hang>
0000000000082914 <sync_invalid_el1h>:
sync_invalid_el1h:
handle_invalid_entry SYNC_INVALID_EL1h
82914: d10443ff sub sp, sp, #0x110
82918: a90007e0 stp x0, x1, [sp]
8291c: a9010fe2 stp x2, x3, [sp, #16]
82920: a90217e4 stp x4, x5, [sp, #32]
82924: a9031fe6 stp x6, x7, [sp, #48]
82928: a90427e8 stp x8, x9, [sp, #64]
8292c: a9052fea stp x10, x11, [sp, #80]
82930: a90637ec stp x12, x13, [sp, #96]
82934: a9073fee stp x14, x15, [sp, #112]
82938: a90847f0 stp x16, x17, [sp, #128]
8293c: a9094ff2 stp x18, x19, [sp, #144]
82940: a90a57f4 stp x20, x21, [sp, #160]
82944: a90b5ff6 stp x22, x23, [sp, #176]
82948: a90c67f8 stp x24, x25, [sp, #192]
8294c: a90d6ffa stp x26, x27, [sp, #208]
82950: a90e77fc stp x28, x29, [sp, #224]
82954: d5384036 mrs x22, elr_el1
82958: d5384017 mrs x23, spsr_el1
8295c: a90f5bfe stp x30, x22, [sp, #240]
82960: f90083f7 str x23, [sp, #256]
82964: d2800080 mov x0, #0x4 // #4
82968: d5385201 mrs x1, esr_el1
8296c: d5384022 mrs x2, elr_el1
82970: 97fff806 bl 80988 <show_invalid_entry_message>
82974: 14000128 b 82e14 <err_hang>
0000000000082978 <fiq_invalid_el1h>:
fiq_invalid_el1h:
handle_invalid_entry FIQ_INVALID_EL1h
82978: d10443ff sub sp, sp, #0x110
8297c: a90007e0 stp x0, x1, [sp]
82980: a9010fe2 stp x2, x3, [sp, #16]
82984: a90217e4 stp x4, x5, [sp, #32]
82988: a9031fe6 stp x6, x7, [sp, #48]
8298c: a90427e8 stp x8, x9, [sp, #64]
82990: a9052fea stp x10, x11, [sp, #80]
82994: a90637ec stp x12, x13, [sp, #96]
82998: a9073fee stp x14, x15, [sp, #112]
8299c: a90847f0 stp x16, x17, [sp, #128]
829a0: a9094ff2 stp x18, x19, [sp, #144]
829a4: a90a57f4 stp x20, x21, [sp, #160]
829a8: a90b5ff6 stp x22, x23, [sp, #176]
829ac: a90c67f8 stp x24, x25, [sp, #192]
829b0: a90d6ffa stp x26, x27, [sp, #208]
829b4: a90e77fc stp x28, x29, [sp, #224]
829b8: d5384036 mrs x22, elr_el1
829bc: d5384017 mrs x23, spsr_el1
829c0: a90f5bfe stp x30, x22, [sp, #240]
829c4: f90083f7 str x23, [sp, #256]
829c8: d28000c0 mov x0, #0x6 // #6
829cc: d5385201 mrs x1, esr_el1
829d0: d5384022 mrs x2, elr_el1
829d4: 97fff7ed bl 80988 <show_invalid_entry_message>
829d8: 1400010f b 82e14 <err_hang>
00000000000829dc <error_invalid_el1h>:
error_invalid_el1h:
handle_invalid_entry ERROR_INVALID_EL1h
829dc: d10443ff sub sp, sp, #0x110
829e0: a90007e0 stp x0, x1, [sp]
829e4: a9010fe2 stp x2, x3, [sp, #16]
829e8: a90217e4 stp x4, x5, [sp, #32]
829ec: a9031fe6 stp x6, x7, [sp, #48]
829f0: a90427e8 stp x8, x9, [sp, #64]
829f4: a9052fea stp x10, x11, [sp, #80]
829f8: a90637ec stp x12, x13, [sp, #96]
829fc: a9073fee stp x14, x15, [sp, #112]
82a00: a90847f0 stp x16, x17, [sp, #128]
82a04: a9094ff2 stp x18, x19, [sp, #144]
82a08: a90a57f4 stp x20, x21, [sp, #160]
82a0c: a90b5ff6 stp x22, x23, [sp, #176]
82a10: a90c67f8 stp x24, x25, [sp, #192]
82a14: a90d6ffa stp x26, x27, [sp, #208]
82a18: a90e77fc stp x28, x29, [sp, #224]
82a1c: d5384036 mrs x22, elr_el1
82a20: d5384017 mrs x23, spsr_el1
82a24: a90f5bfe stp x30, x22, [sp, #240]
82a28: f90083f7 str x23, [sp, #256]
82a2c: d28000e0 mov x0, #0x7 // #7
82a30: d5385201 mrs x1, esr_el1
82a34: d5384022 mrs x2, elr_el1
82a38: 97fff7d4 bl 80988 <show_invalid_entry_message>
82a3c: 140000f6 b 82e14 <err_hang>
0000000000082a40 <sync_invalid_el0_64>:
sync_invalid_el0_64:
handle_invalid_entry SYNC_INVALID_EL0_64
82a40: d10443ff sub sp, sp, #0x110
82a44: a90007e0 stp x0, x1, [sp]
82a48: a9010fe2 stp x2, x3, [sp, #16]
82a4c: a90217e4 stp x4, x5, [sp, #32]
82a50: a9031fe6 stp x6, x7, [sp, #48]
82a54: a90427e8 stp x8, x9, [sp, #64]
82a58: a9052fea stp x10, x11, [sp, #80]
82a5c: a90637ec stp x12, x13, [sp, #96]
82a60: a9073fee stp x14, x15, [sp, #112]
82a64: a90847f0 stp x16, x17, [sp, #128]
82a68: a9094ff2 stp x18, x19, [sp, #144]
82a6c: a90a57f4 stp x20, x21, [sp, #160]
82a70: a90b5ff6 stp x22, x23, [sp, #176]
82a74: a90c67f8 stp x24, x25, [sp, #192]
82a78: a90d6ffa stp x26, x27, [sp, #208]
82a7c: a90e77fc stp x28, x29, [sp, #224]
82a80: d5384036 mrs x22, elr_el1
82a84: d5384017 mrs x23, spsr_el1
82a88: a90f5bfe stp x30, x22, [sp, #240]
82a8c: f90083f7 str x23, [sp, #256]
82a90: d2800100 mov x0, #0x8 // #8
82a94: d5385201 mrs x1, esr_el1
82a98: d5384022 mrs x2, elr_el1
82a9c: 97fff7bb bl 80988 <show_invalid_entry_message>
82aa0: 140000dd b 82e14 <err_hang>
0000000000082aa4 <irq_invalid_el0_64>:
irq_invalid_el0_64:
handle_invalid_entry IRQ_INVALID_EL0_64
82aa4: d10443ff sub sp, sp, #0x110
82aa8: a90007e0 stp x0, x1, [sp]
82aac: a9010fe2 stp x2, x3, [sp, #16]
82ab0: a90217e4 stp x4, x5, [sp, #32]
82ab4: a9031fe6 stp x6, x7, [sp, #48]
82ab8: a90427e8 stp x8, x9, [sp, #64]
82abc: a9052fea stp x10, x11, [sp, #80]
82ac0: a90637ec stp x12, x13, [sp, #96]
82ac4: a9073fee stp x14, x15, [sp, #112]
82ac8: a90847f0 stp x16, x17, [sp, #128]
82acc: a9094ff2 stp x18, x19, [sp, #144]
82ad0: a90a57f4 stp x20, x21, [sp, #160]
82ad4: a90b5ff6 stp x22, x23, [sp, #176]
82ad8: a90c67f8 stp x24, x25, [sp, #192]
82adc: a90d6ffa stp x26, x27, [sp, #208]
82ae0: a90e77fc stp x28, x29, [sp, #224]
82ae4: d5384036 mrs x22, elr_el1
82ae8: d5384017 mrs x23, spsr_el1
82aec: a90f5bfe stp x30, x22, [sp, #240]
82af0: f90083f7 str x23, [sp, #256]
82af4: d2800120 mov x0, #0x9 // #9
82af8: d5385201 mrs x1, esr_el1
82afc: d5384022 mrs x2, elr_el1
82b00: 97fff7a2 bl 80988 <show_invalid_entry_message>
82b04: 140000c4 b 82e14 <err_hang>
0000000000082b08 <fiq_invalid_el0_64>:
fiq_invalid_el0_64:
handle_invalid_entry FIQ_INVALID_EL0_64
82b08: d10443ff sub sp, sp, #0x110
82b0c: a90007e0 stp x0, x1, [sp]
82b10: a9010fe2 stp x2, x3, [sp, #16]
82b14: a90217e4 stp x4, x5, [sp, #32]
82b18: a9031fe6 stp x6, x7, [sp, #48]
82b1c: a90427e8 stp x8, x9, [sp, #64]
82b20: a9052fea stp x10, x11, [sp, #80]
82b24: a90637ec stp x12, x13, [sp, #96]
82b28: a9073fee stp x14, x15, [sp, #112]
82b2c: a90847f0 stp x16, x17, [sp, #128]
82b30: a9094ff2 stp x18, x19, [sp, #144]
82b34: a90a57f4 stp x20, x21, [sp, #160]
82b38: a90b5ff6 stp x22, x23, [sp, #176]
82b3c: a90c67f8 stp x24, x25, [sp, #192]
82b40: a90d6ffa stp x26, x27, [sp, #208]
82b44: a90e77fc stp x28, x29, [sp, #224]
82b48: d5384036 mrs x22, elr_el1
82b4c: d5384017 mrs x23, spsr_el1
82b50: a90f5bfe stp x30, x22, [sp, #240]
82b54: f90083f7 str x23, [sp, #256]
82b58: d2800140 mov x0, #0xa // #10
82b5c: d5385201 mrs x1, esr_el1
82b60: d5384022 mrs x2, elr_el1
82b64: 97fff789 bl 80988 <show_invalid_entry_message>
82b68: 140000ab b 82e14 <err_hang>
0000000000082b6c <error_invalid_el0_64>:
error_invalid_el0_64:
handle_invalid_entry ERROR_INVALID_EL0_64
82b6c: d10443ff sub sp, sp, #0x110
82b70: a90007e0 stp x0, x1, [sp]
82b74: a9010fe2 stp x2, x3, [sp, #16]
82b78: a90217e4 stp x4, x5, [sp, #32]
82b7c: a9031fe6 stp x6, x7, [sp, #48]
82b80: a90427e8 stp x8, x9, [sp, #64]
82b84: a9052fea stp x10, x11, [sp, #80]
82b88: a90637ec stp x12, x13, [sp, #96]
82b8c: a9073fee stp x14, x15, [sp, #112]
82b90: a90847f0 stp x16, x17, [sp, #128]
82b94: a9094ff2 stp x18, x19, [sp, #144]
82b98: a90a57f4 stp x20, x21, [sp, #160]
82b9c: a90b5ff6 stp x22, x23, [sp, #176]
82ba0: a90c67f8 stp x24, x25, [sp, #192]
82ba4: a90d6ffa stp x26, x27, [sp, #208]
82ba8: a90e77fc stp x28, x29, [sp, #224]
82bac: d5384036 mrs x22, elr_el1
82bb0: d5384017 mrs x23, spsr_el1
82bb4: a90f5bfe stp x30, x22, [sp, #240]
82bb8: f90083f7 str x23, [sp, #256]
82bbc: d2800160 mov x0, #0xb // #11
82bc0: d5385201 mrs x1, esr_el1
82bc4: d5384022 mrs x2, elr_el1
82bc8: 97fff770 bl 80988 <show_invalid_entry_message>
82bcc: 14000092 b 82e14 <err_hang>
0000000000082bd0 <sync_invalid_el0_32>:
sync_invalid_el0_32:
handle_invalid_entry SYNC_INVALID_EL0_32
82bd0: d10443ff sub sp, sp, #0x110
82bd4: a90007e0 stp x0, x1, [sp]
82bd8: a9010fe2 stp x2, x3, [sp, #16]
82bdc: a90217e4 stp x4, x5, [sp, #32]
82be0: a9031fe6 stp x6, x7, [sp, #48]
82be4: a90427e8 stp x8, x9, [sp, #64]
82be8: a9052fea stp x10, x11, [sp, #80]
82bec: a90637ec stp x12, x13, [sp, #96]
82bf0: a9073fee stp x14, x15, [sp, #112]
82bf4: a90847f0 stp x16, x17, [sp, #128]
82bf8: a9094ff2 stp x18, x19, [sp, #144]
82bfc: a90a57f4 stp x20, x21, [sp, #160]
82c00: a90b5ff6 stp x22, x23, [sp, #176]
82c04: a90c67f8 stp x24, x25, [sp, #192]
82c08: a90d6ffa stp x26, x27, [sp, #208]
82c0c: a90e77fc stp x28, x29, [sp, #224]
82c10: d5384036 mrs x22, elr_el1
82c14: d5384017 mrs x23, spsr_el1
82c18: a90f5bfe stp x30, x22, [sp, #240]
82c1c: f90083f7 str x23, [sp, #256]
82c20: d2800180 mov x0, #0xc // #12
82c24: d5385201 mrs x1, esr_el1
82c28: d5384022 mrs x2, elr_el1
82c2c: 97fff757 bl 80988 <show_invalid_entry_message>
82c30: 14000079 b 82e14 <err_hang>
0000000000082c34 <irq_invalid_el0_32>:
irq_invalid_el0_32:
handle_invalid_entry IRQ_INVALID_EL0_32
82c34: d10443ff sub sp, sp, #0x110
82c38: a90007e0 stp x0, x1, [sp]
82c3c: a9010fe2 stp x2, x3, [sp, #16]
82c40: a90217e4 stp x4, x5, [sp, #32]
82c44: a9031fe6 stp x6, x7, [sp, #48]
82c48: a90427e8 stp x8, x9, [sp, #64]
82c4c: a9052fea stp x10, x11, [sp, #80]
82c50: a90637ec stp x12, x13, [sp, #96]
82c54: a9073fee stp x14, x15, [sp, #112]
82c58: a90847f0 stp x16, x17, [sp, #128]
82c5c: a9094ff2 stp x18, x19, [sp, #144]
82c60: a90a57f4 stp x20, x21, [sp, #160]
82c64: a90b5ff6 stp x22, x23, [sp, #176]
82c68: a90c67f8 stp x24, x25, [sp, #192]
82c6c: a90d6ffa stp x26, x27, [sp, #208]
82c70: a90e77fc stp x28, x29, [sp, #224]
82c74: d5384036 mrs x22, elr_el1
82c78: d5384017 mrs x23, spsr_el1
82c7c: a90f5bfe stp x30, x22, [sp, #240]
82c80: f90083f7 str x23, [sp, #256]
82c84: d28001a0 mov x0, #0xd // #13
82c88: d5385201 mrs x1, esr_el1
82c8c: d5384022 mrs x2, elr_el1
82c90: 97fff73e bl 80988 <show_invalid_entry_message>
82c94: 14000060 b 82e14 <err_hang>
0000000000082c98 <fiq_invalid_el0_32>:
fiq_invalid_el0_32:
handle_invalid_entry FIQ_INVALID_EL0_32
82c98: d10443ff sub sp, sp, #0x110
82c9c: a90007e0 stp x0, x1, [sp]
82ca0: a9010fe2 stp x2, x3, [sp, #16]
82ca4: a90217e4 stp x4, x5, [sp, #32]
82ca8: a9031fe6 stp x6, x7, [sp, #48]
82cac: a90427e8 stp x8, x9, [sp, #64]
82cb0: a9052fea stp x10, x11, [sp, #80]
82cb4: a90637ec stp x12, x13, [sp, #96]
82cb8: a9073fee stp x14, x15, [sp, #112]
82cbc: a90847f0 stp x16, x17, [sp, #128]
82cc0: a9094ff2 stp x18, x19, [sp, #144]
82cc4: a90a57f4 stp x20, x21, [sp, #160]
82cc8: a90b5ff6 stp x22, x23, [sp, #176]
82ccc: a90c67f8 stp x24, x25, [sp, #192]
82cd0: a90d6ffa stp x26, x27, [sp, #208]
82cd4: a90e77fc stp x28, x29, [sp, #224]
82cd8: d5384036 mrs x22, elr_el1
82cdc: d5384017 mrs x23, spsr_el1
82ce0: a90f5bfe stp x30, x22, [sp, #240]
82ce4: f90083f7 str x23, [sp, #256]
82ce8: d28001c0 mov x0, #0xe // #14
82cec: d5385201 mrs x1, esr_el1
82cf0: d5384022 mrs x2, elr_el1
82cf4: 97fff725 bl 80988 <show_invalid_entry_message>
82cf8: 14000047 b 82e14 <err_hang>
0000000000082cfc <error_invalid_el0_32>:
error_invalid_el0_32:
handle_invalid_entry ERROR_INVALID_EL0_32
82cfc: d10443ff sub sp, sp, #0x110
82d00: a90007e0 stp x0, x1, [sp]
82d04: a9010fe2 stp x2, x3, [sp, #16]
82d08: a90217e4 stp x4, x5, [sp, #32]
82d0c: a9031fe6 stp x6, x7, [sp, #48]
82d10: a90427e8 stp x8, x9, [sp, #64]
82d14: a9052fea stp x10, x11, [sp, #80]
82d18: a90637ec stp x12, x13, [sp, #96]
82d1c: a9073fee stp x14, x15, [sp, #112]
82d20: a90847f0 stp x16, x17, [sp, #128]
82d24: a9094ff2 stp x18, x19, [sp, #144]
82d28: a90a57f4 stp x20, x21, [sp, #160]
82d2c: a90b5ff6 stp x22, x23, [sp, #176]
82d30: a90c67f8 stp x24, x25, [sp, #192]
82d34: a90d6ffa stp x26, x27, [sp, #208]
82d38: a90e77fc stp x28, x29, [sp, #224]
82d3c: d5384036 mrs x22, elr_el1
82d40: d5384017 mrs x23, spsr_el1
82d44: a90f5bfe stp x30, x22, [sp, #240]
82d48: f90083f7 str x23, [sp, #256]
82d4c: d28001e0 mov x0, #0xf // #15
82d50: d5385201 mrs x1, esr_el1
82d54: d5384022 mrs x2, elr_el1
82d58: 97fff70c bl 80988 <show_invalid_entry_message>
82d5c: 1400002e b 82e14 <err_hang>
0000000000082d60 <el1_irq>:
el1_irq:
kernel_entry
82d60: d10443ff sub sp, sp, #0x110
82d64: a90007e0 stp x0, x1, [sp]
82d68: a9010fe2 stp x2, x3, [sp, #16]
82d6c: a90217e4 stp x4, x5, [sp, #32]
82d70: a9031fe6 stp x6, x7, [sp, #48]
82d74: a90427e8 stp x8, x9, [sp, #64]
82d78: a9052fea stp x10, x11, [sp, #80]
82d7c: a90637ec stp x12, x13, [sp, #96]
82d80: a9073fee stp x14, x15, [sp, #112]
82d84: a90847f0 stp x16, x17, [sp, #128]
82d88: a9094ff2 stp x18, x19, [sp, #144]
82d8c: a90a57f4 stp x20, x21, [sp, #160]
82d90: a90b5ff6 stp x22, x23, [sp, #176]
82d94: a90c67f8 stp x24, x25, [sp, #192]
82d98: a90d6ffa stp x26, x27, [sp, #208]
82d9c: a90e77fc stp x28, x29, [sp, #224]
82da0: d5384036 mrs x22, elr_el1
82da4: d5384017 mrs x23, spsr_el1
82da8: a90f5bfe stp x30, x22, [sp, #240]
82dac: f90083f7 str x23, [sp, #256]
bl handle_irq
82db0: 97fff707 bl 809cc <handle_irq>
kernel_exit
82db4: f94083f7 ldr x23, [sp, #256]
82db8: a94f5bfe ldp x30, x22, [sp, #240]
82dbc: d5184036 msr elr_el1, x22
82dc0: d5184017 msr spsr_el1, x23
82dc4: a94007e0 ldp x0, x1, [sp]
82dc8: a9410fe2 ldp x2, x3, [sp, #16]
82dcc: a94217e4 ldp x4, x5, [sp, #32]
82dd0: a9431fe6 ldp x6, x7, [sp, #48]
82dd4: a94427e8 ldp x8, x9, [sp, #64]
82dd8: a9452fea ldp x10, x11, [sp, #80]
82ddc: a94637ec ldp x12, x13, [sp, #96]
82de0: a9473fee ldp x14, x15, [sp, #112]
82de4: a94847f0 ldp x16, x17, [sp, #128]
82de8: a9494ff2 ldp x18, x19, [sp, #144]
82dec: a94a57f4 ldp x20, x21, [sp, #160]
82df0: a94b5ff6 ldp x22, x23, [sp, #176]
82df4: a94c67f8 ldp x24, x25, [sp, #192]
82df8: a94d6ffa ldp x26, x27, [sp, #208]
82dfc: a94e77fc ldp x28, x29, [sp, #224]
82e00: 910443ff add sp, sp, #0x110
82e04: d69f03e0 eret
0000000000082e08 <ret_from_fork>:
.globl ret_from_fork
ret_from_fork:
bl schedule_tail
82e08: 97fff82f bl 80ec4 <schedule_tail>
mov x0, x20
82e0c: aa1403e0 mov x0, x20
blr x19 //should never return
82e10: d63f0260 blr x19
0000000000082e14 <err_hang>:
.globl err_hang
err_hang: b err_hang
82e14: 14000000 b 82e14 <err_hang>
0000000000082e18 <memzero>:
.globl memzero
memzero:
str xzr, [x0], #8
82e18: f800841f str xzr, [x0], #8
subs x1, x1, #8
82e1c: f1002021 subs x1, x1, #0x8
b.gt memzero
82e20: 54ffffcc b.gt 82e18 <memzero>
ret
82e24: d65f03c0 ret
0000000000082e28 <cpu_switch_to>:
#include "sched.h"
.globl cpu_switch_to
cpu_switch_to:
mov x10, #THREAD_CPU_CONTEXT
82e28: d280000a mov x10, #0x0 // #0
add x8, x0, x10
82e2c: 8b0a0008 add x8, x0, x10
mov x9, sp
82e30: 910003e9 mov x9, sp
stp x19, x20, [x8], #16 // store callee-saved registers
82e34: a8815113 stp x19, x20, [x8], #16
stp x21, x22, [x8], #16
82e38: a8815915 stp x21, x22, [x8], #16
stp x23, x24, [x8], #16
82e3c: a8816117 stp x23, x24, [x8], #16
stp x25, x26, [x8], #16
82e40: a8816919 stp x25, x26, [x8], #16
stp x27, x28, [x8], #16
82e44: a881711b stp x27, x28, [x8], #16
stp x29, x9, [x8], #16
82e48: a881251d stp x29, x9, [x8], #16
str x30, [x8]
82e4c: f900011e str x30, [x8]
add x8, x1, x10
82e50: 8b0a0028 add x8, x1, x10
ldp x19, x20, [x8], #16 // restore callee-saved registers
82e54: a8c15113 ldp x19, x20, [x8], #16
ldp x21, x22, [x8], #16
82e58: a8c15915 ldp x21, x22, [x8], #16
ldp x23, x24, [x8], #16
82e5c: a8c16117 ldp x23, x24, [x8], #16
ldp x25, x26, [x8], #16
82e60: a8c16919 ldp x25, x26, [x8], #16
ldp x27, x28, [x8], #16
82e64: a8c1711b ldp x27, x28, [x8], #16
ldp x29, x9, [x8], #16
82e68: a8c1251d ldp x29, x9, [x8], #16
ldr x30, [x8]
82e6c: f940011e ldr x30, [x8]
mov sp, x9
82e70: 9100013f mov sp, x9
ret
82e74: d65f03c0 ret
|
graphics.adb | Sinbad-The-Sailor/Ada-Snake | 0 | 2326 | <filename>graphics.adb
package body graphics is
--------------------------------------------------------------------------------
procedure Transform_To_Graphical(X_Pos, Y_pos : in Integer; G_X, G_Y : out Integer) is
begin
G_X := X_Pos*Scaling_Factor + 40;
G_Y := Y_Pos*Scaling_Factor + 10;
end Transform_To_Graphical;
--------------------------------------------------------------------------------
procedure Get_Picture_Dimensions(File_Name : in String; X_Dim, Y_Dim : out Integer) is
File : File_Type;
Temp_String : String(1..10);
begin
Open(File, In_File, File_Name);
While not End_Of_Line(File) loop
Get(File, Temp_String);
X_Dim := Integer'Value(Temp_String(7..10));
Skip_Line(File);
Get(File, Temp_String);
Y_Dim := Integer'Value(Temp_String(7..10));
end loop;
Close(File);
end Get_Picture_Dimensions;
--------------------------------------------------------------------------------
procedure Load_Picture(File_Name : in String; Picture : out Picture_Type) is
File : File_Type;
X_Boundary, Y_Boundary : Integer;
Temp_Integer : Integer;
begin
Get_Picture_Dimensions(File_Name, X_Boundary, Y_Boundary);
Open(File, In_File, File_Name);
Skip_Line(File);
Skip_Line(File);
for I in 1..Y_Boundary loop
for J in 1..X_Boundary loop
Get(File, Temp_Integer);
Picture(I,J) := Temp_Integer;
end loop;
end loop;
Close(File);
end Load_Picture;
--------------------------------------------------------------------------------
procedure Put_Picture(Picture : in Picture_Type; X_Pos, Y_Pos, X_Range, Y_Range : in Integer) is
Temp_Color : Colour_Type;
Temp_Integer : Integer;
Temp_X_Pos : Integer := X_Pos;
Org_X : Integer := X_Pos;
Org_Y : Integer := Y_Pos;
begin
for I in 1..Y_Range loop
for J in 1..X_Range loop
Goto_XY(Org_X, Org_Y);
Temp_Integer := Picture(I, J);
Temp_Color := Colour_Type'Val(Temp_Integer);
Set_Background_Colour(Temp_Color);
Put(" ");
Org_X := Org_X + 1;
end loop;
New_Line;
Org_X := Temp_X_Pos;
Org_Y := Org_Y + 1;
end loop;
Reset_Colours;
end Put_Picture;
--------------------------------------------------------------------------------
procedure Fix_Picture(Picture : in Picture_Type; X_Pos, Y_Pos, X_Range, Y_Range : in Integer) is
Temp_Color : Colour_Type;
Temp_Integer : Integer;
Temp_X_Pos : Integer := X_Pos;
Org_X : Integer := X_Pos;
Org_Y : Integer := Y_Pos;
begin
for I in 1..Y_Range loop
for J in 1..X_Range loop
Goto_XY(Org_X, Org_Y);
Temp_Integer := Picture(Integer(Float(Org_Y/2)+10.0), Integer(Float(Org_X/2)+40.0));
-- Temp_Integer := Picture(Integer(Float(Org_Y)-40.0), Integer(Float(Org_X)-10.0));
-- Temp_Integer := Picture(Org_Y, Org_X);
Temp_Color := Colour_Type'Val(Temp_Integer);
Set_Background_Colour(Temp_Color);
Put(" ");
Org_X := Org_X + 1;
end loop;
New_Line;
Org_X := Temp_X_Pos;
Org_Y := Org_Y + 1;
end loop;
end Fix_Picture;
--------------------------------------------------------------------------------
procedure Put_Bushes(Picture : in Picture_Type; Background_Start_X, Background_Start_Y, Width, Height : in Integer) is
Org_X : Integer := Background_Start_X;
Org_Y : Integer := Background_Start_Y;
Bottom_Y : Integer := (Org_Y + Height - 2);
Right_X : Integer := (Org_X + Width - 2 );
----------------------------------------------------------------------------
procedure Put_Top_Bottom_Bushes(Temp_X, Temp_Y: in Integer) is
Number_Of_Bushes : Integer;
Copy_X : Integer := Temp_X;
begin
Number_Of_Bushes := Integer(Width/2);
for I in 1..Number_Of_Bushes loop
Goto_XY(Copy_X, Temp_Y);
Put_Picture(Picture, Copy_X, Temp_Y, 2, 2);
Copy_X := Copy_X + 2;
end loop;
end Put_Top_Bottom_Bushes;
----------------------------------------------------------------------------
procedure Put_Middle_Bushes(Temp_X, Temp_Y : in Integer) is
Number_Of_Bushes : Integer;
Copy_Y : Integer := Temp_Y + 2;
begin
Number_Of_Bushes := Integer((Height - 2 - 2)/2);
for I in 1..Number_Of_Bushes loop
Goto_XY(Temp_X, Copy_Y);
Put_Picture(Picture, Temp_X, Copy_Y, 2, 2);
Copy_Y := Copy_Y + 2;
end loop;
end Put_Middle_Bushes;
----------------------------------------------------------------------------
begin
Put_Top_Bottom_Bushes(Org_X, Org_Y);
Put_Top_Bottom_Bushes(Org_X, Bottom_Y);
Put_Middle_Bushes(Org_X, Org_Y);
Put_Middle_Bushes(Right_X, Org_Y);
end Put_Bushes;
--------------------------------------------------------------------------------
procedure Check_Out_Of_Bounds(X_Gra, Y_Gra, Width, Height, Size_Of_Water : in Integer; Running : in out Boolean) is
Background_Start_X : Integer := 40;
Background_Start_Y : Integer := 10;
begin
if (X_Gra <= Size_Of_Water + Background_Start_X or X_Gra >= Width - 2*Size_Of_Water) or
(Y_Gra <= Size_Of_Water + Background_Start_Y or Y_Gra >= Height - 2*Size_Of_Water) then
Running := False;
end if;
end Check_Out_Of_Bounds;
--------------------------------------------------------------------------------
procedure Setup_Terminal is
begin
Set_Buffer_Mode(Off);
Set_Echo_Mode(Off);
Cursor_Invisible;
end Setup_Terminal;
--------------------------------------------------------------------------------
procedure Start_Up_Screen(Name : out String) is
begin
Set_Background_Colour(White);
Put_Line("THIS IS A<NAME>!");
Put("ENTER YOUR NAME: ");
Get(Name);
Skip_Line;
Reset_Colours_And_Text_Modes;
end Start_Up_Screen;
--------------------------------------------------------------------------------
procedure Put_End_Screen(X_Start, Y_Start, X_Range, Y_Range : in Integer) is
Org_X : Integer := X_Start;
Org_Y : Integer := Y_Start;
Temp_X : Integer := X_Start;
begin
Set_Background_Colour(White);
for I in 1..Y_Range loop
for J in 1..X_Range loop
Goto_XY(Org_X, Org_Y);
Put(" ");
Org_X := Org_X + 1;
end loop;
Org_X := Temp_X;
Org_Y := Org_Y + 1;
end loop;
end Put_End_Screen;
--------------------------------------------------------------------------------
procedure Exit_Game is
begin
Set_Echo_Mode(On);
Set_Buffer_Mode(On);
Cursor_Visible;
Reset_Colours_And_Text_Modes;
Reset_To_Original_Window_Settings;
end Exit_Game;
--------------------------------------------------------------------------------
end graphics;
|
src/main/antlr/GraphqlCommon.g4 | salewski/graphql-java | 0 | 1909 | grammar GraphqlCommon;
operationType : SUBSCRIPTION | MUTATION | QUERY;
description : stringValue;
enumValue : name ;
arrayValue: '[' value* ']';
arrayValueWithVariable: '[' valueWithVariable* ']';
objectValue: '{' objectField* '}';
objectValueWithVariable: '{' objectFieldWithVariable* '}';
objectField : name ':' value;
objectFieldWithVariable : name ':' valueWithVariable;
directives : directive+;
directive :'@' name arguments?;
arguments : '(' argument+ ')';
argument : name ':' valueWithVariable;
name: NAME | FRAGMENT | QUERY | MUTATION | SUBSCRIPTION | SCHEMA | SCALAR | TYPE | INTERFACE | IMPLEMENTS | ENUM | UNION | INPUT | EXTEND | DIRECTIVE;
value :
stringValue |
IntValue |
FloatValue |
BooleanValue |
NullValue |
enumValue |
arrayValue |
objectValue;
valueWithVariable :
variable |
stringValue |
IntValue |
FloatValue |
BooleanValue |
NullValue |
enumValue |
arrayValueWithVariable |
objectValueWithVariable;
variable : '$' name;
defaultValue : '=' value;
stringValue
: TripleQuotedStringValue
| StringValue
;
type : typeName | listType | nonNullType;
typeName : name;
listType : '[' type ']';
nonNullType: typeName '!' | listType '!';
BooleanValue: 'true' | 'false';
NullValue: 'null';
FRAGMENT: 'fragment';
QUERY: 'query';
MUTATION: 'mutation';
SUBSCRIPTION: 'subscription';
SCHEMA: 'schema';
SCALAR: 'scalar';
TYPE: 'type';
INTERFACE: 'interface';
IMPLEMENTS: 'implements';
ENUM: 'enum';
UNION: 'union';
INPUT: 'input';
EXTEND: 'extend';
DIRECTIVE: 'directive';
NAME: [_A-Za-z][_0-9A-Za-z]*;
IntValue : Sign? IntegerPart;
FloatValue : Sign? IntegerPart ('.' Digit+)? ExponentPart?;
Sign : '-';
IntegerPart : '0' | NonZeroDigit | NonZeroDigit Digit+;
NonZeroDigit: '1'.. '9';
ExponentPart : ('e'|'E') Sign? Digit+;
Digit : '0'..'9';
StringValue
: '"' ( ~["\\\n\r\u2028\u2029] | EscapedChar )* '"'
;
TripleQuotedStringValue
: '"""' TripleQuotedStringPart? '"""'
;
// Fragments never become a token of their own: they are only used inside other lexer rules
fragment TripleQuotedStringPart : ( EscapedTripleQuote | SourceCharacter )+?;
fragment EscapedTripleQuote : '\\"""';
fragment SourceCharacter :[\u0009\u000A\u000D\u0020-\uFFFF];
Comment: '#' ~[\n\r\u2028\u2029]* -> channel(2);
fragment EscapedChar : '\\' (["\\/bfnrt] | Unicode) ;
fragment Unicode : 'u' Hex Hex Hex Hex ;
fragment Hex : [0-9a-fA-F] ;
LF: [\n] -> channel(3);
CR: [\r] -> channel(3);
LineTerminator: [\u2028\u2029] -> channel(3);
Space : [\u0020] -> channel(3);
Tab : [\u0009] -> channel(3);
Comma : ',' -> channel(3);
UnicodeBOM : [\ufeff] -> channel(3);
|
mergesort_v1.asm | kibiwotthenry/MergeSortInMIPS | 0 | 171767 | <filename>mergesort_v1.asm
#########################################################################################
# #
# Program: MERGESORT In MIPS Assembly #
# Author: <NAME> #
# #
# #
# #
#########################################################################################
.data
list: .space 100000 # original array of unsorted values
left: .space 100000 # temporary array to hold left half of main array
right: .space 100000 # temporary array to hold right half of main array
n: .word 0 # Holds the number of values to be sorted
arraySize: .word 0
arrayEndAddress:.word 0
prompt1: .asciiz "Enter n: "
prompt2: .asciiz "Enter element "
dialog1: .asciiz "The size of array entered is not power of 2!"
dialog2: .asciiz "The sorted list is: "
space: .asciiz " "
colon: .asciiz ": "
eol: .asciiz "\n"
.text
main:
la $a0, prompt1
li $v0, 4
syscall
li $v0, 5
syscall
sw $v0, n
lw $t1, n
sll $t1, $t1, 2
li $t2, 1
li $t0, 0
writeElements:
bge $t0, $t1, done
la $a0,prompt2
li $v0, 4
syscall
move $a0, $t2
li $v0, 1
syscall
add $t2, $t2, 1
la $a0,colon
li $v0, 4
syscall
li $v0, 5
syscall
sw $v0, list($t0)
add $t0, $t0, 4
j writeElements
done:
sw $t0, arrayEndAddress
la $t1, list
sub $t0, $t0, $t1
sw $t0, arraySize
jal mergesort
jal printArray
exit:
li $v0, 10
syscall
#################################################################################
# Function: Mergesort #
# Description: Splits the Array (or subarray) into smaller subarray #
# Receives: Nothing #
# Returns: Nothing #
mergesort: #
#################################################################################
add $sp, $sp, -4
sw $ra, 0($sp)
lw $t0, n
sub $t0, $t0, 1
li $t1, 1
for1:
li $t2, 0
li $t3, 0
li $t4, 0
for2:
addu $t3, $t2, $t1
sub $t3, $t3, 1
sll $t4, $t1, 1
addu $t4, $t4, $t2
sub $t4, $t4, 1
findmin:
blt $t4, $t0, setmin
move $t4, $t0
setmin: move $t4, $t4
###################################
move $a0, $t2
li $v0, 1
syscall
la $a0, space
li $v0, 4
syscall
move $a0, $t3
li $v0, 1
syscall
la $a0, space
li $v0, 4
syscall
move $a0, $t4
li $v0, 1
syscall
la $a0, eol
li $v0, 4
syscall
###################################
jal merge
sll $t5, $t1, 1
addu $t2, $t2, $t5
blt $t2, $t0, for2
sll $t1, $t1, 1
ble $t1, $t0, for1
mergesortDone:
lw $ra, 0($sp)
add $sp, $sp, 4
jr $ra
########################################################################################################
# Function: Merge #
# Description: combines two subarrays into one sorted array and updates the original array #
# Receives: -$t2, $t3, $t #
# - $t2 has lower index of subarray #
# - $t3 has the middle index of the subarray #
# - $t4 has the index of the end of the subarray #
# Returns: Nothing #
merge: #
#########################################################################################################
addi $sp, $sp, -20
sw $t0, 0($sp)
sw $t1, 4($sp)
sw $t2, 8($sp)
sw $t3, 12($sp)
sw $t4, 16($sp)
lw $s2, 8($sp)
lw $s3, 12($sp)
lw $s4, 16($sp)
addi $t0, $s3,1
sub $t0, $t0, $s2
sub $t1, $s4, $s3
li $t3, 0
li $t4, 0
for3: #copy left half of array
add $s5, $s2, $t3
sll $s5, $s5, 2
lw $t5, list($s5)
sll $s6, $t3, 2
sw $t5, left($s6)
addiu $t3, $t3, 1
sltu $t9,$t3, $t0
bne $t9, $0, for3
for4: #copy right half of the array
addi $s5, $s3,1
add $s5, $s5, $t4
sll $s5, $s5, 2
lw $t5, list($s5)
sll $s6, $t4, 2
sw $t5, right($s6)
addi $t4, $t4, 1
sltu $t9, $t4, $t1
bne $t9, $0, for4
li $t3, 0
li $t4, 0
move $s0, $s2
while1: #loop to sort the subarrays
slt $a2, $t3, $t0
slt $a3, $t4, $t1
and $v1,$a2, $a3
beqz $v1, while2
sll $s2, $t3, 2
lw $t5, left($s2)
sll $s3, $t4, 2
lw $t6, right($s3)
sll $s4, $s0, 2
if:
bgt $t5, $t6, else
sw $t5, list($s4)
addi $t3, $t3, 1
b loop
else:
sw $t6, list($s4)
addi $t4, $t4, 1
b loop
loop:
addi $s0, $s0, 1
j while1
while2: #copy the remaining values of the left subarray into the original array
bge $t3, $t0, while3
sll $s2, $t3, 2
lw $t5, left($s2)
sll $s4, $s0, 2
sw $t5, list($s4)
addi $t3, $t3, 1
addi $s0, $s0, 1
j while2
while3: #copy the remaining values of the right subarray into the original array
bge $t4, $t1, doneMerge
sll $s2, $t4, 2
lw $t5, right($s2)
sll $s4, $s0, 2
sw $t5, list($s4)
addi $t4, $t3, 1
addi $s0, $s0, 1
j while3
doneMerge:
lw $t2, 8($sp)
lw $t1, 4($sp)
lw $t0, 0($sp)
addi $sp, $sp, 20
jr $ra
########################################################################################################
# Function: printArray: #
# Description: Displays the sorted numbers on the screen #
# Receives: Nothing #
# Returns: Nothing #
printArray: #
#########################################################################################################
add $sp, $sp,-4
sw $ra, 0($sp)
la $a0, dialog2
li $v0, 4
syscall
li $t0, 0
lw $t1, n
loop1:
bge $t0, $t1, donePrint
sll $s0, $t0, 2
lw $a0, list($s0)
li $v0, 1
syscall
la $a0, space
li $v0, 4
syscall
add $t0, $t0, 1
j loop1
la $a0, eol
li $v0, 4
syscall
donePrint:
lw $ra, 0($sp)
jr $ra
|
Portfolio/3/old code/12_7_14/Assembly.g4 | mattmckillip/SE319 | 0 | 2635 | <filename>Portfolio/3/old code/12_7_14/Assembly.g4
grammar Assembly; // It is important to know the NAME of the grammar
/*----------------
* PARSER RULES
*----------------*/
start : (expr ';')+;
expr : INSTRUCTION (REGISTER COMMA REGISTER COMMA REGISTER) | INSTRUCTION (REGISTER COMMA REGISTER) | INSTRUCTION (REGISTER) | INSTRUCTION;
/*----------------
* LEXER RULES
*----------------*/
COMMA : ',';
NEWLINE : '\r'?'\n';
WS : ( ' ' | '\t' | '\r' | '\n' )+ {skip();};
INT : [0-9]+ ;
INSTRUCTION : 'ADD' | 'ADDI' | 'AND' | 'OR' | 'SLT' | 'SLTI' | 'SLL' | 'SRL' | 'XOR' | 'LW' | 'LWI' | 'SW' | 'PRINT';
REGISTER : 'R1' | 'R2' | 'R3' | 'R4'; |
Cubical/Foundations/Equiv/Base.agda | Edlyr/cubical | 0 | 503 | <gh_stars>0
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Foundations.Equiv.Base where
open import Cubical.Foundations.Function
open import Cubical.Foundations.Prelude
open import Cubical.Core.Glue public
using ( isEquiv ; equiv-proof ; _≃_ ; equivFun ; equivProof )
fiber : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} (f : A → B) (y : B) → Type (ℓ-max ℓ ℓ')
fiber {A = A} f y = Σ[ x ∈ A ] f x ≡ y
-- Helper function for constructing equivalences from pairs (f,g) that cancel each other up to definitional
-- equality. For such (f,g), the result type simplifies to isContr (fiber f b).
strictContrFibers : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} {f : A → B} (g : B → A) (b : B)
→ Σ[ t ∈ fiber f (f (g b)) ]
((t' : fiber f b) → Path (fiber f (f (g b))) t (g (f (t' .fst)) , cong (f ∘ g) (t' .snd)))
strictContrFibers {f = f} g b .fst = (g b , refl)
strictContrFibers {f = f} g b .snd (a , p) i = (g (p (~ i)) , λ j → f (g (p (~ i ∨ j))))
-- The identity equivalence
idIsEquiv : ∀ {ℓ} (A : Type ℓ) → isEquiv (idfun A)
idIsEquiv A .equiv-proof = strictContrFibers (idfun A)
idEquiv : ∀ {ℓ} (A : Type ℓ) → A ≃ A
idEquiv A .fst = idfun A
idEquiv A .snd = idIsEquiv A
|
src/sys/init.asm | neri/osz | 7 | 16447 | <filename>src/sys/init.asm
;;
;; SYSINIT: Root Process for MEG-OS Zero
;;
;; Copyright (c) MEG-OS project
;; All rights reserved.
;;
;; Redistribution and use in source and binary forms, with or without modification,
;; are permitted provided that the following conditions are met:
;;
;; * Redistributions of source code must retain the above copyright notice, this
;; list of conditions and the following disclaimer.
;;
;; * Redistributions in binary form must reproduce the above copyright notice, this
;; list of conditions and the following disclaimer in the documentation and/or
;; other materials provided with the distribution.
;;
;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
;; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
;; ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
;; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
;; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
;; ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;;
%include "osz.inc"
%define STDAUX_FILENO 3
%define STDPRN_FILENO 4
[CPU 8086]
[BITS 16]
[ORG 0x0100]
sub bp, bp
jmp _init
alignb 2
__bdos resw 1
_call_bdos:
jmp word [cs:__bdos]
; ---------------------------------------------------------------------
_init:
mov [__bdos], bp
mov sp, _END
; INIT STDIO
mov dx, _CON
mov ah, OSZ_OPEN
call _call_bdos
mov bx, ax
; mov cx, STDIN_FILENO
; mov ah, OSZ_DUP2
; call _call_bdos
mov cx, STDOUT_FILENO
mov ah, OSZ_DUP2
call _call_bdos
mov cx, STDERR_FILENO
mov ah, OSZ_DUP2
call _call_bdos
mov dx, _CON
mov ah, OSZ_OPEN
call _call_bdos
mov bx, ax
; mov cx, STDAUX_FILENO
; mov ah, OSZ_DUP2
; call _call_bdos
mov cx, STDPRN_FILENO
mov ah, OSZ_DUP2
call _call_bdos
; INVOKE SHELL
push cs
pop ds
xor bx, bx
mov es, bx
mov dx, _SHELL
mov ah, OSZ_EXEC
call _call_bdos
; SHUTDOWN
int 0x20
; ---------------------------------------------------------------------
_CON db "CON", 0
_NUL db "NUL", 0
_SHELL db "ZCOM.COM", 0
_CONFIG_SYS db "CONFIG.SYS", 0
_default_config:
db "dos=high", 13, 10
db "buffers=8", 13, 10
db "files=20", 13, 10
db "device=fdfs.sys", 13, 10
db 0
_buffer:
alignb 16
resb 256
_END:
|
10/antlr_learning/example/data/Data.g4 | SummerLife/building-my-computer | 10 | 1289 | grammar Data;
file : group+ ;
group: INT sequence[$INT.int] ;
sequence[int n]
locals [int i = 1]
: ({$i<=$n}? INT {$i++;})*
;
INT: [0-9]+ ;
WS : [ \t\n\r]+ -> skip ;
|
basic68k.asm | mattuna15/merlin | 9 | 105059 | *************************************************************************************
* *
* Enhanced BASIC for the Motorola MC680xx *
* *
* This version is for Merlin FPGA Computer. *
* <NAME> *
* *
*************************************************************************************
* *
* Enhanced BASIC for the Motorola MC680xx *
* *
* This version is for the TS2 single board computer. *
* <NAME> (<EMAIL>) *
* *
*************************************************************************************
* *
* Copyright(C) 2002-12 by <NAME>. This program may be freely distributed *
* for personal use only. All commercial rights are reserved. *
* *
* More 68000 and other projects can be found on my website at .. *
* *
* http://mycorner.no-ip.org/index.html *
* *
* mail : <EMAIL> *
* *
*************************************************************************************
* Ver 3.54
* Ver 3.54 adds experimental support for LOAD/SAVE using Hobbytronics
* USB Flash Drive Host Board
* Ver 3.53 fixes math error that affected exponentiation ("^") and
* EXP() function. Thanks to joelang for fix.
* Ver 3.52 stops USING$() from reading beyond the end of the format string
* Ver 3.51 fixes the UCASE$() and LCASE$() functions for null strings
* Ver 3.50 unary minus in concatenate generates a type mismatch error
* Ver 3.49 doesn't tokenise 'DEF' or 'DEC' within a hex value
* Ver 3.48 allows scientific notation underflow in the USING$() function
* Ver 3.47 traps the use of array elements as the FOR loop variable
* Ver 3.46 updates function and function variable handling
*************************************************************************************
*
* Ver 3.45 makes the handling of non existant variables consistent and gives the
* option of not returning an error for a non existant variable. If this is the
* behaviour you want just change novar to some non zero value
XREF outbyte
XREF inbyte_noecho
XREF havebyte
XDEF main
* Set the symbol FLASH_SUPPORT to 1 if you want to enable experimental
* support for LOAD/SAVE using a Hobbytronics USB Flash Drive Host
* Board.
novar EQU 0 * non existant variables cause errors
* Set the symbol FLASH_SUPPORT to 1 if you want to enable experimental
* support for LOAD/SAVE using a Hobbytronics USB Flash Drive Host
* Board.
FLASH_SUPPORT EQU 0
*************************************************************************************
* Ver 3.44 adds overflow indication to the USING$() function
* Ver 3.43 removes an undocumented feature of concatenating null strings
* Ver 3.42 reimplements backspace so that characters are overwritten with [SPACE]
* Ver 3.41 removes undocumented features of the USING$() function
* Ver 3.40 adds the USING$() function
* Ver 3.33 adds the file requester to LOAD and SAVE
* Ver 3.32 adds the optional ELSE clause to IF .. THEN
*************************************************************************************
*
* Version 3.25 adds the option to change the behaviour of INPUT so that a null
* response does not cause a program break. If this is the behaviour you want just
* change nobrk to some non zero value.
nobrk EQU 0 * null response to INPUT causes a break
*************************************************************************************
*
* Version 3.xx replaces the fixed RAM addressing from previous versions with a RAM
* pointer in a3. this means that this could now be run as a task on a multitasking
* system where memory resources may change.
*************************************************************************************
* This lot is in RAM
* OFFSET 0 * start of RAM
ram_strt ds.l $100 * allow 1K for the stack, this should be plenty
* for any BASIC program that doesn't do something
* silly, it could even be much less.
ram_base
LAB_WARM ds.w 1 * BASIC warm start entry point
Wrmjpv ds.l 1 * BASIC warm start jump vector
Usrjmp ds.w 1 * USR function JMP address
Usrjpv ds.l 1 * USR function JMP vector
* system dependant i/o vectors
* these are in RAM and are set at start-up
V_INPT ds.w 1 * non halting scan input device entry point
V_INPTv ds.l 1 * non halting scan input device jump vector
V_OUTP ds.w 1 * send byte to output device entry point
V_OUTPv ds.l 1 * send byte to output device jump vector
V_LOAD ds.w 1 * load BASIC program entry point
V_LOADv ds.l 1 * load BASIC program jump vector
V_SAVE ds.w 1 * save BASIC program entry point
V_SAVEv ds.l 1 * save BASIC program jump vector
V_CTLC ds.w 1 * save CTRL-C check entry point
V_CTLCv ds.l 1 * save CTRL-C check jump vector
Itemp ds.l 1 * temporary integer (for GOTO etc)
Smeml ds.l 1 * start of memory (start of program)
* the program is stored as a series of lines each line having the following format
*
* ds.l 1 * pointer to the next line or $00000000 if [EOT]
* ds.l 1 * line number
* ds.b n * program bytes
* dc.b $00 * [EOL] marker, there will be a second $00 byte, if
* * needed, to pad the line to an even number of bytes
Sfncl ds.l 1 * start of functions (end of Program)
* the functions are stored as function name, function execute pointer and function
* variable name
*
* ds.l 1 * name
* ds.l 1 * execute pointer
* ds.l 1 * function variable
Svarl ds.l 1 * start of variables (end of functions)
* the variables are stored as variable name, variable value
*
* ds.l 1 * name
* ds.l 1 * packed float or integer value
Sstrl ds.l 1 * start of strings (end of variables)
* the strings are stored as string name, string pointer and string length
*
* ds.l 1 * name
* ds.l 1 * string pointer
* ds.w 1 * string length
Sarryl ds.l 1 * start of arrays (end of strings)
* the arrays are stored as array name, array size, array dimensions count, array
* dimensions upper bounds and array elements
*
* ds.l 1 * name
* ds.l 1 * size including this header
* ds.w 1 * dimensions count
* ds.w 1 * 1st dimension upper bound
* ds.w 1 * 2nd dimension upper bound
* ... * ...
* ds.w 1 * nth dimension upper bound
*
* then (i1+1)*(i2+1)...*(in+1) of either ..
*
* ds.l 1 * packed float or integer value
*
* .. if float or integer, or ..
*
* ds.l 1 * string pointer
* ds.w 1 * string length
*
* .. if string
Earryl ds.l 1 * end of arrays (start of free mem)
Sstorl ds.l 1 * string storage (moving down)
Ememl ds.l 1 * end of memory (upper bound of RAM)
Sutill ds.l 1 * string utility ptr
Clinel ds.l 1 * current line (Basic line number)
Blinel ds.l 1 * break line (Basic line number)
Cpntrl ds.l 1 * continue pointer
Dlinel ds.l 1 * current DATA line
Dptrl ds.l 1 * DATA pointer
Rdptrl ds.l 1 * read pointer
Varname ds.l 1 * current var name
Cvaral ds.l 1 * current var address
Lvarpl ds.l 1 * variable pointer for LET and FOR/NEXT
des_sk_e ds.l 6 * descriptor stack end address
des_sk * descriptor stack start address
* use a4 for the descriptor pointer
ds.w 1
Ibuffs ds.l $40 * start of input buffer
Ibuffe
* end of input buffer
FAC1_m ds.l 1 * FAC1 mantissa1
FAC1_e ds.w 1 * FAC1 exponent
FAC1_s EQU FAC1_e+1 * FAC1 sign (b7)
ds.w 1
FAC2_m ds.l 1 * FAC2 mantissa1
FAC2_e ds.l 1 * FAC2 exponent
FAC2_s EQU FAC2_e+1 * FAC2 sign (b7)
FAC_sc EQU FAC2_e+2 * FAC sign comparison, Acc#1 vs #2
flag EQU FAC2_e+3 * flag byte for divide routine
PRNlword ds.l 1 * PRNG seed long word
ut1_pl ds.l 1 * utility pointer 1
Asptl ds.l 1 * array size/pointer
Astrtl ds.l 1 * array start pointer
numexp EQU Astrtl * string to float number exponent count
expcnt EQU Astrtl+1 * string to float exponent count
expneg EQU Astrtl+3 * string to float eval exponent -ve flag
func_l ds.l 1 * function pointer
* these two need to be a word aligned pair !
Defdim ds.w 1 * default DIM flag
cosout EQU Defdim * flag which CORDIC output (re-use byte)
Dtypef EQU Defdim+1 * data type flag, $80=string, $40=integer, $00=float
Binss ds.l 4 * number to bin string start (32 chrs)
Decss ds.l 1 * number to decimal string start (16 chrs)
ds.w 1 *
Usdss ds.w 1 * unsigned decimal string start (10 chrs)
Hexss ds.l 2 * number to hex string start (8 chrs)
BHsend ds.w 1 * bin/decimal/hex string end
prstk ds.b 1 * stacked function index
tpower ds.b 1 * remember CORDIC power
Asrch ds.b 1 * scan-between-quotes flag, alt search character
Dimcnt ds.b 1 * # of dimensions
Breakf ds.b 1 * break flag, $00=END else=break
Oquote ds.b 1 * open quote flag (Flag: DATA; LIST; memory)
Gclctd ds.b 1 * garbage collected flag
Sufnxf ds.b 1 * subscript/FNX flag, 1xxx xxx = FN(0xxx xxx)
Imode ds.b 1 * input mode flag, $00=INPUT, $98=READ
Cflag ds.b 1 * comparison evaluation flag
TabSiz ds.b 1 * TAB step size
comp_f ds.b 1 * compare function flag, bits 0,1 and 2 used
* bit 2 set if >
* bit 1 set if =
* bit 0 set if <
Nullct ds.b 1 * nulls output after each line
TPos ds.b 1 * BASIC terminal position byte
TWidth ds.b 1 * BASIC terminal width byte
Iclim ds.b 1 * input column limit
ccflag ds.b 1 * CTRL-C check flag
ccbyte ds.b 1 * CTRL-C last received byte
ccnull ds.b 1 * CTRL-C last received byte 'life' timer
* these variables for simulator load/save routines
file_byte ds.b 1 * load/save data byte
file_id ds.l 1 * load/save file ID
dc.w 0 * dummy even value and zero pad byte
main
prg_strt
ram_addr EQU $80000 * RAM start address
ram_size EQU $aF0000 * RAM size
ACIA_1 EQU $00010040 * Console ACIA base address
ACIA_2 EQU $00010041 * Auxiliary ACIA base address
BRA code_start * For convenience, so you can start from first address
*************************************************************************************
*
* the following code is simulator specific, change to suit your system
* Output character to the console from register d0.b
VEC_OUT
jsr outbyte
RTS
* Output character to the second (aux) serial port from register d0.b
ifne FLASH_SUPPORT
VEC_OUT2
MOVEM.L A0/D1,-(A7) * Save working registers
LEA.L ACIA_2,A0 * A0 points to console ACIA
TXNOTREADY1
MOVE.B (A0),D1 * Read ACIA status
BTST #1,D1 * Test TDRE bit
BEQ.s TXNOTREADY1 * Until ACIA Tx ready
MOVE.B D0,2(A0) * Write character to send
MOVEM.L (A7)+,A0/D1 * Restore working registers
RTS
* Output null terminated string pointed to by A0 to first serial port.
PRINTSTRING1
MOVEM.L A0/D0,-(A7) * Save working registers
LP1 CMP.B #0,(A0) * Is it null?
BEQ RET1 * If so, return
MOVE.B (A0)+,D0 * Get character and advance pointer
JSR VEC_OUT * Output it
BRA LP1 * Continue for rest of string
RET1 MOVEM.L (A7)+,A0/D0 * Restore working registers
RTS * Return
* Output null terminated string pointed to by A0 to second serial port.
PRINTSTRING2
MOVEM.L A0/D0,-(A7) * Save working registers
LP2 CMP.B #0,(A0) * Is it null?
BEQ RET2 * If so, return
MOVE.B (A0)+,D0 * Get character and advance pointer
JSR VEC_OUT2 * Output it
BRA LP2 * Continue for rest of string
RET2 MOVEM.L (A7)+,A0/D0 * Restore working registers
RTS * Return
endc
*************************************************************************************
*
* input a character from the console into register d0
* else return Cb=0 if there's no character available
VEC_IN
jsr havebyte
CMP #0,D0
BEQ.s RXNOTREADY
jsr inbyte_noecho
ORI.B #1,CCR * Set the carry, flag we got a byte
RTS * Return
RXNOTREADY
ANDI.B #$FE,CCR * Clear the carry, flag character not available
RTS
* Input routine used in LOAD mode to read file from USB flash storage.
ifne FLASH_SUPPORT
VEC_IN2
MOVEM.L A0/D1,-(A7) * Save working registers
LEA.L VEC_OUT2,A0 * Redirect output to aux. port.
MOVE.L A0,V_OUTPv(a3)
* The first time, send READ <filename> 1 1
* Subsequent times, send READ <filename> n 1
LEA LAB_READN(pc),A0 * Send READ command string
BSR PRINTSTRING2 * Print null terminated string
LEA load_filename(A3),A0 * Send filename string
BSR PRINTSTRING2 * Print null terminated string
MOVE.B #' ',D0 * Send space
JSR VEC_OUT2
CMP.B #1,load_first(A3) * First time?
BNE NOTFIRST1
MOVE.B #'1',D0 * Send '1'
CLR.B load_first(A3) * Clear first flag
BRA SENDCMD1
NOTFIRST1
MOVE.B #'n',D0 * Send 'n'
SENDCMD1
JSR VEC_OUT2
MOVE.B #' ',D0 * Send space
JSR VEC_OUT2
MOVE.B #'1',D0 * Send '1'
JSR VEC_OUT2
MOVE.B #$0D,D0 * Send <Return>
JSR VEC_OUT2
LEA.L VEC_OUT,A0 * Redirect output back to console port.
MOVE.L A0,V_OUTPv(a3)
* Read one byte from USB host
LEA.L ACIA_2,A0 * A0 points to console ACIA
RXNOTREADY2
MOVE.B (A0),D1 * Read ACIA status
BTST #0,D1 * Test RDRF bit
BEQ.S RXNOTREADY2 * Branch if ACIA Rx not ready
MOVE.B 2(A0),D0 * Read character received
* Check for end of file character ('~') and if found, redirect
* input back to console port.
CMP.B #'~',D0 * End of file marker?
BNE NOTEOF
MOVE.B #$0D,D0 * Convert '~' to a Return
LEA.L VEC_IN,A0 * Redirect input back to console port.
MOVE.L A0,V_INPTv(a3)
NOTEOF
MOVEM.L (A7)+,A0/D1 * Restore working registers
ORI.b #1,CCR * Set the carry, flag we got a byte
RTS * Return
endc
*************************************************************************************
*
* LOAD routine for the TS2 computer (not implemented)
ifeq FLASH_SUPPORT
VEC_LD
MOVEQ #$2E,d7 * error code $2E "Not implemented" error
BRA LAB_XERR * do error #d7, then warm start
endc
* LOAD routine for the TS2 computer. Supports a Hobbytronics USB Flash
* Drive Host Board connected to the auxiliary serial port.
ifne FLASH_SUPPORT
VEC_LD LEA LAB_FILENAME(PC),A0 * Prompt for filename.
BSR PRINTSTRING1 * Print null terminated string
MOVE.L A3,A2 * Save pointer to RAM variables
GETFN1 JSR VEC_IN * Get character
BCC GETFN1 * Go back if carry clear, indicating no key pressed
JSR VEC_OUT * Echo the character
CMP.B #$0D,D0 * Was it <Return>?
BEQ ENDLN1 * If so, branch
CMP.B #$7F,D0 * Was it <Delete>?
BEQ DELETE1 * If so, handle delete
CMP.B #$08,D0 * Was it <Backspace?
BEQ DELETE1 * If so, handle as delete
MOVE.B D0,load_filename(A2) * Save in buffer
ADDQ.L #1,A2 * Advance string pointer
BRA GETFN1 * Go back and get next character
DELETE1 SUBQ.L #1,A2 * Delete last character entered
BRA GETFN1 * Go back and get next character
ENDLN1 MOVE.B #0,load_filename(A2) * Add terminating null to filename
LEA.L VEC_IN2,A0 * Redirect input from aux. port.
MOVE.L A0,V_INPTv(a3)
MOVE.B #1,load_first(A3) * Set load_first flag
* Input routine will detect end of file and redirect input back to
* console port.
RTS
endc
*************************************************************************************
*
* SAVE routine for the TS2 computer (not implemented)
ifeq FLASH_SUPPORT
VEC_SV
MOVEQ #$2E,d7 * error code $2E "Not implemented" error
BRA LAB_XERR * do error #d7, then warm start
endc
ifne FLASH_SUPPORT
* SAVE routine for the TS2 computer. Supports a Hobbytronics USB Flash
* Drive Host Board connected to the auxiliary serial port.
* TODO: Make configurable at build time
VEC_SV LEA LAB_FILENAME(PC),A0 * Prompt for filename.
BSR PRINTSTRING1 * Print null terminated string
MOVE.L A3,A2 * Save pointer to RAM variables
GETFN JSR VEC_IN * Get character
BCC GETFN * Go back if carry clear, indicating no key pressed
JSR VEC_OUT * Echo the character
CMP.B #$0D,D0 * Was it <Return>?
BEQ ENDLN * If so, branch
CMP.B #$7F,D0 * Was it <Delete>?
BEQ DELETE * If so, handle delete
CMP.B #$08,D0 * Was it <Backspace?
BEQ DELETE * If so, handle as delete
MOVE.B D0,load_filename(A2) * Save in buffer
ADDQ.L #1,A2 * Advance string pointer
BRA GETFN * Go back and get next character
DELETE SUBQ.L #1,A2 * Delete last character entered
BRA GETFN * Go back and get next character
ENDLN MOVE.B #0,load_filename(A2) * Add terminating null to filename
LEA.L VEC_OUT2,A0 * Redirect output to aux. port.
MOVE.L A0,V_OUTPv(a3)
LEA LAB_WRITE(pc),A0 * Send WRITE command string
BSR PRINTSTRING2 * Print null terminated string
LEA load_filename(A3),A0 * Send filename string
BSR PRINTSTRING2 * Print null terminated string
MOVE.B #$0D,D0 * Send <Return>
JSR VEC_OUT2
MOVE.l #356000,d0 * Delay approx. 1 second to allow USB to create file
DELAY SUBQ.l #1,d0
BNE DELAY
MOVEQ #0,d0 * Tells LIST no arguments
ANDI.b #$FE,CCR * Clear carry
BSR LAB_LIST * Call LIST routine
MOVEQ #'~',d0 * Send tilde symbol indicate end of file (used when loading)
BSR LAB_PRNA
MOVEQ #26,d0 * Send Control-Z to indicate end of file save operation
BSR LAB_PRNA
LEA.L VEC_OUT,A0 * Redirect output back to console port.
MOVE.L A0,V_OUTPv(a3)
RTS * Return
LAB_WRITE
dc.b '$WRITE ',$00
LAB_READN
dc.b '$READ ',$00
LAB_FILENAME
dc.b 'Filename? ',$00
endc
even
*************************************************************************************
code_start
* Set up ACIA parameters
LEA.L ACIA_1,A0 * A0 points to console ACIA
MOVE.B #$15,(A0) * Set up ACIA1 constants (no IRQ,
* RTS* low, 8 bit, no parity, 1 stop)
LEA.L ACIA_2,A0 * A0 points to aux. ACIA
MOVE.B #$15,(A0) * Set up ACIA2 constants (no IRQ,
* RTS* low, 8 bit, no parity, 1 stop)
* to tell EhBASIC where and how much RAM it has pass the address in a0 and the size
* in d0. these values are at the end of the .inc file
MOVEA.l #ram_addr,a0 * tell BASIC where RAM starts
MOVE.l #ram_size,d0 * tell BASIC how big RAM is
* end of simulator specific code
****************************************************************************************
****************************************************************************************
****************************************************************************************
****************************************************************************************
*
* Register use :- (must improve this !!)
*
* a6 - temp Bpntr * temporary BASIC execute pointer
* a5 - Bpntr * BASIC execute (get byte) pointer
* a4 - des_sk * descriptor stack pointer
* a3 - ram_strt * start of RAM. all RAM references are offsets
* * from this value
*
*************************************************************************************
*
* BASIC cold start entry point. assume entry with RAM address in a0 and RAM length
* in d0
LAB_COLD
CMP.l #$4000,d0 * compare size with 16k
BGE.s LAB_sizok * branch if >= 16k
MOVEQ #5,d0 * error 5 - not enough RAM
move.b #228,D7 * Go to TUTOR function
trap #14 * Call TRAP14 handler
LAB_sizok
MOVEA.l a0,a3 * copy RAM base to a3
ADDA.l d0,a0 * a0 is top of RAM
MOVE.l a0,Ememl(a3) * set end of mem
LEA ram_base(a3),sp * set stack to RAM start + 1k
MOVE.w #$4EF9,d0 * JMP opcode
MOVEA.l sp,a0 * point to start of vector table
MOVE.w d0,(a0)+ * LAB_WARM
LEA LAB_COLD(pc),a1 * initial warm start vector
MOVE.l a1,(a0)+ * set vector
MOVE.w d0,(a0)+ * Usrjmp
LEA LAB_FCER(pc),a1 * initial user function vector
* "Function call" error
MOVE.l a1,(a0)+ * set vector
MOVE.w d0,(a0)+ * V_INPT JMP opcode
LEA VEC_IN(pc),a1 * get byte from input device vector
MOVE.l a1,(a0)+ * set vector
MOVE.w d0,(a0)+ * V_OUTP JMP opcode
LEA VEC_OUT(pc),a1 * send byte to output device vector
MOVE.l a1,(a0)+ * set vector
MOVE.w d0,(a0)+ * V_LOAD JMP opcode
LEA VEC_LD(pc),a1 * load BASIC program vector
MOVE.l a1,(a0)+ * set vector
MOVE.w d0,(a0)+ * V_SAVE JMP opcode
LEA VEC_SV(pc),a1 * save BASIC program vector
MOVE.l a1,(a0)+ * set vector
MOVE.w d0,(a0)+ * V_CTLC JMP opcode
LEA VEC_CC(pc),a1 * save CTRL-C check vector
MOVE.l a1,(a0)+ * set vector
* set-up start values
*##LAB_GMEM
MOVEQ #$00,d0 * clear d0
MOVE.b d0,Nullct(a3) * default NULL count
MOVE.b d0,TPos(a3) * clear terminal position
MOVE.b d0,ccflag(a3) * allow CTRL-C check
MOVE.w d0,prg_strt-2(a3) * clear start word
MOVE.w d0,BHsend(a3) * clear value to string end word
MOVE.b #$50,TWidth(a3) * default terminal width byte for simulator
MOVE.b #$0E,TabSiz(a3) * save default tab size = 14
MOVE.b #$38,Iclim(a3) * default limit for TAB = 14 for simulator
LEA des_sk(a3),a4 * set descriptor stack start
LEA prg_strt(a3),a0 * get start of mem
MOVE.l a0,Smeml(a3) * save start of mem
BSR LAB_1463 * do "NEW" and "CLEAR"
BSR LAB_CRLF * print CR/LF
MOVE.l Ememl(a3),d0 * get end of mem
SUB.l Smeml(a3),d0 * subtract start of mem
BSR LAB_295E * print d0 as unsigned integer (bytes free)
LEA LAB_SMSG(pc),a0 * point to start message
BSR LAB_18C3 * print null terminated string from memory
LEA LAB_RSED(pc),a0 * get pointer to value
BSR LAB_UFAC * unpack memory (a0) into FAC1
LEA LAB_1274(pc),a0 * get warm start vector
MOVE.l a0,Wrmjpv(a3) * set warm start vector
BSR LAB_RND * initialise
JMP LAB_WARM(a3) * go do warm start
*************************************************************************************
*
* do format error
LAB_FOER
MOVEQ #$2C,d7 * error code $2C "Format" error
BRA.s LAB_XERR * do error #d7, then warm start
*************************************************************************************
*
* do address error
LAB_ADER
MOVEQ #$2A,d7 * error code $2A "Address" error
BRA.s LAB_XERR * do error #d7, then warm start
*************************************************************************************
*
* do wrong dimensions error
LAB_WDER
MOVEQ #$28,d7 * error code $28 "Wrong dimensions" error
BRA.s LAB_XERR * do error #d7, then warm start
*************************************************************************************
*
* do undimensioned array error
LAB_UDER
MOVEQ #$26,d7 * error code $26 "undimensioned array" error
BRA.s LAB_XERR * do error #d7, then warm start
*************************************************************************************
*
* do undefined variable error
LAB_UVER
* if you do want a non existant variable to return an error then leave the novar
* value at the top of this file set to zero
ifeq novar
MOVEQ #$24,d7 * error code $24 "undefined variable" error
BRA.s LAB_XERR * do error #d7, then warm start
endc
* if you want a non existant variable to return a null value then set the novar
* value at the top of this file to some non zero value
ifne novar
ADD.l d0,d0 * .......$ .......& ........ .......0
SWAP d0 * ........ .......0 .......$ .......&
ROR.b #1,d0 * ........ .......0 .......$ &.......
LSR.w #1,d0 * ........ .......0 0....... $&.....�.
AND.b #$C0,d0 * mask the type bits
MOVE.b d0,Dtypef(a3) * save the data type
MOVEQ #0,d0 * clear d0 and set the zero flag
MOVEA.l d0,a0 * return a null address
RTS
endc
*************************************************************************************
*
* do loop without do error
LAB_LDER
MOVEQ #$22,d7 * error code $22 "LOOP without DO" error
BRA.s LAB_XERR * do error #d7, then warm start
*************************************************************************************
*
* do undefined function error
LAB_UFER
MOVEQ #$20,d7 * error code $20 "Undefined function" error
BRA.s LAB_XERR * do error #d7, then warm start
*************************************************************************************
*
* do can't continue error
LAB_CCER
MOVEQ #$1E,d7 * error code $1E "Can't continue" error
BRA.s LAB_XERR * do error #d7, then warm start
*************************************************************************************
*
* do string too complex error
LAB_SCER
MOVEQ #$1C,d7 * error code $1C "String too complex" error
BRA.s LAB_XERR * do error #d7, then warm start
*************************************************************************************
*
* do string too long error
LAB_SLER
MOVEQ #$1A,d7 * error code $1A "String too long" error
BRA.s LAB_XERR * do error #d7, then warm start
*************************************************************************************
*
* do type missmatch error
LAB_TMER
MOVEQ #$18,d7 * error code $18 "Type mismatch" error
BRA.s LAB_XERR * do error #d7, then warm start
*************************************************************************************
*
* do illegal direct error
LAB_IDER
MOVEQ #$16,d7 * error code $16 "Illegal direct" error
BRA.s LAB_XERR * do error #d7, then warm start
*************************************************************************************
*
* do divide by zero error
LAB_DZER
MOVEQ #$14,d7 * error code $14 "Divide by zero" error
BRA.s LAB_XERR * do error #d7, then warm start
*************************************************************************************
*
* do double dimension error
LAB_DDER
MOVEQ #$12,d7 * error code $12 "Double dimension" error
BRA.s LAB_XERR * do error #d7, then warm start
*************************************************************************************
*
* do array bounds error
LAB_ABER
MOVEQ #$10,d7 * error code $10 "Array bounds" error
BRA.s LAB_XERR * do error #d7, then warm start
*************************************************************************************
*
* do undefined satement error
LAB_USER
MOVEQ #$0E,d7 * error code $0E "Undefined statement" error
BRA.s LAB_XERR * do error #d7, then warm start
*************************************************************************************
*
* do out of memory error
LAB_OMER
MOVEQ #$0C,d7 * error code $0C "Out of memory" error
BRA.s LAB_XERR * do error #d7, then warm start
*************************************************************************************
*
* do overflow error
LAB_OFER
MOVEQ #$0A,d7 * error code $0A "Overflow" error
BRA.s LAB_XERR * do error #d7, then warm start
*************************************************************************************
*
* do function call error
LAB_FCER
MOVEQ #$08,d7 * error code $08 "Function call" error
BRA.s LAB_XERR * do error #d7, then warm start
*************************************************************************************
*
* do out of data error
LAB_ODER
MOVEQ #$06,d7 * error code $06 "Out of DATA" error
BRA.s LAB_XERR * do error #d7, then warm start
*************************************************************************************
*
* do return without gosub error
LAB_RGER
MOVEQ #$04,d7 * error code $04 "RETURN without GOSUB" error
BRA.s LAB_XERR * do error #d7, then warm start
*************************************************************************************
*
* do syntax error
LAB_SNER
MOVEQ #$02,d7 * error code $02 "Syntax" error
BRA.s LAB_XERR * do error #d7, then warm start
*************************************************************************************
*
* do next without for error
LAB_NFER
MOVEQ #$00,d7 * error code $00 "NEXT without FOR" error
*************************************************************************************
*
* do error #d7, then warm start
LAB_XERR
BSR LAB_1491 * flush stack & clear continue flag
BSR LAB_CRLF * print CR/LF
LEA LAB_BAER(pc),a1 * start of error message pointer table
MOVE.w (a1,d7.w),d7 * get error message offset
LEA (a1,d7.w),a0 * get error message address
BSR LAB_18C3 * print null terminated string from memory
LEA LAB_EMSG(pc),a0 * point to " Error" message
LAB_1269
BSR LAB_18C3 * print null terminated string from memory
MOVE.l Clinel(a3),d0 * get current line
BMI.s LAB_1274 * go do warm start if -ve # (was immediate mode)
* else print line number
BSR LAB_2953 * print " in line [LINE #]"
* BASIC warm start entry point, wait for Basic command
LAB_1274
LEA LAB_RMSG(pc),a0 * point to "Ready" message
BSR LAB_18C3 * go do print string
* wait for Basic command - no "Ready"
LAB_127D
MOVEQ #-1,d1 * set to -1
MOVE.l d1,Clinel(a3) * set current line #
MOVE.b d1,Breakf(a3) * set break flag
LEA Ibuffs(a3),a5 * set basic execute pointer ready for new line
LAB_127E
BSR LAB_1357 * call for BASIC input
BSR LAB_GBYT * scan memory
BEQ.s LAB_127E * loop while null
* got to interpret input line now ....
BCS.s LAB_1295 * branch if numeric character, handle new
* BASIC line
* no line number so do immediate mode, a5
* points to the buffer start
BSR LAB_13A6 * crunch keywords into Basic tokens
* crunch from (a5), output to (a0)
* returns ..
* d2 is length, d1 trashed, d0 trashed,
* a1 trashed
BRA LAB_15F6 * go scan & interpret code
*************************************************************************************
*
* handle a new BASIC line
LAB_1295
BSR LAB_GFPN * get fixed-point number into temp integer & d1
BSR LAB_13A6 * crunch keywords into Basic tokens
* crunch from (a5), output to (a0)
* returns .. d2 is length,
* d1 trashed, d0 trashed, a1 trashed
MOVE.l Itemp(a3),d1 * get required line #
BSR LAB_SSLN * search BASIC for d1 line number
* returns pointer in a0
BCS.s LAB_12E6 * branch if not found
* aroooogah! line # already exists! delete it
MOVEA.l (a0),a1 * get start of block (next line pointer)
MOVE.l Sfncl(a3),d0 * get end of block (start of functions)
SUB.l a1,d0 * subtract start of block ( = bytes to move)
LSR.l #1,d0 * /2 (word move)
SUBQ.l #1,d0 * adjust for DBF loop
SWAP d0 * swap high word to low word
MOVEA.l a0,a2 * copy destination
LAB_12AE
SWAP d0 * swap high word to low word
LAB_12B0
MOVE.w (a1)+,(a2)+ * copy word
DBF d0,LAB_12B0 * decrement low count and loop until done
SWAP d0 * swap high word to low word
DBF d0,LAB_12AE * decrement high count and loop until done
MOVE.l a2,Sfncl(a3) * start of functions
MOVE.l a2,Svarl(a3) * save start of variables
MOVE.l a2,Sstrl(a3) * start of strings
MOVE.l a2,Sarryl(a3) * save start of arrays
MOVE.l a2,Earryl(a3) * save end of arrays
* got new line in buffer and no existing same #
LAB_12E6
MOVE.b Ibuffs(a3),d0 * get byte from start of input buffer
BEQ.s LAB_1325 * if null line go do line chaining
* got new line and it isn't empty line
MOVEA.l Sfncl(a3),a1 * get start of functions (end of block to move)
LEA 8(a1,d2),a2 * copy it, add line length and add room for
* pointer and line number
MOVE.l a2,Sfncl(a3) * start of functions
MOVE.l a2,Svarl(a3) * save start of variables
MOVE.l a2,Sstrl(a3) * start of strings
MOVE.l a2,Sarryl(a3) * save start of arrays
MOVE.l a2,Earryl(a3) * save end of arrays
MOVE.l Ememl(a3),Sstorl(a3) * copy end of mem to start of strings, clear
* strings
MOVE.l a1,d1 * copy end of block to move
SUB.l a0,d1 * subtract start of block to move
LSR.l #1,d1 * /2 (word copy)
SUBQ.l #1,d1 * correct for loop end on -1
SWAP d1 * swap high word to low word
LAB_12FF
SWAP d1 * swap high word to low word
LAB_1301
MOVE.w -(a1),-(a2) * decrement pointers and copy word
DBF d1,LAB_1301 * decrement & loop
SWAP d1 * swap high word to low word
DBF d1,LAB_12FF * decrement high count and loop until done
* space is opened up, now copy the crunched line from the input buffer into the space
LEA Ibuffs(a3),a1 * source is input buffer
MOVEA.l a0,a2 * copy destination
MOVEQ #-1,d1 * set to allow re-chaining
MOVE.l d1,(a2)+ * set next line pointer (allow re-chaining)
MOVE.l Itemp(a3),(a2)+ * save line number
LSR.w #1,d2 * /2 (word copy)
SUBQ.w #1,d2 * correct for loop end on -1
LAB_1303
MOVE.w (a1)+,(a2)+ * copy word
DBF d2,LAB_1303 * decrement & loop
BRA.s LAB_1325 * go test for end of prog
* rebuild chaining of BASIC lines
LAB_132E
ADDQ.w #8,a0 * point to first code byte of line, there is
* always 1 byte + [EOL] as null entries are
* deleted
LAB_1330
TST.b (a0)+ * test byte
BNE.s LAB_1330 * loop if not [EOL]
* was [EOL] so get next line start
MOVE.w a0,d1 * past pad byte(s)
ANDI.w #1,d1 * mask odd bit
ADD.w d1,a0 * add back to ensure even
MOVE.l a0,(a1) * save next line pointer to current line
LAB_1325
MOVEA.l a0,a1 * copy pointer for this line
TST.l (a0) * test pointer to next line
BNE.s LAB_132E * not end of program yet so we must
* go and fix the pointers
BSR LAB_1477 * reset execution to start, clear variables
* and flush stack
BRA LAB_127D * now we just wait for Basic command, no "Ready"
*************************************************************************************
*
* receive a line from the keyboard
* character $08 as delete key, BACKSPACE on
* standard keyboard
LAB_134B
BSR LAB_PRNA * go print the character
MOVEQ #' ',d0 * load [SPACE]
BSR LAB_PRNA * go print
MOVEQ #$08,d0 * load [BACKSPACE]
BSR LAB_PRNA * go print
SUBQ.w #$01,d1 * decrement the buffer index (delete)
BRA.s LAB_1359 * re-enter loop
* print "? " and get BASIC input
* return a0 pointing to the buffer start
LAB_INLN
BSR LAB_18E3 * print "?" character
MOVEQ #' ',d0 * load " "
BSR LAB_PRNA * go print
* call for BASIC input (main entry point)
* return a0 pointing to the buffer start
LAB_1357
MOVEQ #$00,d1 * clear buffer index
LEA Ibuffs(a3),a0 * set buffer base pointer
LAB_1359
JSR V_INPT(a3) * call scan input device
BCC.s LAB_1359 * loop if no byte
BEQ.s LAB_1359 * loop if null byte
CMP.b #$07,d0 * compare with [BELL]
BEQ.s LAB_1378 * branch if [BELL]
CMP.b #$0D,d0 * compare with [CR]
BEQ LAB_1866 * do CR/LF exit if [CR]
TST.w d1 * set flags on buffer index
BNE.s LAB_1374 * branch if not empty
* the next two lines ignore any non printing character and [SPACE] if the input buffer
* is empty
CMP.b #' ',d0 * compare with [SP]+1
BLS.s LAB_1359 * if < ignore character
*## CMP.b #' '+1,d0 * compare with [SP]+1
*## BCS.s LAB_1359 * if < ignore character
LAB_1374
CMP.b #$08,d0 * compare with [BACKSPACE]
BEQ.s LAB_134B * go delete last character
LAB_1378
CMP.w #(Ibuffe-Ibuffs-1),d1 * compare character count with max-1
BCC.s LAB_138E * skip store & do [BELL] if buffer full
MOVE.b d0,(a0,d1.w) * else store in buffer
ADDQ.w #$01,d1 * increment index
LAB_137F
BSR LAB_PRNA * go print the character
BRA.s LAB_1359 * always loop for next character
* announce buffer full
LAB_138E
MOVEQ #$07,d0 * [BELL] character into d0
BRA.s LAB_137F * go print the [BELL] but ignore input character
*************************************************************************************
*
* copy a hex value without crunching
LAB_1392
MOVE.b d0,(a0,d2.w) * save the byte to the output
ADDQ.w #1,d2 * increment the buffer save index
ADDQ.w #1,d1 * increment the buffer read index
MOVE.b (a5,d1.w),d0 * get a byte from the input buffer
BEQ LAB_13EC * if [EOL] go save it without crunching
CMP.b #' ',d0 * compare the character with " "
BEQ.s LAB_1392 * if [SPACE] just go save it and get another
CMP.b #'0',d0 * compare the character with "0"
BCS.s LAB_13C6 * if < "0" quit the hex save loop
CMP.b #'9',d0 * compare with "9"
BLS.s LAB_1392 * if it is "0" to "9" save it and get another
MOVEQ #-33,d5 * mask xx0x xxxx, ASCII upper case
AND.b d0,d5 * mask the character
CMP.b #'A',d5 * compare with "A"
BCS.s LAB_13CC * if < "A" quit the hex save loop
CMP.b #'F',d5 * compare with "F"
BLS.s LAB_1392 * if it is "A" to "F" save it and get another
BRA.s LAB_13CC * else continue crunching
* crunch keywords into Basic tokens
* crunch from (a5), output to (a0)
* returns ..
* d4 trashed
* d3 trashed
* d2 is length
* d1 trashed
* d0 trashed
* a1 trashed
* this is the improved BASIC crunch routine and is 10 to 100 times faster than the
* old list search
LAB_13A6
MOVEQ #0,d1 * clear the read index
MOVE.l d1,d2 * clear the save index
MOVE.b d1,Oquote(a3) * clear the open quote/DATA flag
LAB_13AC
MOVEQ #0,d0 * clear word
MOVE.b (a5,d1.w),d0 * get byte from input buffer
BEQ.s LAB_13EC * if null save byte then continue crunching
CMP.b #'_',d0 * compare with "_"
BCC.s LAB_13EC * if >= "_" save byte then continue crunching
CMP.b #'<',d0 * compare with "<"
BCC.s LAB_13CC * if >= "<" go crunch
CMP.b #'0',d0 * compare with "0"
BCC.s LAB_13EC * if >= "0" save byte then continue crunching
MOVE.b d0,Asrch(a3) * save buffer byte as search character
CMP.b #$22,d0 * is it quote character?
BEQ.s LAB_1410 * branch if so (copy quoted string)
CMP.b #'$',d0 * is it the hex value character?
BEQ.s LAB_1392 * if so go copy a hex value
LAB_13C6
CMP.b #'*',d0 * compare with "*"
BCS.s LAB_13EC * if <= "*" save byte then continue crunching
* crunch rest
LAB_13CC
BTST.b #6,Oquote(a3) * test open quote/DATA token flag
BNE.s LAB_13EC * branch if b6 of Oquote set (was DATA)
* go save byte then continue crunching
SUB.b #$2A,d0 * normalise byte
ADD.w d0,d0 * *2 makes word offset (high byte=$00)
LEA TAB_CHRT(pc),a1 * get keyword offset table address
MOVE.w (a1,d0.w),d0 * get offset into keyword table
BMI.s LAB_141F * branch if no keywords for character
LEA TAB_STAR(pc),a1 * get keyword table address
ADDA.w d0,a1 * add keyword offset
MOVEQ #-1,d3 * clear index
MOVE.w d1,d4 * copy read index
LAB_13D6
ADDQ.w #1,d3 * increment table index
MOVE.b (a1,d3.w),d0 * get byte from table
LAB_13D8
BMI.s LAB_13EA * branch if token, save token and continue
* crunching
ADDQ.w #1,d4 * increment read index
CMP.b (a5,d4.w),d0 * compare byte from input buffer
BEQ.s LAB_13D6 * loop if character match
BRA.s LAB_1417 * branch if no match
LAB_13EA
MOVE.w d4,d1 * update read index
LAB_13EC
MOVE.b d0,(a0,d2.w) * save byte to output
ADDQ.w #1,d2 * increment buffer save index
ADDQ.w #1,d1 * increment buffer read index
TST.b d0 * set flags
BEQ.s LAB_142A * branch if was null [EOL]
* d0 holds token or byte here
SUB.b #$3A,d0 * subtract ":"
BEQ.s LAB_13FF * branch if it was ":" (is now $00)
* d0 now holds token-$3A
CMP.b #(TK_DATA-$3A),d0 * compare with DATA token - $3A
BNE.s LAB_1401 * branch if not DATA
* token was : or DATA
LAB_13FF
MOVE.b d0,Oquote(a3) * save token-$3A ($00 for ":", TK_DATA-$3A for
* DATA)
LAB_1401
SUB.b #(TK_REM-$3A),d0 * subtract REM token offset
BNE LAB_13AC * If wasn't REM then go crunch rest of line
MOVE.b d0,Asrch(a3) * else was REM so set search for [EOL]
* loop for REM, "..." etc.
LAB_1408
MOVE.b (a5,d1.w),d0 * get byte from input buffer
BEQ.s LAB_13EC * branch if null [EOL]
CMP.b Asrch(a3),d0 * compare with stored character
BEQ.s LAB_13EC * branch if match (end quote, REM, :, or DATA)
* entry for copy string in quotes, don't crunch
LAB_1410
MOVE.b d0,(a0,d2.w) * save byte to output
ADDQ.w #1,d2 * increment buffer save index
ADDQ.w #1,d1 * increment buffer read index
BRA.s LAB_1408 * loop
* not found keyword this go so find the end of this word in the table
LAB_1417
MOVE.w d1,d4 * reset read pointer
LAB_141B
ADDQ.w #1,d3 * increment keyword table pointer, flag
* unchanged
MOVE.b (a1,d3.w),d0 * get keyword table byte
BPL.s LAB_141B * if not end of keyword go do next byte
ADDQ.w #1,d3 * increment keyword table pointer flag
* unchanged
MOVE.b (a1,d3.w),d0 * get keyword table byte
BNE.s LAB_13D8 * go test next word if not zero byte (table end)
* reached end of table with no match
LAB_141F
MOVE.b (a5,d1.w),d0 * restore byte from input buffer
BRA.s LAB_13EC * go save byte in output and continue crunching
* reached [EOL]
LAB_142A
MOVEQ #0,d0 * ensure longword clear
BTST d0,d2 * test odd bit (fastest)
BEQ.s LAB_142C * branch if no bytes to fill
MOVE.b d0,(a0,d2.w) * clear next byte
ADDQ.w #1,d2 * increment buffer save index
LAB_142C
MOVE.l d0,(a0,d2.w) * clear next line pointer, EOT in immediate mode
RTS
*************************************************************************************
*
* search Basic for d1 line number from start of mem
LAB_SSLN
MOVEA.l Smeml(a3),a0 * get start of program mem
BRA.s LAB_SCLN * go search for required line from a0
LAB_145F
MOVEA.l d0,a0 * copy next line pointer
* search Basic for d1 line number from a0
* returns Cb=0 if found
* returns a0 pointer to found or next higher (not found) line
LAB_SCLN
MOVE.l (a0)+,d0 * get next line pointer and point to line #
BEQ.s LAB_145E * is end marker so we're done, do 'no line' exit
CMP.l (a0),d1 * compare this line # with required line #
BGT.s LAB_145F * loop if required # > this #
SUBQ.w #4,a0 * adjust pointer, flags not changed
RTS
LAB_145E
SUBQ.w #4,a0 * adjust pointer, flags not changed
SUBQ.l #1,d0 * make end program found = -1, set carry
RTS
*************************************************************************************
*
* perform NEW
LAB_NEW
BNE.s RTS_005 * exit if not end of statement (do syntax error)
LAB_1463
MOVEA.l Smeml(a3),a0 * point to start of program memory
MOVEQ #0,d0 * clear longword
MOVE.l d0,(a0)+ * clear first line, next line pointer
MOVE.l a0,Sfncl(a3) * set start of functions
* reset execution to start, clear variables and flush stack
LAB_1477
MOVEA.l Smeml(a3),a5 * reset BASIC execute pointer
SUBQ.w #1,a5 * -1 (as end of previous line)
* "CLEAR" command gets here
LAB_147A
MOVE.l Ememl(a3),Sstorl(a3) * save end of mem as bottom of string space
MOVE.l Sfncl(a3),d0 * get start of functions
MOVE.l d0,Svarl(a3) * start of variables
MOVE.l d0,Sstrl(a3) * start of strings
MOVE.l d0,Sarryl(a3) * set start of arrays
MOVE.l d0,Earryl(a3) * set end of arrays
LAB_1480
MOVEQ #0,d0 * set Zb
MOVE.b d0,ccnull(a3) * clear get byte countdown
BSR LAB_RESTORE * perform RESTORE command
* flush stack & clear continue flag
LAB_1491
LEA des_sk(a3),a4 * reset descriptor stack pointer
MOVE.l (sp)+,d0 * pull return address
LEA ram_base(a3),sp * set stack to RAM start + 1k, flush stack
MOVE.l d0,-(sp) * restore return address
MOVEQ #0,d0 * clear longword
MOVE.l d0,Cpntrl(a3) * clear continue pointer
MOVE.b d0,Sufnxf(a3) * clear subscript/FNX flag
RTS_005
RTS
*************************************************************************************
*
* perform CLEAR
LAB_CLEAR
BEQ.s LAB_147A * if no following byte go do "CLEAR"
RTS * was following byte (go do syntax error)
*************************************************************************************
*
* perform LIST [n][-m]
LAB_LIST
BCS.s LAB_14BD * branch if next character numeric (LIST n...)
MOVEQ #-1,d1 * set end to $FFFFFFFF
MOVE.l d1,Itemp(a3) * save to Itemp
MOVEQ #0,d1 * set start to $00000000
TST.b d0 * test next byte
BEQ.s LAB_14C0 * branch if next character [NULL] (LIST)
CMP.b #TK_MINUS,d0 * compare with token for -
BNE.s RTS_005 * exit if not - (LIST -m)
* LIST [[n]-[m]] this sets the n, if present,
* as the start and end
LAB_14BD
BSR LAB_GFPN * get fixed-point number into temp integer & d1
LAB_14C0
BSR LAB_SSLN * search BASIC for d1 line number
* (pointer in a0)
BSR LAB_GBYT * scan memory
BEQ.s LAB_14D4 * branch if no more characters
* this bit checks the - is present
CMP.b #TK_MINUS,d0 * compare with token for -
BNE.s RTS_005 * return if not "-" (will be Syntax error)
MOVEQ #-1,d1 * set end to $FFFFFFFF
MOVE.l d1,Itemp(a3) * save Itemp
* LIST [n]-[m] the - was there so see if
* there is an m to set as the end value
BSR LAB_IGBY * increment & scan memory
BEQ.s LAB_14D4 * branch if was [NULL] (LIST n-)
BSR LAB_GFPN * get fixed-point number into temp integer & d1
LAB_14D4
MOVE.b #$00,Oquote(a3) * clear open quote flag
BSR LAB_CRLF * print CR/LF
MOVE.l (a0)+,d0 * get next line pointer
BEQ.s RTS_005 * if null all done so exit
MOVEA.l d0,a1 * copy next line pointer
BSR LAB_1629 * do CRTL-C check vector
MOVE.l (a0)+,d0 * get this line #
CMP.l Itemp(a3),d0 * compare end line # with this line #
BHI.s RTS_005 * if this line greater all done so exit
LAB_14E2
MOVEM.l a0-a1,-(sp) * save registers
BSR LAB_295E * print d0 as unsigned integer
MOVEM.l (sp)+,a0-a1 * restore registers
MOVEQ #$20,d0 * space is the next character
LAB_150C
BSR LAB_PRNA * go print the character
CMP.b #$22,d0 * was it " character
BNE.s LAB_1519 * branch if not
* we're either entering or leaving quotes
EOR.b #$FF,Oquote(a3) * toggle open quote flag
LAB_1519
MOVE.b (a0)+,d0 * get byte and increment pointer
BNE.s LAB_152E * branch if not [EOL] (go print)
* was [EOL]
MOVEA.l a1,a0 * copy next line pointer
MOVE.l a0,d0 * copy to set flags
BNE.s LAB_14D4 * go do next line if not [EOT]
RTS
LAB_152E
BPL.s LAB_150C * just go print it if not token byte
* else it was a token byte so maybe uncrunch it
TST.b Oquote(a3) * test the open quote flag
BMI.s LAB_150C * just go print character if open quote set
* else uncrunch BASIC token
LEA LAB_KEYT(pc),a2 * get keyword table address
MOVEQ #$7F,d1 * mask into d1
AND.b d0,d1 * copy and mask token
LSL.w #2,d1 * *4
LEA (a2,d1.w),a2 * get keyword entry address
MOVE.b (a2)+,d0 * get byte from keyword table
BSR LAB_PRNA * go print the first character
MOVEQ #0,d1 * clear d1
MOVE.b (a2)+,d1 * get remaining length byte from keyword table
BMI.s LAB_1519 * if -ve done so go get next byte
MOVE.w (a2),d0 * get offset to rest
LEA TAB_STAR(pc),a2 * get keyword table address
LEA (a2,d0.w),a2 * get address of rest
LAB_1540
MOVE.b (a2)+,d0 * get byte from keyword table
BSR LAB_PRNA * go print the character
DBF d1,LAB_1540 * decrement and loop if more to do
BRA.s LAB_1519 * go get next byte
*************************************************************************************
*
* perform FOR
LAB_FOR
BSR LAB_LET * go do LET
MOVE.l Lvarpl(a3),d0 * get the loop variable pointer
CMP.l Sstrl(a3),d0 * compare it with the end of vars memory
BGE LAB_TMER * if greater go do type mismatch error
* test for not less than the start of variables memory if needed
*
* CMP.l Svarl(a3),d0 * compare it with the start of variables memory
* BLT LAB_TMER * if not variables memory do type mismatch error
* MOVEQ #28,d0 * we need 28 bytes !
* BSR.s LAB_1212 * check room on stack for d0 bytes
BSR LAB_SNBS * scan for next BASIC statement ([:] or [EOL])
* returns a0 as pointer to [:] or [EOL]
MOVE.l a0,(sp) * push onto stack (and dump the return address)
MOVE.l Clinel(a3),-(sp) * push current line onto stack
MOVE.w #TK_TO-$100,d0 * set "TO" token
BSR LAB_SCCA * scan for CHR$(d0) else syntax error/warm start
BSR LAB_CTNM * check if source is numeric, else type mismatch
MOVE.b Dtypef(a3),-(sp) * push the FOR variable data type onto stack
BSR LAB_EVNM * evaluate expression and check is numeric else
* do type mismatch
MOVE.l FAC1_m(a3),-(sp) * push TO value mantissa
MOVE.w FAC1_e(a3),-(sp) * push TO value exponent and sign
MOVE.l #$80000000,FAC1_m(a3) * set default STEP size mantissa
MOVE.w #$8100,FAC1_e(a3) * set default STEP size exponent and sign
BSR LAB_GBYT * scan memory
CMP.b #TK_STEP,d0 * compare with STEP token
BNE.s LAB_15B3 * jump if not "STEP"
* was STEP token so ....
BSR LAB_IGBY * increment & scan memory
BSR LAB_EVNM * evaluate expression & check is numeric
* else do type mismatch
LAB_15B3
MOVE.l FAC1_m(a3),-(sp) * push STEP value mantissa
MOVE.w FAC1_e(a3),-(sp) * push STEP value exponent and sign
MOVE.l Lvarpl(a3),-(sp) * push variable pointer for FOR/NEXT
MOVE.w #TK_FOR,-(sp) * push FOR token on stack
BRA.s LAB_15C2 * go do interpreter inner loop
LAB_15DC * have reached [EOL]+1
MOVE.w a5,d0 * copy BASIC execute pointer
AND.w #1,d0 * and make line start address even
ADD.w d0,a5 * add to BASIC execute pointer
MOVE.l (a5)+,d0 * get next line pointer
BEQ LAB_1274 * if null go to immediate mode, no "BREAK"
* message (was immediate or [EOT] marker)
MOVE.l (a5)+,Clinel(a3) * save (new) current line #
LAB_15F6
BSR LAB_GBYT * get BASIC byte
BSR.s LAB_15FF * go interpret BASIC code from (a5)
* interpreter inner loop (re)entry point
LAB_15C2
BSR.s LAB_1629 * do CRTL-C check vector
TST.b Clinel(a3) * test current line #, is -ve for immediate mode
BMI.s LAB_15D1 * branch if immediate mode
MOVE.l a5,Cpntrl(a3) * save BASIC execute pointer as continue pointer
LAB_15D1
MOVE.b (a5)+,d0 * get this byte & increment pointer
BEQ.s LAB_15DC * loop if [EOL]
CMP.b #$3A,d0 * compare with ":"
BEQ.s LAB_15F6 * loop if was statement separator
BRA LAB_SNER * else syntax error, then warm start
*************************************************************************************
*
* interpret BASIC code from (a5)
LAB_15FF
BEQ RTS_006 * exit if zero [EOL]
LAB_1602
EORI.b #$80,d0 * normalise token
BMI LAB_LET * if not token, go do implied LET
CMP.b #(TK_TAB-$80),d0 * compare normalised token with TAB
BCC LAB_SNER * branch if d0>=TAB, syntax error/warm start
* only tokens before TAB can start a statement
EXT.w d0 * byte to word (clear high byte)
ADD.w d0,d0 * *2
LEA LAB_CTBL(pc),a0 * get vector table base address
MOVE.w (a0,d0.w),d0 * get offset to vector
PEA (a0,d0.w) * push vector
BRA LAB_IGBY * get following byte & execute vector
*************************************************************************************
*
* CTRL-C check jump. this is called as a subroutine but exits back via a jump if a
* key press is detected.
LAB_1629
JMP V_CTLC(a3) * ctrl c check vector
* if there was a key press it gets back here .....
LAB_1636
CMP.b #$03,d0 * compare with CTRL-C
BEQ.s LAB_163B * STOP if was CTRL-C
LAB_1639
RTS *
*************************************************************************************
*
* perform END
LAB_END
BNE.s LAB_1639 * exit if something follows STOP
MOVE.b #0,Breakf(a3) * clear break flag, indicate program end
*************************************************************************************
*
* perform STOP
LAB_STOP
BNE.s LAB_1639 * exit if something follows STOP
LAB_163B
LEA Ibuffe(a3),a1 * get buffer end
CMPA.l a1,a5 * compare execute address with buffer end
BCS.s LAB_164F * branch if BASIC pointer is in buffer
* can't continue in immediate mode
* else...
MOVE.l a5,Cpntrl(a3) * save BASIC execute pointer as continue pointer
LAB_1647
MOVE.l Clinel(a3),Blinel(a3) * save break line
LAB_164F
ADDQ.w #4,sp * dump return address, don't return to execute
* loop
MOVE.b Breakf(a3),d0 * get break flag
BEQ LAB_1274 * go do warm start if was program end
LEA LAB_BMSG(pc),a0 * point to "Break"
BRA LAB_1269 * print "Break" and do warm start
*************************************************************************************
*
* perform RESTORE
LAB_RESTORE
MOVEA.l Smeml(a3),a0 * copy start of memory
BEQ.s LAB_1624 * branch if next character null (RESTORE)
BSR LAB_GFPN * get fixed-point number into temp integer & d1
CMP.l Clinel(a3),d1 * compare current line # with required line #
BLS.s LAB_GSCH * branch if >= (start search from beginning)
MOVEA.l a5,a0 * copy BASIC execute pointer
LAB_RESs
TST.b (a0)+ * test next byte & increment pointer
BNE.s LAB_RESs * loop if not EOL
MOVE.w a0,d0 * copy pointer
AND.w #1,d0 * mask odd bit
ADD.w d0,a0 * add pointer
* search for line in Itemp from (a0)
LAB_GSCH
BSR LAB_SCLN * search for d1 line number from a0
* returns Cb=0 if found
BCS LAB_USER * go do "Undefined statement" error if not found
LAB_1624
TST.b -(a0) * decrement pointer (faster)
MOVE.l a0,Dptrl(a3) * save DATA pointer
RTS_006
RTS
*************************************************************************************
*
* perform NULL
LAB_NULL
BSR LAB_GTBY * get byte parameter, result in d0 and Itemp
MOVE.b d0,Nullct(a3) * save new NULL count
RTS
*************************************************************************************
*
* perform CONT
LAB_CONT
BNE LAB_SNER * if following byte exit to do syntax error
TST.b Clinel(a3) * test current line #, is -ve for immediate mode
BPL LAB_CCER * if running go do can't continue error
MOVE.l Cpntrl(a3),d0 * get continue pointer
BEQ LAB_CCER * go do can't continue error if we can't
* we can continue so ...
MOVEA.l d0,a5 * save continue pointer as BASIC execute pointer
MOVE.l Blinel(a3),Clinel(a3) * set break line as current line
RTS
*************************************************************************************
*
* perform RUN
LAB_RUN
BNE.s LAB_RUNn * if following byte do RUN n
BSR LAB_1477 * execution to start, clear vars & flush stack
MOVE.l a5,Cpntrl(a3) * save as continue pointer
BRA LAB_15C2 * go do interpreter inner loop
* (can't RTS, we flushed the stack!)
LAB_RUNn
BSR LAB_147A * go do "CLEAR"
BRA.s LAB_16B0 * get n and do GOTO n
*************************************************************************************
*
* perform DO
LAB_DO
* MOVE.l #$05,d0 * need 5 bytes for DO
* BSR.s LAB_1212 * check room on stack for A bytes
MOVE.l a5,-(sp) * push BASIC execute pointer on stack
MOVE.l Clinel(a3),-(sp) * push current line on stack
MOVE.w #TK_DO,-(sp) * push token for DO on stack
PEA LAB_15C2(pc) * set return address
BRA LAB_GBYT * scan memory & return to interpreter inner loop
*************************************************************************************
*
* perform GOSUB
LAB_GOSUB
* MOVE.l #10,d0 * need 10 bytes for GOSUB
* BSR.s LAB_1212 * check room on stack for d0 bytes
MOVE.l a5,-(sp) * push BASIC execute pointer
MOVE.l Clinel(a3),-(sp) * push current line
MOVE.w #TK_GOSUB,-(sp) * push token for GOSUB
LAB_16B0
BSR LAB_GBYT * scan memory
PEA LAB_15C2(pc) * return to interpreter inner loop after GOTO n
* this PEA is needed because either we just cleared the stack and have nowhere to return
* to or, in the case of GOSUB, we have just dropped a load on the stack and the address
* we whould have returned to is buried. This burried return address will be unstacked by
* the corresponding RETURN command
*************************************************************************************
*
* perform GOTO
LAB_GOTO
BSR LAB_GFPN * get fixed-point number into temp integer & d1
MOVEA.l Smeml(a3),a0 * get start of memory
CMP.l Clinel(a3),d1 * compare current line with wanted #
BLS.s LAB_16D0 * branch if current # => wanted #
MOVEA.l a5,a0 * copy BASIC execute pointer
LAB_GOTs
TST.b (a0)+ * test next byte & increment pointer
BNE.s LAB_GOTs * loop if not EOL
MOVE.w a0,d0 * past pad byte(s)
AND.w #1,d0 * mask odd bit
ADD.w d0,a0 * add to pointer
LAB_16D0
BSR LAB_SCLN * search for d1 line number from a0
* returns Cb=0 if found
BCS LAB_USER * if carry set go do "Undefined statement" error
MOVEA.l a0,a5 * copy to basic execute pointer
SUBQ.w #1,a5 * decrement pointer
MOVE.l a5,Cpntrl(a3) * save as continue pointer
RTS
*************************************************************************************
*
* perform LOOP
LAB_LOOP
CMP.w #TK_DO,4(sp) * compare token on stack with DO token
BNE LAB_LDER * branch if no matching DO
MOVE.b d0,d7 * copy following token (byte)
BEQ.s LoopAlways * if no following token loop forever
CMP.b #':',d7 * compare with ":"
BEQ.s LoopAlways * if no following token loop forever
SUB.b #TK_UNTIL,d7 * subtract token for UNTIL
BEQ.s DoRest * branch if was UNTIL
SUBQ.b #1,d7 * decrement result
BNE LAB_SNER * if not WHILE go do syntax error & warm start
* only if the token was WHILE will this fail
MOVEQ #-1,d7 * set invert result longword
DoRest
BSR LAB_IGBY * increment & scan memory
BSR LAB_EVEX * evaluate expression
TST.b FAC1_e(a3) * test FAC1 exponent
BEQ.s DoCmp * if = 0 go do straight compare
MOVE.b #$FF,FAC1_e(a3) * else set all bits
DoCmp
EOR.b d7,FAC1_e(a3) * EOR with invert byte
BNE.s LoopDone * if <> 0 clear stack & back to interpreter loop
* loop condition wasn't met so do it again
LoopAlways
MOVE.l 6(sp),Clinel(a3) * copy DO current line
MOVE.l 10(sp),a5 * save BASIC execute pointer
LEA LAB_15C2(pc),a0 * get return address
MOVE.l a0,(sp) * dump the call to this routine and set the
* return address
BRA LAB_GBYT * scan memory and return to interpreter inner
* loop
* clear stack & back to interpreter loop
LoopDone
LEA 14(sp),sp * dump structure and call from stack
BRA.s LAB_DATA * go perform DATA (find : or [EOL])
*************************************************************************************
*
* perform RETURN
LAB_RETURN
BNE.s RTS_007 * exit if following token to allow syntax error
CMP.w #TK_GOSUB,4(sp) * compare token from stack with GOSUB
BNE LAB_RGER * do RETURN without GOSUB error if no matching
* GOSUB
ADDQ.w #6,sp * dump calling address & token
MOVE.l (sp)+,Clinel(a3) * pull current line
MOVE.l (sp)+,a5 * pull BASIC execute pointer
* now do perform "DATA" statement as we could be
* returning into the middle of an ON <var> GOSUB
* n,m,p,q line (the return address used by the
* DATA statement is the one pushed before the
* GOSUB was executed!)
*************************************************************************************
*
* perform DATA
LAB_DATA
BSR.s LAB_SNBS * scan for next BASIC statement ([:] or [EOL])
* returns a0 as pointer to [:] or [EOL]
MOVEA.l a0,a5 * skip rest of statement
RTS_007
RTS
*************************************************************************************
*
* scan for next BASIC statement ([:] or [EOL])
* returns a0 as pointer to [:] or [EOL]
LAB_SNBS
MOVEA.l a5,a0 * copy BASIC execute pointer
MOVEQ #$22,d1 * set string quote character
MOVEQ #$3A,d2 * set look for character = ":"
BRA.s LAB_172D * go do search
LAB_172C
CMP.b d0,d2 * compare with ":"
BEQ.s RTS_007a * exit if found
CMP.b d0,d1 * compare with '"'
BEQ.s LAB_1725 * if found go search for [EOL]
LAB_172D
MOVE.b (a0)+,d0 * get next byte
BNE.s LAB_172C * loop if not null [EOL]
RTS_007a
SUBQ.w #1,a0 * correct pointer
RTS
LAB_1723
CMP.b d0,d1 * compare with '"'
BEQ.s LAB_172D * if found go search for ":" or [EOL]
LAB_1725
MOVE.b (a0)+,d0 * get next byte
BNE.s LAB_1723 * loop if not null [EOL]
BRA.s RTS_007a * correct pointer & return
*************************************************************************************
*
* perform IF
LAB_IF
BSR LAB_EVEX * evaluate expression
BSR LAB_GBYT * scan memory
CMP.b #TK_THEN,d0 * compare with THEN token
BEQ.s LAB_174B * if it was THEN then continue
* wasn't IF .. THEN so must be IF .. GOTO
CMP.b #TK_GOTO,d0 * compare with GOTO token
BNE LAB_SNER * if not GOTO token do syntax error/warm start
* was GOTO so check for GOTO <n>
MOVE.l a5,a0 * save the execute pointer
BSR LAB_IGBY * scan memory, test for a numeric character
MOVE.l a0,a5 * restore the execute pointer
BCC LAB_SNER * if not numeric do syntax error/warm start
LAB_174B
MOVE.b FAC1_e(a3),d0 * get FAC1 exponent
BEQ.s LAB_174E * if result was zero go look for an ELSE
BSR LAB_IGBY * increment & scan memory
BCS LAB_GOTO * if numeric do GOTO n
* a GOTO <n> will never return to the IF
* statement so there is no need to return
* to this code
CMP.b #TK_RETURN,d0 * compare with RETURN token
BEQ LAB_1602 * if RETURN then interpret BASIC code from (a5)
* and don't return here
BSR LAB_15FF * else interpret BASIC code from (a5)
* the IF was executed and there may be a following ELSE so the code needs to return
* here to check and ignore the ELSE if present
MOVE.b (a5),d0 * get the next basic byte
CMP.b #TK_ELSE,d0 * compare it with the token for ELSE
BEQ LAB_DATA * if ELSE ignore the following statement
* there was no ELSE so continue execution of IF <expr> THEN <stat> [: <stat>]. any
* following ELSE will, correctly, cause a syntax error
RTS * else return to interpreter inner loop
* perform ELSE after IF
LAB_174E
MOVE.b (a5)+,d0 * faster increment past THEN
MOVE.b #TK_ELSE,d3 * set search for ELSE token
MOVE.b #TK_IF,d4 * set search for IF token
MOVEQ #0,d5 * clear the nesting depth
LAB_1750
MOVE.b (a5)+,d0 * get next BASIC byte & increment ptr
BEQ.s LAB_1754 * if EOL correct the pointer and return
CMP.b d4,d0 * compare with "IF" token
BNE.s LAB_1752 * skip if not nested IF
ADDQ.w #1,d5 * else increment the nesting depth ..
BRA.s LAB_1750 * .. and continue looking
LAB_1752
CMP.b d3,d0 * compare with ELSE token
BNE.s LAB_1750 * if not ELSE continue looking
LAB_1756
DBF d5,LAB_1750 * loop if still nested
* found the matching ELSE, now do <{n|statement}>
BSR LAB_GBYT * scan memory
BCS LAB_GOTO * if numeric do GOTO n
* code will return to the interpreter loop
* at the tail end of the GOTO <n>
BRA LAB_15FF * else interpret BASIC code from (a5)
* code will return to the interpreter loop
* at the tail end of the <statement>
*************************************************************************************
*
* perform REM, skip (rest of) line
LAB_REM
TST.b (a5)+ * test byte & increment pointer
BNE.s LAB_REM * loop if not EOL
LAB_1754
SUBQ.w #1,a5 * correct the execute pointer
RTS
*************************************************************************************
*
* perform ON
LAB_ON
BSR LAB_GTBY * get byte parameter, result in d0 and Itemp
MOVE.b d0,d2 * copy byte
BSR LAB_GBYT * restore BASIC byte
MOVE.w d0,-(sp) * push GOTO/GOSUB token
CMP.b #TK_GOSUB,d0 * compare with GOSUB token
BEQ.s LAB_176C * branch if GOSUB
CMP.b #TK_GOTO,d0 * compare with GOTO token
BNE LAB_SNER * if not GOTO do syntax error, then warm start
* next character was GOTO or GOSUB
LAB_176C
SUBQ.b #1,d2 * decrement index (byte value)
BNE.s LAB_1773 * branch if not zero
MOVE.w (sp)+,d0 * pull GOTO/GOSUB token
BRA LAB_1602 * go execute it
LAB_1773
BSR LAB_IGBY * increment & scan memory
BSR.s LAB_GFPN * get fixed-point number into temp integer & d1
* (skip this n)
CMP.b #$2C,d0 * compare next character with ","
BEQ.s LAB_176C * loop if ","
MOVE.w (sp)+,d0 * pull GOTO/GOSUB token (run out of options)
RTS * and exit
*************************************************************************************
*
* get fixed-point number into temp integer & d1
* interpret number from (a5), leave (a5) pointing to byte after #
LAB_GFPN
MOVEQ #$00,d1 * clear integer register
MOVE.l d1,d0 * clear d0
BSR LAB_GBYT * scan memory, Cb=1 if "0"-"9", & get byte
BCC.s LAB_1786 * return if carry clear, chr was not "0"-"9"
MOVE.l d2,-(sp) * save d2
LAB_1785
MOVE.l d1,d2 * copy integer register
ADD.l d1,d1 * *2
BCS LAB_SNER * if overflow do syntax error, then warm start
ADD.l d1,d1 * *4
BCS LAB_SNER * if overflow do syntax error, then warm start
ADD.l d2,d1 * *1 + *4
BCS LAB_SNER * if overflow do syntax error, then warm start
ADD.l d1,d1 * *10
BCS LAB_SNER * if overflow do syntax error, then warm start
SUB.b #$30,d0 * subtract $30 from byte
ADD.l d0,d1 * add to integer register, the top 24 bits are
* always clear
BVS LAB_SNER * if overflow do syntax error, then warm start
* this makes the maximum line number 2147483647
BSR LAB_IGBY * increment & scan memory
BCS.s LAB_1785 * loop for next character if "0"-"9"
MOVE.l (sp)+,d2 * restore d2
LAB_1786
MOVE.l d1,Itemp(a3) * save Itemp
RTS
*************************************************************************************
*
* perform DEC
LAB_DEC
MOVE.w #$8180,-(sp) * set -1 sign/exponent
BRA.s LAB_17B7 * go do DEC
*************************************************************************************
*
* perform INC
LAB_INC
MOVE.w #$8100,-(sp) * set 1 sign/exponent
BRA.s LAB_17B7 * go do INC
* was "," so another INCR variable to do
LAB_17B8
BSR LAB_IGBY * increment and scan memory
LAB_17B7
BSR LAB_GVAR * get variable address in a0
* if you want a non existant variable to return a null value then set the novar
* value at the top of this file to some non zero value
ifne novar
BEQ.s LAB_INCT * if variable not found skip the inc/dec
endc
TST.b Dtypef(a3) * test data type, $80=string, $40=integer,
* $00=float
BMI LAB_TMER * if string do "Type mismatch" error/warm start
BNE.s LAB_INCI * go do integer INC/DEC
MOVE.l a0,Lvarpl(a3) * save var address
BSR LAB_UFAC * unpack memory (a0) into FAC1
MOVE.l #$80000000,FAC2_m(a3) * set FAC2 mantissa for 1
MOVE.w (sp),d0 * move exponent & sign to d0
MOVE.w d0,FAC2_e(a3) * move exponent & sign to FAC2
MOVE.b FAC1_s(a3),FAC_sc(a3) * make sign compare = FAC1 sign
EOR.b d0,FAC_sc(a3) * make sign compare (FAC1_s EOR FAC2_s)
BSR LAB_ADD * add FAC2 to FAC1
BSR LAB_PFAC * pack FAC1 into variable (Lvarpl)
LAB_INCT
BSR LAB_GBYT * scan memory
CMPI.b #$2C,d0 * compare with ","
BEQ.s LAB_17B8 * continue if "," (another variable to do)
ADDQ.w #2,sp * else dump sign & exponent
RTS
LAB_INCI
TST.b 1(sp) * test sign
BNE.s LAB_DECI * branch if DEC
ADDQ.l #1,(a0) * increment variable
BRA.s LAB_INCT * go scan for more
LAB_DECI
SUBQ.l #1,(a0) * decrement variable
BRA.s LAB_INCT * go scan for more
*************************************************************************************
*
* perform LET
LAB_LET
BSR LAB_SVAR * search for or create a variable
* return the variable address in a0
MOVE.l a0,Lvarpl(a3) * save variable address
MOVE.b Dtypef(a3),-(sp) * push var data type, $80=string, $40=integer,
* $00=float
MOVE.w #TK_EQUAL-$100,d0 * get = token
BSR LAB_SCCA * scan for CHR$(d0), else do syntax error/warm
* start
BSR LAB_EVEX * evaluate expression
MOVE.b Dtypef(a3),d0 * copy expression data type
MOVE.b (sp)+,Dtypef(a3) * pop variable data type
ROL.b #1,d0 * set carry if expression type = string
BSR LAB_CKTM * type match check, set C for string
BEQ LAB_PFAC * if number pack FAC1 into variable Lvarpl & RET
* string LET
LAB_17D5
MOVEA.l Lvarpl(a3),a2 * get pointer to variable
LAB_17D6
MOVEA.l FAC1_m(a3),a0 * get descriptor pointer
MOVEA.l (a0),a1 * get string pointer
CMP.l Sstorl(a3),a1 * compare string memory start with string
* pointer
BCS.s LAB_1811 * if it was in program memory assign the value
* and exit
CMPA.l Sfncl(a3),a0 * compare functions start with descriptor
* pointer
BCS.s LAB_1811 * branch if >= (string is on stack)
* string is variable$ make space and copy string
LAB_1810
MOVEQ #0,d1 * clear length
MOVE.w 4(a0),d1 * get string length
MOVEA.l (a0),a0 * get string pointer
BSR LAB_20C9 * copy string
MOVEA.l FAC1_m(a3),a0 * get descriptor pointer back
* clean stack & assign value to string variable
LAB_1811
CMPA.l a0,a4 * is string on the descriptor stack
BNE.s LAB_1813 * skip pop if not
ADDQ.w #$06,a4 * else update stack pointer
LAB_1813
MOVE.l (a0)+,(a2)+ * save pointer to variable
MOVE.w (a0),(a2) * save length to variable
RTS_008
RTS
*************************************************************************************
*
* perform GET
LAB_GET
BSR LAB_SVAR * search for or create a variable
* return the variable address in a0
MOVE.l a0,Lvarpl(a3) * save variable address as GET variable
TST.b Dtypef(a3) * test data type, $80=string, $40=integer,
* $00=float
BMI.s LAB_GETS * go get string character
* was numeric get
BSR INGET * get input byte
BSR LAB_1FD0 * convert d0 to unsigned byte in FAC1
BRA LAB_PFAC * pack FAC1 into variable (Lvarpl) & return
LAB_GETS
MOVEQ #$00,d1 * assume no byte
MOVE.l d1,a0 * assume null string
BSR INGET * get input byte
BCC.s LAB_NoSt * branch if no byte received
MOVEQ #$01,d1 * string is single byte
BSR LAB_2115 * make string space d1 bytes long
* return a0 = pointer, other registers unchanged
MOVE.b d0,(a0) * save byte in string (byte IS string!)
LAB_NoSt
BSR LAB_RTST * push string on descriptor stack
* a0 = pointer, d1 = length
BRA.s LAB_17D5 * do string LET & return
*************************************************************************************
*
* PRINT
LAB_1829
BSR LAB_18C6 * print string from stack
LAB_182C
BSR LAB_GBYT * scan memory
* perform PRINT
LAB_PRINT
BEQ.s LAB_CRLF * if nothing following just print CR/LF
LAB_1831
CMP.b #TK_TAB,d0 * compare with TAB( token
BEQ.s LAB_18A2 * go do TAB/SPC
CMP.b #TK_SPC,d0 * compare with SPC( token
BEQ.s LAB_18A2 * go do TAB/SPC
CMP.b #',',d0 * compare with ","
BEQ.s LAB_188B * go do move to next TAB mark
CMP.b #';',d0 * compare with ";"
BEQ LAB_18BD * if ";" continue with PRINT processing
BSR LAB_EVEX * evaluate expression
TST.b Dtypef(a3) * test data type, $80=string, $40=integer,
* $00=float
BMI.s LAB_1829 * branch if string
** replace the two lines above with this code
** MOVE.b Dtypef(a3),d0 * get data type flag, $80=string, $00=numeric
** BMI.s LAB_1829 * branch if string
BSR LAB_2970 * convert FAC1 to string
BSR LAB_20AE * print " terminated string to FAC1 stack
* don't check fit if terminal width byte is zero
MOVEQ #0,d0 * clear d0
MOVE.b TWidth(a3),d0 * get terminal width byte
BEQ.s LAB_185E * skip check if zero
SUB.b 7(a4),d0 * subtract string length
SUB.b TPos(a3),d0 * subtract terminal position
BCC.s LAB_185E * branch if less than terminal width
BSR.s LAB_CRLF * else print CR/LF
LAB_185E
BSR.s LAB_18C6 * print string from stack
BRA.s LAB_182C * always go continue processing line
*************************************************************************************
*
* CR/LF return to BASIC from BASIC input handler
* leaves a0 pointing to the buffer start
LAB_1866
MOVE.b #$00,(a0,d1.w) * null terminate input
* print CR/LF
LAB_CRLF
MOVEQ #$0D,d0 * load [CR]
BSR.s LAB_PRNA * go print the character
MOVEQ #$0A,d0 * load [LF]
BRA.s LAB_PRNA * go print the character & return
LAB_188B
MOVE.b TPos(a3),d2 * get terminal position
CMP.b Iclim(a3),d2 * compare with input column limit
BCS.s LAB_1898 * branch if less than Iclim
BSR.s LAB_CRLF * else print CR/LF (next line)
BRA.s LAB_18BD * continue with PRINT processing
LAB_1898
SUB.b TabSiz(a3),d2 * subtract TAB size
BCC.s LAB_1898 * loop if result was >= 0
NEG.b d2 * twos complement it
BRA.s LAB_18B7 * print d2 spaces
* do TAB/SPC
LAB_18A2
MOVE.w d0,-(sp) * save token
BSR LAB_SGBY * increment and get byte, result in d0 and Itemp
MOVE.w d0,d2 * copy byte
BSR LAB_GBYT * get basic byte back
CMP.b #$29,d0 * is next character ")"
BNE LAB_SNER * if not do syntax error, then warm start
MOVE.w (sp)+,d0 * get token back
CMP.b #TK_TAB,d0 * was it TAB ?
BNE.s LAB_18B7 * branch if not (was SPC)
* calculate TAB offset
SUB.b TPos(a3),d2 * subtract terminal position
BLS.s LAB_18BD * branch if result was <= 0
* can't TAB backwards or already there
* print d2.b spaces
LAB_18B7
MOVEQ #0,d0 * clear longword
SUBQ.b #1,d0 * make d0 = $FF
AND.l d0,d2 * mask for byte only
BEQ.s LAB_18BD * branch if zero
MOVEQ #$20,d0 * load " "
SUBQ.b #1,d2 * adjust for DBF loop
LAB_18B8
BSR.s LAB_PRNA * go print
DBF d2,LAB_18B8 * decrement count and loop if not all done
* continue with PRINT processing
LAB_18BD
BSR LAB_IGBY * increment & scan memory
BNE LAB_1831 * if byte continue executing PRINT
RTS * exit if nothing more to print
*************************************************************************************
*
* print null terminated string from a0
LAB_18C3
BSR LAB_20AE * print terminated string to FAC1/stack
* print string from stack
LAB_18C6
BSR LAB_22B6 * pop string off descriptor stack or from memory
* returns with d0 = length, a0 = pointer
BEQ.s RTS_009 * exit (RTS) if null string
MOVE.w d0,d1 * copy length & set Z flag
SUBQ.w #1,d1 * -1 for BF loop
LAB_18CD
MOVE.b (a0)+,d0 * get byte from string
BSR.s LAB_PRNA * go print the character
DBF d1,LAB_18CD * decrement count and loop if not done yet
RTS_009
RTS
*************************************************************************************
*
* print "?" character
LAB_18E3
MOVEQ #$3F,d0 * load "?" character
*************************************************************************************
*
* print character in d0, includes the null handler and infinite line length code
* changes no registers
LAB_PRNA
MOVE.l d1,-(sp) * save d1
CMP.b #$20,d0 * compare with " "
BCS.s LAB_18F9 * branch if less, non printing character
* don't check fit if terminal width byte is zero
MOVE.b TWidth(a3),d1 * get terminal width
BNE.s LAB_18F0 * branch if not zero (not infinite length)
* is "infinite line" so check TAB position
MOVE.b TPos(a3),d1 * get position
SUB.b TabSiz(a3),d1 * subtract TAB size
BNE.s LAB_18F7 * skip reset if different
MOVE.b d1,TPos(a3) * else reset position
BRA.s LAB_18F7 * go print character
LAB_18F0
CMP.b TPos(a3),d1 * compare with terminal character position
BNE.s LAB_18F7 * branch if not at end of line
MOVE.l d0,-(sp) * save d0
BSR LAB_CRLF * else print CR/LF
MOVE.l (sp)+,d0 * restore d0
LAB_18F7
ADDQ.b #$01,TPos(a3) * increment terminal position
LAB_18F9
JSR V_OUTP(a3) * output byte via output vector
CMP.b #$0D,d0 * compare with [CR]
BNE.s LAB_188A * branch if not [CR]
* else print nullct nulls after the [CR]
MOVEQ #$00,d1 * clear d1
MOVE.b Nullct(a3),d1 * get null count
BEQ.s LAB_1886 * branch if no nulls
MOVEQ #$00,d0 * load [NULL]
LAB_1880
JSR V_OUTP(a3) * go print the character
DBF d1,LAB_1880 * decrement count and loop if not all done
MOVEQ #$0D,d0 * restore the character
LAB_1886
MOVE.b d1,TPos(a3) * clear terminal position
LAB_188A
MOVE.l (sp)+,d1 * restore d1
RTS
*************************************************************************************
*
* handle bad input data
LAB_1904
MOVEA.l (sp)+,a5 * restore execute pointer
TST.b Imode(a3) * test input mode flag, $00=INPUT, $98=READ
BPL.s LAB_1913 * branch if INPUT (go do redo)
MOVE.l Dlinel(a3),Clinel(a3) * save DATA line as current line
BRA LAB_TMER * do type mismatch error, then warm start
* mode was INPUT
LAB_1913
LEA LAB_REDO(pc),a0 * point to redo message
BSR LAB_18C3 * print null terminated string from memory
MOVEA.l Cpntrl(a3),a5 * save continue pointer as BASIC execute pointer
RTS
*************************************************************************************
*
* perform INPUT
LAB_INPUT
BSR LAB_CKRN * check not direct (back here if ok)
CMP.b #'"',d0 * compare the next byte with open quote
BNE.s LAB_1934 * if no prompt string just go get the input
BSR LAB_1BC1 * print "..." string
MOVEQ #';',d0 * set the search character to ";"
BSR LAB_SCCA * scan for CHR$(d0), else do syntax error/warm
* start
BSR LAB_18C6 * print string from Sutill/Sutilh
* finished the prompt, now read the data
LAB_1934
BSR LAB_INLN * print "? " and get BASIC input
* return a0 pointing to the buffer start
MOVEQ #0,d0 * flag INPUT
* if you don't want a null response to INPUT to break the program then set the nobrk
* value at the top of this file to some non zero value
ifne nobrk
BRA.s LAB_1953 * go handle the input
endc
* if you do want a null response to INPUT to break the program then leave the nobrk
* value at the top of this file set to zero
ifeq nobrk
TST.b (a0) * test first byte from buffer
BNE.s LAB_1953 * branch if not null input
BRA LAB_1647 * go do BREAK exit
endc
*************************************************************************************
*
* perform READ
LAB_READ
MOVEA.l Dptrl(a3),a0 * get the DATA pointer
MOVEQ #$98-$100,d0 * flag READ
LAB_1953
MOVE.b d0,Imode(a3) * set input mode flag, $00=INPUT, $98=READ
MOVE.l a0,Rdptrl(a3) * save READ pointer
* READ or INPUT the next variable from list
LAB_195B
BSR LAB_SVAR * search for or create a variable
* return the variable address in a0
MOVE.l a0,Lvarpl(a3) * save variable address as LET variable
MOVE.l a5,-(sp) * save BASIC execute pointer
LAB_1961
MOVEA.l Rdptrl(a3),a5 * set READ pointer as BASIC execute pointer
BSR LAB_GBYT * scan memory
BNE.s LAB_1986 * if not null go get the value
* the pointer was to a null entry
TST.b Imode(a3) * test input mode flag, $00=INPUT, $98=READ
BMI.s LAB_19DD * branch if READ (go find the next statement)
* else the mode was INPUT so get more
BSR LAB_18E3 * print a "?" character
BSR LAB_INLN * print "? " and get BASIC input
* return a0 pointing to the buffer start
* if you don't want a null response to INPUT to break the program then set the nobrk
* value at the top of this file to some non zero value
ifne nobrk
MOVE.l a0,Rdptrl(a3) * save the READ pointer
BRA.s LAB_1961 * go handle the input
endc
* if you do want a null response to INPUT to break the program then leave the nobrk
* value at the top of this file set to zero
ifeq nobrk
TST.b (a0) * test the first byte from the buffer
BNE.s LAB_1984 * if not null input go handle it
BRA LAB_1647 * else go do the BREAK exit
LAB_1984
MOVEA.l a0,a5 * set the execute pointer to the buffer
SUBQ.w #1,a5 * decrement the execute pointer
endc
LAB_1985
BSR LAB_IGBY * increment & scan memory
LAB_1986
TST.b Dtypef(a3) * test data type, $80=string, $40=integer,
* $00=float
BPL.s LAB_19B0 * branch if numeric
* else get string
MOVE.b d0,d2 * save search character
CMP.b #$22,d0 * was it " ?
BEQ.s LAB_1999 * branch if so
MOVEQ #':',d2 * set new search character
MOVEQ #',',d0 * other search character is ","
SUBQ.w #1,a5 * decrement BASIC execute pointer
LAB_1999
ADDQ.w #1,a5 * increment BASIC execute pointer
MOVE.b d0,d3 * set second search character
MOVEA.l a5,a0 * BASIC execute pointer is source
BSR LAB_20B4 * print d2/d3 terminated string to FAC1 stack
* d2 = Srchc, d3 = Asrch, a0 is source
MOVEA.l a2,a5 * copy end of string to BASIC execute pointer
BSR LAB_17D5 * go do string LET
BRA.s LAB_19B6 * go check string terminator
* get numeric INPUT
LAB_19B0
MOVE.b Dtypef(a3),-(sp) * save variable data type
BSR LAB_2887 * get FAC1 from string
MOVE.b (sp)+,Dtypef(a3) * restore variable data type
BSR LAB_PFAC * pack FAC1 into (Lvarpl)
LAB_19B6
BSR LAB_GBYT * scan memory
BEQ.s LAB_19C2 * branch if null (last entry)
CMP.b #',',d0 * else compare with ","
BNE LAB_1904 * if not "," go handle bad input data
ADDQ.w #1,a5 * else was "," so point to next chr
* got good input data
LAB_19C2
MOVE.l a5,Rdptrl(a3) * save the read pointer for now
MOVEA.l (sp)+,a5 * restore the execute pointer
BSR LAB_GBYT * scan the memory
BEQ.s LAB_1A03 * if null go do extra ignored message
PEA LAB_195B(pc) * set return address
BRA LAB_1C01 * scan for "," else do syntax error/warm start
* then go INPUT next variable from list
* find next DATA statement or do "Out of Data"
* error
LAB_19DD
BSR LAB_SNBS * scan for next BASIC statement ([:] or [EOL])
* returns a0 as pointer to [:] or [EOL]
MOVEA.l a0,a5 * add index, now = pointer to [EOL]/[EOS]
ADDQ.w #1,a5 * pointer to next character
CMP.b #':',d0 * was it statement end?
BEQ.s LAB_19F6 * branch if [:]
* was [EOL] so find next line
MOVE.w a5,d1 * past pad byte(s)
AND.w #1,d1 * mask odd bit
ADD.w d1,a5 * add pointer
MOVE.l (a5)+,d2 * get next line pointer
BEQ LAB_ODER * branch if end of program
MOVE.l (a5)+,Dlinel(a3) * save current DATA line
LAB_19F6
BSR LAB_GBYT * scan memory
CMP.b #TK_DATA,d0 * compare with "DATA" token
BEQ LAB_1985 * was "DATA" so go do next READ
BRA.s LAB_19DD * go find next statement if not "DATA"
* end of INPUT/READ routine
LAB_1A03
MOVEA.l Rdptrl(a3),a0 * get temp READ pointer
TST.b Imode(a3) * get input mode flag, $00=INPUT, $98=READ
BPL.s LAB_1A0E * branch if INPUT
MOVE.l a0,Dptrl(a3) * else save temp READ pointer as DATA pointer
RTS
* we were getting INPUT
LAB_1A0E
TST.b (a0) * test next byte
BNE.s LAB_1A1B * error if not end of INPUT
RTS
* user typed too much
LAB_1A1B
LEA LAB_IMSG(pc),a0 * point to extra ignored message
BRA LAB_18C3 * print null terminated string from memory & RTS
*************************************************************************************
*
* perform NEXT
LAB_NEXT
BNE.s LAB_1A46 * branch if NEXT var
ADDQ.w #4,sp * back past return address
CMP.w #TK_FOR,(sp) * is FOR token on stack?
BNE LAB_NFER * if not do NEXT without FOR err/warm start
MOVEA.l 2(sp),a0 * get stacked FOR variable pointer
BRA.s LAB_11BD * branch always (no variable to search for)
* NEXT var
LAB_1A46
BSR LAB_GVAR * get variable address in a0
ADDQ.w #4,sp * back past return address
MOVE.w #TK_FOR,d0 * set for FOR token
MOVEQ #$1C,d1 * set for FOR use size
BRA.s LAB_11A6 * enter loop for next variable search
LAB_11A5
ADDA.l d1,sp * add FOR stack use size
LAB_11A6
CMP.w (sp),d0 * is FOR token on stack?
BNE LAB_NFER * if not found do NEXT without FOR error and
* warm start
* was FOR token
CMPA.l 2(sp),a0 * compare var pointer with stacked var pointer
BNE.s LAB_11A5 * loop if no match found
LAB_11BD
MOVE.w 6(sp),FAC2_e(a3) * get STEP value exponent and sign
MOVE.l 8(sp),FAC2_m(a3) * get STEP value mantissa
MOVE.b 18(sp),Dtypef(a3) * restore FOR variable data type
BSR LAB_1C19 * check type and unpack (a0)
MOVE.b FAC2_s(a3),FAC_sc(a3) * save FAC2 sign as sign compare
MOVE.b FAC1_s(a3),d0 * get FAC1 sign
EOR.b d0,FAC_sc(a3) * EOR to create sign compare
MOVE.l a0,Lvarpl(a3) * save variable pointer
BSR LAB_ADD * add STEP value to FOR variable
MOVE.b 18(sp),Dtypef(a3) * restore FOR variable data type (again)
BSR LAB_PFAC * pack FAC1 into FOR variable (Lvarpl)
MOVE.w 12(sp),FAC2_e(a3) * get TO value exponent and sign
MOVE.l 14(sp),FAC2_m(a3) * get TO value mantissa
MOVE.b FAC2_s(a3),FAC_sc(a3) * save FAC2 sign as sign compare
MOVE.b FAC1_s(a3),d0 * get FAC1 sign
EOR.b d0,FAC_sc(a3) * EOR to create sign compare
BSR LAB_27FA * compare FAC1 with FAC2 (TO value)
* returns d0=+1 if FAC1 > FAC2
* returns d0= 0 if FAC1 = FAC2
* returns d0=-1 if FAC1 < FAC2
MOVE.w 6(sp),d1 * get STEP value exponent and sign
EOR.w d0,d1 * EOR compare result with STEP exponent and sign
TST.b d0 * test for =
BEQ.s LAB_1A90 * branch if = (loop INcomplete)
TST.b d1 * test result
BPL.s LAB_1A9B * branch if > (loop complete)
* loop back and do it all again
LAB_1A90
MOVE.l 20(sp),Clinel(a3) * reset current line
MOVE.l 24(sp),a5 * reset BASIC execute pointer
BRA LAB_15C2 * go do interpreter inner loop
* loop complete so carry on
LAB_1A9B
ADDA.w #28,sp * add 28 to dump FOR structure
BSR LAB_GBYT * scan memory
CMP.b #$2C,d0 * compare with ","
BNE LAB_15C2 * if not "," go do interpreter inner loop
* was "," so another NEXT variable to do
BSR LAB_IGBY * else increment & scan memory
BSR LAB_1A46 * do NEXT (var)
*************************************************************************************
*
* evaluate expression & check is numeric, else do type mismatch
LAB_EVNM
BSR.s LAB_EVEX * evaluate expression
*************************************************************************************
*
* check if source is numeric, else do type mismatch
LAB_CTNM
CMP.w d0,d0 * required type is numeric so clear carry
*************************************************************************************
*
* type match check, set C for string, clear C for numeric
LAB_CKTM
BTST.b #7,Dtypef(a3) * test data type flag, don't change carry
BNE.s LAB_1ABA * branch if data type is string
* else data type was numeric
BCS LAB_TMER * if required type is string do type mismatch
* error
RTS
* data type was string, now check required type
LAB_1ABA
BCC LAB_TMER * if required type is numeric do type mismatch
* error
RTS
*************************************************************************************
*
* this routine evaluates any type of expression. first it pushes an end marker so
* it knows when the expression has been evaluated, this is a precedence value of zero.
* next the first value is evaluated, this can be an in line value, either numeric or
* string, a variable or array element of any type, a function or even an expression
* in parenthesis. this value is kept in FAC_1
* after the value is evaluated a test is made on the next BASIC program byte, if it
* is a comparrison operator i.e. "<", "=" or ">", then the corresponding bit is set
* in the comparison evaluation flag. this test loops until no more comparrison operators
* are found or more than one of any type is found. in the last case an error is generated
* evaluate expression
LAB_EVEX
SUBQ.w #1,a5 * decrement BASIC execute pointer
LAB_EVEZ
MOVEQ #0,d1 * clear precedence word
MOVE.b d1,Dtypef(a3) * clear the data type, $80=string, $40=integer,
* $00=float
BRA.s LAB_1ACD * enter loop
* get vector, set up operator then continue evaluation
LAB_1B43 *
LEA LAB_OPPT(pc),a0 * point to operator vector table
MOVE.w 2(a0,d1.w),d0 * get vector offset
PEA (a0,d0.w) * push vector
MOVE.l FAC1_m(a3),-(sp) * push FAC1 mantissa
MOVE.w FAC1_e(a3),-(sp) * push sign and exponent
MOVE.b comp_f(a3),-(sp) * push comparison evaluation flag
MOVE.w (a0,d1.w),d1 * get precedence value
LAB_1ACD
MOVE.w d1,-(sp) * push precedence value
BSR LAB_GVAL * get value from line
MOVE.b #$00,comp_f(a3) * clear compare function flag
LAB_1ADB
BSR LAB_GBYT * scan memory
LAB_1ADE
SUB.b #TK_GT,d0 * subtract token for > (lowest compare function)
BCS.s LAB_1AFA * branch if < TK_GT
CMP.b #$03,d0 * compare with ">" to "<" tokens
BCS.s LAB_1AE0 * branch if <= TK_SGN (is compare function)
TST.b comp_f(a3) * test compare function flag
BNE.s LAB_1B2A * branch if compare function
BRA LAB_1B78 * go do functions
* was token for > = or < (d0 = 0, 1 or 2)
LAB_1AE0
MOVEQ #1,d1 * set to 0000 0001
ASL.b d0,d1 * 1 if >, 2 if =, 4 if <
MOVE.b comp_f(a3),d0 * copy old compare function flag
EOR.b d1,comp_f(a3) * EOR in this compare function bit
CMP.b comp_f(a3),d0 * compare old with new compare function flag
BCC LAB_SNER * if new <= old comp_f do syntax error and warm
* start, there was more than one <, = or >
BSR LAB_IGBY * increment & scan memory
BRA.s LAB_1ADE * go do next character
* token is < ">" or > "<" tokens
LAB_1AFA
TST.b comp_f(a3) * test compare function flag
BNE.s LAB_1B2A * branch if compare function
* was < TK_GT so is operator or lower
ADD.b #(TK_GT-TK_PLUS),d0 * add # of operators (+ - * / ^ AND OR EOR)
BCC.s LAB_1B78 * branch if < + operator
BNE.s LAB_1B0B * branch if not + token
TST.b Dtypef(a3) * test data type, $80=string, $40=integer,
* $00=float
BMI LAB_224D * type is string & token was +
LAB_1B0B
MOVEQ #0,d1 * clear longword
ADD.b d0,d0 * *2
ADD.b d0,d0 * *4
MOVE.b d0,d1 * copy to index
LAB_1B13
MOVE.w (sp)+,d0 * pull previous precedence
LEA LAB_OPPT(pc),a0 * set pointer to operator table
CMP.w (a0,d1.w),d0 * compare with this opperator precedence
BCC.s LAB_1B7D * branch if previous precedence (d0) >=
BSR LAB_CTNM * check if source is numeric, else type mismatch
LAB_1B1C
MOVE.w d0,-(sp) * save precedence
LAB_1B1D
BSR LAB_1B43 * get vector, set-up operator and continue
* evaluation
MOVE.w (sp)+,d0 * restore precedence
MOVE.l prstk(a3),d1 * get stacked function pointer
BPL.s LAB_1B3C * branch if stacked values
MOVE.w d0,d0 * copy precedence (set flags)
BEQ.s LAB_1B7B * exit if done
BRA.s LAB_1B86 * else pop FAC2 & return (do function)
* was compare function (< = >)
LAB_1B2A
MOVE.b Dtypef(a3),d0 * get data type flag
MOVE.b comp_f(a3),d1 * get compare function flag
ADD.b d0,d0 * string bit flag into X bit
ADDX.b d1,d1 * shift compare function flag
MOVE.b #0,Dtypef(a3) * clear data type flag, $00=float
MOVE.b d1,comp_f(a3) * save new compare function flag
SUBQ.w #1,a5 * decrement BASIC execute pointer
MOVEQ #(TK_LT-TK_PLUS)*4,d1 * set offset to last operator entry
BRA.s LAB_1B13 * branch always
LAB_1B3C
LEA LAB_OPPT(pc),a0 * point to function vector table
CMP.w (a0,d1.w),d0 * compare with this opperator precedence
BCC.s LAB_1B86 * branch if d0 >=, pop FAC2 & return
BRA.s LAB_1B1C * branch always
* do functions
LAB_1B78
MOVEQ #-1,d1 * flag all done
MOVE.w (sp)+,d0 * pull precedence word
LAB_1B7B
BEQ.s LAB_1B9D * exit if done
LAB_1B7D
CMP.w #$64,d0 * compare previous precedence with $64
BEQ.s LAB_1B84 * branch if was $64 (< function can be string)
BSR LAB_CTNM * check if source is numeric, else type mismatch
LAB_1B84
MOVE.l d1,prstk(a3) * save current operator index
* pop FAC2 & return
LAB_1B86
MOVE.b (sp)+,d0 * pop comparison evaluation flag
MOVE.b d0,d1 * copy comparison evaluation flag
LSR.b #1,d0 * shift out comparison evaluation lowest bit
MOVE.b d0,Cflag(a3) * save comparison evaluation flag
MOVE.w (sp)+,FAC2_e(a3) * pop exponent and sign
MOVE.l (sp)+,FAC2_m(a3) * pop mantissa
MOVE.b FAC2_s(a3),FAC_sc(a3) * copy FAC2 sign
MOVE.b FAC1_s(a3),d0 * get FAC1 sign
EOR.b d0,FAC_sc(a3) * EOR FAC1 sign and set sign compare
LSR.b #1,d1 * type bit into X and C
RTS
LAB_1B9D
MOVE.b FAC1_e(a3),d0 * get FAC1 exponent
RTS
*************************************************************************************
*
* get a value from the BASIC line
LAB_GVAL
BSR.s LAB_IGBY * increment & scan memory
BCS LAB_2887 * if numeric get FAC1 from string & return
TST.b d0 * test byte
BMI LAB_1BD0 * if -ve go test token values
* else it is either a string, number, variable
* or (<expr>)
CMP.b #'$',d0 * compare with "$"
BEQ LAB_2887 * if "$" get hex number from string & return
CMP.b #'%',d0 * else compare with "%"
BEQ LAB_2887 * if "%" get binary number from string & return
CMP.b #$2E,d0 * compare with "."
BEQ LAB_2887 * if so get FAC1 from string and return
* (e.g. .123)
* wasn't a number so ...
CMP.b #$22,d0 * compare with "
BNE.s LAB_1BF3 * if not open quote it must be a variable or
* open bracket
* was open quote so get the enclosed string
* print "..." string to string stack
LAB_1BC1
MOVE.b (a5)+,d0 * increment BASIC execute pointer (past ")
* fastest/shortest method
MOVEA.l a5,a0 * copy basic execute pointer (string start)
BSR LAB_20AE * print " terminated string to stack
MOVEA.l a2,a5 * restore BASIC execute pointer from temp
RTS
* get value from line .. continued
* wasn't any sort of number so ...
LAB_1BF3
CMP.b #'(',d0 * compare with "("
BNE.s LAB_1C18 * if not "(" get (var) and return value in FAC1
* and $ flag
*************************************************************************************
*
* evaluate expression within parentheses
LAB_1BF7
BSR LAB_EVEZ * evaluate expression (no decrement)
*************************************************************************************
*
* all the 'scan for' routines return the character after the sought character
* scan for ")", else do syntax error, then warm start
LAB_1BFB
MOVEQ #$29,d0 * load d0 with ")"
BRA.s LAB_SCCA
*************************************************************************************
*
* scan for "," and get byte, else do Syntax error then warm start
LAB_SCGB
PEA LAB_GTBY(pc) * return address is to get byte parameter
*************************************************************************************
*
* scan for ",", else do syntax error, then warm start
LAB_1C01
MOVEQ #$2C,d0 * load d0 with ","
*************************************************************************************
*
* scan for CHR$(d0) , else do syntax error, then warm start
LAB_SCCA
CMP.b (a5)+,d0 * check next byte is = d0
BEQ.s LAB_GBYT * if so go get next
BRA LAB_SNER * else do syntax error/warm start
*************************************************************************************
*
* BASIC increment and scan memory routine
LAB_IGBY
MOVE.b (a5)+,d0 * get byte & increment pointer
* scan memory routine, exit with Cb = 1 if numeric character
* also skips any spaces encountered
LAB_GBYT
MOVE.b (a5),d0 * get byte
CMP.b #$20,d0 * compare with " "
BEQ.s LAB_IGBY * if " " go do next
* test current BASIC byte, exit with Cb = 1 if numeric character
CMP.b #TK_ELSE,d0 * compare with the token for ELSE
BCC.s RTS_001 * exit if >= (not numeric, carry clear)
CMP.b #$3A,d0 * compare with ":"
BCC.s RTS_001 * exit if >= (not numeric, carry clear)
MOVe.b #$D0,d6 * set -"0"
ADD.b d6,d0 * add -"0"
SUB.b d6,d0 * subtract -"0"
RTS_001 * carry set if byte = "0"-"9"
RTS
*************************************************************************************
*
* set-up for - operator
LAB_1C11
BSR LAB_CTNM * check if source is numeric, else type mismatch
MOVEQ #(TK_GT-TK_PLUS)*4,d1 * set offset from base to - operator
LAB_1C13
LEA 4(sp),sp * dump GVAL return address
BRA LAB_1B1D * continue evaluating expression
*************************************************************************************
*
* variable name set-up
* get (var), return value in FAC_1 & data type flag
LAB_1C18
BSR LAB_GVAR * get variable address in a0
* if you want a non existant variable to return a null value then set the novar
* value at the top of this file to some non zero value
ifne novar
BNE.s LAB_1C19 * if it exists return it
LEA.l LAB_1D96(pc),a0 * else return a null descriptor/pointer
endc
* return existing variable value
LAB_1C19
TST.b Dtypef(a3) * test data type, $80=string, $40=integer,
* $00=float
BEQ LAB_UFAC * if float unpack memory (a0) into FAC1 and
* return
BPL.s LAB_1C1A * if integer unpack memory (a0) into FAC1
* and return
MOVE.l a0,FAC1_m(a3) * else save descriptor pointer in FAC1
RTS
LAB_1C1A
MOVE.l (a0),d0 * get integer value
BRA LAB_AYFC * convert d0 to signed longword in FAC1 & return
*************************************************************************************
*
* get value from line .. continued
* do tokens
LAB_1BD0
CMP.b #TK_MINUS,d0 * compare with token for -
BEQ.s LAB_1C11 * branch if - token (do set-up for - operator)
* wasn't -123 so ...
CMP.b #TK_PLUS,d0 * compare with token for +
BEQ LAB_GVAL * branch if + token (+n = n so ignore leading +)
CMP.b #TK_NOT,d0 * compare with token for NOT
BNE.s LAB_1BE7 * branch if not token for NOT
* was NOT token
MOVE.w #(TK_EQUAL-TK_PLUS)*4,d1 * offset to NOT function
BRA.s LAB_1C13 * do set-up for function then execute
* wasn't +, - or NOT so ...
LAB_1BE7
CMP.b #TK_FN,d0 * compare with token for FN
BEQ LAB_201E * if FN go evaluate FNx
* wasn't +, -, NOT or FN so ...
SUB.b #TK_SGN,d0 * compare with token for SGN & normalise
BCS LAB_SNER * if < SGN token then do syntax error
* get value from line .. continued
* only functions left so set up function references
* new for V2.0+ this replaces a lot of IF .. THEN .. ELSEIF .. THEN .. that was needed
* to process function calls. now the function vector is computed and pushed on the stack
* and the preprocess offset is read. if the preprocess offset is non zero then the vector
* is calculated and the routine called, if not this routine just does RTS. whichever
* happens the RTS at the end of this routine, or the preprocess routine calls, the
* function code
* this also removes some less than elegant code that was used to bypass type checking
* for functions that returned strings
AND.w #$7F,d0 * mask byte
ADD.w d0,d0 * *2 (2 bytes per function offset)
LEA LAB_FTBL(pc),a0 * pointer to functions vector table
MOVE.w (a0,d0.w),d1 * get function vector offset
PEA (a0,d1.w) * push function vector
LEA LAB_FTPP(pc),a0 * pointer to functions preprocess vector table
MOVE.w (a0,d0.w),d0 * get function preprocess vector offset
BEQ.s LAB_1C2A * no preprocess vector so go do function
LEA (a0,d0.w),a0 * get function preprocess vector
JMP (a0) * go do preprocess routine then function
*************************************************************************************
*
* process string expression in parenthesis
LAB_PPFS
BSR LAB_1BF7 * process expression in parenthesis
TST.b Dtypef(a3) * test data type
BPL LAB_TMER * if numeric do Type missmatch Error/warm start
LAB_1C2A
RTS * else do function
*************************************************************************************
*
* process numeric expression in parenthesis
LAB_PPFN
BSR LAB_1BF7 * process expression in parenthesis
TST.b Dtypef(a3) * test data type
BMI LAB_TMER * if string do Type missmatch Error/warm start
RTS * else do function
*************************************************************************************
*
* set numeric data type and increment BASIC execute pointer
LAB_PPBI
MOVE.b #$00,Dtypef(a3) * clear data type flag, $00=float
MOVE.b (a5)+,d0 * get next BASIC byte
RTS * do function
*************************************************************************************
*
* process string for LEFT$, RIGHT$ or MID$
LAB_LRMS
BSR LAB_EVEZ * evaluate (should be string) expression
TST.b Dtypef(a3) * test data type flag
BPL LAB_TMER * if type is not string do type mismatch error
MOVE.b (a5)+,d2 * get BASIC byte
CMP.b #',',d2 * compare with comma
BNE LAB_SNER * if not "," go do syntax error/warm start
MOVE.l FAC1_m(a3),-(sp) * save descriptor pointer
BSR LAB_GTWO * get word parameter, result in d0 and Itemp
MOVEA.l (sp)+,a0 * restore descriptor pointer
RTS * do function
*************************************************************************************
*
* process numeric expression(s) for BIN$ or HEX$
LAB_BHSS
BSR LAB_EVEZ * evaluate expression (no decrement)
TST.b Dtypef(a3) * test data type
BMI LAB_TMER * if string do Type missmatch Error/warm start
BSR LAB_2831 * convert FAC1 floating to fixed
* result in d0 and Itemp
MOVEQ #0,d1 * set default to no leading "0"s
MOVE.b (a5)+,d2 * get BASIC byte
CMP.b #',',d2 * compare with comma
BNE.s LAB_BHCB * if not "," go check close bracket
MOVE.l d0,-(sp) * copy number to stack
BSR LAB_GTBY * get byte value
MOVE.l d0,d1 * copy leading 0s #
MOVE.l (sp)+,d0 * restore number from stack
MOVE.b (a5)+,d2 * get BASIC byte
LAB_BHCB
CMP.b #')',d2 * compare with close bracket
BNE LAB_SNER * if not ")" do Syntax Error/warm start
RTS * go do function
*************************************************************************************
*
* perform EOR
LAB_EOR
BSR.s GetFirst * get two values for OR, AND or EOR
* first in d0, and Itemp, second in d2
EOR.l d2,d0 * EOR values
BRA LAB_AYFC * convert d0 to signed longword in FAC1 & RET
*************************************************************************************
*
* perform OR
LAB_OR
BSR.s GetFirst * get two values for OR, AND or EOR
* first in d0, and Itemp, second in d2
OR.l d2,d0 * do OR
BRA LAB_AYFC * convert d0 to signed longword in FAC1 & RET
*************************************************************************************
*
* perform AND
LAB_AND
BSR.s GetFirst * get two values for OR, AND or EOR
* first in d0, and Itemp, second in d2
AND.l d2,d0 * do AND
BRA LAB_AYFC * convert d0 to signed longword in FAC1 & RET
*************************************************************************************
*
* get two values for OR, AND, EOR
* first in d0, second in d2
GetFirst
BSR LAB_EVIR * evaluate integer expression (no sign check)
* result in d0 and Itemp
MOVE.l d0,d2 * copy second value
BSR LAB_279B * copy FAC2 to FAC1, get first value in
* expression
BRA LAB_EVIR * evaluate integer expression (no sign check)
* result in d0 and Itemp & return
*************************************************************************************
*
* perform NOT
LAB_EQUAL
BSR LAB_EVIR * evaluate integer expression (no sign check)
* result in d0 and Itemp
NOT.l d0 * bitwise invert
BRA LAB_AYFC * convert d0 to signed longword in FAC1 & RET
*************************************************************************************
*
* perform comparisons
* do < compare
LAB_LTHAN
BSR LAB_CKTM * type match check, set C for string
BCS.s LAB_1CAE * branch if string
* do numeric < compare
BSR LAB_27FA * compare FAC1 with FAC2
* returns d0=+1 if FAC1 > FAC2
* returns d0= 0 if FAC1 = FAC2
* returns d0=-1 if FAC1 < FAC2
BRA.s LAB_1CF2 * process result
* do string < compare
LAB_1CAE
MOVE.b #$00,Dtypef(a3) * clear data type, $80=string, $40=integer,
* $00=float
BSR LAB_22B6 * pop string off descriptor stack, or from top
* of string space returns d0 = length,
* a0 = pointer
MOVEA.l a0,a1 * copy string 2 pointer
MOVE.l d0,d1 * copy string 2 length
MOVEA.l FAC2_m(a3),a0 * get string 1 descriptor pointer
BSR LAB_22BA * pop (a0) descriptor, returns with ..
* d0 = length, a0 = pointer
MOVE.l d0,d2 * copy length
BNE.s LAB_1CB5 * branch if not null string
TST.l d1 * test if string 2 is null also
BEQ.s LAB_1CF2 * if so do string 1 = string 2
LAB_1CB5
SUB.l d1,d2 * subtract string 2 length
BEQ.s LAB_1CD5 * branch if strings = length
BCS.s LAB_1CD4 * branch if string 1 < string 2
MOVEQ #-1,d0 * set for string 1 > string 2
BRA.s LAB_1CD6 * go do character comapare
LAB_1CD4
MOVE.l d0,d1 * string 1 length is compare length
MOVEQ #1,d0 * and set for string 1 < string 2
BRA.s LAB_1CD6 * go do character comapare
LAB_1CD5
MOVE.l d2,d0 * set for string 1 = string 2
LAB_1CD6
SUBQ.l #1,d1 * adjust length for DBcc loop
* d1 is length to compare, d0 is <=> for length
* a0 is string 1 pointer, a1 is string 2 pointer
LAB_1CE6
CMPM.b (a0)+,(a1)+ * compare string bytes (1 with 2)
DBNE d1,LAB_1CE6 * loop if same and not end yet
BEQ.s LAB_1CF2 * if = to here, then go use length compare
BCC.s LAB_1CDB * else branch if string 1 > string 2
MOVEQ #-1,d0 * else set for string 1 < string 2
BRA.s LAB_1CF2 * go set result
LAB_1CDB
MOVEQ #1,d0 * and set for string 1 > string 2
LAB_1CF2
ADDQ.b #1,d0 * make result 0, 1 or 2
MOVE.b d0,d1 * copy to d1
MOVEQ #1,d0 * set d0 longword
ROL.b d1,d0 * make 1, 2 or 4 (result = flag bit)
AND.b Cflag(a3),d0 * AND with comparison evaluation flag
BEQ LAB_27DB * exit if not a wanted result (i.e. false)
MOVEQ #-1,d0 * else set -1 (true)
BRA LAB_27DB * save d0 as integer & return
LAB_1CFE
BSR LAB_1C01 * scan for ",", else do syntax error/warm start
*************************************************************************************
*
* perform DIM
LAB_DIM
MOVEQ #-1,d1 * set "DIM" flag
BSR.s LAB_1D10 * search for or dimension a variable
BSR LAB_GBYT * scan memory
BNE.s LAB_1CFE * loop and scan for "," if not null
RTS
*************************************************************************************
*
* perform << (left shift)
LAB_LSHIFT
BSR.s GetPair * get an integer and byte pair
* byte is in d2, integer is in d0 and Itemp
BEQ.s NoShift * branch if byte zero
CMP.b #$20,d2 * compare bit count with 32d
BCC.s TooBig * branch if >=
ASL.l d2,d0 * shift longword
NoShift
BRA LAB_AYFC * convert d0 to signed longword in FAC1 & RET
*************************************************************************************
*
* perform >> (right shift)
LAB_RSHIFT
BSR.s GetPair * get an integer and byte pair
* byte is in d2, integer is in d0 and Itemp
BEQ.s NoShift * branch if byte zero
CMP.b #$20,d2 * compare bit count with 32d
BCS.s Not2Big * branch if >= (return shift)
TST.l d0 * test sign bit
BPL.s TooBig * branch if +ve
MOVEQ #-1,d0 * set longword
BRA LAB_AYFC * convert d0 to longword in FAC1 & RET
Not2Big
ASR.l d2,d0 * shift longword
BRA LAB_AYFC * convert d0 to longword in FAC1 & RET
TooBig
MOVEQ #0,d0 * clear longword
BRA LAB_AYFC * convert d0 to longword in FAC1 & RET
*************************************************************************************
*
* get an integer and byte pair
* byte is in d2, integer is in d0 and Itemp
GetPair
BSR LAB_EVBY * evaluate byte expression, result in d0 and
* Itemp
MOVE.b d0,d2 * save it
BSR LAB_279B * copy FAC2 to FAC1, get first value in
* expression
BSR LAB_EVIR * evaluate integer expression (no sign check)
* result in d0 and Itemp
TST.b d2 * test byte value
RTS
*************************************************************************************
*
* check alpha, return C=0 if<"A" or >"Z" or <"a" to "z">
LAB_CASC
CMP.b #$61,d0 * compare with "a"
BCC.s LAB_1D83 * if >="a" go check =<"z"
*************************************************************************************
*
* check alpha upper case, return C=0 if<"A" or >"Z"
LAB_CAUC
CMP.b #$41,d0 * compare with "A"
BCC.s LAB_1D8A * if >="A" go check =<"Z"
OR d0,d0 * make C=0
RTS
LAB_1D8A
CMP.b #$5B,d0 * compare with "Z"+1
* carry set if byte<="Z"
RTS
LAB_1D83
CMP.b #$7B,d0 * compare with "z"+1
* carry set if byte<="z"
RTS
*************************************************************************************
*
* search for or create variable. this is used to automatically create a variable if
* it is not found. any routines that need to create the variable call LAB_GVAR via
* this point and error generation is supressed and the variable will be created
*
* return pointer to variable in Cvaral and a0
* set data type to variable type
LAB_SVAR
BSR.s LAB_GVAR * search for variable
LAB_FVAR
RTS
*************************************************************************************
*
* search for variable. if this routine is called from anywhere but the above call and
* the variable searched for does not exist then an error will be returned
*
* DIM flag is in d1.b
* return pointer to variable in Cvaral and a0
* set data type to variable type
LAB_GVAR
MOVEQ #$00,d1 * set DIM flag = $00
BSR LAB_GBYT * scan memory (1st character)
LAB_1D10
MOVE.b d1,Defdim(a3) * save DIM flag
* search for FN name entry point
LAB_1D12
BSR.s LAB_CASC * check byte, return C=0 if<"A" or >"Z"
BCC LAB_SNER * if not, syntax error then warm start
* it is a variable name so ...
MOVEQ #$0,d1 * set index for name byte
LEA Varname(a3),a0 * pointer to variable name
MOVE.l d1,(a0) * clear the variable name
MOVE.b d1,Dtypef(a3) * clear the data type, $80=string, $40=integer,
* $00=float
LAB_1D2D
CMP.w #$04,d1 * done all significant characters?
BCC.s LAB_1D2E * if so go ignore any more
MOVE.b d0,(a0,d1.w) * save the character
ADDQ.w #1,d1 * increment index
LAB_1D2E
BSR LAB_IGBY * increment & scan memory (next character)
BCS.s LAB_1D2D * branch if character = "0"-"9" (ok)
* character wasn't "0" to "9" so ...
BSR.s LAB_CASC * check byte, return C=0 if<"A" or >"Z"
BCS.s LAB_1D2D * branch if = "A"-"Z" (ok)
* check if string variable
CMP.b #'$',d0 * compare with "$"
BNE.s LAB_1D44 * branch if not string
* type is string
OR.b #$80,Varname+1(a3) * set top bit of 2nd character, indicate string
BSR LAB_IGBY * increment & scan memory
BRA.s LAB_1D45 * skip integer check
* check if integer variable
LAB_1D44
CMP.b #'&',d0 * compare with "&"
BNE.s LAB_1D45 * branch if not integer
* type is integer
OR.b #$80,Varname+2(a3) * set top bit of 3rd character, indicate integer
BSR LAB_IGBY * increment & scan memory
* after we have determined the variable type we need to determine
* if it's an array of type
* gets here with character after var name in d0
LAB_1D45
TST.b Sufnxf(a3) * test function name flag
BEQ.s LAB_1D48 * if not FN or FN variable continue
BPL.s LAB_1D49 * if FN variable go find or create it
* else was FN name
MOVE.l Varname(a3),d0 * get whole function name
MOVEQ #8,d1 * set step to next function size -4
LEA Sfncl(a3),a0 * get pointer to start of functions
BRA.s LAB_1D4B * go find function
LAB_1D48
SUB.b #'(',d0 * subtract "("
BEQ LAB_1E17 * if "(" go find, or make, array
* either find or create var
* var name (1st four characters only!) is in Varname
* variable name wasn't var( .. so look for
* plain variable
LAB_1D49
MOVE.l Varname(a3),d0 * get whole variable name
LAB_1D4A
MOVEQ #4,d1 * set step to next variable size -4
LEA Svarl(a3),a0 * get pointer to start of variables
BTST.l #23,d0 * test if string name
BEQ.s LAB_1D4B * branch if not
ADDQ.w #2,d1 * 6 bytes per string entry
ADD.w #(Sstrl-Svarl),a0 * move to string area
LAB_1D4B
MOVEA.l 4(a0),a1 * get end address
MOVEA.l (a0),a0 * get start address
BRA.s LAB_1D5E * enter loop at exit check
LAB_1D5D
CMP.l (a0)+,d0 * compare this variable with name
BEQ.s LAB_1DD7 * branch if match (found var)
ADDA.l d1,a0 * add offset to next variable
LAB_1D5E
CMPA.l a1,a0 * compare address with variable space end
BNE.s LAB_1D5D * if not end go check next
TST.b Sufnxf(a3) * is it a function or function variable
BNE.s LAB_1D94 * if was go do DEF or function variable
* reached end of variable mem without match
* ... so create new variable, possibly
LEA LAB_FVAR(pc),a2 * get the address of the create if doesn't
* exist call to LAB_GVAR
CMPA.l (sp),a2 * compare the return address with expected
BNE LAB_UVER * if not create go do error or return null
* this will only branch if the call to LAB_GVAR wasn't from LAB_SVAR
LAB_1D94
BTST.b #0,Sufnxf(a3) * test function search flag
BNE LAB_UFER * if not doing DEF then go do undefined
* function error
* else create new variable/function
LAB_1D98
MOVEA.l Earryl(a3),a2 * get end of block to move
MOVE.l a2,d2 * copy end of block to move
SUB.l a1,d2 * calculate block to move size
MOVEA.l a2,a0 * copy end of block to move
ADDQ.l #4,d1 * space for one variable/function + name
ADDA.l d1,a2 * add space for one variable/function
MOVE.l a2,Earryl(a3) * set new array mem end
LSR.l #1,d2 * /2 for word copy
BEQ.s LAB_1DAF * skip move if zero length block
SUBQ.l #1,d2 * -1 for DFB loop
SWAP d2 * swap high word to low word
LAB_1DAC
SWAP d2 * swap high word to low word
LAB_1DAE
MOVE.w -(a0),-(a2) * copy word
DBF d2,LAB_1DAE * loop until done
SWAP d2 * swap high word to low word
DBF d2,LAB_1DAC * decrement high count and loop until done
* get here after creating either a function, variable or string
* if function set variables start, string start, array start
* if variable set string start, array start
* if string set array start
LAB_1DAF
TST.b Sufnxf(a3) * was it function
BMI.s LAB_1DB0 * branch if was FN
BTST.l #23,d0 * was it string
BNE.s LAB_1DB2 * branch if string
BRA.s LAB_1DB1 * branch if was plain variable
LAB_1DB0
ADD.l d1,Svarl(a3) * set new variable memory start
LAB_1DB1
ADD.l d1,Sstrl(a3) * set new start of strings
LAB_1DB2
ADD.l d1,Sarryl(a3) * set new array memory start
MOVE.l d0,(a0)+ * save variable/function name
MOVE.l #$00,(a0) * initialise variable
BTST.l #23,d0 * was it string
BEQ.s LAB_1DD7 * branch if not string
MOVE.w #$00,4(a0) * else initialise string length
* found a match for var ((Vrschl) = ptr)
LAB_1DD7
MOVE.l d0,d1 * ........ $....... &....... ........
ADD.l d1,d1 * .......$ .......& ........ .......0
SWAP d1 * ........ .......0 .......$ .......&
ROR.b #1,d1 * ........ .......0 .......$ &.......
LSR.w #1,d1 * ........ .......0 0....... $&.....�.
AND.b #$C0,d1 * mask the type bits
MOVE.b d1,Dtypef(a3) * save the data type
MOVE.b #$00,Sufnxf(a3) * clear FN flag byte
* if you want a non existant variable to return a null value then set the novar
* value at the top of this file to some non zero value
ifne novar
MOVEQ #-1,d0 * return variable found
endc
RTS
*************************************************************************************
*
* set-up array pointer, d0, to first element in array
* set d0 to (a0)+2*(Dimcnt)+$0A
LAB_1DE6
MOVEQ #5,d0 * set d0 to 5 (*2 = 10, later)
ADD.b Dimcnt(a3),d0 * add # of dimensions (1, 2 or 3)
ADD.l d0,d0 * *2 (bytes per dimension size)
ADD.l a0,d0 * add array start pointer
RTS
*************************************************************************************
*
* evaluate unsigned integer expression
LAB_EVIN
BSR LAB_IGBY * increment & scan memory
BSR LAB_EVNM * evaluate expression & check is numeric,
* else do type mismatch
*************************************************************************************
*
* evaluate positive integer expression, result in d0 and Itemp
LAB_EVPI
TST.b FAC1_s(a3) * test FAC1 sign (b7)
BMI LAB_FCER * do function call error if -ve
*************************************************************************************
*
* evaluate integer expression, no sign check
* result in d0 and Itemp, exit with flags set correctly
LAB_EVIR
CMPI.b #$A0,FAC1_e(a3) * compare exponent with exponent = 2^32 (n>2^31)
BCS LAB_2831 * convert FAC1 floating to fixed
* result in d0 and Itemp
BNE LAB_FCER * if > do function call error, then warm start
TST.b FAC1_s(a3) * test sign of FAC1
BPL LAB_2831 * if +ve then ok
MOVE.l FAC1_m(a3),d0 * get mantissa
NEG.l d0 * do -d0
BVC LAB_FCER * if not $80000000 do FC error, then warm start
MOVE.l d0,Itemp(a3) * else just set it
RTS
*************************************************************************************
*
* find or make array
LAB_1E17
MOVE.w Defdim(a3),-(sp) * get DIM flag and data type flag (word in mem)
MOVEQ #0,d1 * clear dimensions count
* now get the array dimension(s) and stack it (them) before the data type and DIM flag
LAB_1E1F
MOVE.w d1,-(sp) * save dimensions count
MOVE.l Varname(a3),-(sp) * save variable name
BSR.s LAB_EVIN * evaluate integer expression
SWAP d0 * swap high word to low word
TST.w d0 * test swapped high word
BNE LAB_ABER * if too big do array bounds error
MOVE.l (sp)+,Varname(a3) * restore variable name
MOVE.w (sp)+,d1 * restore dimensions count
MOVE.w (sp)+,d0 * restore DIM and data type flags
MOVE.w Itemp+2(a3),-(sp) * stack this dimension size
MOVE.w d0,-(sp) * save DIM and data type flags
ADDQ.w #1,d1 * increment dimensions count
BSR LAB_GBYT * scan memory
CMP.b #$2C,d0 * compare with ","
BEQ.s LAB_1E1F * if found go do next dimension
MOVE.b d1,Dimcnt(a3) * store dimensions count
BSR LAB_1BFB * scan for ")", else do syntax error/warm start
MOVE.w (sp)+,Defdim(a3) * restore DIM and data type flags (word in mem)
MOVEA.l Sarryl(a3),a0 * get array mem start
* now check to see if we are at the end of array memory (we would be if there were
* no arrays).
LAB_1E5C
MOVE.l a0,Astrtl(a3) * save as array start pointer
CMPA.l Earryl(a3),a0 * compare with array mem end
BEQ.s LAB_1EA1 * go build array if not found
* search for array
MOVE.l (a0),d0 * get this array name
CMP.l Varname(a3),d0 * compare with array name
BEQ.s LAB_1E8D * array found so branch
* no match
MOVEA.l 4(a0),a0 * get this array size
ADDA.l Astrtl(a3),a0 * add to array start pointer
BRA.s LAB_1E5C * go check next array
* found array, are we trying to dimension it?
LAB_1E8D
TST.b Defdim(a3) * are we trying to dimension it?
BNE LAB_DDER * if so do double dimension error/warm start
* found the array and we're not dimensioning it so we must find an element in it
BSR LAB_1DE6 * set data pointer, d0, to the first element
* in the array
ADDQ.w #8,a0 * index to dimension count
MOVE.w (a0)+,d0 * get no of dimensions
CMP.b Dimcnt(a3),d0 * compare with dimensions count
BEQ LAB_1F28 * found array so go get element
BRA LAB_WDER * else wrong so do "Wrong dimensions" error
* array not found, so possibly build it
LAB_1EA1
TST.b Defdim(a3) * test the default DIM flag
BEQ LAB_UDER * if default flag is clear then we are not
* explicitly dimensioning an array so go
* do an "Undimensioned array" error
BSR LAB_1DE6 * set data pointer, d0, to the first element
* in the array
MOVE.l Varname(a3),d0 * get array name
MOVE.l d0,(a0)+ * save array name
MOVEQ #4,d1 * set 4 bytes per element
BTST.l #23,d0 * test if string array
BEQ.s LAB_1EDF * branch if not string
MOVEQ #6,d1 * else 6 bytes per element
LAB_1EDF
MOVE.l d1,Asptl(a3) * set array data size (bytes per element)
MOVE.b Dimcnt(a3),d1 * get dimensions count
ADDQ.w #4,a0 * skip the array size now (don't know it yet!)
MOVE.w d1,(a0)+ * set array's dimensions count
* now calculate the array data space size
LAB_1EC0
* If you want arrays to dimension themselves by default then comment out the test
* above and uncomment the next three code lines and the label LAB_1ED0
* MOVE.w #$0A,d1 * set default dimension value, allow 0 to 9
* TST.b Defdim(a3) * test default DIM flag
* BNE.s LAB_1ED0 * branch if b6 of Defdim is clear
MOVE.w (sp)+,d1 * get dimension size
*LAB_1ED0
MOVE.w d1,(a0)+ * save to array header
BSR LAB_1F7C * do this dimension size+1 * array size
* (d1+1)*(Asptl), result in d0
MOVE.l d0,Asptl(a3) * save array data size
SUBQ.b #1,Dimcnt(a3) * decrement dimensions count
BNE.s LAB_1EC0 * loop while not = 0
ADDA.l Asptl(a3),a0 * add size to first element address
BCS LAB_OMER * if overflow go do "Out of memory" error
CMPA.l Sstorl(a3),a0 * compare with bottom of string memory
BCS.s LAB_1ED6 * branch if less (is ok)
BSR LAB_GARB * do garbage collection routine
CMPA.l Sstorl(a3),a0 * compare with bottom of string memory
BCC LAB_OMER * if Sstorl <= a0 do "Out of memory"
* error then warm start
LAB_1ED6 * ok exit, carry set
MOVE.l a0,Earryl(a3) * save array mem end
MOVEQ #0,d0 * zero d0
MOVE.l Asptl(a3),d1 * get size in bytes
LSR.l #1,d1 * /2 for word fill (may be odd # words)
SUBQ.w #1,d1 * adjust for DBF loop
LAB_1ED8
MOVE.w d0,-(a0) * decrement pointer and clear word
DBF d1,LAB_1ED8 * decrement & loop until low word done
SWAP d1 * swap words
TST.w d1 * test high word
BEQ.s LAB_1F07 * exit if done
SUBQ.w #1,d1 * decrement low (high) word
SWAP d1 * swap back
BRA.s LAB_1ED8 * go do a whole block
* now we need to calculate the array size by doing Earryl - Astrtl
LAB_1F07
MOVEA.l Astrtl(a3),a0 * get for calculation and as pointer
MOVE.l Earryl(a3),d0 * get array memory end
SUB.l a0,d0 * calculate array size
MOVE.l d0,4(a0) * save size to array
TST.b Defdim(a3) * test default DIM flag
BNE.s RTS_011 * exit (RET) if this was a DIM command
* else, find element
ADDQ.w #8,a0 * index to dimension count
MOVE.w (a0)+,Dimcnt(a3) * get array's dimension count
* we have found, or built, the array. now we need to find the element
LAB_1F28
MOVEQ #0,d0 * clear first result
MOVE.l d0,Asptl(a3) * clear array data pointer
* compare nth dimension bound (a0) with nth index (sp)+
* if greater do array bounds error
LAB_1F2C
MOVE.w (a0)+,d1 * get nth dimension bound
CMP.w (sp),d1 * compare nth index with nth dimension bound
BCS LAB_ABER * if d1 less or = do array bounds error
* now do pointer = pointer * nth dimension + nth index
TST.l d0 * test pointer
BEQ.s LAB_1F5A * skip multiply if last result = null
BSR.s LAB_1F7C * do this dimension size+1 * array size
LAB_1F5A
MOVEQ #0,d1 * clear longword
MOVE.w (sp)+,d1 * get nth dimension index
ADD.l d1,d0 * add index to size
MOVE.l d0,Asptl(a3) * save array data pointer
SUBQ.b #1,Dimcnt(a3) * decrement dimensions count
BNE.s LAB_1F2C * loop if dimensions still to do
MOVE.b #0,Dtypef(a3) * set data type to float
MOVEQ #3,d1 * set for numeric array
TST.b Varname+1(a3) * test if string array
BPL.s LAB_1F6A * branch if not string
MOVEQ #5,d1 * else set for string array
MOVE.b #$80,Dtypef(a3) * and set data type to string
BRA.s LAB_1F6B * skip integer test
LAB_1F6A
TST.b Varname+2(a3) * test if integer array
BPL.s LAB_1F6B * branch if not integer
MOVE.b #$40,Dtypef(a3) * else set data type to integer
LAB_1F6B
BSR.s LAB_1F7C * do element size (d1) * array size (Asptl)
ADDA.l d0,a0 * add array data start pointer
RTS_011
RTS
*************************************************************************************
*
* do this dimension size (d1) * array data size (Asptl)
* do a 16 x 32 bit multiply
* d1 holds the 16 bit multiplier
* Asptl holds the 32 bit multiplicand
* d0 bbbb bbbb
* d1 0000 aaaa
* ----------
* d0 rrrr rrrr
LAB_1F7C
MOVE.l Asptl(a3),d0 * get result
MOVE.l d0,d2 * copy it
SWAP d2 * shift high word to low word
MULU.w d1,d0 * d1 * low word = low result
MULU.w d1,d2 * d1 * high word = high result
SWAP d2 * align words for test
TST.w d2 * must be zero
BNE LAB_OMER * if overflow go do "Out of memory" error
ADD.l d2,d0 * calculate result
BCS LAB_OMER * if overflow go do "Out of memory" error
ADD.l Asptl(a3),d0 * add original
BCS LAB_OMER * if overflow go do "Out of memory" error
RTS
*************************************************************************************
*
* perform FRE()
LAB_FRE
TST.b Dtypef(a3) * test data type, $80=string, $40=integer,
* $00=float
BPL.s LAB_1FB4 * branch if numeric
BSR LAB_22B6 * pop string off descriptor stack, or from
* top of string space, returns d0 = length,
* a0 = pointer
* FRE(n) was numeric so do this
LAB_1FB4
BSR LAB_GARB * go do garbage collection
MOVE.l Sstorl(a3),d0 * get bottom of string space
SUB.l Earryl(a3),d0 * subtract array mem end
*************************************************************************************
*
* convert d0 to signed longword in FAC1
LAB_AYFC
MOVE.b #$00,Dtypef(a3) * clear data type, $80=string, $40=integer,
* $00=float
MOVE.w #$A000,FAC1_e(a3) * set FAC1 exponent and clear sign (b7)
MOVE.l d0,FAC1_m(a3) * save FAC1 mantissa
BPL LAB_24D0 * convert if +ve
ORI.b #1,CCR * else set carry
BRA LAB_24D0 * do +/- (carry is sign) & normalise FAC1
*************************************************************************************
*
* remember if the line length is zero (infinite line) then POS(n) will return
* position MOD tabsize
* perform POS()
LAB_POS
MOVE.b TPos(a3),d0 * get terminal position
* convert d0 to unsigned byte in FAC1
LAB_1FD0
AND.l #$FF,d0 * clear high bits
BRA.s LAB_AYFC * convert d0 to signed longword in FAC1 & RET
* check not direct (used by DEF and INPUT)
LAB_CKRN
TST.b Clinel(a3) * test current line #
BMI LAB_IDER * if -ve go do illegal direct error then warm
* start
RTS * can continue so return
*************************************************************************************
*
* perform DEF
LAB_DEF
MOVE.w #TK_FN-$100,d0 * get FN token
BSR LAB_SCCA * scan for CHR$(d0), else syntax error and
* warm start
* return character after d0
MOVE.b #$80,Sufnxf(a3) * set FN flag bit
BSR LAB_1D12 * get FN name
MOVE.l a0,func_l(a3) * save function pointer
BSR.s LAB_CKRN * check not direct (back here if ok)
CMP.b #$28,(a5)+ * check next byte is "(" and increment
BNE LAB_SNER * else do syntax error/warm start
MOVE.b #$7E,Sufnxf(a3) * set FN variable flag bits
BSR LAB_SVAR * search for or create a variable
* return the variable address in a0
BSR LAB_1BFB * scan for ")", else do syntax error/warm start
MOVE.w #TK_EQUAL-$100,d0 * = token
BSR LAB_SCCA * scan for CHR$(A), else syntax error/warm start
* return character after d0
MOVE.l Varname(a3),-(sp) * push current variable name
MOVE.l a5,-(sp) * push BASIC execute pointer
BSR LAB_DATA * go perform DATA, find end of DEF FN statement
MOVEA.l func_l(a3),a0 * get the function pointer
MOVE.l (sp)+,(a0) * save BASIC execute pointer to function
MOVE.l (sp)+,4(a0) * save current variable name to function
RTS
*************************************************************************************
*
* evaluate FNx
LAB_201E
MOVE.b #$81,Sufnxf(a3) * set FN flag (find not create)
BSR LAB_IGBY * increment & scan memory
BSR LAB_1D12 * get FN name
MOVE.b Dtypef(a3),-(sp) * push data type flag (function type)
MOVE.l a0,-(sp) * push function pointer
CMP.b #$28,(a5) * check next byte is "(", no increment
BNE LAB_SNER * else do syntax error/warm start
BSR LAB_1BF7 * evaluate expression within parentheses
MOVEA.l (sp)+,a0 * pop function pointer
MOVE.l a0,func_l(a3) * set function pointer
MOVE.b Dtypef(a3),-(sp) * push data type flag (function expression type)
MOVE.l 4(a0),d0 * get function variable name
BSR LAB_1D4A * go find function variable (already created)
* now check type match for variable
MOVE.b (sp)+,d0 * pop data type flag (function expression type)
ROL.b #1,d0 * set carry if type = string
BSR LAB_CKTM * type match check, set C for string
* now stack the function variable value before
* use
BEQ.s LAB_2043 * branch if not string
LEA des_sk_e(a3),a1 * get string stack pointer max+1
CMPA.l a1,a4 * compare string stack pointer with max+1
BEQ LAB_SCER * if no space on the stack go do string too
* complex error
MOVE.w 4(a0),-(a4) * string length on descriptor stack
MOVE.l (a0),-(a4) * string address on stack
BRA.s LAB_204S * skip var push
LAB_2043
MOVE.l (a0),-(sp) * push variable
LAB_204S
MOVE.l a0,-(sp) * push variable address
MOVE.b Dtypef(a3),-(sp) * push variable data type
BSR.s LAB_2045 * pack function expression value into (a0)
* (function variable)
MOVE.l a5,-(sp) * push BASIC execute pointer
MOVEA.l func_l(a3),a0 * get function pointer
MOVEA.l (a0),a5 * save function execute ptr as BASIC execute ptr
BSR LAB_EVEX * evaluate expression
BSR LAB_GBYT * scan memory
BNE LAB_SNER * if not [EOL] or [EOS] do syntax error and
* warm start
MOVE.l (sp)+,a5 * restore BASIC execute pointer
* restore variable from stack and test data type
MOVE.b (sp)+,d0 * pull variable data type
MOVEA.l (sp)+,a0 * pull variable address
TST.b d0 * test variable data type
BPL.s LAB_204T * branch if not string
MOVE.l (a4)+,(a0) * string address from descriptor stack
MOVE.w (a4)+,4(a0) * string length from descriptor stack
BRA.s LAB_2044 * skip variable pull
LAB_204T
MOVE.l (sp)+,(a0) * restore variable from stack
LAB_2044
MOVE.b (sp)+,d0 * pop data type flag (function type)
ROL.b #1,d0 * set carry if type = string
BSR LAB_CKTM * type match check, set C for string
RTS
LAB_2045
TST.b Dtypef(a3) * test data type
BPL LAB_2778 * if numeric pack FAC1 into variable (a0)
* and return
MOVEA.l a0,a2 * copy variable pointer
BRA LAB_17D6 * go do string LET & return
*************************************************************************************
*
* perform STR$()
LAB_STRS
BSR LAB_2970 * convert FAC1 to string
* scan, set up string
* print " terminated string to FAC1 stack
LAB_20AE
MOVEQ #$22,d2 * set Srchc character (terminator 1)
MOVE.w d2,d3 * set Asrch character (terminator 2)
* print d2/d3 terminated string to FAC1 stack
* d2 = Srchc, d3 = Asrch, a0 is source
* a6 is temp
LAB_20B4
MOVEQ #0,d1 * clear longword
SUBQ.w #1,d1 * set length to -1
MOVEA.l a0,a2 * copy start to calculate end
LAB_20BE
ADDQ.w #1,d1 * increment length
MOVE.b (a0,d1.w),d0 * get byte from string
BEQ.s LAB_20D0 * exit loop if null byte [EOS]
CMP.b d2,d0 * compare with search character (terminator 1)
BEQ.s LAB_20CB * branch if terminator
CMP.b d3,d0 * compare with terminator 2
BNE.s LAB_20BE * loop if not terminator 2 (or null string)
LAB_20CB
CMP.b #$22,d0 * compare with "
BNE.s LAB_20D0 * branch if not "
ADDQ.w #1,a2 * else increment string start (skip " at end)
LAB_20D0
ADDA.l d1,a2 * add longowrd length to make string end+1
CMPA.l a3,a0 * is string in ram
BCS.s LAB_RTST * if not go push descriptor on stack & exit
* (could be message string from ROM)
CMPA.l Smeml(a3),a0 * is string in utility ram
BCC.s LAB_RTST * if not go push descriptor on stack & exit
* (is in string or program space)
* (else) copy string to string memory
LAB_20C9
MOVEA.l a0,a1 * copy descriptor pointer
MOVE.l d1,d0 * copy longword length
BNE.s LAB_20D8 * branch if not null string
MOVEA.l d1,a0 * make null pointer
BRA.s LAB_RTST * go push descriptor on stack & exit
LAB_20D8
BSR.s LAB_2115 * make string space d1 bytes long
ADDA.l d1,a0 * new string end
ADDA.l d1,a1 * old string end
SUBQ.w #1,d0 * -1 for DBF loop
LAB_20E0
MOVE.b -(a1),-(a0) * copy byte (source can be odd aligned)
DBF d0,LAB_20E0 * loop until done
*************************************************************************************
*
* check for space on descriptor stack then ...
* put string address and length on descriptor stack & update stack pointers
* start is in a0, length is in d1
LAB_RTST
LEA des_sk_e(a3),a1 * get string stack pointer max+1
CMPA.l a1,a4 * compare string stack pointer with max+1
BEQ LAB_SCER * if no space on string stack ..
* .. go do 'string too complex' error
* push string & update pointers
MOVE.w d1,-(a4) * string length on descriptor stack
MOVE.l a0,-(a4) * string address on stack
MOVE.l a4,FAC1_m(a3) * string descriptor pointer in FAC1
MOVE.b #$80,Dtypef(a3) * save data type flag, $80=string
RTS
*************************************************************************************
*
* build descriptor a0/d1
* make space in string memory for string d1.w long
* return pointer in a0/Sutill
LAB_2115
TST.w d1 * test length
BEQ.s LAB_2128 * branch if user wants null string
* make space for string d1 long
MOVE.l d0,-(sp) * save d0
MOVEQ #0,d0 * clear longword
MOVE.b d0,Gclctd(a3) * clear garbage collected flag (b7)
MOVEQ #1,d0 * +1 to possibly round up
AND.w d1,d0 * mask odd bit
ADD.w d1,d0 * ensure d0 is even length
BCC.s LAB_2117 * branch if no overflow
MOVEQ #1,d0 * set to allocate 65536 bytes
SWAP d0 * makes $00010000
LAB_2117
MOVEA.l Sstorl(a3),a0 * get bottom of string space
SUBA.l d0,a0 * subtract string length
CMPA.l Earryl(a3),a0 * compare with top of array space
BCS.s LAB_2137 * if less do out of memory error
MOVE.l a0,Sstorl(a3) * save bottom of string space
MOVE.l a0,Sutill(a3) * save string utility pointer
MOVE.l (sp)+,d0 * restore d0
TST.w d1 * set flags on length
RTS
LAB_2128
MOVEA.w d1,a0 * make null pointer
RTS
LAB_2137
TST.b Gclctd(a3) * get garbage collected flag
BMI LAB_OMER * do "Out of memory" error, then warm start
MOVE.l a1,-(sp) * save a1
BSR.s LAB_GARB * else go do garbage collection
MOVEA.l (sp)+,a1 * restore a1
MOVE.b #$80,Gclctd(a3) * set garbage collected flag
BRA.s LAB_2117 * go try again
*************************************************************************************
*
* garbage collection routine
LAB_GARB
MOVEM.l d0-d2/a0-a2,-(sp) * save registers
MOVE.l Ememl(a3),Sstorl(a3) * start with no strings
* re-run routine from last ending
LAB_214B
MOVE.l Earryl(a3),d1 * set highest uncollected string so far
MOVEQ #0,d0 * clear longword
MOVEA.l d0,a1 * clear string to move pointer
MOVEA.l Sstrl(a3),a0 * set pointer to start of strings
LEA 4(a0),a0 * index to string pointer
MOVEA.l Sarryl(a3),a2 * set end pointer to start of arrays (end of
* strings)
BRA.s LAB_2176 * branch into loop at end loop test
LAB_2161
BSR LAB_2206 * test and set if this is the highest string
LEA 10(a0),a0 * increment to next string
LAB_2176
CMPA.l a2,a0 * compare end of area with pointer
BCS.s LAB_2161 * go do next if not at end
* done strings, now do arrays.
LEA -4(a0),a0 * decrement pointer to start of arrays
MOVEA.l Earryl(a3),a2 * set end pointer to end of arrays
BRA.s LAB_218F * branch into loop at end loop test
LAB_217E
MOVE.l 4(a0),d2 * get array size
ADD.l a0,d2 * makes start of next array
MOVE.l (a0),d0 * get array name
BTST #23,d0 * test string flag
BEQ.s LAB_218B * branch if not string
MOVE.w 8(a0),d0 * get # of dimensions
ADD.w d0,d0 * *2
ADDA.w d0,a0 * add to skip dimension size(s)
LEA 10(a0),a0 * increment to first element
LAB_2183
BSR.s LAB_2206 * test and set if this is the highest string
ADDQ.w #6,a0 * increment to next element
CMPA.l d2,a0 * compare with start of next array
BNE.s LAB_2183 * go do next if not at end of array
LAB_218B
MOVEA.l d2,a0 * pointer to next array
LAB_218F
CMPA.l a0,a2 * compare pointer with array end
BNE.s LAB_217E * go do next if not at end
* done arrays and variables, now just the descriptor stack to do
MOVEA.l a4,a0 * get descriptor stack pointer
LEA des_sk(a3),a2 * set end pointer to end of stack
BRA.s LAB_21C4 * branch into loop at end loop test
LAB_21C2
BSR.s LAB_2206 * test and set if this is the highest string
LEA 6(a0),a0 * increment to next string
LAB_21C4
CMPA.l a0,a2 * compare pointer with stack end
BNE.s LAB_21C2 * go do next if not at end
* descriptor search complete, now either exit or set-up and move string
MOVE.l a1,d0 * set the flags (a1 is move string)
BEQ.s LAB_21D1 * go tidy up and exit if no move
MOVEA.l (a1),a0 * a0 is now string start
MOVEQ #0,d1 * clear d1
MOVE.w 4(a1),d1 * d1 is string length
ADDQ.l #1,d1 * +1
AND.b #$FE,d1 * make even length
ADDA.l d1,a0 * pointer is now to string end+1
MOVEA.l Sstorl(a3),a2 * is destination end+1
CMPA.l a2,a0 * does the string need moving
BEQ.s LAB_2240 * branch if not
LSR.l #1,d1 * word move so do /2
SUBQ.w #1,d1 * -1 for DBF loop
LAB_2216
MOVE.w -(a0),-(a2) * copy word
DBF d1,LAB_2216 * loop until done
MOVE.l a2,(a1) * save new string start
LAB_2240
MOVE.l (a1),Sstorl(a3) * string start is new string mem start
BRA LAB_214B * re-run routine from last ending
* (but don't collect this string)
LAB_21D1
MOVEM.l (sp)+,d0-d2/a0-a2 * restore registers
RTS
* test and set if this is the highest string
LAB_2206
MOVE.l (a0),d0 * get this string pointer
BEQ.s RTS_012 * exit if null string
CMP.l d0,d1 * compare with highest uncollected string so far
BCC.s RTS_012 * exit if <= with highest so far
CMP.l Sstorl(a3),d0 * compare with bottom of string space
BCC.s RTS_012 * exit if >= bottom of string space
MOVEQ #-1,d0 * d0 = $FFFFFFFF
MOVE.w 4(a0),d0 * d0 is string length
NEG.w d0 * make -ve
AND.b #$FE,d0 * make -ve even length
ADD.l Sstorl(a3),d0 * add string store to -ve length
CMP.l (a0),d0 * compare with string address
BEQ.s LAB_2212 * if = go move string store pointer down
MOVE.l (a0),d1 * highest = current
MOVEA.l a0,a1 * string to move = current
RTS
LAB_2212
MOVE.l d0,Sstorl(a3) * set new string store start
RTS_012
RTS
*************************************************************************************
*
* concatenate - add strings
* string descriptor 1 is in FAC1_m, string 2 is in line
LAB_224D
PEA LAB_1ADB(pc) * continue evaluation after concatenate
MOVE.l FAC1_m(a3),-(sp) * stack descriptor pointer for string 1
BSR LAB_GVAL * get value from line
TST.b Dtypef(a3) * test data type flag
BPL LAB_TMER * if type is not string do type mismatch error
MOVEA.l (sp)+,a0 * restore descriptor pointer for string 1
*************************************************************************************
*
* concatenate
* string descriptor 1 is in a0, string descriptor 2 is in FAC1_m
LAB_224E
MOVEA.l FAC1_m(a3),a1 * copy descriptor pointer 2
MOVE.w 4(a0),d1 * get length 1
ADD.w 4(a1),d1 * add length 2
BCS LAB_SLER * if overflow go do 'string too long' error
MOVE.l a0,-(sp) * save descriptor pointer 1
BSR LAB_2115 * make space d1 bytes long
MOVE.l a0,FAC2_m(a3) * save new string start pointer
MOVEA.l (sp),a0 * copy descriptor pointer 1 from stack
MOVE.w 4(a0),d0 * get length
MOVEA.l (a0),a0 * get string pointer
BSR.s LAB_229E * copy string d0 bytes long from a0 to Sutill
* return with a0 = pointer, d1 = length
MOVEA.l FAC1_m(a3),a0 * get descriptor pointer for string 2
BSR.s LAB_22BA * pop (a0) descriptor, returns with ..
* a0 = pointer, d0 = length
BSR.s LAB_229E * copy string d0 bytes long from a0 to Sutill
* return with a0 = pointer, d1 = length
MOVEA.l (sp)+,a0 * get descriptor pointer for string 1
BSR.s LAB_22BA * pop (a0) descriptor, returns with ..
* d0 = length, a0 = pointer
MOVEA.l FAC2_m(a3),a0 * retreive the result string pointer
MOVE.l a0,d1 * copy the result string pointer
BEQ LAB_RTST * if it is a null string just return it
* a0 = pointer, d1 = length
NEG.l d1 * else make the start pointer negative
ADD.l Sutill(a3),d1 * add the end pointert to give the length
BRA LAB_RTST * push string on descriptor stack
* a0 = pointer, d1 = length
*************************************************************************************
*
* copy string d0 bytes long from a0 to Sutill
* return with a0 = pointer, d1 = length
LAB_229E
MOVE.w d0,d1 * copy and check length
BEQ.s RTS_013 * skip copy if null
MOVEA.l Sutill(a3),a1 * get destination pointer
MOVE.l a1,-(sp) * save destination string pointer
SUBQ.w #1,d0 * subtract for DBF loop
LAB_22A0
MOVE.b (a0)+,(a1)+ * copy byte
DBF d0,LAB_22A0 * loop if not done
MOVE.l a1,Sutill(a3) * update Sutill to end of copied string
MOVEA.l (sp)+,a0 * restore destination string pointer
RTS_013
RTS
*************************************************************************************
*
* pop string off descriptor stack, or from top of string space
* returns with d0.l = length, a0 = pointer
LAB_22B6
MOVEA.l FAC1_m(a3),a0 * get descriptor pointer
*************************************************************************************
*
* pop (a0) descriptor off stack or from string space
* returns with d0.l = length, a0 = pointer
LAB_22BA
MOVEM.l a1/d1,-(sp) * save other regs
CMPA.l a0,a4 * is string on the descriptor stack
BNE.s LAB_22BD * skip pop if not
ADDQ.w #$06,a4 * else update stack pointer
LAB_22BD
MOVEQ #0,d0 * clear string length longword
MOVEA.l (a0)+,a1 * get string address
MOVE.w (a0)+,d0 * get string length
CMPA.l a0,a4 * was it on the descriptor stack
BNE.s LAB_22E6 * branch if it wasn't
CMPA.l Sstorl(a3),a1 * compare string address with bottom of string
* space
BNE.s LAB_22E6 * branch if <>
MOVEQ #1,d1 * mask for odd bit
AND.w d0,d1 * AND length
ADD.l d0,d1 * make it fit word aligned length
ADD.l d1,Sstorl(a3) * add to bottom of string space
LAB_22E6
MOVEA.l a1,a0 * copy to a0
MOVEM.l (sp)+,a1/d1 * restore other regs
TST.l d0 * set flags on length
RTS
*************************************************************************************
*
* perform CHR$()
LAB_CHRS
BSR LAB_EVBY * evaluate byte expression, result in d0 and
* Itemp
LAB_MKCHR
MOVEQ #1,d1 * string is single byte
BSR LAB_2115 * make string space d1 bytes long
* return a0/Sutill = pointer, others unchanged
MOVE.b d0,(a0) * save byte in string (byte IS string!)
BRA LAB_RTST * push string on descriptor stack
* a0 = pointer, d1 = length
*************************************************************************************
*
* perform LEFT$()
* enter with a0 is descriptor, d0 & Itemp is word 1
LAB_LEFT
EXG d0,d1 * word in d1
BSR LAB_1BFB * scan for ")", else do syntax error/warm start
TST.l d1 * test returned length
BEQ.s LAB_231C * branch if null return
MOVEQ #0,d0 * clear start offset
CMP.w 4(a0),d1 * compare word parameter with string length
BCS.s LAB_231C * branch if string length > word parameter
BRA.s LAB_2317 * go copy whole string
*************************************************************************************
*
* perform RIGHT$()
* enter with a0 is descriptor, d0 & Itemp is word 1
LAB_RIGHT
EXG d0,d1 * word in d1
BSR LAB_1BFB * scan for ")", else do syntax error/warm start
TST.l d1 * test returned length
BEQ.s LAB_231C * branch if null return
MOVE.w 4(a0),d0 * get string length
SUB.l d1,d0 * subtract word
BCC.s LAB_231C * branch if string length > word parameter
* else copy whole string
LAB_2316
MOVEQ #0,d0 * clear start offset
LAB_2317
MOVE.w 4(a0),d1 * else make parameter = length
* get here with ...
* a0 - points to descriptor
* d0 - is offset from string start
* d1 - is required string length
LAB_231C
MOVEA.l a0,a1 * save string descriptor pointer
BSR LAB_2115 * make string space d1 bytes long
* return a0/Sutill = pointer, others unchanged
MOVEA.l a1,a0 * restore string descriptor pointer
MOVE.l d0,-(sp) * save start offset (longword)
BSR.s LAB_22BA * pop (a0) descriptor, returns with ..
* d0 = length, a0 = pointer
ADDA.l (sp)+,a0 * adjust pointer to start of wanted string
MOVE.w d1,d0 * length to d0
BSR LAB_229E * store string d0 bytes long from (a0) to
* (Sutill) return with a0 = pointer,
* d1 = length
BRA LAB_RTST * push string on descriptor stack
* a0 = pointer, d1 = length
*************************************************************************************
*
* perform MID$()
* enter with a0 is descriptor, d0 & Itemp is word 1
LAB_MIDS
MOVEQ #0,d7 * clear longword
SUBQ.w #1,d7 * set default length = 65535
MOVE.l d0,-(sp) * save word 1
BSR LAB_GBYT * scan memory
CMP.b #',',d0 * was it ","
BNE.s LAB_2358 * branch if not "," (skip second byte get)
MOVE.b (a5)+,d0 * increment pointer past ","
MOVE.l a0,-(sp) * save descriptor pointer
BSR LAB_GTWO * get word parameter, result in d0 and Itemp
MOVEA.l (sp)+,a0 * restore descriptor pointer
MOVE.l d0,d7 * copy length
LAB_2358
BSR LAB_1BFB * scan for ")", else do syntax error then warm
* start
MOVE.l (sp)+,d0 * restore word 1
MOVEQ #0,d1 * null length
SUBQ.l #1,d0 * decrement start index (word 1)
BMI LAB_FCER * if was null do function call error then warm
* start
CMP.w 4(a0),d0 * compare string length with start index
BCC.s LAB_231C * if start not in string do null string (d1=0)
MOVE.l d7,d1 * get length back
ADD.w d0,d7 * d7 now = MID$() end
BCS.s LAB_2368 * already too long so do RIGHT$ equivalent
CMP.w 4(a0),d7 * compare string length with start index+length
BCS.s LAB_231C * if end in string go do string
LAB_2368
MOVE.w 4(a0),d1 * get string length
SUB.w d0,d1 * subtract start offset
BRA.s LAB_231C * go do string (effectively RIGHT$)
*************************************************************************************
*
* perform LCASE$()
LAB_LCASE
BSR LAB_22B6 * pop string off descriptor stack or from memory
* returns with d0 = length, a0 = pointer
MOVE.l d0,d1 * copy the string length
BEQ.s NoString * if null go return a null string
* else copy and change the string
MOVEA.l a0,a1 * copy the string address
BSR LAB_2115 * make a string space d1 bytes long
ADDA.l d1,a0 * new string end
ADDA.l d1,a1 * old string end
MOVE.w d1,d2 * copy length for loop
SUBQ.w #1,d2 * -1 for DBF loop
LC_loop
MOVE.b -(a1),d0 * get byte from string
CMP.b #$5B,d0 * compare with "Z"+1
BCC.s NoUcase * if > "Z" skip change
CMP.b #$41,d0 * compare with "A"
BCS.s NoUcase * if < "A" skip change
ORI.b #$20,d0 * convert upper case to lower case
NoUcase
MOVE.b d0,-(a0) * copy upper case byte back to string
DBF d2,LC_loop * decrement and loop if not all done
BRA.s NoString * tidy up & exit (branch always)
*************************************************************************************
*
* perform UCASE$()
LAB_UCASE
BSR LAB_22B6 * pop string off descriptor stack or from memory
* returns with d0 = length, a0 = pointer
MOVE.l d0,d1 * copy the string length
BEQ.s NoString * if null go return a null string
* else copy and change the string
MOVEA.l a0,a1 * copy the string address
BSR LAB_2115 * make a string space d1 bytes long
ADDA.l d1,a0 * new string end
ADDA.l d1,a1 * old string end
MOVE.w d1,d2 * copy length for loop
SUBQ.w #1,d2 * -1 for DBF loop
UC_loop
MOVE.b -(a1),d0 * get a byte from the string
CMP.b #$61,d0 * compare with "a"
BCS.s NoLcase * if < "a" skip change
CMP.b #$7B,d0 * compare with "z"+1
BCC.s NoLcase * if > "z" skip change
ANDI.b #$DF,d0 * convert lower case to upper case
NoLcase
MOVE.b d0,-(a0) * copy upper case byte back to string
DBF d2,UC_loop * decrement and loop if not all done
NoString
BRA LAB_RTST * push string on descriptor stack
* a0 = pointer, d1 = length
*************************************************************************************
*
* perform SADD()
LAB_SADD
MOVE.b (a5)+,d0 * increment pointer
BSR LAB_GVAR * get variable address in a0
BSR LAB_1BFB * scan for ")", else do syntax error/warm start
TST.b Dtypef(a3) * test data type flag
BPL LAB_TMER * if numeric do Type missmatch Error
* if you want a non existant variable to return a null value then set the novar
* value at the top of this file to some non zero value
ifne novar
MOVE.l a0,d0 * test the variable found flag
BEQ LAB_AYFC * if not found go return null
endc
MOVE.l (a0),d0 * get string address
BRA LAB_AYFC * convert d0 to signed longword in FAC1 & return
*************************************************************************************
*
* perform LEN()
LAB_LENS
PEA LAB_AYFC(pc) * set return address to convert d0 to signed
* longword in FAC1
BRA LAB_22B6 * pop string off descriptor stack or from memory
* returns with d0 = length, a0 = pointer
*************************************************************************************
*
* perform ASC()
LAB_ASC
BSR LAB_22B6 * pop string off descriptor stack or from memory
* returns with d0 = length, a0 = pointer
TST.w d0 * test length
BEQ LAB_FCER * if null do function call error then warm start
MOVE.b (a0),d0 * get first character byte
BRA LAB_1FD0 * convert d0 to unsigned byte in FAC1 & return
*************************************************************************************
*
* increment and get byte, result in d0 and Itemp
LAB_SGBY
BSR LAB_IGBY * increment & scan memory
*************************************************************************************
*
* get byte parameter, result in d0 and Itemp
LAB_GTBY
BSR LAB_EVNM * evaluate expression & check is numeric,
* else do type mismatch
*************************************************************************************
*
* evaluate byte expression, result in d0 and Itemp
LAB_EVBY
BSR LAB_EVPI * evaluate positive integer expression
* result in d0 and Itemp
MOVE.w #$80,d1 * set mask/2
ADD.l d1,d1 * =$FFFFFF00
AND.l d0,d1 * check top 24 bits
BNE LAB_FCER * if <> 0 do function call error/warm start
RTS
*************************************************************************************
*
* get word parameter, result in d0 and Itemp
LAB_GTWO
BSR LAB_EVNM * evaluate expression & check is numeric,
* else do type mismatch
BSR LAB_EVPI * evaluate positive integer expression
* result in d0 and Itemp
SWAP d0 * copy high word to low word
TST.w d0 * set flags
BNE LAB_FCER * if <> 0 do function call error/warm start
SWAP d0 * copy high word to low word
RTS
*************************************************************************************
*
* perform VAL()
LAB_VAL
BSR LAB_22B6 * pop string off descriptor stack or from memory
* returns with d0 = length, a0 = pointer
BEQ.s LAB_VALZ * string was null so set result = $00
* clear FAC1 exponent & sign & return
MOVEA.l a5,a6 * save BASIC execute pointer
MOVEA.l a0,a5 * copy string pointer to execute pointer
ADDA.l d0,a0 * string end+1
MOVE.b (a0),d0 * get byte from string+1
MOVE.w d0,-(sp) * save it
MOVE.l a0,-(sp) * save address
MOVE.b #0,(a0) * null terminate string
BSR LAB_GBYT * scan memory
BSR LAB_2887 * get FAC1 from string
MOVEA.l (sp)+,a0 * restore pointer
MOVE.w (sp)+,d0 * pop byte
MOVE.b d0,(a0) * restore to memory
MOVEA.l a6,a5 * restore BASIC execute pointer
RTS
LAB_VALZ
MOVE.w d0,FAC1_e(a3) * clear FAC1 exponent & sign
RTS
*************************************************************************************
*
* get two parameters for POKE or WAIT, first parameter in a0, second in d0
LAB_GADB
BSR LAB_EVNM * evaluate expression & check is numeric,
* else do type mismatch
BSR LAB_EVIR * evaluate integer expression
* (does FC error not OF error if out of range)
MOVE.l d0,-(sp) * copy to stack
BSR LAB_1C01 * scan for ",", else do syntax error/warm start
BSR.s LAB_GTBY * get byte parameter, result in d0 and Itemp
MOVEA.l (sp)+,a0 * pull address
RTS
*************************************************************************************
*
* get two parameters for DOKE or WAITW, first parameter in a0, second in d0
LAB_GADW
BSR.s LAB_GEAD * get even address for word/long memory actions
* address returned in d0 and on the stack
BSR LAB_1C01 * scan for ",", else do syntax error/warm start
BSR LAB_EVNM * evaluate expression & check is numeric,
* else do type mismatch
BSR LAB_EVIR * evaluate integer expression
* result in d0 and Itemp
SWAP d0 * swap words
TST.w d0 * test high word
BEQ.s LAB_XGADW * exit if null
ADDQ.w #1,d0 * increment word
BNE LAB_FCER * if <> 0 do function call error/warm start
LAB_XGADW
SWAP d0 * swap words back
MOVEA.l (sp)+,a0 * pull address
RTS
*************************************************************************************
*
* get even address (for word or longword memory actions)
* address returned in d0 and on the stack
* does address error if the address is odd
LAB_GEAD
BSR LAB_EVNM * evaluate expression & check is numeric,
* else do type mismatch
BSR LAB_EVIR * evaluate integer expression
* (does FC error not OF error if out of range)
BTST #0,d0 * test low bit of longword
BNE LAB_ADER * if address is odd do address error/warm start
MOVEA.l (sp),a0 * copy return address
MOVE.l d0,(sp) * even address on stack
JMP (a0) * effectively RTS
*************************************************************************************
*
* perform PEEK()
LAB_PEEK
BSR LAB_EVIR * evaluate integer expression
* (does FC error not OF error if out of range)
MOVEA.l d0,a0 * copy to address register
MOVE.b (a0),d0 * get byte
BRA LAB_1FD0 * convert d0 to unsigned byte in FAC1 & return
*************************************************************************************
*
* perform POKE
LAB_POKE
BSR.s LAB_GADB * get two parameters for POKE or WAIT
* first parameter in a0, second in d0
MOVE.b d0,(a0) * put byte in memory
RTS
*************************************************************************************
*
* perform DEEK()
LAB_DEEK
BSR LAB_EVIR * evaluate integer expression
* (does FC error not OF error if out of range)
LSR.b #1,d0 * shift bit 0 to carry
BCS LAB_ADER * if address is odd do address error/warm start
ADD.b d0,d0 * shift byte back
EXG d0,a0 * copy to address register
MOVEQ #0,d0 * clear top bits
MOVE.w (a0),d0 * get word
BRA LAB_AYFC * convert d0 to signed longword in FAC1 & return
*************************************************************************************
*
* perform LEEK()
LAB_LEEK
BSR LAB_EVIR * evaluate integer expression
* (does FC error not OF error if out of range)
LSR.b #1,d0 * shift bit 0 to carry
BCS LAB_ADER * if address is odd do address error/warm start
ADD.b d0,d0 * shift byte back
EXG d0,a0 * copy to address register
MOVE.l (a0),d0 * get longword
BRA LAB_AYFC * convert d0 to signed longword in FAC1 & return
*************************************************************************************
*
* perform DOKE
LAB_DOKE
BSR.s LAB_GADW * get two parameters for DOKE or WAIT
* first parameter in a0, second in d0
MOVE.w d0,(a0) * put word in memory
RTS
*************************************************************************************
*
* perform LOKE
LAB_LOKE
BSR.s LAB_GEAD * get even address for word/long memory actions
* address returned in d0 and on the stack
BSR LAB_1C01 * scan for ",", else do syntax error/warm start
BSR LAB_EVNM * evaluate expression & check is numeric,
* else do type mismatch
BSR LAB_EVIR * evaluate integer value (no sign check)
MOVEA.l (sp)+,a0 * pull address
MOVE.l d0,(a0) * put longword in memory
RTS_015
RTS
*************************************************************************************
*
* perform SWAP
LAB_SWAP
BSR LAB_GVAR * get variable 1 address in a0
MOVE.l a0,-(sp) * save variable 1 address
MOVE.b Dtypef(a3),d4 * copy variable 1 data type, $80=string,
* $40=inetger, $00=float
BSR LAB_1C01 * scan for ",", else do syntax error/warm start
BSR LAB_GVAR * get variable 2 address in a0
MOVEA.l (sp)+,a2 * restore variable 1 address
CMP.b Dtypef(a3),d4 * compare variable 1 data type with variable 2
* data type
BNE LAB_TMER * if not both the same type do "Type mismatch"
* error then warm start
* if you do want a non existant variable to return an error then leave the novar
* value at the top of this file set to zero
ifeq novar
MOVE.l (a0),d0 * get variable 2
MOVE.l (a2),(a0)+ * copy variable 1 to variable 2
MOVE.l d0,(a2)+ * save variable 2 to variable 1
TST.b d4 * check data type
BPL.s RTS_015 * exit if not string
MOVE.w (a0),d0 * get string 2 length
MOVE.w (a2),(a0) * copy string 1 length to string 2 length
MOVE.w d0,(a2) * save string 2 length to string 1 length
endc
* if you want a non existant variable to return a null value then set the novar
* value at the top of this file to some non zero value
ifne novar
MOVE.l a2,d2 * copy the variable 1 pointer
MOVE.l d2,d3 * and again for any length
BEQ.s no_variable1 * if variable 1 doesn't exist skip the
* value get
MOVE.l (a2),d2 * get variable 1 value
TST.b d4 * check the data type
BPL.s no_variable1 * if not string skip the length get
MOVE.w 4(a2),d3 * else get variable 1 string length
no_variable1
MOVE.l a0,d0 * copy the variable 2 pointer
MOVE.l d0,d1 * and again for any length
BEQ.s no_variable2 * if variable 2 doesn't exist skip the
* value get and the new value save
MOVE.l (a0),d0 * get variable 2 value
MOVE.l d2,(a0)+ * save variable 2 new value
TST.b d4 * check the data type
BPL.s no_variable2 * if not string skip the length get and
* new length save
MOVE.w (a0),d1 * else get variable 2 string length
MOVE.w d3,(a0) * save variable 2 new string length
no_variable2
TST.l d2 * test if variable 1 exists
BEQ.s EXIT_SWAP * if variable 1 doesn't exist skip the
* new value save
MOVE.l d0,(a2)+ * save variable 1 new value
TST.b d4 * check the data type
BPL.s EXIT_SWAP * if not string skip the new length save
MOVE.w d1,(a2) * save variable 1 new string length
EXIT_SWAP
endc
RTS
*************************************************************************************
*
* perform USR
LAB_USR
JSR Usrjmp(a3) * do user vector
BRA LAB_1BFB * scan for ")", else do syntax error/warm start
*************************************************************************************
*
* perform LOAD
LAB_LOAD
JMP V_LOAD(a3) * do load vector
*************************************************************************************
*
* perform SAVE
LAB_SAVE
JMP V_SAVE(a3) * do save vector
*************************************************************************************
*
* perform CALL
LAB_CALL
PEA LAB_GBYT(pc) * put return address on stack
BSR LAB_GEAD * get even address for word/long memory actions
* address returned in d0 and on the stack
RTS * effectively calls the routine
* if the called routine exits correctly then it will return via the get byte routine.
* this will then get the next byte for the interpreter and return
*************************************************************************************
*
* perform WAIT
LAB_WAIT
BSR LAB_GADB * get two parameters for POKE or WAIT
* first parameter in a0, second in d0
MOVE.l a0,-(sp) * save address
MOVE.w d0,-(sp) * save byte
MOVEQ #0,d2 * clear mask
BSR LAB_GBYT * scan memory
BEQ.s LAB_2441 * skip if no third argument
BSR LAB_SCGB * scan for "," & get byte,
* else do syntax error/warm start
MOVE.l d0,d2 * copy mask
LAB_2441
MOVE.w (sp)+,d1 * get byte
MOVEA.l (sp)+,a0 * get address
LAB_2445
MOVE.b (a0),d0 * read memory byte
EOR.b d2,d0 * EOR with second argument (mask)
AND.b d1,d0 * AND with first argument (byte)
BEQ.s LAB_2445 * loop if result is zero
RTS
*************************************************************************************
*
* perform subtraction, FAC1 from FAC2
LAB_SUBTRACT
EORI.b #$80,FAC1_s(a3) * complement FAC1 sign
MOVE.b FAC2_s(a3),FAC_sc(a3) * copy FAC2 sign byte
MOVE.b FAC1_s(a3),d0 * get FAC1 sign byte
EOR.b d0,FAC_sc(a3) * EOR with FAC2 sign
*************************************************************************************
*
* add FAC2 to FAC1
LAB_ADD
MOVE.b FAC1_e(a3),d0 * get exponent
BEQ LAB_279B * FAC1 was zero so copy FAC2 to FAC1 & return
* FAC1 is non zero
LEA FAC2_m(a3),a0 * set pointer1 to FAC2 mantissa
MOVE.b FAC2_e(a3),d0 * get FAC2 exponent
BEQ.s RTS_016 * exit if zero
SUB.b FAC1_e(a3),d0 * subtract FAC1 exponent
BEQ.s LAB_24A8 * branch if = (go add mantissa)
BCS.s LAB_249C * branch if FAC2 < FAC1
* FAC2 > FAC1
MOVE.w FAC2_e(a3),FAC1_e(a3) * copy sign and exponent of FAC2
NEG.b d0 * negate exponent difference (make diff -ve)
SUBQ.w #8,a0 * pointer1 to FAC1
LAB_249C
NEG.b d0 * negate exponent difference (make diff +ve)
MOVE.l d1,-(sp) * save d1
CMP.b #32,d0 * compare exponent diff with 32
BLT.s LAB_2467 * branch if range >= 32
MOVEQ #0,d1 * clear d1
BRA.s LAB_2468 * go clear smaller mantissa
LAB_2467
MOVE.l (a0),d1 * get FACx mantissa
LSR.l d0,d1 * shift d0 times right
LAB_2468
MOVE.l d1,(a0) * save it back
MOVE.l (sp)+,d1 * restore d1
* exponents are equal now do mantissa add or
* subtract
LAB_24A8
TST.b FAC_sc(a3) * test sign compare (FAC1 EOR FAC2)
BMI.s LAB_24F8 * if <> go do subtract
MOVE.l FAC2_m(a3),d0 * get FAC2 mantissa
ADD.l FAC1_m(a3),d0 * add FAC1 mantissa
BCC.s LAB_24F7 * save and exit if no carry (FAC1 is normal)
ROXR.l #1,d0 * else shift carry back into mantissa
ADDQ.b #1,FAC1_e(a3) * increment FAC1 exponent
BCS LAB_OFER * if carry do overflow error & warm start
LAB_24F7
MOVE.l d0,FAC1_m(a3) * save mantissa
RTS_016
RTS
* signs are different
LAB_24F8
LEA FAC1_m(a3),a1 * pointer 2 to FAC1
CMPA.l a0,a1 * compare pointers
BNE.s LAB_24B4 * branch if <>
ADDQ.w #8,a1 * else pointer2 to FAC2
* take smaller from bigger (take sign of bigger)
LAB_24B4
MOVE.l (a1),d0 * get larger mantissa
MOVE.l (a0),d1 * get smaller mantissa
MOVE.l d0,FAC1_m(a3) * save larger mantissa
SUB.l d1,FAC1_m(a3) * subtract smaller
*************************************************************************************
*
* do +/- (carry is sign) & normalise FAC1
LAB_24D0
BCC.s LAB_24D5 * branch if result is +ve
* erk! subtract is the wrong way round so
* negate everything
EORI.b #$FF,FAC1_s(a3) * complement FAC1 sign
NEG.l FAC1_m(a3) * negate FAC1 mantissa
*************************************************************************************
*
* normalise FAC1
LAB_24D5
MOVE.l FAC1_m(a3),d0 * get mantissa
BMI.s LAB_24DA * mantissa is normal so just exit
BNE.s LAB_24D9 * mantissa is not zero so go normalise FAC1
MOVE.w d0,FAC1_e(a3) * else make FAC1 = +zero
RTS
LAB_24D9
MOVE.l d1,-(sp) * save d1
MOVE.l d0,d1 * mantissa to d1
MOVEQ #0,d0 * clear d0
MOVE.b FAC1_e(a3),d0 * get exponent byte
BEQ.s LAB_24D8 * if exponent is zero then clean up and exit
LAB_24D6
ADD.l d1,d1 * shift mantissa, ADD is quicker for a single
* shift
DBMI d0,LAB_24D6 * decrement exponent and loop if mantissa and
* exponent +ve
TST.w d0 * test exponent
BEQ.s LAB_24D8 * if exponent is zero make FAC1 zero
BPL.s LAB_24D7 * if exponent is >zero go save FAC1
MOVEQ #1,d0 * else set for zero after correction
LAB_24D7
SUBQ.b #1,d0 * adjust exponent for loop
MOVE.l d1,FAC1_m(a3) * save normalised mantissa
LAB_24D8
MOVE.l (sp)+,d1 * restore d1
MOVE.b d0,FAC1_e(a3) * save corrected exponent
LAB_24DA
RTS
*************************************************************************************
*
* perform LOG()
LAB_LOG
TST.b FAC1_s(a3) * test sign
BMI LAB_FCER * if -ve do function call error/warm start
MOVEQ #0,d7 * clear d7
MOVE.b d7,FAC_sc(a3) * clear sign compare
MOVE.b FAC1_e(a3),d7 * get exponent
BEQ LAB_FCER * if 0 do function call error/warm start
SUB.l #$81,d7 * normalise exponent
MOVE.b #$81,FAC1_e(a3) * force a value between 1 and 2
MOVE.l FAC1_m(a3),d6 * copy mantissa
MOVE.l #$80000000,FAC2_m(a3) * set mantissa for 1
MOVE.w #$8100,FAC2_e(a3) * set exponent for 1
BSR LAB_ADD * find arg+1
MOVEQ #0,d0 * setup for calc skip
MOVE.w d0,FAC2_e(a3) * set FAC1 for zero result
ADD.l d6,d6 * shift 1 bit out
MOVE.l d6,FAC2_m(a3) * put back FAC2
BEQ.s LAB_LONN * if 0 skip calculation
MOVE.w #$8000,FAC2_e(a3) * set exponent for .5
BSR LAB_DIVIDE * do (arg-1)/(arg+1)
TST.b FAC1_e(a3) * test exponent
BEQ.s LAB_LONN * if 0 skip calculation
MOVE.b FAC1_e(a3),d1 * get exponent
SUB.b #$82,d1 * normalise and two integer bits
NEG.b d1 * negate for shift
** CMP.b #$1F,d1 * will mantissa vanish?
** BGT.s LAB_dunno * if so do ???
MOVE.l FAC1_m(a3),d0 * get mantissa
LSR.l d1,d0 * shift in two integer bits
* d0 = arg
* d0 = x, d1 = y
* d2 = x1, d3 = y1
* d4 = shift count
* d5 = loop count
* d6 = z
* a0 = table pointer
MOVEQ #0,d6 * z = 0
MOVE.l #1<<30,d1 * y = 1
LEA TAB_HTHET(pc),a0 * get pointer to hyperbolic tangent table
MOVEQ #30,d5 * loop 31 times
MOVEQ #1,d4 * set shift count
BRA.s LAB_LOCC * entry point for loop
LAB_LAAD
ASR.l d4,d2 * x1 >> i
SUB.l d2,d1 * y = y - x1
ADD.l (a0),d6 * z = z + tanh(i)
LAB_LOCC
MOVE.l d0,d2 * x1 = x
MOVE.l d1,d3 * y1 = Y
ASR.l d4,d3 * y1 >> i
BCC.s LAB_LOLP
ADDQ.l #1,d3
LAB_LOLP
SUB.l d3,d0 * x = x - y1
BPL.s LAB_LAAD * branch if > 0
MOVE.l d2,d0 * get x back
ADDQ.w #4,a0 * next entry
ADDQ.l #1,d4 * next i
LSR.l #1,d3 * /2
BEQ.s LAB_LOCX * branch y1 = 0
DBF d5,LAB_LOLP * decrement and loop if not done
* now sort out the result
LAB_LOCX
ADD.l d6,d6 * *2
MOVE.l d6,d0 * setup for d7 = 0
LAB_LONN
MOVE.l d0,d4 * save cordic result
MOVEQ #0,d5 * set default exponent sign
TST.l d7 * check original exponent sign
BEQ.s LAB_LOXO * branch if original was 0
BPL.s LAB_LOXP * branch if was +ve
NEG.l d7 * make original exponent +ve
MOVEQ #$80-$100,d5 * make sign -ve
LAB_LOXP
MOVE.b d5,FAC1_s(a3) * save original exponent sign
SWAP d7 * 16 bit shift
LSL.l #8,d7 * easy first part
MOVEQ #$88-$100,d5 * start with byte
LAB_LONE
SUBQ.l #1,d5 * decrement exponent
ADD.l d7,d7 * shift mantissa
BPL.s LAB_LONE * loop if not normal
LAB_LOXO
MOVE.l d7,FAC1_m(a3) * save original exponent as mantissa
MOVE.b d5,FAC1_e(a3) * save exponent for this
MOVE.l #$B17217F8,FAC2_m(a3) * LOG(2) mantissa
MOVE.w #$8000,FAC2_e(a3) * LOG(2) exponent & sign
MOVE.b FAC1_s(a3),FAC_sc(a3) * make sign compare = FAC1 sign
BSR.s LAB_MULTIPLY * do multiply
MOVE.l d4,FAC2_m(a3) * save cordic result
BEQ.s LAB_LOWZ * branch if zero
MOVE.w #$8200,FAC2_e(a3) * set exponent & sign
MOVE.b FAC1_s(a3),FAC_sc(a3) * clear sign compare
BSR LAB_ADD * and add for final result
LAB_LOWZ
RTS
*************************************************************************************
*
* multiply FAC1 by FAC2
LAB_MULTIPLY
MOVEM.l d0-d4,-(sp) * save registers
TST.b FAC1_e(a3) * test FAC1 exponent
BEQ.s LAB_MUUF * if exponent zero go make result zero
MOVE.b FAC2_e(a3),d0 * get FAC2 exponent
BEQ.s LAB_MUUF * if exponent zero go make result zero
MOVE.b FAC_sc(a3),FAC1_s(a3) * sign compare becomes sign
ADD.b FAC1_e(a3),d0 * multiply exponents by adding
BCC.s LAB_MNOC * branch if no carry
SUB.b #$80,d0 * normalise result
BCC LAB_OFER * if no carry do overflow
BRA.s LAB_MADD * branch
* no carry for exponent add
LAB_MNOC
SUB.b #$80,d0 * normalise result
BCS.s LAB_MUUF * return zero if underflow
LAB_MADD
MOVE.b d0,FAC1_e(a3) * save exponent
* d1 (FAC1) x d2 (FAC2)
MOVE.l FAC1_m(a3),d1 * get FAC1 mantissa
MOVE.l FAC2_m(a3),d2 * get FAC2 mantissa
MOVE.w d1,d4 * copy low word FAC1
MOVE.l d1,d0 * copy long word FAC1
SWAP d0 * high word FAC1 to low word FAC1
MOVE.w d0,d3 * copy high word FAC1
MULU d2,d1 * low word FAC2 x low word FAC1
MULU d2,d0 * low word FAC2 x high word FAC1
SWAP d2 * high word FAC2 to low word FAC2
MULU d2,d4 * high word FAC2 x low word FAC1
MULU d2,d3 * high word FAC2 x high word FAC1
* done multiply, now add partial products
* d1 = aaaa ---- FAC2_L x FAC1_L
* d0 = bbbb aaaa FAC2_L x FAC1_H
* d4 = bbbb aaaa FAC2_H x FAC1_L
* d3 = cccc bbbb FAC2_H x FAC1_H
* product = mmmm mmmm
ADD.L #$8000,d1 * round up lowest word
CLR.w d1 * clear low word, don't need it
SWAP d1 * align high word
ADD.l d0,d1 * add FAC2_L x FAC1_H (can't be carry)
LAB_MUF1
ADD.l d4,d1 * now add intermediate (FAC2_H x FAC1_L)
BCC.s LAB_MUF2 * branch if no carry
ADD.l #$10000,d3 * else correct result
LAB_MUF2
ADD.l #$8000,d1 * round up low word
CLR.w d1 * clear low word
SWAP d1 * align for final add
ADD.l d3,d1 * add FAC2_H x FAC1_H, result
BMI.s LAB_MUF3 * branch if normalisation not needed
ADD.l d1,d1 * shift mantissa
SUBQ.b #1,FAC1_e(a3) * adjust exponent
BEQ.s LAB_MUUF * branch if underflow
LAB_MUF3
MOVE.l d1,FAC1_m(a3) * save mantissa
LAB_MUEX
MOVEM.l (sp)+,d0-d4 * restore registers
RTS
* either zero or underflow result
LAB_MUUF
MOVEQ #0,d0 * quick clear
MOVE.l d0,FAC1_m(a3) * clear mantissa
MOVE.w d0,FAC1_e(a3) * clear sign and exponent
BRA.s LAB_MUEX * restore regs & exit
*************************************************************************************
*
* do FAC2/FAC1, result in FAC1
* fast hardware divide version
LAB_DIVIDE
MOVE.l d7,-(sp) * save d7
MOVEQ #0,d0 * clear FAC2 exponent
MOVE.l d0,d2 * clear FAC1 exponent
MOVE.b FAC1_e(a3),d2 * get FAC1 exponent
BEQ LAB_DZER * if zero go do /0 error
MOVE.b FAC2_e(a3),d0 * get FAC2 exponent
BEQ.s LAB_DIV0 * if zero return zero
SUB.w d2,d0 * get result exponent by subtracting
ADD.w #$80,d0 * correct 16 bit exponent result
MOVE.b FAC_sc(a3),FAC1_s(a3) * sign compare is result sign
* now to do 32/32 bit mantissa divide
CLR.b flag(a3) * clear 'flag' byte
MOVE.l FAC1_m(a3),d3 * get FAC1 mantissa
MOVE.l FAC2_m(a3),d4 * get FAC2 mantissa
CMP.l d3,d4 * compare FAC2 with FAC1 mantissa
BEQ.s LAB_MAN1 * set mantissa result = 1 if equal
BCS.s AC1gtAC2 * branch if FAC1 > FAC2
SUB.l d3,d4 * subtract FAC1 from FAC2, result now must be <1
ADDQ.b #3,flag(a3) * FAC2>FAC1 so set 'flag' byte
AC1gtAC2
BSR.s LAB_32_16 * do 32/16 divide
SWAP d1 * move 16 bit result to high word
MOVE.l d2,d4 * copy remainder longword
BSR.s LAB_3216 * do 32/16 divide again (skip copy d4 to d2)
DIVU.w d5,d2 * now divide remainder to make guard word
MOVE.b flag(a3),d7 * now normalise, get flag byte back
BEQ.s LAB_DIVX * skip add if null
* else result was >1 so we need to add 1 to result mantissa and adjust exponent
LSR.b #1,d7 * shift 1 into eXtend
ROXR.l #1,d1 * shift extend result >>
ROXR.w #1,d2 * shift extend guard word >>
ADDQ.b #1,d0 * adjust exponent
* now round result to 32 bits
LAB_DIVX
ADD.w d2,d2 * guard bit into eXtend bit
BCC.s L_DIVRND * branch if guard=0
ADDQ.l #1,d1 * add guard to mantissa
BCC.s L_DIVRND * branch if no overflow
LAB_SET1
ROXR.l #1,d1 * shift extend result >>
ADDQ.w #1,d0 * adjust exponent
* test for over/under flow
L_DIVRND
MOVE.w d0,d3 * copy exponent
BMI.s LAB_DIV0 * if -ve return zero
ANDI.w #$FF00,d3 * mask word high byte
BNE LAB_OFER * branch if overflow
* move result into FAC1
LAB_XDIV
MOVE.l (sp)+,d7 * restore d7
MOVE.b d0,FAC1_e(a3) * save result exponent
MOVE.l d1,FAC1_m(a3) * save result mantissa
RTS
* FAC1 mantissa = FAC2 mantissa so set result mantissa
LAB_MAN1
MOVEQ #1,d1 * set bit
LSR.l d1,d1 * bit into eXtend
BRA.s LAB_SET1 * set mantissa, adjust exponent and exit
* result is zero
LAB_DIV0
MOVEQ #0,d0 * zero exponent & sign
MOVE.l d0,d1 * zero mantissa
BRA LAB_XDIV * exit divide
* divide 16 bits into 32, AB/Ex
*
* d4 AAAA BBBB * 32 bit numerator
* d3 EEEE xxxx * 16 bit denominator
*
* returns -
*
* d1 xxxx DDDD * 16 bit result
* d2 HHHH IIII * 32 bit remainder
LAB_32_16
MOVE.l d4,d2 * copy FAC2 mantissa (AB)
LAB_3216
MOVE.l d3,d5 * copy FAC1 mantissa (EF)
CLR.w d5 * clear low word d1 (Ex)
SWAP d5 * swap high word to low word (xE)
* d3 EEEE FFFF * denominator copy
* d5 0000 EEEE * denominator high word
* d2 AAAA BBBB * numerator copy
* d4 AAAA BBBB * numerator
DIVU.w d5,d4 * do FAC2/FAC1 high word (AB/E)
BVC.s LAB_LT_1 * if no overflow DIV was ok
MOVEQ #-1,d4 * else set default value
* done the divide, now check the result, we have ...
* d3 EEEE FFFF * denominator copy
* d5 0000 EEEE * denominator high word
* d2 AAAA BBBB * numerator copy
* d4 MMMM DDDD * result MOD and DIV
LAB_LT_1
MOVE.w d4,d6 * copy 16 bit result
MOVE.w d4,d1 * copy 16 bit result again
* we now have ..
* d3 EEEE FFFF * denominator copy
* d5 0000 EEEE * denominator high word
* d6 xxxx DDDD * result DIV copy
* d1 xxxx DDDD * result DIV copy
* d2 AAAA BBBB * numerator copy
* d4 MMMM DDDD * result MOD and DIV
* now multiply out 32 bit denominator by 16 bit result
* QRS = AB*D
MULU.w d3,d6 * FFFF * DDDD = rrrr SSSS
MULU.w d5,d4 * EEEE * DDDD = QQQQ rrrr
* we now have ..
* d3 EEEE FFFF * denominator copy
* d5 0000 EEEE * denominator high word
* d6 rrrr SSSS * 48 bit result partial low
* d1 xxxx DDDD * result DIV copy
* d2 AAAA BBBB * numerator copy
* d4 QQQQ rrrr * 48 bit result partial
MOVE.w d6,d7 * copy low word of low multiply
* d7 xxxx SSSS * 48 bit result partial low
CLR.w d6 * clear low word of low multiply
SWAP d6 * high word of low multiply to low word
* d6 0000 rrrr * high word of 48 bit result partial low
ADD.l d6,d4
* d4 QQQQ RRRR * 48 bit result partial high longword
MOVEQ #0,d6 * clear to extend numerator to 48 bits
* now do GHI = AB0 - QRS (which is the remainder)
SUB.w d7,d6 * low word subtract
* d6 xxxx IIII * remainder low word
SUBX.l d4,d2 * high longword subtract
* d2 GGGG HHHH * remainder high longword
* now if we got the divide correct then the remainder high longword will be +ve
BPL.s L_DDIV * branch if result is ok (<needed)
* remainder was -ve so DDDD is too big
LAB_REMM
SUBQ.w #1,d1 * adjust DDDD
* d3 xxxx FFFF * denominator copy
* d6 xxxx IIII * remainder low word
ADD.w d3,d6 * add EF*1 low remainder low word
* d5 0000 EEEE * denominator high word
* d2 GGGG HHHH * remainder high longword
ADDX.l d5,d2 * add extend EF*1 to remainder high longword
BMI.s LAB_REMM * loop if result still too big
* all done and result correct or <
L_DDIV
SWAP d2 * remainder mid word to high word
* d2 HHHH GGGG * (high word /should/ be $0000)
MOVE.w d6,d2 * remainder in high word
* d2 HHHH IIII * now is 32 bit remainder
* d1 xxxx DDDD * 16 bit result
RTS
*************************************************************************************
*
* unpack memory (a0) into FAC1
LAB_UFAC
MOVE.l (a0),d0 * get packed value
SWAP d0 * exponent and sign into least significant word
MOVE.w d0,FAC1_e(a3) * save exponent and sign
BEQ.s LAB_NB1T * branch if exponent (and the rest) zero
OR.w #$80,d0 * set MSb
SWAP d0 * word order back to normal
ASL.l #8,d0 * shift exponent & clear guard byte
LAB_NB1T
MOVE.l d0,FAC1_m(a3) * move into FAC1
MOVE.b FAC1_e(a3),d0 * get FAC1 exponent
RTS
*************************************************************************************
*
* set numeric variable, pack FAC1 into Lvarpl
LAB_PFAC
MOVE.l a0,-(sp) * save pointer
MOVEA.l Lvarpl(a3),a0 * get destination pointer
BTST #6,Dtypef(a3) * test data type
BEQ.s LAB_277C * branch if floating
BSR LAB_2831 * convert FAC1 floating to fixed
* result in d0 and Itemp
MOVE.l d0,(a0) * save in var
MOVE.l (sp)+,a0 * restore pointer
RTS
*************************************************************************************
*
* normalise round and pack FAC1 into (a0)
LAB_2778
MOVE.l a0,-(sp) * save pointer
LAB_277C
BSR LAB_24D5 * normalise FAC1
BSR.s LAB_27BA * round FAC1
MOVE.l FAC1_m(a3),d0 * get FAC1 mantissa
ROR.l #8,d0 * align 24/32 bit mantissa
SWAP d0 * exponent/sign into 0-15
AND.w #$7F,d0 * clear exponent and sign bit
ANDI.b #$80,FAC1_s(a3) * clear non sign bits in sign
OR.w FAC1_e(a3),d0 * OR in exponent and sign
SWAP d0 * move exponent and sign back to 16-31
MOVE.l d0,(a0) * store in destination
MOVE.l (sp)+,a0 * restore pointer
RTS
*************************************************************************************
*
* copy FAC2 to FAC1
LAB_279B
MOVE.w FAC2_e(a3),FAC1_e(a3) * copy exponent & sign
MOVE.l FAC2_m(a3),FAC1_m(a3) * copy mantissa
RTS
*************************************************************************************
*
* round FAC1
LAB_27BA
MOVE.b FAC1_e(a3),d0 * get FAC1 exponent
BEQ.s LAB_27C4 * branch if zero
MOVE.l FAC1_m(a3),d0 * get FAC1
ADD.l #$80,d0 * round to 24 bit
BCC.s LAB_27C3 * branch if no overflow
ROXR.l #1,d0 * shift FAC1 mantissa
ADDQ.b #1,FAC1_e(a3) * correct exponent
BCS LAB_OFER * if carry do overflow error & warm start
LAB_27C3
AND.b #$00,d0 * clear guard byte
MOVE.l d0,FAC1_m(a3) * save back to FAC1
RTS
LAB_27C4
MOVE.b d0,FAC1_s(a3) * make zero always +ve
RTS_017
RTS
*************************************************************************************
*
* get FAC1 sign
* return d0=-1,C=1/-ve d0=+1,C=0/+ve
LAB_27CA
MOVEQ #0,d0 * clear d0
MOVE.b FAC1_e(a3),d0 * get FAC1 exponent
BEQ.s RTS_017 * exit if zero (already correct SGN(0)=0)
*************************************************************************************
*
* return d0=-1,C=1/-ve d0=+1,C=0/+ve
* no = 0 check
LAB_27CE
MOVE.b FAC1_s(a3),d0 * else get FAC1 sign (b7)
*************************************************************************************
*
* return d0=-1,C=1/-ve d0=+1,C=0/+ve
* no = 0 check, sign in d0
LAB_27D0
EXT.w d0 * make word
EXT.l d0 * make longword
ASR.l #8,d0 * move sign bit through byte to carry
BCS.s RTS_017 * exit if carry set
MOVEQ #1,d0 * set result for +ve sign
RTS
*************************************************************************************
*
* perform SGN()
LAB_SGN
BSR.s LAB_27CA * get FAC1 sign
* return d0=-1/-ve d0=+1/+ve
*************************************************************************************
*
* save d0 as integer longword
LAB_27DB
MOVE.l d0,FAC1_m(a3) * save FAC1 mantissa
MOVE.w #$A000,FAC1_e(a3) * set FAC1 exponent & sign
ADD.l d0,d0 * top bit into carry
BRA LAB_24D0 * do +/- (carry is sign) & normalise FAC1
*************************************************************************************
*
* perform ABS()
LAB_ABS
MOVE.b #0,FAC1_s(a3) * clear FAC1 sign
RTS
*************************************************************************************
*
* compare FAC1 with FAC2
* returns d0=+1 Cb=0 if FAC1 > FAC2
* returns d0= 0 Cb=0 if FAC1 = FAC2
* returns d0=-1 Cb=1 if FAC1 < FAC2
LAB_27FA
MOVE.b FAC2_e(a3),d1 * get FAC2 exponent
BEQ.s LAB_27CA * branch if FAC2 exponent=0 & get FAC1 sign
* d0=-1,C=1/-ve d0=+1,C=0/+ve
MOVE.b FAC_sc(a3),d0 * get FAC sign compare
BMI.s LAB_27CE * if signs <> do return d0=-1,C=1/-ve
* d0=+1,C=0/+ve & return
MOVE.b FAC1_s(a3),d0 * get FAC1 sign
CMP.b FAC1_e(a3),d1 * compare FAC1 exponent with FAC2 exponent
BNE.s LAB_2828 * branch if different
MOVE.l FAC2_m(a3),d1 * get FAC2 mantissa
CMP.l FAC1_m(a3),d1 * compare mantissas
BEQ.s LAB_282F * exit if mantissas equal
* gets here if number <> FAC1
LAB_2828
BCS.s LAB_27D0 * if FAC1 > FAC2 return d0=-1,C=1/-ve d0=+1,
* C=0/+ve
EORI.b #$80,d0 * else toggle FAC1 sign
LAB_282E
BRA.s LAB_27D0 * return d0=-1,C=1/-ve d0=+1,C=0/+ve
LAB_282F
MOVEQ #0,d0 * clear result
RTS
*************************************************************************************
*
* convert FAC1 floating to fixed
* result in d0 and Itemp, sets flags correctly
LAB_2831
MOVE.l FAC1_m(a3),d0 * copy mantissa
BEQ.s LAB_284J * branch if mantissa = 0
MOVE.l d1,-(sp) * save d1
MOVE.w #$A0,d1 * set for no floating bits
SUB.b FAC1_e(a3),d1 * subtract FAC1 exponent
BCS LAB_OFER * do overflow if too big
BNE.s LAB_284G * branch if exponent was not $A0
TST.b FAC1_s(a3) * test FAC1 sign
BPL.s LAB_284H * branch if FAC1 +ve
NEG.l d0
BVS.s LAB_284H * branch if was $80000000
BRA LAB_OFER * do overflow if too big
LAB_284G
CMP.b #$20,d1 * compare with minimum result for integer
BCS.s LAB_284L * if < minimum just do shift
MOVEQ #0,d0 * else return zero
LAB_284L
LSR.l d1,d0 * shift integer
TST.b FAC1_s(a3) * test FAC1 sign (b7)
BPL.s LAB_284H * branch if FAC1 +ve
NEG.l d0 * negate integer value
LAB_284H
MOVE.l (sp)+,d1 * restore d1
LAB_284J
MOVE.l d0,Itemp(a3) * save result to Itemp
RTS
*************************************************************************************
*
* perform INT()
LAB_INT
MOVE.w #$A0,d0 * set for no floating bits
SUB.b FAC1_e(a3),d0 * subtract FAC1 exponent
BLS.s LAB_IRTS * exit if exponent >= $A0
* (too big for fraction part!)
CMP.b #$20,d0 * compare with minimum result for integer
BCC LAB_POZE * if >= minimum go return 0
* (too small for integer part!)
MOVEQ #-1,d1 * set integer mask
ASL.l d0,d1 * shift mask [8+2*d0]
AND.l d1,FAC1_m(a3) * mask mantissa
LAB_IRTS
RTS
*************************************************************************************
*
* print " in line [LINE #]"
LAB_2953
LEA LAB_LMSG(pc),a0 * point to " in line " message
BSR LAB_18C3 * print null terminated string
* Print Basic line #
MOVE.l Clinel(a3),d0 * get current line
*************************************************************************************
*
* print d0 as unsigned integer
LAB_295E
LEA Bin2dec(pc),a1 * get table address
MOVEQ #0,d1 * table index
LEA Usdss(a3),a0 * output string start
MOVE.l d1,d2 * output string index
LAB_2967
MOVE.l (a1,d1.w),d3 * get table value
BEQ.s LAB_2969 * exit if end marker
MOVEQ #'0'-1,d4 * set character to "0"-1
LAB_2968
ADDQ.w #1,d4 * next numeric character
SUB.l d3,d0 * subtract table value
BPL.s LAB_2968 * not overdone so loop
ADD.l d3,d0 * correct value
MOVE.b d4,(a0,d2.w) * character out to string
ADDQ.w #4,d1 * increment table pointer
ADDQ.w #1,d2 * increment output string pointer
BRA.s LAB_2967 * loop
LAB_2969
ADD.b #'0',d0 * make last character
MOVE.b d0,(a0,d2.w) * character out to string
SUBQ.w #1,a0 * decrement a0 (allow simple loop)
* now find non zero start of string
LAB_296A
ADDQ.w #1,a0 * increment a0 (this will never carry to b16)
LEA BHsend-1(a3),a1 * get string end
CMPA.l a1,a0 * are we at end
BEQ LAB_18C3 * if so print null terminated string and RETURN
CMPI.b #'0',(a0) * is character "0" ?
BEQ.s LAB_296A * loop if so
BRA LAB_18C3 * print null terminated string from memory & RET
*************************************************************************************
*
* convert FAC1 to ASCII string result in (a0)
* STR$() function enters here
* now outputs 7 significant digits
* d0 is character out
* d1 is save index
* d2 is gash
* a0 is output string pointer
LAB_2970
LEA Decss(a3),a1 * set output string start
MOVEQ #' ',d2 * character = " ", assume +ve
BCLR.b #7,FAC1_s(a3) * test and clear FAC1 sign (b7)
BEQ.s LAB_2978 * branch if +ve
MOVEQ #'-',d2 * else character = "-"
LAB_2978
MOVE.b d2,(a1) * save the sign character
MOVE.b FAC1_e(a3),d2 * get FAC1 exponent
BNE.s LAB_2989 * branch if FAC1<>0
* exponent was $00 so FAC1 is 0
MOVEQ #'0',d0 * set character = "0"
MOVEQ #1,d1 * set output string index
BRA LAB_2A89 * save last character, [EOT] & exit
* FAC1 is some non zero value
LAB_2989
MOVE.b #0,numexp(a3) * clear number exponent count
CMP.b #$81,d2 * compare FAC1 exponent with $81 (>1.00000)
BCC.s LAB_299C * branch if FAC1=>1
* else FAC1 < 1
MOVE.l #$98968000,FAC2_m(a3) * 10000000 mantissa
MOVE.w #$9800,FAC2_e(a3) * 10000000 exponent & sign
MOVE.b FAC1_s(a3),FAC_sc(a3) * make FAC1 sign sign compare
BSR LAB_MULTIPLY * do FAC2*FAC1
MOVE.b #$F9,numexp(a3) * set number exponent count (-7)
BRA.s LAB_299C * go test for fit
LAB_29B9
MOVE.w FAC1_e(a3),FAC2_e(a3) * copy exponent & sign from FAC1 to FAC2
MOVE.l FAC1_m(a3),FAC2_m(a3) * copy FAC1 mantissa to FAC2 mantissa
MOVE.b FAC1_s(a3),FAC_sc(a3) * save FAC1_s as sign compare
MOVE.l #$CCCCCCCD,FAC1_m(a3) * 1/10 mantissa
MOVE.w #$7D00,FAC1_e(a3) * 1/10 exponent & sign
BSR LAB_MULTIPLY * do FAC2*FAC1, effectively divide by 10 but
* faster
ADDQ.b #1,numexp(a3) * increment number exponent count
LAB_299C
MOVE.l #$98967F70,FAC2_m(a3) * 9999999.4375 mantissa
MOVE.w #$9800,FAC2_e(a3) * 9999999.4375 exponent & sign
* (max before scientific notation)
BSR LAB_27F0 * fast compare FAC1 with FAC2
* returns d0=+1 C=0 if FAC1 > FAC2
* returns d0= 0 C=0 if FAC1 = FAC2
* returns d0=-1 C=1 if FAC1 < FAC2
BHI.s LAB_29B9 * go do /10 if FAC1 > 9999999.4375
BEQ.s LAB_29C3 * branch if FAC1 = 9999999.4375
* FAC1 < 9999999.4375
MOVE.l #$F423F800,FAC2_m(a3) * set mantissa for 999999.5
MOVE.w #$9400,FAC2_e(a3) * set exponent for 999999.5
LEA FAC1_m(a3),a0 * set pointer for x10
LAB_29A7
BSR LAB_27F0 * fast compare FAC1 with FAC2
* returns d0=+1 C=0 if FAC1 > FAC2
* returns d0= 0 C=0 if FAC1 = FAC2
* returns d0=-1 C=1 if FAC1 < FAC2
BHI.s LAB_29C0 * branch if FAC1 > 99999.9375,no decimal places
* FAC1 <= 999999.5 so do x 10
MOVE.l (a0),d0 * get FAC1 mantissa
MOVE.b 4(a0),d1 * get FAC1 exponent
MOVE.l d0,d2 * copy it
LSR.l #2,d0 * /4
ADD.l d2,d0 * add FAC1 (x1.125)
BCC.s LAB_29B7 * branch if no carry
ROXR.l #1,d0 * shift carry back in
ADDQ.b #1,d1 * increment exponent (never overflows)
LAB_29B7
ADDQ.b #3,d1 * correct exponent ( 8 x 1.125 = 10 )
* (never overflows)
MOVE.l d0,(a0) * save new mantissa
MOVE.b d1,4(a0) * save new exponent
SUBQ.b #1,numexp(a3) * decrement number exponent count
BRA.s LAB_29A7 * go test again
* now we have just the digits to do
LAB_29C0
MOVE.l #$80000000,FAC2_m(a3) * set mantissa for 0.5
MOVE.w #$8000,FAC2_e(a3) * set exponent for 0.5
MOVE.b FAC1_s(a3),FAC_sc(a3) * sign compare = sign
BSR LAB_ADD * add the 0.5 to FAC1 (round FAC1)
LAB_29C3
BSR LAB_2831 * convert FAC1 floating to fixed
* result in d0 and Itemp
MOVEQ #$01,d2 * set default digits before dp = 1
MOVE.b numexp(a3),d0 * get number exponent count
ADD.b #8,d0 * allow 7 digits before point
BMI.s LAB_29D9 * if -ve then 1 digit before dp
CMP.b #$09,d0 * d0>=9 if n>=1E7
BCC.s LAB_29D9 * branch if >= $09
* < $08
SUBQ.b #1,d0 * take 1 from digit count
MOVE.b d0,d2 * copy byte
MOVEQ #$02,d0 * set exponent adjust
LAB_29D9
MOVEQ #0,d1 * set output string index
SUBQ.b #2,d0 * -2
MOVE.b d0,expcnt(a3) * save exponent adjust
MOVE.b d2,numexp(a3) * save digits before dp count
MOVE.b d2,d0 * copy digits before dp count
BEQ.s LAB_29E4 * branch if no digits before dp
BPL.s LAB_29F7 * branch if digits before dp
LAB_29E4
ADDQ.l #1,d1 * increment index
MOVE.b #'.',(a1,d1.w) * save to output string
TST.b d2 * test digits before dp count
BEQ.s LAB_29F7 * branch if no digits before dp
ADDQ.l #1,d1 * increment index
MOVE.b #'0',(a1,d1.w) * save to output string
LAB_29F7
MOVEQ #0,d2 * clear index (point to 1,000,000)
MOVEQ #$80-$100,d0 * set output character
LAB_29FB
LEA LAB_2A9A(pc),a0 * get base of table
MOVE.l (a0,d2.w),d3 * get table value
LAB_29FD
ADDQ.b #1,d0 * increment output character
ADD.l d3,Itemp(a3) * add to (now fixed) mantissa
BTST #7,d0 * set test sense (z flag only)
BCS.s LAB_2A18 * did carry so has wrapped past zero
BEQ.s LAB_29FD * no wrap and +ve test so try again
BRA.s LAB_2A1A * found this digit
LAB_2A18
BNE.s LAB_29FD * wrap and -ve test so try again
LAB_2A1A
BCC.s LAB_2A21 * branch if +ve test result
NEG.b d0 * negate the digit number
ADD.b #$0B,d0 * and subtract from 11 decimal
LAB_2A21
ADD.b #$2F,d0 * add "0"-1 to result
ADDQ.w #4,d2 * increment index to next less power of ten
ADDQ.w #1,d1 * increment output string index
MOVE.b d0,d3 * copy character to d3
AND.b #$7F,d3 * mask out top bit
MOVE.b d3,(a1,d1.w) * save to output string
SUB.b #1,numexp(a3) * decrement # of characters before the dp
BNE.s LAB_2A3B * branch if still characters to do
* else output the point
ADDQ.l #1,d1 * increment index
MOVE.b #'.',(a1,d1.w) * save to output string
LAB_2A3B
AND.b #$80,d0 * mask test sense bit
EORI.b #$80,d0 * invert it
CMP.b #LAB_2A9B-LAB_2A9A,d2 * compare table index with max+4
BNE.s LAB_29FB * loop if not max
* now remove trailing zeroes
LAB_2A4B
MOVE.b (a1,d1.w),d0 * get character from output string
SUBQ.l #1,d1 * decrement output string index
CMP.b #'0',d0 * compare with "0"
BEQ.s LAB_2A4B * loop until non "0" character found
CMP.b #'.',d0 * compare with "."
BEQ.s LAB_2A58 * branch if was dp
* else restore last character
ADDQ.l #1,d1 * increment output string index
LAB_2A58
MOVE.b #'+',2(a1,d1.w) * save character "+" to output string
TST.b expcnt(a3) * test exponent count
BEQ.s LAB_2A8C * if zero go set null terminator & exit
* exponent isn't zero so write exponent
BPL.s LAB_2A68 * branch if exponent count +ve
MOVE.b #'-',2(a1,d1.w) * save character "-" to output string
NEG.b expcnt(a3) * convert -ve to +ve
LAB_2A68
MOVE.b #'E',1(a1,d1.w) * save character "E" to output string
MOVE.b expcnt(a3),d2 * get exponent count
MOVEQ #$2F,d0 * one less than "0" character
LAB_2A74
ADDQ.b #1,d0 * increment 10's character
SUB.b #$0A,d2 * subtract 10 from exponent count
BCC.s LAB_2A74 * loop while still >= 0
ADD.b #$3A,d2 * add character ":", $30+$0A, result is 10-value
MOVE.b d0,3(a1,d1.w) * save 10's character to output string
MOVE.b d2,4(a1,d1.w) * save 1's character to output string
MOVE.b #0,5(a1,d1.w) * save null terminator after last character
BRA.s LAB_2A91 * go set string pointer (a0) and exit
LAB_2A89
MOVE.b d0,(a1,d1.w) * save last character to output string
LAB_2A8C
MOVE.b #0,1(a1,d1.w) * save null terminator after last character
LAB_2A91
MOVEA.l a1,a0 * set result string pointer (a0)
RTS
*************************************************************************************
*
* fast compare FAC1 with FAC2
* assumes both are +ve and FAC2>0
* returns d0=+1 C=0 if FAC1 > FAC2
* returns d0= 0 C=0 if FAC1 = FAC2
* returns d0=-1 C=1 if FAC1 < FAC2
LAB_27F0
MOVEQ #0,d0 * set for FAC1 = FAC2
MOVE.b FAC2_e(a3),d1 * get FAC2 exponent
CMP.b FAC1_e(a3),d1 * compare FAC1 exponent with FAC2 exponent
BNE.s LAB_27F1 * branch if different
MOVE.l FAC2_m(a3),d1 * get FAC2 mantissa
CMP.l FAC1_m(a3),d1 * compare mantissas
BEQ.s LAB_27F3 * exit if mantissas equal
LAB_27F1
BCS.s LAB_27F2 * if FAC1 > FAC2 return d0=+1,C=0
SUBQ.l #1,d0 * else FAC1 < FAC2 return d0=-1,C=1
RTS
LAB_27F2
ADDQ.l #1,d0
LAB_27F3
RTS
*************************************************************************************
*
* make FAC1 = 1
LAB_POON
MOVE.l #$80000000,FAC1_m(a3) * 1 mantissa
MOVE.w #$8100,FAC1_e(a3) * 1 exonent & sign
RTS
*************************************************************************************
*
* make FAC1 = 0
LAB_POZE
MOVEQ #0,d0 * clear longword
MOVE.l d0,FAC1_m(a3) * 0 mantissa
MOVE.w d0,FAC1_e(a3) * 0 exonent & sign
RTS
*************************************************************************************
*
* perform power function
* the number is in FAC2, the power is in FAC1
* no longer trashes Itemp
LAB_POWER
TST.b FAC1_e(a3) * test power
BEQ.s LAB_POON * if zero go return 1
TST.b FAC2_e(a3) * test number
BEQ.s LAB_POZE * if zero go return 0
MOVE.b FAC2_s(a3),-(sp) * save number sign
BPL.s LAB_POWP * power of positive number
MOVEQ #0,d1 * clear d1
MOVE.b d1,FAC2_s(a3) * make sign +ve
* number sign was -ve and can only be raised to
* an integer power which gives an x +j0 result,
* else do 'function call' error
MOVE.b FAC1_e(a3),d1 * get power exponent
SUB.w #$80,d1 * normalise to .5
BLS LAB_FCER * if 0<power<1 then do 'function call' error
* now shift all the integer bits out
MOVE.l FAC1_m(a3),d0 * get power mantissa
ASL.l d1,d0 * shift mantissa
BNE LAB_FCER * if power<>INT(power) then do 'function call'
* error
BCS.s LAB_POWP * if integer value odd then leave result -ve
MOVE.b d0,(sp) * save result sign +ve
LAB_POWP
MOVE.l FAC1_m(a3),-(sp) * save power mantissa
MOVE.w FAC1_e(a3),-(sp) * save power sign & exponent
BSR LAB_279B * copy number to FAC1
BSR LAB_LOG * find log of number
MOVE.w (sp)+,d0 * get power sign & exponent
MOVE.l (sp)+,FAC2_m(a3) * get power mantissa
MOVE.w d0,FAC2_e(a3) * save sign & exponent to FAC2
MOVE.b d0,FAC_sc(a3) * save sign as sign compare
MOVE.b FAC1_s(a3),d0 * get FAC1 sign
EOR.b d0,FAC_sc(a3) * make sign compare (FAC1_s EOR FAC2_s)
BSR LAB_MULTIPLY * multiply by power
BSR.s LAB_EXP * find exponential
MOVE.b (sp)+,FAC1_s(a3) * restore number sign
RTS
*************************************************************************************
*
* do - FAC1
LAB_GTHAN
TST.b FAC1_e(a3) * test for non zero FAC1
BEQ.s RTS_020 * branch if null
EORI.b #$80,FAC1_s(a3) * (else) toggle FAC1 sign bit
RTS_020
RTS
*************************************************************************************
*
* return +1
LAB_EX1
MOVE.l #$80000000,FAC1_m(a3) * +1 mantissa
MOVE.w #$8100,FAC1_e(a3) * +1 sign & exponent
RTS
* do over/under flow
LAB_EXOU
TST.b FAC1_s(a3) * test sign
BPL LAB_OFER * was +ve so do overflow error
* else underflow so return zero
MOVEQ #0,d0 * clear longword
MOVE.l d0,FAC1_m(a3) * 0 mantissa
MOVE.w d0,FAC1_e(a3) * 0 sign & exponent
RTS
* fraction was zero so do 2^n
LAB_EXOF
MOVE.l #$80000000,FAC1_m(a3) * +n mantissa
MOVE.b #0,FAC1_s(a3) * clear sign
TST.b cosout(a3) * test sign flag
BPL.s LAB_EXOL * branch if +ve
NEG.l d1 * else do 1/2^n
LAB_EXOL
ADD.b #$81,d1 * adjust exponent
MOVE.b d1,FAC1_e(a3) * save exponent
RTS
* perform EXP() (x^e)
* valid input range is -88 to +88
LAB_EXP
MOVE.b FAC1_e(a3),d0 * get exponent
BEQ.s LAB_EX1 * return 1 for zero in
CMP.b #$64,d0 * compare exponent with min
BCS.s LAB_EX1 * if smaller just return 1
** MOVEM.l d1-d6/a0,-(sp) * save the registers
MOVE.b #0,cosout(a3) * flag +ve number
MOVE.l FAC1_m(a3),d1 * get mantissa
CMP.b #$87,d0 * compare exponent with max
BHI.s LAB_EXOU * go do over/under flow if greater
BNE.s LAB_EXCM * branch if less
* else is 2^7
CMP.l #$B00F33C7,d1 * compare mantissa with n*2^7 max
BCC.s LAB_EXOU * if => go over/underflow
LAB_EXCM
TST.b FAC1_s(a3) * test sign
BPL.s LAB_EXPS * branch if arg +ve
MOVE.b #$FF,cosout(a3) * flag -ve number
MOVE.b #0,FAC1_s(a3) * take absolute value
LAB_EXPS
* now do n/LOG(2)
MOVE.l #$B8AA3B29,FAC2_m(a3) * 1/LOG(2) mantissa
MOVE.w #$8100,FAC2_e(a3) * 1/LOG(2) exponent & sign
MOVE.b #0,FAC_sc(a3) * we know they're both +ve
BSR LAB_MULTIPLY * effectively divide by log(2)
* max here is +/- 127
* now separate integer and fraction
MOVE.b #0,tpower(a3) * clear exponent add byte
MOVE.b FAC1_e(a3),d5 * get exponent
SUB.b #$80,d5 * normalise
BLS.s LAB_ESML * branch if < 1 (d5 is 0 or -ve)
* result is > 1
MOVE.l FAC1_m(a3),d0 * get mantissa
MOVE.l d0,d1 * copy it
MOVE.l d5,d6 * copy normalised exponent
NEG.w d6 * make -ve
ADD.w #32,d6 * is now 32-d6
LSR.l d6,d1 * just integer bits
MOVE.b d1,tpower(a3) * set exponent add byte
LSL.l d5,d0 * shift out integer bits
BEQ LAB_EXOF * fraction is zero so do 2^n
MOVE.l d0,FAC1_m(a3) * fraction to FAC1
MOVE.w #$8000,FAC1_e(a3) * set exponent & sign
* multiple was < 1
LAB_ESML
MOVE.l #$B17217F8,FAC2_m(a3) * LOG(2) mantissa
MOVE.w #$8000,FAC2_e(a3) * LOG(2) exponent & sign
MOVE.b #0,FAC_sc(a3) * clear sign compare
BSR LAB_MULTIPLY * multiply by log(2)
MOVE.l FAC1_m(a3),d0 * get mantissa
MOVE.b FAC1_e(a3),d5 * get exponent
SUB.w #$82,d5 * normalise and -2 (result is -1 to -30)
NEG.w d5 * make +ve
LSR.l d5,d0 * shift for 2 integer bits
* d0 = arg
* d6 = x, d1 = y
* d2 = x1, d3 = y1
* d4 = shift count
* d5 = loop count
* now do cordic set-up
MOVEQ #0,d1 * y = 0
MOVE.l #KFCTSEED,d6 * x = 1 with jkh inverse factored out
LEA TAB_HTHET(pc),a0 * get pointer to hyperbolic arctan table
MOVEQ #0,d4 * clear shift count
* cordic loop, shifts 4 and 13 (and 39
* if it went that far) need to be repeated
MOVEQ #3,d5 * 4 loops
BSR.s LAB_EXCC * do loops 1 through 4
SUBQ.w #4,a0 * do table entry again
SUBQ.l #1,d4 * do shift count again
MOVEQ #9,d5 * 10 loops
BSR.s LAB_EXCC * do loops 4 (again) through 13
SUBQ.w #4,a0 * do table entry again
SUBQ.l #1,d4 * do shift count again
MOVEQ #18,d5 * 19 loops
BSR.s LAB_EXCC * do loops 13 (again) through 31
* now get the result
TST.b cosout(a3) * test sign flag
BPL.s LAB_EXPL * branch if +ve
NEG.l d1 * do -y
NEG.b tpower(a3) * do -exp
LAB_EXPL
MOVEQ #$83-$100,d0 * set exponent
ADD.l d1,d6 * y = y +/- x
BMI.s LAB_EXRN * branch if result normal
LAB_EXNN
SUBQ.l #1,d0 * decrement exponent
ADD.l d6,d6 * shift mantissa
BPL.s LAB_EXNN * loop if not normal
LAB_EXRN
MOVE.l d6,FAC1_m(a3) * save exponent result
ADD.b tpower(a3),d0 * add integer part
MOVE.b d0,FAC1_e(a3) * save exponent
** MOVEM.l (sp)+,d1-d6/a0 * restore registers
RTS
* cordic loop
LAB_EXCC
ADDQ.l #1,d4 * increment shift count
MOVE.l d6,d2 * x1 = x
ASR.l d4,d2 * x1 >> n
MOVE.l d1,d3 * y1 = y
ASR.l d4,d3 * y1 >> n
TST.l d0 * test arg
BMI.s LAB_EXAD * branch if -ve
ADD.l d2,d1 * y = y + x1
ADD.l d3,d6 * x = x + y1
SUB.l (a0)+,d0 * arg = arg - atnh(a0)
DBF d5,LAB_EXCC * decrement and loop if not done
RTS
LAB_EXAD
SUB.l d2,d1 * y = y - x1
SUB.l d3,d6 * x = x + y1
ADD.l (a0)+,d0 * arg = arg + atnh(a0)
DBF d5,LAB_EXCC * decrement and loop if not done
RTS
*************************************************************************************
*
* RND(n), 32 bit Galois version. make n=0 for 19th next number in sequence or n<>0
* to get 19th next number in sequence after seed n. This version of the PRNG uses
* the Galois method and a sample of 65536 bytes produced gives the following values.
* Entropy = 7.997442 bits per byte
* Optimum compression would reduce these 65536 bytes by 0 percent
* Chi square distribution for 65536 samples is 232.01, and
* randomly would exceed this value 75.00 percent of the time
* Arithmetic mean value of data bytes is 127.6724, 127.5 would be random
* Monte Carlo value for Pi is 3.122871269, error 0.60 percent
* Serial correlation coefficient is -0.000370, totally uncorrelated would be 0.0
LAB_RND
TST.b FAC1_e(a3) * get FAC1 exponent
BEQ.s NextPRN * do next random number if zero
* else get seed into random number store
LEA PRNlword(a3),a0 * set PRNG pointer
BSR LAB_2778 * pack FAC1 into (a0)
NextPRN
MOVEQ #$AF-$100,d1 * set EOR value
MOVEQ #18,d2 * do this 19 times
MOVE.l PRNlword(a3),d0 * get current
Ninc0
ADD.l d0,d0 * shift left 1 bit
BCC.s Ninc1 * branch if bit 32 not set
EOR.b d1,d0 * do Galois LFSR feedback
Ninc1
DBF d2,Ninc0 * loop
MOVE.l d0,PRNlword(a3) * save back to seed word
MOVE.l d0,FAC1_m(a3) * copy to FAC1 mantissa
MOVE.w #$8000,FAC1_e(a3) * set the exponent and clear the sign
BRA LAB_24D5 * normalise FAC1 & return
*************************************************************************************
*
* cordic TAN(x) routine, TAN(x) = SIN(x)/COS(x)
* x = angle in radians
LAB_TAN
BSR.s LAB_SIN * go do SIN/COS cordic compute
MOVE.w FAC1_e(a3),FAC2_e(a3) * copy exponent & sign from FAC1 to FAC2
MOVE.l FAC1_m(a3),FAC2_m(a3) * copy FAC1 mantissa to FAC2 mantissa
MOVE.l d1,FAC1_m(a3) * get COS(x) mantissa
MOVE.b d3,FAC1_e(a3) * get COS(x) exponent
BEQ LAB_OFER * do overflow if COS = 0
BSR LAB_24D5 * normalise FAC1
BRA LAB_DIVIDE * do FAC2/FAC1 and return, FAC_sc set by SIN
* COS calculation
*************************************************************************************
*
* cordic SIN(x), COS(x) routine
* x = angle in radians
LAB_COS
MOVE.l #$C90FDAA3,FAC2_m(a3) * pi/2 mantissa (LSB is rounded up so
* COS(PI/2)=0)
MOVE.w #$8100,FAC2_e(a3) * pi/2 exponent and sign
MOVE.b FAC1_s(a3),FAC_sc(a3) * sign = FAC1 sign (b7)
BSR LAB_ADD * add FAC2 to FAC1, adjust for COS(x)
*************************************************************************************
*
* SIN/COS cordic calculator
LAB_SIN
MOVE.b #0,cosout(a3) * set needed result
MOVE.l #$A2F9836F,FAC2_m(a3) * 1/pi mantissa (LSB is rounded up so SIN(PI)=0)
MOVE.w #$7F00,FAC2_e(a3) * 1/pi exponent & sign
MOVE.b FAC1_s(a3),FAC_sc(a3) * sign = FAC1 sign (b7)
BSR LAB_MULTIPLY * multiply by 1/pi
MOVE.b FAC1_e(a3),d0 * get FAC1 exponent
BEQ.s LAB_SCZE * branch if zero
LEA TAB_SNCO(pc),a0 * get pointer to constants table
MOVE.l FAC1_m(a3),d6 * get FAC1 mantissa
SUBQ.b #1,d0 * 2 radians in 360 degrees so /2
BEQ.s LAB_SCZE * branch if zero
SUB.b #$80,d0 * normalise exponent
BMI.s LAB_SCL0 * branch if < 1
* X is > 1
CMP.b #$20,d0 * is it >= 2^32
BCC.s LAB_SCZE * may as well do zero
LSL.l d0,d6 * shift out integer part bits
BNE.s LAB_CORD * if fraction go test quadrant and adjust
* else no fraction so do zero
LAB_SCZE
MOVEQ #$81-$100,d2 * set exponent for 1.0
MOVEQ #0,d3 * set exponent for 0.0
MOVE.l #$80000000,d0 * mantissa for 1.0
MOVE.l d3,d1 * mantissa for 0.0
BRA.s outloop * go output it
* x is < 1
LAB_SCL0
NEG.b d0 * make +ve
CMP.b #$1E,d0 * is it <= 2^-30
BCC.s LAB_SCZE * may as well do zero
LSR.l d0,d6 * shift out <= 2^-32 bits
* cordic calculator, argument in d6
* table pointer in a0, returns in d0-d3
LAB_CORD
MOVE.b FAC1_s(a3),FAC_sc(a3) * copy as sign compare for TAN
ADD.l d6,d6 * shift 0.5 bit into carry
BCC.s LAB_LTPF * branch if less than 0.5
EORI.b #$FF,FAC1_s(a3) * toggle result sign
LAB_LTPF
ADD.l d6,d6 * shift 0.25 bit into carry
BCC.s LAB_LTPT * branch if less than 0.25
EORI.b #$FF,cosout(a3) * toggle needed result
EORI.b #$FF,FAC_sc(a3) * toggle sign compare for TAN
LAB_LTPT
LSR.l #2,d6 * shift the bits back (clear integer bits)
BEQ.s LAB_SCZE * no fraction so go do zero
* set start values
MOVEQ #1,d5 * set bit count
MOVE.l -4(a0),d0 * get multiply constant (1st itteration d0)
MOVE.l d0,d1 * 1st itteration d1
SUB.l (a0)+,d6 * 1st always +ve so do 1st step
BRA.s mainloop * jump into routine
subloop
SUB.l (a0)+,d6 * z = z - arctan(i)/2pi
SUB.l d3,d0 * x = x - y1
ADD.l d2,d1 * y = y + x1
BRA.s nexta * back to main loop
mainloop
MOVE.l d0,d2 * x1 = x
ASR.l d5,d2 * / (2 ^ i)
MOVE.l d1,d3 * y1 = y
ASR.l d5,d3 * / (2 ^ i)
TST.l d6 * test sign (is 2^0 bit)
BPL.s subloop * go do subtract if > 1
ADD.l (a0)+,d6 * z = z + arctan(i)/2pi
ADD.l d3,d0 * x = x + y1
SUB.l d2,d1 * y = y + x1
nexta
ADDQ.l #1,d5 * i = i + 1
CMP.l #$1E,d5 * check end condition
BNE.s mainloop * loop if not all done
* now untangle output value
MOVEQ #$81-$100,d2 * set exponent for 0 to .99 rec.
MOVE.l d2,d3 * copy it for cos output
outloop
TST.b cosout(a3) * did we want cos output?
BMI.s subexit * if so skip
EXG d0,d1 * swap SIN and COS mantissas
EXG d2,d3 * swap SIN and COS exponents
subexit
MOVE.l d0,FAC1_m(a3) * set result mantissa
MOVE.b d2,FAC1_e(a3) * set result exponent
BRA LAB_24D5 * normalise FAC1 & return
*************************************************************************************
*
* perform ATN()
LAB_ATN
MOVE.b FAC1_e(a3),d0 * get FAC1 exponent
BEQ RTS_021 * ATN(0) = 0 so skip calculation
MOVE.b #0,cosout(a3) * set result needed
CMP.b #$81,d0 * compare exponent with 1
BCS.s LAB_ATLE * branch if n<1
BNE.s LAB_ATGO * branch if n>1
MOVE.l FAC1_m(a3),d0 * get mantissa
ADD.l d0,d0 * shift left
BEQ.s LAB_ATLE * branch if n=1
LAB_ATGO
MOVE.l #$80000000,FAC2_m(a3) * set mantissa for 1
MOVE.w #$8100,FAC2_e(a3) * set exponent for 1
MOVE.b FAC1_s(a3),FAC_sc(a3) * sign compare = sign
BSR LAB_DIVIDE * do 1/n
MOVE.b #$FF,cosout(a3) * set inverse result needed
LAB_ATLE
MOVE.l FAC1_m(a3),d0 * get FAC1 mantissa
MOVE.w #$82,d1 * set to correct exponent
SUB.b FAC1_e(a3),d1 * subtract FAC1 exponent (always <= 1)
LSR.l d1,d0 * shift in two integer part bits
LEA TAB_ATNC(pc),a0 * get pointer to arctan table
MOVEQ #0,d6 * Z = 0
MOVE.l #1<<30,d1 * y = 1
MOVEQ #29,d5 * loop 30 times
MOVEQ #1,d4 * shift counter
BRA.s LAB_ATCD * enter loop
LAB_ATNP
ASR.l d4,d2 * x1 / 2^i
ADD.l d2,d1 * y = y + x1
ADD.l (a0),d6 * z = z + atn(i)
LAB_ATCD
MOVE.l d0,d2 * x1 = x
MOVE.l d1,d3 * y1 = y
ASR.l d4,d3 * y1 / 2^i
LAB_CATN
SUB.l d3,d0 * x = x - y1
BPL.s LAB_ATNP * branch if x >= 0
MOVE.l d2,d0 * else get x back
ADDQ.w #4,a0 * increment pointer
ADDQ.l #1,d4 * increment i
ASR.l #1,d3 * y1 / 2^i
DBF d5,LAB_CATN * decrement and loop if not done
MOVE.b #$82,FAC1_e(a3) * set new exponent
MOVE.l d6,FAC1_m(a3) * save mantissa
BSR LAB_24D5 * normalise FAC1
TST.b cosout(a3) * was it > 1 ?
BPL.s RTS_021 * branch if not
MOVE.b FAC1_s(a3),d7 * get sign
MOVE.b #0,FAC1_s(a3) * clear sign
MOVE.l #$C90FDAA2,FAC2_m(a3) * set -(pi/2)
MOVE.w #$8180,FAC2_e(a3) * set exponent and sign
MOVE.b #$FF,FAC_sc(a3) * set sign compare
BSR LAB_ADD * perform addition, FAC2 to FAC1
MOVE.b d7,FAC1_s(a3) * restore sign
RTS_021
RTS
*************************************************************************************
*
* perform BITSET
LAB_BITSET
BSR LAB_GADB * get two parameters for POKE or WAIT
* first parameter in a0, second in d0
CMP.b #$08,d0 * only 0 to 7 are allowed
BCC LAB_FCER * branch if > 7
BSET d0,(a0) * set bit
RTS
*************************************************************************************
*
* perform BITCLR
LAB_BITCLR
BSR LAB_GADB * get two parameters for POKE or WAIT
* first parameter in a0, second in d0
CMP.b #$08,d0 * only 0 to 7 are allowed
BCC LAB_FCER * branch if > 7
BCLR d0,(a0) * clear bit
RTS
*************************************************************************************
*
* perform BITTST()
LAB_BTST
MOVE.b (a5)+,d0 * increment BASIC pointer
BSR LAB_GADB * get two parameters for POKE or WAIT
* first parameter in a0, second in d0
CMP.b #$08,d0 * only 0 to 7 are allowed
BCC LAB_FCER * branch if > 7
MOVE.l d0,d1 * copy bit # to test
BSR LAB_GBYT * get next BASIC byte
CMP.b #')',d0 * is next character ")"
BNE LAB_SNER * if not ")" go do syntax error, then warm start
BSR LAB_IGBY * update execute pointer (to character past ")")
MOVEQ #0,d0 * set the result as zero
BTST d1,(a0) * test bit
BEQ LAB_27DB * branch if zero (already correct)
MOVEQ #-1,d0 * set for -1 result
BRA LAB_27DB * go do SGN tail
*************************************************************************************
*
* perform USING$()
fsd EQU 0 * (sp) format string descriptor pointer
fsti EQU 4 * 4(sp) format string this index
fsli EQU 6 * 6(sp) format string last index
fsdpi EQU 8 * 8(sp) format string decimal point index
fsdc EQU 10 * 10(sp) format string decimal characters
fend EQU 12-4 * x(sp) end-4, fsd is popped by itself
ofchr EQU '#' * the overflow character
LAB_USINGS
TST.b Dtypef(a3) * test data type, $80=string
BPL LAB_FOER * if not string type go do format error
MOVEA.l FAC1_m(a3),a2 * get the format string descriptor pointer
MOVE.w 4(a2),d7 * get the format string length
BEQ LAB_FOER * if null string go do format error
* clear the format string values
MOVEQ #0,d0 * clear d0
MOVE.w d0,-(sp) * clear the format string decimal characters
MOVE.w d0,-(sp) * clear the format string decimal point index
MOVE.w d0,-(sp) * clear the format string last index
MOVE.w d0,-(sp) * clear the format string this index
MOVE.l a2,-(sp) * save the format string descriptor pointer
* make a null return string for the first string add
MOVEQ #0,d1 * make a null string
MOVEA.l d1,a0 * with a null pointer
BSR LAB_RTST * push a string on the descriptor stack
* a0 = pointer, d1 = length
* do the USING$() function next value
MOVE.b (a5)+,d0 * get the next BASIC byte
LAB_U002
CMP.b #',',d0 * compare with comma
BNE LAB_SNER * if not "," go do syntax error
BSR LAB_ProcFo * process the format string
TST.b d2 * test the special characters flag
BEQ LAB_FOER * if no special characters go do format error
BSR LAB_EVEX * evaluate the expression
TST.b Dtypef(a3) * test the data type
BMI LAB_TMER * if string type go do type missmatch error
TST.b FAC1_e(a3) * test FAC1 exponent
BEQ.s LAB_U004 * if FAC1 = 0 skip the rounding
MOVE.w fsdc(sp),d1 * get the format string decimal character count
CMP.w #8,d1 * compare the fraction digit count with 8
BCC.s LAB_U004 * if >= 8 skip the rounding
MOVE.w d1,d0 * else copy the fraction digit count
ADD.w d1,d1 * * 2
ADD.w d0,d1 * * 3
ADD.w d1,d1 * * 6
LEA LAB_P_10(pc),a0 * get the rounding table base
MOVE.l 2(a0,d1.w),FAC2_m(a3) * get the rounding mantissa
MOVE.w (a0,d1.w),d0 * get the rounding exponent
SUB.w #$100,d0 * effectively divide the mantissa by 2
MOVE.w d0,FAC2_e(a3) * save the rounding exponent
MOVE.b #$00,FAC_sc(a3) * clear the sign compare
BSR LAB_ADD * round the value to n places
LAB_U004
BSR LAB_2970 * convert FAC1 to string - not on stack
BSR LAB_DupFmt * duplicate the processed format string section
* returns length in d1, pointer in a0
* process the number string, length in d6, decimal point index in d2
LEA Decss(a3),a2 * set the number string start
MOVEQ #0,d6 * clear the number string index
MOVEQ #'.',d4 * set the decimal point character
LAB_U005
MOVE.w d6,d2 * save the index to flag the decimal point
LAB_U006
ADDQ.w #1,d6 * increment the number string index
MOVE.b (a2,d6.w),d0 * get a number string character
BEQ.s LAB_U010 * if null then number complete
CMP.b #'E',d0 * compare the character with an "E"
BEQ.s LAB_U008 * was sx[.x]Esxx so go handle sci notation
CMP.b d4,d0 * compare the character with "."
BNE.s LAB_U006 * if not decimal point go get the next digit
BRA.s LAB_U005 * go save the index and get the next digit
* have found an sx[.x]Esxx number, the [.x] will not be present for a single digit
LAB_U008
MOVE.w d6,d3 * copy the index to the "E"
SUBQ.w #1,d3 * -1 gives the last digit index
ADDQ.w #1,d6 * increment the index to the exponent sign
MOVE.b (a2,d6.w),d0 * get the exponent sign character
CMP.b #'-',d0 * compare the exponent sign with "-"
BNE LAB_FCER * if it wasn't sx[.x]E-xx go do function
* call error
* found an sx[.x]E-xx number so check the exponent magnitude
ADDQ.w #1,d6 * increment the index to the exponent 10s
MOVE.b (a2,d6.w),d0 * get the exponent 10s character
CMP.b #'0',d0 * compare the exponent 10s with "0"
BEQ.s LAB_U009 * if it was sx[.x]E-0x go get the exponent
* 1s character
MOVEQ #10,d0 * else start writing at index 10
BRA.s LAB_U00A * go copy the digits
* found an sx[.x]E-0x number so get the exponent magnitude
LAB_U009
ADDQ.w #1,d6 * increment the index to the exponent 1s
MOVEQ #$0F,d0 * set the mask for the exponent 1s digit
AND.b (a2,d6.w),d0 * get and convert the exponent 1s digit
LAB_U00A
MOVE.w d3,d2 * copy the number last digit index
CMPI.w #1,d2 * is the number of the form sxE-0x
BNE.s LAB_U00B * if it is sx.xE-0x skip the increment
* else make room for the decimal point
ADDQ.w #1,d2 * add 1 to the write index
LAB_U00B
ADD.w d0,d2 * add the exponent 1s to the write index
MOVEQ #10,d0 * set the maximum write index
SUB.w d2,d0 * compare the index with the maximum
BGT.s LAB_U00C * if the index < the maximum continue
ADD.w d0,d2 * else set the index to the maximum
ADD.w d0,d3 * adjust the read index
CMPI.w #1,d3 * compare the adjusted index with 1
BGT.s LAB_U00C * if > 1 continue
MOVEQ #0,d3 * else allow for the decimal point
LAB_U00C
MOVE.w d2,d6 * copy the write index as the number
* string length
MOVEQ #0,d0 * clear d0 to null terminate the number
* string
LAB_U00D
MOVE.b d0,(a2,d2.w) * save the character to the number string
SUBQ.w #1,d2 * decrement the number write index
CMPI.w #1,d2 * compare the number write index with 1
BEQ.s LAB_U00F * if at the decimal point go save it
* else write a digit to the number string
MOVEQ #'0',d0 * default to "0"
TST.w d3 * test the number read index
BEQ.s LAB_U00D * if zero just go save the "0"
LAB_U00E
MOVE.b (a2,d3.w),d0 * read the next number digit
SUBQ.w #1,d3 * decrement the read index
CMP.b d4,d0 * compare the digit with "."
BNE.s LAB_U00D * if not "." go save the digit
BRA.s LAB_U00E * else go get the next digit
LAB_U00F
MOVE.b d4,(a2,d2.w) * save the decimal point
LAB_U010
TST.w d2 * test the number string decimal point index
BNE.s LAB_U014 * if dp present skip the reset
MOVE.w d6,d2 * make the decimal point index = the length
* copy the fractional digit characters from the number string
LAB_U014
MOVE.w d2,d3 * copy the number string decimal point index
ADDQ.w #1,d3 * increment the number string index
MOVE.w fsdpi(sp),d4 * get the new format string decimal point index
LAB_U018
ADDQ.w #1,d4 * increment the new format string index
CMP.w d4,d1 * compare it with the new format string length
BLS.s LAB_U022 * if done the fraction digits go do integer
MOVE.b (a0,d4.w),d0 * get a new format string character
CMP.b #'%',d0 * compare it with "%"
BEQ.s LAB_U01C * if "%" go copy a number character
CMP.b #'#',d0 * compare it with "#"
BNE.s LAB_U018 * if not "#" go do the next new format character
LAB_U01C
MOVEQ #'0',d0 * default to "0" character
CMP.w d3,d6 * compare the number string index with length
BLS.s LAB_U020 * if there skip the character get
MOVE.b (a2,d3.w),d0 * get a character from the number string
ADDQ.w #1,d3 * increment the number string index
LAB_U020
MOVE.b d0,(a0,d4.w) * save the number character to the new format
* string
BRA.s LAB_U018 * go do the next new format character
* now copy the integer digit characters from the number string
LAB_U022
MOVEQ #0,d6 * clear the sign done flag
MOVEQ #0,d5 * clear the sign present flag
SUBQ.w #1,d2 * decrement the number string index
BNE.s LAB_U026 * if not now at sign continue
MOVEQ #1,d2 * increment the number string index
MOVE.b #'0',(a2,d2.w) * replace the point with a zero
LAB_U026
MOVE.w fsdpi(sp),d4 * get the new format string decimal point index
CMP.w d4,d1 * compare it with the new format string length
BCC.s LAB_U02A * if within the string go use the index
MOVE.w d1,d4 * else set the index to the end of the string
LAB_U02A
SUBQ.w #1,d4 * decrement the new format string index
BMI.s LAB_U03E * if all done go test for any overflow
MOVE.b (a0,d4.w),d0 * else get a new format string character
MOVEQ #'0',d7 * default to "0" character
CMP.b #'%',d0 * compare it with "%"
BEQ.s LAB_U02B * if "%" go copy a number character
MOVEQ #' ',d7 * default to " " character
CMP.b #'#',d0 * compare it with "#"
BNE.s LAB_U02C * if not "#" go try ","
LAB_U02B
TST.w d2 * test the number string index
BNE.s LAB_U036 * if not at the sign go get a number character
BRA.s LAB_U03C * else go save the default character
LAB_U02C
CMP.b #',',d0 * compare it with ","
BNE.s LAB_U030 * if not "," go try the sign characters
TST.w d2 * test the number string index
BNE.s LAB_U02E * if not at the sign keep the ","
CMP.b #'%',-1(a0,d4.w) * else compare the next format string character
* with "%"
BNE.s LAB_U03C * if not "%" keep the default character
LAB_U02E
MOVE.b d0,d7 * else use the "," character
BRA.s LAB_U03C * go save the character to the string
LAB_U030
CMP.b #'-',d0 * compare it with "-"
BEQ.s LAB_U034 * if "-" go do the sign character
CMP.b #'+',d0 * compare it with "+"
BNE.s LAB_U02A * if not "+" go do the next new format character
CMP.b #'-',(a2) * compare the sign character with "-"
BEQ.s LAB_U034 * if "-" don't change the sign character
MOVE.b #'+',(a2) * else make the sign character "+"
LAB_U034
MOVE.b d0,d5 * set the sign present flag
TST.w d2 * test the number string index
BEQ.s LAB_U038 * if at the sign keep the default character
LAB_U036
MOVE.b (a2,d2.w),d7 * else get a character from the number string
SUBQ.w #1,d2 * decrement the number string index
BRA.s LAB_U03C * go save the character
LAB_U038
TST.b d6 * test the sign done flag
BNE.s LAB_U03C * if the sign has been done go use the space
* character
MOVE.b (a2),d7 * else get the sign character
MOVE.b d7,d6 * flag that the sign has been done
LAB_U03C
MOVE.b d7,(a0,d4.w) * save the number character to the new format
* string
BRA.s LAB_U02A * go do the next new format character
* test for overflow conditions
LAB_U03E
TST.w d2 * test the number string index
BNE.s LAB_U040 * if all the digits aren't done go output
* an overflow indication
* test for sign overflows
TST.b d5 * test the sign present flag
BEQ.s LAB_U04A * if no sign present go add the string
* there was a sign in the format string
TST.b d6 * test the sign done flag
BNE.s LAB_U04A * if the sign is done go add the string
* the sign isn't done so see if it was mandatory
CMPI.b #'+',d5 * compare the sign with "+"
BEQ.s LAB_U040 * if it was "+" go output an overflow
* indication
* the sign wasn't mandatory but the number may have been negative
CMP.b #'-',(a2) * compare the sign character with "-"
BNE.s LAB_U04A * if it wasn't "-" go add the string
* else the sign was "-" and a sign hasn't been output so ..
* the number overflowed the format string so replace all the special format characters
* with the overflow character
LAB_U040
MOVEQ #ofchr,d5 * set the overflow character
MOVE.w d1,d7 * copy the new format string length
SUBQ.w #1,d7 * adjust for the loop type
MOVE.w fsti(sp),d6 * copy the new format string last index
SUBQ.w #1,d6 * -1 gives the last character of this string
BGT.s LAB_U044 * if not zero continue
MOVE.w d7,d6 * else set the format string index to the end
LAB_U044
MOVE.b (a1,d6.w),d0 * get a character from the format string
CMPI.b #'#',d0 * compare it with "#" special format character
BEQ.s LAB_U046 * if "#" go use the overflow character
CMPI.b #'%',d0 * compare it with "%" special format character
BEQ.s LAB_U046 * if "%" go use the overflow character
CMPI.b #',',d0 * compare it with "," special format character
BEQ.s LAB_U046 * if "," go use the overflow character
CMPI.b #'+',d0 * compare it with "+" special format character
BEQ.s LAB_U046 * if "+" go use the overflow character
CMPI.b #'-',d0 * compare it with "-" special format character
BEQ.s LAB_U046 * if "-" go use the overflow character
CMPI.b #'.',d0 * compare it with "." special format character
BNE.s LAB_U048 * if not "." skip the using overflow character
LAB_U046
MOVE.b d5,d0 * use the overflow character
LAB_U048
MOVE.b d0,(a0,d7.w) * save the character to the new format string
SUBQ.w #1,d6 * decrement the format string index
DBF d7,LAB_U044 * decrement the count and loop if not all done
* add the new string to the previous string
LAB_U04A
LEA 6(a4),a0 * get the descriptor pointer for string 1
MOVE.l a4,FAC1_m(a3) * save the descriptor pointer for string 2
BSR LAB_224E * concatenate the strings
* now check for any tail on the format string
MOVE.w fsti(sp),d0 * get this index
BEQ.s LAB_U04C * if at start of string skip the output
MOVE.w d0,fsli(sp) * save this index to the last index
BSR LAB_ProcFo * now process the format string
TST.b d2 * test the special characters flag
BNE.s LAB_U04C * if special characters present skip the output
* else output the new string part
BSR.s LAB_DupFmt * duplicate the processed format string section
MOVE.w fsti(sp),fsli(sp) * copy this index to the last index
* add the new string to the previous string
LEA 6(a4),a0 * get the descriptor pointer for string 1
MOVE.l a4,FAC1_m(a3) * save the descriptor pointer for string 2
BSR LAB_224E * concatenate the strings
* check for another value or end of function
LAB_U04C
MOVE.b (a5)+,d0 * get the next BASIC byte
CMP.b #')',d0 * compare with close bracket
BNE LAB_U002 * if not ")" go do next value
* pop the result string off the descriptor stack
MOVEA.l a4,a0 * copy the result string descriptor pointer
MOVE.l Sstorl(a3),d1 * save the bottom of string space
BSR LAB_22BA * pop (a0) descriptor, returns with ..
* d0 = length, a0 = pointer
MOVE.l d1,Sstorl(a3) * restore the bottom of string space
MOVEA.l a0,a1 * copy the string result pointer
MOVE.w d0,d1 * copy the string result length
* pop the format string off the descriptor stack
MOVEA.l (sp)+,a0 * pull the format string descriptor pointer
BSR LAB_22BA * pop (a0) descriptor, returns with ..
* d0 = length, a0 = pointer
LEA fend(sp),sp * dump the saved values
* push the result string back on the descriptor stack and return
MOVEA.l a1,a0 * copy the result string pointer back
BRA LAB_RTST * push a string on the descriptor stack and
* return. a0 = pointer, d1 = length
*************************************************************************************
*
* duplicate the processed format string section
* make a string as long as the format string
LAB_DupFmt
MOVEA.l 4+fsd(sp),a1 * get the format string descriptor pointer
MOVE.w 4(a1),d7 * get the format string length
MOVE.w 4+fsli(sp),d2 * get the format string last index
MOVE.w 4+fsti(sp),d6 * get the format string this index
MOVE.w d6,d1 * copy the format string this index
SUB.w d2,d1 * subtract the format string last index
BHI.s LAB_D002 * if > 0 skip the correction
ADD.w d7,d1 * else add the format string length as the
* correction
LAB_D002
BSR LAB_2115 * make string space d1 bytes long
* return a0/Sutill = pointer, others unchanged
* push the new string on the descriptor stack
BSR LAB_RTST * push a string on the descriptor stack and
* return. a0 = pointer, d1 = length
* copy the characters from the format string
MOVEA.l 4+fsd(sp),a1 * get the format string descriptor pointer
MOVEA.l (a1),a1 * get the format string pointer
MOVEQ #0,d4 * clear the new string index
LAB_D00A
MOVE.b (a1,d2.w),(a0,d4.w) * get a character from the format string and
* save it to the new string
ADDQ.w #1,d4 * increment the new string index
ADDQ.w #1,d2 * increment the format string index
CMP.w d2,d7 * compare the format index with the length
BNE.s LAB_D00E * if not there skip the reset
MOVEQ #0,d2 * else reset the format string index
LAB_D00E
CMP.w d2,d6 * compare the index with this index
BNE.s LAB_D00A * if not equal go do the next character
RTS
**************************************************************************************
*
* process the format string
LAB_ProcFo
MOVEA.l 4+fsd(sp),a1 * get the format string descriptor pointer
MOVE.w 4(a1),d7 * get the format string length
MOVEA.l (a1),a1 * get the format string pointer
MOVE.w 4+fsli(sp),d6 * get the format string last index
MOVE.w d7,4+fsdpi(sp) * set the format string decimal point index
*## MOVE.w #-1,4+fsdpi(sp) * set the format string decimal point index
MOVEQ #0,d5 * no decimal point
MOVEQ #0,d3 * no decimal characters
MOVEQ #0,d2 * no special characters
LAB_P004
MOVE.b (a1,d6.w),d0 * get a format string byte
CMP.b #',',d0 * compare it with ","
BEQ.s LAB_P01A * if "," go do the next format string byte
CMP.b #'#',d0 * compare it with "#"
BEQ.s LAB_P008 * if "#" go flag special characters
CMP.b #'%',d0 * compare it with "%"
BNE.s LAB_P00C * if not "%" go try "+"
LAB_P008
TST.l d5 * test the decimal point flag
BPL.s LAB_P00E * if no point skip counting decimal characters
ADDQ.w #1,d3 * else increment the decimal character count
BRA.s LAB_P01A * go do the next character
LAB_P00C
CMP.b #'+',d0 * compare it with "+"
BEQ.s LAB_P00E * if "+" go flag special characters
CMP.b #'-',d0 * compare it with "-"
BNE.s LAB_P010 * if not "-" go check decimal point
LAB_P00E
OR.b d0,d2 * flag special characters
BRA.s LAB_P01A * go do the next character
LAB_P010
CMP.b #'.',d0 * compare it with "."
BNE.s LAB_P018 * if not "." go check next
* "." a decimal point
TST.l d5 * if there is already a decimal point
BMI.s LAB_P01A * go do the next character
MOVE.w d6,d0 * copy the decimal point index
SUB.w 4+fsli(sp),d0 * calculate it from the scan start
MOVE.w d0,4+fsdpi(sp) * save the decimal point index
MOVEQ #-1,d5 * flag decimal point
OR.b d0,d2 * flag special characters
BRA.s LAB_P01A * go do the next character
* was not a special character
LAB_P018
TST.b d2 * test if there have been special characters
BNE.s LAB_P01E * if so exit the format string process
LAB_P01A
ADDQ.w #1,d6 * increment the format string index
CMP.w d6,d7 * compare it with the format string length
BHI.s LAB_P004 * if length > index go get the next character
MOVEQ #0,d6 * length = index so reset the format string
* index
LAB_P01E
MOVE.w d6,4+fsti(sp) * save the format string this index
MOVE.w d3,4+fsdc(sp) * save the format string decimal characters
RTS
*************************************************************************************
*
* perform BIN$()
* # of leading 0s is in d1, the number is in d0
LAB_BINS
CMP.b #$21,d1 * max + 1
BCC LAB_FCER * exit if too big ( > or = )
MOVEQ #$1F,d2 * bit count-1
LEA Binss(a3),a0 * point to string
MOVEQ #$30,d4 * "0" character for ADDX
NextB1
MOVEQ #0,d3 * clear byte
LSR.l #1,d0 * shift bit into Xb
ADDX.b d4,d3 * add carry and character to zero
MOVE.b d3,(a0,d2.w) * save character to string
DBF d2,NextB1 * decrement and loop if not done
* this is the exit code and is also used by HEX$()
EndBHS
MOVE.b #0,BHsend(a3) * null terminate the string
TST.b d1 * test # of characters
BEQ.s NextB2 * go truncate string
NEG.l d1 * make -ve
ADD.l #BHsend,d1 * effectively (end-length)
LEA 0(a3,d1.w),a0 * effectively add (end-length) to pointer
BRA.s BinPr * go print string
* truncate string to remove leading "0"s
NextB2
MOVE.b (a0),d0 * get byte
BEQ.s BinPr * if null then end of string so add 1 and go
* print it
CMP.b #'0',d0 * compare with "0"
BNE.s GoPr * if not "0" then go print string from here
ADDQ.w #1,a0 * else increment pointer
BRA.s NextB2 * loop always
* make fixed length output string - ignore overflows!
BinPr
LEA BHsend(a3),a1 * get string end
CMPA.l a1,a0 * are we at the string end
BNE.s GoPr * branch if not
SUBQ.w #1,a0 * else need at least one zero
GoPr
BRA LAB_20AE * print " terminated string to FAC1, stack & RET
*************************************************************************************
*
* perform HEX$()
* # of leading 0s is in d1, the number is in d0
LAB_HEXS
CMP.b #$09,d1 * max + 1
BCC LAB_FCER * exit if too big ( > or = )
MOVEQ #$07,d2 * nibble count-1
LEA Hexss(a3),a0 * point to string
MOVEQ #$30,d4 * "0" character for ABCD
NextH1
MOVE.b d0,d3 * copy lowest byte
ROR.l #4,d0 * shift nibble into 0-3
AND.b #$0F,d3 * just this nibble
MOVE.b d3,d5 * copy it
ADD.b #$F6,d5 * set extend bit
ABCD d4,d3 * decimal add extend and character to zero
MOVE.b d3,(a0,d2.w) * save character to string
DBF d2,NextH1 * decrement and loop if not done
BRA.s EndBHS * go process string
*************************************************************************************
*
* ctrl-c check routine. includes limited "life" byte save for INGET routine
VEC_CC
TST.b ccflag(a3) * check [CTRL-C] check flag
BNE.s RTS_022 * exit if [CTRL-C] check inhibited
JSR V_INPT(a3) * scan input device
BCC.s LAB_FBA0 * exit if buffer empty
MOVE.b d0,ccbyte(a3) * save received byte
MOVE.b #$20,ccnull(a3) * set "life" timer for bytes countdown
BRA LAB_1636 * return to BASIC
LAB_FBA0
TST.b ccnull(a3) * get countdown byte
BEQ.s RTS_022 * exit if finished
SUBQ.b #1,ccnull(a3) * else decrement countdown
RTS_022
RTS
*************************************************************************************
*
* get byte from input device, no waiting
* returns with carry set if byte in A
INGET
JSR V_INPT(a3) * call scan input device
BCS.s LAB_FB95 * if byte go reset timer
MOVE.b ccnull(a3),d0 * get countdown
BEQ.s RTS_022 * exit if empty
MOVE.b ccbyte(a3),d0 * get last received byte
LAB_FB95
MOVE.b #$00,ccnull(a3) * clear timer because we got a byte
ORI.b #1,CCR * set carry, flag we got a byte
RTS
*************************************************************************************
*
* perform MAX()
LAB_MAX
BSR LAB_EVEZ * evaluate expression (no decrement)
TST.b Dtypef(a3) * test data type
BMI LAB_TMER * if string do Type missmatch Error/warm start
LAB_MAXN
BSR.s LAB_PHFA * push FAC1, evaluate expression,
* pull FAC2 & compare with FAC1
BCC.s LAB_MAXN * branch if no swap to do
BSR LAB_279B * copy FAC2 to FAC1
BRA.s LAB_MAXN * go do next
*************************************************************************************
*
* perform MIN()
LAB_MIN
BSR LAB_EVEZ * evaluate expression (no decrement)
TST.b Dtypef(a3) * test data type
BMI LAB_TMER * if string do Type missmatch Error/warm start
LAB_MINN
BSR.s LAB_PHFA * push FAC1, evaluate expression,
* pull FAC2 & compare with FAC1
BLS.s LAB_MINN * branch if no swap to do
BSR LAB_279B * copy FAC2 to FAC1
BRA.s LAB_MINN * go do next (branch always)
* exit routine. don't bother returning to the loop code
* check for correct exit, else so syntax error
LAB_MMEC
CMP.b #')',d0 * is it end of function?
BNE LAB_SNER * if not do MAX MIN syntax error
LEA 4(sp),sp * dump return address (faster)
BRA LAB_IGBY * update BASIC execute pointer (to chr past ")")
* and return
* check for next, evaluate & return or exit
* this is the routine that does most of the work
LAB_PHFA
BSR LAB_GBYT * get next BASIC byte
CMP.b #',',d0 * is there more ?
BNE.s LAB_MMEC * if not go do end check
MOVE.w FAC1_e(a3),-(sp) * push exponent and sign
MOVE.l FAC1_m(a3),-(sp) * push mantissa
BSR LAB_EVEZ * evaluate expression (no decrement)
TST.b Dtypef(a3) * test data type
BMI LAB_TMER * if string do Type missmatch Error/warm start
* pop FAC2 (MAX/MIN expression so far)
MOVE.l (sp)+,FAC2_m(a3) * pop mantissa
MOVE.w (sp)+,d0 * pop exponent and sign
MOVE.w d0,FAC2_e(a3) * save exponent and sign
MOVE.b FAC1_s(a3),FAC_sc(a3) * get FAC1 sign
EOR.b d0,FAC_sc(a3) * EOR to create sign compare
BRA LAB_27FA * compare FAC1 with FAC2 & return
* returns d0=+1 Cb=0 if FAC1 > FAC2
* returns d0= 0 Cb=0 if FAC1 = FAC2
* returns d0=-1 Cb=1 if FAC1 < FAC2
*************************************************************************************
*
* perform WIDTH
LAB_WDTH
CMP.b #',',d0 * is next byte ","
BEQ.s LAB_TBSZ * if so do tab size
BSR LAB_GTBY * get byte parameter, result in d0 and Itemp
TST.b d0 * test result
BEQ.s LAB_NSTT * branch if set for infinite line
CMP.b #$10,d0 * else make min width = 16d
BCS LAB_FCER * if less do function call error & exit
* this next compare ensures that we can't exit WIDTH via an error leaving the
* tab size greater than the line length.
CMP.b TabSiz(a3),d0 * compare with tab size
BCC.s LAB_NSTT * branch if >= tab size
MOVE.b d0,TabSiz(a3) * else make tab size = terminal width
LAB_NSTT
MOVE.b d0,TWidth(a3) * set the terminal width
BSR LAB_GBYT * get BASIC byte back
BEQ.s WExit * exit if no following
CMP.b #',',d0 * else is it ","
BNE LAB_SNER * if not do syntax error
LAB_TBSZ
BSR LAB_SGBY * increment and get byte, result in d0 and Itemp
TST.b d0 * test TAB size
BMI LAB_FCER * if >127 do function call error & exit
CMP.b #1,d0 * compare with min-1
BCS LAB_FCER * if <=1 do function call error & exit
MOVE.b TWidth(a3),d1 * set flags for width
BEQ.s LAB_SVTB * skip check if infinite line
CMP.b TWidth(a3),d0 * compare TAB with width
BGT LAB_FCER * branch if too big
LAB_SVTB
MOVE.b d0,TabSiz(a3) * save TAB size
* calculate tab column limit from TAB size. The Iclim is set to the last tab
* position on a line that still has at least one whole tab width between it
* and the end of the line.
WExit
MOVE.b TWidth(a3),d0 * get width
BEQ.s LAB_WDLP * branch if infinite line
CMP.b TabSiz(a3),d0 * compare with tab size
BCC.s LAB_WDLP * branch if >= tab size
MOVE.b d0,TabSiz(a3) * else make tab size = terminal width
LAB_WDLP
SUB.b TabSiz(a3),d0 * subtract tab size
BCC.s LAB_WDLP * loop while no borrow
ADD.b TabSiz(a3),d0 * add tab size back
ADD.b TabSiz(a3),d0 * add tab size back again
NEG.b d0 * make -ve
ADD.b TWidth(a3),d0 * subtract remainder from width
MOVE.b d0,Iclim(a3) * save tab column limit
RTS_023
RTS
*************************************************************************************
*
* perform SQR()
* d0 is number to find the root of
* d1 is the root result
* d2 is the remainder
* d3 is a counter
* d4 is temp
LAB_SQR
TST.b FAC1_s(a3) * test FAC1 sign
BMI LAB_FCER * if -ve do function call error
TST.b FAC1_e(a3) * test exponent
BEQ.s RTS_023 * exit if zero
MOVEM.l d1-d4,-(sp) * save registers
MOVE.l FAC1_m(a3),d0 * copy FAC1
MOVEQ #0,d2 * clear remainder
MOVE.l d2,d1 * clear root
MOVEQ #$1F,d3 * $1F for DBF, 64 pairs of bits to
* do for a 32 bit result
BTST #0,FAC1_e(a3) * test exponent odd/even
BNE.s LAB_SQE2 * if odd only 1 shift first time
LAB_SQE1
ADD.l d0,d0 * shift highest bit of number ..
ADDX.l d2,d2 * .. into remainder .. never overflows
ADD.l d1,d1 * root = root * 2 .. never overflows
LAB_SQE2
ADD.l d0,d0 * shift highest bit of number ..
ADDX.l d2,d2 * .. into remainder .. never overflows
MOVE.l d1,d4 * copy root
ADD.l d4,d4 * 2n
ADDQ.l #1,d4 * 2n+1
CMP.l d4,d2 * compare 2n+1 to remainder
BCS.s LAB_SQNS * skip sub if remainder smaller
SUB.l d4,d2 * subtract temp from remainder
ADDQ.l #1,d1 * increment root
LAB_SQNS
DBF d3,LAB_SQE1 * loop if not all done
MOVE.l d1,FAC1_m(a3) * save result mantissa
MOVE.b FAC1_e(a3),d0 * get exponent (d0 is clear here)
SUB.w #$80,d0 * normalise
LSR.w #1,d0 * /2
BCC.s LAB_SQNA * skip increment if carry clear
ADDQ.w #1,d0 * add bit zero back in (allow for half shift)
LAB_SQNA
ADD.w #$80,d0 * re-bias to $80
MOVE.b d0,FAC1_e(a3) * save it
MOVEM.l (sp)+,d1-d4 * restore registers
BRA LAB_24D5 * normalise FAC1 & return
*************************************************************************************
*
* perform VARPTR()
LAB_VARPTR
MOVE.b (a5)+,d0 * increment pointer
LAB_VARCALL
BSR LAB_GVAR * get variable address in a0
BSR LAB_1BFB * scan for ")", else do syntax error/warm start
MOVE.l a0,d0 * copy the variable address
BRA LAB_AYFC * convert d0 to signed longword in FAC1 & return
*************************************************************************************
*
* perform RAMBASE
LAB_RAM
LEA ram_base(a3),a0 * get start of EhBASIC RAM
MOVE.l a0,d0 * copy it
BRA LAB_AYFC * convert d0 to signed longword in FAC1 & return
*************************************************************************************
*
* perform PI
LAB_PI
MOVE.l #$C90FDAA2,FAC1_m(a3) * pi mantissa (32 bit)
MOVE.w #$8200,FAC1_e(a3) * pi exponent and sign
RTS
*************************************************************************************
*
* perform TWOPI
LAB_TWOPI
MOVE.l #$C90FDAA2,FAC1_m(a3) * 2pi mantissa (32 bit)
MOVE.w #$8300,FAC1_e(a3) * 2pi exponent and sign
RTS
*************************************************************************************
*
* get ASCII string equivalent into FAC1 as integer32 or float
* entry is with a5 pointing to the first character of the string
* exit with a5 pointing to the first character after the string
* d0 is character
* d1 is mantissa
* d2 is partial and table mantissa
* d3 is mantissa exponent (decimal & binary)
* d4 is decimal exponent
* get FAC1 from string
* this routine now handles hex and binary values from strings
* starting with "$" and "%" respectively
LAB_2887
MOVEM.l d1-d5,-(sp) * save registers
MOVEQ #$00,d1 * clear temp accumulator
MOVE.l d1,d3 * set mantissa decimal exponent count
MOVE.l d1,d4 * clear decimal exponent
MOVE.b d1,FAC1_s(a3) * clear sign byte
MOVE.b d1,Dtypef(a3) * set float data type
MOVE.b d1,expneg(a3) * clear exponent sign
BSR LAB_GBYT * get first byte back
BCS.s LAB_28FE * go get floating if 1st character numeric
CMP.b #'-',d0 * or is it -ve number
BNE.s LAB_289A * branch if not
MOVE.b #$FF,FAC1_s(a3) * set sign byte
BRA.s LAB_289C * now go scan & check for hex/bin/int
LAB_289A
* first character wasn't numeric or -
CMP.b #'+',d0 * compare with '+'
BNE.s LAB_289D * branch if not '+' (go check for '.'/hex/binary
* /integer)
LAB_289C
* was "+" or "-" to start, so get next character
BSR LAB_IGBY * increment & scan memory
BCS.s LAB_28FE * branch if numeric character
LAB_289D
CMP.b #'.',d0 * else compare with '.'
BEQ LAB_2904 * branch if '.'
* code here for hex/binary/integer numbers
CMP.b #'$',d0 * compare with '$'
BEQ LAB_CHEX * branch if '$'
CMP.b #'%',d0 * else compare with '%'
BEQ LAB_CBIN * branch if '%'
BRA LAB_2Y01 * not #.$%& so return 0
LAB_28FD
BSR LAB_IGBY * get next character
BCC.s LAB_2902 * exit loop if not a digit
LAB_28FE
BSR d1x10 * multiply d1 by 10 and add character
BCC.s LAB_28FD * loop for more if no overflow
LAB_28FF
* overflowed mantissa, count 10s exponent
ADDQ.l #1,d3 * increment mantissa decimal exponent count
BSR LAB_IGBY * get next character
BCS.s LAB_28FF * loop while numeric character
* done overflow, now flush fraction or do E
CMP.b #'.',d0 * else compare with '.'
BNE.s LAB_2901 * branch if not '.'
LAB_2900
* flush remaining fraction digits
BSR LAB_IGBY * get next character
BCS LAB_2900 * loop while numeric character
LAB_2901
* done number, only (possible) exponent remains
CMP.b #'E',d0 * else compare with 'E'
BNE.s LAB_2Y01 * if not 'E' all done, go evaluate
* process exponent
BSR LAB_IGBY * get next character
BCS.s LAB_2X04 * branch if digit
CMP.b #'-',d0 * or is it -ve number
BEQ.s LAB_2X01 * branch if so
CMP.b #TK_MINUS,d0 * or is it -ve number
BNE.s LAB_2X02 * branch if not
LAB_2X01
MOVE.b #$FF,expneg(a3) * set exponent sign
BRA.s LAB_2X03 * now go scan & check exponent
LAB_2X02
CMP.b #'+',d0 * or is it +ve number
BEQ.s LAB_2X03 * branch if so
CMP.b #TK_PLUS,d0 * or is it +ve number
BNE LAB_SNER * wasn't - + TK_MINUS TK_PLUS or # so do error
LAB_2X03
BSR LAB_IGBY * get next character
BCC.s LAB_2Y01 * if not digit all done, go evaluate
LAB_2X04
MULU #10,d4 * multiply decimal exponent by 10
AND.l #$FF,d0 * mask character
SUB.b #'0',d0 * convert to value
ADD.l d0,d4 * add to decimal exponent
CMP.b #48,d4 * compare with decimal exponent limit+10
BLE.s LAB_2X03 * loop if no overflow/underflow
LAB_2X05
* exponent value has overflowed
BSR LAB_IGBY * get next character
BCS.s LAB_2X05 * loop while numeric digit
BRA.s LAB_2Y01 * all done, go evaluate
LAB_2902
CMP.b #'.',d0 * else compare with '.'
BEQ.s LAB_2904 * branch if was '.'
BRA.s LAB_2901 * branch if not '.' (go check/do 'E')
LAB_2903
SUBQ.l #1,d3 * decrement mantissa decimal exponent
LAB_2904
* was dp so get fraction part
BSR LAB_IGBY * get next character
BCC.s LAB_2901 * exit loop if not a digit (go check/do 'E')
BSR d1x10 * multiply d1 by 10 and add character
BCC.s LAB_2903 * loop for more if no overflow
BRA.s LAB_2900 * else go flush remaining fraction part
LAB_2Y01
* now evaluate result
TST.b expneg(a3) * test exponent sign
BPL.s LAB_2Y02 * branch if sign positive
NEG.l d4 * negate decimal exponent
LAB_2Y02
ADD.l d3,d4 * add mantissa decimal exponent
MOVEQ #32,d3 * set up max binary exponent
TST.l d1 * test mantissa
BEQ.s LAB_rtn0 * if mantissa=0 return 0
BMI.s LAB_2Y04 * branch if already mormalised
SUBQ.l #1,d3 * decrement bianry exponent for DBMI loop
LAB_2Y03
ADD.l d1,d1 * shift mantissa
DBMI d3,LAB_2Y03 * decrement & loop if not normalised
* ensure not too big or small
LAB_2Y04
CMP.l #38,d4 * compare decimal exponent with max exponent
BGT LAB_OFER * if greater do overflow error and warm start
CMP.l #-38,d4 * compare decimal exponent with min exponent
BLT.s LAB_ret0 * if less just return zero
NEG.l d4 * negate decimal exponent to go right way
MULS #6,d4 * 6 bytes per entry
MOVE.l a0,-(sp) * save register
LEA LAB_P_10(pc),a0 * point to table
MOVE.b (a0,d4.w),FAC2_e(a3) * copy exponent for multiply
MOVE.l 2(a0,d4.w),FAC2_m(a3) * copy table mantissa
MOVE.l (sp)+,a0 * restore register
EORI.b #$80,d3 * normalise input exponent
MOVE.l d1,FAC1_m(a3) * save input mantissa
MOVE.b d3,FAC1_e(a3) * save input exponent
MOVE.b FAC1_s(a3),FAC_sc(a3) * set sign as sign compare
MOVEM.l (sp)+,d1-d5 * restore registers
BRA LAB_MULTIPLY * go multiply input by table
LAB_ret0
MOVEQ #0,d1 * clear mantissa
LAB_rtn0
MOVE.l d1,d3 * clear exponent
MOVE.b d3,FAC1_e(a3) * save exponent
MOVE.l d1,FAC1_m(a3) * save mantissa
MOVEM.l (sp)+,d1-d5 * restore registers
RTS
*************************************************************************************
*
* $ for hex add-on
* gets here if the first character was "$" for hex
* get hex number
LAB_CHEX
MOVE.b #$40,Dtypef(a3) * set integer numeric data type
MOVEQ #32,d3 * set up max binary exponent
LAB_CHXX
BSR LAB_IGBY * increment & scan memory
BCS.s LAB_ISHN * branch if numeric character
OR.b #$20,d0 * case convert, allow "A" to "F" and "a" to "f"
SUB.b #'a',d0 * subtract "a"
BCS.s LAB_CHX3 * exit if <"a"
CMP.b #$06,d0 * compare normalised with $06 (max+1)
BCC.s LAB_CHX3 * exit if >"f"
ADD.b #$3A,d0 * convert to nibble+"0"
LAB_ISHN
BSR.s d1x16 * multiply d1 by 16 and add the character
BCC.s LAB_CHXX * loop for more if no overflow
* overflowed mantissa, count 16s exponent
LAB_CHX1
ADDQ.l #4,d3 * increment mantissa exponent count
BVS LAB_OFER * do overflow error if overflowed
BSR LAB_IGBY * get next character
BCS.s LAB_CHX1 * loop while numeric character
OR.b #$20,d0 * case convert, allow "A" to "F" and "a" to "f"
SUB.b #'a',d0 * subtract "a"
BCS.s LAB_CHX3 * exit if <"a"
CMP.b #$06,d0 * compare normalised with $06 (max+1)
BCS.s LAB_CHX1 * loop if <="f"
* now return value
LAB_CHX3
TST.l d1 * test mantissa
BEQ.s LAB_rtn0 * if mantissa=0 return 0
BMI.s LAB_exxf * branch if already mormalised
SUBQ.l #1,d3 * decrement bianry exponent for DBMI loop
LAB_CHX2
ADD.l d1,d1 * shift mantissa
DBMI d3,LAB_CHX2 * decrement & loop if not normalised
LAB_exxf
EORI.b #$80,d3 * normalise exponent
MOVE.b d3,FAC1_e(a3) * save exponent
MOVE.l d1,FAC1_m(a3) * save mantissa
MOVEM.l (sp)+,d1-d5 * restore registers
RTS_024
RTS
*************************************************************************************
*
* % for binary add-on
* gets here if the first character was "%" for binary
* get binary number
LAB_CBIN
MOVE.b #$40,Dtypef(a3) * set integer numeric data type
MOVEQ #32,d3 * set up max binary exponent
LAB_CBXN
BSR LAB_IGBY * increment & scan memory
BCC.s LAB_CHX3 * if not numeric character go return value
CMP.b #'2',d0 * compare with "2" (max+1)
BCC.s LAB_CHX3 * if >="2" go return value
MOVE.l d1,d2 * copy value
BSR.s d1x02 * multiply d1 by 2 and add character
BCC.s LAB_CBXN * loop for more if no overflow
* overflowed mantissa, count 2s exponent
LAB_CBX1
ADDQ.l #1,d3 * increment mantissa exponent count
BVS LAB_OFER * do overflow error if overflowed
BSR LAB_IGBY * get next character
BCC.s LAB_CHX3 * if not numeric character go return value
CMP.b #'2',d0 * compare with "2" (max+1)
BCS.s LAB_CBX1 * loop if <"2"
BRA.s LAB_CHX3 * if not numeric character go return value
* half way decent times 16 and times 2 with overflow checks
d1x16
MOVE.l d1,d2 * copy value
ADD.l d2,d2 * times two
BCS.s RTS_024 * return if overflow
ADD.l d2,d2 * times four
BCS.s RTS_024 * return if overflow
ADD.l d2,d2 * times eight
BCS.s RTS_024 * return if overflow
d1x02
ADD.l d2,d2 * times sixteen (ten/two)
BCS.s RTS_024 * return if overflow
* now add in new digit
AND.l #$FF,d0 * mask character
SUB.b #'0',d0 * convert to value
ADD.l d0,d2 * add to result
BCS.s RTS_024 * return if overflow, it should never ever do
* this
MOVE.l d2,d1 * copy result
RTS
* half way decent times 10 with overflow checks
d1x10
MOVE.l d1,d2 * copy value
ADD.l d2,d2 * times two
BCS.s RTS_025 * return if overflow
ADD.l d2,d2 * times four
BCS.s RTS_025 * return if overflow
ADD.l d1,d2 * times five
BCC.s d1x02 * do times two and add in new digit if ok
RTS_025
RTS
*************************************************************************************
*
* token values needed for BASIC
TK_END EQU $80 * $80
TK_FOR EQU TK_END+1 * $81
TK_NEXT EQU TK_FOR+1 * $82
TK_DATA EQU TK_NEXT+1 * $83
TK_INPUT EQU TK_DATA+1 * $84
TK_DIM EQU TK_INPUT+1 * $85
TK_READ EQU TK_DIM+1 * $86
TK_LET EQU TK_READ+1 * $87
TK_DEC EQU TK_LET+1 * $88
TK_GOTO EQU TK_DEC+1 * $89
TK_RUN EQU TK_GOTO+1 * $8A
TK_IF EQU TK_RUN+1 * $8B
TK_RESTORE EQU TK_IF+1 * $8C
TK_GOSUB EQU TK_RESTORE+1 * $8D
TK_RETURN EQU TK_GOSUB+1 * $8E
TK_REM EQU TK_RETURN+1 * $8F
TK_STOP EQU TK_REM+1 * $90
TK_ON EQU TK_STOP+1 * $91
TK_NULL EQU TK_ON+1 * $92
TK_INC EQU TK_NULL+1 * $93
TK_WAIT EQU TK_INC+1 * $94
TK_LOAD EQU TK_WAIT+1 * $95
TK_SAVE EQU TK_LOAD+1 * $96
TK_DEF EQU TK_SAVE+1 * $97
TK_POKE EQU TK_DEF+1 * $98
TK_DOKE EQU TK_POKE+1 * $99
TK_LOKE EQU TK_DOKE+1 * $9A
TK_CALL EQU TK_LOKE+1 * $9B
TK_DO EQU TK_CALL+1 * $9C
TK_LOOP EQU TK_DO+1 * $9D
TK_PRINT EQU TK_LOOP+1 * $9E
TK_CONT EQU TK_PRINT+1 * $9F
TK_LIST EQU TK_CONT+1 * $A0
TK_CLEAR EQU TK_LIST+1 * $A1
TK_NEW EQU TK_CLEAR+1 * $A2
TK_WIDTH EQU TK_NEW+1 * $A3
TK_GET EQU TK_WIDTH+1 * $A4
TK_SWAP EQU TK_GET+1 * $A5
TK_BITSET EQU TK_SWAP+1 * $A6
TK_BITCLR EQU TK_BITSET+1 * $A7
TK_TAB EQU TK_BITCLR+1 * $A8
TK_ELSE EQU TK_TAB+1 * $A9
TK_TO EQU TK_ELSE+1 * $AA
TK_FN EQU TK_TO+1 * $AB
TK_SPC EQU TK_FN+1 * $AC
TK_THEN EQU TK_SPC+1 * $AD
TK_NOT EQU TK_THEN+1 * $AE
TK_STEP EQU TK_NOT+1 * $AF
TK_UNTIL EQU TK_STEP+1 * $B0
TK_WHILE EQU TK_UNTIL+1 * $B1
TK_PLUS EQU TK_WHILE+1 * $B2
TK_MINUS EQU TK_PLUS+1 * $B3
TK_MULT EQU TK_MINUS+1 * $B4
TK_DIV EQU TK_MULT+1 * $B5
TK_POWER EQU TK_DIV+1 * $B6
TK_AND EQU TK_POWER+1 * $B7
TK_EOR EQU TK_AND+1 * $B8
TK_OR EQU TK_EOR+1 * $B9
TK_RSHIFT EQU TK_OR+1 * $BA
TK_LSHIFT EQU TK_RSHIFT+1 * $BB
TK_GT EQU TK_LSHIFT+1 * $BC
TK_EQUAL EQU TK_GT+1 * $BD
TK_LT EQU TK_EQUAL+1 * $BE
TK_SGN EQU TK_LT+1 * $BF
TK_INT EQU TK_SGN+1 * $C0
TK_ABS EQU TK_INT+1 * $C1
TK_USR EQU TK_ABS+1 * $C2
TK_FRE EQU TK_USR+1 * $C3
TK_POS EQU TK_FRE+1 * $C4
TK_SQR EQU TK_POS+1 * $C5
TK_RND EQU TK_SQR+1 * $C6
TK_LOG EQU TK_RND+1 * $C7
TK_EXP EQU TK_LOG+1 * $C8
TK_COS EQU TK_EXP+1 * $C9
TK_SIN EQU TK_COS+1 * $CA
TK_TAN EQU TK_SIN+1 * $CB
TK_ATN EQU TK_TAN+1 * $CC
TK_PEEK EQU TK_ATN+1 * $CD
TK_DEEK EQU TK_PEEK+1 * $CE
TK_LEEK EQU TK_DEEK+1 * $CF
TK_LEN EQU TK_LEEK+1 * $D0
TK_STRS EQU TK_LEN+1 * $D1
TK_VAL EQU TK_STRS+1 * $D2
TK_ASC EQU TK_VAL+1 * $D3
TK_UCASES EQU TK_ASC+1 * $D4
TK_LCASES EQU TK_UCASES+1 * $D5
TK_CHRS EQU TK_LCASES+1 * $D6
TK_HEXS EQU TK_CHRS+1 * $D7
TK_BINS EQU TK_HEXS+1 * $D8
TK_BITTST EQU TK_BINS+1 * $D9
TK_MAX EQU TK_BITTST+1 * $DA
TK_MIN EQU TK_MAX+1 * $DB
TK_RAM EQU TK_MIN+1 * $DC
TK_PI EQU TK_RAM+1 * $DD
TK_TWOPI EQU TK_PI+1 * $DE
TK_VPTR EQU TK_TWOPI+1 * $DF
TK_SADD EQU TK_VPTR+1 * $E0
TK_LEFTS EQU TK_SADD+1 * $E1
TK_RIGHTS EQU TK_LEFTS+1 * $E2
TK_MIDS EQU TK_RIGHTS+1 * $E3
TK_USINGS EQU TK_MIDS+1 * $E4
*************************************************************************************
*
* binary to unsigned decimal table
Bin2dec
dc.l $3B9ACA00 * 1000000000
dc.l $05F5E100 * 100000000
dc.l $00989680 * 10000000
dc.l $000F4240 * 1000000
dc.l $000186A0 * 100000
dc.l $00002710 * 10000
dc.l $000003E8 * 1000
dc.l $00000064 * 100
dc.l $0000000A * 10
dc.l $00000000 * 0 end marker
LAB_RSED
dc.l $332E3232 * 858665522
* string to value exponent table
dc.w 255<<8 * 10**38
dc.l $96769951
dc.w 251<<8 * 10**37
dc.l $F0BDC21B
dc.w 248<<8 * 10**36
dc.l $C097CE7C
dc.w 245<<8 * 10**35
dc.l $9A130B96
dc.w 241<<8 * 10**34
dc.l $F684DF57
dc.w 238<<8 * 10**33
dc.l $C5371912
dc.w 235<<8 * 10**32
dc.l $9DC5ADA8
dc.w 231<<8 * 10**31
dc.l $FC6F7C40
dc.w 228<<8 * 10**30
dc.l $C9F2C9CD
dc.w 225<<8 * 10**29
dc.l $A18F07D7
dc.w 222<<8 * 10**28
dc.l $813F3979
dc.w 218<<8 * 10**27
dc.l $CECB8F28
dc.w 215<<8 * 10**26
dc.l $A56FA5BA
dc.w 212<<8 * 10**25
dc.l $84595161
dc.w 208<<8 * 10**24
dc.l $D3C21BCF
dc.w 205<<8 * 10**23
dc.l $A968163F
dc.w 202<<8 * 10**22
dc.l $87867832
dc.w 198<<8 * 10**21
dc.l $D8D726B7
dc.w 195<<8 * 10**20
dc.l $AD78EBC6
dc.w 192<<8 * 10**19
dc.l $8AC72305
dc.w 188<<8 * 10**18
dc.l $DE0B6B3A
dc.w 185<<8 * 10**17
dc.l $B1A2BC2F
dc.w 182<<8 * 10**16
dc.l $8E1BC9BF
dc.w 178<<8 * 10**15
dc.l $E35FA932
dc.w 175<<8 * 10**14
dc.l $B5E620F5
dc.w 172<<8 * 10**13
dc.l $9184E72A
dc.w 168<<8 * 10**12
dc.l $E8D4A510
dc.w 165<<8 * 10**11
dc.l $BA43B740
dc.w 162<<8 * 10**10
dc.l $9502F900
dc.w 158<<8 * 10**9
dc.l $EE6B2800
dc.w 155<<8 * 10**8
dc.l $BEBC2000
dc.w 152<<8 * 10**7
dc.l $98968000
dc.w 148<<8 * 10**6
dc.l $F4240000
dc.w 145<<8 * 10**5
dc.l $C3500000
dc.w 142<<8 * 10**4
dc.l $9C400000
dc.w 138<<8 * 10**3
dc.l $FA000000
dc.w 135<<8 * 10**2
dc.l $C8000000
dc.w 132<<8 * 10**1
dc.l $A0000000
LAB_P_10
dc.w 129<<8 * 10**0
dc.l $80000000
dc.w 125<<8 * 10**-1
dc.l $CCCCCCCD
dc.w 122<<8 * 10**-2
dc.l $A3D70A3D
dc.w 119<<8 * 10**-3
dc.l $83126E98
dc.w 115<<8 * 10**-4
dc.l $D1B71759
dc.w 112<<8 * 10**-5
dc.l $A7C5AC47
dc.w 109<<8 * 10**-6
dc.l $8637BD06
dc.w 105<<8 * 10**-7
dc.l $D6BF94D6
dc.w 102<<8 * 10**-8
dc.l $ABCC7712
dc.w 99<<8 * 10**-9
dc.l $89705F41
dc.w 95<<8 * 10**-10
dc.l $DBE6FECF
dc.w 92<<8 * 10**-11
dc.l $AFEBFF0C
dc.w 89<<8 * 10**-12
dc.l $8CBCCC09
dc.w 85<<8 * 10**-13
dc.l $E12E1342
dc.w 82<<8 * 10**-14
dc.l $B424DC35
dc.w 79<<8 * 10**-15
dc.l $901D7CF7
dc.w 75<<8 * 10**-16
dc.l $E69594BF
dc.w 72<<8 * 10**-17
dc.l $B877AA32
dc.w 69<<8 * 10**-18
dc.l $9392EE8F
dc.w 65<<8 * 10**-19
dc.l $EC1E4A7E
dc.w 62<<8 * 10**-20
dc.l $BCE50865
dc.w 59<<8 * 10**-21
dc.l $971DA050
dc.w 55<<8 * 10**-22
dc.l $F1C90081
dc.w 52<<8 * 10**-23
dc.l $C16D9A01
dc.w 49<<8 * 10**-24
dc.l $9ABE14CD
dc.w 45<<8 * 10**-25
dc.l $F79687AE
dc.w 42<<8 * 10**-26
dc.l $C6120625
dc.w 39<<8 * 10**-27
dc.l $9E74D1B8
dc.w 35<<8 * 10**-28
dc.l $FD87B5F3
dc.w 32<<8 * 10**-29
dc.l $CAD2F7F5
dc.w 29<<8 * 10**-30
dc.l $A2425FF7
dc.w 26<<8 * 10**-31
dc.l $81CEB32C
dc.w 22<<8 * 10**-32
dc.l $CFB11EAD
dc.w 19<<8 * 10**-33
dc.l $A6274BBE
dc.w 16<<8 * 10**-34
dc.l $84EC3C98
dc.w 12<<8 * 10**-35
dc.l $D4AD2DC0
dc.w 9<<8 * 10**-36
dc.l $AA242499
dc.w 6<<8 * 10**-37
dc.l $881CEA14
dc.w 2<<8 * 10**-38
dc.l $D9C7DCED
*************************************************************************************
*
* table of constants for cordic SIN/COS/TAN calculations
* constants are un normalised fractions and are atn(2^-i)/2pi
dc.l $4DBA76D4 * SIN/COS multiply constant
TAB_SNCO
dc.l $20000000 * atn(2^0)/2pi
dc.l $12E4051E * atn(2^1)/2pi
dc.l $09FB385C * atn(2^2)/2pi
dc.l $051111D5 * atn(2^3)/2pi
dc.l $028B0D44 * atn(2^4)/2pi
dc.l $0145D7E2 * atn(2^5)/2pi
dc.l $00A2F61F * atn(2^6)/2pi
dc.l $00517C56 * atn(2^7)/2pi
dc.l $0028BE54 * atn(2^8)/2pi
dc.l $00145F2F * atn(2^9)/2pi
dc.l $000A2F99 * atn(2^10)/2pi
dc.l $000517CD * atn(2^11)/2pi
dc.l $00028BE7 * atn(2^12)/2pi
dc.l $000145F4 * atn(2^13)/2pi
dc.l $0000A2FA * atn(2^14)/2pi
dc.l $0000517D * atn(2^15)/2pi
dc.l $000028BF * atn(2^16)/2pi
dc.l $00001460 * atn(2^17)/2pi
dc.l $00000A30 * atn(2^18)/2pi
dc.l $00000518 * atn(2^19)/2pi
dc.l $0000028C * atn(2^20)/2pi
dc.l $00000146 * atn(2^21)/2pi
dc.l $000000A3 * atn(2^22)/2pi
dc.l $00000052 * atn(2^23)/2pi
dc.l $00000029 * atn(2^24)/2pi
dc.l $00000015 * atn(2^25)/2pi
dc.l $0000000B * atn(2^26)/2pi
dc.l $00000006 * atn(2^27)/2pi
dc.l $00000003 * atn(2^28)/2pi
dc.l $00000002 * atn(2^29)/2pi
dc.l $00000001 * atn(2^30)/2pi
dc.l $00000001 * atn(2^31)/2pi
*************************************************************************************
*
* table of constants for cordic ATN calculation
* constants are normalised to two integer bits and are atn(2^-i)
TAB_ATNC
dc.l $1DAC6705 * atn(2^-1)
dc.l $0FADBAFD * atn(2^-2)
dc.l $07F56EA7 * atn(2^-3)
dc.l $03FEAB77 * atn(2^-4)
dc.l $01FFD55C * atn(2^-5)
dc.l $00FFFAAB * atn(2^-6)
dc.l $007FFF55 * atn(2^-7)
dc.l $003FFFEB * atn(2^-8)
dc.l $001FFFFD * atn(2^-9)
dc.l $00100000 * atn(2^-10)
dc.l $00080000 * atn(2^-11)
dc.l $00040000 * atn(2^-12)
dc.l $00020000 * atn(2^-13)
dc.l $00010000 * atn(2^-14)
dc.l $00008000 * atn(2^-15)
dc.l $00004000 * atn(2^-16)
dc.l $00002000 * atn(2^-17)
dc.l $00001000 * atn(2^-18)
dc.l $00000800 * atn(2^-19)
dc.l $00000400 * atn(2^-20)
dc.l $00000200 * atn(2^-21)
dc.l $00000100 * atn(2^-22)
dc.l $00000080 * atn(2^-23)
dc.l $00000040 * atn(2^-24)
dc.l $00000020 * atn(2^-25)
dc.l $00000010 * atn(2^-26)
dc.l $00000008 * atn(2^-27)
dc.l $00000004 * atn(2^-28)
dc.l $00000002 * atn(2^-29)
dc.l $00000001 * atn(2^-30)
LAB_1D96
dc.l $00000000 * atn(2^-31)
dc.l $00000000 * atn(2^-32)
* constants are normalised to n integer bits and are tanh(2^-i)
n equ 2
TAB_HTHET
dc.l $2327d4f4 * atnh(2^-1) .549306144
dc.l $1058aefa * atnh(2^-2) .255412812
dc.l $080ac48e * atnh(2^-3)
dc.l $04015622 * atnh(2^-4)
dc.l $02002ab0 * atnh(2^-5)
dc.l $01000554 * atnh(2^-6)
dc.l $008000aa * atnh(2^-7)
dc.l $00400014 * atnh(2^-8)
dc.l $00200002 * atnh(2^-9)
dc.l $00100000 * atnh(2^-10)
dc.l $00080000 * atnh(2^-11)
dc.l $00040000 * atnh(2^-12)
dc.l $00020000 * atnh(2^-13)
dc.l $00010000 * atnh(2^-14)
dc.l $00008000 * atnh(2^-15)
dc.l $00004000 * atnh(2^-16)
dc.l $00002000 * atnh(2^-17)
dc.l $00001000 * atnh(2^-18)
dc.l $00000800 * atnh(2^-19)
dc.l $00000400 * atnh(2^-20)
dc.l $00000200 * atnh(2^-21)
dc.l $00000100 * atnh(2^-22)
dc.l $00000080 * atnh(2^-23)
dc.l $00000040 * atnh(2^-24)
dc.l $00000020 * atnh(2^-25)
dc.l $00000010 * atnh(2^-26)
dc.l $00000008 * atnh(2^-27)
dc.l $00000004 * atnh(2^-28)
dc.l $00000002 * atnh(2^-29)
dc.l $00000001 * atnh(2^-30)
dc.l $00000000 * atnh(2^-31)
dc.l $00000000 * atnh(2^-32)
KFCTSEED equ $26A3D110 * $26A3D110
*************************************************************************************
*
* command vector table
LAB_CTBL
dc.w LAB_END-LAB_CTBL * END
dc.w LAB_FOR-LAB_CTBL * FOR
dc.w LAB_NEXT-LAB_CTBL * NEXT
dc.w LAB_DATA-LAB_CTBL * DATA
dc.w LAB_INPUT-LAB_CTBL * INPUT
dc.w LAB_DIM-LAB_CTBL * DIM
dc.w LAB_READ-LAB_CTBL * READ
dc.w LAB_LET-LAB_CTBL * LET
dc.w LAB_DEC-LAB_CTBL * DEC
dc.w LAB_GOTO-LAB_CTBL * GOTO
dc.w LAB_RUN-LAB_CTBL * RUN
dc.w LAB_IF-LAB_CTBL * IF
dc.w LAB_RESTORE-LAB_CTBL * RESTORE
dc.w LAB_GOSUB-LAB_CTBL * GOSUB
dc.w LAB_RETURN-LAB_CTBL * RETURN
dc.w LAB_REM-LAB_CTBL * REM
dc.w LAB_STOP-LAB_CTBL * STOP
dc.w LAB_ON-LAB_CTBL * ON
dc.w LAB_NULL-LAB_CTBL * NULL
dc.w LAB_INC-LAB_CTBL * INC
dc.w LAB_WAIT-LAB_CTBL * WAIT
dc.w LAB_LOAD-LAB_CTBL * LOAD
dc.w LAB_SAVE-LAB_CTBL * SAVE
dc.w LAB_DEF-LAB_CTBL * DEF
dc.w LAB_POKE-LAB_CTBL * POKE
dc.w LAB_DOKE-LAB_CTBL * DOKE
dc.w LAB_LOKE-LAB_CTBL * LOKE
dc.w LAB_CALL-LAB_CTBL * CALL
dc.w LAB_DO-LAB_CTBL * DO
dc.w LAB_LOOP-LAB_CTBL * LOOP
dc.w LAB_PRINT-LAB_CTBL * PRINT
dc.w LAB_CONT-LAB_CTBL * CONT
dc.w LAB_LIST-LAB_CTBL * LIST
dc.w LAB_CLEAR-LAB_CTBL * CLEAR
dc.w LAB_NEW-LAB_CTBL * NEW
dc.w LAB_WDTH-LAB_CTBL * WIDTH
dc.w LAB_GET-LAB_CTBL * GET
dc.w LAB_SWAP-LAB_CTBL * SWAP
dc.w LAB_BITSET-LAB_CTBL * BITSET
dc.w LAB_BITCLR-LAB_CTBL * BITCLR
*************************************************************************************
*
* function pre process routine table
LAB_FTPP
dc.w LAB_PPFN-LAB_FTPP * SGN(n) process numeric expression in ()
dc.w LAB_PPFN-LAB_FTPP * INT(n) "
dc.w LAB_PPFN-LAB_FTPP * ABS(n) "
dc.w LAB_EVEZ-LAB_FTPP * USR(x) process any expression
dc.w LAB_1BF7-LAB_FTPP * FRE(x) process any expression in ()
dc.w LAB_1BF7-LAB_FTPP * POS(x) "
dc.w LAB_PPFN-LAB_FTPP * SQR(n) process numeric expression in ()
dc.w LAB_PPFN-LAB_FTPP * RND(n) "
dc.w LAB_PPFN-LAB_FTPP * LOG(n) "
dc.w LAB_PPFN-LAB_FTPP * EXP(n) "
dc.w LAB_PPFN-LAB_FTPP * COS(n) "
dc.w LAB_PPFN-LAB_FTPP * SIN(n) "
dc.w LAB_PPFN-LAB_FTPP * TAN(n) "
dc.w LAB_PPFN-LAB_FTPP * ATN(n) "
dc.w LAB_PPFN-LAB_FTPP * PEEK(n) "
dc.w LAB_PPFN-LAB_FTPP * DEEK(n) "
dc.w LAB_PPFN-LAB_FTPP * LEEK(n) "
dc.w LAB_PPFS-LAB_FTPP * LEN($) process string expression in ()
dc.w LAB_PPFN-LAB_FTPP * STR$(n) process numeric expression in ()
dc.w LAB_PPFS-LAB_FTPP * VAL($) process string expression in ()
dc.w LAB_PPFS-LAB_FTPP * ASC($) "
dc.w LAB_PPFS-LAB_FTPP * UCASE$($) "
dc.w LAB_PPFS-LAB_FTPP * LCASE$($) "
dc.w LAB_PPFN-LAB_FTPP * CHR$(n) process numeric expression in ()
dc.w LAB_BHSS-LAB_FTPP * HEX$() bin/hex pre process
dc.w LAB_BHSS-LAB_FTPP * BIN$() "
dc.w $0000 * BITTST() none
dc.w $0000 * MAX() "
dc.w $0000 * MIN() "
dc.w LAB_PPBI-LAB_FTPP * RAMBASE advance pointer
dc.w LAB_PPBI-LAB_FTPP * PI "
dc.w LAB_PPBI-LAB_FTPP * TWOPI "
dc.w $0000 * VARPTR() none
dc.w $0000 * SADD() "
dc.w LAB_LRMS-LAB_FTPP * LEFT$() process string expression
dc.w LAB_LRMS-LAB_FTPP * RIGHT$() "
dc.w LAB_LRMS-LAB_FTPP * MID$() "
dc.w LAB_EVEZ-LAB_FTPP * USING$(x) process any expression
*************************************************************************************
*
* action addresses for functions
LAB_FTBL
dc.w LAB_SGN-LAB_FTBL * SGN()
dc.w LAB_INT-LAB_FTBL * INT()
dc.w LAB_ABS-LAB_FTBL * ABS()
dc.w LAB_USR-LAB_FTBL * USR()
dc.w LAB_FRE-LAB_FTBL * FRE()
dc.w LAB_POS-LAB_FTBL * POS()
dc.w LAB_SQR-LAB_FTBL * SQR()
dc.w LAB_RND-LAB_FTBL * RND()
dc.w LAB_LOG-LAB_FTBL * LOG()
dc.w LAB_EXP-LAB_FTBL * EXP()
dc.w LAB_COS-LAB_FTBL * COS()
dc.w LAB_SIN-LAB_FTBL * SIN()
dc.w LAB_TAN-LAB_FTBL * TAN()
dc.w LAB_ATN-LAB_FTBL * ATN()
dc.w LAB_PEEK-LAB_FTBL * PEEK()
dc.w LAB_DEEK-LAB_FTBL * DEEK()
dc.w LAB_LEEK-LAB_FTBL * LEEK()
dc.w LAB_LENS-LAB_FTBL * LEN()
dc.w LAB_STRS-LAB_FTBL * STR$()
dc.w LAB_VAL-LAB_FTBL * VAL()
dc.w LAB_ASC-LAB_FTBL * ASC()
dc.w LAB_UCASE-LAB_FTBL * UCASE$()
dc.w LAB_LCASE-LAB_FTBL * LCASE$()
dc.w LAB_CHRS-LAB_FTBL * CHR$()
dc.w LAB_HEXS-LAB_FTBL * HEX$()
dc.w LAB_BINS-LAB_FTBL * BIN$()
dc.w LAB_BTST-LAB_FTBL * BITTST()
dc.w LAB_MAX-LAB_FTBL * MAX()
dc.w LAB_MIN-LAB_FTBL * MIN()
dc.w LAB_RAM-LAB_FTBL * RAMBASE
dc.w LAB_PI-LAB_FTBL * PI
dc.w LAB_TWOPI-LAB_FTBL * TWOPI
dc.w LAB_VARPTR-LAB_FTBL * VARPTR()
dc.w LAB_SADD-LAB_FTBL * SADD()
dc.w LAB_LEFT-LAB_FTBL * LEFT$()
dc.w LAB_RIGHT-LAB_FTBL * RIGHT$()
dc.w LAB_MIDS-LAB_FTBL * MID$()
dc.w LAB_USINGS-LAB_FTBL * USING$()
*************************************************************************************
*
* hierarchy and action addresses for operator
LAB_OPPT
dc.w $0079 * +
dc.w LAB_ADD-LAB_OPPT
dc.w $0079 * -
dc.w LAB_SUBTRACT-LAB_OPPT
dc.w $007B * *
dc.w LAB_MULTIPLY-LAB_OPPT
dc.w $007B * /
dc.w LAB_DIVIDE-LAB_OPPT
dc.w $007F * ^
dc.w LAB_POWER-LAB_OPPT
dc.w $0050 * AND
dc.w LAB_AND-LAB_OPPT
dc.w $0046 * EOR
dc.w LAB_EOR-LAB_OPPT
dc.w $0046 * OR
dc.w LAB_OR-LAB_OPPT
dc.w $0056 * >>
dc.w LAB_RSHIFT-LAB_OPPT
dc.w $0056 * <<
dc.w LAB_LSHIFT-LAB_OPPT
dc.w $007D * >
dc.w LAB_GTHAN-LAB_OPPT * used to evaluate -n
dc.w $005A * =
dc.w LAB_EQUAL-LAB_OPPT * used to evaluate NOT
dc.w $0064 * <
dc.w LAB_LTHAN-LAB_OPPT
*************************************************************************************
*
* misc constants
* This table is used in converting numbers to ASCII.
* first four entries for expansion to 9.25 digits
LAB_2A9A
dc.l $FFF0BDC0 * -1000000
dc.l $000186A0 * 100000
dc.l $FFFFD8F0 * -10000
dc.l $000003E8 * 1000
dc.l $FFFFFF9C * -100
dc.l $0000000A * 10
dc.l $FFFFFFFF * -1
LAB_2A9B
*************************************************************************************
*
* new keyword tables
* offsets to keyword tables
TAB_CHRT
dc.w TAB_STAR-TAB_STAR * "*" $2A
dc.w TAB_PLUS-TAB_STAR * "+" $2B
dc.w -1 * "," $2C no keywords
dc.w TAB_MNUS-TAB_STAR * "-" $2D
dc.w -1 * "." $2E no keywords
dc.w TAB_SLAS-TAB_STAR * "/" $2F
dc.w -1 * "0" $30 no keywords
dc.w -1 * "1" $31 no keywords
dc.w -1 * "2" $32 no keywords
dc.w -1 * "3" $33 no keywords
dc.w -1 * "4" $34 no keywords
dc.w -1 * "5" $35 no keywords
dc.w -1 * "6" $36 no keywords
dc.w -1 * "7" $37 no keywords
dc.w -1 * "8" $38 no keywords
dc.w -1 * "9" $39 no keywords
dc.w -1 * ";" $3A no keywords
dc.w -1 * ":" $3B no keywords
dc.w TAB_LESS-TAB_STAR * "<" $3C
dc.w TAB_EQUL-TAB_STAR * "=" $3D
dc.w TAB_MORE-TAB_STAR * ">" $3E
dc.w TAB_QEST-TAB_STAR * "?" $3F
dc.w -1 * "@" $40 no keywords
dc.w TAB_ASCA-TAB_STAR * "A" $41
dc.w TAB_ASCB-TAB_STAR * "B" $42
dc.w TAB_ASCC-TAB_STAR * "C" $43
dc.w TAB_ASCD-TAB_STAR * "D" $44
dc.w TAB_ASCE-TAB_STAR * "E" $45
dc.w TAB_ASCF-TAB_STAR * "F" $46
dc.w TAB_ASCG-TAB_STAR * "G" $47
dc.w TAB_ASCH-TAB_STAR * "H" $48
dc.w TAB_ASCI-TAB_STAR * "I" $49
dc.w -1 * "J" $4A no keywords
dc.w -1 * "K" $4B no keywords
dc.w TAB_ASCL-TAB_STAR * "L" $4C
dc.w TAB_ASCM-TAB_STAR * "M" $4D
dc.w TAB_ASCN-TAB_STAR * "N" $4E
dc.w TAB_ASCO-TAB_STAR * "O" $4F
dc.w TAB_ASCP-TAB_STAR * "P" $50
dc.w -1 * "Q" $51 no keywords
dc.w TAB_ASCR-TAB_STAR * "R" $52
dc.w TAB_ASCS-TAB_STAR * "S" $53
dc.w TAB_ASCT-TAB_STAR * "T" $54
dc.w TAB_ASCU-TAB_STAR * "U" $55
dc.w TAB_ASCV-TAB_STAR * "V" $56
dc.w TAB_ASCW-TAB_STAR * "W" $57
dc.w -1 * "X" $58 no keywords
dc.w -1 * "Y" $59 no keywords
dc.w -1 * "Z" $5A no keywords
dc.w -1 * "[" $5B no keywords
dc.w -1 * "\" $5C no keywords
dc.w -1 * "]" $5D no keywords
dc.w TAB_POWR-TAB_STAR * "^" $5E
*************************************************************************************
*
* Table of Basic keywords for LIST command
* [byte]first character,[byte]remaining length -1
* [word]offset from table start
LAB_KEYT
dc.b 'E',1
dc.w KEY_END-TAB_STAR * END
dc.b 'F',1
dc.w KEY_FOR-TAB_STAR * FOR
dc.b 'N',2
dc.w KEY_NEXT-TAB_STAR * NEXT
dc.b 'D',2
dc.w KEY_DATA-TAB_STAR * DATA
dc.b 'I',3
dc.w KEY_INPUT-TAB_STAR * INPUT
dc.b 'D',1
dc.w KEY_DIM-TAB_STAR * DIM
dc.b 'R',2
dc.w KEY_READ-TAB_STAR * READ
dc.b 'L',1
dc.w KEY_LET-TAB_STAR * LET
dc.b 'D',1
dc.w KEY_DEC-TAB_STAR * DEC
dc.b 'G',2
dc.w KEY_GOTO-TAB_STAR * GOTO
dc.b 'R',1
dc.w KEY_RUN-TAB_STAR * RUN
dc.b 'I',0
dc.w KEY_IF-TAB_STAR * IF
dc.b 'R',5
dc.w KEY_RESTORE-TAB_STAR * RESTORE
dc.b 'G',3
dc.w KEY_GOSUB-TAB_STAR * GOSUB
dc.b 'R',4
dc.w KEY_RETURN-TAB_STAR * RETURN
dc.b 'R',1
dc.w KEY_REM-TAB_STAR * REM
dc.b 'S',2
dc.w KEY_STOP-TAB_STAR * STOP
dc.b 'O',0
dc.w KEY_ON-TAB_STAR * ON
dc.b 'N',2
dc.w KEY_NULL-TAB_STAR * NULL
dc.b 'I',1
dc.w KEY_INC-TAB_STAR * INC
dc.b 'W',2
dc.w KEY_WAIT-TAB_STAR * WAIT
dc.b 'L',2
dc.w KEY_LOAD-TAB_STAR * LOAD
dc.b 'S',2
dc.w KEY_SAVE-TAB_STAR * SAVE
dc.b 'D',1
dc.w KEY_DEF-TAB_STAR * DEF
dc.b 'P',2
dc.w KEY_POKE-TAB_STAR * POKE
dc.b 'D',2
dc.w KEY_DOKE-TAB_STAR * DOKE
dc.b 'L',2
dc.w KEY_LOKE-TAB_STAR * LOKE
dc.b 'C',2
dc.w KEY_CALL-TAB_STAR * CALL
dc.b 'D',0
dc.w KEY_DO-TAB_STAR * DO
dc.b 'L',2
dc.w KEY_LOOP-TAB_STAR * LOOP
dc.b 'P',3
dc.w KEY_PRINT-TAB_STAR * PRINT
dc.b 'C',2
dc.w KEY_CONT-TAB_STAR * CONT
dc.b 'L',2
dc.w KEY_LIST-TAB_STAR * LIST
dc.b 'C',3
dc.w KEY_CLEAR-TAB_STAR * CLEAR
dc.b 'N',1
dc.w KEY_NEW-TAB_STAR * NEW
dc.b 'W',3
dc.w KEY_WIDTH-TAB_STAR * WIDTH
dc.b 'G',1
dc.w KEY_GET-TAB_STAR * GET
dc.b 'S',2
dc.w KEY_SWAP-TAB_STAR * SWAP
dc.b 'B',4
dc.w KEY_BITSET-TAB_STAR * BITSET
dc.b 'B',4
dc.w KEY_BITCLR-TAB_STAR * BITCLR
dc.b 'T',2
dc.w KEY_TAB-TAB_STAR * TAB(
dc.b 'E',2
dc.w KEY_ELSE-TAB_STAR * ELSE
dc.b 'T',0
dc.w KEY_TO-TAB_STAR * TO
dc.b 'F',0
dc.w KEY_FN-TAB_STAR * FN
dc.b 'S',2
dc.w KEY_SPC-TAB_STAR * SPC(
dc.b 'T',2
dc.w KEY_THEN-TAB_STAR * THEN
dc.b 'N',1
dc.w KEY_NOT-TAB_STAR * NOT
dc.b 'S',2
dc.w KEY_STEP-TAB_STAR * STEP
dc.b 'U',3
dc.w KEY_UNTIL-TAB_STAR * UNTIL
dc.b 'W',3
dc.w KEY_WHILE-TAB_STAR * WHILE
dc.b '+',-1
dc.w KEY_PLUS-TAB_STAR * +
dc.b '-',-1
dc.w KEY_MINUS-TAB_STAR * -
dc.b '*',-1
dc.w KEY_MULT-TAB_STAR * *
dc.b '/',-1
dc.w KEY_DIV-TAB_STAR * /
dc.b '^',-1
dc.w KEY_POWER-TAB_STAR * ^
dc.b 'A',1
dc.w KEY_AND-TAB_STAR * AND
dc.b 'E',1
dc.w KEY_EOR-TAB_STAR * EOR
dc.b 'O',0
dc.w KEY_OR-TAB_STAR * OR
dc.b '>',0
dc.w KEY_RSHIFT-TAB_STAR * >>
dc.b '<',0
dc.w KEY_LSHIFT-TAB_STAR * <<
dc.b '>',-1
dc.w KEY_GT-TAB_STAR * >
dc.b '=',-1
dc.w KEY_EQUAL-TAB_STAR * =
dc.b '<',-1
dc.w KEY_LT-TAB_STAR * <
dc.b 'S',2
dc.w KEY_SGN-TAB_STAR * SGN(
dc.b 'I',2
dc.w KEY_INT-TAB_STAR * INT(
dc.b 'A',2
dc.w KEY_ABS-TAB_STAR * ABS(
dc.b 'U',2
dc.w KEY_USR-TAB_STAR * USR(
dc.b 'F',2
dc.w KEY_FRE-TAB_STAR * FRE(
dc.b 'P',2
dc.w KEY_POS-TAB_STAR * POS(
dc.b 'S',2
dc.w KEY_SQR-TAB_STAR * SQR(
dc.b 'R',2
dc.w KEY_RND-TAB_STAR * RND(
dc.b 'L',2
dc.w KEY_LOG-TAB_STAR * LOG(
dc.b 'E',2
dc.w KEY_EXP-TAB_STAR * EXP(
dc.b 'C',2
dc.w KEY_COS-TAB_STAR * COS(
dc.b 'S',2
dc.w KEY_SIN-TAB_STAR * SIN(
dc.b 'T',2
dc.w KEY_TAN-TAB_STAR * TAN(
dc.b 'A',2
dc.w KEY_ATN-TAB_STAR * ATN(
dc.b 'P',3
dc.w KEY_PEEK-TAB_STAR * PEEK(
dc.b 'D',3
dc.w KEY_DEEK-TAB_STAR * DEEK(
dc.b 'L',3
dc.w KEY_LEEK-TAB_STAR * LEEK(
dc.b 'L',2
dc.w KEY_LEN-TAB_STAR * LEN(
dc.b 'S',3
dc.w KEY_STRS-TAB_STAR * STR$(
dc.b 'V',2
dc.w KEY_VAL-TAB_STAR * VAL(
dc.b 'A',2
dc.w KEY_ASC-TAB_STAR * ASC(
dc.b 'U',5
dc.w KEY_UCASES-TAB_STAR * UCASE$(
dc.b 'L',5
dc.w KEY_LCASES-TAB_STAR * LCASE$(
dc.b 'C',3
dc.w KEY_CHRS-TAB_STAR * CHR$(
dc.b 'H',3
dc.w KEY_HEXS-TAB_STAR * HEX$(
dc.b 'B',3
dc.w KEY_BINS-TAB_STAR * BIN$(
dc.b 'B',5
dc.w KEY_BITTST-TAB_STAR * BITTST(
dc.b 'M',2
dc.w KEY_MAX-TAB_STAR * MAX(
dc.b 'M',2
dc.w KEY_MIN-TAB_STAR * MIN(
dc.b 'R',5
dc.w KEY_RAM-TAB_STAR * RAMBASE
dc.b 'P',0
dc.w KEY_PI-TAB_STAR * PI
dc.b 'T',3
dc.w KEY_TWOPI-TAB_STAR * TWOPI
dc.b 'V',5
dc.w KEY_VPTR-TAB_STAR * VARPTR(
dc.b 'S',3
dc.w KEY_SADD-TAB_STAR * SADD(
dc.b 'L',4
dc.w KEY_LEFTS-TAB_STAR * LEFT$(
dc.b 'R',5
dc.w KEY_RIGHTS-TAB_STAR * RIGHT$(
dc.b 'M',3
dc.w KEY_MIDS-TAB_STAR * MID$(
dc.b 'U',5
dc.w KEY_USINGS-TAB_STAR * USING$(
*************************************************************************************
*
* BASIC error messages
LAB_BAER
dc.w LAB_NF-LAB_BAER * $00 NEXT without FOR
dc.w LAB_SN-LAB_BAER * $02 syntax
dc.w LAB_RG-LAB_BAER * $04 RETURN without GOSUB
dc.w LAB_OD-LAB_BAER * $06 out of data
dc.w LAB_FC-LAB_BAER * $08 function call
dc.w LAB_OV-LAB_BAER * $0A overflow
dc.w LAB_OM-LAB_BAER * $0C out of memory
dc.w LAB_US-LAB_BAER * $0E undefined statement
dc.w LAB_BS-LAB_BAER * $10 array bounds
dc.w LAB_DD-LAB_BAER * $12 double dimension array
dc.w LAB_D0-LAB_BAER * $14 divide by 0
dc.w LAB_ID-LAB_BAER * $16 illegal direct
dc.w LAB_TM-LAB_BAER * $18 type mismatch
dc.w LAB_LS-LAB_BAER * $1A long string
dc.w LAB_ST-LAB_BAER * $1C string too complex
dc.w LAB_CN-LAB_BAER * $1E continue error
dc.w LAB_UF-LAB_BAER * $20 undefined function
dc.w LAB_LD-LAB_BAER * $22 LOOP without DO
dc.w LAB_UV-LAB_BAER * $24 undefined variable
dc.w LAB_UA-LAB_BAER * $26 undimensioned array
dc.w LAB_WD-LAB_BAER * $28 wrong dimensions
dc.w LAB_AD-LAB_BAER * $2A address
dc.w LAB_FO-LAB_BAER * $2C format
dc.w LAB_NI-LAB_BAER * $2E not implemented
LAB_NF dc.b 'NEXT without FOR',$00
LAB_SN dc.b 'Syntax',$00
LAB_RG dc.b 'RETURN without GOSUB',$00
LAB_OD dc.b 'Out of DATA',$00
LAB_FC dc.b 'Function call',$00
LAB_OV dc.b 'Overflow',$00
LAB_OM dc.b 'Out of memory',$00
LAB_US dc.b 'Undefined statement',$00
LAB_BS dc.b 'Array bounds',$00
LAB_DD dc.b 'Double dimension',$00
LAB_D0 dc.b 'Divide by zero',$00
LAB_ID dc.b 'Illegal direct',$00
LAB_TM dc.b 'Type mismatch',$00
LAB_LS dc.b 'String too long',$00
LAB_ST dc.b 'String too complex',$00
LAB_CN dc.b 'Can''t continue',$00
LAB_UF dc.b 'Undefined function',$00
LAB_LD dc.b 'LOOP without DO',$00
LAB_UV dc.b 'Undefined variable',$00
LAB_UA dc.b 'Undimensioned array',$00
LAB_WD dc.b 'Wrong dimensions',$00
LAB_AD dc.b 'Address',$00
LAB_FO dc.b 'Format',$00
LAB_NI dc.b 'Not implemented',$00
*************************************************************************************
*
* keyword table for line (un)crunching
* [keyword,token
* [keyword,token]]
* end marker (#$00)
TAB_STAR
KEY_MULT
dc.b TK_MULT,$00 * *
TAB_PLUS
KEY_PLUS
dc.b TK_PLUS,$00 * +
TAB_MNUS
KEY_MINUS
dc.b TK_MINUS,$00 * -
TAB_SLAS
KEY_DIV
dc.b TK_DIV,$00 * /
TAB_LESS
KEY_LSHIFT
dc.b '<',TK_LSHIFT * <<
KEY_LT
dc.b TK_LT * <
dc.b $00
TAB_EQUL
KEY_EQUAL
dc.b TK_EQUAL,$00 * =
TAB_MORE
KEY_RSHIFT
dc.b '>',TK_RSHIFT * >>
KEY_GT
dc.b TK_GT * >
dc.b $00
TAB_QEST
dc.b TK_PRINT,$00 * ?
TAB_ASCA
KEY_ABS
dc.b 'BS(',TK_ABS * ABS(
KEY_AND
dc.b 'ND',TK_AND * AND
KEY_ASC
dc.b 'SC(',TK_ASC * ASC(
KEY_ATN
dc.b 'TN(',TK_ATN * ATN(
dc.b $00
TAB_ASCB
KEY_BINS
dc.b 'IN$(',TK_BINS * BIN$(
KEY_BITCLR
dc.b 'ITCLR',TK_BITCLR * BITCLR
KEY_BITSET
dc.b 'ITSET',TK_BITSET * BITSET
KEY_BITTST
dc.b 'ITTST(',TK_BITTST * BITTST(
dc.b $00
TAB_ASCC
KEY_CALL
dc.b 'ALL',TK_CALL * CALL
KEY_CHRS
dc.b 'HR$(',TK_CHRS * CHR$(
KEY_CLEAR
dc.b 'LEAR',TK_CLEAR * CLEAR
KEY_CONT
dc.b 'ONT',TK_CONT * CONT
KEY_COS
dc.b 'OS(',TK_COS * COS(
dc.b $00
TAB_ASCD
KEY_DATA
dc.b 'ATA',TK_DATA * DATA
KEY_DEC
dc.b 'EC',TK_DEC * DEC
KEY_DEEK
dc.b 'EEK(',TK_DEEK * DEEK(
KEY_DEF
dc.b 'EF',TK_DEF * DEF
KEY_DIM
dc.b 'IM',TK_DIM * DIM
KEY_DOKE
dc.b 'OKE',TK_DOKE * DOKE
KEY_DO
dc.b 'O',TK_DO * DO
dc.b $00
TAB_ASCE
KEY_ELSE
dc.b 'LSE',TK_ELSE * ELSE
KEY_END
dc.b 'ND',TK_END * END
KEY_EOR
dc.b 'OR',TK_EOR * EOR
KEY_EXP
dc.b 'XP(',TK_EXP * EXP(
dc.b $00
TAB_ASCF
KEY_FOR
dc.b 'OR',TK_FOR * FOR
KEY_FN
dc.b 'N',TK_FN * FN
KEY_FRE
dc.b 'RE(',TK_FRE * FRE(
dc.b $00
TAB_ASCG
KEY_GET
dc.b 'ET',TK_GET * GET
KEY_GOTO
dc.b 'OTO',TK_GOTO * GOTO
KEY_GOSUB
dc.b 'OSUB',TK_GOSUB * GOSUB
dc.b $00
TAB_ASCH
KEY_HEXS
dc.b 'EX$(',TK_HEXS,$00 * HEX$(
TAB_ASCI
KEY_IF
dc.b 'F',TK_IF * IF
KEY_INC
dc.b 'NC',TK_INC * INC
KEY_INPUT
dc.b 'NPUT',TK_INPUT * INPUT
KEY_INT
dc.b 'NT(',TK_INT * INT(
dc.b $00
TAB_ASCL
KEY_LCASES
dc.b 'CASE$(',TK_LCASES * LCASE$(
KEY_LEEK
dc.b 'EEK(',TK_LEEK * LEEK(
KEY_LEFTS
dc.b 'EFT$(',TK_LEFTS * LEFT$(
KEY_LEN
dc.b 'EN(',TK_LEN * LEN(
KEY_LET
dc.b 'ET',TK_LET * LET
KEY_LIST
dc.b 'IST',TK_LIST * LIST
KEY_LOAD
dc.b 'OAD',TK_LOAD * LOAD
KEY_LOG
dc.b 'OG(',TK_LOG * LOG(
KEY_LOKE
dc.b 'OKE',TK_LOKE * LOKE
KEY_LOOP
dc.b 'OOP',TK_LOOP * LOOP
dc.b $00
TAB_ASCM
KEY_MAX
dc.b 'AX(',TK_MAX * MAX(
KEY_MIDS
dc.b 'ID$(',TK_MIDS * MID$(
KEY_MIN
dc.b 'IN(',TK_MIN * MIN(
dc.b $00
TAB_ASCN
KEY_NEW
dc.b 'EW',TK_NEW * NEW
KEY_NEXT
dc.b 'EXT',TK_NEXT * NEXT
KEY_NOT
dc.b 'OT',TK_NOT * NOT
KEY_NULL
dc.b 'ULL',TK_NULL * NULL
dc.b $00
TAB_ASCO
KEY_ON
dc.b 'N',TK_ON * ON
KEY_OR
dc.b 'R',TK_OR * OR
dc.b $00
TAB_ASCP
KEY_PEEK
dc.b 'EEK(',TK_PEEK * PEEK(
KEY_PI
dc.b 'I',TK_PI * PI
KEY_POKE
dc.b 'OKE',TK_POKE * POKE
KEY_POS
dc.b 'OS(',TK_POS * POS(
KEY_PRINT
dc.b 'RINT',TK_PRINT * PRINT
dc.b $00
TAB_ASCR
KEY_RAM
dc.b 'AMBASE',TK_RAM * RAMBASE
KEY_READ
dc.b 'EAD',TK_READ * READ
KEY_REM
dc.b 'EM',TK_REM * REM
KEY_RESTORE
dc.b 'ESTORE',TK_RESTORE * RESTORE
KEY_RETURN
dc.b 'ETURN',TK_RETURN * RETURN
KEY_RIGHTS
dc.b 'IGHT$(',TK_RIGHTS * RIGHT$(
KEY_RND
dc.b 'ND(',TK_RND * RND(
KEY_RUN
dc.b 'UN',TK_RUN * RUN
dc.b $00
TAB_ASCS
KEY_SADD
dc.b 'ADD(',TK_SADD * SADD(
KEY_SAVE
dc.b 'AVE',TK_SAVE * SAVE
KEY_SGN
dc.b 'GN(',TK_SGN * SGN(
KEY_SIN
dc.b 'IN(',TK_SIN * SIN(
KEY_SPC
dc.b 'PC(',TK_SPC * SPC(
KEY_SQR
dc.b 'QR(',TK_SQR * SQR(
KEY_STEP
dc.b 'TEP',TK_STEP * STEP
KEY_STOP
dc.b 'TOP',TK_STOP * STOP
KEY_STRS
dc.b 'TR$(',TK_STRS * STR$(
KEY_SWAP
dc.b 'WAP',TK_SWAP * SWAP
dc.b $00
TAB_ASCT
KEY_TAB
dc.b 'AB(',TK_TAB * TAB(
KEY_TAN
dc.b 'AN(',TK_TAN * TAN
KEY_THEN
dc.b 'HEN',TK_THEN * THEN
KEY_TO
dc.b 'O',TK_TO * TO
KEY_TWOPI
dc.b 'WOPI',TK_TWOPI * TWOPI
dc.b $00
TAB_ASCU
KEY_UCASES
dc.b 'CASE$(',TK_UCASES * UCASE$(
KEY_UNTIL
dc.b 'NTIL',TK_UNTIL * UNTIL
KEY_USINGS
dc.b 'SING$(',TK_USINGS * USING$(
KEY_USR
dc.b 'SR(',TK_USR * USR(
dc.b $00
TAB_ASCV
KEY_VAL
dc.b 'AL(',TK_VAL * VAL(
KEY_VPTR
dc.b 'ARPTR(',TK_VPTR * VARPTR(
dc.b $00
TAB_ASCW
KEY_WAIT
dc.b 'AIT',TK_WAIT * WAIT
KEY_WHILE
dc.b 'HILE',TK_WHILE * WHILE
KEY_WIDTH
dc.b 'IDTH',TK_WIDTH * WIDTH
dc.b $00
TAB_POWR
KEY_POWER
dc.b TK_POWER,$00 * ^
*************************************************************************************
*
* just messages
LAB_BMSG
dc.b $0D,$0A,'Break',$00
LAB_EMSG
dc.b ' Error',$00
LAB_LMSG
dc.b ' in line ',$00
LAB_IMSG
dc.b 'Extra ignored',$0D,$0A,$00
LAB_REDO
dc.b 'Redo from start',$0D,$0A,$00
LAB_RMSG
dc.b $0D,$0A,'Ready',$0D,$0A,$00
LAB_SMSG
dc.b ' Bytes free',$0D,$0A,$0A
dc.b 'GCC Enhanced 68k BASIC for Merlin V3.6 2021',$0D,$0A,$00
*************************************************************************************
* EhBASIC keywords quick reference list *
*************************************************************************************
* glossary
* <.> required
* {.|.} one of required
* [.] optional
* ... may repeat as last
* any = anything
* num = number
* state = statement
* n = positive integer
* str = string
* var = variable
* nvar = numeric variable
* svar = string variable
* expr = expression
* nexpr = numeric expression
* sexpr = string expression
* statement separator
* : . [<state>] : [<state>] * done
* number bases
* % . %<binary num> * done
* $ . $<hex num> * done
* commands
* END . END * done
* FOR . FOR <nvar>=<nexpr> TO <nexpr> [STEP <nexpr>] * done
* NEXT . NEXT [<nvar>[,<nvar>]...] * done
* DATA . DATA [{num|["]str["]}[,{num|["]str["]}]...] * done
* INPUT . INPUT [<">str<">;] <var>[,<var>[,<var>]...] * done
* DIM . DIM <var>(<nexpr>[,<nexpr>[,<nexpr>]]) * done
* READ . READ <var>[,<var>[,<var>]...] * done
* LET . [LET] <var>=<expr> * done
* DEC . DEC <nvar>[,<nvar>[,<nvar>]...] * done
* GOTO . GOTO <n> * done
* RUN . RUN [<n>] * done
* IF . IF <expr>{GOTO<n>|THEN<{n|comm}>}[ELSE <{n|comm}>] * done
* RESTORE . RESTORE [<n>] * done
* GOSUB . GOSUB <n> * done
* RETURN . RETURN * done
* REM . REM [<any>] * done
* STOP . STOP * done
* ON . ON <nexpr>{GOTO|GOSUB}<n>[,<n>[,<n>]...] * done
* NULL . NULL <nexpr> * done
* INC . INC <nvar>[,<nvar>[,<nvar>]...] * done
* WAIT . WAIT <nexpr>,<nexpr>[,<nexpr>] * done
* LOAD . LOAD [<sexpr>] * done for sim
* SAVE . SAVE [<sexpr>][,[<n>][-<n>]] * done for sim
* DEF . DEF FN<var>(<var>)=<expr> * done
* POKE . POKE <nexpr>,<nexpr> * done
* DOKE . DOKE <nexpr>,<nexpr> * done
* LOKE . LOKE <nexpr>,<nexpr> * done
* CALL . CALL <nexpr> * done
* DO . DO * done
* LOOP . LOOP [{WHILE|UNTIL}<nexpr>] * done
* PRINT . PRINT [{;|,}][<expr>][{;|,}[<expr>]...] * done
* CONT . CONT * done
* LIST . LIST [<n>][-<n>] * done
* CLEAR . CLEAR * done
* NEW . NEW * done
* WIDTH . WIDTH [<n>][,<n>] * done
* GET . GET <var> * done
* SWAP . SWAP <var>,<var> * done
* BITSET . BITSET <nexpr>,<nexpr> * done
* BITCLR . BITCLR <nexpr>,<nexpr> * done
* sub commands (may not start a statement)
* TAB . TAB(<nexpr>) * done
* ELSE . IF <expr>{GOTO<n>|THEN<{n|comm}>}[ELSE <{n|comm}>] * done
* TO . FOR <nvar>=<nexpr> TO <nexpr> [STEP <nexpr>] * done
* FN . FN <var>(<expr>) * done
* SPC . SPC(<nexpr>) * done
* THEN . IF <nexpr> {THEN <{n|comm}>|GOTO <n>} * done
* NOT . NOT <nexpr> * done
* STEP . FOR <nvar>=<nexpr> TO <nexpr> [STEP <nexpr>] * done
* UNTIL . LOOP [{WHILE|UNTIL}<nexpr>] * done
* WHILE . LOOP [{WHILE|UNTIL}<nexpr>] * done
* operators
* + . [expr] + <expr> * done
* - . [nexpr] - <nexpr> * done
* * . <nexpr> * <nexpr> * done fast hardware
* / . <nexpr> / <nexpr> * done fast hardware
* ^ . <nexpr> ^ <nexpr> * done
* AND . <nexpr> AND <nexpr> * done
* EOR . <nexpr> EOR <nexpr> * done
* OR . <nexpr> OR <nexpr> * done
* >> . <nexpr> >> <nexpr> * done
* << . <nexpr> << <nexpr> * done
* compare functions
* < . <expr> < <expr> * done
* = . <expr> = <expr> * done
* > . <expr> > <expr> * done
* functions
* SGN . SGN(<nexpr>) * done
* INT . INT(<nexpr>) * done
* ABS . ABS(<nexpr>) * done
* USR . USR(<expr>) * done
* FRE . FRE(<expr>) * done
* POS . POS(<expr>) * done
* SQR . SQR(<nexpr>) * done fast shift/sub
* RND . RND(<nexpr>) * done 32 bit PRNG
* LOG . LOG(<nexpr>) * done fast cordic
* EXP . EXP(<nexpr>) * done fast cordic
* COS . COS(<nexpr>) * done fast cordic
* SIN . SIN(<nexpr>) * done fast cordic
* TAN . TAN(<nexpr>) * done fast cordic
* ATN . ATN(<nexpr>) * done fast cordic
* PEEK . PEEK(<nexpr>) * done
* DEEK . DEEK(<nexpr>) * done
* LEEK . LEEK(<nexpr>) * done
* LEN . LEN(<sexpr>) * done
* STR$ . STR$(<nexpr>) * done
* VAL . VAL(<sexpr>) * done
* ASC . ASC(<sexpr>) * done
* UCASE$ . UCASE$(<sexpr>) * done
* LCASE$ . LCASE$(<sexpr>) * done
* CHR$ . CHR$(<nexpr>) * done
* HEX$ . HEX$(<nexpr>) * done
* BIN$ . BIN$(<nexpr>) * done
* BTST . BTST(<nexpr>,<nexpr>) * done
* MAX . MAX(<nexpr>[,<nexpr>[,<nexpr>]...]) * done
* MIN . MIN(<nexpr>[,<nexpr>[,<nexpr>]...]) * done
* PI . PI * done
* TWOPI . TWOPI * done
* VARPTR . VARPTR(<var>) * done
* SADD . SADD(<svar>) * done
* LEFT$ . LEFT$(<sexpr>,<nexpr>) * done
* RIGHT$ . RIGHT$(<sexpr>,<nexpr>) * done
* MID$ . MID$(<sexpr>,<nexpr>[,<nexpr>]) * done
* USING$ . USING$(<sexpr>,<nexpr>[,<nexpr>]...]) * done
|
programs/oeis/152/A152456.asm | neoneye/loda | 22 | 22950 | <reponame>neoneye/loda<gh_stars>10-100
; A152456: a(n)=1*(n+2)!-2*(n+1)!-3*n!.
; -3,-1,6,54,408,3240,28080,267120,2782080,31570560,388281600,5149267200,73287244800,1114636723200,18045906278400,309918825216000,5628230479872000,107773290713088000,2170404686241792000
mov $2,$0
add $0,1
mov $1,1
sub $2,1
lpb $0
sub $1,$2
mul $2,$0
sub $0,1
sub $2,$1
mov $1,$2
lpe
mov $0,$1
|
src/core/spat-proof_attempt.ads | HeisenbugLtd/spat | 20 | 14228 | <reponame>HeisenbugLtd/spat
------------------------------------------------------------------------------
-- Copyright (C) 2020 by Heisenbug Ltd. (<EMAIL>)
--
-- This work is free. You can redistribute it and/or modify it under the
-- terms of the Do What The Fuck You Want To Public License, Version 2,
-- as published by Sam Hocevar. See the LICENSE file for more details.
------------------------------------------------------------------------------
pragma License (Unrestricted);
------------------------------------------------------------------------------
--
-- SPARK Proof Analysis Tool
--
-- S.P.A.T. - Object representing a JSON "proof attempt" object.
--
------------------------------------------------------------------------------
with SPAT.Entity;
with SPAT.Field_Names;
with SPAT.Preconditions;
private with SPAT.Unique_Ids;
package SPAT.Proof_Attempt is
use all type GNATCOLL.JSON.JSON_Value_Type;
---------------------------------------------------------------------------
-- Has_Required_Fields
---------------------------------------------------------------------------
function Has_Required_Fields (Object : JSON_Value) return Boolean is
(Preconditions.Ensure_Field (Object => Object,
Field => Field_Names.Result,
Kind => JSON_String_Type) and
Preconditions.Ensure_Field (Object => Object,
Field => Field_Names.Time,
Kinds_Allowed => Preconditions.Number_Kind) and
Preconditions.Ensure_Field (Object => Object,
Field => Field_Names.Steps,
Kind => JSON_Int_Type));
type Prover_Result is (Valid, Unproved);
-- FIXME: There are more, but right now we're only concerned with if it's
-- proven or not.
type T is new Entity.T with private;
---------------------------------------------------------------------------
-- Create
---------------------------------------------------------------------------
not overriding
function Create (Object : JSON_Value;
Prover : Prover_Name) return T
with Pre => Has_Required_Fields (Object => Object);
---------------------------------------------------------------------------
-- Trivial_True
---------------------------------------------------------------------------
not overriding
function Trivial_True return T;
-- Special Proof_Attempt instance that represents a trivially true proof.
--
-- Since GNAT_CE_2020 we can also have a "trivial_true" in the check_tree
-- which - unlike a proper proof attempt - has no Result nor Time value, so
-- we assume "Valid" and "no time" (i.e. 0.0 s). These kind of proof
-- attempts are registered to a special prover object "Trivial" (which
-- subsequently appears in the "stats" objects).
-- Sorting instantiations.
---------------------------------------------------------------------------
-- "<"
--
-- Comparison operator.
---------------------------------------------------------------------------
not overriding
function "<" (Left : in T;
Right : in T) return Boolean;
---------------------------------------------------------------------------
-- Prover
---------------------------------------------------------------------------
not overriding
function Prover (This : in T) return Prover_Name;
---------------------------------------------------------------------------
-- Result
---------------------------------------------------------------------------
not overriding
function Result (This : in T) return Prover_Result;
---------------------------------------------------------------------------
-- Steps
---------------------------------------------------------------------------
not overriding
function Steps (This : in T) return Prover_Steps;
---------------------------------------------------------------------------
-- Time
---------------------------------------------------------------------------
not overriding
function Time (This : in T) return Duration;
private
package Proof_Attempt_Ids is new SPAT.Unique_Ids;
type T is new Entity.T with
record
Prover : Prover_Name; -- Prover involved.
Result : Result_Name; -- "Valid", "Unknown", etc.
Workload : Time_And_Steps;
-- time spent during proof, and number of steps the prover took
-- Steps might be negative (e.g. with Z3, the number of steps is
-- recorded as -1 if Z3 ran out of memory).
Id : Proof_Attempt_Ids.Id; -- unique id for stable sorting
end record;
---------------------------------------------------------------------------
-- Image
---------------------------------------------------------------------------
overriding
function Image (This : in T) return String is
(To_String (This.Prover) & ": " &
Image (Value => This.Time,
Steps => This.Steps) & ", " &
To_String (This.Result));
function Trivial_True return T is
(T'(Entity.T with
Prover => Prover_Name (To_Name (Source => "Trivial")),
Result => Result_Name (To_Name (Source => "Valid")),
Workload => None,
Id => Proof_Attempt_Ids.Next));
---------------------------------------------------------------------------
-- Prover
---------------------------------------------------------------------------
not overriding
function Prover (This : in T) return Prover_Name is
(This.Prover);
---------------------------------------------------------------------------
-- Result
---------------------------------------------------------------------------
not overriding
function Result (This : in T) return Prover_Result is
(if This.Result = Result_Name (To_Name (Source => "Valid"))
then Valid
else Unproved);
---------------------------------------------------------------------------
-- Steps
---------------------------------------------------------------------------
not overriding
function Steps (This : in T) return Prover_Steps is
(This.Workload.Steps);
---------------------------------------------------------------------------
-- Time
---------------------------------------------------------------------------
not overriding
function Time (This : in T) return Duration is
(This.Workload.Time);
end SPAT.Proof_Attempt;
|
programs/oeis/189/A189450.asm | neoneye/loda | 22 | 246048 | <filename>programs/oeis/189/A189450.asm
; A189450: Number of 2 X n array permutations with each element moving zero or one space horizontally or diagonally.
; 1,5,16,61,225,841,3136,11705,43681,163021,608400,2270581,8473921,31625105,118026496,440480881,1643897025,6135107221,22896531856,85451020205,318907548961,1190179175641,4441809153600,16577057438761,61866420601441,230888624967005,861688079266576,3215863692099301,12001766689130625,44791203064423201,167163045568562176,623860979209825505,2328280871270739841,8689262505873133861,32428769152221795600,121025814103014048541,451674487259834398561,1685672134936323545705,6291014052485459784256,23478384075005515591321,87622522247536602581025,327011704915140894732781,1220424297413026976350096,4554685484736967010667605,16998317641534841066320321,63438585081402397254613681,236756022684074747952134400,883585505654896594553923921,3297585999935511630263561281,12306758494087149926500321205,45929447976413088075737723536,171411033411565202376450572941,639714685669847721430064568225,2387447709267825683343807699961,8910076151401455011945166231616,33252856896337994364436857226505,124101351433950522445802262674401,463152548839464095418772193471101,1728508843923905859229286511210000,6450882826856159341498373851368901,24075022463500731506764208894265601,89849207027146766685558461725693505,335321805645086335235469638008508416
add $0,2
seq $0,3500 ; a(n) = 4*a(n-1) - a(n-2) with a(0) = 2, a(1) = 4.
div $0,4
sub $0,1
div $0,3
add $0,1
|
Vectors.agda | jmchapman/Relative-Monads | 21 | 10984 | record SemiRing : Set1 where
field
R : Set
_+_ : R -> R -> R
zero : R
_*_ : R -> R -> R
one : R
module Vectors (S : SemiRing) where
open SemiRing S
open import Data.Nat renaming (ℕ to Nat; zero to z; _*_ to times; _+_ to plus)
open import Data.Fin renaming (zero to z) hiding (_+_)
open import RMonads
open import Functors.Fin
open import Data.Bool
open import Function
open import Relation.Binary.HeterogeneousEquality
Vec : Nat -> Set
Vec n = Fin n -> R
Matrix : Nat -> Nat -> Set
Matrix m n = Fin m -> Vec n
-- unit
delta : forall {n} -> Matrix n n
delta i j = if feq i j then one else zero
transpose : forall {m n} -> Matrix m n -> Matrix n m
transpose A = λ j i -> A i j
dot : forall {n} -> Vec n -> Vec n -> R
dot {z} x y = zero
dot {suc n} x y = (x z * y z) + dot (x ∘ suc) (y ∘ suc)
mult : forall {m n} -> Matrix m n -> Vec m -> Vec n
mult A x = λ j -> dot (transpose A j) x
VecRMon : RMonad FinF
VecRMon = rmonad
Vec
delta
mult
{!!}
{!!}
{!!}
where
{-
lem : forall {n}(x : Vec n)(j : Fin n) -> dot (λ i → if feq i j then one else zero) x ≅ x j
lem {z} x ()
lem {suc n} x z = {!lem {n} (x ∘ suc) !}
lem {suc n} x (suc j) = {!!}
-}
|
uw1/eop-toggleMouseLook.asm | JohnGlassmyer/UltimaHacks | 68 | 15671 | %ifndef EXE_LENGTH
%include "../UltimaPatcher.asm"
%include "include/uw1.asm"
%include "include/uw1-eop.asm"
%endif
[bits 16]
startPatch EXE_LENGTH, \
expanded overlay procedure: toggleMouseLook
startBlockAt addr_eop_toggleMouseLook
push bp
mov bp, sp
; bp-based stack frame:
%assign ____callerIp 0x02
%assign ____callerBp 0x00
%assign var_string -0x20
add sp, var_string
push si
push di
cmp byte [dseg_isMouseLookEnabled], 0
jz enableMouseLook
disableMouseLook:
push 0
call calcJump(off_eop_setMouseLookState)
add sp, 2
mov ax, offsetInCodeSegment(mouseLookDisabledString)
jmp printString
enableMouseLook:
push 1
call calcJump(off_eop_setMouseLookState)
add sp, 2
mov ax, offsetInCodeSegment(mouseLookEnabledString)
printString:
mov byte [bp+var_string], 0
push cs
push ax
push ss
lea ax, [bp+var_string]
push ax
callFromOverlay strcat_far
add sp, 8
push ss
lea ax, [bp+var_string]
push ax
callFromOverlay printStringToScroll
add sp, 4
endProc:
pop di
pop si
mov sp, bp
pop bp
retn
mouseLookEnabledString:
db "Mouse look enabled.", `\n`, 0
mouseLookDisabledString:
db "Mouse look disabled.", `\n`, 0
endBlockAt off_eop_toggleMouseLook_end
endPatch
|
tier-1/fann/source/thin/fann_c-fann_layer.ads | charlie5/cBound | 2 | 12381 | -- This file is generated by SWIG. Please do *not* modify by hand.
--
with fann_c.fann_neuron;
with interfaces.C;
package fann_c.fann_layer is
-- Item
--
type Item is
record
first_neuron : access fann_c.fann_neuron.Item;
last_neuron : access fann_c.fann_neuron.Item;
end record;
-- Items
--
type Items is array (interfaces.C.Size_t range <>) of aliased fann_c.fann_layer.Item;
-- Pointer
--
type Pointer is access all fann_c.fann_layer.Item;
-- Pointers
--
type Pointers is array (interfaces.C.Size_t range <>) of aliased fann_c.fann_layer.Pointer;
-- Pointer_Pointer
--
type Pointer_Pointer is access all fann_c.fann_layer.Pointer;
end fann_c.fann_layer;
|
lab3/assignment_3.asm | 0000Blaze/Microprocess | 0 | 13930 | # ORG 9024
# DB A2
# ORG 9025
# DB 79
# ORG 8000
LXI H,9024
MOV A,M
MVI L,25
ORA M
MVI L,26
MOV M,A
HLT
|
antlr-grammars/clingo/ClingoParser.g4 | DomenicoIngrati/EmbASP | 1 | 2495 | parser grammar ClingoParser;
options {tokenVocab=ClingoLexer;}
answer_set : START model;
model : predicate_atom* NEW_LINE;
output : answer_set*;
predicate_atom: IDENTIFIER (TERMS_BEGIN term (COMMA term)* TERMS_END)?;
term : IDENTIFIER | INTEGER_CONSTANT | predicate_atom | STRING_CONSTANT;
|
libsrc/_DEVELOPMENT/input/ep/z80/asm_in_key_pressed.asm | jpoikela/z88dk | 640 | 87756 | <gh_stars>100-1000
; ===============================================================
; Aug 2015
; ===============================================================
;
; int in_key_pressed(uint16_t scancode)
;
; Using the scancode to identify a key, quickly determine
; if the key is one of those currently pressed.
;
; ===============================================================
SECTION code_clib
SECTION code_input
PUBLIC asm_in_key_pressed
EXTERN error_znc, error_mc
asm_in_key_pressed:
; enter : hl = scancode
;
; exit : if key is pressed
;
; hl = -1
; carry set
;
; if key is not pressed
;
; hl = 0
; carry reset
;
; uses : af, bc, hl
ld a,l
and $e0
jr z, key
alt:
add a,a
jr nc, ctrl
ld a,7
out ($b5),a
in a,($b5)
and $80
jr z, key ; if ALT pressed
jp error_znc
ctrl:
bit 6,l
jr z, shift
ld a,1
out ($b5),a
in a,($b5)
and $80
jr z, key ; if CTRL pressed
jp error_znc
shift:
bit 5,l
jr z, key
xor a
out ($b5),a
in a,($b5)
and $80
jr z, key ; if LSHIFT pressed
ld a,8
out ($b5),a
in a,($b5)
and $20
jp nz, error_znc ; if RSHIFT not pressed
key:
ld a,l
and $0f
out ($b5),a
in a,($b5)
and h
jp nz, error_znc ; if key is not pressed
jp error_mc ; if key is pressed
|
programs/oeis/101/A101869.asm | jmorken/loda | 1 | 241063 | ; A101869: Row 2 of A101866.
; 10,20,26,36,46,52,62,68,78,88,94,104,114,120,130,136,146,156,162,172,178,188,198,204,214,224,230,240,246,256,266,272,282,292,298,308,314,324,334,340,350,356,366,376,382,392,402,408,418,424,434,444,450,460,466,476,486
mov $3,$0
mov $7,$0
add $7,1
lpb $7
mov $0,$3
sub $7,1
sub $0,$7
mov $11,$0
mov $13,2
lpb $13
mov $0,$11
sub $13,1
add $0,$13
sub $0,1
mov $2,$0
mov $0,32
add $2,1
mov $4,$6
mov $5,33
div $9,15
add $9,$2
mov $10,13
lpb $0
add $0,2
add $4,$0
mov $0,5
mul $10,$5
mul $10,$9
div $10,$4
add $10,2
mul $10,2
sub $10,2
lpe
mov $8,$13
mov $9,2
lpb $8
sub $8,1
mov $12,$10
lpe
lpe
lpb $11
mov $11,0
sub $12,$10
lpe
mov $10,$12
sub $10,24
div $10,2
mul $10,4
add $10,6
add $1,$10
lpe
|
libsrc/video/mc6845/asm_set_cursor_state.asm | Frodevan/z88dk | 640 | 7214 | <reponame>Frodevan/z88dk
SECTION code_clib
PUBLIC asm_set_cursor_state
INCLUDE "mc6845.inc"
; Set the state of the hardware cursor
;
; Entry: l = cursor state:
; 0x00 = always on
; 0x20 = off
; 0x40 = fast blink
; 0x60 = slow blink
; l = lower 5 bits = first cursor row
; h = cursor end row
;
; Uses: af, l, bc (on some targets)
asm_set_cursor_state:
ld a,0x0a
IF address_w > 256
ld bc,address_w
out (c),a
ELSE
out (address_w),a
ENDIF
IF register_w > 256
ld bc,register_w
out (c),l
ELSE
ld a,l
out (register_w),a
ENDIF
ld a,0x0b
IF address_w > 256
ld bc,address_w
out (c),a
ELSE
out (address_w),a
ENDIF
IF register_w > 256
ld bc,register_w
out (c),h
ELSE
ld a,h
out (register_w),a
ENDIF
ret
|
source/amf/mof/amf-generic_collections.adb | svn2github/matreshka | 24 | 3021 | <filename>source/amf/mof/amf-generic_collections.adb<gh_stars>10-100
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, <NAME> <<EMAIL>> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with AMF.Elements;
with AMF.Holders.Reflective_Collections;
with AMF.Internals.Collections.Elements.Containers;
with AMF.Reflective_Collections.Internals;
package body AMF.Generic_Collections is
use type AMF.Internals.Collections.Elements.Shared_Element_Collection_Access;
---------
-- Add --
---------
-- procedure Add (Self : Collection'Class; Item : not null Element_Access) is
procedure Add
(Self : in out Collection'Class;
Item : not null access Abstract_Element'Class) is
begin
if Self.Collection = null then
Self.Collection :=
new AMF.Internals.Collections.Elements.Containers.Shared_Element_Collection_Container;
end if;
Self.Collection.Add (AMF.Elements.Element_Access (Item));
end Add;
------------
-- Adjust --
------------
overriding procedure Adjust (Self : in out Collection) is
begin
if Self.Collection /= null then
Self.Collection.Reference;
end if;
end Adjust;
-------------
-- Element --
-------------
function Element
(Self : Collection'Class;
Index : Positive) return not null Element_Access is
begin
if Self.Collection = null then
raise Constraint_Error with "Index is out of range";
else
return
Element_Access
(AMF.Elements.Element_Access'(Self.Collection.Element (Index)));
end if;
end Element;
--------------
-- Excludes --
--------------
function Excludes
(Self : Collection'Class;
Element : not null access constant Abstract_Element'Class)
return Boolean is
begin
for J in 1 .. Self.Length loop
if Self.Element (J) = Element then
return False;
end if;
end loop;
return True;
end Excludes;
--------------
-- Finalize --
--------------
overriding procedure Finalize (Self : in out Collection) is
begin
if Self.Collection /= null then
Self.Collection.Unreference;
Self.Collection := null;
end if;
end Finalize;
--------------
-- Includes --
--------------
function Includes
(Self : Collection'Class;
Element : not null access constant Abstract_Element'Class)
return Boolean is
begin
for J in 1 .. Self.Length loop
if Self.Element (J) = Element then
return True;
end if;
end loop;
return False;
end Includes;
--------------
-- Internal --
--------------
function Internal
(Self : Collection'Class)
return
AMF.Internals.Collections.Elements.Shared_Element_Collection_Access is
begin
return Self.Collection;
end Internal;
---------------
-- Internals --
---------------
package body Internals is
---------------
-- To_Holder --
---------------
function To_Holder
(Item : Collection'Class) return League.Holders.Holder is
begin
return
AMF.Holders.Reflective_Collections.To_Holder
(AMF.Reflective_Collections.Internals.Create
(AMF.Internals.Collections.Shared_Collection_Access
(Item.Collection)));
end To_Holder;
end Internals;
--------------
-- Is_Empty --
--------------
function Is_Empty (Self : Collection'Class) return Boolean is
begin
return Self.Collection = null or else Self.Collection.Length = 0;
end Is_Empty;
------------
-- Length --
------------
function Length (Self : Collection'Class) return Natural is
begin
if Self.Collection = null then
return 0;
else
return Self.Collection.Length;
end if;
end Length;
-----------
-- Union --
-----------
procedure Union
(Self : in out Set'Class;
Collection : Set'Class) is
begin
for J in 1 .. Collection.Length loop
if not Self.Includes (Collection.Element (J)) then
Self.Add (Collection.Element (J));
end if;
end loop;
end Union;
----------
-- Wrap --
----------
function Wrap
(Item : not null
AMF.Internals.Collections.Elements.Shared_Element_Collection_Access)
return Bag is
begin
return Bag'(Ada.Finalization.Controlled with Collection => Item);
end Wrap;
----------
-- Wrap --
----------
function Wrap
(Item : not null
AMF.Internals.Collections.Elements.Shared_Element_Collection_Access)
return Ordered_Set is
begin
return Ordered_Set'(Ada.Finalization.Controlled with Collection => Item);
end Wrap;
----------
-- Wrap --
----------
function Wrap
(Item : not null
AMF.Internals.Collections.Elements.Shared_Element_Collection_Access)
return Sequence is
begin
return Sequence'(Ada.Finalization.Controlled with Collection => Item);
end Wrap;
----------
-- Wrap --
----------
function Wrap
(Item : not null
AMF.Internals.Collections.Elements.Shared_Element_Collection_Access)
return Set is
begin
return Set'(Ada.Finalization.Controlled with Collection => Item);
end Wrap;
end AMF.Generic_Collections;
|
drivers/drivers-si7006.adb | ekoeppen/MSP430_Generic_Ada_Drivers | 1 | 24113 | <gh_stars>1-10
with STM32GD.I2C;
with STM32_SVD; use STM32_SVD;
package body Drivers.Si7006 is
Measurement : STM32GD.I2C.I2C_Data (0 .. 2);
function Temperature_x100 return Temperature_Type is
begin
if I2C.Master_Transmit (16#40#, 16#E3#, True)
and then I2C.Master_Receive (16#40#, Measurement)
then return Temperature_Type (
Shift_Right ((UInt32 (Measurement (0)) * 256 +
UInt32 (Measurement (1))) * 17572, 16) - 4685);
else return 0;
end if;
end Temperature_x100;
function Humidity return Humidity_Type is
begin
if I2C.Master_Transmit (16#40#, 16#E5#, True)
and then I2C.Master_Receive (16#40#, Measurement)
then return Humidity_Type (
Shift_Right ((UInt32 (Measurement (0)) * 256 +
UInt32 (Measurement (1))) * 125, 16) - 6);
else return 0;
end if;
end Humidity;
end Drivers.Si7006;
|
term3/Programmirovanie/lab6.asm | japanese-goblinn/labs | 0 | 167598 | <reponame>japanese-goblinn/labs<filename>term3/Programmirovanie/lab6.asm<gh_stars>0
;Перекрыть девятую функцию прерывания 21h таким образом, чтобы в выводимой строке маленькие буквы заменялись большими,
; а большие на маленькие.
CSEG segment
assume cs:CSEG, ds:CSEG, es:CSEG, ss:CSEG
org 80h
cmdLength db ? ;cmd line lenght
cmdLine db ? ;cmd line
org 100h
Start:
jmp init
Int_21h_proc proc
cmp ah, 09h
je itsOkayToBe9h
jmp dword ptr cs:[Int_21h_vect]
itsOkayToBe9h:
push dx
push di
push si
push es
push ds
pop es
mov di, dx
mov si, dx
veryCoolLoop:
lodsb
cmp al, '$'
je finish
cmp al, 'a'
je space
cmp al, 'e'
je space
cmp al, 'i'
je space
cmp al, 'o'
je space
cmp al, 'u'
je space
cmp al, 'A'
je space
cmp al, 'E'
je space
cmp al, 'I'
je space
cmp al, 'O'
je space
cmp al, 'U'
je space
jmp ignore
space:
mov al, ''
ignore:
stosb
jmp veryCoolLoop
finish:
pushf
call dword ptr cs:[Int_21h_vect]
pop es
pop si
pop di
pop dx
iret
Int_21h_proc endp
installFlag dw 13579
Int_21h_vect dd ?
msgAlreadyInstalled db 'Already installed', 13, 10, '$'
msgCmdArgsErr db 'Command line arguments are invalid', 13, 10, '$'
msgNotInstalled db 'Not installed', 13, 10, '$'
msgUninstalled db 'Uninstalled', 13, 10, '$'
msgInstalled db 'Installed', 13, 10, '$'
init:
mov ax, 3521h
int 21h
mov word ptr Int_21h_vect, bx
mov word ptr Int_21h_vect + 2, es
cmp cmdLength, 0
je install
cmp cmdLength, 3
jne invalidParams
cmp cmdLine[0], ' '
jne invalidParams
cmp cmdLine[1], '-'
jne invalidParams
cmp cmdLine[2], 'd'
jne invalidParams
cmp es:installFlag, 13579
jne notInstalled
;if user wants to unistall handler
mov dx, offset msgUninstalled
mov ah, 09h
int 21h
mov ax, 2521h
mov ds, word ptr es:Int_21h_vect + 2
mov dx, word ptr es:Int_21h_vect
int 21h
mov ah, 4ch
int 21h
invalidParams:
mov dx, offset msgCmdArgsErr
jmp toEnd
alreadyInstalled:
mov dx, offset msgAlreadyInstalled
jmp toEnd
notInstalled:
mov dx, offset msgNotInstalled
toEnd:
mov ah, 09h
int 21h
mov ah, 4ch
int 21h
install:
cmp es:installFlag, 13579
je alreadyInstalled
mov ah, 09h
mov dx, offset msgInstalled
int 21h
;25h - installing of our handler
mov ax, 2521h
mov dx, offset Int_21h_proc; in ds:dx should be our handler
int 21h
;27h - saving last byte of init label so its stays in memory
mov dx, offset Init
int 27h
mov ah, 35h ;this function return adress of original handler
mov al, 21h ;choosing for what interrupt we whant to get
int 21h
;now in es:bx adress of 21h handler
;saving of old handler
mov word ptr Int_21h_vect, bx
mov word ptr Int_21h_vect + 2, es
;25h - installing of our handler
mov ah, 25h
mov al, 21h
mov dx, offset Int_21h_proc; in ds:dx should be our handler
int 21h
;27h - saving last byte of init label so its stays in memory
mov dx, offset Init
int 27h
CSEG ends
end Start
|
ada/euler22.adb | procrastiraptor/euler | 1 | 28131 | with Ada.Containers.Generic_Array_Sort;
with Ada.Integer_Text_IO;
with Ada.Text_IO;
with Words;
procedure Euler22 is
function "<"(L, R: Words.String_Ptr) return Boolean is (L.all < R.all);
procedure Sort is new Ada.Containers.Generic_Array_Sort(
Index_Type => Positive,
Element_Type => Words.String_Ptr,
Array_Type => Words.List);
begin
declare
Names: Words.List := Words.Split(Ada.Text_IO.Get_Line);
Total: Natural := 0;
begin
Sort(Names);
for I in Names'Range loop
Total := Total + I * Words.Score(Names(I).all);
end loop;
Ada.Integer_Text_IO.Put(Total);
Words.Free(Names);
end;
end Euler22;
|
other.7z/NEWS.7z/NEWS/テープリストア/NEWS_05/NEWS_05.tar/home/kimura/kart/risc.lzh/risc/join/sound.asm | prismotizm/gigaleak | 0 | 102832 | Name: sound.asm
Type: file
Size: 506
Last-Modified: '1991-12-16T11:05:59Z'
SHA-1: D34ABADC511C2153FBD2F27268CE5D063008E9BA
Description: null
|
modules/setFirstRegister.asm | antuniooh/assembly-calculator | 2 | 16864 | <gh_stars>1-10
SETFIRST_REGISTER:
MOV A, #50h
ADD A, R0
MOV R0, A
MOV A, @R0
MOV R5, A
|
untested/ARM/intToBase.asm | GabrielRavier/Generic-Assembly-Samples | 0 | 173237 | <reponame>GabrielRavier/Generic-Assembly-Samples
code32
format ELF
public _intToBase
public _intToBase64
extrn __divmodsi4
section '.text' executable align 16
_intToBase:
cmp r0, #0
beq .prnt0
push {r4, r5, r6, r7, r8, r9, r10, fp, lr}
rsblt r0, #0
movlt r9, #1
movge r9, #0
asr r8, r2, #31
eor r6, r2, r8
sub r6, r8
sub r4, r1, #1
mov r7, r4
mov r5, #0
.digitsLoop:
asr lr, r0, #31
eor r10, lr, r8
cmp r6, #0
moveq lr, r6
beq .den0
mov r3, r6
mov ip, #1
blt .denNegative
.countShiftLoop:
lsl ip, #1
lsls r3, #1
bpl .countShiftLoop
cmp ip, #0
beq .qbit0
.denNegative:
eor fp, lr, r0
sub fp, lr
mov lr, #0
.divLoop:
cmp r3, fp
subls fp, r3
addls lr, ip
lsr r3, #1
lsrs ip, #1
bne .divLoop
.den0:
eor lr, r10
sub lr, r10
mul r3, lr, r2
sub r0, r3
and r3, r0, #255
cmp r0, #9
addgt r3, #87
addle r3, #48
and r3, #255
add ip, r5, #1
strb r3, [r7, #1]
subs r0, lr, #0
movne r5, ip
bne .digitsLoop
cmp r9, #0
bne .numNegative
strb r9, [r1, ip]
cmp r5, #0
popeq {r4, r5, r6, r7, r8, r9, r10, fp, pc}
.startReverse:
add r2, r1, ip
.reverseLoop:
ldrb r3, [r4, #1]
ldrb r0, [r2, #-1]
strb r0, [r4, #1]
strb r3, [r2]
add r0, r4, #2
sub r0, r1
add r4, #1
mvn r3, r4
add r3, r1
add r3, r5
cmp r3, r0
bgt .reverseLoop
pop {r4, r5, r6, r7, r8, r9, r10, fp, pc}
.numNegative:
mov r3, #45
strb r3, [r1, ip]
add r5, r1, r5
strb lr, [r5, #2]
mov r5, ip
add ip, #1
b .startReverse
.qbit0:
mov lr, ip
b .den0
.prnt0:
mov r3, #48
strb r3, [r1]
strb r0, [r1, #1]
bx lr
_intToBaseARMv7ve:
cmp r0, #0
beq .prnt0
sub r3, r1, #1
rsblt r0, #0
push {r4, r5, r6, lr}
movlt r6, #1
movge r6, #0
mov r5, r3
b .startDigitsLoop
.digitsLoop:
mov lr, ip
.startDigitsLoop:
sdiv r4, r0, r2
mls r0, r2, r4, r0
add ip, lr, #1
cmp r0, #9
uxtb r0, r0
addgt r0, #87
addle r0, #48
cmp r4, #0
uxtb r0, r0
strb r0, [r5, #1]!
mov r0, r4
bne .digitsLoop
cmp r6, #0
bne .numNegative
cmp lr, #0
strb r6, [r1, ip]
popeq {r4, r5, r6, pc}
.startReverse:
add r0, r1, ip
.reverseLoop:
ldrb r4, [r0, #-1]
add ip, r3, #2
ldrb r2, [r3, #1]
add r3, #1
sub ip, r1
strb r4, [r3]
strb r2, [r0]
mvn r2, r3
add r2, r1
add r2, lr
cmp ip, r2
blt .reverseLoop
pop {r4, r5, r6, pc}
.numNegative:
add r2, r1, lr
mov r0, #45
mov lr, ip
strb r0, [r1, ip]
strb r4, [r2, #2]
add ip, #1
b .startReverse
.prnt0:
mov r3, #48
strb r0, [r1, #1]
strb r3, [r1]
bx lr
_intToBase64:
push {r4, r5, r6, r7, r8, r9, r10, fp, lr}
sub sp, #60
mov r5, r1
orrs r1, r0, r1
beq .prnt0
mov r4, r0
mov r1, r5
cmp r0, #0
sbcs ip, r5, #0
movge r1, #0
strge r1, [sp, #44]
blt .numNegative
.startDigitsLoop:
asr r7, r3, #31
asr lr, r7, #31
str lr, [sp, #36]
str lr, [sp, #40]
eor r0, r3, lr
eor ip, r7, lr
subs r0, lr
str r0, [sp, #16]
sbc r1, ip, lr
str r1, [sp, #28]
sub ip, r2, #1
str ip, [sp, #8]
mov r8, #0
mov r7, #65536
sub r7, #1
and r3, r7
str r3, [sp, #32]
str ip, [sp, #48]
mov r6, r5
mov r5, r4
str r2, [sp, #52]
.digitsLoop:
asr ip, r6, #31
mov lr, ip
ldr r3, [sp, #36]
eor r3, ip, r3
str r3, [sp, #12]
ldr r3, [sp, #40]
eor r3, ip, r3
str r3, [sp, #24]
add r3, sp, #16
ldmia r3, {r2-r3}
orrs r1, r2, r3
beq .den0
cmp r2, #0
sbcs r1, r3, #0
mov r0, #1
mov r1, #0
blt .denNegative
.denLoop:
adds r2, r2
adc r3, r3
adds r0,r0
adc r1, r1
cmp r2, #0
sbcs r4, r3, #0
bge .denLoop
orrs r4, r0, r1
beq .qbit0
.denNegative:
eor r4, ip, r5
eor fp, lr, r6
subs r9, r4, ip
sbc r10, fp, lr
mov ip, #0
mov lr, ip
.qbitLoop:
cmp r3, r10
cmpeq r2, r9
bhi .denSupNum
subs r9, r2
sbc r10, r3
adds ip, r0
adc lr, r1
.denSupNum:
lsr r4, r2, #1
orr r4, r3, lsl #31
lsr fp, r3, #1
mov r2, r4
mov r3, fp
lsr r4, r0, #1
orr r4, r1, lsl #31
lsr fp, r1, #1
mov r0, r4
mov r1, fp
orrs r4, r0, r1
bne .qbitLoop
.endDiv:
ldr r3, [sp, #12]
ldr r2, [sp, #24]
eor ip, r3
eor lr, r2
subs r3, ip, r3
str r3, [sp]
sbc r3, lr, r2
str r3, [sp, #4]
ldmia sp, {r3-r4}
and r1, r7, r3
ldr r2, [sp, #32]
mov r0, r2
mul r0, r1, r0
ldr r3, [sp, #16]
mul r2, r3, r2
add r2, r0, lsr #16
and r3, r0, r7
add r3, r2, lsl #16
ldr r2, [sp, #8]
mul r2, r1, r2
add r1, r2, r3, lsr #16
and r3, r7
add r2, r3, r1, lsl #16
subs r2, r5, r2
and r3, r2, #255
cmp r2, #9
addgt r2, r3, #87
addle r2, r3, #48
and r2, #255
add r3, r8, #1
ldr r1, [sp, #8]
strb r2, [r1, #1]!
str r1, [sp, #8]
ldmia sp, {r5-r6}
orrs r2, r5, r6
beq .num0
mov r8, r3
b .digitsLoop
.den0:
dw 0xE7F0DEF0 ; make invalid instruction exception
.num0:
ldr ip, [sp, #48]
ldr r2, [sp, #52]
ldr r1, [sp, #44]
cmp r1, #0
bne .numIsNegative
strb r1, [r2, r3]
cmp r8, #0
beq .return
.startReverse:
add r3, r2, r3
.reverseLoop:
ldrb r1, [ip, #1]
ldrb r0, [r3, #-1]
strb r0, [ip, #1]
strb r1, [r3]
add r0, ip, #2
sub r0, r2
add ip, #1
mvn r1, ip
add r1, r2
add r1, r8
cmp r1, r0
bgt .reverseLoop
.return:
add sp, #60
pop {r4, r5, r6, r7, r8, r9, r10, fp, pc}
.numIsNegative:
mov r1, #45
strb r1, [r2, r3]
add r8, r2, r8
mov r1, #0
strb r1, [r8, #2]
mov r8, r3
add r3, #1
b .startReverse
.numNegative:
rsbs r0, #0
rsc r1, #0
mov r4, r0
mov r5, r1
mov r1, #1
str r1, [sp, #44]
b .startDigitsLoop
.qbit0:
mov ip, r0
mov lr, r1
b .endDiv
.prnt0:
mov r3, #48
strb r3, [r2]
mov r3, #0
strb r3, [r2, #1]
add sp, #60
pop {r4, r5, r6, r7, r8, r9, r10, fp, pc}
_intToBase64ARMv3m:
push {r4, r5, r6, r7, r8, r9, r10, fp, lr}
sub sp, #68
stm sp, {r0-r1}
orrs r1, r0, r1
beq .prnt0
ldmia sp, {r0-r1}
cmp r0, #0
sbcs ip, r1, #0
movge r1, #0
strge r1, [sp, #52]
blt .numNegative
.startDigitsLoop:
asr r1, r3, #31
asr lr, r1, #31
mov r0, r3
eor r3, lr
subs r3, lr
str r3, [sp, #16]
mov r3, r1
mov r9, #0
eor r3, lr
sub ip, r2, #1
sbc r3, lr
str r0, [sp, #32]
str r1, [sp, #36]
str lr, [sp, #44]
str lr, [sp, #48]
str r3, [sp, #20]
str r9, [sp, #12]
str ip, [sp, #56]
str ip, [sp, #40]
str r2, [sp, #60]
.digitsLoop:
ldr r3, [sp, #4]
asr r6, r3, #31
add r4, sp, #16
ldmia r4, {r3-r4}
orrs r2, r3, r4
ldr r2, [sp, #48]
eor r5, r6, r2
ldr r2, [sp, #44]
mov r7, r6
eor lr, r6, r2
beq .den0
cmp r3, #0
sbcs r2, r4, #0
blt .denNegative
mov r2, r3
mov r0, #1
mov r1, #0
mov r3, r4
.denLoop:
adds r2, r2
adc r3, r3
adds r0, r0
adc r1, r1
cmp r2, #0
sbcs ip, r3, #0
bge .denLoop
str r2, [sp, #24]
str r3, [sp, #28]
orrs r3, r0, r1
beq .qbit0
.doTheDiv:
mov ip, #0
mov r4, ip
ldr r3, [sp]
eor r3, r6, r3
subs r8, r3, r6
ldr r3, [sp, #4]
eor r6, r7, r3
add r3, sp, #24
ldmia r3, {r2-r3}
sbc r9, r6, r7
.qbitLoop:
cmp r3, r9
cmpeq r2, r8
bhi .denSupNum
subs r8, r2
sbc r9, r3
adds ip, r0
adc r4, r1
.denSupNum:
lsr r6, r0, #1
orr r6, r8, r1, lsl #31
lsr r7, r1, #1
mov r0, r6
mov r1, r7
lsr r6, r2, #1
orr r6, r3, lsl #31
lsr r7, r3, #1
mov r2, r6
orrs r6, r0, r1
mov r3, r7
bne .qbitLoop
.endDiv:
eor ip, lr
subs r10, ip, lr
eor r4, r5
sbc fp, r4, r5
add r5, sp, #32
ldmia r5, {r4-r5}
umull r2, r3, r4, r10
ldr r1, [sp]
subs r2, r1, r2
cmp r2, #9
and r2, #255
addgt r2, #87
addle r2, #48
orrs r3, r10, fp
ldr r3, [sp, #40]
and r2, #255
strb r2, [r3, #1]!
str r3, [sp, #40]
ldr r3, [sp, #12]
stm sp, {r10-fp}
add r3, #1
beq .num0
str r3, [sp, #12]
b .digitsLoop
.den0:
dw 0xE7F0DEF0 ; make invalid instruction exception
.num0:
ldr r1, [sp, #52]
cmp r1, #0
ldr r9, [sp, #12]
ldr ip, [sp, #56]
ldr r2, [sp, #60]
bne .numIsNegative
cmp r9, #0
strb r1, [r2, r3]
beq .return
.startReverse:
add r3, r2, r3
.reverseLoop:
ldrb r1, [r3, #-1]!
ldrb lr, [ip, #1]
add r0, ip, #2
strb r1, [ip, #1]
add ip, #1
mvn r1, ip
add r1, r2
sub r0, r2
add r1, r9
cmp r1, r0
strb lr, [r3]
bgt .reverseLoop
.return:
add sp, #68
pop {r4, r5, r6, r7, r8, r9, r10, fp, pc}
.numIsNegative:
mov lr, #45
mov r0, #0
add r1, r2, r9
strb lr, [r2, r3]
mov r9, r3
strb r0, [r1, #2]
add r3, #1
b .startReverse
.numNegative:
rsbs r0, #0
rsc r1, #0
stm sp, {r0-r1}
mov r1, #1
str r1, [sp, #52]
b .startDigitsLoop
.qbit0:
mov ip, r0
mov r4, r1
b .endDiv
.denNegative:
str r3, [sp, #24]
str r4, [sp, #28]
mov r0, #1
mov r1, #0
b .doTheDiv
.prnt0:
mov r1, #48
mov r3, #0
strb r1, [r2]
strb r3, [r2, #1]
add sp, #68
pop {r4, r5, r6, r7, r8, r9, r10, fp, pc}
_intToBase64ARMv5e:
push {r4, r5, r6, r7, r8, r9, r10, fp, lr}
sub sp, #60
strd r0, [sp]
orrs r1, r0, r1
beq .prnt0
ldrd r0, [sp]
cmp r0, #0
sbcs ip, r1, #0
movge r1, #0
strge r1, [sp, #44]
blt .numNegative
.startDigitsLoop:
asr r1, r3, #31
asr lr, r1, #31
mov r0, r3
eor r3, lr
subs r3, lr
str r3, [sp, #16]
mov r3, r1
eor r3, lr
sub ip, r2, #1
sbc r3, lr
mov r9, #0
strd r0, [sp, #24]
str lr, [sp, #36]
str lr, [sp, #40]
str r3, [sp, #20]
str ip, [sp, #12]
str r9, [sp, #32]
str ip, [sp, #48]
str r2, [sp, #52]
.digitsLoop:
ldr r3, [sp, #4]
asr ip, r3, #31
ldrd r2, [sp, #16]
mov r4, ip
orrs r1, r2, r3
ldr r1, [sp, #40]
eor r5, ip, r1
ldr r1, [sp, #36]
eor lr, ip, r1
beq .den0
cmp r2, #0
sbcs r1, r3, #0
mov r0, #1
mov r1, #0
blt .startQbitLoop
.denLoop:
adds r2, r2
adc r3, r3
adds r0, r0
adc r1, r1
cmp r2, #0
sbcs r6, r3, #0
bge .denLoop
orrs r6, r0, r1
beq .qbit0
.startQbitLoop:
ldr r6, [sp]
eor r6, ip, r6
subs r8, r6, ip
ldr ip, [sp, #4]
eor ip, r4, ip
sbc r9, ip, r4
mov ip, #0
mov r4, ip
.qbitLoop:
cmp r3, r9
cmpeq r2, r8
bhi .denSupNum
subs r8, r2
sbc r9, r3
adds ip, r0
adc r4, r1
.denSupNum:
lsr r6, r0, #1
orr r6, r1, lsl #31
lsr r7, r1, #1
mov r0, r6
mov r1, r7
lsr r6, r2, #1
orr r6, r3, lsl #31
orrs r7, r0, r1
lsr r7, r3, #1
mov r2, r6
mov r3, r7
bne .qbitLoop
.endDiv:
eor ip, lr
subs r10, ip, lr
eor r4, r5
sbc fp, r4, r5
ldrd r4, [sp, #24]
ldr r1, [sp]
umull r2, r3, r4, r10
strd r10, [sp]
subs r2, r1, r2
cmp r2, #9
and r2, #255
addgt r2, #87
addle r2, #48
orrs r3, r10, fp
ldr r3, [sp, #12]
and r2, #255
strb r2, [r3, #1]
str r3, [sp, #12]
ldr r3, [sp, #32]
add r3, #1
beq .num0
str r3, [sp, #32]
b .digitsLoop
.den0:
dw 0xE7F0DEF0 ; make invalid instruction exception
.num0:
ldr r1, [sp, #44]
ldr r9, [sp, #32]
cmp r1, #0
ldr ip, [sp, #48]
ldr r2, [sp, #52]
bne .numIsNegative
cmp r9, #0
strb r1, [r2, r3]
beq .return
.startReverse:
add r3, r2, r3
.reverseLoop:
ldrb r1, [r3, #-1]
ldrb lr, [ip, #1]
add r0, ip, #2
strb r1, [ip, #1]
add ip, #1
mvn r1, ip
add r1, r2
sub r0, r2
add r1, r9
cmp r1, r0
strb lr, [r3]
bgt .reverseLoop
.return:
add sp, #60
pop {r4, r5, r6, r7, r8, r9, r10, fp, pc}
.numIsNegative:
mov r0, #45
add r1, r2, r9
strb r0, [r2, r3]
mov r9, r3
mov r3, #0
strb r3, [r1, #2]
add r3, r9, #1
b .startReverse
.numNegative:
rsbs r0, #0
rsc r1, #0
strd r0, [sp]
mov r1, #1
str r1, [sp, #44]
b .startDigitsLoop
.qbit0:
mov ip, r0
mov r4, r1
b .endDiv
.prnt0:
mov r1, #48
mov r3, #0
strb r1, [r2]
strb r3, [r2, #1]
add sp, #60
pop {r4, r5, r6, r7, r8, r9, r10, fp, pc} |
programs/oeis/156/A156773.asm | karttu/loda | 1 | 162727 | ; A156773: a(n) = 6561*n^2 - 9558*n + 3482.
; 3482,485,10610,33857,70226,119717,182330,258065,346922,448901,564002,692225,833570,988037,1155626,1336337,1530170,1737125,1957202,2190401,2436722,2696165,2968730,3254417,3553226,3865157,4190210,4528385,4879682,5244101,5621642,6012305,6416090,6832997,7263026,7706177,8162450,8631845,9114362,9610001,10118762,10640645,11175650,11723777,12285026,12859397,13446890,14047505,14661242,15288101,15928082,16581185,17247410,17926757,18619226,19324817,20043530,20775365,21520322,22278401,23049602,23833925,24631370,25441937,26265626,27102437,27952370,28815425,29691602,30580901,31483322,32398865,33327530,34269317,35224226,36192257,37173410,38167685,39175082,40195601,41229242,42276005,43335890,44408897,45495026,46594277,47706650,48832145,49970762,51122501,52287362,53465345,54656450,55860677,57078026,58308497,59552090,60808805,62078642,63361601,64657682,65966885,67289210,68624657,69973226,71334917,72709730,74097665,75498722,76912901,78340202,79780625,81234170,82700837,84180626,85673537,87179570,88698725,90231002,91776401,93334922,94906565,96491330,98089217,99700226,101324357,102961610,104611985,106275482,107952101,109641842,111344705,113060690,114789797,116532026,118287377,120055850,121837445,123632162,125440001,127260962,129095045,130942250,132802577,134676026,136562597,138462290,140375105,142301042,144240101,146192282,148157585,150136010,152127557,154132226,156150017,158180930,160224965,162282122,164352401,166435802,168532325,170641970,172764737,174900626,177049637,179211770,181387025,183575402,185776901,187991522,190219265,192460130,194714117,196981226,199261457,201554810,203861285,206180882,208513601,210859442,213218405,215590490,217975697,220374026,222785477,225210050,227647745,230098562,232562501,235039562,237529745,240033050,242549477,245079026,247621697,250177490,252746405,255328442,257923601,260531882,263153285,265787810,268435457,271096226,273770117,276457130,279157265,281870522,284596901,287336402,290089025,292854770,295633637,298425626,301230737,304048970,306880325,309724802,312582401,315453122,318336965,321233930,324144017,327067226,330003557,332953010,335915585,338891282,341880101,344882042,347897105,350925290,353966597,357021026,360088577,363169250,366263045,369369962,372490001,375623162,378769445,381928850,385101377,388287026,391485797,394697690,397922705,401160842,404412101
mov $1,2
mov $2,$0
sub $2,1
mov $3,$2
mov $4,$2
mul $4,8
add $3,$4
add $1,$3
pow $1,2
add $4,2
add $1,$4
sub $1,6
mul $1,81
add $1,485
|
programs/oeis/135/A135703.asm | karttu/loda | 1 | 87462 | <filename>programs/oeis/135/A135703.asm
; A135703: a(n) = n*(7*n-2).
; 0,5,24,57,104,165,240,329,432,549,680,825,984,1157,1344,1545,1760,1989,2232,2489,2760,3045,3344,3657,3984,4325,4680,5049,5432,5829,6240,6665,7104,7557,8024,8505,9000,9509,10032,10569,11120,11685,12264,12857,13464,14085,14720,15369,16032,16709,17400,18105,18824,19557,20304,21065,21840,22629,23432,24249,25080,25925,26784,27657,28544,29445,30360,31289,32232,33189,34160,35145,36144,37157,38184,39225,40280,41349,42432,43529,44640,45765,46904,48057,49224,50405,51600,52809,54032,55269,56520,57785,59064,60357,61664,62985,64320,65669,67032,68409,69800,71205,72624,74057,75504,76965,78440,79929,81432,82949,84480,86025,87584,89157,90744,92345,93960,95589,97232,98889,100560,102245,103944,105657,107384,109125,110880,112649,114432,116229,118040,119865,121704,123557,125424,127305,129200,131109,133032,134969,136920,138885,140864,142857,144864,146885,148920,150969,153032,155109,157200,159305,161424,163557,165704,167865,170040,172229,174432,176649,178880,181125,183384,185657,187944,190245,192560,194889,197232,199589,201960,204345,206744,209157,211584,214025,216480,218949,221432,223929,226440,228965,231504,234057,236624,239205,241800,244409,247032,249669,252320,254985,257664,260357,263064,265785,268520,271269,274032,276809,279600,282405,285224,288057,290904,293765,296640,299529,302432,305349,308280,311225,314184,317157,320144,323145,326160,329189,332232,335289,338360,341445,344544,347657,350784,353925,357080,360249,363432,366629,369840,373065,376304,379557,382824,386105,389400,392709,396032,399369,402720,406085,409464,412857,416264,419685,423120,426569,430032,433509
mov $1,$0
mul $0,7
sub $0,2
mul $1,$0
|
ada/discovery/serial_io.adb | FrankBuss/Ada_Synth | 4 | 12659 | <reponame>FrankBuss/Ada_Synth
with HAL; use HAL;
with STM32; use STM32;
with STM32.GPIO; use STM32.GPIO;
with STM32.Device; use STM32.Device;
package body Serial_IO is
protected body Serial_Port_Controller is
procedure Init (Baud_Rate : Baud_Rates) is
Tx_Pin : constant GPIO_Point := PB6;
Rx_Pin : constant GPIO_Point := PB7;
Device_Pins : constant GPIO_Points := Rx_Pin & Tx_Pin;
Configuration : GPIO_Port_Configuration;
begin
-- configure UART 1
Enable_Clock (USART_1);
Disable (USART_1);
Set_Baud_Rate (USART_1, Baud_Rate);
Set_Mode (USART_1, Tx_Rx_Mode);
Set_Stop_Bits (USART_1, Stopbits_1);
Set_Word_Length (USART_1, Word_Length_8);
Set_Parity (USART_1, No_Parity);
Set_Flow_Control (USART_1, No_Flow_Control);
Enable (USART_1);
-- configure pins
Enable_Clock (Device_Pins);
Configuration.Mode := Mode_AF;
Configuration.Speed := Speed_50MHz;
Configuration.Output_Type := Push_Pull;
Configuration.Resistors := Pull_Up;
Configure_IO (Device_Pins, Configuration);
Configure_Alternate_Function (Device_Pins, GPIO_AF_USART1_7);
-- enable interrupt
Enable_Interrupts (USART_1, Received_Data_Not_Empty);
Enable_Interrupts (USART_1, Transmission_Complete);
Initialized := True;
end Init;
function Available return Boolean is
begin
return not Input.Is_Empty;
end Available;
procedure Read (Result : out Unsigned_8) is
begin
Result := Input.Read;
end Read;
-- doesn't work, because in protected functions I can't modify variables
-- function Read return Unsigned_8 is
-- begin
-- return Input.Read;
-- end;
procedure Write (Data : Unsigned_8) is
begin
if Output.Is_Empty then
-- if the output FIFO is empty, start transfer
Transmit (USART_1, UInt9 (Data));
else
-- else add to the FIFO: TODO: possible race condition?
output.Write (Data);
end if;
end Write;
procedure Interrupt_Handler is
Received_Char : Unsigned_8;
begin
-- check for data arrival
if Status (USART_1, Read_Data_Register_Not_Empty) and
Interrupt_Enabled (USART_1, Received_Data_Not_Empty)
then
Received_Char := Unsigned_8 (Current_Input (USART_1) and 255);
Input.Write (Received_Char);
end if;
-- check for transmission ready
if Status (USART_1, Transmission_Complete_Indicated) and
Interrupt_Enabled (USART_1, Transmission_Complete)
then
if not Output.Is_Empty then
Transmit (USART_1, UInt9 (Output.Read));
end if;
Clear_Status (USART_1, Transmission_Complete_Indicated);
end if;
end Interrupt_Handler;
end Serial_Port_Controller;
end Serial_IO;
|
programs/oeis/020/A020702.asm | neoneye/loda | 22 | 160365 | ; A020702: Expansion of (1+x^10)/((1-x)*(1-x^2)*(1-x^3)*(1-x^5)).
; 1,1,2,3,4,6,8,10,13,16,21,25,31,37,44,53,62,72,84,96,111,126,143,161,181,203,226,251,278,306,338,370,405,442,481,523,567,613,662,713,768,824,884,946,1011,1080,1151,1225,1303,1383,1468,1555,1646
lpb $0
mov $2,$0
sub $0,2
seq $2,97920 ; G.f.: (1+x^10)/((1-x)*(1-x^3)*(1-x^5)).
add $1,$2
lpe
add $1,1
mov $0,$1
|
libsrc/_DEVELOPMENT/temp/sp1/zx/c/sccz80/sp1_AddColSpr_callee.asm | jpoikela/z88dk | 640 | 175586 | ; uint __CALLEE__ sp1_AddColSpr_callee(struct sp1_ss *s, void *drawf, uchar type, int graphic, uchar plane)
SECTION code_clib
SECTION code_temp_sp1
PUBLIC sp1_AddColSpr_callee
EXTERN asm_sp1_AddColSpr
sp1_AddColSpr_callee:
pop af
pop hl
ld h,l
pop bc
pop de
ld l,e
pop de
pop ix
push af
jp asm_sp1_AddColSpr
|
agda/Nat.agda | halfaya/MusicTools | 28 | 1570 | {-# OPTIONS --erased-cubical --safe #-}
open import Data.Nat using (ℕ; zero; suc; _+_; _*_; _≤_ ; _>_; _<_; _≥_; z≤n; s≤s)
open import Data.Sum using (_⊎_; inj₁; inj₂)
open import Relation.Binary.PropositionalEquality using (_≡_; refl; cong)
module Nat where
-- Useful functions for natural numbers
_-_ : (n m : ℕ) → {m ≤ n} → ℕ
(n - zero) {z≤n} = n
(suc n - suc m) {s≤s p} = _-_ n m {p}
_-_⟨_⟩ : (n m : ℕ) → (m ≤ n) → ℕ
_-_⟨_⟩ n m m≤n = _-_ n m {m≤n}
m+n-m=n : (m n : ℕ) → {m≤n : m ≤ n} → m + (n - m ⟨ m≤n ⟩) ≡ n
m+n-m=n zero n {z≤n} = refl
m+n-m=n (suc m) (suc n) {s≤s m≤n} = cong suc (m+n-m=n m n {m≤n})
<-∨-≥ : (m n : ℕ) → m < n ⊎ m ≥ n
<-∨-≥ zero zero = inj₂ z≤n
<-∨-≥ zero (suc n) = inj₁ (s≤s z≤n)
<-∨-≥ (suc m) zero = inj₂ z≤n
<-∨-≥ (suc m) (suc n) with <-∨-≥ m n
... | inj₁ m<n = inj₁ (s≤s m<n)
... | inj₂ m≥n = inj₂ (s≤s m≥n)
|
oeis/270/A270312.asm | neoneye/loda-programs | 11 | 97562 | <reponame>neoneye/loda-programs<filename>oeis/270/A270312.asm
; A270312: Numerator of Fibonacci(n)/n.
; Submitted by <NAME>(s2)
; 1,1,2,3,1,4,13,21,34,11,89,12,233,377,122,987,1597,1292,4181,1353,10946,17711,28657,1932,3001,121393,196418,317811,514229,83204,1346269,2178309,3524578,5702887,1845493,414732,24157817,39088169,63245986,20466831,165580141
add $0,1
mov $1,$0
seq $0,45 ; Fibonacci numbers: F(n) = F(n-1) + F(n-2) with F(0) = 0 and F(1) = 1.
gcd $1,$0
div $0,$1
|
README.agda | borszag/smallib | 0 | 1505 | <reponame>borszag/smallib
module README where
----------------------------------------------------------------------
-- The Agda smallib library, version 0.1
----------------------------------------------------------------------
--
-- This library implements a type theory which is described in the
-- Appendix of the HoTT book. It also contains some properties derived
-- from the rules of this theory.
----------------------------------------------------------------------
--
-- This project is meant to be a practice for the author but as a
-- secondary goal it would be nice to create a small library which is
-- less intimidating than the standard one.
--
-- This version was tested using Agda 2.6.1.
----------------------------------------------------------------------
----------------------------------------------------------------------
-- High-level overview of contents
----------------------------------------------------------------------
--
-- The top-level module L is not implemented (yet), it's sole purpose
-- is to prepend all of the module names with something to avoid
-- possible name clashes with the standard library.
--
-- The structure of the library is the following:
--
-- • Base
-- The derivation rules of the implemented type theory and some
-- useful properties which can be derived from these. To make a
-- clear distinction between these every type has a Core and a
-- Properties submodule. In some cases the latter might be empty.
--
-- • Data
-- ◦ Bool
-- A specialized form of the Coproduct type. It implements if as
-- an elimination rule. The following operations are defined on
-- them: not, ∧, ∨, xor.
----------------------------------------------------------------------
----------------------------------------------------------------------
-- Some useful modules
----------------------------------------------------------------------
--
-- • To use several things at once
import L.Base -- Type theory with it's properties.
import L.Base.Core -- Derivation rules.
--
-- • To use only one base type
import L.Base.Sigma -- Products (universe polymorphic).
import L.Base.Coproduct -- Disjoint sums (universe polymorphic).
import L.Base.Empty -- Empty type.
import L.Base.Unit -- Unit type.
import L.Base.Nat -- Natural numbers.
import L.Base.Id -- Propositional equality (universe poly.).
--
-- • To use the properties of the above
import L.Base.Sigma.Properties
import L.Base.Coproduct.Properties
import L.Base.Empty.Properties
import L.Base.Unit.Properties
import L.Base.Nat.Properties
import L.Base.Id.Properties
--
-- • Some datatypes
import L.Data.Bool -- Booleans.
----------------------------------------------------------------------
----------------------------------------------------------------------
-- Notes
----------------------------------------------------------------------
--
-- • L.Base exports L.Coproduct.Core._+_ as _⊎_ to avoid multiple
-- definitions of _+_, as L.Base.Nat declares it as well.
----------------------------------------------------------------------
|
programs/oeis/323/A323221.asm | neoneye/loda | 22 | 170556 | <filename>programs/oeis/323/A323221.asm
; A323221: a(n) = n*(n + 5)*(n + 7)/6 + 1.
; 1,9,22,41,67,101,144,197,261,337,426,529,647,781,932,1101,1289,1497,1726,1977,2251,2549,2872,3221,3597,4001,4434,4897,5391,5917,6476,7069,7697,8361,9062,9801,10579,11397,12256,13157,14101,15089,16122,17201,18327,19501
add $0,5
mov $2,$0
bin $0,3
sub $0,$2
sub $0,$2
add $0,1
|
tools-src/gnu/gcc/gcc/ada/mlib-tgt.adb | enfoTek/tomato.linksys.e2000.nvram-mod | 80 | 5982 | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- M L I B . T G T --
-- (Default Version) --
-- --
-- B o d y --
-- --
-- $Revision$
-- --
-- Copyright (C) 2001, Ada Core Technologies, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, USA. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
-- --
------------------------------------------------------------------------------
-- This is the default version which does not support libraries.
-- All subprograms are dummies, because they are never called,
-- except Libraries_Are_Supported which returns False.
package body MLib.Tgt is
-----------------
-- Archive_Ext --
-----------------
function Archive_Ext return String is
begin
return "";
end Archive_Ext;
-----------------
-- Base_Option --
-----------------
function Base_Option return String is
begin
return "";
end Base_Option;
---------------------------
-- Build_Dynamic_Library --
---------------------------
procedure Build_Dynamic_Library
(Ofiles : Argument_List;
Foreign : Argument_List;
Afiles : Argument_List;
Options : Argument_List;
Lib_Filename : String;
Lib_Dir : String;
Lib_Address : String := "";
Lib_Version : String := "";
Relocatable : Boolean := False)
is
begin
null;
end Build_Dynamic_Library;
--------------------
-- Copy_ALI_Files --
--------------------
procedure Copy_ALI_Files
(From : Name_Id;
To : Name_Id)
is
begin
null;
end Copy_ALI_Files;
-------------------------
-- Default_DLL_Address --
-------------------------
function Default_DLL_Address return String is
begin
return "";
end Default_DLL_Address;
-------------
-- DLL_Ext --
-------------
function DLL_Ext return String is
begin
return "";
end DLL_Ext;
--------------------
-- Dynamic_Option --
--------------------
function Dynamic_Option return String is
begin
return "";
end Dynamic_Option;
-------------------
-- Is_Object_Ext --
-------------------
function Is_Object_Ext (Ext : String) return Boolean is
begin
return False;
end Is_Object_Ext;
--------------
-- Is_C_Ext --
--------------
function Is_C_Ext (Ext : String) return Boolean is
begin
return False;
end Is_C_Ext;
--------------------
-- Is_Archive_Ext --
--------------------
function Is_Archive_Ext (Ext : String) return Boolean is
begin
return False;
end Is_Archive_Ext;
-------------
-- Libgnat --
-------------
function Libgnat return String is
begin
return "libgnat.a";
end Libgnat;
-----------------------------
-- Libraries_Are_Supported --
-----------------------------
function Libraries_Are_Supported return Boolean is
begin
return False;
end Libraries_Are_Supported;
--------------------------------
-- Linker_Library_Path_Option --
--------------------------------
function Linker_Library_Path_Option
(Directory : String)
return String_Access
is
begin
return null;
end Linker_Library_Path_Option;
----------------
-- Object_Ext --
----------------
function Object_Ext return String is
begin
return "";
end Object_Ext;
----------------
-- PIC_Option --
----------------
function PIC_Option return String is
begin
return "";
end PIC_Option;
end MLib.Tgt;
|
yasm-1.3.0/modules/objfmts/win64/tests/win64-imagebase.asm | xu5343/ffmpegtoolkit_CentOS7 | 2,151 | 2805 | [section .text]
handler: ret
func: ret
func_end:
[section .pdata]
dd func
dd func_end
dd myunwnd
[section .xdata]
myunwnd:
db 9,0,0,0
dd handler
[section .foo]
dd handler wrt ..imagebase
|
nasmfunc.asm | zulinx86/haribote-os-on-mac | 0 | 8837 | ; nasmfunc
bits 32
global io_hlt, io_cli, io_sti, io_stihlt
global io_in8, io_in16, io_in32
global io_out8, io_out16, io_out32
global io_load_eflags, io_store_eflags
global load_cr0, store_cr0
global load_gdtr, load_idtr, load_tr
global asm_inthandler20, asm_inthandler21, asm_inthandler2c
extern inthandler20, inthandler21, inthandler2c
global memtest_sub
global farjmp
section .text
io_hlt: ; void io_hlt(void);
hlt
ret
io_cli: ; void io_cli(void);
cli
ret
io_sti: ; void io_sti(void);
sti
ret
io_stihlt: ; void io_stihlt(void);
sti
hlt
ret
io_in8: ; int io_in8(int port);
mov edx,[esp+4] ; port
mov eax,0
in al,dx
ret
io_in16: ; int io_in16(int port);
mov edx,[esp+4]
mov eax,0
in ax,dx
ret
io_in32: ; int io_in32(int port);
mov edx,[esp+4]
in eax,dx
ret
io_out8: ; void io_out8(int port, int data);
mov edx,[esp+4]
mov eax,[esp+8]
out dx,al
ret
io_out16: ; void io_out16(int port, int data);
mov edx,[esp+4]
mov eax,[esp+8]
out dx,ax
ret
io_out32: ; void io_out32(int port, int data);
mov edx,[esp+4]
mov eax,[esp+8]
out dx,eax
ret
io_load_eflags: ; int io_load_eflags(void);
pushfd
pop eax
ret
io_store_eflags: ; void io_store_eflags(int eflags);
mov eax,[esp+4]
push eax
popfd
ret
load_cr0: ; int load_cr0(void);
mov eax,cr0
ret
store_cr0: ; void store_cr0(int cr0);
mov eax,[esp+4]
mov cr0,eax
ret
load_gdtr: ; void load_gdtr(int limit, int addr);
mov ax,[esp+4]
mov [esp+6],ax
lgdt [esp+6]
ret
load_idtr: ; void load_idtr(int limit, int addr);
mov ax,[esp+4]
mov [esp+6],ax
lidt [esp+6]
ret
load_tr: ; void load_tr(int tr);
ltr [esp+4]
ret
asm_inthandler20:
push es
push ds
pushad
mov eax,esp
push eax
mov ax,ss
mov ds,ax
mov es,ax
call inthandler20
pop eax
popad
pop ds
pop es
iretd
asm_inthandler21:
push es
push ds
pushad
mov eax,esp
push eax
mov ax,ss
mov ds,ax
mov es,ax
call inthandler21
pop eax
popad
pop ds
pop es
iretd
asm_inthandler2c:
push es
push ds
pushad
mov eax,esp
push eax
mov ax,ss
mov ds,ax
mov es,ax
call inthandler2c
pop eax
popad
pop ds
pop es
iretd
memtest_sub: ; unsigned int memtest_sub(unsigned int start, unsigned int end);
push edi
push esi
push ebx
mov eax,[esp+12+4] ; unsigned int i = start;
mov esi,0xaa55aa55 ; unsigned int pat0 = 0xaa55aa55;
mov edi,0x55aa55aa ; unsigned int pat1 = 0x55aa55aa;
.loop:
mov ebx,eax
add ebx,0xffc ; unsigned int *p = i + 0x0ffc;
mov edx,[ebx] ; unsigned int old = *p;
mov [ebx],esi ; *p = pat0;
xor dword [ebx],0xffffffff ; *p ^= 0xffffffff;
cmp edi,[ebx] ; if (*p != pat1)
jne .fin ; goto .fin;
xor dword [ebx],0xffffffff ; *p ^= 0xffffffff;
cmp esi,[ebx] ; if (*p != pat0)
jne .fin ; goto .fin;
mov [ebx],edx ; *p = old;
add eax,0x1000 ; i += 0x1000;
cmp eax,[esp+12+8] ; if (i < end)
jb .loop ; goto .loop;
pop ebx
pop esi
pop edi
ret
.fin:
mov [ebx],edx ; *p = old;
pop ebx
pop esi
pop edi
ret
farjmp: ; void farjmp(int eip, int cs);
; [esp+4]: eip
; [esp+8]: cs
jmp far [esp+4]
ret |
src/tests/gvm.asm | nrichardsonphd/gvm | 3 | 7727 | <reponame>nrichardsonphd/gvm<filename>src/tests/gvm.asm
LOAD 5
LOAD 8
ADD
|
oeis/135/A135151.asm | neoneye/loda-programs | 11 | 16727 | ; A135151: A002260 + A128174 - I, I = Identity matrix.
; Submitted by <NAME>
; 1,1,2,2,2,3,1,3,3,4,2,2,4,4,5,1,3,3,5,5,6,2,2,4,4,6,6,7,1,3,3,5,5,7,7,8,2,2,4,4,6,6,8,8,9,1,3,3,5,5,7,7,9,9,10
lpb $0
add $1,$2
add $2,1
sub $0,$2
trn $1,$0
lpe
mod $1,2
add $1,$0
mov $0,$1
add $0,1
|
Transynther/x86/_processed/NONE/_xt_/i7-8650U_0xd2.log_605_1563.asm | ljhsiun2/medusa | 9 | 162834 | .global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r13
push %r9
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_UC_ht+0x13cc5, %rsi
lea addresses_WT_ht+0x1d401, %rdi
sub $23362, %r13
mov $89, %rcx
rep movsq
nop
nop
nop
nop
sub $65319, %r9
lea addresses_A_ht+0xb8c5, %r10
nop
nop
nop
nop
add %rbx, %rbx
movups (%r10), %xmm6
vpextrq $1, %xmm6, %r13
nop
nop
nop
xor $62184, %r13
lea addresses_normal_ht+0x50c5, %r9
nop
nop
nop
dec %rdi
movw $0x6162, (%r9)
sub $31575, %r9
lea addresses_WC_ht+0x15d85, %r13
sub $36549, %r9
movb (%r13), %r10b
nop
nop
nop
nop
nop
inc %r13
lea addresses_A_ht+0x13f89, %rbx
add %r9, %r9
mov $0x6162636465666768, %rcx
movq %rcx, %xmm2
movups %xmm2, (%rbx)
nop
nop
nop
nop
cmp %rsi, %rsi
lea addresses_normal_ht+0x78c5, %rsi
lea addresses_UC_ht+0x12785, %rdi
clflush (%rsi)
nop
nop
nop
dec %r9
mov $42, %rcx
rep movsw
nop
dec %rsi
lea addresses_UC_ht+0x14dc5, %rsi
lea addresses_D_ht+0x40c5, %rdi
nop
nop
nop
xor %r11, %r11
mov $113, %rcx
rep movsl
nop
nop
nop
sub %r10, %r10
lea addresses_normal_ht+0xc105, %rcx
nop
nop
nop
and %rsi, %rsi
mov $0x6162636465666768, %r9
movq %r9, %xmm6
vmovups %ymm6, (%rcx)
xor $33532, %r11
lea addresses_D_ht+0x150c5, %rdi
nop
nop
nop
nop
nop
and $56243, %r10
mov (%rdi), %bx
nop
nop
nop
nop
sub $47602, %rcx
lea addresses_A_ht+0x180e4, %r11
clflush (%r11)
nop
nop
nop
sub $61539, %rdi
vmovups (%r11), %ymm6
vextracti128 $0, %ymm6, %xmm6
vpextrq $1, %xmm6, %r13
nop
nop
cmp $17378, %rcx
lea addresses_D_ht+0x14645, %r9
nop
nop
and $27370, %rsi
movb $0x61, (%r9)
nop
cmp $32947, %rcx
lea addresses_A_ht+0x1dba5, %rsi
nop
and $62736, %r13
movl $0x61626364, (%rsi)
nop
nop
nop
and $5194, %r9
lea addresses_normal_ht+0x1a225, %rsi
lea addresses_WC_ht+0xa5f9, %rdi
nop
nop
nop
nop
sub $32694, %r9
mov $14, %rcx
rep movsb
nop
and $50216, %r9
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %r9
pop %r13
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r13
push %r15
push %r9
push %rbp
push %rsi
// Store
lea addresses_RW+0x10271, %r9
clflush (%r9)
nop
nop
nop
and $25945, %rbp
movl $0x51525354, (%r9)
nop
nop
nop
cmp %r13, %r13
// Load
lea addresses_normal+0xe845, %r13
nop
nop
nop
sub %r15, %r15
mov (%r13), %bp
nop
nop
and %rsi, %rsi
// Store
lea addresses_normal+0x19ac5, %r11
nop
sub $6419, %r10
mov $0x5152535455565758, %rbp
movq %rbp, %xmm1
vmovntdq %ymm1, (%r11)
nop
nop
nop
nop
nop
cmp $64183, %rsi
// Faulty Load
lea addresses_RW+0x188c5, %r13
nop
nop
inc %r15
movb (%r13), %r10b
lea oracles, %rbp
and $0xff, %r10
shlq $12, %r10
mov (%rbp,%r10,1), %r10
pop %rsi
pop %rbp
pop %r9
pop %r15
pop %r13
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_RW', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'size': 2, 'AVXalign': False, 'NT': True, 'congruent': 6, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal', 'size': 32, 'AVXalign': False, 'NT': True, 'congruent': 8, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 10, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 2, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 11, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 9, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 4, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 11, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 4, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': True}}
{'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 2, 'same': False}}
{'32': 605}
32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
*/
|
programs/oeis/003/A003463.asm | karttu/loda | 1 | 175036 | <reponame>karttu/loda<gh_stars>1-10
; A003463: a(n) = (5^n - 1)/4.
; 0,1,6,31,156,781,3906,19531,97656,488281,2441406,12207031,61035156,305175781,1525878906,7629394531,38146972656,190734863281,953674316406,4768371582031,23841857910156,119209289550781,596046447753906,2980232238769531
mov $1,5
pow $1,$0
div $1,4
|
base/mvdm/wow16/kernel31/w32sys.asm | npocmaka/Windows-Server-2003 | 17 | 27822 | TITLE w32sys - Win32S support
.xlist
include kernel.inc
include tdb.inc
.list
DataBegin
externW curTDB
DataEnd
sBegin CODE
assumes CS,CODE
assumes ds,nothing
assumes es,nothing
public GetW32SysInfo
cProc GetW32SysInfo,<PUBLIC,FAR>
cBegin nogen
SetKernelDS ES
mov dx, es
lea ax, curTDB
ret
assumes es,nothing
cEnd nogen
sEnd CODE
end
|
src/boot/boot.asm | TheRealJoe24/BrandOS-Legacy | 2 | 84181 | [bits 16]
[org 0x7c00]
boot:
mov [DISK], dl
mov ax, 0x3
int 0x10
; setup stack
mov bp, 0x9000
mov sp, bp
; load disk sectors
mov bx, KERNEL_OFFSET
mov dh, NUM_SECTORS
mov dl, [DISK]
call disk_load
cli
; load gdt
lgdt [gdt_descriptor]
mov eax, cr0
or eax, 0x1
mov cr0, eax
jmp CODE_SEG:init_kernel
jmp $
gdt_start:
dq 0x0
gdt_code:
dw 0xffff
dw 0x0
db 0x0
db 10011010b
db 11001111b
db 0x0
gdt_data:
dw 0xffff
dw 0x0
db 0x0
db 10010010b
db 11001111b
db 0x0
gdt_end:
gdt_descriptor:
dw gdt_end - gdt_start - 1
dd gdt_start
CODE_SEG equ gdt_code - gdt_start
DATA_SEG equ gdt_data - gdt_start
data:
DISK db 0
KERNEL_OFFSET equ 0x1000
NUM_SECTORS equ 31
disk_load:
pusha
push dx
mov ah, 0x02
mov al, dh
mov cl, 0x02
mov ch, 0x00
mov dh, 0x00
int 0x13
pop dx
popa
ret
[bits 32]
init_kernel:
mov ax, DATA_SEG
mov ds, ax
mov ss, ax
mov es, ax
mov fs, ax
mov gs, ax
; initialize stack
mov ebp, 0x90000
mov esp, ebp
; jump to kernel-entry.asm
call KERNEL_OFFSET
jmp $
times 510 - ($-$$) db 0
dw 0xaa55 |
src/gnat/mlib-utl.ads | My-Colaborations/dynamo | 15 | 28330 | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- M L I B . U T L --
-- --
-- S p e c --
-- --
-- Copyright (C) 2001-2008, AdaCore --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package provides an easy way of calling various tools such as gcc,
-- ar, etc...
package MLib.Utl is
procedure Delete_File (Filename : String);
-- Delete the file Filename and output the name of the deleted file in
-- verbose mode.
procedure Gcc
(Output_File : String;
Objects : Argument_List;
Options : Argument_List;
Options_2 : Argument_List;
Driver_Name : Name_Id := No_Name);
-- Driver_Name indicates the "driver" to invoke; by default, the "driver"
-- is gcc. This procedure invokes the driver to create a shared library.
-- Options are passed to gcc before the objects, Options_2 after.
-- Output_File is the name of the library file to create. Objects are the
-- names of the object files to put in the library.
procedure Ar
(Output_File : String;
Objects : Argument_List);
-- Run ar to move all the binaries inside the archive. If ranlib is on
-- the path, run it also. Output_File is the path name of the archive to
-- create. Objects is the list of the path names of the object files to be
-- put in the archive. This procedure currently assumes that it is always
-- called in the context of gnatmake. If other executables start using this
-- procedure, an additional parameter would need to be added, and calls to
-- Osint.Program_Name updated accordingly in the body.
function Lib_Directory return String;
-- Return the directory containing libgnat
procedure Specify_Adalib_Dir (Path : String);
-- Specify the path of the GNAT adalib directory, to be returned by
-- function Lib_Directory without looking for it. This is used only in
-- gprlib, because we cannot rely on the search in Lib_Directory, as the
-- GNAT version may be different for gprbuild/gprlib and the compiler.
end MLib.Utl;
|
agda/Cham/Molecule.agda | riz0id/chemical-abstract-machine | 0 | 5780 | <filename>agda/Cham/Molecule.agda
{-# OPTIONS --without-K #-}
module Cham.Molecule where
open import Cham.Agent
open import Cham.Context
open import Cham.Label
open import Cham.Name
open import Data.List
open import Data.Product using (_×_)
data Molecule : Context → Set₁ where
Reagent : ∀ {Γ} → Agent Γ → Molecule Γ
_·ₘ_ : ∀ {Γ}
→ (Valence : Label)
→ Molecule Γ
→ Molecule (Γ ⊢ Valence)
_∣ₘ_ : ∀ {Γ₁ Γ₂}
→ Molecule Γ₁
→ Molecule Γ₂
→ Molecule (Γ₁ , Γ₂)
_/ₘ_ : ∀ {Γ}
→ (Ion : Name)
→ Molecule Γ
→ Molecule (Γ ⊢ Ion ⁻)
⟨_,_⟩ : ∀ {Γ₁ Γ₂}
→ Molecule Γ₁
→ Molecule Γ₂
→ Molecule (Γ₁ , Γ₂)
l∶⟨_,_⟩ : ∀ {Γ₁ Γ₂}
→ Molecule (Γ₁ , Γ₂)
→ Molecule Γ₁
r∶⟨_,_⟩ : ∀ {Γ₁ Γ₂}
→ Molecule (Γ₁ , Γ₂)
→ Molecule Γ₂
-- molecular solutions
Sol : ∀ {Γ₁ Γ₂}
→ Molecule Γ₁
→ Molecule Γ₂
→ Molecule (permeate Γ₁ Γ₂)
|
other.7z/SFC.7z/SFC/ソースデータ/ゼルダの伝説神々のトライフォース/英語_PAL/pal_asm/zel_dmap.asm | prismotizm/gigaleak | 0 | 98711 | Name: zel_dmap.asm
Type: file
Size: 90491
Last-Modified: '2016-05-13T04:25:37Z'
SHA-1: 11D08261E131CCFBB5D9043914125CEF481F310F
Description: null
|
source/containers/a-cnslli.adb | ytomino/drake | 33 | 15326 | with Ada.Containers.Linked_Lists;
package body Ada.Containers.Naked_Singly_Linked_Lists is
function Previous (Position : not null Node_Access) return Node_Access is
begin
return Position.Previous;
end Previous;
procedure Reverse_Iterate (
Last : Node_Access;
Process : not null access procedure (Position : not null Node_Access))
is
procedure Reverse_Iterate_Body is
new Linked_Lists.Reverse_Iterate (Node, Node_Access);
pragma Inline_Always (Reverse_Iterate_Body);
begin
Reverse_Iterate_Body (Last, Process => Process);
end Reverse_Iterate;
function Reverse_Find (
Last : Node_Access;
Params : System.Address;
Equivalent : not null access function (
Right : not null Node_Access;
Params : System.Address)
return Boolean)
return Node_Access
is
function Reverse_Find_Body is
new Linked_Lists.Reverse_Find (Node, Node_Access);
pragma Inline_Always (Reverse_Find_Body);
begin
return Reverse_Find_Body (Last, Params, Equivalent => Equivalent);
end Reverse_Find;
function Is_Before (Before, After : Node_Access) return Boolean is
I : Node_Access;
J : Node_Access;
begin
if After = Before then
return False;
else
I := After.Previous;
J := Before.Previous;
loop
if J = null or else I = Before then
return True;
elsif I = null or else J = After then
return False;
else
I := I.Previous;
J := J.Previous;
end if;
end loop;
end if;
end Is_Before;
function Equivalent (
Left_Last, Right_Last : Node_Access;
Equivalent : not null access function (
Left, Right : not null Node_Access)
return Boolean)
return Boolean
is
function Equivalent_Body is
new Linked_Lists.Equivalent (Node, Node_Access);
pragma Inline_Always (Equivalent_Body);
begin
return Equivalent_Body (Left_Last, Right_Last, Equivalent => Equivalent);
end Equivalent;
procedure Free (
First : in out Node_Access;
Last : in out Node_Access;
Length : in out Count_Type;
Free : not null access procedure (Object : in out Node_Access))
is
procedure Free_Body is new Linked_Lists.Free (Node, Node_Access);
pragma Inline_Always (Free_Body);
begin
Free_Body (First, Last, Length, Free => Free);
end Free;
procedure Insert (
First : in out Node_Access;
Last : in out Node_Access;
Length : in out Count_Type;
Before : Node_Access;
New_Item : not null Node_Access) is
begin
if Before = null then
New_Item.Previous := Last;
Last := New_Item;
else
New_Item.Previous := Before.Previous;
Before.Previous := New_Item;
end if;
if First = Before then
First := New_Item;
end if;
Length := Length + 1;
end Insert;
procedure Remove (
First : in out Node_Access;
Last : in out Node_Access;
Length : in out Count_Type;
Position : not null Node_Access;
Next : Node_Access) is
begin
if Next /= null then
pragma Assert (Last /= Position);
pragma Assert (Next.Previous = Position);
Next.Previous := Position.Previous;
if First = Position then
First := Next;
end if;
else
pragma Assert (Last = Position);
Last := Position.Previous;
if First = Position then
pragma Assert (Last = null);
First := null;
end if;
end if;
Length := Length - 1;
end Remove;
procedure Split (
Target_First : out Node_Access;
Target_Last : out Node_Access;
Length : out Count_Type;
Source_First : in out Node_Access;
Source_Last : in out Node_Access;
Source_Length : in out Count_Type;
Count : Count_Type) is
begin
if Count = 0 then
Target_First := null;
Target_Last := null;
Length := 0;
elsif Count = Source_Length then
Target_First := Source_First;
Target_Last := Source_Last;
Length := Source_Length;
Source_First := null;
Source_Last := null;
Source_Length := 0;
else
declare
Before : Node_Access := Source_Last;
begin
for I in 1 .. Source_Length - Count - 1 loop
Before := Before.Previous;
end loop;
Target_First := Source_First;
Target_Last := Before.Previous;
Source_First := Before;
Source_First.Previous := null;
Length := Count;
Source_Length := Source_Length - Count;
end;
end if;
end Split;
procedure Copy (
Target_First : out Node_Access;
Target_Last : out Node_Access;
Length : out Count_Type;
Source_Last : Node_Access;
Copy : not null access procedure (
Target : out Node_Access;
Source : not null Node_Access))
is
procedure Copy_Body is new Linked_Lists.Copy (Node, Node_Access);
pragma Inline_Always (Copy_Body);
begin
Copy_Body (Target_First, Target_Last, Length, Source_Last, Copy => Copy);
end Copy;
procedure Reverse_Elements (
Target_First : in out Node_Access;
Target_Last : in out Node_Access;
Length : in out Count_Type)
is
procedure Reverse_Elements_Body is
new Linked_Lists.Reverse_Elements (Node, Node_Access);
pragma Inline_Always (Reverse_Elements_Body);
begin
Reverse_Elements_Body (Target_First, Target_Last, Length);
end Reverse_Elements;
function Is_Sorted (
Last : Node_Access;
LT : not null access function (
Left, Right : not null Node_Access)
return Boolean)
return Boolean
is
function Is_Sorted_Body is
new Linked_Lists.Is_Sorted (Node, Node_Access);
pragma Inline_Always (Is_Sorted_Body);
begin
return Is_Sorted_Body (Last, LT => LT);
end Is_Sorted;
procedure Merge (
Target_First : in out Node_Access;
Target_Last : in out Node_Access;
Length : in out Count_Type;
Source_First : in out Node_Access;
Source_Last : in out Node_Access;
Source_Length : in out Count_Type;
LT : not null access function (
Left, Right : not null Node_Access)
return Boolean)
is
procedure Merge_Body is new Linked_Lists.Merge (Node, Node_Access);
pragma Inline_Always (Merge_Body);
begin
Merge_Body (
Target_First,
Target_Last,
Length,
Source_First,
Source_Last,
Source_Length,
LT => LT);
end Merge;
procedure Merge_Sort (
Target_First : in out Node_Access;
Target_Last : in out Node_Access;
Length : in out Count_Type;
LT : not null access function (
Left, Right : not null Node_Access)
return Boolean)
is
procedure Merge_Sort_Body is
new Linked_Lists.Merge_Sort (Node, Node_Access);
-- no inline, Merge_Sort uses recursive calling
begin
Merge_Sort_Body (Target_First, Target_Last, Length, LT => LT);
end Merge_Sort;
end Ada.Containers.Naked_Singly_Linked_Lists;
|
src/clic-subcommand-instance.adb | reznikmm/clic | 0 | 18915 | <filename>src/clic-subcommand-instance.adb
with Ada.Command_Line;
with GNAT.Command_Line; use GNAT.Command_Line;
with GNAT.OS_Lib;
with GNAT.Strings;
with Ada.Containers.Hashed_Maps;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Strings.Unbounded.Hash;
with AAA.Table_IO;
with AAA.Text_IO;
package body CLIC.Subcommand.Instance is
package Command_Maps is new Ada.Containers.Hashed_Maps
(Key_Type => Ada.Strings.Unbounded.Unbounded_String,
Element_Type => Command_Access,
Hash => Ada.Strings.Unbounded.Hash,
Equivalent_Keys => Ada.Strings.Unbounded."=");
package Topic_Maps is new Ada.Containers.Hashed_Maps
(Key_Type => Ada.Strings.Unbounded.Unbounded_String,
Element_Type => Help_Topic_Access,
Hash => Ada.Strings.Unbounded.Hash,
Equivalent_Keys => Ada.Strings.Unbounded."=");
package Group_Maps is new Ada.Containers.Hashed_Maps
(Key_Type => Ada.Strings.Unbounded.Unbounded_String,
Element_Type => AAA.Strings.Vectors.Vector,
"=" => AAA.Strings.Vectors."=",
Hash => Ada.Strings.Unbounded.Hash,
Equivalent_Keys => Ada.Strings.Unbounded."=");
Registered_Commands : Command_Maps.Map;
-- A map of commands based on their names
Registered_Topics : Topic_Maps.Map;
-- A map of topics based on their names
Registered_Groups : Group_Maps.Map;
-- A map of list of commands based on their group names
Not_In_A_Group : AAA.Strings.Vector;
-- List of commands that are not in a group
Global_Arguments : AAA.Strings.Vector;
-- Vector of arguments for the global command, the first one should be the
-- command name, otherwise there is an invalid global switch on the command
-- line.
Help_Requested : Boolean;
First_Nonswitch : Integer;
Global_Config : Switches_Configuration;
Global_Parsing_Done : Boolean := False;
procedure Display_Options
(Config : Switches_Configuration;
Title : String);
procedure Display_Global_Options;
function Highlight_Switches (Line : String) return String;
function What_Command (Str : String := "") return not null Command_Access;
procedure Put_Line_For_Access (Str : String);
function To_Argument_List (V : AAA.Strings.Vector)
return GNAT.OS_Lib.Argument_List_Access;
-------------------------
-- Put_Line_For_Access --
-------------------------
procedure Put_Line_For_Access (Str : String) is
begin
Put_Line (Str);
end Put_Line_For_Access;
----------------------
-- To_Argument_List --
----------------------
function To_Argument_List (V : AAA.Strings.Vector)
return GNAT.OS_Lib.Argument_List_Access
is
List : constant GNAT.OS_Lib.Argument_List_Access :=
new GNAT.Strings.String_List (1 .. V.Count);
begin
for Index in List.all'Range loop
List (Index) := new String'(V (Index));
end loop;
return List;
end To_Argument_List;
--------------
-- Register --
--------------
procedure Register (Cmd : not null Command_Access) is
Name : constant Unbounded_String := To_Unbounded_String (Cmd.Name);
begin
if Registered_Commands.Contains (Name) then
raise Command_Already_Defined with Cmd.Name;
else
-- Register the command
Registered_Commands.Insert (Name, Cmd);
-- This command is not in a group
Not_In_A_Group.Append (Cmd.Name);
end if;
end Register;
--------------
-- Register --
--------------
procedure Register (Group : String; Cmd : not null Command_Access) is
Name : constant Unbounded_String := To_Unbounded_String (Cmd.Name);
Ugroup : constant Unbounded_String := To_Unbounded_String (Group);
begin
if Registered_Commands.Contains (Name) then
raise Command_Already_Defined with Cmd.Name;
else
-- Register the command
Registered_Commands.Insert (Name, Cmd);
-- Create the group if it doesn't exist yet
if not Registered_Groups.Contains (Ugroup) then
Registered_Groups.Insert (Ugroup,
AAA.Strings.Vectors.Empty_Vector);
end if;
-- Add this command to the list of commands for the group
Registered_Groups.Reference (Ugroup).Append (Cmd.Name);
end if;
end Register;
--------------
-- Register --
--------------
procedure Register (Topic : not null Help_Topic_Access) is
Name : constant Unbounded_String := To_Unbounded_String (Topic.Name);
begin
if Registered_Topics.Contains (Name) then
raise Program_Error;
else
Registered_Topics.Insert (Name, Topic);
end if;
end Register;
------------------
-- What_Command --
------------------
function What_Command (Str : String := "") return not null Command_Access is
Name : constant Unbounded_String :=
To_Unbounded_String (if Str = "" then What_Command else Str);
begin
if Registered_Commands.Contains (Name) then
return Registered_Commands.Element (Name);
else
raise Error_No_Command;
end if;
end What_Command;
------------------
-- What_Command --
------------------
function What_Command return String is
begin
if Global_Arguments.Is_Empty
or else
AAA.Strings.Has_Prefix (Global_Arguments.First_Element, "-")
then
raise Error_No_Command;
else
return Global_Arguments.First_Element;
end if;
end What_Command;
--------------------
-- Fill_Arguments --
--------------------
procedure Fill_Arguments (Switch : String;
Parameter : String;
Section : String)
is
pragma Unreferenced (Parameter);
pragma Unreferenced (Section);
begin
Global_Arguments.Append (Switch);
end Fill_Arguments;
----------------------------
-- Display_Valid_Commands --
----------------------------
procedure Display_Valid_Commands is
use Command_Maps;
use Group_Maps;
Tab : constant String (1 .. 1) := (others => ' ');
Table : AAA.Table_IO.Table;
-----------------
-- Add_Command --
-----------------
procedure Add_Command (Cmd : not null Command_Access) is
begin
Table.New_Row;
Table.Append (Tab);
Table.Append (TTY_Description (Cmd.Name));
Table.Append (Tab);
Table.Append (Cmd.Short_Description);
end Add_Command;
First_Group : Boolean := Not_In_A_Group.Is_Empty;
begin
if Registered_Commands.Is_Empty then
return;
end if;
Put_Line (TTY_Chapter ("COMMANDS"));
for Name of Not_In_A_Group loop
Add_Command (Registered_Commands (To_Unbounded_String (Name)));
end loop;
for Iter in Registered_Groups.Iterate loop
if not First_Group then
Table.New_Row;
Table.Append (Tab);
else
First_Group := False;
end if;
declare
Group : constant String := To_String (Key (Iter));
begin
Table.New_Row;
Table.Append (Tab);
Table.Append (TTY_Underline (Group));
for Name of Element (Iter) loop
Add_Command (Registered_Commands (To_Unbounded_String (Name)));
end loop;
end;
end loop;
Table.Print (Separator => " ", Put_Line => Put_Line_For_Access'Access);
end Display_Valid_Commands;
--------------------------
-- Display_Valid_Topics --
--------------------------
procedure Display_Valid_Topics is
Tab : constant String (1 .. 1) := (others => ' ');
Table : AAA.Table_IO.Table;
use Topic_Maps;
begin
if Registered_Topics.Is_Empty then
return;
end if;
Put_Line (TTY_Chapter ("TOPICS"));
for Elt in Registered_Topics.Iterate loop
Table.New_Row;
Table.Append (Tab);
Table.Append (TTY_Description (To_String (Key (Elt))));
Table.Append (Tab);
Table.Append (Element (Elt).Title);
end loop;
Table.Print (Separator => " ", Put_Line => Put_Line_For_Access'Access);
end Display_Valid_Topics;
-------------------
-- Display_Usage --
-------------------
procedure Display_Usage (Cmd : not null Command_Access) is
Config : Switches_Configuration;
Canary1 : Switches_Configuration;
Canary2 : Switches_Configuration;
begin
Put_Line (TTY_Chapter ("SUMMARY"));
Put_Line (" " & Cmd.Short_Description);
Put_Line ("");
Put_Line (TTY_Chapter ("USAGE"));
Put (" ");
Put_Line
(TTY_Underline (Main_Command_Name) &
" " &
TTY_Underline (Cmd.Name) &
" [options] " &
Cmd.Usage_Custom_Parameters);
-- We use the following two canaries to detect if a command is adding
-- its own switches, in which case we need to show their specific help.
Set_Global_Switches (Canary1); -- For comparison
Set_Global_Switches (Canary2); -- For comparison
Cmd.Setup_Switches (Canary1);
if Get_Switches (Canary1.GNAT_Cfg) /= Get_Switches (Canary2.GNAT_Cfg)
then
Cmd.Setup_Switches (Config);
end if;
-- Without the following line, GNAT.Display_Help causes a segfault for
-- reasons I'm unable to pinpoint. This way it prints a harmless blank
-- line that we want anyway.
Define_Switch (Config, " ", " ", " ", " ", " ");
Display_Options (Config, "OPTIONS");
Display_Global_Options;
-- Format and print the long command description
Put_Line ("");
Put_Line (TTY_Chapter ("DESCRIPTION"));
for Line of Cmd.Long_Description loop
AAA.Text_IO.Put_Paragraph (Highlight_Switches (Line),
Line_Prefix => " ");
-- GNATCOLL.Paragraph_Filling seems buggy at the moment, otherwise
-- it would be the logical choice.
end loop;
end Display_Usage;
-------------------
-- Display_Usage --
-------------------
procedure Display_Usage (Displayed_Error : Boolean := False) is
begin
if not Displayed_Error then
Put_Line (Main_Command_Name & " " & TTY_Version (Version));
Put_Line ("");
end if;
Put_Line (TTY_Chapter ("USAGE"));
Put_Line (" " & TTY_Underline (Main_Command_Name) &
" [global options] " &
"<command> [command options] [<arguments>]");
Put_Line ("");
Put_Line (" " & TTY_Underline (Main_Command_Name) & " " &
TTY_Underline ("help") &
" [<command>|<topic>]");
Put_Line ("");
Put_Line (TTY_Chapter ("ARGUMENTS"));
declare
Tab : constant String (1 .. 1) := (others => ' ');
Table : AAA.Table_IO.Table;
begin
Table.New_Row;
Table.Append (Tab);
Table.Append (TTY_Description ("<command>"));
Table.Append ("Command to execute");
Table.New_Row;
Table.Append (Tab);
Table.Append (TTY_Description ("<arguments>"));
Table.Append ("List of arguments for the command");
Table.Print (Separator => " ",
Put_Line => Put_Line_For_Access'Access);
end;
Display_Global_Options;
Display_Valid_Commands;
Display_Valid_Topics;
end Display_Usage;
---------------------------
-- Parse_Global_Switches --
---------------------------
procedure Parse_Global_Switches is
---------------------------
-- Check_First_Nonswitch --
---------------------------
function Check_First_Nonswitch return Integer is
use Ada.Command_Line;
First_Nonswitch : Integer := 0;
-- Used to store the first argument that doesn't start with '-';
-- that would be the command for which help is being asked.
begin
for I in 1 .. Argument_Count loop
declare
Arg : constant String := Ada.Command_Line.Argument (I);
begin
if First_Nonswitch = 0 and then Arg (Arg'First) /= '-' then
First_Nonswitch := I;
end if;
end;
end loop;
return First_Nonswitch;
end Check_First_Nonswitch;
--------------------
-- Check_For_Help --
--------------------
function Check_For_Help return Boolean is
use Ada.Command_Line;
begin
return (for some I in 1 .. Argument_Count =>
Ada.Command_Line.Argument (I) in "-h" | "--help");
end Check_For_Help;
----------------------
-- Filter_Arguments --
----------------------
function Filter_Arguments return GNAT.OS_Lib.Argument_List_Access is
use Ada.Command_Line;
Arguments : AAA.Strings.Vector;
begin
for I in 1 .. Argument_Count loop
declare
Arg : constant String := Ada.Command_Line.Argument (I);
begin
if Arg not in "-h" | "--help" then
Arguments.Append (Arg);
end if;
end;
end loop;
return To_Argument_List (Arguments);
end Filter_Arguments;
Arguments : GNAT.OS_Lib.Argument_List_Access;
Arguments_Parser : Opt_Parser;
begin
-- Only do the global parsing once
if Global_Parsing_Done then
return;
else
Global_Parsing_Done := True;
end if;
-- GNAT switch handling intercepts -h/--help. To have the same output
-- for '<main> -h command' and '<main> help command', we do manual
-- handling first in search of a -h/--help:
Help_Requested := Check_For_Help;
First_Nonswitch := Check_First_Nonswitch;
-- We filter the command line arguments to remove -h/--help that would
-- trigger the Getopt automatic help system.
Arguments := Filter_Arguments;
Set_Global_Switches (Global_Config);
-- To avoid erroring on command-specific switches we add the wildcard.
-- However, if help was requested, we don't want the "[any string]" text
-- to be displayed by Getopt below, so in that case we bypass it.
if not Help_Requested then
Define_Switch (Global_Config, "*");
end if;
-- Run the parser first with only the global switches. With the wildcard
-- above (Define_Switch (Global_Config, "*")) all the unknown switches
-- and arguments go through the Fill_Arguments callback, and therefore
-- are added to Global_Arguments. This includes the command name and all
-- potential command specific switches and arguments.
Initialize_Option_Scan (Arguments_Parser, Arguments);
Getopt (Global_Config.GNAT_Cfg,
Callback => Fill_Arguments'Unrestricted_Access,
Parser => Arguments_Parser);
GNAT.OS_Lib.Free (Arguments);
-- At this point the command and all unknown switches are in
-- Global_Arguments.
exception
when Exit_From_Command_Line | Invalid_Switch | Invalid_Parameter =>
Put_Line ("");
Put_Line ("Use """ & Main_Command_Name &
" help <command>"" for specific command help");
Error_Exit (1);
end Parse_Global_Switches;
-------------
-- Execute --
-------------
procedure Execute is
begin
Parse_Global_Switches;
-- Show either general or specific help
if Help_Requested then
if First_Nonswitch > 0 then
Display_Help (Ada.Command_Line.Argument (First_Nonswitch));
Error_Exit (0);
else
null;
-- Nothing to do; later on GNAT switch processing will catch
-- the -h/--help and display the general help.
end if;
end if;
if Global_Arguments.Is_Empty then
-- We should at least have the sub-command name in the arguments
Display_Usage;
Error_Exit (1);
elsif AAA.Strings.Has_Prefix (Global_Arguments.First_Element, "-") then
-- If the first Global_Arguments is a switch (starts with '-'),
-- that means it is an invalid global switch. It is in the arguments
-- because of the wildcard: Define_Switch (Global_Config, "*");
Put_Error ("Unrecognized global option: " &
Global_Arguments.First_Element);
Display_Global_Options;
Error_Exit (1);
end if;
-- Dispatch to the appropriate command
declare
Cmd : constant not null Command_Access := What_Command;
-- Might raise if invalid, if so we are done
Command_Config : Switches_Configuration;
Sub_Cmd_Line : GNAT.OS_Lib.String_List_Access :=
To_Argument_List (Global_Arguments);
-- Make a new command line argument list from the remaining arguments
-- and switches after global parsing.
Parser : Opt_Parser;
Sub_Arguments : AAA.Strings.Vector;
begin
-- Add command specific switches to the config. We don't need the
-- global switches because they have been parsed before.
Cmd.Setup_Switches (Command_Config);
-- Ensure Command has not set a switch that is already global:
if not Verify_No_Duplicates (Command_Config, Global_Config) then
Put_Error ("Duplicate switch definition detected");
Error_Exit (1);
end if;
-- Initialize a new switch parser that will only see the new
-- sub-command line (i.e. the remaining args and switches after
-- global parsing).
Initialize_Option_Scan (Parser, Sub_Cmd_Line);
-- Parse sub-command line, invalid switches will raise an exception
Getopt (Command_Config.GNAT_Cfg, Parser => Parser);
-- Make a vector of arguments for the sub-command (every element that
-- was not a switch in the sub-command line).
loop
declare
Arg : constant String :=
GNAT.Command_Line.Get_Argument (Parser => Parser);
begin
exit when Arg = "";
Sub_Arguments.Append (Arg);
end;
end loop;
-- We don't need this anymore
GNAT.OS_Lib.Free (Sub_Cmd_Line);
pragma Assert (not Sub_Arguments.Is_Empty,
"Should have at least the command name");
-- Remove the sub-command name from the list
Sub_Arguments.Delete_First;
Cmd.Execute (Sub_Arguments);
end;
exception
when Exit_From_Command_Line | Invalid_Switch | Invalid_Parameter =>
-- Getopt has already displayed some help
Put_Line ("");
Put_Line ("Use """ & Main_Command_Name &
" help <command>"" for specific command help");
Error_Exit (1);
when Error_No_Command =>
Put_Error ("Unrecognized command: " & Global_Arguments.First_Element);
Put_Line ("");
Display_Usage (Displayed_Error => True);
Error_Exit (1);
end Execute;
------------------------
-- Highlight_Switches --
------------------------
function Highlight_Switches (Line : String) return String is
use AAA.Strings.Vectors;
use AAA.Strings;
---------------
-- Highlight --
---------------
-- Avoid highlighting non-alphanumeric characters
function Highlight (Word : String) return String is
subtype Valid_Chars is Character with
Dynamic_Predicate => Valid_Chars in '0' .. '9' | 'a' .. 'z';
I : Natural := Word'Last; -- last char to highlight
begin
while I >= Word'First and then Word (I) not in Valid_Chars loop
I := I - 1;
end loop;
return TTY_Emph (Word (Word'First .. I)) & Word (I + 1 .. Word'Last);
end Highlight;
Words : AAA.Strings.Vector := AAA.Strings.Split (Line, Separator => ' ');
I, J : Vectors.Cursor;
begin
I := Words.First;
while Has_Element (I) loop
declare
Word : constant String := Element (I);
begin
J := Next (I);
if Has_Prefix (Word, "--") and then Word'Length > 2
then
Words.Insert (Before => J, New_Item => Highlight (Word));
Words.Delete (I);
end if;
I := J;
end;
end loop;
return Flatten (Words);
end Highlight_Switches;
---------------------
-- Display_Options --
---------------------
procedure Display_Options
(Config : Switches_Configuration;
Title : String)
is
Tab : constant String (1 .. 1) := (others => ' ');
Table : AAA.Table_IO.Table;
Has_Printable_Rows : Boolean := False;
-----------------
-- Without_Arg --
-----------------
function Without_Arg (Value : String) return String is
Required_Character : constant Character := Value (Value'Last);
begin
return
(if Required_Character in '=' | ':' | '!' | '?' then
Value (Value'First .. Value'Last - 1)
else
Value);
end Without_Arg;
--------------
-- With_Arg --
--------------
function With_Arg (Value, Arg : String) return String is
Required_Character : constant Character := Value (Value'Last);
begin
return
(if Required_Character in '=' | ':' | '!' | '?' then
AAA.Strings.Replace
(Value,
"" & Required_Character,
(case Required_Character is
when '=' => "=" & Arg,
when ':' => "[ ] " & Arg,
when '!' => Arg,
when '?' => "[" & Arg & "]",
when others => raise Program_Error))
else Value);
end With_Arg;
---------------
-- Print_Row --
---------------
procedure Print_Row (Short_Switch, Long_Switch, Arg, Help : String) is
Has_Short : constant Boolean := Short_Switch not in " " | "";
Has_Long : constant Boolean := Long_Switch not in " " | "";
begin
if (not Has_Short and not Has_Long) or Help = "" then
return;
end if;
Table.New_Row;
Table.Append (Tab);
if Has_Short and Has_Long then
Table.Append (TTY_Description (Without_Arg (Short_Switch)) &
" (" & With_Arg (Long_Switch, Arg) & ")");
elsif not Has_Short and Has_Long then
Table.Append (TTY_Description (With_Arg (Long_Switch, Arg)));
elsif Has_Short and not Has_Long then
Table.Append (TTY_Description (With_Arg (Short_Switch, Arg)));
end if;
Table.Append (Help);
Has_Printable_Rows := True;
end Print_Row;
begin
for Elt of Config.Info loop
Print_Row (To_String (Elt.Switch),
To_String (Elt.Long_Switch),
To_String (Elt.Argument),
To_String (Elt.Help));
end loop;
if Has_Printable_Rows then
Put_Line ("");
Put_Line (TTY_Chapter (Title));
Table.Print (Separator => " ",
Put_Line => Put_Line_For_Access'Access);
end if;
end Display_Options;
----------------------------
-- Display_Global_Options --
----------------------------
procedure Display_Global_Options is
Global_Config : Switches_Configuration;
begin
Set_Global_Switches (Global_Config);
Display_Options (Global_Config, "GLOBAL OPTIONS");
end Display_Global_Options;
------------------
-- Display_Help --
------------------
procedure Display_Help (Keyword : String) is
------------
-- Format --
------------
procedure Format (Text : AAA.Strings.Vector) is
begin
for Line of Text loop
AAA.Text_IO.Put_Paragraph (Highlight_Switches (Line),
Line_Prefix => " ");
end loop;
end Format;
Ukey : constant Unbounded_String := To_Unbounded_String (Keyword);
begin
if Registered_Commands.Contains (Ukey) then
Display_Usage (What_Command (Keyword));
elsif Registered_Topics.Contains (Ukey) then
Put_Line (TTY_Chapter (Registered_Topics.Element (Ukey).Title));
Format (Registered_Topics.Element (Ukey).Content);
else
Put_Error ("No help found for: " & Keyword);
Display_Global_Options;
Display_Valid_Commands;
Display_Valid_Topics;
Error_Exit (1);
end if;
end Display_Help;
-------------
-- Execute --
-------------
overriding
procedure Execute (This : in out Builtin_Help;
Args : AAA.Strings.Vector)
is
pragma Unreferenced (This);
begin
if Args.Count /= 1 then
if Args.Count > 1 then
Put_Error ("Please specify a single help keyword");
Put_Line ("");
end if;
Put_Line (TTY_Chapter ("USAGE"));
Put_Line (" " & TTY_Underline (Main_Command_Name) & " " &
TTY_Underline ("help") & " [<command>|<topic>]");
Put_Line ("");
Put_Line (TTY_Chapter ("ARGUMENTS"));
declare
Tab : constant String (1 .. 1) := (others => ' ');
Table : AAA.Table_IO.Table;
begin
Table.New_Row;
Table.Append (Tab);
Table.Append (TTY_Description ("<command>"));
Table.Append ("Command for which to show a description");
Table.New_Row;
Table.Append (Tab);
Table.Append (TTY_Description ("<topic>"));
Table.Append ("Topic for which to show a description");
Table.Print (Separator => " ",
Put_Line => Put_Line_For_Access'Access);
end;
Display_Global_Options;
Display_Valid_Commands;
Display_Valid_Topics;
Error_Exit (1);
end if;
Display_Help (Args (1));
end Execute;
end CLIC.Subcommand.Instance;
|
asm/procedureTemplate.asm | IronHeart7334/AssemblyPrograms | 0 | 99955 | <reponame>IronHeart7334/AssemblyPrograms
; general comments
; This is a template for how to do procedures following the cdelc style
; preprocessor directives
.586
.MODEL FLAT
; external files to link with
; stack configuration
.STACK 4096
; named memory allocation and initialization
.DATA
param1 DWORD 1d
param2 DWORD 2d
param3 DWORD 3d
; names of procedures defined in other *.asm files in the project
; procedure code
.CODE
main PROC
; Step 1: before calling the procedure, the caller must push parameters in reverse order
mov EAX, param3
push EAX
mov EAX, param2
push EAX
mov EAX, param1
push EAX
; Step 2: call the procedure
call myProc ; remember: this pushes the address of this to the stack
; Step 9: trash the parameters I passed
pop EAX
pop EAX
pop EAX
mov EAX, 0
ret
main ENDP
; cdecl says that a procedure must leave all registers (except for EAX) and the stack as it found them
; it returns its value in EAX
; and is not allowed to access named memory locations
; this example in c would be
; int myProc(int a, int b, int c){
; int d = a - b;
; int e = a + c;
; return d + e;
; }
myProc PROC
; Step 3: set up a stack frame as a fixed point on the stack
push EBP ; set up stack frame
mov EBP, ESP ; EBP is stable, so use it to store the address of old EBP's stack address
; Now the stack looks like this: (using higher addresses at the top)
; [rubbish ]
; [param3 ]
; [param2 ]
; [param1 ]
; [return address]
; [old EBP ] <- EBP <- ESP
; ESP can move around, so I only care about addresses relative to EBP
; Step 4: save all register values except for EAX (the return value)
pushfd
push EBX
; Step 5: (optional) allocate temporary storage (saves on register usage)
mov EBX, 0 ; don't need to 0-out first
push EBX
push EBX
; Now the stack looks like this: (using higher addresses at the top)
; [rubbish ]
; [param3 ]
; [param2 ]
; [param1 ]
; [return address ]
; [old EBP ] <- EBP
; [old EFLAGS ]
; [old EBX ]
; [allocated storage 1](d)
; [allocated storage 2](e) <- ESP
; Step 6: now we get to the actual procedure
mov EAX, DWORD PTR [EBP + 4*2] ; first parameter is two frames above EBP, as the return address is one above
sub EAX, DWORD PTR [EBP + 4*3] ; EAX is now a - b
mov DWORD PTR [EBP - 4*3], EAX ; store a - b in d
mov EAX, DWORD PTR [EBP + 4*2] ; EAX is param a again
add EAX, DWORD PTR [EBP + 4*4] ; EAX is a + c
mov DWORD PTR [EBP - 4*4], EAX ; store a + c in d (don't need to do, but this is an example)
mov EAX, DWORD PTR [EBP - 4*3] ; EAX is a - b
add EAX, DWORD PTR [EBP - 4*4] ; EAX = d + e = a - b + a + c = 2a - b + c
; Step 7: free allocated storage
pop EBX
pop EBX
; Step 8: restore everything (except EAX) back to the way it was
pop EBX
popfd
pop EBP ; get rid of stack frame
ret
myProc ENDP
END
|
Graphs/Complement.agda | Smaug123/agdaproofs | 4 | 7943 | {-# OPTIONS --warning=error --safe --without-K #-}
open import LogicalFormulae
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
open import Functions.Definition
open import Setoids.Setoids
open import Setoids.Subset
open import Graphs.Definition
open import Sets.EquivalenceRelations
module Graphs.Complement {a b c : _} {V' : Set a} {V : Setoid {a} {b} V'} (G : Graph c V) where
open Graph G
open Setoid V
open Equivalence eq
complement : Graph (b ⊔ c) V
Graph._<->_ complement x y = ((x <-> y) → False) && ((x ∼ y) → False)
Graph.noSelfRelation complement x (pr1 ,, pr2) = pr2 reflexive
Graph.symmetric complement (x!-y ,, x!=y) = (λ pr → x!-y (Graph.symmetric G pr)) ,, λ pr → x!=y (Equivalence.symmetric eq pr)
Graph.wellDefined complement x=y r=s (x!-r ,, x!=r) = (λ y-s → x!-r (wellDefined (Equivalence.symmetric eq x=y) (Equivalence.symmetric eq r=s) y-s)) ,, λ y=s → x!=r (transitive x=y (transitive y=s (Equivalence.symmetric eq r=s)))
|
programs/oeis/067/A067461.asm | neoneye/loda | 22 | 24596 | ; A067461: mu(prime(n)+1)+1.
; 0,1,2,1,1,2,1,1,1,0,1,2,0,1,1,1,1,2,1,1,2,1,1,1,1,0,1,1,0,0,1,1,0,1,1,1,2,1,1,0,1,0,1,2,1,1,1,1,1,0,1,1,1,1,0,1,1,1,2,0,1,1,1,1,2,0,1,1,1,1,0,1,1,0,1,1,2,2,0,0,1,2,1,0,1,1,1,2,2,1,1,1,1,1,1,1,2,1,1,2
seq $0,6005 ; The odd prime numbers together with 1.
seq $0,8683 ; Möbius (or Moebius) function mu(n). mu(1) = 1; mu(n) = (-1)^k if n is the product of k different primes; otherwise mu(n) = 0.
add $0,1
|
src/main/antlr/me/yzyzsun/jiro/parser/CoreErlang.g4 | yzyzsun/truffle-erlang | 11 | 7908 | /*
Adapted from the Core Erlang 1.0.3 language specification.
Optional annotations are removed for simplicity.
*/
grammar CoreErlang;
module
: 'module' ATOM '[' (functionName (',' functionName)*)? ']' attributes functionDefinition* 'end'
;
attributes
: 'attributes' '[' (moduleAttribute (',' moduleAttribute)*)? ']'
;
moduleAttribute
: ATOM '=' constant
;
constant
: atomicLiteral # literalConstant
| '{' (constant (',' constant)*)? '}' # tupleConstant
| '[' constant (',' constant)* ']' # listConstant
| '[' constant (',' constant)* '|' constant ']' # consConstant
;
atomicLiteral
: INTEGER # integer
| FLOAT # float
| CHAR # char
| STRING # string
| ATOM # atom
| '[' ']' # nil
;
functionDefinition
: functionName '=' fun
;
functionName
: ATOM '/' INTEGER
;
fun
: 'fun' '(' (VARIABLE_NAME (',' VARIABLE_NAME)*)? ')' '->' expression
;
expression
: singleExpression
| '<' (singleExpression (',' singleExpression)*)? '>'
;
singleExpression
: VARIABLE_NAME # variable
| atomicLiteral # literal
| functionName # fname
| fun # f
| '{' (expression (',' expression)*)? '}' # tuple
| '[' expression (',' expression)* ']' # list
| '[' expression (',' expression)* '|' expression ']' # cons
| '#' '{' (bitstring (',' bitstring)*)? '}' '#' # binary
| 'let' variables '=' expression 'in' expression # let
| 'case' expression 'of' clause+ 'end' # case
| 'letrec' functionDefinition* 'in' expression # letrec
| 'apply' expression '(' (expression (',' expression)*)? ')' # application
| 'call' expression ':' expression '(' (expression (',' expression)*)? ')' # interModuleCall
| 'primop' ATOM '(' (expression (',' expression)*)? ')' # primOpCall
| 'try' expression 'of' variables '->' expression 'catch' variables '->' expression # try
| 'receive' clause* 'after' expression '->' expression # receive
| 'do' expression expression # sequencing
| 'catch' expression # catching
;
bitstring
: '#' '<' expression '>' '(' (expression (',' expression)*)? ')'
;
variables
: VARIABLE_NAME
| '<' (VARIABLE_NAME (',' VARIABLE_NAME)*)? '>'
;
clause
: patterns 'when' expression '->' expression
;
patterns
: pattern
| '<' (pattern (',' pattern)*)? '>'
;
pattern
: VARIABLE_NAME # variablePattern
| atomicLiteral # literalPattern
| '{' (pattern (',' pattern)*)? '}' # tuplePattern
| '[' pattern (',' pattern)* ']' # listPattern
| '[' pattern (',' pattern)* '|' pattern ']' # consPattern
| '#' '{' (bitstringPattern (',' bitstringPattern)*)? '}' '#' # binaryPattern
| VARIABLE_NAME '=' pattern # aliasPattern
;
bitstringPattern
: '#' '<' pattern '>' '(' (expression (',' expression)*)? ')'
;
INTEGER : SIGN? DIGIT+;
FLOAT : SIGN? DIGIT+ '.' DIGIT+ (('E' | 'e') SIGN? DIGIT+)?;
CHAR : '$' (~[\u0000-\u001f \\] | ESCAPE);
STRING : '"' (~'"' | '\\"')* '"';
ATOM : '\'' (~'\'' | '\\\'')* '\'';
VARIABLE_NAME : (UPPERCASE | ('_' NAME_CHAR)) NAME_CHAR*;
fragment SIGN : '+' | '-';
fragment DIGIT : [0-9];
fragment UPPERCASE : [A-Z\u00c0-\u00d6\u00d8-\u00de];
fragment LOWERCASE : [a-z\u00df-\u00f6\u00f8-\u00ff];
fragment NAME_CHAR : UPPERCASE | LOWERCASE | DIGIT | '@' | '_';
fragment ESCAPE : '\\' (OCTAL | ('^' CTRL_CHAR) | ESCAPE_CHAR);
fragment OCTAL_DIGIT : [0-7];
fragment OCTAL : OCTAL_DIGIT (OCTAL_DIGIT OCTAL_DIGIT?)?;
fragment CTRL_CHAR : [\u0040-\u005f];
fragment ESCAPE_CHAR : [bdefnrstv"'\\];
WHITESPACE : [ \t\r\n] -> skip;
COMMENT : '%' ~[\r\n]* -> skip;
|
programs/oeis/140/A140853.asm | neoneye/loda | 22 | 80707 | <reponame>neoneye/loda
; A140853: a(n) = prime(prime(n) - 1) - 1, where prime(n) is the n-th prime.
; 1,2,6,12,28,36,52,60,78,106,112,150,172,180,198,238,270,280,316,348,358,396,420,456,502,540,556,576,592,612,700,732,768,786,856,862,910,952,982,1020,1060,1068,1150,1162,1192,1212,1290,1398,1428,1438,1458,1492,1510,1582,1618,1666,1720,1732,1782,1810,1830,1906,2016,2052,2068,2088,2212,2266,2338,2346,2376,2410,2472,2542,2592,2632,2676,2712,2740,2800,2886,2902,2998,3010,3060,3088,3166,3220,3256,3270,3312,3390,3466,3510,3556,3582,3630,3726,3738,3906
seq $0,6005 ; The odd prime numbers together with 1.
trn $0,2
seq $0,40 ; The prime numbers.
sub $0,1
|
Transynther/x86/_processed/AVXALIGN/_st_/i9-9900K_12_0xa0_notsx.log_21829_530.asm | ljhsiun2/medusa | 9 | 82208 | <reponame>ljhsiun2/medusa
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r14
push %r9
push %rax
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_A_ht+0xed00, %rbp
nop
nop
nop
nop
nop
sub $24701, %r9
mov (%rbp), %r11
nop
nop
nop
nop
nop
add $30703, %r14
lea addresses_WC_ht+0x8258, %rax
nop
sub %rcx, %rcx
mov $0x6162636465666768, %r14
movq %r14, (%rax)
nop
nop
nop
nop
nop
xor $872, %rcx
lea addresses_WC_ht+0x34e8, %rsi
lea addresses_WC_ht+0x12d9a, %rdi
sub %r9, %r9
mov $12, %rcx
rep movsb
nop
nop
nop
nop
nop
sub $40559, %rdi
lea addresses_UC_ht+0x56d8, %rdi
nop
nop
nop
nop
nop
inc %rcx
mov (%rdi), %bp
nop
cmp %r11, %r11
lea addresses_WT_ht+0x13c58, %rsi
nop
and %r14, %r14
mov $0x6162636465666768, %rcx
movq %rcx, %xmm2
movups %xmm2, (%rsi)
add %r9, %r9
lea addresses_A_ht+0x6ec8, %rsi
lea addresses_D_ht+0x41d4, %rdi
add $25784, %r14
mov $93, %rcx
rep movsq
sub %r9, %r9
lea addresses_WT_ht+0x186a8, %r14
nop
nop
nop
nop
nop
cmp $37560, %rax
mov $0x6162636465666768, %r9
movq %r9, %xmm0
and $0xffffffffffffffc0, %r14
vmovntdq %ymm0, (%r14)
nop
nop
nop
nop
nop
inc %r14
lea addresses_normal_ht+0x18658, %rbp
nop
xor %rcx, %rcx
movb $0x61, (%rbp)
dec %r11
lea addresses_UC_ht+0x2e58, %rsi
lea addresses_WC_ht+0x14858, %rdi
nop
nop
sub $44944, %r11
mov $17, %rcx
rep movsl
nop
nop
cmp %r9, %r9
lea addresses_normal_ht+0x1ba18, %r9
nop
cmp $44934, %rdi
mov (%r9), %esi
nop
nop
nop
nop
cmp $32382, %rax
lea addresses_WC_ht+0x1a666, %rsi
lea addresses_WT_ht+0x14b8, %rdi
nop
nop
nop
sub %r14, %r14
mov $115, %rcx
rep movsb
nop
inc %rdi
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %rax
pop %r9
pop %r14
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r13
push %r15
push %r8
push %rcx
push %rdi
push %rdx
push %rsi
// REPMOV
lea addresses_RW+0x1e088, %rsi
lea addresses_A+0x12058, %rdi
nop
nop
nop
nop
nop
and $28615, %r8
mov $9, %rcx
rep movsq
nop
nop
nop
nop
and %r8, %r8
// Load
lea addresses_WC+0x80b4, %r8
nop
nop
lfence
movups (%r8), %xmm0
vpextrq $0, %xmm0, %rsi
nop
xor %rsi, %rsi
// Store
lea addresses_WT+0x17858, %r8
nop
nop
nop
nop
add $3472, %rcx
mov $0x5152535455565758, %r13
movq %r13, %xmm6
vmovups %ymm6, (%r8)
nop
inc %rdi
// Store
lea addresses_WT+0x8e34, %rcx
and %rdx, %rdx
mov $0x5152535455565758, %r15
movq %r15, %xmm2
vmovups %ymm2, (%rcx)
nop
nop
nop
cmp %rsi, %rsi
// Store
lea addresses_normal+0x3ebd, %r8
xor $2801, %rcx
movb $0x51, (%r8)
nop
nop
nop
nop
nop
cmp $26687, %rdx
// Store
lea addresses_WT+0x70b8, %rdx
inc %r8
mov $0x5152535455565758, %r13
movq %r13, %xmm5
movups %xmm5, (%rdx)
add %rdx, %rdx
// Store
lea addresses_WT+0x188f8, %r15
nop
nop
nop
nop
nop
xor $9892, %rcx
mov $0x5152535455565758, %rsi
movq %rsi, %xmm4
vmovups %ymm4, (%r15)
nop
nop
cmp $9971, %rdx
// Store
lea addresses_PSE+0xebd8, %rdi
clflush (%rdi)
nop
nop
nop
nop
sub $36735, %r13
movw $0x5152, (%rdi)
nop
nop
nop
nop
nop
sub $5357, %rdi
// Faulty Load
lea addresses_RW+0x4058, %rsi
nop
nop
nop
nop
and $8386, %r13
mov (%rsi), %edi
lea oracles, %r8
and $0xff, %rdi
shlq $12, %rdi
mov (%r8,%rdi,1), %rdi
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %r8
pop %r15
pop %r13
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_RW', 'AVXalign': True, 'size': 16, 'NT': True, 'same': False, 'congruent': 0}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_RW', 'congruent': 2, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_A', 'congruent': 8, 'same': False}}
{'src': {'type': 'addresses_WC', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 2}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 11}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 2}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal', 'AVXalign': False, 'size': 1, 'NT': False, 'same': False, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 4}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 5}}
{'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'AVXalign': False, 'size': 2, 'NT': False, 'same': False, 'congruent': 7}}
[Faulty Load]
{'src': {'type': 'addresses_RW', 'AVXalign': True, 'size': 4, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 8, 'NT': False, 'same': False, 'congruent': 1}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': True, 'size': 8, 'NT': True, 'same': False, 'congruent': 9}}
{'src': {'type': 'addresses_WC_ht', 'congruent': 4, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 0, 'same': False}}
{'src': {'type': 'addresses_UC_ht', 'AVXalign': True, 'size': 2, 'NT': False, 'same': False, 'congruent': 5}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 9}}
{'src': {'type': 'addresses_A_ht', 'congruent': 1, 'same': True}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 2, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 32, 'NT': True, 'same': True, 'congruent': 3}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 1, 'NT': False, 'same': False, 'congruent': 9}}
{'src': {'type': 'addresses_UC_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 11, 'same': True}}
{'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 5}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WC_ht', 'congruent': 1, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 5, 'same': False}}
{'32': 21829}
32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
*/
|
archive/test/manual/etags/ada-src/2ataspri.adb | RyanMcCarl/.emacs.d | 0 | 2095 | ------------------------------------------------------------------------------
-- --
-- GNU ADA RUNTIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . T A S K _ P R I M I T I V E S --
-- --
-- B o d y --
-- --
-- $Revision: 1.1 $ --
-- --
-- Copyright (C) 1991,1992,1993,1994,1996 Florida State University --
-- --
-- GNARL is free software; you can redistribute it and/or modify it under --
-- terms of the GNU Library General Public License as published by the --
-- Free Software Foundation; either version 2, or (at your option) any --
-- later version. GNARL is distributed in the hope that it will be use- --
-- ful, but but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Gen- --
-- eral Library Public License for more details. You should have received --
-- a copy of the GNU Library General Public License along with GNARL; see --
-- file COPYING.LIB. If not, write to the Free Software Foundation, 675 --
-- Mass Ave, Cambridge, MA 02139, USA. --
-- --
------------------------------------------------------------------------------
with GNAT.IO;
with Interfaces.C.POSIX_timers;
with Interfaces.C.POSIX_Error;
use Interfaces.C.POSIX_Error;
with Interfaces.C.POSIX_RTE;
use Interfaces.C.POSIX_RTE;
with Interfaces.C.Pthreads;
use Interfaces.C.Pthreads;
with Interfaces.C;
use Interfaces.C;
with System.Tasking;
use System.Tasking;
with System.Storage_Elements;
use System.Storage_Elements;
with System.Compiler_Exceptions;
use System.Compiler_Exceptions;
with System.Task_Specific_Data;
use System.Task_Specific_Data;
with System.Secondary_Stack;
use System.Secondary_Stack;
with System.Tasking_Soft_Links;
with System.Task_Clock;
use System.Task_Clock;
with Unchecked_Conversion;
with Interfaces.C.System_Constants;
package body System.Task_Primitives is
use Interfaces.C.Pthreads;
use Interfaces.C.System_Constants;
package RTE renames Interfaces.C.POSIX_RTE;
package TSL renames System.Tasking_Soft_Links;
Test_And_Set_Mutex : Lock;
Abort_Signal : constant := 6;
Abort_Handler : Abort_Handler_Pointer;
ATCB_Key : aliased pthread_key_t;
Unblocked_Signal_Mask : aliased RTE.Signal_Set;
-- The set of signals that should be unblocked in a task.
-- This is in general the signals that can be generated synchronously,
-- and which should therefore be converted into Ada exceptions.
-- It also includes the Abort_Signal, to allow asynchronous abortion.
function To_void_ptr is new
Unchecked_Conversion (TCB_Ptr, void_ptr);
function To_TCB_Ptr is new
Unchecked_Conversion (void_ptr, TCB_Ptr);
function pthread_mutexattr_setprotocol
(attr : access pthread_attr_t; priority : integer) return int;
pragma Import (C,
pthread_mutexattr_setprotocol,
"pthread_mutexattr_setprotocol",
"pthread_mutexattr_setprotocol");
function pthread_mutexattr_setprio_ceiling
(attr : access pthread_attr_t; priority : int) return int;
pragma Import (C,
pthread_mutexattr_setprio_ceiling,
"pthread_mutexattr_setprio_ceiling",
"pthread_mutexattr_setprio_ceiling");
pthread_mutexattr_default : pthread_mutexattr_t;
pragma Import (C, pthread_mutexattr_default,
"pthread_mutexattr_default",
"pthread_mutexattr_default");
-----------------------
-- Local Subprograms --
-----------------------
procedure Abort_Wrapper
(signo : Integer;
info : RTE.siginfo_ptr;
context : System.Address);
-- This is a signal handler procedure which calls the user-specified
-- abort handler procedure.
procedure LL_Wrapper (T : TCB_Ptr);
-- A wrapper procedure that is called from a new low-level task.
-- It performs initializations for the new task and calls the
-- user-specified startup procedure.
-------------------------
-- Initialize_LL_Tasks --
-------------------------
procedure Initialize_LL_Tasks (T : TCB_Ptr) is
Result : int;
begin
T.LL_Entry_Point := null;
T.Thread := pthread_self;
Result := pthread_key_create (ATCB_Key'Access, null);
if Result = FUNC_ERR then
raise Storage_Error; -- Insufficient resources.
end if;
T.Thread := pthread_self;
Result := pthread_setspecific (ATCB_Key, To_void_ptr (T));
if Result = FUNC_ERR then
GNAT.IO.Put_Line ("Get specific failed");
raise Storage_Error; -- Insufficient resources.
end if;
pragma Assert (Result /= FUNC_ERR,
"GNULLI failure---pthread_setspecific");
end Initialize_LL_Tasks;
----------
-- Self --
----------
function Self return TCB_Ptr is
Temp : aliased void_ptr;
Result : int;
begin
Result := pthread_getspecific (ATCB_Key, Temp'Access);
pragma Assert (Result /= FUNC_ERR,
"GNULLI failure---pthread_getspecific");
return To_TCB_Ptr (Temp);
end Self;
---------------------
-- Initialize_Lock --
---------------------
procedure Initialize_Lock
(Prio : System.Any_Priority;
L : in out Lock)
is
Attributes : aliased pthread_mutexattr_t;
Result : int;
MUTEX_NONRECURSIVE_NP : constant := 2;
begin
Result := pthread_mutexattr_init (Attributes'Access);
if Result = FUNC_ERR then
raise STORAGE_ERROR; -- should be ENOMEM
end if;
Result := pthread_mutexattr_setkind
(Attributes'Access, MUTEX_NONRECURSIVE_NP);
if Result = FUNC_ERR then
raise STORAGE_ERROR; -- should be ENOMEM
end if;
Result := pthread_mutex_init (L.mutex'Access, Attributes);
if Result = FUNC_ERR then
Result := pthread_mutexattr_destroy (Attributes'Access);
raise STORAGE_ERROR; -- should be ENOMEM ???
end if;
Result := pthread_mutexattr_destroy (Attributes'Access);
end Initialize_Lock;
-------------------
-- Finalize_Lock --
-------------------
procedure Finalize_Lock (L : in out Lock) is
Result : int;
begin
Result := pthread_mutex_destroy (L.mutex'Access);
pragma Assert
(Result /= FUNC_ERR, "GNULLI failure---pthread_mutex_destroy");
end Finalize_Lock;
----------------
-- Write_Lock --
----------------
--
-- The current pthreads implementation does not check for Ceiling
-- violations.
--
procedure Write_Lock (L : in out Lock; Ceiling_Violation : out Boolean) is
Result : int;
begin
Ceiling_Violation := False;
Result := pthread_mutex_lock (L.mutex'Access);
pragma Assert
(Result /= FUNC_ERR, "GNULLI FUNC_ERR---pthread_mutex_lock");
end Write_Lock;
---------------
-- Read_Lock --
---------------
procedure Read_Lock (L : in out Lock; Ceiling_Violation : out Boolean)
renames Write_Lock;
------------
-- Unlock --
------------
procedure Unlock (L : in out Lock) is
Result : int;
begin
Result := pthread_mutex_unlock (L.mutex'Access);
pragma Assert
(Result /= FUNC_ERR, "GNULLI FUNC_ERR---pthread_mutex_unlock");
end Unlock;
---------------------
-- Initialize_Cond --
---------------------
procedure Initialize_Cond (Cond : in out Condition_Variable) is
Attributes : aliased Pthreads.pthread_condattr_t;
Result : int;
begin
Result := pthread_condattr_init (Attributes'Access);
if Result = FUNC_ERR then
raise STORAGE_ERROR; -- should be ENOMEM ???
end if;
-- Result := pthread_cond_init (Cond.CV'Access, Attributes'Access);
Result := pthread_cond_init (Cond.CV'Access, Attributes);
if Result = FUNC_ERR then
raise STORAGE_ERROR; -- should be ENOMEM ???
end if;
Result := pthread_condattr_destroy (Attributes'Access);
pragma Assert
(Result /= FUNC_ERR, "GNULLI FUNC_ERR---pthread_condattr_destroy");
end Initialize_Cond;
-------------------
-- Finalize_Cond --
-------------------
procedure Finalize_Cond (Cond : in out Condition_Variable) is
Result : int;
begin
Result := pthread_cond_destroy (Cond.CV'Access);
pragma Assert
(Result /= FUNC_ERR, "GNULLI failure---pthread_cond_destroy");
end Finalize_Cond;
---------------
-- Cond_Wait --
---------------
procedure Cond_Wait (Cond : in out Condition_Variable; L : in out Lock) is
Result : int;
begin
Result := pthread_cond_wait (Cond.CV'Access, L.mutex'Access);
pragma Assert
(Result /= FUNC_ERR, "GNULLI failure---pthread_cond_wait");
end Cond_Wait;
---------------------
-- Cond_Timed_Wait --
---------------------
procedure Cond_Timed_Wait
(Cond : in out Condition_Variable;
L : in out Lock;
Abs_Time : System.Task_Clock.Stimespec;
Timed_Out : out Boolean) is
Result : int;
TV : aliased timespec;
use POSIX_Error;
begin
Timed_Out := False; -- Assume success until we know otherwise
TV.tv_sec := int (Interfaces.C.POSIX_timers.time_t
(Task_Clock.Stimespec_Seconds (Abs_Time)));
TV.tv_nsec := long (Interfaces.C.POSIX_timers.Nanoseconds
(Task_Clock.Stimespec_NSeconds (Abs_Time)));
Result := pthread_cond_timedwait
(Cond.CV'Access, L.mutex'Access, TV'Access);
pragma Assert
(Result /= FUNC_ERR, "GNULLI failure---pthread_cond_timedwait");
end Cond_Timed_Wait;
-----------------
-- Cond_Signal --
-----------------
procedure Cond_Signal (Cond : in out Condition_Variable) is
Result : int;
begin
Result := pthread_cond_signal (Cond.CV'Access);
pragma Assert
(Result /= FUNC_ERR, "GNULLI failure---pthread_cond_signal");
end Cond_Signal;
------------------
-- Set_Priority --
------------------
procedure Set_Priority
(T : TCB_Ptr;
Prio : System.Any_Priority) is
Result : int;
Thread : Pthreads.pthread_t renames T.Thread;
begin
Result := pthread_setprio (Thread, int (Prio));
pragma Assert
(Result /= FUNC_ERR, "GNULLI failure---pthread_setprio");
end Set_Priority;
----------------------
-- Set_Own_Priority --
----------------------
procedure Set_Own_Priority (Prio : System.Any_Priority) is
begin
null;
-- ENOSYS Result :=
-- pthread_setprio (pthread_self, int (Prio));
-- pragma Assert
-- (Result /= FUNC_ERR, "GNULLI failure---pthread_setprio");
end Set_Own_Priority;
------------------
-- Get_Priority --
------------------
function Get_Priority (T : TCB_Ptr) return System.Any_Priority is
Priority : aliased int := 0;
begin
-- ENOSYS Result := pthread_getprio (T.Thread, Priority'Access);
-- pragma Assert
-- (Result /= FUNC_ERR, "GNULLI failure---pthread_getprio");
return System.Priority (Priority);
end Get_Priority;
-----------------------
-- Get_Own_Priority --
-----------------------
function Get_Own_Priority return System.Any_Priority is
Result : int;
Priority : aliased int := 0;
begin
Result := pthread_getprio (pthread_self, Priority'Access);
pragma Assert
(Result /= FUNC_ERR, "GNULLI failure---pthread_getprio");
return System.Priority (Priority);
end Get_Own_Priority;
--------------------
-- Create_LL_Task --
--------------------
procedure Create_LL_Task
(Priority : System.Any_Priority;
Stack_Size : Task_Storage_Size;
Task_Info : System.Task_Info.Task_Info_Type;
LL_Entry_Point : LL_Task_Procedure_Access;
Arg : System.Address;
T : TCB_Ptr) is
use Pthreads;
Attributes : aliased pthread_attr_t;
Result : int;
L_Priority : System.Any_Priority := Priority;
function To_Start_Addr is new
Unchecked_Conversion (System.Address, start_addr);
begin
T.LL_Entry_Point := LL_Entry_Point;
T.LL_Arg := Arg;
T.Stack_Size := Stack_Size;
Result := pthread_attr_init (Attributes'Access);
pragma Assert (Result /= FUNC_ERR, "GNULLI failure---pthread_attr_init");
-- Result := pthread_attr_setdetachstate (Attributes'Access, 1);
-- pragma Assert
-- (Result /= FUNC_ERR, "GNULLI failure---pthread_setdetachstate");
Result := pthread_attr_setstacksize
(Attributes'Access, size_t (Stack_Size));
pragma Assert
(Result /= FUNC_ERR, "GNULLI failure---pthread_setstacksize");
Result := pthread_attr_setinheritsched
(Attributes'Access, PTHREAD_DEFAULT_SCHED);
pragma Assert
(Result /= FUNC_ERR, "GNULLI failure---pthread_setinheritsched");
Result := pthread_attr_setsched
(Attributes'Access, SCHED_FIFO);
pragma Assert
(Result /= FUNC_ERR, "GNULLI failure---pthread_setinheritsched");
-- The following priority adjustment is a kludge to get around needing
-- root privileges to run at higher than 18 for FIFO or 19 for OTHER.
if (L_Priority > 18) then
L_Priority := 18;
elsif (L_Priority < 14) then
L_Priority := 14;
end if;
Result := pthread_attr_setprio
(Attributes'Access, int (L_Priority));
pragma Assert
(Result /= FUNC_ERR, "GNULLI failure---pthread_attr_setprio");
Result := pthread_create
(T.Thread'Access,
Attributes,
To_Start_Addr (LL_Wrapper'Address),
T.all'Address);
if Result = FUNC_ERR then
GNAT.IO.Put_Line ("pthread create failed");
raise Storage_Error;
end if;
pragma Assert (Result /= FUNC_ERR, "GNULLI failure---pthread_create");
Result := pthread_attr_destroy (Attributes'Access);
pragma Assert
(Result /= FUNC_ERR, "GNULLI failure---pthread_attr_destroy");
end Create_LL_Task;
-----------------
-- Exit_LL_Task --
------------------
procedure Exit_LL_Task is
begin
pthread_exit (System.Null_Address);
end Exit_LL_Task;
----------------
-- Abort_Task --
----------------
procedure Abort_Task (T : TCB_Ptr) is
Result : int;
begin
-- Result := pthread_kill (T.Thread);
-- pragma Assert
-- (Result /= FUNC_ERR, "GNULLI failure---pthread_kill");
null;
end Abort_Task;
----------------
-- Test_Abort --
----------------
-- This procedure does nothing. It is intended for systems without
-- asynchronous abortion, where the runtime system would have to
-- synchronously poll for pending abortions. This should be done
-- at least at every synchronization point.
procedure Test_Abort is
begin
null;
end Test_Abort;
---------------------------
-- Install_Abort_Handler --
---------------------------
procedure Install_Abort_Handler (Handler : Abort_Handler_Pointer) is
act : aliased RTE.struct_sigaction;
old_act : aliased RTE.struct_sigaction;
Result : POSIX_Error.Return_Code;
SA_SIGINFO : constant := 64;
use type POSIX_Error.Return_Code;
begin
Abort_Handler := Handler;
act.sa_flags := SA_SIGINFO;
act.sa_handler := Abort_Wrapper'Address;
RTE.sigemptyset (act.sa_mask'Access, Result);
pragma Assert (Result /= FUNC_ERR, "GNULLI failure---sigemptyset");
RTE.sigaction (Abort_Signal, act'Access, old_act'Access, Result);
pragma Assert (Result /= FUNC_ERR, "GNULLI failure---sigaction");
end Install_Abort_Handler;
-------------------
-- Abort_Wrapper --
-------------------
-- This is the handler called by the OS when an abort signal is
-- received; it in turn calls the handler installed by the client.
-- This procedure serves to isolate the client from the
-- implementation-specific calling conventions of asynchronous
-- handlers.
procedure Abort_Wrapper
(signo : Integer;
info : RTE.siginfo_ptr;
context : System.Address)
is
function Address_To_Call_State is new
Unchecked_Conversion (System.Address, Pre_Call_State);
begin
Abort_Handler (Address_To_Call_State (context));
end Abort_Wrapper;
---------------------------
-- Install_Error_Handler --
---------------------------
procedure Install_Error_Handler (Handler : System.Address) is
Temp : Address;
use Pthreads;
begin
-- Set up the soft links to tasking services used in the absence of
-- tasking. These replace tasking-free defaults.
Temp := TSL.Get_Jmpbuf_Address.all;
-- pthread_set_jumpbuf_address (Temp);
Temp := TSL.Get_Sec_Stack_Addr.all;
-- pthread_set_sec_stack_addr (Temp);
-- TSL.Get_Jmpbuf_Address := pthread_get_jumpbuf_address'Access;
-- TSL.Set_Jmpbuf_Address := pthread_set_jumpbuf_address'Access;
-- TSL.Get_Gnat_Exception := pthread_get_exception'Access;
-- TSL.Set_Gnat_Exception := pthread_set_exception'Access;
end Install_Error_Handler;
---------------
-- LL_Assert --
---------------
procedure LL_Assert (B : Boolean; M : String) is
begin
null;
end LL_Assert;
----------------
-- LL_Wrapper --
----------------
procedure LL_Wrapper (T : TCB_Ptr) is
Result : POSIX_Error.Return_Code;
Result1 : int;
Exc_Stack : String (1 .. 256);
Exc_Base : Address := Exc_Stack (Exc_Stack'Last)'Address + 1;
Old_Set : aliased RTE.Signal_Set;
begin
Result1 := pthread_setspecific (ATCB_Key, T.all'Address);
RTE.sigprocmask (
RTE.SIG_UNBLOCK, Unblocked_Signal_Mask'Access, Old_Set'Access, Result);
pragma Assert (
Result /= Failure, "GNULLI failure---sigprocmask");
-- Note that the following call may not return!
T.LL_Entry_Point (T.LL_Arg);
end LL_Wrapper;
--------------------------
-- Test and Set support --
--------------------------
procedure Initialize_TAS_Cell (Cell : out TAS_Cell) is
begin
Cell.Value := 0;
end Initialize_TAS_Cell;
procedure Finalize_TAS_Cell (Cell : in out TAS_Cell) is
begin
null;
end Finalize_TAS_Cell;
procedure Clear (Cell : in out TAS_Cell) is
begin
Cell.Value := 1;
end Clear;
procedure Test_And_Set (Cell : in out TAS_Cell; Result : out Boolean) is
Error : Boolean;
begin
Write_Lock (Test_And_Set_Mutex, Error);
if Cell.Value = 1 then
Result := False;
else
Result := True;
Cell.Value := 1;
end if;
Unlock (Test_And_Set_Mutex);
end Test_And_Set;
function Is_Set (Cell : in TAS_Cell) return Boolean is
begin
return Cell.Value = 1;
end Is_Set;
begin
Initialize_Lock (System.Any_Priority'Last, Test_And_Set_Mutex);
end System.Task_Primitives;
|
libsrc/strings/strrstrip.asm | grancier/z180 | 8 | 162864 | <reponame>grancier/z180
; CALLER linkage for function pointers
SECTION code_clib
PUBLIC strrstrip
PUBLIC _strrstrip
EXTERN strrstrip_callee
EXTERN ASMDISP_STRRSTRIP_CALLEE
.strrstrip
._strrstrip
pop de
pop bc
pop hl
push hl
push bc
push de
jp strrstrip_callee + ASMDISP_STRRSTRIP_CALLEE
|
src/common/keccak-generic_keccakf-byte_lanes-twisted.adb | damaki/libkeccak | 26 | 10713 | <filename>src/common/keccak-generic_keccakf-byte_lanes-twisted.adb
-------------------------------------------------------------------------------
-- Copyright (c) 2019, <NAME>
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
-- * Redistributions of source code must retain the above copyright
-- notice, this list of conditions and the following disclaimer.
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- * The name of the copyright holder may not be used to endorse or promote
-- Products derived from this software without specific prior written
-- permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
-- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------
package body Keccak.Generic_KeccakF.Byte_Lanes.Twisted is
Twist : constant array (Y_Coord, X_Coord) of X_Coord :=
(0 => (0 => 0,
1 => 1,
2 => 2,
3 => 3,
4 => 4),
1 => (0 => 3,
1 => 4,
2 => 0,
3 => 1,
4 => 2),
2 => (0 => 1,
1 => 2,
2 => 3,
3 => 4,
4 => 0),
3 => (0 => 4,
1 => 0,
2 => 1,
3 => 2,
4 => 3),
4 => (0 => 2,
1 => 3,
2 => 4,
3 => 0,
4 => 1));
-- Twist mapping for the X coordinate.
--
-- The twisted Y coordinate is equal to the un-twisted X coordinate.
-----------------------------------
-- XOR_Bits_Into_State_Twisted --
-----------------------------------
procedure XOR_Bits_Into_State_Twisted (A : in out State;
Data : in Keccak.Types.Byte_Array;
Bit_Len : in Natural)
is
use type Keccak.Types.Byte;
Remaining_Bits : Natural := Bit_Len;
Offset : Natural := 0;
XT : X_Coord;
YT : Y_Coord;
begin
-- Process whole lanes (64 bits).
Outer_Loop :
for Y in Y_Coord loop
pragma Loop_Invariant ((Offset * 8) + Remaining_Bits = Bit_Len);
pragma Loop_Invariant (Offset mod (Lane_Size_Bits / 8) = 0);
pragma Loop_Invariant (Offset = Natural (Y) * (Lane_Size_Bits / 8) * 5);
for X in X_Coord loop
pragma Loop_Invariant ((Offset * 8) + Remaining_Bits = Bit_Len);
pragma Loop_Invariant (Offset mod (Lane_Size_Bits / 8) = 0);
pragma Loop_Invariant (Offset = (Natural (Y) * (Lane_Size_Bits / 8) * 5) +
(Natural (X) * (Lane_Size_Bits / 8)));
exit Outer_Loop when Remaining_Bits < Lane_Size_Bits;
declare
Lane : Lane_Type := 0;
begin
for I in Natural range 0 .. (Lane_Size_Bits / 8) - 1 loop
Lane := Lane or Shift_Left (Lane_Type (Data (Data'First + Offset + I)),
I * 8);
end loop;
XT := Twist (Y, X);
YT := Y_Coord (X);
A (XT, YT) := A (XT, YT) xor Lane;
end;
Offset := Offset + Lane_Size_Bits / 8;
Remaining_Bits := Remaining_Bits - Lane_Size_Bits;
end loop;
end loop Outer_Loop;
-- Process any remaining data (smaller than 1 lane - 64 bits)
if Remaining_Bits > 0 then
declare
X : constant X_Coord := X_Coord ((Bit_Len / Lane_Size_Bits) mod 5);
Y : constant Y_Coord := Y_Coord ((Bit_Len / Lane_Size_Bits) / 5);
Word : Lane_Type := 0;
Remaining_Bytes : constant Natural := (Remaining_Bits + 7) / 8;
begin
XT := Twist (Y, X);
YT := Y_Coord (X);
for I in Natural range 0 .. Remaining_Bytes - 1 loop
Word := Word or Shift_Left (Lane_Type (Data (Data'First + Offset + I)), I * 8);
end loop;
A (XT, YT) := A (XT, YT) xor (Word and (2**Remaining_Bits) - 1);
end;
end if;
end XOR_Bits_Into_State_Twisted;
-----------------------------------
-- XOR_Bits_Into_State_Twisted --
-----------------------------------
procedure XOR_Bits_Into_State_Twisted (A : in out Lane_Complemented_State;
Data : in Keccak.Types.Byte_Array;
Bit_Len : in Natural)
is
begin
XOR_Bits_Into_State_Twisted
(A => State (A),
Data => Data,
Bit_Len => Bit_Len);
end XOR_Bits_Into_State_Twisted;
-----------------------------------
-- XOR_Byte_Into_State_Twisted --
-----------------------------------
procedure XOR_Byte_Into_State_Twisted (A : in out State;
Offset : in Natural;
Value : in Keccak.Types.Byte)
is
Lane_Size_Bytes : constant Positive := Lane_Size_Bits / 8;
X : constant X_Coord := X_Coord ((Offset / Lane_Size_Bytes) mod 5);
Y : constant Y_Coord := Y_Coord (Offset / (Lane_Size_Bytes * 5));
XT : constant X_Coord := Twist (Y, X);
YT : constant Y_Coord := Y_Coord (X);
begin
A (XT, YT) := A (XT, YT) xor Shift_Left (Lane_Type (Value),
(Offset mod (Lane_Size_Bits / 8)) * 8);
end XOR_Byte_Into_State_Twisted;
---------------------------
-- XOR_Byte_Into_State_Twisted --
---------------------------
procedure XOR_Byte_Into_State_Twisted (A : in out Lane_Complemented_State;
Offset : in Natural;
Value : in Keccak.Types.Byte)
is
begin
XOR_Byte_Into_State_Twisted (State (A), Offset, Value);
end XOR_Byte_Into_State_Twisted;
-----------------------------
-- Extract_Bytes_Twisted --
-----------------------------
procedure Extract_Bytes_Twisted (A : in State;
Data : out Keccak.Types.Byte_Array)
is
use type Keccak.Types.Byte;
X : X_Coord := 0;
Y : Y_Coord := 0;
XT : X_Coord;
YT : Y_Coord;
Remaining_Bytes : Natural := Data'Length;
Offset : Natural := 0;
Lane : Lane_Type;
begin
-- Case when each lane is at least 1 byte (i.e. 8, 16, 32, or 64 bits)
-- Process whole lanes
Outer_Loop :
for Y2 in Y_Coord loop
pragma Loop_Invariant (Offset mod (Lane_Size_Bits / 8) = 0
and Offset + Remaining_Bytes = Data'Length);
for X2 in X_Coord loop
pragma Loop_Variant (Increases => Offset,
Decreases => Remaining_Bytes);
pragma Loop_Invariant (Offset mod (Lane_Size_Bits / 8) = 0
and Offset + Remaining_Bytes = Data'Length);
XT := Twist (Y2, X2);
YT := Y_Coord (X2);
if Remaining_Bytes < Lane_Size_Bits / 8 then
X := XT;
Y := YT;
exit Outer_Loop;
end if;
Lane := A (XT, YT);
for I in Natural range 0 .. (Lane_Size_Bits / 8) - 1 loop
Data (Data'First + Offset + I)
:= Keccak.Types.Byte (Shift_Right (Lane, I * 8) and 16#FF#);
pragma Annotate (GNATprove, False_Positive,
"""Data"" might not be initialized",
"Data is initialized at end of procedure");
end loop;
Remaining_Bytes := Remaining_Bytes - Lane_Size_Bits / 8;
Offset := Offset + Lane_Size_Bits / 8;
end loop;
end loop Outer_Loop;
-- Process any remaining data (smaller than 1 lane)
if Remaining_Bytes > 0 then
Lane := A (X, Y);
declare
Initial_Offset : constant Natural := Offset with Ghost;
Shift : Natural := 0;
begin
while Remaining_Bytes > 0 loop
pragma Loop_Variant (Increases => Offset,
Increases => Shift,
Decreases => Remaining_Bytes);
pragma Loop_Invariant (Offset + Remaining_Bytes = Data'Length
and Shift mod 8 = 0
and Shift = (Offset - Initial_Offset) * 8);
Data (Data'First + Offset)
:= Keccak.Types.Byte (Shift_Right (Lane, Shift) and 16#FF#);
pragma Annotate (GNATprove, False_Positive,
"""Data"" might not be initialized",
"Data is initialized at end of procedure");
Shift := Shift + 8;
Offset := Offset + 1;
Remaining_Bytes := Remaining_Bytes - 1;
end loop;
end;
end if;
end Extract_Bytes_Twisted;
-----------------------------
-- Extract_Bytes_Twisted --
-----------------------------
procedure Extract_Bytes_Twisted (A : in Lane_Complemented_State;
Data : out Keccak.Types.Byte_Array)
is
use type Keccak.Types.Byte;
Complement_Mask : constant Lane_Complemented_State :=
(0 => (4 => Lane_Type'Last,
others => 0),
1 => (0 => Lane_Type'Last,
others => 0),
2 => (0 | 2 | 3 => Lane_Type'Last,
others => 0),
3 => (1 => Lane_Type'Last,
others => 0),
4 => (others => 0));
-- Some lanes need to be complemented (bitwise NOT) when reading them
-- from the Keccak-f state. We do this by storing a mask of all 1's
-- for those lanes that need to be complemented (and all 0's for the
-- other lanes). We then XOR against the corresponding entry in this
-- Complement_Mask to complement only the required lanes (as XOR'ing
-- against all 1's has the same effect as bitwise NOT).
X : X_Coord := 0;
Y : Y_Coord := 0;
XT : X_Coord;
YT : Y_Coord;
Remaining_Bytes : Natural := Data'Length;
Offset : Natural := 0;
Lane : Lane_Type;
begin
-- Case when each lane is at least 1 byte (i.e. 8, 16, 32, or 64 bits)
-- Process whole lanes
Outer_Loop :
for Y2 in Y_Coord loop
pragma Loop_Invariant (Offset mod (Lane_Size_Bits / 8) = 0
and Offset + Remaining_Bytes = Data'Length);
for X2 in X_Coord loop
pragma Loop_Variant (Increases => Offset,
Decreases => Remaining_Bytes);
pragma Loop_Invariant (Offset mod (Lane_Size_Bits / 8) = 0
and Offset + Remaining_Bytes = Data'Length);
XT := Twist (Y2, X2);
YT := Y_Coord (X2);
if Remaining_Bytes < Lane_Size_Bits / 8 then
X := XT;
Y := YT;
exit Outer_Loop;
end if;
Lane := A (XT, YT) xor Complement_Mask (XT, YT);
for I in Natural range 0 .. (Lane_Size_Bits / 8) - 1 loop
Data (Data'First + Offset + I)
:= Keccak.Types.Byte (Shift_Right (Lane, I * 8) and 16#FF#);
pragma Annotate (GNATprove, False_Positive,
"""Data"" might not be initialized",
"Data is initialized at end of procedure");
end loop;
Remaining_Bytes := Remaining_Bytes - Lane_Size_Bits / 8;
Offset := Offset + Lane_Size_Bits / 8;
end loop;
end loop Outer_Loop;
-- Process any remaining data (smaller than 1 lane)
if Remaining_Bytes > 0 then
Lane := A (X, Y) xor Complement_Mask (X, Y);
declare
Initial_Offset : constant Natural := Offset with Ghost;
Shift : Natural := 0;
begin
while Remaining_Bytes > 0 loop
pragma Loop_Variant (Increases => Offset,
Increases => Shift,
Decreases => Remaining_Bytes);
pragma Loop_Invariant (Offset + Remaining_Bytes = Data'Length
and Shift mod 8 = 0
and Shift = (Offset - Initial_Offset) * 8);
Data (Data'First + Offset)
:= Keccak.Types.Byte (Shift_Right (Lane, Shift) and 16#FF#);
pragma Annotate (GNATprove, False_Positive,
"""Data"" might not be initialized",
"Data is initialized at end of procedure");
Shift := Shift + 8;
Offset := Offset + 1;
Remaining_Bytes := Remaining_Bytes - 1;
end loop;
end;
end if;
end Extract_Bytes_Twisted;
--------------------
-- Extract_Bits --
--------------------
procedure Extract_Bits_Twisted (A : in State;
Data : out Keccak.Types.Byte_Array;
Bit_Len : in Natural)
is
use type Keccak.Types.Byte;
begin
Extract_Bytes_Twisted (A, Data);
-- Avoid exposing more bits than requested by masking away higher bits
-- in the last byte.
if Bit_Len > 0 and Bit_Len mod 8 /= 0 then
Data (Data'Last) := Data (Data'Last) and (2**(Bit_Len mod 8) - 1);
end if;
end Extract_Bits_Twisted;
--------------------
-- Extract_Bits --
--------------------
procedure Extract_Bits_Twisted (A : in Lane_Complemented_State;
Data : out Keccak.Types.Byte_Array;
Bit_Len : in Natural)
is
use type Keccak.Types.Byte;
begin
Extract_Bytes_Twisted (A, Data);
-- Avoid exposing more bits than requested by masking away higher bits
-- in the last byte.
if Bit_Len > 0 and Bit_Len mod 8 /= 0 then
Data (Data'Last) := Data (Data'Last) and (2**(Bit_Len mod 8) - 1);
end if;
end Extract_Bits_Twisted;
end Keccak.Generic_KeccakF.Byte_Lanes.Twisted;
|
Transynther/x86/_processed/NONE/_zr_/i7-8650U_0xd2_notsx.log_18_1642.asm | ljhsiun2/medusa | 9 | 22196 | .global s_prepare_buffers
s_prepare_buffers:
push %r13
push %r15
push %r8
push %r9
push %rbx
push %rdx
push %rsi
lea addresses_WT_ht+0x1ce96, %r13
add %rbx, %rbx
movups (%r13), %xmm4
vpextrq $1, %xmm4, %r15
nop
cmp $29464, %rsi
lea addresses_A_ht+0xd67e, %rbx
nop
nop
nop
nop
add $18769, %r15
mov (%rbx), %si
xor $22358, %rdx
lea addresses_WT_ht+0xa1f2, %r8
nop
nop
nop
and %r9, %r9
mov $0x6162636465666768, %rdx
movq %rdx, (%r8)
nop
nop
dec %r9
lea addresses_UC_ht+0x196e2, %r8
clflush (%r8)
nop
nop
nop
add %r13, %r13
mov (%r8), %esi
nop
nop
nop
nop
sub %r15, %r15
lea addresses_WC_ht+0x6234, %rsi
clflush (%rsi)
nop
nop
nop
sub %rdx, %rdx
vmovups (%rsi), %ymm4
vextracti128 $0, %ymm4, %xmm4
vpextrq $0, %xmm4, %r9
nop
nop
nop
nop
nop
inc %rdx
lea addresses_WC_ht+0x6396, %r13
nop
nop
nop
xor %rbx, %rbx
mov $0x6162636465666768, %r15
movq %r15, %xmm6
movups %xmm6, (%r13)
nop
nop
sub $3699, %rbx
pop %rsi
pop %rdx
pop %rbx
pop %r9
pop %r8
pop %r15
pop %r13
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r13
push %r14
push %r9
push %rax
push %rbx
push %rsi
// Load
lea addresses_US+0x170fe, %r14
nop
nop
nop
dec %rax
mov (%r14), %rbx
and %r14, %r14
// Store
lea addresses_A+0x1996, %rsi
clflush (%rsi)
nop
add $51282, %r13
mov $0x5152535455565758, %r12
movq %r12, %xmm3
vmovups %ymm3, (%rsi)
nop
nop
nop
nop
sub $49556, %r14
// Store
lea addresses_RW+0x15496, %r13
nop
nop
nop
cmp $20798, %r9
movb $0x51, (%r13)
dec %rsi
// Store
mov $0x45d7020000000c96, %r14
nop
nop
inc %rax
movl $0x51525354, (%r14)
xor $6232, %rax
// Load
lea addresses_US+0x5e96, %r12
nop
nop
nop
nop
xor $43678, %r9
vmovups (%r12), %ymm4
vextracti128 $0, %ymm4, %xmm4
vpextrq $1, %xmm4, %rsi
nop
nop
nop
nop
nop
sub $11609, %r9
// Load
lea addresses_normal+0x68a, %r13
nop
cmp %r14, %r14
mov (%r13), %si
nop
nop
nop
sub %rax, %rax
// Load
lea addresses_WT+0xe96, %r12
nop
nop
add $65333, %r14
movb (%r12), %bl
xor $38799, %rax
// Store
lea addresses_normal+0x15296, %r12
nop
nop
nop
nop
nop
add $126, %r13
movw $0x5152, (%r12)
nop
nop
dec %r12
// Faulty Load
lea addresses_A+0x6696, %r12
nop
nop
nop
and %rsi, %rsi
vmovups (%r12), %ymm4
vextracti128 $1, %ymm4, %xmm4
vpextrq $1, %xmm4, %rbx
lea oracles, %rsi
and $0xff, %rbx
shlq $12, %rbx
mov (%rsi,%rbx,1), %rbx
pop %rsi
pop %rbx
pop %rax
pop %r9
pop %r14
pop %r13
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_A', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_US', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_RW', 'size': 1, 'AVXalign': False, 'NT': True, 'congruent': 9, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_NC', 'size': 4, 'AVXalign': True, 'NT': False, 'congruent': 3, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_US', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 8, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_A', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 9, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'size': 4, 'AVXalign': True, 'NT': False, 'congruent': 1, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}}
{'00': 18}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
programs/oeis/103/A103532.asm | neoneye/loda | 22 | 2873 | <reponame>neoneye/loda
; A103532: Number of divisors of 240^n.
; 1,20,81,208,425,756,1225,1856,2673,3700,4961,6480,8281,10388,12825,15616,18785,22356,26353,30800,35721,41140,47081,53568,60625,68276,76545,85456,95033,105300,116281,128000,140481,153748,167825,182736
mul $0,4
add $0,2
mov $2,$0
mov $3,$0
add $0,3
mul $2,$3
mul $0,$2
div $0,16
|
src/Univalence-axiom/Isomorphism-is-equality/Monoid.agda | nad/equality | 3 | 15833 | ------------------------------------------------------------------------
-- Isomorphism of monoids on sets coincides with equality (assuming
-- univalence)
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
-- This module has been developed in collaboration with Thierry
-- Coquand.
open import Equality
module Univalence-axiom.Isomorphism-is-equality.Monoid
{reflexive} (eq : ∀ {a p} → Equality-with-J a p reflexive) where
open import Bijection eq using (_↔_; Σ-≡,≡↔≡; ↑↔)
open Derived-definitions-and-properties eq
open import Equivalence eq as Eq using (_≃_)
open import Function-universe eq hiding (id)
open import H-level eq
open import H-level.Closure eq
open import Prelude hiding (id)
open import Univalence-axiom eq
-- Monoid laws (including the assumption that the carrier type is a
-- set).
Is-monoid : (C : Type) → (C → C → C) → C → Type
Is-monoid C _∙_ id =
-- C is a set.
Is-set C ×
-- Left and right identity laws.
(∀ x → (id ∙ x) ≡ x) ×
(∀ x → (x ∙ id) ≡ x) ×
-- Associativity.
(∀ x y z → (x ∙ (y ∙ z)) ≡ ((x ∙ y) ∙ z))
-- Monoids (on sets).
Monoid : Type₁
Monoid =
-- Carrier.
Σ Type λ C →
-- Binary operation.
Σ (C → C → C) λ _∙_ →
-- Identity.
Σ C λ id →
-- Laws.
Is-monoid C _∙_ id
-- The carrier type.
Carrier : Monoid → Type
Carrier M = proj₁ M
-- The binary operation.
op : (M : Monoid) → Carrier M → Carrier M → Carrier M
op M = proj₁ (proj₂ M)
-- The identity element.
id : (M : Monoid) → Carrier M
id M = proj₁ (proj₂ (proj₂ M))
-- The monoid laws.
laws : (M : Monoid) → Is-monoid (Carrier M) (op M) (id M)
laws M = proj₂ (proj₂ (proj₂ M))
-- Monoid morphisms.
Is-homomorphism :
(M₁ M₂ : Monoid) → (Carrier M₁ → Carrier M₂) → Type
Is-homomorphism M₁ M₂ f =
(∀ x y → f (op M₁ x y) ≡ op M₂ (f x) (f y)) ×
(f (id M₁) ≡ id M₂)
-- Monoid isomorphisms.
_≅_ : Monoid → Monoid → Type
M₁ ≅ M₂ =
Σ (Carrier M₁ ↔ Carrier M₂) λ f →
Is-homomorphism M₁ M₂ (_↔_.to f)
-- The monoid laws are propositional (assuming extensionality).
laws-propositional :
Extensionality (# 0) (# 0) →
(M : Monoid) →
Is-proposition (Is-monoid (Carrier M) (op M) (id M))
laws-propositional ext M =
×-closure 1 (H-level-propositional ext 2)
(×-closure 1 (Π-closure ext 1 λ _ →
is-set)
(×-closure 1 (Π-closure ext 1 λ _ →
is-set)
(Π-closure ext 1 λ _ →
Π-closure ext 1 λ _ →
Π-closure ext 1 λ _ →
is-set)))
where is-set = proj₁ (laws M)
-- Monoid equality is isomorphic to equality of the carrier sets,
-- binary operations and identity elements, suitably transported
-- (assuming extensionality).
equality-triple-lemma :
Extensionality (# 0) (# 0) →
(M₁ M₂ : Monoid) →
M₁ ≡ M₂ ↔
Σ (Carrier M₁ ≡ Carrier M₂) λ C-eq →
subst (λ C → C → C → C) C-eq (op M₁) ≡ op M₂ ×
subst (λ C → C) C-eq (id M₁) ≡ id M₂
equality-triple-lemma
ext (C₁ , op₁ , id₁ , laws₁) (C₂ , op₂ , id₂ , laws₂) =
((C₁ , op₁ , id₁ , laws₁) ≡ (C₂ , op₂ , id₂ , laws₂)) ↔⟨ inverse $ Eq.≃-≡ $ Eq.↔⇒≃ bij ⟩
(((C₁ , op₁ , id₁) , laws₁) ≡ ((C₂ , op₂ , id₂) , laws₂)) ↝⟨ inverse $ ignore-propositional-component $
laws-propositional ext (C₂ , op₂ , id₂ , laws₂) ⟩
((C₁ , op₁ , id₁) ≡ (C₂ , op₂ , id₂)) ↝⟨ inverse Σ-≡,≡↔≡ ⟩
(Σ (C₁ ≡ C₂) λ C-eq →
subst (λ C → (C → C → C) × C) C-eq (op₁ , id₁) ≡ (op₂ , id₂)) ↝⟨ ∃-cong (λ _ → ≡⇒↝ _ $ cong (λ x → x ≡ _) $
push-subst-, (λ C → C → C → C) (λ C → C)) ⟩
(Σ (C₁ ≡ C₂) λ C-eq →
(subst (λ C → C → C → C) C-eq op₁ , subst (λ C → C) C-eq id₁) ≡
(op₂ , id₂)) ↝⟨ ∃-cong (λ _ → inverse ≡×≡↔≡) ⟩□
(Σ (C₁ ≡ C₂) λ C-eq →
subst (λ C → C → C → C) C-eq op₁ ≡ op₂ ×
subst (λ C → C) C-eq id₁ ≡ id₂) □
where
bij =
(Σ Type λ C → Σ (C → C → C) λ op → Σ C λ id → Is-monoid C op id) ↝⟨ ∃-cong (λ _ → Σ-assoc) ⟩
(Σ Type λ C → Σ ((C → C → C) × C) λ { (op , id) →
Is-monoid C op id }) ↝⟨ Σ-assoc ⟩□
(Σ (Σ Type λ C → (C → C → C) × C) λ { (C , op , id) →
Is-monoid C op id }) □
-- If two monoids are isomorphic, then they are equal (assuming
-- univalence).
isomorphic-equal :
Univalence (# 0) →
Univalence (# 1) →
(M₁ M₂ : Monoid) → M₁ ≅ M₂ → M₁ ≡ M₂
isomorphic-equal univ univ₁ M₁ M₂ (bij , bij-op , bij-id) = goal
where
open _≃_
-- Our goal:
goal : M₁ ≡ M₂
-- Extensionality follows from univalence.
ext : Extensionality (# 0) (# 0)
ext = dependent-extensionality univ₁ univ
-- Hence the goal follows from monoids-equal-if, if we can prove
-- three equalities.
C-eq : Carrier M₁ ≡ Carrier M₂
op-eq : subst (λ A → A → A → A) C-eq (op M₁) ≡ op M₂
id-eq : subst (λ A → A) C-eq (id M₁) ≡ id M₂
goal = _↔_.from (equality-triple-lemma ext M₁ M₂)
(C-eq , op-eq , id-eq)
-- Our bijection can be converted into an equivalence.
equiv : Carrier M₁ ≃ Carrier M₂
equiv = Eq.↔⇒≃ bij
-- Hence the first equality follows directly from univalence.
C-eq = ≃⇒≡ univ equiv
-- For the second equality, let us first define a "cast" operator.
cast₂ : {A B : Type} → A ≃ B → (A → A → A) → (B → B → B)
cast₂ eq f = λ x y → to eq (f (from eq x) (from eq y))
-- The transport theorem implies that cast₂ equiv can be expressed
-- using subst.
cast₂-equiv-is-subst :
∀ f → cast₂ equiv f ≡ subst (λ A → A → A → A) C-eq f
cast₂-equiv-is-subst f =
transport-theorem (λ A → A → A → A) cast₂ refl univ equiv f
-- The second equality op-eq follows from extensionality,
-- cast₂-equiv-is-subst, and the fact that the bijection is a
-- monoid homomorphism.
op-eq = apply-ext ext λ x → apply-ext ext λ y →
subst (λ A → A → A → A) C-eq (op M₁) x y ≡⟨ cong (λ f → f x y) $ sym $ cast₂-equiv-is-subst (op M₁) ⟩
to equiv (op M₁ (from equiv x) (from equiv y)) ≡⟨ bij-op (from equiv x) (from equiv y) ⟩
op M₂ (to equiv (from equiv x)) (to equiv (from equiv y)) ≡⟨ cong₂ (op M₂) (right-inverse-of equiv x) (right-inverse-of equiv y) ⟩∎
op M₂ x y ∎
-- The development above can be repeated for the identity
-- elements.
cast₀ : {A B : Type} → A ≃ B → A → B
cast₀ eq x = to eq x
cast₀-equiv-is-subst : ∀ x → cast₀ equiv x ≡ subst (λ A → A) C-eq x
cast₀-equiv-is-subst x =
transport-theorem (λ A → A) cast₀ refl univ equiv x
id-eq =
subst (λ A → A) C-eq (id M₁) ≡⟨ sym $ cast₀-equiv-is-subst (id M₁) ⟩
to equiv (id M₁) ≡⟨ bij-id ⟩∎
id M₂ ∎
-- Equality of monoids is in fact in bijective correspondence with
-- isomorphism of monoids (assuming univalence).
isomorphism-is-equality :
Univalence (# 0) →
Univalence (# 1) →
(M₁ M₂ : Monoid) → (M₁ ≅ M₂) ↔ (M₁ ≡ M₂)
isomorphism-is-equality univ univ₁
(C₁ , op₁ , id₁ , laws₁) (C₂ , op₂ , id₂ , laws₂) =
(Σ (C₁ ↔ C₂) λ f → Is-homomorphism M₁ M₂ (_↔_.to f)) ↝⟨ Σ-cong (Eq.↔↔≃ ext C₁-set) (λ _ → _ □) ⟩
(Σ (C₁ ≃ C₂) λ C-eq → Is-homomorphism M₁ M₂ (_≃_.to C-eq)) ↝⟨ ∃-cong (λ C-eq → op-lemma C-eq ×-cong id-lemma C-eq) ⟩
(Σ (C₁ ≃ C₂) λ C-eq →
subst (λ C → C → C → C) (≃⇒≡ univ C-eq) op₁ ≡ op₂ ×
subst (λ C → C) (≃⇒≡ univ C-eq) id₁ ≡ id₂) ↝⟨ inverse $ Σ-cong (≡≃≃ univ) (λ C-eq → ≡⇒↝ _ $
cong (λ eq → subst (λ C → C → C → C) eq op₁ ≡ op₂ ×
subst (λ C → C) eq id₁ ≡ id₂) $ sym $
_≃_.left-inverse-of (≡≃≃ univ) C-eq) ⟩
(Σ (C₁ ≡ C₂) λ C-eq →
subst (λ C → C → C → C) C-eq op₁ ≡ op₂ ×
subst (λ C → C) C-eq id₁ ≡ id₂) ↝⟨ inverse $ equality-triple-lemma ext M₁ M₂ ⟩
((C₁ , op₁ , id₁ , laws₁) ≡ (C₂ , op₂ , id₂ , laws₂)) □
where
-- The two monoids.
M₁ = (C₁ , op₁ , id₁ , laws₁)
M₂ = (C₂ , op₂ , id₂ , laws₂)
-- Extensionality follows from univalence.
ext : Extensionality (# 0) (# 0)
ext = dependent-extensionality univ₁ univ
-- C₁ is a set.
C₁-set : Is-set C₁
C₁-set = proj₁ laws₁
module _ (C-eq : C₁ ≃ C₂) where
open _≃_ C-eq
-- Two component lemmas.
op-lemma :
(∀ x y → to (op₁ x y) ≡ op₂ (to x) (to y)) ↔
subst (λ C → C → C → C) (≃⇒≡ univ C-eq) op₁ ≡ op₂
op-lemma =
(∀ x y → to (op₁ x y) ≡ op₂ (to x) (to y)) ↔⟨ ∀-cong ext (λ _ → Eq.extensionality-isomorphism ext) ⟩
(∀ x → (λ y → to (op₁ x y)) ≡ (λ y → op₂ (to x) (to y))) ↝⟨ ∀-cong ext (λ _ → inverse $ ∘from≡↔≡∘to ext C-eq) ⟩
(∀ x → (λ y → to (op₁ x (from y))) ≡ (λ y → op₂ (to x) y)) ↔⟨ Eq.extensionality-isomorphism ext ⟩
((λ x y → to (op₁ x (from y))) ≡ (λ x y → op₂ (to x) y)) ↝⟨ inverse $ ∘from≡↔≡∘to ext C-eq ⟩
((λ x y → to (op₁ (from x) (from y))) ≡ (λ x y → op₂ x y)) ↝⟨ ≡⇒↝ _ $ cong (λ o → o ≡ op₂) $
transport-theorem
(λ C → C → C → C)
(λ eq f x y → _≃_.to eq (f (_≃_.from eq x) (_≃_.from eq y)))
refl univ C-eq op₁ ⟩
(subst (λ C → C → C → C) (≃⇒≡ univ C-eq) op₁ ≡ op₂) □
id-lemma : (to id₁ ≡ id₂) ↔
(subst (λ C → C) (≃⇒≡ univ C-eq) id₁ ≡ id₂)
id-lemma =
(to id₁ ≡ id₂) ↝⟨ ≡⇒↝ _ $ cong (λ i → i ≡ id₂) $
transport-theorem (λ C → C) _≃_.to refl univ C-eq id₁ ⟩□
(subst (λ C → C) (≃⇒≡ univ C-eq) id₁ ≡ id₂) □
-- Equality of monoids is thus equal to equality (assuming
-- univalence).
isomorphism-is-equal-to-equality :
Univalence (# 0) →
Univalence (# 1) →
(M₁ M₂ : Monoid) → ↑ _ (M₁ ≅ M₂) ≡ (M₁ ≡ M₂)
isomorphism-is-equal-to-equality univ univ₁ M₁ M₂ =
≃⇒≡ univ₁ $ Eq.↔⇒≃ (
↑ _ (M₁ ≅ M₂) ↝⟨ ↑↔ ⟩
(M₁ ≅ M₂) ↝⟨ isomorphism-is-equality univ univ₁ M₁ M₂ ⟩□
(M₁ ≡ M₂) □)
|
test/fixtures/asm.asm | majacQ/retroputer | 58 | 167964 | <filename>test/fixtures/asm.asm
.segment test-nop 0x02000 {
nop {$00}
brk {$3F}
}
# test-not-db-0.regs: CL=0xF0
# test-not-db-0.flags: N+ Z-
.segment test-not-db-1 0x02000 {
ld cl, 0x0F
not cl
brk
}
# test-not-db-1.regs: AL=0xF0
# test-not-db-1.flags: N+ Z-
.segment test-not-db-1 0x02000 {
ld al, 0x0F
not al
brk
}
# test-not-db-2.regs: AL=0xFF
# test-not-db-2.flags: N+ Z-
.segment test-not-db-2 0x02000 {
ld al, 0x00
not al
brk
}
# test-not-db-3.regs: AL=0x00
# test-not-db-3.flags: N- Z+
.segment test-not-db-3 0x02000 {
ld al, 0xFF
not al
brk
}
# test-neg-db-0.regs: CL=0xF1
# test-neg-db-0.flags: N+ Z-
.segment test-neg-db-1 0x02000 {
ld cl, 0x0F
neg cl
brk
}
# test-neg-db-1.regs: AL=0xF1
# test-neg-db-1.flags: N+ Z-
.segment test-neg-db-1 0x02000 {
ld al, 0x0F
neg al
brk
}
# test-neg-db-2.regs: AL=0x00
# test-neg-db-2.flags: N- Z+
.segment test-neg-db-2 0x02000 {
ld al, 0x00
neg al
brk
}
# test-neg-db-3.regs: AL=0xFF
# test-neg-db-3.flags: N+ Z-
.segment test-neg-db-3 0x02000 {
ld al, 0x01
neg al
brk
}
# test-neg-db-4.regs: AL=0x01
# test-neg-db-4.flags: N- Z-
.segment test-neg-db-4 0x02000 {
ld al, 0xFF
neg al
brk
}
# test-not-dw-0.regs: C=0xFFF0
# test-not-dw-0.flags: N+ Z-
.segment test-not-dw-1 0x02000 {
ld c, 0x000F
not c
brk
}
# test-not-dw-1.regs: A=0xFFF0
# test-not-dw-1.flags: N+ Z-
.segment test-not-dw-1 0x02000 {
ld a, 0x000F
not a
brk
}
# test-not-dw-2.regs: A=0xFFFF
# test-not-dw-2.flags: N+ Z-
.segment test-not-dw-2 0x02000 {
ld a, 0
not a
brk
}
# test-not-dw-3.regs: A=0x0000
# test-not-dw-3.flags: N- Z+
.segment test-not-dw-3 0x02000 {
ld a, 0xFFFF
not a
brk
}
# test-neg-dw-0.regs: C=0xFFF1
# test-neg-dw-0.flags: N+ Z-
.segment test-neg-dw-1 0x02000 {
ld c, 0xF
neg c
brk
}
# test-neg-dw-1.regs: A=0xFFF1
# test-neg-dw-1.flags: N+ Z-
.segment test-neg-dw-1 0x02000 {
ld a, 0xF
neg a
brk
}
# test-neg-dw-2.regs: A=0x0000
# test-neg-dw-2.flags: N- Z+
.segment test-neg-dw-2 0x02000 {
ld a, 0x0000
neg a
brk
}
# test-neg-dw-3.regs: A=0xFFFF
# test-neg-dw-3.flags: N+ Z-
.segment test-neg-dw-3 0x02000 {
ld a, 0x1
neg a
brk
}
# test-neg-dw-4.regs: A=0x0001
# test-neg-dw-4.flags: N- Z-
.segment test-neg-dw-4 0x02000 {
ld a, 0xFFFF
neg a
brk
}
# test-exc-db-1.regs: BL=0xF0
# text-exc-db-1.flags: N+ Z-
.segment test-exc-db-1 0x02000 {
ld bl, 0x0F
exc bl
brk
}
# test-exc-dw-1.regs: B=0x1200
# text-exc-dw-1.flags: N- Z-
.segment test-exc-dw-1 0x02000 {
ld b, 0x0012
exc b
brk
}
# test-cmp-dw-1.regs: A=0x0123 B=0x0123
# test-cmp-dw-1.flags: C- Z+ N-
.segment test-cmp-dw-1 0x02000 {
ld a, 0x0123 {$10 $00 $01 $23}
ld b, 0x0123 {$12 $00 $01 $23}
cmp a, b {$03 $02}
brk {$3F}
}
# test-cmp-dw-2.regs: A=0x0123 B=0x0124
# test-cmp-dw-2.flags: C+ Z- N+
.segment test-cmp-dw-2 0x02000 {
ld a, 0x0123 {$10 $00 $01 $23}
ld b, 0x0124 {$12 $00 $01 $24}
cmp a, b {$03 $02}
brk {$3F}
}
# test-cmp-dw-3.regs: A=0x0123 B=0x0122
# test-cmp-dw-3.flags: C- Z- N-
.segment test-cmp-dw-3 0x02000 {
ld a, 0x0123 {$10 $00 $01 $23}
ld b, 0x0122 {$12 $00 $01 $22}
cmp a, b {$03 $02}
brk {$3F}
}
# test-cmp-dw-4.regs: A=0x0001 B=0xFFFF
# test-cmp-dw-4.flags: C+ Z- N-
.segment test-cmp-dw-4 0x02000 {
ld a, 0x0001 {$10 $00 $00 $01}
ld b, 0xFFFF {$12 $00 $FF $FF}
cmp a, b {$03 $02}
brk {$3F}
}
# test-cmp-dw-5.regs: A=0x0001
# test-cmp-dw-5.flags: C+ Z- N-
.segment test-cmp-dw-5 0x02000 {
ld a, 0x0001 {$10 $00 $00 $01}
cmp a, 0xFFFF {$58 $FF $FF}
brk {$3F}
}
# test-cmp-flags-1.regs: A=0x2000 B=0x2001
# test-cmp-flags-1.flags: Z- N+
.segment test-cmp-flags-1 0x02000 {
ld a, 0x2000
ld b, 0x2001
set c # set c -- cmp shouldn't be affected
cmp a, b # a is <= b, so N should be set, Z should be clear
brk
}
# test-load-and-add-dw-1.regs: A=0x0246 B=0x0123
# test-load-and-add-dw-1.flags: C- Z- N- V-
.segment test-load-and-add-dw-1 0x02000 {
ld a, 0x0123 {$10 $00 $01 $23}
ld b, 0x0123 {$12 $00 $01 $23}
add a, b {$01 $02}
brk {$3F}
}
# test-load-and-add-db-1.regs: AL=0x46 BL=0x23
# test-load-and-add-db-1.flags: C- Z- N- V-
.segment test-load-and-add-db-1 0x02000 {
ld al, 0x23 {$11 $00 $23}
ld bl, 0x23 {$13 $00 $23}
add al, bl {$01 $13}
brk {$3F}
}
# test-load-and-add-dw-2.regs: A=0x0246
# test-load-and-add-dw-2.flags: C- Z- N- V-
.segment test-load-and-add-dw-2 0x02000 {
ld a, 0x0123 {$10 $00 $01 $23}
add a, 0x0123 {$48 $01 $23}
brk {$3F}
}
# test-load-dw-1.regs: A=0x0000
.segment test-load-dw-1 0x02000 {
ld a, 0x0000 {$10 $00 $00 $00}
brk {$3F}
}
# test-load-and-store-dw-1.regs: A=0x1234 B=0x1234
.segment test-load-and-store-dw-1 0x02000 {
ld b, 0x1234 {$12 $00 $12 $34}
st [0x01000], b {$22 $40 $10 $00}
ld a, [0x01000] {$10 $40 $10 $00}
brk {$3F}
}
# test-load-and-store-dw-3.regs: A=0x1234 B=0x1234 D=0x0010
.segment test-load-and-store-dw-3 0x02000 {
ld b, 0x1234 {$12 $00 $12 $34}
ld d, 0x0010 {$16 $00 $00 $10}
st [d], b {$22 $C0 $00 $00}
ld a, [d] {$10 $C0 $00 $00}
brk {$3F}
}
# test-load-and-store-dw-2.regs: A=0x2345 B=0x2345
.segment test-load-and-store-dw-2 0x02000 {
b := 0 {$12 $00 $00 $00}
[0x01000] := b {$22 $40 $10 $00}
ld b, 0x1234 {$12 $00 $12 $34}
st [0x01002], b {$22 $40 $10 $02}
ld b, 0x2345 {$12 $00 $23 $45}
st [0x01234], b {$22 $40 $12 $34}
ld a, <0x01000> {$10 $60 $10 $00}
brk {$3F}
}
# test-dec-from-zero.regs: A=0xFFFF
# test-dec-from-zero.flags: C+
.segment test-dec-from-zero 0x02000 {
ld a, 0x0000 {$10 $00 $00 $00}
dec a {$D0}
brk {$3F}
}
# test-dec-from-max-word.regs: C=0xFFFE
# test-dec-from-max-word.flags: C-
.segment test-dec-from-max-word 0x02000 {
ld c, 0xFFFF {$14 $00 $FF $FF}
dec c {$D4}
brk {$3F}
}
# test-dec-from-zero-3.regs: C=0x7FFF
# test-dec-from-zero-3.flags: C-
.segment test-dec-from-zero-3 0x02000 {
ld c, 0x8000 {$14 $00 $80 $00}
dec c {$D4}
brk {$3F}
}
# test-dec-with-carry.regs: A=0x0FFF
# test-dec-with-carry.flags: Z-
.segment test-dec-with-carry 0x02000 {
ld a, 0x1000
set c
dec a
brk
}
# test-inc-with-carry.regs: A=0x1001
# test-inc-with-carry.flags: Z
.segment test-inc-with-carry 0x02000 {
ld a, 0x1000
set c
inc a
brk
}
# test-div-by-zero.regs: A=0x0 B=0
# test-div-by-zero.flags: EX+
.segment test-div-by-zero 0x02000 {
ld a, 0x1000
ld b, 0
div a, b
brk
} |
libsrc/_DEVELOPMENT/math/float/math32/lm32/z80/asm_fabsf.asm | jpoikela/z88dk | 640 | 90327 | <filename>libsrc/_DEVELOPMENT/math/float/math32/lm32/z80/asm_fabsf.asm
; float _fabsf (float number) __z88dk_fastcall
SECTION code_clib
SECTION code_fp_math32
PUBLIC asm_fabsf
EXTERN m32_fabs_fastcall
; Takes the absolute value of a float
;
; enter : stack = ret
; DEHL = sccz80_float number
;
; exit : DEHL = |sccz80_float|
;
; uses : de, hl
defc asm_fabsf = m32_fabs_fastcall
|
Transynther/x86/_processed/NONE/_xt_/i7-8650U_0xd2.log_13057_322.asm | ljhsiun2/medusa | 9 | 20453 | .global s_prepare_buffers
s_prepare_buffers:
push %r13
push %r8
push %rax
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_WC_ht+0x1e814, %r13
nop
nop
nop
nop
nop
and $25703, %rax
movups (%r13), %xmm3
vpextrq $0, %xmm3, %r8
nop
nop
nop
nop
nop
sub $48815, %rcx
lea addresses_UC_ht+0x1eeb4, %rsi
lea addresses_D_ht+0x1448a, %rdi
nop
nop
nop
dec %rbx
mov $108, %rcx
rep movsq
nop
nop
and $7135, %rbx
lea addresses_normal_ht+0x2ba4, %rsi
lea addresses_WC_ht+0x8974, %rdi
inc %r13
mov $120, %rcx
rep movsw
nop
nop
nop
inc %rbx
lea addresses_A_ht+0x4234, %rcx
nop
nop
nop
nop
nop
cmp %rbx, %rbx
movb (%rcx), %r8b
nop
cmp $9433, %rbx
lea addresses_UC_ht+0x1c534, %rsi
nop
nop
nop
nop
inc %rax
movw $0x6162, (%rsi)
nop
add %r13, %r13
lea addresses_normal_ht+0x154e5, %r13
xor %r8, %r8
movw $0x6162, (%r13)
and %rdi, %rdi
lea addresses_WC_ht+0x19294, %rcx
nop
nop
xor $62148, %rdi
movl $0x61626364, (%rcx)
inc %rsi
lea addresses_UC_ht+0x118f4, %rax
add $61617, %rsi
mov (%rax), %rcx
nop
nop
nop
xor $29779, %rbx
lea addresses_D_ht+0x18044, %rsi
lea addresses_D_ht+0x36b4, %rdi
nop
nop
nop
nop
add $45018, %r8
mov $97, %rcx
rep movsq
nop
nop
inc %rcx
lea addresses_WC_ht+0x1cb5e, %r13
clflush (%r13)
nop
nop
nop
nop
nop
and %rdi, %rdi
mov (%r13), %bx
xor %rbx, %rbx
lea addresses_D_ht+0x3a44, %rcx
nop
nop
nop
nop
nop
add $2802, %r13
mov $0x6162636465666768, %rbx
movq %rbx, %xmm0
movups %xmm0, (%rcx)
nop
nop
nop
nop
and $45495, %rbx
lea addresses_UC_ht+0x7434, %rdi
add $57665, %rsi
movl $0x61626364, (%rdi)
nop
cmp $51766, %rcx
lea addresses_UC_ht+0x3786, %r13
nop
nop
nop
nop
nop
inc %rsi
mov (%r13), %rax
dec %rcx
lea addresses_D_ht+0xc6b4, %r8
nop
nop
nop
nop
nop
add $37757, %rax
mov (%r8), %r13d
nop
nop
nop
and $9418, %r13
lea addresses_WT_ht+0xc004, %rdi
cmp %r13, %r13
mov (%rdi), %eax
nop
nop
nop
dec %r8
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r8
pop %r13
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r15
push %r8
push %r9
push %rax
push %rbx
push %rdx
// Store
lea addresses_normal+0x10d34, %rdx
nop
inc %rax
movl $0x51525354, (%rdx)
nop
nop
nop
cmp $26780, %rdx
// Faulty Load
lea addresses_normal+0x1d6b4, %rbx
inc %r9
mov (%rbx), %r8
lea oracles, %r10
and $0xff, %r8
shlq $12, %r8
mov (%r10,%r8,1), %r8
pop %rdx
pop %rbx
pop %rax
pop %r9
pop %r8
pop %r15
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'size': 16, 'AVXalign': True, 'NT': False, 'congruent': 0, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal', 'size': 4, 'AVXalign': True, 'NT': False, 'congruent': 1, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 1, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 5, 'same': True}}
{'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'size': 1, 'AVXalign': False, 'NT': True, 'congruent': 7, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'size': 2, 'AVXalign': True, 'NT': False, 'congruent': 0, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 9, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': True}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 4, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 3, 'same': True}}
{'34': 13057}
34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34
*/
|
software/application/disktest.asm | JCLemme/eprisc | 0 | 102737 | <reponame>JCLemme/eprisc<filename>software/application/disktest.asm
; epRISC development platform - MBR and ext2 testing routines
;
; written by <NAME>, jclemme (at) proportionallabs (dot) com
; this file is part of the epRISC project, released under the epRISC license - see "license.txt" for details.
;
; Test routines for reading the Master Boot Record of a disk and loading an ext2 partition from a disk.
!ip h00004000
!def BUS_BASE_ADDRESS h2000
; Vector table - makes jumping in from Lemon easy
:jdsk_gparts brch.a a:dsk_gparts
:jdsk_rsuper brch.a a:dsk_rsuper
!zone dsk_gparts
!def REG_DADR %Zw
!def REG_STRA %Zx
!def REG_TEMP %Zy
!def REG_RESP %Zz
:dsk_gparts push.r s:REG_DADR
push.r s:REG_STRA
push.r s:REG_TEMP
move.v d:REG_DADR v:#h8000 ; Where the disk image starts
addr.v d:REG_DADR a:REG_DADR v:#h7F ; Look for the MBR signature
move.v d:REG_TEMP v:#hFFFF
load.o d:REG_STRA r:REG_DADR
andb.r d:REG_STRA a:REG_STRA b:REG_TEMP
move.v d:REG_TEMP v:#h55AA
cmpr.r a:REG_STRA b:REG_TEMP ; Is MBR signature valid?
brch.a c:%EQL a:.goodmbr ; If so, do something about it
move.v d:%Yw v:dsk_strcrrpt ; Disk is corrupt
push.r s:%Yw
call.s a:str_puts
pops.r d:%Yw ; Print the crash message
brch.a a:.exit ; And abort
:.goodmbr move.v d:%Yw v:dsk_strvalid ; Disk is valid
push.r s:%Yw
call.s a:str_puts
pops.r d:%Yw ; Print the acceptance message
subr.v d:REG_DADR a:REG_DADR v:#h7F ; Get the disk offset back
move.v d:%Yw v:dsk_strplabl ; "Partition"
push.r s:%Yw
call.s a:str_puts
pops.r d:%Yw
move.v d:REG_TEMP v:#h01
push.r s:REG_TEMP
call.s a:str_hnum
pops.r d:REG_TEMP ; Partition number
move.v d:%Yw v:dsk_strplabn ; ":"
push.r s:%Yw
call.s a:str_puts
pops.r d:%Yw
addr.v d:REG_DADR a:REG_DADR v:#h70 ; Block with the partition ID
load.o d:REG_STRA r:REG_DADR
masr.v d:REG_STRA a:REG_STRA v:#hFF s:#h04 ; Get said partition ID
cmpr.v a:REG_STRA v:#h00
brch.a c:%NEQ a:.prespart
move.v d:%Yw v:dsk_strempty ; Partition isn't there
push.r s:%Yw
call.s a:str_puts
pops.r d:%Yw ; Print the empty message
brch.a a:.exit ; And abort
:.prespart move.v d:%Yw v:dsk_strtypen ; Partition is there
push.r s:%Yw
call.s a:str_puts
pops.r d:%Yw ; "Partition type is"
push.r s:REG_STRA
call.s a:str_hnum
pops.r d:REG_STRA ; Partition type
move.v d:%Yw v:dsk_strplabd ; "."
push.r s:%Yw
call.s a:str_puts
pops.r d:%Yw
addr.v d:REG_DADR a:REG_DADR v:#h01 ; The starting sector lives in the next word
load.o d:REG_STRA r:REG_DADR
arsl.v d:REG_STRA a:REG_STRA v:#h10
addr.v d:REG_DADR a:REG_DADR v:#h01 ; The rest of the starting sector lives in the next word
load.o d:REG_TEMP r:REG_DADR
push.r s:REG_STRA
move.v d:REG_STRA v:#hFFFF
andb.r d:REG_TEMP a:REG_TEMP b:REG_STRA
losr.v d:REG_TEMP a:REG_TEMP v:#h10
pops.r d:REG_STRA
orbt.r d:REG_STRA a:REG_STRA b:REG_TEMP ; REASSEMBLE
; endx.r d:REG_STRA a:REG_STRA ; Value is stored little-endian, so convert that into something we can use
move.v d:%Yw v:dsk_strloadn
push.r s:%Yw
call.s a:str_puts
pops.r d:%Yw ; "Partition starts at"
push.r s:REG_STRA
call.s a:str_hnum
pops.r d:REG_STRA ; Partition start LBA
move.v d:%Yw v:dsk_strplabd
push.r s:%Yw
call.s a:str_puts
pops.r d:%Yw ; "."
load.o d:REG_STRA r:REG_DADR
arsl.v d:REG_STRA a:REG_STRA v:#h10
addr.v d:REG_DADR a:REG_DADR v:#h01 ; The rest of the run length lives in the next word
load.o d:REG_TEMP r:REG_DADR
push.r s:REG_STRA
move.v d:REG_STRA v:#hFFFF
andb.r d:REG_TEMP a:REG_TEMP b:REG_STRA
losr.v d:REG_TEMP a:REG_TEMP v:#h10
pops.r d:REG_STRA
orbt.r d:REG_STRA a:REG_STRA b:REG_TEMP ; REASSEMBLE
; endx.r d:REG_STRA a:REG_STRA ; Value is stored little-endian, so convert that into something we can use
move.v d:%Yw v:dsk_strlengn
push.r s:%Yw
call.s a:str_puts
pops.r d:%Yw ; "Partition runs for"
push.r s:REG_STRA
call.s a:str_hnum
pops.r d:REG_STRA ; Partition length in LBA
move.v d:%Yw v:dsk_strplabs
push.r s:%Yw
call.s a:str_puts
pops.r d:%Yw ; "sectors."
:.exit pops.r d:REG_TEMP
pops.r d:REG_STRA
pops.r d:REG_DADR
rtrn.s ; And return
!zone dsk_rsuper
!def REG_DADR %Zw
!def REG_STRA %Zx
!def REG_TEMP %Zy
!def REG_RESP %Zz
:dsk_rsuper push.r s:REG_DADR
push.r s:REG_STRA
push.r s:REG_TEMP
move.v d:REG_DADR v:#h48000 ; Where the partition starts
addr.v d:REG_DADR a:REG_DADR v:#h10 s:#h02 ; The superblock begins 100 words ahead of the partition start
addr.v d:REG_DADR a:REG_DADR v:#h0E ; Look for the magic number
load.o d:REG_STRA r:REG_DADR
; endx.r d:REG_STRA a:REG_STRA
move.v d:REG_TEMP v:#hFFFF
andb.r d:REG_STRA a:REG_STRA b:REG_TEMP
move.v d:REG_TEMP v:#hEF53
cmpr.r a:REG_STRA b:REG_TEMP
brch.a c:%EQL a:.goodsblk ; Jump away if the superblock is present
move.v d:%Yw v:dsk_xbadblock
push.r s:%Yw
call.s a:str_puts
pops.r d:%Yw ; Bad superblock
brch.a a:.exit
:.goodsblk move.v d:%Yw v:dsk_xgudblock
push.r s:%Yw
call.s a:str_puts
pops.r d:%Yw ; Good superblock
move.v d:%Yw v:dsk_xlabelbeg
push.r s:%Yw
call.s a:str_puts
pops.r d:%Yw ; "Disk"
subr.v d:REG_DADR a:REG_DADR v:#h0E
addr.v d:REG_DADR a:REG_DADR v:#h1E ; Volume label
push.r s:REG_DADR
call.s a:str_puts
pops.r d:REG_DADR
move.v d:%Yw v:dsk_xlabelend
push.r s:%Yw
call.s a:str_puts
pops.r d:%Yw ; "loaded"
subr.v d:REG_DADR a:REG_DADR v:#h1E
addr.v d:REG_DADR a:REG_DADR v:#h1E ; Volume label
; Read block size
; Read blocks per group
; Read inodes per group
; Read starting block of first group
; Find inode's block group
; Block_group = (inode - 1) / inodes_per_group
; Read block group descriptor for inode's block group
; Extract location of block group's inode table
; Find index of inode in inode table
; index = (inode - 1) % inodes_per_group
; Index inode table
:.exit pops.r d:REG_TEMP
pops.r d:REG_STRA
pops.r d:REG_DADR
rtrn.s ; And return
:dsk_strcrrpt !str "MBR appears corrupt.\n\r\0"
:dsk_strvalid !str "MBR is valid.\n\r\0"
:dsk_strplabl !str "Partition \0"
:dsk_strplabn !str ":\n\r\0"
:dsk_strplabd !str ".\n\r\0"
:dsk_strplabr !str "\n\r\0"
:dsk_strplabs !str " sectors.\n\r\0"
:dsk_strempty !str " Partition is not present.\n\r\0"
:dsk_strtypen !str " Partition type is \0"
:dsk_strloadn !str " Partition starts at \0"
:dsk_strlengn !str " Partition runs for \0"
:dsk_xbadblock !str "Superblock is corrupt.\n\r\0"
:dsk_xgudblock !str "Superblock is present.\n\r\0"
:dsk_xlabelbeg !str "Mounting partition \"\0"
:dsk_xlabelend !str "\"...\n\r\0"
!include "../rom/bios_bus.asm"
!include "../rom/bios_uart.asm"
!include "../rom/bios_string.asm"
!include "../rom/bios_video.asm"
|
tools/scitools/conf/understand/ada/ada83/sequential_io.ads | brucegua/moocos | 1 | 8132 | <filename>tools/scitools/conf/understand/ada/ada83/sequential_io.ads
with IO_EXCEPTIONS;
generic
type ELEMENT_TYPE is private;
package SEQUENTIAL_IO is
type FILE_TYPE is limited private;
type FILE_MODE is (IN_FILE, OUT_FILE);
-- File management
procedure CREATE(FILE : in out FILE_TYPE;
MODE : in FILE_MODE := OUT_FILE;
NAME : in STRING := "";
FORM : in STRING := "");
procedure OPEN (FILE : in out FILE_TYPE;
MODE : in FILE_MODE;
NAME : in STRING;
FORM : in STRING := "");
procedure CLOSE (FILE : in out FILE_TYPE);
procedure DELETE(FILE : in out FILE_TYPE);
procedure RESET (FILE : in out FILE_TYPE;
MODE : in FILE_MODE);
procedure RESET (FILE : in out FILE_TYPE);
function MODE (FILE : in FILE_TYPE) return FILE_MODE;
function NAME (FILE : in FILE_TYPE) return STRING;
function FORM (FILE : in FILE_TYPE) return STRING;
function IS_OPEN(FILE : in FILE_TYPE) return BOOLEAN;
-- Input and output operations
procedure READ (FILE : in FILE_TYPE; ITEM : out ELEMENT_TYPE);
procedure WRITE (FILE : in FILE_TYPE; ITEM : in ELEMENT_TYPE);
function END_OF_FILE(FILE : in FILE_TYPE) return BOOLEAN;
-- Exceptions
STATUS_ERROR : exception renames IO_EXCEPTIONS.STATUS_ERROR;
MODE_ERROR : exception renames IO_EXCEPTIONS.MODE_ERROR;
NAME_ERROR : exception renames IO_EXCEPTIONS.NAME_ERROR;
USE_ERROR : exception renames IO_EXCEPTIONS.USE_ERROR;
DEVICE_ERROR : exception renames IO_EXCEPTIONS.DEVICE_ERROR;
END_ERROR : exception renames IO_EXCEPTIONS.END_ERROR;
DATA_ERROR : exception renames IO_EXCEPTIONS.DATA_ERROR;
private
type FILE_TYPE is new integer;
-- implementation-dependent
end SEQUENTIAL_IO;
|
polynomial/clenshaw/factorial.adb | jscparker/math_packages | 30 | 16129 | <reponame>jscparker/math_packages
-----------------------------------------------------------------------
-- package body Factorial. Use Stieltjes' continued fraction to get Log of N!
-- Copyright (C) 2018 <NAME>
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
---------------------------------------------------------------------------
with Ada.Numerics.Generic_Elementary_Functions;
package body Factorial is
package Maths is new Ada.Numerics.Generic_Elementary_Functions (Real);
use Maths;
Zero : constant Real := +0.0;
One : constant Real := +1.0;
-- Coefficients for the Stieltjes continued fraction gamma function.
-- The "+" functions can be used to translate the nums to an extended
-- precision floating point.
--
-- A call to the test routine verifies that the b's have not mutated.
b00 : constant Real := Zero;
b01 : constant Real := One / (+12.0);
b02 : constant Real := One / (+30.0);
b03 : constant Real := (+53.0) / (+210.0);
b04 : constant Real := (+195.0) / (+371.0);
b05 : constant Real := (+22999.0) / (+22737.0);
b06 : constant Real := (+29944523.0) / (+19733142.0);
b07 : constant Real := (+109535241009.0) / (+48264275462.0);
b08 : constant Real :=
+3.009917383259398170073140734207715727373474076764904290594203015613;
b09 : constant Real :=
+4.026887192343901226168875953181442836326602212574471272142220773421;
b10 : constant Real :=
+5.002768080754030051688502412276188574812183167579805723221777492737;
b11 : constant Real :=
+6.283911370815782180072663154951647264278439820333187714994251481107;
b12 : constant Real :=
+7.495919122384033929752354708267505465745798697815425327954440696079;
Half_Log_Two_Pi : constant Real :=
+0.918938533204672741780329736405617639861397473637783412817151540483;
--+0.918938533204672741780329736405617639861397473637783412817151540483;
---------------------------------
-- Log_Factorial_Table_0_to_32 --
---------------------------------
subtype Factorial_Table_Range is Natural range 0 .. 32;
type Table is array (Factorial_Table_Range) of Real;
-- A call to the test routine verifies that the table has not mutated.
Log_Factorial_Table_0_to_32 : constant Table :=
(0.0,
0.0,
0.69314718055994530941723212145817656807550013436025525412068000949,
1.79175946922805500081247735838070227272299069218300470585537434313,
3.17805383034794561964694160129705540887399096090351521409673436211,
4.78749174278204599424770093452324304839959231517203293600938225359,
6.57925121201010099506017829290394532112258300735503764186475659672,
8.52516136106541430016553103634712505075966773693689883032414674666,
10.60460290274525022841722740072165475498616814001766459268618677514,
12.80182748008146961120771787456670616428114925566316349615557544241,
15.10441257307551529522570932925107037188225074429193647218890334338,
17.50230784587388583928765290721619967170395759822935364740747105251,
19.98721449566188614951736238705507851250244842477261360738352540513,
22.55216385312342288557084982862039711730771636953282072380257091580,
25.19122118273868150009343469352175341502030123347493716638264107523,
27.89927138384089156608943926367046675919339314556620434002998330034,
30.67186010608067280375836774950317303149539368300722535651270333831,
33.50507345013688888400790236737629956708359669559297014380994107619,
36.39544520803305357621562496267952754445407794559872430140000975296,
39.33988418719949403622465239456738108169145720689785311993796998937,
42.33561646075348502965987597070992185736805882988688135009197789983,
45.38013889847690802616047395107562729165263411729149199028606238341,
48.47118135183522387963964965049893315954984110558916441962531010203,
51.60667556776437357044640248230912927799222142042960016162394547952,
54.78472939811231919009334408360618468686621238133311537572067984163,
58.00360522298051993929486275005855996591741508987015081954597562458,
61.26170176100200198476558231308205513879818316899061319008570114474,
64.55753862700633105895131802384963225274065484245886154528978414565,
67.88974313718153498289113501020916511852873984076123324199053431458,
71.25703896716800901007440704257107672402325275468397732091220466622,
74.65823634883016438548764373417796663627184480113549974868022690082,
78.09222355331531063141680805872032384672178373161609172043694497330,
81.55795945611503717850296866601120668709928440341736799104034502077);
type CF_Coeff_range is range 0 .. 12;
type CF_Coeff is array(CF_Coeff_range) of Real;
---------------------------------
-- Evaluate_Continued_Fraction --
---------------------------------
-- no attempt here to prevent overflow
-- CF_value := a0 + b1/(a1 + b2/(a2 + b3/( ...)))
procedure Evaluate_Continued_Fraction
(CF_value : out Real;
Truncation_Error : out Real;
a, b : in CF_Coeff;
Max_Term_in_Series : in CF_Coeff_Range := CF_Coeff_Range'Last;
Error_Estimate_Desired : in Boolean := False)
is
P, Q : array (-1 .. Max_Term_in_Series) of Real;
begin
Q(-1) := Zero;
Q(0) := One;
P(-1) := One;
P(0) := a(0);
for j in 1 .. Max_Term_in_Series loop
P(j) := a(j) * P(j-1) + b(j) * P(j-2);
Q(j) := a(j) * Q(j-1) + b(j) * Q(j-2);
end loop;
CF_value := P(Max_Term_in_Series) / Q(Max_Term_in_Series);
Truncation_Error := Zero;
if Error_Estimate_Desired then
Truncation_Error :=
CF_value - P(Max_Term_in_Series-1) / Q(Max_Term_in_Series-1);
end if;
end Evaluate_Continued_Fraction;
-------------------
-- Log_Factorial --
-------------------
-- For x < 33, uses table for log (factorial).
-- For x >= 33, uses Stieltjes' continued fraction gamma:
--
-- gamma(N) := (N-1)!
-- gamma(m+1) := m!
--
-- Stieltjes' continued fraction gamma:
--
-- good to 21 sig figures for x > 10
--
-- Estimate based on trunc_error, and on comparison with rational
-- poly-gamma function, but approximate!
function Log_Factorial (N : in Natural) return Real is
x : constant Real := Real (N + 1); -- so gamma(x) = N!
a : constant CF_Coeff := (Zero, others => x);
b : constant CF_Coeff :=
(b00, b01, b02, b03, b04, b05, b06, b07, b08, b09, b10, b11, b12);
CF, Trunc_Error, Log_Kernal_x, Log_Gamma_x : Real;
begin
if N < 0 then raise Constraint_Error; end if;
if N in Factorial_Table_Range then
return Log_Factorial_Table_0_to_32 (N);
end if;
-- For testing. these 3 should give identical answers:
-- CF := (1.0/12.0)/(x + (1.0/30.0)/(x + (53.0/210.0)/(x + (195.0/371.0)/x)));
-- CF := a(0) + b(1)/(a(1) + b(2)/(a(2) + b(3)/(a(3) + b(4)/(a(4)))));
-- Evaluate_Continued_Fraction (CF, Trunc_Error, a, b, 4, True);
Evaluate_Continued_Fraction (CF, Trunc_Error, a, b, CF_Coeff_range'Last, False);
--Evaluate_Continued_Fraction (CF, Trunc_Error, a, b, CF_Coeff_range'Last, True);
--text_io.put_line(Real'image(Trunc_Error));
Log_Kernal_x := Half_Log_Two_Pi + (x - 0.5)*Log (x) - x;
Log_Gamma_x := Log_Kernal_x + CF;
return Log_Gamma_x;
end Log_Factorial;
-- Make sure that CF_Coeff's have not mutated:
procedure Test_Stieltjes_Coefficients
is
Difference : Real;
Numerator : constant CF_Coeff :=
(0.0, 1.0, 1.0, 53.0, 195.0, 22999.0, 29944523.0, 109535241009.0,
29404527905795295658.0,
455377030420113432210116914702.0,
26370812569397719001931992945645578779849.0,
152537496709054809881638897472985990866753853122697839.0,
100043420063777451042472529806266909090824649341814868347109676190691.0);
Denominator : constant CF_Coeff :=
(1.0, 12.0, 30.0, 210.0, 371.0, 22737.0, 19733142.0, 48264275462.0,
9769214287853155785.0,
113084128923675014537885725485.0,
5271244267917980801966553649147604697542.0,
24274291553105128438297398108902195365373879212227726.0,
13346384670164266280033479022693768890138348905413621178450736182873.0);
B_coeff : constant CF_Coeff :=
(b00, b01, b02, b03, b04, b05, b06, b07, b08, b09, b10, b11, b12);
begin
for i in CF_Coeff_range loop
Difference := B_coeff(i) - Numerator(i) / Denominator(i);
if Abs Difference > 4.0 * Real'Epsilon then
raise Program_Error;
end if;
end loop;
end Test_Stieltjes_Coefficients;
procedure Test_Log_Factorial_Table is
Factorial : Real := 1.0;
Max_Err, Err : Real := 0.0;
begin
for i in Factorial_Table_Range loop
Err := Abs (Log_Factorial_Table_0_to_32(i) - Log (Factorial));
if Err > Max_Err then
Max_Err := Err;
end if;
Factorial := Factorial * Real (i+1);
end loop;
if Max_Err > 16.0 * Real'Epsilon then
raise Program_Error;
end if;
end Test_Log_Factorial_Table;
end Factorial;
|
oeis/032/A032441.asm | loda-lang/loda-programs | 11 | 85979 | ; A032441: a(n) = Sum_{i=0..2} binomial(Fibonacci(n),i).
; Submitted by <NAME>(w1)
; 1,2,2,4,7,16,37,92,232,596,1541,4006,10441,27262,71254,186356,487579,1276004,3339821,8742472,22885996,59912932,156848617,410626154,1075018897,2814412826,7368190922,19290113572,50502074767,132215989336,346145696821,906220783316
seq $0,45 ; Fibonacci numbers: F(n) = F(n-1) + F(n-2) with F(0) = 0 and F(1) = 1.
add $0,1
mov $1,$0
sub $0,1
mul $1,$0
mov $0,$1
div $0,2
add $0,1
|
tests/missions-test_data-tests-mission_container.ads | thindil/steamsky | 80 | 4636 | <filename>tests/missions-test_data-tests-mission_container.ads<gh_stars>10-100
package Missions.Test_Data.Tests.Mission_Container is
end Missions.Test_Data.Tests.Mission_Container;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.