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 |
|---|---|---|---|---|
Transynther/x86/_processed/NONE/_un_/i9-9900K_12_0xa0.log_3_785.asm | ljhsiun2/medusa | 9 | 25590 | .global s_prepare_buffers
s_prepare_buffers:
push %r8
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_WT_ht+0x1c83, %rsi
lea addresses_UC_ht+0x133e3, %rdi
and %rdx, %rdx
mov $53, %rcx
rep movsb
nop
nop
inc %r8
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %r8
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r12
push %r15
push %rax
push %rbp
// Faulty Load
lea addresses_A+0x193af, %r15
nop
nop
nop
nop
sub $47044, %r12
vmovups (%r15), %ymm6
vextracti128 $1, %ymm6, %xmm6
vpextrq $0, %xmm6, %rbp
lea oracles, %r15
and $0xff, %rbp
shlq $12, %rbp
mov (%r15,%rbp,1), %rbp
pop %rbp
pop %rax
pop %r15
pop %r12
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_A', 'AVXalign': False, 'size': 16}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_A', 'AVXalign': False, 'size': 32}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'same': False, 'congruent': 2, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 2, 'type': 'addresses_UC_ht'}}
{'cd': 1, 'db': 1, '81': 1}
cd 81 db
*/
|
Task/Tokenize-a-string/AppleScript/tokenize-a-string.applescript | LaudateCorpus1/RosettaCodeData | 1 | 3353 | on run {}
intercalate(".", splitOn(",", "Hello,How,Are,You,Today"))
end run
-- splitOn :: String -> String -> [String]
on splitOn(strDelim, strMain)
set {dlm, my text item delimiters} to {my text item delimiters, strDelim}
set lstParts to text items of strMain
set my text item delimiters to dlm
return lstParts
end splitOn
-- intercalate :: String -> [String] -> String
on intercalate(strText, lstText)
set {dlm, my text item delimiters} to {my text item delimiters, strText}
set strJoined to lstText as text
set my text item delimiters to dlm
return strJoined
end intercalate
|
cc65/add/add.asm | rcmolina/AppleII_tools | 0 | 85303 | <filename>cc65/add/add.asm
CLC ; CLEAR CARRY BIT
CLD ; CLEAR DECIMAL BIT
ADR1 = $6100 ; WHERE IN MEMORY ARE THESE THINGS
ADR2 = $6101
ADR3 = $6102
; check results in basic with PRINT PEEK(24834)
LDA #01
STA ADR1 ;load ADR1 with the value 1
LDA #02
STA ADR2 ;load ADR2 with the value 2
LDA ADR1 ; LOAD CONTENTS OF ADR1 INTO ACCUMULATOR
ADC ADR2 ; ADD CONTENTS OF ADR2 INTO ACCUMULATOR
STA ADR3 ; TRANSFER CONTENT OF ACC TO ADR3
RTS
|
Task/Odd-word-problem/Ada/odd-word-problem.ada | LaudateCorpus1/RosettaCodeData | 1 | 23496 | with Ada.Text_IO;
procedure Odd_Word_Problem is
use Ada.Text_IO; -- Get, Put, and Look_Ahead
function Current return Character is
-- reads the current input character, without consuming it
End_Of_Line: Boolean;
C: Character;
begin
Look_Ahead(C, End_Of_Line);
if End_Of_Line then
raise Constraint_Error with "end of line before the terminating '.'";
end if;
return C;
end Current;
procedure Skip is
-- consumes the current input character
C: Character;
begin
Get(C);
end Skip;
function Is_Alpha(Ch: Character) return Boolean is
begin
return (Ch in 'a' .. 'z') or (Ch in 'A' .. 'Z');
end Is_Alpha;
procedure Odd_Word(C: Character) is
begin
if Is_Alpha(C) then
Skip;
Odd_Word(Current);
Put(C);
end if;
end Odd_Word;
begin -- Odd_Word_Problem
Put(Current);
while Is_Alpha(Current) loop -- read an even word
Skip;
Put(Current);
end loop;
if Current /= '.' then -- read an odd word
Skip;
Odd_Word(Current);
Put(Current);
if Current /= '.' then -- read the remaining words
Skip;
Odd_Word_Problem;
end if;
end if;
end Odd_Word_Problem;
|
src/natools-web-simple_pages-markdown_pages.ads | faelys/lithium3 | 1 | 17957 | ------------------------------------------------------------------------------
-- Copyright (c) 2015-2019, <NAME> --
-- --
-- Permission to use, copy, modify, and 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. --
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- Natools.Web.Simple_Pages.Markdown_Pages extends simple pages with a new --
-- file format, starting with the usual simple-page S-expression embeded in --
-- a list, followed by markdown text which is rendered as the element --
-- named "markdown-text". --
------------------------------------------------------------------------------
with Natools.S_Expressions;
with Natools.Web.Sites;
private with Ada.Calendar;
private with Natools.S_Expressions.Atom_Refs;
package Natools.Web.Simple_Pages.Markdown_Pages is
type Loader is new Sites.Page_Loader with private;
overriding procedure Load
(Object : in out Loader;
Builder : in out Sites.Site_Builder;
Path : in S_Expressions.Atom);
not overriding procedure Force_Load
(Object : in out Loader;
Builder : in out Sites.Site_Builder;
Path : in S_Expressions.Atom);
function Create (File : in S_Expressions.Atom)
return Sites.Page_Loader'Class;
private
type Loader is new Sites.Page_Loader with record
File_Path : S_Expressions.Atom_Refs.Immutable_Reference;
File_Time : Ada.Calendar.Time;
Cache : Page_Ref;
end record;
end Natools.Web.Simple_Pages.Markdown_Pages;
|
Validation/pyFrame3DD-master/gcc-master/gcc/ada/back_end.adb | djamal2727/Main-Bearing-Analytical-Model | 0 | 27354 | <reponame>djamal2727/Main-Bearing-Analytical-Model
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- B A C K _ E N D --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2020, 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. 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 is the version of the Back_End package for GCC back ends
with Atree; use Atree;
with Debug; use Debug;
with Elists; use Elists;
with Errout; use Errout;
with Lib; use Lib;
with Osint; use Osint;
with Opt; use Opt;
with Osint.C; use Osint.C;
with Namet; use Namet;
with Nlists; use Nlists;
with Stand; use Stand;
with Sinput; use Sinput;
with Stringt; use Stringt;
with Switch; use Switch;
with Switch.C; use Switch.C;
with System; use System;
with Types; use Types;
with System.OS_Lib; use System.OS_Lib;
package body Back_End is
type Arg_Array is array (Nat) of Big_String_Ptr;
type Arg_Array_Ptr is access Arg_Array;
-- Types to access compiler arguments
flag_stack_check : Int;
pragma Import (C, flag_stack_check);
-- Indicates if stack checking is enabled, imported from misc.c
save_argc : Nat;
pragma Import (C, save_argc);
-- Saved value of argc (number of arguments), imported from misc.c
save_argv : Arg_Array_Ptr;
pragma Import (C, save_argv);
-- Saved value of argv (argument pointers), imported from misc.c
function Len_Arg (Arg : Pos) return Nat;
-- Determine length of argument number Arg on original gnat1 command line
-------------------
-- Call_Back_End --
-------------------
procedure Call_Back_End (Mode : Back_End_Mode_Type) is
-- The Source_File_Record type has a lot of components that are
-- meaningless to the back end, so a new record type is created
-- here to contain the needed information for each file.
type File_Info_Type is record
File_Name : File_Name_Type;
Instance : Instance_Id;
Num_Source_Lines : Nat;
end record;
File_Info_Array : array (1 .. Last_Source_File) of File_Info_Type;
procedure gigi
(gnat_root : Int;
max_gnat_node : Int;
number_name : Nat;
nodes_ptr : Address;
flags_ptr : Address;
next_node_ptr : Address;
prev_node_ptr : Address;
elists_ptr : Address;
elmts_ptr : Address;
strings_ptr : Address;
string_chars_ptr : Address;
list_headers_ptr : Address;
number_file : Nat;
file_info_ptr : Address;
gigi_standard_boolean : Entity_Id;
gigi_standard_integer : Entity_Id;
gigi_standard_character : Entity_Id;
gigi_standard_long_long_float : Entity_Id;
gigi_standard_exception_type : Entity_Id;
gigi_operating_mode : Back_End_Mode_Type);
pragma Import (C, gigi);
begin
-- Skip call if in -gnatdH mode
if Debug_Flag_HH then
return;
end if;
-- The back end needs to know the maximum line number that can appear
-- in a Sloc, in other words the maximum logical line number.
for J in 1 .. Last_Source_File loop
File_Info_Array (J).File_Name := Full_Debug_Name (J);
File_Info_Array (J).Instance := Instance (J);
File_Info_Array (J).Num_Source_Lines :=
Nat (Physical_To_Logical (Last_Source_Line (J), J));
end loop;
-- Deal with case of generating SCIL, we should not be here unless
-- debugging CodePeer mode in GNAT.
if Generate_SCIL then
Error_Msg_N ("'S'C'I'L generation not available", Cunit (Main_Unit));
if CodePeer_Mode
or else (Mode /= Generate_Object
and then not Back_Annotate_Rep_Info)
then
return;
end if;
end if;
-- We should be here in GNATprove mode only when debugging GNAT. Do not
-- call gigi in that case, as it is not prepared to handle the special
-- form of the tree obtained in GNATprove mode.
if GNATprove_Mode then
return;
end if;
-- The actual call to the back end
gigi
(gnat_root => Int (Cunit (Main_Unit)),
max_gnat_node => Int (Last_Node_Id - First_Node_Id + 1),
number_name => Name_Entries_Count,
nodes_ptr => Nodes_Address,
flags_ptr => Flags_Address,
next_node_ptr => Next_Node_Address,
prev_node_ptr => Prev_Node_Address,
elists_ptr => Elists_Address,
elmts_ptr => Elmts_Address,
strings_ptr => Strings_Address,
string_chars_ptr => String_Chars_Address,
list_headers_ptr => Lists_Address,
number_file => Num_Source_Files,
file_info_ptr => File_Info_Array'Address,
gigi_standard_boolean => Standard_Boolean,
gigi_standard_integer => Standard_Integer,
gigi_standard_character => Standard_Character,
gigi_standard_long_long_float => Standard_Long_Long_Float,
gigi_standard_exception_type => Standard_Exception_Type,
gigi_operating_mode => Mode);
end Call_Back_End;
-------------------------------
-- Gen_Or_Update_Object_File --
-------------------------------
procedure Gen_Or_Update_Object_File is
begin
null;
end Gen_Or_Update_Object_File;
-------------
-- Len_Arg --
-------------
function Len_Arg (Arg : Pos) return Nat is
begin
for J in 1 .. Nat'Last loop
if save_argv (Arg).all (Natural (J)) = ASCII.NUL then
return J - 1;
end if;
end loop;
raise Program_Error;
end Len_Arg;
-----------------------------
-- Scan_Compiler_Arguments --
-----------------------------
procedure Scan_Compiler_Arguments is
Next_Arg : Positive;
-- Next argument to be scanned
Arg_Count : constant Natural := Natural (save_argc - 1);
Args : Argument_List (1 .. Arg_Count);
Output_File_Name_Seen : Boolean := False;
-- Set to True after having scanned file_name for switch "-gnatO file"
procedure Scan_Back_End_Switches (Switch_Chars : String);
-- Procedure to scan out switches stored in Switch_Chars. The first
-- character is known to be a valid switch character, and there are no
-- blanks or other switch terminator characters in the string, so the
-- entire string should consist of valid switch characters, except that
-- an optional terminating NUL character is allowed.
--
-- Back end switches have already been checked and processed by GCC in
-- toplev.c, so no errors can occur and control will always return. The
-- switches must still be scanned to skip "-o" or internal GCC switches
-- with their argument.
----------------------------
-- Scan_Back_End_Switches --
----------------------------
procedure Scan_Back_End_Switches (Switch_Chars : String) is
First : constant Positive := Switch_Chars'First + 1;
Last : constant Natural := Switch_Last (Switch_Chars);
begin
-- Skip -o or internal GCC switches together with their argument
if Switch_Chars (First .. Last) = "o"
or else Is_Internal_GCC_Switch (Switch_Chars)
then
Next_Arg := Next_Arg + 1;
-- Store -G xxx as -Gxxx and go directly to the next argument
elsif Switch_Chars (First .. Last) = "G" then
Next_Arg := Next_Arg + 1;
-- Should never get there with -G not followed by an argument,
-- but use defensive code nonetheless. Store as -Gxxx to avoid
-- storing parameters in ALI files that might create confusion.
if Next_Arg <= Args'Last then
Store_Compilation_Switch (Switch_Chars & Args (Next_Arg).all);
end if;
-- Do not record -quiet switch
elsif Switch_Chars (First .. Last) = "quiet" then
null;
-- Store any other GCC switches. Also do special processing for some
-- specific switches that the Ada front-end knows about.
else
Store_Compilation_Switch (Switch_Chars);
-- For gcc back ends, -fno-inline disables Inline pragmas only,
-- not Inline_Always to remain consistent with the always_inline
-- attribute behavior.
if Switch_Chars (First .. Last) = "fno-inline" then
Opt.Disable_FE_Inline := True;
-- Back end switch -fpreserve-control-flow also sets the front end
-- flag that inhibits improper control flow transformations.
elsif Switch_Chars (First .. Last) = "fpreserve-control-flow" then
Opt.Suppress_Control_Flow_Optimizations := True;
-- Back end switch -fdump-scos, which exists primarily for C, is
-- also accepted for Ada as a synonym of -gnateS.
elsif Switch_Chars (First .. Last) = "fdump-scos" then
Opt.Generate_SCO := True;
Opt.Generate_SCO_Instance_Table := True;
elsif Switch_Chars (First) = 'g' then
Debugger_Level := 2;
if First < Last then
case Switch_Chars (First + 1) is
when '0' =>
Debugger_Level := 0;
when '1' =>
Debugger_Level := 1;
when '2' =>
Debugger_Level := 2;
when '3' =>
Debugger_Level := 3;
when others =>
null;
end case;
end if;
end if;
end if;
end Scan_Back_End_Switches;
-- Start of processing for Scan_Compiler_Arguments
begin
-- Acquire stack checking mode directly from GCC. The reason we do this
-- is to make sure that the indication of stack checking being enabled
-- is the same in the front end and the back end. This status obtained
-- from gcc is affected by more than just the switch -fstack-check.
Opt.Stack_Checking_Enabled := (flag_stack_check /= 0);
-- Put the arguments in Args
for Arg in Pos range 1 .. save_argc - 1 loop
declare
Argv_Ptr : constant Big_String_Ptr := save_argv (Arg);
Argv_Len : constant Nat := Len_Arg (Arg);
Argv : constant String :=
Argv_Ptr (1 .. Natural (Argv_Len));
begin
Args (Positive (Arg)) := new String'(Argv);
end;
end loop;
-- Loop through command line arguments, storing them for later access
Next_Arg := 1;
while Next_Arg <= Args'Last loop
Look_At_Arg : declare
Argv : constant String := Args (Next_Arg).all;
begin
-- If the previous switch has set the Output_File_Name_Present
-- flag (that is we have seen a -gnatO), then the next argument
-- is the name of the output object file.
if Output_File_Name_Present and then not Output_File_Name_Seen then
if Is_Switch (Argv) then
Fail ("Object file name missing after -gnatO");
else
Set_Output_Object_File_Name (Argv);
Output_File_Name_Seen := True;
end if;
-- If the previous switch has set the Search_Directory_Present
-- flag (that is if we have just seen -I), then the next argument
-- is a search directory path.
elsif Search_Directory_Present then
if Is_Switch (Argv) then
Fail ("search directory missing after -I");
else
Add_Src_Search_Dir (Argv);
Search_Directory_Present := False;
end if;
-- If not a switch, must be a file name
elsif not Is_Switch (Argv) then
Add_File (Argv);
-- We must recognize -nostdinc to suppress visibility on the
-- standard GNAT RTL sources. This is also a gcc switch.
elsif Argv (Argv'First + 1 .. Argv'Last) = "nostdinc" then
Opt.No_Stdinc := True;
Scan_Back_End_Switches (Argv);
-- We must recognize -nostdlib to suppress visibility on the
-- standard GNAT RTL objects.
elsif Argv (Argv'First + 1 .. Argv'Last) = "nostdlib" then
Opt.No_Stdlib := True;
elsif Is_Front_End_Switch (Argv) then
Scan_Front_End_Switches (Argv, Args, Next_Arg);
-- All non-front-end switches are back-end switches
else
Scan_Back_End_Switches (Argv);
end if;
end Look_At_Arg;
Next_Arg := Next_Arg + 1;
end loop;
end Scan_Compiler_Arguments;
end Back_End;
|
oeis/086/A086614.asm | neoneye/loda-programs | 11 | 27712 | <filename>oeis/086/A086614.asm<gh_stars>10-100
; A086614: Triangle read by rows, where T(n,k) is the coefficient of x^n*y^k in f(x,y) that satisfies f(x,y) = 1/(1-x)^2 + xy*f(x,y)^2.
; Submitted by <NAME>
; 1,2,1,3,4,2,4,10,12,5,5,20,42,40,14,6,35,112,180,140,42,7,56,252,600,770,504,132,8,84,504,1650,3080,3276,1848,429,9,120,924,3960,10010,15288,13860,6864,1430,10,165,1584,8580,28028,57330,73920,58344,25740
lpb $0
add $1,1
sub $0,$1
mov $2,$0
lpe
mul $0,2
add $0,1
add $1,$2
add $1,1
bin $1,$0
mov $0,2
mul $0,$2
bin $0,$2
add $2,1
div $0,$2
mul $1,$0
mov $0,$1
|
AOC/Meus Exercicios/Aula11/exercicio2.asm | joao-frohlich/BCC | 10 | 243838 | <filename>AOC/Meus Exercicios/Aula11/exercicio2.asm
.data
n_text: .asciiz "\nInsira valor de n: "
ans_text: .asciiz "Fib(n): "
.text
# <NAME>
.globl main
main:
ori $v0, $zero, 4 # call code para print_str
la $a0, n_text # carregando str para arg da syscall
syscall
ori $v0, $zero, 5 # call code para read_int
syscall
move $a0, $v0 # carregando valor da syscall para arg
slt $t0, $a0, $zero # if n < 0
bnez $t0, end
jal fib
move $s0, $v0
ori $v0, $zero, 4 # call code para print_str
la $a0, ans_text # carregando str para arg da syscall
syscall
ori $v0, $zero, 1 # call code para print_int
move $a0, $s0 # carregando valor de fib(n) para o arg da syscall
syscall
j main
end:
ori $v0, $zero, 10 # call code para exit
syscall
fib:
ori $v0, $zero, 0 # valor base
beqz $a0, fib_zero
ori $t2, $zero, 0 # contador
ori $t1, $zero, 1 # valor base
ori $t3, $a0, 0 # valor n
fib_loop:
move $t0, $v0
add $v0, $t1, $v0 # fib(n) = fib(n-1) + fib(n-2)
move $t1, $t0
addi $t2, $t2, 1 # contador++
slt $t0, $t2, $t3 # cont < n
bne $t0, $zero, fib_loop# saindo do loop
jr $ra
fib_zero:
jr $ra |
echo.asm | shahendahamdy/xv6-threads | 0 | 99647 |
_echo: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
#include "stat.h"
#include "user.h"
int
main(int argc, char *argv[])
{
0: f3 0f 1e fb endbr32
4: 8d 4c 24 04 lea 0x4(%esp),%ecx
8: 83 e4 f0 and $0xfffffff0,%esp
b: ff 71 fc pushl -0x4(%ecx)
e: 55 push %ebp
f: 89 e5 mov %esp,%ebp
11: 56 push %esi
12: 53 push %ebx
13: 51 push %ecx
14: 83 ec 0c sub $0xc,%esp
17: 8b 01 mov (%ecx),%eax
19: 8b 51 04 mov 0x4(%ecx),%edx
int i;
for(i = 1; i < argc; i++)
1c: 83 f8 01 cmp $0x1,%eax
1f: 7e 4b jle 6c <main+0x6c>
21: 8d 5a 04 lea 0x4(%edx),%ebx
24: 8d 34 82 lea (%edx,%eax,4),%esi
printf(1, "%s%s", argv[i], i+1 < argc ? " " : "\n");
27: 83 c3 04 add $0x4,%ebx
2a: 8b 43 fc mov -0x4(%ebx),%eax
2d: 39 f3 cmp %esi,%ebx
2f: 74 26 je 57 <main+0x57>
31: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
38: 68 68 08 00 00 push $0x868
3d: 83 c3 04 add $0x4,%ebx
40: 50 push %eax
41: 68 6a 08 00 00 push $0x86a
46: 6a 01 push $0x1
48: e8 53 06 00 00 call 6a0 <printf>
for(i = 1; i < argc; i++)
4d: 8b 43 fc mov -0x4(%ebx),%eax
printf(1, "%s%s", argv[i], i+1 < argc ? " " : "\n");
50: 83 c4 10 add $0x10,%esp
53: 39 f3 cmp %esi,%ebx
55: 75 e1 jne 38 <main+0x38>
57: 68 6f 08 00 00 push $0x86f
5c: 50 push %eax
5d: 68 6a 08 00 00 push $0x86a
62: 6a 01 push $0x1
64: e8 37 06 00 00 call 6a0 <printf>
69: 83 c4 10 add $0x10,%esp
exit();
6c: e8 bc 04 00 00 call 52d <exit>
71: 66 90 xchg %ax,%ax
73: 66 90 xchg %ax,%ax
75: 66 90 xchg %ax,%ax
77: 66 90 xchg %ax,%ax
79: 66 90 xchg %ax,%ax
7b: 66 90 xchg %ax,%ax
7d: 66 90 xchg %ax,%ax
7f: 90 nop
00000080 <strcpy>:
};
char*
strcpy(char *s, const char *t)
{
80: f3 0f 1e fb endbr32
84: 55 push %ebp
char *os;
os = s;
while((*s++ = *t++) != 0)
85: 31 c0 xor %eax,%eax
{
87: 89 e5 mov %esp,%ebp
89: 53 push %ebx
8a: 8b 4d 08 mov 0x8(%ebp),%ecx
8d: 8b 5d 0c mov 0xc(%ebp),%ebx
while((*s++ = *t++) != 0)
90: 0f b6 14 03 movzbl (%ebx,%eax,1),%edx
94: 88 14 01 mov %dl,(%ecx,%eax,1)
97: 83 c0 01 add $0x1,%eax
9a: 84 d2 test %dl,%dl
9c: 75 f2 jne 90 <strcpy+0x10>
;
return os;
}
9e: 89 c8 mov %ecx,%eax
a0: 5b pop %ebx
a1: 5d pop %ebp
a2: c3 ret
a3: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
aa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
000000b0 <strcmp>:
int
strcmp(const char *p, const char *q)
{
b0: f3 0f 1e fb endbr32
b4: 55 push %ebp
b5: 89 e5 mov %esp,%ebp
b7: 53 push %ebx
b8: 8b 4d 08 mov 0x8(%ebp),%ecx
bb: 8b 55 0c mov 0xc(%ebp),%edx
while(*p && *p == *q)
be: 0f b6 01 movzbl (%ecx),%eax
c1: 0f b6 1a movzbl (%edx),%ebx
c4: 84 c0 test %al,%al
c6: 75 19 jne e1 <strcmp+0x31>
c8: eb 26 jmp f0 <strcmp+0x40>
ca: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
d0: 0f b6 41 01 movzbl 0x1(%ecx),%eax
p++, q++;
d4: 83 c1 01 add $0x1,%ecx
d7: 83 c2 01 add $0x1,%edx
while(*p && *p == *q)
da: 0f b6 1a movzbl (%edx),%ebx
dd: 84 c0 test %al,%al
df: 74 0f je f0 <strcmp+0x40>
e1: 38 d8 cmp %bl,%al
e3: 74 eb je d0 <strcmp+0x20>
return (uchar)*p - (uchar)*q;
e5: 29 d8 sub %ebx,%eax
}
e7: 5b pop %ebx
e8: 5d pop %ebp
e9: c3 ret
ea: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
f0: 31 c0 xor %eax,%eax
return (uchar)*p - (uchar)*q;
f2: 29 d8 sub %ebx,%eax
}
f4: 5b pop %ebx
f5: 5d pop %ebp
f6: c3 ret
f7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
fe: 66 90 xchg %ax,%ax
00000100 <strlen>:
uint
strlen(const char *s)
{
100: f3 0f 1e fb endbr32
104: 55 push %ebp
105: 89 e5 mov %esp,%ebp
107: 8b 55 08 mov 0x8(%ebp),%edx
int n;
for(n = 0; s[n]; n++)
10a: 80 3a 00 cmpb $0x0,(%edx)
10d: 74 21 je 130 <strlen+0x30>
10f: 31 c0 xor %eax,%eax
111: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
118: 83 c0 01 add $0x1,%eax
11b: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1)
11f: 89 c1 mov %eax,%ecx
121: 75 f5 jne 118 <strlen+0x18>
;
return n;
}
123: 89 c8 mov %ecx,%eax
125: 5d pop %ebp
126: c3 ret
127: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
12e: 66 90 xchg %ax,%ax
for(n = 0; s[n]; n++)
130: 31 c9 xor %ecx,%ecx
}
132: 5d pop %ebp
133: 89 c8 mov %ecx,%eax
135: c3 ret
136: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
13d: 8d 76 00 lea 0x0(%esi),%esi
00000140 <memset>:
void*
memset(void *dst, int c, uint n)
{
140: f3 0f 1e fb endbr32
144: 55 push %ebp
145: 89 e5 mov %esp,%ebp
147: 57 push %edi
148: 8b 55 08 mov 0x8(%ebp),%edx
}
static inline void
stosb(void *addr, int data, int cnt)
{
asm volatile("cld; rep stosb" :
14b: 8b 4d 10 mov 0x10(%ebp),%ecx
14e: 8b 45 0c mov 0xc(%ebp),%eax
151: 89 d7 mov %edx,%edi
153: fc cld
154: f3 aa rep stos %al,%es:(%edi)
stosb(dst, c, n);
return dst;
}
156: 89 d0 mov %edx,%eax
158: 5f pop %edi
159: 5d pop %ebp
15a: c3 ret
15b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
15f: 90 nop
00000160 <strchr>:
char*
strchr(const char *s, char c)
{
160: f3 0f 1e fb endbr32
164: 55 push %ebp
165: 89 e5 mov %esp,%ebp
167: 8b 45 08 mov 0x8(%ebp),%eax
16a: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx
for(; *s; s++)
16e: 0f b6 10 movzbl (%eax),%edx
171: 84 d2 test %dl,%dl
173: 75 16 jne 18b <strchr+0x2b>
175: eb 21 jmp 198 <strchr+0x38>
177: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
17e: 66 90 xchg %ax,%ax
180: 0f b6 50 01 movzbl 0x1(%eax),%edx
184: 83 c0 01 add $0x1,%eax
187: 84 d2 test %dl,%dl
189: 74 0d je 198 <strchr+0x38>
if(*s == c)
18b: 38 d1 cmp %dl,%cl
18d: 75 f1 jne 180 <strchr+0x20>
return (char*)s;
return 0;
}
18f: 5d pop %ebp
190: c3 ret
191: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
return 0;
198: 31 c0 xor %eax,%eax
}
19a: 5d pop %ebp
19b: c3 ret
19c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
000001a0 <gets>:
char*
gets(char *buf, int max)
{
1a0: f3 0f 1e fb endbr32
1a4: 55 push %ebp
1a5: 89 e5 mov %esp,%ebp
1a7: 57 push %edi
1a8: 56 push %esi
int i, cc;
char c;
for(i=0; i+1 < max; ){
1a9: 31 f6 xor %esi,%esi
{
1ab: 53 push %ebx
1ac: 89 f3 mov %esi,%ebx
1ae: 83 ec 1c sub $0x1c,%esp
1b1: 8b 7d 08 mov 0x8(%ebp),%edi
for(i=0; i+1 < max; ){
1b4: eb 33 jmp 1e9 <gets+0x49>
1b6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
1bd: 8d 76 00 lea 0x0(%esi),%esi
cc = read(0, &c, 1);
1c0: 83 ec 04 sub $0x4,%esp
1c3: 8d 45 e7 lea -0x19(%ebp),%eax
1c6: 6a 01 push $0x1
1c8: 50 push %eax
1c9: 6a 00 push $0x0
1cb: e8 75 03 00 00 call 545 <read>
if(cc < 1)
1d0: 83 c4 10 add $0x10,%esp
1d3: 85 c0 test %eax,%eax
1d5: 7e 1c jle 1f3 <gets+0x53>
break;
buf[i++] = c;
1d7: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
1db: 83 c7 01 add $0x1,%edi
1de: 88 47 ff mov %al,-0x1(%edi)
if(c == '\n' || c == '\r')
1e1: 3c 0a cmp $0xa,%al
1e3: 74 23 je 208 <gets+0x68>
1e5: 3c 0d cmp $0xd,%al
1e7: 74 1f je 208 <gets+0x68>
for(i=0; i+1 < max; ){
1e9: 83 c3 01 add $0x1,%ebx
1ec: 89 fe mov %edi,%esi
1ee: 3b 5d 0c cmp 0xc(%ebp),%ebx
1f1: 7c cd jl 1c0 <gets+0x20>
1f3: 89 f3 mov %esi,%ebx
break;
}
buf[i] = '\0';
return buf;
}
1f5: 8b 45 08 mov 0x8(%ebp),%eax
buf[i] = '\0';
1f8: c6 03 00 movb $0x0,(%ebx)
}
1fb: 8d 65 f4 lea -0xc(%ebp),%esp
1fe: 5b pop %ebx
1ff: 5e pop %esi
200: 5f pop %edi
201: 5d pop %ebp
202: c3 ret
203: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
207: 90 nop
208: 8b 75 08 mov 0x8(%ebp),%esi
20b: 8b 45 08 mov 0x8(%ebp),%eax
20e: 01 de add %ebx,%esi
210: 89 f3 mov %esi,%ebx
buf[i] = '\0';
212: c6 03 00 movb $0x0,(%ebx)
}
215: 8d 65 f4 lea -0xc(%ebp),%esp
218: 5b pop %ebx
219: 5e pop %esi
21a: 5f pop %edi
21b: 5d pop %ebp
21c: c3 ret
21d: 8d 76 00 lea 0x0(%esi),%esi
00000220 <stat>:
int
stat(const char *n, struct stat *st)
{
220: f3 0f 1e fb endbr32
224: 55 push %ebp
225: 89 e5 mov %esp,%ebp
227: 56 push %esi
228: 53 push %ebx
int fd;
int r;
fd = open(n, O_RDONLY);
229: 83 ec 08 sub $0x8,%esp
22c: 6a 00 push $0x0
22e: ff 75 08 pushl 0x8(%ebp)
231: e8 37 03 00 00 call 56d <open>
if(fd < 0)
236: 83 c4 10 add $0x10,%esp
239: 85 c0 test %eax,%eax
23b: 78 2b js 268 <stat+0x48>
return -1;
r = fstat(fd, st);
23d: 83 ec 08 sub $0x8,%esp
240: ff 75 0c pushl 0xc(%ebp)
243: 89 c3 mov %eax,%ebx
245: 50 push %eax
246: e8 3a 03 00 00 call 585 <fstat>
close(fd);
24b: 89 1c 24 mov %ebx,(%esp)
r = fstat(fd, st);
24e: 89 c6 mov %eax,%esi
close(fd);
250: e8 00 03 00 00 call 555 <close>
return r;
255: 83 c4 10 add $0x10,%esp
}
258: 8d 65 f8 lea -0x8(%ebp),%esp
25b: 89 f0 mov %esi,%eax
25d: 5b pop %ebx
25e: 5e pop %esi
25f: 5d pop %ebp
260: c3 ret
261: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
return -1;
268: be ff ff ff ff mov $0xffffffff,%esi
26d: eb e9 jmp 258 <stat+0x38>
26f: 90 nop
00000270 <atoi>:
int
atoi(const char *s)
{
270: f3 0f 1e fb endbr32
274: 55 push %ebp
275: 89 e5 mov %esp,%ebp
277: 53 push %ebx
278: 8b 55 08 mov 0x8(%ebp),%edx
int n;
n = 0;
while('0' <= *s && *s <= '9')
27b: 0f be 02 movsbl (%edx),%eax
27e: 8d 48 d0 lea -0x30(%eax),%ecx
281: 80 f9 09 cmp $0x9,%cl
n = 0;
284: b9 00 00 00 00 mov $0x0,%ecx
while('0' <= *s && *s <= '9')
289: 77 1a ja 2a5 <atoi+0x35>
28b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
28f: 90 nop
n = n*10 + *s++ - '0';
290: 83 c2 01 add $0x1,%edx
293: 8d 0c 89 lea (%ecx,%ecx,4),%ecx
296: 8d 4c 48 d0 lea -0x30(%eax,%ecx,2),%ecx
while('0' <= *s && *s <= '9')
29a: 0f be 02 movsbl (%edx),%eax
29d: 8d 58 d0 lea -0x30(%eax),%ebx
2a0: 80 fb 09 cmp $0x9,%bl
2a3: 76 eb jbe 290 <atoi+0x20>
return n;
}
2a5: 89 c8 mov %ecx,%eax
2a7: 5b pop %ebx
2a8: 5d pop %ebp
2a9: c3 ret
2aa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
000002b0 <memmove>:
void*
memmove(void *vdst, const void *vsrc, int n)
{
2b0: f3 0f 1e fb endbr32
2b4: 55 push %ebp
2b5: 89 e5 mov %esp,%ebp
2b7: 57 push %edi
2b8: 8b 45 10 mov 0x10(%ebp),%eax
2bb: 8b 55 08 mov 0x8(%ebp),%edx
2be: 56 push %esi
2bf: 8b 75 0c mov 0xc(%ebp),%esi
char *dst;
const char *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
2c2: 85 c0 test %eax,%eax
2c4: 7e 0f jle 2d5 <memmove+0x25>
2c6: 01 d0 add %edx,%eax
dst = vdst;
2c8: 89 d7 mov %edx,%edi
2ca: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
*dst++ = *src++;
2d0: a4 movsb %ds:(%esi),%es:(%edi)
while(n-- > 0)
2d1: 39 f8 cmp %edi,%eax
2d3: 75 fb jne 2d0 <memmove+0x20>
return vdst;
}
2d5: 5e pop %esi
2d6: 89 d0 mov %edx,%eax
2d8: 5f pop %edi
2d9: 5d pop %ebp
2da: c3 ret
2db: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
2df: 90 nop
000002e0 <thread_join>:
void* stack;
stack =malloc(4096); //pgsize
return clone(start_routine,arg1,arg2,stack);
}
int thread_join()
{
2e0: f3 0f 1e fb endbr32
2e4: 55 push %ebp
2e5: 89 e5 mov %esp,%ebp
2e7: 83 ec 24 sub $0x24,%esp
void * stackPtr;
int x = join(&stackPtr);
2ea: 8d 45 f4 lea -0xc(%ebp),%eax
2ed: 50 push %eax
2ee: e8 f2 02 00 00 call 5e5 <join>
return x;
}
2f3: c9 leave
2f4: c3 ret
2f5: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
2fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
00000300 <lock_init>:
void lock_init(struct lock_t *lk){
300: f3 0f 1e fb endbr32
304: 55 push %ebp
305: 89 e5 mov %esp,%ebp
lk->locked=0; //intialize as unnlocked
307: 8b 45 08 mov 0x8(%ebp),%eax
30a: c7 00 00 00 00 00 movl $0x0,(%eax)
}
310: 5d pop %ebp
311: c3 ret
312: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
319: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00000320 <lock_acquire>:
void lock_acquire(struct lock_t *lk){
320: f3 0f 1e fb endbr32
324: 55 push %ebp
xchg(volatile uint *addr, uint newval)
{
uint result;
// The + in "+m" denotes a read-modify-write operand.
asm volatile("lock; xchgl %0, %1" :
325: b9 01 00 00 00 mov $0x1,%ecx
32a: 89 e5 mov %esp,%ebp
32c: 8b 55 08 mov 0x8(%ebp),%edx
32f: 90 nop
330: 89 c8 mov %ecx,%eax
332: f0 87 02 lock xchg %eax,(%edx)
while(xchg(&lk->locked,1) != 0);
335: 85 c0 test %eax,%eax
337: 75 f7 jne 330 <lock_acquire+0x10>
}
339: 5d pop %ebp
33a: c3 ret
33b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
33f: 90 nop
00000340 <lock_release>:
void lock_release(struct lock_t *lk){
340: f3 0f 1e fb endbr32
344: 55 push %ebp
345: 31 c0 xor %eax,%eax
347: 89 e5 mov %esp,%ebp
349: 8b 55 08 mov 0x8(%ebp),%edx
34c: f0 87 02 lock xchg %eax,(%edx)
xchg(&lk->locked,0) ;
}
34f: 5d pop %ebp
350: c3 ret
351: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
358: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
35f: 90 nop
00000360 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
360: f3 0f 1e fb endbr32
364: 55 push %ebp
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
365: a1 c8 0b 00 00 mov 0xbc8,%eax
{
36a: 89 e5 mov %esp,%ebp
36c: 57 push %edi
36d: 56 push %esi
36e: 53 push %ebx
36f: 8b 5d 08 mov 0x8(%ebp),%ebx
372: 8b 10 mov (%eax),%edx
bp = (Header*)ap - 1;
374: 8d 4b f8 lea -0x8(%ebx),%ecx
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
377: 39 c8 cmp %ecx,%eax
379: 73 15 jae 390 <free+0x30>
37b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
37f: 90 nop
380: 39 d1 cmp %edx,%ecx
382: 72 14 jb 398 <free+0x38>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
384: 39 d0 cmp %edx,%eax
386: 73 10 jae 398 <free+0x38>
{
388: 89 d0 mov %edx,%eax
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
38a: 8b 10 mov (%eax),%edx
38c: 39 c8 cmp %ecx,%eax
38e: 72 f0 jb 380 <free+0x20>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
390: 39 d0 cmp %edx,%eax
392: 72 f4 jb 388 <free+0x28>
394: 39 d1 cmp %edx,%ecx
396: 73 f0 jae 388 <free+0x28>
break;
if(bp + bp->s.size == p->s.ptr){
398: 8b 73 fc mov -0x4(%ebx),%esi
39b: 8d 3c f1 lea (%ecx,%esi,8),%edi
39e: 39 fa cmp %edi,%edx
3a0: 74 1e je 3c0 <free+0x60>
bp->s.size += p->s.ptr->s.size;
bp->s.ptr = p->s.ptr->s.ptr;
} else
bp->s.ptr = p->s.ptr;
3a2: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
3a5: 8b 50 04 mov 0x4(%eax),%edx
3a8: 8d 34 d0 lea (%eax,%edx,8),%esi
3ab: 39 f1 cmp %esi,%ecx
3ad: 74 28 je 3d7 <free+0x77>
p->s.size += bp->s.size;
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
3af: 89 08 mov %ecx,(%eax)
freep = p;
}
3b1: 5b pop %ebx
freep = p;
3b2: a3 c8 0b 00 00 mov %eax,0xbc8
}
3b7: 5e pop %esi
3b8: 5f pop %edi
3b9: 5d pop %ebp
3ba: c3 ret
3bb: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
3bf: 90 nop
bp->s.size += p->s.ptr->s.size;
3c0: 03 72 04 add 0x4(%edx),%esi
3c3: 89 73 fc mov %esi,-0x4(%ebx)
bp->s.ptr = p->s.ptr->s.ptr;
3c6: 8b 10 mov (%eax),%edx
3c8: 8b 12 mov (%edx),%edx
3ca: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
3cd: 8b 50 04 mov 0x4(%eax),%edx
3d0: 8d 34 d0 lea (%eax,%edx,8),%esi
3d3: 39 f1 cmp %esi,%ecx
3d5: 75 d8 jne 3af <free+0x4f>
p->s.size += bp->s.size;
3d7: 03 53 fc add -0x4(%ebx),%edx
freep = p;
3da: a3 c8 0b 00 00 mov %eax,0xbc8
p->s.size += bp->s.size;
3df: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
3e2: 8b 53 f8 mov -0x8(%ebx),%edx
3e5: 89 10 mov %edx,(%eax)
}
3e7: 5b pop %ebx
3e8: 5e pop %esi
3e9: 5f pop %edi
3ea: 5d pop %ebp
3eb: c3 ret
3ec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
000003f0 <malloc>:
return freep;
}
void*
malloc(uint nbytes)
{
3f0: f3 0f 1e fb endbr32
3f4: 55 push %ebp
3f5: 89 e5 mov %esp,%ebp
3f7: 57 push %edi
3f8: 56 push %esi
3f9: 53 push %ebx
3fa: 83 ec 1c sub $0x1c,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
3fd: 8b 45 08 mov 0x8(%ebp),%eax
if((prevp = freep) == 0){
400: 8b 3d c8 0b 00 00 mov 0xbc8,%edi
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
406: 8d 70 07 lea 0x7(%eax),%esi
409: c1 ee 03 shr $0x3,%esi
40c: 83 c6 01 add $0x1,%esi
if((prevp = freep) == 0){
40f: 85 ff test %edi,%edi
411: 0f 84 a9 00 00 00 je 4c0 <malloc+0xd0>
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
417: 8b 07 mov (%edi),%eax
if(p->s.size >= nunits){
419: 8b 48 04 mov 0x4(%eax),%ecx
41c: 39 f1 cmp %esi,%ecx
41e: 73 6d jae 48d <malloc+0x9d>
420: 81 fe 00 10 00 00 cmp $0x1000,%esi
426: bb 00 10 00 00 mov $0x1000,%ebx
42b: 0f 43 de cmovae %esi,%ebx
p = sbrk(nu * sizeof(Header));
42e: 8d 0c dd 00 00 00 00 lea 0x0(,%ebx,8),%ecx
435: 89 4d e4 mov %ecx,-0x1c(%ebp)
438: eb 17 jmp 451 <malloc+0x61>
43a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
440: 8b 10 mov (%eax),%edx
if(p->s.size >= nunits){
442: 8b 4a 04 mov 0x4(%edx),%ecx
445: 39 f1 cmp %esi,%ecx
447: 73 4f jae 498 <malloc+0xa8>
449: 8b 3d c8 0b 00 00 mov 0xbc8,%edi
44f: 89 d0 mov %edx,%eax
p->s.size = nunits;
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
451: 39 c7 cmp %eax,%edi
453: 75 eb jne 440 <malloc+0x50>
p = sbrk(nu * sizeof(Header));
455: 83 ec 0c sub $0xc,%esp
458: ff 75 e4 pushl -0x1c(%ebp)
45b: e8 65 01 00 00 call 5c5 <sbrk>
if(p == (char*)-1)
460: 83 c4 10 add $0x10,%esp
463: 83 f8 ff cmp $0xffffffff,%eax
466: 74 1b je 483 <malloc+0x93>
hp->s.size = nu;
468: 89 58 04 mov %ebx,0x4(%eax)
free((void*)(hp + 1));
46b: 83 ec 0c sub $0xc,%esp
46e: 83 c0 08 add $0x8,%eax
471: 50 push %eax
472: e8 e9 fe ff ff call 360 <free>
return freep;
477: a1 c8 0b 00 00 mov 0xbc8,%eax
if((p = morecore(nunits)) == 0)
47c: 83 c4 10 add $0x10,%esp
47f: 85 c0 test %eax,%eax
481: 75 bd jne 440 <malloc+0x50>
return 0;
}
}
483: 8d 65 f4 lea -0xc(%ebp),%esp
return 0;
486: 31 c0 xor %eax,%eax
}
488: 5b pop %ebx
489: 5e pop %esi
48a: 5f pop %edi
48b: 5d pop %ebp
48c: c3 ret
if(p->s.size >= nunits){
48d: 89 c2 mov %eax,%edx
48f: 89 f8 mov %edi,%eax
491: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
if(p->s.size == nunits)
498: 39 ce cmp %ecx,%esi
49a: 74 54 je 4f0 <malloc+0x100>
p->s.size -= nunits;
49c: 29 f1 sub %esi,%ecx
49e: 89 4a 04 mov %ecx,0x4(%edx)
p += p->s.size;
4a1: 8d 14 ca lea (%edx,%ecx,8),%edx
p->s.size = nunits;
4a4: 89 72 04 mov %esi,0x4(%edx)
freep = prevp;
4a7: a3 c8 0b 00 00 mov %eax,0xbc8
}
4ac: 8d 65 f4 lea -0xc(%ebp),%esp
return (void*)(p + 1);
4af: 8d 42 08 lea 0x8(%edx),%eax
}
4b2: 5b pop %ebx
4b3: 5e pop %esi
4b4: 5f pop %edi
4b5: 5d pop %ebp
4b6: c3 ret
4b7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
4be: 66 90 xchg %ax,%ax
base.s.ptr = freep = prevp = &base;
4c0: c7 05 c8 0b 00 00 cc movl $0xbcc,0xbc8
4c7: 0b 00 00
base.s.size = 0;
4ca: bf cc 0b 00 00 mov $0xbcc,%edi
base.s.ptr = freep = prevp = &base;
4cf: c7 05 cc 0b 00 00 cc movl $0xbcc,0xbcc
4d6: 0b 00 00
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
4d9: 89 f8 mov %edi,%eax
base.s.size = 0;
4db: c7 05 d0 0b 00 00 00 movl $0x0,0xbd0
4e2: 00 00 00
if(p->s.size >= nunits){
4e5: e9 36 ff ff ff jmp 420 <malloc+0x30>
4ea: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
prevp->s.ptr = p->s.ptr;
4f0: 8b 0a mov (%edx),%ecx
4f2: 89 08 mov %ecx,(%eax)
4f4: eb b1 jmp 4a7 <malloc+0xb7>
4f6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
4fd: 8d 76 00 lea 0x0(%esi),%esi
00000500 <thread_create>:
{
500: f3 0f 1e fb endbr32
504: 55 push %ebp
505: 89 e5 mov %esp,%ebp
507: 83 ec 14 sub $0x14,%esp
stack =malloc(4096); //pgsize
50a: 68 00 10 00 00 push $0x1000
50f: e8 dc fe ff ff call 3f0 <malloc>
return clone(start_routine,arg1,arg2,stack);
514: 50 push %eax
515: ff 75 10 pushl 0x10(%ebp)
518: ff 75 0c pushl 0xc(%ebp)
51b: ff 75 08 pushl 0x8(%ebp)
51e: e8 ba 00 00 00 call 5dd <clone>
}
523: c9 leave
524: c3 ret
00000525 <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
525: b8 01 00 00 00 mov $0x1,%eax
52a: cd 40 int $0x40
52c: c3 ret
0000052d <exit>:
SYSCALL(exit)
52d: b8 02 00 00 00 mov $0x2,%eax
532: cd 40 int $0x40
534: c3 ret
00000535 <wait>:
SYSCALL(wait)
535: b8 03 00 00 00 mov $0x3,%eax
53a: cd 40 int $0x40
53c: c3 ret
0000053d <pipe>:
SYSCALL(pipe)
53d: b8 04 00 00 00 mov $0x4,%eax
542: cd 40 int $0x40
544: c3 ret
00000545 <read>:
SYSCALL(read)
545: b8 05 00 00 00 mov $0x5,%eax
54a: cd 40 int $0x40
54c: c3 ret
0000054d <write>:
SYSCALL(write)
54d: b8 10 00 00 00 mov $0x10,%eax
552: cd 40 int $0x40
554: c3 ret
00000555 <close>:
SYSCALL(close)
555: b8 15 00 00 00 mov $0x15,%eax
55a: cd 40 int $0x40
55c: c3 ret
0000055d <kill>:
SYSCALL(kill)
55d: b8 06 00 00 00 mov $0x6,%eax
562: cd 40 int $0x40
564: c3 ret
00000565 <exec>:
SYSCALL(exec)
565: b8 07 00 00 00 mov $0x7,%eax
56a: cd 40 int $0x40
56c: c3 ret
0000056d <open>:
SYSCALL(open)
56d: b8 0f 00 00 00 mov $0xf,%eax
572: cd 40 int $0x40
574: c3 ret
00000575 <mknod>:
SYSCALL(mknod)
575: b8 11 00 00 00 mov $0x11,%eax
57a: cd 40 int $0x40
57c: c3 ret
0000057d <unlink>:
SYSCALL(unlink)
57d: b8 12 00 00 00 mov $0x12,%eax
582: cd 40 int $0x40
584: c3 ret
00000585 <fstat>:
SYSCALL(fstat)
585: b8 08 00 00 00 mov $0x8,%eax
58a: cd 40 int $0x40
58c: c3 ret
0000058d <link>:
SYSCALL(link)
58d: b8 13 00 00 00 mov $0x13,%eax
592: cd 40 int $0x40
594: c3 ret
00000595 <mkdir>:
SYSCALL(mkdir)
595: b8 14 00 00 00 mov $0x14,%eax
59a: cd 40 int $0x40
59c: c3 ret
0000059d <chdir>:
SYSCALL(chdir)
59d: b8 09 00 00 00 mov $0x9,%eax
5a2: cd 40 int $0x40
5a4: c3 ret
000005a5 <dup>:
SYSCALL(dup)
5a5: b8 0a 00 00 00 mov $0xa,%eax
5aa: cd 40 int $0x40
5ac: c3 ret
000005ad <getpid>:
SYSCALL(getpid)
5ad: b8 0b 00 00 00 mov $0xb,%eax
5b2: cd 40 int $0x40
5b4: c3 ret
000005b5 <getyear>:
SYSCALL(getyear)
5b5: b8 16 00 00 00 mov $0x16,%eax
5ba: cd 40 int $0x40
5bc: c3 ret
000005bd <getreadcount>:
SYSCALL(getreadcount)
5bd: b8 17 00 00 00 mov $0x17,%eax
5c2: cd 40 int $0x40
5c4: c3 ret
000005c5 <sbrk>:
SYSCALL(sbrk)
5c5: b8 0c 00 00 00 mov $0xc,%eax
5ca: cd 40 int $0x40
5cc: c3 ret
000005cd <sleep>:
SYSCALL(sleep)
5cd: b8 0d 00 00 00 mov $0xd,%eax
5d2: cd 40 int $0x40
5d4: c3 ret
000005d5 <uptime>:
SYSCALL(uptime)
5d5: b8 0e 00 00 00 mov $0xe,%eax
5da: cd 40 int $0x40
5dc: c3 ret
000005dd <clone>:
SYSCALL(clone)
5dd: b8 18 00 00 00 mov $0x18,%eax
5e2: cd 40 int $0x40
5e4: c3 ret
000005e5 <join>:
SYSCALL(join)
5e5: b8 19 00 00 00 mov $0x19,%eax
5ea: cd 40 int $0x40
5ec: c3 ret
5ed: 66 90 xchg %ax,%ax
5ef: 90 nop
000005f0 <printint>:
write(fd, &c, 1);
}
static void
printint(int fd, int xx, int base, int sgn)
{
5f0: 55 push %ebp
5f1: 89 e5 mov %esp,%ebp
5f3: 57 push %edi
5f4: 56 push %esi
5f5: 53 push %ebx
5f6: 83 ec 3c sub $0x3c,%esp
5f9: 89 4d c4 mov %ecx,-0x3c(%ebp)
uint x;
neg = 0;
if(sgn && xx < 0){
neg = 1;
x = -xx;
5fc: 89 d1 mov %edx,%ecx
{
5fe: 89 45 b8 mov %eax,-0x48(%ebp)
if(sgn && xx < 0){
601: 85 d2 test %edx,%edx
603: 0f 89 7f 00 00 00 jns 688 <printint+0x98>
609: f6 45 08 01 testb $0x1,0x8(%ebp)
60d: 74 79 je 688 <printint+0x98>
neg = 1;
60f: c7 45 bc 01 00 00 00 movl $0x1,-0x44(%ebp)
x = -xx;
616: f7 d9 neg %ecx
} else {
x = xx;
}
i = 0;
618: 31 db xor %ebx,%ebx
61a: 8d 75 d7 lea -0x29(%ebp),%esi
61d: 8d 76 00 lea 0x0(%esi),%esi
do{
buf[i++] = digits[x % base];
620: 89 c8 mov %ecx,%eax
622: 31 d2 xor %edx,%edx
624: 89 cf mov %ecx,%edi
626: f7 75 c4 divl -0x3c(%ebp)
629: 0f b6 92 78 08 00 00 movzbl 0x878(%edx),%edx
630: 89 45 c0 mov %eax,-0x40(%ebp)
633: 89 d8 mov %ebx,%eax
635: 8d 5b 01 lea 0x1(%ebx),%ebx
}while((x /= base) != 0);
638: 8b 4d c0 mov -0x40(%ebp),%ecx
buf[i++] = digits[x % base];
63b: 88 14 1e mov %dl,(%esi,%ebx,1)
}while((x /= base) != 0);
63e: 39 7d c4 cmp %edi,-0x3c(%ebp)
641: 76 dd jbe 620 <printint+0x30>
if(neg)
643: 8b 4d bc mov -0x44(%ebp),%ecx
646: 85 c9 test %ecx,%ecx
648: 74 0c je 656 <printint+0x66>
buf[i++] = '-';
64a: c6 44 1d d8 2d movb $0x2d,-0x28(%ebp,%ebx,1)
buf[i++] = digits[x % base];
64f: 89 d8 mov %ebx,%eax
buf[i++] = '-';
651: ba 2d 00 00 00 mov $0x2d,%edx
while(--i >= 0)
656: 8b 7d b8 mov -0x48(%ebp),%edi
659: 8d 5c 05 d7 lea -0x29(%ebp,%eax,1),%ebx
65d: eb 07 jmp 666 <printint+0x76>
65f: 90 nop
660: 0f b6 13 movzbl (%ebx),%edx
663: 83 eb 01 sub $0x1,%ebx
write(fd, &c, 1);
666: 83 ec 04 sub $0x4,%esp
669: 88 55 d7 mov %dl,-0x29(%ebp)
66c: 6a 01 push $0x1
66e: 56 push %esi
66f: 57 push %edi
670: e8 d8 fe ff ff call 54d <write>
while(--i >= 0)
675: 83 c4 10 add $0x10,%esp
678: 39 de cmp %ebx,%esi
67a: 75 e4 jne 660 <printint+0x70>
putc(fd, buf[i]);
}
67c: 8d 65 f4 lea -0xc(%ebp),%esp
67f: 5b pop %ebx
680: 5e pop %esi
681: 5f pop %edi
682: 5d pop %ebp
683: c3 ret
684: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
neg = 0;
688: c7 45 bc 00 00 00 00 movl $0x0,-0x44(%ebp)
68f: eb 87 jmp 618 <printint+0x28>
691: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
698: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
69f: 90 nop
000006a0 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, const char *fmt, ...)
{
6a0: f3 0f 1e fb endbr32
6a4: 55 push %ebp
6a5: 89 e5 mov %esp,%ebp
6a7: 57 push %edi
6a8: 56 push %esi
6a9: 53 push %ebx
6aa: 83 ec 2c sub $0x2c,%esp
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
6ad: 8b 75 0c mov 0xc(%ebp),%esi
6b0: 0f b6 1e movzbl (%esi),%ebx
6b3: 84 db test %bl,%bl
6b5: 0f 84 b4 00 00 00 je 76f <printf+0xcf>
ap = (uint*)(void*)&fmt + 1;
6bb: 8d 45 10 lea 0x10(%ebp),%eax
6be: 83 c6 01 add $0x1,%esi
write(fd, &c, 1);
6c1: 8d 7d e7 lea -0x19(%ebp),%edi
state = 0;
6c4: 31 d2 xor %edx,%edx
ap = (uint*)(void*)&fmt + 1;
6c6: 89 45 d0 mov %eax,-0x30(%ebp)
6c9: eb 33 jmp 6fe <printf+0x5e>
6cb: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
6cf: 90 nop
6d0: 89 55 d4 mov %edx,-0x2c(%ebp)
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
state = '%';
6d3: ba 25 00 00 00 mov $0x25,%edx
if(c == '%'){
6d8: 83 f8 25 cmp $0x25,%eax
6db: 74 17 je 6f4 <printf+0x54>
write(fd, &c, 1);
6dd: 83 ec 04 sub $0x4,%esp
6e0: 88 5d e7 mov %bl,-0x19(%ebp)
6e3: 6a 01 push $0x1
6e5: 57 push %edi
6e6: ff 75 08 pushl 0x8(%ebp)
6e9: e8 5f fe ff ff call 54d <write>
6ee: 8b 55 d4 mov -0x2c(%ebp),%edx
} else {
putc(fd, c);
6f1: 83 c4 10 add $0x10,%esp
for(i = 0; fmt[i]; i++){
6f4: 0f b6 1e movzbl (%esi),%ebx
6f7: 83 c6 01 add $0x1,%esi
6fa: 84 db test %bl,%bl
6fc: 74 71 je 76f <printf+0xcf>
c = fmt[i] & 0xff;
6fe: 0f be cb movsbl %bl,%ecx
701: 0f b6 c3 movzbl %bl,%eax
if(state == 0){
704: 85 d2 test %edx,%edx
706: 74 c8 je 6d0 <printf+0x30>
}
} else if(state == '%'){
708: 83 fa 25 cmp $0x25,%edx
70b: 75 e7 jne 6f4 <printf+0x54>
if(c == 'd'){
70d: 83 f8 64 cmp $0x64,%eax
710: 0f 84 9a 00 00 00 je 7b0 <printf+0x110>
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
716: 81 e1 f7 00 00 00 and $0xf7,%ecx
71c: 83 f9 70 cmp $0x70,%ecx
71f: 74 5f je 780 <printf+0xe0>
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
721: 83 f8 73 cmp $0x73,%eax
724: 0f 84 d6 00 00 00 je 800 <printf+0x160>
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
72a: 83 f8 63 cmp $0x63,%eax
72d: 0f 84 8d 00 00 00 je 7c0 <printf+0x120>
putc(fd, *ap);
ap++;
} else if(c == '%'){
733: 83 f8 25 cmp $0x25,%eax
736: 0f 84 b4 00 00 00 je 7f0 <printf+0x150>
write(fd, &c, 1);
73c: 83 ec 04 sub $0x4,%esp
73f: c6 45 e7 25 movb $0x25,-0x19(%ebp)
743: 6a 01 push $0x1
745: 57 push %edi
746: ff 75 08 pushl 0x8(%ebp)
749: e8 ff fd ff ff call 54d <write>
putc(fd, c);
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
74e: 88 5d e7 mov %bl,-0x19(%ebp)
write(fd, &c, 1);
751: 83 c4 0c add $0xc,%esp
754: 6a 01 push $0x1
756: 83 c6 01 add $0x1,%esi
759: 57 push %edi
75a: ff 75 08 pushl 0x8(%ebp)
75d: e8 eb fd ff ff call 54d <write>
for(i = 0; fmt[i]; i++){
762: 0f b6 5e ff movzbl -0x1(%esi),%ebx
putc(fd, c);
766: 83 c4 10 add $0x10,%esp
}
state = 0;
769: 31 d2 xor %edx,%edx
for(i = 0; fmt[i]; i++){
76b: 84 db test %bl,%bl
76d: 75 8f jne 6fe <printf+0x5e>
}
}
}
76f: 8d 65 f4 lea -0xc(%ebp),%esp
772: 5b pop %ebx
773: 5e pop %esi
774: 5f pop %edi
775: 5d pop %ebp
776: c3 ret
777: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
77e: 66 90 xchg %ax,%ax
printint(fd, *ap, 16, 0);
780: 83 ec 0c sub $0xc,%esp
783: b9 10 00 00 00 mov $0x10,%ecx
788: 6a 00 push $0x0
78a: 8b 5d d0 mov -0x30(%ebp),%ebx
78d: 8b 45 08 mov 0x8(%ebp),%eax
790: 8b 13 mov (%ebx),%edx
792: e8 59 fe ff ff call 5f0 <printint>
ap++;
797: 89 d8 mov %ebx,%eax
799: 83 c4 10 add $0x10,%esp
state = 0;
79c: 31 d2 xor %edx,%edx
ap++;
79e: 83 c0 04 add $0x4,%eax
7a1: 89 45 d0 mov %eax,-0x30(%ebp)
7a4: e9 4b ff ff ff jmp 6f4 <printf+0x54>
7a9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
printint(fd, *ap, 10, 1);
7b0: 83 ec 0c sub $0xc,%esp
7b3: b9 0a 00 00 00 mov $0xa,%ecx
7b8: 6a 01 push $0x1
7ba: eb ce jmp 78a <printf+0xea>
7bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
putc(fd, *ap);
7c0: 8b 5d d0 mov -0x30(%ebp),%ebx
write(fd, &c, 1);
7c3: 83 ec 04 sub $0x4,%esp
putc(fd, *ap);
7c6: 8b 03 mov (%ebx),%eax
write(fd, &c, 1);
7c8: 6a 01 push $0x1
ap++;
7ca: 83 c3 04 add $0x4,%ebx
write(fd, &c, 1);
7cd: 57 push %edi
7ce: ff 75 08 pushl 0x8(%ebp)
putc(fd, *ap);
7d1: 88 45 e7 mov %al,-0x19(%ebp)
write(fd, &c, 1);
7d4: e8 74 fd ff ff call 54d <write>
ap++;
7d9: 89 5d d0 mov %ebx,-0x30(%ebp)
7dc: 83 c4 10 add $0x10,%esp
state = 0;
7df: 31 d2 xor %edx,%edx
7e1: e9 0e ff ff ff jmp 6f4 <printf+0x54>
7e6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
7ed: 8d 76 00 lea 0x0(%esi),%esi
putc(fd, c);
7f0: 88 5d e7 mov %bl,-0x19(%ebp)
write(fd, &c, 1);
7f3: 83 ec 04 sub $0x4,%esp
7f6: e9 59 ff ff ff jmp 754 <printf+0xb4>
7fb: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
7ff: 90 nop
s = (char*)*ap;
800: 8b 45 d0 mov -0x30(%ebp),%eax
803: 8b 18 mov (%eax),%ebx
ap++;
805: 83 c0 04 add $0x4,%eax
808: 89 45 d0 mov %eax,-0x30(%ebp)
if(s == 0)
80b: 85 db test %ebx,%ebx
80d: 74 17 je 826 <printf+0x186>
while(*s != 0){
80f: 0f b6 03 movzbl (%ebx),%eax
state = 0;
812: 31 d2 xor %edx,%edx
while(*s != 0){
814: 84 c0 test %al,%al
816: 0f 84 d8 fe ff ff je 6f4 <printf+0x54>
81c: 89 75 d4 mov %esi,-0x2c(%ebp)
81f: 89 de mov %ebx,%esi
821: 8b 5d 08 mov 0x8(%ebp),%ebx
824: eb 1a jmp 840 <printf+0x1a0>
s = "(null)";
826: bb 71 08 00 00 mov $0x871,%ebx
while(*s != 0){
82b: 89 75 d4 mov %esi,-0x2c(%ebp)
82e: b8 28 00 00 00 mov $0x28,%eax
833: 89 de mov %ebx,%esi
835: 8b 5d 08 mov 0x8(%ebp),%ebx
838: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
83f: 90 nop
write(fd, &c, 1);
840: 83 ec 04 sub $0x4,%esp
s++;
843: 83 c6 01 add $0x1,%esi
846: 88 45 e7 mov %al,-0x19(%ebp)
write(fd, &c, 1);
849: 6a 01 push $0x1
84b: 57 push %edi
84c: 53 push %ebx
84d: e8 fb fc ff ff call 54d <write>
while(*s != 0){
852: 0f b6 06 movzbl (%esi),%eax
855: 83 c4 10 add $0x10,%esp
858: 84 c0 test %al,%al
85a: 75 e4 jne 840 <printf+0x1a0>
85c: 8b 75 d4 mov -0x2c(%ebp),%esi
state = 0;
85f: 31 d2 xor %edx,%edx
861: e9 8e fe ff ff jmp 6f4 <printf+0x54>
|
base/mvdm/wow16/wifeman/wifethk.asm | npocmaka/Windows-Server-2003 | 17 | 163352 | <filename>base/mvdm/wow16/wifeman/wifethk.asm
;++
;
; WOW v1.0
;
; Copyright (c) 1994, Microsoft Corporation
;
; USER.ASM
; Win16 WINNLS thunks
;
; History:
;
; Created 17-May-1994 by hiroh
;--
TITLE WIFEMAN.ASM
PAGE ,132
.286p
.xlist
include wow.inc
include wowwife.inc
include cmacros.inc
.list
__acrtused = 0
public __acrtused ;satisfy external C ref.
externFP WOW16Call
externA __MOD_WIFEMAN
createSeg _TEXT,CODE,WORD,PUBLIC,CODE
createSeg _DATA,DATA,WORD,PUBLIC,DATA,DGROUP
defgrp DGROUP,DATA
sBegin DATA
Reserved db 16 dup (0) ;reserved for Windows
sEnd DATA
sBegin CODE
assumes CS,CODE
assumes DS,NOTHING
assumes ES,NOTHING
WifeManThunk MISCGETEUDCLEADBYTERANGE
sEnd CODE
end
|
source/streams/a-sostio.adb | ytomino/drake | 33 | 14889 | package body Ada.Streams.Overlaps_Storage_IO is
use type System.Storage_Elements.Storage_Offset;
function Create (
Address : System.Address;
Size : System.Storage_Elements.Storage_Count)
return Overlay is
begin
return (Address, Size, 1);
end Create;
procedure Reset (Object : in out Overlay) is
begin
Object.Index := 1;
end Reset;
function Stream (Object : Overlay)
return not null access Root_Stream_Type'Class is
begin
return Object'Unrestricted_Access;
end Stream;
overriding procedure Read (
Object : in out Overlay;
Item : out Stream_Element_Array;
Last : out Stream_Element_Offset)
is
Rest : constant System.Storage_Elements.Storage_Count :=
Object.Size - Object.Index + 1;
Size : System.Storage_Elements.Storage_Count := Item'Length;
begin
if Size > Rest then
Size := Rest;
if Size = 0 and then Item'First = Stream_Element_Offset'First then
raise Constraint_Error; -- AARM 13.13.1(11/2)
end if;
end if;
Last := Item'First + (Stream_Element_Offset (Size) - 1);
declare
Source : Stream_Element_Array (1 .. Stream_Element_Offset (Size));
for Source'Address use Object.Address + Object.Index - 1;
begin
Item (Item'First .. Last) := Source;
end;
Object.Index := Object.Index + Size;
end Read;
overriding procedure Write (
Object : in out Overlay;
Item : Stream_Element_Array)
is
Size : constant System.Storage_Elements.Storage_Count := Item'Length;
Next_Index : constant System.Storage_Elements.Storage_Offset :=
Object.Index + Size;
begin
if Next_Index > Object.Size + 1 then
raise Storage_Error;
end if;
declare
Target : Stream_Element_Array (1 .. Stream_Element_Offset (Size));
for Target'Address use Object.Address + Object.Index - 1;
begin
Target := Item;
end;
Object.Index := Next_Index;
end Write;
overriding procedure Set_Index (
Object : in out Overlay;
To : Stream_Element_Positive_Count)
is
To_Index : constant System.Storage_Elements.Storage_Offset :=
System.Storage_Elements.Storage_Offset (To);
begin
if To_Index not in 1 .. Object.Size + 1 then
raise Constraint_Error;
end if;
Object.Index := To_Index;
end Set_Index;
overriding function Index (Object : Overlay)
return Stream_Element_Positive_Count is
begin
return Stream_Element_Offset (Object.Index);
end Index;
overriding function Size (Object : Overlay)
return Stream_Element_Count is
begin
return Stream_Element_Offset (Object.Size);
end Size;
end Ada.Streams.Overlaps_Storage_IO;
|
Transynther/x86/_processed/NONE/_st_/i3-7100_9_0xca_notsx.log_21829_563.asm | ljhsiun2/medusa | 9 | 102802 | .global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r13
push %r9
push %rax
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_A_ht+0x590e, %rbp
xor $63501, %r13
mov (%rbp), %r11w
nop
and $6766, %rax
lea addresses_normal_ht+0x338a, %rax
nop
nop
and %rdi, %rdi
mov $0x6162636465666768, %r9
movq %r9, %xmm1
movups %xmm1, (%rax)
nop
nop
nop
nop
dec %rdi
lea addresses_normal_ht+0x1210e, %rsi
lea addresses_UC_ht+0xbb4e, %rdi
nop
nop
cmp $56855, %rbp
mov $99, %rcx
rep movsw
nop
and %rdi, %rdi
lea addresses_D_ht+0x79be, %r13
xor $37009, %rcx
mov $0x6162636465666768, %rbp
movq %rbp, (%r13)
nop
nop
nop
nop
nop
and %rbp, %rbp
lea addresses_WC_ht+0x5162, %rsi
lea addresses_WT_ht+0x11d96, %rdi
nop
nop
cmp %r9, %r9
mov $105, %rcx
rep movsw
nop
nop
nop
add $44906, %rcx
lea addresses_WT_ht+0x1438e, %rsi
lea addresses_D_ht+0x1bf0e, %rdi
nop
nop
cmp %rbp, %rbp
mov $15, %rcx
rep movsb
xor $22692, %rax
lea addresses_D_ht+0x2a95, %rax
add $24439, %r11
mov $0x6162636465666768, %rdi
movq %rdi, (%rax)
cmp %r13, %r13
lea addresses_D_ht+0x6366, %r13
nop
cmp %rdi, %rdi
mov $0x6162636465666768, %rbp
movq %rbp, %xmm2
movups %xmm2, (%r13)
nop
cmp $4587, %rsi
lea addresses_WC_ht+0x16a86, %rbp
clflush (%rbp)
nop
nop
nop
nop
nop
inc %rdi
movl $0x61626364, (%rbp)
nop
nop
nop
add $46939, %rax
lea addresses_normal_ht+0x430e, %r9
nop
nop
nop
nop
nop
and $14395, %r13
movups (%r9), %xmm5
vpextrq $1, %xmm5, %r11
nop
nop
nop
xor %rax, %rax
lea addresses_D_ht+0x147ce, %rbp
nop
nop
nop
xor $20514, %r11
mov $0x6162636465666768, %rsi
movq %rsi, %xmm0
movups %xmm0, (%rbp)
nop
xor $39658, %rdi
lea addresses_UC_ht+0x11076, %rax
and %rsi, %rsi
movb $0x61, (%rax)
and %rbp, %rbp
lea addresses_A_ht+0x18126, %r13
nop
and $32593, %rbp
mov (%r13), %r11d
nop
nop
nop
xor %r11, %r11
lea addresses_WC_ht+0x490e, %rsi
lea addresses_WC_ht+0x15d0e, %rdi
clflush (%rsi)
nop
nop
sub %r13, %r13
mov $49, %rcx
rep movsq
nop
nop
nop
sub $64223, %rdi
lea addresses_D_ht+0x1010e, %rsi
nop
nop
nop
nop
nop
and $18128, %rcx
movups (%rsi), %xmm0
vpextrq $0, %xmm0, %rdi
nop
nop
add %rsi, %rsi
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %rax
pop %r9
pop %r13
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r14
push %r8
push %rbp
push %rbx
push %rcx
push %rdi
push %rsi
// Load
lea addresses_D+0x1dd3e, %r14
nop
nop
nop
and %r8, %r8
vmovups (%r14), %ymm4
vextracti128 $0, %ymm4, %xmm4
vpextrq $0, %xmm4, %rbx
nop
nop
nop
nop
nop
inc %r14
// REPMOV
lea addresses_WT+0x1857e, %rsi
lea addresses_PSE+0x9bc8, %rdi
nop
sub %r14, %r14
mov $19, %rcx
rep movsb
inc %rbx
// Load
lea addresses_PSE+0x510e, %rdi
nop
nop
nop
dec %r8
mov (%rdi), %rsi
nop
cmp %rbx, %rbx
// REPMOV
lea addresses_D+0x4f8e, %rsi
lea addresses_WT+0x1090e, %rdi
nop
nop
add $48365, %r14
mov $15, %rcx
rep movsb
nop
and %rbx, %rbx
// REPMOV
lea addresses_WC+0xf40e, %rsi
lea addresses_D+0x1f38a, %rdi
nop
nop
sub %r8, %r8
mov $95, %rcx
rep movsq
nop
nop
nop
nop
cmp $45141, %rbx
// Store
lea addresses_normal+0xba8e, %r8
xor %r11, %r11
movl $0x51525354, (%r8)
nop
nop
nop
nop
nop
sub %rsi, %rsi
// Faulty Load
lea addresses_WT+0x1090e, %rdi
nop
nop
and $46356, %r14
mov (%rdi), %r11d
lea oracles, %rcx
and $0xff, %r11
shlq $12, %r11
mov (%rcx,%r11,1), %r11
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %r8
pop %r14
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_WT', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'same': False, 'congruent': 2, 'NT': False, 'type': 'addresses_D', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WT', 'congruent': 2, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_PSE', 'congruent': 1, 'same': False}}
{'src': {'same': False, 'congruent': 11, 'NT': True, 'type': 'addresses_PSE', 'size': 8, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_D', 'congruent': 7, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT', 'congruent': 0, 'same': True}}
{'src': {'type': 'addresses_WC', 'congruent': 8, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D', 'congruent': 2, 'same': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 6, 'NT': False, 'type': 'addresses_normal', 'size': 4, 'AVXalign': False}}
[Faulty Load]
{'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_WT', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'same': False, 'congruent': 10, 'NT': False, 'type': 'addresses_A_ht', 'size': 2, 'AVXalign': True}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 2, 'NT': False, 'type': 'addresses_normal_ht', 'size': 16, 'AVXalign': False}}
{'src': {'type': 'addresses_normal_ht', 'congruent': 10, 'same': True}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 6, 'same': False}}
{'OP': 'STOR', 'dst': {'same': True, 'congruent': 2, 'NT': False, 'type': 'addresses_D_ht', 'size': 8, 'AVXalign': False}}
{'src': {'type': 'addresses_WC_ht', 'congruent': 2, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 0, 'same': False}}
{'src': {'type': 'addresses_WT_ht', 'congruent': 7, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 9, 'same': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_D_ht', 'size': 8, 'AVXalign': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 1, 'NT': False, 'type': 'addresses_D_ht', 'size': 16, 'AVXalign': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_WC_ht', 'size': 4, 'AVXalign': False}}
{'src': {'same': False, 'congruent': 7, 'NT': False, 'type': 'addresses_normal_ht', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_D_ht', 'size': 16, 'AVXalign': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_UC_ht', 'size': 1, 'AVXalign': False}}
{'src': {'same': False, 'congruent': 2, 'NT': True, 'type': 'addresses_A_ht', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WC_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 8, 'same': False}}
{'src': {'same': False, 'congruent': 11, 'NT': False, 'type': 'addresses_D_ht', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'}
{'36': 21829}
36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36
*/
|
programs/oeis/067/A067275.asm | karttu/loda | 1 | 97211 | <filename>programs/oeis/067/A067275.asm
; A067275: Number of Fibonacci numbers A000045(k), k <= 10^n, which end in 4.
; 0,1,7,67,667,6667,66667,666667,6666667,66666667,666666667,6666666667,66666666667,666666666667,6666666666667,66666666666667,666666666666667,6666666666666667
lpb $0,1
sub $3,1
add $1,$3
mul $1,2
sub $0,1
mov $2,$1
mov $3,$2
add $1,1
add $1,$2
add $3,$1
lpe
mov $1,$3
|
unittests/ASM/REP/F3_2C.asm | woachk/FEX | 0 | 162815 | <gh_stars>0
%ifdef CONFIG
{
"RegData": {
"RAX": "0x1",
"RBX": "0x2",
"RCX": "0x3",
"RDX": "0x4",
"RBP": "0xFFFFFFFE",
"RSI": "0xFFFFFFFC"
},
"MemoryRegions": {
"0x100000000": "4096"
}
}
%endif
mov rdx, 0xe0000000
mov rax, 0x414243443f800000
mov [rdx + 8 * 0], rax
mov rax, 0x5152535455565758
mov [rdx + 8 * 1], rax
mov rax, 0x4142434440000000
mov [rdx + 8 * 2], rax
mov rax, 0x5152535455565758
mov [rdx + 8 * 3], rax
mov rax, 0x4142434440400000
mov [rdx + 8 * 4], rax
mov rax, 0x5152535455565758
mov [rdx + 8 * 5], rax
mov rax, 0x4142434440800000
mov [rdx + 8 * 6], rax
mov rax, 0x5152535455565758
mov [rdx + 8 * 7], rax
mov rax, 0x41424344C0000000
mov [rdx + 8 * 8], rax
mov rax, 0x5152535455565758
mov [rdx + 8 * 9], rax
mov rax, 0x41424344C0800000
mov [rdx + 8 * 10], rax
mov rax, 0x5152535455565758
mov [rdx + 8 * 11], rax
movapd xmm0, [rdx + 8 * 0]
movapd xmm1, [rdx + 8 * 2]
cvttss2si eax, xmm0
cvttss2si rbx, xmm1
cvttss2si ebp, [rdx + 8 * 8]
cvttss2si rsi, [rdx + 8 * 10]
cvttss2si ecx, [rdx + 8 * 4]
cvttss2si rdx, [rdx + 8 * 6]
hlt
|
Projects/PJZ2/Framework/IntroLibrary.asm | jonathanbennett73/amiga-pjz-planet-disco-balls | 21 | 6287 | <gh_stars>10-100
*****************************************************************************
; Name : IntroLibrary.s
; Coded by : Antiriad (<NAME> <<EMAIL>>)
; Description : Shared useful functions that can be turned on from IntroConfig.i.
; Date last edited : 04/02/2020
*****************************************************************************
ifnd _CUSTOMMACROS_I
include "CustomMacros.i"
endif
include "../IntroConfig.i"
include "IntroLibrary.i"
*****************************************************************************
section FW_PublicCode,CODE ;Code section in Public memory
*****************************************************************************
*****************************************************************************
*****************************************************************************
* Runs precalc code for any library functions that are enabled.
* IN:
* OUT:
* TRASHED: d0-a1/a0-a1
*****************************************************************************
xdef LIB_PreCalc
LIB_PreCalc:
movem.l d2-d7/a2-a6,-(sp)
ifd LIB_ENABLE_RGB12_LERP
bsr.s LIB_RGB12_Interpolate_Fast_BuildTable
endif
movem.l (sp)+,d2-d7/a2-a6
rts
*****************************************************************************
*****************************************************************************
* Interpolates between 2 12 bit colors. Use for fades.
* From post on eab. Meynaf's version. 8bit fractional.
* 506 cycles for $fff to $000, step 7
*
* IN: d0, color source
* d1, color dest
* d2, step (0-15)
* OUT: d0, new color
* TRASHED: d0-d4
*****************************************************************************
ifd LIB_ENABLE_RGB12_LERP
LIB_RGB12_Interpolate_8bit:
move.l d5,-(sp)
move.l d6,-(sp)
moveq #15,d6
lsl.w #8,d2
divu d6,d2
.loop:
move.w d6,d4 ; (ex: 0f0)
move.w d6,d5
and.w d0,d4 ; d4=0v0
and.w d1,d5 ; d5=0w0
eor.w d4,d0 ; d0=v0v
move.w d4,d3 ; d3=0v0
sub.w d5,d4 ; d4=*d0
muls d2,d4 ; d4=m*0
lsr.l #8,d4 ; d4=*m*
add.w d3,d4 ; d4=*c*
and.w d6,d4 ; d4=0c0
add.w d4,d0 ; d0=vcv
lsl.w #4,d6
bpl.s .loop ; f000 -> n=1
move.l (sp)+,d6
move.l (sp)+,d5
rts
endif ; LIB_ENABLE_RGB12_LERP
*****************************************************************************
* Interpolates between 2 12 bit colors. Use for fades.
* From post on eab. Ross's version. 16bit fractional.
* 850 cycles for $fff to $000, step 7
*
* IN: d0, color source
* d1, color dest
* d2, step (0-15)
* OUT: d0, new color
* TRASHED: d0-d4
*****************************************************************************
ifd LIB_ENABLE_RGB12_LERP
LIB_RGB12_Interpolate_16bit:
move.l d5,-(sp)
move.l d6,-(sp)
moveq #0,d3
moveq #3,d4
.ls: moveq #15,d5
moveq #15,d6
and.w d0,d5
and.w d1,d6
lsr.w #4,d0
lsr.w #4,d1
sub.w d5,d6
muls.w d2,d6
muls.w #$1111,d6 ; (1/15)*2^16=4369,0x
add.w d6,d6
swap d6
addx.w d6,d5 ; +0.5
or.w d5,d3
ror.w #4,d3
dbf d4,.ls
move.l d3,d0
move.l (sp)+,d6
move.l (sp)+,d5
rts
endif ; LIB_ENABLE_RGB12_LERP
*****************************************************************************
* Builds table for fast lerp.
* From post on eab. a/b's version.
* IN: d0, color source
* d1, color dest
* d2, step (0-15)
* OUT: d0, new color
* TRASHED: d0-d2/a0
*****************************************************************************
ifd LIB_ENABLE_RGB12_LERP
LIB_RGB12_Interpolate_Fast_BuildTable:
lea LIB_RGB12_Interpolate_Table,a0
moveq #-15,d2
.LoopColor
moveq #0,d1
.LoopScale
move.w d2,d0
muls.w d1,d0
divs.w #15,d0
move.b d0,(a0)+
asl.b #4,d0
move.b d0,(a0)+
addq.w #1,d1
cmp.w #16,d1
bne.b .LoopScale
addq.w #1,d2
cmp.w #16,d2
bne.b .LoopColor
rts
endif ; LIB_ENABLE_RGB12_LERP
*****************************************************************************
* Interpolates between 2 12 bit colors. Use for fades.
* From post on eab. a/b's version.
*
* 196 cycles.
*
* IN: d0, color source
* d1, color dest
* d2, step (0-15)
* OUT: d0, new color
* TRASHED: d0-d4/a0
*****************************************************************************
ifd LIB_ENABLE_RGB12_LERP
xdef LIB_RGB12_Interpolate_Fast
LIB_RGB12_Interpolate_Fast:
;if colors are the same just exit
;Removed: Check before calling
;cmp.w d0,d1
;beq.s .exit
lea LIB_RGB12_Interpolate_Table,a0
move.w #$0f0,d3 ; 8
add.w d3,d2 ; 4
add.w d2,d2 ; 4
move.w d3,d4 ; 4
and.w d0,d3 ; 4
and.w d1,d4 ; 4
sub.w d3,d4 ; 4
add.w d4,d4 ; 4
add.w d2,d4 ; 4
add.b 1(a0,d4.w),d0 ; 14
;move.w #$00f,d3 ; 8
moveq #$00f,d3 ; 4
move.w d3,d4 ; 4
and.w d0,d3 ; 4
and.w d1,d4 ; 4
sub.w d3,d4 ; 4
asl.w #4+1,d4 ; 6+2*5=16
add.w d2,d4 ; 4
add.b (a0,d4.w),d0 ; 14
move.w d0,d3 ; 4
clr.b d3 ; 4
clr.b d1 ; 4
sub.w d3,d1 ; 4
asr.w #8-(4+1),d1 ; 6+2*3=12
add.w d2,d1 ; 4
move.w (a0,d1.w),d1 ; 14
clr.b d1 ; 4
add.w d1,d0 ; 4
.exit:
rts ; 16
endif ; LIB_ENABLE_RGB12_LERP
*****************************************************************************
* Interpolates between 2 12 bit colors. Use for fades.
*
* This version does multiple colors at once from a list of RGB words
* IN: a0, color source palette
* a1, color dest palette
* a2, resulting palette
* d0, num colours to process
* d1, step (0-15)
* OUT: d1, step
* TRASHED: d0/d2-d6/a0-a3
*****************************************************************************
ifd LIB_ENABLE_RGB12_LERP
xdef LIB_RGB12_Interpolate_Fast_Palette
LIB_RGB12_Interpolate_Fast_Palette:
lea LIB_RGB12_Interpolate_Table,a3
subq.w #1,d0 ;correct dbf
bmi.s .exit
.loop:
move.w d1,d2 ;restore step
move.w (a0)+,d5 ;source
move.w (a1)+,d6 ;dest
cmp.w d5,d6
beq.s .store ;skip processing if colors the same
move.w #$0f0,d3 ; 8
add.w d3,d2 ; 4
add.w d2,d2 ; 4
move.w d3,d4 ; 4
and.w d5,d3 ; 4
and.w d6,d4 ; 4
sub.w d3,d4 ; 4
add.w d4,d4 ; 4
add.w d2,d4 ; 4
add.b 1(a3,d4.w),d5 ; 14
;move.w #$00f,d3 ; 8
moveq #$00f,d3 ; 4
move.w d3,d4 ; 4
and.w d5,d3 ; 4
and.w d6,d4 ; 4
sub.w d3,d4 ; 4
asl.w #4+1,d4 ; 6+2*5=16
add.w d2,d4 ; 4
add.b (a3,d4.w),d5 ; 14
move.w d5,d3 ; 4
clr.b d3 ; 4
clr.b d6 ; 4
sub.w d3,d6 ; 4
asr.w #8-(4+1),d6 ; 6+2*3=12
add.w d2,d6 ; 4
move.w (a3,d6.w),d6 ; 14
clr.b d6 ; 4
add.w d6,d5 ; 4
.store:
move.w d5,(a2)+ ;store result color
dbf d0,.loop
.exit:
rts
endif ; LIB_ENABLE_RGB12_LERP
*****************************************************************************
* Takes two colours and outputs 16 steps of fade. Use for creating a table for fades.
*
* IN: d0, color source
* d1, color dest
* a0, destination palette (16 words)
* OUT: a0, updated palette
* TRASHED: d0-d7/a0-a1
*****************************************************************************
ifd LIB_ENABLE_RGB12_LERP
xdef LIB_RGB12_Interpolate_Fast_AllSteps
LIB_RGB12_Interpolate_Fast_AllSteps:
;Catch case where source = dest and shortcircuit
cmp.w d0,d1
bne.s .calc
swap d0
move.w d1,d0
rept 8
move.l d0,(a0)+
endr
rts
.calc:
lea LIB_RGB12_Interpolate_Table,a1
;we know that step 0 will be the source color and step 15 will be the dest color
;so we can skip those calculations
move.w d0,(a0)+ ;step 0 colour
move.w d0,d6 ;save col
move.w d1,d7 ;save col
moveq #1,d5 ;step 1 (already done step 0)
.loop:
move.w d6,d0
move.w d7,d1
move.w d5,d2 ;new step
move.w #$0f0,d3 ; 8
add.w d3,d2 ; 4
add.w d2,d2 ; 4
move.w d3,d4 ; 4
and.w d0,d3 ; 4
and.w d1,d4 ; 4
sub.w d3,d4 ; 4
add.w d4,d4 ; 4
add.w d2,d4 ; 4
add.b 1(a1,d4.w),d0 ; 14
moveq #$00f,d3 ; 4
move.w d3,d4 ; 4
and.w d0,d3 ; 4
and.w d1,d4 ; 4
sub.w d3,d4 ; 4
asl.w #4+1,d4 ; 6+2*5=16
add.w d2,d4 ; 4
add.b (a1,d4.w),d0 ; 14
move.w d0,d3 ; 4
clr.b d3 ; 4
clr.b d1 ; 4
sub.w d3,d1 ; 4
asr.w #8-(4+1),d1 ; 6+2*3=12
add.w d2,d1 ; 4
move.w (a1,d1.w),d1 ; 14
clr.b d1 ; 4
add.w d1,d0 ; 4
move.w d0,(a0)+
addq.w #1,d5
cmp.w #14,d5
ble.s .loop
move.w d7,(a0)+ ;step 15 color
rts
endif ; LIB_ENABLE_RGB12_LERP
*****************************************************************************
* XOR horizontal fill. TODO: not finished
* IN: a0, packed data
* a1, destination
* OUT: a1, ptr to end of packed data
* TRASHED: d0-d1/a0-a1
*****************************************************************************
ifd LIB_ENABLE_BLT_FILL_GEN
xdef BM_To_BLT_FILL_XOR_Horizontal
BM_To_BLT_FILL_XOR_Horizontal:
move.w #286-1,d0 ;video lines
.nl
moveq #384/8/2-1,d1 ;words in a line
moveq #0,d7 ;FCI
moveq #0,d6 ;state
.rw
moveq #16-1,d2 ;bits in a word
move.w -(a1),d3
eor.w d6,d3 ;propagate state
.eb
lsr.w #1,d3 ;read bit
subx.w d7,d7 ;update FCI
eor.w d7,d6 ;update state
roxr.w #1,d4 ;insert bit
eor.w d7,d3 ;propagate FCI
dbf d2,.eb
move.w d4,-(a2)
dbf d1,.rw
dbf d0,.nl
rts
endif
*****************************************************************************
* Converts a bitmap into something that can be used for blitter vertical filling.
* Thanks <NAME> for the code.
* IN: a0, pointer to bitmap
* d0, bitmap width in bytes
* d1, bitmap height in lines
* OUT:
* TRASHED: d0-d4/d6/d7/a0
*****************************************************************************
ifd LIB_ENABLE_BLT_FILL_GEN
xdef BM_To_BLT_FILL_XOR_Vertical
BM_To_BLT_FILL_XOR_Vertical:
move.w d0,d6
subq #1,d6
.XLoop
moveq #0,d2
move.w d1,d7
subq #1,d7
moveq #0,d4
.YLoop
move.b (a0,d2.w),d3
eor.b d3,d4
move.b d4,(a0,d2.w)
move.b d3,d4
add.w d0,d2
dbra d7,.YLoop
addq.w #1,a0
dbra d6,.XLoop
rts
endif
*****************************************************************************
* Arj m7 depacker.
* arjbeta a -m7 -jm __temp__archive__.arj in.bin
* arj2raw __temp__archive__.arj in.bin out.am7
* IN: a0, packed data
* a1, destination
* OUT: a1, ptr to end of packed data
* TRASHED: d0-d1/a0-a1
*****************************************************************************
ifd LIB_ENABLE_ARJM7
xdef LIB_ArjM7_Depack
LIB_ArjM7_Depack:
;routine wants src=a1,dest=a0
exg a0,a1
;a2, buffer (11312 bytes / LIB_ARJM7_BUFFER_SIZE)
lea LIB_Depack_Buffer,a2
include "Depack/ArjM7_Depack_ross.asm"
endif
*****************************************************************************
* PackFire depacker (large model).
* packfire -l in.bin out.pkf
* IN: a0, packed data
* a1, destination
* OUT:
* TRASHED: d0-d1/a0-a1
*****************************************************************************
ifd LIB_ENABLE_PACKFIRE_LARGE
xdef LIB_PackFire_Large_Depack
LIB_PackFire_Large_Depack:
movem.l d2-d7/a2-a6,-(sp)
;a2, buffer (15980 bytes / LIB_PACKFIRE_BUFFER_SIZE)
lea LIB_Depack_Buffer,a2
bsr.s packfire_large_depack
movem.l (sp)+,d2-d7/a2-a6
rts
include "Depack/PackFire_Depack_Large.asm"
endif
*****************************************************************************
* LZ4 depacker.
* Use lz4.exe -9 --no-frame-crc in.bin out.lz4
* IN: a0, packed data
* a1, destination
* d0.l, size of packed data in bytes
* OUT:
* TRASHED: d0-d1/a0-a1
*****************************************************************************
ifd LIB_ENABLE_LZ4
xdef LIB_LZ4_Depack
LIB_LZ4_Depack:
movem.l d2-d7/a2-a6,-(sp)
bsr.s lz4_frame_depack
movem.l (sp)+,d2-d7/a2-a6
rts
include "Depack/LZ4_Depack_Frame.asm"
endif
*****************************************************************************
* Cranker depacker.
* Use cranker -cd -f in.bin -o out.cra
*
* In-place decrunching: Align the crunched data to the end of the
* destination area PLUS overhead.
*
* IN: a0, packed data
* a1, destination
* OUT:
* TRASHED: d0-d1/a0-a1
*****************************************************************************
ifd LIB_ENABLE_CRANKER
xdef LIB_Cranker_Depack
LIB_Cranker_Depack:
;Note that the cruncher produces a 4 byte header, $b0 followed by the
;24bit length of the decrunched data. Strip off or skip these first
;four bytes from the crunched data when passing them to this routine.
addq.l #4,a0
include "Depack/Cranker_Depack.asm"
endif
*****************************************************************************
* Doynamite68k depacker.
* Use doynamite68k_lz.exe -o output.doy intput.bin
* IN: a0, packed data (must be even aligned)
* a1, destination
* OUT:
* TRASHED: d0-d1/a0-a1
*****************************************************************************
ifd LIB_ENABLE_DOYNAMITE68K
xdef LIB_Doynamite68k_Depack
LIB_Doynamite68k_Depack:
movem.l d2-d7/a2-a6,-(sp)
bsr.s doynax_depack
movem.l (sp)+,d2-d7/a2-a6
rts
include "Depack/doynamite68k_Depack.asm"
endif
*****************************************************************************
* NRV2S depacker. Can depack in place with offset. Load source at the offset
* given by the nrv2x commandline into the dest buffer.
*
* IN: a0, packed data
* a1, destination
* OUT: a0, dest start
* a1, dest end
* TRASHED: d0-d1/a0-a1
*****************************************************************************
ifd LIB_ENABLE_NRV2S
xdef LIB_NRV2S_Depack
LIB_NRV2S_Depack:
include "Depack/nrv2s_Depack.asm"
endif
*****************************************************************************
* NRV2R depacker. Can depack in place with a0=a1.
*
* IN: a0, packed data
* a1, destination
* OUT: a1, dest start
* TRASHED: d0-d1/a0-a1
*****************************************************************************
ifd LIB_ENABLE_NRV2R
xdef LIB_NRV2R_Depack
LIB_NRV2R_Depack:
include "Depack/nrv2r_Depack.asm"
endif
*****************************************************************************
*
* IN: a0, packed data
* a1, destination
* OUT:
* TRASHED: d0-d1/a0-a1
*****************************************************************************
ifd LIB_ENABLE_SHRINKLER
xdef LIB_Shrinkler_Depack
LIB_Shrinkler_Depack:
movem.l a2-a3,-(sp) ;everything else saved by routine
sub.l a2,a2 ;no callback
bsr.s Shrinkler_Depack
movem.l (sp)+,a2-a3
rts
include "Depack/Shrinkler_Depack.asm"
endif
*****************************************************************************
*
* IN: a0, packed data
* a1, destination
* OUT: d0.l = length of unpacked file in bytes OR error code
* 0 = not a packed file
* -1 = packed data CRC error
* -2 = unpacked data CRC error
* TRASHED: d0-d1/a0-a1
*****************************************************************************
ifd LIB_ENABLE_RNC_1
xdef LIB_RNC_Depack
LIB_RNC_Depack:
moveq #0,d0 ;No key
bsr.s RNC_Unpack
rts
include "Depack/RNC_Depack_1.asm"
endif
*****************************************************************************
*
* IN: a0, packed data
* a1, destination
* OUT:
* TRASHED: d0-d1/a0-a1
*****************************************************************************
ifd LIB_ENABLE_RNC_1C
xdef LIB_RNC_Depack
LIB_RNC_Depack:
moveq #0,d0 ;No key
bsr.s RNC_Unpack
rts
include "Depack/RNC_Depack_1C.asm"
endif
*****************************************************************************
*
* IN: a0, packed data
* a1, destination
* OUT: d0.l = length of unpacked file in bytes OR error code
* 0 = not a packed file
* -1 = packed data CRC error
* -2 = unpacked data CRC error
* TRASHED: d0-d1/a0-a1
*****************************************************************************
ifd LIB_ENABLE_RNC_2
xdef LIB_RNC_Depack
LIB_RNC_Depack:
moveq #0,d0 ;No key
bsr.s RNC_Unpack
rts
include "Depack/RNC_Depack_2.asm"
endif
*****************************************************************************
* From:
* Atari-Forum
*
* The fastest.
*
* IN: d0.l, number to find square root of
* OUT: d0.w, square root (top of .l is zeroed so d0.l is usable)
* TRASHED: d0-d3
*****************************************************************************
ifd LIB_ENABLE_SQRT
xdef LIB_Sqrt_FastNewton
LIB_Sqrt_FastNewton:
move.l #$100,d2 ;ensure top of d2 clear
cmp.l d2,d0 ; d0<256?
bcs.s .8bit ; yep
move.l d0,d3 ; x
swap d0
tst.w d0
bne.s .32bit
move.l d3,d0
moveq #0,d1
.loop:
addq.w #1,d1 ;
.loop_start: ; 16 bits left
lsr.w #2,d0 ;
cmp.w d2,d0
bcc.s .loop
move.b .sqrt_table(pc,d0.w),d0 ; table lookup
lsl.w d1,d0 ; order 0
move.l d3,d1 ; x
divu d0,d1 ; x/tmp
add.w d1,d0 ; tmp+=x/tmp
lsr.w #1,d0 ; tmp/=2 order 1
move.l d3,d1
divu d0,d1 ; x/tmp
add.w d1,d0 ; tmp+=x/tmp
lsr.w #1,d0 ; tmp/=2 order 2
rts
.8bit:
move.b .sqrt_table(pc,d0.w),d0 ; table lookup
rts
.32bit:
cmp.w d2,d0 ; 24 bit?
bcc.s .24bit
move.l d3,d0
lsr.l #8,d0
moveq #5,d1
bra.s .loop_start
.24bit:
cmpi.w #$3fc0,d0 ; bignum?
bcc.s .bignum ; yep
move.l d3,d0
clr.w d0
swap d0
moveq #9,d1
bra.s .loop_start
.bignum: ; big nums cause overflows
cmpi.w #$fffd,d0 ; big bignum?
bcc.s .bigbignum ; yep!
move.l d3,-(sp) ; store x
swap d0
lsr.l #4,d0 ; x geen bignum meer
move.l d0,d3 ; x
clr.w d0
swap d0
moveq #9,d1
bsr.s .loop_start
add.w d0,d0
add.w d0,d0 ; d0 is our guess now
move.l (sp)+,d1 ; x
divu d0,d1 ; i/tmp
bvc.s .cont0
moveq #1,d1 ; overflow!
bra.s .cont1
.cont0:
swap d1
clr.w d1
.cont1:
swap d1
add.l d1,d0 ; tmp+=i/tmp
lsr.l #1,d0 ; tmp/=2
rts
.bigbignum:
moveq #0,d0
subq.w #1,d0 ; d0=$0000ffff
rts
.sqrt_table:
dc.b 0,1,1,1,2,2,2,2,2,3,3,3,3,3,3,3
dc.b 4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5
dc.b 5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6
dc.b 6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
dc.b 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8
dc.b 8,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9
dc.b 9,9,9,9,10,10,10,10,10,10,10,10,10,10,10,10
dc.b 10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11
dc.b 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11
dc.b 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12
dc.b 12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13
dc.b 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13
dc.b 13,13,13,13,14,14,14,14,14,14,14,14,14,14,14,14
dc.b 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14
dc.b 14,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15
dc.b 15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15
endif
*****************************************************************************
* From:
* Atari-Forum.
*
* The 2nd fastest
*
* IN: d0.l, number to find square root of
* OUT: d0.w, square root
* TRASHED: d0-d3
*****************************************************************************
ifne 0
ifd LIB_ENABLE_SQRT
xdef LIB_Sqrt_DAVID
LIB_Sqrt_DAVID:
move.l d0,d3 ; save x
swap d0
tst.w d0 ; <= 65535?
beq.s .LESS ;
cmpi.w #255,d0
bls.s .L2
cmp.w #$fffd,d0
bcc.s .exit_max
moveq #16,d1
add.w d0,d0
bcs.s .START
subq.w #1,d1
.L1:
add.w d0,d0 ; Normalization
bcs.s .START
add.w d0,d0
dbcs d1,.L1
bra.s .START
.exit_max:
moveq #0,d0
subq.w #1,d0
rts
.L2:
moveq #12,d1
add.b d0,d0 ; Normalization
bcs.s .START
subq.w #1,d1
.L2L:
add.b d0,d0
bcs.s .START
add.b d0,d0
dbcs d1,.L2L
.START:
move.l d3,d2 ; x
moveq #0,d0
bset d1,d0
lsr.l d1,d2 ; x is 32 bit
addx.l d2,d0
lsr.l #1,d0 ; for FFFCFFFF first gues is FFFE
subq.l #1,d3 ; for better results
move.l d3,d1 ; a/x
divu d0,d1 ;
addq.w #1,d0 ; LSB rounded, no overflow possible here!
add.w d1,d0 ; x = (a/x + x) / 2 ;
roxr.w #1,d0 ; MSB shifted back in, max answer is FFFE
move.l d3,d1 ; a/x
divu d0,d1 ;
addq.w #1,d0 ; LSB rounded
add.w d1,d0 ; x = (a/x + x) / 2 ;
roxr.w #1,d0 ; MSB shifted back in
.SQRTF: rts
.LESS: swap d0
cmpi.w #255,d0
bls.s .L4
moveq #8,d1
add.w d0,d0
bcs.s .STARTS
subq.w #1,d1
.L3: add.w d0,d0 ; Normalization
bcs.s .STARTS
add.w d0,d0
dbcs d1,.L3 ;
bra.s .STARTS
.L4: cmp.w #1,d0 ;
bls.s .SQRTF ; return with sqrt of 0 or 1 now
moveq #4,d1
add.b d0,d0
bcs.s .STARTS
subq.w #1,d1
.L4L: add.b d0,d0 ; Normalization
bcs.s .STARTS
add.b d0,d0
dbcs d1,.L4L ;
.STARTS:
move.l d3,d2 ; x
lsr.w d1,d2 ; x is 16 bit
moveq #0,d0
bset d1,d0 ; x is not affected
addx.w d2,d0
lsr.w #1,d0
move.l d3,d1 ; a/x
subq.w #1,d1
divu d0,d1 ;
addq.w #1,d0
add.w d1,d0 ; x = (a/x + x) / 2 ;
roxr.w #1,d0 ; MSB shifted back in
rts
endif
endif
*****************************************************************************
* Find the sqrt of a long word N in d0 in three iterations: sqrt=1/2(squrt+N/squrt)
* approximate starting value found from highest bit in d0: Result passed in d0.w
* Adapted from: Amiga Realtime Graphics Book
*
* The 3rd fastest.
*
* IN: d0.l, number to find square root of
* OUT: d0.w, approximate square root (accurate to a word width though)
* TRASHED: d0-d2
*****************************************************************************
ifne 0
ifd LIB_ENABLE_SQRT
xdef LIB_Sqrt_ARTGFX
LIB_Sqrt_ARTGFX:
tst.l d0
beq.s .sqrt2 ;quit if zero
moveq #31,d2 ;31 bits to examine
.sqrt1:
btst d2,d0 ;is this bit set?
dbne d2,.sqrt1
lsr.w #1,d2 ;bit is set: 2^d2/2 approx root
bset d2,d2 ;raise 2 to this power
move.l d0,d1
divs d2,d1 ;N/squrt
add d1,d2 ;squrt+N/squrt
lsr.w #1,d2 ;/2 gives new trial value
move.l d0,d1 ;N
divs d2,d1
add d1,d2
lsr.w #1,d2 ;second result
move.l d0,d1
divs d2,d1
add d1,d2
lsr.w #1,d2 ;final result
move.w d2,d0
.sqrt2:
rts
endif
endif
*****************************************************************************
* Small but slow sqrt from:
* Atari-Forum
*
* IN: d0.l, number to find square root of
* OUT: d0.l, square root
* TRASHED: d0-d1
*****************************************************************************
ifne 0
sqrt_short:
moveq #-1,d1
.loop:
addq.l #2,d1
sub.l d1,d0
bcc.s .loop
lsr.l #1,d1
move.l d1,d0
rts
endif
*****************************************************************************
* Generates 2048+512 sin followed by cos table from -16383 to 16383.
* Code by ross.
*
* IN: a0, destination table (2048+512 words)
* OUT:
* TRASHED: d0-d1/a0-a1
*****************************************************************************
;2048 entries, index mask is 0-2047. offset mask is 0-4094
;LIB_GENSIN_16384_2048W_NUMWORDS equ 2048
;LIB_GENSIN_16384_2048W_INDEX_MASK equ LIB_GENSIN_16384_2048W_NUMWORDS-1
;LIB_GENSIN_16384_2048W_OFFSET_MASK equ ((LIB_GENSIN_16384_2048W_NUMWORDS*2)-2)
;Note need to be a little careful when shifting right to change range as -16383 >> 1 = -8192
;so ranges change as follows when shifting right
;-8192 to 8191 etc
;-4096 to 4095
;If rounding with addx means this becomes:
;-8191 to 8192
ifd LIB_ENABLE_GENSINE_2048
xdef LIB_GenSin_16384_2048W
LIB_GenSin_16384_2048W:
movem.l d2-d3/a2,-(sp)
lea 512*2(a0),a1
moveq #3,d0
ror.l #2,d0 ; <<30 (^32)
move.w #(512-1)<<6,d1 ; ^9+^6=^15
.l move.l d0,d3
move.l d1,d2
mulu.w d2,d2 ; ^15+^15=^30
sub.l d2,d3 ; -> (^31~3.0
swap d3 ; ^32-^16=^16--
mulu.w d1,d3 ; (^16--)+(^15--)=^30
swap d3 ; ^30-^16=^14
move.w d3,-(a1)
subi.w #1<<6,d1
bpl.b .l
lea (512*2)-2(a0),a1 ; all quadrant
move.w (a1)+,d1
.l0 move.w #512-1,d0
movea.l a1,a2
move.w d1,(a2)+
.l1 move.w -(a1),(a2)+
dbf d0,.l1
move.w -(a2),d1
movea.l a2,a1
lsr.w #7,d0
.l2 move.w d1,(a1)+
move.w -(a2),d1
neg.w d1
dbf d0,.l2
bmi.b .l0
movem.l (sp)+,d2-d3/a2
rts
endif
*****************************************************************************
* Generates a number of words of noise into a buffer.
*
* This one gives very good random numbers :
*
* http://www.flipcode.com/archives/07-15-2002.shtml
*
* lea .rand(pc),a0
* lea 4(a0),a1
* move.l (a0),d0 ; AB
* move.l (a1),d1 ; CD
* swap d1 ; DC
* add.l d1,(a0) ; AB + DC
* add.l d0,(a1) ; CD + AB
*
*.rand: dc.l $3E50B28C
* dc.l $D461A7F9
* Of course the seed is just an example, but its entropy is quit good.
* You can get rid of a1 by using post-increment and pre-decrement on a0.
*
* PS: if you want to test your random generator... listen it ;)
*
* IN: d0.w, number of words
* d1.l/d2.l seeds
* a0, buffer
* OUT: d1.l/d2.l new seeds
* TRASHED: d0-d2/a0
*****************************************************************************
xdef LIB_GenNoise_W
LIB_GenNoise_W:
move.l d3,-(sp)
lsr.w #1,d0 ;number of words to longs
bcc.s .firstlong
.firstword:
move.l d2,d3
swap d3
add.l d1,d2
add.l d3,d1
move.w d3,(a0)+ ;write out just word
.firstlong:
subq.w #1,d0 ;-1 for dbf
bmi.s .done
.loop:
move.l d2,d3
swap d3
add.l d1,d2
add.l d3,d1
move.l d3,(a0)+ ;write out entire long
dbf d0,.loop
.done:
move.l (sp)+,d3
rts
*****************************************************************************
*****************************************************************************
section FW_PublicData,data ;Code section in Public memory
*****************************************************************************
ifd LIB_ENABLE_SIN_Q15
;
; Q15 (15 bits used for fractional, 1 bit sign)
; Note the table is in words from -32768 to 32767
; After multiplying
; add.l d0,d0
; swap d0
; = /32768
xdef LIB_SIN_Q15_1024W_Table
xdef LIB_COS_Q15_1024W_Table
LIB_SIN_Q15_1024W_Table:
dc.w $0000,$00c9,$0192,$025b,$0324,$03ed,$04b6,$057f,$0648,$0711,$07d9,$08a2,$096a,$0a33,$0afb,$0bc4
dc.w $0c8c,$0d54,$0e1c,$0ee3,$0fab,$1072,$113a,$1201,$12c8,$138f,$1455,$151c,$15e2,$16a8,$176e,$1833
dc.w $18f9,$19be,$1a82,$1b47,$1c0b,$1ccf,$1d93,$1e57,$1f1a,$1fdd,$209f,$2161,$2223,$22e5,$23a6,$2467
dc.w $2528,$25e8,$26a8,$2767,$2826,$28e5,$29a3,$2a61,$2b1f,$2bdc,$2c99,$2d55,$2e11,$2ecc,$2f87,$3041
dc.w $30fb,$31b5,$326e,$3326,$33df,$3496,$354d,$3604,$36ba,$376f,$3824,$38d9,$398c,$3a40,$3af2,$3ba5
dc.w $3c56,$3d07,$3db8,$3e68,$3f17,$3fc5,$4073,$4121,$41ce,$427a,$4325,$43d0,$447a,$4524,$45cd,$4675
dc.w $471c,$47c3,$4869,$490f,$49b4,$4a58,$4afb,$4b9d,$4c3f,$4ce0,$4d81,$4e20,$4ebf,$4f5d,$4ffb,$5097
dc.w $5133,$51ce,$5268,$5302,$539b,$5432,$54c9,$5560,$55f5,$568a,$571d,$57b0,$5842,$58d3,$5964,$59f3
dc.w $5a82,$5b10,$5b9c,$5c28,$5cb3,$5d3e,$5dc7,$5e4f,$5ed7,$5f5d,$5fe3,$6068,$60eb,$616e,$61f0,$6271
dc.w $62f1,$6370,$63ee,$646c,$64e8,$6563,$65dd,$6656,$66cf,$6746,$67bc,$6832,$68a6,$6919,$698b,$69fd
dc.w $6a6d,$6adc,$6b4a,$6bb7,$6c23,$6c8e,$6cf8,$6d61,$6dc9,$6e30,$6e96,$6efb,$6f5e,$6fc1,$7022,$7083
dc.w $70e2,$7140,$719d,$71f9,$7254,$72ae,$7307,$735f,$73b5,$740a,$745f,$74b2,$7504,$7555,$75a5,$75f3
dc.w $7641,$768d,$76d8,$7722,$776b,$77b3,$77fa,$783f,$7884,$78c7,$7909,$794a,$7989,$79c8,$7a05,$7a41
dc.w $7a7c,$7ab6,$7aee,$7b26,$7b5c,$7b91,$7bc5,$7bf8,$7c29,$7c59,$7c88,$7cb6,$7ce3,$7d0e,$7d39,$7d62
dc.w $7d89,$7db0,$7dd5,$7dfa,$7e1d,$7e3e,$7e5f,$7e7e,$7e9c,$7eb9,$7ed5,$7eef,$7f09,$7f21,$7f37,$7f4d
dc.w $7f61,$7f74,$7f86,$7f97,$7fa6,$7fb4,$7fc1,$7fcd,$7fd8,$7fe1,$7fe9,$7ff0,$7ff5,$7ff9,$7ffd,$7ffe
LIB_COS_Q15_1024W_Table:
dc.w $7fff,$7ffe,$7ffd,$7ff9,$7ff5,$7ff0,$7fe9,$7fe1,$7fd8,$7fcd,$7fc1,$7fb4,$7fa6,$7f97,$7f86,$7f74
dc.w $7f61,$7f4d,$7f37,$7f21,$7f09,$7eef,$7ed5,$7eb9,$7e9c,$7e7e,$7e5f,$7e3e,$7e1d,$7dfa,$7dd5,$7db0
dc.w $7d89,$7d62,$7d39,$7d0e,$7ce3,$7cb6,$7c88,$7c59,$7c29,$7bf8,$7bc5,$7b91,$7b5c,$7b26,$7aee,$7ab6
dc.w $7a7c,$7a41,$7a05,$79c8,$7989,$794a,$7909,$78c7,$7884,$783f,$77fa,$77b3,$776b,$7722,$76d8,$768d
dc.w $7641,$75f3,$75a5,$7555,$7504,$74b2,$745f,$740a,$73b5,$735f,$7307,$72ae,$7254,$71f9,$719d,$7140
dc.w $70e2,$7083,$7022,$6fc1,$6f5e,$6efb,$6e96,$6e30,$6dc9,$6d61,$6cf8,$6c8e,$6c23,$6bb7,$6b4a,$6adc
dc.w $6a6d,$69fd,$698b,$6919,$68a6,$6832,$67bc,$6746,$66cf,$6656,$65dd,$6563,$64e8,$646c,$63ee,$6370
dc.w $62f1,$6271,$61f0,$616e,$60eb,$6068,$5fe3,$5f5d,$5ed7,$5e4f,$5dc7,$5d3e,$5cb3,$5c28,$5b9c,$5b10
dc.w $5a82,$59f3,$5964,$58d3,$5842,$57b0,$571d,$568a,$55f5,$5560,$54c9,$5432,$539b,$5302,$5268,$51ce
dc.w $5133,$5097,$4ffb,$4f5d,$4ebf,$4e20,$4d81,$4ce0,$4c3f,$4b9d,$4afb,$4a58,$49b4,$490f,$4869,$47c3
dc.w $471c,$4675,$45cd,$4524,$447a,$43d0,$4325,$427a,$41ce,$4121,$4073,$3fc5,$3f17,$3e68,$3db8,$3d07
dc.w $3c56,$3ba5,$3af2,$3a40,$398c,$38d9,$3824,$376f,$36ba,$3604,$354d,$3496,$33df,$3326,$326e,$31b5
dc.w $30fb,$3041,$2f87,$2ecc,$2e11,$2d55,$2c99,$2bdc,$2b1f,$2a61,$29a3,$28e5,$2826,$2767,$26a8,$25e8
dc.w $2528,$2467,$23a6,$22e5,$2223,$2161,$209f,$1fdd,$1f1a,$1e57,$1d93,$1ccf,$1c0b,$1b47,$1a82,$19be
dc.w $18f9,$1833,$176e,$16a8,$15e2,$151c,$1455,$138f,$12c8,$1201,$113a,$1072,$0fab,$0ee3,$0e1c,$0d54
dc.w $0c8c,$0bc4,$0afb,$0a33,$096a,$08a2,$07d9,$0711,$0648,$057f,$04b6,$03ed,$0324,$025b,$0192,$00c9
dc.w $0000,$ff37,$fe6e,$fda5,$fcdc,$fc13,$fb4a,$fa81,$f9b8,$f8ef,$f827,$f75e,$f696,$f5cd,$f505,$f43c
dc.w $f374,$f2ac,$f1e4,$f11d,$f055,$ef8e,$eec6,$edff,$ed38,$ec71,$ebab,$eae4,$ea1e,$e958,$e892,$e7cd
dc.w $e707,$e642,$e57e,$e4b9,$e3f5,$e331,$e26d,$e1a9,$e0e6,$e023,$df61,$de9f,$dddd,$dd1b,$dc5a,$db99
dc.w $dad8,$da18,$d958,$d899,$d7da,$d71b,$d65d,$d59f,$d4e1,$d424,$d367,$d2ab,$d1ef,$d134,$d079,$cfbf
dc.w $cf05,$ce4b,$cd92,$ccda,$cc21,$cb6a,$cab3,$c9fc,$c946,$c891,$c7dc,$c727,$c674,$c5c0,$c50e,$c45b
dc.w $c3aa,$c2f9,$c248,$c198,$c0e9,$c03b,$bf8d,$bedf,$be32,$bd86,$bcdb,$bc30,$bb86,$badc,$ba33,$b98b
dc.w $b8e4,$b83d,$b797,$b6f1,$b64c,$b5a8,$b505,$b463,$b3c1,$b320,$b27f,$b1e0,$b141,$b0a3,$b005,$af69
dc.w $aecd,$ae32,$ad98,$acfe,$ac65,$abce,$ab37,$aaa0,$aa0b,$a976,$a8e3,$a850,$a7be,$a72d,$a69c,$a60d
dc.w $a57e,$a4f0,$a464,$a3d8,$a34d,$a2c2,$a239,$a1b1,$a129,$a0a3,$a01d,$9f98,$9f15,$9e92,$9e10,$9d8f
dc.w $9d0f,$9c90,$9c12,$9b94,$9b18,$9a9d,$9a23,$99aa,$9931,$98ba,$9844,$97ce,$975a,$96e7,$9675,$9603
dc.w $9593,$9524,$94b6,$9449,$93dd,$9372,$9308,$929f,$9237,$91d0,$916a,$9105,$90a2,$903f,$8fde,$8f7d
dc.w $8f1e,$8ec0,$8e63,$8e07,$8dac,$8d52,$8cf9,$8ca1,$8c4b,$8bf6,$8ba1,$8b4e,$8afc,$8aab,$8a5b,$8a0d
dc.w $89bf,$8973,$8928,$88de,$8895,$884d,$8806,$87c1,$877c,$8739,$86f7,$86b6,$8677,$8638,$85fb,$85bf
dc.w $8584,$854a,$8512,$84da,$84a4,$846f,$843b,$8408,$83d7,$83a7,$8378,$834a,$831d,$82f2,$82c7,$829e
dc.w $8277,$8250,$822b,$8206,$81e3,$81c2,$81a1,$8182,$8164,$8147,$812b,$8111,$80f7,$80df,$80c9,$80b3
dc.w $809f,$808c,$807a,$8069,$805a,$804c,$803f,$8033,$8028,$801f,$8017,$8010,$800b,$8007,$8003,$8002
dc.w $8001,$8002,$8003,$8007,$800b,$8010,$8017,$801f,$8028,$8033,$803f,$804c,$805a,$8069,$807a,$808c
dc.w $809f,$80b3,$80c9,$80df,$80f7,$8111,$812b,$8147,$8164,$8182,$81a1,$81c2,$81e3,$8206,$822b,$8250
dc.w $8277,$829e,$82c7,$82f2,$831d,$834a,$8378,$83a7,$83d7,$8408,$843b,$846f,$84a4,$84da,$8512,$854a
dc.w $8584,$85bf,$85fb,$8638,$8677,$86b6,$86f7,$8739,$877c,$87c1,$8806,$884d,$8895,$88de,$8928,$8973
dc.w $89bf,$8a0d,$8a5b,$8aab,$8afc,$8b4e,$8ba1,$8bf6,$8c4b,$8ca1,$8cf9,$8d52,$8dac,$8e07,$8e63,$8ec0
dc.w $8f1e,$8f7d,$8fde,$903f,$90a2,$9105,$916a,$91d0,$9237,$929f,$9308,$9372,$93dd,$9449,$94b6,$9524
dc.w $9593,$9603,$9675,$96e7,$975a,$97ce,$9844,$98ba,$9931,$99aa,$9a23,$9a9d,$9b18,$9b94,$9c12,$9c90
dc.w $9d0f,$9d8f,$9e10,$9e92,$9f15,$9f98,$a01d,$a0a3,$a129,$a1b1,$a239,$a2c2,$a34d,$a3d8,$a464,$a4f0
dc.w $a57e,$a60d,$a69c,$a72d,$a7be,$a850,$a8e3,$a976,$aa0b,$aaa0,$ab37,$abce,$ac65,$acfe,$ad98,$ae32
dc.w $aecd,$af69,$b005,$b0a3,$b141,$b1e0,$b27f,$b320,$b3c1,$b463,$b505,$b5a8,$b64c,$b6f1,$b797,$b83d
dc.w $b8e4,$b98b,$ba33,$badc,$bb86,$bc30,$bcdb,$bd86,$be32,$bedf,$bf8d,$c03b,$c0e9,$c198,$c248,$c2f9
dc.w $c3aa,$c45b,$c50e,$c5c0,$c674,$c727,$c7dc,$c891,$c946,$c9fc,$cab3,$cb6a,$cc21,$ccda,$cd92,$ce4b
dc.w $cf05,$cfbf,$d079,$d134,$d1ef,$d2ab,$d367,$d424,$d4e1,$d59f,$d65d,$d71b,$d7da,$d899,$d958,$da18
dc.w $dad8,$db99,$dc5a,$dd1b,$dddd,$de9f,$df61,$e023,$e0e6,$e1a9,$e26d,$e331,$e3f5,$e4b9,$e57e,$e642
dc.w $e707,$e7cd,$e892,$e958,$ea1e,$eae4,$ebab,$ec71,$ed38,$edff,$eec6,$ef8e,$f055,$f11d,$f1e4,$f2ac
dc.w $f374,$f43c,$f505,$f5cd,$f696,$f75e,$f827,$f8ef,$f9b8,$fa81,$fb4a,$fc13,$fcdc,$fda5,$fe6e,$ff37
dc.w $0000,$00c9,$0192,$025b,$0324,$03ed,$04b6,$057f,$0648,$0711,$07d9,$08a2,$096a,$0a33,$0afb,$0bc4
dc.w $0c8c,$0d54,$0e1c,$0ee3,$0fab,$1072,$113a,$1201,$12c8,$138f,$1455,$151c,$15e2,$16a8,$176e,$1833
dc.w $18f9,$19be,$1a82,$1b47,$1c0b,$1ccf,$1d93,$1e57,$1f1a,$1fdd,$209f,$2161,$2223,$22e5,$23a6,$2467
dc.w $2528,$25e8,$26a8,$2767,$2826,$28e5,$29a3,$2a61,$2b1f,$2bdc,$2c99,$2d55,$2e11,$2ecc,$2f87,$3041
dc.w $30fb,$31b5,$326e,$3326,$33df,$3496,$354d,$3604,$36ba,$376f,$3824,$38d9,$398c,$3a40,$3af2,$3ba5
dc.w $3c56,$3d07,$3db8,$3e68,$3f17,$3fc5,$4073,$4121,$41ce,$427a,$4325,$43d0,$447a,$4524,$45cd,$4675
dc.w $471c,$47c3,$4869,$490f,$49b4,$4a58,$4afb,$4b9d,$4c3f,$4ce0,$4d81,$4e20,$4ebf,$4f5d,$4ffb,$5097
dc.w $5133,$51ce,$5268,$5302,$539b,$5432,$54c9,$5560,$55f5,$568a,$571d,$57b0,$5842,$58d3,$5964,$59f3
dc.w $5a82,$5b10,$5b9c,$5c28,$5cb3,$5d3e,$5dc7,$5e4f,$5ed7,$5f5d,$5fe3,$6068,$60eb,$616e,$61f0,$6271
dc.w $62f1,$6370,$63ee,$646c,$64e8,$6563,$65dd,$6656,$66cf,$6746,$67bc,$6832,$68a6,$6919,$698b,$69fd
dc.w $6a6d,$6adc,$6b4a,$6bb7,$6c23,$6c8e,$6cf8,$6d61,$6dc9,$6e30,$6e96,$6efb,$6f5e,$6fc1,$7022,$7083
dc.w $70e2,$7140,$719d,$71f9,$7254,$72ae,$7307,$735f,$73b5,$740a,$745f,$74b2,$7504,$7555,$75a5,$75f3
dc.w $7641,$768d,$76d8,$7722,$776b,$77b3,$77fa,$783f,$7884,$78c7,$7909,$794a,$7989,$79c8,$7a05,$7a41
dc.w $7a7c,$7ab6,$7aee,$7b26,$7b5c,$7b91,$7bc5,$7bf8,$7c29,$7c59,$7c88,$7cb6,$7ce3,$7d0e,$7d39,$7d62
dc.w $7d89,$7db0,$7dd5,$7dfa,$7e1d,$7e3e,$7e5f,$7e7e,$7e9c,$7eb9,$7ed5,$7eef,$7f09,$7f21,$7f37,$7f4d
dc.w $7f61,$7f74,$7f86,$7f97,$7fa6,$7fb4,$7fc1,$7fcd,$7fd8,$7fe1,$7fe9,$7ff0,$7ff5,$7ff9,$7ffd,$7ffe
endif ; LIB_ENABLE_SIN_Q15
ifd LIB_ENABLE_SIN_Q14
;
; Q14 (14 bits used for fractional, 1 bit sign 1 bit int)
; Note the table is in words from -16384 to 16384, $c000 to $4000
; After multiplying into 4.28
; add.l d0,d0
; add.l d0,d0
; swap d0
; = /16384
;
; if extra precision needed:
; add.l d0,d0
; add.l d0,d0
; add.w d0,d0
; swap d0
; addx.w dx,d0 (where dx=0)
xdef LIB_SIN_Q14_1024W_Table
xdef LIB_COS_Q14_1024W_Table
LIB_SIN_Q14_1024W_Table:
dc.w $0000,$0065,$00c9,$012e,$0192,$01f7,$025b,$02c0,$0324,$0388,$03ed,$0451,$04b5,$051a,$057e,$05e2
dc.w $0646,$06aa,$070e,$0772,$07d6,$0839,$089d,$0901,$0964,$09c7,$0a2b,$0a8e,$0af1,$0b54,$0bb7,$0c1a
dc.w $0c7c,$0cdf,$0d41,$0da4,$0e06,$0e68,$0eca,$0f2b,$0f8d,$0fee,$1050,$10b1,$1112,$1173,$11d3,$1234
dc.w $1294,$12f4,$1354,$13b4,$1413,$1473,$14d2,$1531,$1590,$15ee,$164c,$16ab,$1709,$1766,$17c4,$1821
dc.w $187e,$18db,$1937,$1993,$19ef,$1a4b,$1aa7,$1b02,$1b5d,$1bb8,$1c12,$1c6c,$1cc6,$1d20,$1d79,$1dd3
dc.w $1e2b,$1e84,$1edc,$1f34,$1f8c,$1fe3,$203a,$2091,$20e7,$213d,$2193,$21e8,$223d,$2292,$22e7,$233b
dc.w $238e,$23e2,$2435,$2488,$24da,$252c,$257e,$25cf,$2620,$2670,$26c1,$2711,$2760,$27af,$27fe,$284c
dc.w $289a,$28e7,$2935,$2981,$29ce,$2a1a,$2a65,$2ab0,$2afb,$2b45,$2b8f,$2bd8,$2c21,$2c6a,$2cb2,$2cfa
dc.w $2d41,$2d88,$2dcf,$2e15,$2e5a,$2e9f,$2ee4,$2f28,$2f6c,$2faf,$2ff2,$3034,$3076,$30b8,$30f9,$3139
dc.w $3179,$31b9,$31f8,$3236,$3274,$32b2,$32ef,$332c,$3368,$33a3,$33df,$3419,$3453,$348d,$34c6,$34ff
dc.w $3537,$356e,$35a5,$35dc,$3612,$3648,$367d,$36b1,$36e5,$3718,$374b,$377e,$37b0,$37e1,$3812,$3842
dc.w $3871,$38a1,$38cf,$38fd,$392b,$3958,$3984,$39b0,$39db,$3a06,$3a30,$3a59,$3a82,$3aab,$3ad3,$3afa
dc.w $3b21,$3b47,$3b6d,$3b92,$3bb6,$3bda,$3bfd,$3c20,$3c42,$3c64,$3c85,$3ca5,$3cc5,$3ce4,$3d03,$3d21
dc.w $3d3f,$3d5b,$3d78,$3d93,$3daf,$3dc9,$3de3,$3dfc,$3e15,$3e2d,$3e45,$3e5c,$3e72,$3e88,$3e9d,$3eb1
dc.w $3ec5,$3ed9,$3eeb,$3efd,$3f0f,$3f20,$3f30,$3f40,$3f4f,$3f5d,$3f6b,$3f78,$3f85,$3f91,$3f9c,$3fa7
dc.w $3fb1,$3fbb,$3fc4,$3fcc,$3fd4,$3fdb,$3fe1,$3fe7,$3fec,$3ff1,$3ff5,$3ff8,$3ffb,$3ffd,$3fff,$4000
LIB_COS_Q14_1024W_Table:
dc.w $4000,$4000,$3fff,$3ffd,$3ffb,$3ff8,$3ff5,$3ff1,$3fec,$3fe7,$3fe1,$3fdb,$3fd4,$3fcc,$3fc4,$3fbb
dc.w $3fb1,$3fa7,$3f9c,$3f91,$3f85,$3f78,$3f6b,$3f5d,$3f4f,$3f40,$3f30,$3f20,$3f0f,$3efd,$3eeb,$3ed9
dc.w $3ec5,$3eb1,$3e9d,$3e88,$3e72,$3e5c,$3e45,$3e2d,$3e15,$3dfc,$3de3,$3dc9,$3daf,$3d93,$3d78,$3d5b
dc.w $3d3f,$3d21,$3d03,$3ce4,$3cc5,$3ca5,$3c85,$3c64,$3c42,$3c20,$3bfd,$3bda,$3bb6,$3b92,$3b6d,$3b47
dc.w $3b21,$3afa,$3ad3,$3aab,$3a82,$3a59,$3a30,$3a06,$39db,$39b0,$3984,$3958,$392b,$38fd,$38cf,$38a1
dc.w $3871,$3842,$3812,$37e1,$37b0,$377e,$374b,$3718,$36e5,$36b1,$367d,$3648,$3612,$35dc,$35a5,$356e
dc.w $3537,$34ff,$34c6,$348d,$3453,$3419,$33df,$33a3,$3368,$332c,$32ef,$32b2,$3274,$3236,$31f8,$31b9
dc.w $3179,$3139,$30f9,$30b8,$3076,$3034,$2ff2,$2faf,$2f6c,$2f28,$2ee4,$2e9f,$2e5a,$2e15,$2dcf,$2d88
dc.w $2d41,$2cfa,$2cb2,$2c6a,$2c21,$2bd8,$2b8f,$2b45,$2afb,$2ab0,$2a65,$2a1a,$29ce,$2981,$2935,$28e7
dc.w $289a,$284c,$27fe,$27af,$2760,$2711,$26c1,$2670,$2620,$25cf,$257e,$252c,$24da,$2488,$2435,$23e2
dc.w $238e,$233b,$22e7,$2292,$223d,$21e8,$2193,$213d,$20e7,$2091,$203a,$1fe3,$1f8c,$1f34,$1edc,$1e84
dc.w $1e2b,$1dd3,$1d79,$1d20,$1cc6,$1c6c,$1c12,$1bb8,$1b5d,$1b02,$1aa7,$1a4b,$19ef,$1993,$1937,$18db
dc.w $187e,$1821,$17c4,$1766,$1709,$16ab,$164c,$15ee,$1590,$1531,$14d2,$1473,$1413,$13b4,$1354,$12f4
dc.w $1294,$1234,$11d3,$1173,$1112,$10b1,$1050,$0fee,$0f8d,$0f2b,$0eca,$0e68,$0e06,$0da4,$0d41,$0cdf
dc.w $0c7c,$0c1a,$0bb7,$0b54,$0af1,$0a8e,$0a2b,$09c7,$0964,$0901,$089d,$0839,$07d6,$0772,$070e,$06aa
dc.w $0646,$05e2,$057e,$051a,$04b5,$0451,$03ed,$0388,$0324,$02c0,$025b,$01f7,$0192,$012e,$00c9,$0065
dc.w $0000,$ff9b,$ff37,$fed2,$fe6e,$fe09,$fda5,$fd40,$fcdc,$fc78,$fc13,$fbaf,$fb4b,$fae6,$fa82,$fa1e
dc.w $f9ba,$f956,$f8f2,$f88e,$f82a,$f7c7,$f763,$f6ff,$f69c,$f639,$f5d5,$f572,$f50f,$f4ac,$f449,$f3e6
dc.w $f384,$f321,$f2bf,$f25c,$f1fa,$f198,$f136,$f0d5,$f073,$f012,$efb0,$ef4f,$eeee,$ee8d,$ee2d,$edcc
dc.w $ed6c,$ed0c,$ecac,$ec4c,$ebed,$eb8d,$eb2e,$eacf,$ea70,$ea12,$e9b4,$e955,$e8f7,$e89a,$e83c,$e7df
dc.w $e782,$e725,$e6c9,$e66d,$e611,$e5b5,$e559,$e4fe,$e4a3,$e448,$e3ee,$e394,$e33a,$e2e0,$e287,$e22d
dc.w $e1d5,$e17c,$e124,$e0cc,$e074,$e01d,$dfc6,$df6f,$df19,$dec3,$de6d,$de18,$ddc3,$dd6e,$dd19,$dcc5
dc.w $dc72,$dc1e,$dbcb,$db78,$db26,$dad4,$da82,$da31,$d9e0,$d990,$d93f,$d8ef,$d8a0,$d851,$d802,$d7b4
dc.w $d766,$d719,$d6cb,$d67f,$d632,$d5e6,$d59b,$d550,$d505,$d4bb,$d471,$d428,$d3df,$d396,$d34e,$d306
dc.w $d2bf,$d278,$d231,$d1eb,$d1a6,$d161,$d11c,$d0d8,$d094,$d051,$d00e,$cfcc,$cf8a,$cf48,$cf07,$cec7
dc.w $ce87,$ce47,$ce08,$cdca,$cd8c,$cd4e,$cd11,$ccd4,$cc98,$cc5d,$cc21,$cbe7,$cbad,$cb73,$cb3a,$cb01
dc.w $cac9,$ca92,$ca5b,$ca24,$c9ee,$c9b8,$c983,$c94f,$c91b,$c8e8,$c8b5,$c882,$c850,$c81f,$c7ee,$c7be
dc.w $c78f,$c75f,$c731,$c703,$c6d5,$c6a8,$c67c,$c650,$c625,$c5fa,$c5d0,$c5a7,$c57e,$c555,$c52d,$c506
dc.w $c4df,$c4b9,$c493,$c46e,$c44a,$c426,$c403,$c3e0,$c3be,$c39c,$c37b,$c35b,$c33b,$c31c,$c2fd,$c2df
dc.w $c2c1,$c2a5,$c288,$c26d,$c251,$c237,$c21d,$c204,$c1eb,$c1d3,$c1bb,$c1a4,$c18e,$c178,$c163,$c14f
dc.w $c13b,$c127,$c115,$c103,$c0f1,$c0e0,$c0d0,$c0c0,$c0b1,$c0a3,$c095,$c088,$c07b,$c06f,$c064,$c059
dc.w $c04f,$c045,$c03c,$c034,$c02c,$c025,$c01f,$c019,$c014,$c00f,$c00b,$c008,$c005,$c003,$c001,$c000
dc.w $c000,$c000,$c001,$c003,$c005,$c008,$c00b,$c00f,$c014,$c019,$c01f,$c025,$c02c,$c034,$c03c,$c045
dc.w $c04f,$c059,$c064,$c06f,$c07b,$c088,$c095,$c0a3,$c0b1,$c0c0,$c0d0,$c0e0,$c0f1,$c103,$c115,$c127
dc.w $c13b,$c14f,$c163,$c178,$c18e,$c1a4,$c1bb,$c1d3,$c1eb,$c204,$c21d,$c237,$c251,$c26d,$c288,$c2a5
dc.w $c2c1,$c2df,$c2fd,$c31c,$c33b,$c35b,$c37b,$c39c,$c3be,$c3e0,$c403,$c426,$c44a,$c46e,$c493,$c4b9
dc.w $c4df,$c506,$c52d,$c555,$c57e,$c5a7,$c5d0,$c5fa,$c625,$c650,$c67c,$c6a8,$c6d5,$c703,$c731,$c75f
dc.w $c78f,$c7be,$c7ee,$c81f,$c850,$c882,$c8b5,$c8e8,$c91b,$c94f,$c983,$c9b8,$c9ee,$ca24,$ca5b,$ca92
dc.w $cac9,$cb01,$cb3a,$cb73,$cbad,$cbe7,$cc21,$cc5d,$cc98,$ccd4,$cd11,$cd4e,$cd8c,$cdca,$ce08,$ce47
dc.w $ce87,$cec7,$cf07,$cf48,$cf8a,$cfcc,$d00e,$d051,$d094,$d0d8,$d11c,$d161,$d1a6,$d1eb,$d231,$d278
dc.w $d2bf,$d306,$d34e,$d396,$d3df,$d428,$d471,$d4bb,$d505,$d550,$d59b,$d5e6,$d632,$d67f,$d6cb,$d719
dc.w $d766,$d7b4,$d802,$d851,$d8a0,$d8ef,$d93f,$d990,$d9e0,$da31,$da82,$dad4,$db26,$db78,$dbcb,$dc1e
dc.w $dc72,$dcc5,$dd19,$dd6e,$ddc3,$de18,$de6d,$dec3,$df19,$df6f,$dfc6,$e01d,$e074,$e0cc,$e124,$e17c
dc.w $e1d5,$e22d,$e287,$e2e0,$e33a,$e394,$e3ee,$e448,$e4a3,$e4fe,$e559,$e5b5,$e611,$e66d,$e6c9,$e725
dc.w $e782,$e7df,$e83c,$e89a,$e8f7,$e955,$e9b4,$ea12,$ea70,$eacf,$eb2e,$eb8d,$ebed,$ec4c,$ecac,$ed0c
dc.w $ed6c,$edcc,$ee2d,$ee8d,$eeee,$ef4f,$efb0,$f012,$f073,$f0d5,$f136,$f198,$f1fa,$f25c,$f2bf,$f321
dc.w $f384,$f3e6,$f449,$f4ac,$f50f,$f572,$f5d5,$f639,$f69c,$f6ff,$f763,$f7c7,$f82a,$f88e,$f8f2,$f956
dc.w $f9ba,$fa1e,$fa82,$fae6,$fb4b,$fbaf,$fc13,$fc78,$fcdc,$fd40,$fda5,$fe09,$fe6e,$fed2,$ff37,$ff9b
dc.w $0000,$0065,$00c9,$012e,$0192,$01f7,$025b,$02c0,$0324,$0388,$03ed,$0451,$04b5,$051a,$057e,$05e2
dc.w $0646,$06aa,$070e,$0772,$07d6,$0839,$089d,$0901,$0964,$09c7,$0a2b,$0a8e,$0af1,$0b54,$0bb7,$0c1a
dc.w $0c7c,$0cdf,$0d41,$0da4,$0e06,$0e68,$0eca,$0f2b,$0f8d,$0fee,$1050,$10b1,$1112,$1173,$11d3,$1234
dc.w $1294,$12f4,$1354,$13b4,$1413,$1473,$14d2,$1531,$1590,$15ee,$164c,$16ab,$1709,$1766,$17c4,$1821
dc.w $187e,$18db,$1937,$1993,$19ef,$1a4b,$1aa7,$1b02,$1b5d,$1bb8,$1c12,$1c6c,$1cc6,$1d20,$1d79,$1dd3
dc.w $1e2b,$1e84,$1edc,$1f34,$1f8c,$1fe3,$203a,$2091,$20e7,$213d,$2193,$21e8,$223d,$2292,$22e7,$233b
dc.w $238e,$23e2,$2435,$2488,$24da,$252c,$257e,$25cf,$2620,$2670,$26c1,$2711,$2760,$27af,$27fe,$284c
dc.w $289a,$28e7,$2935,$2981,$29ce,$2a1a,$2a65,$2ab0,$2afb,$2b45,$2b8f,$2bd8,$2c21,$2c6a,$2cb2,$2cfa
dc.w $2d41,$2d88,$2dcf,$2e15,$2e5a,$2e9f,$2ee4,$2f28,$2f6c,$2faf,$2ff2,$3034,$3076,$30b8,$30f9,$3139
dc.w $3179,$31b9,$31f8,$3236,$3274,$32b2,$32ef,$332c,$3368,$33a3,$33df,$3419,$3453,$348d,$34c6,$34ff
dc.w $3537,$356e,$35a5,$35dc,$3612,$3648,$367d,$36b1,$36e5,$3718,$374b,$377e,$37b0,$37e1,$3812,$3842
dc.w $3871,$38a1,$38cf,$38fd,$392b,$3958,$3984,$39b0,$39db,$3a06,$3a30,$3a59,$3a82,$3aab,$3ad3,$3afa
dc.w $3b21,$3b47,$3b6d,$3b92,$3bb6,$3bda,$3bfd,$3c20,$3c42,$3c64,$3c85,$3ca5,$3cc5,$3ce4,$3d03,$3d21
dc.w $3d3f,$3d5b,$3d78,$3d93,$3daf,$3dc9,$3de3,$3dfc,$3e15,$3e2d,$3e45,$3e5c,$3e72,$3e88,$3e9d,$3eb1
dc.w $3ec5,$3ed9,$3eeb,$3efd,$3f0f,$3f20,$3f30,$3f40,$3f4f,$3f5d,$3f6b,$3f78,$3f85,$3f91,$3f9c,$3fa7
dc.w $3fb1,$3fbb,$3fc4,$3fcc,$3fd4,$3fdb,$3fe1,$3fe7,$3fec,$3ff1,$3ff5,$3ff8,$3ffb,$3ffd,$3fff,$4000
endif ; LIB_ENABLE_SIN_Q14
*****************************************************************************
*****************************************************************************
*****************************************************************************
section FW_PublicBss,bss ;BSS section in Public memory
*****************************************************************************
ifd LIB_ENABLE_RGB12_LERP
LIB_RGB12_Interpolate_Table: DS.W 31*16 ; [-15..15]x[0..15], 992bytes
endif
*****************************************************************************
; Packfire is largest so if multiple depack routines use this
;LIB_PACKFIRE_BUFFER_SIZE = 15980
;LIB_ARJM7_BUFFER_SIZE = 11312
ifd LIB_ENABLE_PACKFIRE_LARGE
LIB_Depack_Buffer:
ds.b LIB_PACKFIRE_BUFFER_SIZE
even
else
ifd LIB_ENABLE_ARJM7
LIB_Depack_Buffer:
ds.b LIB_ARJM7_BUFFER_SIZE
even
endif
endif
|
unused/develop/obj/spritesheet_2.asm | pau-tomas/gbvm | 33 | 82489 | ;--------------------------------------------------------
; File Created by SDCC : free open source ANSI-C Compiler
; Version 4.1.4 #12246 (Mac OS X x86_64)
;--------------------------------------------------------
.module spritesheet_2
.optsdcc -mgbz80
;--------------------------------------------------------
; Public variables in this module
;--------------------------------------------------------
.globl _spritesheet_2
.globl _spritesheet_2_animations_lookup
.globl _spritesheet_2_animations
.globl _spritesheet_2_metasprites
.globl _spritesheet_2_metasprite_7
.globl _spritesheet_2_metasprite_6
.globl _spritesheet_2_metasprite_5
.globl _spritesheet_2_metasprite_4
.globl _spritesheet_2_metasprite_3
.globl _spritesheet_2_metasprite_2
.globl _spritesheet_2_metasprite_1
.globl _spritesheet_2_metasprite_0
.globl ___bank_spritesheet_2
;--------------------------------------------------------
; special function registers
;--------------------------------------------------------
;--------------------------------------------------------
; ram data
;--------------------------------------------------------
.area _DATA
;--------------------------------------------------------
; ram data
;--------------------------------------------------------
.area _INITIALIZED
;--------------------------------------------------------
; absolute external ram data
;--------------------------------------------------------
.area _DABS (ABS)
;--------------------------------------------------------
; global & static initialisations
;--------------------------------------------------------
.area _HOME
.area _GSINIT
.area _GSFINAL
.area _GSINIT
;--------------------------------------------------------
; Home
;--------------------------------------------------------
.area _HOME
.area _HOME
;--------------------------------------------------------
; code
;--------------------------------------------------------
.area _CODE_255
.area _CODE_255
___bank_spritesheet_2 = 0x00ff
_spritesheet_2_metasprite_0:
.db #0x00 ; 0
.db #0x00 ; 0
.db #0x00 ; 0
.db #0x00 ; 0
.db #0x00 ; 0
.db #0x08 ; 8
.db #0x02 ; 2
.db #0x00 ; 0
.db #0x80 ; -128
.db #0x00 ; 0
.db #0x00 ; 0
.db #0x00 ; 0
_spritesheet_2_metasprite_1:
.db #0x00 ; 0
.db #0x00 ; 0
.db #0x04 ; 4
.db #0x00 ; 0
.db #0x00 ; 0
.db #0x08 ; 8
.db #0x06 ; 6
.db #0x00 ; 0
.db #0x80 ; -128
.db #0x00 ; 0
.db #0x00 ; 0
.db #0x00 ; 0
_spritesheet_2_metasprite_2:
.db #0x00 ; 0
.db #0x00 ; 0
.db #0x08 ; 8
.db #0x00 ; 0
.db #0x00 ; 0
.db #0x08 ; 8
.db #0x0a ; 10
.db #0x00 ; 0
.db #0x80 ; -128
.db #0x00 ; 0
.db #0x00 ; 0
.db #0x00 ; 0
_spritesheet_2_metasprite_3:
.db #0x00 ; 0
.db #0x00 ; 0
.db #0x0c ; 12
.db #0x00 ; 0
.db #0x00 ; 0
.db #0x08 ; 8
.db #0x0e ; 14
.db #0x00 ; 0
.db #0x80 ; -128
.db #0x00 ; 0
.db #0x00 ; 0
.db #0x00 ; 0
_spritesheet_2_metasprite_4:
.db #0x00 ; 0
.db #0x00 ; 0
.db #0x10 ; 16
.db #0x00 ; 0
.db #0x00 ; 0
.db #0x08 ; 8
.db #0x12 ; 18
.db #0x00 ; 0
.db #0x80 ; -128
.db #0x00 ; 0
.db #0x00 ; 0
.db #0x00 ; 0
_spritesheet_2_metasprite_5:
.db #0x00 ; 0
.db #0x00 ; 0
.db #0x14 ; 20
.db #0x00 ; 0
.db #0x00 ; 0
.db #0x08 ; 8
.db #0x16 ; 22
.db #0x00 ; 0
.db #0x80 ; -128
.db #0x00 ; 0
.db #0x00 ; 0
.db #0x00 ; 0
_spritesheet_2_metasprite_6:
.db #0x00 ; 0
.db #0x00 ; 0
.db #0x12 ; 18
.db #0x20 ; 32
.db #0x00 ; 0
.db #0x08 ; 8
.db #0x10 ; 16
.db #0x20 ; 32
.db #0x80 ; -128
.db #0x00 ; 0
.db #0x00 ; 0
.db #0x00 ; 0
_spritesheet_2_metasprite_7:
.db #0x00 ; 0
.db #0x00 ; 0
.db #0x16 ; 22
.db #0x20 ; 32
.db #0x00 ; 0
.db #0x08 ; 8
.db #0x14 ; 20
.db #0x20 ; 32
.db #0x80 ; -128
.db #0x00 ; 0
.db #0x00 ; 0
.db #0x00 ; 0
_spritesheet_2_metasprites:
.dw _spritesheet_2_metasprite_0
.dw _spritesheet_2_metasprite_1
.dw _spritesheet_2_metasprite_2
.dw _spritesheet_2_metasprite_3
.dw _spritesheet_2_metasprite_4
.dw _spritesheet_2_metasprite_5
.dw _spritesheet_2_metasprite_6
.dw _spritesheet_2_metasprite_7
_spritesheet_2_animations:
.db #0x00 ; 0
.db #0x00 ; 0
.db #0x00 ; 0
.db #0x00 ; 0
.db #0x00 ; 0
.db #0x00 ; 0
.db #0x00 ; 0
.db #0x00 ; 0
.db #0x00 ; 0
.db #0x00 ; 0
.db #0x00 ; 0
.db #0x00 ; 0
.db #0x00 ; 0
.db #0x00 ; 0
.db #0x00 ; 0
.db #0x00 ; 0
_spritesheet_2_animations_lookup:
.dw #0x0000
_spritesheet_2:
.db #0x06 ; 6
.dw _spritesheet_2_metasprites
.dw _spritesheet_2_animations
.dw _spritesheet_2_animations_lookup
.db #0x00 ; 0
.db #0x0f ; 15
.db #0xf8 ; -8
.db #0x07 ; 7
.byte ___bank_spritesheet_2_tiles
.dw _spritesheet_2_tiles
.db #0x00 ; 0
.dw #0x0000
.area _INITIALIZER
.area _CABS (ABS)
|
test/Fail/ConfluenceNestedOverlap.agda | cruhland/agda | 1,989 | 13816 | {-# OPTIONS --rewriting --confluence-check #-}
open import Agda.Builtin.Equality
open import Agda.Builtin.Equality.Rewrite
postulate
A : Set
a b c : A
f g : A → A
rew₁ : f a ≡ b
rew₂ : ∀ {x} → f (g x) ≡ c
rew₃ : g a ≡ a
{-# REWRITE rew₁ #-}
{-# REWRITE rew₂ #-}
{-# REWRITE rew₃ #-}
works : (x : A) → f (g x) ≡ c
works x = refl
works' : f (g a) ≡ c
works' = works a
fails : f (g a) ≡ c
fails = refl
|
oeis/142/A142744.asm | neoneye/loda-programs | 11 | 6538 | ; A142744: Primes congruent to 17 mod 59.
; Submitted by <NAME>
; 17,607,1433,1669,1787,2141,2377,2731,3203,3557,3793,3911,4973,5209,5563,6271,6389,7333,7451,7687,8513,8867,9103,9221,9811,9929,11699,12289,13469,14177,14767,15121,16183,16301,17599,18307,18661,19841,20431,20549,20903,21139,21493,21611,23027,23971,24443,25033,25741,26449,26921,27983,28219,28573,28927,29399,29753,29989,30697,31051,32467,32939,33529,33647,34591,35771,36007,36479,36833,37423,38603,38839,39901,40609,41081,42379,43441,43913,44267,44621,45329,46273,47807,48397,48751,48869,49223,49459
mov $1,8
mov $2,$0
add $2,2
pow $2,2
lpb $2
sub $2,1
mov $3,$1
mul $3,2
seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0.
sub $0,$3
add $1,59
mov $4,$0
max $4,0
cmp $4,$0
mul $2,$4
lpe
mov $0,$1
sub $0,60
mul $0,2
add $0,3
|
courses/spark_for_ada_programmers/labs/answers/110_advanced_proof_techniques/max.ads | AdaCore/training_material | 15 | 4005 | <filename>courses/spark_for_ada_programmers/labs/answers/110_advanced_proof_techniques/max.ads
package Max
with SPARK_Mode
is
Min_Table_Size : constant := 1;
Max_Table_Size : constant := 100;
Min_Content : constant := -200;
Max_Content : constant := 200;
type Index_Range is range Min_Table_Size .. Max_Table_Size;
type Content_Range is range Min_Content .. Max_Content;
type Our_Array is array (Index_Range) of Content_Range;
function Arrays_Max (A : in Our_Array) return Index_Range
with Post => (for all N in Index_Range => A (Arrays_Max'Result) >= A (N));
end Max;
|
sk.agda | logicshan/IAL | 0 | 162 | module sk where
open import nat
data comb : Set where
S : comb
K : comb
app : comb → comb → comb
data _↝_ : comb → comb → Set where
↝K : (a b : comb) → (app (app K a) b) ↝ a
↝S : (a b c : comb) → (app (app (app S a) b) c) ↝ (app (app a c) (app b c))
↝Cong1 : {a a' : comb} (b : comb) → a ↝ a' → (app a b) ↝ (app a' b)
↝Cong2 : (a : comb) {b b' : comb} → b ↝ b' → (app a b) ↝ (app a b')
size : comb → ℕ
size S = 1
size K = 1
size (app a b) = suc (size a + size b)
|
Fields/CauchyCompletion/Archimedean.agda | Smaug123/agdaproofs | 4 | 3216 | <reponame>Smaug123/agdaproofs
{-# OPTIONS --safe --warning=error --without-K --guardedness #-}
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
open import Setoids.Setoids
open import Rings.Definition
open import Rings.Orders.Partial.Definition
open import Rings.Orders.Total.Definition
open import Groups.Definition
open import Groups.Orders.Archimedean
open import Fields.Fields
open import Sets.EquivalenceRelations
open import Sequences
open import Setoids.Orders.Partial.Definition
open import Functions.Definition
open import LogicalFormulae
open import Numbers.Naturals.Semiring
open import Numbers.Naturals.Order
open import Fields.Orders.Total.Archimedean
module Fields.CauchyCompletion.Archimedean {m n o : _} {A : Set m} {S : Setoid {m} {n} A} {_+_ : A → A → A} {_*_ : A → A → A} {_<_ : Rel {m} {o} A} {pOrder : SetoidPartialOrder S _<_} {R : Ring S _+_ _*_} {pRing : PartiallyOrderedRing R pOrder} (order : TotallyOrderedRing pRing) (F : Field R) (arch : ArchimedeanField {F = F} (record { oRing = pRing })) where
open import Fields.CauchyCompletion.Group order F
open import Fields.CauchyCompletion.Ring order F
open import Fields.CauchyCompletion.Comparison order F
open import Fields.CauchyCompletion.PartiallyOrderedRing order F
CArchimedean : Archimedean (toGroup CRing CpOrderedRing)
CArchimedean x y xPos yPos = {!!}
|
stm32f0/stm32f030x/svd/stm32_svd-adc.ads | ekoeppen/STM32_Generic_Ada_Drivers | 1 | 9611 | <filename>stm32f0/stm32f030x/svd/stm32_svd-adc.ads
-- This spec has been automatically generated from STM32F030.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with System;
package STM32_SVD.ADC is
pragma Preelaborate;
---------------
-- Registers --
---------------
subtype ISR_ADRDY_Field is STM32_SVD.Bit;
subtype ISR_EOSMP_Field is STM32_SVD.Bit;
subtype ISR_EOC_Field is STM32_SVD.Bit;
subtype ISR_EOS_Field is STM32_SVD.Bit;
subtype ISR_OVR_Field is STM32_SVD.Bit;
subtype ISR_AWD_Field is STM32_SVD.Bit;
-- interrupt and status register
type ISR_Register is record
-- ADC ready
ADRDY : ISR_ADRDY_Field := 16#0#;
-- End of sampling flag
EOSMP : ISR_EOSMP_Field := 16#0#;
-- End of conversion flag
EOC : ISR_EOC_Field := 16#0#;
-- End of sequence flag
EOS : ISR_EOS_Field := 16#0#;
-- ADC overrun
OVR : ISR_OVR_Field := 16#0#;
-- unspecified
Reserved_5_6 : STM32_SVD.UInt2 := 16#0#;
-- Analog watchdog flag
AWD : ISR_AWD_Field := 16#0#;
-- unspecified
Reserved_8_31 : STM32_SVD.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ISR_Register use record
ADRDY at 0 range 0 .. 0;
EOSMP at 0 range 1 .. 1;
EOC at 0 range 2 .. 2;
EOS at 0 range 3 .. 3;
OVR at 0 range 4 .. 4;
Reserved_5_6 at 0 range 5 .. 6;
AWD at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype IER_ADRDYIE_Field is STM32_SVD.Bit;
subtype IER_EOSMPIE_Field is STM32_SVD.Bit;
subtype IER_EOCIE_Field is STM32_SVD.Bit;
subtype IER_EOSIE_Field is STM32_SVD.Bit;
subtype IER_OVRIE_Field is STM32_SVD.Bit;
subtype IER_AWDIE_Field is STM32_SVD.Bit;
-- interrupt enable register
type IER_Register is record
-- ADC ready interrupt enable
ADRDYIE : IER_ADRDYIE_Field := 16#0#;
-- End of sampling flag interrupt enable
EOSMPIE : IER_EOSMPIE_Field := 16#0#;
-- End of conversion interrupt enable
EOCIE : IER_EOCIE_Field := 16#0#;
-- End of conversion sequence interrupt enable
EOSIE : IER_EOSIE_Field := 16#0#;
-- Overrun interrupt enable
OVRIE : IER_OVRIE_Field := 16#0#;
-- unspecified
Reserved_5_6 : STM32_SVD.UInt2 := 16#0#;
-- Analog watchdog interrupt enable
AWDIE : IER_AWDIE_Field := 16#0#;
-- unspecified
Reserved_8_31 : STM32_SVD.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for IER_Register use record
ADRDYIE at 0 range 0 .. 0;
EOSMPIE at 0 range 1 .. 1;
EOCIE at 0 range 2 .. 2;
EOSIE at 0 range 3 .. 3;
OVRIE at 0 range 4 .. 4;
Reserved_5_6 at 0 range 5 .. 6;
AWDIE at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype CR_ADEN_Field is STM32_SVD.Bit;
subtype CR_ADDIS_Field is STM32_SVD.Bit;
subtype CR_ADSTART_Field is STM32_SVD.Bit;
subtype CR_ADSTP_Field is STM32_SVD.Bit;
subtype CR_ADCAL_Field is STM32_SVD.Bit;
-- control register
type CR_Register is record
-- ADC enable command
ADEN : CR_ADEN_Field := 16#0#;
-- ADC disable command
ADDIS : CR_ADDIS_Field := 16#0#;
-- ADC start conversion command
ADSTART : CR_ADSTART_Field := 16#0#;
-- unspecified
Reserved_3_3 : STM32_SVD.Bit := 16#0#;
-- ADC stop conversion command
ADSTP : CR_ADSTP_Field := 16#0#;
-- unspecified
Reserved_5_30 : STM32_SVD.UInt26 := 16#0#;
-- ADC calibration
ADCAL : CR_ADCAL_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR_Register use record
ADEN at 0 range 0 .. 0;
ADDIS at 0 range 1 .. 1;
ADSTART at 0 range 2 .. 2;
Reserved_3_3 at 0 range 3 .. 3;
ADSTP at 0 range 4 .. 4;
Reserved_5_30 at 0 range 5 .. 30;
ADCAL at 0 range 31 .. 31;
end record;
subtype CFGR1_DMAEN_Field is STM32_SVD.Bit;
subtype CFGR1_DMACFG_Field is STM32_SVD.Bit;
subtype CFGR1_SCANDIR_Field is STM32_SVD.Bit;
subtype CFGR1_RES_Field is STM32_SVD.UInt2;
subtype CFGR1_ALIGN_Field is STM32_SVD.Bit;
subtype CFGR1_EXTSEL_Field is STM32_SVD.UInt3;
subtype CFGR1_EXTEN_Field is STM32_SVD.UInt2;
subtype CFGR1_OVRMOD_Field is STM32_SVD.Bit;
subtype CFGR1_CONT_Field is STM32_SVD.Bit;
subtype CFGR1_AUTDLY_Field is STM32_SVD.Bit;
subtype CFGR1_AUTOFF_Field is STM32_SVD.Bit;
subtype CFGR1_DISCEN_Field is STM32_SVD.Bit;
subtype CFGR1_AWDSGL_Field is STM32_SVD.Bit;
subtype CFGR1_AWDEN_Field is STM32_SVD.Bit;
subtype CFGR1_AWDCH_Field is STM32_SVD.UInt5;
-- configuration register 1
type CFGR1_Register is record
-- Direct memory access enable
DMAEN : CFGR1_DMAEN_Field := 16#0#;
-- Direct memery access configuration
DMACFG : CFGR1_DMACFG_Field := 16#0#;
-- Scan sequence direction
SCANDIR : CFGR1_SCANDIR_Field := 16#0#;
-- Data resolution
RES : CFGR1_RES_Field := 16#0#;
-- Data alignment
ALIGN : CFGR1_ALIGN_Field := 16#0#;
-- External trigger selection
EXTSEL : CFGR1_EXTSEL_Field := 16#0#;
-- unspecified
Reserved_9_9 : STM32_SVD.Bit := 16#0#;
-- External trigger enable and polarity selection
EXTEN : CFGR1_EXTEN_Field := 16#0#;
-- Overrun management mode
OVRMOD : CFGR1_OVRMOD_Field := 16#0#;
-- Single / continuous conversion mode
CONT : CFGR1_CONT_Field := 16#0#;
-- Auto-delayed conversion mode
AUTDLY : CFGR1_AUTDLY_Field := 16#0#;
-- Auto-off mode
AUTOFF : CFGR1_AUTOFF_Field := 16#0#;
-- Discontinuous mode
DISCEN : CFGR1_DISCEN_Field := 16#0#;
-- unspecified
Reserved_17_21 : STM32_SVD.UInt5 := 16#0#;
-- Enable the watchdog on a single channel or on all channels
AWDSGL : CFGR1_AWDSGL_Field := 16#0#;
-- Analog watchdog enable
AWDEN : CFGR1_AWDEN_Field := 16#0#;
-- unspecified
Reserved_24_25 : STM32_SVD.UInt2 := 16#0#;
-- Analog watchdog channel selection
AWDCH : CFGR1_AWDCH_Field := 16#0#;
-- unspecified
Reserved_31_31 : STM32_SVD.Bit := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CFGR1_Register use record
DMAEN at 0 range 0 .. 0;
DMACFG at 0 range 1 .. 1;
SCANDIR at 0 range 2 .. 2;
RES at 0 range 3 .. 4;
ALIGN at 0 range 5 .. 5;
EXTSEL at 0 range 6 .. 8;
Reserved_9_9 at 0 range 9 .. 9;
EXTEN at 0 range 10 .. 11;
OVRMOD at 0 range 12 .. 12;
CONT at 0 range 13 .. 13;
AUTDLY at 0 range 14 .. 14;
AUTOFF at 0 range 15 .. 15;
DISCEN at 0 range 16 .. 16;
Reserved_17_21 at 0 range 17 .. 21;
AWDSGL at 0 range 22 .. 22;
AWDEN at 0 range 23 .. 23;
Reserved_24_25 at 0 range 24 .. 25;
AWDCH at 0 range 26 .. 30;
Reserved_31_31 at 0 range 31 .. 31;
end record;
-- CFGR2_JITOFF_D array element
subtype CFGR2_JITOFF_D_Element is STM32_SVD.Bit;
-- CFGR2_JITOFF_D array
type CFGR2_JITOFF_D_Field_Array is array (2 .. 3)
of CFGR2_JITOFF_D_Element
with Component_Size => 1, Size => 2;
-- Type definition for CFGR2_JITOFF_D
type CFGR2_JITOFF_D_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- JITOFF_D as a value
Val : STM32_SVD.UInt2;
when True =>
-- JITOFF_D as an array
Arr : CFGR2_JITOFF_D_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for CFGR2_JITOFF_D_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- configuration register 2
type CFGR2_Register is record
-- unspecified
Reserved_0_29 : STM32_SVD.UInt30 := 16#8000#;
-- JITOFF_D2
JITOFF_D : CFGR2_JITOFF_D_Field :=
(As_Array => False, Val => 16#0#);
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CFGR2_Register use record
Reserved_0_29 at 0 range 0 .. 29;
JITOFF_D at 0 range 30 .. 31;
end record;
subtype SMPR_SMPR_Field is STM32_SVD.UInt3;
-- sampling time register
type SMPR_Register is record
-- Sampling time selection
SMPR : SMPR_SMPR_Field := 16#0#;
-- unspecified
Reserved_3_31 : STM32_SVD.UInt29 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SMPR_Register use record
SMPR at 0 range 0 .. 2;
Reserved_3_31 at 0 range 3 .. 31;
end record;
subtype TR_LT_Field is STM32_SVD.UInt12;
subtype TR_HT_Field is STM32_SVD.UInt12;
-- watchdog threshold register
type TR_Register is record
-- Analog watchdog lower threshold
LT : TR_LT_Field := 16#FFF#;
-- unspecified
Reserved_12_15 : STM32_SVD.UInt4 := 16#0#;
-- Analog watchdog higher threshold
HT : TR_HT_Field := 16#0#;
-- unspecified
Reserved_28_31 : STM32_SVD.UInt4 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for TR_Register use record
LT at 0 range 0 .. 11;
Reserved_12_15 at 0 range 12 .. 15;
HT at 0 range 16 .. 27;
Reserved_28_31 at 0 range 28 .. 31;
end record;
-- CHSELR_CHSEL array element
subtype CHSELR_CHSEL_Element is STM32_SVD.Bit;
-- CHSELR_CHSEL array
type CHSELR_CHSEL_Field_Array is array (0 .. 18) of CHSELR_CHSEL_Element
with Component_Size => 1, Size => 19;
-- Type definition for CHSELR_CHSEL
type CHSELR_CHSEL_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- CHSEL as a value
Val : STM32_SVD.UInt19;
when True =>
-- CHSEL as an array
Arr : CHSELR_CHSEL_Field_Array;
end case;
end record
with Unchecked_Union, Size => 19;
for CHSELR_CHSEL_Field use record
Val at 0 range 0 .. 18;
Arr at 0 range 0 .. 18;
end record;
-- channel selection register
type CHSELR_Register is record
-- Channel-x selection
CHSEL : CHSELR_CHSEL_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_19_31 : STM32_SVD.UInt13 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CHSELR_Register use record
CHSEL at 0 range 0 .. 18;
Reserved_19_31 at 0 range 19 .. 31;
end record;
subtype DR_DATA_Field is STM32_SVD.UInt16;
-- data register
type DR_Register is record
-- Read-only. Converted data
DATA : DR_DATA_Field;
-- unspecified
Reserved_16_31 : STM32_SVD.UInt16;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR_Register use record
DATA at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype CCR_VREFEN_Field is STM32_SVD.Bit;
subtype CCR_TSEN_Field is STM32_SVD.Bit;
subtype CCR_VBATEN_Field is STM32_SVD.Bit;
-- common configuration register
type CCR_Register is record
-- unspecified
Reserved_0_21 : STM32_SVD.UInt22 := 16#0#;
-- Temperature sensor and VREFINT enable
VREFEN : CCR_VREFEN_Field := 16#0#;
-- Temperature sensor enable
TSEN : CCR_TSEN_Field := 16#0#;
-- VBAT enable
VBATEN : CCR_VBATEN_Field := 16#0#;
-- unspecified
Reserved_25_31 : STM32_SVD.UInt7 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CCR_Register use record
Reserved_0_21 at 0 range 0 .. 21;
VREFEN at 0 range 22 .. 22;
TSEN at 0 range 23 .. 23;
VBATEN at 0 range 24 .. 24;
Reserved_25_31 at 0 range 25 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Analog-to-digital converter
type ADC_Peripheral is record
-- interrupt and status register
ISR : aliased ISR_Register;
-- interrupt enable register
IER : aliased IER_Register;
-- control register
CR : aliased CR_Register;
-- configuration register 1
CFGR1 : aliased CFGR1_Register;
-- configuration register 2
CFGR2 : aliased CFGR2_Register;
-- sampling time register
SMPR : aliased SMPR_Register;
-- watchdog threshold register
TR : aliased TR_Register;
-- channel selection register
CHSELR : aliased CHSELR_Register;
-- data register
DR : aliased DR_Register;
-- common configuration register
CCR : aliased CCR_Register;
end record
with Volatile;
for ADC_Peripheral use record
ISR at 16#0# range 0 .. 31;
IER at 16#4# range 0 .. 31;
CR at 16#8# range 0 .. 31;
CFGR1 at 16#C# range 0 .. 31;
CFGR2 at 16#10# range 0 .. 31;
SMPR at 16#14# range 0 .. 31;
TR at 16#20# range 0 .. 31;
CHSELR at 16#28# range 0 .. 31;
DR at 16#40# range 0 .. 31;
CCR at 16#308# range 0 .. 31;
end record;
-- Analog-to-digital converter
ADC_Periph : aliased ADC_Peripheral
with Import, Address => System'To_Address (16#40012400#);
end STM32_SVD.ADC;
|
joystick/pqueue.ads | darkestkhan/lumen | 8 | 11897 | <gh_stars>1-10
--
-- PQueue -- Generic protected queue package
--
-- This code was adapted from two different chunks of code in Norman
-- <NAME>'s excellent book Ada as a Second Language. It implements a simple
-- protected generic queue type.
generic
type Data_Type is private;
package PQueue is
pragma Preelaborate;
------------------------------------------------------------------------------
--
-- Public types
--
------------------------------------------------------------------------------
-- The implementation details of the queue aren't important to users
type Queue_Type is limited private;
-- The protected type, providing an interface to manage the queue
protected type Protected_Queue_Type is
-- Place an item on the back of the queue. Doesn't block.
procedure Enqueue (Item : in Data_Type);
-- Remove an item from the front of the queue. Blocks if no items are
-- present.
entry Dequeue (Item : out Data_Type);
-- Return the number of items presently on the queue. Doesn't block.
function Length return natural;
private
-- The actual queue we're protecting
Queue : Queue_Type;
end Protected_Queue_Type;
------------------------------------------------------------------------------
--
-- Private types
--
------------------------------------------------------------------------------
private
-- Implementation of a simple queue, using a linked list. First, define
-- the list node type, with a data item of whatever type the user specifies
-- when they instantiate this generic package.
type Queue_Element_Type;
type Queue_Element_Pointer is access Queue_Element_Type;
type Queue_Element_Type is record
Data : Data_Type;
Next : Queue_Element_Pointer;
end record;
-- Now the queue itself, with its length, and pointers to the front and
-- back items.
type Queue_Type is record
Len : natural := 0;
Front : Queue_Element_Pointer := null;
Back : Queue_Element_Pointer := null;
end record;
---------------------------------------------------------------------------
end PQueue;
|
libsrc/_DEVELOPMENT/arch/hbios/c/sdcc/hbios_a_fastcall.asm | Frodevan/z88dk | 640 | 95325 |
; uint8_t hbios_a(uint16_t func_device) __z88dk_fastcall
SECTION code_clib
SECTION code_arch
PUBLIC _hbios_a_fastcall
EXTERN asm_hbios_a
._hbios_a_fastcall
ld b,h
ld c,l
jp asm_hbios_a
|
programs/oeis/135/A135300.asm | karttu/loda | 1 | 247783 | ; A135300: Positive X-values of solutions to the equation 1!*X^4 - 2!*(X + 1)^3 + 3!*(X + 2)^2 - (4^2)*(X + 3) + 5^2 = Y^3.
; 1,7,26,63,124,215,342,511,728,999,1330,1727,2196,2743,3374,4095,4912,5831,6858,7999,9260,10647,12166,13823,15624,17575,19682,21951,24388,26999,29790,32767,35936,39303,42874,46655,50652,54871,59318,63999,68920,74087,79506,85183,91124,97335,103822,110591,117648,124999,132650,140607,148876,157463,166374,175615,185192,195111,205378,215999,226980,238327,250046,262143,274624,287495,300762,314431,328508,342999,357910,373247,389016,405223,421874,438975,456532,474551,493038,511999,531440,551367,571786,592703,614124,636055,658502,681471,704968,728999,753570,778687,804356,830583,857374,884735,912672,941191,970298,999999,1030300,1061207,1092726,1124863,1157624,1191015,1225042,1259711,1295028,1330999,1367630,1404927,1442896,1481543,1520874,1560895,1601612,1643031,1685158,1727999,1771560,1815847,1860866,1906623,1953124,2000375,2048382,2097151,2146688,2196999,2248090,2299967,2352636,2406103,2460374,2515455,2571352,2628071,2685618,2743999,2803220,2863287,2924206,2985983,3048624,3112135,3176522,3241791,3307948,3374999,3442950,3511807,3581576,3652263,3723874,3796415,3869892,3944311,4019678,4095999,4173280,4251527,4330746,4410943,4492124,4574295,4657462,4741631,4826808,4912999,5000210,5088447,5177716,5268023,5359374,5451775,5545232,5639751,5735338,5831999,5929740,6028567,6128486,6229503,6331624,6434855,6539202,6644671,6751268,6858999,6967870,7077887,7189056,7301383,7414874,7529535,7645372,7762391,7880598,7999999,8120600,8242407,8365426,8489663,8615124,8741815,8869742,8998911,9129328,9260999,9393930,9528127,9663596,9800343,9938374,10077695,10218312,10360231,10503458,10647999,10793860,10941047,11089566,11239423,11390624,11543175,11697082,11852351,12008988,12166999,12326390,12487167,12649336,12812903,12977874,13144255,13312052,13481271,13651918,13823999,13997520,14172487,14348906,14526783,14706124,14886935,15069222,15252991,15438248,15624999
add $0,1
pow $0,3
trn $0,2
mov $1,$0
add $1,1
|
src/bootsect/loader_disk.asm | wangziqi2016/Kernel | 3 | 101163 | _loader_disk_start:
;
; loader_disk.asm - This file contains disk driver and I/O routine
;
%define DISK_DEBUG
DISK_MAX_DEVICE equ 8 ; The maximum number of hardware devices we could support
DISK_MAX_RETRY equ 3 ; The max number of times we retry for read/write failure
DISK_SECTOR_SIZE equ 512 ; The byte size of a sector of the disk
DISK_SECTOR_SIZE_SHIFT equ 9 ; Number of bits that need to be shifted
DISK_SECTOR_SIZE_MASK equ 01ffh ; Mask that leaves only sector offset bits
DISK_FIRST_HDD_ID equ 80h ; The device ID of first HDD
DISK_BUFFER_SEG equ LARGE_BSS ; Segment of disk buffer
; Error code for disk operations
DISK_ERR_WRONG_LETTER equ 1
DISK_ERR_INT13H_FAIL equ 2
DISK_ERR_RESET_ERROR equ 3
DISK_ERR_INVALID_LBA equ 4
DISK_FS_NONE equ 0
DISK_FS_FAT12 equ 1
struc disk_param ; This defines the structure of the disk parameter table
.number: resb 1 ; The BIOS assigned number for the device
.letter: resb 1 ; The letter we use to represent the device, starting from 'A'; Also used as index
.type: resb 1
.fstype: resb 1 ; Type of the FS
.sector: resw 1 ; # of sectors
.head: resw 1 ; # of heads
.track: resw 1 ; # of tracks
.capacity: resd 1 ; Total # of sectors in linear address space; double word
.fsptr: resw 1 ; A pointer to the file system metadata
.size:
endstruc
; 16 sectors are cached in memory
DISK_BUFFER_SIZE equ 10h ; 16 entries
DISK_BUFFER_SIZE_MASK equ 000fh ; Mask is 0x000F to extract the index bit
; Constants defined for disk sector buffer
DISK_BUFFER_STATUS_VALID equ 0001h
DISK_BUFFER_STATUS_DIRTY equ 0002h
; These two are used as arguments for performing disk r/w
; via the common interface
DISK_OP_READ equ 0201h
DISK_OP_WRITE equ 0301h
; This is the structure of buffer entry in the disk buffer cache
struc disk_buffer_entry
.status: resw 1 ; Dirty/Valid
.number: resb 1 ; BIOS numbering
.letter: resb 1 ; The device letter
.lba: resd 1 ; The LBA that this sector is read from
.data: resb DISK_SECTOR_SIZE ; Sector data to be stored
.padding: resw 1 ; Avoid invalid read/write when accessing the last byte - DO NOT REMOVE
.size:
endstruc
disk_init:
cli ; Disable interrupt because we allocate memory during init
call disk_probe ; Probes disks and populate the disk parameter table
call disk_buffer_init ; Allocates a disk sector buffer at A20 memory region
sti
retn
; This function allocates buffer pool for disk sectors and initialize the buffer
disk_buffer_init:
push es
push bx
push si
mov ax, disk_buffer_entry.size
mov cx, DISK_BUFFER_SIZE
mul cx ; DX:AX is the total number of bytes required
test dx, dx ; If overflows to DX then it is too large (> 64KB we cannot afford)
jnz .buffer_too_large
mov bx, ax ; Save the size to BX
call mem_get_large_bss ; Otherwise AX contains requested size
jc .buffer_too_large ; If allocation fails report error
mov [disk_buffer], ax ; Otherwise AX is the start address
push bx
push ax
push disk_buffer_size_str
call video_printf_near ; Print the disk buffer info
;add sp, 6 ; Moved to below
push bx ; Length
xor ax, ax
push ax ; Value
push word LARGE_BSS ; Segment
mov ax, [disk_buffer]
push ax ; Offset
call memset ; Sets the buffer space to zero
add sp, 14 ; Clear arg for both functions
pop si
pop bx
pop es
ret
.buffer_too_large:
push dx
push ax
push ds
push disk_buffer_too_large_str
call bsod_fatal
; Enumerates FDDs and HDDs using INT13H. Disk parameters are allocated on the
; system segment and stored as disk_mapping
disk_probe:
push es
push di
push bx
push bp
mov bp, sp
sub sp, 4
.curr_letter equ -1 ; Local variables
.curr_number equ -2
.curr_status equ -4
.STATUS_CHECK_FLOPPY equ 0 ; Constants for the current disk probing status
.STATUS_CHECK_HDD equ 1
xor ax, ax
mov [bp + .curr_status], ax ; Current status is set to 0
mov ah, 'A'
mov [bp + .curr_number], ax ; We start from 0x00 (disk num) and 'A' (letter assignment)
.body:
xor ax, ax
mov es, ax
mov di, ax ; ES:DI = 0:0 as required by INT13H
mov ah, 08h ; BIOS INT 13h/AH=08H to detect disk param
mov dl, [bp + .curr_number] ; DL is BIOS drive number, 7th bit set if HDD
int 13h ; It does not preserve any register value
jc .error_13h ; Either disk number non-exist or real error
mov al, [bp + .curr_number] ; Note that it is possible that this routine returns success even if the
and al, 7fh ; number is invalid. In this case we compare DL (# of drives returned) with
cmp dl, al ; the ID of drives to see if it is the case
jle .error_13h
push cx ; Save CX, DX before function call
push dx
mov ax, disk_param.size ; Reserve one slot for the detected drive (AX is allocation size)
call mem_get_sys_bss
pop dx
pop cx
jc .error_unrecoverable ; Fail if CF = 1
mov [disk_mapping], ax ; Save this everytime since the system segment grows downwards
xchg ax, bx ; AL = drive type; BX = starting offset (INT13H/08H returns drive type in BL)
mov [bx + disk_param.type], al ; Save disk type
xor dl, dl
xchg dh, dl ; DH is always zero, DL is the head number
inc dx ; DX is the number of heads
mov [bx + disk_param.head], dx ; Save number of heads (returned by INT13H/08H)
mov al, ch ; Move CL[7:6]CH[7:0] into AX and save as number of tracks; CL has higher 2 bits
mov ah, cl
shr ah, 6
inc ax ; Store the # of tracks
mov [bx + disk_param.track], ax ; AH = CL >> 6 and AL = CH
and cl, 03fh
xor ch, ch ; Higher 8 bits are 0
mov [bx + disk_param.sector], cx ; Save number of sectors as (CL & 0x3F), i.e. mask off high two bits
mul cl ; AX = CL * AL (# sector * # track)
mul dx ; DX:AX = AX * DX (# sector * # track * # head)
mov [bx + disk_param.capacity], ax
mov [bx + disk_param.capacity + 2], dx ; Store this as capacity in terms of sectors
mov ax, [bp + .curr_number] ; Low byte number high byte letter
mov [bx + disk_param.number], ax ; Save the above info into the table
mov byte [bx + disk_param.fstype], \
DISK_FS_NONE ; Initialize fstype to zero
call .print_found ; Register will be destroyed in this routine
inc byte [bp + .curr_number] ; Increment the current letter and device number
inc byte [bp + .curr_letter]
inc word [disk_mapping_num] ; Also increment the number of mappings
cmp word [disk_mapping_num], DISK_MAX_DEVICE ; Report error if too many drives
ja .error_too_many_disks
jmp .body
.return:
mov sp, bp
pop bp
pop bx
pop di
pop es
retn
.print_found: ; Print the drive just found using printf
push word [bx + disk_param.capacity + 2]
push word [bx + disk_param.capacity] ; 32 bit unsigned little endian
push word [bx + disk_param.sector]
push word [bx + disk_param.head]
push word [bx + disk_param.track]
push word [bp + .curr_number] ; High 8 bits will be ignored although we also pushed the letter with this
xor ax, ax
mov al, [bp + .curr_letter]
push ax
push disk_init_found_str
call video_printf_near
add sp, 16
retn
.finish_checking_floppy:
mov byte [bp + .curr_number], DISK_FIRST_HDD_ID ; Begin enumerating HDDs
mov word [bp + .curr_status], .STATUS_CHECK_HDD ; Also change the status such that on next INT13H fail we return
jmp .body
.error_13h: ; This can be a real error or just because we finished the current drive type
cmp word [bp + .curr_status], .STATUS_CHECK_FLOPPY ; If we are checking floppy and see this then switch to enumerate HDD
je .finish_checking_floppy
jmp .return ; Otherwise return because we finished enumerating all disks
.error_unrecoverable:
push ax
push ds
push disk_init_error_str
call bsod_fatal
.error_too_many_disks: ; Print the max # of disks and then die
push word DISK_MAX_DEVICE
push ds
push disk_too_many_disk_str
call bsod_fatal
; This function returns a pointer to the disk param block given a disk letter
; AX - The disk letter (ignore high 8 bits)
; Return:
; AX = Address of the disk_param entry
; CF is set on failure. AX is set to DISK_ERR_WRONG_LETTER
disk_getparam:
mov ah, al
cmp ah, 'A'
jb .return_invalid
sub ah, 'A'
cmp ah, [disk_mapping_num]
jae .return_invalid ; If ah - 'A' >= mapping num it is also invalid
mov al, [disk_mapping_num] ; entry index = (mapping num - 1 - (letter - 'A'))
sub al, ah
dec al
mov ah, disk_param.size
mul ah ; Get the byte offset of the entry
add ax, [disk_mapping] ; Add with the base address
clc
retn
.return_invalid:
stc
mov ax, DISK_ERR_WRONG_LETTER
retn
; This function returns the CHS representation given a linear sector ID
; and the drive letter
; [BP + 4] - Device letter (ignore high 8 bits)
; [BP + 6][BP + 8] - Linear sector ID (LBA) in small endian
; Return:
; DH = head
; DL = device number (i.e. the hardware number)
; CH = low 8 bits of cylinder
; CL[6:7] = high 2 bits of cylinder
; CL[0:5] = sector
; CF is clear when success, AX is undefined
; CF is set when error, AX contains one of the following:
; - DISK_ERR_WRONG_LETTER if letter is wrong
; - DISK_ERR_INVALID_LBA if LBA is too large
disk_getchs:
push bp
mov bp, sp
push ax ; Local variable used as current sector (starting from 1, must not be more than 6 bits)
.curr_sector equ -2
push bx
mov ax, [bp + 4] ; AX = Paremeter to the function
call disk_getparam ; Get disk parameter first
jc .error_wrong_letter
mov bx, ax ; BX is the table entry
mov dx, [bp + 8] ; Next compare the input LBA and the maximum LBA
mov ax, [bp + 6] ; DX:AX = Input LBA
cmp dx, [bx + disk_param.capacity + 2]
ja .error_invalid_lba ; If higher word is larger then LBA is too large
jne .body ; Jump to body is higher word is less than capacity
cmp ax, [bx + disk_param.capacity]
jae .error_invalid_lba ; Lower word must be capacity - 1 or less
.body:
mov cx, [bx + disk_param.sector] ; CX = number of sectors per track
div cx ; DX = Sector (only DL, no more than 6 bits); AX = Next step;
inc dx ; Note that sector begins at 1
mov [bp + .curr_sector], dx ; Save sector in the local var
xor dx, dx ; DX:AX = Next step
mov cx, [bx + disk_param.head] ; CX = number of heads per cylinder
div cx ; DX = Head; AX = track
mov dh, dl ; DH = head
mov dl, [bx + disk_param.number] ; DL = BIOS number
mov ch, al ; CH = low 8 bits of track
shl ah, 6 ; Shift lower 2 bits to highest 2 bits (<<= 6)
mov cl, ah ; High 2 bits of CL is low 2 bits of AH
or cl, [bp + .curr_sector] ; Low 6 bits of CL is OR'ed with sector (we know sector must not be more than 6 bits)
.return:
pop bx
mov sp, bp
pop bp
ret
.error_invalid_lba:
mov ax, DISK_ERR_INVALID_LBA
stc
.error_wrong_letter: ; AX is already the error code
jmp .return
; Reads or writes a word from/into disk, given the byte offset. Supports maximum 4GB disk.
; [BP + 4] - Device letter
; [BP + 6][BP + 8] - Byte offset of the word, can be unaligned
; [BP + 10] - Data for write; do not need this for read
; AX - operation code; DISK_OP_READ/DISK_OP_WRITE
; Return:
; AX stores the 16 bit word for read; Returns data just written for write
; On error, CF and AX are set based on the same condition as disk_insert_buffer
disk_op_word:
push bp
mov bp, sp
push es ; [BP - 2]
push bx ; [BP - 4] - Note: Must clear arguments before restoring these two reg
push word LARGE_BSS
pop es ; Load ES as the segment of buffer
push ax ; [BP - 6] - Operation code (R/W)
push ax ; [BP - 8] - Buffer data
push ax ; [BP - 10] - Offset
mov ax, [bp + 8] ; Offset high
mov cx, ax
shr ax, DISK_SECTOR_SIZE_SHIFT ; AX >>= 9 to shift out the lowest 9 bits into lower
shl cx, 7 ; CX = offset_hi << 7, high 9 bits are low 9 bits of lba high
push ax ; [BP - 12] lba_hi
mov ax, [bp + 6] ; Offset low
shr ax, DISK_SECTOR_SIZE_SHIFT ; AX >>= 9 to shift out the offset bits
or ax, cx
push ax ; [BP - 14] lba_lo
mov ax, [bp + 4]
push ax ; [BP - 16] letter
.opcode equ -6 ; Local variables
.buffer_data equ -8 ; The following two are local scratch pads
.offset equ -10
.lba_hi equ -12 ; Note that stack layout below is exactly the same as the argument list
.lba_lo equ -14 ; ... that disk_insert_buffer accept
.letter equ -16
mov ax, [bp + 6] ; Offset low
and ax, DISK_SECTOR_SIZE_MASK ; Extract lowest 9 bits
mov [bp + .offset], ax ; ... and store as offset
call disk_insert_buffer ; Arguments have been set up
jc .return_err ; We can directly use jc because stack is not cleared
mov bx, ax ; Return value is in AX
add bx, [bp +.offset] ; First add in-sector offset. We also add field offset below
cmp word [bp + .opcode], DISK_OP_WRITE
je .process_write_1 ; Fall through to read
mov ax, [es:bx + \
disk_buffer_entry.data] ; Read ES:BX + offset entry.data + logical offset (not .offset variable)
jmp .after_1
.process_write_1:
mov ax, [bp + 10]
mov [es:bx + \
disk_buffer_entry.data], ax ; We can do this even at sector boundary b/c the buffer has padding
sub bx, [bp +.offset] ; Reset BX to the head of the buffer
or word [es:bx + \
disk_buffer_entry.status], \
DISK_BUFFER_STATUS_DIRTY ; Set dirty bits
.after_1:
cmp word [bp + .offset], 01ffh ; If offset is not 511 then the read does not cross boundary
jne .finish
mov [bp + .buffer_data], ax ; Save AX to local var (high byte is ignored) - for write this is ignored
inc word [bp + .lba_lo]
adc word [bp + .lba_hi], 0 ; Increment the 32 bit LBA by 1 using INC + ADC
call disk_insert_buffer ; Read second half
jc .return_err ; Same as above
mov bx, ax ; Return value is in AX
cmp word [bp + .opcode], DISK_OP_WRITE
je .process_write_2 ; Fall through to read for the 2nd half
mov ah, [es:bx + \
disk_buffer_entry.data] ; Read first byte of buffer data into AX high byte
mov al, [bp + .buffer_data] ; Read into AX low byte
jmp .finish
.process_write_2:
mov al, [bp + 11] ; This is the high byte
mov [es:bx + \
disk_buffer_entry.data], al ; Just write first byte using the higher byte
or word [es:bx + \
disk_buffer_entry.status], \
DISK_BUFFER_STATUS_DIRTY ; Set dirty bits
mov ax, [bp + 10] ; Return data just written
.finish:
clc
jmp .return_normal
.return_err:
stc ; Note that the add sp, 8 below will clear CF
.return_normal:
add sp, 12 ; Clear stack local variables (resets CF; we clc anyway to stress the point)
pop bx
pop es
mov sp, bp
pop bp
ret
; Inserts an entry into the buffer, may evict an existing entry. If an empty entry is found,
; the LBA and letter is filled into that entry and data is loaded from disk. On eviction,
; if the buffer entry is dirty then the sector is written back
; [BP + 4] - Device letter
; [BP + 6][BP + 8] - Linear sector ID (LBA) in small endian
; Return:
; AX points to the entry's begin address, and the entry is already filled with LBA and letter and is valid.
; Dirty bit may or may not be set
; On error, CF and AX are set based on the same condition as disk_op_lba
; On error, the buffer is not affected and no invalid entry will be entered
disk_insert_buffer:
push bp
mov bp, sp
.empty_slot equ -2
xor ax, ax
push ax ; [BP + .empty_slot], if 0 then there is no empty slot (0 is not valid offset in this case)
push es
push bx
push si ; SI counts the number of entries, break loop if this equals buffer size
mov cx, [bp + 6]
and cx, DISK_BUFFER_SIZE_MASK ; CX = Table index
mov ax, disk_buffer_entry.size; Note that this is greater than 256
mul cx ; DX:AX = Offset; Ignore DX because we know it must be < 64KB
mov bx, ax
add bx, [disk_buffer] ; BX = table base + entry offset
mov ax, cx ; AX = Table index
xor si, si ; SI begins at 0
push word LARGE_BSS
pop es
;mov bx, [disk_buffer] ; ES:BX = Address of buffer entries
;xor ax, ax
.body:
cmp si, DISK_BUFFER_SIZE ; Check whether we finished all entries
je .try_empty ; If no matching entry is found then first try to claim empty then evict
test word [es:bx + disk_buffer_entry.status], DISK_BUFFER_STATUS_VALID
jnz .check_existing ; If it is valid entry then check parameters
mov [bp + .empty_slot], bx ; Write down empty slot in local var for later use
jmp .continue ; And then try next entry
.check_existing:
mov cx, [bp + 4] ; CX = disk letter
cmp cl, [es:bx + disk_buffer_entry.letter]
jne .continue ; Skip if letter does not match
mov cx, [es:bx + disk_buffer_entry.lba]
cmp cx, [bp + 6]
jne .continue ; Skip if lower bytes do not match
mov cx, [es:bx + disk_buffer_entry.lba + 2]
cmp cx, [bp + 8]
jne .continue ; Skip if higher bytes do not match
.return: ; If found matching entry then fall through and return
mov ax, bx
.return_err: ; Do not change AX (which is the err code) on error
pop si
pop bx
pop es
mov sp, bp
pop bp
ret
.continue:
inc si ; Update number of entries
inc ax ; Update current index
add bx, disk_buffer_entry.size ; Update current entry pointer
cmp ax, DISK_BUFFER_SIZE
jne .body ; If AX has not reached the very end no wrap back
xor ax, ax
mov bx, [disk_buffer] ; Wrap back - Set AX and BX
jmp .body
.try_empty: ; Get here if all entries are checked and no matching is found
mov bx, [bp + .empty_slot] ; BX = Either empty slot or 0x0000
test bx, bx
jz .evict ; If BX is not valid, then evict an entry (no empty slot)
.found_empty: ; Otherwise, fall through to use the empty slot
or word [es:bx + disk_buffer_entry.status], DISK_BUFFER_STATUS_VALID ; Make the entry valid by setting the bit
push es ; 4th argument - Segment of data pointer
lea ax, [bx + disk_buffer_entry.data] ; Generate the address within the entry
push ax ; 4th argument - Offset of data pointer
mov ax, [bp + 8]
mov [es:bx + disk_buffer_entry.lba + 2], ax ; Copy higher 16 bits of LBA
push ax ; 3rd argument - LBA high 16 bits
mov ax, [bp + 6]
mov [es:bx + disk_buffer_entry.lba], ax ; Copy lower 16 bits of LBA
push ax ; 3rd argument - LBA low 16 bits
mov ax, [bp + 4]
mov [es:bx + disk_buffer_entry.letter], al ; Copy the letter; Note that we should only copy the low byte
push ax ; 2nd argument - Disk letter
push word DISK_OP_READ ; 1st argument - Opcode for disk LBA operation
;push .str
;call video_printf_near ; Uncomment this to enable debug printing
;add sp, 2
call disk_op_lba
sbb cx, cx ; Save CF bit in CX
add sp, 12
test cx, cx
jnz .error_read_fail ; If read error just return with CF
jmp .return
;.str: db "%u %c %U %x %x", 0ah, 00h ; Uncomment this to enable debug printing
.evict:
mov ax, [disk_last_evicted] ; Use the previous eviction index to compute this one (just +1)
inc ax
and ax, DISK_BUFFER_SIZE_MASK ; Potentially wrap back
mov [disk_last_evicted], ax ; Store it for next eviction
mov cx, disk_buffer_entry.size
mul cx ; DX:AX = offset into the table; We assume DX == 0 because we enforce this in init
add ax, [disk_buffer] ; Add with base address
mov bx, ax ; BX = Address of entry to evict
call disk_evict_buffer ; This function assumes ES:BX points to the entry to be evicted
jmp .found_empty ; Now we have an empty entry on ES:BX
.error_read_fail:
and word [es:bx + disk_buffer_entry.status], \
~(DISK_BUFFER_STATUS_VALID | \
DISK_BUFFER_STATUS_DIRTY) ; Clear dirty and valid bits if read reports an error
stc ; Previous operation may reset CF
jmp .return_err
; Evicts a disk buffer entry. This function also writes back data if the entry is dirty
; The returned buffer pointer in BX has both valid and dirty bits off
; BX - The address of the buffer entry
; ES - The large BSS segment
; Return:
; ES:BX - The address of the buffer entry (unchanged)
; AX may get destroyed
; CF is undefined. BSOD if eviction I/O fails
disk_evict_buffer:
test word [es:bx + disk_buffer_entry.status], DISK_BUFFER_STATUS_DIRTY
jz .after_evict ; If non-dirty just clear the bits and return non-changed
push es ; Segment of data pointer (since we assume ES to be LARGE BSS)
lea ax, [bx + disk_buffer_entry.data] ; Generate address within the entry
push ax ; Offset (current BX) of data pointer
mov ax, [es:bx + disk_buffer_entry.lba + 2]
push ax ; High 16 bits of LBA
mov ax, [es:bx + disk_buffer_entry.lba]
push ax ; Low 16 bits of LBA
mov ax, [es:bx + disk_buffer_entry.letter]
push ax ; Disk letter
push word DISK_OP_WRITE ; Opcode for disk LBA operation
call disk_op_lba ; We assume invalid entries will not be entered into buffer
sbb cx, cx
add sp, 12
test cx, cx
jnz .error_evict_fail ; ... and therefore if this fails it must be data corruption or code bug
.after_evict:
and word [es:bx + disk_buffer_entry.status], \
~(DISK_BUFFER_STATUS_VALID | \
DISK_BUFFER_STATUS_DIRTY) ; Clear dirty and valid bits
ret
.error_evict_fail:
push ds
push disk_evict_fail_str
call bsod_fatal
%ifdef DISK_DEBUG
DISK_DEBUG_NONE equ 0 ; Do nothing
DISK_DEBUG_EVICT equ 1 ; Whether this function also evicts dirty buffers
; This function is for debugging purpose. Prints buffer status, LBA and letter
; AX - One or more of the above constants to control behavior
disk_print_buffer:
push es
push bx
push si
push di
mov di, ax ; DI = options passed via AX
mov bx, [disk_buffer]
push word LARGE_BSS
pop es ; ES:BX = Buffer pointer
xor si, si ; SI = index on the buffer table
.body:
cmp si, DISK_BUFFER_SIZE
je .return
mov ax, [es:bx + disk_buffer_entry.status]
test ax, DISK_BUFFER_STATUS_VALID
jz .after_evict
test ax, DISK_BUFFER_STATUS_DIRTY
jz .after_evict
test di, DISK_DEBUG_EVICT
jz .after_evict
call disk_evict_buffer ; ES:BX has been set and will not be changed
.after_evict:
mov ax, [es:bx + disk_buffer_entry.status]
push ax
mov ax, [es:bx + disk_buffer_entry.letter]
push ax
mov ax, [es:bx + disk_buffer_entry.lba + 2]
push ax
mov ax, [es:bx + disk_buffer_entry.lba]
push ax
push .str
call video_printf_near
add sp, 10
inc si
add bx, disk_buffer_entry.size
jmp .body
.return:
mov ax, 000ah
call putchar
pop di
pop si
pop bx
pop es
ret
.str: db "%U %c (%u), ", 00h
%endif
; This function reads or writes LBA of a given disk
; Note that we use 32 bit LBA. For floppy disks, if INT13H fails, we retry
; for three times. If all are not successful we just return fail
; int disk_op_lba(int op, char letter, uint32_t lba, void far *buffer_data);
; [BP + 4] - 8 bit opcode on lower byte (0x02 for read, 0x03 for write);
; 8 bit # of sectors to operate on higher byte (should be 1)
; [BP + 6] - Disk letter (ignore high 8 bits)
; [BP + 8][BP + 10] - low and high word of the LBA
; [BP + 12][BP + 14] - Far pointer to the buffer data
; Return value:
; CF set if error occurs. AX contains the error code that can be one of the following:
; - DISK_ERR_WRONG_LETTER if the disk does not exist
; - DISK_ERR_INVALID_LBA if LBA is too large
; - DISK_ERR_INT13H_FAIL if INT13H fails that is not the above reason
; - DISK_ERR_RESET_ERROR if disk motor reset fails
disk_op_lba:
push bp
mov bp, sp
.retry_counter equ -2
xor ax, ax
push ax ; This is temp var retry counter
push es
push bx
push si
.retry:
mov ax, [bp + 10]
push ax ; LBA high 16 bits
mov ax, [bp + 8]
push ax ; LBA low 16 bits
mov ax, [bp + 6]
push ax ; Disk letter
call disk_getchs ; Returns CHS representation in DX and CX; This may return err code in AX
sbb si, si ; Can't use CX b/c it is the register for returning
add sp, 6
test si, si
jnz .return_err ; Both CF and AX are properly set, directly return
mov ax, [bp + 14]
mov es, ax
mov bx, [bp + 12] ; Load ES:BX to point to the buffer
mov ax, [bp + 4] ; AX = Opcode + number of sectors to read/write
int 13h ; Read/Write the LBA on given disk drive
jc .retry_or_fail ; Either retry or fail
xor ax, ax
clc
jmp .return
.return_fail_reset_error:
mov ax, DISK_ERR_RESET_ERROR
jmp .return_err
.return_fail_int13h_error:
mov ax, DISK_ERR_INT13H_FAIL
.return_err:
stc
.return:
pop si
pop bx
pop es
mov sp, bp
pop bp
retn
.retry_or_fail:
mov ax, [bp + .retry_counter] ; AX = Current number of failures
cmp ax, DISK_MAX_RETRY ; Compare to see if we exceeds maximum
je .return_fail_int13h_error ; If positive then report INT13H error
inc word [bp + .retry_counter] ; Increment the failure counter for next use
mov ax, [bp + 6] ; AX = Disk letter
call disk_getparam
jc .return_err ; Both CF and AX are properly set
mov bx, ax ; BX = pointer to the table
test byte [bx + disk_param.number], 80h ; If the number has 7-th bit set then it is an HDD
jnz .return_fail_int13h_error ; Do not retry for HDD
mov dl, [bx + disk_param.number] ; Otherwise it is FDD and we can reset the motor
xor ax, ax
int 13h ; INT13H/00H - Reset motor
jc .return_fail_reset_error
jmp .retry
disk_init_error_str: db "Error initializing disk parameters (AX = 0x%x)", 0ah, 00h
disk_init_found_str: db "%c: #%y Maximum C/H/S (0x): %x/%y/%y Cap %U", 0ah, 00h
disk_buffer_too_large_str: db "Disk buffer too large! (%U)", 0ah, 00h
disk_buffer_size_str: db "Sector buffer begins at 0x%x; size %u bytes", 0ah, 00h
disk_too_many_disk_str: db "Too many disks detected. Max = %u", 0ah, 00h
disk_evict_fail_str: db "Evict fail", 0ah, 00h
disk_mapping: dw 0 ; Offset in the system BSS segment to the start of the disk param table
disk_mapping_num: dw 0 ; Number of elements in the disk mapping table
disk_buffer: dw 0 ; This is the starting offset of the disk buffer
disk_last_evicted: dw DISK_BUFFER_SIZE - 1 ; Index of the last evicted buffer entry
|
base/mvdm/softpc.new/base/video/i386/ggdcdraw.asm | npocmaka/Windows-Server-2003 | 17 | 817 | ;ifdef NEC98 /* #endif position = EOF */
;/*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/
;/*:::::::::::::::: NEC98 GGDC Graphic Draw Emulation :::::::::::::::*/
;/*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/
;/* add making start NEC NEC98 930623 KBNES 1OA */
.386p
include ks386.inc
include callconv.inc
_TEXT SEGMENT DWORD USE32 PUBLIC 'CODE'
ASSUME DS:NOTHING, ES:NOTHING, SS:FLAT, FS:NOTHING, GS:NOTHING
_TEXT ENDS
_DATA SEGMENT DWORD USE32 PUBLIC 'DATA'
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
write_one_word label dword
dd offset draw_mov ; replace
draw_one_pixel label dword
dd offset draw_and ; replace
dd offset draw_or ; replace
draw_one_word label dword
dd offset draw_mov ; replace
dd offset draw_xor ; complement
dd offset draw_and ; clear
dd offset draw_or ; set
draw_0_pixel label dword
dd offset draw_and ; replace
dd offset draw_nop ; complement
dd offset draw_nop ; clear
dd offset draw_nop ; set
draw_1_pixel label dword
dd offset draw_or ; replace
dd offset draw_xor ; complement
dd offset draw_and ; clear
dd offset draw_or ; set
ggdc_dir_func_pixel label dword
dd offset pixel_dir_0
dd offset pixel_dir_1
dd offset pixel_dir_2
dd offset pixel_dir_3
dd offset pixel_dir_4
dd offset pixel_dir_5
dd offset pixel_dir_6
dd offset pixel_dir_7
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
ggdc_dir_func_word label dword
dd offset word_dir_0
dd offset word_dir_1
dd offset word_dir_2
dd offset word_dir_3
dd offset word_dir_4
dd offset word_dir_5
dd offset word_dir_6
dd offset word_dir_7
ggdc_VRAM dd 00000000H
ggdc_EAD dd 00000000H
ggdc_PITCH dd 00000000H
ggdc_DIR dd 00000000H
ggdc_DC dw 0000H
ggdc_D dw 0000H
ggdc_D2 dw 0000H
ggdc_D1 dw 0000H
ggdc_DM dw 0000H
ggdc_PTN dw 0000H
ggdc_ZOOM dw 0000H
ggdc_SL dw 0000H
ggdc_WG dw 0000H
ggdc_MASKGDC dw 0000H
ggdc_TXT label byte
db 00H
db 00H
db 00H
db 00H
db 00H
db 00H
db 00H
db 00H
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
ggdc_MASKCPU dw 0000H
ggdc_READ dw 0000H
ZOOM1 dw 0000H
ZOOM2 dw 0000H
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
ggdc_read_back_EAD dd 00000000H
ggdc_read_back_DAD dw 0000H
ggdc_CSRR_1 db 00H
ggdc_CSRR_2 db 00H
ggdc_CSRR_3 db 00H
ggdc_CSRR_4 db 00H
ggdc_CSRR_5 db 00H
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
_DATA ENDS
_TEXT SEGMENT
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;:::::::::::::::: NEC98 GGDC Graphic DATA SET ::::::::::::::::::
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
cPublicProc _ggdc_mod_select,1
push ebp ; save ebp
mov ebp,esp ; set up stack frame
; ebp - n = local data area
; ebp + 0 = save ebp
; ebp + 4 = return address
pushad
; push eax ; save eax reg
; push ebx ; save ebx reg
xor ebx,ebx ; ebx = 0
mov eax,[ebp+8] ; parameter 1 = mod data address
mov bl,byte ptr[eax] ; set mode
mov eax,draw_0_pixel[ebx*4] ; select logic
mov [draw_one_pixel][0],eax ; save 1dot 0bit
mov eax,draw_1_pixel[ebx*4] ; select logic
mov [draw_one_pixel][4],eax ; save 1dot 1bit
mov eax,draw_one_word[ebx*4]; select logic
mov [write_one_word],eax ; save 1dot 1bit
; pop ebx ; restore ebx
; pop eax ; restore eax
popad
mov esp,ebp ; restore stack frame
pop ebp ; restore ebp
stdRET _ggdc_mod_select
stdENDP _ggdc_mod_select
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
cPublicProc _ggdc_send_c_asm,1
push ebp
mov ebp,esp
pushad
mov esi,[ebp+8] ; c data area
mov edi,offset ggdc_VRAM ; asm data area
mov ecx,11 ; move count
rep movsd ; 44 bytes data move
mov ecx,16 ;
mov dx,[ggdc_MASKGDC] ; GGDC mask data
@@: rcr dx,1 ; reverse right <-> left
rcl ax,1 ;
loop short @b ;
mov [ggdc_MASKCPU],ax ; use CPU drawing
popad
pop ebp
stdRET _ggdc_send_c_asm
stdENDP _ggdc_send_c_asm
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
cPublicProc _ggdc_read_back,1
push ebp
mov ebp,esp
pushad
mov esi,offset ggdc_read_back_EAD ; copy back data
mov edi,[ebp+8] ; asm data area
mov ecx,11 ; move count
rep movsb ; 11 bytes data move
popad
pop ebp
stdRET _ggdc_read_back
stdENDP _ggdc_read_back
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;:::::::::::::::::: NEC98 GGDC Graphic Draw LINE :::::::::::::::::
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
cPublicProc _ggdc_drawing_line,0
pushad ; save all reg
mov esi,[ggdc_EAD] ; esi = ggdc start address
mov ebp,[ggdc_VRAM] ; ebp = vram start address
mov ebx,[ggdc_DIR] ; ebx = direction next
mov cx ,[ggdc_PTN] ; cx = line pattern
mov dx ,[ggdc_D] ; dx = vectw param D
draw_line_loop:
movzx eax,cx ; line pattern set
and eax,1 ; select logic
ror cx,1 ; next pattern
mov eax,draw_one_pixel[eax*4] ; address set
call eax ; drawing 1 dot
test dx, 2000h ; D >= 0 ? check bit 13
jz short draw_line_pos ; Yes jump!
add dx,[ggdc_D1] ; D = D + D1
movzx eax,bx ; ax = DIR
test al,1 ; DIR LSB = 0 ?
jnz short draw_line_inc ; No! DIR = DIR + 1
jmp short draw_line_dir ; Yes DIR = DIR
draw_line_pos:
add dx,[ggdc_D2] ; D = D + D2
movzx eax,bx ; ax = DIR
test al,1 ; DIR LSB = 0 ?
jnz short draw_line_dir ; No! DIR = DIR
draw_line_inc:
inc ax ; DIR = DIR + 1
and ax,7 ; bound dir 0-->7
draw_line_dir:
mov eax,ggdc_dir_func_pixel[eax*4] ; select dir function
call eax ; next pixel position
dec word ptr[ggdc_DC] ; loop-1
jnz draw_line_loop ; 0 ?? next pixel
call save_ead_dad ; last position save
popad ; restore all reg
stdRET _ggdc_drawing_line
stdENDP _ggdc_drawing_line
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;:::::::::::::::::: NEC98 GGDC Graphic Draw ARC :::::::::::::::::
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
cPublicProc _ggdc_drawing_arc,0
pushad ; save all reg
mov esi,[ggdc_EAD] ; esi = ggdc start address
mov ebp,[ggdc_VRAM] ; ebp = vram start address
mov ebx,[ggdc_DIR] ; bx = direction next
mov cx ,[ggdc_PTN] ; cx = mask pattern
mov dx ,[ggdc_D] ; dx = vectw param D
inc word ptr [ggdc_DM] ; DM = DM + 1
draw_arc_loop:
dec word ptr [ggdc_DM] ; DM = DM - 1
jnz short @f ; DM = 0 ? No! jump
inc word ptr [ggdc_DM]
movzx eax,cx ; ax is PTN
and ax,1 ; pattern set
mov eax,draw_one_pixel[eax*4] ; address set
call eax ; drawing 1 dot
@@:
ror cx,1 ; next pattern
add dx,[ggdc_D1] ; D = D + D1
test dx,2000h ; D >= 0 ?
jz short draw_arc_pos ; Yes! jump
add dx,[ggdc_D2] ; D = D + D2
sub word ptr [ggdc_D2],2 ; D2 = D2 - 2
mov eax,ebx ; ax = DIR
test al,1 ; DIR LSB = 0 ?
jz short draw_arc_inc ; yes !
jmp short draw_arc_dir ; no !
draw_arc_pos:
mov eax,ebx ; ax = DIR
test al,1 ; DIR LSB = 0 ?
jz short draw_arc_dir ; Yes!
draw_arc_inc:
inc ax ; DIR = DIR + 1
and ax,7 ; bound 7
draw_arc_dir:
sub word ptr[ggdc_D1],2 ; D1 = D1 - 2
mov eax,ggdc_dir_func_pixel[eax*4] ; select dir function
call eax ; next position
dec [ggdc_DC] ; loop - 1
jnz draw_arc_loop ; 0 ?? next pixel
call save_ead_dad ; last position save
popad ; restore all reg
stdRET _ggdc_drawing_arc
stdENDP _ggdc_drawing_arc
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;:::::::::::::::::: NEC98 GGDC Graphic Draw RECT :::::::::::::::::
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
cPublicProc _ggdc_drawing_rect,0
pushad
mov esi,[ggdc_EAD] ; esi = ggdc start address
mov ebp,[ggdc_VRAM] ; ebp = vram start address
mov ebx,[ggdc_DIR] ; bx = direction next
mov cx ,[ggdc_PTN] ; cx = mask pattern
mov dx ,[ggdc_D] ; dx = vectw param D
draw_rect_loop:
movzx eax,cx ; ax is PTN
and eax,1 ; set pattern
mov eax,draw_one_pixel[eax*4] ; address set
call eax ; drawing 1 dot
ror cx,1 ; next pattern
movzx ebx,bx ; ax = DIR
mov eax,ggdc_dir_func_pixel[ebx*4] ; select dir function
call eax ; next position
add dx,[ggdc_D1] ; D = D+1
test dx,3fffh ; D=0 ?
jnz draw_rect_loop ; no! next
test word ptr[ggdc_DC],1 ; DC LSB = 0
jnz short @f ; No ! jump
add dx,[ggdc_D2] ; D = D + D2
jmp short draw_rect_dec ;
@@:
add dx,[ggdc_DM] ;
draw_rect_dec:
add bx,2 ; DIR = DIR + 2
and bx,7 ; bound 7
dec [ggdc_DC] ; DC = DC - 1
jnz draw_rect_loop ; if DC!=0 loop
call save_ead_dad ; last position save
popad ; restore all reg
stdRET _ggdc_drawing_rect
stdENDP _ggdc_drawing_rect
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;:::::::::::::::::: NEC98 GGDC Graphic Draw PIXEL :::::::::::::::::::
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
cPublicProc _ggdc_drawing_pixel
pushad
mov esi,[ggdc_EAD] ; esi = ggdc start address
mov ebp,[ggdc_VRAM] ; ebp = vram start address
mov ebx,[ggdc_DIR] ; bx = direction next
mov cx ,[ggdc_PTN] ; cx = line pattern
movzx eax,cx ; set line pattern
and eax, 1 ; pattern ?
mov eax,draw_one_pixel[eax*4] ; select function
call eax ; draw pixel
mov eax,ggdc_dir_func_pixel[ebx*4] ; select dir function
call eax ; next position
call save_ead_dad ; last position save
popad ; restore all reg
stdRET _ggdc_drawing_pixel
stdENDP _ggdc_drawing_pixel
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;:::::::::::::::::: NEC98 GGDC Graphic Draw TEXT :::::::::::::::::::
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
cPublicProc _ggdc_drawing_text,0
pushad
mov esi,[ggdc_EAD] ; esi = ggdc start address
mov ebp,[ggdc_VRAM] ; ebp = vram start address
mov dx, [ggdc_D] ; edx = D
mov ax, [ggdc_ZOOM] ; copy zoom
mov [ZOOM1],ax ; ZW1
xor ebx,ebx ; TXT start data
mov ch,01h ; reset PS
text_2nd_dir_loop:
mov cl,ggdc_TXT[ebx] ; get TXn
inc ebx ; point to next TX
and bl,7 ; bound 7
mov ax,[ggdc_ZOOM] ; eax = zoom
mov [ZOOM2],ax ; ZW2 = ZW + 1
text_2nd_dir_zoom: ; D times (D2 times)
text_1st_dir_loop:
mov al,cl ; copy TXn
test al,ch ; get PS bit
mov eax,0 ; PS bit 1 or 0 ?
jz short @f ; 0 : EAX = 0
inc eax ; 1 : EAX = 1
@@:
mov eax,draw_one_pixel[eax*4] ; select function
call eax ; drawing 1 dot
dec word ptr[ZOOM1] ; ZW1 = ZW1 - 1
jnz short text_1st_zoom_skip ; ZW1 = 0 ? No!
mov ax,[ggdc_ZOOM] ; ax = ZW + 1
mov [ZOOM1],ax ; ZW1 = ZW + 1
add dx,[ggdc_D1] ; D = D + D1
test dx,3fffh ; D = 0 ?
jz short text_1st_dir_loop_exit ; Yes!
rol ch, 1 ; ROL(PS)
test word ptr[ggdc_DM],1 ; if LSB(DM)
jnz short text_1st_zoom_skip ; 1 : ROL(PS)
ror ch, 2 ; 0 : ROR(PS)
text_1st_zoom_skip:
mov eax,[ggdc_DIR] ; get DIR
mov eax,ggdc_dir_func_pixel[eax*4] ; select dir function
call eax ; calculate next dot address
jmp short text_1st_dir_loop ; while D != 0
text_1st_dir_loop_exit:
mov eax,[ggdc_DIR] ; get DIR' = DIR
inc ax ; DIR' = DIR' + 1
test word ptr[ggdc_SL],1 ; SL bit check ?
jnz short @f ; 1 : DIR' = DIR' + 0
inc ax ; 0 : DIR' = DIR' + 1
@@:
test word ptr[ggdc_DM],1 ; if LSB(DM)
jnz short @f ; 1 : DIR' = DIR' + 0
add ax, 4 ; 0 : DIR' = DIR' + 4
@@:
and eax, 7 ; normalize DIR'
mov eax,ggdc_dir_func_pixel[eax*4] ; select dir function
call eax ; calculate next scanline address
add [ggdc_DIR],4 ; DIR = DIR + 4
and [ggdc_DIR],7 ; normalize DIR
mov dx,[ggdc_D2] ;
dec word ptr[ggdc_DM] ; DM = DM - 1
dec word ptr[ZOOM2] ; ZOOM2 - 1
jnz text_2nd_dir_zoom ; ZOOM2 != 0
dec word ptr[ggdc_DC] ; DC = DC - 1
jnz text_2nd_dir_loop ; DC != 0
call save_ead_dad ; last position save
popad ; restore all reg
stdRET _ggdc_drawing_text
stdENDP _ggdc_drawing_text
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;:::::::::::::::::: NEC98 GGDC Graphic Draw WRITE :::::::::::::::::::
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
cPublicProc _ggdc_writing,1
push ebp
mov ebp,esp
pushad
mov ebx,[ebp+8] ; output data address
mov bx,word ptr[ebx] ; output data
mov esi,[ggdc_EAD] ; esi = ggdc start address
mov ebp,[ggdc_VRAM] ; ebp = vram start address
mov edx,[ggdc_DIR] ; dx = direction
test [ggdc_WG],1 ; WG bit on ?
jnz short write_text_mode ; 1: TEXT mode
; 0: GRAPH mode
write_graph_mode:
test bx,1 ; check LSB of output data
jz short @f ;
mov eax,[write_one_word] ;
call eax ; drawing 1 pixel
@@:
mov eax,ggdc_dir_func_pixel[edx*4] ; select dir function
call eax ; calculate next dot address
jmp short write_end ;
write_text_mode:
mov ecx,16 ; change out data
@@: rcr bx,1 ;
rcl ax,1 ; left bit <-> right bit
loop @b ;
mov bx,[ggdc_MASKCPU] ; save mask data
and ax,bx ; mask & out data
mov [ggdc_MASKCPU],ax ; ax = mask data
mov eax,[write_one_word] ;
call eax ; drawing 1 word
mov eax,ggdc_dir_func_word[edx*4] ; select dir function
call eax ; calculate next dot address
mov [ggdc_MASKCPU],bx ; resrtore dAD/MASK
write_end:
call save_ead_dad ; last position save
popad ;
pop ebp ;
stdRET _ggdc_writing
stdENDP _ggdc_writing
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;:::::::::::::::::: NEC98 GGDC Graphic Draw READ :::::::::::::::::::
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
cPublicProc _ggdc_reading,1
push ebp
mov ebp,esp
pushad
mov ebx,[ebp+8] ; return data address
push ebx ; save it
mov esi,[ggdc_EAD] ; esi = ggdc start address
mov ebp,[ggdc_VRAM] ; ebp = vram start address
mov edx,[ggdc_DIR] ; dx = direction
mov edi,esi ; copy ggdc address
and edi,0000ffffH ; recalc NEC98 vram address bound
mov ax,[ebp+edi*2] ; read data
xchg ah,al ; high <-> low
mov ecx, 16
@@: rcr ax, 1 ; reverse bits
rcl bx, 1 ; left to right
loop short @b ; do 16 times
mov [ggdc_READ],bx ; save data
test [ggdc_WG],1 ; WG check
jnz short read_text_mode ; 1: TEXT mode
; 0: GRAPHIC mode
read_graph_mode:
mov eax,ggdc_dir_func_pixel[edx*4] ; select dir function
call eax ; calculate next dot address
jmp short read_end
read_text_mode:
mov eax,ggdc_dir_func_word[edx*4] ; select dir function
call eax ; calculate next dot address
read_end:
mov ax,[ggdc_READ] ; copy back from tmp
pop ebx ; data address
mov word ptr[ebx],ax ; return
call save_ead_dad ; last position save
popad
pop ebp
stdRET _ggdc_reading
stdENDP _ggdc_reading
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::;
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::;
save_ead_dad:
mov eax,esi ; Last Ead address
and eax,0003FFFFH ; bound GGDC memory area
mov [ggdc_read_back_EAD],eax;
mov [ggdc_CSRR_1],al ; return data1
shr eax,8 ;
mov [ggdc_CSRR_2],al ; return data2
shr eax,8 ;
mov [ggdc_CSRR_3],al ; return data3
mov ecx,16 ;
mov dx,[ggdc_MASKCPU] ; GGDC mask data
@@: rcr dx,1 ; reverse right <-> left
rcl ax,1 ;
loop short @b ;
mov [ggdc_read_back_DAD],ax ; use GDC drawing
mov [ggdc_CSRR_4],al ; return data4
mov [ggdc_CSRR_5],ah ; return data5
ret
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::;
; draw_and ;
; input: ;
; esi = ggdc address ;
; ebp = virtual vram start address ;
; destory: ;
; eax,edi,flag ;
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::;
draw_and:
public draw_and
mov ax,[ggdc_MASKCPU] ; set
xchg ah,al ; change High <-> Low
not ax ; not
mov edi,esi ; copy ggdc address
and edi,0000ffffH ; recalc NEC98 vram address bound
and [ebp+edi*2],ax ; draw pixel
ret ; return
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::;
; draw_or ;
; input: ;
; esi = ggdc address ;
; ebp = virtual vram start address ;
; destory: ;
; eax,edi,flag ;
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::;
draw_or:
public draw_or
mov ax,[ggdc_MASKCPU] ; set
xchg ah,al ; change High <-> Low
mov edi,esi ; copy ggdc address
and edi,0000ffffH ; recalc NEC98 vram address bound
or [ebp+edi*2],ax ; draw pixel
ret ; return
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::;
; draw_xor ;
; input: ;
; esi = ggdc address ;
; ebp = virtual vram start address ;
; destory: ;
; eax,edi,flag ;
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::;
draw_xor:
public draw_xor
mov ax,[ggdc_MASKCPU] ; set
xchg ah,al ; change High <-> Low
mov edi,esi ; copy ggdc address
and edi,0000ffffH ; recalc NEC98 vram address bound
xor [ebp+edi*2],ax ; draw pixel
ret ; return
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::;
; draw_mov ;
; input: ;
; esi = ggdc address ;
; ebp = virtual vram start address ;
; destory: ;
; eax,edi,flag ;
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::;
draw_mov:
public draw_mov
mov ax,[ggdc_MASKCPU] ; set
xchg ah,al ; change High <-> Low
mov edi,esi ; copy ggdc address
and edi,0000ffffH ; recalc NEC98 vram address bound
mov [ebp+edi*2],ax ; draw pixel
ret ; return
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::;
; draw_mov ;
; input : none ;
; destory: none ;
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::;
draw_nop:
public draw_nop
ret ; do nothing
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::;
; ggdc_dir_func_pixel ;
; input : none ;
; update : esi ;
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::;
pixel_dir_0:
public pixel_dir_0
add esi,[ggdc_PITCH] ; move down
ret ; return
;-----------------------------------------------------------------------;
pixel_dir_1:
public pixel_dir_1
add esi,[ggdc_PITCH] ; move down
ror word ptr [ggdc_MASKCPU],1 ; move right
adc esi,0 ; over word?
ret ; return
;-----------------------------------------------------------------------;
pixel_dir_2:
public pixel_dir_2
ror word ptr [ggdc_MASKCPU],1 ; move right
adc esi,0 ; over word?
ret ; return
;-----------------------------------------------------------------------;
pixel_dir_3:
public pixel_dir_3
sub esi,[ggdc_PITCH] ; move up
ror word ptr[ggdc_MASKCPU],1 ; move right
adc esi,0 ; over word?
ret ; return
;-----------------------------------------------------------------------;
pixel_dir_4:
public pixel_dir_4
sub esi,[ggdc_PITCH] ; move up
ret ; return
;-----------------------------------------------------------------------;
pixel_dir_5:
public pixel_dir_5
sub esi,[ggdc_PITCH] ; move up
rol word ptr [ggdc_MASKCPU],1 ; move left
sbb esi,0 ; over word?
ret ; return
;-----------------------------------------------------------------------;
pixel_dir_6:
public pixel_dir_6
rol word ptr [ggdc_MASKCPU],1 ; move left
sbb esi,0 ; over word?
ret ; return
;-----------------------------------------------------------------------;
pixel_dir_7:
public pixel_dir_7
add esi,[ggdc_PITCH] ; move down
rol word ptr [ggdc_MASKCPU],1 ; move left
sbb esi,0 ; over word?
ret ; return
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::;
; ggdc_dir_func_short ;
; input : none ;
; destory: esi , dx , flag ;
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::;
word_dir_0:
public word_dir_0
add esi,[ggdc_PITCH] ; move down
ret ; return
;-----------------------------------------------------------------------;
word_dir_1:
public word_dir_1
add esi,[ggdc_PITCH] ; move down
inc esi ; move right
ret ; return
;-----------------------------------------------------------------------;
word_dir_2:
public word_dir_2
inc esi ; move right
ret ; return
;-----------------------------------------------------------------------;
word_dir_3:
public word_dir_3
sub esi,[ggdc_PITCH] ; move up
inc esi ; move right
ret ; return
;-----------------------------------------------------------------------;
word_dir_4:
public word_dir_4
sub esi,[ggdc_PITCH] ; move up
ret ; return
;-----------------------------------------------------------------------;
word_dir_5:
public word_dir_5
sub esi,[ggdc_PITCH] ; move up
dec esi ; move left
ret ; return
;-----------------------------------------------------------------------;
word_dir_6:
public word_dir_6
dec esi ; move left
ret ; return
;-----------------------------------------------------------------------;
word_dir_7:
public word_dir_7
add esi,[ggdc_PITCH] ; move down
dec esi ; move left
ret ; return
_TEXT ENDS
END
;endif
|
metron-analytics/metron-profiler-client/src/main/antlr4/org/apache/metron/profiler/client/window/generated/Window.g4 | JonZeolla/incubator-metron | 631 | 2719 | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
grammar Window;
@header {
//CHECKSTYLE:OFF
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
}
COMMA : ',';
COLON : ':';
WINDOW : 'window' | 'windows';
INCLUDE : 'include' | 'INCLUDE' | 'includes' | 'INCLUDES' | 'including' | 'INCLUDING';
EXCLUDE : 'exclude' | 'EXCLUDE' | 'excludes' | 'EXCLUDES' | 'excluding' | 'EXCLUDING';
FROM : 'FROM' | 'from' | 'STARTING FROM' | 'starting from';
EVERY : 'EVERY' | 'every' | 'FOR EVERY' | 'for every';
TO : 'TO' | 'to' | 'until' | 'UNTIL';
AGO : 'AGO' | 'ago';
NUMBER : FIRST_DIGIT DIGIT*;
IDENTIFIER : [:][a-zA-Z0-9][a-zA-Z0-9_\.\-/]*;
DAY_SPECIFIER : MONDAY | TUESDAY | WEDNESDAY | THURSDAY
| FRIDAY | SATURDAY | SUNDAY
| CURRENT_DAY_OF_WEEK
| WEEKEND | WEEKDAY | HOLIDAYS
| DATE
;
TIME_UNIT : SECOND_UNIT | MINUTE_UNIT | HOUR_UNIT | DAY_UNIT ;
WS : [ \r\t\u000C\n]+ -> skip;
fragment SECOND_UNIT : 'SECOND' | 'second' | 'seconds' | 'SECONDS' | 'second(s)' | 'SECOND(S)';
fragment MINUTE_UNIT : 'MINUTE' | 'minute' | 'minutes' | 'MINUTES' | 'minute(s)' | 'MINUTE(S)';
fragment HOUR_UNIT : 'HOUR' | 'hour' | 'hours' | 'HOURS' | 'hour(s)' | 'HOUR(S)';
fragment DAY_UNIT : 'DAY' | 'day' | 'days' | 'DAYS' | 'day(s)' | 'DAY(S)';
fragment MONDAY : 'MONDAY' | 'monday' | 'MONDAYS' | 'mondays';
fragment TUESDAY : 'TUESDAY' | 'tuesday' | 'TUESDAYS' | 'tuesdays';
fragment WEDNESDAY : 'WEDNESDAY' | 'wednesday' | 'WEDNESDAYS' | 'wednesdays';
fragment THURSDAY : 'THURSDAY' | 'thursday' | 'THURSDAYS' | 'thursdays';
fragment FRIDAY : 'FRIDAY' | 'friday' | 'FRIDAYS' | 'fridays';
fragment SATURDAY: 'SATURDAY' | 'saturday' | 'SATURDAYS' | 'saturdays';
fragment SUNDAY : 'SUNDAY' | 'sunday' | 'SUNDAYS' | 'sundays';
fragment CURRENT_DAY_OF_WEEK: 'this day of week' | 'THIS DAY OF WEEK' | 'this day of the week' | 'THIS DAY OF THE WEEK'
| 'current day of week' | 'CURRENT DAY OF WEEK'
| 'current day of the week' | 'CURRENT DAY OF THE WEEK';
fragment WEEKEND : 'weekend' | 'WEEKEND' | 'weekends' | 'WEEKENDS';
fragment WEEKDAY: 'weekday' | 'WEEKDAY' | 'weekdays' | 'WEEKDAYS';
fragment HOLIDAYS: 'holiday' | 'HOLIDAY' | 'holidays' | 'HOLIDAYS';
fragment DATE: 'date' | 'DATE';
fragment DIGIT : '0'..'9';
fragment FIRST_DIGIT : '1'..'9';
window : window_expression EOF;
window_expression : window_width including_specifier? excluding_specifier? #NonRepeatingWindow
| window_width skip_distance duration including_specifier? excluding_specifier? #RepeatingWindow
| duration #DenseWindow
;
excluding_specifier : EXCLUDE specifier_list
;
including_specifier : INCLUDE specifier_list
;
specifier : day_specifier
| day_specifier specifier_arg_list
;
specifier_arg_list : identifier
| identifier specifier_arg_list
;
day_specifier : DAY_SPECIFIER ;
identifier : NUMBER | IDENTIFIER
;
specifier_list : specifier
| specifier_list COMMA specifier
;
duration : FROM time_interval AGO? TO time_interval AGO? #FromToDuration
| FROM time_interval AGO? #FromDuration
;
skip_distance : EVERY time_interval #SkipDistance
;
window_width : time_interval WINDOW? #WindowWidth
;
time_interval : time_amount time_unit #TimeInterval
;
time_amount : NUMBER #TimeAmount
;
time_unit : TIME_UNIT #TimeUnit
;
|
programs/oeis/103/A103455.asm | karttu/loda | 1 | 176062 | ; A103455: a(n) = 0^n + 5^n - 1.
; 1,4,24,124,624,3124,15624,78124,390624,1953124,9765624,48828124,244140624,1220703124,6103515624,30517578124,152587890624,762939453124,3814697265624,19073486328124,95367431640624,476837158203124,2384185791015624
mov $1,5
pow $1,$0
trn $1,2
add $1,1
|
ASSEMBLY-EMU8086/ADDITION.asm | ar-pavel/Code-Library | 0 | 161760 |
INCLUDE 'EMU8086.INC'
.MODEL SMALL
.STACK 100H
.DATA
;VAR/DATA
.CODE
MAIN PROC
INPUT:
PRINT "INPUT THE FIRST NUMBER : "
MOV AH,1
INT 21H
MOV BL,AL
MOV AH,2
; PRINT LINE BREAK AND CARRIAGE RETURN
MOV DL,0DH
INT 21H
MOV DL,0AH
INT 21H
PRINT "INPUT THE SECOND NUMBER : "
MOV AH,1
INT 21H
MOV CL,AL
;PRINT LINE BREAK AND CARRIAGE RETURN
MOV AH,2
MOV DL,0AH
INT 21H
MOV DL,0DH
INT 21H
PRINT:
PRINT "THE SUM IS : "
SUB BL,48
SUB CL,48
ADD CL,BL
ADD CL,48
MOV DL,CL
MOV AH,2
INT 21H
FINISH:
MOV AH,4CH
INT 21H
ENDP MAIN
END MAIN
|
programs/oeis/274/A274139.asm | neoneye/loda | 22 | 164898 | ; A274139: a(n) = 2^A000265(n) = 2^numerator(n/2^n), a sequence related to Oresme numbers.
; 2,2,8,2,32,8,128,2,512,32,2048,8,8192,128,32768,2,131072,512,524288,32,2097152,2048,8388608,8,33554432,8192,134217728,128,536870912,32768,2147483648,2,8589934592,131072,34359738368,512,137438953472,524288,549755813888,32
mov $1,2
lpb $0
sub $0,1
mul $0,2
dif $0,4
lpe
pow $1,$0
mul $1,2
mov $0,$1
|
lab3_test_harness/test/state_data_in/comp.asm | Zaydax/PipelineProcessor | 2 | 15502 | <reponame>Zaydax/PipelineProcessor
.ORIG x3000
LEA R0, DATA1
LDW R2, R0, #0
COUNT LDW R1, R0, #0
XOR R3 ,R1, R2
BRZ ERROR
ADD R0, R0, x-1
LSHF R2, R2, #1
ADD R2, R2, #1
BRP COUNT
BRNZP DONE
ERROR LEA R5, DATA17
LDW R6, R5,#0
DONE HALT
DATA1 .FILL x1
DATA2 .FILL x3
DATA3 .FILL x7
DATA4 .FILL xf
DATA5 .FILL xf1
DATA6 .FILL xf3
DATA7 .FILL xf7
DATA8 .FILL xff
DATA9 .FILL xff1
DATA10 .FILL xff3
DATA11 .FILL xff7
DATA12 .FILL xfff
DATA13 .FILL xfff1
DATA14 .FILL xfff3
DATA15 .FILL xfff7
DATA16 .FILL xffff
DATA17 .FILL xaaaa
.END |
src/shared/generic/lsc-internal-sha512.ads | Componolit/libsparkcrypto | 30 | 27489 | <filename>src/shared/generic/lsc-internal-sha512.ads
-------------------------------------------------------------------------------
-- This file is part of libsparkcrypto.
--
-- Copyright (C) 2010, <NAME>
-- Copyright (C) 2010, secunet Security Networks AG
-- 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 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.
-------------------------------------------------------------------------------
with LSC.Internal.Types;
use type LSC.Internal.Types.Index;
use type LSC.Internal.Types.Word64;
-------------------------------------------------------------------------------
-- The SHA-512 and SHA-386 hash algorithms
--
-- <ul>
-- <li>
-- <a href="http://csrc.nist.gov/publications/fips/fips180-3/fips180-3_final.pdf">
-- FIPS PUB 180-3, Secure Hash Standard (SHS), National Institute of
-- Standards and Technology, U.S. Department of Commerce, October 2008. </a>
-- </li>
-- </ul>
-------------------------------------------------------------------------------
package LSC.Internal.SHA512 is
pragma Pure;
-- SHA-512 context
type Context_Type is private;
-- Index for SHA-512 block
subtype Block_Index is Types.Index range 0 .. 15;
-- SHA-512 block
subtype Block_Type is Types.Word64_Array_Type (Block_Index);
-- SHA-512 block size
Block_Size : constant := 1024;
-- Index for SHA-512 hash
subtype SHA512_Hash_Index is Types.Index range 0 .. 7;
-- SHA-512 hash
subtype SHA512_Hash_Type is Types.Word64_Array_Type (SHA512_Hash_Index);
-- Index for SHA-384 hash
subtype SHA384_Hash_Index is Types.Index range 0 .. 5;
-- SHA-384 hash
subtype SHA384_Hash_Type is Types.Word64_Array_Type (SHA384_Hash_Index);
-- SHA-512 block length
subtype Block_Length_Type is Types.Word64 range 0 .. Block_Size - 1;
-- Index for SHA-512 message
--
-- A SHA-512 hash can be at most 2^128 bit long. As one block has 1024 bit,
-- this makes 2^118 blocks. <strong> NOTE: We support a size of 2^64 only!
-- (i.e. 2^54 blocks)
-- </strong>
type Message_Index is range 0 .. 2 ** 54 - 1;
-- SHA-512 message
type Message_Type is array (Message_Index range <>) of Block_Type;
-- Initialize SHA-512 context.
function SHA512_Context_Init return Context_Type;
-- Initialize SHA-384 context.
function SHA384_Context_Init return Context_Type;
-- Update SHA-512 @Context@ context with message block @Block@.
procedure Context_Update
(Context : in out Context_Type;
Block : in Block_Type)
with Depends => (Context =>+ Block);
pragma Inline (Context_Update);
-- Finalize SHA-512 context @Context@ using @Length@ bits of final message
-- block @Block@.
--
procedure Context_Finalize
(Context : in out Context_Type;
Block : in Block_Type;
Length : in Block_Length_Type)
with Depends => (Context =>+ (Block, Length));
-- Return SHA-512 hash.
function SHA512_Get_Hash (Context : Context_Type) return SHA512_Hash_Type;
-- Return SHA-384 hash.
function SHA384_Get_Hash (Context : Context_Type) return SHA384_Hash_Type;
procedure Hash_Context
(Message : in Message_Type;
Length : in Message_Index;
Ctx : in out Context_Type)
with
Depends => (Ctx =>+ (Message, Length)),
Pre =>
Message'First <= Message'Last and
Length / Block_Size +
(if Length mod Block_Size = 0 then 0 else 1) <= Message'Length;
-- Compute SHA-512 hash value of @Length@ bits of @Message@.
function SHA512_Hash
(Message : Message_Type;
Length : Message_Index) return SHA512_Hash_Type
with
Pre =>
Message'First <= Message'Last and
Length / Block_Size +
(if Length mod Block_Size = 0 then 0 else 1) <= Message'Length;
-- Compute SHA-384 hash value of @Length@ bits of @Message@.
function SHA384_Hash
(Message : Message_Type;
Length : Message_Index) return SHA384_Hash_Type
with
Pre =>
Message'First <= Message'Last and
Length / Block_Size +
(if Length mod Block_Size = 0 then 0 else 1) <= Message'Length;
-- Empty block
Null_Block : constant Block_Type;
-- Empty SHA-384 hash
Null_SHA384_Hash : constant SHA384_Hash_Type;
-- Empty SHA-512 hash
Null_SHA512_Hash : constant SHA512_Hash_Type;
private
type Data_Length is record
LSW : Types.Word64;
MSW : Types.Word64;
end record;
subtype Schedule_Index is Types.Index range 0 .. 79;
subtype Schedule_Type is Types.Word64_Array_Type (Schedule_Index);
Null_Schedule : constant Schedule_Type := Schedule_Type'(Schedule_Index => 0);
type Context_Type is record
Length : Data_Length;
H : SHA512_Hash_Type;
W : Schedule_Type;
end record;
Null_Block : constant Block_Type :=
Block_Type'(Block_Index => 0);
Null_SHA384_Hash : constant SHA384_Hash_Type :=
SHA384_Hash_Type'(SHA384_Hash_Index => 0);
Null_SHA512_Hash : constant SHA512_Hash_Type :=
SHA512_Hash_Type'(SHA512_Hash_Index => 0);
end LSC.Internal.SHA512;
|
002-re-cmd-modify/patch1.asm | gynvael/stream | 152 | 178548 | [bits 64]
[org 0x014000B93E]
jmp 0x140059000
|
src/Categories/Adjoint/Construction/EilenbergMoore.agda | MirceaS/agda-categories | 0 | 180 | <reponame>MirceaS/agda-categories<filename>src/Categories/Adjoint/Construction/EilenbergMoore.agda
{-# OPTIONS --without-K --safe #-}
open import Categories.Category
open import Categories.Monad
module Categories.Adjoint.Construction.EilenbergMoore {o ℓ e} {C : Category o ℓ e} (M : Monad C) where
open import Categories.Category.Construction.EilenbergMoore M
open import Categories.Adjoint
open import Categories.Functor
open import Categories.Functor.Properties
open import Categories.NaturalTransformation
open import Categories.NaturalTransformation.NaturalIsomorphism using (_≃_)
open import Categories.Morphism.Reasoning C
private
module C = Category C
module M = Monad M
open M.F
open C
open HomReasoning
Forgetful : Functor EilenbergMoore C
Forgetful = record
{ F₀ = λ X → Module.A X
; F₁ = λ f → Module⇒.arr f
; identity = refl
; homomorphism = refl
; F-resp-≈ = λ eq → eq
}
Free : Functor C EilenbergMoore
Free = record
{ F₀ = λ A → record
{ A = F₀ A
; action = M.μ.η A
; commute = M.assoc
; identity = M.identityʳ
}
; F₁ = λ f → record
{ arr = F₁ f
; commute = ⟺ (M.μ.commute f)
}
; identity = identity
; homomorphism = homomorphism
; F-resp-≈ = F-resp-≈
}
FF≃F : Forgetful ∘F Free ≃ M.F
FF≃F = record
{ F⇒G = record
{ η = λ X → F₁ C.id
; commute = λ f → [ M.F ]-resp-square id-comm-sym
; sym-commute = λ f → [ M.F ]-resp-square id-comm
}
; F⇐G = record
{ η = λ X → F₁ C.id
; commute = λ f → [ M.F ]-resp-square id-comm-sym
; sym-commute = λ f → [ M.F ]-resp-square id-comm
}
; iso = λ X → record
{ isoˡ = elimˡ identity ○ identity
; isoʳ = elimˡ identity ○ identity
}
}
Free⊣Forgetful : Free ⊣ Forgetful
Free⊣Forgetful = record
{ unit = record
{ η = M.η.η
; commute = M.η.commute
; sym-commute = M.η.sym-commute
}
; counit = record
{ η = λ X →
let module X = Module X
in record
{ arr = X.action
; commute = ⟺ X.commute
}
; commute = λ f → ⟺ (Module⇒.commute f)
; sym-commute = Module⇒.commute
}
; zig = M.identityˡ
; zag = λ {B} → Module.identity B
}
|
mat/src/mat-formats.adb | stcarrez/mat | 7 | 1867 | -----------------------------------------------------------------------
-- mat-formats - Format various types for the console or GUI interface
-- Copyright (C) 2015, 2021 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Strings;
package body MAT.Formats is
use type MAT.Types.Target_Tick_Ref;
Hex_Prefix : constant Boolean := True;
Hex_Length : Positive := 16;
Conversion : constant String (1 .. 10) := "0123456789";
function Location (File : in Ada.Strings.Unbounded.Unbounded_String) return String;
-- Format a short description of a malloc event.
function Event_Malloc (Item : in MAT.Events.Target_Event_Type;
Related : in MAT.Events.Tools.Target_Event_Vector;
Start_Time : in MAT.Types.Target_Tick_Ref) return String;
-- Format a short description of a realloc event.
function Event_Realloc (Item : in MAT.Events.Target_Event_Type;
Related : in MAT.Events.Tools.Target_Event_Vector;
Start_Time : in MAT.Types.Target_Tick_Ref) return String;
-- Format a short description of a free event.
function Event_Free (Item : in MAT.Events.Target_Event_Type;
Related : in MAT.Events.Tools.Target_Event_Vector;
Start_Time : in MAT.Types.Target_Tick_Ref) return String;
-- ------------------------------
-- Set the size of a target address to format them.
-- ------------------------------
procedure Set_Address_Size (Size : in Positive) is
begin
Hex_Length := Size;
end Set_Address_Size;
-- ------------------------------
-- Format the PID into a string.
-- ------------------------------
function Pid (Value : in MAT.Types.Target_Process_Ref) return String is
begin
return Util.Strings.Image (Natural (Value));
end Pid;
-- ------------------------------
-- Format the address into a string.
-- ------------------------------
function Addr (Value : in MAT.Types.Target_Addr) return String is
Hex : constant String := MAT.Types.Hex_Image (Value, Hex_Length);
begin
if Hex_Prefix then
return "0x" & Hex;
else
return Hex;
end if;
end Addr;
-- ------------------------------
-- Format the size into a string.
-- ------------------------------
function Size (Value : in MAT.Types.Target_Size) return String is
Result : constant String := MAT.Types.Target_Size'Image (Value);
begin
if Result (Result'First) = ' ' then
return Result (Result'First + 1 .. Result'Last);
else
return Result;
end if;
end Size;
-- ------------------------------
-- Format the memory growth size into a string.
-- ------------------------------
function Size (Alloced : in MAT.Types.Target_Size;
Freed : in MAT.Types.Target_Size) return String is
use type MAT.Types.Target_Size;
begin
if Alloced > Freed then
return "+" & Size (Alloced - Freed);
elsif Alloced < Freed then
return "-" & Size (Freed - Alloced);
else
return "=" & Size (Alloced);
end if;
end Size;
-- ------------------------------
-- Format the time relative to the start time.
-- ------------------------------
function Time (Value : in MAT.Types.Target_Tick_Ref;
Start : in MAT.Types.Target_Tick_Ref) return String is
T : constant MAT.Types.Target_Tick_Ref := Value - Start;
Sec : constant MAT.Types.Target_Tick_Ref := T / 1_000_000;
Usec : constant MAT.Types.Target_Tick_Ref := T mod 1_000_000;
Msec : Natural := Natural (Usec / 1_000);
Frac : String (1 .. 5);
begin
Frac (5) := 's';
Frac (4) := Conversion (Msec mod 10 + 1);
Msec := Msec / 10;
Frac (3) := Conversion (Msec mod 10 + 1);
Msec := Msec / 10;
Frac (2) := Conversion (Msec mod 10 + 1);
Frac (1) := '.';
return MAT.Types.Target_Tick_Ref'Image (Sec) & Frac;
end Time;
-- ------------------------------
-- Format the duration in seconds, milliseconds or microseconds.
-- ------------------------------
function Duration (Value : in MAT.Types.Target_Tick_Ref) return String is
Sec : constant MAT.Types.Target_Tick_Ref := Value / 1_000_000;
Usec : constant MAT.Types.Target_Tick_Ref := Value mod 1_000_000;
Msec : constant Natural := Natural (Usec / 1_000);
Val : Natural;
Frac : String (1 .. 5);
begin
if Sec = 0 and Msec = 0 then
return Util.Strings.Image (Integer (Usec)) & "us";
elsif Sec = 0 then
Val := Natural (Usec mod 1_000);
Frac (5) := 's';
Frac (4) := 'm';
Frac (3) := Conversion (Val mod 10 + 1);
Val := Val / 10;
Frac (3) := Conversion (Val mod 10 + 1);
Val := Val / 10;
Frac (2) := Conversion (Val mod 10 + 1);
Frac (1) := '.';
return Util.Strings.Image (Integer (Msec)) & Frac;
else
Val := Msec;
Frac (4) := 's';
Frac (3) := Conversion (Val mod 10 + 1);
Val := Val / 10;
Frac (3) := Conversion (Val mod 10 + 1);
Val := Val / 10;
Frac (2) := Conversion (Val mod 10 + 1);
Frac (1) := '.';
return Util.Strings.Image (Integer (Sec)) & Frac (1 .. 4);
end if;
end Duration;
function Location (File : in Ada.Strings.Unbounded.Unbounded_String) return String is
Pos : constant Natural := Ada.Strings.Unbounded.Index (File, "/", Ada.Strings.Backward);
Len : constant Natural := Ada.Strings.Unbounded.Length (File);
begin
if Pos /= 0 then
return Ada.Strings.Unbounded.Slice (File, Pos + 1, Len);
else
return Ada.Strings.Unbounded.To_String (File);
end if;
end Location;
-- ------------------------------
-- Format a file, line, function information into a string.
-- ------------------------------
function Location (File : in Ada.Strings.Unbounded.Unbounded_String;
Line : in Natural;
Func : in Ada.Strings.Unbounded.Unbounded_String) return String is
begin
if Ada.Strings.Unbounded.Length (File) = 0 then
return Ada.Strings.Unbounded.To_String (Func);
elsif Line > 0 then
declare
Num : constant String := Natural'Image (Line);
begin
return Ada.Strings.Unbounded.To_String (Func) & " ("
& Location (File) & ":" & Num (Num'First + 1 .. Num'Last) & ")";
end;
else
return Ada.Strings.Unbounded.To_String (Func) & " (" & Location (File) & ")";
end if;
end Location;
-- ------------------------------
-- Format an event range description.
-- ------------------------------
function Event (First : in MAT.Events.Target_Event_Type;
Last : in MAT.Events.Target_Event_Type) return String is
use type MAT.Events.Event_Id_Type;
Id1 : constant String := MAT.Events.Event_Id_Type'Image (First.Id);
Id2 : constant String := MAT.Events.Event_Id_Type'Image (Last.Id);
begin
if First.Id = Last.Id then
return Id1 (Id1'First + 1 .. Id1'Last);
else
return Id1 (Id1'First + 1 .. Id1'Last) & ".." & Id2 (Id2'First + 1 .. Id2'Last);
end if;
end Event;
-- ------------------------------
-- Format a short description of the event.
-- ------------------------------
function Event (Item : in MAT.Events.Target_Event_Type;
Mode : in Format_Type := NORMAL) return String is
use type MAT.Types.Target_Addr;
begin
case Item.Index is
when MAT.Events.MSG_MALLOC =>
if Mode = BRIEF then
return "malloc";
else
return "malloc(" & Size (Item.Size) & ") = " & Addr (Item.Addr);
end if;
when MAT.Events.MSG_REALLOC =>
if Mode = BRIEF then
if Item.Old_Addr = 0 then
return "realloc";
else
return "realloc";
end if;
else
if Item.Old_Addr = 0 then
return "realloc(0," & Size (Item.Size) & ") = "
& Addr (Item.Addr);
else
return "realloc(" & Addr (Item.Old_Addr) & "," & Size (Item.Size) & ") = "
& Addr (Item.Addr);
end if;
end if;
when MAT.Events.MSG_FREE =>
if Mode = BRIEF then
return "free";
else
return "free(" & Addr (Item.Addr) & "), " & Size (Item.Size);
end if;
when MAT.Events.MSG_BEGIN =>
return "begin";
when MAT.Events.MSG_END =>
return "end";
when MAT.Events.MSG_LIBRARY =>
return "library";
end case;
end Event;
-- ------------------------------
-- Format a short description of a malloc event.
-- ------------------------------
function Event_Malloc (Item : in MAT.Events.Target_Event_Type;
Related : in MAT.Events.Tools.Target_Event_Vector;
Start_Time : in MAT.Types.Target_Tick_Ref) return String is
Free_Event : MAT.Events.Target_Event_Type;
Slot_Addr : constant String := Addr (Item.Addr);
begin
Free_Event := MAT.Events.Tools.Find (Related, MAT.Events.MSG_FREE);
return Size (Item.Size) & " bytes allocated at "
& Slot_Addr
& " after " & Duration (Item.Time - Start_Time)
& ", freed " & Duration (Free_Event.Time - Item.Time)
& " after by event" & MAT.Events.Event_Id_Type'Image (Free_Event.Id)
;
exception
when MAT.Events.Tools.Not_Found =>
return Size (Item.Size) & " bytes allocated at " & Slot_Addr & " (never freed)";
end Event_Malloc;
-- ------------------------------
-- Format a short description of a realloc event.
-- ------------------------------
function Event_Realloc (Item : in MAT.Events.Target_Event_Type;
Related : in MAT.Events.Tools.Target_Event_Vector;
Start_Time : in MAT.Types.Target_Tick_Ref) return String is
use type MAT.Events.Event_Id_Type;
Free_Event : MAT.Events.Target_Event_Type;
Slot_Addr : constant String := Addr (Item.Addr);
begin
if Item.Next_Id = 0 and Item.Prev_Id = 0 then
return Size (Item.Size) & " bytes reallocated at " & Slot_Addr
& " after " & Duration (Item.Time - Start_Time)
& " (never freed)";
end if;
Free_Event := MAT.Events.Tools.Find (Related, MAT.Events.MSG_FREE);
return Size (Item.Size) & " bytes reallocated at " & Slot_Addr
& " after " & Duration (Item.Time - Start_Time)
& ", freed " & Duration (Free_Event.Time - Item.Time)
& " after by event" & MAT.Events.Event_Id_Type'Image (Free_Event.Id)
& " " & Size (Item.Size, Item.Old_Size) & " bytes";
exception
when MAT.Events.Tools.Not_Found =>
return Size (Item.Size) & " bytes reallocated at " & Slot_Addr
& " after " & Duration (Item.Time - Start_Time)
& " (never freed) " & Size (Item.Size, Item.Old_Size) & " bytes";
end Event_Realloc;
-- ------------------------------
-- Format a short description of a free event.
-- ------------------------------
function Event_Free (Item : in MAT.Events.Target_Event_Type;
Related : in MAT.Events.Tools.Target_Event_Vector;
Start_Time : in MAT.Types.Target_Tick_Ref) return String is
Alloc_Event : MAT.Events.Target_Event_Type;
Slot_Addr : constant String := Addr (Item.Addr);
begin
Alloc_Event := MAT.Events.Tools.Find (Related, MAT.Events.MSG_MALLOC);
return Size (Alloc_Event.Size) & " bytes freed at " & Slot_Addr
& " after " & Duration (Item.Time - Start_Time)
& ", alloc'ed for " & Duration (Item.Time - Alloc_Event.Time)
& " by event" & MAT.Events.Event_Id_Type'Image (Alloc_Event.Id);
exception
when MAT.Events.Tools.Not_Found =>
return Size (Item.Size) & " bytes freed at " & Slot_Addr;
end Event_Free;
-- ------------------------------
-- Format a short description of the event.
-- ------------------------------
function Event (Item : in MAT.Events.Target_Event_Type;
Related : in MAT.Events.Tools.Target_Event_Vector;
Start_Time : in MAT.Types.Target_Tick_Ref) return String is
begin
case Item.Index is
when MAT.Events.MSG_MALLOC =>
return Event_Malloc (Item, Related, Start_Time);
when MAT.Events.MSG_REALLOC =>
return Event_Realloc (Item, Related, Start_Time);
when MAT.Events.MSG_FREE =>
return Event_Free (Item, Related, Start_Time);
when MAT.Events.MSG_BEGIN =>
return "Begin event";
when MAT.Events.MSG_END =>
return "End event";
when MAT.Events.MSG_LIBRARY =>
return "Library information event";
end case;
end Event;
-- ------------------------------
-- Format the difference between two event IDs (offset).
-- ------------------------------
function Offset (First : in MAT.Events.Event_Id_Type;
Second : in MAT.Events.Event_Id_Type) return String is
use type MAT.Events.Event_Id_Type;
begin
if First = Second or First = 0 or Second = 0 then
return "";
elsif First > Second then
return "+" & Util.Strings.Image (Natural (First - Second));
else
return "-" & Util.Strings.Image (Natural (Second - First));
end if;
end Offset;
-- ------------------------------
-- Format a short description of the memory allocation slot.
-- ------------------------------
function Slot (Value : in MAT.Types.Target_Addr;
Item : in MAT.Memory.Allocation;
Start_Time : in MAT.Types.Target_Tick_Ref) return String is
begin
return Addr (Value) & " is " & Size (Item.Size)
& " bytes allocated after " & Duration (Item.Time - Start_Time)
& " by event" & MAT.Events.Event_Id_Type'Image (Item.Event);
end Slot;
end MAT.Formats;
|
programs/oeis/013/A013721.asm | neoneye/loda | 22 | 94842 | ; A013721: a(n) = 16^(2*n + 1).
; 16,4096,1048576,268435456,68719476736,17592186044416,4503599627370496,1152921504606846976,295147905179352825856,75557863725914323419136,19342813113834066795298816,4951760157141521099596496896,1267650600228229401496703205376,324518553658426726783156020576256,83076749736557242056487941267521536
mov $1,256
pow $1,$0
mul $1,16
mov $0,$1
|
programs/oeis/021/A021179.asm | neoneye/loda | 22 | 162896 | <filename>programs/oeis/021/A021179.asm
; A021179: Decimal expansion of 1/175.
; 0,0,5,7,1,4,2,8,5,7,1,4,2,8,5,7,1,4,2,8,5,7,1,4,2,8,5,7,1,4,2,8,5,7,1,4,2,8,5,7,1,4,2,8,5,7,1,4,2,8,5,7,1,4,2,8,5,7,1,4,2,8,5,7,1,4,2,8,5,7,1,4,2,8,5,7,1,4,2,8,5,7,1,4,2,8,5,7,1,4,2,8,5,7,1,4,2,8,5
mov $1,1
mov $2,$0
mov $3,2
lpb $3
mov $0,$2
sub $3,1
add $0,$3
sub $0,2
lpb $0
sub $0,1
lpb $1
mod $1,7
lpe
mul $1,3
mov $2,4
lpe
lpe
sub $1,1
mod $1,10
mov $0,$1
|
src/Delay-monad/Quantitative-weak-bisimilarity.agda | nad/delay-monad | 0 | 13980 | ------------------------------------------------------------------------
-- A variant of weak bisimilarity that can be used to relate the
-- number of steps in two computations
------------------------------------------------------------------------
{-# OPTIONS --sized-types #-}
open import Prelude hiding (_+_; _*_)
module Delay-monad.Quantitative-weak-bisimilarity {a} {A : Type a} where
open import Equality.Propositional
open import Logical-equivalence using (_⇔_)
open import Prelude.Size
open import Conat equality-with-J as Conat
using (Conat; zero; suc; force; ⌜_⌝; _+_; _*_;
[_]_≤_; step-≤; step-∼≤; _∎≤; step-∼; _∎∼)
open import Function-universe equality-with-J as F hiding (id; _∘_)
open import Delay-monad
open import Delay-monad.Bisimilarity as B
using (now; later; laterˡ; laterʳ; force)
------------------------------------------------------------------------
-- The relation
mutual
-- Quantitative weak bisimilarity. [ ∞ ∣ mˡ ∣ mʳ ∣ nˡ ∣ nʳ ] x ≈ y
-- is a variant of x B.≈ y for which the number of later
-- constructors in x is bounded by nˡ plus 1 + mˡ times the number
-- of later constructors in y, and the number of later constructors
-- in y is bounded by nʳ plus 1 + mʳ times the number of later
-- constructors in x (see ≈⇔≈×steps≤steps² below).
infix 4 [_∣_∣_∣_∣_]_≈_ [_∣_∣_∣_∣_]_≈′_
data [_∣_∣_∣_∣_]_≈_
(i : Size) (mˡ mʳ : Conat ∞) :
Conat ∞ → Conat ∞ → Delay A ∞ → Delay A ∞ → Type a where
now : ∀ {x nˡ nʳ} → [ i ∣ mˡ ∣ mʳ ∣ nˡ ∣ nʳ ] now x ≈ now x
later : ∀ {x y nˡ nʳ} →
[ i ∣ mˡ ∣ mʳ ∣ nˡ + mˡ ∣ nʳ + mʳ ] x .force ≈′ y .force →
[ i ∣ mˡ ∣ mʳ ∣ nˡ ∣ nʳ ] later x ≈ later y
laterˡ : ∀ {x y nˡ nʳ} →
[ i ∣ mˡ ∣ mʳ ∣ nˡ .force ∣ nʳ ] x .force ≈ y →
[ i ∣ mˡ ∣ mʳ ∣ suc nˡ ∣ nʳ ] later x ≈ y
laterʳ : ∀ {x y nˡ nʳ} →
[ i ∣ mˡ ∣ mʳ ∣ nˡ ∣ nʳ .force ] x ≈ y .force →
[ i ∣ mˡ ∣ mʳ ∣ nˡ ∣ suc nʳ ] x ≈ later y
record [_∣_∣_∣_∣_]_≈′_
(i : Size) (mˡ mʳ nˡ nʳ : Conat ∞)
(x y : Delay A ∞) : Type a where
coinductive
field
force : {j : Size< i} → [ j ∣ mˡ ∣ mʳ ∣ nˡ ∣ nʳ ] x ≈ y
open [_∣_∣_∣_∣_]_≈′_ public
-- Specialised variants of [_∣_∣_∣_∣_]_≈_ and [_∣_∣_∣_∣_]_≈′_.
infix 4 [_∣_∣_]_≈_ [_∣_∣_]_≈′_
[_∣_∣_]_≈_ : Size → Conat ∞ → Conat ∞ → Delay A ∞ → Delay A ∞ → Type a
[ i ∣ mˡ ∣ mʳ ] x ≈ y = [ i ∣ mˡ ∣ mʳ ∣ zero ∣ zero ] x ≈ y
[_∣_∣_]_≈′_ : Size → Conat ∞ → Conat ∞ → Delay A ∞ → Delay A ∞ → Type a
[ i ∣ mˡ ∣ mʳ ] x ≈′ y = [ i ∣ mˡ ∣ mʳ ∣ zero ∣ zero ] x ≈′ y
-- Quantitative expansion.
infix 4 [_∣_∣_]_≳_ [_∣_∣_]_≳′_ [_∣_]_≳_ [_∣_]_≳′_
[_∣_∣_]_≳_ : Size → Conat ∞ → Conat ∞ → Delay A ∞ → Delay A ∞ → Type a
[ i ∣ m ∣ n ] x ≳ y = [ i ∣ m ∣ zero ∣ n ∣ zero ] x ≈ y
[_∣_∣_]_≳′_ : Size → Conat ∞ → Conat ∞ → Delay A ∞ → Delay A ∞ → Type a
[ i ∣ m ∣ n ] x ≳′ y = [ i ∣ m ∣ zero ∣ n ∣ zero ] x ≈′ y
[_∣_]_≳_ : Size → Conat ∞ → Delay A ∞ → Delay A ∞ → Type a
[ i ∣ m ] x ≳ y = [ i ∣ m ∣ zero ] x ≳ y
[_∣_]_≳′_ : Size → Conat ∞ → Delay A ∞ → Delay A ∞ → Type a
[ i ∣ m ] x ≳′ y = [ i ∣ m ∣ zero ] x ≳′ y
-- The converse of quantitative expansion.
infix 4 [_∣_∣_]_≲_ [_∣_∣_]_≲′_ [_∣_]_≲_ [_∣_]_≲′_
[_∣_∣_]_≲_ : Size → Conat ∞ → Conat ∞ → Delay A ∞ → Delay A ∞ → Type a
[ i ∣ m ∣ n ] x ≲ y = [ i ∣ m ∣ n ] y ≳ x
[_∣_∣_]_≲′_ : Size → Conat ∞ → Conat ∞ → Delay A ∞ → Delay A ∞ → Type a
[ i ∣ m ∣ n ] x ≲′ y = [ i ∣ m ∣ n ] y ≳′ x
[_∣_]_≲_ : Size → Conat ∞ → Delay A ∞ → Delay A ∞ → Type a
[ i ∣ m ] x ≲ y = [ i ∣ m ] y ≳ x
[_∣_]_≲′_ : Size → Conat ∞ → Delay A ∞ → Delay A ∞ → Type a
[ i ∣ m ] x ≲′ y = [ i ∣ m ] y ≳′ x
------------------------------------------------------------------------
-- Conversions
-- Weakening.
weaken :
∀ {i mˡ mˡ′ mʳ mʳ′ nˡ nˡ′ nʳ nʳ′ x y} →
[ ∞ ] mˡ ≤ mˡ′ → [ ∞ ] mʳ ≤ mʳ′ →
[ ∞ ] nˡ ≤ nˡ′ → [ ∞ ] nʳ ≤ nʳ′ →
[ i ∣ mˡ ∣ mʳ ∣ nˡ ∣ nʳ ] x ≈ y →
[ i ∣ mˡ′ ∣ mʳ′ ∣ nˡ′ ∣ nʳ′ ] x ≈ y
weaken pˡ pʳ = λ where
qˡ qʳ now → now
(suc qˡ) qʳ (laterˡ r) → laterˡ (weaken pˡ pʳ (qˡ .force) qʳ r)
qˡ (suc qʳ) (laterʳ r) → laterʳ (weaken pˡ pʳ qˡ (qʳ .force) r)
qˡ qʳ (later r) → later λ { .force →
weaken pˡ pʳ
(qˡ Conat.+-mono pˡ)
(qʳ Conat.+-mono pʳ)
(r .force) }
weakenˡʳ :
∀ {i mˡ mʳ nˡ nˡ′ nʳ nʳ′ x y} →
[ ∞ ] nˡ ≤ nˡ′ → [ ∞ ] nʳ ≤ nʳ′ →
[ i ∣ mˡ ∣ mʳ ∣ nˡ ∣ nʳ ] x ≈ y →
[ i ∣ mˡ ∣ mʳ ∣ nˡ′ ∣ nʳ′ ] x ≈ y
weakenˡʳ = weaken (_ ∎≤) (_ ∎≤)
weakenˡ :
∀ {i mˡ mʳ nˡ nˡ′ nʳ x y} →
[ ∞ ] nˡ ≤ nˡ′ →
[ i ∣ mˡ ∣ mʳ ∣ nˡ ∣ nʳ ] x ≈ y →
[ i ∣ mˡ ∣ mʳ ∣ nˡ′ ∣ nʳ ] x ≈ y
weakenˡ p = weakenˡʳ p (_ ∎≤)
weakenʳ :
∀ {i mˡ mʳ nˡ nʳ nʳ′ x y} →
[ ∞ ] nʳ ≤ nʳ′ →
[ i ∣ mˡ ∣ mʳ ∣ nˡ ∣ nʳ ] x ≈ y →
[ i ∣ mˡ ∣ mʳ ∣ nˡ ∣ nʳ′ ] x ≈ y
weakenʳ p = weakenˡʳ (_ ∎≤) p
-- Strong bisimilarity is contained in quantitative weak bisimilarity.
∼→≈ : ∀ {i mˡ mʳ nˡ nʳ x y} →
B.[ i ] x ∼ y → [ i ∣ mˡ ∣ mʳ ∣ nˡ ∣ nʳ ] x ≈ y
∼→≈ now = now
∼→≈ (later p) = later λ { .force → ∼→≈ (p .force) }
-- Quantitative expansion is contained in expansion.
≳→≳ : ∀ {i m n x y} →
[ i ∣ m ∣ n ] x ≳ y → B.[ i ] x ≳ y
≳→≳ now = now
≳→≳ (later p) = later λ { .force → ≳→≳ (p .force) }
≳→≳ (laterˡ p) = laterˡ (≳→≳ p)
-- Quantitative weak bisimilarity is contained in weak bisimilarity.
≈→≈ : ∀ {i mˡ mʳ nˡ nʳ x y} →
[ i ∣ mˡ ∣ mʳ ∣ nˡ ∣ nʳ ] x ≈ y → B.[ i ] x ≈ y
≈→≈ now = now
≈→≈ (later p) = later λ { .force → ≈→≈ (p .force) }
≈→≈ (laterˡ p) = laterˡ (≈→≈ p)
≈→≈ (laterʳ p) = laterʳ (≈→≈ p)
-- In some cases expansion is contained in quantitative expansion.
≳→≳-steps :
∀ {m x y i} → B.[ i ] x ≳ y → [ i ∣ m ∣ steps x ] x ≳ y
≳→≳-steps now = now
≳→≳-steps (laterˡ p) = laterˡ (≳→≳-steps p)
≳→≳-steps {m} (later {x = x} p) = later λ { .force →
weakenˡ lemma (≳→≳-steps (p .force)) }
where
lemma =
steps (x .force) ≤⟨ Conat.≤suc ⟩
steps (later x) ≤⟨ Conat.m≤m+n ⟩
steps (later x) + m ∎≤
-- In some cases weak bisimilarity is contained in quantitative weak
-- bisimilarity.
≈→≈-steps :
∀ {mˡ mʳ x y i} →
B.[ i ] x ≈ y → [ i ∣ mˡ ∣ mʳ ∣ steps x ∣ steps y ] x ≈ y
≈→≈-steps now = now
≈→≈-steps (laterˡ p) = laterˡ (≈→≈-steps p)
≈→≈-steps (laterʳ p) = laterʳ (≈→≈-steps p)
≈→≈-steps {mˡ} {mʳ} (later {x = x} {y = y} p) = later λ { .force →
weakenˡʳ x-lemma y-lemma (≈→≈-steps (p .force)) }
where
x-lemma =
steps (x .force) ≤⟨ Conat.≤suc ⟩
steps (later x) ≤⟨ Conat.m≤m+n ⟩
steps (later x) + mˡ ∎≤
y-lemma =
steps (y .force) ≤⟨ Conat.≤suc ⟩
steps (later y) ≤⟨ Conat.m≤m+n ⟩
steps (later y) + mʳ ∎≤
-- In some cases quantitative weak bisimilarity is contained in strong
-- bisimilarity.
never≈→∼ :
∀ {i mˡ mʳ nˡ nʳ x} →
[ i ∣ mˡ ∣ mʳ ∣ nˡ ∣ nʳ ] never ≈ x → B.[ i ] never ∼ x
never≈→∼ (later p) = later λ { .force → never≈→∼ (p .force) }
never≈→∼ (laterˡ p) = never≈→∼ p
never≈→∼ (laterʳ p) = later λ { .force → never≈→∼ p }
≈never→∼ :
∀ {i mˡ mʳ nˡ nʳ x} →
[ i ∣ mˡ ∣ mʳ ∣ nˡ ∣ nʳ ] x ≈ never → B.[ i ] x ∼ never
≈never→∼ (later p) = later λ { .force → ≈never→∼ (p .force) }
≈never→∼ (laterˡ p) = later λ { .force → ≈never→∼ p }
≈never→∼ (laterʳ p) = ≈never→∼ p
≈→∼ : ∀ {i x y} → [ i ∣ zero ∣ zero ] x ≈ y → B.[ i ] x ∼ y
≈→∼ now = now
≈→∼ (later p) = later λ { .force → ≈→∼ (p .force) }
------------------------------------------------------------------------
-- Reflexivity, symmetry/antisymmetry, transitivity
-- Quantitative weak bisimilarity is reflexive.
reflexive-≈ : ∀ {i mˡ mʳ nˡ nʳ} x → [ i ∣ mˡ ∣ mʳ ∣ nˡ ∣ nʳ ] x ≈ x
reflexive-≈ (now _) = now
reflexive-≈ (later x) = later λ { .force → reflexive-≈ (x .force) }
-- Quantitative weak bisimilarity is symmetric (in a certain sense).
symmetric-≈ :
∀ {i mˡ mʳ nˡ nʳ x y} →
[ i ∣ mˡ ∣ mʳ ∣ nˡ ∣ nʳ ] x ≈ y →
[ i ∣ mʳ ∣ mˡ ∣ nʳ ∣ nˡ ] y ≈ x
symmetric-≈ now = now
symmetric-≈ (later p) = later λ { .force → symmetric-≈ (p .force) }
symmetric-≈ (laterˡ p) = laterʳ (symmetric-≈ p)
symmetric-≈ (laterʳ p) = laterˡ (symmetric-≈ p)
-- Four variants of transitivity.
transitive-≳∼ :
∀ {i m n x y z} →
[ i ∣ m ∣ n ] x ≳ y → B.[ i ] y ∼ z → [ i ∣ m ∣ n ] x ≳ z
transitive-≳∼ = λ where
now now → now
(laterˡ p) q → laterˡ (transitive-≳∼ p q)
(later p) (later q) → later λ { .force →
transitive-≳∼ (p .force) (q .force) }
transitive-∼≲ :
∀ {i m n x y z} →
B.[ i ] x ∼ y → [ i ∣ m ∣ n ] y ≲ z → [ i ∣ m ∣ n ] x ≲ z
transitive-∼≲ p q = transitive-≳∼ q (B.symmetric p)
transitive-≈∼ :
∀ {i mˡ mʳ nˡ nʳ x y z} →
[ i ∣ mˡ ∣ mʳ ∣ nˡ ∣ nʳ ] x ≈ y → y B.∼ z →
[ i ∣ mˡ ∣ mʳ ∣ nˡ ∣ nʳ ] x ≈ z
transitive-≈∼ = λ where
now now → now
(later p) (later q) → later λ { .force →
transitive-≈∼ (p .force) (q .force) }
(laterˡ p) q → laterˡ (transitive-≈∼ p q)
(laterʳ p) (later q) → laterʳ (transitive-≈∼ p (q .force))
transitive-∼≈ :
∀ {i mˡ mʳ nˡ nʳ x y z} →
x B.∼ y → [ i ∣ mˡ ∣ mʳ ∣ nˡ ∣ nʳ ] y ≈ z →
[ i ∣ mˡ ∣ mʳ ∣ nˡ ∣ nʳ ] x ≈ z
transitive-∼≈ = λ where
now now → now
(later p) (later q) → later λ { .force →
transitive-∼≈ (p .force) (q .force) }
(later p) (laterˡ q) → laterˡ (transitive-∼≈ (p .force) q)
p (laterʳ q) → laterʳ (transitive-∼≈ p q)
-- Equational reasoning combinators.
infix -1 _∎ˢ
infixr -2 step-∼≈ˢ step-≳∼ˢ step-≈∼ˢ _≳⟨⟩ˢ_ step-≡≈ˢ _∼⟨⟩ˢ_
_∎ˢ : ∀ {i mˡ mʳ nˡ nʳ} x → [ i ∣ mˡ ∣ mʳ ∣ nˡ ∣ nʳ ] x ≈ x
_∎ˢ = reflexive-≈
step-∼≈ˢ : ∀ {i mˡ mʳ nˡ nʳ} x {y z} →
[ i ∣ mˡ ∣ mʳ ∣ nˡ ∣ nʳ ] y ≈ z → x B.∼ y →
[ i ∣ mˡ ∣ mʳ ∣ nˡ ∣ nʳ ] x ≈ z
step-∼≈ˢ _ y≈z x∼y = transitive-∼≈ x∼y y≈z
syntax step-∼≈ˢ x y≈z x∼y = x ∼⟨ x∼y ⟩ˢ y≈z
step-≳∼ˢ : ∀ {i m n} x {y z} →
B.[ i ] y ∼ z → [ i ∣ m ∣ n ] x ≳ y →
[ i ∣ m ∣ n ] x ≳ z
step-≳∼ˢ _ y∼z x≳y = transitive-≳∼ x≳y y∼z
syntax step-≳∼ˢ x y∼z x≳y = x ≳⟨ x≳y ⟩ˢ y∼z
step-≈∼ˢ : ∀ {i mˡ mʳ nˡ nʳ} x {y z} →
y B.∼ z → [ i ∣ mˡ ∣ mʳ ∣ nˡ ∣ nʳ ] x ≈ y →
[ i ∣ mˡ ∣ mʳ ∣ nˡ ∣ nʳ ] x ≈ z
step-≈∼ˢ _ y∼z x≈y = transitive-≈∼ x≈y y∼z
syntax step-≈∼ˢ x y∼z x≈y = x ≈⟨ x≈y ⟩ˢ y∼z
_≳⟨⟩ˢ_ : ∀ {i mˡ mʳ nˡ nʳ} x {y} →
[ i ∣ mˡ ∣ mʳ ∣ nˡ ∣ nʳ ] drop-later x ≈ y →
[ i ∣ mˡ ∣ mʳ ∣ ⌜ 1 ⌝ + nˡ ∣ nʳ ] x ≈ y
now _ ≳⟨⟩ˢ p = weakenˡ Conat.≤suc p
later _ ≳⟨⟩ˢ p = laterˡ p
step-≡≈ˢ : ∀ {i mˡ mʳ nˡ nʳ} x {y z} →
[ i ∣ mˡ ∣ mʳ ∣ nˡ ∣ nʳ ] y ≈ z → x ≡ y →
[ i ∣ mˡ ∣ mʳ ∣ nˡ ∣ nʳ ] x ≈ z
step-≡≈ˢ _ y≈z refl = y≈z
syntax step-≡≈ˢ x y≈z x≡y = x ≡⟨ x≡y ⟩ˢ y≈z
_∼⟨⟩ˢ_ : ∀ {i mˡ mʳ nˡ nʳ} x {y} →
[ i ∣ mˡ ∣ mʳ ∣ nˡ ∣ nʳ ] x ≈ y →
[ i ∣ mˡ ∣ mʳ ∣ nˡ ∣ nʳ ] x ≈ y
_ ∼⟨⟩ˢ x≈y = x≈y
------------------------------------------------------------------------
-- Some results related to the steps function
-- If y is a quantitative expansion of x, then it contains at least as
-- many later constructors as x.
steps-mono :
∀ {i m n x y} → [ i ∣ m ∣ n ] x ≲ y → [ i ] steps x ≤ steps y
steps-mono = B.steps-mono ∘ ≳→≳
-- If [ i ∣ mˡ ∣ mʳ ∣ nˡ ∣ nʳ ] x ≈ y holds, then the number of later
-- constructors in x is bounded by nˡ plus 1 + mˡ times the number of
-- later constructors in y.
steps-+-*ʳ :
∀ {mˡ mʳ nˡ nʳ i x y} →
[ i ∣ mˡ ∣ mʳ ∣ nˡ ∣ nʳ ] x ≈ y →
[ i ] steps x ≤ nˡ + (⌜ 1 ⌝ + mˡ) * steps y
steps-+-*ʳ {mˡ} {mʳ} {nˡ} {nʳ} = λ where
now → zero
(later {x = x} {y = y} p) →
steps (later x) ∼⟨ suc (λ { .force → _ ∎∼ }) ⟩≤
suc (λ { .force → steps (x .force) }) ≤⟨ suc (λ { .force → steps-+-*ʳ (p .force) }) ⟩
suc (λ { .force → nˡ + mˡ + (⌜ 1 ⌝ + mˡ) * steps (y .force) }) ∼⟨ suc (λ { .force → Conat.symmetric-∼ (Conat.+-assoc nˡ) }) ⟩≤
⌜ 1 ⌝ + nˡ + (mˡ + (⌜ 1 ⌝ + mˡ) * steps (y .force)) ∼⟨ Conat.suc+∼+suc ⟩≤
nˡ + ((⌜ 1 ⌝ + mˡ) + (⌜ 1 ⌝ + mˡ) * steps (y .force)) ∼⟨ (nˡ ∎∼) Conat.+-cong Conat.symmetric-∼ Conat.*suc∼+* ⟩≤
nˡ + (⌜ 1 ⌝ + mˡ) * steps (later y) ∎≤
(laterˡ {x = x} {y = y} {nˡ = nˡ} p) →
steps (later x) ∼⟨ suc (λ { .force → _ ∎∼ }) ⟩≤
⌜ 1 ⌝ + steps (x .force) ≤⟨ (_ Conat.∎≤) Conat.+-mono steps-+-*ʳ p ⟩
⌜ 1 ⌝ + (nˡ .force + (⌜ 1 ⌝ + mˡ) * steps y) ∼⟨ suc (λ { .force → _ ∎∼ }) ⟩≤
suc nˡ + (⌜ 1 ⌝ + mˡ) * steps y ∎≤
(laterʳ {x = x} {y = y} {nʳ = nʳ} p) →
steps x ≤⟨ steps-+-*ʳ p ⟩
nˡ + (⌜ 1 ⌝ + mˡ) * steps (y .force) ≤⟨ (nˡ ∎≤) Conat.+-mono Conat.m≤n+m ⟩
nˡ + ((⌜ 1 ⌝ + mˡ) + (⌜ 1 ⌝ + mˡ) * steps (y .force)) ∼⟨ (nˡ ∎∼) Conat.+-cong Conat.symmetric-∼ Conat.*suc∼+* ⟩≤
nˡ + (⌜ 1 ⌝ + mˡ) * steps (later y) ∎≤
-- If [ i ∣ mˡ ∣ mʳ ∣ nˡ ∣ nʳ ] x ≈ y holds, then the number of later
-- constructors in y is bounded by nʳ plus 1 + mʳ times the number of
-- later constructors in x.
steps-+-*ˡ :
∀ {mˡ mʳ nˡ nʳ i x y} →
[ i ∣ mˡ ∣ mʳ ∣ nˡ ∣ nʳ ] x ≈ y →
[ i ] steps y ≤ nʳ + (⌜ 1 ⌝ + mʳ) * steps x
steps-+-*ˡ = steps-+-*ʳ ∘ symmetric-≈
-- [ ∞ ∣ mˡ ∣ mʳ ∣ nˡ ∣ nʳ ] x ≈ y holds iff x and y are weakly
-- bisimilar and the number of later constructors in x and y are
-- related in a certain way.
≈⇔≈×steps≤steps² :
∀ {mˡ mʳ nˡ nʳ x y} →
[ ∞ ∣ mˡ ∣ mʳ ∣ nˡ ∣ nʳ ] x ≈ y ⇔
x B.≈ y ×
[ ∞ ] steps x ≤ nˡ + (⌜ 1 ⌝ + mˡ) * steps y ×
[ ∞ ] steps y ≤ nʳ + (⌜ 1 ⌝ + mʳ) * steps x
≈⇔≈×steps≤steps² {mˡ} {mʳ} {x = x} {y} = record
{ to = λ p → ≈→≈ p , steps-+-*ʳ p , steps-+-*ˡ p
; from = λ { (p , q , r) → from p q r }
}
where
from-lemma :
∀ {m n} {x y : Delay′ A ∞} {i} {j : Size< i} →
[ i ] steps (later x) ≤ n + (⌜ 1 ⌝ + m) * steps (later y) →
[ j ] steps (x .force) ≤ n + m + (⌜ 1 ⌝ + m) * steps (y .force)
from-lemma {m} {n} {x} {y} hyp = Conat.cancel-suc-≤ lemma .force
where
lemma =
⌜ 1 ⌝ + steps (x .force) ∼⟨ suc (λ { .force → _ ∎∼ }) ⟩≤
steps (later x) ≤⟨ hyp ⟩
n + (⌜ 1 ⌝ + m) * steps (later y) ∼⟨ (n ∎∼) Conat.+-cong Conat.*suc∼+* ⟩≤
n + ((⌜ 1 ⌝ + m) + (⌜ 1 ⌝ + m) * steps (y .force)) ∼⟨ Conat.symmetric-∼ Conat.suc+∼+suc ⟩≤
⌜ 1 ⌝ + n + (m + (⌜ 1 ⌝ + m) * steps (y .force)) ∼⟨ suc (λ { .force → _ ∎∼ }) ⟩≤
⌜ 1 ⌝ + (n + (m + (⌜ 1 ⌝ + m) * steps (y .force))) ∼⟨ suc (λ { .force → Conat.+-assoc n }) ⟩≤
⌜ 1 ⌝ + (n + m + (⌜ 1 ⌝ + m) * steps (y .force)) ∎≤
from :
∀ {nˡ nʳ i x y} →
B.[ i ] x ≈ y →
[ ∞ ] steps x ≤ nˡ + (⌜ 1 ⌝ + mˡ) * steps y →
[ ∞ ] steps y ≤ nʳ + (⌜ 1 ⌝ + mʳ) * steps x →
[ i ∣ mˡ ∣ mʳ ∣ nˡ ∣ nʳ ] x ≈ y
from now _ _ = now
from (later p) q r = later λ { .force →
from (p .force) (from-lemma q) (from-lemma r) }
from (laterˡ {y = later _} p) q r = later λ { .force →
from (B.laterʳ⁻¹ p) (from-lemma q) (from-lemma r) }
from (laterʳ {x = later _} p) q r = later λ { .force →
from (B.laterˡ⁻¹ p) (from-lemma q) (from-lemma r) }
from {nˡ = zero} (laterˡ {y = now _} p) ()
from {nˡ = suc _} (laterˡ {y = now _} p) (suc q) _ =
laterˡ (from p (q .force) zero)
from {nʳ = zero} (laterʳ {x = now _} p) _ ()
from {nʳ = suc _} (laterʳ {x = now _} p) _ (suc r) =
laterʳ (from p zero (r .force))
-- [ ∞ ∣ m ∣ n ] x ≳ y holds iff x is an expansion of y and the number
-- of later constructors in x and y are related in a certain way.
≳⇔≳×steps≤steps :
∀ {m n x y} →
[ ∞ ∣ m ∣ n ] x ≳ y ⇔
x B.≳ y × [ ∞ ] steps x ≤ n + (⌜ 1 ⌝ + m) * steps y
≳⇔≳×steps≤steps {m} {n} {x} {y} =
[ ∞ ∣ m ∣ n ] x ≳ y ↝⟨ ≈⇔≈×steps≤steps² ⟩
x B.≈ y ×
[ ∞ ] steps x ≤ n + (⌜ 1 ⌝ + m) * steps y ×
[ ∞ ] steps y ≤ (⌜ 1 ⌝ + ⌜ 0 ⌝) * steps x ↝⟨ F.id ×-cong F.id ×-cong (_ ∎∼) Conat.≤-cong-∼ lemma ⟩
x B.≈ y ×
[ ∞ ] steps x ≤ n + (⌜ 1 ⌝ + m) * steps y ×
[ ∞ ] steps y ≤ steps x ↝⟨ record { to = B.symmetric; from = B.symmetric } ×-cong from-isomorphism ×-comm ⟩
y B.≈ x ×
[ ∞ ] steps y ≤ steps x ×
[ ∞ ] steps x ≤ n + (⌜ 1 ⌝ + m) * steps y ↔⟨ ×-assoc ⟩
(y B.≈ x ×
[ ∞ ] steps y ≤ steps x) ×
[ ∞ ] steps x ≤ n + (⌜ 1 ⌝ + m) * steps y ↝⟨ inverse B.≲⇔≈×steps≤steps ×-cong F.id ⟩□
x B.≳ y × [ ∞ ] steps x ≤ n + (⌜ 1 ⌝ + m) * steps y □
where
lemma =
(⌜ 1 ⌝ + ⌜ 0 ⌝) * steps x ∼⟨ suc (λ { .force → _ ∎∼ }) Conat.*-cong (_ ∎∼) ⟩
⌜ 1 ⌝ * steps x ∼⟨ Conat.*-left-identity _ ⟩
steps x ∎∼
-- [ ∞ ∣ m ∣ n ] x ≳ y holds iff x is weakly bisimilar to y and the
-- number of later constructors in x and y are related in a certain
-- way.
≳⇔≈×steps≤steps² :
∀ {m n x y} →
[ ∞ ∣ m ∣ n ] x ≳ y ⇔
x B.≈ y ×
[ ∞ ] steps y ≤ steps x ×
[ ∞ ] steps x ≤ n + (⌜ 1 ⌝ + m) * steps y
≳⇔≈×steps≤steps² {m} {n} {x} {y} =
[ ∞ ∣ m ∣ n ] x ≳ y ↝⟨ ≳⇔≳×steps≤steps ⟩
x B.≳ y ×
[ ∞ ] steps x ≤ n + (⌜ 1 ⌝ + m) * steps y ↝⟨ B.≲⇔≈×steps≤steps ×-cong F.id ⟩
(y B.≈ x ×
[ ∞ ] steps y ≤ steps x) ×
[ ∞ ] steps x ≤ n + (⌜ 1 ⌝ + m) * steps y ↔⟨ inverse ×-assoc ⟩
y B.≈ x ×
[ ∞ ] steps y ≤ steps x ×
[ ∞ ] steps x ≤ n + (⌜ 1 ⌝ + m) * steps y ↝⟨ record { to = B.symmetric; from = B.symmetric } ×-cong F.id ⟩□
x B.≈ y ×
[ ∞ ] steps y ≤ steps x ×
[ ∞ ] steps x ≤ n + (⌜ 1 ⌝ + m) * steps y □
-- The left-to-right direction of ≳⇔≳×steps≤steps can be made
-- size-preserving.
≳→≳×steps≤steps :
∀ {i m n x y} →
[ i ∣ m ∣ n ] x ≳ y →
B.[ i ] x ≳ y × [ i ] steps x ≤ n + (⌜ 1 ⌝ + m) * steps y
≳→≳×steps≤steps x≳y = ≳→≳ x≳y , steps-+-*ʳ x≳y
-- The right-to-left direction of ≳⇔≳×steps≤steps can be made
-- size-preserving iff A is uninhabited.
≳×steps≤steps→≳⇔uninhabited :
(∀ {i m n x y} →
B.[ i ] x ≳ y ×
[ i ] steps x ≤ n + (⌜ 1 ⌝ + m) * steps y →
[ i ∣ m ∣ n ] x ≳ y)
⇔
¬ A
≳×steps≤steps→≳⇔uninhabited = record
{ to = flip to
; from =
¬ A ↝⟨ (λ ¬A {_ _ _ _ _} → ∼→≈ (B.uninhabited→trivial ¬A _ _)) ⟩
(∀ {i m n x y} → [ i ∣ m ∣ n ] x ≳ y) ↝⟨ (λ hyp {_ _ _ _ _} _ → hyp {_}) ⟩□
(∀ {i m n x y} →
B.[ i ] x ≳ y ×
[ i ] steps x ≤ n + (⌜ 1 ⌝ + m) * steps y →
[ i ∣ m ∣ n ] x ≳ y) □
}
where
strengthen-≳now :
∀ {i m n x y} →
[ i ∣ m ∣ n ] x ≳ now y →
[ ∞ ∣ m ∣ n ] x ≳ now y
strengthen-≳now now = now
strengthen-≳now (laterˡ p) = laterˡ (strengthen-≳now p)
to :
A →
¬ (∀ {i m n x y} →
B.[ i ] x ≳ y ×
[ i ] steps x ≤ n + (⌜ 1 ⌝ + m) * steps y →
[ i ∣ m ∣ n ] x ≳ y)
to x =
(∀ {i m n x y} →
B.[ i ] x ≳ y ×
[ i ] steps x ≤ n + (⌜ 1 ⌝ + m) * steps y →
[ i ∣ m ∣ n ] x ≳ y) ↝⟨ (λ hyp → curry hyp) ⟩
(∀ {i m n} →
B.[ i ] f m ≳ now x →
[ i ] steps (f m) ≤ n + zero →
[ i ∣ zero ∣ n ] f m ≳ now x) ↝⟨ (λ hyp {_ _ _} p → hyp (≳now _) (complicate p)) ⟩
(∀ {i m n} → [ i ] ⌜ m ⌝ ≤ n → [ i ∣ zero ∣ n ] f m ≳ now x) ↝⟨ strengthen-≳now ∘_ ⟩
(∀ {i m n} → [ i ] ⌜ m ⌝ ≤ n → [ ∞ ∣ zero ∣ n ] f m ≳ now x) ↝⟨ (λ hyp {_ _ _} p → steps-+-*ʳ (hyp p)) ⟩
(∀ {i m n} → [ i ] ⌜ m ⌝ ≤ n → [ ∞ ] steps (f m) ≤ n + zero) ↝⟨ (λ hyp {_ _ _} p → simplify (hyp p)) ⟩
(∀ {i m n} → [ i ] ⌜ m ⌝ ≤ n → [ ∞ ] ⌜ m ⌝ ≤ n) ↝⟨ (λ hyp → hyp) ⟩
(∀ {i} → [ i ] ⌜ 2 ⌝ ≤ ⌜ 1 ⌝ → [ ∞ ] ⌜ 2 ⌝ ≤ ⌜ 1 ⌝) ↝⟨ Conat.no-strengthening-≤-21 ⟩□
⊥ □
where
f : ∀ {i} → ℕ → Delay A i
f zero = now x
f (suc n) = later λ { .force → f n }
≳now : ∀ {i} n → B.[ i ] f n ≳ now x
≳now zero = now
≳now (suc n) = laterˡ (≳now n)
∼steps : ∀ {i} n → Conat.[ i ] ⌜ n ⌝ ∼ steps (f n)
∼steps zero = zero
∼steps (suc n) = suc λ { .force → ∼steps n }
complicate :
∀ {m n i} → [ i ] ⌜ m ⌝ ≤ n → [ i ] steps (f m) ≤ n + zero
complicate {m} {n} p =
steps (f m) ∼⟨ Conat.symmetric-∼ (∼steps m) ⟩≤
⌜ m ⌝ ≤⟨ p ⟩
n ∼⟨ Conat.symmetric-∼ (Conat.+-right-identity _) ⟩≤
n + zero ∎≤
simplify :
∀ {m n i} → [ i ] steps (f m) ≤ n + zero → [ i ] ⌜ m ⌝ ≤ n
simplify {m} {n} p =
⌜ m ⌝ ∼⟨ ∼steps m ⟩≤
steps (f m) ≤⟨ p ⟩
n + zero ∼⟨ Conat.+-right-identity _ ⟩≤
n ∎≤
-- The left-to-right direction of ≈⇔≈×steps≤steps² can be made
-- size-preserving.
≈→≈×steps≤steps² :
∀ {i mˡ mʳ nˡ nʳ x y} →
[ ∞ ∣ mˡ ∣ mʳ ∣ nˡ ∣ nʳ ] x ≈ y →
B.[ i ] x ≈ y ×
[ i ] steps x ≤ nˡ + (⌜ 1 ⌝ + mˡ) * steps y ×
[ i ] steps y ≤ nʳ + (⌜ 1 ⌝ + mʳ) * steps x
≈→≈×steps≤steps² x≈y = ≈→≈ x≈y , steps-+-*ʳ x≈y , steps-+-*ˡ x≈y
-- The right-to-left direction of ≈⇔≈×steps≤steps² can be made
-- size-preserving iff A is uninhabited.
≈×steps≤steps²→≈⇔uninhabited :
(∀ {i mˡ mʳ nˡ nʳ x y} →
B.[ i ] x ≈ y ×
[ i ] steps x ≤ nˡ + (⌜ 1 ⌝ + mˡ) * steps y ×
[ i ] steps y ≤ nʳ + (⌜ 1 ⌝ + mʳ) * steps x →
[ i ∣ mˡ ∣ mʳ ∣ nˡ ∣ nʳ ] x ≈ y)
⇔
¬ A
≈×steps≤steps²→≈⇔uninhabited = record
{ to =
(∀ {i mˡ mʳ nˡ nʳ x y} →
B.[ i ] x ≈ y ×
[ i ] steps x ≤ nˡ + (⌜ 1 ⌝ + mˡ) * steps y ×
[ i ] steps y ≤ nʳ + (⌜ 1 ⌝ + mʳ) * steps x →
[ i ∣ mˡ ∣ mʳ ∣ nˡ ∣ nʳ ] x ≈ y) ↝⟨ (λ { hyp (p , q) → hyp (B.≳→ p , q , lemma (B.steps-mono p)) }) ⟩
(∀ {i m n x y} →
B.[ i ] x ≳ y ×
[ i ] steps x ≤ n + (⌜ 1 ⌝ + m) * steps y →
[ i ∣ m ∣ n ] x ≳ y) ↝⟨ _⇔_.to ≳×steps≤steps→≳⇔uninhabited ⟩□
¬ A □
; from =
¬ A ↝⟨ (λ ¬A {_ _ _ _ _} → ∼→≈ (B.uninhabited→trivial ¬A _ _)) ⟩
(∀ {i mˡ mʳ nˡ nʳ x y} → [ i ∣ mˡ ∣ mʳ ∣ nˡ ∣ nʳ ] x ≈ y) ↝⟨ (λ hyp {_ _ _ _ _ _ _} _ → hyp {_}) ⟩□
(∀ {i mˡ mʳ nˡ nʳ x y} →
B.[ i ] x ≈ y ×
[ i ] steps x ≤ nˡ + (⌜ 1 ⌝ + mˡ) * steps y ×
[ i ] steps y ≤ nʳ + (⌜ 1 ⌝ + mʳ) * steps x →
[ i ∣ mˡ ∣ mʳ ∣ nˡ ∣ nʳ ] x ≈ y) □
}
where
lemma :
∀ {m n i} →
[ i ] m ≤ n →
[ i ] m ≤ (⌜ 1 ⌝ + ⌜ 0 ⌝) * n
lemma {m} {n} p =
m ≤⟨ p ⟩
n ∼⟨ Conat.symmetric-∼ (Conat.*-left-identity _) ⟩≤
⌜ 1 ⌝ * n ∼⟨ Conat.symmetric-∼ (Conat.+-right-identity _) Conat.*-cong (_ ∎∼) ⟩≤
(⌜ 1 ⌝ + ⌜ 0 ⌝) * n ∎≤
|
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/renaming6.ads | best08618/asylo | 7 | 25867 | <gh_stars>1-10
package Renaming6 is
I : Integer;
pragma Atomic (I);
function Get_I return Integer;
procedure Set_I (Val : Integer);
J : Integer renames I;
function Get_J return Integer;
procedure Set_J (Val : Integer);
end Renaming6;
|
source/lexer/program-lexical_handlers.adb | reznikmm/gela | 0 | 10367 | -- SPDX-FileCopyrightText: 2019 <NAME> <<EMAIL>>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with Ada.Wide_Wide_Characters.Handling;
with Program.Source_Buffers;
package body Program.Lexical_Handlers is
use all type Program.Scanner_Destinations.Token_Kind;
subtype Hash_Value is Positive range 2 + 2 * 6 .. 12 + 3 * 115;
function Hash (W : Wide_Wide_String) return Hash_Value;
function To_Token
(X : Wide_Wide_String)
return Program.Scanner_Destinations.Token_Kind;
Map : constant array (Program.Scanner_States.Rule_Index range 1 .. 27) of
Program.Scanner_Destinations.Token_Kind :=
(1 => Arrow, 2 => Double_Dot, 3 => Double_Star,
4 => Assignment, 5 => Inequality,
6 => Greater_Or_Equal, 7 => Less_Or_Equal,
8 => Left_Label, 9 => Right_Label, 10 => Box,
11 => Ampersand, 12 => Apostrophe,
13 => Left_Parenthesis, 14 => Right_Parenthesis,
15 => Star, 16 => Plus, 17 => Comma,
18 => Hyphen, 19 => Dot, 20 => Slash,
21 => Colon, 22 => Semicolon, 23 => Less,
24 => Equal, 25 => Greater, 26 => Vertical_Line,
27 => Vertical_Line);
Id : constant Program.Scanner_Destinations.Token_Kind := Identifier;
-- generated by gperf -m 100
Word_Map : constant array (Hash_Value range 22 .. 114)
of Program.Scanner_Destinations.Token_Kind :=
(Else_Keyword,
At_Keyword,
Task_Keyword,
Then_Keyword,
Not_Keyword,
Range_Keyword,
Abs_Keyword,
Renames_Keyword,
Return_Keyword,
End_Keyword,
Terminate_Keyword,
Case_Keyword,
Xor_Keyword,
Abstract_Keyword,
Synchronized_Keyword,
Reverse_Keyword,
And_Keyword,
Exception_Keyword,
Constant_Keyword,
Declare_Keyword,
Access_Keyword,
Record_Keyword,
Accept_Keyword,
Is_Keyword,
In_Keyword,
Type_Keyword,
Entry_Keyword,
Separate_Keyword,
Or_Keyword,
Requeue_Keyword,
Do_Keyword,
Select_Keyword,
When_Keyword,
Exit_Keyword,
Array_Keyword,
Raise_Keyword,
Out_Keyword,
Package_Keyword,
Interface_Keyword,
Pragma_Keyword,
Delta_Keyword,
Use_Keyword,
Digits_Keyword,
Abort_Keyword,
Tagged_Keyword,
Some_Keyword,
Aliased_Keyword,
Elsif_Keyword,
Subtype_Keyword,
Id,
Generic_Keyword,
For_Keyword,
Function_Keyword,
Id,
Mod_Keyword,
Null_Keyword,
Delay_Keyword,
Private_Keyword,
Id, Id,
All_Keyword,
Procedure_Keyword,
New_Keyword,
While_Keyword,
Id,
With_Keyword,
Protected_Keyword,
Others_Keyword,
Id,
If_Keyword,
Goto_Keyword,
Of_Keyword,
Until_Keyword,
Body_Keyword,
Overriding_Keyword,
Id, Id, Id, Id, Id,
Limited_Keyword,
Id,
Begin_Keyword,
Loop_Keyword,
Id, Id, Id, Id, Id, Id, Id, Id,
Rem_Keyword);
Word_Text : constant Wide_Wide_String :=
"else"
& "at"
& "task"
& "then"
& "not"
& "range"
& "abs"
& "renames"
& "return"
& "end"
& "terminate"
& "case"
& "xor"
& "abstract"
& "synchronized"
& "reverse"
& "and"
& "exception"
& "constant"
& "declare"
& "access"
& "record"
& "accept"
& "is"
& "in"
& "type"
& "entry"
& "separate"
& "or"
& "requeue"
& "do"
& "select"
& "when"
& "exit"
& "array"
& "raise"
& "out"
& "package"
& "interface"
& "pragma"
& "delta"
& "use"
& "digits"
& "abort"
& "tagged"
& "some"
& "aliased"
& "elsif"
& "subtype"
& "generic"
& "for"
& "function"
& "mod"
& "null"
& "delay"
& "private"
& "all"
& "procedure"
& "new"
& "while"
& "with"
& "protected"
& "others"
& "if"
& "goto"
& "of"
& "until"
& "body"
& "overriding"
& "limited"
& "begin"
& "loop"
& "rem";
Word_From : constant array (Hash_Value range 22 .. 114) of Natural :=
(1,
5,
7,
11,
15,
18,
23,
26,
33,
39,
42,
51,
55,
58,
66,
78,
85,
88,
97,
105,
112,
118,
124,
130,
132,
134,
138,
143,
151,
153,
160,
162,
168,
172,
176,
181,
186,
189,
196,
205,
211,
216,
219,
225,
230,
236,
240,
247,
252, -- Subtype_Keyword,
0,
259, -- Generic_Keyword,
266, -- For_Keyword,
269, -- Function_Keyword,
0,
277, -- Mod_Keyword,
280, -- Null_Keyword,
284, -- Delay_Keyword,
289, -- Private_Keyword,
0, 0,
296, -- All_Keyword,
299, -- Procedure_Keyw
308, -- New_Keyword,
311, -- While_Keyword,
0,
316, -- With_Keyword,
320, -- Protected_Keywo
329, -- Others_Keyword,
0,
335, -- If_Keyword,
337, -- Goto_Keyword,
341, -- Of_Keyword,
343, -- Until_Keyword,
348, -- Body_Keyword,
352, -- Overriding_Keyword,
0, 0, 0, 0, 0,
362, -- Limited_Keyword,
0,
369, -- Begin_Keyword
374, -- Loop_Keyword,
0, 0, 0, 0, 0, 0, 0, 0,
378); -- Rem_Keyword, Total length 381);
-----------------------
-- Character_Literal --
-----------------------
overriding procedure Character_Literal
(Self : not null access Handler;
Scanner : not null access Program.Scanners.Scanner'Class;
Rule : Program.Scanner_States.Rule_Index;
Token : out Program.Scanner_Destinations.Token_Kind;
Skip : in out Boolean)
is
pragma Unreferenced (Rule);
Value : Program.Scanner_Destinations.Token;
begin
Scanner.Set_Start_Condition (Program.Scanner_States.Allow_Char);
Token := Character_Literal;
Skip := False;
Value := (Kind => Token, Span => Scanner.Get_Span);
Self.Output.New_Token (Value);
Self.Last_Token := Token;
end Character_Literal;
-------------
-- Comment --
-------------
overriding procedure Comment
(Self : not null access Handler;
Scanner : not null access Program.Scanners.Scanner'Class;
Rule : Program.Scanner_States.Rule_Index;
Token : out Program.Scanner_Destinations.Token_Kind;
Skip : in out Boolean)
is
pragma Unreferenced (Self, Scanner, Rule, Token);
begin
Skip := True;
end Comment;
---------------
-- Delimiter --
---------------
overriding procedure Delimiter
(Self : not null access Handler;
Scanner : not null access Program.Scanners.Scanner'Class;
Rule : Program.Scanner_States.Rule_Index;
Token : out Program.Scanner_Destinations.Token_Kind;
Skip : in out Boolean)
is
Value : Program.Scanner_Destinations.Token;
begin
Scanner.Set_Start_Condition (Program.Scanner_States.Allow_Char);
Token := Map (Rule);
Skip := False;
Value := (Kind => Token, Span => Scanner.Get_Span);
Self.Output.New_Token (Value);
Self.Last_Token := Token;
end Delimiter;
-----------
-- Error --
-----------
overriding procedure Error
(Self : not null access Handler;
Scanner : not null access Program.Scanners.Scanner'Class;
Rule : Program.Scanner_States.Rule_Index;
Token : out Program.Scanner_Destinations.Token_Kind;
Skip : in out Boolean)
is
pragma Unreferenced (Rule);
Value : Program.Scanner_Destinations.Token;
begin
Token := Error;
Skip := False;
Value := (Kind => Token, Span => Scanner.Get_Span);
Self.Output.New_Token (Value);
Self.Last_Token := Token;
end Error;
----------
-- Hash --
----------
function Hash (W : Wide_Wide_String) return Hash_Value is
X : constant array (Wide_Wide_Character range 'a' .. 'y') of Positive :=
(13, 51, 17, 11, 6, 52, 41, 38, 37, 115, 6, 33, 51,
7, 39, 29, 29, 9, 6, 8, 48, 15, 37, 13, 29);
function Y (Val : Wide_Wide_Character) return Positive;
function Y (Val : Wide_Wide_Character) return Positive is
begin
if Val in X'Range then
return X (Val);
else
return 115;
end if;
end Y;
Length : constant Positive := W'Length;
Result : Positive := Length; -- 2 .. 12
begin
if Length > 2 then
Result := Result + Y (W (W'First + 2)); -- 6 .. 115
end if;
Result := Result + Y (W (W'First)); -- 6 .. 115
Result := Result + Y (W (Length)); -- 6 .. 115
return Result;
end Hash;
----------------
-- Identifier --
----------------
overriding procedure Identifier
(Self : not null access Handler;
Scanner : not null access Program.Scanners.Scanner'Class;
Rule : Program.Scanner_States.Rule_Index;
Token : out Program.Scanner_Destinations.Token_Kind;
Skip : in out Boolean)
is
pragma Unreferenced (Rule);
Value : Program.Scanner_Destinations.Token;
Span : constant Program.Source_Buffers.Span := Scanner.Get_Span;
Text : constant Wide_Wide_String := Scanner.Get_Source.Text (Span);
Match : constant Wide_Wide_String :=
Ada.Wide_Wide_Characters.Handling.To_Lower (Text);
begin
Token := To_Token (Match);
Skip := False;
if Self.Last_Token = Apostrophe and Token /= Range_Keyword then
Token := Id;
end if;
if Token = Id then
Scanner.Set_Start_Condition (Program.Scanner_States.INITIAL);
else
Scanner.Set_Start_Condition (Program.Scanner_States.Allow_Char);
end if;
Value := (Kind => Token, Span => Scanner.Get_Span);
Self.Output.New_Token (Value);
Self.Last_Token := Token;
end Identifier;
--------------
-- New_Line --
--------------
overriding procedure New_Line
(Self : not null access Handler;
Scanner : not null access Program.Scanners.Scanner'Class;
Rule : Program.Scanner_States.Rule_Index;
Token : out Program.Scanner_Destinations.Token_Kind;
Skip : in out Boolean)
is
pragma Unreferenced (Scanner, Rule, Token);
begin
Skip := True;
Self.Output.New_Line (Self.Line);
Self.Line := Self.Line + 1;
end New_Line;
---------------------
-- Numeric_Literal --
---------------------
overriding procedure Numeric_Literal
(Self : not null access Handler;
Scanner : not null access Program.Scanners.Scanner'Class;
Rule : Program.Scanner_States.Rule_Index;
Token : out Program.Scanner_Destinations.Token_Kind;
Skip : in out Boolean)
is
pragma Unreferenced (Rule);
Value : Program.Scanner_Destinations.Token;
begin
Scanner.Set_Start_Condition (Program.Scanner_States.Allow_Char);
Token := Numeric_Literal;
Skip := False;
Value := (Kind => Token, Span => Scanner.Get_Span);
Self.Output.New_Token (Value);
Self.Last_Token := Token;
end Numeric_Literal;
---------------------------------
-- Obsolescent_Numeric_Literal --
---------------------------------
overriding procedure Obsolescent_Numeric_Literal
(Self : not null access Handler;
Scanner : not null access Program.Scanners.Scanner'Class;
Rule : Program.Scanner_States.Rule_Index;
Token : out Program.Scanner_Destinations.Token_Kind;
Skip : in out Boolean) renames Numeric_Literal;
--------------------------------
-- Obsolescent_String_Literal --
--------------------------------
overriding procedure Obsolescent_String_Literal
(Self : not null access Handler;
Scanner : not null access Program.Scanners.Scanner'Class;
Rule : Program.Scanner_States.Rule_Index;
Token : out Program.Scanner_Destinations.Token_Kind;
Skip : in out Boolean) renames String_Literal;
-----------
-- Space --
-----------
overriding procedure Space
(Self : not null access Handler;
Scanner : not null access Program.Scanners.Scanner'Class;
Rule : Program.Scanner_States.Rule_Index;
Token : out Program.Scanner_Destinations.Token_Kind;
Skip : in out Boolean)
is
pragma Unreferenced (Self, Scanner, Rule, Token);
begin
Skip := True;
end Space;
--------------------
-- String_Literal --
--------------------
overriding procedure String_Literal
(Self : not null access Handler;
Scanner : not null access Program.Scanners.Scanner'Class;
Rule : Program.Scanner_States.Rule_Index;
Token : out Program.Scanner_Destinations.Token_Kind;
Skip : in out Boolean)
is
pragma Unreferenced (Rule);
Value : Program.Scanner_Destinations.Token;
begin
Scanner.Set_Start_Condition (Program.Scanner_States.Allow_Char);
Token := String_Literal;
Skip := False;
Value := (Kind => Token, Span => Scanner.Get_Span);
Self.Output.New_Token (Value);
Self.Last_Token := Token;
end String_Literal;
--------------
-- To_Token --
--------------
function To_Token
(X : Wide_Wide_String)
return Program.Scanner_Destinations.Token_Kind
is
H : Hash_Value;
begin
if X'Length in 2 .. 12 then
H := Hash (X);
if H in Word_From'Range and then
Word_From (H) >= Word_Text'First and then
Word_From (H) + X'Length - 1 <= Word_Text'Last and then
Word_Text (Word_From (H) .. Word_From (H) + X'Length - 1) = X
then
return Word_Map (H);
end if;
end if;
return Identifier;
end To_Token;
end Program.Lexical_Handlers;
|
source/nodes/program-nodes-slices.ads | reznikmm/gela | 0 | 21615 | <reponame>reznikmm/gela
-- SPDX-FileCopyrightText: 2019 <NAME> <<EMAIL>>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with Program.Elements.Expressions;
with Program.Lexical_Elements;
with Program.Elements.Discrete_Ranges;
with Program.Elements.Slices;
with Program.Element_Visitors;
package Program.Nodes.Slices is
pragma Preelaborate;
type Slice is
new Program.Nodes.Node and Program.Elements.Slices.Slice
and Program.Elements.Slices.Slice_Text
with private;
function Create
(Prefix : not null Program.Elements.Expressions
.Expression_Access;
Left_Bracket_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Slice_Range : not null Program.Elements.Discrete_Ranges
.Discrete_Range_Access;
Right_Bracket_Token : not null Program.Lexical_Elements
.Lexical_Element_Access)
return Slice;
type Implicit_Slice is
new Program.Nodes.Node and Program.Elements.Slices.Slice
with private;
function Create
(Prefix : not null Program.Elements.Expressions
.Expression_Access;
Slice_Range : not null Program.Elements.Discrete_Ranges
.Discrete_Range_Access;
Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False)
return Implicit_Slice
with Pre =>
Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance;
private
type Base_Slice is
abstract new Program.Nodes.Node and Program.Elements.Slices.Slice
with record
Prefix : not null Program.Elements.Expressions.Expression_Access;
Slice_Range : not null Program.Elements.Discrete_Ranges
.Discrete_Range_Access;
end record;
procedure Initialize (Self : in out Base_Slice'Class);
overriding procedure Visit
(Self : not null access Base_Slice;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class);
overriding function Prefix
(Self : Base_Slice)
return not null Program.Elements.Expressions.Expression_Access;
overriding function Slice_Range
(Self : Base_Slice)
return not null Program.Elements.Discrete_Ranges.Discrete_Range_Access;
overriding function Is_Slice (Self : Base_Slice) return Boolean;
overriding function Is_Expression (Self : Base_Slice) return Boolean;
type Slice is
new Base_Slice and Program.Elements.Slices.Slice_Text
with record
Left_Bracket_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Right_Bracket_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
end record;
overriding function To_Slice_Text
(Self : in out Slice)
return Program.Elements.Slices.Slice_Text_Access;
overriding function Left_Bracket_Token
(Self : Slice)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function Right_Bracket_Token
(Self : Slice)
return not null Program.Lexical_Elements.Lexical_Element_Access;
type Implicit_Slice is
new Base_Slice
with record
Is_Part_Of_Implicit : Boolean;
Is_Part_Of_Inherited : Boolean;
Is_Part_Of_Instance : Boolean;
end record;
overriding function To_Slice_Text
(Self : in out Implicit_Slice)
return Program.Elements.Slices.Slice_Text_Access;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Slice)
return Boolean;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Slice)
return Boolean;
overriding function Is_Part_Of_Instance
(Self : Implicit_Slice)
return Boolean;
end Program.Nodes.Slices;
|
programs/oeis/155/A155637.asm | neoneye/loda | 22 | 93115 | ; A155637: 10^n+5^n-1.
; 1,14,124,1124,10624,103124,1015624,10078124,100390624,1001953124,10009765624,100048828124,1000244140624,10001220703124,100006103515624,1000030517578124,10000152587890624,100000762939453124,1000003814697265624,10000019073486328124,100000095367431640624,1000000476837158203124,10000002384185791015624,100000011920928955078124,1000000059604644775390624,10000000298023223876953124,100000001490116119384765624,1000000007450580596923828124,10000000037252902984619140624,100000000186264514923095703124,1000000000931322574615478515624,10000000004656612873077392578124,100000000023283064365386962890624,1000000000116415321826934814453124,10000000000582076609134674072265624,100000000002910383045673370361328124
mov $1,5
pow $1,$0
mov $2,10
pow $2,$0
add $1,$2
mov $0,$1
sub $0,1
|
libsrc/_DEVELOPMENT/math/float/math48/lm/c/sdcc_ix/___fsmul_callee.asm | jpoikela/z88dk | 640 | 10852 | <gh_stars>100-1000
SECTION code_clib
SECTION code_fp_math48
PUBLIC ___fsmul_callee
EXTERN cm48_sdccixp_dsmul_callee
defc ___fsmul_callee = cm48_sdccixp_dsmul_callee
|
alloy4fun_models/trashltl/models/18/zeWWzGskAsEi9C82Y.als | Kaixi26/org.alloytools.alloy | 0 | 2021 | open main
pred idzeWWzGskAsEi9C82Y_prop19 {
all f : Protected | (f in Trash and f not in Protected) until f in Protected
}
pred __repair { idzeWWzGskAsEi9C82Y_prop19 }
check __repair { idzeWWzGskAsEi9C82Y_prop19 <=> prop19o } |
Transynther/x86/_processed/NONE/_xt_/i7-7700_9_0x48.log_21829_1820.asm | ljhsiun2/medusa | 9 | 26881 | <reponame>ljhsiun2/medusa
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r14
push %r15
push %rbp
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_UC_ht+0x1b8ba, %r10
add $18007, %rdx
mov $0x6162636465666768, %r14
movq %r14, (%r10)
nop
nop
nop
nop
add $30369, %rsi
lea addresses_WT_ht+0x1d9ca, %rsi
lea addresses_A_ht+0x129fa, %rdi
nop
nop
and $37507, %rbp
mov $72, %rcx
rep movsl
nop
add $40873, %rdi
lea addresses_normal_ht+0xb9fa, %r10
nop
nop
nop
nop
sub $65051, %rdi
movups (%r10), %xmm4
vpextrq $1, %xmm4, %rbp
nop
nop
nop
nop
nop
add %rsi, %rsi
lea addresses_normal_ht+0x77a, %rbp
nop
nop
nop
cmp %r10, %r10
and $0xffffffffffffffc0, %rbp
vmovaps (%rbp), %ymm3
vextracti128 $1, %ymm3, %xmm3
vpextrq $0, %xmm3, %rdx
nop
nop
and $15417, %rbp
lea addresses_A_ht+0x129ba, %rsi
lea addresses_A_ht+0x18ec2, %rdi
nop
nop
nop
nop
nop
cmp %r15, %r15
mov $104, %rcx
rep movsb
nop
nop
nop
nop
sub $45685, %r10
lea addresses_D_ht+0x1575a, %r10
nop
nop
sub $58132, %rsi
movb (%r10), %r15b
nop
cmp %r10, %r10
lea addresses_WC_ht+0x75fa, %r10
nop
nop
nop
nop
nop
xor %r14, %r14
mov $0x6162636465666768, %rsi
movq %rsi, %xmm4
movups %xmm4, (%r10)
nop
nop
nop
xor %r15, %r15
lea addresses_WC_ht+0x1733a, %rdi
nop
nop
nop
sub %rdx, %rdx
movb $0x61, (%rdi)
nop
nop
nop
add %rcx, %rcx
lea addresses_UC_ht+0x13efa, %r10
sub %rcx, %rcx
and $0xffffffffffffffc0, %r10
vmovntdqa (%r10), %ymm1
vextracti128 $1, %ymm1, %xmm1
vpextrq $0, %xmm1, %rbp
nop
nop
add %rcx, %rcx
lea addresses_A_ht+0x99fa, %rsi
lea addresses_normal_ht+0x1c9fa, %rdi
nop
nop
and $10826, %rdx
mov $90, %rcx
rep movsw
nop
nop
add $64442, %rsi
lea addresses_WT_ht+0x1d5fa, %r10
nop
nop
nop
cmp $44721, %rdi
movb (%r10), %r15b
nop
nop
nop
nop
nop
xor %r15, %r15
lea addresses_D_ht+0x120da, %rdx
nop
nop
nop
cmp %r15, %r15
mov $0x6162636465666768, %rbp
movq %rbp, %xmm3
vmovups %ymm3, (%rdx)
nop
nop
inc %r14
lea addresses_WC_ht+0x175fa, %rdx
nop
nop
nop
add %rcx, %rcx
mov $0x6162636465666768, %rbp
movq %rbp, %xmm0
movups %xmm0, (%rdx)
nop
nop
nop
nop
add %rsi, %rsi
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbp
pop %r15
pop %r14
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r12
push %r15
push %rax
push %rbp
push %rdx
// Store
lea addresses_WT+0x13efa, %rbp
inc %r11
mov $0x5152535455565758, %r10
movq %r10, (%rbp)
nop
nop
nop
sub %rax, %rax
// Store
lea addresses_A+0x175fa, %rdx
nop
nop
nop
nop
nop
xor %r10, %r10
movw $0x5152, (%rdx)
add $12236, %r11
// Store
lea addresses_WC+0x1887a, %rax
nop
add %r10, %r10
movb $0x51, (%rax)
nop
nop
nop
nop
nop
xor $23779, %rbp
// Faulty Load
lea addresses_PSE+0x171fa, %rbp
dec %r15
vmovups (%rbp), %ymm1
vextracti128 $1, %ymm1, %xmm1
vpextrq $0, %xmm1, %r10
lea oracles, %r15
and $0xff, %r10
shlq $12, %r10
mov (%r15,%r10,1), %r10
pop %rdx
pop %rbp
pop %rax
pop %r15
pop %r12
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_PSE', 'AVXalign': True, 'congruent': 0, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT', 'AVXalign': False, 'congruent': 8, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A', 'AVXalign': False, 'congruent': 10, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'AVXalign': False, 'congruent': 6, 'size': 1, 'same': False, 'NT': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_PSE', 'AVXalign': False, 'congruent': 0, 'size': 32, 'same': True, 'NT': False}}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 3, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 11, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 11, 'size': 16, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'AVXalign': True, 'congruent': 5, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 3, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 5, 'size': 1, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 8, 'size': 16, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 6, 'size': 1, 'same': True, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 5, 'size': 32, 'same': False, 'NT': True}}
{'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 10, 'same': True}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 11, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 10, 'size': 1, 'same': True, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 4, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 10, 'size': 16, 'same': False, 'NT': False}}
{'33': 21829}
33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33
*/
|
tools/scitools/sample/mahjongg/display.adb | brucegua/moocos | 1 | 15303 | WITH TileADT, Text_IO;
USE TileADT, Text_IO;
PACKAGE BODY Display IS
--
-- Implementation of Display ADT for Mahjongg solitaire game
--
PROCEDURE SayTile(TheTile : Tile) IS
BEGIN
null;
END SayTile;
PROCEDURE ShowTile(TheTile : Tile) IS
-- Assumes : TheTile has a position and a value.
-- Uses : TheTile.
-- Results : TheTile is displayed on the screen in its appropriate place.
Symbols : ARRAY (1..4) of CHARACTER := (' ','.','+','#');
BEGIN
null;
END ShowTile;
PROCEDURE ShowTilesLeft IS
-- Display number of tiles remaining
BEGIN
null;
END ShowTilesLeft;
END Display;
|
Orders/WellFounded/Definition.agda | Smaug123/agdaproofs | 4 | 6628 | {-# OPTIONS --safe --warning=error --without-K #-}
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
open import Functions.Definition
module Orders.WellFounded.Definition {a b : _} {A : Set a} (_<_ : Rel {a} {b} A) where
data Accessible (x : A) : Set (lsuc a ⊔ b) where
access : (∀ y → y < x → Accessible y) → Accessible x
WellFounded : Set (lsuc a ⊔ b)
WellFounded = ∀ x → Accessible x
|
src/util-properties-json.ads | Letractively/ada-util | 0 | 25641 | <reponame>Letractively/ada-util<gh_stars>0
-----------------------------------------------------------------------
-- util-properties-json -- read json files into properties
-- Copyright (C) 2013 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
-- The <tt>Util.Properties.JSON</tt> package provides operations to read a JSON
-- content and put the result in a property manager. The JSON content is flattened
-- into a set of name/value pairs. The JSON structure is reflected in the name.
-- Example:
--
-- { "id": "1", id -> 1
-- "info": { "name": "search", info.name -> search
-- "count", "12", info.count -> 12
-- "data": { "value": "empty" }}, info.data -> empty
-- "count": 1 info.count -> 1
-- }
package Util.Properties.JSON is
-- Parse the JSON content and put the flattened content in the property manager.
procedure Parse_JSON (Manager : in out Util.Properties.Manager'Class;
Content : in String;
Flatten_Separator : in String := ".");
-- Read the JSON file into the property manager.
-- The JSON content is flatten into Flatten the JSON content and add the properties.
procedure Read_JSON (Manager : in out Util.Properties.Manager'Class;
Path : in String;
Flatten_Separator : in String := ".");
end Util.Properties.JSON;
|
8_kyu/I_love_you_a_little_a_lot_passionately_not_at_all.asm | UlrichBerntien/Codewars-Katas | 0 | 17339 | <filename>8_kyu/I_love_you_a_little_a_lot_passionately_not_at_all.asm<gh_stars>0
SECTION .text
global how_much_i_love_you
how_much_i_love_you:
xor rdx, rdx
mov rax, rdi
dec rax
mov rcx, 6
div rcx ; rdx = (rdi-1) % 6
mov rax,[table+rdx*8]
ret
SECTION .data
text0: db 'I love you',0
text1: db 'a little',0
text2: db 'a lot',0
text3: db 'passionately',0
text4: db 'madly',0
text5: db 'not at all',0
table: dq text0
dq text1
dq text2
dq text3
dq text4
dq text5
|
assets/assembly/IA32/linux_nasm_progs/nasm_linux_ORG_CH12/tst_gtpt.asm | edassis/SB-Tradutor | 1 | 26947 | <filename>assets/assembly/IA32/linux_nasm_progs/nasm_linux_ORG_CH12/tst_gtpt.asm<gh_stars>1-10
;Test routine for GetPut.asm TEST_GETPUT.ASM
;
; Objective: To test 8-bit integer input & output
; Input: Requests an integer from the user.
; Output: Outputs the input number.
%include "io.mac"
.DATA
prompt_msg db "Please input a number (-128 to +127): ",0
output_msg db "The number is ",0
.CODE
EXTERN GetInt8, PutInt8
.STARTUP
PutStr prompt_msg
call GetInt8
PutStr output_msg
call PutInt8
nwln
done:
.EXIT
|
test/Succeed/Issue1614f.agda | shlevy/agda | 1,989 | 9501 | <reponame>shlevy/agda
-- New NO_POSITIVITY_CHECK pragma for data definitions and mutual
-- blocks
-- Skipping a single data definition in an abstract block.
abstract
{-# NO_POSITIVITY_CHECK #-}
data D : Set where
lam : (D → D) → D
|
apps/rfm69_ntc_sensor/main.adb | ekoeppen/MSP430_Generic_Ada_Drivers | 0 | 3053 | with System.Storage_Elements; use System.Storage_Elements;
with MSP430_SVD; use MSP430_SVD;
with MSPGD.Board; use MSPGD.Board;
with MSPGD.Clock; use MSPGD.Clock;
with MSPGD.Clock.Source;
with MSPGD.GPIO; use MSPGD.GPIO;
with MSPGD.GPIO.Pin;
with Drivers.Text_IO;
with Drivers.NTC;
with Drivers.RFM69;
with Interfaces; use Interfaces;
with CBOR_Codec;
procedure Main is
pragma Preelaborate;
Sensor_Reading_Tag : constant Natural := 6;
Voltage_Tag : constant Natural := 7;
Temperature_Tag : constant Natural := 8;
Humidity_Tag : constant Natural := 9;
Pressure_Tag : constant Natural := 10;
Lux_Tag : constant Natural := 11;
UV_Index_Tag : constant Natural := 12;
Motion_Tag : constant Natural := 13;
Sound_Level_Tag : constant Natural := 14;
CO2_Tag : constant Natural := 15;
Test_Packet_Tag : constant Natural := 64;
Heartbeat_Tag : constant Natural := 65;
Log_Message_Tag : constant Natural := 66;
Ping_Tag : constant Natural := 67;
Register_Value_Tag : constant Natural := 68;
Error_Message_Tag : constant Natural := 69;
Status_Cmd_Tag : constant Natural := 256;
Ping_Cmd_Tag : constant Natural := 257;
Reset_Cmd_Tag : constant Natural := 258;
type R_To_T is record
R : Unsigned_32;
T : Integer;
end record;
package Text_IO is new Drivers.Text_IO (USART => UART);
package Radio is new Drivers.RFM69 (SPI => SPI, Chip_Select => SSEL, IRQ => IRQ, Packet_Size => 62, Frequency => 868_000_000);
package Delay_Clock is new MSPGD.Clock.Source (Frequency => 3000, Input => VLO, Source => ACLK);
package NTC is new Drivers.NTC;
TX_Data : Radio.Packet_Type;
TX_Data_Index : Radio.Packet_Size_Type;
type Config_Record_Type is
record
Node_ID : String (1 .. 4);
Version : String (1 .. 3);
TX_Power : Radio.Output_Power_Type;
TX_Interval : Unsigned_8;
end record;
Config_Record : aliased Config_Record_Type with Import, Convention => Asm, External_Name => "__info_start";
function TX_Power return Radio.Output_Power_Type is
begin
if Config_Record.TX_Power < Radio.Output_Power_Type'First then
return Radio.Output_Power_Type'First;
elsif Config_Record.TX_Power > Radio.Output_Power_Type'Last then
return Radio.Output_Power_Type'Last;
end if;
return Radio.Output_Power_Type (Config_Record.TX_Power);
end TX_Power;
function TX_Interval return Unsigned_16 is
begin
if Config_Record.TX_Interval = 0 then
return 1;
end if;
return Unsigned_16 (Config_Record.TX_Interval);
end TX_Interval;
procedure Write_Data (Data : Unsigned_8) is
begin
TX_Data (TX_Data_Index) := Data;
TX_Data_Index := TX_Data_Index + 1;
end Write_Data;
function Read_Data return Unsigned_8 is
begin
return 0;
end Read_Data;
procedure Print_Registers is new Radio.Print_Registers (Put_Line => Text_IO.Put_Line);
package CBOR is new CBOR_Codec (Write => Write_Data, Read => Read_Data);
function NTC_To_Temperature (NTC_Value : Unsigned_32) return Integer is
NTC_Table_b3380 : constant array (1 .. 28) of R_To_T := (
(0, 1000),
(4096, 505),
(6144, 384),
(8192, 303),
(10240, 244),
(12288, 197),
(14336, 158),
(16384, 126),
(18432, 97),
(20480, 73),
(22528, 51),
(24576, 31),
(26624, 13),
(28672, -3),
(30720, -19),
(32768, -33),
(40960, -80),
(49152, -117),
(57344, -148),
(65536, -174),
(73728, -197),
(81920, -217),
(90112, -234),
(98304, -250),
(106496, -265),
(114688, -278),
(122880, -290),
(Unsigned_32'Last, -500));
Index : Integer := NTC_Table_b3380'Last;
Prev, Next : R_To_T;
D : Unsigned_32;
begin
for I in NTC_Table_b3380'Range loop
Index := I;
exit when NTC_Table_b3380 (I).R > NTC_Value;
end loop;
Prev := NTC_Table_b3380 (Index - 1);
Next := NTC_Table_b3380 (Index);
D := Unsigned_32 (Prev.T - Next.T) * (NTC_Value - Prev.R) / (Next.R - Prev.R);
return Prev.T - Integer (D);
end NTC_To_Temperature;
procedure Transmit_Loop (Interval : Unsigned_16) is
NTC_Value : Unsigned_32;
Temperature : Integer;
Voltage : Unsigned_16;
begin
loop
LED.Set;
NTC_Value := NTC.Value (Integer (Read_NTC));
Temperature := NTC_To_Temperature (NTC_Value);
Voltage := Read_VCC;
Text_IO.Put ("NTC value: ");
Text_IO.Put_Hex (NTC_Value);
Text_IO.Put (" Temperature: ");
Text_IO.Put_Integer (Temperature);
Text_IO.Put (" Voltage: ");
Text_IO.Put_Integer (Integer (Voltage));
Text_IO.New_Line;
TX_Data_Index := Radio.Packet_Size_Type'First;
CBOR.Encode_Tag (Sensor_Reading_Tag);
CBOR.Encode_Array (3);
CBOR.Encode_Byte_String (Config_Record.Node_ID);
CBOR.Encode_Tag (Voltage_Tag);
CBOR.Encode_Decimal_Fraction (Integer (Voltage), -3);
CBOR.Encode_Tag (Temperature_Tag);
CBOR.Encode_Decimal_Fraction (Temperature, -1);
LED.Clear;
Radio.TX (TX_Data, TX_Data_Index - 1);
Radio.Power_Down;
Power_Down;
Delay_Clock.Delay_Slow_Periods (Interval);
Power_Up;
end loop;
end Transmit_Loop;
begin
Init;
Delay_Clock.Init;
SSEL.Set;
Text_IO.Put_Line ("RFM69 sender starting...");
Text_IO.Put ("Node: " & Config_Record.Node_ID & " Interval: ");
Text_IO.Put_Integer (Integer (Config_Record.TX_Interval));
Text_IO.New_Line;
Radio.Init;
Radio.Set_Output_Power (TX_Power);
Print_Registers;
Transmit_Loop (TX_Interval);
end Main;
|
src/q_bingo-q_bombo.ads | mgrojo/bingada | 2 | 15393 | --*****************************************************************************
--*
--* PROJECT: BINGADA
--*
--* FILE: q_bingo-q_bombo.ads
--*
--* AUTHOR: <NAME>
--*
--*****************************************************************************
package Q_BINGO.Q_BOMBO is
procedure P_INIT;
procedure P_SPIN (V_NUMBER : out POSITIVE;
V_CURRENT_INDEX : out T_NUMBER;
V_LAST_NUMBER : out BOOLEAN);
function F_GET_NUMBER (V_INDEX : T_NUMBER) return T_NUMBER;
function F_GET_CURRENT_INDEX return T_NUMBER;
end Q_BINGO.Q_BOMBO;
|
Appl/Calendar/Repeat/repeatCreate.asm | steakknife/pcgeos | 504 | 27948 | <reponame>steakknife/pcgeos<filename>Appl/Calendar/Repeat/repeatCreate.asm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) GeoWorks 1989 -- All Rights Reserved
PROJECT: PC GEOS
MODULE: Calendar/Repeat
FILE: repeatCreate.asm
AUTHOR: <NAME>, Nov 20, 1989
ROUTINES:
Name Description
---- -----------
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 11/20/89 Initial revision
DESCRIPTION:
Implements the creation of repeating events.
$Id: repeatCreate.asm,v 1.1 97/04/04 14:48:56 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
RepeatCode segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
RepeatNewEvent
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Set-up the New Repeat Event DB
CALLED BY: UI (MSG_REPEAT_NEW_EVENT)
PASS: DS, ES = DGroup
RETURN: Nothing
DESTROYED: AX, BX, CX, DX, DI, SI, BP
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 2/4/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
RepeatNewEvent proc far
.enter
; Create the starting time
;
call TimerGetDateAndTime
mov bp, ax ; year to BP also
mov dx, bx ; day/month => DX
xchg dh, dl ; month to high byte
mov cx, (12 shl 8) or 31 ; December 31
mov bx, 1 ; don't adjust the forever excl
call RepeatSetupDuration ; set up the duration stuff
; Clear the event text & reset the time text
;
mov si, offset RepeatBlock:RepeatTimeText
mov bx, 1 ; want a time string
mov cx, ds:[repeatTime] ; hour/minute => CX
call RepeatDateOrTimeToString ; stuff text into object
mov si, offset RepeatBlock:RepeatEventText
call ClearTextField ; clear the text field
; Set up the dialog for use
;
mov ax, MSG_REPEAT_ADD_NOW ; action for OK trigger
mov bx, offset RepeatBlock:NewRepeatMoniker
ifdef GPC_ONLY
mov cx, offset RepeatBlock:RepeatOKCreateMoniker
mov dx, offset RepeatBlock:RepeatCancelCreateMoniker
endif
call RepeatSetupCommon
.leave
ret
RepeatNewEvent endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
RepeatChangeEventLow
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Stuff the dialog box with the current RepeatStruct values
CALLED BY: RepeatChangeEvent
PASS: DS, ES = DGroup
AX = RepeatStruct - group
DI = RepeatStruct - item
RETURN: Nothing
DESTROYED: AX, BX, CX, DX, DI, SI, BP, ES
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 2/4/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
RepeatChangeEventLow proc far
.enter
; Some set-up work
;
call GP_DBLockDerefSI ; lock the RepeatStruct
; Stuff the begining and ending dates
;
mov bp, es:[si].RES_startYear
mov dx, {word} es:[si].RES_startDay
mov ax, es:[si].RES_endYear
mov cx, {word} es:[si].RES_endDay
clr bx ; adjust the forever excl
call RepeatSetupDuration ; setup all the duration stuff
; Stuff the time of day
;
mov si, es:[di] ; re-dereference the hanlde
mov cx, {word} es:[si].RES_minute ; Hour/Minute => CX
mov bx, 1
mov si, offset RepeatBlock:RepeatTimeText
call RepeatDateOrTimeToString
; Stuff the event text
;
push di
mov si, es:[di] ; re-dereference the handle
mov cx, es:[si].RES_dataLength
DBCS < shr cx, 1 ; # bytes -> # chars >
mov dx, es
mov bp, si
add bp, offset RES_data ; DX:BP points to the text
mov si, offset RepeatBlock:RepeatEventText
mov ax, MSG_VIS_TEXT_REPLACE_ALL_PTR
call ObjMessage_repeat_call
pop di
; Setup the control area
;
call RepeatSetupControlArea
; Almost done - set the additional date information
;
call RepeatSetupDateInfo
call DBUnlock ; unlock the RepeatStruct
; Finally, let's set the moniker, the action, and the box usable
;
mov ax, MSG_REPEAT_CHANGE_NOW
mov bx, offset RepeatBlock:ChangeRepeatMoniker
ifdef GPC_ONLY
mov cx, offset RepeatBlock:RepeatOKChangeMoniker
mov dx, offset RepeatBlock:RepeatCancelChangeMoniker
endif
call RepeatSetupCommon
.leave
ret
RepeatChangeEventLow endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
RepeatSetupDuration
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Set up the duration fields and list
CALLED BY: INTERNAL - RepeatNewEvent, RepeatChangeEventLow
PASS: DS = DGroup
DX:BP = Month/Day/Year to start with
CX:AX = Month/Day/Year to end with
BX = 0 - adjust the forever exclusive, else don't
RETURN: Nothing
DESTROYED: AX, BX, CX, DX, SI
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 6/14/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
RepeatSetupDuration proc near
uses di
.enter
; Create the starting and ending dates
;
mov di, bx ; flag => DI
push ax, cx ; save flag, the last date
mov si, offset RepeatBlock:RepeatStartText
clr bx ; create a date string
call RepeatDateOrTimeToString
pop bp, dx ; year => BP, month/day => DX
cmp bp, HIGH_YEAR+1 ; forever ??
pushf ; save this flag
mov si, offset RepeatBlock:RepeatEndText
clr bx ; create a date string
call RepeatDateOrTimeToString
; Set the list properly
;
mov cx, MSG_GEN_SET_NOT_ENABLED ; assume forever
popf ; restore comparison results
je setList
CheckHack <(MSG_GEN_SET_NOT_ENABLED-1) eq (MSG_GEN_SET_ENABLED)>
dec cx ; else set the other entry
setList:
tst di ; check the exclusive flag
jnz done ; don't change the exclusive
mov si, offset RepeatBlock:RepeatDurationList
call RepeatSetItemGroupSelection ; set an item group selection
done:
.leave
ret
RepeatSetupDuration endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
RepeatDateOrTimeToString
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Takes a year/month/day and stuff the resulting string
into the deisred text object
CALLED BY: GLOBAL
PASS: BX = 0
BP = Year
DX = Month/Day
BX = Anything else
CX = Hour/Minute
SI = Text Object in RepeatBlock to hold string
DS = DGroup
RETURN: Nothing
DESTROYED: AX, BX, CX, DX, SI, BP
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 2/9/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
RepeatDateOrTimeToString proc near
uses di
.enter
; Create the string
;
push es:[LMBH_handle] ; save the block handle
segmov es, ds, di ; DGroup => ES
mov di, ds:[repeatBlockHan] ; TextObject => DI:SI
tst bx ; date or time ??
jne timeString
mov cx, DTF_SHORT ; DateTimeFormat
call DateToTextObject ; create & stuff date text
jmp common
timeString:
call TimeToTextObject ; create & stuff time text
common:
pop bx ; block handle => BX
call MemDerefES ; restore the segment
.leave
ret
RepeatDateOrTimeToString endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
RepeatSetupControlArea
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Setup the control area for the RepeatAdd/Change Box
CALLED BY: RepeatChangeEventLow
PASS: ES:*DI = RepeatStruct
RETURN: Nothing
DESTROYED: AX, BX, CX, DX, SI, BP
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 2/11/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
RepeatSetupControlArea proc near
uses di
.enter
; Set up the specify type
;
mov si, es:[di] ; re-dereference the handle
clr ch
mov cl, es:[si].RES_type ; get the event type
cmp cx, RET_WEEKLY ; is this weekly ?
je setFrequency ; if so, jump
push cx ; save the RepeatEventType
andnf cx, 1 ; clear all but the low bit
mov si, offset RepeatBlock:RepeatSpecifyList
call RepeatSetItemGroupSelection
pop cx ; restore the RepeatEventType
; Now set the frequency
;
andnf cx, not 1 ; clear low bit
setFrequency:
mov si, offset RepeatBlock:RepeatFrequencyList
call RepeatSetItemGroupSelection
.leave
ret
RepeatSetupControlArea endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
RepeatSetupDateInfo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Set up all the additional date information
CALLED BY: RepeatChangeEventLow
PASS: ES:*DI = RepeatStruct
RETURN: Nothing
DESTROYED: AX, BX, CX, DX, SI, BP
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 2/11/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
RepeatSetupDateInfo proc near
.enter
; Set-up all the individual DOW fields
;
push di
mov si, es:[di] ; re-dereference the handle
mov ax, MSG_GEN_BOOLEAN_GROUP_SET_GROUP_STATE
clr dx ; indeterminate booleans => DX
mov ch, dh
mov cl, es:[si].RES_DOWFlags ; determinate booleans => CX
mov si, offset RepeatBlock:RepeatLongDOW
call ObjMessage_repeat_send
pop di
; Set the month spin
;
mov si, es:[di] ; re-dereference the handle
mov cl, es:[si].RES_month
mov si, offset RepeatBlock:RepeatMonthValue
call RepeatSetCustomSpinState
; Set the date text
;
mov si, es:[di] ; dereference the handle
mov cl, es:[si].RES_day ; day => CL
call RepeatSetDayRange ; setup the DayRange stuff
; Set the the DOW spin
;
mov si, es:[di] ; re-dereference the handle
mov cl, es:[si].RES_DOW
mov si, offset RepeatBlock:RepeatShortDOW
call RepeatSetCustomSpinState
; Set the date text
;
mov si, es:[di] ; re-dereference the handle
mov cl, es:[si].RES_occur
mov si, offset RepeatBlock:RepeatOccurrence
call RepeatSetCustomSpinState
.leave
ret
RepeatSetupDateInfo endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
RepeatSetDayRange
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Call to set the index value of a CustomSpin gadget
CALLED BY: RepeatSetupDateInfo
PASS: DS = DGroup
CL = Day
RETURN: Nothing
DESTROYED: AX, BX, CX, DX
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 2/11/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
RepeatSetDayRange proc near
uses di
.enter
; Setup the list first
;
clr ch
push cx ; save the day value
jcxz setList
mov cx, -1
setList:
CheckHack <(MSG_GEN_SET_NOT_ENABLED - 1) eq MSG_GEN_SET_ENABLED>
add cx, MSG_GEN_SET_NOT_ENABLED
mov si, offset RepeatBlock:RepeatDateList
call RepeatSetItemGroupSelection
; Now setup the range
;
mov ax, MSG_GEN_VALUE_SET_INTEGER_VALUE
pop cx ; day value => CX
tst cx ; is it zero ??
jnz setRange
mov cx, 1 ; else make it start at day 1
setRange:
clr bp ; a "determinate" value
mov si, offset RepeatBlock:RepeatDateValue
call ObjMessage_repeat_send
.leave
ret
RepeatSetDayRange endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ClearTextField
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Sets the text to either the number passed or blank if CL = -1
CALLED BY: RepeatSetupDateInfo
PASS: SI = Handle of TextObject in RepeatBlock
DS = DGroup
RETURN: Nothing
DESTROYED: AX, BX, CX, DX, BP
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 2/11/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
LocalDefNLString blankByte1 <0>
ClearTextField proc near
uses di
.enter
; Setup the text buffer to use
;
mov dx, cs
mov bp, offset blankByte1 ; text string => DX:BP
clr cx ; no text
mov ax, MSG_VIS_TEXT_REPLACE_ALL_PTR
call ObjMessage_repeat_send
.leave
ret
ClearTextField endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
RepeatSetupCommon
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Sets the OK action, the box moniker, and initiates the
interaction
CALLED BY: RepeatNewEvent, RepeatChangeEventLow
PASS: DS = DGroup
AX = Method for OK action
BX = Chunk containing dialog box moniker
GPC_ONLY:
CX = Chunk containing OK trigger moniker
DX = Chunk containing Cancel trigger moniker
RETURN: Nothing
DESTROYED: AX, BX, CX, DX, DI, SI, BP
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 2/9/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
RepeatSetupCommon proc near
; Set the OK trigger message
;
push bx ; save dialog box moniker
ifdef GPC_ONLY
push dx ; save cancel trigger moniker
push cx ; save OK trigger moniker
endif
mov_tr cx, ax ; message => CX
mov ax, MSG_GEN_TRIGGER_SET_ACTION_MSG
mov si, offset RepeatBlock:RepeatOKTrigger
call ObjMessage_repeat_send
ifdef GPC_ONLY
; Set the OK moniker
;
mov ax, MSG_GEN_USE_VIS_MONIKER
mov si, offset RepeatBlock:RepeatOKTrigger
pop cx ; Moniker chunk => CX
mov dl, VUM_DELAYED_VIA_UI_QUEUE
call ObjMessage_repeat_send ; set the moniker chunk
; Set the Cancel moniker
;
mov ax, MSG_GEN_USE_VIS_MONIKER
mov si, offset RepeatBlock:RepeatCancelTrigger
pop cx ; Moniker chunk => CX
mov dl, VUM_DELAYED_VIA_UI_QUEUE
call ObjMessage_repeat_send ; set the moniker chunk
endif
; Set the window moniker
;
mov ax, MSG_GEN_USE_VIS_MONIKER
mov si, offset RepeatBlock:RepeatAddBox
pop cx ; Moniker chunk => CX
mov dl, VUM_DELAYED_VIA_UI_QUEUE
call ObjMessage_repeat_send ; set the moniker chunk
; Now put it on the screen
;
mov ax, MSG_GEN_INTERACTION_INITIATE
GOTO ObjMessage_repeat_send ; make the dialog box visible
RepeatSetupCommon endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
RepeatSetFrequency
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Set up the type of the RepeatEvent
CALLED BY: UI (MSG_REPEAT_SET_FREQUENCY)
PASS: DS = DGroup
CL = RepeatEventType
RETURN: Nothing
DESTROYED: AX, BX, CX, DX, SI, DI, BP
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 2/1/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
RepeatSetFrequency proc far
; Some set-up work
;
mov ds:[curRepeatType], cl ; store the type of event
cmp cl, RET_WEEKLY
; Enable/disable some of the gadgets
;
mov ax, MSG_GEN_SET_ENABLED ; assume not weekly
mov bp, MSG_GEN_SET_NOT_ENABLED
jne doPart1
xchg ax, bp ; swap the methods
mov si, offset RepeatBlock:RepeatOccurrence
call RepeatSetState
mov si, offset RepeatBlock:RepeatShortDOW
call RepeatSetState
doPart1:
mov si, offset RepeatBlock:RepeatSpecifyList
call RepeatSetState
mov si, offset RepeatBlock:RepeatInfoPart1
call RepeatSetState
; Enable/disable another group of gadgets
;
mov ax, bp ; do reverse of above
mov si, offset RepeatBlock:RepeatLongDOW
call RepeatSetState
cmp ax, MSG_GEN_SET_ENABLED ; was it weekly ??
je done ; if so, we're done
; Either enable or diable the month field
;
mov ax, MSG_GEN_SET_NOT_ENABLED
cmp ds:[curRepeatType], RET_MONTHLY_DATE
je setMonthField
mov ax, MSG_GEN_SET_ENABLED
setMonthField:
mov si, offset RepeatBlock:RepeatMonthValue
call RepeatSetState
; Finally, set the rest of the fields
;
mov si, offset RepeatBlock:RepeatSpecifyList
call RepeatItemGroupGetSelection
mov_tr cx, ax ; result => CX
call RepeatSetSpecify ; Set the specify types
done:
ret
RepeatSetFrequency endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
RepeatSetSpecify
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Set up the Date or Day of Week type of RepeatEvent
CALLED BY: RepeatSetSpecifyDate, RepeatSetSpecifyDOW
PASS: DS = DGroup
CL = 0 for Date
= 1 for Day of Week
RETURN: Nothing
DESTROYED: AX, BX, CX, DX, DI, SI, BP
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 2/1/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
RepeatSetSpecify proc far
.enter
; Set up the Repeat Event type
;
and ds:[curRepeatType], not 1 ; clear the low bit
or ds:[curRepeatType], cl ; set the proper event type
; Enable/disable the short DOW list & the occur field
;
mov ax, MSG_GEN_SET_ENABLED
test ds:[curRepeatType], 1 ; low bit set ??
jne setShortDOW
mov ax, MSG_GEN_SET_NOT_ENABLED
setShortDOW:
mov si, offset RepeatBlock:RepeatShortDOW
call RepeatSetState
mov si, offset RepeatBlock:RepeatOccurrence
call RepeatSetState
; Enable/disable the date field
;
mov ax, MSG_GEN_SET_NOT_ENABLED
test ds:[curRepeatType], 1 ; low bit set ??
jne setDateField
mov ax, MSG_GEN_SET_ENABLED
setDateField:
mov si, offset RepeatBlock:RepeatDateGroup
call RepeatSetState
.leave
ret
RepeatSetSpecify endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
RepeatSetDateExcl
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Enable or disable the date range
CALLED BY: UI (MSG_REPEAT_SET_DATE_EXCL)
PASS: DS, ES = DGroup
CX = Method to send
RETURN: Nothing
DESTROYED: AX, BX, DL, DI, SI
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 6/13/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
RepeatSetDateExcl proc far
.enter
mov si, offset RepeatBlock:RepeatDateValue
mov ax, cx ; method to AX
call RepeatSetState ; set the state
.leave
ret
RepeatSetDateExcl endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
RepeatSetDurationExcl
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Enable/dsiable the duration date fields
CALLED BY: UI (MSG_REPEAT_SET_DURATION_EXCL)
PASS: ES, DS = DGroup
CX = Method to send
RETURN: Nothing
DESTROYED: AX, BX, DL, DI, SI
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 6/13/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
RepeatSetDurationExcl proc far
.enter
mov ax, cx ; method to AX
mov si, offset RepeatBlock:RepeatStartText
call RepeatSetState
mov si, offset RepeatBlock:RepeatEndText
call RepeatSetState
.leave
ret
RepeatSetDurationExcl endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
RepeatAddNow
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Add a repeating event to this calendar
CALLED BY: UI (MSG_REPEAT_ADD_NOW)
PASS: DS = DGroup
RETURN: Nothing
DESTROYED: AX, BX, CX, DX, DI, SI, BP, ES
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 10/30/89 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
RepeatAddNow proc far
.enter
; Verify the information; store Repeat Event if valid
;
sub sp, size RepeatStruct ; allocate a repeat struct
mov bp, sp ; SS:BP points to the struct
call RepeatNewCommon ; attempt to create the Repeat
jc done ; if carry set, fail
call RepeatStore ; store the event
done:
add sp, size RepeatStruct ; clean up the stack
.leave
ret
RepeatAddNow endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
RepeatChangeNow
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Change a repeating event to a new type
CALLED BY: UI (MSG_REPEAT_CHANGE_NOW)
PASS: DS = DGroup
RETURN: Nothing
DESTROYED: AX, BX, CX, DX, DI, SI, BP, ES
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 2/9/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
RepeatChangeNow proc far
.enter
; Load & verify the Repeat Event data
;
sub sp, size RepeatStruct ; allocate a repeat struct
mov bp, sp ; SS:BP points to the struct
call RepeatNewCommon ; attempt to create the Repeat
jc done ; if carry set, fail
; Delete the existing Repeat Event. Store the new one
;
mov ax, ds:[repeatChangeIndex] ; get existing ID
call RepeatModify ; modifiy existing event
done:
add sp, size RepeatStruct ; clean up the stack
.leave
ret
RepeatChangeNow endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
RepeatNewCommon
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Create a new repeat struct based on the infromarion in the
current RepeatBox (either Add or Change)
CALLED BY: RepeatAddNow, RepeatChangeNow
PASS: DS = DGroup
SS:BP = RepeatStruct buffer
RETURN: SS:BP = Filled RepeatStruct
DX = Handle to event text
CX = Length of event text
Carry = Clear if valid
= Set if invalid (no text handle in that case)
DESTROYED: AX, BX, DI, SI
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 2/18/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
repeatCallTable nptr.near \
CreateWeekly,
CreateMonthlyByDate,
CreateMonthlyByDOW,
CreateYearlyByDate,
CreateYearlyByDOW
RepeatNewCommon proc near
.enter
; Some set up work, & initialize some instance data
;
mov bx, ds:[repeatBlockHan] ; RepeatBlock handle to BX
mov al, ds:[curRepeatType] ; move the RepeatEventType
mov ss:[bp].RES_flags, mask EIF_REPEAT
mov ss:[bp].RES_type, al ; store the EventType
mov ss:[bp].RES_DOWFlags, 0 ; no flags set
mov ss:[bp].RES_day, 1 ; 1st day
mov ss:[bp].RES_month, 1 ; January
mov ss:[bp].RES_DOW, 0 ; Sunday
mov ss:[bp].RES_occur, 0 ; First
mov ss:[bp].RES_startYear, LOW_YEAR - 1
mov ss:[bp].RES_endYear, HIGH_YEAR + 1
mov {word} ss:[bp].RES_startDay, -1
mov {word} ss:[bp].RES_endDay, -1
; Now call the approriate creation routine
;
clr ah ; turn into a word
mov si, ax ; enumerated type to SI
EC < cmp si, RepeatEventType ; bad enumerated type ??>
EC < ERROR_GE REPEAT_NEW_BAD_REPEAT_EVENT_TYPE >
sub si, RET_WEEKLY ; make type zero-based
EC < ERROR_L REPEAT_NEW_BAD_REPEAT_EVENT_TYPE >
shl si, 1 ; double to word counter
call {word} cs:[repeatCallTable][si] ; call the handler
jc shortShortDone ; exit with carry set
; First get the time, and store it if possible
;
mov di, ds:[repeatBlockHan] ; RepeatBlock handle to DI
mov si, offset RepeatBlock:RepeatTimeText ; OD => DI:SI
clr cx ; allow no time
call StringToTime ; get the time, if any
jc shortShortDone ; if fail, we're done
mov {word} ss:[bp].RES_minute, cx ; store the time
mov ds:[repeatTime], cx ; store the time value
; Now deal with the dates
;
push bp ; save the structure
mov si, offset RepeatBlock:RepeatDurationList
call RepeatItemGroupGetSelection
pop bp ; restore the structure
mov di, bx ; RepeatBlock handle => DI
cmp ax, MSG_GEN_SET_NOT_ENABLED ; if "forever",
je getText ; then don't bother with dates
mov si, offset RepeatBlock:RepeatStartText ; OD => DI:SI
call StringToDate ; get the date
jc shortDone ; if fail, we're done
mov ss:[bp].RES_startYear, dx ; store the year
mov {word} ss:[bp].RES_startDay, cx ; store the month & day
mov si, offset RepeatBlock:RepeatEndText ; OD => DI:SI
call StringToDate ; get the date
shortShortDone:
jc shortDone ; if fail, we're done
mov bx, CAL_ERROR_REPEAT_DATES ; assume the worst
cmp dx, ss:[bp].RES_startYear ; compare last with start year
jl showError ; if less, failure!
jg datesOK ; if greater, always OK
cmp cx, {word} ss:[bp].RES_startDay ; if equal, check month & day
jl showError ; if less, failure
datesOK:
mov ss:[bp].RES_endYear, dx ; store the year
mov {word} ss:[bp].RES_endDay, cx ; store the month & day
; Finally get the text
getText:
push bp ; save the RangeStruct
mov si, offset RepeatBlock:RepeatEventText ; OD => BX:SI
clr dx
mov ax, MSG_VIS_TEXT_GET_ALL_BLOCK
call ObjMessage_repeat_call ; get the event text
pop bp ; restore the RangeStruct
mov bx, cx ; handle of text => BX
mov_tr cx, ax ; text length => CX
jcxz badText ; nope, so display error
call VerifyVisibleString ; as long as we have at least
jz dismiss ; ...one visible character, OK
; Else make this object the focus & target
badText:
mov ax, MSG_GEN_MAKE_FOCUS
call ObjMessage_repeat_send
mov ax, MSG_GEN_MAKE_TARGET
call ObjMessage_repeat_send
mov bx, CAL_ERROR_REPEAT_NOTEXT ; error message => BX
showError:
mov bp, bx ; error message => BP
call RepeatDisplayError ; display the error
shortDone:
jmp done
; Dismiss the interaction, and store the Repeat event
dismiss:
push bx, cx ; save text handle, length
mov si, offset RepeatBlock:RepeatAddBox
mov ax, MSG_GEN_GUP_INTERACTION_COMMAND
mov cx, IC_DISMISS
call ObjMessage_repeat_send ; dismiss the sucker
clc ; ensure the carry is clear
pop dx, cx ; restore text handle, length
done:
.leave
ret
RepeatNewCommon endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
VerifyVisibleString
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Verify that at least one character in the passed string
is visible (i.e. can be seen by the user)
CALLED BY: GLOBAL
PASS: BX = Handle of text
CX = Length of text
RETURN: Zero = Set if at least one character is visible
DESTROYED: Nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 10/12/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
VerifyVisibleString proc near
uses ax, cx, si, ds
.enter
;
; Lock down the text block, and go through each character
;
call MemLock
mov ds, ax
clr ax, si ; clear AH for SBCS
charLoop:
LocalGetChar ax, dssi
call LocalIsSpace
jz done
loop charLoop
done:
.leave
ret
VerifyVisibleString endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CreateWeekly
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Create weekly events by filling in the appropriate info
CALLED BY: RepeatAddNow
PASS: SS:BP = RepeatStruct
BX = RepeatBlock handle
RETURN: Carry = Set if bad input
DESTROYED: AX, CX, DX, DI, SI
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 10/30/89 Initial version
Don 11/20/89 Tried again
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CreateWeekly proc near
; Get all the DOW's invloved
;
push bp
mov ax, MSG_GEN_BOOLEAN_GROUP_GET_SELECTED_BOOLEANS
mov si, offset RepeatBlock:RepeatLongDOW
call ObjMessage_repeat_call ; selections => AL
pop bp
; Do we have at least one day? If so, store the data
;
tst al ; check for no days
je fail
mov ss:[bp].RES_DOWFlags, al ; store the DOWFlag
clc
ret
; Display the error box
fail:
mov bp, CAL_ERROR_REPEAT_WEEKLY ; error message to display
GOTO RepeatDisplayError ; returns carry set
CreateWeekly endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CreateMonthlyByDate
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Create the monthly events (by date)
CALLED BY: RepeatAddNow
PASS: SS:BP = RepeatStruct
BX = RepeatBlock handle
RETURN: Carry = Set if input error
DESTROYED: AX, CX, DX, SI
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 10/30/89 Initial version
Don 11/21/89 Tried again
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CreateMonthlyByDate proc near
; Get the date from the window
;
push bp ; save the RepeatStruct
mov si, offset RepeatBlock:RepeatDateList
call RepeatItemGroupGetSelection ; selection => AX
clr dl
cmp ax, MSG_GEN_SET_NOT_ENABLED ; if "last",
je storeValue ; then go store the value
mov si, offset RepeatBlock:RepeatDateValue
mov ax, MSG_GEN_VALUE_GET_VALUE
call ObjMessage_repeat_call ; value => DX
storeValue:
pop bp ; restore the RepeatStruct
mov ss:[bp].RES_day, dl ; store the date value
clc ; ensure the carry is clear
ret
CreateMonthlyByDate endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CreateMonthlyByDOW
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Create the monthly events (by Day of Week)
CALLED BY: RepeatAddNow
PASS: SS:BP = RepeatStruct
BX = RepeatBlock handle
RETURN: Carry = Clear
DESTROYED: AX, CX, SI
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 10/30/89 Initial version
Don 11/21/89 Tried again
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CreateMonthlyByDOW proc near
; Get the correct day of week
;
mov si, offset RepeatBlock:RepeatShortDOW
call RepeatCustomSpinGetIndex ; get the DOW
mov ss:[bp].RES_DOW, cl ; store the Day of Week
; Now obtain the occurrence
;
mov si, offset RepeatBlock:RepeatOccurrence
call RepeatCustomSpinGetIndex ; get the occur value
mov ss:[bp].RES_occur, cl ; store the occurrence
clc
ret
CreateMonthlyByDOW endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CreateYearlyByDate
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Create yearly events (by date)
CALLED BY: RepeatAddNow
PASS: SS:BP = RepeatStruct
BX = RepeatBlock handle
RETURN: Carry = Set if input error
DESTROYED: AX, CX, SI
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 10/30/89 Initial version
Don 11/21/89 Tried again
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CreateYearlyByDate proc near
; Get the month and day values
;
call CreateMonthlyByDate ; get the day
jc done
mov si, offset RepeatBlock:RepeatMonthValue
call RepeatCustomSpinGetIndex
mov ss:[bp].RES_month, cl ; store the month
; Now check for legal day value
;
push bp
mov bp, 1984 ; this is a leap year...
mov dh, cl ; month => DH
call CalcDaysInMonth ; days in month => CH
pop bp ; restore RepeatStruct
cmp ch, ss:[bp].RES_day ; cannot exceed days in month
jge done ; if valid, we're OK
mov bp, CAL_ERROR_REPEAT_DATE_Y ; error message to display
call RepeatDisplayError ; returns carry set
done:
ret
CreateYearlyByDate endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CreateYearlyByDOW
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Creates yearly events (by Day of Week)
CALLED BY: RepeatAddNow
PASS: SS:BP = RepeatStruct
BX = RepeatBlock handle
RETURN: CarrySet if input error
DESTROYED: AX, CX, SI
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 10/25/89 Initial version
Don 11/20/89 Tried again
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CreateYearlyByDOW proc near
; Do everything the month does - except get a month
;
call CreateMonthlyByDOW ; get the DOW & occurrence
mov si, offset RepeatBlock:RepeatMonthValue
call RepeatCustomSpinGetIndex
mov ss:[bp].RES_month, cl ; store the month
clc
ret
CreateYearlyByDOW endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
RepeatDisplayError
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Display the calendar error box
CALLED BY: Repeat - GLOBAL
PASS: BP = CalErrorValue
RETURN: Carry = Set
DESTROYED: AX, BX, DI
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 1/18/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
RepeatDisplayError proc near
call GeodeGetProcessHandle ; get my process handle
mov ax, MSG_CALENDAR_DISPLAY_ERROR
clr di
call ObjMessage ; send the message
stc
ret
RepeatDisplayError endp
RepeatSetCustomSpinState proc near
push di
clr ch
clr bp
mov ax, MSG_GEN_VALUE_SET_INTEGER_VALUE
call ObjMessage_repeat_send
pop di
ret
RepeatSetCustomSpinState endp
RepeatSetItemGroupSelection proc near
mov ax, MSG_GEN_ITEM_GROUP_SET_SINGLE_SELECTION
clr dx ; determinate selection
call ObjMessage_repeat_send
mov ax, MSG_GEN_ITEM_GROUP_SEND_STATUS_MSG
GOTO ObjMessage_repeat_send
RepeatSetItemGroupSelection endp
RepeatSetState proc near
mov dl, VUM_DELAYED_VIA_UI_QUEUE
FALL_THRU ObjMessage_repeat_send
RepeatSetState endp
ObjMessage_repeat_send proc near
clr di
omrCommon label near
mov bx, ds:[repeatBlockHan] ; OD => BX:SI
call ObjMessage
ret
ObjMessage_repeat_send endp
RepeatItemGroupGetSelection proc near
mov ax, MSG_GEN_ITEM_GROUP_GET_SELECTION
GOTO ObjMessage_repeat_call
RepeatItemGroupGetSelection endp
RepeatCustomSpinGetIndex proc near
push dx, bp
mov ax, MSG_GEN_VALUE_GET_VALUE
call ObjMessage_repeat_call
mov cx, dx
pop dx, bp
ret
RepeatCustomSpinGetIndex endp
ObjMessage_repeat_call proc near
mov di, mask MF_CALL or mask MF_FIXUP_DS or mask MF_FIXUP_ES
GOTO omrCommon
ObjMessage_repeat_call endp
RepeatCode ends
|
STLangParser.g4 | Yodoken/ANTLR_STLang2KVScript | 0 | 4936 | parser grammar STLangParser;
options { tokenVocab=STLangLexer; }
// Entry
structuredText
: st=statements EOF
;
statements
: ((st+=statement)? SEMICOLON)*
;
// 文
statement
: assignmentStatement #statementAssignment
| procedureStatement #statementProcedure
| returnStatement #statementReturn
| ifStatement #statementIf
| caseStatement #statementCase
| forStatement #statementFor
| whileStatement #statementWhile
| repeatStatement #statementRepeat
| continueStatement #statementContinue
| exitStatement #statementExit
;
// 代入
assignmentStatement
: lhs=variable ASSIGN rhs=expression
;
// 関数呼び出し
procedureStatement
: func=identifier LPAREN (args=parameterList)? RPAREN
;
// FOR .. TO .. BY .. DO .. END_FOR
forStatement
: FOR id=identifier ASSIGN start=expression TO end=expression (BY step=expression)? DO st=statements END_FOR
;
// REEPAT .. UNTIL .. END_REPEAT
whileStatement
: WHILE cond=expression DO st=statements END_WHILE
;
// REEPAT .. UNTIL .. END_REPEAT
repeatStatement
: REPEAT st=statements UNTIL cond=expression END_REPEAT
;
// IF .. THEN .. ELSIF .. THEN .. ELSE .. END_IF
ifStatement
: IF cond=expression THEN st=statements (ELSIF elsif_cond+=expression THEN elsif_st+=statements)* (ELSE else_st=statements)? END_IF
;
// CASE .. OF .. ELSE .. END_CASE
caseStatement
: CASE cond=expression OF (cas+=caseList)* (ELSE else_st=statements)? END_CASE
;
caseList
: elm+=caseElement (COMMA elm+=caseElement)* COLON (st=statements) #caseListWithStatement
| elm+=caseElement (COMMA elm+=caseElement)* COLON #caseListWithoutStatement
;
caseElement
: comp=constant #caseElementSingle
| from=constant RANGE to=constant #caseElementRange
;
// CONTINUE
continueStatement
: CONTINUE
;
// EXIT
exitStatement
: EXIT
;
// RETURN
returnStatement
: RETURN
;
// Expression
// 12.括弧
// 11.関数
// 10.ポインタ(対応しない)
// 9.単項演算
// 8.べき乗
// 7.乗算/除算/剰余
// 6.加算/減算
// 5.比較
// 4.等式/不等式
// 3.論理積
// 2.排他的論理和
// 1.論理和
expression
: (c=constant | v=variable) #expressionNone
| LPAREN expr=expression RPAREN #expressionParen
| func=identifier LPAREN (args=parameterList)? RPAREN #expressionFunction
| op=(PLUS|MINUS|NOT) expr=expression #expressionUnary
| <assoc=right> lhs=expression op=POWER rhs=expression #expressionPower
| lhs=expression op=(ASTERISK | SLASH | MOD) rhs=expression #expressionMultipricative
| lhs=expression op=(PLUS | MINUS) rhs=expression #expressionAdditive
| lhs=expression op=(GT|LT|GE|LE) rhs=expression #expressionRelative
| lhs=expression op=(EQ|NEQ) rhs=expression #expressionEquality
| lhs=expression op=(AND|AMPERSAND) rhs=expression #expressionLogicalAND
| lhs=expression op=XOR rhs=expression #expressionLogicalXOR
| lhs=expression op=OR rhs=expression #expressionLogicalOR
;
parameterList
: expr+=parameterExpression (COMMA expr+=parameterExpression)*
;
parameterExpression
: expression #parameterExpressionNone
| lhs=variable op=ASSIGN rhs=variable #prameterExpressionAssignFrom
| lhs=variable op=OUTREF rhs=variable #prameterExpressionAssignTo
;
// 定数
constant
: (typ=typeOfNumber SHARP)? num=unsignedNumber #constandUnsignedNumber
| (typ=typeOfNumber SHARP)? sgn=sign num=unsignedNumber #constantSignedNumber
| bool #constantBool
| id=identifier #constantIdentifier
| sgn=sign id=identifier #constantSignedIdentifier
| (typ=typeOfString SHARP)? str=string #constantString
;
unsignedNumber
: unsignedInteger
| unsignedReal
;
unsignedInteger
: num=NUM_INT_DEC #unsignedIntegerDec
| num=NUM_INT_BIN #unsignedIntegerBin
| num=NUM_INT_OCT #unsignedIntegerOct
| num=NUM_INT_HEX #unsignedIntegerHex
;
unsignedReal
: num=NUM_REAL
;
sign
: PLUS
| MINUS
;
bool
: TRUE
| FALSE
;
typeOfNumber
: INT
| UINT
| DINT
| UDINT
| REAL
| LREAL
| WORD
| BOOL
;
typeOfString
: STRING
| WSTRING
;
// 変数 ###mada 配列
variable
: identifier
;
// 文字列
string
: STRING_LITERAL #stringMultiByte
| WSTRING_LITERAL #stringWide
;
// Identifier
identifier
: id=IDENTIFIER
;
|
Transynther/x86/_processed/AVXALIGN/_st_/i7-7700_9_0x48.log_21829_1198.asm | ljhsiun2/medusa | 9 | 103751 | .global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r8
push %rbp
lea addresses_WC_ht+0xd7af, %r8
cmp %r11, %r11
mov (%r8), %rbp
nop
nop
xor $24748, %r10
pop %rbp
pop %r8
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r13
push %r9
push %rbp
push %rdi
push %rdx
// Faulty Load
lea addresses_D+0x1e1af, %rbp
nop
nop
nop
nop
inc %rdi
mov (%rbp), %rdx
lea oracles, %rbp
and $0xff, %rdx
shlq $12, %rdx
mov (%rbp,%rdx,1), %rdx
pop %rdx
pop %rdi
pop %rbp
pop %r9
pop %r13
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_D', 'AVXalign': False, 'congruent': 0, 'size': 2, 'same': False, 'NT': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_D', 'AVXalign': True, 'congruent': 0, 'size': 8, 'same': True, 'NT': False}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 6, 'size': 8, 'same': False, 'NT': False}}
{'36': 21829}
36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36
*/
|
TxMark.Antlr/TxMarkParser.g4 | aarondh/TxMark | 0 | 1684 | /*
* TxMark 1.0.0.alpha-5-g61bda79
*
* Copyright (c) 2016 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
parser grammar TxMarkParser;
options { tokenVocab=TxMarkLexer; }
document
: content EOF
;
whitespace
: WHITESPACE
;
left_nametag:
VERTICAL_BAR word COLON
;
right_nametag:
COLON word VERTICAL_BAR
;
variable
: DOLLAR_SIGN word
| MDOLLAR_SIGN word
;
hookName
: QUESTION_MARK word
| MQUESTION_MARK word
;
word
: WORD
| MWORD
;
number
: NUMBER
| MNUMBER
;
quote
: DOUBLE_QUOTE_STRING
;
operand
: variable
| hookName
| submacro
| constant
| word
| ( OPEN_PARENTHESIS expression CLOSE_PARENTHESIS )
;
indexSuffix
: OPERATOR_ST
| OPERATOR_ND
| OPERATOR_RD
| OPERATOR_TH
;
indexOperand
: number indexSuffix OPERATOR_LAST?
| OPERATOR_LAST
| OPEN_PARENTHESIS expression CLOSE_PARENTHESIS
| quote
| word
;
indexOf_subexpression
: OPERATOR_OF operand
;
index_subexpression
: OPERATOR_POSSESSIVE indexOperand
;
index_expression
: operand index_subexpression*
| indexOperand OPERATOR_OF index_expression
;
signed_index_expression
: (OPERATOR_MINUS)? index_expression
;
booleanOperator:
OPERATOR_AND
| OPERATOR_OR
| OPERATOR_LESS_THAN
| OPERATOR_GREATER_THAN
| OPERATOR_LESS_OR_EQUAL
| OPERATOR_GREATER_OR_EQUAL
| OPERATOR_IS OPERATOR_NOT
| OPERATOR_IS OPERATOR_IN
| OPERATOR_IS
| OPERATOR_CONTAINS
| OPERATOR_POWER
| OPERATOR_MULTIPLY
| OPERATOR_DIVIDE
| OPERATOR_MODULO
| OPERATOR_PLUS
| OPERATOR_MINUS
;
subexpression
: booleanOperator expression
;
expression:
signed_index_expression subexpression*
;
constantTrue
: CONSTANT_TRUE
;
constantFalse
: CONSTANT_FALSE
;
constantNull
: CONSTANT_NULL
;
constant
: number
| constantTrue
| constantFalse
| constantNull
| quote
| word
;
macroArgument:
expression
;
literal
: LITERAL
;
punctuation
: PUNCTUATION
;
htmlOpenTag
: LESS_THAN word htmlAttribute* GREATER_THAN
| LESS_THAN word htmlAttribute* SLASH GREATER_THAN
;
htmlCloseTag
: LESS_THAN SLASH word GREATER_THAN
;
htmlElement
: htmlOpenTag
| htmlCloseTag
| script
| style
;
emphasis
: ASTERISK content ASTERISK #single_emphasis
| DOUBLE_ASTERISK content DOUBLE_ASTERISK #double_emphasis
| DOUBLE_SINGLE_QUOTE content DOUBLE_SINGLE_QUOTE #boldface
| DOUBLE_SLASH content DOUBLE_SLASH #italics
| DOUBLE_TILDA content DOUBLE_TILDA #deleted
| DOUBLE_CIRCUMFLEX content DOUBLE_CIRCUMFLEX #superscript
;
muinuta
: DOLLAR_SIGN
| QUESTION_MARK
| COLON
| SLASH
| EQUALS
| LESS_THAN
| GREATER_THAN
| VERTICAL_BAR
| GREATER_THAN
| DOUBLE_QUOTE
| SINGLE_QUOTE
;
htmlAttributeName
: word
;
htmlAttribute
: whitespace? htmlAttributeName whitespace? EQUALS whitespace? htmlAttributeValue
;
htmlAttributeValueContent
: phrase
| hookName
| variable
| literal
| muinuta
| whitespace
| punctuation
;
htmlAttributeValue
: DOUBLE_QUOTE htmlAttributeValueContent*? DOUBLE_QUOTE
| SINGLE_QUOTE htmlAttributeValueContent*? SINGLE_QUOTE
;
script
: OPEN_SCRIPT ( SCRIPT_BODY | SCRIPT_SHORT_BODY)
;
style
: OPEN_STYLE ( STYLE_BODY | STYLE_SHORT_BODY)
;
element
: if_clause
| choose_clause
| each_clause
| set_clause
| hook_definition_clause
| macro_clause (whitespace? macro_clause)*
| hook_clause
| htmlElement
| hookName
| variable
| literal
| emphasis
| muinuta
;
content
: phrase? (element phrase?)*?
;
phrase
: (word | number | whitespace | punctuation)+
;
hook_clause
: left_nametag? hook right_nametag?
;
macro_clause
: left_nametag? macro (whitespace? hook right_nametag?)?
;
each_clause
: MACRO_OPEN KEYWORD_EACH MCOLON macroArgument (OPERATOR_AS variable)? CLOSE_PARENTHESIS (whitespace? hook)?
;
elseIf_clause
: MACRO_OPEN KEYWORD_ELSEIF MCOLON macroArgument CLOSE_PARENTHESIS (whitespace? hook)?
(whitespace? (elseIf_clause | else_clause))?
;
else_clause
: MACRO_OPEN KEYWORD_ELSE MCOLON CLOSE_PARENTHESIS (whitespace? hook)?
;
if_clause
: MACRO_OPEN KEYWORD_IF MCOLON macroArgument CLOSE_PARENTHESIS (whitespace? hook)?
(whitespace? (elseIf_clause | else_clause))?
;
when_clause
: MACRO_OPEN KEYWORD_WHEN MCOLON macroArgument CLOSE_PARENTHESIS (whitespace? hook)?
(whitespace? (when_clause | otherwise_clause))?
;
otherwise_clause
: MACRO_OPEN KEYWORD_OTHERWISE MCOLON CLOSE_PARENTHESIS (whitespace? hook)?
;
choose_clause
: MACRO_OPEN KEYWORD_CHOOSE MCOLON macroArgument CLOSE_PARENTHESIS
(whitespace? (when_clause | otherwise_clause))?
;
set_clause
: MACRO_OPEN KEYWORD_SET MCOLON variable KEYWORD_TO macroArgument CLOSE_PARENTHESIS
;
hook_definition_clause
: MACRO_OPEN KEYWORD_HOOK MCOLON (variable | hookName) CLOSE_PARENTHESIS hook
;
macro
: MACRO_OPEN macroName MCOLON (macroArgument (MCOMMA macroArgument )*)? (OPERATOR_AS variable)? CLOSE_PARENTHESIS
;
submacro
: OPEN_PARENTHESIS macroName MCOLON (macroArgument (MCOMMA macroArgument )*)? CLOSE_PARENTHESIS
;
hook
: OPEN_HOOK content CLOSE_HOOK
;
macroName
: MWORD
;
|
models/tests/test21b.als | transclosure/Amalgam | 4 | 784 | <reponame>transclosure/Amalgam
module tests/test21b // Bugpost by <EMAIL>
open tests/test21a as part1
sig CL extends T2 {}
sig C extends CL {
s : one SM
}
sig SM extends T2 {}
{
t = this.~@s
t = this.~@s
this.@t = this.~@s
this.@t = this.~@s
this.@t = this.~@s
this.@t = this.~@s
}
run { } expect 1
|
alloy4fun_models/trashltl/models/13/3LkvbQFnzopXqfuFa.als | Kaixi26/org.alloytools.alloy | 0 | 4206 | <filename>alloy4fun_models/trashltl/models/13/3LkvbQFnzopXqfuFa.als<gh_stars>0
open main
pred id3LkvbQFnzopXqfuFa_prop14 {
all f : Trash & Protected | after f not in Protected
}
pred __repair { id3LkvbQFnzopXqfuFa_prop14 }
check __repair { id3LkvbQFnzopXqfuFa_prop14 <=> prop14o } |
bb-runtimes/arm/nordic/nrf52/nrf52832/svd/i-nrf52-nvmc.ads | JCGobbi/Nucleo-STM32G474RE | 0 | 24192 | --
-- Copyright (C) 2019, AdaCore
--
-- Copyright (c) 2010 - 2018, Nordic Semiconductor ASA
--
-- 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, except as embedded into a Nordic
-- Semiconductor ASA integrated circuit in a product or a software update for
-- such product, 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.
--
-- 3. Neither the name of Nordic Semiconductor ASA nor the names of its
-- contributors may be used to endorse or promote products derived from this
-- software without specific prior written permission.
--
-- 4. This software, with or without modification, must only be used with a
-- Nordic Semiconductor ASA integrated circuit.
--
-- 5. Any software provided in binary form under this license must not be
-- reverse engineered, decompiled, modified and/or disassembled.
--
-- THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY
-- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-- WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR
-- ASA 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.
--
-- This spec has been automatically generated from nrf52.svd
pragma Ada_2012;
pragma Style_Checks (Off);
with System;
package Interfaces.NRF52.NVMC is
pragma Preelaborate;
pragma No_Elaboration_Code_All;
---------------
-- Registers --
---------------
-- NVMC is ready or busy
type READY_READY_Field is
(-- NVMC is busy (on-going write or erase operation)
Busy,
-- NVMC is ready
Ready)
with Size => 1;
for READY_READY_Field use
(Busy => 0,
Ready => 1);
-- Ready flag
type READY_Register is record
-- Read-only. NVMC is ready or busy
READY : READY_READY_Field;
-- unspecified
Reserved_1_31 : Interfaces.NRF52.UInt31;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for READY_Register use record
READY at 0 range 0 .. 0;
Reserved_1_31 at 0 range 1 .. 31;
end record;
-- Program memory access mode. It is strongly recommended to only activate
-- erase and write modes when they are actively used. Enabling write or
-- erase will invalidate the cache and keep it invalidated.
type CONFIG_WEN_Field is
(-- Read only access
Ren,
-- Write Enabled
Wen,
-- Erase enabled
Een)
with Size => 2;
for CONFIG_WEN_Field use
(Ren => 0,
Wen => 1,
Een => 2);
-- Configuration register
type CONFIG_Register is record
-- Program memory access mode. It is strongly recommended to only
-- activate erase and write modes when they are actively used. Enabling
-- write or erase will invalidate the cache and keep it invalidated.
WEN : CONFIG_WEN_Field := Interfaces.NRF52.NVMC.Ren;
-- unspecified
Reserved_2_31 : Interfaces.NRF52.UInt30 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CONFIG_Register use record
WEN at 0 range 0 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
-- Erase all non-volatile memory including UICR registers. Note that code
-- erase has to be enabled by CONFIG.EEN before the UICR can be erased.
type ERASEALL_ERASEALL_Field is
(-- No operation
Nooperation,
-- Start chip erase
Erase)
with Size => 1;
for ERASEALL_ERASEALL_Field use
(Nooperation => 0,
Erase => 1);
-- Register for erasing all non-volatile user memory
type ERASEALL_Register is record
-- Erase all non-volatile memory including UICR registers. Note that
-- code erase has to be enabled by CONFIG.EEN before the UICR can be
-- erased.
ERASEALL : ERASEALL_ERASEALL_Field :=
Interfaces.NRF52.NVMC.Nooperation;
-- unspecified
Reserved_1_31 : Interfaces.NRF52.UInt31 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ERASEALL_Register use record
ERASEALL at 0 range 0 .. 0;
Reserved_1_31 at 0 range 1 .. 31;
end record;
-- Register starting erase of all User Information Configuration Registers.
-- Note that code erase has to be enabled by CONFIG.EEN before the UICR can
-- be erased.
type ERASEUICR_ERASEUICR_Field is
(-- No operation
Nooperation,
-- Start erase of UICR
Erase)
with Size => 1;
for ERASEUICR_ERASEUICR_Field use
(Nooperation => 0,
Erase => 1);
-- Register for erasing User Information Configuration Registers
type ERASEUICR_Register is record
-- Register starting erase of all User Information Configuration
-- Registers. Note that code erase has to be enabled by CONFIG.EEN
-- before the UICR can be erased.
ERASEUICR : ERASEUICR_ERASEUICR_Field :=
Interfaces.NRF52.NVMC.Nooperation;
-- unspecified
Reserved_1_31 : Interfaces.NRF52.UInt31 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ERASEUICR_Register use record
ERASEUICR at 0 range 0 .. 0;
Reserved_1_31 at 0 range 1 .. 31;
end record;
-- Cache enable
type ICACHECNF_CACHEEN_Field is
(-- Disable cache. Invalidates all cache entries.
Disabled,
-- Enable cache
Enabled)
with Size => 1;
for ICACHECNF_CACHEEN_Field use
(Disabled => 0,
Enabled => 1);
-- Cache profiling enable
type ICACHECNF_CACHEPROFEN_Field is
(-- Disable cache profiling
Disabled,
-- Enable cache profiling
Enabled)
with Size => 1;
for ICACHECNF_CACHEPROFEN_Field use
(Disabled => 0,
Enabled => 1);
-- I-Code cache configuration register.
type ICACHECNF_Register is record
-- Cache enable
CACHEEN : ICACHECNF_CACHEEN_Field :=
Interfaces.NRF52.NVMC.Disabled;
-- unspecified
Reserved_1_7 : Interfaces.NRF52.UInt7 := 16#0#;
-- Cache profiling enable
CACHEPROFEN : ICACHECNF_CACHEPROFEN_Field :=
Interfaces.NRF52.NVMC.Disabled;
-- unspecified
Reserved_9_31 : Interfaces.NRF52.UInt23 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ICACHECNF_Register use record
CACHEEN at 0 range 0 .. 0;
Reserved_1_7 at 0 range 1 .. 7;
CACHEPROFEN at 0 range 8 .. 8;
Reserved_9_31 at 0 range 9 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
type NVMC_Disc is
(Age,
Cr1);
-- Non Volatile Memory Controller
type NVMC_Peripheral
(Discriminent : NVMC_Disc := Age)
is record
-- Ready flag
READY : aliased READY_Register;
-- Configuration register
CONFIG : aliased CONFIG_Register;
-- Register for erasing all non-volatile user memory
ERASEALL : aliased ERASEALL_Register;
-- Deprecated register - Register for erasing a page in Code area.
-- Equivalent to ERASEPAGE.
ERASEPCR0 : aliased Interfaces.NRF52.UInt32;
-- Register for erasing User Information Configuration Registers
ERASEUICR : aliased ERASEUICR_Register;
-- I-Code cache configuration register.
ICACHECNF : aliased ICACHECNF_Register;
-- I-Code cache hit counter.
IHIT : aliased Interfaces.NRF52.UInt32;
-- I-Code cache miss counter.
IMISS : aliased Interfaces.NRF52.UInt32;
case Discriminent is
when Age =>
-- Register for erasing a page in Code area
ERASEPAGE : aliased Interfaces.NRF52.UInt32;
when Cr1 =>
-- Deprecated register - Register for erasing a page in Code area.
-- Equivalent to ERASEPAGE.
ERASEPCR1 : aliased Interfaces.NRF52.UInt32;
end case;
end record
with Unchecked_Union, Volatile;
for NVMC_Peripheral use record
READY at 16#400# range 0 .. 31;
CONFIG at 16#504# range 0 .. 31;
ERASEALL at 16#50C# range 0 .. 31;
ERASEPCR0 at 16#510# range 0 .. 31;
ERASEUICR at 16#514# range 0 .. 31;
ICACHECNF at 16#540# range 0 .. 31;
IHIT at 16#548# range 0 .. 31;
IMISS at 16#54C# range 0 .. 31;
ERASEPAGE at 16#508# range 0 .. 31;
ERASEPCR1 at 16#508# range 0 .. 31;
end record;
-- Non Volatile Memory Controller
NVMC_Periph : aliased NVMC_Peripheral
with Import, Address => NVMC_Base;
end Interfaces.NRF52.NVMC;
|
Appl/Bindery/UI/uiPageName.asm | steakknife/pcgeos | 504 | 172662 | COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) Geoworks 1994 -- All Rights Reserved
PROJECT: Book Bindery
MODULE: Bindery
FILE: uiPageName.asm
AUTHOR: <NAME>, Sep 9, 1994
ROUTINES:
Name Description
---- -----------
REVISION HISTORY:
Name Date Description
---- ---- -----------
jenny 9/ 9/94 Initial revision
DESCRIPTION:
This file contains the code for StudioLocalPageNameControlClass.
$Id: uiPageName.asm,v 1.1 97/04/04 14:40:29 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DocSTUFF segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
StudioLocalPageNameControlGetInfo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Add an extra GCN list and notification type to those
specified by our superclass.
CALLED BY: MSG_GEN_CONTROL_GET_INFO
PASS: *ds:si = StudioLocalPageNameControlClass object
ds:di = StudioLocalPageNameControlClass instance data
es = segment of StudioLocalPageNameControlClass
ax = message #
cx:dx = GenControlBuildInfo structure to fill in
RETURN: nothing
DESTROYED:
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
We need to be able to enable/disable the StudioPageNameControl
when the GrObj tool changes, which means we must add ourselves
to another notification list beyond those chosen by our
superclass. To do this, we get the GenControlBuildInfo
specified by our superclass and then replace the relevant
parts to include, not only the lists we know the superclass
wants to be on, but also an extra GCN list and notification type.
REVISION HISTORY:
Name Date Description
---- ---- -----------
jenny 9/13/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
StudioLocalPageNameControlGetInfo method dynamic StudioLocalPageNameControlClass,
MSG_GEN_CONTROL_GET_INFO
;
; First call our superclass to get the current info.
;
pushdw cxdx
mov di, offset StudioLocalPageNameControlClass
call ObjCallSuperNoLock
;
; Now modify the info.
;
popdw esdi
mov si, offset SLPNC_newFields
mov cx, length SLPNC_newFields
call CopyNewFieldsToBuildInfo
ret
StudioLocalPageNameControlGetInfo endm
NewFieldEntry struct
NFE_offset byte
NFE_size byte
NFE_data dword
NewFieldEntry ends
SLPNC_newFields NewFieldEntry \
<offset GCBI_gcnList, size GCBI_gcnList,
SLPNC_gcnList>,
<offset GCBI_gcnCount, size GCBI_gcnCount,
length SLPNC_gcnList>,
<offset GCBI_notificationList, size GCBI_notificationList,
SLPNC_notificationList>,
<offset GCBI_notificationCount, size GCBI_notificationCount,
length SLPNC_notificationList>
;
; The PageNameControl always wants to be on the text name change,
; document change, and page name change GCN lists. The
; StudioPageNameControl needs to be on the GrObj current tool change
; list as well.
;
SLPNC_gcnList GCNListType \
<MANUFACTURER_ID_GEOWORKS, GAGCNLT_APP_TARGET_NOTIFY_TEXT_NAME_CHANGE>,
<MANUFACTURER_ID_GEOWORKS, GAGCNLT_APP_TARGET_NOTIFY_DOCUMENT_CHANGE>,
<MANUFACTURER_ID_GEOWORKS, GAGCNLT_APP_TARGET_NOTIFY_PAGE_NAME_CHANGE>,
<MANUFACTURER_ID_GEOWORKS,
GAGCNLT_APP_TARGET_NOTIFY_GROBJ_CURRENT_TOOL_CHANGE>
SLPNC_notificationList NotificationType \
<MANUFACTURER_ID_GEOWORKS, GWNT_TEXT_NAME_CHANGE>,
<MANUFACTURER_ID_GEOWORKS, GWNT_DOCUMENT_CHANGE>,
<MANUFACTURER_ID_GEOWORKS, GWNT_PAGE_NAME_CHANGE>,
<MANUFACTURER_ID_GEOWORKS, GWNT_GROBJ_CURRENT_TOOL_CHANGE>
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CopyNewFieldsToBuildInfo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Copy fields from a table of NewFieldEntry structures
to a GenControlBuildInfo structure.
CALLED BY: INTERNAL StudioLocalPageNameControlGetInfo
PASS: es:di = GenControlBuildInfo structure.
cs:si = table of NewFieldEntry structures
cx = table length
RETURN: nothing
DESTROYED: ax, bx, cx, dx, si, bp, ds
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jenny 9/13/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CopyNewFieldsToBuildInfo proc near
segmov ds, cs
copyLoop:
;
; Copy field at which ds:si is pointing.
;
push cx, si, di
clr ax
lodsb ; ax <- offset
add di, ax
clr ax
lodsb
mov_tr cx, ax ; cx <- count
rep movsb
;
; Advance to next field and loop.
;
pop cx, si, di
add si, size NewFieldEntry
loop copyLoop
ret
CopyNewFieldsToBuildInfo endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
StudioLocalPageNameControlUpdateUI
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Handle GWNT_GROBJ_CURRENT_TOOL_CHANGE notification.
CALLED BY: MSG_GEN_CONTROL_UPDATE_UI
PASS: *ds:si = StudioLocalPageNameControlClass object
ds:di = StudioLocalPageNameControlClass instance data
ds:bx = StudioLocalPageNameControlClass object (same as *ds:si)
es = segment of StudioLocalPageNameControlClass
ax = message #
ss:bp = GenControlUpdateUIParams
RETURN: nothing
DESTROYED:
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
This handler works in conjunction with the handler for
MSG_GEN_SET_ENABLED, found below, to disable the
StudioPageNameControl when the text doesn't have the target.
When the GrObj drawing tool changes not to be the text tool,
Studio gives the target to the GrObjBody rather than the text
object. When MSG_GEN_CONTROL_UPDATE_UI arrives here at the
StudioPageNameControl with GWNT_GROBJ_CURRENT_TOOL_CHANGE, we
check whether the tool is the text tool and disable ourselves if not.
Then we hit a snarl - GenControlNotifyWithDataBlock notices
that we're disabled when it thinks we should be enabled, so it
helpfully tries to enable us. In our handler for MSG_GEN_SET_ENABLED,
we decline the favor if the text doesn't have the target.
Note that if we don't intercept MSG_GEN_CONTROL_UPDATE_UI and
disable ourselves here, then GenControlNotifyWithDataBlock
will see that we're enabled, as it thinks we should be, and so
will never try to enable us, denying us the opportunity to
turn up our nose. We must intercept both messages.
REVISION HISTORY:
Name Date Description
---- ---- -----------
jenny 9/ 9/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
StudioLocalPageNameControlUpdateUI method dynamic StudioLocalPageNameControlClass,
MSG_GEN_CONTROL_UPDATE_UI
;
; We handle things here only if the current grobj drawing tool has
; changed.
;
cmp ss:[bp].GCUUIP_changeType,
GWNT_GROBJ_CURRENT_TOOL_CHANGE
je toolChange
;
; Call the superclass to handle all other notifications.
;
mov di, offset StudioLocalPageNameControlClass
call ObjCallSuperNoLock
done:
ret
toolChange:
;
; Get the class of the current tool.
;
mov bx, ss:[bp].GCUUIP_dataBlock
call MemLock
mov es, ax
movdw cxdx, es:[GONCT_toolClass]
call MemUnlock
;
; If the current tool is not the text tool, we disable ourselves.
;
CheckHack <FALSE eq 0>
clr bp ; bp <- FALSE
mov ax, MSG_GEN_SET_NOT_ENABLED
cmp cx, segment EditTextGuardianClass
jne enableDisable
cmp dx, offset EditTextGuardianClass
jne enableDisable
;
; Ah, it is the text tool. We revive.
;
mov ax, MSG_GEN_SET_ENABLED
mov bp, TRUE
enableDisable:
;
; Declare our decision and keep a record of it.
;
mov ds:[di].SLPNCI_allowEnable, bp
mov dl, VUM_DELAYED_VIA_UI_QUEUE
call ObjCallInstanceNoLock
jmp done
StudioLocalPageNameControlUpdateUI endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
StudioLocalPageNameControlSetEnabled
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Enable the StudioPageNameControl only if it's a good idea.
CALLED BY: MSG_GEN_SET_ENABLED
PASS: *ds:si = StudioLocalPageNameControlClass object
ds:di = StudioLocalPageNameControlClass instance data
ds:bx = StudioLocalPageNameControlClass object (same as *ds:si)
es = segment of StudioLocalPageNameControlClass
ax = message #
RETURN: nothing
DESTROYED: di
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
See comments for StudioLocalPageNameControlUpdateUI, above.
REVISION HISTORY:
Name Date Description
---- ---- -----------
jenny 11/30/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
StudioLocalPageNameControlSetEnabled method dynamic StudioLocalPageNameControlClass,
MSG_GEN_SET_ENABLED
;
; We refuse to be enabled unless we've previously decided it's
; allowable.
;
cmp ds:[di].SLPNCI_allowEnable, TRUE
if not ERROR_CHECK
jne done
else
je callSuper
cmp ds:[di].SLPNCI_allowEnable, FALSE
je done
ERROR STUDIO_PAGE_NAME_CONTROL_INSTANCE_DATA_TRASHED
callSuper:
endif
mov di, offset StudioLocalPageNameControlClass
call ObjCallSuperNoLock
done:
ret
StudioLocalPageNameControlSetEnabled endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
StudioLocalPageNameControlSetAllowEnable
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Set the SLPNCI_allowEnable instance data field
CALLED BY: MSG_SLPNC_SET_ALLOW_ENABLE
PASS: *ds:si = StudioLocalPageNameControlClass object
ds:di = StudioLocalPageNameControlClass instance data
ds:bx = StudioLocalPageNameControlClass object (same as *ds:si)
es = segment of StudioLocalPageNameControlClass
ax = message #
cx = BooleanWord
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jenny 12/ 1/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
StudioLocalPageNameControlSetAllowEnable method dynamic StudioLocalPageNameControlClass,
MSG_SLPNC_SET_ALLOW_ENABLE
mov ds:[di].SLPNCI_allowEnable, cx
ret
StudioLocalPageNameControlSetAllowEnable endm
DocSTUFF ends
|
programs/oeis/036/A036100.asm | neoneye/loda | 22 | 13127 | <reponame>neoneye/loda
; A036100: Centered cube numbers: (n+1)^22 + n^22.
; 1,4194305,31385253913,17623567104025,2401777977060041,134005889633282761,4041442752425255185,77696797343421194513,1058557878478449439345,10984770902183611232881,91402749386839761113321,633464188299276178706665,3763900316867291522750713,19610816941310676211030265,91217254490147965881263521,384303286248137213500171681,1484047886342493527698843745,5304991410633477787491772513,17700408952286420236319081785,55513020418174090907801371961,164637367386105632949003612841,464122204750325190345650336425,1249274312140215732803387284913,3223359936252183891464173673905,7999855387556989203026427253201,19155770539242362073950967566801,44374583035794172948902615229705,99685453669678186249567752987913,217634737830128876326985675761625,462663034633083302439338564577241,959401294285138073036733040138561,1943664912828844980169357122443585,3852578745478613650761070587256513,7480978302089065809697193537674945,14248213560689530810701467979989081,26646012711786851096551865332908121,48978953062000605648752625819773065,88571303287528388487788407055640713,157707530431474246256856285536118865,276712767727764984065901359914608721,478783903593903582494593171234930481,817479351282595983195130820588388145
sub $2,$0
add $0,1
pow $0,22
pow $2,22
add $0,$2
|
agda/Algebra/Construct/Free/Semilattice/Union.agda | oisdk/combinatorics-paper | 6 | 9563 | <filename>agda/Algebra/Construct/Free/Semilattice/Union.agda
{-# OPTIONS --cubical --safe #-}
module Algebra.Construct.Free.Semilattice.Union where
open import Prelude
open import Path.Reasoning
open import Algebra
open import Algebra.Construct.Free.Semilattice.Definition
open import Algebra.Construct.Free.Semilattice.Eliminators
infixr 5 _∪_
_∪_ : 𝒦 A → 𝒦 A → 𝒦 A
_∪_ = λ xs ys → [ union′ ys ]↓ xs
where
union′ : 𝒦 A → A ↘ 𝒦 A
[ union′ ys ]-set = trunc
[ union′ ys ] x ∷ xs = x ∷ xs
[ union′ ys ][] = ys
[ union′ ys ]-dup = dup
[ union′ ys ]-com = com
∪-assoc : (xs ys zs : 𝒦 A) → (xs ∪ ys) ∪ zs ≡ xs ∪ (ys ∪ zs)
∪-assoc = λ xs ys zs → ∥ ∪-assoc′ ys zs ∥⇓ xs
where
∪-assoc′ : (ys zs : 𝒦 A) → xs ∈𝒦 A ⇒∥ (xs ∪ ys) ∪ zs ≡ xs ∪ (ys ∪ zs) ∥
∥ ∪-assoc′ ys zs ∥-prop = trunc _ _
∥ ∪-assoc′ ys zs ∥[] = refl
∥ ∪-assoc′ ys zs ∥ x ∷ xs ⟨ Pxs ⟩ = cong (x ∷_) Pxs
∪-identityʳ : (xs : 𝒦 A) → xs ∪ [] ≡ xs
∪-identityʳ = ∥ ∪-identityʳ′ ∥⇓
where
∪-identityʳ′ : xs ∈𝒦 A ⇒∥ xs ∪ [] ≡ xs ∥
∥ ∪-identityʳ′ ∥-prop = trunc _ _
∥ ∪-identityʳ′ ∥[] = refl
∥ ∪-identityʳ′ ∥ x ∷ xs ⟨ Pxs ⟩ = cong (x ∷_) Pxs
cons-distrib-∪ : (x : A) (xs ys : 𝒦 A) → x ∷ xs ∪ ys ≡ xs ∪ (x ∷ ys)
cons-distrib-∪ = λ x xs ys → ∥ cons-distrib-∪′ x ys ∥⇓ xs
where
cons-distrib-∪′ : (x : A) (ys : 𝒦 A) → xs ∈𝒦 A ⇒∥ x ∷ xs ∪ ys ≡ xs ∪ (x ∷ ys) ∥
∥ cons-distrib-∪′ x ys ∥-prop = trunc _ _
∥ cons-distrib-∪′ x ys ∥[] = refl
∥ cons-distrib-∪′ x ys ∥ z ∷ xs ⟨ Pxs ⟩ =
x ∷ ((z ∷ xs) ∪ ys) ≡⟨⟩
x ∷ z ∷ (xs ∪ ys) ≡⟨ com x z (xs ∪ ys) ⟩
z ∷ x ∷ (xs ∪ ys) ≡⟨ cong (z ∷_) Pxs ⟩
((z ∷ xs) ∪ (x ∷ ys)) ∎
∪-comm : (xs ys : 𝒦 A) → xs ∪ ys ≡ ys ∪ xs
∪-comm = λ xs ys → ∥ ∪-comm′ ys ∥⇓ xs
where
∪-comm′ : (ys : 𝒦 A) → xs ∈𝒦 A ⇒∥ xs ∪ ys ≡ ys ∪ xs ∥
∥ ∪-comm′ ys ∥-prop = trunc _ _
∥ ∪-comm′ ys ∥[] = sym (∪-identityʳ ys)
∥ ∪-comm′ ys ∥ x ∷ xs ⟨ Pxs ⟩ =
(x ∷ xs) ∪ ys ≡⟨⟩
x ∷ (xs ∪ ys) ≡⟨ cong (x ∷_) Pxs ⟩
x ∷ (ys ∪ xs) ≡⟨⟩
(x ∷ ys) ∪ xs ≡⟨ cons-distrib-∪ x ys xs ⟩
ys ∪ (x ∷ xs) ∎
∪-idem : (xs : 𝒦 A) → xs ∪ xs ≡ xs
∪-idem = ∥ ∪-idem′ ∥⇓
where
∪-idem′ : xs ∈𝒦 A ⇒∥ xs ∪ xs ≡ xs ∥
∥ ∪-idem′ ∥-prop = trunc _ _
∥ ∪-idem′ ∥[] = refl
∥ ∪-idem′ ∥ x ∷ xs ⟨ Pxs ⟩ =
((x ∷ xs) ∪ (x ∷ xs)) ≡˘⟨ cons-distrib-∪ x (x ∷ xs) xs ⟩
x ∷ x ∷ (xs ∪ xs) ≡⟨ dup x (xs ∪ xs) ⟩
x ∷ (xs ∪ xs) ≡⟨ cong (x ∷_) Pxs ⟩
x ∷ xs ∎
module _ {a} {A : Type a} where
open Semilattice
open CommutativeMonoid
open Monoid
𝒦-semilattice : Semilattice a
𝒦-semilattice .commutativeMonoid .monoid .𝑆 = 𝒦 A
𝒦-semilattice .commutativeMonoid .monoid ._∙_ = _∪_
𝒦-semilattice .commutativeMonoid .monoid .ε = []
𝒦-semilattice .commutativeMonoid .monoid .assoc = ∪-assoc
𝒦-semilattice .commutativeMonoid .monoid .ε∙ _ = refl
𝒦-semilattice .commutativeMonoid .monoid .∙ε = ∪-identityʳ
𝒦-semilattice .commutativeMonoid .comm = ∪-comm
𝒦-semilattice .idem = ∪-idem
|
oeis/242/A242376.asm | neoneye/loda-programs | 11 | 15766 | <reponame>neoneye/loda-programs<filename>oeis/242/A242376.asm
; A242376: Numerators of b(n) = b(n-1)/2 + 1/(2*n), b(0)=0.
; Submitted by <NAME>
; 0,1,1,5,1,4,13,151,16,83,73,1433,647,15341,28211,10447,608,19345,18181,651745,771079,731957,2786599,122289917,14614772,140001721,134354573,774885169,745984697,41711914513,80530073893,4825521853483,145908326272,282654114997,274050911261,531914398571,129164452987,4645847894222,18079412000719,35204192311819,4287344619904,342747737449289,334365081328507,28068960355850251,13707288497202919,26790049828872949,52386756782140399,4817074608461204153,294648374308590304,4038970064194568803
mul $0,2
mov $1,41
lpb $0
sub $0,2
div $1,2
add $2,1
dif $3,2
mul $3,$2
add $3,$1
mul $1,$2
mul $1,2
lpe
mov $0,$3
gcd $3,$1
mov $1,$0
div $1,$3
mov $0,$1
|
COM/testprogs/keycon.asm | johnsonjh/com-cpm | 5 | 95963 | <gh_stars>1-10
; Keyboard Controller Version 2.0
;
; Author: <NAME> 3/30/84
;
; This is the firmware for an 8085 based serial keyboard.
; The hardware is 1 8085, 1 2716, 2 8155's, and 1 8251. It
; features autorepeat, a 240 character buffer, a keyboard macro
; facility, and 256 characters of macro storage. It features
; polled operation (with typeahead) or standard operation
; (without typeahead). Macro lookup may be disabled, and a
; META key may be enabled (8th bit set) under key control.
; The keyboard is a modified Keytronic 65-1655 word processing
; keyboard.
; Port Equates ...
SERCMD EQU 09H ; 8251 command port
SERDAT EQU 08H ; 8251 data port
P1CMD EQU 10H ; 8155 #1 command port
P1ADAT EQU 11H ; " " A data port
P1BDAT EQU 12H ; " " B data port
P1CDAT EQU 13H ; " " C data port
P1TLO EQU 14H ; " " Timer, low
P1THI EQU 15H ; " " Timer, high
P2CMD EQU 18H ; 8155 #2 command port
P2ADAT EQU 19H ; " " A data port
P2BDAT EQU 1AH ; " " B data port
P2TLO EQU 1CH ; " " Timer, low
P2THI EQU 1DH ; " " Timer, high
;
; Miscellaneous Equates
;
RAM1 EQU 1000H ; Start of RAM area #1
RAM2 EQU 1800H ; " " " " #2
RAM1TP EQU 1100H ; End of RAM #1 +1
RAM2TP EQU 1900H ; End of RAM #2 +1
STACK EQU RAM2TP ; Stack at end of RAM 2
BUFST EQU RAM2 ; Start of typeahead buffer.
BUFEND EQU RAM2TP-RAM2-32 ; End of buffer.
MACBUF EQU RAM1 ; Keyboard macro buffer.
BPTIME EQU 40 ; 1/5 Second beep time.
RTIM1 EQU 100 ; 1/2 Sec delay to repeat start.
RTIM2 EQU 20 ; 1/10 Sec initial repeat time.
RTIM3 EQU 10 ; 1/20 Sec final repeat time.
T100MS EQU 20 ; 100 msec power on beep.
BON EQU 8 ; Beeper on -- C port data.
BOFF EQU 0 ; Beeper off
ACK EQU 0FEH ; Acknowledge ; Communication constants and
NAK EQU 0FFH ; No-Acknowledge ; buffer flags. Don't change!
BAUDIV EQU 15 ; Divisor for 9600 baud.
; = 4.608MHz/16/2/9600
; Port contents -- keys
KMSG EQU 1 ; MSG key = bit 0 P1A Do META key lock for EDIT.
KCONV EQU 2 ; CONV key = bit 1 " Do macro lookups.
KPAGE EQU 4 ; PAGE key = bit 2 " Lock number pad in control mode.
KLOCAL EQU 8 ; LOCAL key = bit 3 " Do typeahead buffering.
KSHIFT EQU 1 ; SHIFT keys = bit 1 P2A
KCTRL EQU 2 ; CTRL keys = bit 2 "
KEDIT EQU 4 ; EDIT keys = bit 3 "
KYELLO EQU 8 ; YELLOW key = bit 4 "
KCAPSL EQU 16 ; CAPS lock = bit 5 "
KREPT EQU 32 ; REPT key = bit 6 "
KAKD EQU 64 ; any key = bit 7 "
ORG RAM2TP-32 ; RAM storage.
TIMER: DS 2 ; Repeat timer.
BTIMR: DS 2 ; Beeper timer.
TIMLOD: DS 2 ; Timer reload storage.
RTCNT: DS 1 ; Repeat timer count for increment.
QHEAD: DS 2 ; Queue head pointer.
QTAIL: DS 2 ; Queue tail pointer.
LASTCH: DS 1 ; Last typed char (for repeat).
ORG 0
RESET: MVI A,0CEH ; Init USART --
OUT SERCMD ; 2 stop, no parity, x16 clock async,
MVI A,15H ; Enable Rx, Tx, clear errors.
OUT SERCMD
MVI A,0EDH ; 5msec pulses on timer #1, main clock
OUT P1THI ; interrupt for beep & repeat times.
MVI A,0 ; Don't start yet. (15360 decimal)
OUT P1TLO
MVI A,0D4H ; Start timer, 'A' interrupts.
OUT P1CMD ; Alt mode 3, A=B=IN on #1
MVI A,BAUDIV/256+40H ; x16 Square wave.
OUT P2THI ; ON TIMER #2. (Baud clock)
MVI A,BAUDIV AND 0FFH
OUT P2TLO
MVI A,0C0H ; Start timer, no interrupts.
OUT P2CMD ; ALT mode 1, A=B=input
JMP INIT2 ; Continue elsewhere, past RST locs.
; Interrupt Service Locations.
ORG 2CH ; RST 5.5 Timer interrupt.
JMP TIMINT
ORG 34H ; RST 6.5 Serial input char interrupt.
JMP SERINT
ORG 38H ; RST 7 ( Block RST 7 instructions )
DI ; ( which fill all unused ROM )
JMP ISOOPS
ORG 3CH ; RST 7.5 Keyboard interrupt
JMP KEYINT ; on char typed.
ORG 100H ; More code here.
INIT2: LXI H,0 ; Clear repeat timer
SHLD TIMER
LXI H,T100MS ; 100msec beep on power-up.
SHLD BTIMR
LXI SP,STACK
CALL CLRQ ; Clear the typeahead buffer.
CALL KILMACS ; Clear the macro buffer.
MVI A,58H ; Enable interrupts.
DB 30H ; SIM instruction.
EI
JMP START ; and GO!
; Main loop checks for no keys pressed and stops repeat
; timer if so. All other tasks are interrupt driven.
START: IN P2ADAT ; Check for falling edge.
START2: ANI KAKD ; of keydown flag.
JZ START ; Found leading edge?
IN P2ADAT
ANI KAKD
JNZ START2 ; Found falling edge?
LXI H,0
SHLD TIMER ; Yes, clear repeat timer.
JMP START ; Go back
;
; Clear the typeahead queue. Called by SCOTCH
; command and by the initialization routine.
;
CLRQ: LXI H,BUFST
SHLD QHEAD ; Clear by setting head & tail
SHLD QTAIL ; to same place.
RET
;
; Enqueue the 'A' character if possible. Return a
; NAK and beep bell if queue is full, discarding
; the character. Called by SHIPIT.
;
ENQ: PUSH H
PUSH PSW ; Save state
LHLD QTAIL
XCHG
LHLD QHEAD ; Look for end of buffer.
INX H ; Bump pointer.
MVI A,BUFEND
CMP L
JNZ ENQ1 ; No
LXI H,BUFST ; Yes, wrap around to beginning.
ENQ1: MOV A,L
CMP E ; Check for equal pointers.
JZ QFULL
XCHG ; BUFFERS<=256 CHARS ONLY!!!!!!!!!
LHLD QHEAD ; Get old head pointer
POP PSW ; and char to enqueue.
MOV M,A ; Do so.
XCHG ; Retrieve new calculated pointer
SHLD QHEAD ; and store it.
POP H
RET
QFULL: POP PSW ; Clean stack.
LXI H,BPTIME
SHLD BTIMR ; Ring bell
MVI A,NAK ; if queue is full,
POP H ; and return NAK.
RET
;
; Get a character from the queue if possible.
; Return a NAK if queue is empty. Called by
; SERINT subcommand NXTCHR.
;
DEQ: LHLD QHEAD
XCHG
LHLD QTAIL
MOV A,L
CMP E ; Are pointers equal?
MVI A,NAK ; Get NAK now.
RZ ; Return NAK if empty,
MOV D,M ; else get char.
INX H
MVI A,BUFEND ; Check for end of bufr
CMP L
JNZ DEQ1 ; No
LXI H,BUFST ; Yes, wrap around.
DEQ1: SHLD QTAIL
MOV A,D ; Get char
RET ; and return.
;
; Search learn buffer for 'A' character. Leave HL
; pointing at it if found, or at $FF terminator.
; Called by SHIPIT and SERINT subcommand LEARN.
;
SEARCH: MOV B,A ; Tuck away char.
LXI H,MACBUF
CMP M ; Norman?
RZ
SRLOP1: CALL SRLOOP ; Search for next terminator.
CPI NAK ; At end of table?
RZ ; Yes, quit.
INR L ; Else is a $FE separator.
MOV A,M ; Bump to next and check it.
CMP B ; Is it our baby?
RZ
JMP SRLOP1 ; No, try next one.
SRLOOP: MOV A,M
CPI ACK ; Is char a terminator?
RNC ; No.
INR L
JNZ SRLOOP ; Didn't fall off end, keep looking.
DCR L
RET ; Make sure pointer is in table.
;
; 5 msec interrupt timer handler. Takes care of
; the repeat and beeper timers, and of emptying the
; typeahead buffer if the 'LOCAL' key is not down.
; Called by RST 5.5.
;
TIMINT: PUSH PSW ; Save state.
PUSH D
PUSH H
IN P1ADAT ; Reset timer interrupt
LHLD BTIMR ; every 5 msec.
MOV A,H ; Decrement timer.
ORA L ; If not zero only
JZ NOBEEP
DCX H ; Do the decrement.
SHLD BTIMR
MVI A,BON ; Turn on beeper.
BP1: OUT P1CDAT
JMP RPT
NOBEEP: MVI A,BOFF ; Shut off beeper.
JMP BP1
RPT: LHLD TIMER ; Handle repeat timer.
MOV A,H
ORA L ; Decrement if not zero.
CNZ NOTOFF
IN P1ADAT ; Check to see if we must empty
ANI KLOCAL ; typeahead buffer steadily.
JZ TIMEND ; 'LOCAL' key? Don't empty buffer.
IN SERCMD ; Check for ready, don't if not.
ANI 1
JZ TIMEND
CALL DEQ ; Is there a char to send?
CPI NAK
JZ TIMEND ; No, skip sending NAK,
OUT SERDAT ; else ship it.
TIMEND: POP H ; Return from all timer ops.
POP D
POP PSW
EI
RET
NOTOFF: DCX H ; Decrement timer.
MOV A,H
ORA L ; Detect edge of zero state.
JZ LODTMR
SHLD TIMER ; No
RET
LODTMR: LHLD TIMLOD ; Reload timer.
SHLD TIMER
LDA RTCNT ; Get rate count.
ORA A
JZ FASTRP ; If zero then we're already at
DCR A ; fast rate, else decrement rate.
STA RTCNT
DCX H ; Decrement reload value
SHLD TIMLOD ; so succeeding repeats faster.
FASTRP: LDA LASTCH ; Finally do the repeat itself
CALL SHIPIT ; and put in output buffer.
RET
;
; Take translated character and look up any
; aliases in the macro buffer and enqueue
; all the chars in the definition, if any.
; called by KEYINT and TIMINT sections.
;
SHIPIT: MOV B,A
IN P1ADAT ; In lookup mode?
ANI KCONV ; ( CONV key )
MOV A,B
JNZ ENQ ; No, directly enqueue it,
CALL SEARCH ; else look for it.
CPI NAK ; Found?
MOV A,B
JZ ENQ ; Yes, enqueue definition.
SHLOOP: INX H
MOV A,M
CPI ACK ; Look for terminator at end.
RNC ; $FE OR $FF WILL DO.
CALL ENQ
JMP SHLOOP
; Take raw char from keyboard and translate to
; ASCII, set repeat timer, and handle the
; 'BREAK' character. Enqueues the resultant
; character, if any. Called by RST 7.5.
;
KEYINT: PUSH PSW
PUSH H
IN P2BDAT ; Get raw key.
CMA ; Invert to proper sense.
ANI 7FH ; Mask to 7 bits.
CPI 10H ; Is it a shifting key?
JC SHFTOP
CPI 2FH ; No, 'BREAK'?
JNZ NOBRK
LXI H,0 ; Yes
SHLD TIMER ; Stop autorepeat if running.
MVI A,ACK
CALL SENDCH ; Send $FE, bypass buffering!
JMP SHFTOP ; and quit.
NOBRK: CALL LOOKUP ; Normal char, lookup keycode.
STA LASTCH ; Save for autorepeat.
CALL SHIPIT ; Ship char (or macro)
LXI H,RTIM1 ; Start autorepeat timer.
SHLD TIMER
LXI H,RTIM2 ; Set slowest reload rate.
SHLD TIMLOD
MVI A,RTIM2-RTIM3
STA RTCNT ; Set repeat accel counter.
IN P2ADAT ; Is REPEAT key down?
ANI KREPT
JZ SHFTOP ; No,
LXI H,RTIM3 ; else reload at max repeat rate.
SHLD TIMLOD
SHLD TIMER ; From the start.
MVI A,0
STA RTCNT
SHFTOP: POP H
POP PSW
EI
RET
; Handle request from host system for service.
; Ignore errors on serial input line.
; Also ignore command # larger than maximum.
; Called by RST 6.5.
;
SERINT: PUSH PSW
PUSH H
LXI H,SHFTOP ; Return address.
PUSH H
IN SERCMD
ANI 38H ; Errors?
JZ SEROK
IN SERDAT ; Yes, clear register.
MVI A,15H ; Reset errors.
OUT SERCMD
RET ; Return to SHFTOP return point.
SEROK: IN SERDAT ; Get command.
LXI H,CMDTAB
CPI MAXCMD ; Too big?
RNC ; Yes, quit.
ADD A ; Double it.
MOV E,A
MVI D,0
DAD D ; Index into table.
MOV E,M ; Find routine address --
INX H
MOV D,M
XCHG
PCHL ; and execute it.
;
; Defined commands:
;
; 0 Enquire for next character.
; 1 Sound bell.
; 2 Clear typeahead buffer.
; 3 Empty the Macro definition buffer.
; 4 Learn following definition.
;
CMDTAB: DW NXTCHR
DW DOBEEP
DW SCOTCH
DW KILMACS
DW LEARN
;
MAXCMD EQU 5
NXTCHR: CALL DEQ ; Get char if any.
CALL SENDCH ; Send it.
RET
DOBEEP: LXI H,BPTIME
SHLD BTIMR ; Start beeper.
RET
SCOTCH: CALL CLRQ ; Empty buffer.
RET
KILMACS: MVI A,NAK ; Dump MACRO buffer
STA MACBUF ; by putting term. at end.
RET
;
; Learn the definition of the following character.
; The definition is the characters following the
; redefined character until a terminating $FF or
; until the learn buffer is full. Keyboard
; processing is suspended during the learn
; sequence. If the definition is of null length
; the def. is removed, likewise a redefinition
; removes the old definition first.
;
LEARN: CALL GETCH ; Get char to learn def for.
PUSH PSW ; Save it.
CALL SEARCH ; Find any old def, or the
CPI NAK ; end of the buffer.
JZ NODUP
DCX H ; Point to preceding delimiter.
MOV E,L
MOV D,H
DELOOP: INX D ; Find end of this old def.
LDAX D
CPI ACK ; At delimeter.
JC DELOOP ; No, keep looking.
CPI NAK ; If last one then no delete needed.
JZ NODUP
MVI C,0
MOV B,E
DELOP1: LDAX D ; Now how long is rest of table?
INX D
INR C ; ( in C )
CPI NAK ; Look for terminator.
JNZ DELOP1
DCX D ; Leave DE at delim after def.
MOV E,B
DELOP2: LDAX D
MOV M,A ; Move rest of table down --
INX D
INX H
DCR C
JNZ DELOP2 ; until all moved.
DCX H ; HL at delimiter at end of table.
NODUP: MOV A,L ; Room for any new def?
CPI ACK-1
JNC NOROOM
MVI M,ACK ; New separator at end of table.
INX H
POP PSW ; Get char 'NAME.'
MOV M,A ; Save in table.
INX H
CALL GETCH ; Now see if a null def, get char.
CPI NAK ; If end then erase name.
JNZ INSLP1
DCX H ; Point to separator.
DCX H
MVI M,NAK ; New terminator.
RET
INSLOP: CALL GETCH ; Get char in definition.
INSLP1: MOV M,A ; Put into table.
CPI ACK ; Don't insert separators!
JZ INSLOP
INX H ; Else OK.
CPI NAK ; A terminator?
RZ ; Yes, all done!
MVI A,NAK
CMP L ; End of table space?
JNZ INSLOP ; No, go for more.
MOV M,A ; Make sure a terminator is there
JMP NORLOP ; in the table, then swallow
NOROOM: POP PSW ; rest of definition!
NORLOP: CALL GETCH
CPI NAK
JNZ NORLOP ; Until terminating NAK
RET
;
; Get a character from the serial line
; in a polled manner. Called by LEARN
; for getting the definition.
;
GETCH: IN SERCMD
ANI 2 ; Errors?
JZ GETCH ; Yes, ignore.
IN SERDAT ; Get data.
RET
;
; Send the 'A' character out the serial line.
; Wait for ready first. Called by SERINT
; subcommand NXTCHR, the 'BREAK' handler, and
; the TIMER routine if not buffering.
;
SENDCH: MOV B,A
SENDLP: IN SERCMD ; Poll for ready.
ANI 1
JZ SENDLP
MOV A,B ; Ship it.
OUT SERDAT
RET
;
; Error routine, called upon RST 7
; halts the processor with the beeper
; on to flag an error. We should
; never get here!
;
ISOOPS: MVI A,BON
OUT P1CDAT
DI
HLT
JMP ISOOPS ; Just in case.
;
; Do the actual translation from raw keyboard
; character to ASCII. Called by KEYINT.
;
LOOKUP: SUI 10H ; No typing chars are < $10
MVI D,0 ; Table index.
MOV E,A
IN P2ADAT ; Do some 'SHIFT' handling first.
ANI KYELLO ; CRT (YELLOW) key?
JNZ SCRKEY ; Yes, always a SCREEN control key.
IN P2ADAT
ANI KSHIFT ; SHIFT key?
JNZ SCRKEY ; Yes, always a SCREEN key.
IN P1ADAT
ANI KPAGE ; 'SCREEN LOCK' key?
JNZ NOCRT ; Yes, always a SCREEN key.
SCRKEY: LXI H,SCRTAB ; SCREEN key table.
DAD D
MOV A,M ; Try to look up SCREEN key.
ORA A
RNZ ; If not zero then valid SCREEN key,
NOCRT: IN P2ADAT ; else do upr/lwr ASCII translate.
ANI KSHIFT ; SHIFT key.
LXI H,LOWTBL ; Lowercase table.
JZ LOWER ; Lower case?
LXI H,UPRTBL
LOWER: DAD D
IN P2ADAT
ANI KCAPSL ; CAPS lock?
MOV A,M
JZ LDONE ; No CAPS, then lookup done,
CPI 'a' ; otherwise
JC LDONE ; check range for CAPS lock.
CPI 'z'+1
JNC LDONE
SUI 20H ; Lower case ==> upper case.
LDONE: MOV E,A ; Apply CTRL & EDIT functions.
IN P2ADAT
ANI KCTRL+KEDIT ; CTRL or EDIT down?
MOV A,E
RZ ; No, all done.
IN P1ADAT ; META lock?
ANI KMSG
JNZ NOMETA ; No, process normally.
IN P2ADAT ; Is an EDIT or CTRL, META lock.
ANI KCTRL ; Is CTRL,
JNZ NOMETA ; process normally.
MOV A,E
JMP ISEDIT ; Is EDIT, & META lock -- skip case folding.
NOMETA: MOV A,E ; Is an EDIT or CTRL, non-META lock.
CPI '@'
RC ; Check range, must be >$3F
CPI 60H ; Lowercase?
JC CTRLED ; No, straight,
SUI 20H ; else do LWR => UPR first,
CTRLED: SUI '@' ; then do CTRL folding.
MOV E,A
IN P2ADAT
ANI KEDIT ; EDIT key?
MOV A,E
RZ ; No, done.
ISEDIT: ADI 80H ; Yes, set high bit.
CPI ACK ; Make sure no ACK or NAK chars get out.
RC
ANI 7FH ; Clip them to normal ASCII just in case.
RET
;
; Lowercase lookup table.
;
LOWTBL: DB 0,0,0,0,'3',8,'.,' ; Codes 10-17
DB '6',0,0,0,'28',13,'9' ; Codes 18-1f
DB '5',0,0,'1*-47' ; Codes 20-27
DB '+',0,'0',3,7BH,60H,7FH,0 ; Codes 28-2f
DB '\',0,'/',13,27H,'=',10,8 ; Codes 30-37
DB 5BH,'./;l0p-' ; Codes 38-3f
DB 'om,kj8i9' ; Codes 40-47
DB 'u nhg6y7' ; Codes 48-4f
DB 'tbvfd4r5' ; Codes 50-57
DB 'ecxsa2w3' ; Codes 58-5f
DB 'qz',0,0,1BH,13H,9,'1' ; Codes 60-67
DB 11H,0,0,0,0,0,0,0 ; Codes 68-6f
;
; Uppercase lookup table.
;
UPRTBL: DB 0,0,0,0,'3','8','.,' ; Codes 10-17
DB '6',0,0,0,'28',13,'9' ; Codes 18-1f
DB '5',0,0,'1*-47' ; Codes 20-27
DB '+',0,'0',3,7DH,7EH,7FH,0 ; Codes 28-2f
DB 7CH,0,'/',13,'"+',10,8 ; Codes 30-37
DB 5DH,'>?:L)P',5FH ; Codes 38-3f
DB 'OM<KJ*I(' ; Codes 40-47
DB 'U NHG^Y&' ; Codes 48-4f
DB 'TBVFD$R%' ; Codes 50-57
DB 'ECXSA@W#' ; Codes 58-5f
DB 'QZ',0,0,1BH,13H,9,'!' ; Codes 60-67
DB 11H,0,0,0,0,0,0,0 ; Codes 68-6f
;
; Screen control lookup table.
;
SCRTAB: DB 0,0,0,0,0ADH,0AFH,0AEH,0D0H ; Codes 10-17
DB 0ACH,0,0,0,0A9H,0A7H,0D1H,0ABH ; Codes 18-1f
DB 0A8H,0,0,0A6H,0A2H,0A0H,0A5H,0A4H ; Codes 20-27
DB 0A1H,0,0AAH,0,0,0,0,0 ; Codes 28-2f
DB 0,0,0A3H,0,0,0,0,0 ; Codes 30-37
DB 0,0,0,0,0,0,0,0 ; Codes 38-3f
DB 0,0,0,0,0,0,0,0 ; Codes 40-47
DB 0,0,0,0,0,0,0,0 ; Codes 48-4f
DB 0,0,0,0,0,0,0,0 ; Codes 50-57
DB 0,0,0,0,0,0,0,0 ; Codes 58-5f
DB 0,0,0,0,0,0,0,0 ; Codes 60-67
DB 0,0,0,0,0,0,0,0 ; Codes 68-6f
END
|
oeis/167/A167180.asm | neoneye/loda-programs | 11 | 10252 | ; A167180: a(n) = pi(n) plus the number of nonprimes less than prime(n).
; Submitted by <NAME>
; 1,2,4,5,9,10,14,15,18,23,25,30,34,35,38,43,49,50,56,59,60,65,69,74,81,84,85,88,90,93,107,110,115,116,125,126,132,137,140,145,151,152,162,163,166,167,179,190,193,194,197,202,204,213,218,223,228,229,235,238,240,249,262,265,266,269,283,288,297,298,302,307,315,320,325,328,333,340,344,351,360,361,371,372,377,380,385,392,396,397,400,411,418,421,428,431,437,448,449,466
mov $1,$0
seq $1,100486 ; a(n) = pi(n) + n-th prime, where pi(n) = A000720(n) is the prime counting function.
sub $1,$0
mov $0,$1
sub $0,1
|
columns.asm | cristoferfb/columns | 0 | 12975 | [bits 16]
org 100h
segment .text
%include "main.asm"
%include "core/move.asm"
%include "core/frame.asm"
%include "core/delay.asm"
%include "core/sound.asm"
%include "core/randomn.asm"
%include "core/gravity.asm"
%include "core/collChec.asm"
%include "core/chekFiel.asm"
%include "core/drawGame.asm"
%include "core/startGam.asm"
%include "core/genBlock.asm"
%include "core/gameLoop.asm"
%include "core/drawBloc.asm"
%include "core/checkKey.asm"
segment .data
delay_stopping_point_centiseconds db 0 ; Variables necesarias para
delay_initial db 0 ; generar un retraso o
random_number db 0 ; 'sleep' del sistema
delay_centiseconds db 5 ; Tiempo del retraso
frame_count db 0 ; Contador de frames
frame_gravi db 0 ; frame en el que se debe aplicar gravedad
collision db 0 ; Para saber si se esta colisionando con algo
slowness db 10 ; lentitud a la que va la "gavedad"
lv_count db 0 ; contador para subir la velocidad del juego
gravi_size db 0 ; Cuantos espacios tiene que caer un bloque
block_color_1 db 0 ; Estos seran los colores
block_color_2 db 0 ; que componen a un bloque
block_color_3 db 0 ; de tres secciones.
cblock_color_1 db 0 ; Estos seran los colores
cblock_color_2 db 0 ; que componen al actual
cblock_color_3 db 0 ; bloque.
block_x db 0 ; Posicion de la cabeza
block_y db 0 ; del bloque actual
oblock_x db 0 ; Posicion anterior de
oblock_y db 0 ; la cabeza del bloque actual
exist_block db 0 ; Para saber si se esta controlando un bloque
color_check db 0 ; Color para chekear convinaciones de piezas
match_count db 0 ; Numero de piezas iguales encontradas
stack_count db 0 ; Numero de piezas que se deben eliminar
check_x db 0 ; Esta es la posicion que
check_y db 0 ; esta siendo checkeada
points db 0 ; Puntaje del jugador
points_assci db '000$'; Puntaje del jugador en forma de string
; Lo que sigue solo son los textos del juego
msg_next db 'Siguiente:','$'
msg_point db 'Puntaje:','$'
|
source/s-forfix.ads | ytomino/drake | 33 | 5856 | <gh_stars>10-100
pragma License (Unrestricted);
-- implementation unit
package System.Formatting.Fixed is
pragma Pure;
procedure Image (
Value : Long_Long_Float;
Item : out String; -- To'Length >= T'Fore + T'Aft + 5 (16#.#)
Fore_Last, Last : out Natural;
Signs : Sign_Marks := ('-', ' ', ' ');
Base : Number_Base := 10;
Base_Form : Boolean := False;
Set : Type_Set := Upper_Case;
Fore_Digits_Width : Positive := 1;
Fore_Digits_Fill : Character := '0';
Aft_Width : Positive);
end System.Formatting.Fixed;
|
llvm-gcc-4.2-2.9/gcc/ada/g-cgi.adb | vidkidz/crossbridge | 1 | 3089 | <reponame>vidkidz/crossbridge
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- G N A T . C G I --
-- --
-- B o d y --
-- --
-- Copyright (C) 2001-2005, 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 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, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Ada.Text_IO;
with Ada.Strings.Fixed;
with Ada.Characters.Handling;
with Ada.Strings.Maps;
with GNAT.OS_Lib;
with GNAT.Table;
package body GNAT.CGI is
use Ada;
Valid_Environment : Boolean := True;
-- This boolean will be set to False if the initialization was not
-- completed correctly. It must be set to true there because the
-- Initialize routine (called during elaboration) will use some of the
-- services exported by this unit.
Current_Method : Method_Type;
-- This is the current method used to pass CGI parameters
Header_Sent : Boolean := False;
-- Will be set to True when the header will be sent
-- Key/Value table declaration
type String_Access is access String;
type Key_Value is record
Key : String_Access;
Value : String_Access;
end record;
package Key_Value_Table is new Table (Key_Value, Positive, 1, 1, 50);
-----------------------
-- Local subprograms --
-----------------------
procedure Check_Environment;
pragma Inline (Check_Environment);
-- This procedure will raise Data_Error if Valid_Environment is False
procedure Initialize;
-- Initialize CGI package by reading the runtime environment. This
-- procedure is called during elaboration. All exceptions raised during
-- this procedure are deferred.
--------------------
-- Argument_Count --
--------------------
function Argument_Count return Natural is
begin
Check_Environment;
return Key_Value_Table.Last;
end Argument_Count;
-----------------------
-- Check_Environment --
-----------------------
procedure Check_Environment is
begin
if not Valid_Environment then
raise Data_Error;
end if;
end Check_Environment;
------------
-- Decode --
------------
function Decode (S : String) return String is
Result : String (S'Range);
K : Positive := S'First;
J : Positive := Result'First;
begin
while K <= S'Last loop
if K + 2 <= S'Last
and then S (K) = '%'
and then Characters.Handling.Is_Hexadecimal_Digit (S (K + 1))
and then Characters.Handling.Is_Hexadecimal_Digit (S (K + 2))
then
-- Here we have '%HH' which is an encoded character where 'HH' is
-- the character number in hexadecimal.
Result (J) := Character'Val
(Natural'Value ("16#" & S (K + 1 .. K + 2) & '#'));
K := K + 3;
else
Result (J) := S (K);
K := K + 1;
end if;
J := J + 1;
end loop;
return Result (Result'First .. J - 1);
end Decode;
-------------------------
-- For_Every_Parameter --
-------------------------
procedure For_Every_Parameter is
Quit : Boolean;
begin
Check_Environment;
for K in 1 .. Key_Value_Table.Last loop
Quit := False;
Action (Key_Value_Table.Table (K).Key.all,
Key_Value_Table.Table (K).Value.all,
K,
Quit);
exit when Quit;
end loop;
end For_Every_Parameter;
----------------
-- Initialize --
----------------
procedure Initialize is
Request_Method : constant String :=
Characters.Handling.To_Upper
(Metavariable (CGI.Request_Method));
procedure Initialize_GET;
-- Read CGI parameters for a GET method. In this case the parameters
-- are passed into QUERY_STRING environment variable.
procedure Initialize_POST;
-- Read CGI parameters for a POST method. In this case the parameters
-- are passed with the standard input. The total number of characters
-- for the data is passed in CONTENT_LENGTH environment variable.
procedure Set_Parameter_Table (Data : String);
-- Parse the parameter data and set the parameter table
--------------------
-- Initialize_GET --
--------------------
procedure Initialize_GET is
Data : constant String := Metavariable (Query_String);
begin
Current_Method := Get;
if Data /= "" then
Set_Parameter_Table (Data);
end if;
end Initialize_GET;
---------------------
-- Initialize_POST --
---------------------
procedure Initialize_POST is
Content_Length : constant Natural :=
Natural'Value (Metavariable (CGI.Content_Length));
Data : String (1 .. Content_Length);
begin
Current_Method := Post;
if Content_Length /= 0 then
Text_IO.Get (Data);
Set_Parameter_Table (Data);
end if;
end Initialize_POST;
-------------------------
-- Set_Parameter_Table --
-------------------------
procedure Set_Parameter_Table (Data : String) is
procedure Add_Parameter (K : Positive; P : String);
-- Add a single parameter into the table at index K. The parameter
-- format is "key=value".
Count : constant Positive :=
1 + Strings.Fixed.Count (Data, Strings.Maps.To_Set ("&"));
-- Count is the number of parameters in the string. Parameters are
-- separated by ampersand character.
Index : Positive := Data'First;
Amp : Natural;
-------------------
-- Add_Parameter --
-------------------
procedure Add_Parameter (K : Positive; P : String) is
Equal : constant Natural := Strings.Fixed.Index (P, "=");
begin
if Equal = 0 then
raise Data_Error;
else
Key_Value_Table.Table (K) :=
Key_Value'(new String'(Decode (P (P'First .. Equal - 1))),
new String'(Decode (P (Equal + 1 .. P'Last))));
end if;
end Add_Parameter;
-- Start of processing for Set_Parameter_Table
begin
Key_Value_Table.Set_Last (Count);
for K in 1 .. Count - 1 loop
Amp := Strings.Fixed.Index (Data (Index .. Data'Last), "&");
Add_Parameter (K, Data (Index .. Amp - 1));
Index := Amp + 1;
end loop;
-- add last parameter
Add_Parameter (Count, Data (Index .. Data'Last));
end Set_Parameter_Table;
-- Start of processing for Initialize
begin
if Request_Method = "GET" then
Initialize_GET;
elsif Request_Method = "POST" then
Initialize_POST;
else
Valid_Environment := False;
end if;
exception
when others =>
-- If we have an exception during initialization of this unit we
-- just declare it invalid.
Valid_Environment := False;
end Initialize;
---------
-- Key --
---------
function Key (Position : Positive) return String is
begin
Check_Environment;
if Position <= Key_Value_Table.Last then
return Key_Value_Table.Table (Position).Key.all;
else
raise Parameter_Not_Found;
end if;
end Key;
----------------
-- Key_Exists --
----------------
function Key_Exists (Key : String) return Boolean is
begin
Check_Environment;
for K in 1 .. Key_Value_Table.Last loop
if Key_Value_Table.Table (K).Key.all = Key then
return True;
end if;
end loop;
return False;
end Key_Exists;
------------------
-- Metavariable --
------------------
function Metavariable
(Name : Metavariable_Name;
Required : Boolean := False) return String
is
function Get_Environment (Variable_Name : String) return String;
-- Returns the environment variable content
---------------------
-- Get_Environment --
---------------------
function Get_Environment (Variable_Name : String) return String is
Value : OS_Lib.String_Access := OS_Lib.Getenv (Variable_Name);
Result : constant String := Value.all;
begin
OS_Lib.Free (Value);
return Result;
end Get_Environment;
Result : constant String :=
Get_Environment (Metavariable_Name'Image (Name));
-- Start of processing for Metavariable
begin
Check_Environment;
if Result = "" and then Required then
raise Parameter_Not_Found;
else
return Result;
end if;
end Metavariable;
-------------------------
-- Metavariable_Exists --
-------------------------
function Metavariable_Exists (Name : Metavariable_Name) return Boolean is
begin
Check_Environment;
if Metavariable (Name) = "" then
return False;
else
return True;
end if;
end Metavariable_Exists;
------------
-- Method --
------------
function Method return Method_Type is
begin
Check_Environment;
return Current_Method;
end Method;
--------
-- Ok --
--------
function Ok return Boolean is
begin
return Valid_Environment;
end Ok;
----------------
-- Put_Header --
----------------
procedure Put_Header
(Header : String := Default_Header;
Force : Boolean := False)
is
begin
if Header_Sent = False or else Force then
Check_Environment;
Text_IO.Put_Line (Header);
Text_IO.New_Line;
Header_Sent := True;
end if;
end Put_Header;
---------
-- URL --
---------
function URL return String is
function Exists_And_Not_80 (Server_Port : String) return String;
-- Returns ':' & Server_Port if Server_Port is not "80" and the empty
-- string otherwise (80 is the default sever port).
-----------------------
-- Exists_And_Not_80 --
-----------------------
function Exists_And_Not_80 (Server_Port : String) return String is
begin
if Server_Port = "80" then
return "";
else
return ':' & Server_Port;
end if;
end Exists_And_Not_80;
-- Start of processing for URL
begin
Check_Environment;
return "http://"
& Metavariable (Server_Name)
& Exists_And_Not_80 (Metavariable (Server_Port))
& Metavariable (Script_Name);
end URL;
-----------
-- Value --
-----------
function Value
(Key : String;
Required : Boolean := False)
return String
is
begin
Check_Environment;
for K in 1 .. Key_Value_Table.Last loop
if Key_Value_Table.Table (K).Key.all = Key then
return Key_Value_Table.Table (K).Value.all;
end if;
end loop;
if Required then
raise Parameter_Not_Found;
else
return "";
end if;
end Value;
-----------
-- Value --
-----------
function Value (Position : Positive) return String is
begin
Check_Environment;
if Position <= Key_Value_Table.Last then
return Key_Value_Table.Table (Position).Value.all;
else
raise Parameter_Not_Found;
end if;
end Value;
begin
Initialize;
end GNAT.CGI;
|
Agda/localizations-rings.agda | UlrikBuchholtz/HoTT-Intro | 333 | 10808 | {-# OPTIONS --without-K --exact-split #-}
module localizations-rings where
import subrings
open subrings public
is-invertible-Ring :
{l1 : Level} (R : Ring l1) (x : type-Ring R) → UU l1
is-invertible-Ring R =
is-invertible-Monoid (multiplicative-monoid-Ring R)
is-prop-is-invertible-Ring :
{l1 : Level} (R : Ring l1) (x : type-Ring R) →
is-prop (is-invertible-Ring R x)
is-prop-is-invertible-Ring R =
is-prop-is-invertible-Monoid (multiplicative-monoid-Ring R)
--------------------------------------------------------------------------------
{- We introduce homomorphism that invert specific elements -}
inverts-element-hom-Ring :
{l1 l2 : Level} (R1 : Ring l1) (R2 : Ring l2) (x : type-Ring R1) →
(f : hom-Ring R1 R2) → UU l2
inverts-element-hom-Ring R1 R2 x f =
is-invertible-Ring R2 (map-hom-Ring R1 R2 f x)
is-prop-inverts-element-hom-Ring :
{l1 l2 : Level} (R : Ring l1) (S : Ring l2) (x : type-Ring R)
(f : hom-Ring R S) → is-prop (inverts-element-hom-Ring R S x f)
is-prop-inverts-element-hom-Ring R S x f =
is-prop-is-invertible-Ring S (map-hom-Ring R S f x)
inv-inverts-element-hom-Ring :
{l1 l2 : Level} (R : Ring l1) (S : Ring l2) (x : type-Ring R)
(f : hom-Ring R S) → inverts-element-hom-Ring R S x f → type-Ring S
inv-inverts-element-hom-Ring R S x f H = pr1 H
is-left-inverse-inv-inverts-element-hom-Ring :
{l1 l2 : Level} (R : Ring l1) (S : Ring l2) (x : type-Ring R)
(f : hom-Ring R S) (H : inverts-element-hom-Ring R S x f) →
Id ( mul-Ring S
( inv-inverts-element-hom-Ring R S x f H)
( map-hom-Ring R S f x))
( unit-Ring S)
is-left-inverse-inv-inverts-element-hom-Ring R S x f H = pr1 (pr2 H)
is-right-inverse-inv-inverts-element-hom-Ring :
{l1 l2 : Level} (R : Ring l1) (S : Ring l2) (x : type-Ring R)
(f : hom-Ring R S) (H : inverts-element-hom-Ring R S x f) →
Id ( mul-Ring S
( map-hom-Ring R S f x)
( inv-inverts-element-hom-Ring R S x f H))
( unit-Ring S)
is-right-inverse-inv-inverts-element-hom-Ring R S x f H = pr2 (pr2 H)
inverts-element-comp-hom-Ring :
{l1 l2 l3 : Level} (R : Ring l1) (S : Ring l2) (T : Ring l3) (x : type-Ring R)
(g : hom-Ring S T) (f : hom-Ring R S) → inverts-element-hom-Ring R S x f →
inverts-element-hom-Ring R T x (comp-hom-Ring R S T g f)
inverts-element-comp-hom-Ring R S T x g f H =
pair
( map-hom-Ring S T g (inv-inverts-element-hom-Ring R S x f H))
( pair
( ( inv
( preserves-mul-hom-Ring S T g
( inv-inverts-element-hom-Ring R S x f H)
( map-hom-Ring R S f x))) ∙
( ( ap
( map-hom-Ring S T g)
( is-left-inverse-inv-inverts-element-hom-Ring R S x f H)) ∙
( preserves-unit-hom-Ring S T g)))
( ( inv
( preserves-mul-hom-Ring S T g
( map-hom-Ring R S f x)
( inv-inverts-element-hom-Ring R S x f H))) ∙
( ( ap
( map-hom-Ring S T g)
( is-right-inverse-inv-inverts-element-hom-Ring R S x f H)) ∙
( preserves-unit-hom-Ring S T g))))
{- We state the universal property of the localization of a Ring at a single
element x ∈ R. -}
precomp-universal-property-localization-Ring :
{l1 l2 l3 : Level} (R : Ring l1) (S : Ring l2) (T : Ring l3) (x : type-Ring R)
(f : hom-Ring R S) (H : inverts-element-hom-Ring R S x f) →
hom-Ring S T → Σ (hom-Ring R T) (inverts-element-hom-Ring R T x)
precomp-universal-property-localization-Ring R S T x f H g =
pair (comp-hom-Ring R S T g f) (inverts-element-comp-hom-Ring R S T x g f H)
universal-property-localization-Ring :
(l : Level) {l1 l2 : Level} (R : Ring l1) (S : Ring l2) (x : type-Ring R)
(f : hom-Ring R S) → inverts-element-hom-Ring R S x f → UU (lsuc l ⊔ l1 ⊔ l2)
universal-property-localization-Ring l R S x f H =
(T : Ring l) →
is-equiv (precomp-universal-property-localization-Ring R S T x f H)
unique-extension-universal-property-localization-Ring :
{l1 l2 l3 : Level} (R : Ring l1) (S : Ring l2) (T : Ring l3) (x : type-Ring R)
(f : hom-Ring R S) (H : inverts-element-hom-Ring R S x f) →
universal-property-localization-Ring l3 R S x f H →
(h : hom-Ring R T) (K : inverts-element-hom-Ring R T x h) →
is-contr
(Σ (hom-Ring S T) (λ g → htpy-hom-Ring R T (comp-hom-Ring R S T g f) h))
unique-extension-universal-property-localization-Ring R S T x f H up-f h K =
is-contr-equiv'
( fib (precomp-universal-property-localization-Ring R S T x f H) (pair h K))
( equiv-tot ( λ g →
( equiv-htpy-hom-Ring-eq R T (comp-hom-Ring R S T g f) h) ∘e
( equiv-Eq-total-subtype-eq
( is-prop-inverts-element-hom-Ring R T x)
( precomp-universal-property-localization-Ring R S T x f H g)
( pair h K))))
( is-contr-map-is-equiv (up-f T) (pair h K))
center-unique-extension-universal-property-localization-Ring :
{l1 l2 l3 : Level} (R : Ring l1) (S : Ring l2) (T : Ring l3) (x : type-Ring R)
(f : hom-Ring R S) (H : inverts-element-hom-Ring R S x f) →
universal-property-localization-Ring l3 R S x f H →
(h : hom-Ring R T) (K : inverts-element-hom-Ring R T x h) →
Σ (hom-Ring S T) (λ g → htpy-hom-Ring R T (comp-hom-Ring R S T g f) h)
center-unique-extension-universal-property-localization-Ring R S T x f H up-f h K =
center
( unique-extension-universal-property-localization-Ring
R S T x f H up-f h K)
map-universal-property-localization-Ring :
{l1 l2 l3 : Level} (R : Ring l1) (S : Ring l2) (T : Ring l3) (x : type-Ring R)
(f : hom-Ring R S) (H : inverts-element-hom-Ring R S x f) →
universal-property-localization-Ring l3 R S x f H →
(h : hom-Ring R T) (K : inverts-element-hom-Ring R T x h) → hom-Ring S T
map-universal-property-localization-Ring R S T x f H up-f h K =
pr1 ( center-unique-extension-universal-property-localization-Ring
R S T x f H up-f h K)
htpy-universal-property-localization-Ring :
{l1 l2 l3 : Level} (R : Ring l1) (S : Ring l2) (T : Ring l3) (x : type-Ring R)
(f : hom-Ring R S) (H : inverts-element-hom-Ring R S x f) →
(up-f : universal-property-localization-Ring l3 R S x f H) →
(h : hom-Ring R T) (K : inverts-element-hom-Ring R T x h) →
htpy-hom-Ring R T (comp-hom-Ring R S T (map-universal-property-localization-Ring R S T x f H up-f h K) f) h
htpy-universal-property-localization-Ring R S T x f H up-f h K =
pr2 ( center-unique-extension-universal-property-localization-Ring
R S T x f H up-f h K)
{- We show that the type of localizations of a ring R at an element x is
contractible. -}
is-equiv-up-localization-up-localization-Ring :
{l1 l2 l3 : Level} (R : Ring l1) (S : Ring l2) (T : Ring l3) (x : type-Ring R)
(f : hom-Ring R S) (inverts-f : inverts-element-hom-Ring R S x f) →
(g : hom-Ring R T) (inverts-g : inverts-element-hom-Ring R T x g) →
(h : hom-Ring S T) (H : htpy-hom-Ring R T (comp-hom-Ring R S T h f) g) →
({l : Level} → universal-property-localization-Ring l R S x f inverts-f) →
({l : Level} → universal-property-localization-Ring l R T x g inverts-g) →
is-iso-hom-Ring S T h
is-equiv-up-localization-up-localization-Ring R S T x f inverts-f g inverts-g h H up-f up-g = {!is-iso-is-equiv-hom-Ring!}
--------------------------------------------------------------------------------
{- We introduce homomorphisms that invert all elements of a subset of a ring -}
inverts-subset-hom-Ring :
{l1 l2 l3 : Level} (R : Ring l1) (S : Ring l2) (P : subset-Ring l3 R) →
(f : hom-Ring R S) → UU (l1 ⊔ l2 ⊔ l3)
inverts-subset-hom-Ring R S P f =
(x : type-Ring R) (p : type-Prop (P x)) → inverts-element-hom-Ring R S x f
is-prop-inverts-subset-hom-Ring :
{l1 l2 l3 : Level} (R : Ring l1) (S : Ring l2) (P : subset-Ring l3 R) →
(f : hom-Ring R S) → is-prop (inverts-subset-hom-Ring R S P f)
is-prop-inverts-subset-hom-Ring R S P f =
is-prop-Π (λ x → is-prop-Π (λ p → is-prop-inverts-element-hom-Ring R S x f))
inv-inverts-subset-hom-Ring :
{l1 l2 l3 : Level} (R : Ring l1) (S : Ring l2) (P : subset-Ring l3 R)
(f : hom-Ring R S) (H : inverts-subset-hom-Ring R S P f)
(x : type-Ring R) (p : type-Prop (P x)) → type-Ring S
inv-inverts-subset-hom-Ring R S P f H x p =
inv-inverts-element-hom-Ring R S x f (H x p)
is-left-inverse-inv-inverts-subset-hom-Ring :
{l1 l2 l3 : Level} (R : Ring l1) (S : Ring l2) (P : subset-Ring l3 R)
(f : hom-Ring R S) (H : inverts-subset-hom-Ring R S P f)
(x : type-Ring R) (p : type-Prop (P x)) →
Id (mul-Ring S (inv-inverts-subset-hom-Ring R S P f H x p) (map-hom-Ring R S f x)) (unit-Ring S)
is-left-inverse-inv-inverts-subset-hom-Ring R S P f H x p =
is-left-inverse-inv-inverts-element-hom-Ring R S x f (H x p)
is-right-inverse-inv-inverts-subset-hom-Ring :
{l1 l2 l3 : Level} (R : Ring l1) (S : Ring l2) (P : subset-Ring l3 R)
(f : hom-Ring R S) (H : inverts-subset-hom-Ring R S P f)
(x : type-Ring R) (p : type-Prop (P x)) →
Id (mul-Ring S (map-hom-Ring R S f x) (inv-inverts-subset-hom-Ring R S P f H x p)) (unit-Ring S)
is-right-inverse-inv-inverts-subset-hom-Ring R S P f H x p =
is-right-inverse-inv-inverts-element-hom-Ring R S x f (H x p)
inverts-subset-comp-hom-Ring :
{l1 l2 l3 l4 : Level} (R : Ring l1) (S : Ring l2) (T : Ring l3)
(P : subset-Ring l4 R) (g : hom-Ring S T) (f : hom-Ring R S) →
inverts-subset-hom-Ring R S P f →
inverts-subset-hom-Ring R T P (comp-hom-Ring R S T g f)
inverts-subset-comp-hom-Ring R S T P g f H x p =
inverts-element-comp-hom-Ring R S T x g f (H x p)
{- We state the universal property of the localization of a Ring at a subset
of R. -}
precomp-universal-property-localization-subset-Ring :
{l1 l2 l3 l4 : Level} (R : Ring l1) (S : Ring l2) (T : Ring l3)
(P : subset-Ring l4 R) →
(f : hom-Ring R S) (H : inverts-subset-hom-Ring R S P f) →
hom-Ring S T → Σ (hom-Ring R T) (inverts-subset-hom-Ring R T P)
precomp-universal-property-localization-subset-Ring R S T P f H g =
pair (comp-hom-Ring R S T g f) (inverts-subset-comp-hom-Ring R S T P g f H)
universal-property-localization-subset-Ring :
(l : Level) {l1 l2 l3 : Level} (R : Ring l1) (S : Ring l2)
(P : subset-Ring l3 R) (f : hom-Ring R S) →
inverts-subset-hom-Ring R S P f → UU (lsuc l ⊔ l1 ⊔ l2 ⊔ l3)
universal-property-localization-subset-Ring l R S P f H =
(T : Ring l) →
is-equiv (precomp-universal-property-localization-subset-Ring R S T P f H)
|
programs/oeis/087/A087229.asm | karttu/loda | 0 | 161034 | <filename>programs/oeis/087/A087229.asm
; A087229: Exponent of p=2 in 12n+4=3(4n+1)+1 numbers.
; 4,2,3,2,6,2,3,2,4,2,3,2,5,2,3,2,4,2,3,2,8,2,3,2,4,2,3,2,5,2,3,2,4,2,3,2,6,2,3,2,4,2,3,2,5,2,3,2,4,2,3,2,7,2,3,2,4,2,3,2,5,2,3,2,4,2,3,2,6,2,3,2,4,2,3,2,5,2,3,2,4,2,3,2,10,2,3,2,4,2,3,2,5,2,3,2,4,2,3,2,6,2,3,2,4,2,3,2,5,2,3,2,4,2,3,2,7,2,3,2,4,2,3,2,5,2,3,2,4,2,3,2,6,2,3,2,4,2,3,2,5,2,3,2,4,2,3,2,8,2,3,2,4,2,3,2,5,2,3,2,4,2,3,2,6,2,3,2,4,2,3,2,5,2,3,2,4,2,3,2,7,2,3,2,4,2,3,2,5,2,3,2,4,2,3,2,6,2,3,2,4,2,3,2,5,2,3,2,4,2,3,2,9,2,3,2,4,2,3,2,5,2,3,2,4,2,3,2,6,2,3,2,4,2,3,2,5,2,3,2,4,2,3,2,7,2,3,2,4,2
sub $0,453061
mul $0,9
sub $0,7
mov $2,4
lpb $0,1
mul $0,2
gcd $2,$0
div $0,$2
add $1,1
lpe
add $1,2
|
nasm-gcc/src/print_call.asm | MaksVe/nasm-gcc-container | 0 | 1161 | <reponame>MaksVe/nasm-gcc-container
; nasm -felf64 print_call.asm -o print_call.o
; ld -o print_call.out print_call.o
; chmod u+x print_call.out
; ./print_call.out
section .data
newline_char: db 10
codes: db '0123456789ABCDEF'
section .text
global _start
print_newline:
mov rax, 1 ; 'write' system call identifier
mov rdi, 1 ; sdout file descriptor
mov rsi, newline_char ; where do we take data from
mov rdx, 1 ; the amout of bytes to write
syscall
ret
print_hex:
mov rax, rdi
mov rdi, 1
mov rdx, 1
mov rcx, 64 ; how far we are shifting rax
iterate:
push rax ; save the initial rax value
sub rcx, 4
sar rax, cl ; shift to 60, 56, 52, .. 4, 0
and rax, 0xf ; clear all bits but the lowest four
lea rsi, [codes + rax] ; take a hexadecimal digit character code
mov rax, 1
push rcx ; syscall will break rcx
syscall ; rax = 1 (31) -- the write identifier,
; rdi = 1 for stdout,
; rsi = the address of a character, see line 29
pop rcx
pop rax ; see line 24
test rcx, rcx ; rcx = 0 whel all digits are shown
jnz iterate
ret
_start:
mov rdi, 0x1122334455667788
call print_hex
call print_newline
mov rax, 60
xor rdi, rdi
syscall |
Validation/pyFrame3DD-master/gcc-master/gcc/ada/libgnat/a-stwisu.ads | djamal2727/Main-Bearing-Analytical-Model | 0 | 19435 | <gh_stars>0
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . S T R I N G S . W I D E _ S U P E R B O U N D E D --
-- --
-- S p e c --
-- --
-- Copyright (C) 2003-2020, 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. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- 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. --
-- --
------------------------------------------------------------------------------
-- This non generic package contains most of the implementation of the
-- generic package Ada.Strings.Wide_Bounded.Generic_Bounded_Length.
-- It defines type Super_String as a discriminated record with the maximum
-- length as the discriminant. Individual instantiations of the package
-- Strings.Wide_Bounded.Generic_Bounded_Length use this type with
-- an appropriate discriminant value set.
with Ada.Strings.Wide_Maps;
package Ada.Strings.Wide_Superbounded is
pragma Preelaborate;
Wide_NUL : constant Wide_Character := Wide_Character'Val (0);
-- Ada.Strings.Wide_Bounded.Generic_Bounded_Length.Wide_Bounded_String is
-- derived from Super_String, with the constraint of the maximum length.
type Super_String (Max_Length : Positive) is record
Current_Length : Natural := 0;
Data : Wide_String (1 .. Max_Length);
-- A previous version had a default initial value for Data, which is
-- no longer necessary, because we now special-case this type in the
-- compiler, so "=" composes properly for descendants of this type.
-- Leaving it out is more efficient.
end record;
-- The subprograms defined for Super_String are similar to those defined
-- for Bounded_Wide_String, except that they have different names, so that
-- they can be renamed in Ada.Strings.Wide_Bounded.Generic_Bounded_Length.
function Super_Length (Source : Super_String) return Natural;
--------------------------------------------------------
-- Conversion, Concatenation, and Selection Functions --
--------------------------------------------------------
function To_Super_String
(Source : Wide_String;
Max_Length : Natural;
Drop : Truncation := Error) return Super_String;
-- Note the additional parameter Max_Length, which specifies the maximum
-- length setting of the resulting Super_String value.
-- The following procedures have declarations (and semantics) that are
-- exactly analogous to those declared in Ada.Strings.Wide_Bounded.
function Super_To_String (Source : Super_String) return Wide_String;
procedure Set_Super_String
(Target : out Super_String;
Source : Wide_String;
Drop : Truncation := Error);
function Super_Append
(Left : Super_String;
Right : Super_String;
Drop : Truncation := Error) return Super_String;
function Super_Append
(Left : Super_String;
Right : Wide_String;
Drop : Truncation := Error) return Super_String;
function Super_Append
(Left : Wide_String;
Right : Super_String;
Drop : Truncation := Error) return Super_String;
function Super_Append
(Left : Super_String;
Right : Wide_Character;
Drop : Truncation := Error) return Super_String;
function Super_Append
(Left : Wide_Character;
Right : Super_String;
Drop : Truncation := Error) return Super_String;
procedure Super_Append
(Source : in out Super_String;
New_Item : Super_String;
Drop : Truncation := Error);
procedure Super_Append
(Source : in out Super_String;
New_Item : Wide_String;
Drop : Truncation := Error);
procedure Super_Append
(Source : in out Super_String;
New_Item : Wide_Character;
Drop : Truncation := Error);
function Concat
(Left : Super_String;
Right : Super_String) return Super_String;
function Concat
(Left : Super_String;
Right : Wide_String) return Super_String;
function Concat
(Left : Wide_String;
Right : Super_String) return Super_String;
function Concat
(Left : Super_String;
Right : Wide_Character) return Super_String;
function Concat
(Left : Wide_Character;
Right : Super_String) return Super_String;
function Super_Element
(Source : Super_String;
Index : Positive) return Wide_Character;
procedure Super_Replace_Element
(Source : in out Super_String;
Index : Positive;
By : Wide_Character);
function Super_Slice
(Source : Super_String;
Low : Positive;
High : Natural) return Wide_String;
function Super_Slice
(Source : Super_String;
Low : Positive;
High : Natural) return Super_String;
procedure Super_Slice
(Source : Super_String;
Target : out Super_String;
Low : Positive;
High : Natural);
function "="
(Left : Super_String;
Right : Super_String) return Boolean;
function Equal
(Left : Super_String;
Right : Super_String) return Boolean renames "=";
function Equal
(Left : Super_String;
Right : Wide_String) return Boolean;
function Equal
(Left : Wide_String;
Right : Super_String) return Boolean;
function Less
(Left : Super_String;
Right : Super_String) return Boolean;
function Less
(Left : Super_String;
Right : Wide_String) return Boolean;
function Less
(Left : Wide_String;
Right : Super_String) return Boolean;
function Less_Or_Equal
(Left : Super_String;
Right : Super_String) return Boolean;
function Less_Or_Equal
(Left : Super_String;
Right : Wide_String) return Boolean;
function Less_Or_Equal
(Left : Wide_String;
Right : Super_String) return Boolean;
function Greater
(Left : Super_String;
Right : Super_String) return Boolean;
function Greater
(Left : Super_String;
Right : Wide_String) return Boolean;
function Greater
(Left : Wide_String;
Right : Super_String) return Boolean;
function Greater_Or_Equal
(Left : Super_String;
Right : Super_String) return Boolean;
function Greater_Or_Equal
(Left : Super_String;
Right : Wide_String) return Boolean;
function Greater_Or_Equal
(Left : Wide_String;
Right : Super_String) return Boolean;
----------------------
-- Search Functions --
----------------------
function Super_Index
(Source : Super_String;
Pattern : Wide_String;
Going : Direction := Forward;
Mapping : Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity)
return Natural;
function Super_Index
(Source : Super_String;
Pattern : Wide_String;
Going : Direction := Forward;
Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Natural;
function Super_Index
(Source : Super_String;
Set : Wide_Maps.Wide_Character_Set;
Test : Membership := Inside;
Going : Direction := Forward) return Natural;
function Super_Index
(Source : Super_String;
Pattern : Wide_String;
From : Positive;
Going : Direction := Forward;
Mapping : Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity)
return Natural;
function Super_Index
(Source : Super_String;
Pattern : Wide_String;
From : Positive;
Going : Direction := Forward;
Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Natural;
function Super_Index
(Source : Super_String;
Set : Wide_Maps.Wide_Character_Set;
From : Positive;
Test : Membership := Inside;
Going : Direction := Forward) return Natural;
function Super_Index_Non_Blank
(Source : Super_String;
Going : Direction := Forward) return Natural;
function Super_Index_Non_Blank
(Source : Super_String;
From : Positive;
Going : Direction := Forward) return Natural;
function Super_Count
(Source : Super_String;
Pattern : Wide_String;
Mapping : Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity)
return Natural;
function Super_Count
(Source : Super_String;
Pattern : Wide_String;
Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Natural;
function Super_Count
(Source : Super_String;
Set : Wide_Maps.Wide_Character_Set) return Natural;
procedure Super_Find_Token
(Source : Super_String;
Set : Wide_Maps.Wide_Character_Set;
From : Positive;
Test : Membership;
First : out Positive;
Last : out Natural);
procedure Super_Find_Token
(Source : Super_String;
Set : Wide_Maps.Wide_Character_Set;
Test : Membership;
First : out Positive;
Last : out Natural);
------------------------------------
-- String Translation Subprograms --
------------------------------------
function Super_Translate
(Source : Super_String;
Mapping : Wide_Maps.Wide_Character_Mapping) return Super_String;
procedure Super_Translate
(Source : in out Super_String;
Mapping : Wide_Maps.Wide_Character_Mapping);
function Super_Translate
(Source : Super_String;
Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Super_String;
procedure Super_Translate
(Source : in out Super_String;
Mapping : Wide_Maps.Wide_Character_Mapping_Function);
---------------------------------------
-- String Transformation Subprograms --
---------------------------------------
function Super_Replace_Slice
(Source : Super_String;
Low : Positive;
High : Natural;
By : Wide_String;
Drop : Truncation := Error) return Super_String;
procedure Super_Replace_Slice
(Source : in out Super_String;
Low : Positive;
High : Natural;
By : Wide_String;
Drop : Truncation := Error);
function Super_Insert
(Source : Super_String;
Before : Positive;
New_Item : Wide_String;
Drop : Truncation := Error) return Super_String;
procedure Super_Insert
(Source : in out Super_String;
Before : Positive;
New_Item : Wide_String;
Drop : Truncation := Error);
function Super_Overwrite
(Source : Super_String;
Position : Positive;
New_Item : Wide_String;
Drop : Truncation := Error) return Super_String;
procedure Super_Overwrite
(Source : in out Super_String;
Position : Positive;
New_Item : Wide_String;
Drop : Truncation := Error);
function Super_Delete
(Source : Super_String;
From : Positive;
Through : Natural) return Super_String;
procedure Super_Delete
(Source : in out Super_String;
From : Positive;
Through : Natural);
---------------------------------
-- String Selector Subprograms --
---------------------------------
function Super_Trim
(Source : Super_String;
Side : Trim_End) return Super_String;
procedure Super_Trim
(Source : in out Super_String;
Side : Trim_End);
function Super_Trim
(Source : Super_String;
Left : Wide_Maps.Wide_Character_Set;
Right : Wide_Maps.Wide_Character_Set) return Super_String;
procedure Super_Trim
(Source : in out Super_String;
Left : Wide_Maps.Wide_Character_Set;
Right : Wide_Maps.Wide_Character_Set);
function Super_Head
(Source : Super_String;
Count : Natural;
Pad : Wide_Character := Wide_Space;
Drop : Truncation := Error) return Super_String;
procedure Super_Head
(Source : in out Super_String;
Count : Natural;
Pad : Wide_Character := Wide_Space;
Drop : Truncation := Error);
function Super_Tail
(Source : Super_String;
Count : Natural;
Pad : Wide_Character := Wide_Space;
Drop : Truncation := Error) return Super_String;
procedure Super_Tail
(Source : in out Super_String;
Count : Natural;
Pad : Wide_Character := Wide_Space;
Drop : Truncation := Error);
------------------------------------
-- String Constructor Subprograms --
------------------------------------
-- Note: in some of the following routines, there is an extra parameter
-- Max_Length which specifies the value of the maximum length for the
-- resulting Super_String value.
function Times
(Left : Natural;
Right : Wide_Character;
Max_Length : Positive) return Super_String;
-- Note the additional parameter Max_Length
function Times
(Left : Natural;
Right : Wide_String;
Max_Length : Positive) return Super_String;
-- Note the additional parameter Max_Length
function Times
(Left : Natural;
Right : Super_String) return Super_String;
function Super_Replicate
(Count : Natural;
Item : Wide_Character;
Drop : Truncation := Error;
Max_Length : Positive) return Super_String;
-- Note the additional parameter Max_Length
function Super_Replicate
(Count : Natural;
Item : Wide_String;
Drop : Truncation := Error;
Max_Length : Positive) return Super_String;
-- Note the additional parameter Max_Length
function Super_Replicate
(Count : Natural;
Item : Super_String;
Drop : Truncation := Error) return Super_String;
private
-- Pragma Inline declarations
pragma Inline ("=");
pragma Inline (Less);
pragma Inline (Less_Or_Equal);
pragma Inline (Greater);
pragma Inline (Greater_Or_Equal);
pragma Inline (Concat);
pragma Inline (Super_Count);
pragma Inline (Super_Element);
pragma Inline (Super_Find_Token);
pragma Inline (Super_Index);
pragma Inline (Super_Index_Non_Blank);
pragma Inline (Super_Length);
pragma Inline (Super_Replace_Element);
pragma Inline (Super_Slice);
pragma Inline (Super_To_String);
end Ada.Strings.Wide_Superbounded;
|
programs/oeis/027/A027924.asm | neoneye/loda | 22 | 452 | ; A027924: a(n) = least k such that 1+2+...+k >= 1^3 + 2^3 + ... + n^3.
; 1,4,8,14,21,30,40,51,64,78,93,110,129,148,170,192,216,242,269,297,327,358,390,424,460,496,535,574,615,658,701,747,793,841,891,942,994,1048,1103,1160,1218,1277,1338,1400,1464,1529,1595,1663,1732,1803,1875
mov $2,$0
bin $0,2
add $0,6
mul $2,2
add $0,$2
seq $0,87057 ; Smallest number whose square is larger than 2*n^2.
sub $0,9
|
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/deferred_const2_pkg.adb | best08618/asylo | 7 | 26819 | with System; use System;
package body Deferred_Const2_Pkg is
procedure Dummy is begin null; end;
begin
if S'Address /= I'Address then
raise Program_Error;
end if;
end Deferred_Const2_Pkg;
|
out/CommRing/Signature.agda | JoeyEremondi/agda-soas | 39 | 7956 | {-
This second-order signature was created from the following second-order syntax description:
syntax CommRing | CR
type
* : 0-ary
term
zero : * | 𝟘
add : * * -> * | _⊕_ l20
one : * | 𝟙
mult : * * -> * | _⊗_ l30
neg : * -> * | ⊖_ r50
theory
(𝟘U⊕ᴸ) a |> add (zero, a) = a
(𝟘U⊕ᴿ) a |> add (a, zero) = a
(⊕A) a b c |> add (add(a, b), c) = add (a, add(b, c))
(⊕C) a b |> add(a, b) = add(b, a)
(𝟙U⊗ᴸ) a |> mult (one, a) = a
(𝟙U⊗ᴿ) a |> mult (a, one) = a
(⊗A) a b c |> mult (mult(a, b), c) = mult (a, mult(b, c))
(⊗D⊕ᴸ) a b c |> mult (a, add (b, c)) = add (mult(a, b), mult(a, c))
(⊗D⊕ᴿ) a b c |> mult (add (a, b), c) = add (mult(a, c), mult(b, c))
(𝟘X⊗ᴸ) a |> mult (zero, a) = zero
(𝟘X⊗ᴿ) a |> mult (a, zero) = zero
(⊖N⊕ᴸ) a |> add (neg (a), a) = zero
(⊖N⊕ᴿ) a |> add (a, neg (a)) = zero
(⊗C) a b |> mult(a, b) = mult(b, a)
-}
module CommRing.Signature where
open import SOAS.Context
open import SOAS.Common
open import SOAS.Syntax.Signature *T public
open import SOAS.Syntax.Build *T public
-- Operator symbols
data CRₒ : Set where
zeroₒ addₒ oneₒ multₒ negₒ : CRₒ
-- Term signature
CR:Sig : Signature CRₒ
CR:Sig = sig λ
{ zeroₒ → ⟼₀ *
; addₒ → (⊢₀ *) , (⊢₀ *) ⟼₂ *
; oneₒ → ⟼₀ *
; multₒ → (⊢₀ *) , (⊢₀ *) ⟼₂ *
; negₒ → (⊢₀ *) ⟼₁ *
}
open Signature CR:Sig public
|
programs/oeis/017/A017219.asm | neoneye/loda | 22 | 103583 | ; A017219: a(n) = (9*n + 4)^11.
; 4194304,1792160394037,584318301411328,25408476896404831,419430400000000000,3909821048582988049,24986644000165537792,122130132904968017083,488595558857835544576,1673432436896142578125,5062982072492057196544,13842338707244455781047,34785499933455142617088,81402749386839761113321,179216039403700000000000,374250856383374715683539,746240592700077928087552,1428552404463186019525093,2637478745165999792674816,4714314324855804443359375,8184573499099987295862784,13839818640542834852821057,22848887739705683048654848,36906852424971083485992811,58431830141132800000000000,90821841990842470457948029,138786277585726844783245312,208769228288504308517520103,309485009821345068724781056,452589644988876542822265625,653515949089146258317953024,932504187587662529970024067,1315865092186113398284484608,1837517363158923337459953301,2540847689640483100000000000,3480947823559350267570691519,4727290386521267611811971072,6366912912781415703444512113,8508188177411469292077623296,11285268170004959241748046875,14863299195173980157734027264,19444516557322886668124300077,25275339165644378498708666368,32654597224127007351927104791,41943040000000000000000000000,53574285543133366239295624009,68067390210373163218005624832,86041232985790766413028611123,108230927934780930945540161536,135506497742528825219189453125,168894062222506223751543445504,209599817996529430739834959087,259037109303946675027997360128,318856915154403706875322757281,390982104858298804900000000000,477645842414670666895611255499,581434550372305641487929966592,705335875671998020885807527133,852792133693094851836500555776,1027759742333903757355615234375,1234775195522690052378270367744,1479028165154542070164647711097,1766442362151297812563548325888,2103764831220211147045849420771,2498664400016553779200000000000,2959840051871614745048248895989,3497140042107539438489709156352,4121692631302365092279372570143,4846049364771931674565742166016,5684341886080801486968994140625,6652453333663885125801859753984,7768205433717376298112278666107,9051562469486326303036064923648,10524853377022476462245292805261,12213013290496801708300000000000,14143845936314841845173468655479,16348308354688802241321329754112,18860819510059339094078792650153,21719594437923904738055379552256,24967005665310767214189794921875,28649973735432839556346333364224,32820388764059014706376078334117,37535565055949810985508820113408,42858730914417052610343077820751,48859555885783554457600000000000,55614717793339117396720595443969,63208512032415589898313264719872,71733505719539585795878718277163,81291239414371192166111034474496,91992979263406433068835986328125,103960522549317404752220205758464,117327059769435148914666815625127,132238096511356018385684600455168,148852438543083302439338564577241,167343243689614257812500000000000,187899144227561729924334314971459,210725443694373792973095417413632,236045392179100086342617165561173,264101544337566829536666251892736,295157204556382162758788037109375
mul $0,9
add $0,4
pow $0,11
|
programs/oeis/070/A070457.asm | neoneye/loda | 22 | 241455 | ; A070457: a(n) = n^2 mod 35.
; 0,1,4,9,16,25,1,14,29,11,30,16,4,29,21,15,11,9,9,11,15,21,29,4,16,30,11,29,14,1,25,16,9,4,1,0,1,4,9,16,25,1,14,29,11,30,16,4,29,21,15,11,9,9,11,15,21,29,4,16,30,11,29,14,1,25,16,9,4,1,0,1,4,9,16,25,1,14,29,11,30,16,4,29,21,15,11,9,9,11,15,21,29,4,16,30,11,29,14,1
pow $0,2
mod $0,35
|
programs/oeis/186/A186497.asm | jmorken/loda | 1 | 178929 | <gh_stars>1-10
; A186497: Adjusted joint rank sequence of (f(i)) and (g(j)) with f(i) before g(j) when f(i)=g(j), where f(i)=3i-2 and g(j)=j-th triangular number. Complement of A186498.
; 1,4,6,7,9,11,12,14,15,16,18,19,21,22,23,25,26,27,28,30,31,32,34,35,36,37,39,40,41,42,43,45,46,47,48,50,51,52,53,54,56,57,58,59,60,61,63,64,65,66,67,69,70,71,72,73,74,76,77,78,79,80,81,82,84,85,86,87,88,89,91,92,93,94,95,96,97,99,100,101,102,103,104,105,106,108,109,110,111,112,113,114,116,117,118,119,120,121,122,123,125,126,127,128,129,130,131,132,133,135,136,137,138,139,140,141,142,144,145,146
mov $1,$0
mov $2,2
add $2,$0
mul $0,2
sub $2,1
add $0,$2
lpb $0
sub $0,1
add $1,1
mov $3,$1
sub $3,$2
trn $0,$3
lpe
|
archive/agda-3/src/Oscar/Class/Similarity.agda | m0davis/oscar | 0 | 13446 |
open import Oscar.Prelude
open import Oscar.Class
open import Oscar.Class.SimilaritySingleton
open import Oscar.Class.SimilarityM
module Oscar.Class.Similarity where
module Similarity
{𝔞} {𝔄 : Ø 𝔞}
{𝔟} {𝔅 : Ø 𝔟}
{𝔣} {𝔉 : Ø 𝔣}
{𝔞̇ 𝔟̇}
(_∼₁_ : 𝔄 → 𝔄 → Ø 𝔞̇)
(_∼₂_ : 𝔅 → 𝔅 → Ø 𝔟̇) (let _∼₂_ = _∼₂_; infix 4 _∼₂_)
(_◃_ : 𝔉 → 𝔄 → 𝔅) (let _◃_ = _◃_; infix 16 _◃_)
= ℭLASS (_◃_ , _∼₂_) (∀ {x y} f → x ∼₁ y → f ◃ x ∼₂ f ◃ y)
module _
{𝔞} {𝔄 : Ø 𝔞}
{𝔟} {𝔅 : Ø 𝔟}
{𝔣} {𝔉 : Ø 𝔣}
{𝔞̇ 𝔟̇}
{_∼₁_ : 𝔄 → 𝔄 → Ø 𝔞̇}
{_∼₂_ : 𝔅 → 𝔅 → Ø 𝔟̇}
{_◃_ : 𝔉 → 𝔄 → 𝔅}
where
similarity = Similarity.method _∼₁_ _∼₂_ _◃_
module _ ⦃ _ : Similarity.class _∼₁_ _∼₂_ _◃_ ⦄ where
instance
toSimilaritySingleton : ∀ {x y f} → SimilaritySingleton.class (x ∼₁ y) _∼₂_ _◃_ x y f
toSimilaritySingleton .⋆ = similarity _
toSimilarityM : ∀ {x y} → SimilarityM.class _∼₁_ _∼₂_ _◃_ x y
toSimilarityM .⋆ = similarity
open import Oscar.Class.Smap
open import Oscar.Class.Surjection
module Similarity,cosmaparrow
{𝔵₁} {𝔛₁ : Ø 𝔵₁}
{𝔵₂} {𝔛₂ : Ø 𝔵₂}
(surjection : Surjection.type 𝔛₁ 𝔛₂)
{𝔯} (ℜ : 𝔛₁ → 𝔛₁ → Ø 𝔯)
{𝔭₁} (𝔓₁ : 𝔛₂ → Ø 𝔭₁)
{𝔭₂} (𝔓₂ : 𝔛₂ → Ø 𝔭₂)
(smaparrow : Smaparrow.type ℜ 𝔓₁ 𝔓₂ surjection surjection)
{𝔯̇} (ℜ̇ : ∀ {x y} → ℜ x y → ℜ x y → Ø 𝔯̇)
{𝔭̇₂} (𝔓̇₂ : ∀ {x} → 𝔓₂ x → 𝔓₂ x → Ø 𝔭̇₂)
where
class = ∀ {m n} → Similarity.class (ℜ̇ {m} {n}) (𝔓̇₂ {surjection n}) (flip smaparrow)
type = ∀ {m n} → Similarity.type (ℜ̇ {m} {n}) (𝔓̇₂ {surjection n}) (flip smaparrow)
module Similarity,cosmaparrow!
{𝔵₁} {𝔛₁ : Ø 𝔵₁}
{𝔵₂} {𝔛₂ : Ø 𝔵₂}
⦃ _ : Surjection.class 𝔛₁ 𝔛₂ ⦄
{𝔯} (ℜ : 𝔛₁ → 𝔛₁ → Ø 𝔯)
{𝔭₁} (𝔓₁ : 𝔛₂ → Ø 𝔭₁)
{𝔭₂} (𝔓₂ : 𝔛₂ → Ø 𝔭₂)
⦃ _ : Smaparrow!.class ℜ 𝔓₁ 𝔓₂ ⦄
{𝔯̇} (ℜ̇ : ∀ {x y} → ℜ x y → ℜ x y → Ø 𝔯̇)
{𝔭̇₂} (𝔓̇₂ : ∀ {x} → 𝔓₂ x → 𝔓₂ x → Ø 𝔭̇₂)
= Similarity,cosmaparrow surjection ℜ 𝔓₁ 𝔓₂ smaparrow ℜ̇ 𝔓̇₂
module Similarity,cosmaphomarrow
{𝔵₁} {𝔛₁ : Ø 𝔵₁}
{𝔵₂} {𝔛₂ : Ø 𝔵₂}
(surjection : Surjection.type 𝔛₁ 𝔛₂)
{𝔯} (ℜ : 𝔛₁ → 𝔛₁ → Ø 𝔯)
{𝔭} (𝔓 : 𝔛₂ → Ø 𝔭)
(smaparrow : Smaphomarrow.type ℜ 𝔓 surjection)
{𝔯̇} (ℜ̇ : ∀ {x y} → ℜ x y → ℜ x y → Ø 𝔯̇)
{𝔭̇} (𝔓̇ : ∀ {x} → 𝔓 x → 𝔓 x → Ø 𝔭̇)
= Similarity,cosmaparrow surjection ℜ 𝔓 𝔓 smaparrow ℜ̇ 𝔓̇
module Similarity,cosmaphomarrow!
{𝔵₁} {𝔛₁ : Ø 𝔵₁}
{𝔵₂} {𝔛₂ : Ø 𝔵₂}
⦃ _ : Surjection.class 𝔛₁ 𝔛₂ ⦄
{𝔯} (ℜ : 𝔛₁ → 𝔛₁ → Ø 𝔯)
{𝔭} (𝔓 : 𝔛₂ → Ø 𝔭)
⦃ _ : Smaphomarrow!.class ℜ 𝔓 ⦄
{𝔯̇} (ℜ̇ : ∀ {x y} → ℜ x y → ℜ x y → Ø 𝔯̇)
{𝔭̇} (𝔓̇ : ∀ {x} → 𝔓 x → 𝔓 x → Ø 𝔭̇)
= Similarity,cosmaphomarrow surjection ℜ 𝔓 smaparrow ℜ̇ 𝔓̇
module Similarity,smaparrow
{𝔵₁} {𝔛₁ : Ø 𝔵₁}
{𝔵₂} {𝔛₂ : Ø 𝔵₂}
(surjection : Surjection.type 𝔛₁ 𝔛₂)
{𝔯} (ℜ : π̂² 𝔯 𝔛₁)
{𝔭₁} (𝔓₁ : π̂ 𝔭₁ 𝔛₂)
{𝔭₂} (𝔓₂ : π̂ 𝔭₂ 𝔛₂)
(smaparrow : Smaparrow.type ℜ 𝔓₁ 𝔓₂ surjection surjection)
{𝔭̇₁} (𝔓̇₁ : ∀̇ π̂² 𝔭̇₁ (𝔓₁ ∘ surjection))
{𝔭̇₂} (𝔓̇₂ : ∀̇ π̂² 𝔭̇₂ (𝔓₂ ∘ surjection))
where
class = ∀ {m n} → Similarity.class (𝔓̇₁ {m}) (𝔓̇₂ {n}) smaparrow
type = ∀ {m n} → Similarity.type (𝔓̇₁ {m}) (𝔓̇₂ {n}) smaparrow
module Similarity,smaparrow!
{𝔵₁} {𝔛₁ : Ø 𝔵₁}
{𝔵₂} {𝔛₂ : Ø 𝔵₂}
⦃ _ : Surjection.class 𝔛₁ 𝔛₂ ⦄
{𝔯} (ℜ : π̂² 𝔯 𝔛₁)
{𝔭₁} (𝔓₁ : π̂ 𝔭₁ 𝔛₂)
{𝔭₂} (𝔓₂ : π̂ 𝔭₂ 𝔛₂)
⦃ _ : Smaparrow!.class ℜ 𝔓₁ 𝔓₂ ⦄
{𝔭̇₁} (𝔓̇₁ : ∀̇ π̂² 𝔭̇₁ (𝔓₁ ∘ surjection))
{𝔭̇₂} (𝔓̇₂ : ∀̇ π̂² 𝔭̇₂ (𝔓₂ ∘ surjection))
= Similarity,smaparrow surjection ℜ 𝔓₁ 𝔓₂ smaparrow 𝔓̇₁ 𝔓̇₂
module Similarity,smaphomarrow
{𝔵₁} {𝔛₁ : Ø 𝔵₁}
{𝔵₂} {𝔛₂ : Ø 𝔵₂}
(surjection : Surjection.type 𝔛₁ 𝔛₂)
{𝔯} (ℜ : π̂² 𝔯 𝔛₁)
{𝔭} (𝔓 : π̂ 𝔭 𝔛₂)
(smaparrow : Smaphomarrow.type ℜ 𝔓 surjection)
{𝔭̇} (𝔓̇ : ∀̇ π̂² 𝔭̇ (𝔓 ∘ surjection))
= Similarity,smaparrow surjection ℜ 𝔓 𝔓 smaparrow 𝔓̇ 𝔓̇
module Similarity,smaphomarrow!
{𝔵₁} {𝔛₁ : Ø 𝔵₁}
{𝔵₂} {𝔛₂ : Ø 𝔵₂}
⦃ _ : Surjection.class 𝔛₁ 𝔛₂ ⦄
{𝔯} (ℜ : π̂² 𝔯 𝔛₁)
{𝔭} (𝔓 : π̂ 𝔭 𝔛₂)
⦃ _ : Smaphomarrow!.class ℜ 𝔓 ⦄
{𝔭̇} (𝔓̇ : ∀̇ π̂² 𝔭̇ (𝔓 ∘ surjection))
= Similarity,smaphomarrow surjection ℜ 𝔓 smaparrow 𝔓̇
|
oeis/319/A319880.asm | neoneye/loda-programs | 11 | 6424 | ; A319880: Difference between 2^n and the product of primes less than or equal to n.
; Submitted by <NAME>
; 0,1,2,2,10,2,34,-82,46,302,814,-262,1786,-21838,-13646,2738,35506,-379438,-248366,-9175402,-8651114,-7602538,-5505386,-214704262,-206315654,-189538438,-155984006,-88875142,45342586,-5932822318,-5395951406,-198413006482
mov $1,2
pow $1,$0
mul $0,2
seq $0,300951 ; a(n) = Product_{j=1..floor(n/2)} p(j) where p(j) = j if j is prime else 1.
sub $1,$0
mov $0,$1
|
oeis/063/A063235.asm | neoneye/loda-programs | 11 | 104610 | <filename>oeis/063/A063235.asm
; A063235: Dimension of the space of weight 2n cuspidal newforms for Gamma_0( 83 ).
; Submitted by <NAME>(s2)
; 7,20,34,48,62,74,90,102,116,130,144,156,172,184,198,212,226,238,254,266,280,294,308,320,336,348,362,376,390,402,418,430,444,458,472,484,500,512,526,540,554,566,582,594,608,622,636,648,664,676
mov $1,$0
mul $0,13
div $1,3
mul $1,2
mov $2,$0
trn $0,3
mod $0,2
add $0,$1
add $0,$2
add $0,7
|
helloos/Kernel/Resource/kernel.mouse.asm | kbu1564/HelloOS | 15 | 26803 | <reponame>kbu1564/HelloOS
cursor:
.default:
dw 1111111111111110b
dw 1111111111111100b
dw 1111111111111000b
dw 1111111111110000b
dw 1111111111100000b
dw 1111111111000000b
dw 1111111111000000b
dw 1111111111100000b
dw 1111111111110000b
dw 1111111111111000b
dw 1111100111111100b
dw 1111000011111110b
dw 1110000001111100b
dw 1100000000111000b
dw 1000000000010000b
dw 0000000000000000b
|
driver_scripts_templates/finder.scpt | sebmarchand/chrome_safari_power | 0 | 2082 | <reponame>sebmarchand/chrome_safari_power
tell application "Finder"
activate
reopen
close Finder window 1
end tell
|
resources/scripts/archive/ukwebarchive.ads | Elon143/Amass | 7,053 | 9599 | -- Copyright 2021 <NAME>. All rights reserved.
-- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
name = "UKWebArchive"
type = "archive"
function start()
set_rate_limit(3)
end
function vertical(ctx, domain)
scrape(ctx, {['url']=build_url(domain)})
end
function build_url(domain)
return "https://www.webarchive.org.uk/wayback/archive/cdx?matchType=domain&output=json&url=" .. domain
end
|
archive/agda-2/Oscar/Data/Vec/Properties.agda | m0davis/oscar | 0 | 8996 | <gh_stars>0
module Oscar.Data.Vec.Properties where
open import Oscar.Data.Vec
open import Data.Vec.Properties public
open import Data.Nat
open import Data.Product renaming (map to mapP)
open import Relation.Binary.PropositionalEquality
open import Data.Fin
map-∈ : ∀ {a b} {A : Set a} {B : Set b} {y : B} {f : A → B} {n} {xs : Vec A n} → y ∈ map f xs → ∃ λ x → f x ≡ y
map-∈ {xs = []} ()
map-∈ {xs = x ∷ xs} here = x , refl
map-∈ {xs = x ∷ xs} (there y∈mapfxs) = map-∈ y∈mapfxs
∈-map₂ : ∀ {a b} {A : Set a} {B : Set b} {m n : ℕ}
→ ∀ {c} {F : Set c} (f : A → B → F)
{xs : Vec A m} {ys : Vec B n}
{x y} → x ∈ xs → y ∈ ys → (f x y) ∈ map₂ f xs ys
∈-map₂ f {xs = x ∷ xs} {ys} here y∈ys =
∈-++ₗ (∈-map (f x) y∈ys)
∈-map₂ f {xs = x ∷ xs} {ys} (there x∈xs) y∈ys =
∈-++ᵣ (map (f x) ys) (∈-map₂ f x∈xs y∈ys)
lookup-delete-thin : ∀ {a n} {A : Set a} (x : Fin (suc n)) (y : Fin n) (v : Vec A (suc n)) →
lookup y (delete x v) ≡ lookup (thin x y) v
lookup-delete-thin zero zero (_ ∷ _) = refl
lookup-delete-thin zero (suc _) (_ ∷ _) = refl
lookup-delete-thin (suc _) zero (_ ∷ _) = refl
lookup-delete-thin (suc x) (suc y) (_ ∷ v) = lookup-delete-thin x y v
|
src/sys/http/curl/util-http-clients-curl.adb | RREE/ada-util | 60 | 17635 | -----------------------------------------------------------------------
-- util-http-clients-curl -- HTTP Clients with CURL
-- Copyright (C) 2012, 2017, 2018, 2020 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Strings;
with Util.Log.Loggers;
with Util.Http.Clients.Curl.Constants;
package body Util.Http.Clients.Curl is
use System;
pragma Linker_Options ("-lcurl");
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Util.Http.Clients.Curl");
function Get_Request (Http : in Client'Class) return Curl_Http_Request_Access;
PUT_TOKEN : constant Chars_Ptr := Strings.New_String ("PUT");
PATCH_TOKEN : constant Chars_Ptr := Strings.New_String ("PATCH");
OPTIONS_TOKEN : constant Chars_Ptr := Strings.New_String ("OPTIONS");
DELETE_TOKEN : constant Chars_Ptr := Strings.New_String ("DELETE");
Manager : aliased Curl_Http_Manager;
-- ------------------------------
-- Register the CURL Http manager.
-- ------------------------------
procedure Register is
begin
Default_Http_Manager := Manager'Access;
end Register;
-- ------------------------------
-- Check the CURL result code and report and exception and a log message if
-- the CURL code indicates an error.
-- ------------------------------
procedure Check_Code (Code : in CURL_Code;
Message : in String) is
begin
if Code /= CURLE_OK then
declare
Error : constant Chars_Ptr := Curl_Easy_Strerror (Code);
Msg : constant String := Interfaces.C.Strings.Value (Error);
begin
Log.Error ("{0}: {1}", Message, Msg);
raise Connection_Error with Msg;
end;
end if;
end Check_Code;
-- ------------------------------
-- Create a new HTTP request associated with the current request manager.
-- ------------------------------
procedure Create (Manager : in Curl_Http_Manager;
Http : in out Client'Class) is
pragma Unreferenced (Manager);
Request : Curl_Http_Request_Access;
Data : CURL;
begin
Data := Curl_Easy_Init;
if Data = System.Null_Address then
raise Storage_Error with "curl_easy_init cannot create the CURL instance";
end if;
Request := new Curl_Http_Request;
Request.Data := Data;
Http.Delegate := Request.all'Access;
end Create;
function Get_Request (Http : in Client'Class) return Curl_Http_Request_Access is
begin
return Curl_Http_Request'Class (Http.Delegate.all)'Access;
end Get_Request;
-- ------------------------------
-- This function is called by CURL when a response line was read.
-- ------------------------------
function Read_Response (Data : in Chars_Ptr;
Size : in Size_T;
Nmemb : in Size_T;
Response : in Curl_Http_Response_Access) return Size_T is
Total : constant Size_T := Size * Nmemb;
Last : Natural;
Line : constant String := Interfaces.C.Strings.Value (Data, Total);
begin
Last := Line'Last;
while Last > Line'First and then (Line (Last) = ASCII.CR or Line (Last) = ASCII.LF) loop
Last := Last - 1;
end loop;
Log.Debug ("RCV: {0}", Line (Line'First .. Last));
if Response.Parsing_Body then
Ada.Strings.Unbounded.Append (Response.Content, Line);
elsif Total = 2 and then Line (1) = ASCII.CR and then Line (2) = ASCII.LF then
Response.Parsing_Body := True;
else
declare
Pos : constant Natural := Util.Strings.Index (Line, ':');
Start : Natural;
begin
if Pos > 0 then
Start := Pos + 1;
while Start <= Line'Last and Line (Start) = ' ' loop
Start := Start + 1;
end loop;
Response.Add_Header (Name => Line (Line'First .. Pos - 1),
Value => Line (Start .. Last));
end if;
end;
end if;
return Total;
end Read_Response;
-- ------------------------------
-- Prepare to setup the headers in the request.
-- ------------------------------
procedure Set_Headers (Request : in out Curl_Http_Request) is
procedure Process (Name, Value : in String);
procedure Process (Name, Value : in String) is
S : Chars_Ptr := Strings.New_String (Name & ": " & Value);
begin
Request.Curl_Headers := Curl_Slist_Append (Request.Curl_Headers, S);
Interfaces.C.Strings.Free (S);
end Process;
begin
if Request.Curl_Headers /= null then
Curl_Slist_Free_All (Request.Curl_Headers);
Request.Curl_Headers := null;
end if;
Request.Iterate_Headers (Process'Access);
end Set_Headers;
procedure Do_Get (Manager : in Curl_Http_Manager;
Http : in Client'Class;
URI : in String;
Reply : out Response'Class) is
pragma Unreferenced (Manager);
use Interfaces.C;
Req : constant Curl_Http_Request_Access := Get_Request (Http);
Result : CURL_Code;
Response : Curl_Http_Response_Access;
Status : aliased C.long;
begin
Log.Info ("GET {0}", URI);
Result := Curl_Easy_Setopt_Write_Callback (Req.Data, Constants.CURLOPT_WRITEUNCTION,
Read_Response'Access);
Check_Code (Result, "set callback");
Req.Set_Headers;
Interfaces.C.Strings.Free (Req.URL);
Req.URL := Strings.New_String (URI);
Result := Curl_Easy_Setopt_Long (Req.Data, Constants.CURLOPT_HTTPGET, 1);
Check_Code (Result, "set http GET");
Result := Curl_Easy_Setopt_Long (Req.Data, Constants.CURLOPT_HEADER, 1);
Check_Code (Result, "set header");
Result := Curl_Easy_Setopt_Slist (Req.Data, Constants.CURLOPT_HTTPHEADER, Req.Curl_Headers);
Check_Code (Result, "set http GET headers");
Result := Curl_Easy_Setopt_String (Req.Data, Constants.CURLOPT_URL, Req.URL);
Check_Code (Result, "set url");
Response := new Curl_Http_Response;
Result := Curl_Easy_Setopt_Data (Req.Data, Constants.CURLOPT_WRITEDATA, Response);
Check_Code (Result, "set write data");
Reply.Delegate := Response.all'Access;
Result := Curl_Easy_Perform (Req.Data);
Check_Code (Result, "get request");
Result := Curl_Easy_Getinfo_Long (Req.Data, Constants.CURLINFO_RESPONSE_CODE, Status'Access);
Check_Code (Result, "get response code");
Response.Status := Natural (Status);
end Do_Get;
procedure Do_Head (Manager : in Curl_Http_Manager;
Http : in Client'Class;
URI : in String;
Reply : out Response'Class) is
pragma Unreferenced (Manager);
use Interfaces.C;
Req : constant Curl_Http_Request_Access := Get_Request (Http);
Result : CURL_Code;
Response : Curl_Http_Response_Access;
Status : aliased C.long;
begin
Log.Info ("HEAD {0}", URI);
Result := Curl_Easy_Setopt_Write_Callback (Req.Data, Constants.CURLOPT_WRITEUNCTION,
Read_Response'Access);
Check_Code (Result, "set callback");
Req.Set_Headers;
Interfaces.C.Strings.Free (Req.URL);
Req.URL := Strings.New_String (URI);
Result := Curl_Easy_Setopt_Long (Req.Data, Constants.CURLOPT_NOBODY, 1);
Check_Code (Result, "set http HEAD");
Result := Curl_Easy_Setopt_Long (Req.Data, Constants.CURLOPT_HEADER, 1);
Check_Code (Result, "set header");
Result := Curl_Easy_Setopt_Slist (Req.Data, Constants.CURLOPT_HTTPHEADER, Req.Curl_Headers);
Check_Code (Result, "set http GET headers");
Result := Curl_Easy_Setopt_String (Req.Data, Constants.CURLOPT_URL, Req.URL);
Check_Code (Result, "set url");
Response := new Curl_Http_Response;
Result := Curl_Easy_Setopt_Data (Req.Data, Constants.CURLOPT_WRITEDATA, Response);
Check_Code (Result, "set write data");
Reply.Delegate := Response.all'Access;
Result := Curl_Easy_Perform (Req.Data);
Check_Code (Result, "get request");
Result := Curl_Easy_Getinfo_Long (Req.Data, Constants.CURLINFO_RESPONSE_CODE, Status'Access);
Check_Code (Result, "get response code");
Response.Status := Natural (Status);
end Do_Head;
procedure Do_Post (Manager : in Curl_Http_Manager;
Http : in Client'Class;
URI : in String;
Data : in String;
Reply : out Response'Class) is
pragma Unreferenced (Manager);
use Interfaces.C;
Req : constant Curl_Http_Request_Access := Get_Request (Http);
Result : CURL_Code;
Response : Curl_Http_Response_Access;
Status : aliased C.long;
begin
Log.Info ("POST {0}", URI);
Result := Curl_Easy_Setopt_Write_Callback (Req.Data, Constants.CURLOPT_WRITEUNCTION,
Read_Response'Access);
Check_Code (Result, "set callback");
Req.Set_Headers;
Interfaces.C.Strings.Free (Req.URL);
Req.URL := Strings.New_String (URI);
Interfaces.C.Strings.Free (Req.Content);
Req.Content := Strings.New_String (Data);
Result := Curl_Easy_Setopt_Long (Req.Data, Constants.CURLOPT_POST, 1);
Check_Code (Result, "set http POST");
Result := Curl_Easy_Setopt_Long (Req.Data, Constants.CURLOPT_HEADER, 1);
Check_Code (Result, "set header");
Result := Curl_Easy_Setopt_Slist (Req.Data, Constants.CURLOPT_HTTPHEADER, Req.Curl_Headers);
Check_Code (Result, "set http POST headers");
Result := Curl_Easy_Setopt_String (Req.Data, Constants.CURLOPT_URL, Req.URL);
Check_Code (Result, "set url");
Result := Curl_Easy_Setopt_String (Req.Data, Constants.CURLOPT_POSTFIELDS, Req.Content);
Check_Code (Result, "set post data");
Result := Curl_Easy_Setopt_Long (Req.Data, Constants.CURLOPT_POSTFIELDSIZE, Data'Length);
Check_Code (Result, "set post data");
Response := new Curl_Http_Response;
Result := Curl_Easy_Setopt_Data (Req.Data, Constants.CURLOPT_WRITEDATA, Response);
Check_Code (Result, "set write data");
Reply.Delegate := Response.all'Access;
Result := Curl_Easy_Perform (Req.Data);
Check_Code (Result, "get request");
Result := Curl_Easy_Getinfo_Long (Req.Data, Constants.CURLINFO_RESPONSE_CODE, Status'Access);
Check_Code (Result, "get response code");
Response.Status := Natural (Status);
if Req.Curl_Headers /= null then
Curl_Slist_Free_All (Req.Curl_Headers);
Req.Curl_Headers := null;
end if;
end Do_Post;
overriding
procedure Do_Put (Manager : in Curl_Http_Manager;
Http : in Client'Class;
URI : in String;
Data : in String;
Reply : out Response'Class) is
pragma Unreferenced (Manager);
use Interfaces.C;
Req : constant Curl_Http_Request_Access := Get_Request (Http);
Result : CURL_Code;
Response : Curl_Http_Response_Access;
Status : aliased C.long;
begin
Log.Info ("PUT {0}", URI);
Result := Curl_Easy_Setopt_Write_Callback (Req.Data, Constants.CURLOPT_WRITEUNCTION,
Read_Response'Access);
Check_Code (Result, "set callback");
Req.Set_Headers;
Interfaces.C.Strings.Free (Req.URL);
Req.URL := Strings.New_String (URI);
Interfaces.C.Strings.Free (Req.Content);
Req.Content := Strings.New_String (Data);
Result := Curl_Easy_Setopt_Long (Req.Data, Constants.CURLOPT_POST, 1);
Check_Code (Result, "set http PUT");
Result := Curl_Easy_Setopt_Long (Req.Data, Constants.CURLOPT_HEADER, 1);
Check_Code (Result, "set header");
Result := Curl_Easy_Setopt_String (Req.Data, Constants.CURLOPT_CUSTOMREQUEST, PUT_TOKEN);
Check_Code (Result, "set http PUT");
Result := Curl_Easy_Setopt_Slist (Req.Data, Constants.CURLOPT_HTTPHEADER, Req.Curl_Headers);
Check_Code (Result, "set http PUT headers");
Result := Curl_Easy_Setopt_String (Req.Data, Constants.CURLOPT_URL, Req.URL);
Check_Code (Result, "set url");
Result := Curl_Easy_Setopt_String (Req.Data, Constants.CURLOPT_POSTFIELDS, Req.Content);
Check_Code (Result, "set put data");
Result := Curl_Easy_Setopt_Long (Req.Data, Constants.CURLOPT_POSTFIELDSIZE, Data'Length);
Check_Code (Result, "set put data");
Response := new Curl_Http_Response;
Result := Curl_Easy_Setopt_Data (Req.Data, Constants.CURLOPT_WRITEDATA, Response);
Check_Code (Result, "set write data");
Reply.Delegate := Response.all'Access;
Result := Curl_Easy_Perform (Req.Data);
Check_Code (Result, "get request");
Result := Curl_Easy_Getinfo_Long (Req.Data, Constants.CURLINFO_RESPONSE_CODE, Status'Access);
Check_Code (Result, "get response code");
Response.Status := Natural (Status);
Result := Curl_Easy_Setopt_String (Req.Data, Constants.CURLOPT_CUSTOMREQUEST,
Interfaces.C.Strings.Null_Ptr);
Check_Code (Result, "restore set http default");
if Req.Curl_Headers /= null then
Curl_Slist_Free_All (Req.Curl_Headers);
Req.Curl_Headers := null;
end if;
end Do_Put;
overriding
procedure Do_Patch (Manager : in Curl_Http_Manager;
Http : in Client'Class;
URI : in String;
Data : in String;
Reply : out Response'Class) is
pragma Unreferenced (Manager);
use Interfaces.C;
Req : constant Curl_Http_Request_Access := Get_Request (Http);
Result : CURL_Code;
Response : Curl_Http_Response_Access;
Status : aliased C.long;
begin
Log.Info ("PATCH {0}", URI);
Result := Curl_Easy_Setopt_Write_Callback (Req.Data, Constants.CURLOPT_WRITEUNCTION,
Read_Response'Access);
Check_Code (Result, "set callback");
Req.Set_Headers;
Interfaces.C.Strings.Free (Req.URL);
Req.URL := Strings.New_String (URI);
Interfaces.C.Strings.Free (Req.Content);
Req.Content := Strings.New_String (Data);
Result := Curl_Easy_Setopt_Long (Req.Data, Constants.CURLOPT_POST, 1);
Check_Code (Result, "set http PATCH");
Result := Curl_Easy_Setopt_Long (Req.Data, Constants.CURLOPT_HEADER, 1);
Check_Code (Result, "set header");
Result := Curl_Easy_Setopt_String (Req.Data, Constants.CURLOPT_CUSTOMREQUEST, PATCH_TOKEN);
Check_Code (Result, "set http PATCH");
Result := Curl_Easy_Setopt_Slist (Req.Data, Constants.CURLOPT_HTTPHEADER, Req.Curl_Headers);
Check_Code (Result, "set http PATCH headers");
Result := Curl_Easy_Setopt_String (Req.Data, Constants.CURLOPT_URL, Req.URL);
Check_Code (Result, "set url");
Result := Curl_Easy_Setopt_String (Req.Data, Constants.CURLOPT_POSTFIELDS, Req.Content);
Check_Code (Result, "set patch data");
Result := Curl_Easy_Setopt_Long (Req.Data, Constants.CURLOPT_POSTFIELDSIZE, Data'Length);
Check_Code (Result, "set patch data");
Response := new Curl_Http_Response;
Result := Curl_Easy_Setopt_Data (Req.Data, Constants.CURLOPT_WRITEDATA, Response);
Check_Code (Result, "set write data");
Reply.Delegate := Response.all'Access;
Result := Curl_Easy_Perform (Req.Data);
Check_Code (Result, "get request");
Result := Curl_Easy_Getinfo_Long (Req.Data, Constants.CURLINFO_RESPONSE_CODE, Status'Access);
Check_Code (Result, "get response code");
Response.Status := Natural (Status);
Result := Curl_Easy_Setopt_String (Req.Data, Constants.CURLOPT_CUSTOMREQUEST,
Interfaces.C.Strings.Null_Ptr);
Check_Code (Result, "restore set http default");
if Req.Curl_Headers /= null then
Curl_Slist_Free_All (Req.Curl_Headers);
Req.Curl_Headers := null;
end if;
end Do_Patch;
overriding
procedure Do_Delete (Manager : in Curl_Http_Manager;
Http : in Client'Class;
URI : in String;
Reply : out Response'Class) is
pragma Unreferenced (Manager);
use Interfaces.C;
Req : constant Curl_Http_Request_Access := Get_Request (Http);
Result : CURL_Code;
Response : Curl_Http_Response_Access;
Status : aliased C.long;
begin
Log.Info ("DELETE {0}", URI);
Result := Curl_Easy_Setopt_Write_Callback (Req.Data, Constants.CURLOPT_WRITEUNCTION,
Read_Response'Access);
Check_Code (Result, "set callback");
Req.Set_Headers;
Interfaces.C.Strings.Free (Req.URL);
Req.URL := Strings.New_String (URI);
Result := Curl_Easy_Setopt_Long (Req.Data, Constants.CURLOPT_POST, 1);
Check_Code (Result, "set http DELETE");
Result := Curl_Easy_Setopt_Long (Req.Data, Constants.CURLOPT_HEADER, 1);
Check_Code (Result, "set header");
Result := Curl_Easy_Setopt_String (Req.Data, Constants.CURLOPT_CUSTOMREQUEST, DELETE_TOKEN);
Check_Code (Result, "set http DELETE");
Result := Curl_Easy_Setopt_Slist (Req.Data, Constants.CURLOPT_HTTPHEADER, Req.Curl_Headers);
Check_Code (Result, "set http GET headers");
Result := Curl_Easy_Setopt_String (Req.Data, Constants.CURLOPT_URL, Req.URL);
Check_Code (Result, "set url");
-- Result := Curl_Easy_Setopt_String (Req.Data, Constants.CURLOPT_POSTFIELDS, Req.Content);
-- Check_Code (Result, "set post data");
Result := Curl_Easy_Setopt_Long (Req.Data, Constants.CURLOPT_POSTFIELDSIZE, 0);
Check_Code (Result, "set post data");
Response := new Curl_Http_Response;
Result := Curl_Easy_Setopt_Data (Req.Data, Constants.CURLOPT_WRITEDATA, Response);
Check_Code (Result, "set write data");
Reply.Delegate := Response.all'Access;
Result := Curl_Easy_Perform (Req.Data);
Check_Code (Result, "get request");
Result := Curl_Easy_Getinfo_Long (Req.Data, Constants.CURLINFO_RESPONSE_CODE, Status'Access);
Check_Code (Result, "get response code");
Response.Status := Natural (Status);
Result := Curl_Easy_Setopt_String (Req.Data, Constants.CURLOPT_CUSTOMREQUEST,
Interfaces.C.Strings.Null_Ptr);
Check_Code (Result, "restore set http default");
end Do_Delete;
overriding
procedure Do_Options (Manager : in Curl_Http_Manager;
Http : in Client'Class;
URI : in String;
Reply : out Response'Class) is
pragma Unreferenced (Manager);
use Interfaces.C;
Req : constant Curl_Http_Request_Access := Get_Request (Http);
Result : CURL_Code;
Response : Curl_Http_Response_Access;
Status : aliased C.long;
begin
Log.Info ("OPTIONS {0}", URI);
Result := Curl_Easy_Setopt_Write_Callback (Req.Data, Constants.CURLOPT_WRITEUNCTION,
Read_Response'Access);
Check_Code (Result, "set callback");
Req.Set_Headers;
Interfaces.C.Strings.Free (Req.URL);
Req.URL := Strings.New_String (URI);
Result := Curl_Easy_Setopt_Long (Req.Data, Constants.CURLOPT_POST, 1);
Check_Code (Result, "set http OPTIONS");
Result := Curl_Easy_Setopt_Long (Req.Data, Constants.CURLOPT_HEADER, 1);
Check_Code (Result, "set header");
Result := Curl_Easy_Setopt_String (Req.Data, Constants.CURLOPT_CUSTOMREQUEST, OPTIONS_TOKEN);
Check_Code (Result, "set http OPTIONS");
Result := Curl_Easy_Setopt_Slist (Req.Data, Constants.CURLOPT_HTTPHEADER, Req.Curl_Headers);
Check_Code (Result, "set http OPTIONS headers");
Result := Curl_Easy_Setopt_String (Req.Data, Constants.CURLOPT_URL, Req.URL);
Check_Code (Result, "set url");
Result := Curl_Easy_Setopt_Long (Req.Data, Constants.CURLOPT_POSTFIELDSIZE, 0);
Check_Code (Result, "set options data");
Response := new Curl_Http_Response;
Result := Curl_Easy_Setopt_Data (Req.Data, Constants.CURLOPT_WRITEDATA, Response);
Check_Code (Result, "set write data");
Reply.Delegate := Response.all'Access;
Result := Curl_Easy_Perform (Req.Data);
Check_Code (Result, "get request");
Result := Curl_Easy_Getinfo_Long (Req.Data, Constants.CURLINFO_RESPONSE_CODE, Status'Access);
Check_Code (Result, "get response code");
Response.Status := Natural (Status);
Result := Curl_Easy_Setopt_String (Req.Data, Constants.CURLOPT_CUSTOMREQUEST,
Interfaces.C.Strings.Null_Ptr);
Check_Code (Result, "restore set http default");
end Do_Options;
-- ------------------------------
-- Set the timeout for the connection.
-- ------------------------------
overriding
procedure Set_Timeout (Manager : in Curl_Http_Manager;
Http : in Client'Class;
Timeout : in Duration) is
pragma Unreferenced (Manager);
Req : constant Curl_Http_Request_Access := Get_Request (Http);
Time : constant Interfaces.C.long := Interfaces.C.long (Timeout);
Result : CURL_Code;
begin
Result := Curl_Easy_Setopt_Long (Req.Data, Constants.CURLOPT_TIMEOUT, Time);
Check_Code (Result, "set timeout");
end Set_Timeout;
overriding
procedure Finalize (Request : in out Curl_Http_Request) is
begin
if Request.Data /= System.Null_Address then
Curl_Easy_Cleanup (Request.Data);
Request.Data := System.Null_Address;
end if;
if Request.Curl_Headers /= null then
Curl_Slist_Free_All (Request.Curl_Headers);
Request.Curl_Headers := null;
end if;
Interfaces.C.Strings.Free (Request.URL);
Interfaces.C.Strings.Free (Request.Content);
end Finalize;
-- ------------------------------
-- Get the response body as a string.
-- ------------------------------
overriding
function Get_Body (Reply : in Curl_Http_Response) return String is
begin
return Ada.Strings.Unbounded.To_String (Reply.Content);
end Get_Body;
-- ------------------------------
-- Get the response status code.
-- ------------------------------
overriding
function Get_Status (Reply : in Curl_Http_Response) return Natural is
begin
return Reply.Status;
end Get_Status;
end Util.Http.Clients.Curl;
|
libsrc/input/m5/in_KeyPressed.asm | jpoikela/z88dk | 640 | 22117 | ; uint in_KeyPressed(uint scancode)
SECTION code_clib
PUBLIC in_KeyPressed
PUBLIC _in_KeyPressed
; Determines if a key is pressed using the scan code
; returned by in_LookupKey.
; enter : l = scan row
; h = key mask
; exit : carry = key is pressed & HL = 1
; no carry = key not pressed & HL = 0
; used : AF,BC,HL
.in_KeyPressed
._in_KeyPressed
in a,($30)
ld b,a
ld c,@00001101
bit 6,l
jr z,no_control
bit 0,a
jr z,fail
res 0,c
no_control:
bit 7,l
jr z,no_shift
and @00001100
jr z, fail
res 2,c
res 3,c
no_shift:
ld a,b ; Make sure we don't have unwanted modifiers pressed
and c
jr nz,fail
ld a,l
and @00111111
ld c,a
in a,(c)
and h
jr z,fail
ld hl,1
scf
ret
fail:
ld hl,0
and a
ret
|
Library/User/Help/helpFirstAid.asm | steakknife/pcgeos | 504 | 8563 | COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) GeoWorks 1992 -- All Rights Reserved
PROJECT: PC GEOS
MODULE:
FILE: helpFirstAid.asm
AUTHOR: <NAME>, Dec 14, 1992
ROUTINES:
Name Description
---- -----------
REVISION HISTORY:
Name Date Description
---- ---- -----------
Gene 12/14/92 Initial revision
DESCRIPTION:
$Id: helpFirstAid.asm,v 1.1 97/04/07 11:47:27 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
HelpControlCode segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
HelpControlChooseFirstAid
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Handle user choosing a first aid option
CALLED BY: MSG_HC_CHOOSE_FIRST_AID
PASS: *ds:si - instance data
ds:di - *ds:si
es - seg addr of HelpControlClass
ax - the message
cx - VisTextContextType
RETURN: none
DESTROYED: bx, si, di, ds, es (method handler)
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
gene 12/14/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
HelpControlChooseFirstAid method dynamic HelpControlClass,
MSG_HC_CHOOSE_FIRST_AID
HELP_LOCALS
.enter
call HUGetChildBlockAndFeaturesLocals
EC < test ss:features, mask HPCF_HISTORY ;>
EC < ERROR_NZ HELP_CANNOT_HAVE_HISTORY_FOR_FIRST_AID_HELP >
;
; Find the number of entries back to the *oldest* history entry
; of the correct type. This means clicking on TOC, Chapter, or
; Article will take the user to their original entry of the
; given type.
;
; This is currently done in a somewhat inefficient manner, but it
; is relatively small since it is mostly common code. There should
; never be enough history involved for this to really matter, in
; any event, and will be swamped by the time to load, decompress,
; calculate and display the text.
;
mov al, cl ;al <- VisTextContextType
call HFAFindHistory ;cx <- # of items back
goBackLoop:
call HFAGoBackOne ;go back one item in history
jc noHistory ;branch if no history left
loop goBackLoop ;loop until far enough
;
; Display the new text
;
call HLDisplayText
jc openError ;branch if error
call HFAUpdateForMode
openError:
quit:
.leave
ret
;
; We've run out of history -- rather than do nothing, bring
; up the TOC as a last resort.
;
noHistory:
mov ax, MSG_HC_BRING_UP_TOC
call ObjCallInstanceNoLock
jmp quit
HelpControlChooseFirstAid endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
HFAUpdateForMode
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Update the First Aid UI for the current mode
CALLED BY: HelpControlChooseFirstAid()
PASS: ss:bp - inherited locals
RETURN: none
DESTROYED: ax, bx, dx
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
gene 12/14/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
FAM_DONT_CARE equ VTCT_FILE-1 ;don't care about previous
FAM_NONE equ VTCT_FILE-2 ;if there is no previous
FirstAidModeStruct struct
FAMS_prevContext VisTextContextType ;previous context to match
FAMS_curContext VisTextContextType ;current context to match
FAMS_listSetting VisTextContextType ;setting for first aid list
FAMS_chapterState word ;enable or disable
FAMS_articleState word ;enable or disable
FAMS_jumpState word ;enable or disable
FAMS_instructions lptr ;instructions to display
FirstAidModeStruct ends
firstAidModes FirstAidModeStruct <
;
; at "TOC" initially
;
FAM_NONE, ;previous
VTCT_CATEGORY, ;current
VTCT_CATEGORY, ;list state
MSG_GEN_SET_NOT_ENABLED, ;chapter
MSG_GEN_SET_NOT_ENABLED, ;article
MSG_GEN_SET_NOT_ENABLED, ;jump back
offset tocInst
>,<
;
; at "Chapter" initially (ie. no TOC)
;
FAM_NONE, ;previous
VTCT_QUESTION, ;current
VTCT_QUESTION, ;list state
MSG_GEN_SET_ENABLED, ;chapter
MSG_GEN_SET_NOT_ENABLED, ;article
MSG_GEN_SET_NOT_ENABLED, ;jump back
offset chapterInst
>,<
;
; at "Chapter" from TOC
;
VTCT_CATEGORY, ;previous
VTCT_QUESTION, ;current
VTCT_QUESTION, ;list state
MSG_GEN_SET_ENABLED, ;chapter
MSG_GEN_SET_NOT_ENABLED, ;article
MSG_GEN_SET_NOT_ENABLED, ;jump back
offset chapterInst
>,<
;
; at "Answer" from Chapter
;
VTCT_QUESTION, ;previous
VTCT_ANSWER, ;current
VTCT_ANSWER, ;list state
MSG_GEN_SET_ENABLED, ;chapter
MSG_GEN_SET_ENABLED, ;article
MSG_GEN_SET_NOT_ENABLED, ;jump back
offset articleInst
>,<
;
; at Answer from previous "Answer"
;
VTCT_ANSWER, ;previous
VTCT_ANSWER, ;current
FAM_NONE, ;list state
MSG_GEN_SET_ENABLED, ;chapter
MSG_GEN_SET_ENABLED, ;article
MSG_GEN_SET_ENABLED, ;jump back
offset jumpBackInst
>,<
;
; at "Answer" initially (ie. no Chapter, FAM_NONE)
; or at "Answer" from TOC. These are combined into
; FAM_DONT_CARE, since the other cases with "Answer" are
; dealt with above.
;
FAM_DONT_CARE, ;previous
VTCT_ANSWER, ;current
VTCT_ANSWER, ;list state
MSG_GEN_SET_NOT_ENABLED, ;chapter
MSG_GEN_SET_ENABLED, ;article
MSG_GEN_SET_NOT_ENABLED, ;jump back
offset noChapterInst
>,<
;
; error -- no history or nothing else found
;
FAM_DONT_CARE, ;previous
FAM_DONT_CARE, ;current
FAM_NONE, ;list state
MSG_GEN_SET_NOT_ENABLED, ;chapter
MSG_GEN_SET_NOT_ENABLED, ;article
MSG_GEN_SET_NOT_ENABLED, ;jump back
offset nullInst
>
HFAUpdateForMode proc near
uses di, si, cx
HELP_LOCALS
.enter inherit
mov bx, ss:childBlock
;
; Get the previous & current contexts
;
mov dx, FAM_NONE or (FAM_NONE shl 8) ;dx <- no current, no prev
call HHGetHistoryCount ;cx <- # items in history
jcxz findMode ;branch if no history
dec cx
call HHGetHistoryEntry ;get last item
mov dl, ss:nameData.HFND_text.VTND_contextType
jcxz findMode
dec cx
call HHGetHistoryEntry ;get 2nd to last item
mov dh, ss:nameData.HFND_text.VTND_contextType
;
; See if we've been at an answer before -- it so, treat
; everything like another answer. If an answer is further
; back than the most recent item in history, then it counts.
;
mov al, VTCT_ANSWER ;al <- VisTextContextType
call HFAFindHistory
cmp cx, 0 ;far enough back?
je findMode ;branch if recent enough
mov dx, VTCT_ANSWER or (VTCT_ANSWER shl 8)
;
; Find the corresponding mode entry
;
findMode:
clr di ;di <- offset into table
modeLoop:
cmp cs:firstAidModes[di].FAMS_prevContext, FAM_DONT_CARE
je checkCurrent ;branch if don't care about prev
cmp dh, cs:firstAidModes[di].FAMS_prevContext
jne nextMode
checkCurrent:
cmp cs:firstAidModes[di].FAMS_curContext, FAM_DONT_CARE
je foundMode ;branch if don't care about cur
cmp dl, cs:firstAidModes[di].FAMS_curContext
je foundMode ;branch if match
nextMode:
add di, (size FirstAidModeStruct)
EC < cmp di, (size firstAidModes) ;>
EC < ERROR_A HELP_FIRST_AID_MODE_NOT_FOUND ;>
jmp modeLoop
;
; We've found the current mode -- update the UI
;
foundMode:
;
; Enable and disable various UI components
;
test ss:features, mask HPCF_FIRST_AID
jz noFirstAid
mov ax, cs:firstAidModes[di].FAMS_chapterState
mov si, offset HFALQuestionsEntry
call doEnableDisable
mov ax, cs:firstAidModes[di].FAMS_articleState
mov si, offset HFALAnswersEntry
call doEnableDisable
noFirstAid:
test ss:features, mask HPCF_FIRST_AID_GO_BACK
jz noFirstAidGoBack
mov ax, cs:firstAidModes[di].FAMS_jumpState
mov si, offset HelpFirstAidGoBack
call doEnableDisable
noFirstAidGoBack:
;
; Set the list to the correct mode
;
mov cl, cs:firstAidModes[di].FAMS_listSetting
clr ch ;cx <- item to set
clr dx ;dx <- no indeterminate (zero)
cmp cl, FAM_NONE ;indeterminate?
jne gotSetting
dec dx ;dx <- indeterminate (non-zero)
gotSetting:
mov ax, MSG_GEN_ITEM_GROUP_SET_SINGLE_SELECTION
mov si, offset HelpFirstAid
call HUObjMessageSend
;
; Set the instruction text, if any
;
test ss:features, mask HPCF_INSTRUCTIONS
jz noInstructions
push bp
mov dx, handle HelpControlStrings
mov bp, cs:firstAidModes[di].FAMS_instructions
mov ax, MSG_VIS_TEXT_REPLACE_ALL_OPTR
clr cx ;cx <- NULL-terminated
mov si, offset HelpInstructionsText
call HUObjMessageSend
pop bp
noInstructions:
.leave
ret
doEnableDisable:
mov dl, VUM_NOW ;dl <- VisUpdateMode
call HUObjMessageSend
retn
HFAUpdateForMode endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
HelpControlFirstAidGoBack
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: User hit "Jump Back"
CALLED BY: MSG_HC_FIRST_AID_GO_BACK
PASS: *ds:si - instance data
ds:di - *ds:si
es - seg addr of HelpControlClass
ax - the message
RETURN: none
DESTROYED: bx, si, di, ds, es (method handler)
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
gene 12/20/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
HelpControlFirstAidGoBack method dynamic HelpControlClass,
MSG_HC_FIRST_AID_GO_BACK
HELP_LOCALS
.enter
call HUGetChildBlockAndFeaturesLocals
call HFAGoBackOne ;go back one in history
EC < ERROR_C HELP_RECORDED_HELP_MISSING ;>
call HLDisplayText ;display new next
jc openError ;branch if error
call HFAUpdateForMode ;update the UI
openError:
.leave
ret
HelpControlFirstAidGoBack endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
HFAGoBackOne
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Go back one item for First Aid
CALLED BY: HelpControlFirstAidGoBack(), HelpControlChooseFirstAid()
PASS: *ds:si - help controller
ss:bp - inherited locals
RETURN: ss:bp - locals
filename - previous filename
context - previous context
carry - set if no history to go back to
DESTROYED: ax, bx
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
gene 12/20/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
HFAGoBackOne proc near
uses cx
HELP_LOCALS
.enter inherit
;
; Get the last entry & delete it
;
call HHGetHistoryCount ;cx <- # of items in history
stc ;carry <- assume no history
jcxz quit ;branch if no history
dec cx ;cx <- last item
call HHGetHistoryEntry ;get last entry
call HHDeleteHistory ;delete last; cx <- # left
call HHSameFile? ;same file?
je sameFile ;branch if same file
clr bx ;bx <- no new file
call HFSetFileCloseOld ;close current file
sameFile:
;
; Get the new last entry
;
stc ;carry <- assume no history
jcxz quit ;branch if no more history
dec cx ;cx <- last item
call HHGetHistoryEntry ;get last entry
clc ;carry <- no error
quit:
.leave
ret
HFAGoBackOne endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
HFAFindHistory
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Find oldest history entry of given type
CALLED BY: HelpControlChooseFirstAid()
PASS: *ds:si - controller
ss:bp - inherited locals
al - VisTextContextType to match
RETURN: cx - # of entries to go back
(0 means one of:
- no history
- no history of the right type
- the oldest history of the right type is the
current item
all these mean no going back is necessary)
DESTROYED: none
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
gene 12/21/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
HFAFindHistory proc near
uses bx, ds, si
.enter
;
; Lock the history array
;
call HHLockHistoryArray
;
; Get the total number of entries
;
call ChunkArrayGetCount
;
; "Begin at the beginning..." and go until we find the first entry
; of the correct type
;
mov bx, cs
mov di, offset HFAFindHistoryCallback
call ChunkArrayEnum
;
; Unlock the history array
;
call HHUnlockHistoryArray
.leave
ret
HFAFindHistory endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
HFAFindHistoryCallback
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Find the first history element of the specified type
CALLED BY: HFAFindHistory() via ChunkArrayEnum()
PASS: ds:di - current element
al - VisTextContextType to match
cx - # of entries left
RETURN: carry - set to abort
cx - new # of entries left
DESTROYED: none
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
gene 12/21/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
HFAFindHistoryCallback proc far
.enter
dec cx ;one less entry
cmp al, ds:[di].HHE_type ;correct type?
clc ;carry <- assume mismatch
jne done ;branch if mismatch
stc ;carry <- match
done:
.leave
ret
HFAFindHistoryCallback endp
HelpControlCode ends
|
test/naive-tests/5-simple-mem.asm | skyzh/mips-simulator | 35 | 170301 | <gh_stars>10-100
li $a0, 0x10
sb $a0, 0x2000($zero)
sw $a0, 0x2010($zero)
lb $a1, 0x2000($zero)
lw $a2, 0x2010($zero)
|
programs/oeis/016/A016889.asm | neoneye/loda | 22 | 161854 | <filename>programs/oeis/016/A016889.asm
; A016889: (5n+3)^5.
; 243,32768,371293,1889568,6436343,17210368,39135393,79235168,147008443,254803968,418195493,656356768,992436543,1453933568,2073071593,2887174368,3939040643,5277319168,6956883693,9039207968,11592740743,14693280768,18424351793,22877577568,28153056843,34359738368,41615795893,50049003168,59797108943,71008211968,83841135993,98465804768,115063617043,133827821568,154963892093,178689902368,205236901143,234849287168,267785184193,304316815968,344730881243,389328928768,438427732293,492359665568,551473077343,616132666368,686719856393,763633171168,847288609443,938120019968,1036579476493,1143137652768,1258284197543,1382528109568,1516398112593,1660443030368,1815232161643,1981355655168,2159424884693,2350072823968,2553954421743,2771746976768,3004150512793,3251888153568,3515706497843,3796375994368,4094691316893,4411471739168,4747561509943,5103830227968,5481173216993,5880511900768,6302794178043,6748994797568,7220115733093,7717186558368,8241264822143,8793436423168,9374815985193,9986547231968,10629803362243,11305787424768,12015732693293,12760903041568,13542593318343,14362129722368,15220870177393,16120204707168,17061555810443,18046378835968,19076162357493,20152428548768,21276733558543,22450667885568,23675856753593,24953960486368,26286674882643,27675731591168,29122898485693,30629980039968
mul $0,5
add $0,3
pow $0,5
|
sgb/command_mlt_req.asm | endrift/SameSuite | 21 | 17253 | <filename>sgb/command_mlt_req.asm
RESULTS_START EQU $c000
RESULTS_N_ROWS EQU 3
include "base.inc"
; This test verifies how SGB command MLT_REQ works
SgbPacket: MACRO
push hl
ld hl, \1
call SendSgbPacket
pop hl
ENDM
CorrectResults:
db $FF, $FE, $FF, $FF, $FF, $FF, $FE, $FD
db $FC, $FE, $FF, $FE, $FF, $FF, $FD, $FD
db $FD, $FF, $FF, $FD, $FD, $FD, $FD, $FF
RunTest:
ld de, $c000
; Initial value always reads out as controller 1
SgbPacket MLT_REQ_1
ldh a, [rP1]
call StoreResult
; Check that incrementing works as expected
call Increment
ldh a, [rP1]
call StoreResult
; Test to see if the controller value is reset by going back to 1 player
SgbPacket MLT_REQ_0
SgbPacket MLT_REQ_1
ldh a, [rP1]
call StoreResult
; Test to see the controller value in unsupported MLT_REQ 2
SgbPacket MLT_REQ_0
SgbPacket MLT_REQ_2
ldh a, [rP1]
call StoreResult
call Increment
ldh a, [rP1]
call StoreResult
; Test to see the controller order in MLT_REQ 3
SgbPacket MLT_REQ_0
SgbPacket MLT_REQ_3
ldh a, [rP1]
call StoreResult
call Increment
ldh a, [rP1]
call StoreResult
call Increment
ldh a, [rP1]
call StoreResult
call Increment
ldh a, [rP1]
call StoreResult
; Test if switching from 3 to 1 retains any state
SgbPacket MLT_REQ_0
SgbPacket MLT_REQ_3
SgbPacket MLT_REQ_1 ; Each of these increments the player 5 times before it gets ANDed
ldh a, [rP1]
call StoreResult
SgbPacket MLT_REQ_0
SgbPacket MLT_REQ_3
call Increment
SgbPacket MLT_REQ_1
ldh a, [rP1]
call StoreResult
SgbPacket MLT_REQ_0
SgbPacket MLT_REQ_3
call Increment
call Increment
SgbPacket MLT_REQ_1
ldh a, [rP1]
call StoreResult
SgbPacket MLT_REQ_0
SgbPacket MLT_REQ_3
call Increment
call Increment
call Increment
SgbPacket MLT_REQ_1
ldh a, [rP1]
call StoreResult
; Test how many times sending a packet increments
SgbPacket MLT_REQ_0
SgbPacket MLT_REQ_3
ldh a, [rP1]
call StoreResult
SgbPacket MLT_REQ_3 ; This should increment the player 6 times before it gets ANDed
ldh a, [rP1]
call StoreResult
; Test if invalid mode 2 has a glitched player 3
SgbPacket MLT_REQ_0
SgbPacket MLT_REQ_3
SgbPacket MLT_REQ_2 ; This should increment the player 5 times
ldh a, [rP1]
call StoreResult
SgbPacket MLT_REQ_0
SgbPacket MLT_REQ_3
call Increment
SgbPacket MLT_REQ_2
ldh a, [rP1]
call StoreResult
SgbPacket MLT_REQ_0
SgbPacket MLT_REQ_3
call Increment
call Increment
SgbPacket MLT_REQ_2
ldh a, [rP1]
call StoreResult
SgbPacket MLT_REQ_0
SgbPacket MLT_REQ_3
call Increment
call Increment
call Increment
SgbPacket MLT_REQ_2
ldh a, [rP1]
call StoreResult
; Test if incrementing within the glitched mode works
SgbPacket MLT_REQ_0
SgbPacket MLT_REQ_3
SgbPacket MLT_REQ_2
call Increment
ldh a, [rP1]
call StoreResult
call Increment
ldh a, [rP1]
call StoreResult
SgbPacket MLT_REQ_0
SgbPacket MLT_REQ_3
call Increment
SgbPacket MLT_REQ_2
call Increment
ldh a, [rP1]
call StoreResult
call Increment
ldh a, [rP1]
call StoreResult
SgbPacket MLT_REQ_0
SgbPacket MLT_REQ_3
call Increment
call Increment
SgbPacket MLT_REQ_2
call Increment
ldh a, [rP1]
call StoreResult
ret
SendSgbPacket:
push bc
push de
ld d, 16
; Reset packet buffer
xor a
ldh [rP1], a
ld a, $30
ldh [rP1], a
.sgbByte:
ld a, [hl+] ; Load next byte
ld c, 8
ld b, a
.sgbByteLoop:
ld a, $10
bit 0, b
jr nz, .sgbBit
sla a
.sgbBit:
ldh [rP1], a
ld a, $30
ldh [rP1], a
srl b
dec c
jr nz, .sgbByteLoop
dec d
jr nz, .sgbByte
; Terminate packet
ld a, $20
ldh [rP1], a
ld a, $30
ldh [rP1], a
pop de
pop bc
SgbWait:
push de
ld de, 7000
.waitloop:
nop
nop
nop
dec de
ld a, e
or d
jr nz, .waitloop
pop de
ret
Increment:
ld a, $10
ldh [rP1], a
ld a, $30
ldh [rP1], a
ret
StoreResult::
ld [de], a
inc de
ret
MLT_REQ_0:
db $89, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
MLT_REQ_1:
db $89, $01, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
MLT_REQ_2:
db $89, $02, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
MLT_REQ_3:
db $89, $03, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
SGB_MODE
|
plugin/trino-base-jdbc/src/main/antlr4/io/trino/plugin/jdbc/expression/ConnectorExpressionPattern.g4 | RameshByndoor/trino | 1 | 2573 | /*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
grammar ConnectorExpressionPattern;
tokens {
DELIMITER
}
standaloneExpression
: expression EOF
;
standaloneType
: type EOF
;
expression
: call
| expressionCapture
;
call
: identifier '(' expression (',' expression)* ')' (':' type)?
;
expressionCapture
: identifier ':' type
;
type
: identifier
| identifier '(' typeParameter (',' typeParameter)* ')'
;
typeParameter
: number
| identifier
;
identifier
: IDENTIFIER
;
number
: INTEGER_VALUE
;
IDENTIFIER
: (LETTER | '_' | '$') (LETTER | DIGIT | '_' | '$')*
;
INTEGER_VALUE
: DIGIT+
;
fragment DIGIT
: [0-9]
;
fragment LETTER
: [A-Za-z]
;
WS
: [ \r\n\t]+ -> channel(HIDDEN)
;
// Catch-all for anything we can't recognize.
UNRECOGNIZED: .;
|
programs/oeis/173/A173035.asm | karttu/loda | 0 | 105175 | <reponame>karttu/loda
; A173035: Cat years in human years: a(0) = 0, a(1) = 15, a(2) = 24, a(n) = a(n-1) + 4 for n >= 3.
; 0,15,24,28,32,36,40,44,48,52,56,60,64,68,72,76,80,84,88,92,96,100,104,108,112,116,120,124,128,132,136,140,144,148,152,156,160,164,168,172,176,180,184,188,192,196,200,204,208,212,216,220,224,228,232,236,240
mov $2,$0
mov $3,$0
lpb $2,1
add $4,$0
mov $0,6
mov $1,$4
add $1,10
sub $2,1
trn $4,$1
lpe
lpb $3,1
add $1,4
sub $3,1
lpe
|
programs/oeis/212/A212331.asm | neoneye/loda | 22 | 82558 | <reponame>neoneye/loda<filename>programs/oeis/212/A212331.asm
; A212331: a(n) = 5*n*(n+5)/2.
; 0,15,35,60,90,125,165,210,260,315,375,440,510,585,665,750,840,935,1035,1140,1250,1365,1485,1610,1740,1875,2015,2160,2310,2465,2625,2790,2960,3135,3315,3500,3690,3885,4085,4290,4500,4715,4935,5160,5390,5625,5865,6110,6360,6615,6875,7140,7410,7685,7965,8250,8540,8835,9135,9440,9750,10065,10385,10710,11040,11375,11715,12060,12410,12765,13125,13490,13860,14235,14615,15000,15390,15785,16185,16590,17000,17415,17835,18260,18690,19125,19565,20010,20460,20915,21375,21840,22310,22785,23265,23750,24240,24735,25235,25740
mov $1,5
add $1,$0
mul $1,$0
div $1,2
mul $1,5
mov $0,$1
|
MPI/Lab-1/div_8_bit.asm | vishwas1101/Misc | 0 | 177109 | <filename>MPI/Lab-1/div_8_bit.asm
org 100h
MOV AL,19H
MOV BL,03H
DIV BL
ret
|
libsrc/games/sam/bit_open_di.asm | andydansby/z88dk-mk2 | 1 | 246325 | <reponame>andydansby/z88dk-mk2<gh_stars>1-10
; $Id: bit_open_di.asm,v 1.1 2003/02/04 09:10:18 stefano Exp $
;
; ZX Spectrum 1 bit sound functions
;
; Open sound and disable interrupts for exact timing
;
; <NAME> - 28/9/2001
;
XLIB bit_open_di
LIB bit_open
XREF snd_tick
.bit_open_di
di
jp bit_open
; ld a,(23624)
; rrca
; rrca
; rrca
; or 8
; ld (snd_tick),a
; ret
|
base/c64/clrscr.asm | zbyti/Mad-Pascal | 1 | 8426 |
; unit CRT: TextMode
.proc @ClrScr
jmp $e544
.endp
|
crt/bigshl.asm | malxau/minicrt | 27 | 94511 | ;
; BIGSHL.ASM
;
; Implementation for for signed and unsigned left shift of a 64 bit integer.
;
; Copyright (c) 2017 <NAME>
;
; Permission is hereby granted, free of charge, to any person obtaining a copy
; of this software and associated documentation files (the "Software"), to deal
; in the Software without restriction, including without limitation the rights
; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
; copies of the Software, and to permit persons to whom the Software is
; furnished to do so, subject to the following conditions:
;
; The above copyright notice and this permission notice shall be included in
; all copies or substantial portions of the Software.
;
; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
; THE SOFTWARE.
;
.386
.MODEL FLAT, C
.CODE
; LARGE_INTEGER [High EDX, Low EAX]
; _allshl(
; LARGE_INTEGER Value, [High EDX, Low EAX]
; UCHAR Shift [CL]
; );
public _allshl
_allshl proc
; If the shift is for more than 64 bits, all the data would be gone, so
; return zero. If the shift is for more than 32 bits, the low 32 bits
; of the result must be zero, and the high 32 bits contains the low 32
; bits of input after shifting. If the shift is less than 32 bits, then
; both components must be shifted with bits carried between the two.
cmp cl,64
jae allshl_no_shift
cmp cl,32
jae allshl_long_shift
jmp allshl_short_shift
allshl_short_shift:
shld edx, eax, cl
shl eax, cl
ret
allshl_long_shift:
sub cl, 32
shl eax, cl
mov edx, eax
xor eax, eax
ret
allshl_no_shift:
xor eax, eax
xor edx, edx
ret
_allshl endp
END
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.