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 |
|---|---|---|---|---|
programs/oeis/118/A118719.asm | karttu/loda | 0 | 6643 | ; A118719: Cubes for which the digital root is also a cube.
; 0,1,8,64,125,343,512,1000,1331,2197,2744,4096,4913,6859,8000,10648,12167,15625,17576,21952,24389,29791,32768,39304,42875,50653,54872,64000,68921,79507,85184,97336,103823,117649,125000,140608,148877,166375,175616,195112,205379,226981,238328,262144,274625,300763,314432,343000,357911,389017,405224,438976,456533,493039,512000,551368,571787,614125,636056,681472,704969,753571,778688,830584,857375,912673,941192,1000000,1030301,1092727,1124864,1191016,1225043,1295029,1331000,1404928,1442897,1520875,1560896,1643032,1685159,1771561,1815848,1906624,1953125,2048383,2097152,2197000,2248091,2352637,2406104,2515456,2571353,2685619,2744000,2863288,2924207,3048625,3112136,3241792,3307949,3442951,3511808,3652264,3723875,3869893,3944312,4096000,4173281,4330747,4410944,4574296,4657463,4826809,4913000,5088448,5177717,5359375,5451776,5639752,5735339,5929741,6028568,6229504,6331625,6539203,6644672,6859000,6967871,7189057,7301384,7529536,7645373,7880599,8000000,8242408,8365427,8615125,8741816,8998912,9129329,9393931,9528128,9800344,9938375,10218313,10360232,10648000,10793861,11089567,11239424,11543176,11697083,12008989,12167000,12487168,12649337,12977875,13144256,13481272,13651919,13997521,14172488,14526784,14706125,15069223,15252992,15625000,15813251,16194277,16387064,16777216,16974593,17373979,17576000,17984728,18191447,18609625,18821096,19248832,19465109,19902511,20123648,20570824,20796875,21253933,21484952,21952000,22188041,22665187,22906304,23393656,23639903,24137569,24389000,24897088,25153757,25672375,25934336,26463592,26730899,27270901,27543608,28094464,28372625,28934443,29218112,29791000,30080231,30664297,30959144,31554496,31855013,32461759,32768000,33386248,33698267,34328125,34645976,35287552,35611289,36264691,36594368,37259704,37595375,38272753,38614472,39304000,39651821,40353607,40707584,41421736,41781923,42508549,42875000,43614208,43986977,44738875,45118016,45882712,46268279,47045881,47437928,48228544,48627125,49430863,49836032,50653000,51064811,51895117
mov $3,$0
lpb $3,1
mul $0,3
mov $1,$0
sub $1,1
div $1,2
mul $3,$2
lpe
pow $1,3
|
data/pokemon/dex_entries/houndour.asm | AtmaBuster/pokeplat-gen2 | 6 | 22346 | db "DARK@" ; species name
db "Around dawn, its"
next "ominous howl"
next "echoes through the"
page "area to announce"
next "that this is its"
next "territory.@"
|
programs/oeis/136/A136755.asm | neoneye/loda | 22 | 87217 | <gh_stars>10-100
; A136755: a(n) = leading digit of n! in base 4.
; 1,1,2,1,1,1,2,1,2,1,3,2,1,1,1,1,1,1,1,1,2,2,3,1,2,3,1,2,3,1,3,1,3,1,3,1,1,2,1,3,2,1,3,2,1,1,3,2,1,1,1,3,2,2,2,1,1,1,1,1,1,1,1,3,3,1,1,1,1,1,1,1,1,1,2,2,3,3,1,1,1,2,2,3,1,1,2,2,1,1,1,2,1,1,2,3,1,1,2,1
seq $0,142 ; Factorial numbers: n! = 1*2*3*4*...*n (order of symmetric group S_n, number of permutations of n letters).
lpb $0
mov $1,$0
div $0,4
lpe
mov $0,$1
|
src/math/find_int_digits/src/find_int_digits.asm | nikAizuddin/lib80386 | 4 | 84615 | <reponame>nikAizuddin/lib80386
; 1 2 3 4 5 6 7
;234567890123456789012345678901234567890123456789012345678901234567890
;=====================================================================
;
; FUNCTION NAME: find_int_digits
; FUNCTION PURPOSE: <See doc/description file>
;
; AUTHOR: <NAME> <NAME>
; EMAIL: <EMAIL>
; DATE CREATED: 11-OCT-2014
;
; CONTRIBUTORS: ---
;
; LANGUAGE: x86 Assembly Language
; SYNTAX: Intel
; ASSEMBLER: NASM
; ARCHITECTURE: i386
; KERNEL: Linux 32-bit
; FORMAT: elf32
; INCLUDE FILES: ---
;
; VERSION: 0.1.21
; STATUS: Alpha
; BUGS: --- <See doc/bugs/index file>
;
; REVISION HISTORY: <See doc/revision_history/index file>
;
; MIT Licensed. See /LICENSE file.
;
;=====================================================================
global find_int_digits
section .text
find_int_digits:
;parameter 1 = integer_x:32bit
;parameter 2 = flag:32bit
;returns = the number of digits from integer_x (EAX)
.setup_stackframe:
sub esp, 4 ;reserve 4 bytes of stack
mov [esp], ebp ;save ebp to stack memory
mov ebp, esp ;save current stack ptr to ebp
.get_arguments:
add ebp, 8 ;+8 offsets ebp, to get arguments
mov eax, [ebp ] ;get integer_x
mov ebx, [ebp + 4] ;get flag
.set_localvariables:
sub esp, 16 ;reserve 16 bytes
mov [esp ], eax ;integer_x
mov [esp + 4], ebx ;flag
mov dword [esp + 8], 0 ;num_of_digits
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;
; Is integer_x positive or negative?
;
; If flag = 1, that means the integer_x is signed int.
; So, we have to check its sign value to determine whether
; it is a positive or negative number.
;
; If the integer_x is negative number, we have to find the
; value from its two's complement form.
;
; If the integer_x is positive number, no need to find the
; value from its two's complement form.
;
; Otherwise if the flag = 0, skip these instructions.
;
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;
; Check whether integer_x is signed or unsigned int.
;
; 001: if flag != 1, then
; goto .integer_x_is_unsigned;
;
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
mov eax, [esp + 4] ;eax = flag
cmp eax, 1
jne .integer_x_is_unsigned
.integer_x_is_signed:
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;
; If integer_x is signed, check its sign value
;
; 002: if (integer_x & 0x80000000) == 0, then
; goto .integer_x_is_positive;
;
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
mov eax, [esp] ;eax = integer_x
and eax, 0x80000000
cmp eax, 0
je .integer_x_is_positive
.integer_x_is_negative:
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;
; Looks like integer_x is negative, so invert all bits.
;
; 003: integer_x = !integer_x;
; 004: integer_x += 1;
;
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
mov eax, [esp] ;eax = integer_x
not eax
mov [esp], eax ;integer_x = !integer_x
mov eax, [esp] ;eax = integer_x
add eax, 1
mov [esp], eax ;integer_x = integer_x + 1
.integer_x_is_positive:
.integer_x_is_unsigned:
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;
; Find the number of digits of integer_x.
;
; Note: the conditional jump cannot jump more than 128 bytes.
;
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
mov eax, [esp] ;eax = integer_x
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;
; 005: if integer_x < 10, then
; goto .jumper_10;
;
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
cmp eax, 10
jb .jumper_10
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;
; 006: if integer_x < 100, then
; goto .jumper_100;
;
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
cmp eax, 100
jb .jumper_100
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;
; 007: if integer_x < 1000, then
; goto .jumper_1000;
;
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
cmp eax, 1000
jb .jumper_1000
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;
; 008: if integer_x < 10000, then
; goto .jumper_10000;
;
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
cmp eax, 10000
jb .jumper_10000
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;
; 009: if integer_x < 100000, then
; goto .jumper_100000;
;
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
cmp eax, 100000
jb .jumper_100000
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;
; 010: if integer_x < 1000000, then
; goto .jumper_1000000;
;
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
cmp eax, 1000000
jb .jumper_1000000
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;
; 011: if integer_x < 10000000, then
; goto .jumper_10000000;
;
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
cmp eax, 10000000
jb .jumper_10000000
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;
; 012: if integer_x < 100000000, then
; goto .jumper_100000000;
;
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
cmp eax, 100000000
jb .jumper_100000000
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;
; 013: if integer_x < 1000000000, then
; goto .jumper_1000000000;
;
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
cmp eax, 1000000000
jb .jumper_1000000000
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;
; 014: if integer_x >= 1000000000, then
; goto .more_equal_1000000000;
;
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
jmp .more_equal_1000000000
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;
; Jumpers, because cond. jumps can only jump up to 128 bytes.
;
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
.jumper_10:
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;
; 015: goto .less_than_10;
;
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
jmp .less_than_10
.jumper_100:
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;
; 016: goto .less_than_100;
;
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
jmp .less_than_100
.jumper_1000:
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;
; 017: goto .less_than_1000;
;
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
jmp .less_than_1000
.jumper_10000:
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;
; 018: goto .less_than_10000;
;
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
jmp .less_than_10000
.jumper_100000:
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;
; 019: goto .less_than_100000;
;
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
jmp .less_than_100000
.jumper_1000000:
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;
; 020: goto .less_than_1000000;
;
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
jmp .less_than_1000000
.jumper_10000000:
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;
; 021: goto .less_than_10000000;
;
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
jmp .less_than_10000000
.jumper_100000000:
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;
; 022: goto .less_than_100000000;
;
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
jmp .less_than_100000000
.jumper_1000000000:
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;
; 023: goto .less_than_1000000000;
;
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
jmp .less_than_1000000000
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;
; Assigns num_of_digits to a value based from jumpers
;
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
.less_than_10:
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;
; 024: num_of_digits = 1;
; 025: goto .endcondition;
;
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
mov dword [esp + 8], 1 ;num_of_digits = 1
jmp .endcondition
.less_than_100:
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;
; 026: num_of_digits = 2;
; 027: goto .endcondition;
;
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
mov dword [esp + 8], 2 ;num_of_digits = 2
jmp .endcondition
.less_than_1000:
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;
; 028: num_of_digits = 3;
; 029: goto .endcondition;
;
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
mov dword [esp + 8], 3 ;num_of_digits = 3
jmp .endcondition
.less_than_10000:
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;
; 030: num_of_digits = 4;
; 031: goto .endcondition;
;
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
mov dword [esp + 8], 4 ;num_of_digits = 4
jmp .endcondition
.less_than_100000:
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;
; 032: num_of_digits = 5
; 033: goto .endcondition;
;
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
mov dword [esp + 8], 5 ;num_of_digits = 5
jmp .endcondition
.less_than_1000000:
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;
; 034: num_of_digits = 6;
; 035: goto .endcondition;
;
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
mov dword [esp + 8], 6 ;num_of_digits = 6
jmp .endcondition
.less_than_10000000:
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;
; 036: num_of_digits = 7;
; 037: goto .endcondition;
;
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
mov dword [esp + 8], 7 ;num_of_digits = 7
jmp .endcondition
.less_than_100000000:
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;
; 038: num_of_digits = 8;
; 039: goto .endcondition;
;
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
mov dword [esp + 8], 8 ;num_of_digits = 8
jmp .endcondition
.less_than_1000000000:
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;
; 040: num_of_digits = 9;
; 041: goto .endcondition;
;
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
mov dword [esp + 8], 9 ;num_of_digits = 9
jmp .endcondition
.more_equal_1000000000:
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;
; 042: num_of_digits = 10;
; 043: goto .endcondition;
;
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
mov dword [esp + 8], 10 ;num_of_digits = 10
.endcondition:
.return:
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;
; 044: return EAX = num_of_digits;
;
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
mov eax, [esp + 8] ;eax = num_of_digits
.clean_stackframe:
sub ebp, 8 ;-8 bytes offsets to ebp
mov esp, ebp ;restore stack ptr to initial value
mov ebp, [esp] ;restore ebp to its initial value
add esp, 4 ;restore 4 bytes of stack
ret
|
source/amf/mof/xmi/amf-internals-xmi_uri_rewriter.adb | svn2github/matreshka | 24 | 20856 | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, <NAME> <<EMAIL>> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Ada.Exceptions;
with Ada.Text_IO;
with League.Application;
with Matreshka.XML_Catalogs.Entry_Files;
with Matreshka.XML_Catalogs.Loader;
with Matreshka.XML_Catalogs.Resolver;
package body AMF.Internals.XMI_URI_Rewriter is
use type League.Strings.Universal_String;
function "+"
(Item : Wide_Wide_String) return League.Strings.Universal_String
renames League.Strings.To_Universal_String;
Namespace_Rules : aliased
Matreshka.XML_Catalogs.Entry_Files.Catalog_Entry_File_List;
Document_Rules : aliased
Matreshka.XML_Catalogs.Entry_Files.Catalog_Entry_File_List;
-- Rules to rewrite URIs of namespaces and documents.
----------------
-- Initialize --
----------------
procedure Initialize is
begin
-- Load metamodels mapping.
begin
Namespace_Rules.Catalog_Entry_Files.Append
(Matreshka.XML_Catalogs.Loader.Load_By_File_Name
(League.Application.Environment.Value (+"AMF_DATA_DIR", +".")
& "/metamodels/mapping.xml",
Matreshka.XML_Catalogs.Entry_Files.System));
exception
when E : others =>
Ada.Text_IO.Put_Line
(Ada.Text_IO.Standard_Error,
Ada.Exceptions.Exception_Information (E));
end;
-- Load models mapping.
begin
Document_Rules.Catalog_Entry_Files.Append
(Matreshka.XML_Catalogs.Loader.Load_By_File_Name
(League.Application.Environment.Value (+"AMF_DATA_DIR", +".")
& "/models/mapping.xml",
Matreshka.XML_Catalogs.Entry_Files.System));
exception
when E : others =>
Ada.Text_IO.Put_Line
(Ada.Text_IO.Standard_Error,
Ada.Exceptions.Exception_Information (E));
end;
end Initialize;
-----------------------
-- Rewrite_Model_URI --
-----------------------
function Rewrite_Model_URI
(URI : League.Strings.Universal_String)
return League.Strings.Universal_String
is
Resolved : League.Strings.Universal_String;
Success : Boolean;
begin
Matreshka.XML_Catalogs.Resolver.Resolve_URI
(Document_Rules'Access, URI, Resolved, Success);
return Resolved;
end Rewrite_Model_URI;
---------------------------
-- Rewrite_Namespace_URI --
---------------------------
function Rewrite_Namespace_URI
(URI : League.Strings.Universal_String)
return League.Strings.Universal_String
is
Resolved : League.Strings.Universal_String;
Success : Boolean;
begin
Matreshka.XML_Catalogs.Resolver.Resolve_URI
(Namespace_Rules'Access, URI, Resolved, Success);
return Resolved;
end Rewrite_Namespace_URI;
end AMF.Internals.XMI_URI_Rewriter;
|
g-expect.ads | ytomino/gnat4drake | 0 | 2995 | pragma License (Unrestricted);
with GNAT.OS_Lib;
with GNAT.Regpat;
private with Ada.Processes;
private with Ada.Streams.Stream_IO;
package GNAT.Expect is
type Process_Descriptor is tagged limited private;
type Process_Descriptor_Access is access Process_Descriptor'Class;
-- Spawning a process
procedure Close (Descriptor : in out Process_Descriptor);
procedure Close (
Descriptor : in out Process_Descriptor;
Status : out Integer);
function Get_Command_Output (
Command : String;
Arguments : GNAT.OS_Lib.Argument_List;
Input : String;
Status : not null access Integer;
Err_To_Out : Boolean := False)
return String;
-- Sending data
procedure Send (
Descriptor : in out Process_Descriptor;
Str : String;
Add_LF : Boolean := True;
Empty_Buffer : Boolean := False);
-- Working on the output (single process, simple regexp)
type Expect_Match is new Integer;
Expect_Timeout : constant Expect_Match := -2;
procedure Expect (
Descriptor : in out Process_Descriptor;
Result : out Expect_Match;
Regexp : String;
Timeout : Integer := 10_000;
Full_Buffer : Boolean := False);
procedure Expect (
Descriptor : in out Process_Descriptor;
Result : out Expect_Match;
Regexp : GNAT.Regpat.Pattern_Matcher;
Timeout : Integer := 10_000;
Full_Buffer : Boolean := False);
-- Getting the output
procedure Flush (
Descriptor : in out Process_Descriptor;
Timeout : Integer := 0);
function Expect_Out (Descriptor : Process_Descriptor) return String;
-- Exceptions
Invalid_Process : exception;
Process_Died : exception;
private
type Process_Descriptor is tagged limited record
Item : Ada.Processes.Process;
Input_Writing : access Ada.Streams.Stream_IO.File_Type;
end record;
end GNAT.Expect;
|
src/io/darach/bitsyntax/BitSyntax.g4 | darach/bitsyntax-java | 2 | 1127 | /*
* A bit syntax representation inspired by Erlang's bit syntax suitable for
* describe binary packet structures suitable for compilation / code generation.
*
*/
grammar BitSyntax;
@header {
// Copyright (c) 2013 <NAME> < <EMAIL> at <EMAIL> dot <EMAIL> >.
//
// 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.
// package io.darach.bitsyntax;
}
// A binary is a sequence of element segments
binary
: BO segments? BC
;
// Segments are comma delimited
segments
: segment (CM segment)*
;
segment
: QS | (NM | ID) size? specifiers?
;
size
: CN NM | CN ID
;
specifiers
: FS specifier (DS specifier)*
;
specifier
: (LE | BE | ST | UT | IT | BT | FT | DB) | unit
;
unit
: 'unit' CN NM
;
LE: 'little' ;
BE: 'big';
ST: 'signed';
UT: 'unsigned';
IT: 'integer';
BT: 'binary';
FT: 'float';
DB: 'double';
QS: '"' ( ES | ~('\\'|'"') )* '"';
fragment ES: '\\' ('b'|'t'|'n'|'f'|'r'|'\"'|'\''|'\\') | UES | OES;
fragment UES: '\\' 'u' HX HX HX HX;
fragment OES: '\\' ('0'..'3') ('0'..'7') ('0'..'7') | '\\' ('0'..'7') ('0'..'7') | '\\' ('0'..'7');
//NM: '0' | '1'..'9' ('0'..'9')*;
NM: IntegerLiteral;
ID : Identifier;
fragment
HX: ('0'..'9' | 'a'..'f' | 'A'..'F');
BO : '<<' ;
BC : '>>' ;
DS : '-' ;
FS : '/' ;
CM : ',' ;
CN : ':' ;
WS : [ \n\t\r]+ -> skip;
//
// The following productions copied from the Java.g4 grammar and are (C) 2012 <NAME>
//
Identifier
: Letter (Letter|JavaIDDigit)*
;
fragment
Letter
: '\u0024' | // $
'\u0041'..'\u005a' | // A-Z
'\u005f' | // _
'\u0061'..'\u007a' | // a-z
'\u00c0'..'\u00d6' | // Latin Capital Letter A with grave - Latin Capital letter O with diaeresis
'\u00d8'..'\u00f6' | // Latin Capital letter O with stroke - Latin Small Letter O with diaeresis
'\u00f8'..'\u00ff' | // Latin Small Letter O with stroke - Latin Small Letter Y with diaeresis
'\u0100'..'\u1fff' | // Latin Capital Letter A with macron - Latin Small Letter O with stroke and acute
'\u3040'..'\u318f' | // Hiragana
'\u3300'..'\u337f' | // CJK compatibility
'\u3400'..'\u3d2d' | // CJK compatibility
'\u4e00'..'\u9fff' | // CJK compatibility
'\uf900'..'\ufaff' // CJK compatibility
;
fragment
JavaIDDigit
: '\u0030'..'\u0039' | // 0-9
'\u0660'..'\u0669' | // Arabic-Indic Digit 0-9
'\u06f0'..'\u06f9' | // Extended Arabic-Indic Digit 0-9
'\u0966'..'\u096f' | // Devanagari 0-9
'\u09e6'..'\u09ef' | // Bengali 0-9
'\u0a66'..'\u0a6f' | // Gurmukhi 0-9
'\u0ae6'..'\u0aef' | // Gujarati 0-9
'\u0b66'..'\u0b6f' | // Oriya 0-9
'\u0be7'..'\u0bef' | // Tami 0-9
'\u0c66'..'\u0c6f' | // Telugu 0-9
'\u0ce6'..'\u0cef' | // Kannada 0-9
'\u0d66'..'\u0d6f' | // Malayala 0-9
'\u0e50'..'\u0e59' | // Thai 0-9
'\u0ed0'..'\u0ed9' | // Lao 0-9
'\u1040'..'\u1049' // Myanmar 0-9?
;
NumericLiteral
: IntegerLiteral
| FloatingPointLiteral
;
TextLiteral
: CharacterLiteral
| StringLiteral
;
// | BooleanLiteral
// | 'null'
// ;
// §3.10.1 Integer Literals
IntegerLiteral
: DecimalIntegerLiteral
| HexIntegerLiteral
| OctalIntegerLiteral
| BinaryIntegerLiteral
;
fragment
DecimalIntegerLiteral
: DecimalNumeral IntegerTypeSuffix?
;
fragment
HexIntegerLiteral
: HexNumeral IntegerTypeSuffix?
;
fragment
OctalIntegerLiteral
: OctalNumeral IntegerTypeSuffix?
;
fragment
BinaryIntegerLiteral
: BinaryNumeral IntegerTypeSuffix?
;
fragment
IntegerTypeSuffix
: [lL]
;
fragment
DecimalNumeral
: '0'
| NonZeroDigit (Digits? | Underscores Digits)
;
fragment
Digits
: Digit (DigitOrUnderscore* Digit)?
;
fragment
Digit
: '0'
| NonZeroDigit
;
fragment
NonZeroDigit
: [1-9]
;
fragment
DigitOrUnderscore
: Digit
| '_'
;
fragment
Underscores
: '_'+
;
fragment
HexNumeral
: '0' [xX] HexDigits
;
fragment
HexDigits
: HexDigit (HexDigitOrUnderscore* HexDigit)?
;
fragment
HexDigit
: [0-9a-fA-F]
;
fragment
HexDigitOrUnderscore
: HexDigit
| '_'
;
fragment
OctalNumeral
: '0' Underscores? OctalDigits
;
fragment
OctalDigits
: OctalDigit (OctalDigitOrUnderscore* OctalDigit)?
;
fragment
OctalDigit
: [0-7]
;
fragment
OctalDigitOrUnderscore
: OctalDigit
| '_'
;
fragment
BinaryNumeral
: '0' [bB] BinaryDigits
;
fragment
BinaryDigits
: BinaryDigit (BinaryDigitOrUnderscore* BinaryDigit)?
;
fragment
BinaryDigit
: [01]
;
fragment
BinaryDigitOrUnderscore
: BinaryDigit
| '_'
;
// §3.10.2 Floating-Point Literals
FloatingPointLiteral
: DecimalFloatingPointLiteral
| HexadecimalFloatingPointLiteral
;
fragment
DecimalFloatingPointLiteral
: Digits '.' Digits? ExponentPart? FloatTypeSuffix?
| '.' Digits ExponentPart? FloatTypeSuffix?
| Digits ExponentPart FloatTypeSuffix?
| Digits FloatTypeSuffix
;
fragment
ExponentPart
: ExponentIndicator SignedInteger
;
fragment
ExponentIndicator
: [eE]
;
fragment
SignedInteger
: Sign? Digits
;
fragment
Sign
: [+-]
;
fragment
FloatTypeSuffix
: [fFdD]
;
fragment
HexadecimalFloatingPointLiteral
: HexSignificand BinaryExponent FloatTypeSuffix?
;
fragment
HexSignificand
: HexNumeral '.'?
| '0' [xX] HexDigits? '.' HexDigits
;
fragment
BinaryExponent
: BinaryExponentIndicator SignedInteger
;
fragment
BinaryExponentIndicator
: [pP]
;
// §3.10.3 Boolean Literals
BooleanLiteral
: 'true'
| 'false'
;
// §3.10.4 Character Literals
CharacterLiteral
: '\'' SingleCharacter '\''
| '\'' EscapeSequence '\''
;
fragment
SingleCharacter
: ~['\\]
;
// §3.10.5 String Literals
StringLiteral
: '"' StringCharacters? '"'
;
fragment
StringCharacters
: StringCharacter+
;
fragment
StringCharacter
: ~["\\]
| EscapeSequence
;
// §3.10.6 Escape Sequences for Character and String Literals
fragment
EscapeSequence
: '\\' [btnfr"'\\]
| OctalEscape
| UnicodeEscape
;
fragment
OctalEscape
: '\\' OctalDigit
| '\\' OctalDigit OctalDigit
| '\\' ZeroToThree OctalDigit OctalDigit
;
fragment
UnicodeEscape
: '\\' 'u' HexDigit HexDigit HexDigit HexDigit
;
fragment
ZeroToThree
: [0-3]
;
// §3.10.7 The Null Literal
NullLiteral
: 'null'
;
|
oeis/028/A028182.asm | neoneye/loda-programs | 11 | 87182 | ; A028182: Expansion of 1/((1-5x)(1-7x)(1-8x)(1-11x)).
; Submitted by <NAME>
; 1,31,610,9750,138411,1822821,22826140,275975500,3254034421,37677164811,430475351670,4870239751650,54700558488031,611065572906001,6798955260233200,75422919700042200,834843345187547241
mov $1,1
mov $2,$0
mov $3,$0
lpb $2
mov $0,$3
sub $2,1
sub $0,$2
seq $0,20968 ; Expansion of 1/((1-7*x)*(1-8*x)*(1-11*x)).
sub $0,$1
mul $1,6
add $1,$0
lpe
mov $0,$1
|
Mockingbird/Forest/Combination/Vec/Properties.agda | splintah/combinatory-logic | 1 | 10722 | <reponame>splintah/combinatory-logic
open import Mockingbird.Forest using (Forest)
module Mockingbird.Forest.Combination.Vec.Properties {b ℓ} (forest : Forest {b} {ℓ}) where
open import Data.Vec as Vec using (Vec; []; _∷_; _++_)
import Data.Vec.Relation.Unary.Any as Any
open import Data.Vec.Relation.Unary.Any.Properties as Anyₚ using (++⁺ˡ; ++⁺ʳ)
open import Function using (_$_; flip)
open import Relation.Unary using (Pred; _∈_; _⊆_; ∅)
open Forest forest
open import Mockingbird.Forest.Combination.Vec.Base forest
import Mockingbird.Forest.Combination.Properties forest as Combinationₚ
subst : ∀ {n x y} {bs : Vec Bird n} → x ≈ y → x ∈ ⟨ bs ⟩ → y ∈ ⟨ bs ⟩
subst = Combinationₚ.subst λ x≈y → Any.map (trans (sym x≈y))
subst′ : ∀ {n x y} {bs : Vec Bird n} → y ≈ x → x ∈ ⟨ bs ⟩ → y ∈ ⟨ bs ⟩
subst′ y≈x = subst (sym y≈x)
⟨[]⟩ : ⟨ [] ⟩ ⊆ ∅
⟨[]⟩ (X ⟨∙⟩ Y ∣ xy≈z) = ⟨[]⟩ X
weaken-∷ : ∀ {n x y} {bs : Vec Bird n} → x ∈ ⟨ bs ⟩ → x ∈ ⟨ y ∷ bs ⟩
weaken-∷ = Combinationₚ.weaken there
-- TODO: maybe call this ++⁺ˡ.
weaken-++ˡ : ∀ {m n x} {bs : Vec Bird m} {bs′ : Vec Bird n} → x ∈ ⟨ bs ⟩ → x ∈ ⟨ bs ++ bs′ ⟩
weaken-++ˡ {bs = bs} {bs′} [ x∈bs ] = [ ++⁺ˡ x∈bs ]
weaken-++ˡ {bs = bs} {bs′} (x∈⟨bs⟩ ⟨∙⟩ y∈⟨bs⟩ ∣ xy≈z) = weaken-++ˡ x∈⟨bs⟩ ⟨∙⟩ weaken-++ˡ y∈⟨bs⟩ ∣ xy≈z
-- TODO: maybe call this ++⁺ʳ.
weaken-++ʳ : ∀ {m n x} (bs : Vec Bird m) {bs′ : Vec Bird n} → x ∈ ⟨ bs′ ⟩ → x ∈ ⟨ bs ++ bs′ ⟩
weaken-++ʳ bs {bs′} [ x∈bs′ ] = [ ++⁺ʳ bs x∈bs′ ]
weaken-++ʳ bs {bs′} (x∈⟨bs′⟩ ⟨∙⟩ y∈⟨bs′⟩ ∣ xy≈z) = weaken-++ʳ bs x∈⟨bs′⟩ ⟨∙⟩ weaken-++ʳ bs y∈⟨bs′⟩ ∣ xy≈z
++-comm : ∀ {m n x} (bs : Vec Bird m) (bs′ : Vec Bird n) → x ∈ ⟨ bs ++ bs′ ⟩ → x ∈ ⟨ bs′ ++ bs ⟩
++-comm bs bs′ [ x∈bs++bs′ ] = [ Anyₚ.++-comm bs bs′ x∈bs++bs′ ]
++-comm bs bs′ (x∈⟨bs++bs′⟩ ⟨∙⟩ y∈⟨bs++bs′⟩ ∣ xy≈z) = ++-comm bs bs′ x∈⟨bs++bs′⟩ ⟨∙⟩ ++-comm bs bs′ y∈⟨bs++bs′⟩ ∣ xy≈z
open import Mockingbird.Forest.Birds forest
open import Mockingbird.Forest.Extensionality forest
module _ ⦃ _ : Extensional ⦄ ⦃ _ : HasCardinal ⦄ ⦃ _ : HasIdentity ⦄
⦃ _ : HasThrush ⦄ ⦃ _ : HasKestrel ⦄ ⦃ _ : HasStarling ⦄ where
private
CI≈T : C ∙ I ≈ T
CI≈T = ext $ λ x → ext $ λ y → begin
C ∙ I ∙ x ∙ y ≈⟨ isCardinal I x y ⟩
I ∙ y ∙ x ≈⟨ congʳ $ isIdentity y ⟩
y ∙ x ≈˘⟨ isThrush x y ⟩
T ∙ x ∙ y ∎
_ : T ∈ ⟨ C ∷ I ∷ [] ⟩
_ = subst CI≈T $ [# 0 ] ⟨∙⟩ [# 1 ]
_ : I ∈ ⟨ S ∷ K ∷ [] ⟩
_ = flip subst ([# 0 ] ⟨∙⟩ [# 1 ] ⟨∙⟩ [# 1 ]) $ ext $ λ x → begin
S ∙ K ∙ K ∙ x ≈⟨ isStarling K K x ⟩
K ∙ x ∙ (K ∙ x) ≈⟨ isKestrel x (K ∙ x) ⟩
x ≈˘⟨ isIdentity x ⟩
I ∙ x ∎
|
libsrc/_DEVELOPMENT/env/esxdos/z80/asm_env_getenv.asm | jpoikela/z88dk | 640 | 85025 | ; char *env_getenv(unsigned char handle,const char *name,char *val,unsigned int valsz,void *buf,unsigned int bufsz)
INCLUDE "config_private.inc"
SECTION code_env
PUBLIC asm_env_getenv
EXTERN error_zc, error_znc
EXTERN l_jpix, l_ret, l_minu_bc_hl
EXTERN __env_name_sm, __env_value_sm
EXTERN __env_qualify_name
asm_env_getenv:
; Search for "name = value" pair in file and return value in val if found.
; Must hold exclusive access to environment file while searching it.
;
; enter : hl = char *name
; de = char *val
; bc = valsz not including space for terminating 0 > 0
;
; e'= file handle
; hl'= char *buf
; bc'= bufsz > 0
;
; exit : success if valsz == 0
;
; hl = length of value string (val not written)
; carry reset
;
; success if valsz != 0
;
; hl = char *val, zero terminated value written into buffer
; carry reset
;
; fail
;
; hl = 0
; carry set
;
; uses : af, bc, de, hl, bc', de', hl', ix
push de ; save val
push bc ; save valsz
; qualify name
push hl
call __env_qualify_name
pop de
jp nc, error_zc - 2 ; if name string is invalid
ld bc,0 ; file position
ld ix,__env_name_sm ; enter name search state machine
exx
buf_loop:
; e = file handle
; hl = buf
; bc = bufsz
; bc'= file position
; de'= char *name
; hl', ix = state
; stack = val, valsz
; load buffer
push de ; save handle
push bc ; save bufsz
push hl ; save buf
ld a,e
IF __SDCC_IY
push hl
pop iy
ELSE
push ix
push hl
pop ix
ENDIF
rst __ESX_RST_SYS
defb __ESX_F_READ
IF __SDCC_IY
ELSE
pop ix
ENDIF
pop hl
; hl = buf
; bc = actual bytes read
; bc'= file position
; de'= char *name
; hl', ix = state
; stack = val, valsz, handle, bufsz
jp c, error_zc - 4 ; if read error
ld a,b
or c
jp z, error_zc - 4 ; if eof reached
push hl
; name search loop
name_loop:
ld a,(hl)
exx
; hl'= buf
; bc'= actual bytes read
; a = current char
; bc = file position
; de = char *name
; hl,ix = state
; stack = val, valsz, handle, bufsz, buf
call l_jpix ; name match
jr c, name_matched
inc bc ; file position++
exx
cpi ; hl++, bc--
jp pe, name_loop
; bc'= file position
; de'= char *name
; hl', ix = state
; stack = val, valsz, handle, bufsz, buf
pop hl
pop bc
pop de
jr buf_loop
name_matched:
; hl'= buf
; bc'= actual bytes read
; a = current char
; bc = file position
; stack = val, valsz, handle, bufsz, buf
ld ix,__env_value_sm ; enter value state machine
ld e,c
ld d,b ; de = position of value
exx
value_loop:
exx
call l_jpix
jr nc, value_found
; hl'= buf
; bc'= actual bytes read
; bc = file position
; de = position of value
; hl, ix = state
; stack = val, valsz, handle, bufsz, buf
inc bc ; file position++
exx
cpi ; hl++, bc--
ld a,(hl) ; current char
jp pe, value_loop
; bc'= file position
; de'= position of value
; hl', ix = state
; stack = val, valsz, handle, bufsz, buf
buf_load:
pop hl ; hl = buf
pop bc ; bc = bufsz
pop de ; e = handle
push de
push bc
push hl
ld a,e
IF __SDCC_IY
push hl
pop iy
ELSE
push ix
push hl
pop ix
ENDIF
rst __ESX_RST_SYS
defb __ESX_F_READ
IF __SDCC_IY
ELSE
pop ix
ENDIF
pop hl
; hl = buf
; bc = actual bytes read
; bc'= file position
; de'= position of value
; hl', ix = state
; stack = val, valsz, handle, bufsz
jp c, error_zc - 4 ; if read error
push hl
ld a,b
or c
jr z, value_found_exx ; if eof reached
ld a,(hl) ; a = current char
jr value_loop
value_found_exx:
exx
value_found:
; carry reset
sbc hl,de
; de = position of value
; hl = length of value
; stack = val, valsz, handle, bufsz, buf
pop bc
pop bc
pop bc
; c = handle
; de = position of value
; hl = length of value
; stack = val, valsz
ex (sp),hl
ld a,h
or l
jp z, l_ret - 2 ; if valsz == 0 return length of value string
push hl
push bc
; c = handle
; de = position of value
; stack = val, length of value, valsz, handle
; seek to start of value string
ld a,c
ld bc,0
ld l,__esx_seek_set
IF __SDCC_IY
push hl
pop iy
ELSE
push hl
pop ix
ENDIF
rst __ESX_RST_SYS
defb __ESX_F_SEEK
pop de
pop bc
pop hl
; e = handle
; bc = valsz
; hl = length of value
; stack = val
jp c, error_zc - 1 ; if can't seek
; write value string to supplied buffer
call l_minu_bc_hl
ld c,l
ld b,h ; bc = min(valsz, length of value)
; e = handle
; bc = length of value
; stack = val
pop hl ; hl = val
push hl ; save val
ld a,b
or c
jr z, zero_terminate ; if length of value string is zero
push bc ; save size
ld a,e
IF __SDCC_IY
push hl
pop iy
ELSE
push hl
pop ix
ENDIF
rst __ESX_RST_SYS
defb __ESX_F_READ
jp c, error_zc - 2 ; if read error
ex (sp),hl ; hl = size
sbc hl,bc
jp nz, error_zc - 2 ; if complete string not read
pop hl
zero_terminate:
xor a
ld (hl),a
pop hl ; hl = val
ret
|
Transynther/x86/_processed/AVXALIGN/_zr_/i3-7100_9_0x84_notsx.log_21829_708.asm | ljhsiun2/medusa | 9 | 7995 | <gh_stars>1-10
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r13
push %r15
push %r8
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_normal_ht+0x3ec, %r11
nop
nop
nop
and $17401, %r10
mov $0x6162636465666768, %rdi
movq %rdi, %xmm5
vmovups %ymm5, (%r11)
nop
nop
nop
nop
nop
add $15247, %rbx
lea addresses_WT_ht+0x1dedc, %r10
nop
nop
add %r13, %r13
mov $0x6162636465666768, %r15
movq %r15, %xmm4
vmovups %ymm4, (%r10)
nop
nop
nop
nop
nop
inc %rdi
lea addresses_normal_ht+0x1a735, %rbx
nop
nop
nop
add %r8, %r8
movl $0x61626364, (%rbx)
nop
nop
nop
and %r10, %r10
lea addresses_normal_ht+0xa274, %rsi
lea addresses_UC_ht+0x15c1c, %rdi
clflush (%rsi)
nop
nop
nop
and $44295, %r13
mov $1, %rcx
rep movsw
nop
nop
nop
nop
nop
add %r11, %r11
lea addresses_WT_ht+0x51bc, %r8
nop
nop
nop
xor %r15, %r15
mov (%r8), %r13
nop
nop
nop
nop
add $10537, %rbx
lea addresses_WT_ht+0x1a214, %rsi
lea addresses_A_ht+0xc5c, %rdi
nop
nop
nop
cmp $13786, %r11
mov $102, %rcx
rep movsw
nop
nop
nop
sub $7831, %rsi
lea addresses_WC_ht+0x1787c, %r13
nop
nop
nop
nop
nop
sub %r11, %r11
mov $0x6162636465666768, %r10
movq %r10, %xmm2
movups %xmm2, (%r13)
nop
nop
nop
nop
nop
inc %rsi
lea addresses_normal_ht+0x56dc, %rsi
lea addresses_D_ht+0x4886, %rdi
nop
nop
nop
nop
nop
xor $24271, %r11
mov $40, %rcx
rep movsq
nop
nop
nop
nop
nop
cmp %rbx, %rbx
lea addresses_WC_ht+0x1c3dc, %rdi
nop
nop
nop
nop
sub $14685, %rcx
mov $0x6162636465666768, %r8
movq %r8, %xmm3
movups %xmm3, (%rdi)
nop
nop
nop
nop
xor $29612, %r13
lea addresses_WT_ht+0x198bc, %rsi
lea addresses_WT_ht+0xd61d, %rdi
nop
nop
nop
nop
nop
and $60319, %r10
mov $17, %rcx
rep movsl
nop
and $25722, %rbx
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %r8
pop %r15
pop %r13
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r12
push %r14
push %r9
push %rbp
push %rcx
push %rdi
// Store
mov $0x2dc, %rdi
cmp %r12, %r12
movb $0x51, (%rdi)
nop
nop
cmp $18716, %r12
// Store
lea addresses_RW+0xe9dc, %rbp
nop
nop
dec %r14
mov $0x5152535455565758, %r12
movq %r12, %xmm6
vmovups %ymm6, (%rbp)
nop
sub $37080, %rbp
// Faulty Load
lea addresses_US+0x6dc, %r14
clflush (%r14)
and $57007, %r9
vmovntdqa (%r14), %ymm5
vextracti128 $0, %ymm5, %xmm5
vpextrq $0, %xmm5, %rcx
lea oracles, %r12
and $0xff, %rcx
shlq $12, %rcx
mov (%r12,%rcx,1), %rcx
pop %rdi
pop %rcx
pop %rbp
pop %r9
pop %r14
pop %r12
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_US', 'same': True, 'size': 2, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_P', 'same': False, 'size': 1, 'congruent': 9, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_RW', 'same': False, 'size': 32, 'congruent': 7, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
[Faulty Load]
{'src': {'type': 'addresses_US', 'same': True, 'size': 32, 'congruent': 0, 'NT': True, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'dst': {'type': 'addresses_normal_ht', 'same': False, 'size': 32, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_WT_ht', 'same': False, 'size': 32, 'congruent': 9, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_normal_ht', 'same': False, 'size': 4, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_normal_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 6, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_WT_ht', 'same': False, 'size': 8, 'congruent': 5, 'NT': True, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WT_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 7, 'same': False}, 'OP': 'REPM'}
{'dst': {'type': 'addresses_WC_ht', 'same': False, 'size': 16, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_normal_ht', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 1, 'same': False}, 'OP': 'REPM'}
{'dst': {'type': 'addresses_WC_ht', 'same': False, 'size': 16, 'congruent': 6, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_WT_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 0, 'same': False}, 'OP': 'REPM'}
{'00': 21829}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
comments.applescript | looking-for-a-job/applescript-examples | 1 | 4126 | <reponame>looking-for-a-job/applescript-examples<filename>comments.applescript
#!/usr/bin/osascript
-- comment
--> output
(*
multiline comment
*)
|
private/ntos/ke/i386/newsysbg.asm | King0987654/windows2000 | 11 | 6476 | title "System Startup"
;++
;
; Copyright (c) 1989 Microsoft Corporation
;
; Module Name:
;
; systembg.asm
;
; Abstract:
;
; This module implements the code necessary to initially startup the
; NT system.
;
; Author:
;
; <NAME> (shielint) 07-Mar-1990
;
; Environment:
;
; Kernel mode only.
;
; Revision History:
;
; <NAME> (jvert) 25-Jun-1991
; Major overhaul in order to move into new osloader architecture
; Removed old debugger hacks
;
;--
.386p
.xlist
include i386\cpu.inc
include ks386.inc
include i386\kimacro.inc
include mac386.inc
include callconv.inc
include fastsys.inc
FPOFRAME macro a, b
.FPO ( a, b, 0, 0, 0, 0 )
endm
.list
option segment:flat
extrn @ExfInterlockedPopEntrySList@8:DWORD
extrn @ExfInterlockedPushEntrySList@12:DWORD
extrn @ExfInterlockedFlushSList@4:DWORD
extrn @ExInterlockedCompareExchange64@16:DWORD
extrn @ExInterlockedPopEntrySList@8:DWORD
extrn @ExInterlockedPushEntrySList@12:DWORD
extrn @ExInterlockedFlushSList@4:DWORD
extrn @ExpInterlockedCompareExchange64@16:DWORD
extrn _ExInterlockedAddLargeInteger@16:DWORD
extrn _ExInterlockedExchangeAddLargeInteger@16:DWORD
extrn _KiBootFeatureBits:DWORD
EXTRNP _KdInitSystem,2
EXTRNP KfRaiseIrql,1,IMPORT,FASTCALL
EXTRNP KfLowerIrql,1,IMPORT,FASTCALL
EXTRNP _KiInitializeKernel,6
extrn SwapContext:PROC
EXTRNP GetMachineBootPointers
EXTRNP _KiInitializePcr,7
EXTRNP _KiSwapIDT
EXTRNP _KiInitializeTSS,1
EXTRNP _KiInitializeTSS2,2
EXTRNP _KiInitializeGdtEntry,6
extrn _KiTrap08:PROC
extrn _KiTrap02:PROC
EXTRNP _HalDisplayString,1,IMPORT
EXTRNP _KiInitializeAbios,1
EXTRNP _KiInitializeMachineType
EXTRNP _KeGetCurrentIrql,0,IMPORT
EXTRNP _KeBugCheck, 1
EXTRNP _KeBugCheckEx, 5
EXTRNP _HalInitializeProcessor,2,IMPORT
EXTRNP HalClearSoftwareInterrupt,1,IMPORT,FASTCALL
if NT_INST
EXTRNP _KiAcquireSpinLock, 1
EXTRNP _KiReleaseSpinLock, 1
endif
EXTRNP KiTryToAcquireQueuedSpinLock,1,,FASTCALL
extrn _KiFreezeExecutionLock:DWORD
extrn _KiDispatcherLock:DWORD
extrn _IDT:BYTE
extrn _IDTLEN:BYTE ; NOTE - really an ABS, linker problems
extrn _KeNumberProcessors:BYTE
extrn _KeActiveProcessors:DWORD
extrn _KiIdleSummary:DWORD
extrn _KiProcessorBlock:DWORD
extrn _KiFindFirstSetRight:BYTE
EXTRNP _KdPollBreakIn,0
extrn _KeLoaderBlock:DWORD
extrn _KeI386NpxPresent:DWORD
extrn _KeI386CpuType:DWORD
extrn _KeI386CpuStep:DWORD
extrn _KeTickCount:DWORD
extrn _KeFeatureBits:DWORD
ifndef NT_UP
extrn _KiBarrierWait:DWORD
endif
if DBG
extrn _KdDebuggerEnabled:BYTE
EXTRNP _DbgBreakPoint,0
extrn _DbgPrint:near
extrn _MsgDpcTrashedEsp:BYTE
endif
;
; Constants for various variables
;
_DATA SEGMENT PARA PUBLIC 'DATA'
;
; Idle thread process object
;
align 4
public _KiIdleProcess
_KiIdleProcess label byte
db ExtendedProcessObjectLength dup(?) ; sizeof (EPROCESS)
;
; Statically allocated structures for Bootstrap processor
; idle thread object for P0
; idle thread stack for P0
;
align 4
public P0BootThread
P0BootThread label byte
db ExtendedThreadObjectLength dup(?) ; sizeof (ETHREAD)
align 16
public _KiDoubleFaultStack
db DOUBLE_FAULT_STACK_SIZE dup (?)
_KiDoubleFaultStack label byte
public P0BootStack
db KERNEL_STACK_SIZE dup (?)
P0BootStack label byte
;
; Double fault task stack
;
MINIMUM_TSS_SIZE EQU TssIoMaps
align 16
public _KiDoubleFaultTSS
_KiDoubleFaultTSS label byte
db MINIMUM_TSS_SIZE dup(0)
public _KiNMITSS
_KiNMITSS label byte
db MINIMUM_TSS_SIZE dup(0)
;
; Abios specific definitions
;
public _KiCommonDataArea, _KiAbiosPresent
_KiCommonDataArea dd 0
_KiAbiosPresent dd 0
_DATA ends
page ,132
subttl "System Startup"
INIT SEGMENT DWORD PUBLIC 'CODE'
ASSUME DS:FLAT, ES:FLAT, SS:NOTHING, FS:NOTHING, GS:NOTHING
;++
;
; For processor 0, Routine Description:
;
; This routine is called when the NT system begins execution.
; Its function is to initialize system hardware state, call the
; kernel initialization routine, and then fall into code that
; represents the idle thread for all processors.
;
; Entry state created by the boot loader:
; A short-form IDT (0-1f) exists and is active.
; A complete GDT is set up and loaded.
; A complete TSS is set up and loaded.
; Page map is set up with minimal start pages loaded
; The lower 4Mb of virtual memory are directly mapped into
; physical memory.
;
; The system code (ntoskrnl.exe) is mapped into virtual memory
; as described by its memory descriptor.
; DS=ES=SS = flat
; ESP->a usable boot stack
; Interrupts OFF
;
; For processor > 0, Routine Description:
;
; This routine is called when each additional processor begins execution.
; The entry state for the processor is:
; IDT, GDT, TSS, stack, selectors, PCR = all valid
; Page directory is set to the current running directory
; LoaderBlock - parameters for this processor
;
; Arguments:
;
; PLOADER_PARAMETER_BLOCK LoaderBlock
;
; Return Value:
;
; None.
;
;--
;
; Arguments for KiSystemStartupPx
;
KissLoaderBlock equ [ebp+8]
;
; Local variables
;
KissGdt equ [ebp-4]
KissPcr equ [ebp-8]
KissTss equ [ebp-12]
KissIdt equ [ebp-16]
KissIrql equ [ebp-20]
KissPbNumber equ [ebp-24]
KissIdleStack equ [ebp-28]
KissIdleThread equ [ebp-32]
cPublicProc _KiSystemStartup ,1
push ebp
mov ebp, esp
sub esp, 32 ; Reserve space for local variables
mov ebx, dword ptr KissLoaderBlock
mov _KeLoaderBlock, ebx ; Get loader block param
movzx ecx, _KeNumberProcessors ; get number of processors
mov KissPbNumber, ecx
or ecx, ecx ; Is the the boot processor?
jnz @f ; no
; P0 uses static memory for these
mov dword ptr [ebx].LpbThread, offset P0BootThread
mov dword ptr [ebx].LpbKernelStack, offset P0BootStack
push KGDT_R0_PCR ; P0 needs FS set
pop fs
; Save processornumber in Prcb
mov byte ptr fs:PcPrcbData+PbNumber, cl
@@:
mov eax, dword ptr [ebx].LpbThread
mov dword ptr KissIdleThread, eax
mov eax, dword ptr [ebx].LpbKernelStack
mov dword ptr KissIdleStack, eax
stdCall _KiInitializeMachineType
cmp byte ptr KissPbNumber, 0 ; if not p0, then
jne kiss_notp0 ; skip a bunch
;
;+++++++++++++++++++++++
;
; Initialize the PCR
;
stdCall GetMachineBootPointers
;
; Upon return:
; (edi) -> gdt
; (esi) -> pcr
; (edx) -> tss
; (eax) -> idt
; Now, save them in our local variables
;
mov KissGdt, edi
mov KissPcr, esi
mov KissTss, edx
mov KissIdt, eax
;
; edit TSS to be 32bits. loader gives us a tss, but it's 16bits!
;
lea ecx,[edi]+KGDT_TSS ; (ecx) -> TSS descriptor
mov byte ptr [ecx+5],089h ; 32bit, dpl=0, present, TSS32, not busy
; KiInitializeTSS2(
; Linear address of TSS
; Linear address of TSS descriptor
; );
stdCall _KiInitializeTSS2, <KissTss, ecx>
stdCall _KiInitializeTSS, <KissTss>
mov cx,KGDT_TSS
ltr cx
;
; set up 32bit double fault task gate to catch double faults.
;
mov eax,KissIdt
lea ecx,[eax]+40h ; Descriptor 8
mov byte ptr [ecx+5],085h ; dpl=0, present, taskgate
mov word ptr [ecx+2],KGDT_DF_TSS
lea ecx,[edi]+KGDT_DF_TSS
mov byte ptr [ecx+5],089h ; 32bit, dpl=0, present, TSS32, not busy
mov edx,offset FLAT:_KiDoubleFaultTSS
mov eax,edx
mov [ecx+KgdtBaseLow],ax
shr eax,16
mov [ecx+KgdtBaseHi],ah
mov [ecx+KgdtBaseMid],al
mov eax, MINIMUM_TSS_SIZE
mov [ecx+KgdtLimitLow],ax
; KiInitializeTSS(
; address of double fault TSS
; );
stdCall _KiInitializeTSS, <edx>
mov eax,cr3
mov [edx+TssCr3],eax
mov eax, offset FLAT:_KiDoubleFaultStack
mov dword ptr [edx+038h],eax
mov dword ptr [edx+TssEsp0],eax
mov dword ptr [edx+020h],offset FLAT:_KiTrap08
mov dword ptr [edx+024h],0 ; eflags
mov word ptr [edx+04ch],KGDT_R0_CODE ; set value for CS
mov word ptr [edx+058h],KGDT_R0_PCR ; set value for FS
mov [edx+050h],ss
mov word ptr [edx+048h],KGDT_R3_DATA OR RPL_MASK ; Es
mov word ptr [edx+054h],KGDT_R3_DATA OR RPL_MASK ; Ds
;
; set up 32bit NMI task gate to catch NMI faults.
;
mov eax,KissIdt
lea ecx,[eax]+10h ; Descriptor 2
mov byte ptr [ecx+5],085h ; dpl=0, present, taskgate
mov word ptr [ecx+2],KGDT_NMI_TSS
lea ecx,[edi]+KGDT_NMI_TSS
mov byte ptr [ecx+5],089h ; 32bit, dpl=0, present, TSS32, not busy
mov edx,offset FLAT:_KiNMITSS
mov eax,edx
mov [ecx+KgdtBaseLow],ax
shr eax,16
mov [ecx+KgdtBaseHi],ah
mov [ecx+KgdtBaseMid],al
mov eax, MINIMUM_TSS_SIZE
mov [ecx+KgdtLimitLow],ax
push edx
stdCall _KiInitializeTSS,<edx> ; KiInitializeTSS(
; address TSS
; );
;
; We are using the DoubleFault stack as the DoubleFault stack and the
; NMI Task Gate stack and briefly, it is the DPC stack for the first
; processor.
;
mov eax,cr3
mov [edx+TssCr3],eax
mov eax, offset FLAT:_KiDoubleFaultTSS
mov eax, dword ptr [eax+038h] ; get DF stack
mov dword ptr [edx+TssEsp0],eax ; use it for NMI stack
mov dword ptr [edx+038h],eax
mov dword ptr [edx+020h],offset FLAT:_KiTrap02
mov dword ptr [edx+024h],0 ; eflags
mov word ptr [edx+04ch],KGDT_R0_CODE ; set value for CS
mov word ptr [edx+058h],KGDT_R0_PCR ; set value for FS
mov [edx+050h],ss
mov word ptr [edx+048h],KGDT_R3_DATA OR RPL_MASK ; Es
mov word ptr [edx+054h],KGDT_R3_DATA OR RPL_MASK ; Ds
stdCall _KiInitializePcr, <KissPbNumber,KissPcr,KissIdt,KissGdt,KissTss,KissIdleThread,offset FLAT:_KiDoubleFaultStack>
;
; set current process pointer in current thread object
;
mov edx, KissIdleThread
mov ecx, offset FLAT:_KiIdleProcess ; (ecx)-> idle process obj
mov [edx]+ThApcState+AsProcess, ecx ; set addr of thread's process
;
; set up PCR: Teb, Prcb pointers. The PCR:InitialStack, and various fields
; of Prcb will be set up in _KiInitializeKernel
;
mov dword ptr fs:PcTeb, 0 ; PCR->Teb = 0
;
; Initialize KernelDr7 and KernelDr6 to 0. This must be done before
; the debugger is called.
;
mov dword ptr fs:PcPrcbData+PbProcessorState+PsSpecialRegisters+SrKernelDr6,0
mov dword ptr fs:PcPrcbData+PbProcessorState+PsSpecialRegisters+SrKernelDr7,0
;
; Since the entries of Kernel IDT have their Selector and Extended Offset
; fields set up in the wrong order, we need to swap them back to the order
; which i386 recognizes.
; This is only done by the bootup processor.
;
stdCall _KiSwapIDT ; otherwise, do the work
;
; Switch to R3 flat selectors that we want loaded so lazy segment
; loading will work.
;
mov eax,KGDT_R3_DATA OR RPL_MASK ; Set RPL = ring 3
mov ds,ax
mov es,ax
;
; Now copy our trap handlers to replace kernel debugger's handlers.
;
mov eax, KissIdt ; (eax)-> Idt
push dword ptr [eax+40h] ; save double fault's descriptor
push dword ptr [eax+44h]
push dword ptr [eax+10h] ; save nmi fault's descriptor
push dword ptr [eax+14h]
mov edi,KissIdt
mov esi,offset FLAT:_IDT
mov ecx,offset FLAT:_IDTLEN ; _IDTLEN is really an abs, we use
shr ecx,2
rep movsd
pop dword ptr [eax+14h] ; restore nmi fault's descriptor
pop dword ptr [eax+10h]
pop dword ptr [eax+44h] ; restore double fault's descriptor
pop dword ptr [eax+40h]
kiss_notp0:
;
; A new processor can't come online while execution is frozen
; Take freezelock while adding a processor to the system
; NOTE: don't use SPINLOCK macro - it has debugger stuff in it
;
if NT_INST
lea eax, _KiFreezeExecutionLock
stdCall _KiAcquireSpinLock, <eax>
else
@@: test _KiFreezeExecutionLock, 1
jnz short @b
lock bts _KiFreezeExecutionLock, 0
jc short @b
endif
;
; Add processor to active summary, and update BroadcastMasks
;
mov ecx, dword ptr KissPbNumber ; mark this processor as active
mov byte ptr fs:PcNumber, cl
mov eax, 1
shl eax, cl ; our affinity bit
mov fs:PcSetMember, eax
mov fs:PcPrcbData.PbSetMember, eax
;
; Initialize the interprocessor interrupt vector and increment ready
; processor count to enable kernel debugger.
;
stdCall _HalInitializeProcessor, <dword ptr KissPbNumber, KissLoaderBlock>
mov eax, fs:PcSetMember
or _KeActiveProcessors, eax ; New affinity of active processors
;
; Initialize ABIOS data structure if present.
; Note, the KiInitializeAbios MUST be called after the KeLoaderBlock is
; initialized.
;
stdCall _KiInitializeAbios, <dword ptr KissPbNumber>
inc _KeNumberProcessors ; One more processor now active
if NT_INST
lea eax, _KiFreezeExecutionLock
stdCall _KiReleaseSpinLock, <eax>
else
xor eax, eax ; release the executionlock
mov _KiFreezeExecutionLock, eax
endif
cmp byte ptr KissPbNumber, 0
jnz @f
; don't stop in debugger
stdCall _KdInitSystem, <_KeLoaderBlock,0>
if DEVL
;
; Give the debugger an opportunity to gain control.
;
POLL_DEBUGGER
endif ; DEVL
@@:
nop ; leave a spot for int-3 patch
;
; Set initial IRQL = HIGH_LEVEL for init
;
mov ecx, HIGH_LEVEL
fstCall KfRaiseIrql
mov KissIrql, al
;
; If the target machine does not implement the cmpxchg8b instruction,
; then patch the routines that use this instruction to simply jump
; to the corresponding routines that use spinlocks.
;
pushfd ; Save flags
cmp byte ptr KissPbNumber, 0
jnz cx8done ; only test on boot processor
pop ebx ; Get flags into eax
push ebx ; Save original flags
mov ecx, ebx
xor ecx, EFLAGS_ID ; flip ID bit
push ecx
popfd ; load it into flags
pushfd ; re-save flags
pop ecx ; get flags into eax
cmp ebx, ecx ; did bit stay flipped?
je short nocx8 ; No, don't try CPUID
or ebx, EFLAGS_ID
push ebx
popfd ; Make sure ID bit is set
.586p
mov eax, 1 ; Get feature bits
cpuid ; Uses eax, ebx, ecx, edx
.386p
test edx, 100h
jz short nocx8
or _KiBootFeatureBits, KF_CMPXCHG8B ; We're committed to using
jmp short cx8done ; this feature
nocx8:
lea eax, @ExInterlockedCompareExchange64@16 ; get target address
lea ecx, @ExpInterlockedCompareExchange64@16 ; get source address
mov byte ptr [eax], 0e9H ; set jump opcode value
lea edx, [eax] + 5 ; get simulated eip value
sub ecx, edx ; compute displacement
mov [eax] + 1, ecx ; set jump displacement value
lea eax, @ExInterlockedPopEntrySList@8 ; get target address
lea ecx, @ExfInterlockedPopEntrySList@8 ; get source address
mov byte ptr [eax], 0e9H ; set jump opcode value
lea edx, [eax] + 5 ; get simulated eip value
sub ecx, edx ; compute displacement
mov [eax] + 1, ecx ; set jump displacement value
lea eax, @ExInterlockedPushEntrySList@12 ; get target address
lea ecx, @ExfInterlockedPushEntrySList@12 ; get source address
mov byte ptr [eax], 0e9H ; set jump opcode value
lea edx, [eax] + 5 ; get simulated eip value
sub ecx, edx ; compute displacement
mov [eax] + 1, ecx ; set jump displacement value
lea eax, @ExInterlockedFlushSList@4 ; get target address
lea ecx, @ExfInterlockedFlushSList@4 ; get source address
mov byte ptr [eax], 0e9H ; set jump opcode value
lea edx, [eax] + 5 ; get simulated eip value
sub ecx, edx ; compute displacement
mov [eax] + 1, ecx ; set jump displacement value
lea eax, _ExInterlockedExchangeAddLargeInteger@16 ; get target address
lea ecx, _ExInterlockedAddLargeInteger@16 ; get source address
mov byte ptr [eax], 0e9H ; set jump opcode value
lea edx, [eax] + 5 ; get simulated eip value
sub ecx, edx ; compute displacement
mov [eax] + 1, ecx ; set jump displacement value
cx8done:
popfd
;
; Initialize ebp, esp, and argument registers for initializing the kernel.
;
mov ebx, KissIdleThread
mov edx, KissIdleStack
mov eax, KissPbNumber
and edx, NOT 3h ; align stack to 4 byte boundary
xor ebp, ebp ; (ebp) = 0. No more stack frame
mov esp, edx
;
; Reserve space for idle thread stack NPX_SAVE_AREA and initialization
;
sub esp, NPX_FRAME_LENGTH+KTRAP_FRAME_LENGTH+KTRAP_FRAME_ALIGN
push CR0_EM+CR0_TS+CR0_MP ; make space for Cr0NpxState
; arg6 - LoaderBlock
; arg5 - processor number
; arg4 - addr of prcb
; arg3 - idle thread's stack
; arg2 - addr of current thread obj
; arg1 - addr of current process obj
; initialize system data structures
; and HAL.
stdCall _KiInitializeKernel,<offset _KiIdleProcess,ebx,edx,dword ptr fs:PcPrcb,eax,_KeLoaderBlock>
;
; Set "shadow" priority value for Idle thread. This will keep the Mutex
; priority boost/drop code from dropping priority on the Idle thread, and
; thus avoids leaving a bit set in the ActiveMatrix for the Idle thread when
; there should never be any such bit.
;
mov ebx,fs:PcPrcbData+PbCurrentThread ; (eax)->Thread
mov byte ptr [ebx]+ThPriority,LOW_REALTIME_PRIORITY ; set pri.
;
; Control is returned to the idle thread with IRQL at HIGH_LEVEL. Lower IRQL
; to DISPATCH_LEVEL and set wait IRQL of idle thread.
;
sti
mov ecx, DISPATCH_LEVEL
fstCall KfLowerIrql
mov byte ptr [ebx]+ThWaitIrql, DISPATCH_LEVEL
;
; The following code represents the idle thread for a processor. The idle
; thread executes at IRQL DISPATCH_LEVEL and continually polls for work to
; do. Control may be given to this loop either as a result of a return from
; the system initialization routine or as the result of starting up another
; processor in a multiprocessor configuration.
;
mov ebx, PCR[PcSelfPcr] ; get address of PCR
;
; In a multiprocessor system the boot processor proceeds directly into
; the idle loop. As other processors start executing, however, they do
; not directly enter the idle loop - they spin until all processors have
; been started and the boot master allows them to proceed.
;
ifndef NT_UP
@@: cmp _KiBarrierWait, 0 ; check if barrier set
jnz short @b ; if nz, barrier set
endif
jmp KiIdleLoop ; enter idle loop
stdENDP _KiSystemStartup
INIT ends
_TEXT$00 SEGMENT DWORD PUBLIC 'CODE' ; Put IdleLoop in text section
ASSUME DS:FLAT, ES:FLAT, SS:NOTHING, FS:NOTHING, GS:NOTHING
page ,132
subttl "Idle Loop"
;++
;
; Routine Description:
;
; This routine continuously executes the idle loop and never returns.
;
; Arguments:
;
; ebx - Address of the current processor's PCR.
;
; Return value:
;
; None - routine never returns.
;
;--
public KiIdleLoop
KiIdleLoop proc
lea ebp, [ebx].PcPrcbData.PbDpcListHead ; set DPC listhead address
if DBG
xor edi, edi ; reset poll breakin counter
endif
jmp short kid20 ; Skip HalIdleProcessor on first iteration
;
; There are no entries in the DPC list and a thread has not been selected
; for execution on this processor. Call the HAL so power managment can be
; performed.
;
; N.B. The HAL is called with interrupts disabled. The HAL will return
; with interrupts enabled.
;
; N.B. Use a call instruction instead of a push-jmp, as the call instruction
; executes faster and won't invalidate the processor's call-return stack
; cache.
;
kid10: lea ecx, [ebx].PcPrcbData.PbPowerState
call dword ptr [ecx].PpIdleFunction ; (ecx) = Arg0
;
; Give the debugger an opportunity to gain control on debug systems.
;
; N.B. On an MP system the lowest numbered idle processor is the only
; processor that polls for a breakin request.
;
kid20:
if DBG
ifndef NT_UP
mov eax, _KiIdleSummary ; get idle summary
mov ecx, [ebx].PcSetMember ; get set member
dec ecx ; compute right bit mask
and eax, ecx ; check if any lower bits set
jnz short CheckDpcList ; if nz, not lowest numbered
endif
dec edi ; decrement poll counter
jg short CheckDpcList ; if g, not time to poll
POLL_DEBUGGER ; check if break in requested
endif
kid30:
if DBG
ifndef NT_UP
mov edi, 20 * 1000 ; set breakin poll interval
else
mov edi, 100 ; UP idle loop has a HLT in it
endif
endif
CheckDpcList0:
YIELD
;
; Disable interrupts and check if there is any work in the DPC list
; of the current processor or a target processor.
;
CheckDpcList:
;
; N.B. The following code enables interrupts for a few cycles, then
; disables them again for the subsequent DPC and next thread
; checks.
;
sti ; enable interrupts
nop ;
nop ;
cli ; disable interrupts
;
; Process the deferred procedure call list for the current processor.
;
cmp ebp, [ebp].LsFlink ; check if DPC list is empty
je short CheckNextThread ; if eq, DPC list is empty
mov cl, DISPATCH_LEVEL ; set interrupt level
fstCall HalClearSoftwareInterrupt ; clear software interrupt
call KiRetireDpcList ; process the current DPC list
if DBG
xor edi, edi ; clear breakin poll interval
endif
;
; Check if a thread has been selected to run on the current processor.
;
CheckNextThread: ;
cmp dword ptr [ebx].PcPrcbData.PbNextThread, 0 ; thread selected?
je short kid10 ; if eq, no thread selected
;
; A thread has been selected for execution on this processor. Acquire
; the dispatcher database lock, get the thread address again (it may have
; changed), clear the address of the next thread in the processor block,
; and call swap context to start execution of the selected thread.
;
; N.B. If the dispatcher database lock cannot be obtained immediately,
; then attempt to process another DPC rather than spinning on the
; dispatcher database lock.
; N.B. On MP systems, the dispatcher database is always locked at
; SYNCH level to ensure the lock is held for as short a period as
; possible (reduce contention). On UP systems there really is no
; lock, it is sufficient to be at DISPATCH level (which is the
; current level at this point in the code).
ifndef NT_UP
; see if dispatcher lock is available right now
cmp dword ptr _KiDispatcherLock, 0
jnz short CheckDpcList0
; attempt to acquire the dispatcher database lock
lea ecx, [ebx]+PcPrcbData+PbLockQueue+(8*LockQueueDispatcherLock)
fstCall KiTryToAcquireQueuedSpinLock
jz short CheckDpcList0 ; jif could not acquire lock
;
; Raise IRQL to synchronization level and enable interrupts.
;
mov ecx, SYNCH_LEVEL ; raise IRQL to synchronization level
fstCall KfRaiseIrql ;
endif
sti ; enable interrupts
mov esi, [ebx].PcPrcbData.PbNextThread ; get next thread address
mov edi, [ebx].PcPrcbData.PbCurrentThread ; set current thread address
mov dword ptr [ebx].PcPrcbData.PbNextThread, 0 ; clear next thread address
mov [ebx].PcPrcbData.PbCurrentThread, esi ; set current thread address
mov cl, 1 ; set APC interrupt bypass disable
call SwapContext ;
ifndef NT_UP
mov ecx, DISPATCH_LEVEL ; lower IRQL to dispatch level
fstCall KfLowerIrql ;
endif
lea ebp, [ebx].PcPrcbData.PbDpcListHead ; set DPC listhead address
jmp kid30 ;
KiIdleLoop endp
page ,132
subttl "Retire Deferred Procedure Call List"
;++
;
; Routine Description:
;
; This routine is called to retire the specified deferred procedure
; call list. DPC routines are called using the idle thread (current)
; stack.
;
; N.B. Interrupts must be disabled and the DPC list lock held on entry
; to this routine. Control is returned to the caller with the same
; conditions true.
;
; N.B. The registers ebx and ebp are preserved across the call.
;
; Arguments:
;
; ebx - Address of the target processor PCR.
; ebp - Address of the target DPC listhead.
;
; Return value:
;
; None.
;
;--
public KiRetireDpcList
KiRetireDpcList proc
?FpoValue = 0
ifndef NT_UP
?FpoValue = 1
push esi ; save register
lea esi, [ebx].PcPrcbData.PbDpcLock ; get DPC lock address
endif
FPOFRAME ?FpoValue,0
rdl5: mov PCR[PcPrcbData.PbDpcRoutineActive], esp ; set DPC routine active
;
; Process the DPC List.
;
rdl10: ;
ifndef NT_UP
ACQUIRE_SPINLOCK esi, rdl50, NoChecking ; acquire DPC lock
cmp ebp, [ebp].LsFlink ; check if DPC list is empty
je rdl45 ; if eq, DPC list is empty
endif
mov edx, [ebp].LsFlink ; get address of next entry
mov ecx, [edx].LsFlink ; get address of next entry
mov [ebp].LsFlink, ecx ; set address of next in header
mov [ecx].LsBlink, ebp ; set address of previous in next
sub edx, DpDpcListEntry ; compute address of DPC object
mov ecx, [edx].DpDeferredRoutine ; get DPC routine address
if DBG
push edi ; save register
mov edi, esp ; save current stack pointer
endif
FPOFRAME ?FpoValue,0
push [edx].DpSystemArgument2 ; second system argument
push [edx].DpSystemArgument1 ; first system argument
push [edx].DpDeferredContext ; get deferred context argument
push edx ; address of DPC object
mov dword ptr [edx]+DpLock, 0 ; clear DPC inserted state
dec dword ptr [ebx].PcPrcbData.PbDpcQueueDepth ; decrement depth
if DBG
mov PCR[PcPrcbData.PbDebugDpcTime], 0 ; Reset the time in DPC
endif
ifndef NT_UP
RELEASE_SPINLOCK esi, NoChecking ; release DPC lock
endif
sti ; enable interrupts
call ecx ; call DPC routine
if DBG
stdCall _KeGetCurrentIrql ; get current IRQL
cmp al, DISPATCH_LEVEL ; check if still at dispatch level
jne rdl55 ; if ne, not at dispatch level
cmp esp, edi ; check if stack pointer is correct
jne rdl60 ; if ne, stack pointer is not correct
rdl30: pop edi ; restore register
endif
FPOFRAME ?FpoValue,0
rdl35: cli ; disable interrupts
cmp ebp, [ebp].LsFlink ; check if DPC list is empty
jne rdl10 ; if ne, DPC list not empty
;
; Clear DPC routine active and DPC requested flags.
;
rdl40: mov [ebx].PcPrcbData.PbDpcRoutineActive, 0
mov [ebx].PcPrcbData.PbDpcInterruptRequested, 0
;
; Check one last time that the DPC list is empty. This is required to
; close a race condition with the DPC queuing code where it appears that
; a DPC routine is active (and thus an interrupt is not requested), but
; this code has decided the DPC list is empty and is clearing the DPC
; active flag.
;
cmp ebp, [ebp].LsFlink ; check if DPC list is empty
jne rdl5 ; if ne, DPC list not empty
ifndef NT_UP
pop esi ; retore register
endif
ret ; return
;
; Unlock DPC list and clear DPC active.
;
rdl45: ;
ifndef NT_UP
RELEASE_SPINLOCK esi, NoChecking ; release DPC lock
jmp short rdl40 ;
endif
ifndef NT_UP
rdl50: sti ; enable interrupts
SPIN_ON_SPINLOCK esi, <short rdl35> ; spin until lock is freee
endif
if DBG
rdl55: stdCall _KeBugCheckEx, <IRQL_NOT_GREATER_OR_EQUAL, ebx, eax, 0, 0> ;
rdl60: push dword ptr [edi+12] ; push address of DPC function
push offset FLAT:_MsgDpcTrashedEsp ; push message address
call _DbgPrint ; print debug message
add esp, 8 ; remove arguments from stack
int 3 ; break into debugger
mov esp, edi ; reset stack pointer
jmp rdl30 ;
endif
KiRetireDpcList endp
_TEXT$00 ends
_TEXT SEGMENT DWORD PUBLIC 'CODE' ; Put IdleLoop in text section
page ,132
subttl "Set up 80387, or allow for emulation"
;++
;
; Routine Description:
;
; This routine is called during kernel initialization once for each
; processor. It sets EM+TS+MP whether we are emulating or not.
;
; If the 387 hardware exists, EM+TS+MP will all be cleared on the
; first trap 07. Thereafter, EM will never be seen for this thread.
; MP+TS will only be set when an error is detected (via IRQ 13), and
; it will be cleared by the trap 07 that will occur on the next FP
; instruction.
;
; If we're emulating, EM+TS+MP are all always set to ensure that all
; FP instructions trap to the emulator (the trap 07 handler is edited
; to point to the emulator, rather than KiTrap07).
;
; Arguments:
;
; None.
;
; Return Value:
;
; None.
;
;--
cPublicProc _KiSetCR0Bits ,0
mov eax, cr0
;
; There are two useful bits in CR0 that we want to turn on if the processor
; is a 486 or above. (They don't exist on the 386)
;
; CR0_AM - Alignment mask (so we can turn on alignment faults)
;
; CR0_WP - Write protect (so we get page faults if we write to a
; write-protected page from kernel mode)
;
cmp byte ptr fs:PcPrcbData.PbCpuType, 3h
jbe @f
;
; The processor is not a 386, (486 or greater) so we assume it is ok to
; turn on these bits.
;
or eax, CR0_WP
@@:
mov cr0, eax
stdRET _KiSetCR0Bits
stdENDP _KiSetCR0Bits
ifdef DBGMP
cPublicProc _KiPollDebugger,0
cPublicFpo 0,3
push eax
push ecx
push edx
POLL_DEBUGGER
pop edx
pop ecx
pop eax
stdRET _KiPollDebugger
stdENDP _KiPollDebugger
endif
_TEXT ends
end
|
oeis/001/A001091.asm | neoneye/loda-programs | 11 | 26573 | ; A001091: a(n) = 8*a(n-1) - a(n-2); a(0) = 1, a(1) = 4.
; Submitted by <NAME>(s3)
; 1,4,31,244,1921,15124,119071,937444,7380481,58106404,457470751,3601659604,28355806081,223244789044,1757602506271,13837575261124,108942999582721,857706421400644,6752708371622431,53163960551578804,418558976041008001,3295307847776485204,25943903806170873631,204255922601590503844,1608103477006553157121,12660571893450834753124,99676471670600124867871,784751201471350164189844,6178333140100201188650881,48641913919330259345017204,382956978214541873571486751,3015013911797004729226876804
mov $2,1
lpb $0
sub $0,1
add $2,$1
add $1,$2
add $1,$2
add $1,$2
add $2,$1
lpe
mov $0,$2
|
oeis/158/A158639.asm | neoneye/loda-programs | 11 | 99420 | ; A158639: a(n) = 676*n^2 - 26.
; Submitted by <NAME>
; 650,2678,6058,10790,16874,24310,33098,43238,54730,67574,81770,97318,114218,132470,152074,173030,195338,218998,244010,270374,298090,327158,357578,389350,422474,456950,492778,529958,568490,608374,649610,692198,736138,781430,828074,876070,925418,976118,1028170,1081574,1136330,1192438,1249898,1308710,1368874,1430390,1493258,1557478,1623050,1689974,1758250,1827878,1898858,1971190,2044874,2119910,2196298,2274038,2353130,2433574,2515370,2598518,2683018,2768870,2856074,2944630,3034538,3125798,3218410
add $0,1
pow $0,2
mul $0,26
sub $0,1
mul $0,26
|
oeis/138/A138523.asm | neoneye/loda-programs | 11 | 246794 | ; A138523: a(n) = Sum_{k=1..n} (2k-1)!.
; Submitted by <NAME>(w3)
; 1,7,127,5167,368047,40284847,6267305647,1313941673647,357001369769647,122002101778601647,51212944273488041647,25903229683158464681647,15537113273014144448681647,10904406563691366305216681647,8852666400303393320848832681647,8231691320578226211046411712681647,8691549310132464721729240812992681647,10341839515696277394388380578336192681647,13774094930742041323710367962159238592681647,20411656176128185399963992107865056595392681647,33472938269339935293570026045548616721747392681647
mov $1,1
mov $2,$0
add $2,1
add $2,$0
lpb $2
mul $1,$2
sub $2,1
mul $1,$2
add $1,1
sub $2,1
lpe
mov $0,$1
|
alloy4fun_models/trashltl/models/0/uKt389SLiE8NtG66K.als | Kaixi26/org.alloytools.alloy | 0 | 4821 | open main
pred iduKt389SLiE8NtG66K_prop1 {
historically all f:File | f in Protected
}
pred __repair { iduKt389SLiE8NtG66K_prop1 }
check __repair { iduKt389SLiE8NtG66K_prop1 <=> prop1o } |
oeis/122/A122574.asm | neoneye/loda-programs | 11 | 160194 | <gh_stars>10-100
; A122574: a(1) = a(2) = 1, a(n) = -11*a(n-1) + a(n-2).
; Submitted by <NAME>
; 1,1,-10,111,-1231,13652,-151403,1679085,-18621338,206513803,-2290273171,25399518684,-281684978695,3123934284329,-34644962106314,384218517453783,-4261048654097927,47255753712530980,-524074339491938707,5812073488123856757,-64456882708854363034,714837783285521850131,-7927672498849594714475,87919235270631063709356,-975039260475791295517391,10813351100504335314400657,-119921901366023479753924618,1329954266126762612607571455,-14749418828760412218437210623,163573561382491297015416888308
mov $3,1
lpb $0
sub $0,$3
mul $2,-1
add $4,$2
mov $1,$4
mul $1,11
add $2,1
add $2,$1
lpe
mov $0,$4
mul $0,22
add $0,2
div $0,2
|
programs/oeis/024/A024148.asm | neoneye/loda | 22 | 25113 | <reponame>neoneye/loda
; A024148: a(n) = 12^n - n^8.
; 1,11,-112,-4833,-44800,-141793,1306368,30067007,413204480,5116733631,61817364224,742794011807,8915670466560,106992389648351,1283916988759808,15407019011695743,184884254600069120,2218611099764679551,26623333269865283328,319479999353639363807,3833759992421875122176,46005119909331878606751,552061438912381541719808,6624737266949158700134847,79496847203390734058127360,953962166440689977013407807,11447545997288281346388516608,137370551967459378380157437727,1648446623609512543573241692160,19781359483314150526912277872991,237376313799769806328294191431424,2848515765597237675946550606139647,34182189187166852111367742454497280,410186270246002225336424697184882431
mov $1,12
pow $1,$0
pow $0,8
sub $1,$0
mov $0,$1
|
applescripts/all_tasks.applescript | jacobx1/of-sdk | 0 | 1800 | #!/usr/bin/osascript
use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use scripting additions
-- classes, constants, and enums used
property NSJSONWritingPrettyPrinted : a reference to 0
property NSJSONSerialization : a reference to current application's NSJSONSerialization
property NSString : a reference to current application's NSString
on rfc3339FromDate(aDate)
set theFormatter to current application's NSDateFormatter's new()
theFormatter's setLocale:(current application's NSLocale's localeWithLocaleIdentifier:"en_US_POSIX")
theFormatter's setTimeZone:(current application's NSTimeZone's timeZoneWithAbbreviation:"GMT") -- skip for local time
theFormatter's setDateFormat:"yyyy'-'MM'-'dd'T'HH':'mm':'ssXXX"
return (theFormatter's stringFromDate:aDate)
end rfc3339FromDate
on toJSON(obj)
set theJSONData to NSJSONSerialization's dataWithJSONObject:obj options:NSJSONWritingPrettyPrinted |error|:(missing value)
set someString to current application's NSString's alloc()'s initWithData:theJSONData encoding:(current application's NSUTF8StringEncoding)
return someString as text
end toJSON
on actionItemPropertiesToSet(properties)
tell application "OmniFocus"
set currentId to id of properties
set currentName to name of properties
set currentDueDate to my rfc3339FromDate(due date of properties)
set deferDate to my rfc3339FromDate(defer date of properties)
set completionDate to my rfc3339FromDate(completion date of properties)
set currentNote to note of properties
set currentFlagged to flagged of properties
set modificationDate to my rfc3339FromDate(modification date of properties)
set estimatedMinutes to estimated minutes of properties
set isCompleted to completed of properties
set isDropped to dropped of properties
return {|id|:currentId, |name|:currentName, |dueDate|:currentDueDate, |deferDate|:deferDate, |completionDate|:completionDate, |note|:currentNote, |flagged|:currentFlagged, |modificationDate|:modificationDate, |estimatedMinutes|:estimatedMinutes, |completed|:isCompleted, |dropped|:isDropped}
end tell
end actionItemPropertiesToSet
on getExtendedProperties(index, allTags, allParents)
set currentTagIds to item index of item index 1 of allTags
set currentTagNames to item index of item index 2 of allTags
set currentParentId to item index of item index 1 of allParents
set currentParentName to item index of item index 2 of allParents
set allTagsKeyed to {}
repeat with index2 from 1 to length of currentTagIds
set currentTagId to item index2 of currentTagIds
set currentTagName to item index2 of currentTagNames
set end of allTagsKeyed to {|id|:currentTagId, |name|:currentTagName}
end repeat
set parentItem to {|id|:currentParentId, |name|:currentParentName}
return {|parent|:parentItem, tags:allTagsKeyed}
end getExtendedProperties
on getTasksForIterator(iterator, includeExtendedData)
tell application "OmniFocus"
set allProperties to get the properties of iterator
if includeExtendedData then
set allTags to {id, name} of tags of iterator
set allParents to {id, name} of parent task of iterator
end if
set output to {}
repeat with index from 1 to length of allProperties
set propertiesValue to item index of allProperties
set basicProperties to my actionItemPropertiesToSet(propertiesValue)
if includeExtendedData then
set extendedProperties to my getExtendedProperties(index, allTags, allParents)
set end of output to basicProperties & extendedProperties
else
set end of output to basicProperties
end if
end repeat
return output
end tell
end getTasksForIterator
on parseArgv(thisArgv)
set containerParam to false
set shouldGetExtendedProperties to false
set commandType to "tasks"
set filterType to "remaining"
try
set commandType to item 1 of thisArgv -- "tasks", "projects"
set filterType to item 2 of thisArgv -- "all", "remaining", "closed", "dropped", "completed"
set shouldGetExtendedProperties to item 3 of thisArgv as boolean
if length of thisArgv > 3 then
-- For tasks, this is the containing project. For projects, this is the containing folder, or, can not include
set containerParam to item 4 of thisArgv
end if
end try
return {command:commandType, filter:filterType, container:containerParam, shouldGetExtendedProperties:shouldGetExtendedProperties}
end parseArgv
on getBaseIteratorForArgs(args)
tell application "OmniFocus" to tell default document
set filterContainer to |container| of args
if (command of args) is "tasks" then
if filterContainer is false then
return a reference to (every flattened task)
end if
return a reference to (every flattened task of root task of (first project whose id is filterContainer))
else if (command of args) is "projects" then
if filterContainer is false then
return a reference to (root task of every flattened project)
end if
return a reference to ((root task of every flattened project) of (first folder whose id is filterContainer))
end if
end tell
end getBaseIteratorForArgs
on getFilteredIteratorForArgs(args, baseIterator)
tell application "OmniFocus" to tell default document
set iterator to baseIterator
if (filter of args) is "remaining" then
set iterator to a reference to (baseIterator whose completed is false and dropped is false)
else if (filter of args) is "closed" then
set iterator to a reference to (baseIterator whose completed is true or dropped is true)
else if (filter of args) is "dropped" then
set iterator to a reference to (baseIterator whose dropped is true)
else if (filter of args) is "completed" then
set iterator to a reference to (baseIterator whose completed is true)
end if
return iterator
end tell
end getFilteredIteratorForArgs
on handleTasksAndProjects(args)
set baseIterator to my getBaseIteratorForArgs(args)
set iterator to my getFilteredIteratorForArgs(args, baseIterator)
return my getTasksForIterator(iterator, shouldGetExtendedProperties of args)
end handleTasksAndProjects
on run argv
tell application "OmniFocus"
tell default document
set args to my parseArgv(argv)
set output to my handleTasksAndProjects(args)
return my toJSON(output)
end tell
end tell
end run
|
Transynther/x86/_processed/NONE/_xt_sm_/i7-7700_9_0xca.log_13_66.asm | ljhsiun2/medusa | 9 | 5229 | <reponame>ljhsiun2/medusa
.global s_prepare_buffers
s_prepare_buffers:
push %r14
push %r15
push %rax
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_normal_ht+0x1ef3b, %r15
and $6265, %r14
movw $0x6162, (%r15)
nop
nop
nop
nop
nop
xor $35076, %rbx
lea addresses_UC_ht+0x4bbb, %rbx
nop
nop
nop
nop
and %rdx, %rdx
mov $0x6162636465666768, %rcx
movq %rcx, (%rbx)
nop
nop
and $40512, %rdi
lea addresses_normal_ht+0x15bbb, %rsi
lea addresses_WT_ht+0xe31b, %rdi
nop
nop
cmp %rax, %rax
mov $93, %rcx
rep movsl
nop
nop
nop
add $53979, %rbx
lea addresses_WC_ht+0x130df, %rsi
lea addresses_WC_ht+0x148a3, %rdi
nop
nop
add %r15, %r15
mov $8, %rcx
rep movsb
nop
nop
sub $877, %r15
lea addresses_normal_ht+0x7abb, %rsi
lea addresses_normal_ht+0xffbb, %rdi
nop
and $3291, %r14
mov $78, %rcx
rep movsl
nop
nop
nop
add $56053, %r15
lea addresses_UC_ht+0x13, %rsi
lea addresses_UC_ht+0xbbbb, %rdi
clflush (%rsi)
nop
nop
nop
nop
nop
cmp $63530, %rbx
mov $71, %rcx
rep movsl
nop
nop
nop
add $1144, %rax
lea addresses_WC_ht+0x10ebb, %rsi
lea addresses_A_ht+0x4fbb, %rdi
nop
sub $19299, %r14
mov $0, %rcx
rep movsl
nop
sub %rsi, %rsi
lea addresses_WT_ht+0xd5b, %rcx
nop
nop
nop
and $20881, %rsi
mov (%rcx), %r15
and $18385, %rbx
lea addresses_WC_ht+0x5bbb, %rsi
lea addresses_normal_ht+0x13983, %rdi
nop
nop
nop
add $24721, %rdx
mov $14, %rcx
rep movsw
nop
nop
nop
cmp $48622, %r15
lea addresses_WT_ht+0x16f3b, %rcx
clflush (%rcx)
nop
nop
nop
nop
nop
and $51821, %rax
mov (%rcx), %edx
nop
nop
add $32473, %rax
lea addresses_UC_ht+0x1babb, %rdi
nop
nop
nop
nop
nop
and %rdx, %rdx
mov (%rdi), %rsi
nop
nop
nop
cmp $21841, %r15
lea addresses_A_ht+0x11abb, %rdi
nop
nop
nop
nop
inc %r15
mov $0x6162636465666768, %rcx
movq %rcx, %xmm5
movups %xmm5, (%rdi)
nop
nop
nop
nop
add $1842, %r14
lea addresses_D_ht+0x32cb, %rax
inc %r15
mov $0x6162636465666768, %rbx
movq %rbx, %xmm7
vmovups %ymm7, (%rax)
nop
nop
nop
nop
and %rdx, %rdx
lea addresses_WC_ht+0x47db, %r15
nop
nop
nop
nop
nop
and $57474, %rax
vmovups (%r15), %ymm4
vextracti128 $0, %ymm4, %xmm4
vpextrq $1, %xmm4, %rdx
nop
nop
nop
dec %rbx
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r15
pop %r14
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r13
push %r14
push %r9
push %rax
push %rsi
// Load
lea addresses_PSE+0x55fb, %r9
nop
cmp %r13, %r13
mov (%r9), %esi
nop
nop
sub %rsi, %rsi
// Store
lea addresses_D+0x1e25a, %r10
clflush (%r10)
nop
nop
nop
nop
nop
sub %r11, %r11
mov $0x5152535455565758, %r9
movq %r9, %xmm4
movups %xmm4, (%r10)
nop
add %r13, %r13
// Load
lea addresses_RW+0x3c4b, %rax
nop
nop
nop
nop
nop
sub $17512, %r9
mov (%rax), %si
nop
nop
nop
nop
nop
cmp %r11, %r11
// Store
lea addresses_normal+0x7c3, %r14
nop
add $35313, %r9
movw $0x5152, (%r14)
nop
nop
dec %r14
// Store
lea addresses_RW+0x14bbb, %r10
clflush (%r10)
nop
nop
dec %rax
movb $0x51, (%r10)
dec %r11
// Store
mov $0x719241000000093b, %r10
nop
nop
nop
add %r11, %r11
mov $0x5152535455565758, %rsi
movq %rsi, %xmm1
vmovups %ymm1, (%r10)
nop
nop
nop
xor %r13, %r13
// Load
lea addresses_WT+0x3675, %r9
nop
cmp %r13, %r13
mov (%r9), %si
nop
xor %r11, %r11
// Load
lea addresses_US+0x119bb, %rax
nop
nop
nop
cmp $18978, %rsi
mov (%rax), %r14d
sub $52321, %rsi
// Faulty Load
lea addresses_RW+0x14bbb, %rsi
nop
xor %r13, %r13
movb (%rsi), %r9b
lea oracles, %r10
and $0xff, %r9
shlq $12, %r9
mov (%r10,%r9,1), %r9
pop %rsi
pop %rax
pop %r9
pop %r14
pop %r13
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_RW'}, 'OP': 'LOAD'}
{'src': {'congruent': 2, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_PSE'}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_D'}}
{'src': {'congruent': 4, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_RW'}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'congruent': 3, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_normal'}}
{'OP': 'STOR', 'dst': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 1, 'NT': False, 'type': 'addresses_RW'}}
{'OP': 'STOR', 'dst': {'congruent': 7, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_NC'}}
{'src': {'congruent': 1, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_WT'}, 'OP': 'LOAD'}
{'src': {'congruent': 9, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_US'}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 1, 'NT': False, 'type': 'addresses_RW'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'congruent': 6, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_normal_ht'}}
{'OP': 'STOR', 'dst': {'congruent': 11, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_UC_ht'}}
{'src': {'congruent': 5, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'congruent': 5, 'same': False, 'type': 'addresses_WT_ht'}}
{'src': {'congruent': 1, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 2, 'same': False, 'type': 'addresses_WC_ht'}}
{'src': {'congruent': 8, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'congruent': 9, 'same': False, 'type': 'addresses_normal_ht'}}
{'src': {'congruent': 3, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 11, 'same': False, 'type': 'addresses_UC_ht'}}
{'src': {'congruent': 8, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 10, 'same': False, 'type': 'addresses_A_ht'}}
{'src': {'congruent': 4, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 10, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 0, 'same': False, 'type': 'addresses_normal_ht'}}
{'src': {'congruent': 7, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 7, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_UC_ht'}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'congruent': 6, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_A_ht'}}
{'OP': 'STOR', 'dst': {'congruent': 2, 'AVXalign': False, 'same': True, 'size': 32, 'NT': False, 'type': 'addresses_D_ht'}}
{'src': {'congruent': 3, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_WC_ht'}, 'OP': 'LOAD'}
{'51': 13}
51 51 51 51 51 51 51 51 51 51 51 51 51
*/
|
test/Fail/Issue2928.agda | shlevy/agda | 1,989 | 148 | record R : Set₂ where
field
f : Set₁
f : Set → R
f .R.f = Set
|
oeis/058/A058278.asm | neoneye/loda-programs | 11 | 164868 | ; A058278: Expansion of (1 - x^2)/(1 - x - x^3).
; Submitted by <NAME>
; 1,1,0,1,2,2,3,5,7,10,15,22,32,47,69,101,148,217,318,466,683,1001,1467,2150,3151,4618,6768,9919,14537,21305,31224,45761,67066,98290,144051,211117,309407,453458,664575,973982,1427440,2092015,3065997,4493437,6585452,9651449,14144886,20730338,30381787,44526673,65257011,95638798,140165471,205422482,301061280,441226751,646649233,947710513,1388937264,2035586497,2983297010,4372234274,6407820771,9391117781,13763352055,20171172826,29562290607,43325642662,63496815488,93059106095,136384748757,199881564245
mov $2,1
mov $3,1
lpb $0
sub $0,1
mov $1,$4
sub $3,1
sub $1,$3
mov $4,$2
add $2,$3
mov $3,$1
add $4,$1
lpe
mov $0,$2
|
grammar/PicishLexer.g4 | dswisher/swish-diagram | 0 | 4493 | <reponame>dswisher/swish-diagram<gh_stars>0
// Copyright (c) <NAME>. All Rights Reserved.
// Licensed under the MIT License. See LICENSE.md in the project root for license information.
lexer grammar PicishLexer;
BOX: 'box';
CIRCLE: 'circle';
LINE: 'line';
DOWN: 'down';
LEFT: 'left';
RIGHT: 'right';
UP: 'up';
MOVE: 'move';
SEMI: ';';
WS : [ \t\r\n]+ -> skip ; // skip spaces, tabs, newlines
LINE_COMMENT : '//' ~[\r\n]* -> skip ;
|
oeis/159/A159637.asm | neoneye/loda-programs | 11 | 12543 | <filename>oeis/159/A159637.asm
; A159637: Start with [0], repeatedly apply the map 0 -> [01/10], 1 -> [10/01] .
; Submitted by <NAME>
; 0,1,1,1,0,1,0,0,0,0,1,1,0,1,1,0,0,1,1,0,0,0,1,0,0,0,1,0,1,1,1,1,1,1,1,1,1,0,1,0,0,0,1,0,1,0,0,0,0,1,1,0,0,0,0,0,1,0,1,1,0,1,1,0,1,0,1,1,1,1,0,0,0,0,1,1,1,1
mov $2,$0
seq $0,25581 ; Triangle T(n, k) = n-k, 0 <= k <= n.
seq $2,2262 ; Triangle read by rows: T(n,k), 0 <= k <= n, in which row n lists the first n+1 nonnegative integers.
mov $4,$0
min $0,$2
max $4,$2
mov $2,$4
seq $2,70939 ; Length of binary representation of n.
lpb $2
mov $3,$0
div $0,2
add $3,$4
add $1,$3
sub $2,1
div $4,2
lpe
mov $0,$1
mod $0,2
|
uxos/trial/real/vga-string.asm | CaysHub/OS_Test | 0 | 89215 | org 0x7c00
[bits 16]
msg:
db "HELLO", 0
times 510-($-$$) db 0
dw 0xAA55
|
Validation/pyFrame3DD-master/gcc-master/gcc/ada/libgnat/s-gloloc.adb | djamal2727/Main-Bearing-Analytical-Model | 0 | 8974 | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . G L O B A L _ L O C K S --
-- --
-- B o d y --
-- --
-- Copyright (C) 1999-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. --
-- --
------------------------------------------------------------------------------
with System.Soft_Links;
package body System.Global_Locks is
type String_Access is access String;
Dir_Separator : Character;
pragma Import (C, Dir_Separator, "__gnat_dir_separator");
type Lock_File_Entry is record
Dir : String_Access;
File : String_Access;
end record;
Last_Lock : Lock_Type := Null_Lock;
Lock_Table : array (Lock_Type range 1 .. 15) of Lock_File_Entry;
procedure Lock_File
(Dir : String;
File : String;
Wait : Duration := 0.1;
Retries : Natural := Natural'Last);
-- Create a lock file File in directory Dir. If the file cannot be
-- locked because someone already owns the lock, this procedure
-- waits Wait seconds and retries at most Retries times. If the file
-- still cannot be locked, Lock_Error is raised. The default is to try
-- every second, almost forever (Natural'Last times).
------------------
-- Acquire_Lock --
------------------
procedure Acquire_Lock (Lock : in out Lock_Type) is
begin
Lock_File
(Lock_Table (Lock).Dir.all,
Lock_Table (Lock).File.all);
end Acquire_Lock;
-----------------
-- Create_Lock --
-----------------
procedure Create_Lock (Lock : out Lock_Type; Name : String) is
L : Lock_Type;
begin
System.Soft_Links.Lock_Task.all;
Last_Lock := Last_Lock + 1;
L := Last_Lock;
System.Soft_Links.Unlock_Task.all;
if L > Lock_Table'Last then
raise Lock_Error;
end if;
for J in reverse Name'Range loop
if Name (J) = Dir_Separator then
Lock_Table (L).Dir := new String'(Name (Name'First .. J - 1));
Lock_Table (L).File := new String'(Name (J + 1 .. Name'Last));
exit;
end if;
end loop;
if Lock_Table (L).Dir = null then
Lock_Table (L).Dir := new String'(".");
Lock_Table (L).File := new String'(Name);
end if;
Lock := L;
end Create_Lock;
---------------
-- Lock_File --
---------------
procedure Lock_File
(Dir : String;
File : String;
Wait : Duration := 0.1;
Retries : Natural := Natural'Last)
is
C_Dir : aliased String := Dir & ASCII.NUL;
C_File : aliased String := File & ASCII.NUL;
function Try_Lock (Dir, File : System.Address) return Integer;
pragma Import (C, Try_Lock, "__gnat_try_lock");
begin
for I in 0 .. Retries loop
if Try_Lock (C_Dir'Address, C_File'Address) = 1 then
return;
end if;
exit when I = Retries;
delay Wait;
end loop;
raise Lock_Error;
end Lock_File;
------------------
-- Release_Lock --
------------------
procedure Release_Lock (Lock : in out Lock_Type) is
S : aliased String :=
Lock_Table (Lock).Dir.all & Dir_Separator &
Lock_Table (Lock).File.all & ASCII.NUL;
procedure unlink (A : System.Address);
pragma Import (C, unlink, "unlink");
begin
unlink (S'Address);
end Release_Lock;
end System.Global_Locks;
|
transformy/tables/gen/0001.asm | mborik/regression | 3 | 241541 | <gh_stars>1-10
ld a, 15
ld hl, basescradr + #082b
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
ld hl, basescradr + #084b
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
ld hl, basescradr + #086b
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
ld hl, basescradr + #088b
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
ld hl, basescradr + #08ab
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
ld hl, basescradr + #08cb
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
ld hl, basescradr + #08eb
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
ld hl, basescradr + #0a0b
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
ld (basescradr + #00eb), a
ld (basescradr + #01eb), a
ld a, 255
ld hl, basescradr + #00f4
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
ld hl, basescradr + #0814
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
ld hl, basescradr + #0834
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
ld hl, basescradr + #0854
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
ld hl, basescradr + #0874
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
ld hl, basescradr + #0894
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
ld hl, basescradr + #08b4
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
ld hl, basescradr + #08d4
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
ld hl, basescradr + #00ec
ld (hl), a
inc hl
ld (hl), a
inc hl
ld (hl), a
inc hl
ld (hl), a
inc hl
ld (hl), a
inc hl
ld (hl), a
inc hl
ld (hl), a
inc hl
ld (hl), a
ld hl, basescradr + #01ec
ld (hl), a
inc hl
ld (hl), a
inc hl
ld (hl), a
inc hl
ld (hl), a
inc hl
ld (hl), a
inc hl
ld (hl), a
inc hl
ld (hl), a
inc hl
ld (hl), a
ld a, 31
ld hl, basescradr + #04eb
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
inc h
ld (hl), a
ld (basescradr + #080b), a
ld (basescradr + #090b), a
xor a
ld hl, basescradr + #0feb
ld (hl), a
inc hl
ld (hl), a
inc hl
ld (hl), a
inc hl
ld (hl), a
inc hl
ld (hl), a
inc hl
ld (hl), a
inc hl
ld (hl), a
inc hl
ld (hl), a
inc hl
ld (hl), a
inc hl
ld (hl), a
ld hl, basescradr + #100b
ld (hl), a
inc hl
ld (hl), a
inc hl
ld (hl), a
inc hl
ld (hl), a
inc hl
ld (hl), a
inc hl
ld (hl), a
inc hl
ld (hl), a
inc hl
ld (hl), a
inc hl
ld (hl), a
inc hl
ld (hl), a
ld hl, basescradr + #110b
ld (hl), a
inc hl
ld (hl), a
inc hl
ld (hl), a
inc hl
ld (hl), a
inc hl
ld (hl), a
inc hl
ld (hl), a
inc hl
ld (hl), a
inc hl
ld (hl), a
inc hl
ld (hl), a
inc hl
ld (hl), a
ret
|
binutils-2.21.1/gcc-4.5.1/libgcc/config/moxie/crti.asm | cberner12/xv6 | 2 | 8645 | <reponame>cberner12/xv6
# crti.asm for moxie
#
# Copyright (C) 2009 Free Software Foundation
#
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# This file is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# 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/>.
# This file just make a stack frame for the contents of the .fini and
# .init sections. Users may put any desired instructions in those
# sections.
.file "crti.asm"
.section ".init"
.global _init
.type _init, @function
.p2align 1
_init:
.section ".fini"
.global _fini
.type _fini,@function
.p2align 1
_fini:
|
test_3.asm | shavtvalishvili/Assembly-Emulator | 0 | 171726 | R1 = 1
R2 = 2
R3 = 3
R4 = 4
R5 = 1
R6 = 0
BGE R5, 5, PC + 28
R6 = R6 + R1
R6 = R6 + R2
R6 = R6 + R3
R6 = R6 + R4
R5 = R5 + 1
JUMP PC - 24
RV = R6
RET |
awa/src/awa-modules-beans.ads | fuzzysloth/ada-awa | 81 | 1895 | -----------------------------------------------------------------------
-- awa-modules-beans -- Module beans factory
-- Copyright (C) 2009, 2010, 2011 <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 Ada.Strings.Unbounded;
with ASF.Beans;
with Util.Beans.Basic;
generic
type Module is new AWA.Modules.Module with private;
type Module_Access is access all Module'Class;
package AWA.Modules.Beans is
-- Create a bean. The module instance is passed as parameter.
type Create_Bean_Access is access function (Manager : Module_Access)
return Util.Beans.Basic.Readonly_Bean_Access;
-- Register under the given name a function to create the bean instance when
-- it is accessed for a first time. The scope defines the scope of the bean.
-- bean
procedure Register (Plugin : in out Module'Class;
Name : in String;
Handler : in Create_Bean_Access);
private
-- ------------------------------
-- Binding record
-- ------------------------------
type Module_Binding is new ASF.Beans.Class_Binding with record
Module : Module_Access;
Create : Create_Bean_Access;
end record;
type Module_Binding_Access is access all Module_Binding;
--
procedure Create (Factory : in Module_Binding;
Name : in Ada.Strings.Unbounded.Unbounded_String;
Result : out Util.Beans.Basic.Readonly_Bean_Access);
end AWA.Modules.Beans;
|
experiments/test-suite/mutation-based/10/10/dll.als | kaiyuanw/AlloyFLCore | 1 | 1639 | pred test32 {
some disj DLL0: DLL {some disj Node0, Node1, Node2: Node {
DLL = DLL0
header = DLL0->Node2
Node = Node0 + Node1 + Node2
no pre
nxt = Node1->Node0 + Node2->Node1
elem = Node0->-7 + Node1->-8 + Node2->-7
Sorted[]
}}
}
run test32 for 3 expect 0
pred test34 {
some disj DLL0: DLL {some disj Node0, Node1: Node {
DLL = DLL0
header = DLL0->Node1
Node = Node0 + Node1
no pre
nxt = Node1->Node0
elem = Node0->-7 + Node1->-8
ConsistentPreAndNxt[]
}}
}
run test34 for 3 expect 0
pred test46 {
some disj DLL0: DLL {some disj Node0, Node1: Node {
DLL = DLL0
header = DLL0->Node1
Node = Node0 + Node1
no pre
nxt = Node0->Node1 + Node1->Node0
elem = Node0->-7 + Node1->-8
}}
}
run test46 for 3 expect 0
pred test40 {
some disj DLL0: DLL {some disj Node0, Node1, Node2: Node {
DLL = DLL0
header = DLL0->Node2
Node = Node0 + Node1 + Node2
pre = Node0->Node2 + Node1->Node0
nxt = Node0->Node1 + Node2->Node0
elem = Node0->7 + Node1->-7 + Node2->-8
ConsistentPreAndNxt[]
}}
}
run test40 for 3 expect 1
|
src/tcl-variables.adb | thindil/tashy2 | 2 | 17733 | <filename>src/tcl-variables.adb
-- Copyright (c) 2020 <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 Interfaces.C; use Interfaces.C;
with Interfaces.C.Strings; use Interfaces.C.Strings;
with Tashy2; use Tashy2;
package body Tcl.Variables is
-- ****if* Variables/Variables.Create_Flag
-- FUNCTION
-- Create C flag for the manipulating Tcl variables
-- PARAMETERS
-- Flags - Ada array with flags which will be added to the Tcl variable
-- manipulation subprogram
-- RESULT
-- C flag from the selected array
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
function Create_Flag(Flags: Flags_Array) return int is
-- ****
type Unsigned_Integer is mod 4_096;
Default_Unsigned_Integer: constant Unsigned_Integer := 0;
Flag: Unsigned_Integer := Default_Unsigned_Integer;
begin
Set_Flags_Loop :
for Value of Flags loop
Flag := Flag or Variables_Flags'Enum_Rep(Value);
end loop Set_Flags_Loop;
return int(Flag);
end Create_Flag;
function Tcl_Set_Var
(Var_Name, New_Value: String;
Interpreter: Tcl_Interpreter := Get_Interpreter;
Flags: Flags_Array := Default_Flags_Array) return Boolean is
function Tcl_Set_Var_C
(Interp: Tcl_Interpreter; Var_Name_C, New_Value_C: chars_ptr;
Flags_C: int) return chars_ptr with
Global => null,
Import,
Convention => C,
External_Name => "Tcl_SetVar";
Result: constant String :=
From_C_String
(Item =>
Tcl_Set_Var_C
(Interp => Interpreter,
Var_Name_C => To_C_String(Str => Var_Name),
New_Value_C => To_C_String(Str => New_Value),
Flags_C => Create_Flag(Flags => Flags)));
begin
if Result'Length = 0 then
return False;
end if;
return True;
end Tcl_Set_Var;
function Tcl_Set_Var2
(Array_Name, Index_Name, New_Value: String;
Interpreter: Tcl_Interpreter := Get_Interpreter;
Flags: Flags_Array := Default_Flags_Array) return Boolean is
function Tcl_Set_Var2_C
(Interp: Tcl_Interpreter; Name1, Name2, New_Value_C: chars_ptr;
Flags_C: int) return chars_ptr with
Global => null,
Import,
Convention => C,
External_Name => "Tcl_SetVar2";
Result: constant String :=
From_C_String
(Item =>
Tcl_Set_Var2_C
(Interp => Interpreter, Name1 => To_C_String(Str => Array_Name),
Name2 => To_C_String(Str => Index_Name),
New_Value_C => To_C_String(Str => New_Value),
Flags_C => Create_Flag(Flags => Flags)));
begin
if Result'Length = 0 then
return False;
end if;
return True;
end Tcl_Set_Var2;
function Tcl_Get_Var
(Var_Name: String; Interpreter: Tcl_Interpreter := Get_Interpreter;
Flags: Flags_Array := Default_Flags_Array) return String is
function Tcl_Get_Var_C
(Interp: Tcl_Interpreter; Var_Name_C: chars_ptr; Flags_C: int)
return chars_ptr with
Global => null,
Import,
Convention => C,
External_Name => "Tcl_GetVar";
Result: constant chars_ptr :=
Tcl_Get_Var_C
(Interp => Interpreter, Var_Name_C => To_C_String(Str => Var_Name),
Flags_C => Create_Flag(Flags => Flags));
begin
if Result = Null_Ptr then
return "";
end if;
return From_C_String(Item => Result);
end Tcl_Get_Var;
function Generic_Scalar_Tcl_Get_Var
(Var_Name: String; Interpreter: Tcl_Interpreter := Get_Interpreter;
Flags: Flags_Array := Default_Flags_Array) return Result_Type is
begin
return
Result_Type'Value
(Tcl_Get_Var
(Var_Name => Var_Name, Interpreter => Interpreter,
Flags => Flags));
end Generic_Scalar_Tcl_Get_Var;
function Generic_Float_Tcl_Get_Var
(Var_Name: String; Interpreter: Tcl_Interpreter := Get_Interpreter;
Flags: Flags_Array := Default_Flags_Array) return Result_Type is
begin
return
Result_Type'Value
(Tcl_Get_Var
(Var_Name => Var_Name, Interpreter => Interpreter,
Flags => Flags));
end Generic_Float_Tcl_Get_Var;
function Tcl_Get_Var2
(Var_Name, Index_Name: String;
Interpreter: Tcl_Interpreter := Get_Interpreter;
Flags: Flags_Array := Default_Flags_Array) return String is
function Tcl_Get_Var2_C
(Interp: Tcl_Interpreter; Var_Name_C, Index_Name_C: chars_ptr;
Flags_C: int) return chars_ptr with
Global => null,
Import,
Convention => C,
External_Name => "Tcl_GetVar2";
Result: constant chars_ptr :=
Tcl_Get_Var2_C
(Interp => Interpreter, Var_Name_C => To_C_String(Str => Var_Name),
Index_Name_C => To_C_String(Str => Index_Name),
Flags_C => Create_Flag(Flags => Flags));
begin
if Result = Null_Ptr then
return "";
end if;
return From_C_String(Item => Result);
end Tcl_Get_Var2;
function Generic_Scalar_Tcl_Get_Var2
(Var_Name, Index_Name: String;
Interpreter: Tcl_Interpreter := Get_Interpreter;
Flags: Flags_Array := Default_Flags_Array) return Result_Type is
begin
return
Result_Type'Value
(Tcl_Get_Var2
(Var_Name => Var_Name, Index_Name => Index_Name,
Interpreter => Interpreter, Flags => Flags));
end Generic_Scalar_Tcl_Get_Var2;
function Generic_Float_Tcl_Get_Var2
(Var_Name, Index_Name: String;
Interpreter: Tcl_Interpreter := Get_Interpreter;
Flags: Flags_Array := Default_Flags_Array) return Result_Type is
begin
return
Result_Type'Value
(Tcl_Get_Var2
(Var_Name => Var_Name, Index_Name => Index_Name,
Interpreter => Interpreter, Flags => Flags));
end Generic_Float_Tcl_Get_Var2;
function Tcl_Unset_Var
(Var_Name: String; Interpreter: Tcl_Interpreter := Get_Interpreter;
Flags: Flags_Array := Default_Flags_Array) return Boolean is
function Tcl_Unset_Var_C
(Interp: Tcl_Interpreter; Var_Name_C: chars_ptr; Flags_C: int)
return int with
Global => null,
Import,
Convention => C,
External_Name => "Tcl_UnsetVar";
begin
if Tcl_Unset_Var_C
(Interp => Interpreter, Var_Name_C => To_C_String(Str => Var_Name),
Flags_C => Create_Flag(Flags => Flags)) =
int(Tcl_Results'Enum_Rep(TCL_ERROR)) then
return False;
end if;
return True;
end Tcl_Unset_Var;
function Tcl_Unset_Var2
(Var_Name, Index_Name: String;
Interpreter: Tcl_Interpreter := Get_Interpreter;
Flags: Flags_Array := Default_Flags_Array) return Boolean is
function Tcl_Unset_Var2_C
(Interp: Tcl_Interpreter; Var_Name_C, Index_Name_C: chars_ptr;
Flags_C: int) return int with
Global => null,
Import,
Convention => C,
External_Name => "Tcl_UnsetVar2";
begin
if Tcl_Unset_Var2_C
(Interp => Interpreter, Var_Name_C => To_C_String(Str => Var_Name),
Index_Name_C => To_C_String(Str => Index_Name),
Flags_C => Create_Flag(Flags => Flags)) =
int(Tcl_Results'Enum_Rep(TCL_ERROR)) then
return False;
end if;
return True;
end Tcl_Unset_Var2;
end Tcl.Variables;
|
source/RASCAL-FileInternal.adb | bracke/Meaning | 0 | 7683 | <filename>source/RASCAL-FileInternal.adb
--------------------------------------------------------------------------------
-- --
-- Copyright (C) 2004, RISC OS Ada Library (RASCAL) developers. --
-- --
-- This library is free software; you can redistribute it and/or --
-- modify it under the terms of the GNU Lesser General Public --
-- License as published by the Free Software Foundation; either --
-- version 2.1 of the License, or (at your option) any later version. --
-- --
-- This library is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- Lesser General Public License for more details. --
-- --
-- You should have received a copy of the GNU Lesser General Public --
-- License along with this library; if not, write to the Free Software --
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --
-- --
--------------------------------------------------------------------------------
-- $Author$
-- $Date$
-- $Revision$
with RASCAL.OS;
with Ada.Strings; use Ada.Strings;
with Kernel; use Kernel;
with System.Storage_Elements; use System.Storage_Elements;
with Interfaces.C; use Interfaces.C;
with Reporter;
package body RASCAL.FileInternal is
-- Constants
OS_Find : constant := 16#0D#;
OS_BGet : constant := 16#0A#;
OS_BPut : constant := 16#0B#;
OS_Args : constant := 16#09#;
OS_File : constant := 16#08#;
OS_FSControl : constant := 16#29#;
OS_GBPB : constant := 16#0C#;
-- Methods
procedure Skip_EmptyLines (File : in FileHandle_Type) is
str : Unbounded_String;
Start : Integer;
begin
start := FileInternal.Get_Ptr(File);
str := U(Read_Line (File,true));
loop
exit when Length(str)>0;
exit when Is_EOF (File);
start := FileInternal.Get_Ptr(File);
str := U(Read_Line (File,true));
end loop;
if Length(str)>0 then
FileInternal.Set_Ptr(File,Start);
end if;
end Skip_EmptyLines;
--
procedure Close (File : in FileHandle_Type) is
Register : aliased Kernel.swi_regs;
Error : oserror_access; begin
Register.R(0) := 0;
Register.R(1) := int(File.Handle);
Error := Kernel.swi (OS_Find,Register'access,Register'access);
end Close;
--
procedure Goto_End (File : in FileHandle_Type) is
begin
Set_Ptr(File,Get_Extent(File));
end Goto_End;
--
function Is_EOF (File : in FileHandle_Type) return boolean is
Register : aliased Kernel.swi_regs;
Error : oserror_access;
begin Register.R(0) := 5;
Register.R(1) := int(File.Handle);
Error := Kernel.SWI (OS_Args,Register'access,Register'access);
if Error /= null then
pragma Debug(Reporter.Report("FileInternal.Is_EOF: " & To_Ada(Error.ErrMess)));
OS.Raise_Error(Error);
end if;
if Register.R(2) = 0 then
return false;
else
return true;
end if;
end Is_EOF;
--
function Get_Extent (File : in FileHandle_Type) return natural is
Register : aliased Kernel.swi_regs;
Error : oserror_access;
begin
Register.R(0) := 2;
Register.R(1) := int(File.Handle);
Error := Kernel.SWI (OS_Args,Register'access,Register'access);
if Error /= null then
pragma Debug(Reporter.Report("FileInternal.Get_Extent: " & To_Ada(Error.ErrMess)));
OS.Raise_Error(Error);
end if;
return natural(Register.R(2));
end Get_Extent;
--
procedure Goto_Start (File : in FileHandle_Type) is
begin
Set_Ptr(File,0);
end Goto_Start;
--
function Get_Ptr (File : in FileHandle_Type) return Integer is
Register : aliased Kernel.swi_regs;
Error : oserror_access;
begin
Register.R(0) := 0;
Register.R(1) := int(File.Handle);
Error := Kernel.SWI (OS_Args,Register'access,Register'access);
if Error /= null then
pragma Debug(Reporter.Report("FileInternal.Get_Ptr: " & To_Ada(Error.ErrMess)));
OS.Raise_Error(Error);
end if;
return Integer(Register.R(2));
end Get_Ptr;
--
procedure Set_Ptr (File : in FileHandle_Type;
Ptr : in integer) is
Register : aliased Kernel.swi_regs;
Error : oserror_access;
begin
Register.R(0) := 1;
Register.R(1) := int(File.Handle);
Register.R(2) := int(Ptr);
Error := Kernel.SWI (OS_Args,Register'access,Register'access);
if Error /= null then
pragma Debug(Reporter.Report("FileInternal.Set_Ptr: " & To_Ada(Error.ErrMess)));
OS.Raise_Error(Error);
end if;
end Set_Ptr;
--
function Get_Byte (File : in FileHandle_Type) return Integer is
Register : aliased Kernel.swi_regs;
Error : oserror_access;
begin
if Is_EOF(File) then
return -1;
else
Register.R(1) := int(File.Handle);
Error := Kernel.SWI (OS_BGet,Register'access,Register'access);
if Error /= null then
pragma Debug(Reporter.Report("FileInternal.Get_Byte: " & To_Ada(Error.ErrMess)));
OS.Raise_Error(Error);
end if;
return Integer(Register.R(0));
end if;
end Get_Byte;
--
procedure Put_Byte (File : in FileHandle_Type;
Byte : in Integer) is
Register : aliased Kernel.swi_regs;
Error : oserror_access;
begin
Register.R(0) := int(Byte);
Register.R(1) := int(File.Handle);
Error := Kernel.SWI (OS_BPut,Register'access,Register'access);
if Error /= null then
pragma Debug(Reporter.Report("FileInternal.Put_Byte: " & To_Ada(Error.ErrMess)));
OS.Raise_Error(Error);
end if;
end Put_Byte;
--
procedure Skip_Bytes (File : in FileHandle_Type;
Nr : in Integer) is
Current_ptr : Integer;
Register : aliased Kernel.swi_regs;
Error : oserror_access;
begin
Current_ptr := Get_Ptr(File);
Register.R(0) := 1;
Register.R(1) := int(File.Handle);
Register.R(2) := int(Current_ptr + Nr);
Error := Kernel.SWI (OS_Args,Register'access,Register'access);
if Error /= null then
pragma Debug(Reporter.Report("FileInternal.Skip_Bytes: " & To_Ada(Error.ErrMess)));
OS.Raise_Error(Error);
end if;
end Skip_Bytes;
--
procedure Put_String (File : in FileHandle_Type;
Line : in String;
Attach_LF : in Boolean := true) is
Register : aliased Kernel.swi_regs;
Error : oserror_access;
Line_0 : String := Line & Character'Val(10);
begin
Register.R(0) := 2;
Register.R(1) := int(File.Handle);
Register.R(2) := Adr_To_Int(Line_0'Address);
if Attach_LF then
Register.R(3) := int(Line_0'length);
else
Register.R(3) := int(Line_0'length-1);
end if;
Error := Kernel.swi (OS_GBPB,register'Access,register'Access);
if Error /= null then
pragma Debug(Reporter.Report("FileInternal.Put_String: " & To_Ada(Error.ErrMess)));
OS.Raise_Error(Error);
end if;
end Put_String;
--
function Get_Lines (File : in FileHandle_Type;
Trim : in boolean := true) return integer is
Lines : integer := 0;
Point : integer := 0;
Str : Unbounded_String;
begin
Goto_Start(File);
Point := Get_Ptr(File);
while not Is_EOF(File) loop
Str := U(Read_Line(File));
if Trim then
Ada.Strings.Unbounded.Trim(Str,Both);
end if;
if Length(Str)>0 then
Lines := Lines + 1;
end if;
end loop;
Set_Ptr(File,Point);
return Lines;
end Get_Lines;
--
function Read_Line (File : in FileHandle_Type;
Trim : in boolean := false) return String is
Register : aliased Kernel.SWI_regs;
Error : oserror_access;
C : character;
Line : UString := U("");
Index : integer := 0;
begin
Read_Until_EOL:
loop
Register.R(0) := 4;
Register.R(1) := int(File.Handle);
Register.R(2) := Adr_To_Int(C'address);
Register.R(3) := 1;
Register.R(4) := int(Index);
Error := Kernel.SWI (OS_GBPB,Register'access,Register'access);
if Error /= null then
pragma Debug(Reporter.Report("FileInternal.Read_Line: " & To_Ada(Error.ErrMess)));
OS.Raise_Error(Error);
end if;
if Register.R(3) /= 0 then
exit Read_Until_EOL;
end if;
if c /=Character'Val(10) then
Line := Line & C;
else
exit Read_Until_EOL;
end if;
index := Integer(Register.R(4));
end loop Read_Until_EOL;
if Trim then
Ada.Strings.Unbounded.Trim(Line,both);
end if;
return S(Line);
end Read_Line;
--
procedure Ensure_Size (File : in FileHandle_Type;
Size : in Integer) is
Register : aliased Kernel.swi_regs;
Error : oserror_access;
begin
Register.R(0) := 6;
Register.R(1) := int(File.Handle);
Register.R(2) := int(Size);
Error := Kernel.SWI (OS_Args,Register'access,Register'access);
if Error /= null then
pragma Debug(Reporter.Report("FileInternal.Ensure_Size: " & To_Ada(Error.ErrMess)));
OS.Raise_Error(Error);
end if;
end Ensure_Size;
--
procedure Load_File (FileName : in String;
Buffer : in Address) is
Register : aliased Kernel.swi_regs;
Error : oserror_access;
FileName_0 : string := FileName & ASCII.NUL;
begin
Register.R(0) := 16;
Register.R(1) := Adr_To_Int(FileName_0'address);
Register.R(2) := Adr_To_Int(Buffer);
Register.R(3) := 0;
Error := Kernel.SWI (OS_File,Register'access,Register'access);
if Error /= null then
pragma Debug(Reporter.Report("FileInternal.Load_File: " & To_Ada(Error.ErrMess)));
OS.Raise_Error(Error);
end if;
end Load_File;
--
procedure Save_File (FileName : in String;
Buffer : in Address;
Bufferend : in Address;
FileType : in Integer) is
Register : aliased Kernel.swi_regs;
Error : oserror_access;
FileName_0 : String := FileName & ASCII.NUL;
begin
Register.R(0) := 10;
Register.R(1) := Adr_To_Int(FileName_0'address);
Register.R(2) := int(FileType);
Register.R(3) := 0;
Register.R(4) := Adr_To_Int(Buffer);
Register.R(5) := Adr_To_Int(Bufferend);
Error := Kernel.SWI (OS_File,Register'access,Register'access);
if Error /= null then
pragma Debug(Reporter.Report("FileInternal.Save_File: " & To_Ada(Error.ErrMess)));
OS.Raise_Error(Error);
end if;
end Save_File;
--
procedure Get_Bytes (File : in FileHandle_Type;
Buffer : in Address;
Length : in Integer) is
Register : aliased Kernel.swi_regs;
Error : oserror_access;
begin
Register.R(0) := 4;
Register.R(1) := int(File.Handle);
Register.R(2) := Adr_To_Int(Buffer);
Register.R(3) := int(Length);
Error := Kernel.SWI (OS_GBPB,register'Access,register'Access);
if Error /= null then
pragma Debug(Reporter.Report("FileInternal.Get_Bytes: " & To_Ada(Error.ErrMess)));
OS.Raise_Error(Error);
end if;
end Get_Bytes;
--
procedure Put_Bytes (File : in FileHandle_Type;
Buffer : in Address;
Length : in Integer) is
Register : aliased Kernel.swi_regs;
Error : oserror_access;
begin
Register.R(0) := 2;
Register.R(1) := int(File.Handle);
Register.R(2) := Adr_To_Int(Buffer);
Register.R(3) := int(Length);
Error := Kernel.swi (OS_GBPB,Register'access,Register'access);
if Error /= null then
pragma Debug(Reporter.Report("FileInternal.Put_Bytes: " & To_Ada(Error.ErrMess)));
OS.Raise_Error(Error);
end if;
end Put_Bytes;
--
function Get_Real_FileHandle (File : in FileHandle_Type) return Real_FileHandle_Type is begin
return File.Handle;
end Get_Real_FileHandle;
-- Private methods
function OpenIn (FileName : in String) return Real_FileHandle_Type is
Error : oserror_access;
Register : aliased Kernel.swi_regs;
Reasoncode : constant := 16#4B#;
FileName_0 : String := FileName & ASCII.NUL;
begin
Register.R(0) := Reasoncode;
Register.R(1) := int(To_Integer(FileName_0'address));
Error := Kernel.swi (OS_Find,register'Access,register'Access);
if Error /= NULL then
pragma Debug(Reporter.Report("FileInternal.OpenIn: " & To_Ada(Error.ErrMess)));
OS.Raise_Error(Error);
else
return Real_FileHandle_Type(Register.R(0));
end if;
end OpenIn;
--
function OpenOut (FileName : in String) return Real_FileHandle_Type is
Error : oserror_access;
Register : aliased Kernel.swi_regs;
Reasoncode : constant := 16#8B#;
FileName_0 : string := FileName & ASCII.NUL;
begin
Register.R(0) := Reasoncode;
Register.R(1) := Adr_To_Int(FileName_0'address);
Error := Kernel.SWI (OS_Find,Register'access,Register'access);
if Error /= null then
pragma Debug(Reporter.Report("FileInternal.OpenOut: " & To_Ada(Error.ErrMess)));
OS.Raise_Error(Error);
else
return Real_FileHandle_Type(Register.R(0));
end if;
end OpenOut;
--
function OpenUp (FileName : in String) return Real_FileHandle_Type is
Error : oserror_access;
Register : aliased Kernel.swi_regs;
Reasoncode : constant := 16#CB#;
FileName_0 : string := FileName & ASCII.NUL;
begin
Register.R(0) := Reasoncode;
Register.R(1) := Adr_To_Int(FileName_0'address);
Error := Kernel.SWI (OS_Find,Register'access,Register'access);
if Error /= NULL then
return OpenOut (FileName);
else
return Real_FileHandle_Type(Register.R(0));
end if;
end OpenUp;
-- Finalization methods
procedure Initialize (The : in out FileHandle_Type) is
begin
case The.Access_Type is
when Read => The.Handle := OpenIn(S(The.Path));
when Write => The.Handle := OpenOut(S(The.Path));
when ReadWrite => The.Handle := OpenUp(S(The.Path));
end case;
end Initialize;
--
procedure Finalize (The : in out FileHandle_Type) is
begin
if The.Handle /= -1 then
Close (The);
The.Handle := -1;
end if;
end Finalize;
--
end RASCAL.FileInternal;
|
programs/oeis/074/A074526.asm | jmorken/loda | 1 | 103377 | ; A074526: a(n) = 2^n + 3^n + 4^n.
; 3,9,29,99,353,1299,4889,18699,72353,282339,1108649,4373499,17312753,68711379,273234809,1088123499,4338079553,17309140419,69107159369,276040692699,1102999460753,4408508961459,17623571298329,70462895745099,281757423024353,1126747229006499,4506141560307689
mov $4,$0
mov $0,4
mov $1,2
mov $3,$4
lpb $0
mov $2,1
mov $4,$0
sub $0,1
pow $4,$3
add $2,$4
add $1,$2
lpe
sub $1,10
div $1,2
mul $1,2
add $1,3
|
oeis/166/A166457.asm | neoneye/loda-programs | 11 | 177289 | <reponame>neoneye/loda-programs
; A166457: Numbers n such that n*100+1 is prime.
; Submitted by <NAME>
; 1,4,6,7,12,13,16,18,19,28,30,33,37,40,42,48,51,55,57,58,61,63,67,70,79,81,85,90,96,99,103,105,106,117,118,121,123,124,126,130,139,144,151,154,156,159,160,163,169,174,183,184,187,190,193,195,198,201,202,210,211,214,216,217,225,229,232,238,240,253,256,258,265,267,268,277,279,280,282,289,291,292,294,295,316,324,328,333,336,343,345,352,354,358,369,372,375,382,385,393
mov $2,$0
add $2,2
pow $2,2
lpb $2
mov $3,$1
add $1,26
seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0.
sub $0,$3
add $1,74
mov $4,$0
max $4,0
cmp $4,$0
mul $2,$4
sub $2,1
lpe
mov $0,$1
div $0,100
|
tools/akt-commands-password.adb | thierr26/ada-keystore | 25 | 16035 | <reponame>thierr26/ada-keystore
-----------------------------------------------------------------------
-- akt-commands-password -- Add/Change/Remove the wallet password
-- Copyright (C) 2019 <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 Keystore.Passwords.Files;
with Keystore.Passwords.Unsafe;
with Keystore.Passwords.Input;
package body AKT.Commands.Password is
package KP renames Keystore.Passwords;
use GNAT.Strings;
use type Keystore.Passwords.Provider_Access;
use type Keystore.Header_Slot_Count_Type;
-- ------------------------------
-- Create the keystore file.
-- ------------------------------
overriding
procedure Execute (Command : in out Command_Type;
Name : in String;
Args : in Argument_List'Class;
Context : in out Context_Type) is
pragma Unreferenced (Name);
Config : Keystore.Wallet_Config := Keystore.Secure_Config;
New_Password_Provider : Keystore.Passwords.Provider_Access;
begin
Setup_Password_Provider (Context);
Setup_Key_Provider (Context);
if Command.Counter_Range /= null and then Command.Counter_Range'Length > 0 then
Parse_Range (Command.Counter_Range.all, Config);
end if;
if Command.Gpg_User'Length > 0 then
declare
GPG : Keystore.Passwords.GPG.Context_Type;
begin
AKT.Commands.Initialize (GPG);
GPG.Create_Secret (Context.Key_Provider.all);
Context.Change_Password (Args => Args,
New_Password => <PASSWORD>,
Config => Config,
Mode => Command.Mode);
GPG.Save_Secret (User => Command.Gpg_User.all,
Index => Context.Info.Header_Count + 1,
Wallet => Context.Wallet);
end;
else
if Context.Provider = null then
Context.Provider := KP.Input.Create (-("Enter password: "), False);
end if;
if Command.Password_File'Length > 0 then
New_Password_Provider := KP.Files.Create (Command.Password_File.all);
elsif Command.Unsafe_Password'Length > 0 then
New_Password_Provider := KP.Unsafe.Create (Command.Unsafe_Password.all);
else
New_Password_Provider := KP.Input.Create (-("New password: "), False);
end if;
Context.Change_Password (Args => Args,
New_Password => New_Password_Provider.all,
Config => Config,
Mode => Command.Mode);
end if;
end Execute;
-- ------------------------------
-- Setup the command before parsing the arguments and executing it.
-- ------------------------------
procedure Setup (Command : in out Command_Type;
Config : in out GNAT.Command_Line.Command_Line_Configuration;
Context : in out Context_Type) is
package GC renames GNAT.Command_Line;
begin
Setup (Config, Context);
GC.Define_Switch (Config => Config,
Output => Command.Counter_Range'Access,
Switch => "-c:",
Long_Switch => "--counter-range:",
Argument => "RANGE",
Help => -("Set the range for the PBKDF2 counter"));
GC.Define_Switch (Config => Config,
Output => Command.Password_File'Access,
Long_Switch => "--new-passfile=",
Argument => "PATH",
Help => -("Read the file that contains the password"));
GC.Define_Switch (Config => Config,
Output => Command.Unsafe_Password'Access,
Long_Switch => "--new-passfd=",
Argument => "NUM",
Help => -("Read the password from the pipe with"
& " the given file descriptor"));
GC.Define_Switch (Config => Config,
Output => Command.Unsafe_Password'Access,
Long_Switch => "--new-passsocket=",
Help => -("The password is passed within the socket connection"));
GC.Define_Switch (Config => Config,
Output => Command.Password_Env'Access,
Long_Switch => "--new-passenv=",
Argument => "NAME",
Help => -("Read the environment variable that contains"
& " the password (not safe)"));
GC.Define_Switch (Config => Config,
Output => Command.Unsafe_Password'Access,
Long_Switch => "--new-password=",
Help => -("The password is passed within the command line (not safe)"));
GC.Define_Switch (Config => Config,
Output => Command.Gpg_User'Access,
Switch => "-g:",
Long_Switch => "--gpg=",
Argument => "USER",
Help => -("Use gpg to protect the keystore access"));
end Setup;
end AKT.Commands.Password;
|
oeis/195/A195048.asm | neoneye/loda-programs | 11 | 178722 | <gh_stars>10-100
; A195048: Concentric 19-gonal numbers.
; 0,1,19,39,76,115,171,229,304,381,475,571,684,799,931,1065,1216,1369,1539,1711,1900,2091,2299,2509,2736,2965,3211,3459,3724,3991,4275,4561,4864,5169,5491,5815,6156,6499,6859,7221,7600,7981,8379,8779,9196,9615,10051,10489,10944,11401,11875,12351,12844,13339,13851,14365,14896,15429,15979,16531,17100,17671,18259,18849,19456,20065,20691,21319,21964,22611,23275,23941,24624,25309,26011,26715,27436,28159,28899,29641,30400,31161,31939,32719,33516,34315,35131,35949,36784,37621,38475,39331,40204,41079
pow $0,2
mov $1,$0
div $0,4
mul $0,15
add $0,$1
|
test/asset/agda-stdlib-1.0/Data/Container/Indexed.agda | omega12345/agda-mode | 0 | 15156 | <reponame>omega12345/agda-mode<gh_stars>0
------------------------------------------------------------------------
-- The Agda standard library
--
-- Indexed containers aka interaction structures aka polynomial
-- functors. The notation and presentation here is closest to that of
-- Hancock and Hyvernat in "Programming interfaces and basic topology"
-- (2006/9).
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe --guardedness #-}
module Data.Container.Indexed where
open import Level
open import Codata.Musical.M.Indexed
open import Data.Product as Prod hiding (map)
open import Data.W.Indexed
open import Function renaming (id to ⟨id⟩; _∘_ to _⟨∘⟩_)
open import Function.Equality using (_⟨$⟩_)
open import Function.Inverse using (_↔_; module Inverse)
open import Relation.Unary using (Pred; _⊆_)
import Relation.Binary as B
open import Relation.Binary.PropositionalEquality as P using (_≡_; _≗_; refl)
------------------------------------------------------------------------
-- The type and its semantics ("extension").
open import Data.Container.Indexed.Core public
open Container public
-- Abbreviation for the commonly used level one version of indexed
-- containers.
_▷_ : Set → Set → Set₁
I ▷ O = Container I O zero zero
-- The least and greatest fixpoint.
μ ν : ∀ {o c r} {O : Set o} → Container O O c r → Pred O _
μ = W
ν = M
-- An equivalence relation is defined in Data.Container.Indexed.WithK.
------------------------------------------------------------------------
-- Functoriality
-- Indexed containers are functors.
map : ∀ {i o c r ℓ₁ ℓ₂} {I : Set i} {O : Set o}
(C : Container I O c r) {X : Pred I ℓ₁} {Y : Pred I ℓ₂} →
X ⊆ Y → ⟦ C ⟧ X ⊆ ⟦ C ⟧ Y
map _ f = Prod.map ⟨id⟩ (λ g → f ⟨∘⟩ g)
-- Some properties are proved in Data.Container.Indexed.WithK.
------------------------------------------------------------------------
-- Container morphisms
module _ {i₁ i₂ o₁ o₂}
{I₁ : Set i₁} {I₂ : Set i₂} {O₁ : Set o₁} {O₂ : Set o₂} where
-- General container morphism.
record ContainerMorphism {c₁ c₂ r₁ r₂ ℓ₁ ℓ₂}
(C₁ : Container I₁ O₁ c₁ r₁) (C₂ : Container I₂ O₂ c₂ r₂)
(f : I₁ → I₂) (g : O₁ → O₂)
(_∼_ : B.Rel I₂ ℓ₁) (_≈_ : B.REL (Set r₂) (Set r₁) ℓ₂)
(_·_ : ∀ {A B} → A ≈ B → A → B) :
Set (i₁ ⊔ i₂ ⊔ o₁ ⊔ o₂ ⊔ c₁ ⊔ c₂ ⊔ r₁ ⊔ r₂ ⊔ ℓ₁ ⊔ ℓ₂) where
field
command : Command C₁ ⊆ Command C₂ ⟨∘⟩ g
response : ∀ {o} {c₁ : Command C₁ o} →
Response C₂ (command c₁) ≈ Response C₁ c₁
coherent : ∀ {o} {c₁ : Command C₁ o} {r₂ : Response C₂ (command c₁)} →
f (next C₁ c₁ (response · r₂)) ∼ next C₂ (command c₁) r₂
open ContainerMorphism public
-- Plain container morphism.
_⇒[_/_]_ : ∀ {c₁ c₂ r₁ r₂} →
Container I₁ O₁ c₁ r₁ → (I₁ → I₂) → (O₁ → O₂) →
Container I₂ O₂ c₂ r₂ → Set _
C₁ ⇒[ f / g ] C₂ = ContainerMorphism C₁ C₂ f g _≡_ (λ R₂ R₁ → R₂ → R₁) _$_
-- Linear container morphism.
_⊸[_/_]_ : ∀ {c₁ c₂ r₁ r₂} →
Container I₁ O₁ c₁ r₁ → (I₁ → I₂) → (O₁ → O₂) →
Container I₂ O₂ c₂ r₂ → Set _
C₁ ⊸[ f / g ] C₂ = ContainerMorphism C₁ C₂ f g _≡_ _↔_
(λ r₂↔r₁ r₂ → Inverse.to r₂↔r₁ ⟨$⟩ r₂)
-- Cartesian container morphism.
_⇒C[_/_]_ : ∀ {c₁ c₂ r} →
Container I₁ O₁ c₁ r → (I₁ → I₂) → (O₁ → O₂) →
Container I₂ O₂ c₂ r → Set _
C₁ ⇒C[ f / g ] C₂ = ContainerMorphism C₁ C₂ f g _≡_ (λ R₂ R₁ → R₂ ≡ R₁)
(λ r₂≡r₁ r₂ → P.subst ⟨id⟩ r₂≡r₁ r₂)
-- Degenerate cases where no reindexing is performed.
module _ {i o c r} {I : Set i} {O : Set o} where
_⇒_ : B.Rel (Container I O c r) _
C₁ ⇒ C₂ = C₁ ⇒[ ⟨id⟩ / ⟨id⟩ ] C₂
_⊸_ : B.Rel (Container I O c r) _
C₁ ⊸ C₂ = C₁ ⊸[ ⟨id⟩ / ⟨id⟩ ] C₂
_⇒C_ : B.Rel (Container I O c r) _
C₁ ⇒C C₂ = C₁ ⇒C[ ⟨id⟩ / ⟨id⟩ ] C₂
------------------------------------------------------------------------
-- Plain morphisms
-- Interpretation of _⇒_.
⟪_⟫ : ∀ {i o c r ℓ} {I : Set i} {O : Set o} {C₁ C₂ : Container I O c r} →
C₁ ⇒ C₂ → (X : Pred I ℓ) → ⟦ C₁ ⟧ X ⊆ ⟦ C₂ ⟧ X
⟪ m ⟫ X (c , k) = command m c , λ r₂ →
P.subst X (coherent m) (k (response m r₂))
module PlainMorphism {i o c r} {I : Set i} {O : Set o} where
-- Identity.
id : (C : Container I O c r) → C ⇒ C
id _ = record
{ command = ⟨id⟩
; response = ⟨id⟩
; coherent = refl
}
-- Composition.
infixr 9 _∘_
_∘_ : {C₁ C₂ C₃ : Container I O c r} →
C₂ ⇒ C₃ → C₁ ⇒ C₂ → C₁ ⇒ C₃
f ∘ g = record
{ command = command f ⟨∘⟩ command g
; response = response g ⟨∘⟩ response f
; coherent = coherent g ⟨ P.trans ⟩ coherent f
}
-- Identity commutes with ⟪_⟫.
id-correct : ∀ {ℓ} {C : Container I O c r} → ∀ {X : Pred I ℓ} {o} →
⟪ id C ⟫ X {o} ≗ ⟨id⟩
id-correct _ = refl
-- More properties are proved in Data.Container.Indexed.WithK.
------------------------------------------------------------------------
-- Linear container morphisms
module LinearMorphism
{i o c r} {I : Set i} {O : Set o} {C₁ C₂ : Container I O c r}
(m : C₁ ⊸ C₂)
where
morphism : C₁ ⇒ C₂
morphism = record
{ command = command m
; response = _⟨$⟩_ (Inverse.to (response m))
; coherent = coherent m
}
⟪_⟫⊸ : ∀ {ℓ} (X : Pred I ℓ) → ⟦ C₁ ⟧ X ⊆ ⟦ C₂ ⟧ X
⟪_⟫⊸ = ⟪ morphism ⟫
open LinearMorphism public using (⟪_⟫⊸)
------------------------------------------------------------------------
-- Cartesian morphisms
module CartesianMorphism
{i o c r} {I : Set i} {O : Set o} {C₁ C₂ : Container I O c r}
(m : C₁ ⇒C C₂)
where
morphism : C₁ ⇒ C₂
morphism = record
{ command = command m
; response = P.subst ⟨id⟩ (response m)
; coherent = coherent m
}
⟪_⟫C : ∀ {ℓ} (X : Pred I ℓ) → ⟦ C₁ ⟧ X ⊆ ⟦ C₂ ⟧ X
⟪_⟫C = ⟪ morphism ⟫
open CartesianMorphism public using (⟪_⟫C)
------------------------------------------------------------------------
-- All and any
-- □ and ◇ are defined in the core module.
module _ {i o c r ℓ₁ ℓ₂} {I : Set i} {O : Set o} (C : Container I O c r)
{X : Pred I ℓ₁} {P Q : Pred (Σ I X) ℓ₂} where
-- All.
□-map : P ⊆ Q → □ C P ⊆ □ C Q
□-map P⊆Q = _⟨∘⟩_ P⊆Q
-- Any.
◇-map : P ⊆ Q → ◇ C P ⊆ ◇ C Q
◇-map P⊆Q = Prod.map ⟨id⟩ P⊆Q
-- Membership is defined in Data.Container.Indexed.WithK.
|
assignment4/execve-stack-rorxornotencoded.asm | gkweb76/SLAE | 15 | 103194 | ; Title: Execve ROR XOR NOT decoder shellcode
; File: execve-rorxornotencoded.asm
; Author: <NAME>
; SLAE-681
global _start
section .text
_start:
jmp short get_address ; JMP CALL POP method to get "encoded" address
shellcode:
pop esi ; retrieve encoded shellcode address
xor ecx, ecx
mov cl, len ; set the counter to encoded shellcode length
decoder: ; decoding of ROR/XOR/NOT starts end and decodes backward
not byte [esi] ; NOT current byte
xor byte [esi], 0xAA ; XOR 0xaa
rol byte [esi], 7 ; ROL 7: rotate left 7 bytes
inc esi
loop decoder ; loop until ecx = 0
jmp short encoded ; ecx = 0, jump to now decoded shellcode
get_address:
call shellcode
encoded: db 0x37,0xd4,0xf5,0x85,0x89,0x0b,0xb3,0x85,0x85,0x0b,0x0b,0x91,0x87,0x46,0x92,0xf5,0x46,0x90,0xf3,0x46,0x96,0x34,0x43,0xce,0x54
len equ $-encoded:
|
oeis/018/A018522.asm | neoneye/loda-programs | 11 | 4192 | <gh_stars>10-100
; A018522: Divisors of 567.
; Submitted by <NAME>(w3)
; 1,3,7,9,21,27,63,81,189,567
mov $1,$0
mov $2,1
lpb $0
sub $0,1
mov $4,$3
mul $3,$1
div $1,8
pow $3,$4
add $3,$2
add $4,1
add $2,$4
mul $2,$1
mul $4,3
add $2,$4
lpe
mov $0,$4
div $0,3
mul $0,2
add $0,1
|
test/Fail/Issue4924.agda | shlevy/agda | 1,989 | 14465 | module Issue4924 where
record R (T : Set) : Set where
field
f : T → T
module _ {A B : Set} (ra : R A) (rb : R B) (pri : {T : Set} → {{r : R T}} → T) where
open R ra
open R rb
instance
_ = ra
_ : A
_ = f pri
|
src/natools-web-filters-text_blocks.ads | faelys/natools-web | 1 | 15537 | <reponame>faelys/natools-web<gh_stars>1-10
------------------------------------------------------------------------------
-- Copyright (c) 2015, <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.Filters.Text_Blocks provides a basic filter to display "raw" --
-- text in HTML blocks. All active characters are escaped, and <P> tags are --
-- inserted, with blanks lines marking paragraph changes. Newline encoding --
-- is also normalized. --
------------------------------------------------------------------------------
with Natools.S_Expressions.Lockable;
package Natools.Web.Filters.Text_Blocks is
pragma Preelaborate;
type Newline_Encoding is (CR, LF, CR_LF);
type Filter is new Filters.Filter with private;
overriding procedure Apply
(Object : in Filter;
Output : in out Ada.Streams.Root_Stream_Type'Class;
Data : in Ada.Streams.Stream_Element_Array);
-- Transform Data into basic HTML and append it to Output
not overriding procedure Set_Newline_Encoding
(Object : in out Filter;
Encoding : in Newline_Encoding);
-- Set the output newline encoding
function Create
(Arguments : in out S_Expressions.Lockable.Descriptor'Class)
return Filters.Filter'Class;
-- Build a text block filter
private
type Filter is new Filters.Filter with record
Encoding : Newline_Encoding := LF;
end record;
end Natools.Web.Filters.Text_Blocks;
|
libsrc/_DEVELOPMENT/arch/sms/misc/c/sdcc_iy/sms_cxy2saddr_callee.asm | jpoikela/z88dk | 640 | 4720 | <gh_stars>100-1000
; unsigned int sms_cxy2saddr(unsigned char x, unsigned char y)
SECTION code_clib
SECTION code_arch
PUBLIC _sms_cxy2saddr_callee
EXTERN asm_sms_cxy2saddr
_sms_cxy2saddr_callee:
pop hl
ex (sp),hl
jp asm_sms_cxy2saddr
|
Transynther/x86/_processed/NONE/_xt_/i9-9900K_12_0xca_notsx.log_13307_1301.asm | ljhsiun2/medusa | 9 | 96608 | .global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r13
push %r15
push %r9
push %rcx
push %rdi
push %rsi
lea addresses_D_ht+0xebf5, %rsi
lea addresses_A_ht+0x141e4, %rdi
nop
nop
nop
nop
nop
lfence
mov $108, %rcx
rep movsl
nop
nop
sub %r9, %r9
lea addresses_D_ht+0xa2e4, %r13
and %rsi, %rsi
mov (%r13), %r10w
nop
cmp $55324, %rsi
lea addresses_UC_ht+0x34e4, %r9
nop
nop
nop
nop
and %rcx, %rcx
and $0xffffffffffffffc0, %r9
movaps (%r9), %xmm6
vpextrq $1, %xmm6, %r10
nop
nop
inc %rcx
lea addresses_WT_ht+0x16cee, %rsi
nop
nop
nop
nop
inc %rcx
mov (%rsi), %r13d
nop
nop
and $39102, %rcx
lea addresses_WC_ht+0xfae4, %rsi
lea addresses_UC_ht+0x974b, %rdi
nop
nop
nop
nop
nop
xor %r13, %r13
mov $38, %rcx
rep movsb
nop
and %r10, %r10
lea addresses_UC_ht+0x1d9ac, %rsi
nop
sub %r9, %r9
vmovups (%rsi), %ymm6
vextracti128 $1, %ymm6, %xmm6
vpextrq $0, %xmm6, %rcx
nop
nop
nop
nop
and $37831, %rsi
lea addresses_D_ht+0x180f4, %rsi
lea addresses_A_ht+0x1aee4, %rdi
cmp %r15, %r15
mov $97, %rcx
rep movsb
nop
nop
nop
nop
add $29548, %r13
lea addresses_WT_ht+0x4784, %rcx
nop
xor $52487, %r10
vmovups (%rcx), %ymm0
vextracti128 $1, %ymm0, %xmm0
vpextrq $0, %xmm0, %rsi
nop
nop
nop
nop
cmp $45024, %r13
lea addresses_A_ht+0x176dd, %rsi
lea addresses_D_ht+0xc7e4, %rdi
nop
dec %r11
mov $70, %rcx
rep movsw
nop
nop
nop
inc %r11
lea addresses_UC_ht+0x8997, %rdi
nop
nop
nop
nop
nop
inc %r10
movb (%rdi), %r15b
nop
nop
and $3839, %rdi
lea addresses_normal_ht+0x18ee4, %rsi
lea addresses_WT_ht+0xe002, %rdi
nop
nop
nop
add $42362, %r13
mov $81, %rcx
rep movsw
cmp %rcx, %rcx
lea addresses_WT_ht+0xe4e4, %r13
nop
add $43352, %r15
mov (%r13), %r11
nop
nop
nop
cmp %rcx, %rcx
pop %rsi
pop %rdi
pop %rcx
pop %r9
pop %r15
pop %r13
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r15
push %r8
push %rdi
push %rdx
push %rsi
// Store
lea addresses_PSE+0xbafc, %rsi
nop
sub %rdx, %rdx
movb $0x51, (%rsi)
nop
and %r10, %r10
// Store
mov $0x8bbe10000000f74, %rdi
nop
nop
nop
nop
inc %r15
movw $0x5152, (%rdi)
dec %rsi
// Store
lea addresses_D+0xcb13, %rsi
nop
cmp $26463, %r8
movw $0x5152, (%rsi)
add $49163, %r11
// Faulty Load
lea addresses_RW+0x138e4, %rdi
dec %rsi
mov (%rdi), %dx
lea oracles, %r15
and $0xff, %rdx
shlq $12, %rdx
mov (%r15,%rdx,1), %rdx
pop %rsi
pop %rdx
pop %rdi
pop %r8
pop %r15
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_RW', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_PSE', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 3}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_NC', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 4}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_D', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_RW', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'same': False, 'congruent': 0, 'type': 'addresses_D_ht'}, 'dst': {'same': False, 'congruent': 5, 'type': 'addresses_A_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 9}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': True, 'size': 16, 'congruent': 9}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 9, 'type': 'addresses_WC_ht'}, 'dst': {'same': False, 'congruent': 0, 'type': 'addresses_UC_ht'}}
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 2}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 2, 'type': 'addresses_D_ht'}, 'dst': {'same': False, 'congruent': 8, 'type': 'addresses_A_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 4}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 0, 'type': 'addresses_A_ht'}, 'dst': {'same': False, 'congruent': 7, 'type': 'addresses_D_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 0}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 8, 'type': 'addresses_normal_ht'}, 'dst': {'same': False, 'congruent': 0, 'type': 'addresses_WT_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 9}}
{'32': 13307}
32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
*/
|
src/test/ref/32bit-rols.asm | jbrandwood/kickc | 2 | 20989 | <reponame>jbrandwood/kickc
// Tests different rotate left commands
/// @file
/// Functions for performing input and output.
// Commodore 64 PRG executable file
.file [name="32bit-rols.prg", type="prg", segments="Program"]
.segmentdef Program [segments="Basic, Code, Data"]
.segmentdef Basic [start=$0801]
.segmentdef Code [start=$80d]
.segmentdef Data [startAfter="Code"]
.segment Basic
:BasicUpstart(__start)
.const LIGHT_BLUE = $e
.const OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS = 1
.const STACK_BASE = $103
.const SIZEOF_CHAR = 1
.const SIZEOF_STRUCT_PRINTF_BUFFER_NUMBER = $c
/// Color Ram
.label COLORRAM = $d800
/// Default address of screen character matrix
.label DEFAULT_SCREEN = $400
// The number of bytes on the screen
// The current cursor x-position
.label conio_cursor_x = $1b
// The current cursor y-position
.label conio_cursor_y = $11
// The current text cursor line start
.label conio_line_text = $14
// The current color cursor line start
.label conio_line_color = $12
.segment Code
__start: {
// __ma char conio_cursor_x = 0
lda #0
sta.z conio_cursor_x
// __ma char conio_cursor_y = 0
sta.z conio_cursor_y
// __ma char *conio_line_text = CONIO_SCREEN_TEXT
lda #<DEFAULT_SCREEN
sta.z conio_line_text
lda #>DEFAULT_SCREEN
sta.z conio_line_text+1
// __ma char *conio_line_color = CONIO_SCREEN_COLORS
lda #<COLORRAM
sta.z conio_line_color
lda #>COLORRAM
sta.z conio_line_color+1
// #pragma constructor_for(conio_c64_init, cputc, clrscr, cscroll)
jsr conio_c64_init
jsr main
rts
}
// Set initial cursor position
conio_c64_init: {
// Position cursor at current line
.label BASIC_CURSOR_LINE = $d6
// char line = *BASIC_CURSOR_LINE
ldx.z BASIC_CURSOR_LINE
// if(line>=CONIO_HEIGHT)
cpx #$19
bcc __b1
ldx #$19-1
__b1:
// gotoxy(0, line)
jsr gotoxy
// }
rts
}
// Output one character at the current cursor position
// Moves the cursor forward. Scrolls the entire screen if needed
// void cputc(__register(A) char c)
cputc: {
.const OFFSET_STACK_C = 0
tsx
lda STACK_BASE+OFFSET_STACK_C,x
// if(c=='\n')
cmp #'\n'
beq __b1
// conio_line_text[conio_cursor_x] = c
ldy.z conio_cursor_x
sta (conio_line_text),y
// conio_line_color[conio_cursor_x] = conio_textcolor
lda #LIGHT_BLUE
sta (conio_line_color),y
// if(++conio_cursor_x==CONIO_WIDTH)
inc.z conio_cursor_x
lda #$28
cmp.z conio_cursor_x
bne __breturn
// cputln()
jsr cputln
__breturn:
// }
rts
__b1:
// cputln()
jsr cputln
rts
}
main: {
.label __19 = $2c
.label i = $27
lda #0
sta.z i
__b2:
// clrscr()
jsr clrscr
// rol_fixed(vals[i])
lda.z i
asl
asl
sta.z __19
tay
lda vals,y
sta.z rol_fixed.val
lda vals+1,y
sta.z rol_fixed.val+1
lda vals+2,y
sta.z rol_fixed.val+2
lda vals+3,y
sta.z rol_fixed.val+3
jsr rol_fixed
__b3:
// kbhit()
jsr kbhit
// while(!kbhit())
cmp #0
beq __b3
// clrscr()
jsr clrscr
// ror_fixed(vals[i])
ldy.z __19
lda vals,y
sta.z ror_fixed.val
lda vals+1,y
sta.z ror_fixed.val+1
lda vals+2,y
sta.z ror_fixed.val+2
lda vals+3,y
sta.z ror_fixed.val+3
jsr ror_fixed
__b5:
// kbhit()
jsr kbhit
// while(!kbhit())
cmp #0
beq __b5
// clrscr()
jsr clrscr
// rol_var(vals[i])
ldy.z __19
lda vals,y
sta.z rol_var.val
lda vals+1,y
sta.z rol_var.val+1
lda vals+2,y
sta.z rol_var.val+2
lda vals+3,y
sta.z rol_var.val+3
jsr rol_var
__b7:
// kbhit()
jsr kbhit
// while(!kbhit())
cmp #0
beq __b7
// clrscr()
jsr clrscr
// ror_var(vals[i])
ldy.z __19
lda vals,y
sta.z ror_var.val
lda vals+1,y
sta.z ror_var.val+1
lda vals+2,y
sta.z ror_var.val+2
lda vals+3,y
sta.z ror_var.val+3
jsr ror_var
__b9:
// kbhit()
jsr kbhit
// while(!kbhit())
cmp #0
beq __b9
// i+1
ldx.z i
inx
// i = (i+1)&1
lda #1
sax.z i
jmp __b2
.segment Data
vals: .dword $deadbeef, $facefeed
}
.segment Code
// Set the cursor to the specified position
// void gotoxy(char x, __register(X) char y)
gotoxy: {
.const x = 0
.label __5 = $2a
.label __6 = $25
.label __7 = $25
.label line_offset = $25
.label __8 = $28
.label __9 = $25
// if(y>CONIO_HEIGHT)
cpx #$19+1
bcc __b2
ldx #0
__b2:
// conio_cursor_x = x
lda #x
sta.z conio_cursor_x
// conio_cursor_y = y
stx.z conio_cursor_y
// unsigned int line_offset = (unsigned int)y*CONIO_WIDTH
txa
sta.z __7
lda #0
sta.z __7+1
lda.z __7
asl
sta.z __8
lda.z __7+1
rol
sta.z __8+1
asl.z __8
rol.z __8+1
clc
lda.z __9
adc.z __8
sta.z __9
lda.z __9+1
adc.z __8+1
sta.z __9+1
asl.z line_offset
rol.z line_offset+1
asl.z line_offset
rol.z line_offset+1
asl.z line_offset
rol.z line_offset+1
// CONIO_SCREEN_TEXT + line_offset
lda.z line_offset
clc
adc #<DEFAULT_SCREEN
sta.z __5
lda.z line_offset+1
adc #>DEFAULT_SCREEN
sta.z __5+1
// conio_line_text = CONIO_SCREEN_TEXT + line_offset
lda.z __5
sta.z conio_line_text
lda.z __5+1
sta.z conio_line_text+1
// CONIO_SCREEN_COLORS + line_offset
lda.z __6
clc
adc #<COLORRAM
sta.z __6
lda.z __6+1
adc #>COLORRAM
sta.z __6+1
// conio_line_color = CONIO_SCREEN_COLORS + line_offset
lda.z __6
sta.z conio_line_color
lda.z __6+1
sta.z conio_line_color+1
// }
rts
}
// Print a newline
cputln: {
// conio_line_text += CONIO_WIDTH
lda #$28
clc
adc.z conio_line_text
sta.z conio_line_text
bcc !+
inc.z conio_line_text+1
!:
// conio_line_color += CONIO_WIDTH
lda #$28
clc
adc.z conio_line_color
sta.z conio_line_color
bcc !+
inc.z conio_line_color+1
!:
// conio_cursor_x = 0
lda #0
sta.z conio_cursor_x
// conio_cursor_y++;
inc.z conio_cursor_y
// cscroll()
jsr cscroll
// }
rts
}
// clears the screen and moves the cursor to the upper left-hand corner of the screen.
clrscr: {
.label line_text = $16
.label line_cols = $19
lda #<COLORRAM
sta.z line_cols
lda #>COLORRAM
sta.z line_cols+1
lda #<DEFAULT_SCREEN
sta.z line_text
lda #>DEFAULT_SCREEN
sta.z line_text+1
ldx #0
__b1:
// for( char l=0;l<CONIO_HEIGHT; l++ )
cpx #$19
bcc __b2
// conio_cursor_x = 0
lda #0
sta.z conio_cursor_x
// conio_cursor_y = 0
sta.z conio_cursor_y
// conio_line_text = CONIO_SCREEN_TEXT
lda #<DEFAULT_SCREEN
sta.z conio_line_text
lda #>DEFAULT_SCREEN
sta.z conio_line_text+1
// conio_line_color = CONIO_SCREEN_COLORS
lda #<COLORRAM
sta.z conio_line_color
lda #>COLORRAM
sta.z conio_line_color+1
// }
rts
__b2:
ldy #0
__b3:
// for( char c=0;c<CONIO_WIDTH; c++ )
cpy #$28
bcc __b4
// line_text += CONIO_WIDTH
lda #$28
clc
adc.z line_text
sta.z line_text
bcc !+
inc.z line_text+1
!:
// line_cols += CONIO_WIDTH
lda #$28
clc
adc.z line_cols
sta.z line_cols
bcc !+
inc.z line_cols+1
!:
// for( char l=0;l<CONIO_HEIGHT; l++ )
inx
jmp __b1
__b4:
// line_text[c] = ' '
lda #' '
sta (line_text),y
// line_cols[c] = conio_textcolor
lda #LIGHT_BLUE
sta (line_cols),y
// for( char c=0;c<CONIO_WIDTH; c++ )
iny
jmp __b3
}
// void rol_fixed(__zp($21) unsigned long val)
rol_fixed: {
.label val = $21
// printf("rol fixed\n")
lda #<s
sta.z printf_str.s
lda #>s
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 0, val<<0)
lda.z val
sta.z printf_ulong.uvalue
lda.z val+1
sta.z printf_ulong.uvalue+1
lda.z val+2
sta.z printf_ulong.uvalue+2
lda.z val+3
sta.z printf_ulong.uvalue+3
lda #<0
sta.z printf_sint.value
sta.z printf_sint.value+1
jsr printf_sint
// printf("%2d: %08lx\n", 0, val<<0)
lda #<s1
sta.z printf_str.s
lda #>s1
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 0, val<<0)
jsr printf_ulong
// printf("%2d: %08lx\n", 0, val<<0)
lda #<s2
sta.z printf_str.s
lda #>s2
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 1, val<<1)
lda.z val
asl
sta.z printf_ulong.uvalue
lda.z val+1
rol
sta.z printf_ulong.uvalue+1
lda.z val+2
rol
sta.z printf_ulong.uvalue+2
lda.z val+3
rol
sta.z printf_ulong.uvalue+3
lda #<1
sta.z printf_sint.value
lda #>1
sta.z printf_sint.value+1
jsr printf_sint
// printf("%2d: %08lx\n", 1, val<<1)
lda #<s1
sta.z printf_str.s
lda #>s1
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 1, val<<1)
jsr printf_ulong
// printf("%2d: %08lx\n", 1, val<<1)
lda #<s2
sta.z printf_str.s
lda #>s2
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 2, val<<2)
lda.z val
asl
sta.z printf_ulong.uvalue
lda.z val+1
rol
sta.z printf_ulong.uvalue+1
lda.z val+2
rol
sta.z printf_ulong.uvalue+2
lda.z val+3
rol
sta.z printf_ulong.uvalue+3
asl.z printf_ulong.uvalue
rol.z printf_ulong.uvalue+1
rol.z printf_ulong.uvalue+2
rol.z printf_ulong.uvalue+3
lda #<2
sta.z printf_sint.value
lda #>2
sta.z printf_sint.value+1
jsr printf_sint
// printf("%2d: %08lx\n", 2, val<<2)
lda #<s1
sta.z printf_str.s
lda #>s1
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 2, val<<2)
jsr printf_ulong
// printf("%2d: %08lx\n", 2, val<<2)
lda #<s2
sta.z printf_str.s
lda #>s2
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 3, val<<3)
lda.z val
asl
sta.z printf_ulong.uvalue
lda.z val+1
rol
sta.z printf_ulong.uvalue+1
lda.z val+2
rol
sta.z printf_ulong.uvalue+2
lda.z val+3
rol
sta.z printf_ulong.uvalue+3
asl.z printf_ulong.uvalue
rol.z printf_ulong.uvalue+1
rol.z printf_ulong.uvalue+2
rol.z printf_ulong.uvalue+3
asl.z printf_ulong.uvalue
rol.z printf_ulong.uvalue+1
rol.z printf_ulong.uvalue+2
rol.z printf_ulong.uvalue+3
lda #<3
sta.z printf_sint.value
lda #>3
sta.z printf_sint.value+1
jsr printf_sint
// printf("%2d: %08lx\n", 3, val<<3)
lda #<s1
sta.z printf_str.s
lda #>s1
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 3, val<<3)
jsr printf_ulong
// printf("%2d: %08lx\n", 3, val<<3)
lda #<s2
sta.z printf_str.s
lda #>s2
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 4, val<<4)
lda.z val
asl
sta.z printf_ulong.uvalue
lda.z val+1
rol
sta.z printf_ulong.uvalue+1
lda.z val+2
rol
sta.z printf_ulong.uvalue+2
lda.z val+3
rol
sta.z printf_ulong.uvalue+3
asl.z printf_ulong.uvalue
rol.z printf_ulong.uvalue+1
rol.z printf_ulong.uvalue+2
rol.z printf_ulong.uvalue+3
asl.z printf_ulong.uvalue
rol.z printf_ulong.uvalue+1
rol.z printf_ulong.uvalue+2
rol.z printf_ulong.uvalue+3
asl.z printf_ulong.uvalue
rol.z printf_ulong.uvalue+1
rol.z printf_ulong.uvalue+2
rol.z printf_ulong.uvalue+3
lda #<4
sta.z printf_sint.value
lda #>4
sta.z printf_sint.value+1
jsr printf_sint
// printf("%2d: %08lx\n", 4, val<<4)
lda #<s1
sta.z printf_str.s
lda #>s1
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 4, val<<4)
jsr printf_ulong
// printf("%2d: %08lx\n", 4, val<<4)
lda #<s2
sta.z printf_str.s
lda #>s2
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 5, val<<5)
lda.z val
asl
sta.z printf_ulong.uvalue
lda.z val+1
rol
sta.z printf_ulong.uvalue+1
lda.z val+2
rol
sta.z printf_ulong.uvalue+2
lda.z val+3
rol
sta.z printf_ulong.uvalue+3
asl.z printf_ulong.uvalue
rol.z printf_ulong.uvalue+1
rol.z printf_ulong.uvalue+2
rol.z printf_ulong.uvalue+3
asl.z printf_ulong.uvalue
rol.z printf_ulong.uvalue+1
rol.z printf_ulong.uvalue+2
rol.z printf_ulong.uvalue+3
asl.z printf_ulong.uvalue
rol.z printf_ulong.uvalue+1
rol.z printf_ulong.uvalue+2
rol.z printf_ulong.uvalue+3
asl.z printf_ulong.uvalue
rol.z printf_ulong.uvalue+1
rol.z printf_ulong.uvalue+2
rol.z printf_ulong.uvalue+3
lda #<5
sta.z printf_sint.value
lda #>5
sta.z printf_sint.value+1
jsr printf_sint
// printf("%2d: %08lx\n", 5, val<<5)
lda #<s1
sta.z printf_str.s
lda #>s1
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 5, val<<5)
jsr printf_ulong
// printf("%2d: %08lx\n", 5, val<<5)
lda #<s2
sta.z printf_str.s
lda #>s2
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 6, val<<6)
lda.z val+3
lsr
sta.z $ff
lda.z val+2
ror
sta.z printf_ulong.uvalue+3
lda.z val+1
ror
sta.z printf_ulong.uvalue+2
lda.z val
ror
sta.z printf_ulong.uvalue+1
lda #0
ror
sta.z printf_ulong.uvalue
lsr.z $ff
ror.z printf_ulong.uvalue+3
ror.z printf_ulong.uvalue+2
ror.z printf_ulong.uvalue+1
ror.z printf_ulong.uvalue
lda #<6
sta.z printf_sint.value
lda #>6
sta.z printf_sint.value+1
jsr printf_sint
// printf("%2d: %08lx\n", 6, val<<6)
lda #<s1
sta.z printf_str.s
lda #>s1
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 6, val<<6)
jsr printf_ulong
// printf("%2d: %08lx\n", 6, val<<6)
lda #<s2
sta.z printf_str.s
lda #>s2
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 7, val<<7)
lda.z val+3
lsr
lda.z val+2
ror
sta.z printf_ulong.uvalue+3
lda.z val+1
ror
sta.z printf_ulong.uvalue+2
lda.z val
ror
sta.z printf_ulong.uvalue+1
lda #0
ror
sta.z printf_ulong.uvalue
lda #<7
sta.z printf_sint.value
lda #>7
sta.z printf_sint.value+1
jsr printf_sint
// printf("%2d: %08lx\n", 7, val<<7)
lda #<s1
sta.z printf_str.s
lda #>s1
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 7, val<<7)
jsr printf_ulong
// printf("%2d: %08lx\n", 7, val<<7)
lda #<s2
sta.z printf_str.s
lda #>s2
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 8, val<<8)
lda #0
sta.z printf_ulong.uvalue
lda.z val
sta.z printf_ulong.uvalue+1
lda.z val+1
sta.z printf_ulong.uvalue+2
lda.z val+2
sta.z printf_ulong.uvalue+3
lda #<8
sta.z printf_sint.value
lda #>8
sta.z printf_sint.value+1
jsr printf_sint
// printf("%2d: %08lx\n", 8, val<<8)
lda #<s1
sta.z printf_str.s
lda #>s1
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 8, val<<8)
jsr printf_ulong
// printf("%2d: %08lx\n", 8, val<<8)
lda #<s2
sta.z printf_str.s
lda #>s2
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 9, val<<9)
lda #0
sta.z printf_ulong.uvalue
lda.z val
asl
sta.z printf_ulong.uvalue+1
lda.z val+1
rol
sta.z printf_ulong.uvalue+2
lda.z val+2
rol
sta.z printf_ulong.uvalue+3
lda #<9
sta.z printf_sint.value
lda #>9
sta.z printf_sint.value+1
jsr printf_sint
// printf("%2d: %08lx\n", 9, val<<9)
lda #<s1
sta.z printf_str.s
lda #>s1
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 9, val<<9)
jsr printf_ulong
// printf("%2d: %08lx\n", 9, val<<9)
lda #<s2
sta.z printf_str.s
lda #>s2
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 12, val<<12)
ldy #$c
lda.z val
sta.z printf_ulong.uvalue
lda.z val+1
sta.z printf_ulong.uvalue+1
lda.z val+2
sta.z printf_ulong.uvalue+2
lda.z val+3
sta.z printf_ulong.uvalue+3
cpy #0
beq !e+
!:
asl.z printf_ulong.uvalue
rol.z printf_ulong.uvalue+1
rol.z printf_ulong.uvalue+2
rol.z printf_ulong.uvalue+3
dey
bne !-
!e:
lda #<$c
sta.z printf_sint.value
lda #>$c
sta.z printf_sint.value+1
jsr printf_sint
// printf("%2d: %08lx\n", 12, val<<12)
lda #<s1
sta.z printf_str.s
lda #>s1
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 12, val<<12)
jsr printf_ulong
// printf("%2d: %08lx\n", 12, val<<12)
lda #<s2
sta.z printf_str.s
lda #>s2
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 15, val<<15)
ldy #$f
lda.z val
sta.z printf_ulong.uvalue
lda.z val+1
sta.z printf_ulong.uvalue+1
lda.z val+2
sta.z printf_ulong.uvalue+2
lda.z val+3
sta.z printf_ulong.uvalue+3
cpy #0
beq !e+
!:
asl.z printf_ulong.uvalue
rol.z printf_ulong.uvalue+1
rol.z printf_ulong.uvalue+2
rol.z printf_ulong.uvalue+3
dey
bne !-
!e:
lda #<$f
sta.z printf_sint.value
lda #>$f
sta.z printf_sint.value+1
jsr printf_sint
// printf("%2d: %08lx\n", 15, val<<15)
lda #<s1
sta.z printf_str.s
lda #>s1
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 15, val<<15)
jsr printf_ulong
// printf("%2d: %08lx\n", 15, val<<15)
lda #<s2
sta.z printf_str.s
lda #>s2
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 16, val<<16)
lda #0
sta.z printf_ulong.uvalue
sta.z printf_ulong.uvalue+1
lda.z val
sta.z printf_ulong.uvalue+2
lda.z val+1
sta.z printf_ulong.uvalue+3
lda #<$10
sta.z printf_sint.value
lda #>$10
sta.z printf_sint.value+1
jsr printf_sint
// printf("%2d: %08lx\n", 16, val<<16)
lda #<s1
sta.z printf_str.s
lda #>s1
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 16, val<<16)
jsr printf_ulong
// printf("%2d: %08lx\n", 16, val<<16)
lda #<s2
sta.z printf_str.s
lda #>s2
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 17, val<<17)
ldy #$11
lda.z val
sta.z printf_ulong.uvalue
lda.z val+1
sta.z printf_ulong.uvalue+1
lda.z val+2
sta.z printf_ulong.uvalue+2
lda.z val+3
sta.z printf_ulong.uvalue+3
cpy #0
beq !e+
!:
asl.z printf_ulong.uvalue
rol.z printf_ulong.uvalue+1
rol.z printf_ulong.uvalue+2
rol.z printf_ulong.uvalue+3
dey
bne !-
!e:
lda #<$11
sta.z printf_sint.value
lda #>$11
sta.z printf_sint.value+1
jsr printf_sint
// printf("%2d: %08lx\n", 17, val<<17)
lda #<s1
sta.z printf_str.s
lda #>s1
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 17, val<<17)
jsr printf_ulong
// printf("%2d: %08lx\n", 17, val<<17)
lda #<s2
sta.z printf_str.s
lda #>s2
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 20, val<<20)
ldy #$14
lda.z val
sta.z printf_ulong.uvalue
lda.z val+1
sta.z printf_ulong.uvalue+1
lda.z val+2
sta.z printf_ulong.uvalue+2
lda.z val+3
sta.z printf_ulong.uvalue+3
cpy #0
beq !e+
!:
asl.z printf_ulong.uvalue
rol.z printf_ulong.uvalue+1
rol.z printf_ulong.uvalue+2
rol.z printf_ulong.uvalue+3
dey
bne !-
!e:
lda #<$14
sta.z printf_sint.value
lda #>$14
sta.z printf_sint.value+1
jsr printf_sint
// printf("%2d: %08lx\n", 20, val<<20)
lda #<s1
sta.z printf_str.s
lda #>s1
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 20, val<<20)
jsr printf_ulong
// printf("%2d: %08lx\n", 20, val<<20)
lda #<s2
sta.z printf_str.s
lda #>s2
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 23, val<<23)
ldy #$17
lda.z val
sta.z printf_ulong.uvalue
lda.z val+1
sta.z printf_ulong.uvalue+1
lda.z val+2
sta.z printf_ulong.uvalue+2
lda.z val+3
sta.z printf_ulong.uvalue+3
cpy #0
beq !e+
!:
asl.z printf_ulong.uvalue
rol.z printf_ulong.uvalue+1
rol.z printf_ulong.uvalue+2
rol.z printf_ulong.uvalue+3
dey
bne !-
!e:
lda #<$17
sta.z printf_sint.value
lda #>$17
sta.z printf_sint.value+1
jsr printf_sint
// printf("%2d: %08lx\n", 23, val<<23)
lda #<s1
sta.z printf_str.s
lda #>s1
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 23, val<<23)
jsr printf_ulong
// printf("%2d: %08lx\n", 23, val<<23)
lda #<s2
sta.z printf_str.s
lda #>s2
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 24, val<<24)
lda #0
sta.z printf_ulong.uvalue
sta.z printf_ulong.uvalue+1
sta.z printf_ulong.uvalue+2
lda.z val
sta.z printf_ulong.uvalue+3
lda #<$18
sta.z printf_sint.value
lda #>$18
sta.z printf_sint.value+1
jsr printf_sint
// printf("%2d: %08lx\n", 24, val<<24)
lda #<s1
sta.z printf_str.s
lda #>s1
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 24, val<<24)
jsr printf_ulong
// printf("%2d: %08lx\n", 24, val<<24)
lda #<s2
sta.z printf_str.s
lda #>s2
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 25, val<<25)
ldy #$19
lda.z val
sta.z printf_ulong.uvalue
lda.z val+1
sta.z printf_ulong.uvalue+1
lda.z val+2
sta.z printf_ulong.uvalue+2
lda.z val+3
sta.z printf_ulong.uvalue+3
cpy #0
beq !e+
!:
asl.z printf_ulong.uvalue
rol.z printf_ulong.uvalue+1
rol.z printf_ulong.uvalue+2
rol.z printf_ulong.uvalue+3
dey
bne !-
!e:
lda #<$19
sta.z printf_sint.value
lda #>$19
sta.z printf_sint.value+1
jsr printf_sint
// printf("%2d: %08lx\n", 25, val<<25)
lda #<s1
sta.z printf_str.s
lda #>s1
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 25, val<<25)
jsr printf_ulong
// printf("%2d: %08lx\n", 25, val<<25)
lda #<s2
sta.z printf_str.s
lda #>s2
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 28, val<<28)
ldy #$1c
lda.z val
sta.z printf_ulong.uvalue
lda.z val+1
sta.z printf_ulong.uvalue+1
lda.z val+2
sta.z printf_ulong.uvalue+2
lda.z val+3
sta.z printf_ulong.uvalue+3
cpy #0
beq !e+
!:
asl.z printf_ulong.uvalue
rol.z printf_ulong.uvalue+1
rol.z printf_ulong.uvalue+2
rol.z printf_ulong.uvalue+3
dey
bne !-
!e:
lda #<$1c
sta.z printf_sint.value
lda #>$1c
sta.z printf_sint.value+1
jsr printf_sint
// printf("%2d: %08lx\n", 28, val<<28)
lda #<s1
sta.z printf_str.s
lda #>s1
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 28, val<<28)
jsr printf_ulong
// printf("%2d: %08lx\n", 28, val<<28)
lda #<s2
sta.z printf_str.s
lda #>s2
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 31, val<<31)
ldy #$1f
lda.z val
sta.z printf_ulong.uvalue
lda.z val+1
sta.z printf_ulong.uvalue+1
lda.z val+2
sta.z printf_ulong.uvalue+2
lda.z val+3
sta.z printf_ulong.uvalue+3
cpy #0
beq !e+
!:
asl.z printf_ulong.uvalue
rol.z printf_ulong.uvalue+1
rol.z printf_ulong.uvalue+2
rol.z printf_ulong.uvalue+3
dey
bne !-
!e:
lda #<$1f
sta.z printf_sint.value
lda #>$1f
sta.z printf_sint.value+1
jsr printf_sint
// printf("%2d: %08lx\n", 31, val<<31)
lda #<s1
sta.z printf_str.s
lda #>s1
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 31, val<<31)
jsr printf_ulong
// printf("%2d: %08lx\n", 31, val<<31)
lda #<s2
sta.z printf_str.s
lda #>s2
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 32, val<<32)
lda #0
sta.z printf_ulong.uvalue
sta.z printf_ulong.uvalue+1
sta.z printf_ulong.uvalue+2
sta.z printf_ulong.uvalue+3
lda #<$20
sta.z printf_sint.value
lda #>$20
sta.z printf_sint.value+1
jsr printf_sint
// printf("%2d: %08lx\n", 32, val<<32)
lda #<s1
sta.z printf_str.s
lda #>s1
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 32, val<<32)
jsr printf_ulong
// printf("%2d: %08lx\n", 32, val<<32)
lda #<s2
sta.z printf_str.s
lda #>s2
sta.z printf_str.s+1
jsr printf_str
// }
rts
.segment Data
s: .text @"rol fixed\n"
.byte 0
}
.segment Code
// Return true if there's a key waiting, return false if not
kbhit: {
// CIA#1 Port A: keyboard matrix columns and joystick #2
.label CIA1_PORT_A = $dc00
// CIA#1 Port B: keyboard matrix rows and joystick #1.
.label CIA1_PORT_B = $dc01
// *CIA1_PORT_A = 0
lda #0
sta CIA1_PORT_A
// ~*CIA1_PORT_B
lda CIA1_PORT_B
eor #$ff
// }
rts
}
// void ror_fixed(__zp($21) unsigned long val)
ror_fixed: {
.label val = $21
// printf("ror fixed\n")
lda #<s
sta.z printf_str.s
lda #>s
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 0, val>>0)
lda.z val
sta.z printf_ulong.uvalue
lda.z val+1
sta.z printf_ulong.uvalue+1
lda.z val+2
sta.z printf_ulong.uvalue+2
lda.z val+3
sta.z printf_ulong.uvalue+3
lda #<0
sta.z printf_sint.value
sta.z printf_sint.value+1
jsr printf_sint
// printf("%2d: %08lx\n", 0, val>>0)
lda #<s1
sta.z printf_str.s
lda #>s1
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 0, val>>0)
jsr printf_ulong
// printf("%2d: %08lx\n", 0, val>>0)
lda #<s2
sta.z printf_str.s
lda #>s2
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 1, val>>1)
lda.z val+3
lsr
sta.z printf_ulong.uvalue+3
lda.z val+2
ror
sta.z printf_ulong.uvalue+2
lda.z val+1
ror
sta.z printf_ulong.uvalue+1
lda.z val
ror
sta.z printf_ulong.uvalue
lda #<1
sta.z printf_sint.value
lda #>1
sta.z printf_sint.value+1
jsr printf_sint
// printf("%2d: %08lx\n", 1, val>>1)
lda #<s1
sta.z printf_str.s
lda #>s1
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 1, val>>1)
jsr printf_ulong
// printf("%2d: %08lx\n", 1, val>>1)
lda #<s2
sta.z printf_str.s
lda #>s2
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 2, val>>2)
lda.z val+3
lsr
sta.z printf_ulong.uvalue+3
lda.z val+2
ror
sta.z printf_ulong.uvalue+2
lda.z val+1
ror
sta.z printf_ulong.uvalue+1
lda.z val
ror
sta.z printf_ulong.uvalue
lsr.z printf_ulong.uvalue+3
ror.z printf_ulong.uvalue+2
ror.z printf_ulong.uvalue+1
ror.z printf_ulong.uvalue
lda #<2
sta.z printf_sint.value
lda #>2
sta.z printf_sint.value+1
jsr printf_sint
// printf("%2d: %08lx\n", 2, val>>2)
lda #<s1
sta.z printf_str.s
lda #>s1
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 2, val>>2)
jsr printf_ulong
// printf("%2d: %08lx\n", 2, val>>2)
lda #<s2
sta.z printf_str.s
lda #>s2
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 3, val>>3)
lda.z val+3
lsr
sta.z printf_ulong.uvalue+3
lda.z val+2
ror
sta.z printf_ulong.uvalue+2
lda.z val+1
ror
sta.z printf_ulong.uvalue+1
lda.z val
ror
sta.z printf_ulong.uvalue
lsr.z printf_ulong.uvalue+3
ror.z printf_ulong.uvalue+2
ror.z printf_ulong.uvalue+1
ror.z printf_ulong.uvalue
lsr.z printf_ulong.uvalue+3
ror.z printf_ulong.uvalue+2
ror.z printf_ulong.uvalue+1
ror.z printf_ulong.uvalue
lda #<3
sta.z printf_sint.value
lda #>3
sta.z printf_sint.value+1
jsr printf_sint
// printf("%2d: %08lx\n", 3, val>>3)
lda #<s1
sta.z printf_str.s
lda #>s1
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 3, val>>3)
jsr printf_ulong
// printf("%2d: %08lx\n", 3, val>>3)
lda #<s2
sta.z printf_str.s
lda #>s2
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 4, val>>4)
lda.z val+3
lsr
sta.z printf_ulong.uvalue+3
lda.z val+2
ror
sta.z printf_ulong.uvalue+2
lda.z val+1
ror
sta.z printf_ulong.uvalue+1
lda.z val
ror
sta.z printf_ulong.uvalue
lsr.z printf_ulong.uvalue+3
ror.z printf_ulong.uvalue+2
ror.z printf_ulong.uvalue+1
ror.z printf_ulong.uvalue
lsr.z printf_ulong.uvalue+3
ror.z printf_ulong.uvalue+2
ror.z printf_ulong.uvalue+1
ror.z printf_ulong.uvalue
lsr.z printf_ulong.uvalue+3
ror.z printf_ulong.uvalue+2
ror.z printf_ulong.uvalue+1
ror.z printf_ulong.uvalue
lda #<4
sta.z printf_sint.value
lda #>4
sta.z printf_sint.value+1
jsr printf_sint
// printf("%2d: %08lx\n", 4, val>>4)
lda #<s1
sta.z printf_str.s
lda #>s1
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 4, val>>4)
jsr printf_ulong
// printf("%2d: %08lx\n", 4, val>>4)
lda #<s2
sta.z printf_str.s
lda #>s2
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 5, val>>5)
lda.z val+3
lsr
sta.z printf_ulong.uvalue+3
lda.z val+2
ror
sta.z printf_ulong.uvalue+2
lda.z val+1
ror
sta.z printf_ulong.uvalue+1
lda.z val
ror
sta.z printf_ulong.uvalue
lsr.z printf_ulong.uvalue+3
ror.z printf_ulong.uvalue+2
ror.z printf_ulong.uvalue+1
ror.z printf_ulong.uvalue
lsr.z printf_ulong.uvalue+3
ror.z printf_ulong.uvalue+2
ror.z printf_ulong.uvalue+1
ror.z printf_ulong.uvalue
lsr.z printf_ulong.uvalue+3
ror.z printf_ulong.uvalue+2
ror.z printf_ulong.uvalue+1
ror.z printf_ulong.uvalue
lsr.z printf_ulong.uvalue+3
ror.z printf_ulong.uvalue+2
ror.z printf_ulong.uvalue+1
ror.z printf_ulong.uvalue
lda #<5
sta.z printf_sint.value
lda #>5
sta.z printf_sint.value+1
jsr printf_sint
// printf("%2d: %08lx\n", 5, val>>5)
lda #<s1
sta.z printf_str.s
lda #>s1
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 5, val>>5)
jsr printf_ulong
// printf("%2d: %08lx\n", 5, val>>5)
lda #<s2
sta.z printf_str.s
lda #>s2
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 6, val>>6)
lda.z val
asl
sta.z $ff
lda.z val+1
rol
sta.z printf_ulong.uvalue
lda.z val+2
rol
sta.z printf_ulong.uvalue+1
lda.z val+3
rol
sta.z printf_ulong.uvalue+2
lda #0
rol
sta.z printf_ulong.uvalue+3
asl.z $ff
rol.z printf_ulong.uvalue
rol.z printf_ulong.uvalue+1
rol.z printf_ulong.uvalue+2
rol.z printf_ulong.uvalue+3
lda #<6
sta.z printf_sint.value
lda #>6
sta.z printf_sint.value+1
jsr printf_sint
// printf("%2d: %08lx\n", 6, val>>6)
lda #<s1
sta.z printf_str.s
lda #>s1
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 6, val>>6)
jsr printf_ulong
// printf("%2d: %08lx\n", 6, val>>6)
lda #<s2
sta.z printf_str.s
lda #>s2
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 7, val>>7)
lda.z val
asl
lda.z val+1
rol
sta.z printf_ulong.uvalue
lda.z val+2
rol
sta.z printf_ulong.uvalue+1
lda.z val+3
rol
sta.z printf_ulong.uvalue+2
lda #0
rol
sta.z printf_ulong.uvalue+3
lda #<7
sta.z printf_sint.value
lda #>7
sta.z printf_sint.value+1
jsr printf_sint
// printf("%2d: %08lx\n", 7, val>>7)
lda #<s1
sta.z printf_str.s
lda #>s1
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 7, val>>7)
jsr printf_ulong
// printf("%2d: %08lx\n", 7, val>>7)
lda #<s2
sta.z printf_str.s
lda #>s2
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 8, val>>8)
lda #0
sta.z printf_ulong.uvalue+3
lda.z val+3
sta.z printf_ulong.uvalue+2
lda.z val+2
sta.z printf_ulong.uvalue+1
lda.z val+1
sta.z printf_ulong.uvalue
lda #<8
sta.z printf_sint.value
lda #>8
sta.z printf_sint.value+1
jsr printf_sint
// printf("%2d: %08lx\n", 8, val>>8)
lda #<s1
sta.z printf_str.s
lda #>s1
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 8, val>>8)
jsr printf_ulong
// printf("%2d: %08lx\n", 8, val>>8)
lda #<s2
sta.z printf_str.s
lda #>s2
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 9, val>>9)
lda #0
sta.z printf_ulong.uvalue+3
lda.z val+3
lsr
sta.z printf_ulong.uvalue+2
lda.z val+2
ror
sta.z printf_ulong.uvalue+1
lda.z val+1
ror
sta.z printf_ulong.uvalue
lda #<9
sta.z printf_sint.value
lda #>9
sta.z printf_sint.value+1
jsr printf_sint
// printf("%2d: %08lx\n", 9, val>>9)
lda #<s1
sta.z printf_str.s
lda #>s1
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 9, val>>9)
jsr printf_ulong
// printf("%2d: %08lx\n", 9, val>>9)
lda #<s2
sta.z printf_str.s
lda #>s2
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 12, val>>12)
ldx #$c
lda.z val
sta.z printf_ulong.uvalue
lda.z val+1
sta.z printf_ulong.uvalue+1
lda.z val+2
sta.z printf_ulong.uvalue+2
lda.z val+3
sta.z printf_ulong.uvalue+3
cpx #0
beq !e+
!:
lsr.z printf_ulong.uvalue+3
ror.z printf_ulong.uvalue+2
ror.z printf_ulong.uvalue+1
ror.z printf_ulong.uvalue
dex
bne !-
!e:
lda #<$c
sta.z printf_sint.value
lda #>$c
sta.z printf_sint.value+1
jsr printf_sint
// printf("%2d: %08lx\n", 12, val>>12)
lda #<s1
sta.z printf_str.s
lda #>s1
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 12, val>>12)
jsr printf_ulong
// printf("%2d: %08lx\n", 12, val>>12)
lda #<s2
sta.z printf_str.s
lda #>s2
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 15, val>>15)
ldx #$f
lda.z val
sta.z printf_ulong.uvalue
lda.z val+1
sta.z printf_ulong.uvalue+1
lda.z val+2
sta.z printf_ulong.uvalue+2
lda.z val+3
sta.z printf_ulong.uvalue+3
cpx #0
beq !e+
!:
lsr.z printf_ulong.uvalue+3
ror.z printf_ulong.uvalue+2
ror.z printf_ulong.uvalue+1
ror.z printf_ulong.uvalue
dex
bne !-
!e:
lda #<$f
sta.z printf_sint.value
lda #>$f
sta.z printf_sint.value+1
jsr printf_sint
// printf("%2d: %08lx\n", 15, val>>15)
lda #<s1
sta.z printf_str.s
lda #>s1
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 15, val>>15)
jsr printf_ulong
// printf("%2d: %08lx\n", 15, val>>15)
lda #<s2
sta.z printf_str.s
lda #>s2
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 16, val>>16)
lda #0
sta.z printf_ulong.uvalue+3
sta.z printf_ulong.uvalue+2
lda.z val+3
sta.z printf_ulong.uvalue+1
lda.z val+2
sta.z printf_ulong.uvalue
lda #<$10
sta.z printf_sint.value
lda #>$10
sta.z printf_sint.value+1
jsr printf_sint
// printf("%2d: %08lx\n", 16, val>>16)
lda #<s1
sta.z printf_str.s
lda #>s1
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 16, val>>16)
jsr printf_ulong
// printf("%2d: %08lx\n", 16, val>>16)
lda #<s2
sta.z printf_str.s
lda #>s2
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 17, val>>17)
ldx #$11
lda.z val
sta.z printf_ulong.uvalue
lda.z val+1
sta.z printf_ulong.uvalue+1
lda.z val+2
sta.z printf_ulong.uvalue+2
lda.z val+3
sta.z printf_ulong.uvalue+3
cpx #0
beq !e+
!:
lsr.z printf_ulong.uvalue+3
ror.z printf_ulong.uvalue+2
ror.z printf_ulong.uvalue+1
ror.z printf_ulong.uvalue
dex
bne !-
!e:
lda #<$11
sta.z printf_sint.value
lda #>$11
sta.z printf_sint.value+1
jsr printf_sint
// printf("%2d: %08lx\n", 17, val>>17)
lda #<s1
sta.z printf_str.s
lda #>s1
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 17, val>>17)
jsr printf_ulong
// printf("%2d: %08lx\n", 17, val>>17)
lda #<s2
sta.z printf_str.s
lda #>s2
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 20, val>>20)
ldx #$14
lda.z val
sta.z printf_ulong.uvalue
lda.z val+1
sta.z printf_ulong.uvalue+1
lda.z val+2
sta.z printf_ulong.uvalue+2
lda.z val+3
sta.z printf_ulong.uvalue+3
cpx #0
beq !e+
!:
lsr.z printf_ulong.uvalue+3
ror.z printf_ulong.uvalue+2
ror.z printf_ulong.uvalue+1
ror.z printf_ulong.uvalue
dex
bne !-
!e:
lda #<$14
sta.z printf_sint.value
lda #>$14
sta.z printf_sint.value+1
jsr printf_sint
// printf("%2d: %08lx\n", 20, val>>20)
lda #<s1
sta.z printf_str.s
lda #>s1
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 20, val>>20)
jsr printf_ulong
// printf("%2d: %08lx\n", 20, val>>20)
lda #<s2
sta.z printf_str.s
lda #>s2
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 23, val>>23)
ldx #$17
lda.z val
sta.z printf_ulong.uvalue
lda.z val+1
sta.z printf_ulong.uvalue+1
lda.z val+2
sta.z printf_ulong.uvalue+2
lda.z val+3
sta.z printf_ulong.uvalue+3
cpx #0
beq !e+
!:
lsr.z printf_ulong.uvalue+3
ror.z printf_ulong.uvalue+2
ror.z printf_ulong.uvalue+1
ror.z printf_ulong.uvalue
dex
bne !-
!e:
lda #<$17
sta.z printf_sint.value
lda #>$17
sta.z printf_sint.value+1
jsr printf_sint
// printf("%2d: %08lx\n", 23, val>>23)
lda #<s1
sta.z printf_str.s
lda #>s1
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 23, val>>23)
jsr printf_ulong
// printf("%2d: %08lx\n", 23, val>>23)
lda #<s2
sta.z printf_str.s
lda #>s2
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 24, val>>24)
lda #0
sta.z printf_ulong.uvalue+3
sta.z printf_ulong.uvalue+2
sta.z printf_ulong.uvalue+1
lda.z val+3
sta.z printf_ulong.uvalue
lda #<$18
sta.z printf_sint.value
lda #>$18
sta.z printf_sint.value+1
jsr printf_sint
// printf("%2d: %08lx\n", 24, val>>24)
lda #<s1
sta.z printf_str.s
lda #>s1
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 24, val>>24)
jsr printf_ulong
// printf("%2d: %08lx\n", 24, val>>24)
lda #<s2
sta.z printf_str.s
lda #>s2
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 25, val>>25)
ldx #$19
lda.z val
sta.z printf_ulong.uvalue
lda.z val+1
sta.z printf_ulong.uvalue+1
lda.z val+2
sta.z printf_ulong.uvalue+2
lda.z val+3
sta.z printf_ulong.uvalue+3
cpx #0
beq !e+
!:
lsr.z printf_ulong.uvalue+3
ror.z printf_ulong.uvalue+2
ror.z printf_ulong.uvalue+1
ror.z printf_ulong.uvalue
dex
bne !-
!e:
lda #<$19
sta.z printf_sint.value
lda #>$19
sta.z printf_sint.value+1
jsr printf_sint
// printf("%2d: %08lx\n", 25, val>>25)
lda #<s1
sta.z printf_str.s
lda #>s1
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 25, val>>25)
jsr printf_ulong
// printf("%2d: %08lx\n", 25, val>>25)
lda #<s2
sta.z printf_str.s
lda #>s2
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 28, val>>28)
ldx #$1c
lda.z val
sta.z printf_ulong.uvalue
lda.z val+1
sta.z printf_ulong.uvalue+1
lda.z val+2
sta.z printf_ulong.uvalue+2
lda.z val+3
sta.z printf_ulong.uvalue+3
cpx #0
beq !e+
!:
lsr.z printf_ulong.uvalue+3
ror.z printf_ulong.uvalue+2
ror.z printf_ulong.uvalue+1
ror.z printf_ulong.uvalue
dex
bne !-
!e:
lda #<$1c
sta.z printf_sint.value
lda #>$1c
sta.z printf_sint.value+1
jsr printf_sint
// printf("%2d: %08lx\n", 28, val>>28)
lda #<s1
sta.z printf_str.s
lda #>s1
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 28, val>>28)
jsr printf_ulong
// printf("%2d: %08lx\n", 28, val>>28)
lda #<s2
sta.z printf_str.s
lda #>s2
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 31, val>>31)
ldx #$1f
lda.z val
sta.z printf_ulong.uvalue
lda.z val+1
sta.z printf_ulong.uvalue+1
lda.z val+2
sta.z printf_ulong.uvalue+2
lda.z val+3
sta.z printf_ulong.uvalue+3
cpx #0
beq !e+
!:
lsr.z printf_ulong.uvalue+3
ror.z printf_ulong.uvalue+2
ror.z printf_ulong.uvalue+1
ror.z printf_ulong.uvalue
dex
bne !-
!e:
lda #<$1f
sta.z printf_sint.value
lda #>$1f
sta.z printf_sint.value+1
jsr printf_sint
// printf("%2d: %08lx\n", 31, val>>31)
lda #<s1
sta.z printf_str.s
lda #>s1
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 31, val>>31)
jsr printf_ulong
// printf("%2d: %08lx\n", 31, val>>31)
lda #<s2
sta.z printf_str.s
lda #>s2
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 32, val>>32)
lda #0
sta.z printf_ulong.uvalue+3
sta.z printf_ulong.uvalue+2
sta.z printf_ulong.uvalue+1
sta.z printf_ulong.uvalue
lda #<$20
sta.z printf_sint.value
lda #>$20
sta.z printf_sint.value+1
jsr printf_sint
// printf("%2d: %08lx\n", 32, val>>32)
lda #<s1
sta.z printf_str.s
lda #>s1
sta.z printf_str.s+1
jsr printf_str
// printf("%2d: %08lx\n", 32, val>>32)
jsr printf_ulong
// printf("%2d: %08lx\n", 32, val>>32)
lda #<s2
sta.z printf_str.s
lda #>s2
sta.z printf_str.s+1
jsr printf_str
// }
rts
.segment Data
s: .text @"ror fixed\n"
.byte 0
}
.segment Code
// void rol_var(__zp($21) unsigned long val)
rol_var: {
.label val = $21
.label i = $20
// printf("rol var\n")
lda #<s
sta.z printf_str.s
lda #>s
sta.z printf_str.s+1
jsr printf_str
lda #0
sta.z i
__b1:
// for(char i=0;i<sizeof(rols);i++)
lda.z i
cmp #$15*SIZEOF_CHAR
bcc __b2
// }
rts
__b2:
// printf("%2u: %08lx\n", rols[i], val<<rols[i])
ldx.z i
ldy rols,x
lda.z val
sta.z printf_ulong.uvalue
lda.z val+1
sta.z printf_ulong.uvalue+1
lda.z val+2
sta.z printf_ulong.uvalue+2
lda.z val+3
sta.z printf_ulong.uvalue+3
cpy #0
beq !e+
!:
asl.z printf_ulong.uvalue
rol.z printf_ulong.uvalue+1
rol.z printf_ulong.uvalue+2
rol.z printf_ulong.uvalue+3
dey
bne !-
!e:
ldy.z i
ldx rols,y
jsr printf_uchar
// printf("%2u: %08lx\n", rols[i], val<<rols[i])
lda #<s1
sta.z printf_str.s
lda #>s1
sta.z printf_str.s+1
jsr printf_str
// printf("%2u: %08lx\n", rols[i], val<<rols[i])
jsr printf_ulong
// printf("%2u: %08lx\n", rols[i], val<<rols[i])
lda #<s2
sta.z printf_str.s
lda #>s2
sta.z printf_str.s+1
jsr printf_str
// for(char i=0;i<sizeof(rols);i++)
inc.z i
jmp __b1
.segment Data
s: .text @"rol var\n"
.byte 0
}
.segment Code
// void ror_var(__zp($21) unsigned long val)
ror_var: {
.label val = $21
.label i = $20
// printf("ror var\n")
lda #<s
sta.z printf_str.s
lda #>s
sta.z printf_str.s+1
jsr printf_str
lda #0
sta.z i
__b1:
// for(char i=0;i<sizeof(rols);i++)
lda.z i
cmp #$15*SIZEOF_CHAR
bcc __b2
// }
rts
__b2:
// printf("%2u: %08lx\n", rols[i], val>>rols[i])
ldy.z i
ldx rols,y
lda.z val
sta.z printf_ulong.uvalue
lda.z val+1
sta.z printf_ulong.uvalue+1
lda.z val+2
sta.z printf_ulong.uvalue+2
lda.z val+3
sta.z printf_ulong.uvalue+3
cpx #0
beq !e+
!:
lsr.z printf_ulong.uvalue+3
ror.z printf_ulong.uvalue+2
ror.z printf_ulong.uvalue+1
ror.z printf_ulong.uvalue
dex
bne !-
!e:
ldy.z i
ldx rols,y
jsr printf_uchar
// printf("%2u: %08lx\n", rols[i], val>>rols[i])
lda #<s1
sta.z printf_str.s
lda #>s1
sta.z printf_str.s+1
jsr printf_str
// printf("%2u: %08lx\n", rols[i], val>>rols[i])
jsr printf_ulong
// printf("%2u: %08lx\n", rols[i], val>>rols[i])
lda #<s2
sta.z printf_str.s
lda #>s2
sta.z printf_str.s+1
jsr printf_str
// for(char i=0;i<sizeof(rols);i++)
inc.z i
jmp __b1
.segment Data
s: .text @"ror var\n"
.byte 0
}
.segment Code
// Scroll the entire screen if the cursor is beyond the last line
cscroll: {
// if(conio_cursor_y==CONIO_HEIGHT)
lda #$19
cmp.z conio_cursor_y
bne __breturn
// memcpy(CONIO_SCREEN_TEXT, CONIO_SCREEN_TEXT+CONIO_WIDTH, CONIO_BYTES-CONIO_WIDTH)
lda #<DEFAULT_SCREEN
sta.z memcpy.destination
lda #>DEFAULT_SCREEN
sta.z memcpy.destination+1
lda #<DEFAULT_SCREEN+$28
sta.z memcpy.source
lda #>DEFAULT_SCREEN+$28
sta.z memcpy.source+1
jsr memcpy
// memcpy(CONIO_SCREEN_COLORS, CONIO_SCREEN_COLORS+CONIO_WIDTH, CONIO_BYTES-CONIO_WIDTH)
lda #<COLORRAM
sta.z memcpy.destination
lda #>COLORRAM
sta.z memcpy.destination+1
lda #<COLORRAM+$28
sta.z memcpy.source
lda #>COLORRAM+$28
sta.z memcpy.source+1
jsr memcpy
// memset(CONIO_SCREEN_TEXT+CONIO_BYTES-CONIO_WIDTH, ' ', CONIO_WIDTH)
ldx #' '
lda #<DEFAULT_SCREEN+$19*$28-$28
sta.z memset.str
lda #>DEFAULT_SCREEN+$19*$28-$28
sta.z memset.str+1
jsr memset
// memset(CONIO_SCREEN_COLORS+CONIO_BYTES-CONIO_WIDTH, conio_textcolor, CONIO_WIDTH)
ldx #LIGHT_BLUE
lda #<COLORRAM+$19*$28-$28
sta.z memset.str
lda #>COLORRAM+$19*$28-$28
sta.z memset.str+1
jsr memset
// conio_line_text -= CONIO_WIDTH
sec
lda.z conio_line_text
sbc #$28
sta.z conio_line_text
lda.z conio_line_text+1
sbc #0
sta.z conio_line_text+1
// conio_line_color -= CONIO_WIDTH
sec
lda.z conio_line_color
sbc #$28
sta.z conio_line_color
lda.z conio_line_color+1
sbc #0
sta.z conio_line_color+1
// conio_cursor_y--;
dec.z conio_cursor_y
__breturn:
// }
rts
}
/// Print a NUL-terminated string
// void printf_str(void (*putc)(char), __zp($16) const char *s)
printf_str: {
.label s = $16
__b1:
// while(c=*s++)
ldy #0
lda (s),y
inc.z s
bne !+
inc.z s+1
!:
cmp #0
bne __b2
// }
rts
__b2:
// putc(c)
pha
jsr cputc
pla
jmp __b1
}
// Print a signed integer using a specific format
// void printf_sint(void (*putc)(char), __zp($19) int value, char format_min_length, char format_justify_left, char format_sign_always, char format_zero_padding, char format_upper_case, char format_radix)
printf_sint: {
.label value = $19
// printf_buffer.sign = 0
// Handle any sign
lda #0
sta printf_buffer
// if(value<0)
lda.z value+1
bmi __b1
jmp __b2
__b1:
// value = -value
lda #0
sec
sbc.z value
sta.z value
lda #0
sbc.z value+1
sta.z value+1
// printf_buffer.sign = '-'
lda #'-'
sta printf_buffer
__b2:
// utoa(uvalue, printf_buffer.digits, format.radix)
jsr utoa
// printf_number_buffer(putc, printf_buffer, format)
lda printf_buffer
sta.z printf_number_buffer.buffer_sign
// Print using format
lda #0
sta.z printf_number_buffer.format_zero_padding
ldx #2
jsr printf_number_buffer
// }
rts
}
// Print an unsigned int using a specific format
// void printf_ulong(void (*putc)(char), __zp(8) unsigned long uvalue, char format_min_length, char format_justify_left, char format_sign_always, char format_zero_padding, char format_upper_case, char format_radix)
printf_ulong: {
.label uvalue = 8
// printf_buffer.sign = format.sign_always?'+':0
// Handle any sign
lda #0
sta printf_buffer
// ultoa(uvalue, printf_buffer.digits, format.radix)
// Format number into buffer
jsr ultoa
// printf_number_buffer(putc, printf_buffer, format)
lda printf_buffer
sta.z printf_number_buffer.buffer_sign
// Print using format
lda #1
sta.z printf_number_buffer.format_zero_padding
ldx #8
jsr printf_number_buffer
// }
rts
}
// Print an unsigned char using a specific format
// void printf_uchar(void (*putc)(char), __register(X) char uvalue, char format_min_length, char format_justify_left, char format_sign_always, char format_zero_padding, char format_upper_case, char format_radix)
printf_uchar: {
// printf_buffer.sign = format.sign_always?'+':0
// Handle any sign
lda #0
sta printf_buffer
// uctoa(uvalue, printf_buffer.digits, format.radix)
// Format number into buffer
jsr uctoa
// printf_number_buffer(putc, printf_buffer, format)
lda printf_buffer
sta.z printf_number_buffer.buffer_sign
// Print using format
lda #0
sta.z printf_number_buffer.format_zero_padding
ldx #2
jsr printf_number_buffer
// }
rts
}
// Copy block of memory (forwards)
// Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
// void * memcpy(__zp(4) void *destination, __zp(2) void *source, unsigned int num)
memcpy: {
.label src_end = 6
.label dst = 4
.label src = 2
.label source = 2
.label destination = 4
// char* src_end = (char*)source+num
lda.z source
clc
adc #<$19*$28-$28
sta.z src_end
lda.z source+1
adc #>$19*$28-$28
sta.z src_end+1
__b1:
// while(src!=src_end)
lda.z src+1
cmp.z src_end+1
bne __b2
lda.z src
cmp.z src_end
bne __b2
// }
rts
__b2:
// *dst++ = *src++
ldy #0
lda (src),y
sta (dst),y
// *dst++ = *src++;
inc.z dst
bne !+
inc.z dst+1
!:
inc.z src
bne !+
inc.z src+1
!:
jmp __b1
}
// Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
// void * memset(__zp(2) void *str, __register(X) char c, unsigned int num)
memset: {
.label end = 4
.label dst = 2
.label str = 2
// char* end = (char*)str + num
lda #$28
clc
adc.z str
sta.z end
lda #0
adc.z str+1
sta.z end+1
__b2:
// for(char* dst = str; dst!=end; dst++)
lda.z dst+1
cmp.z end+1
bne __b3
lda.z dst
cmp.z end
bne __b3
// }
rts
__b3:
// *dst = c
txa
ldy #0
sta (dst),y
// for(char* dst = str; dst!=end; dst++)
inc.z dst
bne !+
inc.z dst+1
!:
jmp __b2
}
// Converts unsigned number value to a string representing it in RADIX format.
// If the leading digits are zero they are not included in the string.
// - value : The number to be converted to RADIX
// - buffer : receives the string representing the number and zero-termination.
// - radix : The radix to convert the number to (from the enum RADIX)
// void utoa(__zp($19) unsigned int value, __zp(4) char *buffer, char radix)
utoa: {
.label digit_value = 2
.label buffer = 4
.label digit = $1f
.label value = $19
lda #<printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
sta.z buffer
lda #>printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
sta.z buffer+1
ldx #0
txa
sta.z digit
__b1:
// for( char digit=0; digit<max_digits-1; digit++ )
lda.z digit
cmp #5-1
bcc __b2
// *buffer++ = DIGITS[(char)value]
ldx.z value
lda DIGITS,x
ldy #0
sta (buffer),y
// *buffer++ = DIGITS[(char)value];
inc.z buffer
bne !+
inc.z buffer+1
!:
// *buffer = 0
lda #0
tay
sta (buffer),y
// }
rts
__b2:
// unsigned int digit_value = digit_values[digit]
lda.z digit
asl
tay
lda RADIX_DECIMAL_VALUES,y
sta.z digit_value
lda RADIX_DECIMAL_VALUES+1,y
sta.z digit_value+1
// if (started || value >= digit_value)
cpx #0
bne __b5
cmp.z value+1
bne !+
lda.z digit_value
cmp.z value
beq __b5
!:
bcc __b5
__b4:
// for( char digit=0; digit<max_digits-1; digit++ )
inc.z digit
jmp __b1
__b5:
// utoa_append(buffer++, value, digit_value)
jsr utoa_append
// utoa_append(buffer++, value, digit_value)
// value = utoa_append(buffer++, value, digit_value)
// value = utoa_append(buffer++, value, digit_value);
inc.z buffer
bne !+
inc.z buffer+1
!:
ldx #1
jmp __b4
}
// Print the contents of the number buffer using a specific format.
// This handles minimum length, zero-filling, and left/right justification from the format
// void printf_number_buffer(void (*putc)(char), __zp($1e) char buffer_sign, char *buffer_digits, __register(X) char format_min_length, char format_justify_left, char format_sign_always, __zp($1f) char format_zero_padding, char format_upper_case, char format_radix)
printf_number_buffer: {
.label __19 = 2
.label buffer_sign = $1e
.label padding = $1d
.label format_zero_padding = $1f
// if(format.min_length)
cpx #0
beq __b5
// strlen(buffer.digits)
jsr strlen
// strlen(buffer.digits)
// signed char len = (signed char)strlen(buffer.digits)
// There is a minimum length - work out the padding
ldy.z __19
// if(buffer.sign)
lda.z buffer_sign
beq __b10
// len++;
iny
__b10:
// padding = (signed char)format.min_length - len
txa
sty.z $ff
sec
sbc.z $ff
sta.z padding
// if(padding<0)
cmp #0
bpl __b1
__b5:
lda #0
sta.z padding
__b1:
// if(!format.justify_left && !format.zero_padding && padding)
lda.z format_zero_padding
bne __b2
lda.z padding
cmp #0
bne __b7
jmp __b2
__b7:
// printf_padding(putc, ' ',(char)padding)
lda.z padding
sta.z printf_padding.length
lda #' '
sta.z printf_padding.pad
jsr printf_padding
__b2:
// if(buffer.sign)
lda.z buffer_sign
beq __b3
// putc(buffer.sign)
pha
jsr cputc
pla
__b3:
// if(format.zero_padding && padding)
lda.z format_zero_padding
beq __b4
lda.z padding
cmp #0
bne __b9
jmp __b4
__b9:
// printf_padding(putc, '0',(char)padding)
lda.z padding
sta.z printf_padding.length
lda #'0'
sta.z printf_padding.pad
jsr printf_padding
__b4:
// printf_str(putc, buffer.digits)
lda #<printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
sta.z printf_str.s
lda #>printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
sta.z printf_str.s+1
jsr printf_str
// }
rts
}
// Converts unsigned number value to a string representing it in RADIX format.
// If the leading digits are zero they are not included in the string.
// - value : The number to be converted to RADIX
// - buffer : receives the string representing the number and zero-termination.
// - radix : The radix to convert the number to (from the enum RADIX)
// void ultoa(__zp(8) unsigned long value, __zp($16) char *buffer, char radix)
ultoa: {
.label digit_value = $d
.label buffer = $16
.label digit = $1e
.label value = 8
lda #<printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
sta.z buffer
lda #>printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
sta.z buffer+1
ldx #0
txa
sta.z digit
__b1:
// for( char digit=0; digit<max_digits-1; digit++ )
lda.z digit
cmp #8-1
bcc __b2
// *buffer++ = DIGITS[(char)value]
lda.z value
tay
lda DIGITS,y
ldy #0
sta (buffer),y
// *buffer++ = DIGITS[(char)value];
inc.z buffer
bne !+
inc.z buffer+1
!:
// *buffer = 0
lda #0
tay
sta (buffer),y
// }
rts
__b2:
// unsigned long digit_value = digit_values[digit]
lda.z digit
asl
asl
tay
lda RADIX_HEXADECIMAL_VALUES_LONG,y
sta.z digit_value
lda RADIX_HEXADECIMAL_VALUES_LONG+1,y
sta.z digit_value+1
lda RADIX_HEXADECIMAL_VALUES_LONG+2,y
sta.z digit_value+2
lda RADIX_HEXADECIMAL_VALUES_LONG+3,y
sta.z digit_value+3
// if (started || value >= digit_value)
cpx #0
bne __b5
lda.z value+3
cmp.z digit_value+3
bcc !+
bne __b5
lda.z value+2
cmp.z digit_value+2
bcc !+
bne __b5
lda.z value+1
cmp.z digit_value+1
bcc !+
bne __b5
lda.z value
cmp.z digit_value
bcs __b5
!:
__b4:
// for( char digit=0; digit<max_digits-1; digit++ )
inc.z digit
jmp __b1
__b5:
// ultoa_append(buffer++, value, digit_value)
jsr ultoa_append
// ultoa_append(buffer++, value, digit_value)
// value = ultoa_append(buffer++, value, digit_value)
// value = ultoa_append(buffer++, value, digit_value);
inc.z buffer
bne !+
inc.z buffer+1
!:
ldx #1
jmp __b4
}
// Converts unsigned number value to a string representing it in RADIX format.
// If the leading digits are zero they are not included in the string.
// - value : The number to be converted to RADIX
// - buffer : receives the string representing the number and zero-termination.
// - radix : The radix to convert the number to (from the enum RADIX)
// void uctoa(__register(X) char value, __zp($16) char *buffer, char radix)
uctoa: {
.label digit_value = $c
.label buffer = $16
.label digit = $1d
.label started = $1c
lda #<printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
sta.z buffer
lda #>printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
sta.z buffer+1
lda #0
sta.z started
sta.z digit
__b1:
// for( char digit=0; digit<max_digits-1; digit++ )
lda.z digit
cmp #3-1
bcc __b2
// *buffer++ = DIGITS[(char)value]
lda DIGITS,x
ldy #0
sta (buffer),y
// *buffer++ = DIGITS[(char)value];
inc.z buffer
bne !+
inc.z buffer+1
!:
// *buffer = 0
lda #0
tay
sta (buffer),y
// }
rts
__b2:
// unsigned char digit_value = digit_values[digit]
ldy.z digit
lda RADIX_DECIMAL_VALUES_CHAR,y
sta.z digit_value
// if (started || value >= digit_value)
lda.z started
bne __b5
cpx.z digit_value
bcs __b5
__b4:
// for( char digit=0; digit<max_digits-1; digit++ )
inc.z digit
jmp __b1
__b5:
// uctoa_append(buffer++, value, digit_value)
jsr uctoa_append
// uctoa_append(buffer++, value, digit_value)
// value = uctoa_append(buffer++, value, digit_value)
// value = uctoa_append(buffer++, value, digit_value);
inc.z buffer
bne !+
inc.z buffer+1
!:
lda #1
sta.z started
jmp __b4
}
// Used to convert a single digit of an unsigned number value to a string representation
// Counts a single digit up from '0' as long as the value is larger than sub.
// Each time the digit is increased sub is subtracted from value.
// - buffer : pointer to the char that receives the digit
// - value : The value where the digit will be derived from
// - sub : the value of a '1' in the digit. Subtracted continually while the digit is increased.
// (For decimal the subs used are 10000, 1000, 100, 10, 1)
// returns : the value reduced by sub * digit so that it is less than sub.
// __zp($19) unsigned int utoa_append(__zp(4) char *buffer, __zp($19) unsigned int value, __zp(2) unsigned int sub)
utoa_append: {
.label buffer = 4
.label value = $19
.label sub = 2
.label return = $19
ldx #0
__b1:
// while (value >= sub)
lda.z sub+1
cmp.z value+1
bne !+
lda.z sub
cmp.z value
beq __b2
!:
bcc __b2
// *buffer = DIGITS[digit]
lda DIGITS,x
ldy #0
sta (buffer),y
// }
rts
__b2:
// digit++;
inx
// value -= sub
lda.z value
sec
sbc.z sub
sta.z value
lda.z value+1
sbc.z sub+1
sta.z value+1
jmp __b1
}
// Computes the length of the string str up to but not including the terminating null character.
// __zp(2) unsigned int strlen(__zp(6) char *str)
strlen: {
.label len = 2
.label str = 6
.label return = 2
lda #<0
sta.z len
sta.z len+1
lda #<printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
sta.z str
lda #>printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
sta.z str+1
__b1:
// while(*str)
ldy #0
lda (str),y
cmp #0
bne __b2
// }
rts
__b2:
// len++;
inc.z len
bne !+
inc.z len+1
!:
// str++;
inc.z str
bne !+
inc.z str+1
!:
jmp __b1
}
// Print a padding char a number of times
// void printf_padding(void (*putc)(char), __zp($c) char pad, __zp($1c) char length)
printf_padding: {
.label i = $18
.label length = $1c
.label pad = $c
lda #0
sta.z i
__b1:
// for(char i=0;i<length; i++)
lda.z i
cmp.z length
bcc __b2
// }
rts
__b2:
// putc(pad)
lda.z pad
pha
jsr cputc
pla
// for(char i=0;i<length; i++)
inc.z i
jmp __b1
}
// Used to convert a single digit of an unsigned number value to a string representation
// Counts a single digit up from '0' as long as the value is larger than sub.
// Each time the digit is increased sub is subtracted from value.
// - buffer : pointer to the char that receives the digit
// - value : The value where the digit will be derived from
// - sub : the value of a '1' in the digit. Subtracted continually while the digit is increased.
// (For decimal the subs used are 10000, 1000, 100, 10, 1)
// returns : the value reduced by sub * digit so that it is less than sub.
// __zp(8) unsigned long ultoa_append(__zp($16) char *buffer, __zp(8) unsigned long value, __zp($d) unsigned long sub)
ultoa_append: {
.label buffer = $16
.label value = 8
.label sub = $d
.label return = 8
ldx #0
__b1:
// while (value >= sub)
lda.z value+3
cmp.z sub+3
bcc !+
bne __b2
lda.z value+2
cmp.z sub+2
bcc !+
bne __b2
lda.z value+1
cmp.z sub+1
bcc !+
bne __b2
lda.z value
cmp.z sub
bcs __b2
!:
// *buffer = DIGITS[digit]
lda DIGITS,x
ldy #0
sta (buffer),y
// }
rts
__b2:
// digit++;
inx
// value -= sub
lda.z value
sec
sbc.z sub
sta.z value
lda.z value+1
sbc.z sub+1
sta.z value+1
lda.z value+2
sbc.z sub+2
sta.z value+2
lda.z value+3
sbc.z sub+3
sta.z value+3
jmp __b1
}
// Used to convert a single digit of an unsigned number value to a string representation
// Counts a single digit up from '0' as long as the value is larger than sub.
// Each time the digit is increased sub is subtracted from value.
// - buffer : pointer to the char that receives the digit
// - value : The value where the digit will be derived from
// - sub : the value of a '1' in the digit. Subtracted continually while the digit is increased.
// (For decimal the subs used are 10000, 1000, 100, 10, 1)
// returns : the value reduced by sub * digit so that it is less than sub.
// __register(X) char uctoa_append(__zp($16) char *buffer, __register(X) char value, __zp($c) char sub)
uctoa_append: {
.label buffer = $16
.label sub = $c
ldy #0
__b1:
// while (value >= sub)
cpx.z sub
bcs __b2
// *buffer = DIGITS[digit]
lda DIGITS,y
ldy #0
sta (buffer),y
// }
rts
__b2:
// digit++;
iny
// value -= sub
txa
sec
sbc.z sub
tax
jmp __b1
}
.segment Data
// The digits used for numbers
DIGITS: .text "0123456789abcdef"
// Values of decimal digits
RADIX_DECIMAL_VALUES_CHAR: .byte $64, $a
// Values of decimal digits
RADIX_DECIMAL_VALUES: .word $2710, $3e8, $64, $a
// Values of hexadecimal digits
RADIX_HEXADECIMAL_VALUES_LONG: .dword $10000000, $1000000, $100000, $10000, $1000, $100, $10
// The different ROL/ROR values
rols: .byte 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, $c, $f, $10, $11, $14, $17, $18, $19, $1c, $1f, $20
s1: .text ": "
.byte 0
s2: .text @"\n"
.byte 0
// Buffer used for stringified number being printed
printf_buffer: .fill SIZEOF_STRUCT_PRINTF_BUFFER_NUMBER, 0
|
bios/functions.asm | shift-crops/x86emu | 85 | 175092 | <reponame>shift-crops/x86emu
global write_esb, write_esw, write_esd, copy_esw
global in_port, out_port, _cli, _sti
BITS 16
write_esb:
push ebp
mov ebp, esp
push edi
mov di, word [ebp+0x8]
mov eax, dword [ebp+0xc]
mov byte [es:di], al
pop edi
o32 leave
o32 ret
write_esw:
push ebp
mov ebp, esp
push edi
mov di, word [ebp+0x8]
mov eax, dword [ebp+0xc]
mov word [es:di], ax
pop edi
o32 leave
o32 ret
write_esd:
push ebp
mov ebp, esp
push edi
mov di, word [ebp+0x8]
mov eax, dword [ebp+0xc]
mov dword [es:di], eax
pop edi
o32 leave
o32 ret
copy_esw:
push ebp
mov ebp, esp
push esi
push edi
mov di, word [ebp+0x8]
mov si, word [ebp+0xc]
mov ax, word [es:si]
mov word [es:di], ax
pop edi
pop esi
o32 leave
o32 ret
in_port:
push ebp
mov ebp, esp
push edx
mov edx, dword [ebp+0x8]
xor eax, eax
in al, dx
pop edx
o32 leave
o32 ret
out_port:
push ebp
mov ebp, esp
push eax
push edx
mov edx, dword [ebp+0x8]
mov eax, dword [ebp+0xc]
out dx, al
pop edx
pop eax
o32 leave
o32 ret
_cli:
cli
o32 ret
_sti:
sti
o32 ret
|
pixy/src/host/pantilt_in_ada/specs/x86_64_linux_gnu_sys_select_h.ads | GambuzX/Pixy-SIW | 1 | 7527 | --
-- Copyright (c) 2015, <NAME> <<EMAIL>>
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above copyright
-- notice and this permission notice appear in all copies.
--
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
-- TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
-- NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
-- CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
-- PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-- ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
--
pragma Ada_2005;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with x86_64_linux_gnu_bits_sigset_h;
limited with x86_64_linux_gnu_bits_time_h;
limited with time_h;
package x86_64_linux_gnu_sys_select_h is
-- unsupported macro: FD_SETSIZE __FD_SETSIZE
-- unsupported macro: NFDBITS __NFDBITS
-- arg-macro: procedure FD_SET (fd, fdsetp)
-- __FD_SET (fd, fdsetp)
-- arg-macro: procedure FD_CLR (fd, fdsetp)
-- __FD_CLR (fd, fdsetp)
-- arg-macro: procedure FD_ISSET (fd, fdsetp)
-- __FD_ISSET (fd, fdsetp)
-- arg-macro: procedure FD_ZERO (fdsetp)
-- __FD_ZERO (fdsetp)
subtype sigset_t is x86_64_linux_gnu_bits_sigset_h.uu_sigset_t;
subtype uu_fd_mask is long; -- /usr/include/x86_64-linux-gnu/sys/select.h:54
type fd_set_fds_bits_array is array (0 .. 15) of aliased uu_fd_mask;
type fd_set is record
fds_bits : aliased fd_set_fds_bits_array; -- /usr/include/x86_64-linux-gnu/sys/select.h:69
end record;
pragma Convention (C_Pass_By_Copy, fd_set); -- /usr/include/x86_64-linux-gnu/sys/select.h:75
-- skipped anonymous struct anon_10
subtype fd_mask is uu_fd_mask; -- /usr/include/x86_64-linux-gnu/sys/select.h:82
function c_select
(uu_nfds : int;
uu_readfds : access fd_set;
uu_writefds : access fd_set;
uu_exceptfds : access fd_set;
uu_timeout : access x86_64_linux_gnu_bits_time_h.timeval) return int; -- /usr/include/x86_64-linux-gnu/sys/select.h:106
pragma Import (C, c_select, "select");
function pselect
(uu_nfds : int;
uu_readfds : access fd_set;
uu_writefds : access fd_set;
uu_exceptfds : access fd_set;
uu_timeout : access constant time_h.timespec;
uu_sigmask : access constant x86_64_linux_gnu_bits_sigset_h.uu_sigset_t) return int; -- /usr/include/x86_64-linux-gnu/sys/select.h:118
pragma Import (C, pselect, "pselect");
end x86_64_linux_gnu_sys_select_h;
|
Old Programmes/8085/Multiplication/REPADD_16.asm | illuminati-inc-2020/school | 0 | 162354 | <filename>Old Programmes/8085/Multiplication/REPADD_16.asm
;Multiplication of 2 2byte numbers using repeatative addition
;Input : 00A0H, 00A1H <- Multiplicand
; : 00B0H, 00B1H <- Multiplier
;Output : 00C0H, 00C1H, 00C2H, 00C3H <- Product
LHLD 00A0H
MOV B, H
MOV C, L
LHLD 00B0H
LXI SP, 00D0H
XTHL
MVI D, 00H
MOV E, D
MOV H, E
MOV L, H
LOOP: SUB A
DAD B
ADC E
ADC D
XTHL
DCX H
MOV A, H
ORA L
XTHL
JNZ LOOP
SHLD 00C0H
MOV H, D
MOV L, E
SHLD 00C2H
HLT |
libsrc/_DEVELOPMENT/l/z80/l_ldd.asm | jpoikela/z88dk | 640 | 169622 | <gh_stars>100-1000
INCLUDE "config_private.inc"
IF (__CLIB_OPT_UNROLL & 0xc0)
SECTION smc_clib
SECTION smc_l
ELSE
SECTION code_clib
SECTION code_l
ENDIF
PUBLIC l_ldd
PUBLIC l_ldd_256
PUBLIC l_ldd_128
PUBLIC l_ldd_64
PUBLIC l_ldd_32
PUBLIC l_ldd_16
PUBLIC l_ldd_8
PUBLIC l_ldd_4
PUBLIC l_ldd_2
PUBLIC l_ldd_1
defc l_ldd_32 = l_ldd_64 + 64
defc l_ldd_16 = l_ldd_32 + 32
defc l_ldd_8 = l_ldd_16 + 16
defc l_ldd_4 = l_ldd_8 + 8
defc l_ldd_2 = l_ldd_4 + 4
defc l_ldd_1 = l_ldd_2 + 2
l_ldd_256:
call l_ldd_128
l_ldd_128:
call l_ldd_64
IF (__CLIB_OPT_UNROLL & 0xc0)
jp l_ldd_64
sub_14:
or a
ret z
lddr
ret
PUBLIC l_ldd_loop_smc
PUBLIC l_ldd_loop_smc_0
PUBLIC l_ldd_loop_smc_small
l_ldd_loop_smc:
ld a,b
or a
jp z, fine
l_ldd_loop_smc_0:
coarse:
call l_ldd_256
dec a
jp nz, coarse
l_ldd_loop_smc_small:
fine:
ld a,c
cp 14
jp c, sub_14
add a,a
call c, l_ldd_128
add a,a
call c, l_ldd_64
ret z
enter_loop:
xor a
sub c
and $3f
add a,a
ld (active_jr + 1),a
active_jr:
jr 0
ENDIF
l_ldd_64:
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
ldd
l_ldd:
ret
|
asm/scriptcode/tenko/tenko1start.asm | Dimedime-d/kptranslation | 3 | 10149 | .byte 0x02,0x00,0x09,0x00
.word 0x08095838
.byte 0x09,0x00,0x0F,0x00
.byte 0x02,0x00,0x00,0x00
.byte 0x00,0x01,0x00,0x00
.byte 0x00,0x1E,0x00,0x03
.byte 0x09,0x00,0x00,0x00
.byte 0x02,0x00,0x00,0x00
.byte 0xCC,0x14,0x0A,0x00
.byte 0xA2,0x36,0x00,0x00
.byte 0x09,0x00,0x01,0x00
.byte 0x02,0x00,0x00,0x00
.byte 0x70,0x4B,0x0A,0x00
.byte 0xB0,0x04,0x00,0x00
.byte 0x09,0x00,0x02,0x00
.byte 0x02,0x00,0x00,0x00
.byte 0x20,0x50,0x0A,0x00
.byte 0xF0,0x00,0x00,0x00
.byte 0x00,0x00,0x00,0x00
.byte 0x09,0x00,0x0E,0x00
.byte 0x02,0x00,0x00,0x00
.byte 0x09,0x00,0x08,0x00
.byte 0x02,0x00,0x00,0x00
.byte 0x1E,0x00,0x00,0x00
.byte 0x14,0x00,0x00,0x00
.byte 0x09,0x00,0x03,0x00
.byte 0x02,0x00,0x00,0x00
.byte 0x09,0x00,0x09,0x00
.byte 0x02,0x00,0x00,0x00
.byte 0x00,0x00,0x00,0x00
.byte 0x00,0x00,0x00,0x00
.byte 0x09,0x00,0x11,0x00
.byte 0x02,0x00,0x00,0x00
.byte 0x00,0x00,0x00,0x00
.byte 0x08,0x00,0x00,0x00
.byte 0x00,0x00,0x00,0x00
.byte 0x09,0x00,0x04,0x00
.byte 0x02,0x00,0x00,0x00
.byte 0x00,0x00,0x00,0x00
.byte 0x01,0x00,0x01,0x00
.byte 0x0C,0x00,0x00,0x00
.byte 0x42,0x00,0x00,0x00
.byte 0xF0,0x00,0x00,0x00
.byte 0x0C,0x00,0x00,0x00
.byte 0x46,0x00,0x00,0x00
.byte 0x14,0x00,0x00,0x00
.byte 0x0C,0x00,0x02,0x00
.byte 0x48,0x00,0x00,0x00
.byte 0x3F,0x00,0x00,0x00
.byte 0x0C,0x00,0x01,0x00
.byte 0x48,0x00,0x00,0x00
.byte 0x00,0x00,0x00,0x00
.byte 0x0C,0x00,0x00,0x00
.byte 0x4A,0x00,0x00,0x00
.byte 0x3F,0x00,0x00,0x00
.byte 0x0C,0x00,0x01,0x00
.byte 0x00,0x00,0x00,0x00
.byte 0x00,0x40,0x00,0x00
@loc1:
.byte 0x0A,0x00,0x01,0x00
.byte 0x00,0x00,0x00,0x00
.byte 0x00,0x00,0x00,0x00
.byte 0x02,0x00,0x09,0x00
.word 0x080A388C
.byte 0x0A,0x00,0x01,0x00
.byte 0x00,0x00,0x00,0x00
.byte 0x01,0x00,0x00,0x00
.byte 0x06,0x00,0x00,0x00
.byte 0x07,0xFF,0xFF,0x7F
.byte 0x5A,0x00,0x00,0x00
.byte 0x02,0x00,0x09,0x00
.word 0x080A38F8
.byte 0x0A,0x00,0x01,0x00
.byte 0x00,0x00,0x00,0x00
.byte 0x02,0x00,0x00,0x00
.byte 0x0A,0x00,0x01,0x00
.byte 0x01,0x00,0x00,0x00
.byte 0x2F,0x00,0x00,0x00
loadCharsAndSfx s_tenko1start1
.byte 0x02,0x00,0x09,0x00
.word 0x08095F94
.byte 0x05,0x00,0x02,0x00
.byte 0x00,0x00,0x00,0x00
.byte 0x09,0x00,0x05,0x00
.byte 0x02,0x00,0x00,0x00
.byte 0x5A,0x00,0x00,0x00
.byte 0x0A,0x00,0x01,0x00
.byte 0x00,0x00,0x00,0x00
.byte 0x03,0x00,0x00,0x00
.byte 0x0A,0x00,0x01,0x00
.byte 0x01,0x00,0x00,0x00
.byte 0x30,0x00,0x00,0x00
.byte 0x02,0x00,0x09,0x00
.word 0x080A38B0
.byte 0x0A,0x00,0x01,0x00
.byte 0x00,0x00,0x00,0x00
.byte 0x03,0x00,0x00,0x00
.byte 0x0A,0x00,0x01,0x00
.byte 0x01,0x00,0x00,0x00
.byte 0x31,0x00,0x00,0x00
loadCharsAndSfx s_tenko1start2
.byte 0x02,0x00,0x09,0x00
.word 0x08095F94
.byte 0x05,0x00,0x02,0x00
.byte 0x00,0x00,0x00,0x00
.byte 0x0A,0x00,0x01,0x00
.byte 0x00,0x00,0x00,0x00
.byte 0x04,0x00,0x00,0x00
.byte 0x0A,0x00,0x01,0x00
.byte 0x01,0x00,0x00,0x00
.byte 0x32,0x00,0x00,0x00
loadCharsAndSfx s_tenko1start3
.byte 0x02,0x00,0x09,0x00
.word 0x08095F3C
.byte 0x05,0x00,0x02,0x00
.byte 0x00,0x00,0x00,0x00
.byte 0x0A,0x00,0x01,0x00
.byte 0x00,0x00,0x00,0x00
.byte 0x03,0x00,0x00,0x00
.byte 0x0A,0x00,0x01,0x00
.byte 0x01,0x00,0x00,0x00
.byte 0x31,0x00,0x00,0x00
loadCharsAndSfx s_tenko1start4
.byte 0x02,0x00,0x09,0x00
.word 0x08095F94
.byte 0x05,0x00,0x02,0x00
.byte 0x00,0x00,0x00,0x00
.byte 0x0A,0x00,0x01,0x00
.byte 0x00,0x00,0x00,0x00
.byte 0x03,0x00,0x00,0x00
.byte 0x0A,0x00,0x01,0x00
.byte 0x01,0x00,0x00,0x00
.byte 0x33,0x00,0x00,0x00
loadCharsAndSfx s_tenko1start5
.byte 0x02,0x00,0x09,0x00
.word 0x08095F94
.byte 0x05,0x00,0x02,0x00
.byte 0x00,0x00,0x00,0x00
.byte 0x0A,0x00,0x01,0x00
.byte 0x00,0x00,0x00,0x00
.byte 0x03,0x00,0x00,0x00
.byte 0x0A,0x00,0x01,0x00
.byte 0x01,0x00,0x00,0x00
.byte 0x34,0x00,0x00,0x00
loadCharsAndSfx s_tenko1start6
.byte 0x02,0x00,0x09,0x00
.word 0x08095F94
.byte 0x05,0x00,0x02,0x00
.byte 0x00,0x00,0x00,0x00
.byte 0x0A,0x00,0x01,0x00
.byte 0x00,0x00,0x00,0x00
.byte 0x06,0x00,0x00,0x00
.byte 0x0A,0x00,0x01,0x00
.byte 0x01,0x00,0x00,0x00
.byte 0x32,0x00,0x00,0x00
loadCharsAndSfx s_tenko1start7
.byte 0x02,0x00,0x09,0x00
.word 0x08095F3C
.byte 0x05,0x00,0x02,0x00
.byte 0x00,0x00,0x00,0x00
.byte 0x0A,0x00,0x01,0x00
.byte 0x00,0x00,0x00,0x00
.byte 0x03,0x00,0x00,0x00
.byte 0x0A,0x00,0x01,0x00
.byte 0x01,0x00,0x00,0x00
.byte 0x35,0x00,0x00,0x00
loadCharsAndSfx s_tenko1start8
.byte 0x02,0x00,0x09,0x00
.word 0x08095F94
.byte 0x05,0x00,0x02,0x00
.byte 0x00,0x00,0x00,0x00
.byte 0x0A,0x00,0x01,0x00
.byte 0x00,0x00,0x00,0x00
.byte 0x03,0x00,0x00,0x00
.byte 0x0A,0x00,0x01,0x00
.byte 0x01,0x00,0x00,0x00
.byte 0x36,0x00,0x00,0x00
loadCharsAndSfx s_tenko1start9
.byte 0x02,0x00,0x09,0x00
.word 0x08095F94
.byte 0x05,0x00,0x02,0x00
.byte 0x00,0x00,0x00,0x00
.byte 0x00,0x00,0x01,0x00 |
src/joypad.asm | mdsteele/nesfxr | 1 | 103169 | <reponame>mdsteele/nesfxr
.INCLUDE "joypad.inc"
;;;=========================================================================;;;
.ZEROPAGE
;;; ButtonsHeld: A bitfield indicating which player 1 buttons are currently
;;; being held.
.EXPORTZP Zp_P1ButtonsHeld_u8
Zp_P1ButtonsHeld_u8: .res 1
;;; ButtonsPressed: A bitfield indicating which player 1 buttons have been
;;; newly pressed since the previous call to Func_UpdateButtons.
.EXPORTZP Zp_P1ButtonsPressed_u8
Zp_P1ButtonsPressed_u8: .res 1
;;;=========================================================================;;;
.CODE
;;; Helper function for Func_UpdateButtons. Reads buttons from joypad and
;;; populates Zp_P1ButtonsHeld_u8.
;;; @preserve X, Y
.PROC Func_ReadButtons
;; This function's code comes almost directly from
;; https://wiki.nesdev.org/w/index.php/Controller_reading_code.
lda #1
;; While the strobe bit is set, buttons will be continuously reloaded.
;; This means that reading from rJOYPAD1 will only return the state of the
;; first button: button A.
sta rJOYPAD1
sta Zp_P1ButtonsHeld_u8 ; Initialize with a 1 bit, to be used later.
lsr a ; now A is 0
;; By storing 0 into rJOYPAD1, the strobe bit is cleared and the reloading
;; stops. This allows all 8 buttons (newly reloaded) to be read from
;; JOYPAD1.
sta rJOYPAD1
@loop:
lda rJOYPAD1
lsr a ; bit 0 -> Carry
rol Zp_P1ButtonsHeld_u8 ; Carry -> bit 0; bit 7 -> Carry
bcc @loop ; Stop when the initial 1 bit is finally shifted into Carry.
rts
.ENDPROC
;;; Reads buttons from joypad and populates Zp_P1ButtonsHeld_u8 and
;;; Zp_P1ButtonsPressed_u8.
.EXPORT Func_UpdateButtons
.PROC Func_UpdateButtons
;; Store the buttons *not* held last frame in Y.
lda Zp_P1ButtonsHeld_u8
eor #$ff
tay
;; Apparently, when using APU DMC playback, controller reading will
;; sometimes glitch. One standard workaround (used by e.g. Super Mario
;; Bros. 3) is to read the controller repeatedly until you get the same
;; result twice in a row. This part of the code is adapted from
;; https://wiki.nesdev.org/w/index.php/Controller_reading_code.
jsr Func_ReadButtons ; preserves X and Y
@rereadLoop:
ldx Zp_P1ButtonsHeld_u8
jsr Func_ReadButtons ; preserves X and Y
txa
cmp Zp_P1ButtonsHeld_u8
bne @rereadLoop
;; Now that we have a reliable value for Zp_P1ButtonsHeld_u8, we can set
;; Zp_P1ButtonsPressed_u8 to the buttons that are newly held this frame.
tya
and Zp_P1ButtonsHeld_u8
sta Zp_P1ButtonsPressed_u8
rts
.ENDPROC
;;;=========================================================================;;;
|
serial_rom/src/main.asm | zer0x64/nsec2022-gband | 0 | 19153 | ; ------------------------------
; This simple test rom will send a counter through
; the serial port
;
; One machine will be initiated as P1 and
; the other as P2 using Start and Select
;
; P1 will have an even counter, and P2
; an odd counter
;
; The 2 players send each other their counter
; increment, and send back the counter they received
; ------------------------------
include "hardware.inc"
; ------------------------------
; RAM variables
; ------------------------------
def PAD equ _RAM ; Current state of the joypad
def LOCAL_COUNTER equ _RAM+1 ; Local player counter
def RECEIVED_COUNTER equ _RAM+2 ; Received counter for debugging
def COMPARE_RESULT equ _RAM+3 ; Comparison result, if zero then it's equal
; ------------------------------
; Main executable code
; ------------------------------
section "Main", rom0[$0100]
nop
jp main
ds $150 - @, 0 ; Make room for the header
main:
di
ld sp, $ffff
ld hl, rSB
.wait_input:
call read_joypad
ld a, [PAD]
and PADF_START
jr nz, .p1
ld a, [PAD]
and PADF_SELECT
jr nz, .p2
call delay
jr .wait_input
.p1:
; Init the counter
ld a, 0
ld [LOCAL_COUNTER], a
:
; Send P1 counter
ld a, [LOCAL_COUNTER]
call sio_master_transfer
call sio_wait_transfer
; Read P2 counter, increment and send back
ld a, [hl]
add 2
call sio_slave_transfer
call sio_wait_transfer
; Get returned counter
ld a, [hl]
ld [RECEIVED_COUNTER], a
ld b, a
; Increment P1 Counter
ld a, [LOCAL_COUNTER]
add 2
ld [LOCAL_COUNTER], a
; Compare for fun (not much that can be done without display)
sub b
ld [COMPARE_RESULT], a
; Loop
ld bc, 2
ld de, 40000
call big_delay
jr :-
.p2:
; Init the counter
ld a, 1
ld [LOCAL_COUNTER], a
:
; Receive P1 counter, add and send back
ld a, [LOCAL_COUNTER]
call sio_slave_transfer
call sio_wait_transfer
ld a, [hl]
add 2
call sio_master_transfer
call sio_wait_transfer
; Increment P2 Counter
ld a, [LOCAL_COUNTER]
add 2
ld [LOCAL_COUNTER], a
; Retrieve counter returned by P1
ld a, [hl]
ld [RECEIVED_COUNTER], a
ld b, a
; Compare for fun (not much that can be done without display)
sub b
ld [COMPARE_RESULT], a
; Loop
ld bc, 2
ld de, 40000
call big_delay
jr :-
; ------------------------------
; Get pressed buttons on the joypad
;
; Stores the result in `PAD`
; ------------------------------
read_joypad:
push bc
ld a, P1F_GET_DPAD
ld [rP1], a
; Read the state of the dpad, with bouncing protection
ld a, [rP1]
ld a, [rP1]
ld a, [rP1]
ld a, [rP1]
and $0F
swap a
ld b, a
ld a, P1F_GET_BTN
ld [rP1], a
; Read the state of the buttons, with bouncing protection
ld a, [rP1]
ld a, [rP1]
ld a, [rP1]
ld a, [rP1]
and $0F
or b
cpl
ld [PAD], a
pop bc
ret
; ------------------------------
; Wait for 60000+15 cycles (~1.4ms)
; ------------------------------
delay:
push de
ld de, 6000
:
dec de
ld a, d
or e
jr z, :+
nop
jr :-
:
pop de
ret
; ------------------------------
; Wait for about (de*10) * bc cycles
;
; Inputs:
; - de: Nb cycles per iteration
; - bc: Nb iterations
; ------------------------------
big_delay:
.iter:
dec bc
ld a, b
or c
jr z, .end
.loop:
dec de
ld a, d
or e
jr z, .iter
nop
jr .loop
.end
ret
;;;
; .loop:
; ld a, [SIOTYPE]
; or a
; jr nz, .start
; call read_joypad
; ld a, [PAD]
; and PADF_START
; jp z, .skip
; call init_sio_master
; .run:
; call read_joypad
; ld a, [PAD]
; ld [TD], a
; ld a, [SIOTYPE]
; cp MASTER_MODE
; call z, init_sio_master
; .skip:
; ld a, [RD]
; ;???
; .done:
; call delay
; jr .loop
;; .slave:
;; jr .done
;; .master:
;; ld a, [PAD]
;; ld [rSB], a
;; ld a, SCF_START | SCF_SOURCE
;; ld [rSC], a
;; jr .done
;;;
; ld a, [PAD]
; ld [rSB], a
; Temp write a newline for log
; ld a, 10
; ld [rSB], a
; ld a, SCF_START | SCF_SOURCE
; ld [rSC], a
;; ld a, [PAD]
;; and PADF_SELECT
;; jr nz, .slave
;; ld a, [PAD]
;; and PADF_START
;; jr z, .master
|
examples/outdated-and-incorrect/Alonzo/PreludeAll.agda | asr/agda-kanso | 1 | 9616 | module PreludeAll where
import PreludeBool public
import PreludeNat
import PreludeShow
open PreludeBool
open PreludeNat
open PreludeShow |
src/main/antlr4/com/aodocs/partialresponse/fieldsexpression/parser/FieldsExpression.g4 | AODocs/endpoints-partialresponse | 1 | 6723 | grammar FieldsExpression;
//valid field names are anything but the syntax chars and whitespaces
//TODO actual valid key names might not allow such a broad range of chars
//TODO syntax chars might be escaped, to be checked a real API
//see https://github.com/antlr/grammars-v4/blob/master/json/JSON.g4
FIELDNAME: ~(',' | '/' | ')' | '(' | [ \t\r\n])+;
expression : selection (',' selection)*;
selection : FIELDNAME ('/' FIELDNAME)* ('(' expression ')')?;
WS : [ \t\r\n]+ -> skip ;
|
3-mid/opengl/source/lean/model/opengl-model-hexagon.adb | charlie5/lace | 20 | 30090 | package body openGL.Model.hexagon
is
function vertex_Sites (Radius : in Real) return Sites
is
use linear_Algebra_3d;
the_Site : Vector_3 := (Radius, 0.0, 0.0);
Rotation : constant Matrix_3x3 := y_Rotation_from (to_Radians (60.0));
the_Sites : Sites;
begin
for i in the_Sites'Range
loop
the_Sites (i) := the_Site;
the_Site := Rotation * the_Site;
end loop;
return the_Sites;
end vertex_Sites;
end openGL.Model.hexagon;
|
zx_rom_beeper.asm | imneme/spectrum-minilib | 1 | 12016 | <filename>zx_rom_beeper.asm
INCLUDE "romdefs.inc"
SECTION code_clib
GLOBAL _zx_rom_beeper
_zx_rom_beeper:
pop af ; retaddr
pop de ; freqtime
pop hl ; tstates
push af ; restore retaddr
push ix
call ROM3_BEEPER
pop ix
ret
|
original version (1984)/asm/map03-init.asm | fa8ntomas/bclk-samples | 0 | 247581 | lda #$03
sta MapVar1
rts |
list3/task3/c/src/bubble.adb | luk9400/nsi | 0 | 0 | <reponame>luk9400/nsi<gh_stars>0
package body Bubble with SPARK_Mode is
procedure Sort (A : in out Arr) is
Tmp : Integer;
begin
Outer: for I in reverse A'First .. A'Last - 1 loop
Inner: for J in A'First .. I loop
if A(J) > A(J + 1) then
Tmp := A(J);
A(J) := A(J + 1);
A(J + 1) := Tmp;
end if;
pragma Loop_Invariant (for all K1 in A'Range => (for some K2 in A'Range => A(K2) = A'Loop_Entry(Inner)(K1)));
end loop Inner;
pragma Loop_Invariant (for all K1 in A'Range => (for some K2 in A'Range => A(K2) = A'Loop_Entry(Outer)(K1)));
end loop Outer;
end Sort;
end Bubble;
|
libsrc/stdio/osca/getk.asm | grancier/z180 | 0 | 16409 | ;
; Basic keyboard handling for the OSCA architecture
; By <NAME> Jul. 2011
;
; getk() Read key status
;
;
; $Id: getk.asm,v 1.4 2016/06/12 17:32:01 dom Exp $
;
INCLUDE "flos.def"
SECTION code_clib
PUBLIC getk
PUBLIC _getk
.getk
._getk
call kjt_get_key
or a
jr nz,knz
ld b,a
.knz
cp $5a
jr nz,noent
ld b,13
.noent
cp $6b
jr nz,noleft
ld b,8
.noleft
cp $74
jr nz,noright
ld b,9
.noright
cp $75
jr nz,noup
ld b,11
.noup
cp $72
jr nz,nodown
ld b,10
.nodown
cp $71
jr z,isdel
cp $66
jr nz,nodel
.isdel
jr nz,nodel
ld b,12
.nodel
ld l,b ; ASCII CODE
ld h,0
ret
|
alloy4fun_models/trashltl/models/5/iyyBmrarRSsXHm32z.als | Kaixi26/org.alloytools.alloy | 0 | 2502 | open main
pred idiyyBmrarRSsXHm32z_prop6 {
some f : File | always f in Trash since f in Trash
}
pred __repair { idiyyBmrarRSsXHm32z_prop6 }
check __repair { idiyyBmrarRSsXHm32z_prop6 <=> prop6o } |
ANTLR/JSONLDGraphGenerator/fuente/GrammarInputParser.g4 | Alvarohf/University-work | 0 | 7604 | <reponame>Alvarohf/University-work<gh_stars>0
parser grammar GrammarInputParser;
options {
tokenVocab = GrammarInputLexer;
language = Java;
}
@header{
package fuente;
}
//ROOT
input: (file|styleParameters)+ EOF;
//FILE PARAMETER
file: (csvid|jsonid|svgid|dotid) path;
jsonid: JSONID;
csvid:CSVID;
svgid: SVGID;
dotid:DOTID;
path: (TEXT|numberValue)+;
//TARGET ELEMENT IN DOT
field: (node|edge);
edge: EDGE;
node: NODE;
//STYLE PARAMETERS
styleParameters: (len|fontcolor|fontsize|fontname|arrowsize|arrowcolor|penwd|fillcolor|shape|style);
params: (classes|relationship|inheritance|indirect_use|property);
classes: CLASS;
relationship: RELATIONSHIP;
inheritance: INHERITANCE;
indirect_use: INDIRECT_USE;
property: PROPERTY;
fontsize: FONTSIZE field params numberValue;
len: LEN params numberValue;
fontcolor: FONTCOLOR field params string;
fontname: FONTNAME field params string;
arrowsize: ARROWSIZE field params numberValue;
arrowcolor: ARROWCOLOR field params string;
penwd: PENWD field params numberValue;
fillcolor: FILLCOLOR field params string;
shape: SHAPE field params string;
style: STYLE field params string;
//POSIBLE VALUES FOR STYLE PARAMETERS
string: STRINGS|path;
numberValue: INT; |
Library/Gadgets/UI/uiDateSelector.asm | steakknife/pcgeos | 504 | 171945 | <filename>Library/Gadgets/UI/uiDateSelector.asm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) Geoworks 1994 -- All Rights Reserved
PROJECT: Interface Gadgets
MODULE: Date Selector Gadget
FILE: uiDateSelector.asm
AUTHOR: <NAME>, Jun 24, 1994
ROUTINES:
Name Description
---- -----------
INT CopyBuildInfoCommon Return group
INT PrependText This message is sent by the output in
response to
MSG_DATE_SELECTOR_REPLACE_YEAR_TEXT to the
DateSelector, passing a fptr to a
null-terminated string which is
appended/prepended to the year.
INT AppendText This message is sent by the output in
response to
MSG_DATE_SELECTOR_REPLACE_YEAR_TEXT to the
DateSelector, passing a fptr to a
null-terminated string which is
appended/prepended to the year.
INT DSSetDateForReal Message sent to the DateSelector to change
the current displayed date.
INT SendDSActionMessage Sends the action message (DSI_actionMsg) to
the output (GCI_output).
INT GetWeekNumber Calculates the week number given a date
INT DecrementWeek Decrements the date by one week (seven
days)
INT IncrementWeek Increments the date by one week (that's
seven days)
INT DecrementMonth Decrements the current month by 1. The day
will be set to 1. The day of week will be
invalid.
INT IncrementMonth Decrements the current month by 1. The day
will be set to 1. The day of week will be
invalid.
INT DecrementYear Decrements the year by one. The date is
set to 01.01 and the week day is invalid.
INT IncrementYear Increments the year by one. The date is
set to 01.01 and the week day is invalid.
INT UpdateDateSelectorText Update the DSText according to
DSI_dateType.
INT DisplayLongCondensedDate
Sets up the size of the GenText, formats
the date in the correct format and displays
it in the GenText.
INT DisplayLongDate Sets up the size of the GenText, formats
the date in the correct format and displays
it in the GenText.
INT DisplayShortDate Sets up the size of the GenText, formats
the date in the correct format and displays
it in the GenText.
INT DisplayZPaddedShortDate Sets up the size of the GenText, formats
the date in the correct format and displays
it in the GenText.
INT DisplayWeek Sets up the size of the GenText, formats
the date in the correct format and displays
it in the GenText.
INT DisplayWeekYear Sets up the size of the GenText, formats
the date in the correct format and displays
it in the GenText.
INT DisplayMonth Sets up the size of the GenText, formats
the date in the correct format and displays
it in the GenText.
INT DisplayShortMonth Sets up the size of the GenText, formats
the date in the correct format and displays
it in the GenText.
INT DisplayMonthYear Sets up the size of the GenText, formats
the date in the correct format and displays
it in the GenText.
INT DisplayShortMonthYear Sets up the size of the GenText, formats
the date in the correct format and displays
it in the GenText.
INT DisplayShortMonthShortYear
Sets up the size of the GenText, formats
the date in the correct format and displays
it in the GenText.
INT DisplayYear Sets up the size of the GenText, formats
the date in the correct format and displays
it in the GenText.
INT DisplayYearText Sets up the size of the GenText, formats
the date in the correct format and displays
it in the GenText.
INT DisplayWeekday Sets up the size of the GenText, formats
the date in the correct format and displays
it in the GenText.
INT DisplayShortWeekday Sets up the size of the GenText, formats
the date in the correct format and displays
it in the GenText.
INT InitDateSelector Sets the fixed size of the GenText object
of the controller. The text is centered
within the GenText. You can override this
default by setting the textWidth field in
instance data.
INT SetTextFrame Draws a frame around the GenText if
HINT_DATE_SELECTOR_DRAW_FRAME is defined on
the object.
INT SetIncDecTriggersNotUsable
If GA_READ_ONLY is set this function the
Inc and Dec triggers not usable.
INT SetGenTextDefaultWidth Sets the default width of the GenText
object used to display the date. The
default width varies depending on what
dateType the DateSelector is set to.
INT UpdateDateText Formats, Sizes and Displays the date.
INT ReplaceDateText Formats, Sizes and Displays the date.
INT UpdateWeekText Formats, Sizes and Displays the week with
or without the year.
INT FormatWeek Formats the week text.
INT UpdateShortMonthText Updates the custom short month text.
INT UpdateYearText Sends a MSG_DATE_SELECTOR_REPLACE_YEAR text
to the output.
INT LockStringResource Locks a string resource and returns a
pointer to the string
INT UnlockStringResource Unlocks a string resource that was locked
using LockStringResource
REVISION HISTORY:
Name Date Description
---- ---- -----------
SH 6/24/94 Initial revision
DESCRIPTION:
This file contains routines to implement DateSelectorControlClass
$Id: uiDateSelector.asm,v 1.1 97/04/04 17:59:37 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
GadgetsClassStructures segment resource
DateSelectorClass ;declare the class record
GadgetsClassStructures ends
;---------------------------------------------------
GadgetsSelectorCode segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DateSelectorMetaQueryIfPressIsInk
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Intercepted to make sure we handle this because otherwise
we'll go into an infinite loop of sending ourselves this
message forever in the specific-ui.
CALLED BY: MSG_META_QUERY_IF_PRESS_IS_INK
PASS: *ds:si = DateSelectorClass object
ds:di = DateSelectorClass instance data
ds:bx = DateSelectorClass object (same as *ds:si)
es = segment of DateSelectorClass
ax = message #
RETURN: ax = InkReturnValue
DESTROYED:
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
PB 3/10/96 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DateSelectorMetaQueryIfPressIsInk method dynamic DateSelectorClass,
MSG_META_QUERY_IF_PRESS_IS_INK
uses cx, dx, bp
.enter
mov ax, IRV_NO_INK
.leave
ret
DateSelectorMetaQueryIfPressIsInk endm
COMMENT @----------------------------------------------------------------------
MESSAGE: DateSelectorGetInfo --
MSG_GEN_CONTROL_GET_INFO for DateSelectorClass
DESCRIPTION: Return group
PASS:
*ds:si - instance data
es - segment of DateSelectorClass
ax - The message
cx:dx - GenControlBuildInfo structure to fill in
RETURN:
cx:dx - list of children
DESTROYED:
bx, si, di, ds, es (message handler)
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Tony 10/31/91 Initial version
------------------------------------------------------------------------------@
DateSelectorGetInfo method dynamic DateSelectorClass,
MSG_GEN_CONTROL_GET_INFO
mov si, offset DSC_dupInfo
call CopyBuildInfoCommon
ret
DateSelectorGetInfo endm
DSC_dupInfo GenControlBuildInfo <
mask GCBF_NOT_REQUIRED_TO_BE_ON_SELF_LOAD_OPTIONS_LIST, ; GCBI_flags
0, ; GCBI_initFileKey
0, ; GCBI_gcnList
0, ; GCBI_gcnCount
0, ; GCBI_notificationList
0, ; GCBI_notificationCount
0, ; GCBI_controllerName
handle DateSelectorUI, ; GCBI_dupBlock
DSC_childList, ; GCBI_childList
length DSC_childList, ; GCBI_childCount
DSC_featuresList, ; GCBI_featuresList
length DSC_featuresList, ; GCBI_featuresCount
DS_DEFAULT_FEATURES, ; GCBI_features
0, ; GCBI_toolBlock
0, ; GCBI_toolList
0, ; GCBI_toolCount
0, ; GCBI_toolFeaturesList
0, ; GCBI_toolFeaturesCount
0> ; GCBI_toolFeatures
GadgetsControlInfo segment resource
DSC_childList GenControlChildInfo \
<offset DateSelectorGroup, mask DSF_DATE, mask GCCF_ALWAYS_ADD>
; Careful, this table is in the *opposite* order as the record which
; it corresponds to.
DSC_featuresList GenControlFeaturesInfo \
<offset DateSelectorGroup, offset DateSelectorName, 0>
GadgetsControlInfo ends
COMMENT @----------------------------------------------------------------------
MESSAGE: DateSelectorGenerateUI -- MSG_GEN_CONTROL_GENERATE_UI
for DateSelectorClass
DESCRIPTION: This message is subclassed to set the monikers of
the filled/unfilled items
PASS:
*ds:si - instance data
es - segment of DateSelectorClass
ax - The message
RETURN:
nothing
DESTROYED:
bx, si, di, ds, es (message handler)
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Skarpi 06/22/94 Initial version
------------------------------------------------------------------------------@
DateSelectorGenerateUI method dynamic DateSelectorClass,
MSG_GEN_CONTROL_GENERATE_UI
.enter
;
; Call the superclass
;
mov di, offset DateSelectorClass
call ObjCallSuperNoLock
;
; If the do draw/don't draw feature isn't set, then we have no worries
;
call GetChildBlockAndFeatures ; bx <- handle
test ax, mask DSF_DATE
jz done
;
; Display current date UNLESS there's already a valid date
; stored in the object.
;
mov di, ds:[si]
add di, ds:[di].Gen_offset
cmp ds:[di].DSI_date.DT_year, -1
jne alreadyInitialized
;
; Get the current date
;
; returns:
; ax - year (1980 through 2099)
; bl - month (1 through 12)
; bh - day (1 through 31)
; cl - day of the week (0 through 6, 0 = Sunday, 1 = Monday...)
; ch - hours (0 through 23)
; dl - minutes (0 through 59)
; dh - seconds (0 through 59)
;
call TimerGetDateAndTime ; axbxcxdx <- date/time
;
; Copy the current date to instance data
;
add di, offset DSI_date
call SetDate
;
; Initialize the date selector, this sets GenText size and hint.
; Disables the Inc/Dec triggers if so desired.
;
alreadyInitialized:
call InitDateSelector
;
; Format the correct date according to the display option
;
call UpdateDateSelectorText
done:
.leave
ret
DateSelectorGenerateUI endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DateSelectorSetYearText
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: This message is sent by the output in response to
MSG_DATE_SELECTOR_REPLACE_YEAR_TEXT to the DateSelector,
passing a fptr to a null-terminated string which is
appended/prepended to the year.
CALLED BY: MSG_DATE_SELECTOR_SET_YEAR_TEXT
PASS: *ds:si = DateSelectorClass object
ds:di = DateSelectorClass instance data
ds:bx = DateSelectorClass object (same as *ds:si)
es = segment of DateSelectorClass
ax = message #
cx = DSYearTextFormat
dx:bp = fptr to year text (must be fptr for XIP)
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
SH 6/30/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DateSelectorSetYearText method dynamic DateSelectorClass,
MSG_DATE_SELECTOR_SET_YEAR_TEXT
uses ax, cx, dx, bp
.enter
;
; Some error checking code to check if the size of the string is
; correct.
;
EC < push es, di, cx >
EC < movdw esdi, dxbp >
EC < call LocalStringSize ; cx <- size >
EC < add cx, 6 ; cx <- str+year+null >
EC < cmp cx, size DateTimeBuffer >
EC < ERROR_G GADGETS_LIBRARY_SIZE_OF_YEAR_TEXT_EXCEEDS_LIMIT >
EC < pop es, di, cx >
;
; Get the date from instance data.
;
push cx
add di, offset DSI_date
call GetDate ; ax, bx, cl <- date
pop cx
;
; Setup stack space for string.
;
sub sp, size DateTimeBuffer
segmov es, ss
mov di, sp
;
; First check the format type, this decides if we prepend or append.
;
cmp cx, DSYTF_APPEND
je append
;
; Prepend the text to the year.
;
call PrependText
sendMessage:
;
; Update the GenText object showing the new text.
;
call ReplaceDateText
;
; Reset stack space.
;
add sp, size DateTimeBuffer
.leave
ret
append:
;
; Append the text to the year
;
call AppendText
jmp sendMessage
DateSelectorSetYearText endm
;-----
PrependText proc near
uses ds, si
class DateSelectorClass
.enter
clr bx
mov es:[di], bx ; null at begining for StrCat
;
; Copy the year text first
;
mov ds, dx
mov si, bp
clr cx ; null-term
call StrCat
;
; Add space
;
mov bx, C_SPACE
push bx
segmov ds, ss
mov si, sp
call StrCat
pop bx
;
; Add the year
;
push di
call LocalStringSize ; cx <- Number of bytes - NULL
add di, cx
clr dx
mov cx, mask UHTAF_NULL_TERMINATE
call UtilHex32ToAscii ; cx <- length
pop di
;
; Return string size
;
call LocalStringSize ; cx <- size
.leave
ret
PrependText endp
;-----
AppendText proc near
uses ds, si
class DateSelectorClass
.enter
;
; Add the year
;
push dx
clr dx
mov cx, mask UHTAF_NULL_TERMINATE
call UtilHex32ToAscii ; cx <- length
pop dx
;
; Add space
;
mov bx, C_SPACE
push bx
segmov ds, ss
mov si, sp
clr cx
call StrCat
pop bx
;
; Copy the year text first
;
mov ds, dx
mov si, bp
call StrCat
;
; Return string size
;
call LocalStringSize ; cx <- size
.leave
ret
AppendText endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DSDateInc
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Increment the date by one.
CALLED BY: MSG_DS_DATE_INC
PASS: *ds:si = DateSelectorClass object
ds:di = DateSelectorClass instance data
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS: Updates the DSI_date instance data.
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
SH 6/27/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DSDateInc method dynamic DateSelectorClass,
MSG_DS_DATE_INC
uses ax, cx, dx, bp
.enter
;
; Increment the date by one
;
mov di, ds:[si]
add di, ds:[di].Gen_offset
mov bx, ds:[di].DSI_dateType
shl bx
add di, offset DSI_date
call cs:incTable[bx]
;
; Show the new date
;
call UpdateDateSelectorText
;
; Send message letting the output know the date has changed
;
call SendDSActionMessage
.leave
ret
DSDateInc endm
incTable nptr.near \
offset cs:IncrementDate,
offset cs:IncrementDate,
offset cs:IncrementDate,
offset cs:IncrementDate,
offset cs:IncrementWeek,
offset cs:IncrementWeek,
offset cs:IncrementMonth,
offset cs:IncrementMonth,
offset cs:IncrementMonth,
offset cs:IncrementMonth,
offset cs:IncrementMonth,
offset cs:IncrementYear,
offset cs:IncrementYear,
offset cs:IncrementDate, ; DST_WEEKDAY
offset cs:IncrementDate ; DST_SHORT_WEEKDAY
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DSDateDec
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Decrement the date by one.
CALLED BY: MSG_DS_DATE_DEC
PASS: *ds:si = DateSelectorClass object
ds:di = DateSelectorClass instance data
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS: Updates the DSI_date instance data.
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
SH 6/27/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DSDateDec method dynamic DateSelectorClass, MSG_DS_DATE_DEC
uses ax, cx, dx, bp
.enter
;
; Increment the date by one
;
mov di, ds:[si]
add di, ds:[di].Gen_offset
mov bx, ds:[di].DSI_dateType
shl bx
add di, offset DSI_date
call cs:decTable[bx]
;
; Show the new date
;
call UpdateDateSelectorText
;
; Send message letting the output know the date has changed
;
call SendDSActionMessage
.leave
ret
DSDateDec endm
decTable nptr.near \
offset cs:DecrementDate,
offset cs:DecrementDate,
offset cs:DecrementDate,
offset cs:DecrementDate,
offset cs:DecrementWeek,
offset cs:DecrementWeek,
offset cs:DecrementMonth,
offset cs:DecrementMonth,
offset cs:DecrementMonth,
offset cs:DecrementMonth,
offset cs:DecrementMonth,
offset cs:DecrementYear,
offset cs:DecrementYear,
offset cs:DecrementDate,
offset cs:DecrementDate
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DSSetDate
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Message sent to the DateSelector to change the current
displayed date.
CALLED BY: MSG_DATE_SELECTOR_SET_DATE
PASS: *ds:si = DateSelectorClass object
ds:di = DateSelectorClass instance data
ds:bx = DateSelectorClass object (same as *ds:si)
es = segment of DateSelectorClass
ax = message #
cx = year
dl = month
dh = day
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
SH 7/ 1/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DSSetDate method dynamic DateSelectorClass,
MSG_DATE_SELECTOR_SET_DATE
FALL_THRU DSSetDateForReal
DSSetDate endm
DSSetDateForReal proc far
class DateSelectorClass
uses ax, cx, dx, bp
.enter
cmp cx, MIN_YEAR
EC < ERROR_B YEAR_OUT_OF_RANGE >
jb done
cmp cx, MAX_YEAR
EC < ERROR_A YEAR_OUT_OF_RANGE >
ja done
;
; Calculate the day of week for the given date.
;
mov ax, cx ; ax <- year
mov bx, dx ; bx <- month/day
call CalcDayOfWeek ; cl <- day of week
;
; Change the instance data DSI_date to reflect the new date
;
add di, offset DSI_date
call SetDate
;
; Now update the date in the GenText
;
call UpdateDateSelectorText
;
; Send message letting the output know the date has changed
;
; call SendDSActionMessage
done:
.leave
ret
DSSetDateForReal endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DSDateSelectorSetWeekday
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Sets the current weekday
CALLED BY: MSG_DATE_SELECTOR_SET_WEEKDAY
PASS: *ds:si = DateSelectorClass object
ds:di = DateSelectorClass instance data
cl = day of week (0=Sunday, 6=Saturday)
RETURN: nothing
DESTROYED:
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CT 11/17/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DSDateSelectorSetWeekday method dynamic DateSelectorClass,
MSG_DATE_SELECTOR_SET_WEEKDAY
uses cx, dx
.enter
EC < cmp ds:[di].DSI_dateType, DST_WEEKDAY >
EC < je okToUse >
EC < cmp ds:[di].DSI_dateType, DST_SHORT_WEEKDAY >
EC < ERROR_NE GADGETS_LIBRARY_CANNOT_MANIPULATE_WEEKDAY_IN_NON_WEEKDAY_MODE >
EC < okToUse: >
;
; We'll set the weekday by setting ourselves to a date that
; happens to fall on that weekday, among other things.
;
mov dh, 3
add dh, cl
mov dl, 5
mov cx, 1970 ; May 3, 1970 was a Sunday (0)
call DSSetDateForReal
.leave
ret
DSDateSelectorSetWeekday endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DSDateSelectorGetWeekday
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: returns the current weekday
CALLED BY: MSG_DATE_SELECTOR_GET_WEEKDAY
PASS: *ds:si = DateSelectorClass object
ds:di = DateSelectorClass instance data
RETURN: cl = day of week (0=Sunday, 6=Saturday)
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CT 11/17/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DSDateSelectorGetWeekday method dynamic DateSelectorClass,
MSG_DATE_SELECTOR_GET_WEEKDAY
.enter
EC < cmp ds:[di].DSI_dateType, DST_WEEKDAY >
EC < je okToUse >
EC < cmp ds:[di].DSI_dateType, DST_SHORT_WEEKDAY >
EC < ERROR_NE GADGETS_LIBRARY_CANNOT_MANIPULATE_WEEKDAY_IN_NON_WEEKDAY_MODE >
okToUse::
mov cl, ds:[di].DSI_date.DT_weekday
.leave
ret
DSDateSelectorGetWeekday endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DSGetDate
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Returns the current date of the DateSelector.
CALLED BY: MSG_DATE_SELECTOR_GET_DATE
PASS: *ds:si = DateSelectorClass object
ds:di = DateSelectorClass instance data
RETURN: cx = year
dl = month
dh = day of month
bp = day of week
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
SH 7/ 1/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DSGetDate method dynamic DateSelectorClass,
MSG_DATE_SELECTOR_GET_DATE
uses ax
.enter
;
; Get the date for instance data
;
add di, offset DSI_date
call GetDate ; ax, bx, cl <- date
;
; Set the correct return values
;
mov bp, cx ; bp <- day of week
mov cx, ax ; cx <- year
mov dx, bx ; dx <- month/day
.leave
ret
DSGetDate endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SendDSActionMessage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Sends the action message (DSI_actionMsg) to the output
(GCI_output).
CALLED BY: DSDateInc, DSDateDec
PASS: *ds:si - Object
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
SH 6/30/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SendDSActionMessage proc near
uses ax,bx,cx,dx,di,bp
class DateSelectorClass
.enter
EC < call ECCheckObject >
;
; First get the current date
;
mov di, ds:[si]
add di, ds:[di].Gen_offset
push di
add di, offset DSI_date
call GetDate ; ax, bx, cl <- date
mov bp, cx ; bp <- day of week
mov dx, bx ; dx <- month and day
mov cx, ax ; cx <- year
pop di ; ds:di <- instance data
;
; Get the action message and destination from instance data and
; send message.
;
mov ax, ds:[di].DSI_actionMsg ; ax <- msg to send
mov bx, segment DateSelectorClass
mov di, offset DateSelectorClass ; bx:di <- class
call GadgetOutputActionRegs
.leave
ret
SendDSActionMessage endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
UpdateDateSelectorText
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Update the DSText according to DSI_dateType.
CALLED BY: (INTERNAL) DSDateDec, DSDateInc, DSDateSelectorSetDateType,
DSMetaNotify, DSSetDateForReal, DateSelectorGenerateUI
PASS: *ds:si - Date Selector
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
SH 7/21/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
UpdateDateSelectorText proc near
uses bx, di
class DateSelectorClass
.enter
;
; Get the dateType and call the corresponding function that does
; the actual updating.
;
mov di, ds:[si]
add di, ds:[di].Gen_offset
mov bx, ds:[di].DSI_dateType
shl bx
call cs:dateTypeTable[bx]
;
; If we currently have the focus, then draw the focus lines
;
mov ax, TEMP_DATE_SELECTOR_HAS_FOCUS
call ObjVarFindData
jnc done
mov al, MM_COPY
call DSDrawFocusNoGState
done:
.leave
ret
UpdateDateSelectorText endp
dateTypeTable nptr.near \
offset cs:DisplayLongCondensedDate,
offset cs:DisplayLongDate,
offset cs:DisplayShortDate,
offset cs:DisplayZPaddedShortDate,
offset cs:DisplayWeek,
offset cs:DisplayWeekYear,
offset cs:DisplayMonth,
offset cs:DisplayShortMonth,
offset cs:DisplayMonthYear,
offset cs:DisplayShortMonthYear,
offset cs:DisplayShortMonthShortYear,
offset cs:DisplayYear,
offset cs:DisplayYearText,
offset cs:DisplayWeekday,
offset cs:DisplayShortWeekday
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DisplayXXXX
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Sets up the size of the GenText, formats the date in the
correct format and displays it in the GenText.
CALLED BY: DateSelectorGenerateUI
PASS: *ds:si - Object
cx - Non zero to set text size
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
SH 6/28/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DisplayLongCondensedDate proc near
.enter
EC < call ECCheckObject >
;
; then Input the date
;
clr dx
mov ax, DTF_LONG_CONDENSED
call UpdateDateText
.leave
ret
DisplayLongCondensedDate endp
;------
DisplayLongDate proc near
clr dx
mov ax, DTF_LONG
call UpdateDateText
ret
DisplayLongDate endp
;------
DisplayShortDate proc near
clr dx
mov ax, DTF_SHORT
call UpdateDateText
ret
DisplayShortDate endp
;------
DisplayZPaddedShortDate proc near
clr dx
mov ax, DTF_ZERO_PADDED_SHORT
call UpdateDateText
ret
DisplayZPaddedShortDate endp
;------
DisplayWeek proc near
mov ax, FALSE ; no year
call UpdateWeekText
ret
DisplayWeek endp
;------
DisplayWeekYear proc near
mov cx, TRUE ; include year
call UpdateWeekText
ret
DisplayWeekYear endp
;------
DisplayMonth proc near
clr dx
mov ax, DTF_MONTH
call UpdateDateText
ret
DisplayMonth endp
;------
DisplayShortMonth proc near
mov ax, offset JS_ShortMonth
call UpdateShortMonthText
ret
DisplayShortMonth endp
;------
DisplayMonthYear proc near
clr dx
mov ax, DTF_MY_LONG
call UpdateDateText
ret
DisplayMonthYear endp
;------
DisplayShortMonthYear proc near
mov ax, offset JS_ShortMonthYear
call UpdateShortMonthText
ret
DisplayShortMonthYear endp
;------
DisplayShortMonthShortYear proc near
mov ax, offset JS_ShortMonthShortYear
call UpdateShortMonthText
ret
DisplayShortMonthShortYear endp
;------
DisplayYear proc near
clr dx
mov ax, DTF_YEAR
call UpdateDateText
ret
DisplayYear endp
;------
DisplayYearText proc near
call UpdateYearText
ret
DisplayYearText endp
;------
DisplayWeekday proc near
clr dx
mov ax, DTF_WEEKDAY
call UpdateDateText
ret
DisplayWeekday endp
;------
DisplayShortWeekday proc near
push es, bp
clr dx
mov ax, -1
sub sp, ((TOKEN_LENGTH+2) and 0xfffe)
mov bx, sp
segmov es, ss
mov {byte}es:[bx], TOKEN_DELIMITER
mov {word}es:[bx][1], TOKEN_SHORT_WEEKDAY
mov {byte}es:[bx][3], TOKEN_DELIMITER
clr {byte}es:[bx][4]
mov cx, bx ; es:cx = format string
call UpdateDateText
add sp, ((TOKEN_LENGTH+2) and 0xfffe)
pop es, bp
ret
DisplayShortWeekday endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
InitDateSelector
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Sets the fixed size of the GenText object of the controller.
The text is centered within the GenText. You can override
this default by setting the textWidth field in instance
data.
CALLED BY: (INTERNAL) DateSelectorGenerateUI
PASS: *ds:si - Object
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
SH 6/28/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
InitDateSelector proc near
uses ax,bx,cx,dx,si,bp
.enter
EC < call ECCheckObject >
;
; First check if we need to display the text frame.
;
call SetTextFrame
;
; Check if we have to set the INC/DEC triggers not usable.
;
call SetIncDecTriggersNotUsable
;
; Set the default size of the GenText used to display the date.
;
call SetGenTextDefaultWidth
.leave
ret
InitDateSelector endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SetTextFrame
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Draws a frame around the GenText if
HINT_DATE_SELECTOR_DRAW_FRAME is defined on the object.
CALLED BY: (INTERNAL) InitDateSelector
PASS: *ds:si - DateSelector object
RETURN: nothing
DESTROYED: dx
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
SH 7/21/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SetTextFrame proc near
uses ax, si
.enter
EC < call ECCheckObject >
;
; First check if we need to display the text frame.
;
mov ax, HINT_DATE_SELECTOR_DRAW_FRAME
call ObjVarFindData
jnc done
;
; Send the GenText object the HINT_TEXT_FRAME to display the frame.
;
mov dx, size AddVarDataParams
sub sp, dx
mov bp, sp
clrdw ss:[bp].AVDP_data
clr ss:[bp].AVDP_dataSize
mov ss:[bp].AVDP_dataType, HINT_TEXT_FRAME
call GetChildBlockAndFeatures ; bx <- handle
mov si, offset DateText
mov ax, MSG_META_ADD_VAR_DATA
mov di, mask MF_FIXUP_DS or mask MF_STACK or mask MF_CALL
call ObjMessage
add sp, size AddVarDataParams
done:
.leave
ret
SetTextFrame endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SetIncDecTriggersNotUsable
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: If GA_READ_ONLY is set this function the Inc and Dec
triggers not usable.
CALLED BY: (INTERNAL) InitDateSelector
PASS: *ds:si - DateSelector Object
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
SH 7/21/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SetIncDecTriggersNotUsable proc near
uses ax, si
.enter
EC < call ECCheckObject >
;
; See if we've been set to read-only.
;
mov ax, MSG_GEN_GET_ATTRIBUTES
call ObjCallInstanceNoLock ; cl <- GenAttrs
test cl, mask GA_READ_ONLY
jz done
;
; Send the Inc trigger MSG_GEN_SET_NOT_USABLE...
;
mov di, offset IncTrigger
mov dl, VUM_NOW
mov ax, MSG_GEN_SET_NOT_USABLE
call ObjCallControlChild
;
; ...and now the Dec trigger.
;
mov di, offset DecTrigger
mov dl, VUM_NOW
mov ax, MSG_GEN_SET_NOT_USABLE
call ObjCallControlChild
done:
.leave
ret
SetIncDecTriggersNotUsable endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SetGenTextDefaultWidth
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Sets the default width of the GenText object used to
display the date. The default width varies depending on
what dateType the DateSelector is set to.
CALLED BY: (INTERNAL) DSDateSelectorSetDateType InitDateSelector
PASS: *ds:si - DateSelector Object
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
SH 7/21/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SetGenTextDefaultWidth proc near
uses ax,si
class DateSelectorClass
.enter
EC < call ECCheckObject >
;
; Check if the text width was set in the .ui file.
;
mov di, ds:[si]
add di, ds:[di].Gen_offset
mov ax, ds:[di].DSI_textWidth
tst ax
jnz widthDefined
;
; The width is not defined in DSI_testWidth which means we use
; the default width.
;
mov bx, ds:[di].DSI_dateType
shl bx
mov ax, cs:[dateSelectorTextWidthTable][bx]
;
; Set the correct size of the GenText field
;
widthDefined:
sub sp, size SetSizeArgs
mov bp, sp
or ax, SST_AVG_CHAR_WIDTHS shl offset SH_TYPE
mov ss:[bp].SSA_width, ax
clr ss:[bp].SSA_height
clr ss:[bp].SSA_count
mov ss:[bp].SSA_updateMode, VUM_DELAYED_VIA_UI_QUEUE
call GetChildBlockAndFeatures ; bx <- handle
tst bx
jz noChild
mov si, offset DateText
mov dx, size SetSizeArgs
mov ax, MSG_GEN_SET_FIXED_SIZE
mov di, mask MF_STACK or mask MF_FIXUP_DS
call ObjMessage
noChild:
add sp, size SetSizeArgs
.leave
ret
SetGenTextDefaultWidth endp
;
; This table has to be in the same order as DateSelectorType enum.
;
dateSelectorTextWidthTable word \
DS_CONDENSED_SIZE,
DS_LONG_SIZE,
DS_SHORT_SIZE,
DS_ZP_SHORT_SIZE,
DS_WEEK_SIZE,
DS_WEEK_YEAR_SIZE,
DS_MONTH_SIZE,
DS_SHORT_MONTH_SIZE,
DS_MONTH_YEAR_SIZE,
DS_SHORT_MONTH_YEAR_SIZE,
DS_SHORT_MONTH_SHORT_YEAR_SIZE,
DS_YEAR_SIZE,
DS_YEAR_TEXT_SIZE,
DS_WEEKDAY_SIZE,
DS_SHORT_WEEKDAY_SIZE
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
UpdateDateText
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Formats, Sizes and Displays the date.
CALLED BY: (INTERNAL) DisplayLongCondensedDate DisplayLongDate
DisplayMonth DisplayMonthYear DisplayShortDate
DisplayShortWeekday DisplayWeekday DisplayYear
DisplayZPaddedShortDate
PASS: ds:si - Object
ds:di - Instance date
ax - DateTimeFormat
if -1,
es:cx = format string
dx - Max chars to use (0 for all)
RETURN: nothing
DESTROYED: es
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
SH 6/28/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
UpdateDateText proc near
formatOffset local nptr push cx
dateBuffer local DateTimeBuffer
class DateSelectorClass
uses si, dx
.enter
EC < call ECCheckObject >
;
; Get the date from instance data
;
push si, ax
add di, offset DSI_date
call GetDate ; ax, bx, cl <- date
;
; Format the date
;
pop si ; DateTimeFormat
push ds
segmov ds, es
segmov es, ss
lea di, ss:[dateBuffer]
cmp si, -1
jne localFormat
mov si, ss:[formatOffset] ; ds:si = format string
call LocalCustomFormatDateTime
jmp doneFormatting
localFormat:
call LocalFormatDateTime ; es:di <- date string,
; cx <- size
doneFormatting:
pop ds
;
; Truncate if desired
;
tst dx
jz updateIt
DBCS < shl dx, 1 >
mov si, dx
mov cx, dx ; cx <- length
clr dx
SBCS < mov ss:[dateBuffer][si], dl >
DBCS < mov ss:[dateBuffer][si], dx >
;
; Update the DateText to show today's date
;
updateIt:
pop si ; *ds:si <- Object
call ReplaceDateText
.leave
ret
UpdateDateText endp
;-----
ReplaceDateText proc near
push bp
movdw dxbp, esdi ; dx:bp <- date string
mov di, offset DateText
mov ax, MSG_VIS_TEXT_REPLACE_ALL_PTR
call ObjCallControlChild
pop bp
ret
ReplaceDateText endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
UpdateWeekText
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Formats, Sizes and Displays the week with or without the
year.
CALLED BY: (INTERNAL) DisplayWeek DisplayWeekYear
PASS: ds:si - Object
ds:di - Instance date
ax - Non zero if include year
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
SH 6/28/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
UpdateWeekText proc near
dateBuffer local DateTimeBuffer
class DateSelectorClass
uses si
.enter
EC < call ECCheckObject >
;
; Get the date from instance data
;
push si, ax
add di, offset DSI_date
call GetDate ; ax, bx, cl <- date
;
; Convert the date into week number
;
call GetWeekNumber ; bx <- week #
;
; Format the week
;
pop cx ; Non zero to include year
segmov es, ss
lea di, ss:[dateBuffer]
call FormatWeek ; es:di <- week string
; cx <- size
;
; Update the DateText to show today's date
;
pop si ; *ds:si <- Object
call ReplaceDateText
.leave
ret
UpdateWeekText endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FormatWeek
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Formats the week text.
CALLED BY: (INTERNAL) UpdateWeekText
PASS: es:di - Buffer for Week text
ax - Year
bx - Week number
cx - Non zero to include the year in text.
RETURN: es:di - Week text
cx - Length of string
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
SH 6/29/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
FormatWeek proc near
uses ax,bx,dx,si,bp,ds
.enter
;
; Save year data
;
push ax, cx
;
; Copy the week string to the buffer
;
clr si
mov es:[di], si ; null at begining for StrCat
mov si, offset JS_Week
call LockStringResource ; ds:si <- ptr to string
clr cx ; null-terminated
call StrCat
call UnlockStringResource
;
; Add a space
;
mov ax, C_SPACE
push ax
segmov ds, ss
mov si, sp
call StrCat
pop ax ; restore stack
;
; Convert the week number to text
;
push di
call LocalStringSize ; cx <- Number of bytes - NULL
add di, cx
clr dx
mov ax, bx ; ax <- week number
mov cx, mask UHTAF_NULL_TERMINATE
call UtilHex32ToAscii ; cx <- length
pop di
;
; Do we add the year?
;
pop ax, cx
tst cx ; non-zero for year
jz done
;
; Yes, we do. But first add a comma and space.
;
push ax
mov ax, C_COMMA
push ax
segmov ds, ss
mov si, sp
clr cx ; null-terminated
call StrCat
pop ax ; restore stack
mov ax, C_SPACE
push ax
segmov ds, ss
mov si, sp
call StrCat
pop ax ; restore stack
pop ax ; year
push di
call LocalStringSize ; cx <- Number of bytes - NULL
add di, cx
clr dx
mov cx, mask UHTAF_NULL_TERMINATE
call UtilHex32ToAscii ; cx <- length
pop di
;
; Return the size
;
done:
call LocalStringSize ; cx <- Number of bytes - NULL
.leave
ret
FormatWeek endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
UpdateShortMonthText
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Updates the custom short month text.
CALLED BY: (INTERNAL) DisplayShortMonth DisplayShortMonthShortYear
DisplayShortMonthYear
PASS: ds:si - Object
ds:di - Instance date
ax - Offset of Format token
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
SH 6/30/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
UpdateShortMonthText proc near
dateBuffer local DateTimeBuffer
class DateSelectorClass
uses si
.enter
EC < call ECCheckObject >
;
; Lock the token string
;
push ds, si, ds
mov si, ax
call LockStringResource ; ds:si <- token string
;
; Get the date from instance data
;
mov dx, ds ; dx <- segment
pop ds ; ds:di <- Instance data
add di, offset DSI_date
call GetDate ; ax, bx, cl <- date
;
; Format the text
;
mov ds, dx ; ds:si <- token string
segmov es, ss
lea di, ss:[dateBuffer]
call LocalCustomFormatDateTime
;
; Unlock the token string resource
;
call UnlockStringResource
;
; Update the GenText with the short month text
;
pop ds, si ; *ds:si - Object
call ReplaceDateText
.leave
ret
UpdateShortMonthText endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
UpdateYearText
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Sends a MSG_DATE_SELECTOR_REPLACE_YEAR text to the output.
CALLED BY: (INTERNAL) DisplayYearText
PASS: *ds:si - Object
ds:di - Instance date
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
SH 6/30/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
UpdateYearText proc near
class DateSelectorClass
.enter
EC < call ECCheckObject >
;
; Get the date from instance data
;
push si
add di, offset DSI_date
call GetDate ; ax, bx, cl <- date
mov bp, ax ; cx <- year
;
; Send a message to the output requesting a year text.
; A MSG_DATE_SELECTOR_SET_YEAR_TEXT is sent to the DateSelector in
; response. The actual formatting of the text is done in the
; method handler for that message.
;
pop si ; *ds:si - Object
mov cx, ds:[LMBH_handle]
mov dx, si
mov bx, segment DateSelectorClass
mov di, offset DateSelectorClass
mov ax, MSG_DATE_SELECTOR_REPLACE_YEAR_TEXT
call GenControlSendToOutputRegs
.leave
ret
UpdateYearText endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DSDateSelectorSetDateType
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Changes the format of the displayed date. Forces object
to redraw itself.
CALLED BY: MSG_DATE_SELECTOR_SET_DATE_TYPE
PASS: *ds:si = DateSelectorClass object
ds:di = DateSelectorClass instance data
cx = DateSelectorType
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
JAG 1/ 4/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DSDateSelectorSetDateType method dynamic DateSelectorClass,
MSG_DATE_SELECTOR_SET_DATE_TYPE
.enter
Assert etype cx DateSelectorType
;
; Store value passed to us by user.
;
cmp cx, ds:[di].DSI_dateType
je done
mov ds:[di].DSI_dateType, cx
;
; Resize.
;
call SetGenTextDefaultWidth
;
; Redraw.
;
call UpdateDateSelectorText
done:
.leave
ret
DSDateSelectorSetDateType endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DSGenControlAddToGcnLists
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Add us to system GCN lists.
CALLED BY: MSG_GEN_CONTROL_ADD_TO_GCN_LISTS
PASS: *ds:si = DateSelectorClass object
es = segment of DateSelectorClass
ax = message #
RETURN: nothing
DESTROYED: everything
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
JAG 1/18/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DSGenControlAddToGcnLists method dynamic DateSelectorClass,
MSG_GEN_CONTROL_ADD_TO_GCN_LISTS
.enter
call AddSelfToDateTimeGCNLists
.leave
mov di, offset @CurClass
call ObjCallSuperNoLock
ret
DSGenControlAddToGcnLists endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DSGenControlRemoveFromGcnLists
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Name sez it all.
CALLED BY: MSG_GEN_CONTROL_REMOVE_FROM_GCN_LISTS
PASS: *ds:si = DateSelectorClass object
es = segment of DateSelectorClass
ax = message #
RETURN: nothing
DESTROYED: everything
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
JAG 1/18/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DSGenControlRemoveFromGcnLists method dynamic DateSelectorClass,
MSG_GEN_CONTROL_REMOVE_FROM_GCN_LISTS
.enter
call RemoveSelfFromDateTimeGCNLists
.leave
mov di, offset @CurClass
GOTO ObjCallSuperNoLock
DSGenControlRemoveFromGcnLists endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DSMetaNotify
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Redraw us if date/time format hath chang'd.
CALLED BY: MSG_META_NOTIFY
PASS: *ds:si = DateSelectorClass object
es = segment of DateInputClass
ax = message #
cx:dx = NotificationType
cx - NT_manuf
dx - NT_type
bp = change specific data (InitFileEntry)
RETURN: nothing
DESTROYED: ax, cx, dx, bp
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
JAG 1/17/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DSMetaNotify method dynamic DateSelectorClass,
MSG_META_NOTIFY
;
; See if it's the notification we're interested in.
;
cmp cx, MANUFACTURER_ID_GEOWORKS
jne callSoup
cmp dx, GWNT_INIT_FILE_CHANGE
jne callSoup
;
; We need to redraw if the time format has changed.
;
cmp bp, IFE_DATE_TIME_FORMAT
jne exit
call UpdateDateSelectorText
exit:
ret
callSoup:
mov di, offset @CurClass
GOTO ObjCallSuperNoLock
DSMetaNotify endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DSSpecActivateObjectWithMnemonic
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: This message is send when ever the user enters the keyboard
mnemonic for this control. We call supercalls if the
activation was a success when we pass the the focus and
target to the GenText.
CALLED BY: MSG_SPEC_ACTIVATE_OBJECT_WITH_MNEMONIC
PASS: *ds:si = DateInputClass object
ds:di = DateInputClass instance data
ds:bx = DateInputClass object (same as *ds:si)
es = segment of DateInputClass
ax = message #
RETURN: carry set if found, clear otherwise.
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
SH 7/18/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DSSpecActivateObjectWithMnemonic method dynamic DateSelectorClass,
MSG_SPEC_ACTIVATE_OBJECT_WITH_MNEMONIC
uses ax, cx, dx, bp
.enter
;
; Call superclass. If the mnemonic is a match the carry is set.
;
mov di, offset DateSelectorClass
call ObjCallSuperNoLock
jnc done
;
; We have a match. Send MSG_GEN_MAKE_FOCUS to the GenText object.
;
; mov di, offset DateText
mov ax, MSG_GEN_MAKE_FOCUS
call ObjCallInstanceNoLock
stc ; return carry
done:
.leave
ret
DSSpecActivateObjectWithMnemonic endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DSSpecNavigationQuery
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Make sure we don't get focus if hint tells us so.
CALLED BY: MSG_SPEC_NAVIGATION_QUERY
PASS: *ds:si = RepeatTriggerClass object
es = segment of RepeatTriggerClass
ax = message #
^lcx:dx = object which originated this query
bp = NavigateFlags (see below)
RETURN: carry set if object to give focus to, with:
^lcx:dx = object which is replying
else
^lcx:dx = next object to query
bp = NavigateFlags (will be altered as message is
passed around)
al = set if the object is focusable via backtracking
(i.e. can take the focus if it is previous to the
originator in backwards navigation)
DESTROYED: everything
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
JAG 1/30/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DSSpecNavigationQuery method dynamic DateSelectorClass,
MSG_SPEC_NAVIGATION_QUERY
.enter
mov ax, HINT_DATE_SELECTOR_NOT_FOCUSABLE
call ObjVarFindData ; ds:bx <- data
mov bl, mask NCF_IS_FOCUSABLE ; assume focusable
jnc navigate
clr bl ; hint found
navigate:
mov di, si
call VisNavigateCommon
.leave
ret
DSSpecNavigationQuery endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DSMetaGainedSysFocusExcl
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Shows the object with the focus
CALLED BY: MSG_META_GAINED_SYS_FOCUS_EXCL
PASS: *ds:si = DateSelectorClass object
ds:di = DateSelectorClass instance data
ds:bx = DateSelectorClass object (same as *ds:si)
es = segment of DateSelectorClass
ax = message #
RETURN:
DESTROYED:
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CT 5/ 2/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DSMetaGainedSysFocusExcl method dynamic DateSelectorClass,
MSG_META_GAINED_SYS_FOCUS_EXCL
uses ax
.enter
mov al, MM_COPY
call DSDrawFocusNoGState
mov ax, TEMP_DATE_SELECTOR_HAS_FOCUS
clr cx
call ObjVarAddData
.leave
mov di, offset @CurClass
GOTO ObjCallSuperNoLock
DSMetaGainedSysFocusExcl endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DSMetaLostSysFocusExcl
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS:
CALLED BY: MSG_META_LOST_SYS_FOCUS_EXCL
PASS: *ds:si = DateSelectorClass object
ds:di = DateSelectorClass instance data
ds:bx = DateSelectorClass object (same as *ds:si)
es = segment of DateSelectorClass
ax = message #
RETURN:
DESTROYED:
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CT 5/ 2/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DSMetaLostSysFocusExcl method dynamic DateSelectorClass,
MSG_META_LOST_SYS_FOCUS_EXCL
uses ax
.enter
;
; Erase focus
;
mov al, MM_CLEAR
call DSDrawFocusNoGState
mov ax, TEMP_DATE_SELECTOR_HAS_FOCUS
call ObjVarDeleteData
.leave
mov di, offset @CurClass
GOTO ObjCallSuperNoLock
DSMetaLostSysFocusExcl endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DSDrawFocusNoGState
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Draws the focus on an object. Creates its own gstate
CALLED BY:
PASS: al = Mix mode in which to draw focus
*ds:si = DateSelector object
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CT 5/ 2/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DSDrawFocusNoGState proc near
uses ax,cx,dx,bp,di
.enter
push ax
mov ax, MSG_VIS_VUP_CREATE_GSTATE
call ObjCallInstanceNoLock ; bp <- gstate
pop ax
jnc done
;
; How about a dotted box?
;
mov di, bp
call GrSetMixMode
call DSDrawFocus
call GrDestroyState
done:
.leave
ret
DSDrawFocusNoGState endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DSDrawFocus
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Draws graphics to indicate focus on DateSelector
CALLED BY:
PASS: di = GState to draw into
*ds:si = DateSelector object
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CT 5/ 2/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DSDrawFocus proc near
uses ax, bx, cx, dx, bp
.enter
;
; Get text object bounds
;
push di
mov ax, MSG_VIS_GET_BOUNDS
mov di, offset DateText
call ObjCallControlChild ; ax,bp,cx,dx <- l,t,r,b
tst bx
jz noChild
mov_tr bx, bp
dec cx
dec dx
;
; Tweak bounds if certain hints exist
;
push ax, bx
mov ax, HINT_DATE_SELECTOR_DRAW_FRAME
call ObjVarFindData
pop ax, bx
jnc draw
inc ax ; Text frame exists: bring focus box in 1 pixel
inc bx
dec cx
dec dx
draw:
pop di
;
; Draw box
;
call GrSaveState
mov_tr bp, ax
mov al, SDM_50
call GrSetLineMask
mov_tr ax, bp
call GrDrawRect
call GrRestoreState
done:
.leave
ret
noChild:
pop di
jmp done
DSDrawFocus endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DSVisDraw
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: If object has system focus, draw it so.
CALLED BY: MSG_VIS_DRAW
PASS: *ds:si = DateSelectorClass object
ds:di = DateSelectorClass instance data
ds:bx = DateSelectorClass object (same as *ds:si)
es = segment of DateSelectorClass
ax = message #
cl = DrawFlags
bp = GState
RETURN: nothing
DESTROYED: ax, cx, dx, bp
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CT 5/ 2/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DSVisDraw method dynamic DateSelectorClass,
MSG_VIS_DRAW
push bp
mov di, offset @CurClass
call ObjCallSuperNoLock
pop bp
;
; If we currently have the focus, then draw the focus lines
;
mov ax, TEMP_DATE_SELECTOR_HAS_FOCUS
call ObjVarFindData
jnc done
mov di, bp
call GrSaveState
mov al, MM_COPY
call GrSetMixMode
call DSDrawFocus
call GrRestoreState
done:
ret
DSVisDraw endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DSMetaKbdChar
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Message sent out on any keyboard press or release. We need
to subclass this message to catch the arrow-up and arrow_down
keystrokes. We then send a message to increment or decrement
the date to the DateInput control.
CALLED BY: MSG_META_KBD_CHAR
PASS: *ds:si = DateInputTextClass object
ds:di = DateInputTextClass instance data
ds:bx = DateInputTextClass object (same as *ds:si)
es = segment of DateInputTextClass
ax = message #
cx = character value
dl = CharFlags
dh = ShiftState
bp low = ToggleState
bp high = scan code
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
SH 7/12/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DSMetaKbdChar method dynamic DateSelectorClass, MSG_META_KBD_CHAR
;
; Ignore key releases.
;
test dl, mask CF_RELEASE
jnz callSuper
;
; See if it's a character we're interested in. Make sure that
; the desired ctrl/shift/whatever key is also being pressed.
;
mov bx, (offset dsKeymap) - (size KeyAction)
mov di, (offset dsKeymap) + (size dsKeymap)
call KeyToMsg ; ax <- message to send
jc callSuper
;
; Send message associated with the action.
;
GOTO ObjCallInstanceNoLock
callSuper:
mov ax, MSG_META_KBD_CHAR
mov di, offset @CurClass
GOTO ObjCallSuperNoLock
DSMetaKbdChar endm
GadgetsSelectorCode ends
|
source/DEVONthinkPro.popclipext/DEVONthinkClip.applescript | cnstntn-kndrtv/PopClip-Extensions | 1,262 | 4548 | <gh_stars>1000+
tell application "DEVONthink Pro"
if "{popclip text}" = "" then
beep
return
end if
-- edit by <NAME>
-- previous usage of (words of theText) was triggering an applescript bug when faced with japanese text input. The script would hang. I have changed it from 10 words to 70 characters, to avoid the bug.
set theText to "{popclip text}"
set theTitle to theText
if (length of theText) > 70 then
set theTitle to (characters 1 through 70 of theText as string)
set oldDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to " "
set theTitle to (theTitle & "...") as string
set AppleScript's text item delimiters to oldDelimiters
end if
set theURL to ""
if length of "{popclip browser url}" > 0 then
set theURL to "{popclip browser url}"
end if
if length of "{popclip browser title}" > 0 then
set theTitle to "{popclip browser title}"
end if
activate
create record with {name:theTitle, type:txt, plain text:theText, URL:theURL}
end tell |
programs/oeis/021/A021039.asm | jmorken/loda | 1 | 245784 | ; A021039: Decimal expansion of 1/35.
; 0,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,7,1,4,2,8
lpb $0
mov $1,$0
add $1,7
cal $1,182480 ; Decimal expansion of 16000000/63.
mov $0,0
lpe
mov $2,$1
cmp $2,0
add $1,$2
sub $1,1
|
3-mid/opengl/source/lean/shader/opengl-variable.adb | charlie5/lace | 20 | 10521 | <filename>3-mid/opengl/source/lean/shader/opengl-variable.adb
package body openGL.Variable
is
---------
-- Forge
--
procedure define (Self : in out Item) -- TODO: Rid these ?
is
begin
null;
end define;
procedure destroy (Self : in out Item)
is
begin
null;
end destroy;
end openGL.Variable;
|
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/unaligned_rep_clause.adb | best08618/asylo | 7 | 19425 | <gh_stars>1-10
-- { dg-do compile }
procedure Unaligned_Rep_Clause is
type One_Bit_Record is
record
B : Boolean;
end record;
Pragma Pack(One_Bit_Record);
subtype Version_Number_Type is String (1 .. 3);
type Inter is
record
Version : Version_Number_Type;
end record;
type Msg_Type is
record
Status : One_Bit_Record;
Version : Inter;
end record;
for Msg_Type use
record
Status at 0 range 0 .. 0;
Version at 0 range 1 .. 24;
end record;
for Msg_Type'Size use 25;
Data : Msg_Type;
Pragma Warnings (Off, Data);
Version : Inter;
begin
Version := Data.Version;
end;
|
simple_example.adb | jhumphry/Reqrep_Task_Pools | 1 | 4096 | <reponame>jhumphry/Reqrep_Task_Pools
-- simple_example.adb
-- A simple example of using the Reqrep_Task_Pool
-- Copyright (c) 2015, <NAME>
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
--
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
-- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
-- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-- PERFORMANCE OF THIS SOFTWARE.
with Ada.Text_IO; use Ada.Text_IO;
with Reqrep_Task_Pools;
use all type Reqrep_Task_Pools.Reqrep_Status;
with Ada.Task_Termination;
with Ada.Task_Identification;
with Ada.Exceptions;
procedure Simple_Example is
type Delay_Reqrep is tagged record
ID : Positive := 1;
D : Duration := 1.0;
end record;
function Execute
(R : in out Delay_Reqrep) return Reqrep_Task_Pools.Reqrep_Return_Status
is
begin
delay R.D;
return Success;
end Execute;
package Delay_Task_Pool is new Reqrep_Task_Pools.Task_Pool
(Reqrep => Delay_Reqrep,
Number_Workers => 2);
Result : Delay_Task_Pool.Reqrep_Job;
begin
Put_Line ("A simple example of Request-Response handling.");
New_Line;
Put_Line ("Pushing requests onto the queue.");
for I in 1 .. 5 loop
Delay_Task_Pool.Push_Job (Delay_Reqrep'(ID => I, D => 1.0));
Put_Line ("Pushed request:" & Integer'Image (I));
end loop;
New_Line;
Put_Line ("Pulling results off the queue.");
for I in 1 .. 5 loop
Result := Delay_Task_Pool.Get_Result;
Put_Line
("Got response: " &
Reqrep_Task_Pools.Reqrep_Status'Image (Result.Status) &
" for request ID:" &
Integer'Image (Result.ID));
if Result.Status = Unhandled_Exception or Result.Status = Internal_Error then
Delay_Task_Pool.Discard_Exception;
end if;
end loop;
Delay_Task_Pool.Shutdown;
end Simple_Example;
|
programs/oeis/277/A277981.asm | neoneye/loda | 22 | 82140 | <reponame>neoneye/loda
; A277981: a(n) = 4*n^2 + 18*n - 20.
; -20,2,32,70,116,170,232,302,380,466,560,662,772,890,1016,1150,1292,1442,1600,1766,1940,2122,2312,2510,2716,2930,3152,3382,3620,3866,4120,4382,4652,4930,5216,5510,5812,6122,6440,6766,7100,7442,7792,8150
mov $1,$0
mul $1,2
mul $1,$0
mul $0,9
add $0,$1
sub $0,10
mul $0,2
|
programs/oeis/114/A114753.asm | karttu/loda | 0 | 85161 | ; A114753: First column of A114751.
; 1,3,3,7,5,11,7,15,9,19,11,23,13,27,15,31,17,35,19,39,21,43,23,47,25,51,27,55,29,59,31,63,33,67,35,71,37,75,39,79,41,83,43,87,45,91,47,95,49,99,51,103,53,107,55,111,57,115,59,119,61,123,63,127,65,131,67,135,69
mov $1,$0
sub $1,1
gcd $1,2
mul $1,$0
add $1,1
|
unittests/ASM/OpSize/66_D7.asm | cobalt2727/FEX | 628 | 179252 | <reponame>cobalt2727/FEX<gh_stars>100-1000
%ifdef CONFIG
{
"RegData": {
"RAX": "0x0",
"RBX": "0x0",
"RCX": "0xFFFF",
"XMM0": ["0x4142434445464748", "0x5152535455565758"],
"XMM1": ["0x0", "0x0"],
"XMM2": ["0xFFFFFFFFFFFFFFFF", "0xFFFFFFFFFFFFFFFF"]
},
"MemoryRegions": {
"0x100000000": "4096"
}
}
%endif
mov rdx, 0xe0000000
mov rax, 0x4142434445464748
mov [rdx + 8 * 0], rax
mov rax, 0x5152535455565758
mov [rdx + 8 * 1], rax
mov rax, 0
mov [rdx + 8 * 2], rax
mov [rdx + 8 * 3], rax
mov rax, 0xFFFFFFFFFFFFFFFF
mov [rdx + 8 * 4], rax
mov [rdx + 8 * 5], rax
movapd xmm0, [rdx + 8 * 0]
movapd xmm1, [rdx + 8 * 2]
movapd xmm2, [rdx + 8 * 4]
pmovmskb eax, xmm0
pmovmskb ebx, xmm1
pmovmskb ecx, xmm2
hlt
|
audio/music/postcredits.asm | Dev727/ancientplatinum | 28 | 94984 | Music_PostCredits:
musicheader 2, 1, Music_PostCredits_Ch1
musicheader 1, 2, Music_PostCredits_Ch2
db $2
Music_PostCredits_Ch1:
tempo 271
volume $77
pitchoffset 0, D#
dutycycle $2
notetype $c, $93
note __, 8
Music_PostCredits_branch_cfdb2:
octave 3
note C_, 2
note E_, 2
note G_, 2
octave 4
note C_, 2
note E_, 2
intensity $73
note E_, 2
intensity $53
note E_, 2
intensity $43
note E_, 2
intensity $93
octave 2
note B_, 2
octave 3
note D_, 2
note G_, 2
note B_, 2
octave 4
note D_, 2
intensity $73
note D_, 2
intensity $53
note D_, 2
intensity $43
note D_, 2
intensity $93
octave 2
note A#, 2
octave 3
note D_, 2
note G_, 2
note A#, 2
octave 4
note D_, 2
intensity $73
note D_, 2
intensity $53
note D_, 2
intensity $43
note D_, 2
intensity $93
octave 2
note A_, 2
octave 3
note C_, 2
note F_, 2
note A_, 2
octave 4
note C_, 2
intensity $73
note C_, 2
intensity $53
note C_, 2
intensity $43
note C_, 2
intensity $93
octave 2
note G#, 2
octave 3
note C_, 2
note F_, 2
note G#, 2
octave 4
note C_, 2
intensity $73
note C_, 2
intensity $53
note C_, 2
intensity $43
note C_, 2
intensity $93
octave 2
note G_, 2
octave 3
note C_, 2
note E_, 2
note G_, 2
octave 4
note C_, 2
intensity $73
note C_, 2
intensity $63
note C_, 2
intensity $43
note C_, 2
intensity $93
octave 2
note F#, 2
note A_, 2
octave 3
note D_, 2
note F#, 2
note A_, 2
intensity $73
note A_, 2
intensity $63
note A_, 2
intensity $43
note A_, 2
intensity $93
octave 2
note G_, 2
octave 3
note C_, 2
note D_, 2
note G_, 2
note G_, 2
intensity $73
note G_, 2
intensity $93
note D_, 2
octave 2
note G_, 2
loopchannel 0, Music_PostCredits_branch_cfdb2
Music_PostCredits_Ch2:
pitchoffset 0, D#
dutycycle $2
notetype $c, $a3
octave 5
note E_, 2
intensity $73
note E_, 2
intensity $a3
note F_, 2
intensity $73
note F_, 2
Music_PostCredits_branch_cfe5a:
intensity $a3
note G_, 2
intensity $73
note G_, 2
intensity $53
note G_, 2
intensity $43
note G_, 2
intensity $93
octave 6
note D_, 2
note C_, 2
octave 5
note B_, 2
octave 6
note C_, 2
octave 5
note G_, 2
intensity $73
note G_, 2
intensity $53
note G_, 2
intensity $43
note G_, 2
intensity $33
note G_, 2
intensity $a3
note E_, 2
intensity $73
note E_, 2
intensity $a3
note F_, 2
note G_, 2
intensity $73
note G_, 2
intensity $53
note G_, 2
intensity $43
note G_, 2
intensity $33
note G_, 2
intensity $a3
note A_, 2
intensity $73
note A_, 2
intensity $a3
note E_, 2
note G_, 2
intensity $73
note G_, 2
intensity $53
note G_, 2
intensity $a3
note F_, 2
intensity $73
note F_, 2
intensity $53
note F_, 2
intensity $a3
note D_, 2
note E_, 2
note F_, 2
intensity $73
note F_, 2
intensity $53
note F_, 2
intensity $43
note F_, 2
intensity $33
note F_, 2
intensity $a3
note G_, 2
intensity $73
note G_, 2
intensity $a3
note F_, 2
note E_, 2
note D#, 2
note E_, 2
note B_, 2
intensity $73
note B_, 2
intensity $53
note B_, 2
intensity $a3
note A_, 2
intensity $73
note A_, 2
intensity $a3
note D_, 2
intensity $73
note D_, 2
intensity $53
note D_, 2
intensity $43
note D_, 2
intensity $33
note D_, 2
note D_, 2
intensity $23
note D_, 2
note D_, 2
intensity $a3
note G_, 2
intensity $73
octave 4
note G_, 2
intensity $a3
octave 5
note D_, 2
note G_, 2
intensity $73
note G_, 2
intensity $53
note G_, 2
intensity $a3
note E_, 2
note F_, 2
loopchannel 0, Music_PostCredits_branch_cfe5a
|
benchmark.asm | trinadh724/xv-6-Modified- | 0 | 87636 |
_benchmark: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
#include "user.h"
int number_of_processes = 10;
int main(int argc, char *argv[])
{
0: 8d 4c 24 04 lea 0x4(%esp),%ecx
4: 83 e4 f0 and $0xfffffff0,%esp
7: ff 71 fc pushl -0x4(%ecx)
a: 55 push %ebp
b: 89 e5 mov %esp,%ebp
d: 53 push %ebx
e: 51 push %ecx
f: 83 ec 10 sub $0x10,%esp
int j;
for (j = 0; j < number_of_processes; j++)
12: a1 ec 0a 00 00 mov 0xaec,%eax
17: 85 c0 test %eax,%eax
19: 7e 38 jle 53 <main+0x53>
1b: 31 db xor %ebx,%ebx
1d: eb 0e jmp 2d <main+0x2d>
1f: 90 nop
if (pid < 0)
{
printf(1, "Fork failed\n");
continue;
}
if (pid == 0)
20: 74 57 je 79 <main+0x79>
for (j = 0; j < number_of_processes; j++)
22: 83 c3 01 add $0x1,%ebx
25: 39 1d ec 0a 00 00 cmp %ebx,0xaec
2b: 7e 26 jle 53 <main+0x53>
int pid = fork();
2d: e8 18 03 00 00 call 34a <fork>
if (pid < 0)
32: 85 c0 test %eax,%eax
34: 79 ea jns 20 <main+0x20>
printf(1, "Fork failed\n");
36: 83 ec 08 sub $0x8,%esp
for (j = 0; j < number_of_processes; j++)
39: 83 c3 01 add $0x1,%ebx
printf(1, "Fork failed\n");
3c: 68 08 08 00 00 push $0x808
41: 6a 01 push $0x1
43: e8 68 04 00 00 call 4b0 <printf>
continue;
48: 83 c4 10 add $0x10,%esp
for (j = 0; j < number_of_processes; j++)
4b: 39 1d ec 0a 00 00 cmp %ebx,0xaec
51: 7f da jg 2d <main+0x2d>
#ifdef PBS
set_priority(100-(20+j),pid); // will only matter for PBS, comment it out if not implemented yet (better priorty for more IO intensive jobs)
#endif
}
}
for (j = 0; j < number_of_processes+5; j++)
53: 83 3d ec 0a 00 00 fc cmpl $0xfffffffc,0xaec
5a: 7c 18 jl 74 <main+0x74>
5c: 31 db xor %ebx,%ebx
5e: 66 90 xchg %ax,%ax
{
wait();
60: e8 f5 02 00 00 call 35a <wait>
for (j = 0; j < number_of_processes+5; j++)
65: a1 ec 0a 00 00 mov 0xaec,%eax
6a: 83 c3 01 add $0x1,%ebx
6d: 83 c0 04 add $0x4,%eax
70: 39 d8 cmp %ebx,%eax
72: 7d ec jge 60 <main+0x60>
}
exit();
74: e8 d9 02 00 00 call 352 <exit>
for (volatile int k = 0; k < number_of_processes; k++)
79: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
80: 8b 45 f4 mov -0xc(%ebp),%eax
83: 3b 05 ec 0a 00 00 cmp 0xaec,%eax
89: 7c 29 jl b4 <main+0xb4>
8b: eb 58 jmp e5 <main+0xe5>
8d: 8d 76 00 lea 0x0(%esi),%esi
sleep(200); //io time
90: 83 ec 0c sub $0xc,%esp
93: 68 c8 00 00 00 push $0xc8
98: e8 45 03 00 00 call 3e2 <sleep>
9d: 83 c4 10 add $0x10,%esp
for (volatile int k = 0; k < number_of_processes; k++)
a0: 8b 45 f4 mov -0xc(%ebp),%eax
a3: 83 c0 01 add $0x1,%eax
a6: 89 45 f4 mov %eax,-0xc(%ebp)
a9: 8b 45 f4 mov -0xc(%ebp),%eax
ac: 3b 05 ec 0a 00 00 cmp 0xaec,%eax
b2: 7d 31 jge e5 <main+0xe5>
if (k <= j)
b4: 8b 45 f4 mov -0xc(%ebp),%eax
b7: 39 d8 cmp %ebx,%eax
b9: 7e d5 jle 90 <main+0x90>
for (i = 0; i < 100000000; i++)
bb: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
c2: 8b 45 f0 mov -0x10(%ebp),%eax
c5: 3d ff e0 f5 05 cmp $0x5f5e0ff,%eax
ca: 7f d4 jg a0 <main+0xa0>
cc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
d0: 8b 45 f0 mov -0x10(%ebp),%eax
d3: 83 c0 01 add $0x1,%eax
d6: 89 45 f0 mov %eax,-0x10(%ebp)
d9: 8b 45 f0 mov -0x10(%ebp),%eax
dc: 3d ff e0 f5 05 cmp $0x5f5e0ff,%eax
e1: 7e ed jle d0 <main+0xd0>
e3: eb bb jmp a0 <main+0xa0>
printf(1, "Process: %d with PID: %d Finished\n", j,getpid());
e5: e8 e8 02 00 00 call 3d2 <getpid>
ea: 50 push %eax
eb: 53 push %ebx
ec: 68 18 08 00 00 push $0x818
f1: 6a 01 push $0x1
f3: e8 b8 03 00 00 call 4b0 <printf>
exit();
f8: e8 55 02 00 00 call 352 <exit>
fd: 66 90 xchg %ax,%ax
ff: 90 nop
00000100 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, const char *t)
{
100: 55 push %ebp
101: 89 e5 mov %esp,%ebp
103: 53 push %ebx
104: 8b 45 08 mov 0x8(%ebp),%eax
107: 8b 4d 0c mov 0xc(%ebp),%ecx
char *os;
os = s;
while((*s++ = *t++) != 0)
10a: 89 c2 mov %eax,%edx
10c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
110: 83 c1 01 add $0x1,%ecx
113: 0f b6 59 ff movzbl -0x1(%ecx),%ebx
117: 83 c2 01 add $0x1,%edx
11a: 84 db test %bl,%bl
11c: 88 5a ff mov %bl,-0x1(%edx)
11f: 75 ef jne 110 <strcpy+0x10>
;
return os;
}
121: 5b pop %ebx
122: 5d pop %ebp
123: c3 ret
124: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
12a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00000130 <strcmp>:
int
strcmp(const char *p, const char *q)
{
130: 55 push %ebp
131: 89 e5 mov %esp,%ebp
133: 53 push %ebx
134: 8b 55 08 mov 0x8(%ebp),%edx
137: 8b 4d 0c mov 0xc(%ebp),%ecx
while(*p && *p == *q)
13a: 0f b6 02 movzbl (%edx),%eax
13d: 0f b6 19 movzbl (%ecx),%ebx
140: 84 c0 test %al,%al
142: 75 1c jne 160 <strcmp+0x30>
144: eb 2a jmp 170 <strcmp+0x40>
146: 8d 76 00 lea 0x0(%esi),%esi
149: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
p++, q++;
150: 83 c2 01 add $0x1,%edx
while(*p && *p == *q)
153: 0f b6 02 movzbl (%edx),%eax
p++, q++;
156: 83 c1 01 add $0x1,%ecx
159: 0f b6 19 movzbl (%ecx),%ebx
while(*p && *p == *q)
15c: 84 c0 test %al,%al
15e: 74 10 je 170 <strcmp+0x40>
160: 38 d8 cmp %bl,%al
162: 74 ec je 150 <strcmp+0x20>
return (uchar)*p - (uchar)*q;
164: 29 d8 sub %ebx,%eax
}
166: 5b pop %ebx
167: 5d pop %ebp
168: c3 ret
169: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
170: 31 c0 xor %eax,%eax
return (uchar)*p - (uchar)*q;
172: 29 d8 sub %ebx,%eax
}
174: 5b pop %ebx
175: 5d pop %ebp
176: c3 ret
177: 89 f6 mov %esi,%esi
179: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000180 <strlen>:
uint
strlen(const char *s)
{
180: 55 push %ebp
181: 89 e5 mov %esp,%ebp
183: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
for(n = 0; s[n]; n++)
186: 80 39 00 cmpb $0x0,(%ecx)
189: 74 15 je 1a0 <strlen+0x20>
18b: 31 d2 xor %edx,%edx
18d: 8d 76 00 lea 0x0(%esi),%esi
190: 83 c2 01 add $0x1,%edx
193: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1)
197: 89 d0 mov %edx,%eax
199: 75 f5 jne 190 <strlen+0x10>
;
return n;
}
19b: 5d pop %ebp
19c: c3 ret
19d: 8d 76 00 lea 0x0(%esi),%esi
for(n = 0; s[n]; n++)
1a0: 31 c0 xor %eax,%eax
}
1a2: 5d pop %ebp
1a3: c3 ret
1a4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
1aa: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
000001b0 <memset>:
void*
memset(void *dst, int c, uint n)
{
1b0: 55 push %ebp
1b1: 89 e5 mov %esp,%ebp
1b3: 57 push %edi
1b4: 8b 55 08 mov 0x8(%ebp),%edx
}
static inline void
stosb(void *addr, int data, int cnt)
{
asm volatile("cld; rep stosb" :
1b7: 8b 4d 10 mov 0x10(%ebp),%ecx
1ba: 8b 45 0c mov 0xc(%ebp),%eax
1bd: 89 d7 mov %edx,%edi
1bf: fc cld
1c0: f3 aa rep stos %al,%es:(%edi)
stosb(dst, c, n);
return dst;
}
1c2: 89 d0 mov %edx,%eax
1c4: 5f pop %edi
1c5: 5d pop %ebp
1c6: c3 ret
1c7: 89 f6 mov %esi,%esi
1c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000001d0 <strchr>:
char*
strchr(const char *s, char c)
{
1d0: 55 push %ebp
1d1: 89 e5 mov %esp,%ebp
1d3: 53 push %ebx
1d4: 8b 45 08 mov 0x8(%ebp),%eax
1d7: 8b 5d 0c mov 0xc(%ebp),%ebx
for(; *s; s++)
1da: 0f b6 10 movzbl (%eax),%edx
1dd: 84 d2 test %dl,%dl
1df: 74 1d je 1fe <strchr+0x2e>
if(*s == c)
1e1: 38 d3 cmp %dl,%bl
1e3: 89 d9 mov %ebx,%ecx
1e5: 75 0d jne 1f4 <strchr+0x24>
1e7: eb 17 jmp 200 <strchr+0x30>
1e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
1f0: 38 ca cmp %cl,%dl
1f2: 74 0c je 200 <strchr+0x30>
for(; *s; s++)
1f4: 83 c0 01 add $0x1,%eax
1f7: 0f b6 10 movzbl (%eax),%edx
1fa: 84 d2 test %dl,%dl
1fc: 75 f2 jne 1f0 <strchr+0x20>
return (char*)s;
return 0;
1fe: 31 c0 xor %eax,%eax
}
200: 5b pop %ebx
201: 5d pop %ebp
202: c3 ret
203: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
209: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000210 <gets>:
char*
gets(char *buf, int max)
{
210: 55 push %ebp
211: 89 e5 mov %esp,%ebp
213: 57 push %edi
214: 56 push %esi
215: 53 push %ebx
int i, cc;
char c;
for(i=0; i+1 < max; ){
216: 31 f6 xor %esi,%esi
218: 89 f3 mov %esi,%ebx
{
21a: 83 ec 1c sub $0x1c,%esp
21d: 8b 7d 08 mov 0x8(%ebp),%edi
for(i=0; i+1 < max; ){
220: eb 2f jmp 251 <gets+0x41>
222: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
cc = read(0, &c, 1);
228: 8d 45 e7 lea -0x19(%ebp),%eax
22b: 83 ec 04 sub $0x4,%esp
22e: 6a 01 push $0x1
230: 50 push %eax
231: 6a 00 push $0x0
233: e8 32 01 00 00 call 36a <read>
if(cc < 1)
238: 83 c4 10 add $0x10,%esp
23b: 85 c0 test %eax,%eax
23d: 7e 1c jle 25b <gets+0x4b>
break;
buf[i++] = c;
23f: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
243: 83 c7 01 add $0x1,%edi
246: 88 47 ff mov %al,-0x1(%edi)
if(c == '\n' || c == '\r')
249: 3c 0a cmp $0xa,%al
24b: 74 23 je 270 <gets+0x60>
24d: 3c 0d cmp $0xd,%al
24f: 74 1f je 270 <gets+0x60>
for(i=0; i+1 < max; ){
251: 83 c3 01 add $0x1,%ebx
254: 3b 5d 0c cmp 0xc(%ebp),%ebx
257: 89 fe mov %edi,%esi
259: 7c cd jl 228 <gets+0x18>
25b: 89 f3 mov %esi,%ebx
break;
}
buf[i] = '\0';
return buf;
}
25d: 8b 45 08 mov 0x8(%ebp),%eax
buf[i] = '\0';
260: c6 03 00 movb $0x0,(%ebx)
}
263: 8d 65 f4 lea -0xc(%ebp),%esp
266: 5b pop %ebx
267: 5e pop %esi
268: 5f pop %edi
269: 5d pop %ebp
26a: c3 ret
26b: 90 nop
26c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
270: 8b 75 08 mov 0x8(%ebp),%esi
273: 8b 45 08 mov 0x8(%ebp),%eax
276: 01 de add %ebx,%esi
278: 89 f3 mov %esi,%ebx
buf[i] = '\0';
27a: c6 03 00 movb $0x0,(%ebx)
}
27d: 8d 65 f4 lea -0xc(%ebp),%esp
280: 5b pop %ebx
281: 5e pop %esi
282: 5f pop %edi
283: 5d pop %ebp
284: c3 ret
285: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
289: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000290 <stat>:
int
stat(const char *n, struct stat *st)
{
290: 55 push %ebp
291: 89 e5 mov %esp,%ebp
293: 56 push %esi
294: 53 push %ebx
int fd;
int r;
fd = open(n, O_RDONLY);
295: 83 ec 08 sub $0x8,%esp
298: 6a 00 push $0x0
29a: ff 75 08 pushl 0x8(%ebp)
29d: e8 f0 00 00 00 call 392 <open>
if(fd < 0)
2a2: 83 c4 10 add $0x10,%esp
2a5: 85 c0 test %eax,%eax
2a7: 78 27 js 2d0 <stat+0x40>
return -1;
r = fstat(fd, st);
2a9: 83 ec 08 sub $0x8,%esp
2ac: ff 75 0c pushl 0xc(%ebp)
2af: 89 c3 mov %eax,%ebx
2b1: 50 push %eax
2b2: e8 f3 00 00 00 call 3aa <fstat>
close(fd);
2b7: 89 1c 24 mov %ebx,(%esp)
r = fstat(fd, st);
2ba: 89 c6 mov %eax,%esi
close(fd);
2bc: e8 b9 00 00 00 call 37a <close>
return r;
2c1: 83 c4 10 add $0x10,%esp
}
2c4: 8d 65 f8 lea -0x8(%ebp),%esp
2c7: 89 f0 mov %esi,%eax
2c9: 5b pop %ebx
2ca: 5e pop %esi
2cb: 5d pop %ebp
2cc: c3 ret
2cd: 8d 76 00 lea 0x0(%esi),%esi
return -1;
2d0: be ff ff ff ff mov $0xffffffff,%esi
2d5: eb ed jmp 2c4 <stat+0x34>
2d7: 89 f6 mov %esi,%esi
2d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000002e0 <atoi>:
int
atoi(const char *s)
{
2e0: 55 push %ebp
2e1: 89 e5 mov %esp,%ebp
2e3: 53 push %ebx
2e4: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
n = 0;
while('0' <= *s && *s <= '9')
2e7: 0f be 11 movsbl (%ecx),%edx
2ea: 8d 42 d0 lea -0x30(%edx),%eax
2ed: 3c 09 cmp $0x9,%al
n = 0;
2ef: b8 00 00 00 00 mov $0x0,%eax
while('0' <= *s && *s <= '9')
2f4: 77 1f ja 315 <atoi+0x35>
2f6: 8d 76 00 lea 0x0(%esi),%esi
2f9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
n = n*10 + *s++ - '0';
300: 8d 04 80 lea (%eax,%eax,4),%eax
303: 83 c1 01 add $0x1,%ecx
306: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax
while('0' <= *s && *s <= '9')
30a: 0f be 11 movsbl (%ecx),%edx
30d: 8d 5a d0 lea -0x30(%edx),%ebx
310: 80 fb 09 cmp $0x9,%bl
313: 76 eb jbe 300 <atoi+0x20>
return n;
}
315: 5b pop %ebx
316: 5d pop %ebp
317: c3 ret
318: 90 nop
319: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00000320 <memmove>:
void*
memmove(void *vdst, const void *vsrc, int n)
{
320: 55 push %ebp
321: 89 e5 mov %esp,%ebp
323: 56 push %esi
324: 53 push %ebx
325: 8b 5d 10 mov 0x10(%ebp),%ebx
328: 8b 45 08 mov 0x8(%ebp),%eax
32b: 8b 75 0c mov 0xc(%ebp),%esi
char *dst;
const char *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
32e: 85 db test %ebx,%ebx
330: 7e 14 jle 346 <memmove+0x26>
332: 31 d2 xor %edx,%edx
334: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
*dst++ = *src++;
338: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx
33c: 88 0c 10 mov %cl,(%eax,%edx,1)
33f: 83 c2 01 add $0x1,%edx
while(n-- > 0)
342: 39 d3 cmp %edx,%ebx
344: 75 f2 jne 338 <memmove+0x18>
return vdst;
}
346: 5b pop %ebx
347: 5e pop %esi
348: 5d pop %ebp
349: c3 ret
0000034a <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
34a: b8 01 00 00 00 mov $0x1,%eax
34f: cd 40 int $0x40
351: c3 ret
00000352 <exit>:
SYSCALL(exit)
352: b8 02 00 00 00 mov $0x2,%eax
357: cd 40 int $0x40
359: c3 ret
0000035a <wait>:
SYSCALL(wait)
35a: b8 03 00 00 00 mov $0x3,%eax
35f: cd 40 int $0x40
361: c3 ret
00000362 <pipe>:
SYSCALL(pipe)
362: b8 04 00 00 00 mov $0x4,%eax
367: cd 40 int $0x40
369: c3 ret
0000036a <read>:
SYSCALL(read)
36a: b8 05 00 00 00 mov $0x5,%eax
36f: cd 40 int $0x40
371: c3 ret
00000372 <write>:
SYSCALL(write)
372: b8 10 00 00 00 mov $0x10,%eax
377: cd 40 int $0x40
379: c3 ret
0000037a <close>:
SYSCALL(close)
37a: b8 15 00 00 00 mov $0x15,%eax
37f: cd 40 int $0x40
381: c3 ret
00000382 <kill>:
SYSCALL(kill)
382: b8 06 00 00 00 mov $0x6,%eax
387: cd 40 int $0x40
389: c3 ret
0000038a <exec>:
SYSCALL(exec)
38a: b8 07 00 00 00 mov $0x7,%eax
38f: cd 40 int $0x40
391: c3 ret
00000392 <open>:
SYSCALL(open)
392: b8 0f 00 00 00 mov $0xf,%eax
397: cd 40 int $0x40
399: c3 ret
0000039a <mknod>:
SYSCALL(mknod)
39a: b8 11 00 00 00 mov $0x11,%eax
39f: cd 40 int $0x40
3a1: c3 ret
000003a2 <unlink>:
SYSCALL(unlink)
3a2: b8 12 00 00 00 mov $0x12,%eax
3a7: cd 40 int $0x40
3a9: c3 ret
000003aa <fstat>:
SYSCALL(fstat)
3aa: b8 08 00 00 00 mov $0x8,%eax
3af: cd 40 int $0x40
3b1: c3 ret
000003b2 <link>:
SYSCALL(link)
3b2: b8 13 00 00 00 mov $0x13,%eax
3b7: cd 40 int $0x40
3b9: c3 ret
000003ba <mkdir>:
SYSCALL(mkdir)
3ba: b8 14 00 00 00 mov $0x14,%eax
3bf: cd 40 int $0x40
3c1: c3 ret
000003c2 <chdir>:
SYSCALL(chdir)
3c2: b8 09 00 00 00 mov $0x9,%eax
3c7: cd 40 int $0x40
3c9: c3 ret
000003ca <dup>:
SYSCALL(dup)
3ca: b8 0a 00 00 00 mov $0xa,%eax
3cf: cd 40 int $0x40
3d1: c3 ret
000003d2 <getpid>:
SYSCALL(getpid)
3d2: b8 0b 00 00 00 mov $0xb,%eax
3d7: cd 40 int $0x40
3d9: c3 ret
000003da <sbrk>:
SYSCALL(sbrk)
3da: b8 0c 00 00 00 mov $0xc,%eax
3df: cd 40 int $0x40
3e1: c3 ret
000003e2 <sleep>:
SYSCALL(sleep)
3e2: b8 0d 00 00 00 mov $0xd,%eax
3e7: cd 40 int $0x40
3e9: c3 ret
000003ea <uptime>:
SYSCALL(uptime)
3ea: b8 0e 00 00 00 mov $0xe,%eax
3ef: cd 40 int $0x40
3f1: c3 ret
000003f2 <waitx>:
SYSCALL(waitx)
3f2: b8 16 00 00 00 mov $0x16,%eax
3f7: cd 40 int $0x40
3f9: c3 ret
000003fa <set_priority>:
SYSCALL(set_priority)
3fa: b8 17 00 00 00 mov $0x17,%eax
3ff: cd 40 int $0x40
401: c3 ret
00000402 <ps>:
SYSCALL(ps)
402: b8 18 00 00 00 mov $0x18,%eax
407: cd 40 int $0x40
409: c3 ret
40a: 66 90 xchg %ax,%ax
40c: 66 90 xchg %ax,%ax
40e: 66 90 xchg %ax,%ax
00000410 <printint>:
write(fd, &c, 1);
}
static void
printint(int fd, int xx, int base, int sgn)
{
410: 55 push %ebp
411: 89 e5 mov %esp,%ebp
413: 57 push %edi
414: 56 push %esi
415: 53 push %ebx
416: 83 ec 3c sub $0x3c,%esp
char buf[16];
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
419: 85 d2 test %edx,%edx
{
41b: 89 45 c0 mov %eax,-0x40(%ebp)
neg = 1;
x = -xx;
41e: 89 d0 mov %edx,%eax
if(sgn && xx < 0){
420: 79 76 jns 498 <printint+0x88>
422: f6 45 08 01 testb $0x1,0x8(%ebp)
426: 74 70 je 498 <printint+0x88>
x = -xx;
428: f7 d8 neg %eax
neg = 1;
42a: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp)
} else {
x = xx;
}
i = 0;
431: 31 f6 xor %esi,%esi
433: 8d 5d d7 lea -0x29(%ebp),%ebx
436: eb 0a jmp 442 <printint+0x32>
438: 90 nop
439: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
do{
buf[i++] = digits[x % base];
440: 89 fe mov %edi,%esi
442: 31 d2 xor %edx,%edx
444: 8d 7e 01 lea 0x1(%esi),%edi
447: f7 f1 div %ecx
449: 0f b6 92 44 08 00 00 movzbl 0x844(%edx),%edx
}while((x /= base) != 0);
450: 85 c0 test %eax,%eax
buf[i++] = digits[x % base];
452: 88 14 3b mov %dl,(%ebx,%edi,1)
}while((x /= base) != 0);
455: 75 e9 jne 440 <printint+0x30>
if(neg)
457: 8b 45 c4 mov -0x3c(%ebp),%eax
45a: 85 c0 test %eax,%eax
45c: 74 08 je 466 <printint+0x56>
buf[i++] = '-';
45e: c6 44 3d d8 2d movb $0x2d,-0x28(%ebp,%edi,1)
463: 8d 7e 02 lea 0x2(%esi),%edi
466: 8d 74 3d d7 lea -0x29(%ebp,%edi,1),%esi
46a: 8b 7d c0 mov -0x40(%ebp),%edi
46d: 8d 76 00 lea 0x0(%esi),%esi
470: 0f b6 06 movzbl (%esi),%eax
write(fd, &c, 1);
473: 83 ec 04 sub $0x4,%esp
476: 83 ee 01 sub $0x1,%esi
479: 6a 01 push $0x1
47b: 53 push %ebx
47c: 57 push %edi
47d: 88 45 d7 mov %al,-0x29(%ebp)
480: e8 ed fe ff ff call 372 <write>
while(--i >= 0)
485: 83 c4 10 add $0x10,%esp
488: 39 de cmp %ebx,%esi
48a: 75 e4 jne 470 <printint+0x60>
putc(fd, buf[i]);
}
48c: 8d 65 f4 lea -0xc(%ebp),%esp
48f: 5b pop %ebx
490: 5e pop %esi
491: 5f pop %edi
492: 5d pop %ebp
493: c3 ret
494: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
neg = 0;
498: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp)
49f: eb 90 jmp 431 <printint+0x21>
4a1: eb 0d jmp 4b0 <printf>
4a3: 90 nop
4a4: 90 nop
4a5: 90 nop
4a6: 90 nop
4a7: 90 nop
4a8: 90 nop
4a9: 90 nop
4aa: 90 nop
4ab: 90 nop
4ac: 90 nop
4ad: 90 nop
4ae: 90 nop
4af: 90 nop
000004b0 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, const char *fmt, ...)
{
4b0: 55 push %ebp
4b1: 89 e5 mov %esp,%ebp
4b3: 57 push %edi
4b4: 56 push %esi
4b5: 53 push %ebx
4b6: 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++){
4b9: 8b 75 0c mov 0xc(%ebp),%esi
4bc: 0f b6 1e movzbl (%esi),%ebx
4bf: 84 db test %bl,%bl
4c1: 0f 84 b3 00 00 00 je 57a <printf+0xca>
ap = (uint*)(void*)&fmt + 1;
4c7: 8d 45 10 lea 0x10(%ebp),%eax
4ca: 83 c6 01 add $0x1,%esi
state = 0;
4cd: 31 ff xor %edi,%edi
ap = (uint*)(void*)&fmt + 1;
4cf: 89 45 d4 mov %eax,-0x2c(%ebp)
4d2: eb 2f jmp 503 <printf+0x53>
4d4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
4d8: 83 f8 25 cmp $0x25,%eax
4db: 0f 84 a7 00 00 00 je 588 <printf+0xd8>
write(fd, &c, 1);
4e1: 8d 45 e2 lea -0x1e(%ebp),%eax
4e4: 83 ec 04 sub $0x4,%esp
4e7: 88 5d e2 mov %bl,-0x1e(%ebp)
4ea: 6a 01 push $0x1
4ec: 50 push %eax
4ed: ff 75 08 pushl 0x8(%ebp)
4f0: e8 7d fe ff ff call 372 <write>
4f5: 83 c4 10 add $0x10,%esp
4f8: 83 c6 01 add $0x1,%esi
for(i = 0; fmt[i]; i++){
4fb: 0f b6 5e ff movzbl -0x1(%esi),%ebx
4ff: 84 db test %bl,%bl
501: 74 77 je 57a <printf+0xca>
if(state == 0){
503: 85 ff test %edi,%edi
c = fmt[i] & 0xff;
505: 0f be cb movsbl %bl,%ecx
508: 0f b6 c3 movzbl %bl,%eax
if(state == 0){
50b: 74 cb je 4d8 <printf+0x28>
state = '%';
} else {
putc(fd, c);
}
} else if(state == '%'){
50d: 83 ff 25 cmp $0x25,%edi
510: 75 e6 jne 4f8 <printf+0x48>
if(c == 'd'){
512: 83 f8 64 cmp $0x64,%eax
515: 0f 84 05 01 00 00 je 620 <printf+0x170>
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
51b: 81 e1 f7 00 00 00 and $0xf7,%ecx
521: 83 f9 70 cmp $0x70,%ecx
524: 74 72 je 598 <printf+0xe8>
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
526: 83 f8 73 cmp $0x73,%eax
529: 0f 84 99 00 00 00 je 5c8 <printf+0x118>
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
52f: 83 f8 63 cmp $0x63,%eax
532: 0f 84 08 01 00 00 je 640 <printf+0x190>
putc(fd, *ap);
ap++;
} else if(c == '%'){
538: 83 f8 25 cmp $0x25,%eax
53b: 0f 84 ef 00 00 00 je 630 <printf+0x180>
write(fd, &c, 1);
541: 8d 45 e7 lea -0x19(%ebp),%eax
544: 83 ec 04 sub $0x4,%esp
547: c6 45 e7 25 movb $0x25,-0x19(%ebp)
54b: 6a 01 push $0x1
54d: 50 push %eax
54e: ff 75 08 pushl 0x8(%ebp)
551: e8 1c fe ff ff call 372 <write>
556: 83 c4 0c add $0xc,%esp
559: 8d 45 e6 lea -0x1a(%ebp),%eax
55c: 88 5d e6 mov %bl,-0x1a(%ebp)
55f: 6a 01 push $0x1
561: 50 push %eax
562: ff 75 08 pushl 0x8(%ebp)
565: 83 c6 01 add $0x1,%esi
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
568: 31 ff xor %edi,%edi
write(fd, &c, 1);
56a: e8 03 fe ff ff call 372 <write>
for(i = 0; fmt[i]; i++){
56f: 0f b6 5e ff movzbl -0x1(%esi),%ebx
write(fd, &c, 1);
573: 83 c4 10 add $0x10,%esp
for(i = 0; fmt[i]; i++){
576: 84 db test %bl,%bl
578: 75 89 jne 503 <printf+0x53>
}
}
}
57a: 8d 65 f4 lea -0xc(%ebp),%esp
57d: 5b pop %ebx
57e: 5e pop %esi
57f: 5f pop %edi
580: 5d pop %ebp
581: c3 ret
582: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
state = '%';
588: bf 25 00 00 00 mov $0x25,%edi
58d: e9 66 ff ff ff jmp 4f8 <printf+0x48>
592: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
printint(fd, *ap, 16, 0);
598: 83 ec 0c sub $0xc,%esp
59b: b9 10 00 00 00 mov $0x10,%ecx
5a0: 6a 00 push $0x0
5a2: 8b 7d d4 mov -0x2c(%ebp),%edi
5a5: 8b 45 08 mov 0x8(%ebp),%eax
5a8: 8b 17 mov (%edi),%edx
5aa: e8 61 fe ff ff call 410 <printint>
ap++;
5af: 89 f8 mov %edi,%eax
5b1: 83 c4 10 add $0x10,%esp
state = 0;
5b4: 31 ff xor %edi,%edi
ap++;
5b6: 83 c0 04 add $0x4,%eax
5b9: 89 45 d4 mov %eax,-0x2c(%ebp)
5bc: e9 37 ff ff ff jmp 4f8 <printf+0x48>
5c1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
s = (char*)*ap;
5c8: 8b 45 d4 mov -0x2c(%ebp),%eax
5cb: 8b 08 mov (%eax),%ecx
ap++;
5cd: 83 c0 04 add $0x4,%eax
5d0: 89 45 d4 mov %eax,-0x2c(%ebp)
if(s == 0)
5d3: 85 c9 test %ecx,%ecx
5d5: 0f 84 8e 00 00 00 je 669 <printf+0x1b9>
while(*s != 0){
5db: 0f b6 01 movzbl (%ecx),%eax
state = 0;
5de: 31 ff xor %edi,%edi
s = (char*)*ap;
5e0: 89 cb mov %ecx,%ebx
while(*s != 0){
5e2: 84 c0 test %al,%al
5e4: 0f 84 0e ff ff ff je 4f8 <printf+0x48>
5ea: 89 75 d0 mov %esi,-0x30(%ebp)
5ed: 89 de mov %ebx,%esi
5ef: 8b 5d 08 mov 0x8(%ebp),%ebx
5f2: 8d 7d e3 lea -0x1d(%ebp),%edi
5f5: 8d 76 00 lea 0x0(%esi),%esi
write(fd, &c, 1);
5f8: 83 ec 04 sub $0x4,%esp
s++;
5fb: 83 c6 01 add $0x1,%esi
5fe: 88 45 e3 mov %al,-0x1d(%ebp)
write(fd, &c, 1);
601: 6a 01 push $0x1
603: 57 push %edi
604: 53 push %ebx
605: e8 68 fd ff ff call 372 <write>
while(*s != 0){
60a: 0f b6 06 movzbl (%esi),%eax
60d: 83 c4 10 add $0x10,%esp
610: 84 c0 test %al,%al
612: 75 e4 jne 5f8 <printf+0x148>
614: 8b 75 d0 mov -0x30(%ebp),%esi
state = 0;
617: 31 ff xor %edi,%edi
619: e9 da fe ff ff jmp 4f8 <printf+0x48>
61e: 66 90 xchg %ax,%ax
printint(fd, *ap, 10, 1);
620: 83 ec 0c sub $0xc,%esp
623: b9 0a 00 00 00 mov $0xa,%ecx
628: 6a 01 push $0x1
62a: e9 73 ff ff ff jmp 5a2 <printf+0xf2>
62f: 90 nop
write(fd, &c, 1);
630: 83 ec 04 sub $0x4,%esp
633: 88 5d e5 mov %bl,-0x1b(%ebp)
636: 8d 45 e5 lea -0x1b(%ebp),%eax
639: 6a 01 push $0x1
63b: e9 21 ff ff ff jmp 561 <printf+0xb1>
putc(fd, *ap);
640: 8b 7d d4 mov -0x2c(%ebp),%edi
write(fd, &c, 1);
643: 83 ec 04 sub $0x4,%esp
putc(fd, *ap);
646: 8b 07 mov (%edi),%eax
write(fd, &c, 1);
648: 6a 01 push $0x1
ap++;
64a: 83 c7 04 add $0x4,%edi
putc(fd, *ap);
64d: 88 45 e4 mov %al,-0x1c(%ebp)
write(fd, &c, 1);
650: 8d 45 e4 lea -0x1c(%ebp),%eax
653: 50 push %eax
654: ff 75 08 pushl 0x8(%ebp)
657: e8 16 fd ff ff call 372 <write>
ap++;
65c: 89 7d d4 mov %edi,-0x2c(%ebp)
65f: 83 c4 10 add $0x10,%esp
state = 0;
662: 31 ff xor %edi,%edi
664: e9 8f fe ff ff jmp 4f8 <printf+0x48>
s = "(null)";
669: bb 3c 08 00 00 mov $0x83c,%ebx
while(*s != 0){
66e: b8 28 00 00 00 mov $0x28,%eax
673: e9 72 ff ff ff jmp 5ea <printf+0x13a>
678: 66 90 xchg %ax,%ax
67a: 66 90 xchg %ax,%ax
67c: 66 90 xchg %ax,%ax
67e: 66 90 xchg %ax,%ax
00000680 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
680: 55 push %ebp
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
681: a1 f0 0a 00 00 mov 0xaf0,%eax
{
686: 89 e5 mov %esp,%ebp
688: 57 push %edi
689: 56 push %esi
68a: 53 push %ebx
68b: 8b 5d 08 mov 0x8(%ebp),%ebx
bp = (Header*)ap - 1;
68e: 8d 4b f8 lea -0x8(%ebx),%ecx
691: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
698: 39 c8 cmp %ecx,%eax
69a: 8b 10 mov (%eax),%edx
69c: 73 32 jae 6d0 <free+0x50>
69e: 39 d1 cmp %edx,%ecx
6a0: 72 04 jb 6a6 <free+0x26>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
6a2: 39 d0 cmp %edx,%eax
6a4: 72 32 jb 6d8 <free+0x58>
break;
if(bp + bp->s.size == p->s.ptr){
6a6: 8b 73 fc mov -0x4(%ebx),%esi
6a9: 8d 3c f1 lea (%ecx,%esi,8),%edi
6ac: 39 fa cmp %edi,%edx
6ae: 74 30 je 6e0 <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;
6b0: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
6b3: 8b 50 04 mov 0x4(%eax),%edx
6b6: 8d 34 d0 lea (%eax,%edx,8),%esi
6b9: 39 f1 cmp %esi,%ecx
6bb: 74 3a je 6f7 <free+0x77>
p->s.size += bp->s.size;
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
6bd: 89 08 mov %ecx,(%eax)
freep = p;
6bf: a3 f0 0a 00 00 mov %eax,0xaf0
}
6c4: 5b pop %ebx
6c5: 5e pop %esi
6c6: 5f pop %edi
6c7: 5d pop %ebp
6c8: c3 ret
6c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
6d0: 39 d0 cmp %edx,%eax
6d2: 72 04 jb 6d8 <free+0x58>
6d4: 39 d1 cmp %edx,%ecx
6d6: 72 ce jb 6a6 <free+0x26>
{
6d8: 89 d0 mov %edx,%eax
6da: eb bc jmp 698 <free+0x18>
6dc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
bp->s.size += p->s.ptr->s.size;
6e0: 03 72 04 add 0x4(%edx),%esi
6e3: 89 73 fc mov %esi,-0x4(%ebx)
bp->s.ptr = p->s.ptr->s.ptr;
6e6: 8b 10 mov (%eax),%edx
6e8: 8b 12 mov (%edx),%edx
6ea: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
6ed: 8b 50 04 mov 0x4(%eax),%edx
6f0: 8d 34 d0 lea (%eax,%edx,8),%esi
6f3: 39 f1 cmp %esi,%ecx
6f5: 75 c6 jne 6bd <free+0x3d>
p->s.size += bp->s.size;
6f7: 03 53 fc add -0x4(%ebx),%edx
freep = p;
6fa: a3 f0 0a 00 00 mov %eax,0xaf0
p->s.size += bp->s.size;
6ff: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
702: 8b 53 f8 mov -0x8(%ebx),%edx
705: 89 10 mov %edx,(%eax)
}
707: 5b pop %ebx
708: 5e pop %esi
709: 5f pop %edi
70a: 5d pop %ebp
70b: c3 ret
70c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
00000710 <malloc>:
return freep;
}
void*
malloc(uint nbytes)
{
710: 55 push %ebp
711: 89 e5 mov %esp,%ebp
713: 57 push %edi
714: 56 push %esi
715: 53 push %ebx
716: 83 ec 0c sub $0xc,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
719: 8b 45 08 mov 0x8(%ebp),%eax
if((prevp = freep) == 0){
71c: 8b 15 f0 0a 00 00 mov 0xaf0,%edx
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
722: 8d 78 07 lea 0x7(%eax),%edi
725: c1 ef 03 shr $0x3,%edi
728: 83 c7 01 add $0x1,%edi
if((prevp = freep) == 0){
72b: 85 d2 test %edx,%edx
72d: 0f 84 9d 00 00 00 je 7d0 <malloc+0xc0>
733: 8b 02 mov (%edx),%eax
735: 8b 48 04 mov 0x4(%eax),%ecx
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
if(p->s.size >= nunits){
738: 39 cf cmp %ecx,%edi
73a: 76 6c jbe 7a8 <malloc+0x98>
73c: 81 ff 00 10 00 00 cmp $0x1000,%edi
742: bb 00 10 00 00 mov $0x1000,%ebx
747: 0f 43 df cmovae %edi,%ebx
p = sbrk(nu * sizeof(Header));
74a: 8d 34 dd 00 00 00 00 lea 0x0(,%ebx,8),%esi
751: eb 0e jmp 761 <malloc+0x51>
753: 90 nop
754: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
758: 8b 02 mov (%edx),%eax
if(p->s.size >= nunits){
75a: 8b 48 04 mov 0x4(%eax),%ecx
75d: 39 f9 cmp %edi,%ecx
75f: 73 47 jae 7a8 <malloc+0x98>
p->s.size = nunits;
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
761: 39 05 f0 0a 00 00 cmp %eax,0xaf0
767: 89 c2 mov %eax,%edx
769: 75 ed jne 758 <malloc+0x48>
p = sbrk(nu * sizeof(Header));
76b: 83 ec 0c sub $0xc,%esp
76e: 56 push %esi
76f: e8 66 fc ff ff call 3da <sbrk>
if(p == (char*)-1)
774: 83 c4 10 add $0x10,%esp
777: 83 f8 ff cmp $0xffffffff,%eax
77a: 74 1c je 798 <malloc+0x88>
hp->s.size = nu;
77c: 89 58 04 mov %ebx,0x4(%eax)
free((void*)(hp + 1));
77f: 83 ec 0c sub $0xc,%esp
782: 83 c0 08 add $0x8,%eax
785: 50 push %eax
786: e8 f5 fe ff ff call 680 <free>
return freep;
78b: 8b 15 f0 0a 00 00 mov 0xaf0,%edx
if((p = morecore(nunits)) == 0)
791: 83 c4 10 add $0x10,%esp
794: 85 d2 test %edx,%edx
796: 75 c0 jne 758 <malloc+0x48>
return 0;
}
}
798: 8d 65 f4 lea -0xc(%ebp),%esp
return 0;
79b: 31 c0 xor %eax,%eax
}
79d: 5b pop %ebx
79e: 5e pop %esi
79f: 5f pop %edi
7a0: 5d pop %ebp
7a1: c3 ret
7a2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
if(p->s.size == nunits)
7a8: 39 cf cmp %ecx,%edi
7aa: 74 54 je 800 <malloc+0xf0>
p->s.size -= nunits;
7ac: 29 f9 sub %edi,%ecx
7ae: 89 48 04 mov %ecx,0x4(%eax)
p += p->s.size;
7b1: 8d 04 c8 lea (%eax,%ecx,8),%eax
p->s.size = nunits;
7b4: 89 78 04 mov %edi,0x4(%eax)
freep = prevp;
7b7: 89 15 f0 0a 00 00 mov %edx,0xaf0
}
7bd: 8d 65 f4 lea -0xc(%ebp),%esp
return (void*)(p + 1);
7c0: 83 c0 08 add $0x8,%eax
}
7c3: 5b pop %ebx
7c4: 5e pop %esi
7c5: 5f pop %edi
7c6: 5d pop %ebp
7c7: c3 ret
7c8: 90 nop
7c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
base.s.ptr = freep = prevp = &base;
7d0: c7 05 f0 0a 00 00 f4 movl $0xaf4,0xaf0
7d7: 0a 00 00
7da: c7 05 f4 0a 00 00 f4 movl $0xaf4,0xaf4
7e1: 0a 00 00
base.s.size = 0;
7e4: b8 f4 0a 00 00 mov $0xaf4,%eax
7e9: c7 05 f8 0a 00 00 00 movl $0x0,0xaf8
7f0: 00 00 00
7f3: e9 44 ff ff ff jmp 73c <malloc+0x2c>
7f8: 90 nop
7f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
prevp->s.ptr = p->s.ptr;
800: 8b 08 mov (%eax),%ecx
802: 89 0a mov %ecx,(%edx)
804: eb b1 jmp 7b7 <malloc+0xa7>
|
data/maps/sgb_roof_pal_inds.asm | Trap-Master/spacworld97-thingy | 0 | 169363 | <reponame>Trap-Master/spacworld97-thingy<filename>data/maps/sgb_roof_pal_inds.asm
; Crystal does not support SGB, so this is unused.
MapGroupRoofSGBPalInds:
; entries correspond to map groups
db PREDEFPAL_00
db PREDEFPAL_DUNGEONS
db PREDEFPAL_ECRUTEAK
db PREDEFPAL_BLACKTHORN
db PREDEFPAL_CINNABAR
db PREDEFPAL_CERULEAN
db PREDEFPAL_LAKE_OF_RAGE
db PREDEFPAL_VIOLET
db PREDEFPAL_GOLDENROD
db PREDEFPAL_VERMILION
db PREDEFPAL_PALLET
db PREDEFPAL_PEWTER
db PREDEFPAL_VERMILION
db PREDEFPAL_INDIGO
db PREDEFPAL_FUCHSIA
db PREDEFPAL_LAVENDER
db PREDEFPAL_FUCHSIA
db PREDEFPAL_CELADON
db PREDEFPAL_CIANWOOD
db PREDEFPAL_VIRIDIAN
db PREDEFPAL_SAFFRON
|
programs/oeis/060/A060633.asm | neoneye/loda | 22 | 240815 | ; A060633: Surround numbers of an n X 1 rectangle.
; 16,123,361,778,1428,2371,3673,5406,7648,10483,14001,18298,23476,29643,36913,45406,55248,66571,79513,94218,110836,129523,150441,173758,199648,228291,259873,294586,332628,374203,419521,468798,522256,580123,642633,710026,782548,860451,943993,1033438,1129056,1231123,1339921,1455738,1578868,1709611,1848273,1995166,2150608,2314923,2488441,2671498,2864436,3067603,3281353,3506046,3742048,3989731,4249473,4521658,4806676,5104923,5416801,5742718,6083088,6438331,6808873,7195146,7597588,8016643,8452761,8906398,9378016,9868083,10377073,10905466,11453748,12022411,12611953,13222878,13855696,14510923,15189081,15890698,16616308,17366451,18141673,18942526,19769568,20623363,21504481,22413498,23350996,24317563,25313793,26340286,27397648,28486491,29607433,30761098
mov $2,$0
mov $5,3
lpb $0
add $5,$0
sub $0,1
add $5,6
lpe
sub $5,1
mov $3,$5
add $6,1
lpb $3
sub $3,1
add $4,1
lpe
lpb $4
sub $4,1
add $6,$5
lpe
mov $1,$6
lpb $2
add $1,30
sub $2,1
lpe
add $1,11
mov $0,$1
|
programs/oeis/176/A176777.asm | jmorken/loda | 1 | 166154 | ; A176777: 2^n-n*(n-3).
; 1,4,6,8,12,22,46,100,216,458,954,1960,3988,8062,16230,32588,65328,130834,261874,523984,1048236,2096774,4193886,8388148,16776712,33553882,67108266,134217080,268434756,536870158,1073741014,2147482780
mov $2,$0
mov $3,1
lpb $0
sub $0,1
add $1,$0
mul $3,2
lpe
sub $3,$1
add $1,2
add $3,10
sub $3,$1
mov $1,$3
lpb $2
add $1,2
sub $2,1
lpe
sub $1,8
|
Transynther/x86/_processed/NONE/_xt_/i3-7100_9_0xca_notsx.log_21829_915.asm | ljhsiun2/medusa | 9 | 166295 | .global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r13
push %r8
push %r9
push %rcx
push %rdi
push %rsi
lea addresses_A_ht+0x786d, %r13
nop
nop
sub %r9, %r9
movw $0x6162, (%r13)
sub $16846, %r11
lea addresses_WT_ht+0x13365, %r8
nop
nop
inc %r9
movb $0x61, (%r8)
add $11005, %r10
lea addresses_WT_ht+0x1123d, %rsi
lea addresses_A_ht+0x88cd, %rdi
nop
nop
cmp %r13, %r13
mov $2, %rcx
rep movsb
nop
nop
nop
nop
and %r10, %r10
lea addresses_UC_ht+0x11f9d, %rdi
nop
nop
cmp %r13, %r13
mov (%rdi), %r10d
inc %r11
lea addresses_A_ht+0x1986d, %rsi
lea addresses_D_ht+0xf3ed, %rdi
nop
nop
nop
cmp %r9, %r9
mov $43, %rcx
rep movsw
sub $35916, %rdi
lea addresses_A_ht+0xffed, %r11
nop
nop
nop
nop
xor %rcx, %rcx
mov (%r11), %edi
nop
dec %r13
lea addresses_D_ht+0x11fad, %rsi
lea addresses_A_ht+0xec6d, %rdi
nop
nop
nop
inc %r13
mov $33, %rcx
rep movsq
nop
nop
nop
nop
nop
add %r8, %r8
lea addresses_normal_ht+0x118ed, %rsi
lea addresses_normal_ht+0x1341d, %rdi
clflush (%rsi)
nop
add %r13, %r13
mov $15, %rcx
rep movsb
and $42737, %rdi
lea addresses_D_ht+0x206d, %rcx
nop
nop
nop
cmp $7899, %r11
movups (%rcx), %xmm0
vpextrq $1, %xmm0, %rdi
nop
nop
nop
and $52345, %rsi
lea addresses_normal_ht+0xd16d, %r8
nop
nop
dec %r13
mov $0x6162636465666768, %r10
movq %r10, %xmm0
movups %xmm0, (%r8)
nop
sub $56843, %rcx
lea addresses_A_ht+0x79ad, %r8
nop
inc %r9
movl $0x61626364, (%r8)
nop
nop
and %rsi, %rsi
lea addresses_D_ht+0xddad, %r10
nop
nop
cmp $46579, %rdi
mov (%r10), %r9w
nop
nop
nop
and %r8, %r8
lea addresses_WC_ht+0xec6d, %r11
nop
nop
nop
nop
inc %r9
mov (%r11), %r8d
nop
nop
inc %r9
pop %rsi
pop %rdi
pop %rcx
pop %r9
pop %r8
pop %r13
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r13
push %r14
push %r15
push %rbp
push %rbx
// Store
lea addresses_UC+0xa86d, %rbp
nop
nop
nop
sub %r10, %r10
mov $0x5152535455565758, %r13
movq %r13, (%rbp)
nop
nop
nop
nop
nop
cmp $28298, %r10
// Store
lea addresses_WT+0x12c09, %r10
nop
nop
nop
nop
and $23899, %r14
movb $0x51, (%r10)
nop
nop
inc %r14
// Load
lea addresses_UC+0xf06d, %r15
nop
nop
lfence
movups (%r15), %xmm2
vpextrq $0, %xmm2, %r14
nop
nop
nop
nop
nop
add $16292, %r14
// Faulty Load
lea addresses_UC+0xa86d, %r13
nop
nop
nop
nop
xor %rbp, %rbp
movups (%r13), %xmm1
vpextrq $1, %xmm1, %r14
lea oracles, %r13
and $0xff, %r14
shlq $12, %r14
mov (%r13,%r14,1), %r14
pop %rbx
pop %rbp
pop %r15
pop %r14
pop %r13
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_UC', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_UC', 'size': 8, 'AVXalign': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 2, 'NT': False, 'type': 'addresses_WT', 'size': 1, 'AVXalign': False}}
{'src': {'same': False, 'congruent': 11, 'NT': False, 'type': 'addresses_UC', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_UC', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 10, 'NT': False, 'type': 'addresses_A_ht', 'size': 2, 'AVXalign': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_WT_ht', 'size': 1, 'AVXalign': False}}
{'src': {'type': 'addresses_WT_ht', 'congruent': 4, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_A_ht', 'congruent': 4, 'same': False}}
{'src': {'same': False, 'congruent': 4, 'NT': False, 'type': 'addresses_UC_ht', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_A_ht', 'congruent': 11, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 7, 'same': False}}
{'src': {'same': False, 'congruent': 5, 'NT': False, 'type': 'addresses_A_ht', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_D_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_A_ht', 'congruent': 10, 'same': False}}
{'src': {'type': 'addresses_normal_ht', 'congruent': 0, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 4, 'same': False}}
{'src': {'same': False, 'congruent': 10, 'NT': False, 'type': 'addresses_D_ht', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 7, 'NT': False, 'type': 'addresses_normal_ht', 'size': 16, 'AVXalign': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 6, 'NT': False, 'type': 'addresses_A_ht', 'size': 4, 'AVXalign': False}}
{'src': {'same': False, 'congruent': 1, 'NT': False, 'type': 'addresses_D_ht', 'size': 2, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'same': False, 'congruent': 9, 'NT': False, 'type': 'addresses_WC_ht', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'}
{'37': 21829}
37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37
*/
|
Transynther/x86/_processed/AVXALIGN/_zr_/i9-9900K_12_0xca_notsx.log_21829_1915.asm | ljhsiun2/medusa | 9 | 176501 | .global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r12
push %r13
push %r15
push %rbp
push %rbx
push %rcx
lea addresses_UC_ht+0x17baa, %r13
sub $13739, %rbp
mov $0x6162636465666768, %r15
movq %r15, %xmm7
vmovups %ymm7, (%r13)
nop
nop
dec %r12
lea addresses_D_ht+0xe74a, %rbp
nop
nop
nop
inc %rcx
movb (%rbp), %bl
nop
nop
nop
nop
sub $27542, %rbx
lea addresses_UC_ht+0x1244a, %rcx
clflush (%rcx)
nop
nop
nop
nop
inc %r11
mov (%rcx), %r12w
add %rbx, %rbx
pop %rcx
pop %rbx
pop %rbp
pop %r15
pop %r13
pop %r12
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r15
push %r9
push %rbx
push %rcx
push %rdx
push %rsi
// Store
mov $0x4ca, %r9
cmp $53441, %rbx
movb $0x51, (%r9)
dec %r9
// Store
lea addresses_US+0x127ca, %r15
clflush (%r15)
add $19295, %r12
movw $0x5152, (%r15)
nop
nop
nop
nop
nop
and %r15, %r15
// Store
lea addresses_WC+0x810a, %r9
nop
nop
nop
cmp %r12, %r12
mov $0x5152535455565758, %rsi
movq %rsi, (%r9)
nop
nop
nop
nop
add $36247, %rdx
// Faulty Load
lea addresses_US+0x1fa4a, %rcx
nop
nop
nop
and $45712, %r9
movntdqa (%rcx), %xmm4
vpextrq $1, %xmm4, %r15
lea oracles, %r12
and $0xff, %r15
shlq $12, %r15
mov (%r12,%r15,1), %r15
pop %rsi
pop %rdx
pop %rcx
pop %rbx
pop %r9
pop %r15
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_US', 'NT': False, 'AVXalign': True, 'size': 1, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_P', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 7}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_US', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 7}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WC', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 6}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_US', 'NT': True, 'AVXalign': False, 'size': 16, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 4}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 8}}
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 9}}
{'00': 21829}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
jql.g4 | leoybkim/JQL | 8 | 3966 | grammar jql;
parse
: ( jql_stmt_list )* EOF
;
jql_stmt_list
: SCOL* jql_stmt ( SCOL+ jql_stmt )* SCOL*
;
jql_stmt
: OPEN_PAR* expr ( ( K_AND | K_OR) OPEN_PAR* expr CLOSE_PAR* )* CLOSE_PAR* ordering_term?
;
expr
: K_NOT* ( field | literal_value ) operator OPEN_PAR* ( literal_value | literal_list | FUNCTION | dates ) (compare_dates)? CLOSE_PAR*
;
ordering_term
: K_ORDER K_BY literal_value ( K_ASC | K_DESC )? (COMMA literal_value ( K_ASC | K_DESC )? )*
;
operator
: EQ
| NOT_EQ
| CONTAINS
| NOT_CONTAINS
| LT_EQ
| LT
| GT
| GT_EQ
| K_IN
| K_NOT K_IN
| K_IS
| K_WAS
| K_IS K_NOT
| K_WAS K_NOT
| K_CHANGED K_TO
;
literal_value
: STRING_LITERAL
| IDENTIFIER
| state_name
| field
| dates
;
FUNCTION
: [a-zA-Z]+ '(' (.*? | FUNCTION) ')'
;
literal_list
: '(' literal_value ( COMMA literal_value )* ')'
;
keyword
: K_AFTER
| K_AND
| K_ASC
| K_BEFORE
| K_BY
| K_CHANGED
| K_DESC
| K_IN
| K_IS
| K_NOT
| K_NULL
| K_ON
| K_OR
| K_ORDER
| K_TO
| K_WAS
;
state_name
: K_EMPTY
;
field
: F_AFFECTED_VERSION
| F_APPROVALS
| F_ASSIGNEE
| F_ATTACHMENTS
| F_CATEGORY
| F_COMMENT
| F_COMPONENT
| F_CREATED
| F_CREATED_DATE
| F_CREATOR
| F_CUSTOM_FIELD
| F_CUSTOMER_REQUEST_TYPE
| F_DATE
| F_DESCRIPTION
| F_DUE
| F_DURATION
| F_ENVIRONMENT
| F_EPIC_LINK
| F_FILTER
| F_FIX_VERSION
| F_ISSUE
| F_ISSUE_KEY
| F_ISSUE_TYPE
| F_KEY
| F_LABEL
| F_LABELS
| F_LAST_VIEWED
| F_LEVEL
| F_NUMBER
| F_ORGANIZATION
| F_ORIGINAL_ESTIMATE
| F_PARENT
| F_PRIORITY
| F_PROJECT
| F_RANK
| F_REMAINING_ESTIMATE
| F_REPORTER
| F_REQUEST_CHANNEL_TYPE
| F_REQUEST_LAST_ACTIVITY_TIME
| F_RESOLUTION
| F_RESOLUTION_DATE
| F_RESOLVED
| F_SLA
| F_SPRINT
| F_STATUS
| F_SUMMARY
| F_TEXT
| F_TIME_SPENT
| F_TYPE
| F_UPDATED
| F_USER
| F_VERSION
| F_VOTER
| F_VOTES
| F_WATCHER
| F_WATCHERS
| F_WORK_RATIO
;
compare_dates : ( K_ON | K_AFTER | K_BEFORE )? dates ;
dates : DATETIME ;
DATETIME
: ('-'|'+')? (NUMBER ('d'|'w'|'y'|'h'|'m')?)+
| ('"' DIGIT DIGIT DIGIT DIGIT '-' DIGIT DIGIT '-' DIGIT DIGIT (DIGIT DIGIT ':' DIGIT DIGIT)? '"')
| ('\'' DIGIT DIGIT DIGIT DIGIT '-' DIGIT DIGIT '-' DIGIT DIGIT (DIGIT DIGIT ':' DIGIT DIGIT)? '\'')
| ( DIGIT DIGIT DIGIT DIGIT '-' DIGIT DIGIT '-' DIGIT DIGIT (DIGIT DIGIT ':' DIGIT DIGIT)? )
;
NUMBER : DIGIT+ ;
WHITESPACE : ' ' -> skip ;
SCOL : ';';
DOT : '.';
OPEN_PAR : '(';
CLOSE_PAR : ')';
COMMA : ',';
EQ : '=';
STAR : '*';
CONTAINS : '~';
NOT_CONTAINS : '!~';
LT : '<';
LT_EQ : '<=';
GT : '>';
GT_EQ : '>=';
NOT_EQ : '!=';
K_AFTER : A F T E R;
K_AND : A N D;
K_ASC : A S C;
K_BEFORE : B E F O R E;
K_BY : B Y;
K_CHANGED : C H A N G E D;
K_DESC : D E S C;
K_EMPTY : E M P T Y;
K_IN : I N;
K_IS : I S;
K_NOT : N O T;
K_NULL : N U L L;
K_ON : O N;
K_OR : O R;
K_ORDER : O R D E R;
K_TO : T O;
K_WAS : W A S;
F_AFFECTED_VERSION : A F F E C T E D V E R S I O N;
F_APPROVALS : A P P R O V A L S;
F_ASSIGNEE : A S S I G N E E;
F_ATTACHMENTS : A T T A C H M E N T S;
F_CATEGORY : C A T E G O R Y;
F_COMMENT : C O M M E N T;
F_COMPONENT : C O M P O N E N T;
F_CREATED : C R E A T E D;
F_CREATED_DATE : C R E A T E D D A T E;
F_CREATOR : C R E A T O R;
F_CUSTOM_FIELD : C F '[' NUMBER ']';
F_CUSTOMER_REQUEST_TYPE : C U S T O M E R R E Q U E S T T Y P E;
F_DATE : D A T E;
F_DESCRIPTION : D E S C R I P T I O N;
F_DUE : D U E;
F_DURATION : D U R A T I O N;
F_ENVIRONMENT : E N V I R O N M E N T;
F_EPIC_LINK : E P I C L I N K;
F_FILTER : F I L T E R;
F_FIX_VERSION : F I X V E R S I O N;
F_ISSUE : I S S U E;
F_ISSUE_KEY : I <NAME>;
F_ISSUE_TYPE : I S S U E T Y P E;
F_KEY : K E Y;
F_LABEL : L A B E L;
F_LABELS : L A B E L S;
F_LAST_VIEWED : L A S T V I E W E D;
F_LEVEL : L E V E L;
F_NUMBER : N U M B E R;
F_ORGANIZATION : O R G A N I Z A T I O N;
F_ORIGINAL_ESTIMATE : O R I G I N A L E S T I M A T E;
F_PARENT : P A R E N T;
F_PRIORITY : P R I O R I T Y;
F_PROJECT : P R O J E C T;
F_RANK : R A N K;
F_REMAINING_ESTIMATE : R E M A I N I N G E S T I M A T E;
F_REPORTER : R E P O R T E R;
F_REQUEST_CHANNEL_TYPE : R E Q U E S T C H A N N E L T Y P E;
F_REQUEST_LAST_ACTIVITY_TIME : R E Q U E S T L A S T A C T I V I T Y T I M E;
F_RESOLUTION : R E S O L U T I O N;
F_RESOLUTION_DATE : R E S O L U T I O N D A T E;
F_RESOLVED : R E S O L V E D;
F_SLA : S L A;
F_SPRINT : S P R I N T;
F_STATUS : S T A T U S;
F_SUMMARY : S U M M A R Y;
F_TEXT : T E X T;
F_TIME_SPENT : T I M E S P E N T;
F_TYPE : T Y P E;
F_UPDATED : U P D A T E D;
F_USER : U S E R;
F_VERSION : V E R S I O N;
F_VOTER : V O T E R;
F_VOTES : V O T E S;
F_WATCHER : W A T C H E R;
F_WATCHERS : W A T C H E R S;
F_WORK_RATIO : W O R K R A T I O;
IDENTIFIER
: '"' (~'"' | '""')* '"'
| '`' (~'`' | '``')* '`'
| '[' ~']'* ']'
| [a-zA-Z_] [a-zA-Z_0-9.\-]* // TODO check: needs more chars in set
| '-'
| [A-Z]+ '-' [0-9]+ // ex) KEY-###
;
STRING_LITERAL
: '\'' ('\\'. | '\'\'' | ~('\'' | '\\'))* '\''
| '"' ( '\\'. | '""' | ~('"'| '\\') )* '"'
;
COMMENT
: '/*' .*? '*/' -> skip
;
LINE_COMMENT
: '//' ~[\r\n]* -> skip
;
SPACES
: [ \u000B\t\r\n] -> channel(HIDDEN)
;
fragment DIGIT : [0-9];
fragment A : [aA];
fragment B : [bB];
fragment C : [cC];
fragment D : [dD];
fragment E : [eE];
fragment F : [fF];
fragment G : [gG];
fragment H : [hH];
fragment I : [iI];
fragment J : [jJ];
fragment K : [kK];
fragment L : [lL];
fragment M : [mM];
fragment N : [nN];
fragment O : [oO];
fragment P : [pP];
fragment Q : [qQ];
fragment R : [rR];
fragment S : [sS];
fragment T : [tT];
fragment U : [uU];
fragment V : [vV];
fragment W : [wW];
fragment X : [xX];
fragment Y : [yY];
fragment Z : [zZ]; |
Rings/EuclideanDomains/Definition.agda | Smaug123/agdaproofs | 4 | 4080 | <gh_stars>1-10
{-# OPTIONS --safe --warning=error --without-K #-}
open import LogicalFormulae
open import Groups.Definition
open import Numbers.Naturals.Definition
open import Numbers.Naturals.Order
open import Setoids.Setoids
open import Sets.EquivalenceRelations
open import Rings.Definition
open import Rings.IntegralDomains.Definition
open import Orders.Total.Definition
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
module Rings.EuclideanDomains.Definition {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ _*_ : A → A → A} (R : Ring S _+_ _*_) where
open import Rings.Divisible.Definition R
open Setoid S
open Equivalence eq
open Ring R
open Group additiveGroup
record DivisionAlgorithmResult (norm : {a : A} → ((a ∼ 0R) → False) → ℕ) {x y : A} (x!=0 : (x ∼ 0R) → False) (y!=0 : (y ∼ 0R) → False) : Set (a ⊔ b) where
field
quotient : A
rem : A
remSmall : (rem ∼ 0R) || Sg ((rem ∼ 0R) → False) (λ rem!=0 → (norm rem!=0) <N (norm y!=0))
divAlg : x ∼ ((quotient * y) + rem)
record DivisionAlgorithmResult' (norm : (a : A) → ℕ) (x y : A) : Set (a ⊔ b) where
field
quotient : A
rem : A
remSmall : (rem ∼ 0R) || ((norm rem) <N (norm y))
divAlg : x ∼ ((quotient * y) + rem)
record EuclideanDomain : Set (a ⊔ lsuc b) where
field
isIntegralDomain : IntegralDomain R
norm : {a : A} → ((a ∼ 0R) → False) → ℕ
normSize : {a b : A} → (a!=0 : (a ∼ 0R) → False) → (b!=0 : (b ∼ 0R) → False) → (c : A) → b ∼ (a * c) → (norm a!=0) ≤N (norm b!=0)
divisionAlg : {a b : A} → (a!=0 : (a ∼ 0R) → False) → (b!=0 : (b ∼ 0R) → False) → DivisionAlgorithmResult norm a!=0 b!=0
normWellDefined : {a : A} → (p1 p2 : (a ∼ 0R) → False) → norm p1 ≡ norm p2
normWellDefined {a} p1 p2 with normSize p1 p2 1R (symmetric (transitive *Commutative identIsIdent))
normWellDefined {a} p1 p2 | inl n1<n2 with normSize p2 p1 1R (symmetric (transitive *Commutative identIsIdent))
normWellDefined {a} p1 p2 | inl n1<n2 | inl n2<n1 = exFalso (TotalOrder.irreflexive ℕTotalOrder (TotalOrder.<Transitive ℕTotalOrder n1<n2 n2<n1))
normWellDefined {a} p1 p2 | inl n1<n2 | inr n2=n1 = equalityCommutative n2=n1
normWellDefined {a} p1 p2 | inr n1=n2 = n1=n2
normWellDefined' : {a b : A} → (a ∼ b) → (a!=0 : (a ∼ 0R) → False) → (b!=0 : (b ∼ 0R) → False) → norm a!=0 ≡ norm b!=0
normWellDefined' a=b a!=0 b!=0 with normSize a!=0 b!=0 1R (symmetric (transitive *Commutative (transitive identIsIdent a=b)))
normWellDefined' a=b a!=0 b!=0 | inl a<b with normSize b!=0 a!=0 1R (symmetric (transitive *Commutative (transitive identIsIdent (symmetric a=b))))
normWellDefined' a=b a!=0 b!=0 | inl a<b | inl b<a = exFalso (TotalOrder.irreflexive ℕTotalOrder (TotalOrder.<Transitive ℕTotalOrder a<b b<a))
normWellDefined' a=b a!=0 b!=0 | inl a<b | inr n= = equalityCommutative n=
normWellDefined' a=b a!=0 b!=0 | inr n= = n=
record EuclideanDomain' : Set (a ⊔ lsuc b) where
field
isIntegralDomain : IntegralDomain R
norm : A → ℕ
normWellDefined : {a b : A} → (a ∼ b) → norm a ≡ norm b
normSize : (a b : A) → (a ∣ b) → ((b ∼ 0R) → False) → norm a ≤N (norm b)
divisionAlg : (a b : A) → ((b ∼ 0R) → False) → DivisionAlgorithmResult' norm a b
normEquiv : (e : EuclideanDomain) (decidableZero : (a : A) → (a ∼ 0R) || ((a ∼ 0R) → False)) → A → ℕ
normEquiv e decidableZero a with decidableZero a
... | inl a=0 = 0
... | inr a!=0 = EuclideanDomain.norm e a!=0
normSizeEquiv : (e : EuclideanDomain) (decidableZero : (a : A) → (a ∼ 0R) || ((a ∼ 0R) → False)) (a b : A) → (a ∣ b) → ((b ∼ 0R) → False) → normEquiv e decidableZero a ≤N normEquiv e decidableZero b
normSizeEquiv e decidableZero a b (c , ac=b) b!=0 = ans
where
abstract
a!=0 : (a ∼ 0R) → False
a!=0 a=0 = b!=0 (transitive (symmetric ac=b) (transitive (*WellDefined a=0 reflexive) (transitive *Commutative timesZero)))
normIs : normEquiv e decidableZero a ≡ EuclideanDomain.norm e a!=0
normIs with decidableZero a
normIs | inl a=0 = exFalso (a!=0 a=0)
normIs | inr a!=0' = EuclideanDomain.normWellDefined e a!=0' a!=0
normIs' : normEquiv e decidableZero b ≡ EuclideanDomain.norm e b!=0
normIs' with decidableZero b
normIs' | inl b=0 = exFalso (b!=0 b=0)
normIs' | inr b!=0' = EuclideanDomain.normWellDefined e b!=0' b!=0
ans : (normEquiv e decidableZero a) ≤N (normEquiv e decidableZero b)
ans with EuclideanDomain.normSize e a!=0 b!=0 c (symmetric ac=b)
ans | inl n<Nn = inl (identityOfIndiscernablesLeft _<N_ (identityOfIndiscernablesRight _<N_ n<Nn (equalityCommutative normIs')) (equalityCommutative normIs))
ans | inr n=n = inr (transitivity normIs (transitivity n=n (equalityCommutative normIs')))
divisionAlgEquiv : (e : EuclideanDomain) (decidableZero : (a : A) → (a ∼ 0R) || ((a ∼ 0R) → False)) → (a b : A) → ((b ∼ 0R) → False) → DivisionAlgorithmResult' (normEquiv e decidableZero) a b
divisionAlgEquiv e decidableZero a b b!=0 with decidableZero a
divisionAlgEquiv e decidableZero a b b!=0 | inl a=0 = record { quotient = 0R ; rem = 0R ; remSmall = inl reflexive ; divAlg = transitive a=0 (transitive (symmetric identLeft) (+WellDefined (symmetric (transitive *Commutative timesZero)) reflexive)) }
divisionAlgEquiv e decidableZero a b b!=0 | inr a!=0 with EuclideanDomain.divisionAlg e a!=0 b!=0
divisionAlgEquiv e decidableZero a b b!=0 | inr a!=0 | record { quotient = quotient ; rem = rem ; remSmall = inl x ; divAlg = divAlg } = record { quotient = quotient ; rem = rem ; remSmall = inl x ; divAlg = divAlg }
divisionAlgEquiv e decidableZero a b b!=0 | inr a!=0 | record { quotient = quotient ; rem = rem ; remSmall = inr (rem!=0 , pr) ; divAlg = divAlg } = record { quotient = quotient ; rem = rem ; remSmall = inr (identityOfIndiscernablesLeft _<N_ (identityOfIndiscernablesRight _<N_ pr (equalityCommutative normIs')) (equalityCommutative normIs)) ; divAlg = divAlg }
where
normIs : normEquiv e decidableZero rem ≡ EuclideanDomain.norm e rem!=0
normIs with decidableZero rem
normIs | inl rem=0 = exFalso (rem!=0 rem=0)
normIs | inr rem!=0' = EuclideanDomain.normWellDefined e rem!=0' rem!=0
normIs' : normEquiv e decidableZero b ≡ EuclideanDomain.norm e b!=0
normIs' with decidableZero b
normIs' | inl b=0 = exFalso (b!=0 b=0)
normIs' | inr b!=0' = EuclideanDomain.normWellDefined e b!=0' b!=0
normWellDefined : (e : EuclideanDomain) (decidableZero : (a : A) → (a ∼ 0R) || ((a ∼ 0R) → False)) {a b : A} (a=b : a ∼ b) → normEquiv e decidableZero a ≡ normEquiv e decidableZero b
normWellDefined e decidableZero {a} {b} a=b with decidableZero a
normWellDefined e decidableZero {a} {b} a=b | inl a=0 with decidableZero b
normWellDefined e decidableZero {a} {b} a=b | inl a=0 | inl b=0 = refl
normWellDefined e decidableZero {a} {b} a=b | inl a=0 | inr b!=0 = exFalso (b!=0 (transitive (symmetric a=b) a=0))
normWellDefined e decidableZero {a} {b} a=b | inr a!=0 with decidableZero b
normWellDefined e decidableZero {a} {b} a=b | inr a!=0 | inl b=0 = exFalso (a!=0 (transitive a=b b=0))
normWellDefined e decidableZero {a} {b} a=b | inr a!=0 | inr b!=0 = EuclideanDomain.normWellDefined' e a=b a!=0 b!=0
eucDomsEquiv : (decidableZero : (a : A) → (a ∼ 0R) || ((a ∼ 0R) → False)) → EuclideanDomain → EuclideanDomain'
eucDomsEquiv decidableZero e = record { isIntegralDomain = EuclideanDomain.isIntegralDomain e ; norm = normEquiv e decidableZero ; normSize = normSizeEquiv e decidableZero ; divisionAlg = divisionAlgEquiv e decidableZero ; normWellDefined = normWellDefined e decidableZero }
|
src/main/antlr4/Sexp.g4 | jerry-james/cek | 0 | 5764 | grammar Sexp;
sexps : sexp* EOF;
sexp : vardefn | fundefn | atom | list ;
// this grammar has an error, its obviously incorrect to allow a vardefn or fundefn form in the body of a vardefn
vardefn : '(' 'define' SYMBOL sexp ')';
fundefn : '(' 'define' '(' fundefnsymbol SYMBOL* ')' sexp* ')';
fundefnsymbol : SYMBOL;
list : '(' sexp* ')';
atom : STRING | SYMBOL | NUMBER ;
STRING : '"' ('\\' . | ~ ('\\' | '"'))* '"' ;
WHITESPACE : (' ' | '\n' | '\t' | '\r') + -> skip ;
NUMBER : ('+' | '-')? (DIGIT) + ('.' (DIGIT) +)? ;
SYMBOL : SYMBOL_START (SYMBOL_START | DIGIT)* ;
fragment SYMBOL_START : ('a' .. 'z') | ('A' .. 'Z') | '+' | '-' | '*' | '/' | '.' ;
fragment DIGIT : ('0' .. '9') ;
|
libsrc/_DEVELOPMENT/inttypes/c/sdcc_iy/strtoumax_callee.asm | jpoikela/z88dk | 640 | 28555 | <filename>libsrc/_DEVELOPMENT/inttypes/c/sdcc_iy/strtoumax_callee.asm
; uintmax_t strtoumax_callee(const char *nptr, char **endptr, int base)
SECTION code_clib
SECTION code_inttypes
PUBLIC _strtoumax_callee
EXTERN _strtoull_callee
defc _strtoumax_callee = _strtoull_callee
|
ppp.asm | melrick-mascarenhas/mp-testing | 0 | 163369 | <filename>ppp.asm
.model small
putchar macro l
mov ah,2
mov dl,l
int 21h
endm
.data
n dw 5
r dw 1
ncr dw 0
.code
mov ax,@data
mov ds,ax
mov ax,n
mov bx,r
call ncrpro
mov ax,ncr
mov dx,ax
call convdisp
mov ah,4ch
int 21h
ncrpro proc
cmp bx,ax
je r1
cmp bx,0
je r1
cmp bx,1
je rn
dec ax
cmp bx,ax
je r2
push ax
push bx
call ncrpro
pop bx
pop ax
dec ax
push ax
push bx
call ncrpro
pop bx
pop ax
ret
r1: inc ncr
ret
r2: inc ncr
rn: add ncr,ax
ret
ncrpro endp
convdisp proc
;mov al,ncr
aam
add ax,3030h
mov bx,ax
putchar bh
putchar bl
mov ah,4ch
int 21h
ret
convdisp endp
end
|
examples/asm_2/detect.asm | amindlost/dos32a | 5 | 101246 | <reponame>amindlost/dos32a
;
; Copyright (C) 1996-2002 Supernar Systems, Ltd. All rights reserved.
;
; Redistribution and use in source and binary forms, with or without
; modification, are permitted provided that the following conditions are
; met:
;
; 1. Redistributions of source code must retain the above copyright
; notice, this list of conditions and the following disclaimer.
;
; 2. Redistributions in binary form must reproduce the above copyright
; notice, this list of conditions and the following disclaimer in the
; documentation and/or other materials provided with the distribution.
;
; 3. The end-user documentation included with the redistribution, if any,
; must include the following acknowledgment:
;
; "This product uses DOS/32 Advanced DOS Extender technology."
;
; Alternately, this acknowledgment may appear in the software itself, if
; and wherever such third-party acknowledgments normally appear.
;
; 4. Products derived from this software may not be called "DOS/32A" or
; "DOS/32 Advanced".
;
; THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS" AND ANY EXPRESSED
; 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 AUTHORS OR COPYRIGHT HOLDERS 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.
;
;
;*****************************************************************************
;
; DETECT.ASM
; This program will show how to check if DOS/32 Advanced DOS Extender and
; DOS/32 Advanced built-in DPMI are present, ie if your program is running
; under DOS/32 Advanced.
; Note that if an external DPMI host is present, DOS/32 Advanced DOS Extender
; will be installed on top of it, extending DOS API (INT 21h), Mouse API
; (INT 33h) and VGA/VESA API (INT 10h), but the built-in DPMI will not be
; installed, and the present DPMI host will be responsible for handling of
; the exceptions and for memory allocation.
;
;*****************************************************************************
.386p
.MODEL flat
DGROUP group _DATA,STACK ; Tasm will complain about STACK here
.CODE
;=============================================================================
start:
push ds ; make ES = DS
pop es
call dos32a_Detect ; detect DOS Extender, use method #1
test eax,eax
mov edx,offset _msg1
jz @@01
mov edx,offset _msg2
@@01: call prints
call dos32a_GetClientConfig ; detect DOS Extender, use method #2
test eax,eax
mov edx,offset _msg3
jz @@02
mov edx,offset _msg4
@@02: call prints
call dos32a_GetKernelConfig ; detect DOS Extender, use method #3
test eax,eax
mov edx,offset _msg5
jz @@03
mov edx,offset _msg6
@@03: call prints
call dpmi32a_Detect ; detect built-in DPMI
test eax,eax
mov edx,offset _msg7
jz @@04
mov edx,offset _msg8
@@04: call prints
call api32_GetAccessGDT ; show IDT information
mov ax,4C00h ; return to DOS with error code 00h
int 21h
;-----------------------------------------------------------------------------
; This subroutine will use INT 21h, AX=0FF88h from protected mode to detect
; DOS/32 Advanced. Since this function in not used by the standard real mode
; DOS, the DOS Extender will install and use it for identification purposes.
; Note that this function will be available in both real and protected modes
; when DOS/32 Advanced built-in DPMI is installed, and in protected mode only
; when an external DPMI host is present.
;
dos32a_Detect:
mov ax,0FF88h ; AX = DOS/32A API function 0FF88h
int 21h ; detect DOS Extender
cmp eax,'ID32' ; returns: EAX = 'ID32' if DOS/32A
mov eax,1 ; DOS Extender is present
jnz @@11
mov eax,0
@@11: ret
;-----------------------------------------------------------------------------
; This subroutine will use INT 21h, AX=0FF89h function to detect the DOS
; Extender and to get information about its configuration. This function,
; unlike the previous, will be supported by the DOS Extender in protected
; mode only.
;
dos32a_GetClientConfig:
mov ax,0FF89h ; AX = DOS/32A API function 0FF89h
int 21h ; get DOS Extender configuration
cmp eax,'ID32' ; returns: EAX = 'ID32' if DOS/32A
mov eax,1 ; DOS Extender is present
jnz @@21
mov eax,0
@@21: ret
;-----------------------------------------------------------------------------
; This subroutine will use INT 21h, AX=0FF8Ah function to detect the DOS
; Extender and to get information about its configuration. This function
; is supported by the DOS Extender in the protected mode only.
;
dos32a_GetKernelConfig:
mov ax,0FF8Ah ; AX = DOS/32A API function 0FF8Ah
int 21h ; get DPMI Kernel configuration
cmp eax,'ID32' ; returns: EAX = 'ID32' if DOS/32A
mov eax,1 ; DOS Extender is present
jnz @@31
mov eax,0
@@31: ret
;-----------------------------------------------------------------------------
; This subroutine will use DPMI API function 0A00h to detect whether the
; DOS/32 Advanced built-in DPMI is installed.
;
dpmi32a_Detect:
push ds
push es
mov ax,0A00h ; AX = DPMI function 0A00h
mov esi,offset _idstr ; ESI = ptr to ID-string
int 31h ; call DPMI
mov eax,1
jc @@41 ; if CF is clear, the ID-string
mov eax,0 ; was recognized by the DPMI
mov _api_cs,es
mov _api_ip,edi
@@41: pop es
pop ds
ret
;-----------------------------------------------------------------------------
; This subroutine will use ADPMI extensions to show information about IDT
;
api32_GetAccessGDT:
mov eax,_api_ip ; check if ADPMI API extensions are
or ax,_api_cs ; present
jz @@51 ; if not, jump
mov al,0 ; AL = extended API function 00h
call fword ptr _api_ip ; call extended ADPMI
mov ebx,edi ; EBX = IDT base (argument #1)
mov ecx,edx ; ECX = IDT limit (argument #2)
mov edx,offset _msg9 ; EDX = pointer to string
call prints ; Magic!
@@51: ret
;-----------------------------------------------------------------------------
; This subroutine will use the "undocumented" DOS API function AX=Magic.
;
; The Magic function writes a formatted, null-terminated string to the STDOUT
; using DOS API function 09h. EBX and ECX are used to pass arguments to the
; function and DS:EDX is used as a pointer to the string. The accepted
; argument modifiers are: "%b", "%c", "%d", "%l" and "%w". You will
; have to figure out yourself what they do. The maximum *formatted* string
; length is 256 chars. The arguments are optional, of course. Also when
; passing two words as arguments, place both in EBX (high, low) leaving
; ECX unused. Feel free to experiment, and enjoy Magic!
;
prints: mov ax,0FF80h ; DOS API Magic function
int 21h ; call DOS API
ret
.DATA
;=============================================================================
_idstr db 'SUNSYS DOS/32A',0
_msg1 db ' + DOS/32 Advanced DOS Extender is present',0Dh,0Ah,0
_msg2 db ' - DOS/32 Advanced DOS Extender is *NOT* present',0Dh,0Ah,0
_msg3 db ' + DOS/32 Advanced DOS Extender function 0FF89h is supported',0Dh,0Ah,0
_msg4 db ' - DOS/32 Advanced DOS Extender function 0FF89h is *NOT* supported',0Dh,0Ah,0
_msg5 db ' + DOS/32 Advanced DOS Extender function 0FF8Ah is supported',0Dh,0Ah,0
_msg6 db ' - DOS/32 Advanced DOS Extender function 0FF8Ah is *NOT* supported',0Dh,0Ah,0
_msg7 db ' + DOS/32 Advanced built-in DPMI is installed',0Dh,0Ah,0
_msg8 db ' - DOS/32 Advanced built-in DPMI is *NOT* installed',0Dh,0Ah,0
_msg9 db ' + IDT Base=%lh, IDT Limit=%wh',0Dh,0Ah,0
_api_ip dd 0
_api_cs dw 0
.STACK
;=============================================================================
db 1000h dup(?)
end start
|
tests/expect/tests/mov-immoffs.asm | brenden7158/v86 | 12,700 | 29808 | BITS 32
mov eax, [0xcafe]
hlt
|
_maps/obj0A.asm | vladjester2020/Sonic1TMR | 0 | 179201 | ; ---------------------------------------------------------------------------
; Sprite mappings - drowning countdown numbers (LZ)
; ---------------------------------------------------------------------------
dc.w byte_14152-Map_obj0A
byte_14152: dc.b 1
dc.b $E8, $E, 0, 0, $F2
even |
archive/agda-3/src/Oscar/Data/Constraint.agda | m0davis/oscar | 0 | 7102 |
open import Oscar.Prelude
module Oscar.Data.Constraint where
data Constraint {𝔞} {𝔄 : Ø 𝔞} (𝒶 : 𝔄) : Ø₀ where
instance ∅ : Constraint 𝒶
|
oeis/201/A201783.asm | neoneye/loda-programs | 11 | 246021 | <gh_stars>10-100
; A201783: Primes of the form 5n^2 - 1.
; Submitted by <NAME>
; 19,79,179,499,719,1279,1619,1999,2879,3919,5119,5779,7219,8819,9679,11519,15679,19219,20479,24499,25919,28879,33619,35279,36979,40499,44179,49999,56179,71999,74419,79379,81919,84499,87119,89779,92479,95219,109519,124819,147919,151379,158419,161999,188179,199999,204019,216319,233279,237619,278479,292819,302579,337999,343219,364499,380879,391999,408979,420499,426319,462079,474319,480499,492979,505619,537919,557779,655219,677119,691919,699379,737279,760499,768319,776179,799999,808019,824179,873619
mov $2,332202
lpb $2
mov $3,$6
seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0.
sub $0,$3
add $5,$1
add $1,3
mov $4,$0
max $4,0
cmp $4,$0
mul $2,$4
sub $2,18
add $5,$1
add $1,2
mov $6,$5
add $5,2
lpe
mov $0,$5
sub $0,1
|
workshop.asm | FolkertVanVerseveld/c64 | 1 | 13120 | <reponame>FolkertVanVerseveld/c64<gh_stars>1-10
// Assembler: KickAssembler v4.19
BasicUpstart2(main)
.var brkFile = createFile("breakpoints.txt")
.macro break() {
.eval brkFile.writeln("break " + toHexString(*))
}
.var irq_line_top = 40
.var irq_line_middle = 200
.var irq_line_bottom = 250
.var roll_timer = 6
.var music = LoadSid("/home/methos/Music/HVSC69/MUSICIANS/0-9/20CC/van_Santen_Edwin/Greystorm_unused_hi-score.sid")
main:
lda #0
jsr music.init
// first loop
ldy #0
lda #$e0
!l:
!fetch:
lda logo
!put:
sta $0400 + 7 * 40
inc !fetch- + 1
bne !noinc+
inc !fetch- + 2
!noinc:
inc !put- + 1
bne !noinc+
inc !put- + 2
!noinc:
iny
bne !l-
// second loop
!l:
!fetch:
lda logo + $100
!put:
sta $0500 + 7 * 40
inc !fetch- + 1
bne !noinc+
inc !fetch- + 2
!noinc:
inc !put- + 1
bne !noinc+
inc !put- + 2
!noinc:
iny
cpy #184
bne !l-
ldx #0
!l:
lda txt_bottom, x
sta $0400 + 19 * 40, x
inx
cpx #4 * 40
bne !l-
// setup colram at bottom to white
lda #1
ldx #0
!l:
sta $d800 + 19 * 40, x
inx
bne !l-
// INLINE setup irq
sei
lda #$35 // Disable KERNAL and BASIC ROM
sta $01 // Enable all RAM
lda #<irq_top // Setup IRQ vector
sta $fffe
lda #>irq_top
sta $ffff
lda #<dummy
sta $fffa
sta $fffc
lda #>dummy
sta $fffb
sta $fffd
lda #%00011011 // Load screen control:
// Vertical scroll : 3
// Screen height : 25 rows
// Screen : ON
// Mode : TEXT
// Extended background: OFF
sta $d011 // Set screen control
lda #irq_line_top
sta $d012
lda #$01 // Enable mask
sta $d01a // IRQ interrupt ON
lda #%01111111 // Load interrupt control CIA 1:
// Timer A underflow : OFF
// Timer B underflow : OFF
// TOD : OFF
// Serial shift reg. : OFF
// Pos. edge FLAG pin: OFF
sta $dc0d // Set interrupt control CIA 1
sta $dd0d // Set interrupt control CIA 2
lda $dc0d // Clear pending interrupts CIA 1
lda $dd0d // Clear pending interrupts CIA 2
lda #$00
sta $dc0e
lda #$01
sta $d019 // Acknowledge pending interrupts
cli // Start firing interrupts
jmp *
irq_top:
pha
txa
pha
tya
pha
ldx #8
!l:
dex
bne !l-
// modify colors
!timer:
ldx #roll_timer
beq !roll+
jmp !ignore+
!roll:
ldx #roll_timer
stx !timer- + 1
!i0:
lda #14
sta $d800 + 7 * 40 + 5 * 40 + 19
sta $d800 + 7 * 40 + 5 * 40 + 20
inc !i0- + 1
!i1:
lda #13
sta $d800 + 7 * 40 + 4 * 40 + 19
sta $d800 + 7 * 40 + 4 * 40 + 20
sta $d800 + 7 * 40 + 6 * 40 + 19
sta $d800 + 7 * 40 + 6 * 40 + 20
inc !i1- + 1
!i2:
lda #12
sta $d800 + 7 * 40 + 3 * 40 + 19
sta $d800 + 7 * 40 + 3 * 40 + 20
sta $d800 + 7 * 40 + 7 * 40 + 19
sta $d800 + 7 * 40 + 7 * 40 + 20
inc !i2- + 1
!i3:
lda #11
sta $d800 + 7 * 40 + 2 * 40 + 19
sta $d800 + 7 * 40 + 2 * 40 + 20
sta $d800 + 7 * 40 + 8 * 40 + 19
sta $d800 + 7 * 40 + 8 * 40 + 20
inc !i3- + 1
!i4:
lda #10
sta $d800 + 7 * 40 + 1 * 40 + 16
sta $d800 + 7 * 40 + 1 * 40 + 17
sta $d800 + 7 * 40 + 1 * 40 + 18
sta $d800 + 7 * 40 + 1 * 40 + 19
sta $d800 + 7 * 40 + 1 * 40 + 20
sta $d800 + 7 * 40 + 1 * 40 + 21
sta $d800 + 7 * 40 + 1 * 40 + 22
sta $d800 + 7 * 40 + 1 * 40 + 23
sta $d800 + 7 * 40 + 9 * 40 + 16
sta $d800 + 7 * 40 + 9 * 40 + 17
sta $d800 + 7 * 40 + 9 * 40 + 18
sta $d800 + 7 * 40 + 9 * 40 + 19
sta $d800 + 7 * 40 + 9 * 40 + 20
sta $d800 + 7 * 40 + 9 * 40 + 21
sta $d800 + 7 * 40 + 9 * 40 + 22
sta $d800 + 7 * 40 + 9 * 40 + 23
inc !i4- + 1
!i5:
lda #9
sta $d800 + 7 * 40 + 0 * 40 + 16
sta $d800 + 7 * 40 + 0 * 40 + 17
sta $d800 + 7 * 40 + 0 * 40 + 18
sta $d800 + 7 * 40 + 0 * 40 + 19
sta $d800 + 7 * 40 + 0 * 40 + 20
sta $d800 + 7 * 40 + 0 * 40 + 21
sta $d800 + 7 * 40 + 0 * 40 + 22
sta $d800 + 7 * 40 + 0 * 40 + 23
sta $d800 + 7 * 40 + 10 * 40 + 16
sta $d800 + 7 * 40 + 10 * 40 + 17
sta $d800 + 7 * 40 + 10 * 40 + 18
sta $d800 + 7 * 40 + 10 * 40 + 19
sta $d800 + 7 * 40 + 10 * 40 + 20
sta $d800 + 7 * 40 + 10 * 40 + 21
sta $d800 + 7 * 40 + 10 * 40 + 22
sta $d800 + 7 * 40 + 10 * 40 + 23
inc !i5- + 1
!v0:
lda #0
sta $d800 + 7 * 40 + 0 * 40 + 4
sta $d800 + 7 * 40 + 0 * 40 + 5
sta $d800 + 7 * 40 + 0 * 40 + 12
sta $d800 + 7 * 40 + 0 * 40 + 13
inc !v0- + 1
!v1:
lda #1
sta $d800 + 7 * 40 + 1 * 40 + 4
sta $d800 + 7 * 40 + 1 * 40 + 5
sta $d800 + 7 * 40 + 1 * 40 + 12
sta $d800 + 7 * 40 + 1 * 40 + 13
inc !v1- + 1
!v2:
lda #2
sta $d800 + 7 * 40 + 2 * 40 + 4
sta $d800 + 7 * 40 + 2 * 40 + 5
sta $d800 + 7 * 40 + 2 * 40 + 6
sta $d800 + 7 * 40 + 2 * 40 + 11
sta $d800 + 7 * 40 + 2 * 40 + 12
sta $d800 + 7 * 40 + 2 * 40 + 13
inc !v2- + 1
!v3:
lda #3
sta $d800 + 7 * 40 + 3 * 40 + 5
sta $d800 + 7 * 40 + 3 * 40 + 6
sta $d800 + 7 * 40 + 3 * 40 + 11
sta $d800 + 7 * 40 + 3 * 40 + 12
inc !v3- + 1
!v4:
lda #4
sta $d800 + 7 * 40 + 4 * 40 + 5
sta $d800 + 7 * 40 + 4 * 40 + 6
sta $d800 + 7 * 40 + 4 * 40 + 11
sta $d800 + 7 * 40 + 4 * 40 + 12
inc !v4- + 1
!v5:
lda #5
sta $d800 + 7 * 40 + 5 * 40 + 5
sta $d800 + 7 * 40 + 5 * 40 + 6
sta $d800 + 7 * 40 + 5 * 40 + 7
sta $d800 + 7 * 40 + 5 * 40 + 10
sta $d800 + 7 * 40 + 5 * 40 + 11
sta $d800 + 7 * 40 + 5 * 40 + 12
inc !v5- + 1
!v6:
lda #6
sta $d800 + 7 * 40 + 6 * 40 + 6
sta $d800 + 7 * 40 + 6 * 40 + 7
sta $d800 + 7 * 40 + 6 * 40 + 10
sta $d800 + 7 * 40 + 6 * 40 + 11
inc !v6- + 1
!v7:
lda #7
sta $d800 + 7 * 40 + 7 * 40 + 6
sta $d800 + 7 * 40 + 7 * 40 + 7
sta $d800 + 7 * 40 + 7 * 40 + 8
sta $d800 + 7 * 40 + 7 * 40 + 9
sta $d800 + 7 * 40 + 7 * 40 + 10
sta $d800 + 7 * 40 + 7 * 40 + 11
inc !v7- + 1
!v8:
lda #8
sta $d800 + 7 * 40 + 8 * 40 + 6
sta $d800 + 7 * 40 + 8 * 40 + 7
sta $d800 + 7 * 40 + 8 * 40 + 8
sta $d800 + 7 * 40 + 8 * 40 + 9
sta $d800 + 7 * 40 + 8 * 40 + 10
sta $d800 + 7 * 40 + 8 * 40 + 11
inc !v8- + 1
!v9:
lda #9
sta $d800 + 7 * 40 + 9 * 40 + 7
sta $d800 + 7 * 40 + 9 * 40 + 8
sta $d800 + 7 * 40 + 9 * 40 + 9
sta $d800 + 7 * 40 + 9 * 40 + 10
inc !v9- + 1
!v10:
lda #10
sta $d800 + 7 * 40 + 10 * 40 + 7
sta $d800 + 7 * 40 + 10 * 40 + 8
sta $d800 + 7 * 40 + 10 * 40 + 9
sta $d800 + 7 * 40 + 10 * 40 + 10
inc !v10- + 1
!a0:
lda #15
sta $d800 + 7 * 40 + 0 * 40 + 28
sta $d800 + 7 * 40 + 0 * 40 + 29
sta $d800 + 7 * 40 + 0 * 40 + 30
sta $d800 + 7 * 40 + 0 * 40 + 31
sta $d800 + 7 * 40 + 0 * 40 + 32
sta $d800 + 7 * 40 + 0 * 40 + 33
inc !a0- + 1
!a1:
lda #14
sta $d800 + 7 * 40 + 1 * 40 + 27
sta $d800 + 7 * 40 + 1 * 40 + 28
sta $d800 + 7 * 40 + 1 * 40 + 29
sta $d800 + 7 * 40 + 1 * 40 + 30
sta $d800 + 7 * 40 + 1 * 40 + 31
sta $d800 + 7 * 40 + 1 * 40 + 32
sta $d800 + 7 * 40 + 1 * 40 + 33
sta $d800 + 7 * 40 + 1 * 40 + 34
inc !a1- + 1
!a2:
lda #13
sta $d800 + 7 * 40 + 2 * 40 + 27
sta $d800 + 7 * 40 + 2 * 40 + 28
sta $d800 + 7 * 40 + 2 * 40 + 29
sta $d800 + 7 * 40 + 2 * 40 + 32
sta $d800 + 7 * 40 + 2 * 40 + 33
sta $d800 + 7 * 40 + 2 * 40 + 34
inc !a2- + 1
!a3:
lda #12
sta $d800 + 7 * 40 + 3 * 40 + 27
sta $d800 + 7 * 40 + 3 * 40 + 28
sta $d800 + 7 * 40 + 3 * 40 + 33
sta $d800 + 7 * 40 + 3 * 40 + 34
inc !a3- + 1
!a4:
lda #11
sta $d800 + 7 * 40 + 4 * 40 + 27
sta $d800 + 7 * 40 + 4 * 40 + 28
sta $d800 + 7 * 40 + 4 * 40 + 33
sta $d800 + 7 * 40 + 4 * 40 + 34
inc !a4- + 1
!a5:
lda #10
sta $d800 + 7 * 40 + 5 * 40 + 27
sta $d800 + 7 * 40 + 5 * 40 + 28
sta $d800 + 7 * 40 + 5 * 40 + 29
sta $d800 + 7 * 40 + 5 * 40 + 30
sta $d800 + 7 * 40 + 5 * 40 + 31
sta $d800 + 7 * 40 + 5 * 40 + 32
sta $d800 + 7 * 40 + 5 * 40 + 33
sta $d800 + 7 * 40 + 5 * 40 + 34
inc !a5- + 1
!a5:
lda #9
sta $d800 + 7 * 40 + 6 * 40 + 27
sta $d800 + 7 * 40 + 6 * 40 + 28
sta $d800 + 7 * 40 + 6 * 40 + 29
sta $d800 + 7 * 40 + 6 * 40 + 30
sta $d800 + 7 * 40 + 6 * 40 + 31
sta $d800 + 7 * 40 + 6 * 40 + 32
sta $d800 + 7 * 40 + 6 * 40 + 33
sta $d800 + 7 * 40 + 6 * 40 + 34
inc !a5- + 1
!a6:
lda #8
sta $d800 + 7 * 40 + 7 * 40 + 27
sta $d800 + 7 * 40 + 7 * 40 + 28
sta $d800 + 7 * 40 + 7 * 40 + 29
sta $d800 + 7 * 40 + 7 * 40 + 32
sta $d800 + 7 * 40 + 7 * 40 + 33
sta $d800 + 7 * 40 + 7 * 40 + 34
inc !a6- + 1
!a7:
lda #7
sta $d800 + 7 * 40 + 8 * 40 + 27
sta $d800 + 7 * 40 + 8 * 40 + 28
sta $d800 + 7 * 40 + 8 * 40 + 33
sta $d800 + 7 * 40 + 8 * 40 + 34
inc !a7- + 1
!a8:
lda #6
sta $d800 + 7 * 40 + 9 * 40 + 27
sta $d800 + 7 * 40 + 9 * 40 + 28
sta $d800 + 7 * 40 + 9 * 40 + 33
sta $d800 + 7 * 40 + 9 * 40 + 34
inc !a8- + 1
!a9:
lda #5
sta $d800 + 7 * 40 + 10 * 40 + 27
sta $d800 + 7 * 40 + 10 * 40 + 28
sta $d800 + 7 * 40 + 10 * 40 + 33
sta $d800 + 7 * 40 + 10 * 40 + 34
inc !a9- + 1
!ignore:
dec !timer- + 1
lda #irq_line_middle
sta $d012
lda #<irq_middle
sta $fffe
lda #>irq_middle
sta $ffff
// acknowledge irq
asl $d019
pla
tay
pla
tax
pla
dummy:
rti
irq_middle:
pha
txa
pha
tya
pha
ldx #5
dex
bne *-1
lda #0
sta $d020
sta $d021
ldx sinus_pos
lda sinus, x
sta $d011
inx
txa
and #$1f
sta sinus_pos
lda #irq_line_bottom
sta $d012
lda #<irq_bottom
sta $fffe
lda #>irq_bottom
sta $ffff
asl $d019
pla
tay
pla
tax
pla
rti
sinus_pos:
.byte 0
sinus:
.fill $20, round($1b - $4 + $3 * sin(toRadians(i * 360 / $20)))
irq_bottom:
pha
txa
pha
tya
pha
ldx #6
dex
bne *-1
bit $ea
nop
lda #14
sta $d020
lda #6
sta $d021
jsr music.play
lda #$1b
sta $d011
lda #irq_line_top
sta $d012
lda #<irq_top
sta $fffe
lda #>irq_top
sta $ffff
asl $d019
pla
tay
pla
tax
pla
rti
txt_bottom:
.text " de commodore 64 workshop vindt plaats "
.text " op dinsdag 27 november 17:00-19:00 "
.text " "
.text "ga naar: https://svia.nl/activities/644/"
logo:
.byte $20, $20, $20, $20, $e0, $e0, $20, $20, $20, $20, $20, $20, $e0, $e0, $20, $20, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $20, $20, $20, $20, $e9, $e0, $e0, $e0, $e0, $df, $20, $20, $20, $20, $20, $20
.byte $20, $20, $20, $20, $e0, $e0, $20, $20, $20, $20, $20, $20, $e0, $e0, $20, $20, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $20, $20, $20, $e9, $e0, $e0, $e0, $e0, $e0, $e0, $df, $20, $20, $20, $20, $20
.byte $20, $20, $20, $20, $5f, $e0, $df, $20, $20, $20, $20, $e9, $e0, $69, $20, $20, $20, $20, $20, $e0, $e0, $20, $20, $20, $20, $20, $20, $e0, $e0, $69, $20, $20, $5f, $e0, $e0, $20, $20, $20, $20, $20
.byte $20, $20, $20, $20, $20, $e0, $e0, $20, $20, $20, $20, $e0, $e0, $20, $20, $20, $20, $20, $20, $e0, $e0, $20, $20, $20, $20, $20, $20, $e0, $e0, $20, $20, $20, $20, $e0, $e0, $20, $20, $20, $20, $20
.byte $20, $20, $20, $20, $20, $e0, $e0, $20, $20, $20, $20, $e0, $e0, $20, $20, $20, $20, $20, $20, $e0, $e0, $20, $20, $20, $20, $20, $20, $e0, $e0, $20, $20, $20, $20, $e0, $e0, $20, $20, $20, $20, $20
.byte $20, $20, $20, $20, $20, $5f, $e0, $df, $20, $20, $e9, $e0, $69, $20, $20, $20, $20, $20, $20, $e0, $e0, $20, $20, $20, $20, $20, $20, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $20, $20, $20, $20, $20
.byte $20, $20, $20, $20, $20, $20, $e0, $e0, $20, $20, $e0, $e0, $20, $20, $20, $20, $20, $20, $20, $e0, $e0, $20, $20, $20, $20, $20, $20, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $20, $20, $20, $20, $20
.byte $20, $20, $20, $20, $20, $20, $e0, $e0, $e0, $e0, $e0, $e0, $20, $20, $20, $20, $20, $20, $20, $e0, $e0, $20, $20, $20, $20, $20, $20, $e0, $e0, $69, $20, $20, $5f, $e0, $e0, $20, $20, $20, $20, $20
.byte $20, $20, $20, $20, $20, $20, $5f, $e0, $e0, $e0, $e0, $69, $20, $20, $20, $20, $20, $20, $20, $e0, $e0, $20, $20, $20, $20, $20, $20, $e0, $e0, $20, $20, $20, $20, $e0, $e0, $20, $20, $20, $20, $20
.byte $20, $20, $20, $20, $20, $20, $20, $e0, $e0, $e0, $e0, $20, $20, $20, $20, $20, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $20, $20, $20, $e0, $e0, $20, $20, $20, $20, $e0, $e0, $20, $20, $20, $20, $20
.byte $20, $20, $20, $20, $20, $20, $20, $5f, $e0, $e0, $69, $20, $20, $20, $20, $20, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $e0, $20, $20, $20, $e0, $e0, $20, $20, $20, $20, $e0, $e0, $20, $20, $20, $20, $20
* = music.location "music"
.fill music.size, music.getData(i)
.print "music_init = $" + toHexString(music.init)
.print "music_play = $" + toHexString(music.play)
|
linear_algebra/hypot.ads | jscparker/math_packages | 30 | 13984 | <gh_stars>10-100
---------------------------------------------------------------------------
-- package Hypot
-- Copyright (C) 2018 <NAME>.
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
---------------------------------------------------------------------------
-- Package Hypot provides routines for calculating
--
-- Hypot = Sqrt (Max**2 + Min**2)
-- Min_Arg_Over_Hypot = Min / Sqrt (Max**2 + Min**2)
-- Max_Arg_Over_Hypot_Minus_1 = Max / Sqrt (Max**2 + Min**2) - One
--
-- The idea, mostly for fun, was to improve numerical accuracy on
-- Intel SSE hardware. The routines are slightly more accurate than
-- the simplest methods, and quite a bit slower.
-- Typically, they add an additional 1 or 2 calls to "/".
generic
type Real is digits <>;
package Hypot is
-- If Abs b > Abs a then
--
-- Max = Abs b, Min = Abs a
--
-- Hypot = Sqrt (Max**2 + Min**2)
-- Min_Arg_Over_Hypot = Min / Sqrt (Max**2 + Min**2)
-- Max_Arg_Over_Hypot_Minus_1 = Max / Sqrt (Max**2 + Min**2) - One
procedure Get_Hypotenuse
(a, b : in Real;
Hypot : out Real;
Min_Arg_Over_Hypot : out Real;
Max_Arg_Over_Hypot_Minus_1 : out Real);
function Hypotenuse
(a, b : in Real)
return Real;
end Hypot;
|
Array/APL.agda | ashinkarov/agda-array | 6 | 4250 | <reponame>ashinkarov/agda-array
module Array.APL where
open import Array.Base
open import Array.Properties
open import Data.Nat
open import Data.Nat.DivMod hiding (_/_)
open import Data.Nat.Properties
open import Data.Fin using (Fin; zero; suc; raise; toℕ; fromℕ≤)
open import Data.Fin.Properties using (toℕ<n)
open import Data.Vec
open import Data.Vec.Properties
open import Data.Product
open import Agda.Builtin.Float
open import Function
open import Relation.Binary.PropositionalEquality hiding (Extensionality)
open import Relation.Nullary
open import Relation.Nullary.Decidable
open import Relation.Nullary.Negation
--open import Relation.Binary
-- Now we start to introduce APL operators trying
-- to maintain syntactic rules and semantics.
-- We won't be able to mimic explicit concatenations
-- like 2 3 4 is a vector [2, 3, 4], as we would have
-- to overload the " " somehow.
-- This relation describes promotion of the scalar element in
-- dyadic operations.
data dy-args : ∀ n m k → (Vec ℕ n) → (Vec ℕ m) → (Vec ℕ k) → Set where
instance
n-n : ∀ {n}{s} → dy-args n n n s s s
n-0 : ∀ {n}{s}{s₁} → dy-args n 0 n s s₁ s
0-n : ∀ {n}{s}{s₁} → dy-args 0 n n s s₁ s₁
dyadic-type : ∀ a → Set a → Set a
dyadic-type a X = ∀ {n m k}{s s₁ s₂}{{c : dy-args n m k s s₁ s₂}}
→ Ar X n s → Ar X m s₁ → Ar X k s₂
lift-binary-op : ∀ {a}{X : Set a} → ∀ (op : X → X → X) → dyadic-type a X
lift-binary-op op ⦃ c = n-n ⦄ (imap f) (imap g) = imap λ iv → op (f iv) (g iv)
lift-binary-op op {s₁ = []} ⦃ c = n-0 ⦄ (imap f) (imap g) = imap λ iv → op (f iv) (g [])
lift-binary-op op {s = [] } ⦃ c = 0-n ⦄ (imap f) (imap g) = imap λ iv → op (f []) (g iv)
lift-unary-op : ∀ {a}{X : Set a} → ∀ (op : X → X)
→ ∀ {n s} → Ar X n s → Ar X n s
lift-unary-op f (imap g) = imap (λ iv → f (g iv))
dyadic-type-c : ∀ a → Set a → Set a
dyadic-type-c a X = ∀ {n m k}{s s₁ s₂}
→ Ar X n s → dy-args n m k s s₁ s₂ → Ar X m s₁ → Ar X k s₂
-- Nat operations
infixr 20 _+ₙ_
infixr 20 _×ₙ_
_+ₙ_ = lift-binary-op _+_
_×ₙ_ = lift-binary-op _*_
_-safe-_ : (a : ℕ) → (b : ℕ) .{≥ : a ≥ b} → ℕ
a -safe- b = a ∸ b
-- FIXME As _-ₙ_ requires a proof, we won't consider yet
-- full dyadic types for _-ₙ_, as it would require us
-- to define dyadic types for ≥a.
infixr 20 _-ₙ_
_-ₙ_ : ∀ {n}{s}
→ (a : Ar ℕ n s) → (b : Ar ℕ n s)
→ .{≥ : a ≥a b}
→ Ar ℕ n s
(imap f -ₙ imap g) {≥} = imap λ iv → (f iv -safe- g iv) {≥ = ≥ iv}
--≢-sym : ∀ {X : Set}{a b : X} → a ≢ b → b ≢ a
--≢-sym pf = pf ∘ sym
infixr 20 _÷ₙ_
_÷ₙ_ : ∀ {n}{s}
→ (a : Ar ℕ n s) → (b : Ar ℕ n s)
→ {≥0 : cst 0 <a b}
→ Ar ℕ n s
_÷ₙ_ (imap f) (imap g) {≥0} = imap λ iv → (f iv div g iv) {≢0 = fromWitnessFalse (≢-sym $ <⇒≢ $ ≥0 iv) }
infixr 20 _+⟨_⟩ₙ_
infixr 20 _×⟨_⟩ₙ_
_+⟨_⟩ₙ_ : dyadic-type-c _ _
a +⟨ c ⟩ₙ b = _+ₙ_ {{c = c}} a b
_×⟨_⟩ₙ_ : dyadic-type-c _ _
a ×⟨ c ⟩ₙ b = _×ₙ_ {{c = c}} a b
-- Float operations
infixr 20 _+ᵣ_
_+ᵣ_ = lift-binary-op primFloatPlus
infixr 20 _-ᵣ_
_-ᵣ_ = lift-binary-op primFloatMinus
infixr 20 _×ᵣ_
_×ᵣ_ = lift-binary-op primFloatTimes
-- XXX we can request the proof that the right argument is not zero.
-- However, the current primFloatDiv has the type Float → Float → Float, so...
infixr 20 _÷ᵣ_
_÷ᵣ_ = lift-binary-op primFloatDiv
infixr 20 _×⟨_⟩ᵣ_
_×⟨_⟩ᵣ_ : dyadic-type-c _ _
a ×⟨ c ⟩ᵣ b = _×ᵣ_ {{c = c}} a b
infixr 20 _+⟨_⟩ᵣ_
_+⟨_⟩ᵣ_ : dyadic-type-c _ _
a +⟨ c ⟩ᵣ b = _+ᵣ_ {{c = c}} a b
infixr 20 _-⟨_⟩ᵣ_
_-⟨_⟩ᵣ_ : dyadic-type-c _ _
a -⟨ c ⟩ᵣ b = _-ᵣ_ {{c = c}} a b
infixr 20 _÷⟨_⟩ᵣ_
_÷⟨_⟩ᵣ_ : dyadic-type-c _ _
a ÷⟨ c ⟩ᵣ b = _÷ᵣ_ {{c = c}} a b
infixr 20 *ᵣ_
*ᵣ_ = lift-unary-op primFloatExp
module xx where
a : Ar ℕ 2 (3 ∷ 3 ∷ [])
a = cst 1
s : Ar ℕ 0 []
s = cst 2
test₁ = a +ₙ a
test₂ = a +ₙ s
test₃ = s +ₙ a
--test = (s +ₙ s)
test₄ = s +⟨ n-n ⟩ₙ s
test₅ : ∀ {n s} → Ar ℕ n s → Ar ℕ 0 [] → Ar ℕ n s
test₅ = _+ₙ_
infixr 20 ρ_
ρ_ : ∀ {ℓ}{X : Set ℓ}{d s} → Ar X d s → Ar ℕ 1 (d ∷ [])
ρ_ {s = s} _ = s→a s
infixr 20 ,_
,_ : ∀ {a}{X : Set a}{n s} → Ar X n s → Ar X 1 (prod s ∷ [])
,_ {s = s} (p) = imap λ iv → unimap p (off→idx s iv)
-- Reshape
infixr 20 _ρ_
_ρ_ : ∀ {a}{X : Set a}{n}{sa}
→ (s : Ar ℕ 1 (n ∷ []))
→ (a : Ar X n sa)
-- if the `sh` is non-empty, `s` must be non-empty as well.
→ {s≢0⇒ρa≢0 : prod (a→s s) ≢ 0 → prod sa ≢ 0}
→ Ar X n (a→s s)
_ρ_ {sa = sa} s a {s≢0⇒ρa≢0} with prod sa ≟ 0 | prod (a→s s) ≟ 0
_ρ_ {sa = sa} s a {s≢0⇒ρa≢0} | _ | yes s≡0 = mkempty (a→s s) s≡0
_ρ_ {sa = sa} s a {s≢0⇒ρa≢0} | yes ρa≡0 | no s≢0 = contradiction ρa≡0 (s≢0⇒ρa≢0 s≢0)
_ρ_ {sa = sa} s a {s≢0⇒ρa≢0} | no ρa≢0 | _ = imap from-flat
where
from-flat : _
from-flat iv = let
off = idx→off (a→s s) iv --{!!} -- (ix-lookup iv zero)
flat = unimap $ , a
ix = (toℕ (ix-lookup off zero) mod prod sa)
{≢0 = fromWitnessFalse ρa≢0}
in
flat (ix ∷ [])
reduce-1d : ∀ {a}{X : Set a}{n} → Ar X 1 (n ∷ []) → (X → X → X) → X → X
reduce-1d {n = zero} (imap p) op neut = neut
reduce-1d {n = suc n} (imap p) op neut = op (p $ zero ∷ [])
(reduce-1d (imap (λ iv → p (suc (ix-lookup iv zero) ∷ []))) op neut)
{-
This goes right to left if we want to
reduce-1d (imap λ iv → p ((raise 1 $ ix-lookup iv zero) ∷ []))
op (op neut (p $ zero ∷ []))
-}
Scal : ∀ {a} → Set a → Set a
Scal X = Ar X 0 []
scal : ∀ {a}{X : Set a} → X → Scal X
scal = cst
unscal : ∀ {a}{X : Set a} → Scal X → X
unscal (imap f) = f []
module true-reduction where
thm : ∀ {a}{X : Set a}{n m} → (s : Vec X (n + m)) → s ≡ take n s ++ drop n s
thm {n = n} s with splitAt n s
thm {n = n} .(xs ++ ys) | xs , ys , refl = refl
thm2 : ∀ {a}{X : Set a} → (v : Vec X 1) → v ≡ head v ∷ []
thm2 (x ∷ []) = refl
-- This is a variant with take
_/⟨_⟩_ : ∀ {a}{X : Set a}{n}{s : Vec ℕ (n + 1)}
→ (X → X → X) → X
→ Ar X (n + 1) s
→ Ar X n (take n s)
_/⟨_⟩_ {n = n} {s} f neut a = let
x = nest {s = take n s} {s₁ = drop n s} $ subst (λ x → Ar _ _ x) (thm {n = n} s) a
in imap λ iv → reduce-1d (subst (λ x → Ar _ _ x) (thm2 (drop n s)) $ unimap x iv) f neut
_/₁⟨_⟩_ : ∀ {a}{X : Set a}{n}{s : Vec ℕ n}{m}
→ (X → X → X) → X
→ Ar X (n + 1) (s ++ (m ∷ []))
→ Ar X n s
_/₁⟨_⟩_ {n = n} {s} f neut a = let
x = nest {s = s} a
in imap λ iv → reduce-1d (unimap x iv) f neut
module test-reduce where
a : Ar ℕ 2 (4 ∷ 4 ∷ [])
a = cst 1
b : Ar ℕ 1 (5 ∷ [])
b = cst 2
test₁ = _/⟨_⟩_ {n = 0} _+_ 0 (, a)
test₂ = _/⟨_⟩_ {n = 0} _+_ 0 b
-- FIXME! This reduction does not implement semantics of APL,
-- as it assumes that we always reduce to scalars!
-- Instead, in APL / reduce on the last axis only,
-- i.e. ⍴ +/3 4 5 ⍴ ⍳1 = 3 4
-- This is mimicing APL's f/ syntax, but with extra neutral
-- element. We can later introduce the variant where certain
-- operations come with pre-defined neutral elements.
_/⟨_⟩_ : ∀ {a}{X : Set a}{n s}
→ (Scal X → Scal X → Scal X) → Scal X → Ar X n s → Scal X
f /⟨ neut ⟩ a = let
op x y = unscal $ f (scal x) (scal y)
a-1d = , a
neut = unscal neut
in
scal $ reduce-1d a-1d op neut
-- XXX I somehow don't understand how to make X to be an arbitrary Set a...
data reduce-neut : {X : Set} → (Scal X → Scal X → Scal X) → Scal X → Set where
instance
plus-nat : reduce-neut _+⟨ n-n ⟩ₙ_ (cst 0)
mult-nat : reduce-neut _×⟨ n-n ⟩ₙ_ (cst 1)
plus-flo : reduce-neut (_+ᵣ_ {{c = n-n}}) (cst 0.0)
mult-flo : reduce-neut (_×ᵣ_ {{c = n-n}}) (cst 1.0)
infixr 20 _/_
_/_ : ∀ {X : Set}{n s neut}
→ (op : Scal X → Scal X → Scal X) → {{c : reduce-neut op neut}}
→ Ar X n s → Scal X
_/_ {neut = neut} f a = f /⟨ neut ⟩ a
module test-reduce where
a = s→a $ 1 ∷ 2 ∷ 3 ∷ 4 ∷ []
test₁ : reduce-1d a _+_ 0 ≡ 10
test₁ = refl
test₂ : _+⟨ n-n ⟩ₙ_ /⟨ scal 0 ⟩ a ≡ scal 10
test₂ = refl
test₃ : _+ₙ_ / a ≡ scal 10
test₃ = refl
-- This is somewhat semi-useful dot-product expressed
-- pretty close to what you'd write in APL.
dotp : ∀ {n s} → Ar ℕ n s → Ar ℕ n s → Scal ℕ
dotp a b = _+ₙ_ / a ×ₙ b
test₄ : dotp a a ≡ scal (1 + 4 + 9 + 16)
test₄ = refl
-- The size of the leading axis.
infixr 20 ≢_
≢_ : ∀ {a}{X : Set a}{n s} → Ar X n s → Scal ℕ
≢_ {n = zero} a = scal 1
≢_ {n = suc n} {s} a = scal $ head s
data iota-type : (d : ℕ) → (n : ℕ) → (Vec ℕ d) → Set where
instance
iota-scal : iota-type 0 1 []
iota-vec : ∀ {n} → iota-type 1 n (n ∷ [])
iota-res-t : ∀ {d n s} → iota-type d n s → (sh : Ar ℕ d s) → Set
iota-res-t {n = n} iota-scal sh = Ar (Σ ℕ λ x → x < unscal sh)
1 (unscal sh ∷ [])
iota-res-t {n = n} iota-vec sh = Ar (Σ (Ar ℕ 1 (n ∷ []))
λ v → v <a sh)
n (a→s sh)
a<b⇒b≡c⇒a<c : ∀ {a b c} → a < b → b ≡ c → a < c
a<b⇒b≡c⇒a<c a<b refl = a<b
infixr 20 ι_
ι_ : ∀ {d n s}{{c : iota-type d n s}}
→ (sh : Ar ℕ d s)
→ iota-res-t c sh
ι_ ⦃ c = iota-scal ⦄ s = (imap λ iv → (toℕ $ ix-lookup iv zero) , toℕ<n (ix-lookup iv zero))
ι_ {n = n} {s = s ∷ []} ⦃ c = iota-vec ⦄ (imap sh) = imap cast-ix→a
where
cast-ix→a : _
cast-ix→a iv = let
ix , pf = ix→a iv
in ix , λ jv → a<b⇒b≡c⇒a<c (pf jv) (s→a∘a→s (imap sh) jv)
-- Zilde and comma
⍬ : ∀ {a}{X : Set a} → Ar X 1 (0 ∷ [])
⍬ = imap λ iv → magic-fin $ ix-lookup iv zero
-- XXX We are going to use _·_ instead of _,_ as the
-- latter is a constructor of dependent sum. Renaming
-- all the occurrences to something else would take
-- a bit of work which we should do later.
infixr 30 _·_
_·_ : ∀ {a}{X : Set a}{n} → X → Ar X 1 (n ∷ []) → Ar X 1 (suc n ∷ [])
x · (imap p) = imap λ iv → case ix-lookup iv zero of λ where
zero → x
(suc j) → p (j ∷ [])
-- Note that two dots in an upper register combined with
-- the underscore form the _̈ symbol. When the symbol is
-- used on its own, it looks like ̈ which is the correct
-- "spelling".
infixr 20 _̈_
_̈_ : ∀ {a}{X Y : Set a}{n s}
→ (X → Y)
→ Ar X n s
→ Ar Y n s
f ̈ imap p = imap λ iv → f $ p iv
-- Take and Drop
ax+sh<s : ∀ {n}
→ (ax sh s : Ar ℕ 1 (n ∷ []))
→ (s≥sh : s ≥a sh)
→ (ax <a (s -ₙ sh) {≥ = s≥sh})
→ (ax +ₙ sh) <a s
ax+sh<s (imap ax) (imap sh) (imap s) s≥sh ax<s-sh iv =
let
ax+sh<s-sh+sh = +-monoˡ-< (sh iv) (ax<s-sh iv)
s-sh+sh≡s = m∸n+n≡m (s≥sh iv)
in a<b⇒b≡c⇒a<c ax+sh<s-sh+sh s-sh+sh≡s
_↑_ : ∀ {a}{X : Set a}{n s}
→ (sh : Ar ℕ 1 (n ∷ []))
→ (a : Ar X n s)
→ {pf : s→a s ≥a sh}
→ Ar X n $ a→s sh
_↑_ {s = s} sh (imap f) {pf} with (prod $ a→s sh) ≟ 0
_↑_ {s = s} sh (imap f) {pf} | yes Πsh≡0 = mkempty _ Πsh≡0
_↑_ {s = s} (imap q) (imap f) {pf} | no Πsh≢0 = imap mtake
where
mtake : _
mtake iv = let
ai , ai< = ix→a iv
ix<q jv = a<b⇒b≡c⇒a<c (ai< jv) (s→a∘a→s (imap q) jv)
ix = a→ix ai (s→a s) λ jv → ≤-trans (ix<q jv) (pf jv)
in f (subst-ix (a→s∘s→a s) ix)
_↓_ : ∀ {a}{X : Set a}{n s}
→ (sh : Ar ℕ 1 (n ∷ []))
→ (a : Ar X n s)
→ {pf : (s→a s) ≥a sh}
→ Ar X n $ a→s $ (s→a s -ₙ sh) {≥ = pf}
_↓_ {s = s} sh (imap x) {pf} with
let p = prod $ a→s $ (s→a s -ₙ sh) {≥ = pf}
in p ≟ 0
_↓_ {s = s} sh (imap f) {pf} | yes Π≡0 = mkempty _ Π≡0
_↓_ {s = s} (imap q) (imap f) {pf} | no Π≢0 = imap mkdrop
where
mkdrop : _
mkdrop iv = let
ai , ai< = ix→a iv
ax = ai +ₙ (imap q)
thmx = ax+sh<s
ai (imap q) (s→a s) pf
λ jv → a<b⇒b≡c⇒a<c (ai< jv)
(s→a∘a→s ((s→a s -ₙ (imap q)) {≥ = pf}) jv)
ix = a→ix ax (s→a s) thmx
in f (subst-ix (a→s∘s→a s) ix)
_̈⟨_⟩_ : ∀ {a}{X Y Z : Set a}{n s}
→ Ar X n s
→ (X → Y → Z)
→ Ar Y n s → Ar Z n s
--(imap p) ̈⟨ f ⟩ (imap p₁) = imap λ iv → f (p iv) (p₁ iv)
p ̈⟨ f ⟩ p₁ = imap λ iv → f (unimap p iv) (unimap p₁ iv)
|
ditto.asm | kvnallsn/ditto-asm | 0 | 83231 | <reponame>kvnallsn/ditto-asm
## ditto.asm
##
## See homework for instructions
###########################
## Text Section ##
###########################
.text
.globl main
main: # Entry point
la $a0, buf
li $a1, 640
li $a2, 60
jal hexdump
exit:
li $v0, 10 # Exit Syscall
syscall
###
## Print Hex Function
###
printhex:
# prologue
sub $sp, $sp, 12
sw $a0, 0($sp)
sw $ra, 4($sp)
sw $fp, 8($sp)
move $fp, $sp
li $v0, 11
sub $t2, $a0, 10
bgez $t2, printhex_char
add $a0, $a0, 48 # Add 48 to get printable int
b printhex_done
printhex_char:
add $a0, $a0, 55
printhex_done:
syscall
# epilogue
move $sp, $fp
lw $a0, 0($sp)
lw $ra, 4($sp)
lw $fp, 8($sp)
jr $ra
###
## Hex dump function
###
hexdump:
# prologue
sub $sp, $sp, 20
sw $a0, 0($sp)
sw $a1, 4($sp)
sw $a2, 8($sp)
sw $ra, 12($sp)
sw $fp, 16($sp)
move $fp, $sp
# Load args from memory
lw $t0, 0($fp)
lw $t8, 4($fp)
lw $t9, 8($fp)
li $t1, 0
loop_text:
li $v0, 11
lb $a0, ($t0)
sub $t2, $a0, 32
bgez $t2, loop_char
li $a0, 46 # ASCII for . (Period)
loop_char:
syscall
add $t1, $t1, 1
add $t0, $t0, 1
bne $t1, $t9, loop_text
# Print newline (\n, 0x0A)
li $v0, 4
la $a0, endl
syscall
lw $t0, 0($fp)
li $t1, 0
loop_lower:
lb $a0, ($t0)
srl $a0, $a0, 4
and $a0, $a0, 0xF
jal printhex
add $t1, $t1, 1
add $t0, $t0, 1
bne $t1, $t9, loop_lower
# Print newline (\n, 0x0A)
li $v0, 4
la $a0, endl
syscall
lw $t0, 0($fp)
li $t1, 0
loop_upper:
lb $a0, ($t0)
and $a0, $a0, 0xF
jal printhex
add $t1, $t1, 1
add $t0, $t0, 1
bne $t1, $t9, loop_upper
# Print newline (\n, 0x0A)
li $v0, 4
la $a0, endl
syscall
li $t1, 0
li $t2, 0
li $t3, 0
li $t4, 4
loop_guide:
bne $t2, $t4, guide_period
# If multiple of 5
li $t2, 0 # Set t2 back to 1 for next count
add $t1, $t1, 1 # Add an additional 1 for taking 2 spaces
li $v0, 1 # Load 1 into v0 to print int
add $t3, $t3, 5 # Add 5 to t3 to get current interval
move $a0, $t3 # Move that val into a0
j guide_print
guide_period:
li $v0, 11 # Load 11 into v0 to print char
li $a0, 46 # ASCII for . (Period)
guide_print:
syscall # Perform print
add $t1, $t1, 1 # Add 1 to t1
add $t2, $t2, 1 # Add 1 to t2
sub $t5, $t1, $t9 # Subtract linesz from current pos
bltz $t5, loop_guide # If result is < 0, keep going
# Print newline (\n, 0x0A)
li $v0, 4
la $a0, endl
syscall
# epilogue
move $sp, $fp
lw $a0, 0($sp)
lw $a1, 4($sp)
lw $a2, 8($sp)
lw $ra, 12($sp)
lw $fp, 16($sp)
add $sp, $sp, 16
jr $ra
###########################
## Data Section ##
###########################
.data
ans: .asciiz "answer = "
endl: .asciiz "\n"
buf: .byte 0x3c,0x21,0x44,0x4f,0x43,0x54,0x59,0x50
.byte 0x45,0x20,0x48,0x54,0x4d,0x4c,0x20,0x50
.byte 0x55,0x42,0x4c,0x49,0x43,0x20,0x22,0x2d
.byte 0x2f,0x2f,0x57,0x33,0x43,0x2f,0x2f,0x44
.byte 0x54,0x44,0x20,0x48,0x54,0x4d,0x4c,0x20
.byte 0x34,0x2e,0x30,0x31,0x20,0x54,0x72,0x61
.byte 0x6e,0x73,0x69,0x74,0x69,0x6f,0x6e,0x61
.byte 0x6c,0x2f,0x2f,0x45,0x4e,0x22,0x3e,0x0a
.byte 0x3c,0x68,0x74,0x6d,0x6c,0x3e,0x0a,0x20
.byte 0x20,0x3c,0x68,0x65,0x61,0x64,0x3e,0x0a
.byte 0x20,0x20,0x20,0x20,0x3c,0x6d,0x65,0x74
.byte 0x61,0x20,0x68,0x74,0x74,0x70,0x2d,0x65
.byte 0x71,0x75,0x69,0x76,0x3d,0x22,0x43,0x6f
.byte 0x6e,0x74,0x65,0x6e,0x74,0x2d,0x54,0x79
.byte 0x70,0x65,0x22,0x20,0x63,0x6f,0x6e,0x74
.byte 0x65,0x6e,0x74,0x3d,0x22,0x74,0x65,0x78
.byte 0x74,0x2f,0x68,0x74,0x6d,0x6c,0x3b,0x20
.byte 0x63,0x68,0x61,0x72,0x73,0x65,0x74,0x3d
.byte 0x69,0x73,0x6f,0x2d,0x38,0x38,0x35,0x39
.byte 0x2d,0x31,0x22,0x3e,0x20,0x0a,0x20,0x20
.byte 0x20,0x20,0x3c,0x74,0x69,0x74,0x6c,0x65
.byte 0x3e,0x0a,0x20,0x20,0x20,0x20,0x20,0x20
.byte 0x43,0x50,0x53,0x43,0x49,0x20,0x32,0x34
.byte 0x30,0x20,0x2d,0x20,0x43,0x6f,0x6d,0x70
.byte 0x75,0x74,0x65,0x72,0x20,0x4f,0x72,0x67
.byte 0x61,0x6e,0x69,0x7a,0x61,0x74,0x69,0x6f
.byte 0x6e,0x20,0x61,0x6e,0x64,0x20,0x41,0x73
.byte 0x73,0x65,0x6d,0x62,0x6c,0x79,0x20,0x4c
.byte 0x61,0x6e,0x67,0x75,0x61,0x67,0x65,0x20
.byte 0x2d,0x20,0x48,0x6f,0x6d,0x65,0x77,0x6f
.byte 0x72,0x6b,0x20,0x23,0x37,0x0a,0x20,0x20
.byte 0x20,0x20,0x3c,0x2f,0x74,0x69,0x74,0x6c
.byte 0x65,0x3e,0x0a,0x20,0x20,0x20,0x20,0x3c
.byte 0x6c,0x69,0x6e,0x6b,0x20,0x72,0x65,0x6c
.byte 0x3d,0x22,0x73,0x74,0x79,0x6c,0x65,0x73
.byte 0x68,0x65,0x65,0x74,0x22,0x20,0x74,0x79
.byte 0x70,0x65,0x3d,0x22,0x74,0x65,0x78,0x74
.byte 0x2f,0x63,0x73,0x73,0x22,0x20,0x68,0x72
.byte 0x65,0x66,0x3d,0x22,0x63,0x70,0x73,0x63
.byte 0x69,0x32,0x34,0x30,0x2e,0x63,0x73,0x73
.byte 0x7f,0x45,0x4c,0x46,0x01,0x01,0x01,0x00
.byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
.byte 0x02,0x00,0x03,0x00,0x01,0x00,0x00,0x00
.byte 0xb0,0x84,0x04,0x08,0x34,0x00,0x00,0x00
.byte 0x28,0x14,0x00,0x00,0x00,0x00,0x00,0x00
.byte 0x34,0x00,0x20,0x00,0x07,0x00,0x28,0x00
.byte 0x1c,0x00,0x19,0x00,0x06,0x00,0x00,0x00
.byte 0x34,0x00,0x00,0x00,0x34,0x80,0x04,0x08
.byte 0x34,0x80,0x04,0x08,0xe0,0x00,0x00,0x00
.byte 0xe0,0x00,0x00,0x00,0x05,0x00,0x00,0x00
.byte 0x04,0x00,0x00,0x00,0x03,0x00,0x00,0x00
.byte 0x14,0x01,0x00,0x00,0x14,0x81,0x04,0x08
.byte 0x14,0x81,0x04,0x08,0x13,0x00,0x00,0x00
.byte 0x13,0x00,0x00,0x00,0x04,0x00,0x00,0x00
.byte 0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00
.byte 0x00,0x00,0x00,0x00,0x00,0x80,0x04,0x08
.byte 0x00,0x80,0x04,0x08,0x1c,0x0b,0x00,0x00
.byte 0x1c,0x0b,0x00,0x00,0x05,0x00,0x00,0x00
.byte 0x00,0x10,0x00,0x00,0x01,0x00,0x00,0x00
.byte 0x00,0x10,0x00,0x00,0x00,0x90,0x04,0x08
.byte 0x00,0x90,0x04,0x08,0x40,0x02,0x00,0x00
.byte 0x5c,0x08,0x00,0x00,0x06,0x00,0x00,0x00
.byte 0x00,0x10,0x00,0x00,0x02,0x00,0x00,0x00
.byte 0x14,0x10,0x00,0x00,0x14,0x90,0x04,0x08
.byte 0x14,0x90,0x04,0x08,0xc8,0x00,0x00,0x00
.byte 0xc8,0x00,0x00,0x00,0x06,0x00,0x00,0x00
.byte 0x04,0x00,0x00,0x00,0x04,0x00,0x00,0x00
.byte 0x28,0x01,0x00,0x00,0x28,0x81,0x04,0x08
.byte 0x28,0x81,0x04,0x08,0x20,0x00,0x00,0x00
.byte 0x20,0x00,0x00,0x00,0x04,0x00,0x00,0x00
.byte 0x04,0x00,0x00,0x00,0x51,0xe5,0x74,0x64
.byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
.byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
.byte 0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00
.byte 0x04,0x00,0x00,0x00,0x2f,0x6c,0x69,0x62
.byte 0x2f,0x6c,0x64,0x2d,0x6c,0x69,0x6e,0x75
.byte 0x78,0x2e,0x73,0x6f,0x2e,0x32,0x00,0x00
.byte 0x04,0x00,0x00,0x00,0x10,0x00,0x00,0x00
.byte 0x01,0x00,0x00,0x00,0x47,0x4e,0x55,0x00
.byte 0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00
|
specs/ada/server/ike/tkmrpc-operation_handlers-ike-esa_create_no_pfs.ads | DrenfongWong/tkm-rpc | 0 | 19399 | <reponame>DrenfongWong/tkm-rpc<filename>specs/ada/server/ike/tkmrpc-operation_handlers-ike-esa_create_no_pfs.ads<gh_stars>0
with Tkmrpc.Request;
with Tkmrpc.Response;
package Tkmrpc.Operation_Handlers.Ike.Esa_Create_No_Pfs is
procedure Handle (Req : Request.Data_Type; Res : out Response.Data_Type);
-- Handler for the esa_create_no_pfs operation.
end Tkmrpc.Operation_Handlers.Ike.Esa_Create_No_Pfs;
|
pwnlib/shellcraft/templates/aarch64/push.asm | DrKeineLust/pwntools | 8,966 | 245683 | <%
from pwnlib import shellcraft
from pwnlib.util.packing import flat, unpack
from pwnlib.util.iters import group
%>
<%page args="value, register1='x14', register2='x15'"/>
<%docstring>
Pushes a value onto the stack without using null bytes or newline characters.
If src is a string, then we try to evaluate using :func:`pwnlib.constants.eval`
before determining how to push it.
Note that this means that this shellcode can change behavior depending on
the value of `context.os`.
Note:
AArch64 requires that the stack remain 16-byte aligned at all times,
so this alignment is preserved.
Args:
value(int,str): The value or register to push
register1(str): Scratch register to use
register2(str): Second scratch register to use
Example:
>>> print(pwnlib.shellcraft.push(0).rstrip())
/* push 0 */
mov x14, xzr
str x14, [sp, #-16]!
>>> print(pwnlib.shellcraft.push(1).rstrip())
/* push 1 */
mov x14, #1
str x14, [sp, #-16]!
>>> print(pwnlib.shellcraft.push(256).rstrip())
/* push 0x100 */
mov x14, #256
str x14, [sp, #-16]!
>>> print(pwnlib.shellcraft.push('SYS_execve').rstrip())
/* push SYS_execve (0xdd) */
mov x14, #221
str x14, [sp, #-16]!
>>> print(pwnlib.shellcraft.push('SYS_sendfile').rstrip())
/* push SYS_sendfile (0x47) */
mov x14, #71
str x14, [sp, #-16]!
>>> with context.local(os = 'freebsd'):
... print(pwnlib.shellcraft.push('SYS_execve').rstrip())
...
/* push SYS_execve (0x3b) */
mov x14, #59
str x14, [sp, #-16]!
</%docstring>
<%
if isinstance(value, str):
value = shellcraft.eval(value)
pretty = shellcraft.pretty(value, comment=False)
%>
${shellcraft.pushstr(flat(value),
append_null = False,
register1 = register1,
register2 = register2,
pretty = pretty)}
|
source/nodes/program-nodes-protected_definitions.ads | reznikmm/gela | 0 | 4540 | -- SPDX-FileCopyrightText: 2019 <NAME> <<EMAIL>>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with Program.Element_Vectors;
with Program.Lexical_Elements;
with Program.Elements.Identifiers;
with Program.Elements.Protected_Definitions;
with Program.Element_Visitors;
package Program.Nodes.Protected_Definitions is
pragma Preelaborate;
type Protected_Definition is
new Program.Nodes.Node
and Program.Elements.Protected_Definitions.Protected_Definition
and Program.Elements.Protected_Definitions.Protected_Definition_Text
with private;
function Create
(Visible_Declarations : Program.Element_Vectors.Element_Vector_Access;
Private_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Private_Declarations : Program.Element_Vectors.Element_Vector_Access;
End_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
End_Name : Program.Elements.Identifiers.Identifier_Access)
return Protected_Definition;
type Implicit_Protected_Definition is
new Program.Nodes.Node
and Program.Elements.Protected_Definitions.Protected_Definition
with private;
function Create
(Visible_Declarations : Program.Element_Vectors.Element_Vector_Access;
Private_Declarations : Program.Element_Vectors.Element_Vector_Access;
End_Name : Program.Elements.Identifiers.Identifier_Access;
Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False)
return Implicit_Protected_Definition
with Pre =>
Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance;
private
type Base_Protected_Definition is
abstract new Program.Nodes.Node
and Program.Elements.Protected_Definitions.Protected_Definition
with record
Visible_Declarations : Program.Element_Vectors.Element_Vector_Access;
Private_Declarations : Program.Element_Vectors.Element_Vector_Access;
End_Name : Program.Elements.Identifiers.Identifier_Access;
end record;
procedure Initialize (Self : in out Base_Protected_Definition'Class);
overriding procedure Visit
(Self : not null access Base_Protected_Definition;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class);
overriding function Visible_Declarations
(Self : Base_Protected_Definition)
return Program.Element_Vectors.Element_Vector_Access;
overriding function Private_Declarations
(Self : Base_Protected_Definition)
return Program.Element_Vectors.Element_Vector_Access;
overriding function End_Name
(Self : Base_Protected_Definition)
return Program.Elements.Identifiers.Identifier_Access;
overriding function Is_Protected_Definition
(Self : Base_Protected_Definition)
return Boolean;
overriding function Is_Definition
(Self : Base_Protected_Definition)
return Boolean;
type Protected_Definition is
new Base_Protected_Definition
and Program.Elements.Protected_Definitions.Protected_Definition_Text
with record
Private_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
End_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
end record;
overriding function To_Protected_Definition_Text
(Self : in out Protected_Definition)
return Program.Elements.Protected_Definitions
.Protected_Definition_Text_Access;
overriding function Private_Token
(Self : Protected_Definition)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function End_Token
(Self : Protected_Definition)
return not null Program.Lexical_Elements.Lexical_Element_Access;
type Implicit_Protected_Definition is
new Base_Protected_Definition
with record
Is_Part_Of_Implicit : Boolean;
Is_Part_Of_Inherited : Boolean;
Is_Part_Of_Instance : Boolean;
end record;
overriding function To_Protected_Definition_Text
(Self : in out Implicit_Protected_Definition)
return Program.Elements.Protected_Definitions
.Protected_Definition_Text_Access;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Protected_Definition)
return Boolean;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Protected_Definition)
return Boolean;
overriding function Is_Part_Of_Instance
(Self : Implicit_Protected_Definition)
return Boolean;
end Program.Nodes.Protected_Definitions;
|
tools/src/gid/gid.ads | stcarrez/hestia | 2 | 23948 | <filename>tools/src/gid/gid.ads
---------------------------------
-- GID - Generic Image Decoder --
---------------------------------
--
-- Purpose:
--
-- The Generic Image Decoder is a package for decoding a broad
-- variety of image formats, from any data stream, to any kind
-- of medium, be it an in-memory bitmap, a GUI object,
-- some other stream, arrays of floating-point initial data
-- for scientific calculations, a browser element, a device,...
-- Animations are supported.
--
-- The code is unconditionally portable, independent of the
-- choice of operating system, processor, endianess and compiler.
--
-- Image types currently supported:
--
-- BMP, GIF, JPEG, PNG, PNM, TGA
--
-- Credits:
--
-- - <NAME>: GIF's LZW decoder in Ada
-- - <NAME>: most of the JPEG decoder (from NanoJPEG)
--
-- More credits in gid_work.xls, sheet "credits".
--
-- Copyright (c) <NAME> 2010 .. 2018
--
-- 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.
--
-- NB: this is the MIT License, as found 2-May-2010 on the site
-- http://www.opensource.org/licenses/mit-license.php
with Ada.Calendar, Ada.Streams, Ada.Strings.Bounded, Ada.Finalization;
with Interfaces;
with System;
package GID is
type Image_descriptor is private;
---------------------------------------------------
-- 1) Load the image header from the data stream --
---------------------------------------------------
procedure Load_image_header (
image : out Image_descriptor;
from : in out Ada.Streams.Root_Stream_Type'Class;
try_tga : Boolean:= False
);
-- try_tga: if no known signature is found, assume it might be
-- the TGA format (which hasn't a signature) and try to load an
-- image of this format
unknown_image_format,
known_but_unsupported_image_format,
unsupported_image_subformat,
error_in_image_data,
invalid_primary_color_range: exception;
----------------------------------------------------------------------
-- 2) If needed, use dimensions to prepare the retrieval of the --
-- image, for instance: reserving an in-memory bitmap, sizing a --
-- GUI object, defining a browser element, setting up a device --
----------------------------------------------------------------------
function Pixel_width (image: Image_descriptor) return Positive;
function Pixel_height (image: Image_descriptor) return Positive;
-- "Unchanged" orientation has origin at top left
type Orientation is (
Unchanged,
Rotation_90, Rotation_180, Rotation_270
);
function Display_orientation (image: Image_descriptor) return Orientation;
--------------------------------------------------------------------
-- 3) Load and decode the image itself. If the image is animated, --
-- call Load_image_contents until next_frame is 0.0 --
--------------------------------------------------------------------
type Display_mode is (fast, nice);
-- For bitmap pictures, the result is exactly the same, but
-- interlaced images' larger pixels are drawn in full during decoding.
generic
type Primary_color_range is mod <>;
-- Coding of primary colors (red, green or blue)
-- and of opacity (also known as alpha channel), on the target "device".
-- Currently, only 8-bit and 16-bit are admitted.
-- 8-bit coding is usual: TrueColor, PC graphics, etc.;
-- 16-bit coding is seen in some high-end apps/devices/formats.
--
with procedure Set_X_Y (x, y: Natural);
-- After Set_X_Y, next pixel is meant to be displayed at position (x,y)
with procedure Put_Pixel (
red, green, blue : Primary_color_range;
alpha : Primary_color_range
);
-- Called with each byte that was read from the image block section.
with procedure Raw_Byte (Byte : in Interfaces.Unsigned_8);
-- When Put_Pixel is called twice without a Set_X_Y inbetween,
-- the pixel must be displayed on the next X position after the last one.
-- [ Rationale: if the image lands into an array with contiguous pixels
-- on the X axis, this approach allows full address calculation to be
-- made only at the beginning of each row, which is much faster ]
--
with procedure Feedback (percents: Natural);
--
mode: Display_mode;
--
procedure Load_image_contents (
image : in out Image_descriptor;
next_frame: out Ada.Calendar.Day_Duration
-- ^ animation: real time lapse foreseen between the first image
-- and the image right after this one; 0.0 if no next frame
);
-------------------------------------------------------------------
-- Some informations about the image, not necessary for decoding --
-------------------------------------------------------------------
type Image_format_type is
( -- Bitmap formats
BMP, FITS, GIF, JPEG, PNG, PNM, TGA, TIFF
);
function Format (image: Image_descriptor) return Image_format_type;
function Detailed_format (image: Image_descriptor) return String;
-- example: "GIF89a, interlaced"
function Subformat (image: Image_descriptor) return Integer;
-- example the 'color type' in PNG
function Bits_per_pixel (image: Image_descriptor) return Positive;
function RLE_encoded (image: Image_descriptor) return Boolean;
function Interlaced (image: Image_descriptor) return Boolean;
function Greyscale (image: Image_descriptor) return Boolean;
function Has_palette (image: Image_descriptor) return Boolean;
function Expect_transparency (image: Image_descriptor) return Boolean;
generic
with procedure Get_color (Red, Green, Blue : Interfaces.Unsigned_8);
procedure Get_palette (image : Image_descriptor);
----------------------------------------------------------------
-- Information about this package - e.g. for an "about" box --
----------------------------------------------------------------
version : constant String:= "008";
reference : constant String:= "28-Jun-2018";
web: constant String:= "http://gen-img-dec.sf.net/";
-- Hopefully the latest version is at that URL..^
private
use Interfaces;
subtype U8 is Unsigned_8;
subtype U16 is Unsigned_16;
subtype U32 is Unsigned_32;
package Bounded_255 is
new Ada.Strings.Bounded.Generic_Bounded_Length(255);
type Stream_Access is access all Ada.Streams.Root_Stream_Type'Class;
type RGB_color is record
red, green, blue : U8;
end record;
type Color_table is array (Integer range <>) of RGB_color;
type p_Color_table is access Color_table;
min_bits: constant:= Integer'Max(32, System.Word_Size);
-- 13.3(8): A word is the largest amount of storage that can be
-- conveniently and efficiently manipulated by the hardware,
-- given the implementation's run-time model.
type Integer_M32 is range -2**(min_bits-1) .. 2**(min_bits-1) - 1;
-- We define an Integer type which is at least 32 bits, but n bits
-- on a native n > 32 bits architecture (no performance hit on 64+
-- bits architectures).
subtype Natural_M32 is Integer_M32 range 0..Integer_M32'Last;
subtype Positive_M32 is Integer_M32 range 1..Integer_M32'Last;
type Byte_array is array(Integer range <>) of U8;
type Input_buffer is record
data : Byte_array(1..1024);
stream : Stream_Access:= null;
InBufIdx : Positive:= 1; -- Points to next char in buffer to be read
MaxInBufIdx: Natural := 0; -- Count of valid chars in input buffer
InputEoF : Boolean; -- End of file indicator
end record;
-- Initial values ensure call to Fill_Buffer on first Get_Byte
-- JPEG may store data _before_ any image header (SOF), then we have
-- to make the image descriptor store that information, alas...
package JPEG_defs is
type Component is
(Y, -- brightness
Cb, -- hue
Cr, -- saturation
I, -- ??
Q -- ??
);
type QT is array(0..63) of Natural;
type QT_list is array(0..7) of QT;
type Compo_set is array(Component) of Boolean;
type Info_per_component_A is record -- B is defined inside the decoder
qt_assoc : Natural;
samples_hor : Natural;
samples_ver : Natural;
up_factor_x : Natural; -- how much we must repeat horizontally
up_factor_y : Natural; -- how much we must repeat vertically
shift_x : Natural; -- shift for repeating pixels horizontally
shift_y : Natural; -- shift for repeating pixels vertically
end record;
type Component_info_A is array(Component) of Info_per_component_A;
type Supported_color_space is (
YCbCr, -- 3-dim color space
Y_Grey, -- 1-dim greyscale
CMYK -- 4-dim Cyan, Magenta, Yellow, blacK
);
type AC_DC is (AC, DC);
type VLC_code is record
bits, code: U8;
end record;
type VLC_table is array(0..65_535) of VLC_code;
type p_VLC_table is access VLC_table;
type VLC_defs_type is array(AC_DC, 0..7) of p_VLC_table;
end JPEG_defs;
type JPEG_stuff_type is record
components : JPEG_defs.Compo_set:= (others => False);
color_space : JPEG_defs.Supported_color_space;
info : JPEG_defs.Component_info_A;
max_samples_hor : Natural;
max_samples_ver : Natural;
qt_list : JPEG_defs.QT_list;
vlc_defs : JPEG_defs.VLC_defs_type:= (others => (others => null));
restart_interval : Natural; -- predictor restarts every... (0: never)
end record;
type Endianess_type is (little, big); -- for TIFF images
type Image_descriptor is new Ada.Finalization.Controlled with record
format : Image_format_type;
detailed_format : Bounded_255.Bounded_String; -- for humans only!
subformat_id : Integer:= 0;
width, height : Positive;
display_orientation: Orientation;
top_first : Boolean; -- data orientation in TGA
bits_per_pixel : Positive;
RLE_encoded : Boolean:= False;
transparency : Boolean:= False;
greyscale : Boolean:= False;
interlaced : Boolean:= False; -- GIF or PNG
endianess : Endianess_type; -- TIFF
JPEG_stuff : JPEG_stuff_type;
stream : Stream_Access;
buffer : Input_buffer;
palette : p_Color_table:= null;
first_byte : U8;
next_frame : Ada.Calendar.Day_Duration;
end record;
procedure Adjust (Object : in out Image_descriptor);
procedure Finalize (Object : in out Image_descriptor);
to_be_done: exception;
-- this exception should not happen, even with malformed files
-- its role is to pop up when a feature is set as implemented
-- but one aspect (e.g. palette) was forgotten.
--
-- Primitive tracing using Ada.Text_IO, for debugging,
-- or explaining internals.
--
type Trace_type is (
none, -- No trace at all, no use of console from the library
some_t, -- Image / frame technical informations
full -- Byte / pixel / compressed block details
);
trace: constant Trace_type:= none; -- <== Choice here
no_trace : constant Boolean:= trace=none;
full_trace: constant Boolean:= trace=full;
some_trace: constant Boolean:= trace>=some_t;
end GID;
|
oeis/008/A008973.asm | neoneye/loda-programs | 11 | 246193 | <gh_stars>10-100
; A008973: Fibonacci number F(n) to power F(n).
; Submitted by <NAME>
; 1,1,1,4,27,3125,16777216,302875106592253,5842587018385982521381124421,11756638905368616011414050501310355554617941909569536,524744532468751923546122657597368049278513737089035272057324643668607677682302892208099365234375,313119843606264301926053344163576361349265045995115651405929697601914062309331717222037671868698420619053704956499930323034173850662765737986672484408801585719796136592384409
seq $0,45 ; Fibonacci numbers: F(n) = F(n-1) + F(n-2) with F(0) = 0 and F(1) = 1.
pow $0,$0
|
alloy4fun_models/trainstlt/models/10/ujW7JrCoP2fJq9t9z.als | Kaixi26/org.alloytools.alloy | 0 | 2050 | open main
pred idujW7JrCoP2fJq9t9z_prop11 {
always ( all t:Train | some t.pos implies historically some t.pos :> Entry)
}
pred __repair { idujW7JrCoP2fJq9t9z_prop11 }
check __repair { idujW7JrCoP2fJq9t9z_prop11 <=> prop11o } |
examples/arinc653-threads/sample-ada/cpu/part1/activity.ads | ana/pok | 0 | 16507 | <reponame>ana/pok<gh_stars>0
-- POK header
--
-- The following file is a part of the POK project. Any modification should
-- be made according to the POK licence. You CANNOT use this file or a part
-- of a file for your own project.
--
-- For more information on the POK licence, please see our LICENCE FILE
--
-- Please follow the coding guidelines described in doc/CODING_GUIDELINES
--
-- Copyright (c) 2007-2022 POK team
pragma No_Run_Time;
with APEX;
use APEX;
with APEX.Timing;
use APEX.Timing;
with Interfaces.C;
package Activity is
procedure Thr1_Job;
end Activity;
|
test/assembly/ld_word.asm | megis7/riscy | 4 | 82288 | <gh_stars>1-10
# Load words from Data section
# Register x1 is used for indexing. Registers x2-x5 contain read values.
.data
val: .word 0x12341234 0x45674567
.text
main:
la x1, val
lw x2, 0(x1)
addi x4, x4, 1
lw x3, 4(x1)
addi x1, x1, 4
addi x9, x0, 1
lw x4, -4(x1)
lw x5, 0(x1)
halt: beq x0, x0, halt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.