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 |
|---|---|---|---|---|
src/fltk-images-rgb-pnm.ads | micahwelf/FLTK-Ada | 1 | 24853 | <filename>src/fltk-images-rgb-pnm.ads
package FLTK.Images.RGB.PNM is
type PNM_Image is new RGB_Image with private;
type PNM_Image_Reference (Data : not null access PNM_Image'Class) is limited null record
with Implicit_Dereference => Data;
package Forge is
function Create
(Filename : in String)
return PNM_Image;
end Forge;
private
type PNM_Image is new RGB_Image with null record;
overriding procedure Finalize
(This : in out PNM_Image);
end FLTK.Images.RGB.PNM;
|
libsrc/oz/emu/ozgfx/ozgetpoint.asm | andydansby/z88dk-mk2 | 1 | 163857 | ;
; OZ-7xx DK emulation layer for Z88DK
; by <NAME> - Oct. 2003
;
; int ozgetpoint(int x, int y);
;
; ------
; $Id: ozgetpoint.asm,v 1.1 2003/10/29 11:37:11 stefano Exp $
;
XLIB ozgetpoint
LIB pointxy
LIB swapgfxbk
.ozgetpoint
ld ix,0
add ix,sp
ld l,(ix+2)
ld h,(ix+4)
call swapgfxbk
call pointxy
ex af,af'
call swapgfxbk
ex af,af'
ld hl,0
ret z ;pixel set
inc hl
ret
|
tools-src/gnu/gcc/gcc/ada/ttypes.ads | enfoTek/tomato.linksys.e2000.nvram-mod | 80 | 2242 | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- T T Y P E S --
-- --
-- S p e c --
-- --
-- $Revision$
-- --
-- Copyright (C) 1992-2001 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 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, USA. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package contains constants describing target properties
with Types; use Types;
with Get_Targ; use Get_Targ;
package Ttypes is
------------------------------
-- Host/Target Dependencies --
------------------------------
-- It is vital to maintain a clear distinction between properties of
-- types on the host and types on the target, since in the general
-- case of a cross-compiler these will be different.
-- This package and its companion Ttypef provide definitions of values
-- that describe the properties of the target types. All instances of
-- target dependencies, including the definitions of such packages as
-- Standard and System depend directly or indirectly on the definitions
-- in the Ttypes and Ttypef packages.
-- In the source of the compiler, references to attributes such as
-- Integer'Size will give information regarding the host types (i.e.
-- the types within the compiler itself). Such references are therefore
-- almost always suspicious (it is hard for example to see that the
-- code in the compiler should even be using type Integer very much,
-- and certainly this code should not depend on the size of Integer).
-- On the other hand, it is perfectly reasonable for the compiler to
-- require access to the size of type Integer for the target machine,
-- e.g. in constructing the internal representation of package Standard.
-- For this purpose, instead of referencing the attribute Integer'Size,
-- a reference to Ttypes.Standard_Integer_Size will provide the needed
-- value for the target type.
-- Two approaches are used for handling target dependent values in the
-- standard library packages. Package Standard is handled specially,
-- being constructed internally (by package Stand). Target dependent
-- values needed in Stand are obtained by direct reference to Ttypes
-- and Ttypef.
-- For package System, the required constant values are obtained by
-- referencing appropriate attributes. Ada 95 already defines most of
-- the required attributes, and GNAT specific attributes have been
-- defined to cover the remaining cases (such as Storage_Unit). The
-- evaluation of these attributes obtains the required target dependent
-- values from Ttypes and Ttypef. The additional attributes that have
-- been added to GNAT (Address_Size, Storage_Unit, Word_Size, Max_Priority,
-- and Max_Interrupt_Priority) are for almost all purposes redundant with
-- respect to the corresponding references to System constants. For example
-- in a program, System.Address_Size and Standard'Address_Size yield the
-- same value. The critical use of the attribute is in writing the System
-- declaration of Address_Size which of course cannot refer to itself. By
-- this means we achieve complete target independence in the source code
-- of package System, i.e. there is only one copy of the source of System
-- for all targets.
-- Note that during compilation there are two versions of package System
-- around. The version that is directly WITH'ed by compiler packages
-- contains host-dependent definitions, which is what is needed in that
-- case (for example, System.Storage_Unit referenced in the source of the
-- compiler refers to the storage unit of the host, not the target. This
-- means that, like attribute references, any references to constants in
-- package System in the compiler code are suspicious, since it is strange
-- for the compiler to have such host dependencies. If the compiler needs
-- to access the target dependent values of such quantities as Storage_Unit
-- then it should reference the constants in this package (Ttypes), rather
-- than referencing System.Storage_Unit, or Standard'Storage_Unit, both of
-- which would yield the host value.
---------------------------------------------------
-- Target-Dependent Values for Types in Standard --
---------------------------------------------------
-- Note: GNAT always supplies all the following integer and float types,
-- but depending on the machine, some of the types may be identical. For
-- example, on some machines, Short_Float may be the same as Float, and
-- Long_Long_Float may be the same as Long_Float.
Standard_Short_Short_Integer_Size : constant Pos := Get_Char_Size;
Standard_Short_Short_Integer_Width : constant Pos :=
Width_From_Size (Standard_Short_Short_Integer_Size);
Standard_Short_Integer_Size : constant Pos := Get_Short_Size;
Standard_Short_Integer_Width : constant Pos :=
Width_From_Size (Standard_Short_Integer_Size);
Standard_Integer_Size : constant Pos := Get_Int_Size;
Standard_Integer_Width : constant Pos :=
Width_From_Size (Standard_Integer_Size);
Standard_Long_Integer_Size : constant Pos := Get_Long_Size;
Standard_Long_Integer_Width : constant Pos :=
Width_From_Size (Standard_Long_Integer_Size);
Standard_Long_Long_Integer_Size : constant Pos := Get_Long_Long_Size;
Standard_Long_Long_Integer_Width : constant Pos :=
Width_From_Size (Standard_Long_Long_Integer_Size);
Standard_Short_Float_Size : constant Pos := Get_Float_Size;
Standard_Short_Float_Digits : constant Pos :=
Digits_From_Size (Standard_Short_Float_Size);
Standard_Float_Size : constant Pos := Get_Float_Size;
Standard_Float_Digits : constant Pos :=
Digits_From_Size (Standard_Float_Size);
Standard_Long_Float_Size : constant Pos := Get_Double_Size;
Standard_Long_Float_Digits : constant Pos :=
Digits_From_Size (Standard_Long_Float_Size);
Standard_Long_Long_Float_Size : constant Pos := Get_Long_Double_Size;
Standard_Long_Long_Float_Digits : constant Pos :=
Digits_From_Size (Standard_Long_Long_Float_Size);
Standard_Character_Size : constant Pos := Get_Char_Size;
Standard_Wide_Character_Size : constant Pos := 2 * Get_Char_Size;
-- The Standard.Wide_Character type is special in the sense that
-- it is not defined in terms of its corresponding C type (wchar_t).
-- Unfortunately this makes the representation of Wide_Character
-- incompatible with the C wchar_t type.
-- ??? This is required by the RM or backward compatibility
-- Note: there is no specific control over the representation of
-- enumeration types. The convention used is that if an enumeration
-- type has fewer than 2**(Character'Size) elements, then the size
-- used is Character'Size, otherwise Integer'Size is used.
-- Similarly, the size of fixed-point types depends on the size of the
-- corresponding integer type, which is the smallest predefined integer
-- type capable of representing the required range of values.
-------------------------------------------------
-- Target-Dependent Values for Types in System --
-------------------------------------------------
System_Address_Size : constant Pos := Get_Pointer_Size;
-- System.Address'Size (also size of all thin pointers)
System_Max_Binary_Modulus_Power : constant Pos :=
Standard_Long_Long_Integer_Size;
System_Max_Nonbinary_Modulus_Power : constant Pos :=
Standard_Integer_Size - 1;
System_Storage_Unit : constant Pos := Get_Bits_Per_Unit;
System_Word_Size : constant Pos := Get_Bits_Per_Word;
System_Tick_Nanoseconds : constant Pos := 1_000_000_000;
-- Value of System.Tick in nanoseconds. At the moment, this is a fixed
-- constant (with value of 1.0 seconds), but later we should add this
-- value to the GCC configuration file so that its value can be made
-- configuration dependent.
-----------------------------------------------------
-- Target-Dependent Values for Types in Interfaces --
-----------------------------------------------------
Interfaces_Wchar_T_Size : constant Pos := Get_Wchar_T_Size;
----------------------------------------
-- Other Target-Dependent Definitions --
----------------------------------------
Maximum_Alignment : constant Pos := Get_Maximum_Alignment;
-- The maximum alignment, in storage units, that an object or
-- type may require on the target machine.
Bytes_Big_Endian : Boolean := Get_Bytes_BE /= 0;
-- Important note: for Ada purposes, the important setting is the bytes
-- endianness (Bytes_Big_Endian), not the bits value (Bits_Big_Endian).
-- This is because Ada bit addressing must be compatible with the byte
-- ordering (otherwise we would end up with non-contiguous fields). It
-- is rare for the two to be different, but if they are, Bits_Big_Endian
-- is relevant only for the generation of instructions with bit numbers,
-- and thus relevant only to the back end. Note that this is a variable
-- rather than a constant, since it can be modified (flipped) by -gnatd8.
Target_Strict_Alignment : Boolean := Get_Strict_Alignment /= 0;
-- True if instructions will fail if data is misaligned
end Ttypes;
|
oeis/212/A212058.asm | neoneye/loda-programs | 11 | 2362 | ; A212058: Number of (w,x,y,z) with all terms in {1,...,n} and w>=x*y*z.
; Submitted by <NAME>(w3)
; 0,1,5,12,25,41,66,94,132,176,229,285,359,436,522,617,727,840,971,1105,1257,1418,1588,1761,1964,2173,2391,2619,2865,3114,3390,3669,3969,4278,4596,4923,5286,5652,6027,6411,6825,7242,7686,8133,8598
mov $1,$0
mov $3,$0
add $3,1
lpb $3
mov $0,$1
sub $3,1
sub $0,$3
seq $0,7425 ; d_3(n), or tau_3(n), the number of ordered factorizations of n as n = r s t.
mul $0,$3
add $2,$0
lpe
mov $0,$2
|
_build/dispatcher/jmp_ippsGFpECGetPoint_003eee43.asm | zyktrcn/ippcp | 1 | 14464 | extern m7_ippsGFpECGetPoint:function
extern n8_ippsGFpECGetPoint:function
extern y8_ippsGFpECGetPoint:function
extern e9_ippsGFpECGetPoint:function
extern l9_ippsGFpECGetPoint:function
extern n0_ippsGFpECGetPoint:function
extern k0_ippsGFpECGetPoint:function
extern ippcpJumpIndexForMergedLibs
extern ippcpSafeInit:function
segment .data
align 8
dq .Lin_ippsGFpECGetPoint
.Larraddr_ippsGFpECGetPoint:
dq m7_ippsGFpECGetPoint
dq n8_ippsGFpECGetPoint
dq y8_ippsGFpECGetPoint
dq e9_ippsGFpECGetPoint
dq l9_ippsGFpECGetPoint
dq n0_ippsGFpECGetPoint
dq k0_ippsGFpECGetPoint
segment .text
global ippsGFpECGetPoint:function (ippsGFpECGetPoint.LEndippsGFpECGetPoint - ippsGFpECGetPoint)
.Lin_ippsGFpECGetPoint:
db 0xf3, 0x0f, 0x1e, 0xfa
call ippcpSafeInit wrt ..plt
align 16
ippsGFpECGetPoint:
db 0xf3, 0x0f, 0x1e, 0xfa
mov rax, qword [rel ippcpJumpIndexForMergedLibs wrt ..gotpc]
movsxd rax, dword [rax]
lea r11, [rel .Larraddr_ippsGFpECGetPoint]
mov r11, qword [r11+rax*8]
jmp r11
.LEndippsGFpECGetPoint:
|
programs/oeis/116/A116725.asm | neoneye/loda | 22 | 161176 | ; A116725: Number of permutations of length n which avoid the patterns 132, 3421, 4231.
; 1,2,5,12,26,52,99,184,340,632,1189,2268,4382,8556,16839,33328,66216,131888,263113,525428,1049906,2098692,4196075,8390632,16779516,33557032,67111789,134221004,268439110,536874972,1073746319,2147488608,4294972752,8589940576,17179875729,34359745508,68719484506,137438961908,274877916083,549755823768,1099511638436,2199023267032,4398046523445,8796093035452,17592186058606,35184372104012,70368744193879,140737488372624,281474976729080,562949953440912,1125899906863449,2251799813707348,4503599627393922,9007199254765796,18014398509508219,36028797018991688,72057594037957196,144115188075886728,288230376151744253,576460752303457708,1152921504606882966,2305843009213731772,4611686018427427615,9223372036854817472,18446744073709595296,36893488147419148992,73786976294838254369,147573952589676463044,295147905179352878250,590295810358705706452,1180591620717411360579,2361183241434822666488,4722366482869645275892,9444732965739290492216,18889465931478580922309,37778931862957161779868,75557863725914323492286,151115727451828646914348,302231454903657293755623,604462909807314587435248,1208925819614629174791496,2417851639229258349500912,4835703278458516698916585,9671406556917033397744692,19342813113834066795397586,38685626227668133590699972,77371252455336267181301259,154742504910672534362500264,309485009821345068724894620,618970019642690137449679592,1237940039285380274899245709,2475880078570760549798374028,4951760157141521099596626662,9903520314283042199193127836,19807040628566084398386125999,39614081257132168796772118048,79228162514264337593544097776,158456325028528675187088052768,316912650057057350374175958193,633825300114114700748351764388
mov $1,2
pow $1,$0
mov $2,1
sub $2,$0
bin $2,3
sub $1,$2
mov $0,$1
|
libsrc/_DEVELOPMENT/adt/b_vector/c/sccz80/b_vector_append_block.asm | teknoplop/z88dk | 8 | 87357 |
; void *b_vector_append_block(b_vector_t *v, size_t n)
SECTION code_clib
SECTION code_adt_b_vector
PUBLIC b_vector_append_block
EXTERN asm_b_vector_append_block
b_vector_append_block:
pop af
pop de
pop hl
push hl
push de
push af
jp asm_b_vector_append_block
|
programs/oeis/152/A152106.asm | neoneye/loda | 22 | 24317 | ; A152106: a(n) = (11^n + 7^n)/2.
; 1,9,85,837,8521,88929,944605,10155357,110061841,1199150649,13109949925,143644498677,1576134831961,17309800577169,190214028328045,2090997865462797,22991481397070881,252839829506640489
mov $1,7
pow $1,$0
mov $2,11
pow $2,$0
add $1,$2
mov $0,$1
div $0,2
|
programs/oeis/284/A284446.asm | neoneye/loda | 22 | 83477 | ; A284446: Sum_{d|n, d = 5 mod 7} d.
; 0,0,0,0,5,0,0,0,0,5,0,12,0,0,5,0,0,0,19,5,0,0,0,12,5,26,0,0,0,5,0,0,33,0,5,12,0,19,0,45,0,0,0,0,5,0,47,12,0,5,0,26,0,54,5,0,19,0,0,17,61,0,0,0,5,33,0,68,0,5,0,12,0,0,80,19,0,26,0,45,0,82,0,12,5,0,0,0,89,5,0,0,0,47,24,108,0,0,33,5
add $0,1
mov $2,$0
mov $0,211907
lpb $0
sub $0,5
mov $3,$2
dif $3,$0
cmp $3,$2
cmp $3,0
mul $3,$0
sub $0,2
add $1,$3
lpe
mov $0,$1
|
source/nodes/program-nodes-allocators.adb | reznikmm/gela | 0 | 6712 | -- SPDX-FileCopyrightText: 2019 <NAME> <<EMAIL>>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
package body Program.Nodes.Allocators is
function Create
(New_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Left_Bracket_Token : Program.Lexical_Elements.Lexical_Element_Access;
Subpool_Name : Program.Elements.Expressions.Expression_Access;
Right_Bracket_Token : Program.Lexical_Elements.Lexical_Element_Access;
Subtype_Indication : Program.Elements.Subtype_Indications
.Subtype_Indication_Access;
Qualified_Expression : Program.Elements.Qualified_Expressions
.Qualified_Expression_Access)
return Allocator is
begin
return Result : Allocator :=
(New_Token => New_Token, Left_Bracket_Token => Left_Bracket_Token,
Subpool_Name => Subpool_Name,
Right_Bracket_Token => Right_Bracket_Token,
Subtype_Indication => Subtype_Indication,
Qualified_Expression => Qualified_Expression,
Enclosing_Element => null)
do
Initialize (Result);
end return;
end Create;
function Create
(Subpool_Name : Program.Elements.Expressions.Expression_Access;
Subtype_Indication : Program.Elements.Subtype_Indications
.Subtype_Indication_Access;
Qualified_Expression : Program.Elements.Qualified_Expressions
.Qualified_Expression_Access;
Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False)
return Implicit_Allocator is
begin
return Result : Implicit_Allocator :=
(Subpool_Name => Subpool_Name,
Subtype_Indication => Subtype_Indication,
Qualified_Expression => Qualified_Expression,
Is_Part_Of_Implicit => Is_Part_Of_Implicit,
Is_Part_Of_Inherited => Is_Part_Of_Inherited,
Is_Part_Of_Instance => Is_Part_Of_Instance, Enclosing_Element => null)
do
Initialize (Result);
end return;
end Create;
overriding function Subpool_Name
(Self : Base_Allocator)
return Program.Elements.Expressions.Expression_Access is
begin
return Self.Subpool_Name;
end Subpool_Name;
overriding function Subtype_Indication
(Self : Base_Allocator)
return Program.Elements.Subtype_Indications.Subtype_Indication_Access is
begin
return Self.Subtype_Indication;
end Subtype_Indication;
overriding function Qualified_Expression
(Self : Base_Allocator)
return Program.Elements.Qualified_Expressions
.Qualified_Expression_Access is
begin
return Self.Qualified_Expression;
end Qualified_Expression;
overriding function New_Token
(Self : Allocator)
return not null Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.New_Token;
end New_Token;
overriding function Left_Bracket_Token
(Self : Allocator)
return Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Left_Bracket_Token;
end Left_Bracket_Token;
overriding function Right_Bracket_Token
(Self : Allocator)
return Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Right_Bracket_Token;
end Right_Bracket_Token;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Allocator)
return Boolean is
begin
return Self.Is_Part_Of_Implicit;
end Is_Part_Of_Implicit;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Allocator)
return Boolean is
begin
return Self.Is_Part_Of_Inherited;
end Is_Part_Of_Inherited;
overriding function Is_Part_Of_Instance
(Self : Implicit_Allocator)
return Boolean is
begin
return Self.Is_Part_Of_Instance;
end Is_Part_Of_Instance;
procedure Initialize (Self : in out Base_Allocator'Class) is
begin
if Self.Subpool_Name.Assigned then
Set_Enclosing_Element (Self.Subpool_Name, Self'Unchecked_Access);
end if;
if Self.Subtype_Indication.Assigned then
Set_Enclosing_Element
(Self.Subtype_Indication, Self'Unchecked_Access);
end if;
if Self.Qualified_Expression.Assigned then
Set_Enclosing_Element
(Self.Qualified_Expression, Self'Unchecked_Access);
end if;
null;
end Initialize;
overriding function Is_Allocator (Self : Base_Allocator) return Boolean is
pragma Unreferenced (Self);
begin
return True;
end Is_Allocator;
overriding function Is_Expression (Self : Base_Allocator) return Boolean is
pragma Unreferenced (Self);
begin
return True;
end Is_Expression;
overriding procedure Visit
(Self : not null access Base_Allocator;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class) is
begin
Visitor.Allocator (Self);
end Visit;
overriding function To_Allocator_Text
(Self : in out Allocator)
return Program.Elements.Allocators.Allocator_Text_Access is
begin
return Self'Unchecked_Access;
end To_Allocator_Text;
overriding function To_Allocator_Text
(Self : in out Implicit_Allocator)
return Program.Elements.Allocators.Allocator_Text_Access is
pragma Unreferenced (Self);
begin
return null;
end To_Allocator_Text;
end Program.Nodes.Allocators;
|
Source/Levels/L0901.asm | AbePralle/FGB | 0 | 15800 | <gh_stars>0
; L0901.asm
; Generated 01.03.1980 by mlevel
; Modified 01.03.1980 by <NAME>
INCLUDE "Source/Defs.inc"
INCLUDE "Source/Levels.inc"
HFENCE_INDEX EQU 35
VFENCE_INDEX EQU 39
VAR_HFENCE EQU 0
VAR_VFENCE EQU 1
;---------------------------------------------------------------------
SECTION "Level0901Section",ROMX
;---------------------------------------------------------------------
L0901_Contents::
DW L0901_Load
DW L0901_Init
DW L0901_Check
DW L0901_Map
;---------------------------------------------------------------------
; Load
;---------------------------------------------------------------------
L0901_Load:
DW ((L0901_LoadFinished - L0901_Load2)) ;size
L0901_Load2:
call ParseMap
ret
L0901_LoadFinished:
;---------------------------------------------------------------------
; Map
;---------------------------------------------------------------------
L0901_Map:
INCBIN "Data/Levels/L0901_slavecamp.lvl"
;---------------------------------------------------------------------
; Init
;---------------------------------------------------------------------
L0901_Init:
DW ((L0901_InitFinished - L0901_Init2)) ;size
L0901_Init2:
ld a,[bgTileMap+HFENCE_INDEX]
ld [levelVars + VAR_HFENCE],a
ld a,[bgTileMap+VFENCE_INDEX]
ld [levelVars + VAR_VFENCE],a
ret
L0901_InitFinished:
;---------------------------------------------------------------------
; Check
;---------------------------------------------------------------------
L0901_Check:
DW ((L0901_CheckFinished - L0901_Check2)) ;size
L0901_Check2:
call ((.animateFence-L0901_Check2)+levelCheckRAM)
ret
.animateFence
ldio a,[updateTimer]
rrca
and 3
ld b,a
ld hl,bgTileMap+HFENCE_INDEX
ld a,[levelVars+VAR_HFENCE]
ld d,a
call ((.animateFourFrames-L0901_Check2)+levelCheckRAM)
ld a,[levelVars+VAR_VFENCE]
ld d,a
jp ((.animateFourFrames-L0901_Check2)+levelCheckRAM)
.animateFourFrames
ld c,4
.animateFourFrames_loop
ld a,b
add c
and 3
add d
ld [hl+],a
dec c
jr nz,.animateFourFrames_loop
ret
L0901_CheckFinished:
PRINT "0901 Script Sizes (Load/Init/Check) (of $500): "
PRINT (L0901_LoadFinished - L0901_Load2)
PRINT " / "
PRINT (L0901_InitFinished - L0901_Init2)
PRINT " / "
PRINT (L0901_CheckFinished - L0901_Check2)
PRINT "\n"
|
Cubical/HITs/Nullification/Base.agda | borsiemir/cubical | 0 | 6021 | {-# OPTIONS --cubical --safe #-}
module Cubical.HITs.Nullification.Base where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.PathSplitEquiv
open isPathSplitEquiv
isNull : ∀ {ℓ ℓ'} (S : Type ℓ) (A : Type ℓ') → Type (ℓ-max ℓ ℓ')
isNull S A = isPathSplitEquiv (const {A = A} {B = S})
data Null {ℓ ℓ'} (S : Type ℓ) (A : Type ℓ') : Type (ℓ-max ℓ ℓ') where
∣_∣ : A → Null S A
-- the image of every map (S → Null S A) is contractible in Null S A
hub : (f : S → Null S A) → Null S A
spoke : (f : S → Null S A) (s : S) → hub f ≡ f s
-- the image of every map (S → x ≡ y) for x y : A is contractible in x ≡ y
≡hub : ∀ {x y} (p : S → x ≡ y) → x ≡ y
≡spoke : ∀ {x y} (p : S → x ≡ y) (s : S) → ≡hub p ≡ p s
isNull-Null : ∀ {ℓ ℓ'} {S : Type ℓ} {A : Type ℓ'} → isNull S (Null S A)
fst (sec isNull-Null) f = hub f
snd (sec isNull-Null) f i s = spoke f s i
fst (secCong isNull-Null x y) p i = ≡hub (funExt⁻ p) i
snd (secCong isNull-Null x y) p i j s = ≡spoke (funExt⁻ p) s i j
|
libsrc/stdio/__scanf_handle_f.asm | dikdom/z88dk | 1 | 173488 |
MODULE __scanf_handle_f
SECTION code_clib
IF ! __CPU_INTEL__
PUBLIC __scanf_handle_f
EXTERN __scanf_common_start
EXTERN scanf_exit
EXTERN __scanf_ungetchar
EXTERN __scanf_getchar
EXTERN scanf_loop
EXTERN __scanf_check_sign
EXTERN atof
EXTERN l_cmp
EXTERN asm_isdigit
EXTERN dstore
EXTERN CLIB_32BIT_FLOATS
; Floating point
; We read from the stream into a temporary buf on the stack and then run atof() on it
__scanf_handle_f:
call __scanf_common_start
jp c,scanf_exit
call __scanf_ungetchar
push de ;save destination
ld hl,2
add hl,sp
ex de,hl ;de = our buffer for the number
ld c,0 ;[000000E.]
IF __CPU_INTEL__
call __scanf_check_sign
ELSE
bit 0,(ix-3)
ENDIF
jr z,handle_f_fmt_check_width
ld a,'-'
ld (de),a
inc de
handle_f_fmt_check_width:
IF __CPU_INTEL__
ld b,0
call ___scanf_get_width
ld a,b
ELSE
ld a,(ix-4) ;width
ENDIF
and a
jr z,handle_f_fmt_check_width1
cp 39 ;maximum width
jr c,handle_f_fmt_setup_length
handle_f_fmt_check_width1:
ld a,39
handle_f_fmt_setup_length:
ld b,a
handle_f_fmt_loop:
call __scanf_getchar
jr c,handle_f_fmt_finished_reading
cp '.'
jr nz,handle_f_fmt_check_exponent
; It was ., have we already seen one
bit 0,c
jr nz,handle_f_fmt_error
set 0,c
jr handle_f_fmt_store
handle_f_fmt_check_exponent:
cp 'e'
jr z,handle_f_fmt_check_exponent1
cp 'E'
jr nz,handle_f_fmt_check_digit
handle_f_fmt_check_exponent1:
bit 1,c ;have we seen one already?
jr nz,handle_f_fmt_error
set 1,c
jr handle_f_fmt_store
handle_f_fmt_check_digit:
call asm_isdigit
jr nc,handle_f_fmt_store
call __scanf_ungetchar
jr handle_f_fmt_finished_reading
handle_f_fmt_store:
ld (de),a
inc de
djnz handle_f_fmt_loop
handle_f_fmt_finished_reading:
xor a
ld (de),a
ld hl,2
add hl,sp
call l_cmp
jr z,handle_f_fmt_error
; TODO: Check there's something there
ld hl,2 ;we have the destination on the stack
add hl,sp
IF !__CPU_INTEL__
push ix ;save our framepointer - fp library will disturb it
ENDIF
push hl
call atof
pop bc
IF !__CPU_INTEL__
pop ix ;get our framepointer back
ENDIF
ld a,CLIB_32BIT_FLOATS
and a
jr z,store_48bit_float
push hl ;LSW
pop bc ;LSW
pop hl ;destination
ld (hl),c ;Store LSW
inc hl
ld (hl),b
inc hl
ld (hl),e ;Store MSW
inc hl
ld (hl),d
jr store_rejoin
store_48bit_float:
pop hl ;destination
call dstore ;and put it there
store_rejoin:
IF __CPU_INTEL__
call __scanf_increment_conversions
ELSE
inc (ix-1) ;increase number of conversions
ENDIF
jp scanf_loop
handle_f_fmt_error:
call __scanf_ungetchar
pop de ;discard destinatino
jp scanf_exit
ENDIF |
Cubical/Structures/Function.agda | dan-iel-lee/cubical | 0 | 13170 | {-
Functions between structures S and T: X ↦ S X → T X
-}
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Structures.Function where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Function
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Path
open import Cubical.Foundations.SIP
open import Cubical.Foundations.Transport
open import Cubical.Foundations.Univalence
open import Cubical.Functions.FunExtEquiv
open import Cubical.Data.Nat
open import Cubical.Data.Vec
private
variable
ℓ ℓ₁ ℓ₁' ℓ₂ ℓ₂' : Level
-- General function structure
FunctionStructure : (S : Type ℓ → Type ℓ₁) (T : Type ℓ → Type ℓ₂)
→ Type ℓ → Type (ℓ-max ℓ₁ ℓ₂)
FunctionStructure S T X = S X → T X
FunctionEquivStr : {S : Type ℓ → Type ℓ₁} {T : Type ℓ → Type ℓ₂}
→ StrEquiv S ℓ₁' → StrEquiv T ℓ₂'
→ StrEquiv (FunctionStructure S T) (ℓ-max ℓ₁ (ℓ-max ℓ₁' ℓ₂'))
FunctionEquivStr {S = S} {T} ι₁ ι₂ (X , f) (Y , g) e =
{s : S X} {t : S Y} → ι₁ (X , s) (Y , t) e → ι₂ (X , f s) (Y , g t) e
functionUnivalentStr : {S : Type ℓ → Type ℓ₁} {T : Type ℓ → Type ℓ₂}
(ι₁ : StrEquiv S ℓ₁') (θ₁ : UnivalentStr S ι₁)
(ι₂ : StrEquiv T ℓ₂') (θ₂ : UnivalentStr T ι₂)
→ UnivalentStr (FunctionStructure S T) (FunctionEquivStr ι₁ ι₂)
functionUnivalentStr ι₁ θ₁ ι₂ θ₂ e =
compEquiv
(equivImplicitΠCod (equivImplicitΠCod (equiv→ (θ₁ e) (θ₂ e))))
funExtDepEquiv
functionEquivAction : {S : Type ℓ → Type ℓ₁} {T : Type ℓ → Type ℓ₂}
→ EquivAction S → EquivAction T
→ EquivAction (FunctionStructure S T)
functionEquivAction α₁ α₂ e = equiv→ (α₁ e) (α₂ e)
functionTransportStr : {S : Type ℓ → Type ℓ₁} {T : Type ℓ → Type ℓ₂}
(α₁ : EquivAction S) (τ₁ : TransportStr α₁)
(α₂ : EquivAction T) (τ₂ : TransportStr α₂)
→ TransportStr (functionEquivAction α₁ α₂)
functionTransportStr {S = S} α₁ τ₁ α₂ τ₂ e f =
funExt λ t →
cong (equivFun (α₂ e) ∘ f) (invTransportStr α₁ τ₁ e t)
∙ τ₂ e (f (subst⁻ S (ua e) t))
-- Definition of structured equivalence using an action in the domain
FunctionEquivStr+ : {S : Type ℓ → Type ℓ₁} {T : Type ℓ → Type ℓ₂}
→ EquivAction S → StrEquiv T ℓ₂'
→ StrEquiv (FunctionStructure S T) (ℓ-max ℓ₁ ℓ₂')
FunctionEquivStr+ {S = S} {T} α₁ ι₂ (X , f) (Y , g) e =
(s : S X) → ι₂ (X , f s) (Y , g (equivFun (α₁ e) s)) e
functionUnivalentStr+ : {S : Type ℓ → Type ℓ₁} {T : Type ℓ → Type ℓ₂}
(α₁ : EquivAction S) (τ₁ : TransportStr α₁)
(ι₂ : StrEquiv T ℓ₂') (θ₂ : UnivalentStr T ι₂)
→ UnivalentStr (FunctionStructure S T) (FunctionEquivStr+ α₁ ι₂)
functionUnivalentStr+ {S = S} {T} α₁ τ₁ ι₂ θ₂ {X , f} {Y , g} e =
compEquiv
(compEquiv
(equivΠCod λ s →
compEquiv
(θ₂ e)
(pathToEquiv (cong (PathP (λ i → T (ua e i)) (f s) ∘ g) (τ₁ e s))))
(invEquiv heteroHomotopy≃Homotopy))
funExtDepEquiv
|
theorems/cohomology/DisjointlyPointedSet.agda | timjb/HoTT-Agda | 294 | 14458 | {-# OPTIONS --without-K --rewriting #-}
open import HoTT
open import homotopy.Bouquet
open import homotopy.DisjointlyPointedSet
open import cohomology.Theory
module cohomology.DisjointlyPointedSet {i} (OT : OrdinaryTheory i) where
open OrdinaryTheory OT
open import cohomology.Bouquet OT
module _ (X : Ptd i)
(X-is-set : is-set (de⊙ X)) (X-sep : is-separable X)
(ac : has-choice 0 (de⊙ X) i) where
C-set : C 0 X ≃ᴳ Πᴳ (MinusPoint X) (λ _ → C2 0)
C-set = C-Bouquet-diag 0 (MinusPoint X) (MinusPoint-has-choice X-sep ac)
∘eᴳ C-emap 0 (Bouquet-⊙equiv-X X-sep)
module _ {n : ℤ} (n≠0 : n ≠ 0) (X : Ptd i)
(X-is-set : is-set (de⊙ X)) (X-sep : is-separable X)
(ac : has-choice 0 (de⊙ X) i) where
abstract
C-set-≠-is-trivial : is-trivialᴳ (C n X)
C-set-≠-is-trivial = iso-preserves'-trivial
(C-emap n (Bouquet-⊙equiv-X X-sep))
(C-Bouquet-≠-is-trivial n (MinusPoint X) 0 n≠0 (MinusPoint-has-choice X-sep ac))
|
Agda/Ag12.agda | Brethland/LEARNING-STUFF | 2 | 12660 | <reponame>Brethland/LEARNING-STUFF
module Ag12 where
import Relation.Binary.PropositionalEquality as Eq
open Eq
open import Data.Nat using (ℕ; zero; suc; _+_; _*_)
open import Relation.Nullary using (¬_)
open import Data.Product using (_×_; proj₁; proj₂) renaming (_,_ to ⟨_,_⟩)
open import Data.Sum using (_⊎_; inj₁; inj₂)
open import Function
open import Ag09 hiding (_∘_)
-- open import Data.Product using (Σ; _,_; ∃; Σ-syntax; ∃-syntax)
open import Level using (Level; _⊔_) renaming (zero to lzero; suc to lsuc)
open ≡-Reasoning
open ≃-Reasoning
postulate
funExt : ∀ {m n : Level} {A : Set m} {B : Set n} {f g : A → B}
→ (∀ (x : A) → f x ≡ g x)
→ f ≡ g
lemma₀ : ∀ {A B : Set} → (a : A × B) → ⟨ proj₁ a , proj₂ a ⟩ ≡ a
lemma₀ ⟨ fst , snd ⟩ = refl
lemma₁ : ∀ {A : Set} {B C : A → Set}
→ (f : (x : A) → B x × C x)
→ (λ a → ⟨ proj₁ (f a) , proj₂ (f a) ⟩) ≡ f
lemma₁ f = refl
∀-distrib-× : ∀ {A : Set} {B C : A → Set} →
(∀ (x : A) → B x × C x) ≃ (∀ (x : A) → B x) × (∀ (x : A) → C x)
∀-distrib-× {A} {B} {C} =
record
{ to = λ bc → ⟨ proj₁ ∘ bc , proj₂ ∘ bc ⟩
; from = λ bc a → ⟨ proj₁ bc a , proj₂ bc a ⟩
; from∘to = λ f → refl
; to∘from = λ f → refl
}
⊎∀-implies-∀⊎ : ∀ {A : Set} {B C : A → Set} →
(∀ (x : A) → B x) ⊎ (∀ (x : A) → C x) → ∀ (x : A) → B x ⊎ C x
⊎∀-implies-∀⊎ (_⊎_.inj₁ x₁) x = _⊎_.inj₁ (x₁ x)
⊎∀-implies-∀⊎ (_⊎_.inj₂ y) x = _⊎_.inj₂ (y x)
data Σ (A : Set) (B : A → Set) : Set where
⟨_,_⟩ : (x : A) → B x → Σ A B
Σ-syntax = Σ
infix 2 Σ-syntax
syntax Σ-syntax A (λ x → B) = Σ[ x ∈ A ] B
∃ : ∀ {A : Set} (B : A → Set) → Set
∃ {A} B = Σ A B
∃-syntax = ∃
syntax ∃-syntax (λ x → B) = ∃[ x ] B
∃-distrib-⊎ : ∀ {A : Set} {B C : A → Set} →
∃[ x ] (B x ⊎ C x) ≃ (∃[ x ] B x) ⊎ (∃[ x ] C x)
∃-distrib-⊎ =
record
{ to = λ x → {!!}
; from = λ{ (inj₁ x) → ⟨ {!!} , {!!} ⟩ ; (inj₂ x) → {!!} }
; from∘to = {!!}
; to∘from = {!!}
}
|
programs/oeis/001/A001911.asm | jmorken/loda | 1 | 171617 | ; A001911: a(n) = Fibonacci(n+3) - 2.
; 0,1,3,6,11,19,32,53,87,142,231,375,608,985,1595,2582,4179,6763,10944,17709,28655,46366,75023,121391,196416,317809,514227,832038,1346267,2178307,3524576,5702885,9227463,14930350,24157815,39088167,63245984,102334153,165580139,267914294,433494435,701408731,1134903168,1836311901,2971215071,4807526974,7778742047,12586269023,20365011072,32951280097,53316291171,86267571270,139583862443,225851433715,365435296160,591286729877,956722026039,1548008755918,2504730781959,4052739537879,6557470319840,10610209857721,17167680177563,27777890035286,44945570212851,72723460248139,117669030460992,190392490709133,308061521170127,498454011879262,806515533049391,1304969544928655,2111485077978048,3416454622906705,5527939700884755,8944394323791462
mov $1,2
mov $2,1
lpb $0
sub $0,1
mov $3,$2
mov $2,$1
add $1,$3
lpe
sub $1,2
|
dowload_manager/src/aws-resources-streams-pipes.ads | persan/AWS-producer-experiments | 2 | 19419 | pragma Ada_2012;
with AWS.Resources.Streams.Memory;
with GNAT.Semaphores;
with System;
with Ada.Finalization;
package AWS.Resources.Streams.Pipes is
use AWS.Resources.Streams.Memory;
type Stream_Type is new Streams.Memory.Stream_Type with private;
procedure Append
(Resource : in out Stream_Type;
Buffer : Stream_Element_Array;
Trim : Boolean := False);
-- Append Buffer into the memory stream
procedure Append
(Resource : in out Stream_Type;
Buffer : Stream_Element_Access);
-- Append static data pointed to Buffer into the memory stream as is.
-- The stream will free the memory on close.
procedure Append
(Resource : in out Stream_Type;
Buffer : Buffer_Access);
-- Append static data pointed to Buffer into the memory stream as is.
-- The stream would not try to free the memory on close.
overriding procedure Read
(Resource : in out Stream_Type;
Buffer : out Stream_Element_Array;
Last : out Stream_Element_Offset);
-- Returns a chunck of data in Buffer, Last point to the last element
-- returned in Buffer.
overriding function End_Of_File (Resource : Stream_Type) return Boolean;
-- Returns True if the end of the memory stream has been reached
procedure Clear (Resource : in out Stream_Type);
-- Delete all data from memory stream
overriding procedure Reset (Resource : in out Stream_Type) is null;
-- Reset the streaming data to the first position
overriding procedure Set_Index
(Resource : in out Stream_Type;
To : Stream_Element_Offset) is null;
-- Set the position in the stream, next Read will start at the position
-- whose index is To.
overriding function Size
(Resource : Stream_Type) return Stream_Element_Offset is (0);
-- Returns the number of bytes in the memory stream
overriding procedure Close (Resource : in out Stream_Type);
-- Close the memory stream. Release all memory associated with the stream
private
type Stream_Type is new Streams.Memory.Stream_Type with record
Guard : aliased GNAT.Semaphores.Binary_Semaphore (True, System.Default_Priority);
Is_Open : Boolean := True;
Has_Write : Boolean := False with Atomic;
Has_Read : Boolean := False with Atomic;
end record;
type Lock_Type (Guard : not null access GNAT.Semaphores.Binary_Semaphore) is new
Ada.Finalization.Limited_Controlled with null record with
Unreferenced_Objects => True;
procedure Initialize (Object : in out Lock_Type);
procedure Finalize (Object : in out Lock_Type);
end AWS.Resources.Streams.Pipes;
|
theorems/groups/CoefficientExtensionality.agda | timjb/HoTT-Agda | 0 | 7206 | {-# OPTIONS --without-K --rewriting #-}
open import HoTT
module groups.CoefficientExtensionality where
module _ {i} {A : Type i} (dec : has-dec-eq A) where
Word-coef : Word A → (A → ℤ)
Word-coef nil a = 0
Word-coef (inl a' :: w) a with dec a' a
Word-coef (inl a' :: w) a | inl a'=a = succ $ Word-coef w a
Word-coef (inl a' :: w) a | inr a'≠a = Word-coef w a
Word-coef (inr a' :: w) a with dec a' a
Word-coef (inr a' :: w) a | inl a'=a = pred $ Word-coef w a
Word-coef (inr a' :: w) a | inr a'≠a = Word-coef w a
abstract
Word-coef-++ : ∀ w₁ w₂ a → Word-coef (w₁ ++ w₂) a
== Word-coef w₁ a ℤ+ Word-coef w₂ a
Word-coef-++ nil w₂ a = idp
Word-coef-++ (inl a' :: w₁) w₂ a with dec a' a
Word-coef-++ (inl a' :: w₁) w₂ a | inl a'=a =
ap succ (Word-coef-++ w₁ w₂ a)
∙ ! (succ-+ (Word-coef w₁ a) (Word-coef w₂ a))
Word-coef-++ (inl a' :: w₁) w₂ a | inr a'≠a = Word-coef-++ w₁ w₂ a
Word-coef-++ (inr a' :: w₁) w₂ a with dec a' a
Word-coef-++ (inr a' :: w₁) w₂ a | inl a'=a =
ap pred (Word-coef-++ w₁ w₂ a)
∙ ! (pred-+ (Word-coef w₁ a) (Word-coef w₂ a))
Word-coef-++ (inr a' :: w₁) w₂ a | inr a'≠a = Word-coef-++ w₁ w₂ a
Word-coef-flip : ∀ w a → Word-coef (Word-flip w) a == ℤ~ (Word-coef w a)
Word-coef-flip nil a = idp
Word-coef-flip (inl a' :: w) a with dec a' a
Word-coef-flip (inl a' :: w) a | inl a'=a =
ap pred (Word-coef-flip w a) ∙ ! (ℤ~-succ (Word-coef w a))
Word-coef-flip (inl a' :: w) a | inr a'≠a = Word-coef-flip w a
Word-coef-flip (inr a' :: w) a with dec a' a
Word-coef-flip (inr a' :: w) a | inl a'=a =
ap succ (Word-coef-flip w a) ∙ ! (ℤ~-pred (Word-coef w a))
Word-coef-flip (inr a' :: w) a | inr a'≠a = Word-coef-flip w a
private
abstract
FormalSum-coef-rel : {w₁ w₂ : Word A} → FormalSumRel w₁ w₂
→ ∀ a → Word-coef w₁ a == Word-coef w₂ a
FormalSum-coef-rel (fsr-refl p) a = ap (λ w → Word-coef w a) p
FormalSum-coef-rel (fsr-trans fwr₁ fwr₂) a = (FormalSum-coef-rel fwr₁ a) ∙ (FormalSum-coef-rel fwr₂ a)
FormalSum-coef-rel (fsr-sym fsr) a = ! $ FormalSum-coef-rel fsr a
FormalSum-coef-rel (fsr-cons x fwr) a =
Word-coef-++ (x :: nil) _ a
∙ ap (Word-coef (x :: nil) a ℤ+_) (FormalSum-coef-rel fwr a)
∙ ! (Word-coef-++ (x :: nil) _ a)
FormalSum-coef-rel (fsr-swap x y w) a =
Word-coef-++ (x :: y :: nil) _ a
∙ ap (_ℤ+ Word-coef w a)
( Word-coef-++ (x :: nil) (y :: nil) a
∙ ℤ+-comm (Word-coef (x :: nil) a) (Word-coef (y :: nil) a)
∙ ! (Word-coef-++ (y :: nil) (x :: nil) a))
∙ ! (Word-coef-++ (y :: x :: nil) _ a)
FormalSum-coef-rel (fsr-flip x w) a =
Word-coef-++ (x :: flip x :: nil) w a
∙ ap (_ℤ+ Word-coef w a)
( Word-coef-++ (x :: nil) (flip x :: nil) a
∙ ap (Word-coef (x :: nil) a ℤ+_) (Word-coef-flip (x :: nil) a)
∙ ℤ~-inv-r (Word-coef (x :: nil) a) )
∙ ℤ+-unit-l (Word-coef w a)
FormalSum-coef : FormalSum A → (A → ℤ)
FormalSum-coef = FormalSum-rec Word-coef (λ r → λ= $ FormalSum-coef-rel r)
-- Theorem : if coef w a == 0 then FormalSumRel w nil
private
abstract
Word-exp-succ : ∀ (a : A) z → FormalSumRel (inl a :: Word-exp a z) (Word-exp a (succ z))
Word-exp-succ a (pos _) = fsr-refl idp
Word-exp-succ a (negsucc 0) = fsr-flip (inl a) nil
Word-exp-succ a (negsucc (S n)) = fsr-flip (inl a) (Word-exp a (negsucc n))
Word-exp-pred : ∀ (a : A) z → FormalSumRel (inr a :: Word-exp a z) (Word-exp a (pred z))
Word-exp-pred a (pos 0) = fsr-refl idp
Word-exp-pred a (pos (S n)) = fsr-flip (inr a) (Word-exp a (pos n))
Word-exp-pred a (negsucc _) = fsr-refl idp
Word-coef-inl-eq : ∀ {a b} (p : b == a) w
→ Word-coef (inl b :: w) a == succ (Word-coef w a)
Word-coef-inl-eq {a} {b} p w with dec b a
Word-coef-inl-eq {a} {b} p w | inl _ = idp
Word-coef-inl-eq {a} {b} p w | inr ¬p = ⊥-rec (¬p p)
Word-coef-inr-eq : ∀ {a b} (p : b == a) w
→ Word-coef (inr b :: w) a == pred (Word-coef w a)
Word-coef-inr-eq {a} {b} p w with dec b a
Word-coef-inr-eq {a} {b} p w | inl _ = idp
Word-coef-inr-eq {a} {b} p w | inr ¬p = ⊥-rec (¬p p)
Word-coef-inl-neq : ∀ {a b} (p : b ≠ a) w
→ Word-coef (inl b :: w) a == Word-coef w a
Word-coef-inl-neq {a} {b} ¬p w with dec b a
Word-coef-inl-neq {a} {b} ¬p w | inl p = ⊥-rec (¬p p)
Word-coef-inl-neq {a} {b} ¬p w | inr _ = idp
Word-coef-inr-neq : ∀ {a b} (p : b ≠ a) w
→ Word-coef (inr b :: w) a == Word-coef w a
Word-coef-inr-neq {a} {b} ¬p w with dec b a
Word-coef-inr-neq {a} {b} ¬p w | inl p = ⊥-rec (¬p p)
Word-coef-inr-neq {a} {b} ¬p w | inr _ = idp
-- TODO maybe there is a better way to prove the final theorem?
-- Here we are collecting all elements [inl a] and [inr a], and recurse on the rest.
-- The [right-shorter] field makes sure that it is terminating.
record CollectSplitIH (a : A) {n : ℕ} (w : Word A) (len : length w == n) : Type i where
field
left-exponent : ℤ
left-captures-all : Word-coef w a == left-exponent
right-list : Word A
right-shorter : length right-list ≤ n
fsr : FormalSumRel w (Word-exp a left-exponent ++ right-list)
abstract
collect-split : ∀ a {n} w (len=n : length w == n) → CollectSplitIH a w len=n
collect-split a nil idp = record {
left-exponent = 0;
left-captures-all = idp;
right-list = nil;
right-shorter = inl idp;
fsr = fsr-refl idp}
collect-split a (inl b :: w) idp with dec b a
... | inl b=a = record {
left-exponent = succ left-exponent;
left-captures-all = Word-coef-inl-eq b=a w ∙ ap succ left-captures-all;
right-list = right-list;
right-shorter = ≤-trans right-shorter (inr ltS);
fsr = fsr-trans (fsr-refl (ap (λ a → inl a :: w) b=a)) $
fsr-trans (fsr-cons (inl a) fsr) $
(FormalSumRel-cong-++-l (Word-exp-succ a left-exponent) right-list)}
where open CollectSplitIH (collect-split a w idp)
... | inr b≠a = record {
left-exponent = left-exponent;
left-captures-all = Word-coef-inl-neq b≠a w ∙ left-captures-all;
right-list = inl b :: right-list;
right-shorter = ≤-ap-S right-shorter;
fsr = fsr-trans (fsr-cons (inl b) fsr) $
fsr-sym (FormalSumRel-swap1 (inl b) (Word-exp a left-exponent) right-list)}
where open CollectSplitIH (collect-split a w idp)
collect-split a (inr b :: w) idp with dec b a
... | inl b=a = record {
left-exponent = pred left-exponent;
left-captures-all = Word-coef-inr-eq b=a w ∙ ap pred left-captures-all;
right-list = right-list;
right-shorter = ≤-trans right-shorter (inr ltS);
fsr = fsr-trans (fsr-refl (ap (λ a → inr a :: w) b=a)) $
fsr-trans (fsr-cons (inr a) fsr) $
(FormalSumRel-cong-++-l (Word-exp-pred a left-exponent) right-list)}
where open CollectSplitIH (collect-split a w idp)
... | inr b≠a = record {
left-exponent = left-exponent;
left-captures-all = Word-coef-inr-neq b≠a w ∙ left-captures-all;
right-list = inr b :: right-list;
right-shorter = ≤-ap-S right-shorter;
fsr = fsr-trans (fsr-cons (inr b) fsr) $
fsr-sym (FormalSumRel-swap1 (inr b) (Word-exp a left-exponent) right-list)}
where open CollectSplitIH (collect-split a w idp)
-- We simulate strong induction by recursing on both [m] and [n≤m].
-- We could develop a general framework for strong induction but I am lazy. -Favonia
zero-coef-is-ident' : ∀ {m n} (n≤m : n ≤ m) (w : Word A) (len : length w == n)
→ (∀ a → Word-coef w a == 0) → FormalSumRel w nil
zero-coef-is-ident' (inr ltS) w len zero-coef
= zero-coef-is-ident' (inl idp) w len zero-coef
zero-coef-is-ident' (inr (ltSR lt)) w len zero-coef
= zero-coef-is-ident' (inr lt) w len zero-coef
zero-coef-is-ident' {m = O} (inl idp) nil _ _ = fsr-refl idp
zero-coef-is-ident' {m = O} (inl idp) (_ :: _) len _ = ⊥-rec $ ℕ-S≠O _ len
zero-coef-is-ident' {m = S m} (inl idp) nil len _ = ⊥-rec $ ℕ-S≠O _ (! len)
zero-coef-is-ident' {m = S m} (inl idp) (inl a :: w) len zero-coef =
fsr-trans whole-is-right (zero-coef-is-ident' right-shorter right-list idp right-zero-coef)
where
open CollectSplitIH (collect-split a w (ℕ-S-is-inj _ _ len))
left-exponent-is-minus-one : left-exponent == -1
left-exponent-is-minus-one = succ-is-inj left-exponent -1 $
ap succ (! left-captures-all) ∙ ! (Word-coef-inl-eq idp w) ∙ zero-coef a
whole-is-right : FormalSumRel (inl a :: w) right-list
whole-is-right =
fsr-trans (fsr-cons (inl a) fsr) $
fsr-trans (fsr-refl (ap (λ e → inl a :: Word-exp a e ++ right-list) left-exponent-is-minus-one)) $
fsr-flip (inl a) right-list
right-zero-coef : ∀ a' → Word-coef right-list a' == 0
right-zero-coef a' = ! (FormalSum-coef-rel whole-is-right a') ∙ zero-coef a'
zero-coef-is-ident' {m = S m} (inl idp) (inr a :: w) len zero-coef =
fsr-trans whole-is-right (zero-coef-is-ident' right-shorter right-list idp right-zero-coef)
where
open CollectSplitIH (collect-split a w (ℕ-S-is-inj _ _ len))
left-exponent-is-one : left-exponent == 1
left-exponent-is-one = pred-is-inj left-exponent 1 $
ap pred (! left-captures-all) ∙ ! (Word-coef-inr-eq idp w) ∙ zero-coef a
whole-is-right : FormalSumRel (inr a :: w) right-list
whole-is-right =
fsr-trans (fsr-cons (inr a) fsr) $
fsr-trans (fsr-refl (ap (λ e → inr a :: Word-exp a e ++ right-list) left-exponent-is-one)) $
fsr-flip (inr a) right-list
right-zero-coef : ∀ a' → Word-coef right-list a' == 0
right-zero-coef a' = ! (FormalSum-coef-rel whole-is-right a') ∙ zero-coef a'
zero-coef-is-ident : ∀ (w : Word A)
→ (∀ a → Word-coef w a == 0)
→ FormalSumRel w nil
zero-coef-is-ident w = zero-coef-is-ident' (inl idp) w idp
abstract
FormalSum-coef-ext' : ∀ w₁ w₂
→ (∀ a → Word-coef w₁ a == Word-coef w₂ a)
→ fs[ w₁ ] == fs[ w₂ ]
FormalSum-coef-ext' w₁ w₂ same-coef = G.inv-is-inj fs[ w₁ ] fs[ w₂ ] $
G.inv-unique-l (G.inv fs[ w₂ ]) fs[ w₁ ] $ quot-rel $
zero-coef-is-ident (Word-flip w₂ ++ w₁)
(λ a → Word-coef-++ (Word-flip w₂) w₁ a
∙ ap2 _ℤ+_ (Word-coef-flip w₂ a) (same-coef a)
∙ ℤ~-inv-l (Word-coef w₂ a))
where module G = FreeAbGroup A
FormalSum-coef-ext : ∀ fs₁ fs₂
→ (∀ a → FormalSum-coef fs₁ a == FormalSum-coef fs₂ a)
→ fs₁ == fs₂
FormalSum-coef-ext = FormalSum-elim
(λ w₁ → FormalSum-elim
(λ w₂ → FormalSum-coef-ext' w₁ w₂)
(λ _ → prop-has-all-paths-↓))
(λ _ → prop-has-all-paths-↓)
has-finite-support : (A → ℤ) → Type i
has-finite-support f = Σ (FormalSum A) λ fs → ∀ a → f a == FormalSum-coef fs a
module _ {i} {A : Type i} {dec : has-dec-eq A} where
abstract
has-finite-support-is-prop : ∀ f → is-prop (has-finite-support dec f)
has-finite-support-is-prop f = all-paths-is-prop
λ{(fs₁ , match₁) (fs₂ , match₂) → pair=
(FormalSum-coef-ext dec fs₁ fs₂ λ a → ! (match₁ a) ∙ match₂ a)
prop-has-all-paths-↓}
module _ where
private
abstract
Word-coef-exp-diag-pos : ∀ {I} (<I : Fin I) n →
Word-coef Fin-has-dec-eq (Word-exp <I (pos n)) <I == pos n
Word-coef-exp-diag-pos <I O = idp
Word-coef-exp-diag-pos <I (S n) with Fin-has-dec-eq <I <I
... | inl _ = ap succ (Word-coef-exp-diag-pos <I n)
... | inr ¬p = ⊥-rec (¬p idp)
Word-coef-exp-diag-negsucc : ∀ {I} (<I : Fin I) n →
Word-coef Fin-has-dec-eq (Word-exp <I (negsucc n)) <I == negsucc n
Word-coef-exp-diag-negsucc <I O with Fin-has-dec-eq <I <I
... | inl _ = idp
... | inr ¬p = ⊥-rec (¬p idp)
Word-coef-exp-diag-negsucc <I (S n) with Fin-has-dec-eq <I <I
... | inl _ = ap pred (Word-coef-exp-diag-negsucc <I n)
... | inr ¬p = ⊥-rec (¬p idp)
Word-coef-exp-diag : ∀ {I} (<I : Fin I) z →
Word-coef Fin-has-dec-eq (Word-exp <I z) <I == z
Word-coef-exp-diag <I (pos n) = Word-coef-exp-diag-pos <I n
Word-coef-exp-diag <I (negsucc n) = Word-coef-exp-diag-negsucc <I n
Word-coef-exp-≠-pos : ∀ {I} {<I <I' : Fin I} (_ : <I ≠ <I') n →
Word-coef Fin-has-dec-eq (Word-exp <I (pos n)) <I' == 0
Word-coef-exp-≠-pos _ O = idp
Word-coef-exp-≠-pos {<I = <I} {<I'} neq (S n) with Fin-has-dec-eq <I <I'
... | inl p = ⊥-rec (neq p)
... | inr ¬p = Word-coef-exp-≠-pos neq n
Word-coef-exp-≠-negsucc : ∀ {I} {<I <I' : Fin I} (_ : <I ≠ <I') n →
Word-coef Fin-has-dec-eq (Word-exp <I (negsucc n)) <I' == 0
Word-coef-exp-≠-negsucc {<I = <I} {<I'} neq O with Fin-has-dec-eq <I <I'
... | inl p = ⊥-rec (neq p)
... | inr ¬p = idp
Word-coef-exp-≠-negsucc {<I = <I} {<I'} neq (S n) with Fin-has-dec-eq <I <I'
... | inl p = ⊥-rec (neq p)
... | inr ¬p = Word-coef-exp-≠-negsucc neq n
Word-coef-exp-≠ : ∀ {I} {<I <I' : Fin I} (_ : <I ≠ <I') z →
Word-coef Fin-has-dec-eq (Word-exp <I z) <I' == 0
Word-coef-exp-≠ neq (pos n) = Word-coef-exp-≠-pos neq n
Word-coef-exp-≠ neq (negsucc n) = Word-coef-exp-≠-negsucc neq n
Word-sum' : ∀ (I : ℕ) {A : Type₀} (F : Fin I → A) (f : Fin I → ℤ) → Word A
Word-sum' 0 F f = nil
Word-sum' (S I) F f = Word-sum' I (F ∘ Fin-S) (f ∘ Fin-S) ++ Word-exp (F (I , ltS)) (f (I , ltS))
Word-sum : ∀ {I : ℕ} (f : Fin I → ℤ) → Word (Fin I)
Word-sum {I} f = Word-sum' I (idf (Fin I)) f
abstract
Word-coef-sum'-late : ∀ n m (I : ℕ) (f : Fin I → ℤ)
→ Word-coef Fin-has-dec-eq (Word-sum' I (Fin-S^' (S n) ∘ Fin-S^' m) f) (Fin-S^' n (ℕ-S^' m I , ltS)) == 0
Word-coef-sum'-late n m 0 f = idp
Word-coef-sum'-late n m (S I) f =
Word-coef Fin-has-dec-eq
(Word-sum' I (Fin-S^' (S n) ∘ Fin-S^' (S m)) (f ∘ Fin-S) ++ Word-exp (Fin-S^' (S n) (Fin-S^' m (I , ltS))) (f (I , ltS)))
(Fin-S^' n (ℕ-S^' (S m) I , ltS))
=⟨ Word-coef-++ Fin-has-dec-eq
(Word-sum' I (Fin-S^' (S n) ∘ Fin-S^' (S m)) (f ∘ Fin-S))
(Word-exp (Fin-S^' (S n) (Fin-S^' m (I , ltS))) (f (I , ltS)))
(Fin-S^' n (ℕ-S^' (S m) I , ltS)) ⟩
Word-coef Fin-has-dec-eq (Word-sum' I (Fin-S^' (S n) ∘ Fin-S^' (S m)) (f ∘ Fin-S)) (Fin-S^' n (ℕ-S^' (S m) I , ltS))
ℤ+
Word-coef Fin-has-dec-eq (Word-exp (Fin-S^' (S n) (Fin-S^' m (I , ltS))) (f (I , ltS))) (Fin-S^' n (ℕ-S^' (S m) I , ltS))
=⟨ ap2 _ℤ+_
(Word-coef-sum'-late n (S m) I (f ∘ Fin-S))
(Word-coef-exp-≠ (Fin-S^'-≠ n (ltSR≠ltS _)) (f (I , ltS))) ⟩
0
=∎
Word-coef-sum' : ∀ n {I} (f : Fin I → ℤ) <I
→ Word-coef Fin-has-dec-eq (Word-sum' I (Fin-S^' n) f) (Fin-S^' n <I) == f <I
Word-coef-sum' n f (I , ltS) =
Word-coef Fin-has-dec-eq
(Word-sum' I (Fin-S^' (S n)) (f ∘ Fin-S) ++ Word-exp (Fin-S^' n (I , ltS)) (f (I , ltS)))
(Fin-S^' n (I , ltS))
=⟨ Word-coef-++ Fin-has-dec-eq
(Word-sum' I (Fin-S^' (S n)) (f ∘ Fin-S))
(Word-exp (Fin-S^' n (I , ltS)) (f (I , ltS)))
(Fin-S^' n (I , ltS)) ⟩
Word-coef Fin-has-dec-eq (Word-sum' I (Fin-S^' (S n)) (f ∘ Fin-S)) (Fin-S^' n (I , ltS))
ℤ+
Word-coef Fin-has-dec-eq (Word-exp (Fin-S^' n (I , ltS)) (f (I , ltS))) (Fin-S^' n (I , ltS))
=⟨ ap2 _ℤ+_
(Word-coef-sum'-late n 0 I (f ∘ Fin-S))
(Word-coef-exp-diag (Fin-S^' n (I , ltS)) (f (I , ltS))) ⟩
f (I , ltS)
=∎
Word-coef-sum' n {I = S I} f (m , ltSR m<I) =
Word-coef Fin-has-dec-eq
(Word-sum' I (Fin-S^' (S n)) (f ∘ Fin-S) ++ Word-exp (Fin-S^' n (I , ltS)) (f (I , ltS)))
(Fin-S^' (S n) (m , m<I))
=⟨ Word-coef-++ Fin-has-dec-eq
(Word-sum' I (Fin-S^' (S n)) (f ∘ Fin-S))
(Word-exp (Fin-S^' n (I , ltS)) (f (I , ltS)))
(Fin-S^' (S n) (m , m<I)) ⟩
Word-coef Fin-has-dec-eq (Word-sum' I (Fin-S^' (S n)) (f ∘ Fin-S)) (Fin-S^' (S n) (m , m<I))
ℤ+
Word-coef Fin-has-dec-eq (Word-exp (Fin-S^' n (I , ltS)) (f (I , ltS))) (Fin-S^' (S n) (m , m<I))
=⟨ ap2 _ℤ+_
(Word-coef-sum' (S n) {I} (f ∘ Fin-S) (m , m<I))
(Word-coef-exp-≠ (Fin-S^'-≠ n (ltS≠ltSR (m , m<I))) (f (I , ltS))) ⟩
f (m , ltSR m<I) ℤ+ 0
=⟨ ℤ+-unit-r _ ⟩
f (m , ltSR m<I)
=∎
FormalSum-sum' : ∀ n (I : ℕ) (f : Fin I → ℤ) → FormalSum (Fin (ℕ-S^' n I))
FormalSum-sum' n I f =
Group.sum (FreeAbGroup.grp (Fin (ℕ-S^' n I)))
(λ <I → Group.exp (FreeAbGroup.grp (Fin (ℕ-S^' n I))) fs[ inl (Fin-S^' n <I) :: nil ] (f <I))
FormalSum-sum : ∀ {I : ℕ} (f : Fin I → ℤ) → FormalSum (Fin I)
FormalSum-sum {I} = FormalSum-sum' 0 I
private
abstract
FormalSum-sum'-β : ∀ n (I : ℕ) (f : Fin I → ℤ)
→ FormalSum-sum' n I f == fs[ Word-sum' I (Fin-S^' n) f ]
FormalSum-sum'-β n O f = idp
FormalSum-sum'-β n (S I) f =
ap2 (Group.comp (FreeAbGroup.grp (Fin (ℕ-S^' (S n) I))))
(FormalSum-sum'-β (S n) I (f ∘ Fin-S))
(! (FormalSumRel-pres-exp (Fin-S^' n (I , ltS)) (f (I , ltS))))
Fin→-has-finite-support : ∀ {I} (f : Fin I → ℤ) → has-finite-support Fin-has-dec-eq f
Fin→-has-finite-support {I} f = FormalSum-sum f , lemma
where abstract lemma = λ <I → ! (ap (λ fs → FormalSum-coef Fin-has-dec-eq fs <I) (FormalSum-sum'-β 0 I f) ∙ Word-coef-sum' 0 f <I)
|
Cubical/Data/Sigma/Properties.agda | cmester0/cubical | 1 | 15265 | <filename>Cubical/Data/Sigma/Properties.agda
{-
Basic properties about Σ-types
- Characterization of equality in Σ-types using transport ([pathSigma≡sigmaPath])
-}
{-# OPTIONS --cubical --safe #-}
module Cubical.Data.Sigma.Properties where
open import Cubical.Data.Sigma.Base
open import Cubical.Core.Everything
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Equiv.HalfAdjoint
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Foundations.Path
open import Cubical.Foundations.Transport
open import Cubical.Foundations.Univalence
open import Cubical.Relation.Nullary
open import Cubical.Relation.Nullary.DecidableEq
open import Cubical.Data.Unit.Base
private
variable
ℓ : Level
A A' : Type ℓ
B B' : (a : A) → Type ℓ
C : (a : A) (b : B a) → Type ℓ
mapʳ : (∀ {a} → B a → B' a) → Σ A B → Σ A B'
mapʳ f (a , b) = (a , f b)
mapˡ : {B : Type ℓ} → (f : A → A') → Σ A (λ _ → B) → Σ A' (λ _ → B)
mapˡ f (a , b) = (f a , b)
ΣPathP : ∀ {x y}
→ Σ (fst x ≡ fst y) (λ a≡ → PathP (λ i → B (a≡ i)) (snd x) (snd y))
→ x ≡ y
ΣPathP eq i = fst eq i , snd eq i
Σ-split-iso : {x y : Σ A B}
→ Iso (Σ[ q ∈ fst x ≡ fst y ] (PathP (λ i → B (q i)) (snd x) (snd y)))
(x ≡ y)
Iso.fun (Σ-split-iso) = ΣPathP
Iso.inv (Σ-split-iso) eq = (λ i → fst (eq i)) , (λ i → snd (eq i))
Iso.rightInv (Σ-split-iso) x = refl {x = x}
Iso.leftInv (Σ-split-iso) x = refl {x = x}
Σ≃ : {x y : Σ A B} →
Σ (fst x ≡ fst y) (λ p → PathP (λ i → B (p i)) (snd x) (snd y)) ≃
(x ≡ y)
Σ≃ {A = A} {B = B} {x} {y} = isoToEquiv (Σ-split-iso)
Σ≡ : {a a' : A} {b : B a} {b' : B a'} → (Σ (a ≡ a') (λ q → PathP (λ i → B (q i)) b b')) ≡ ((a , b) ≡ (a' , b'))
Σ≡ = isoToPath Σ-split-iso -- ua Σ≃
ΣProp≡ : ((x : A) → isProp (B x)) → {u v : Σ A B}
→ (p : u .fst ≡ v .fst) → u ≡ v
ΣProp≡ pB {u} {v} p i = (p i) , isProp→PathP (λ i → pB (p i)) (u .snd) (v .snd) i
-- Alternative version for path in Σ-types, as in the HoTT book
sigmaPathTransport : (a b : Σ A B) → Type _
sigmaPathTransport {B = B} a b =
Σ (fst a ≡ fst b) (λ p → transport (λ i → B (p i)) (snd a) ≡ snd b)
_Σ≡T_ : (a b : Σ A B) → Type _
a Σ≡T b = sigmaPathTransport a b
-- now we prove that the alternative path space a Σ≡ b is equal to the usual path space a ≡ b
-- forward direction
private
pathSigma-π1 : {a b : Σ A B} → a ≡ b → fst a ≡ fst b
pathSigma-π1 p i = fst (p i)
filler-π2 : {a b : Σ A B} → (p : a ≡ b) → I → (i : I) → B (fst (p i))
filler-π2 {B = B} {a = a} p i =
fill (λ i → B (fst (p i)))
(λ t → λ { (i = i0) → transport-filler (λ j → B (fst (p j))) (snd a) t
; (i = i1) → snd (p t) })
(inS (snd a))
pathSigma-π2 : {a b : Σ A B} → (p : a ≡ b) →
subst B (pathSigma-π1 p) (snd a) ≡ snd b
pathSigma-π2 p i = filler-π2 p i i1
pathSigma→sigmaPath : (a b : Σ A B) → a ≡ b → a Σ≡T b
pathSigma→sigmaPath _ _ p = (pathSigma-π1 p , pathSigma-π2 p)
-- backward direction
private
filler-comp : (a b : Σ A B) → a Σ≡T b → I → I → Σ A B
filler-comp {B = B} a b (p , q) i =
hfill (λ t → λ { (i = i0) → a
; (i = i1) → (p i1 , q t) })
(inS (p i , transport-filler (λ j → B (p j)) (snd a) i))
sigmaPath→pathSigma : (a b : Σ A B) → a Σ≡T b → (a ≡ b)
sigmaPath→pathSigma a b x i = filler-comp a b x i i1
-- first homotopy
private
homotopy-π1 : (a b : Σ A B) →
∀ (x : a Σ≡T b) → pathSigma-π1 (sigmaPath→pathSigma a b x) ≡ fst x
homotopy-π1 a b x i j = fst (filler-comp a b x j (~ i))
homotopy-π2 : (a b : Σ A B) → (p : a Σ≡T b) → (i : I) →
(transport (λ j → B (fst (filler-comp a b p j i))) (snd a) ≡ snd b)
homotopy-π2 {B = B} a b p i j =
comp (λ t → B (fst (filler-comp a b p t (i ∨ j))))
(λ t → λ { (j = i0) → transport-filler (λ t → B (fst (filler-comp a b p t i)))
(snd a) t
; (j = i1) → snd (sigmaPath→pathSigma a b p t)
; (i = i0) → snd (filler-comp a b p t j)
; (i = i1) → filler-π2 (sigmaPath→pathSigma a b p) j t })
(snd a)
pathSigma→sigmaPath→pathSigma : {a b : Σ A B} →
∀ (x : a Σ≡T b) → pathSigma→sigmaPath _ _ (sigmaPath→pathSigma a b x) ≡ x
pathSigma→sigmaPath→pathSigma {a = a} p i =
(homotopy-π1 a _ p i , homotopy-π2 a _ p (~ i))
-- second homotopy
sigmaPath→pathSigma→sigmaPath : {a b : Σ A B} →
∀ (x : a ≡ b) → sigmaPath→pathSigma a b (pathSigma→sigmaPath _ _ x) ≡ x
sigmaPath→pathSigma→sigmaPath {B = B} {a = a} {b = b} p i j =
hcomp (λ t → λ { (i = i1) → (fst (p j) , filler-π2 p t j)
; (i = i0) → filler-comp a b (pathSigma→sigmaPath _ _ p) j t
; (j = i0) → (fst a , snd a)
; (j = i1) → (fst b , filler-π2 p t i1) })
(fst (p j) , transport-filler (λ k → B (fst (p k))) (snd a) j)
pathSigma≡sigmaPath : (a b : Σ A B) → (a ≡ b) ≡ (a Σ≡T b)
pathSigma≡sigmaPath a b =
isoToPath (iso (pathSigma→sigmaPath a b)
(sigmaPath→pathSigma a b)
(pathSigma→sigmaPath→pathSigma {a = a})
sigmaPath→pathSigma→sigmaPath)
discreteΣ : Discrete A → ((a : A) → Discrete (B a)) → Discrete (Σ A B)
discreteΣ {B = B} Adis Bdis (a0 , b0) (a1 , b1) = discreteΣ' (Adis a0 a1)
where
discreteΣ' : Dec (a0 ≡ a1) → Dec ((a0 , b0) ≡ (a1 , b1))
discreteΣ' (yes p) = J (λ a1 p → ∀ b1 → Dec ((a0 , b0) ≡ (a1 , b1))) (discreteΣ'') p b1
where
discreteΣ'' : (b1 : B a0) → Dec ((a0 , b0) ≡ (a0 , b1))
discreteΣ'' b1 with Bdis a0 b0 b1
... | (yes q) = yes (transport (ua Σ≃) (refl , q))
... | (no ¬q) = no (λ r → ¬q (subst (λ X → PathP (λ i → B (X i)) b0 b1) (Discrete→isSet Adis a0 a0 (cong fst r) refl) (cong snd r)))
discreteΣ' (no ¬p) = no (λ r → ¬p (cong fst r))
Σ-contractFst : ∀ {ℓ ℓ'} {A : Type ℓ} {B : A → Type ℓ'} (c : isContr A)
→ Σ A B ≃ B (c .fst)
Σ-contractFst {B = B} c =
isoToEquiv
(iso
(λ {(a , b) → subst B (sym (c .snd a)) b})
(c .fst ,_)
(λ b →
cong (λ p → subst B p b) (isProp→isSet (isContr→isProp c) _ _ _ _)
∙ transportRefl _)
(λ {(a , b) →
sigmaPath→pathSigma _ _ (c .snd a , transportTransport⁻ (cong B (c .snd a)) _)}))
-- a special case of the above
ΣUnit : ∀ {ℓ} (A : Unit → Type ℓ) → Σ Unit A ≃ A tt
ΣUnit A = isoToEquiv (iso snd (λ { x → (tt , x) }) (λ _ → refl) (λ _ → refl))
assocΣ : (Σ[ (a , b) ∈ Σ A B ] C a b) ≃ (Σ[ a ∈ A ] Σ[ b ∈ B a ] C a b)
assocΣ = isoToEquiv (iso (λ { ((x , y) , z) → (x , (y , z)) })
(λ { (x , (y , z)) → ((x , y) , z) })
(λ _ → refl) (λ _ → refl))
congΣEquiv : (∀ a → B a ≃ B' a) → Σ A B ≃ Σ A B'
congΣEquiv h =
isoToEquiv (iso (λ { (x , y) → (x , equivFun (h x) y) })
(λ { (x , y) → (x , invEq (h x) y) })
(λ { (x , y) i → (x , retEq (h x) y i) })
(λ { (x , y) i → (x , secEq (h x) y i) }))
PiΣ : ((a : A) → Σ[ b ∈ B a ] C a b) ≃ (Σ[ f ∈ ((a : A) → B a) ] ∀ a → C a (f a))
PiΣ = isoToEquiv (iso (λ f → fst ∘ f , snd ∘ f)
(λ (f , g) → (λ x → f x , g x))
(λ _ → refl) (λ _ → refl))
swapΣEquiv : ∀ {ℓ'} (A : Type ℓ) (B : Type ℓ') → A × B ≃ B × A
swapΣEquiv A B = isoToEquiv (iso (λ x → x .snd , x .fst) (λ z → z .snd , z .fst) (\ _ → refl) (\ _ → refl))
Σ-ap-iso₁ : ∀ {ℓ} {ℓ'} {A A' : Type ℓ} {B : A' → Type ℓ'}
→ (isom : Iso A A')
→ Iso (Σ A (B ∘ (Iso.fun isom)))
(Σ A' B)
Iso.fun (Σ-ap-iso₁ isom) x = (Iso.fun isom) (x .fst) , x .snd
Iso.inv (Σ-ap-iso₁ {B = B} isom) x = (Iso.inv isom) (x .fst) , subst B (sym (ε' (x .fst))) (x .snd)
where
ε' = fst (vogt isom)
Iso.rightInv (Σ-ap-iso₁ {B = B} isom) (x , y) = ΣPathP (ε' x ,
transport
(sym (PathP≡Path (λ j → cong B (ε' x) j) (subst B (sym (ε' x)) y) y))
(subst B (ε' x) (subst B (sym (ε' x)) y)
≡⟨ sym (substComposite B (sym (ε' x)) (ε' x) y) ⟩
subst B ((sym (ε' x)) ∙ (ε' x)) y
≡⟨ (cong (λ a → subst B a y) (lCancel (ε' x))) ⟩
subst B refl y
≡⟨ substRefl {B = B} y ⟩
y ∎))
where
ε' = fst (vogt isom)
Iso.leftInv (Σ-ap-iso₁ {A = A} {B = B} isom@(iso f g ε η)) (x , y) = ΣPathP (η x ,
transport
(sym (PathP≡Path (λ j → cong B (cong f (η x)) j) (subst B (sym (ε' (f x))) y) y))
(subst B (cong f (η x)) (subst B (sym (ε' (f x))) y)
≡⟨ sym (substComposite B (sym (ε' (f x))) (cong f (η x)) y) ⟩
subst B (sym (ε' (f x)) ∙ (cong f (η x))) y
≡⟨ cong (λ a → subst B a y) (lem x) ⟩
subst B (refl) y
≡⟨ substRefl {B = B} y ⟩
y ∎))
where
ε' = fst (vogt isom)
γ = snd (vogt isom)
lem : (x : A) → sym (ε' (f x)) ∙ cong f (η x) ≡ refl
lem x = cong (λ a → sym (ε' (f x)) ∙ a) (γ x) ∙ lCancel (ε' (f x))
Σ-ap₁ : (isom : A ≡ A') → Σ A (B ∘ transport isom) ≡ Σ A' B
Σ-ap₁ isom = isoToPath (Σ-ap-iso₁ (pathToIso isom))
Σ-ap-iso₂ : ((x : A) → Iso (B x) (B' x)) → Iso (Σ A B) (Σ A B')
Iso.fun (Σ-ap-iso₂ isom) (x , y) = x , Iso.fun (isom x) y
Iso.inv (Σ-ap-iso₂ isom) (x , y') = x , Iso.inv (isom x) y'
Iso.rightInv (Σ-ap-iso₂ isom) (x , y) = ΣPathP (refl , Iso.rightInv (isom x) y)
Iso.leftInv (Σ-ap-iso₂ isom) (x , y') = ΣPathP (refl , Iso.leftInv (isom x) y')
Σ-ap₂ : ((x : A) → B x ≡ B' x) → Σ A B ≡ Σ A B'
Σ-ap₂ isom = isoToPath (Σ-ap-iso₂ (pathToIso ∘ isom))
Σ-ap-iso :
∀ {ℓ ℓ'} {A A' : Type ℓ}
→ {B : A → Type ℓ'} {B' : A' → Type ℓ'}
→ (isom : Iso A A')
→ ((x : A) → Iso (B x) (B' (Iso.fun isom x)))
------------------------
→ Iso (Σ A B) (Σ A' B')
Σ-ap-iso isom isom' = compIso (Σ-ap-iso₂ isom') (Σ-ap-iso₁ isom)
Σ-ap :
∀ {ℓ ℓ'} {X X' : Type ℓ} {Y : X → Type ℓ'} {Y' : X' → Type ℓ'}
→ (isom : X ≡ X')
→ ((x : X) → Y x ≡ Y' (transport isom x))
----------
→ (Σ X Y)
≡ (Σ X' Y')
Σ-ap isom isom' = isoToPath (Σ-ap-iso (pathToIso isom) (pathToIso ∘ isom'))
Σ-ap' :
∀ {ℓ ℓ'} {X X' : Type ℓ} {Y : X → Type ℓ'} {Y' : X' → Type ℓ'}
→ (isom : X ≡ X')
→ (PathP (λ i → isom i → Type ℓ') Y Y')
----------
→ (Σ X Y)
≡ (Σ X' Y')
Σ-ap' {ℓ} {ℓ'} isom isom' = cong₂ (λ (a : Type ℓ) (b : a → Type ℓ') → Σ a λ x → b x) isom isom'
|
projects/batfish/src/main/antlr4/org/batfish/grammar/cumulus_nclu/CumulusNclu_stp.g4 | zabrewer/batfish | 763 | 945 | parser grammar CumulusNclu_stp;
import CumulusNclu_common;
options {
tokenVocab = CumulusNcluLexer;
}
// Spanning tree options that apply to interfaces and bonds
stp_common
:
STP
(
stp_bpduguard
| stp_portadminedge
| stp_portautoedge
| stp_portbpdufilter
| stp_portnetwork
| stp_portrestrrole
)
;
stp_bpduguard
:
BPDUGUARD NEWLINE
;
stp_portadminedge
:
PORTADMINEDGE NEWLINE
;
stp_portautoedge
:
PORTAUTOEDGE NO NEWLINE
;
stp_portbpdufilter
:
PORTBPDUFILTER NEWLINE
;
stp_portnetwork
:
PORTNETWORK NEWLINE
;
stp_portrestrrole
:
PORTRESTROLE NEWLINE
;
|
Transynther/x86/_processed/NONE/_xt_sm_/i7-7700_9_0x48.log_21829_1732.asm | ljhsiun2/medusa | 9 | 89864 | <filename>Transynther/x86/_processed/NONE/_xt_sm_/i7-7700_9_0x48.log_21829_1732.asm
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r12
push %r13
push %rbp
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_UC_ht+0x168a0, %rsi
lea addresses_A_ht+0x8940, %rdi
nop
nop
nop
nop
cmp $35805, %rbp
mov $17, %rcx
rep movsb
nop
nop
xor $32945, %rdi
lea addresses_D_ht+0xd60, %r13
add %rbx, %rbx
movl $0x61626364, (%r13)
nop
nop
nop
nop
sub %rbx, %rbx
lea addresses_D_ht+0xf4a0, %rsi
lea addresses_normal_ht+0x10040, %rdi
nop
nop
nop
nop
sub %r12, %r12
mov $59, %rcx
rep movsl
nop
sub %r12, %r12
lea addresses_D_ht+0xa660, %rdi
nop
nop
nop
nop
nop
sub %rbx, %rbx
mov (%rdi), %r13d
xor %rsi, %rsi
lea addresses_D_ht+0x1cec0, %rsi
lea addresses_A_ht+0x90a0, %rdi
nop
nop
nop
nop
nop
xor $6872, %r11
mov $113, %rcx
rep movsb
cmp %r13, %r13
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %r13
pop %r12
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r13
push %r14
push %r15
push %rdx
push %rsi
// Store
lea addresses_US+0x17ca0, %r13
nop
nop
nop
nop
and %r11, %r11
mov $0x5152535455565758, %r15
movq %r15, %xmm5
movups %xmm5, (%r13)
nop
nop
nop
nop
sub $45784, %rsi
// Store
lea addresses_A+0x1b1a0, %r13
nop
nop
add %r10, %r10
mov $0x5152535455565758, %rdx
movq %rdx, %xmm5
movups %xmm5, (%r13)
xor %r13, %r13
// Store
lea addresses_normal+0x134a0, %r15
nop
nop
nop
nop
nop
sub %r13, %r13
mov $0x5152535455565758, %r11
movq %r11, (%r15)
nop
xor $21890, %r14
// Store
mov $0xa3c, %r11
nop
nop
xor %rsi, %rsi
movl $0x51525354, (%r11)
// Exception!!!
nop
nop
mov (0), %r11
and $48537, %r14
// Store
lea addresses_D+0x1bde4, %r10
sub $38162, %r15
movw $0x5152, (%r10)
nop
nop
sub %rsi, %rsi
// Store
mov $0x6c444400000006e0, %r14
nop
cmp $5570, %rsi
mov $0x5152535455565758, %rdx
movq %rdx, (%r14)
nop
nop
nop
nop
cmp %rdx, %rdx
// Faulty Load
lea addresses_normal+0x134a0, %r13
nop
dec %r15
mov (%r13), %si
lea oracles, %r15
and $0xff, %rsi
shlq $12, %rsi
mov (%r15,%rsi,1), %rsi
pop %rsi
pop %rdx
pop %r15
pop %r14
pop %r13
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'AVXalign': False, 'congruent': 0, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_US', 'AVXalign': False, 'congruent': 11, 'size': 16, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A', 'AVXalign': False, 'congruent': 7, 'size': 16, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal', 'AVXalign': False, 'congruent': 0, 'size': 8, 'same': True, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_P', 'AVXalign': False, 'congruent': 2, 'size': 4, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D', 'AVXalign': False, 'congruent': 2, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_NC', 'AVXalign': False, 'congruent': 5, 'size': 8, 'same': False, 'NT': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'AVXalign': False, 'congruent': 0, 'size': 2, 'same': True, 'NT': False}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 5, 'same': True}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 5, 'size': 4, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 5, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 5, 'size': 4, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 10, 'same': False}}
{'58': 21829}
58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58
*/
|
sway-core/tests/ir_to_asm/strings_in_storage.asm | FuelLabs/sway | 75 | 168655 | .program:
ji i4
noop
DATA_SECTION_OFFSET[0..32]
DATA_SECTION_OFFSET[32..64]
lw $ds $is 1
add $$ds $$ds $is
lw $r1 $fp i73 ; load input function selector
lw $r0 data_3 ; load fn selector for comparison
eq $r0 $r1 $r0 ; function selector comparison
jnzi $r0 i14 ; jump to selected function
lw $r0 data_4 ; load fn selector for comparison
eq $r0 $r1 $r0 ; function selector comparison
jnzi $r0 i39 ; jump to selected function
rvrt $zero ; revert if no selectors matched
move $r3 $sp ; save locals base register
cfei i96 ; allocate 96 bytes for all locals
lw $r2 $fp i74 ; Base register for method parameter
addi $r0 $r3 i0 ; get offset reg for get_ptr
lw $r1 data_0 ; literal instantiation
addi $r0 $r3 i0 ; get store offset
mcpi $r0 $r1 i32 ; store value
addi $r0 $r3 i32 ; get offset reg for get_ptr
addi $r0 $r3 i32 ; get store offset
mcpi $r0 $r2 i64 ; store value
addi $r0 $r3 i32 ; get offset reg for get_ptr
addi $r1 $r3 i32 ; get offset
addi $r0 $r3 i0 ; get offset
swwq $r0 $r1 ; quad word state access
addi $r0 $r3 i0 ; get offset reg for get_ptr
lw $r1 data_1 ; literal instantiation
addi $r0 $r3 i0 ; get store offset
mcpi $r0 $r1 i32 ; store value
addi $r0 $r3 i64 ; get offset reg for get_ptr
addi $r1 $r3 i64 ; get offset
addi $r0 $r3 i0 ; get offset
swwq $r0 $r1 ; quad word state access
ret $zero ; returning unit as zero
move $r3 $sp ; save locals base register
cfei i96 ; allocate 96 bytes for all locals
addi $r0 $r3 i0 ; get offset reg for get_ptr
lw $r1 data_0 ; literal instantiation
addi $r0 $r3 i0 ; get store offset
mcpi $r0 $r1 i32 ; store value
addi $r2 $r3 i32 ; get offset reg for get_ptr
addi $r0 $r3 i32 ; get offset reg for get_ptr
addi $r1 $r3 i32 ; get offset
addi $r0 $r3 i0 ; get offset
srwq $r1 $r0 ; quad word state access
addi $r0 $r3 i0 ; get offset reg for get_ptr
lw $r1 data_1 ; literal instantiation
addi $r0 $r3 i0 ; get store offset
mcpi $r0 $r1 i32 ; store value
addi $r0 $r3 i64 ; get offset reg for get_ptr
addi $r1 $r3 i64 ; get offset
addi $r0 $r3 i0 ; get offset
srwq $r1 $r0 ; quad word state access
lw $r0 data_2 ; loading size for RETD
retd $r2 $r0
noop ; word-alignment of data section
.data:
data_0 .b256 0xf383b0ce51358be57daa3b725fe44acdb2d880604e367199080b4379c41bb6ed
data_1 .b256 0xf383b0ce51358be57daa3b725fe44acdb2d880604e367199080b4379c41bb6ee
data_2 .u64 0x28
data_3 .u32 0xe63a9733
data_4 .u32 0xb8c27db9
|
gcc-gcc-7_3_0-release/gcc/ada/g-alleve.adb | best08618/asylo | 7 | 6998 | <filename>gcc-gcc-7_3_0-release/gcc/ada/g-alleve.adb<gh_stars>1-10
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- G N A T . A L T I V E C . L O W _ L E V E L _ V E C T O R S --
-- --
-- B o d y --
-- (Soft Binding Version) --
-- --
-- Copyright (C) 2004-2015, 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. --
-- --
------------------------------------------------------------------------------
-- ??? What is exactly needed for the soft case is still a bit unclear on
-- some accounts. The expected functional equivalence with the Hard binding
-- might require tricky things to be done on some targets.
-- Examples that come to mind are endianness variations or differences in the
-- base FP model while we need the operation results to be the same as what
-- the real AltiVec instructions would do on a PowerPC.
with Ada.Numerics.Generic_Elementary_Functions;
with Interfaces; use Interfaces;
with System.Storage_Elements; use System.Storage_Elements;
with GNAT.Altivec.Conversions; use GNAT.Altivec.Conversions;
with GNAT.Altivec.Low_Level_Interface; use GNAT.Altivec.Low_Level_Interface;
package body GNAT.Altivec.Low_Level_Vectors is
-- Pixel types. As defined in [PIM-2.1 Data types]:
-- A 16-bit pixel is 1/5/5/5;
-- A 32-bit pixel is 8/8/8/8.
-- We use the following records as an intermediate representation, to
-- ease computation.
type Unsigned_1 is mod 2 ** 1;
type Unsigned_5 is mod 2 ** 5;
type Pixel_16 is record
T : Unsigned_1;
R : Unsigned_5;
G : Unsigned_5;
B : Unsigned_5;
end record;
type Pixel_32 is record
T : unsigned_char;
R : unsigned_char;
G : unsigned_char;
B : unsigned_char;
end record;
-- Conversions to/from the pixel records to the integer types that are
-- actually stored into the pixel vectors:
function To_Pixel (Source : unsigned_short) return Pixel_16;
function To_unsigned_short (Source : Pixel_16) return unsigned_short;
function To_Pixel (Source : unsigned_int) return Pixel_32;
function To_unsigned_int (Source : Pixel_32) return unsigned_int;
package C_float_Operations is
new Ada.Numerics.Generic_Elementary_Functions (C_float);
-- Model of the Vector Status and Control Register (VSCR), as
-- defined in [PIM-4.1 Vector Status and Control Register]:
VSCR : unsigned_int;
-- Positions of the flags in VSCR(0 .. 31):
NJ_POS : constant := 15;
SAT_POS : constant := 31;
-- To control overflows, integer operations are done on 64-bit types:
SINT64_MIN : constant := -2 ** 63;
SINT64_MAX : constant := 2 ** 63 - 1;
UINT64_MAX : constant := 2 ** 64 - 1;
type SI64 is range SINT64_MIN .. SINT64_MAX;
type UI64 is mod UINT64_MAX + 1;
type F64 is digits 15
range -16#0.FFFF_FFFF_FFFF_F8#E+256 .. 16#0.FFFF_FFFF_FFFF_F8#E+256;
function Bits
(X : unsigned_int;
Low : Natural;
High : Natural) return unsigned_int;
function Bits
(X : unsigned_short;
Low : Natural;
High : Natural) return unsigned_short;
function Bits
(X : unsigned_char;
Low : Natural;
High : Natural) return unsigned_char;
function Write_Bit
(X : unsigned_int;
Where : Natural;
Value : Unsigned_1) return unsigned_int;
function Write_Bit
(X : unsigned_short;
Where : Natural;
Value : Unsigned_1) return unsigned_short;
function Write_Bit
(X : unsigned_char;
Where : Natural;
Value : Unsigned_1) return unsigned_char;
function NJ_Truncate (X : C_float) return C_float;
-- If NJ and A is a denormalized number, return zero
function Bound_Align
(X : Integer_Address;
Y : Integer_Address) return Integer_Address;
-- [PIM-4.3 Notations and Conventions]
-- Align X in a y-byte boundary and return the result
function Rnd_To_FP_Nearest (X : F64) return C_float;
-- [PIM-4.3 Notations and Conventions]
function Rnd_To_FPI_Near (X : F64) return F64;
function Rnd_To_FPI_Trunc (X : F64) return F64;
function FP_Recip_Est (X : C_float) return C_float;
-- [PIM-4.3 Notations and Conventions]
-- 12-bit accurate floating-point estimate of 1/x
function ROTL
(Value : unsigned_char;
Amount : Natural) return unsigned_char;
-- [PIM-4.3 Notations and Conventions]
-- Rotate left
function ROTL
(Value : unsigned_short;
Amount : Natural) return unsigned_short;
function ROTL
(Value : unsigned_int;
Amount : Natural) return unsigned_int;
function Recip_SQRT_Est (X : C_float) return C_float;
function Shift_Left
(Value : unsigned_char;
Amount : Natural) return unsigned_char;
-- [PIM-4.3 Notations and Conventions]
-- Shift left
function Shift_Left
(Value : unsigned_short;
Amount : Natural) return unsigned_short;
function Shift_Left
(Value : unsigned_int;
Amount : Natural) return unsigned_int;
function Shift_Right
(Value : unsigned_char;
Amount : Natural) return unsigned_char;
-- [PIM-4.3 Notations and Conventions]
-- Shift Right
function Shift_Right
(Value : unsigned_short;
Amount : Natural) return unsigned_short;
function Shift_Right
(Value : unsigned_int;
Amount : Natural) return unsigned_int;
Signed_Bool_False : constant := 0;
Signed_Bool_True : constant := -1;
------------------------------
-- Signed_Operations (spec) --
------------------------------
generic
type Component_Type is range <>;
type Index_Type is range <>;
type Varray_Type is array (Index_Type) of Component_Type;
package Signed_Operations is
function Modular_Result (X : SI64) return Component_Type;
function Saturate (X : SI64) return Component_Type;
function Saturate (X : F64) return Component_Type;
function Sign_Extend (X : c_int) return Component_Type;
-- [PIM-4.3 Notations and Conventions]
-- Sign-extend X
function abs_vxi (A : Varray_Type) return Varray_Type;
pragma Convention (LL_Altivec, abs_vxi);
function abss_vxi (A : Varray_Type) return Varray_Type;
pragma Convention (LL_Altivec, abss_vxi);
function vaddsxs (A : Varray_Type; B : Varray_Type) return Varray_Type;
pragma Convention (LL_Altivec, vaddsxs);
function vavgsx (A : Varray_Type; B : Varray_Type) return Varray_Type;
pragma Convention (LL_Altivec, vavgsx);
function vcmpgtsx (A : Varray_Type; B : Varray_Type) return Varray_Type;
pragma Convention (LL_Altivec, vcmpgtsx);
function lvexx (A : c_long; B : c_ptr) return Varray_Type;
pragma Convention (LL_Altivec, lvexx);
function vmaxsx (A : Varray_Type; B : Varray_Type) return Varray_Type;
pragma Convention (LL_Altivec, vmaxsx);
function vmrghx (A : Varray_Type; B : Varray_Type) return Varray_Type;
pragma Convention (LL_Altivec, vmrghx);
function vmrglx (A : Varray_Type; B : Varray_Type) return Varray_Type;
pragma Convention (LL_Altivec, vmrglx);
function vminsx (A : Varray_Type; B : Varray_Type) return Varray_Type;
pragma Convention (LL_Altivec, vminsx);
function vspltx (A : Varray_Type; B : c_int) return Varray_Type;
pragma Convention (LL_Altivec, vspltx);
function vspltisx (A : c_int) return Varray_Type;
pragma Convention (LL_Altivec, vspltisx);
type Bit_Operation is
access function
(Value : Component_Type;
Amount : Natural) return Component_Type;
function vsrax
(A : Varray_Type;
B : Varray_Type;
Shift_Func : Bit_Operation) return Varray_Type;
procedure stvexx (A : Varray_Type; B : c_int; C : c_ptr);
pragma Convention (LL_Altivec, stvexx);
function vsubsxs (A : Varray_Type; B : Varray_Type) return Varray_Type;
pragma Convention (LL_Altivec, vsubsxs);
function Check_CR6 (A : c_int; D : Varray_Type) return c_int;
-- If D is the result of a vcmp operation and A the flag for
-- the kind of operation (e.g CR6_LT), check the predicate
-- that corresponds to this flag.
end Signed_Operations;
------------------------------
-- Signed_Operations (body) --
------------------------------
package body Signed_Operations is
Bool_True : constant Component_Type := Signed_Bool_True;
Bool_False : constant Component_Type := Signed_Bool_False;
Number_Of_Elements : constant Integer :=
VECTOR_BIT / Component_Type'Size;
--------------------
-- Modular_Result --
--------------------
function Modular_Result (X : SI64) return Component_Type is
D : Component_Type;
begin
if X > 0 then
D := Component_Type (UI64 (X)
mod (UI64 (Component_Type'Last) + 1));
else
D := Component_Type ((-(UI64 (-X)
mod (UI64 (Component_Type'Last) + 1))));
end if;
return D;
end Modular_Result;
--------------
-- Saturate --
--------------
function Saturate (X : SI64) return Component_Type is
D : Component_Type;
begin
-- Saturation, as defined in
-- [PIM-4.1 Vector Status and Control Register]
D := Component_Type (SI64'Max
(SI64 (Component_Type'First),
SI64'Min
(SI64 (Component_Type'Last),
X)));
if SI64 (D) /= X then
VSCR := Write_Bit (VSCR, SAT_POS, 1);
end if;
return D;
end Saturate;
function Saturate (X : F64) return Component_Type is
D : Component_Type;
begin
-- Saturation, as defined in
-- [PIM-4.1 Vector Status and Control Register]
D := Component_Type (F64'Max
(F64 (Component_Type'First),
F64'Min
(F64 (Component_Type'Last),
X)));
if F64 (D) /= X then
VSCR := Write_Bit (VSCR, SAT_POS, 1);
end if;
return D;
end Saturate;
-----------------
-- Sign_Extend --
-----------------
function Sign_Extend (X : c_int) return Component_Type is
begin
-- X is usually a 5-bits literal. In the case of the simulator,
-- it is an integral parameter, so sign extension is straightforward.
return Component_Type (X);
end Sign_Extend;
-------------
-- abs_vxi --
-------------
function abs_vxi (A : Varray_Type) return Varray_Type is
D : Varray_Type;
begin
for K in Varray_Type'Range loop
D (K) := (if A (K) /= Component_Type'First
then abs (A (K)) else Component_Type'First);
end loop;
return D;
end abs_vxi;
--------------
-- abss_vxi --
--------------
function abss_vxi (A : Varray_Type) return Varray_Type is
D : Varray_Type;
begin
for K in Varray_Type'Range loop
D (K) := Saturate (abs (SI64 (A (K))));
end loop;
return D;
end abss_vxi;
-------------
-- vaddsxs --
-------------
function vaddsxs (A : Varray_Type; B : Varray_Type) return Varray_Type is
D : Varray_Type;
begin
for J in Varray_Type'Range loop
D (J) := Saturate (SI64 (A (J)) + SI64 (B (J)));
end loop;
return D;
end vaddsxs;
------------
-- vavgsx --
------------
function vavgsx (A : Varray_Type; B : Varray_Type) return Varray_Type is
D : Varray_Type;
begin
for J in Varray_Type'Range loop
D (J) := Component_Type ((SI64 (A (J)) + SI64 (B (J)) + 1) / 2);
end loop;
return D;
end vavgsx;
--------------
-- vcmpgtsx --
--------------
function vcmpgtsx
(A : Varray_Type;
B : Varray_Type) return Varray_Type
is
D : Varray_Type;
begin
for J in Varray_Type'Range loop
D (J) := (if A (J) > B (J) then Bool_True else Bool_False);
end loop;
return D;
end vcmpgtsx;
-----------
-- lvexx --
-----------
function lvexx (A : c_long; B : c_ptr) return Varray_Type is
D : Varray_Type;
S : Integer;
EA : Integer_Address;
J : Index_Type;
begin
S := 16 / Number_Of_Elements;
EA := Bound_Align (Integer_Address (A) + To_Integer (B),
Integer_Address (S));
J := Index_Type (((EA mod 16) / Integer_Address (S))
+ Integer_Address (Index_Type'First));
declare
Component : Component_Type;
for Component'Address use To_Address (EA);
begin
D (J) := Component;
end;
return D;
end lvexx;
------------
-- vmaxsx --
------------
function vmaxsx (A : Varray_Type; B : Varray_Type) return Varray_Type is
D : Varray_Type;
begin
for J in Varray_Type'Range loop
D (J) := (if A (J) > B (J) then A (J) else B (J));
end loop;
return D;
end vmaxsx;
------------
-- vmrghx --
------------
function vmrghx (A : Varray_Type; B : Varray_Type) return Varray_Type is
D : Varray_Type;
Offset : constant Integer := Integer (Index_Type'First);
M : constant Integer := Number_Of_Elements / 2;
begin
for J in 0 .. M - 1 loop
D (Index_Type (2 * J + Offset)) := A (Index_Type (J + Offset));
D (Index_Type (2 * J + Offset + 1)) := B (Index_Type (J + Offset));
end loop;
return D;
end vmrghx;
------------
-- vmrglx --
------------
function vmrglx (A : Varray_Type; B : Varray_Type) return Varray_Type is
D : Varray_Type;
Offset : constant Integer := Integer (Index_Type'First);
M : constant Integer := Number_Of_Elements / 2;
begin
for J in 0 .. M - 1 loop
D (Index_Type (2 * J + Offset)) := A (Index_Type (J + Offset + M));
D (Index_Type (2 * J + Offset + 1)) :=
B (Index_Type (J + Offset + M));
end loop;
return D;
end vmrglx;
------------
-- vminsx --
------------
function vminsx (A : Varray_Type; B : Varray_Type) return Varray_Type is
D : Varray_Type;
begin
for J in Varray_Type'Range loop
D (J) := (if A (J) < B (J) then A (J) else B (J));
end loop;
return D;
end vminsx;
------------
-- vspltx --
------------
function vspltx (A : Varray_Type; B : c_int) return Varray_Type is
J : constant Integer :=
Integer (B) mod Number_Of_Elements
+ Integer (Varray_Type'First);
D : Varray_Type;
begin
for K in Varray_Type'Range loop
D (K) := A (Index_Type (J));
end loop;
return D;
end vspltx;
--------------
-- vspltisx --
--------------
function vspltisx (A : c_int) return Varray_Type is
D : Varray_Type;
begin
for J in Varray_Type'Range loop
D (J) := Sign_Extend (A);
end loop;
return D;
end vspltisx;
-----------
-- vsrax --
-----------
function vsrax
(A : Varray_Type;
B : Varray_Type;
Shift_Func : Bit_Operation) return Varray_Type
is
D : Varray_Type;
S : constant Component_Type :=
Component_Type (128 / Number_Of_Elements);
begin
for J in Varray_Type'Range loop
D (J) := Shift_Func (A (J), Natural (B (J) mod S));
end loop;
return D;
end vsrax;
------------
-- stvexx --
------------
procedure stvexx (A : Varray_Type; B : c_int; C : c_ptr) is
S : Integer;
EA : Integer_Address;
J : Index_Type;
begin
S := 16 / Number_Of_Elements;
EA := Bound_Align (Integer_Address (B) + To_Integer (C),
Integer_Address (S));
J := Index_Type ((EA mod 16) / Integer_Address (S)
+ Integer_Address (Index_Type'First));
declare
Component : Component_Type;
for Component'Address use To_Address (EA);
begin
Component := A (J);
end;
end stvexx;
-------------
-- vsubsxs --
-------------
function vsubsxs (A : Varray_Type; B : Varray_Type) return Varray_Type is
D : Varray_Type;
begin
for J in Varray_Type'Range loop
D (J) := Saturate (SI64 (A (J)) - SI64 (B (J)));
end loop;
return D;
end vsubsxs;
---------------
-- Check_CR6 --
---------------
function Check_CR6 (A : c_int; D : Varray_Type) return c_int is
All_Element : Boolean := True;
Any_Element : Boolean := False;
begin
for J in Varray_Type'Range loop
All_Element := All_Element and then (D (J) = Bool_True);
Any_Element := Any_Element or else (D (J) = Bool_True);
end loop;
if A = CR6_LT then
if All_Element then
return 1;
else
return 0;
end if;
elsif A = CR6_EQ then
if not Any_Element then
return 1;
else
return 0;
end if;
elsif A = CR6_EQ_REV then
if Any_Element then
return 1;
else
return 0;
end if;
elsif A = CR6_LT_REV then
if not All_Element then
return 1;
else
return 0;
end if;
end if;
return 0;
end Check_CR6;
end Signed_Operations;
--------------------------------
-- Unsigned_Operations (spec) --
--------------------------------
generic
type Component_Type is mod <>;
type Index_Type is range <>;
type Varray_Type is array (Index_Type) of Component_Type;
package Unsigned_Operations is
function Bits
(X : Component_Type;
Low : Natural;
High : Natural) return Component_Type;
-- Return X [Low:High] as defined in [PIM-4.3 Notations and Conventions]
-- using big endian bit ordering.
function Write_Bit
(X : Component_Type;
Where : Natural;
Value : Unsigned_1) return Component_Type;
-- Write Value into X[Where:Where] (if it fits in) and return the result
-- (big endian bit ordering).
function Modular_Result (X : UI64) return Component_Type;
function Saturate (X : UI64) return Component_Type;
function Saturate (X : F64) return Component_Type;
function Saturate (X : SI64) return Component_Type;
function vadduxm (A : Varray_Type; B : Varray_Type) return Varray_Type;
function vadduxs (A : Varray_Type; B : Varray_Type) return Varray_Type;
function vavgux (A : Varray_Type; B : Varray_Type) return Varray_Type;
function vcmpequx (A : Varray_Type; B : Varray_Type) return Varray_Type;
function vcmpgtux (A : Varray_Type; B : Varray_Type) return Varray_Type;
function vmaxux (A : Varray_Type; B : Varray_Type) return Varray_Type;
function vminux (A : Varray_Type; B : Varray_Type) return Varray_Type;
type Bit_Operation is
access function
(Value : Component_Type;
Amount : Natural) return Component_Type;
function vrlx
(A : Varray_Type;
B : Varray_Type;
ROTL : Bit_Operation) return Varray_Type;
function vsxx
(A : Varray_Type;
B : Varray_Type;
Shift_Func : Bit_Operation) return Varray_Type;
-- Vector shift (left or right, depending on Shift_Func)
function vsubuxm (A : Varray_Type; B : Varray_Type) return Varray_Type;
function vsubuxs (A : Varray_Type; B : Varray_Type) return Varray_Type;
function Check_CR6 (A : c_int; D : Varray_Type) return c_int;
-- If D is the result of a vcmp operation and A the flag for
-- the kind of operation (e.g CR6_LT), check the predicate
-- that corresponds to this flag.
end Unsigned_Operations;
--------------------------------
-- Unsigned_Operations (body) --
--------------------------------
package body Unsigned_Operations is
Number_Of_Elements : constant Integer :=
VECTOR_BIT / Component_Type'Size;
Bool_True : constant Component_Type := Component_Type'Last;
Bool_False : constant Component_Type := 0;
--------------------
-- Modular_Result --
--------------------
function Modular_Result (X : UI64) return Component_Type is
D : Component_Type;
begin
D := Component_Type (X mod (UI64 (Component_Type'Last) + 1));
return D;
end Modular_Result;
--------------
-- Saturate --
--------------
function Saturate (X : UI64) return Component_Type is
D : Component_Type;
begin
-- Saturation, as defined in
-- [PIM-4.1 Vector Status and Control Register]
D := Component_Type (UI64'Max
(UI64 (Component_Type'First),
UI64'Min
(UI64 (Component_Type'Last),
X)));
if UI64 (D) /= X then
VSCR := Write_Bit (VSCR, SAT_POS, 1);
end if;
return D;
end Saturate;
function Saturate (X : SI64) return Component_Type is
D : Component_Type;
begin
-- Saturation, as defined in
-- [PIM-4.1 Vector Status and Control Register]
D := Component_Type (SI64'Max
(SI64 (Component_Type'First),
SI64'Min
(SI64 (Component_Type'Last),
X)));
if SI64 (D) /= X then
VSCR := Write_Bit (VSCR, SAT_POS, 1);
end if;
return D;
end Saturate;
function Saturate (X : F64) return Component_Type is
D : Component_Type;
begin
-- Saturation, as defined in
-- [PIM-4.1 Vector Status and Control Register]
D := Component_Type (F64'Max
(F64 (Component_Type'First),
F64'Min
(F64 (Component_Type'Last),
X)));
if F64 (D) /= X then
VSCR := Write_Bit (VSCR, SAT_POS, 1);
end if;
return D;
end Saturate;
----------
-- Bits --
----------
function Bits
(X : Component_Type;
Low : Natural;
High : Natural) return Component_Type
is
Mask : Component_Type := 0;
-- The Altivec ABI uses a big endian bit ordering, and we are
-- using little endian bit ordering for extracting bits:
Low_LE : constant Natural := Component_Type'Size - 1 - High;
High_LE : constant Natural := Component_Type'Size - 1 - Low;
begin
pragma Assert (Low <= Component_Type'Size);
pragma Assert (High <= Component_Type'Size);
for J in Low_LE .. High_LE loop
Mask := Mask or 2 ** J;
end loop;
return (X and Mask) / 2 ** Low_LE;
end Bits;
---------------
-- Write_Bit --
---------------
function Write_Bit
(X : Component_Type;
Where : Natural;
Value : Unsigned_1) return Component_Type
is
Result : Component_Type := 0;
-- The Altivec ABI uses a big endian bit ordering, and we are
-- using little endian bit ordering for extracting bits:
Where_LE : constant Natural := Component_Type'Size - 1 - Where;
begin
pragma Assert (Where < Component_Type'Size);
case Value is
when 1 =>
Result := X or 2 ** Where_LE;
when 0 =>
Result := X and not (2 ** Where_LE);
end case;
return Result;
end Write_Bit;
-------------
-- vadduxm --
-------------
function vadduxm (A : Varray_Type; B : Varray_Type) return Varray_Type is
D : Varray_Type;
begin
for J in Varray_Type'Range loop
D (J) := A (J) + B (J);
end loop;
return D;
end vadduxm;
-------------
-- vadduxs --
-------------
function vadduxs (A : Varray_Type; B : Varray_Type) return Varray_Type is
D : Varray_Type;
begin
for J in Varray_Type'Range loop
D (J) := Saturate (UI64 (A (J)) + UI64 (B (J)));
end loop;
return D;
end vadduxs;
------------
-- vavgux --
------------
function vavgux (A : Varray_Type; B : Varray_Type) return Varray_Type is
D : Varray_Type;
begin
for J in Varray_Type'Range loop
D (J) := Component_Type ((UI64 (A (J)) + UI64 (B (J)) + 1) / 2);
end loop;
return D;
end vavgux;
--------------
-- vcmpequx --
--------------
function vcmpequx
(A : Varray_Type;
B : Varray_Type) return Varray_Type
is
D : Varray_Type;
begin
for J in Varray_Type'Range loop
D (J) := (if A (J) = B (J) then Bool_True else Bool_False);
end loop;
return D;
end vcmpequx;
--------------
-- vcmpgtux --
--------------
function vcmpgtux
(A : Varray_Type;
B : Varray_Type) return Varray_Type
is
D : Varray_Type;
begin
for J in Varray_Type'Range loop
D (J) := (if A (J) > B (J) then Bool_True else Bool_False);
end loop;
return D;
end vcmpgtux;
------------
-- vmaxux --
------------
function vmaxux (A : Varray_Type; B : Varray_Type) return Varray_Type is
D : Varray_Type;
begin
for J in Varray_Type'Range loop
D (J) := (if A (J) > B (J) then A (J) else B (J));
end loop;
return D;
end vmaxux;
------------
-- vminux --
------------
function vminux (A : Varray_Type; B : Varray_Type) return Varray_Type is
D : Varray_Type;
begin
for J in Varray_Type'Range loop
D (J) := (if A (J) < B (J) then A (J) else B (J));
end loop;
return D;
end vminux;
----------
-- vrlx --
----------
function vrlx
(A : Varray_Type;
B : Varray_Type;
ROTL : Bit_Operation) return Varray_Type
is
D : Varray_Type;
begin
for J in Varray_Type'Range loop
D (J) := ROTL (A (J), Natural (B (J)));
end loop;
return D;
end vrlx;
----------
-- vsxx --
----------
function vsxx
(A : Varray_Type;
B : Varray_Type;
Shift_Func : Bit_Operation) return Varray_Type
is
D : Varray_Type;
S : constant Component_Type :=
Component_Type (128 / Number_Of_Elements);
begin
for J in Varray_Type'Range loop
D (J) := Shift_Func (A (J), Natural (B (J) mod S));
end loop;
return D;
end vsxx;
-------------
-- vsubuxm --
-------------
function vsubuxm (A : Varray_Type; B : Varray_Type) return Varray_Type is
D : Varray_Type;
begin
for J in Varray_Type'Range loop
D (J) := A (J) - B (J);
end loop;
return D;
end vsubuxm;
-------------
-- vsubuxs --
-------------
function vsubuxs (A : Varray_Type; B : Varray_Type) return Varray_Type is
D : Varray_Type;
begin
for J in Varray_Type'Range loop
D (J) := Saturate (SI64 (A (J)) - SI64 (B (J)));
end loop;
return D;
end vsubuxs;
---------------
-- Check_CR6 --
---------------
function Check_CR6 (A : c_int; D : Varray_Type) return c_int is
All_Element : Boolean := True;
Any_Element : Boolean := False;
begin
for J in Varray_Type'Range loop
All_Element := All_Element and then (D (J) = Bool_True);
Any_Element := Any_Element or else (D (J) = Bool_True);
end loop;
if A = CR6_LT then
if All_Element then
return 1;
else
return 0;
end if;
elsif A = CR6_EQ then
if not Any_Element then
return 1;
else
return 0;
end if;
elsif A = CR6_EQ_REV then
if Any_Element then
return 1;
else
return 0;
end if;
elsif A = CR6_LT_REV then
if not All_Element then
return 1;
else
return 0;
end if;
end if;
return 0;
end Check_CR6;
end Unsigned_Operations;
--------------------------------------
-- Signed_Merging_Operations (spec) --
--------------------------------------
generic
type Component_Type is range <>;
type Index_Type is range <>;
type Varray_Type is array (Index_Type) of Component_Type;
type Double_Component_Type is range <>;
type Double_Index_Type is range <>;
type Double_Varray_Type is array (Double_Index_Type)
of Double_Component_Type;
package Signed_Merging_Operations is
pragma Assert (Integer (Varray_Type'First)
= Integer (Double_Varray_Type'First));
pragma Assert (Varray_Type'Length = 2 * Double_Varray_Type'Length);
pragma Assert (2 * Component_Type'Size = Double_Component_Type'Size);
function Saturate
(X : Double_Component_Type) return Component_Type;
function vmulxsx
(Use_Even_Components : Boolean;
A : Varray_Type;
B : Varray_Type) return Double_Varray_Type;
function vpksxss
(A : Double_Varray_Type;
B : Double_Varray_Type) return Varray_Type;
pragma Convention (LL_Altivec, vpksxss);
function vupkxsx
(A : Varray_Type;
Offset : Natural) return Double_Varray_Type;
end Signed_Merging_Operations;
--------------------------------------
-- Signed_Merging_Operations (body) --
--------------------------------------
package body Signed_Merging_Operations is
--------------
-- Saturate --
--------------
function Saturate
(X : Double_Component_Type) return Component_Type
is
D : Component_Type;
begin
-- Saturation, as defined in
-- [PIM-4.1 Vector Status and Control Register]
D := Component_Type (Double_Component_Type'Max
(Double_Component_Type (Component_Type'First),
Double_Component_Type'Min
(Double_Component_Type (Component_Type'Last),
X)));
if Double_Component_Type (D) /= X then
VSCR := Write_Bit (VSCR, SAT_POS, 1);
end if;
return D;
end Saturate;
-------------
-- vmulsxs --
-------------
function vmulxsx
(Use_Even_Components : Boolean;
A : Varray_Type;
B : Varray_Type) return Double_Varray_Type
is
Double_Offset : Double_Index_Type;
Offset : Index_Type;
D : Double_Varray_Type;
N : constant Integer :=
Integer (Double_Index_Type'Last)
- Integer (Double_Index_Type'First) + 1;
begin
for J in 0 .. N - 1 loop
Offset :=
Index_Type ((if Use_Even_Components then 2 * J else 2 * J + 1) +
Integer (Index_Type'First));
Double_Offset :=
Double_Index_Type (J + Integer (Double_Index_Type'First));
D (Double_Offset) :=
Double_Component_Type (A (Offset)) *
Double_Component_Type (B (Offset));
end loop;
return D;
end vmulxsx;
-------------
-- vpksxss --
-------------
function vpksxss
(A : Double_Varray_Type;
B : Double_Varray_Type) return Varray_Type
is
N : constant Index_Type :=
Index_Type (Double_Index_Type'Last);
D : Varray_Type;
Offset : Index_Type;
Double_Offset : Double_Index_Type;
begin
for J in 0 .. N - 1 loop
Offset := Index_Type (Integer (J) + Integer (Index_Type'First));
Double_Offset :=
Double_Index_Type (Integer (J)
+ Integer (Double_Index_Type'First));
D (Offset) := Saturate (A (Double_Offset));
D (Offset + N) := Saturate (B (Double_Offset));
end loop;
return D;
end vpksxss;
-------------
-- vupkxsx --
-------------
function vupkxsx
(A : Varray_Type;
Offset : Natural) return Double_Varray_Type
is
K : Index_Type;
D : Double_Varray_Type;
begin
for J in Double_Varray_Type'Range loop
K := Index_Type (Integer (J)
- Integer (Double_Index_Type'First)
+ Integer (Index_Type'First)
+ Offset);
D (J) := Double_Component_Type (A (K));
end loop;
return D;
end vupkxsx;
end Signed_Merging_Operations;
----------------------------------------
-- Unsigned_Merging_Operations (spec) --
----------------------------------------
generic
type Component_Type is mod <>;
type Index_Type is range <>;
type Varray_Type is array (Index_Type) of Component_Type;
type Double_Component_Type is mod <>;
type Double_Index_Type is range <>;
type Double_Varray_Type is array (Double_Index_Type)
of Double_Component_Type;
package Unsigned_Merging_Operations is
pragma Assert (Integer (Varray_Type'First)
= Integer (Double_Varray_Type'First));
pragma Assert (Varray_Type'Length = 2 * Double_Varray_Type'Length);
pragma Assert (2 * Component_Type'Size = Double_Component_Type'Size);
function UI_To_UI_Mod
(X : Double_Component_Type;
Y : Natural) return Component_Type;
function Saturate (X : Double_Component_Type) return Component_Type;
function vmulxux
(Use_Even_Components : Boolean;
A : Varray_Type;
B : Varray_Type) return Double_Varray_Type;
function vpkuxum
(A : Double_Varray_Type;
B : Double_Varray_Type) return Varray_Type;
function vpkuxus
(A : Double_Varray_Type;
B : Double_Varray_Type) return Varray_Type;
end Unsigned_Merging_Operations;
----------------------------------------
-- Unsigned_Merging_Operations (body) --
----------------------------------------
package body Unsigned_Merging_Operations is
------------------
-- UI_To_UI_Mod --
------------------
function UI_To_UI_Mod
(X : Double_Component_Type;
Y : Natural) return Component_Type is
Z : Component_Type;
begin
Z := Component_Type (X mod 2 ** Y);
return Z;
end UI_To_UI_Mod;
--------------
-- Saturate --
--------------
function Saturate (X : Double_Component_Type) return Component_Type is
D : Component_Type;
begin
-- Saturation, as defined in
-- [PIM-4.1 Vector Status and Control Register]
D := Component_Type (Double_Component_Type'Max
(Double_Component_Type (Component_Type'First),
Double_Component_Type'Min
(Double_Component_Type (Component_Type'Last),
X)));
if Double_Component_Type (D) /= X then
VSCR := Write_Bit (VSCR, SAT_POS, 1);
end if;
return D;
end Saturate;
-------------
-- vmulxux --
-------------
function vmulxux
(Use_Even_Components : Boolean;
A : Varray_Type;
B : Varray_Type) return Double_Varray_Type
is
Double_Offset : Double_Index_Type;
Offset : Index_Type;
D : Double_Varray_Type;
N : constant Integer :=
Integer (Double_Index_Type'Last)
- Integer (Double_Index_Type'First) + 1;
begin
for J in 0 .. N - 1 loop
Offset :=
Index_Type ((if Use_Even_Components then 2 * J else 2 * J + 1) +
Integer (Index_Type'First));
Double_Offset :=
Double_Index_Type (J + Integer (Double_Index_Type'First));
D (Double_Offset) :=
Double_Component_Type (A (Offset)) *
Double_Component_Type (B (Offset));
end loop;
return D;
end vmulxux;
-------------
-- vpkuxum --
-------------
function vpkuxum
(A : Double_Varray_Type;
B : Double_Varray_Type) return Varray_Type
is
S : constant Natural :=
Double_Component_Type'Size / 2;
N : constant Index_Type :=
Index_Type (Double_Index_Type'Last);
D : Varray_Type;
Offset : Index_Type;
Double_Offset : Double_Index_Type;
begin
for J in 0 .. N - 1 loop
Offset := Index_Type (Integer (J) + Integer (Index_Type'First));
Double_Offset :=
Double_Index_Type (Integer (J)
+ Integer (Double_Index_Type'First));
D (Offset) := UI_To_UI_Mod (A (Double_Offset), S);
D (Offset + N) := UI_To_UI_Mod (B (Double_Offset), S);
end loop;
return D;
end vpkuxum;
-------------
-- vpkuxus --
-------------
function vpkuxus
(A : Double_Varray_Type;
B : Double_Varray_Type) return Varray_Type
is
N : constant Index_Type :=
Index_Type (Double_Index_Type'Last);
D : Varray_Type;
Offset : Index_Type;
Double_Offset : Double_Index_Type;
begin
for J in 0 .. N - 1 loop
Offset := Index_Type (Integer (J) + Integer (Index_Type'First));
Double_Offset :=
Double_Index_Type (Integer (J)
+ Integer (Double_Index_Type'First));
D (Offset) := Saturate (A (Double_Offset));
D (Offset + N) := Saturate (B (Double_Offset));
end loop;
return D;
end vpkuxus;
end Unsigned_Merging_Operations;
package LL_VSC_Operations is
new Signed_Operations (signed_char,
Vchar_Range,
Varray_signed_char);
package LL_VSS_Operations is
new Signed_Operations (signed_short,
Vshort_Range,
Varray_signed_short);
package LL_VSI_Operations is
new Signed_Operations (signed_int,
Vint_Range,
Varray_signed_int);
package LL_VUC_Operations is
new Unsigned_Operations (unsigned_char,
Vchar_Range,
Varray_unsigned_char);
package LL_VUS_Operations is
new Unsigned_Operations (unsigned_short,
Vshort_Range,
Varray_unsigned_short);
package LL_VUI_Operations is
new Unsigned_Operations (unsigned_int,
Vint_Range,
Varray_unsigned_int);
package LL_VSC_LL_VSS_Operations is
new Signed_Merging_Operations (signed_char,
Vchar_Range,
Varray_signed_char,
signed_short,
Vshort_Range,
Varray_signed_short);
package LL_VSS_LL_VSI_Operations is
new Signed_Merging_Operations (signed_short,
Vshort_Range,
Varray_signed_short,
signed_int,
Vint_Range,
Varray_signed_int);
package LL_VUC_LL_VUS_Operations is
new Unsigned_Merging_Operations (unsigned_char,
Vchar_Range,
Varray_unsigned_char,
unsigned_short,
Vshort_Range,
Varray_unsigned_short);
package LL_VUS_LL_VUI_Operations is
new Unsigned_Merging_Operations (unsigned_short,
Vshort_Range,
Varray_unsigned_short,
unsigned_int,
Vint_Range,
Varray_unsigned_int);
----------
-- Bits --
----------
function Bits
(X : unsigned_int;
Low : Natural;
High : Natural) return unsigned_int renames LL_VUI_Operations.Bits;
function Bits
(X : unsigned_short;
Low : Natural;
High : Natural) return unsigned_short renames LL_VUS_Operations.Bits;
function Bits
(X : unsigned_char;
Low : Natural;
High : Natural) return unsigned_char renames LL_VUC_Operations.Bits;
---------------
-- Write_Bit --
---------------
function Write_Bit
(X : unsigned_int;
Where : Natural;
Value : Unsigned_1) return unsigned_int
renames LL_VUI_Operations.Write_Bit;
function Write_Bit
(X : unsigned_short;
Where : Natural;
Value : Unsigned_1) return unsigned_short
renames LL_VUS_Operations.Write_Bit;
function Write_Bit
(X : unsigned_char;
Where : Natural;
Value : Unsigned_1) return unsigned_char
renames LL_VUC_Operations.Write_Bit;
-----------------
-- Bound_Align --
-----------------
function Bound_Align
(X : Integer_Address;
Y : Integer_Address) return Integer_Address
is
D : Integer_Address;
begin
D := X - X mod Y;
return D;
end Bound_Align;
-----------------
-- NJ_Truncate --
-----------------
function NJ_Truncate (X : C_float) return C_float is
D : C_float;
begin
if (Bits (VSCR, NJ_POS, NJ_POS) = 1)
and then abs (X) < 2.0 ** (-126)
then
D := (if X < 0.0 then -0.0 else +0.0);
else
D := X;
end if;
return D;
end NJ_Truncate;
-----------------------
-- Rnd_To_FP_Nearest --
-----------------------
function Rnd_To_FP_Nearest (X : F64) return C_float is
begin
return C_float (X);
end Rnd_To_FP_Nearest;
---------------------
-- Rnd_To_FPI_Near --
---------------------
function Rnd_To_FPI_Near (X : F64) return F64 is
Result : F64;
Ceiling : F64;
begin
Result := F64 (SI64 (X));
if (F64'Ceiling (X) - X) = (X + 1.0 - F64'Ceiling (X)) then
-- Round to even
Ceiling := F64'Ceiling (X);
Result :=
(if Rnd_To_FPI_Trunc (Ceiling / 2.0) * 2.0 = Ceiling
then Ceiling else Ceiling - 1.0);
end if;
return Result;
end Rnd_To_FPI_Near;
----------------------
-- Rnd_To_FPI_Trunc --
----------------------
function Rnd_To_FPI_Trunc (X : F64) return F64 is
Result : F64;
begin
Result := F64'Ceiling (X);
-- Rnd_To_FPI_Trunc rounds toward 0, 'Ceiling rounds toward
-- +Infinity
if X > 0.0
and then Result /= X
then
Result := Result - 1.0;
end if;
return Result;
end Rnd_To_FPI_Trunc;
------------------
-- FP_Recip_Est --
------------------
function FP_Recip_Est (X : C_float) return C_float is
begin
-- ??? [PIM-4.4 vec_re] "For result that are not +0, -0, +Inf,
-- -Inf, or QNaN, the estimate has a relative error no greater
-- than one part in 4096, that is:
-- Abs ((estimate - 1 / x) / (1 / x)) < = 1/4096"
return NJ_Truncate (1.0 / NJ_Truncate (X));
end FP_Recip_Est;
----------
-- ROTL --
----------
function ROTL
(Value : unsigned_char;
Amount : Natural) return unsigned_char
is
Result : Unsigned_8;
begin
Result := Rotate_Left (Unsigned_8 (Value), Amount);
return unsigned_char (Result);
end ROTL;
function ROTL
(Value : unsigned_short;
Amount : Natural) return unsigned_short
is
Result : Unsigned_16;
begin
Result := Rotate_Left (Unsigned_16 (Value), Amount);
return unsigned_short (Result);
end ROTL;
function ROTL
(Value : unsigned_int;
Amount : Natural) return unsigned_int
is
Result : Unsigned_32;
begin
Result := Rotate_Left (Unsigned_32 (Value), Amount);
return unsigned_int (Result);
end ROTL;
--------------------
-- Recip_SQRT_Est --
--------------------
function Recip_SQRT_Est (X : C_float) return C_float is
Result : C_float;
begin
-- ???
-- [PIM-4.4 vec_rsqrte] the estimate has a relative error in precision
-- no greater than one part in 4096, that is:
-- abs ((estimate - 1 / sqrt (x)) / (1 / sqrt (x)) <= 1 / 4096"
Result := 1.0 / NJ_Truncate (C_float_Operations.Sqrt (NJ_Truncate (X)));
return NJ_Truncate (Result);
end Recip_SQRT_Est;
----------------
-- Shift_Left --
----------------
function Shift_Left
(Value : unsigned_char;
Amount : Natural) return unsigned_char
is
Result : Unsigned_8;
begin
Result := Shift_Left (Unsigned_8 (Value), Amount);
return unsigned_char (Result);
end Shift_Left;
function Shift_Left
(Value : unsigned_short;
Amount : Natural) return unsigned_short
is
Result : Unsigned_16;
begin
Result := Shift_Left (Unsigned_16 (Value), Amount);
return unsigned_short (Result);
end Shift_Left;
function Shift_Left
(Value : unsigned_int;
Amount : Natural) return unsigned_int
is
Result : Unsigned_32;
begin
Result := Shift_Left (Unsigned_32 (Value), Amount);
return unsigned_int (Result);
end Shift_Left;
-----------------
-- Shift_Right --
-----------------
function Shift_Right
(Value : unsigned_char;
Amount : Natural) return unsigned_char
is
Result : Unsigned_8;
begin
Result := Shift_Right (Unsigned_8 (Value), Amount);
return unsigned_char (Result);
end Shift_Right;
function Shift_Right
(Value : unsigned_short;
Amount : Natural) return unsigned_short
is
Result : Unsigned_16;
begin
Result := Shift_Right (Unsigned_16 (Value), Amount);
return unsigned_short (Result);
end Shift_Right;
function Shift_Right
(Value : unsigned_int;
Amount : Natural) return unsigned_int
is
Result : Unsigned_32;
begin
Result := Shift_Right (Unsigned_32 (Value), Amount);
return unsigned_int (Result);
end Shift_Right;
-------------------
-- Shift_Right_A --
-------------------
generic
type Signed_Type is range <>;
type Unsigned_Type is mod <>;
with function Shift_Right (Value : Unsigned_Type; Amount : Natural)
return Unsigned_Type;
function Shift_Right_Arithmetic
(Value : Signed_Type;
Amount : Natural) return Signed_Type;
function Shift_Right_Arithmetic
(Value : Signed_Type;
Amount : Natural) return Signed_Type
is
begin
if Value > 0 then
return Signed_Type (Shift_Right (Unsigned_Type (Value), Amount));
else
return -Signed_Type (Shift_Right (Unsigned_Type (-Value - 1), Amount)
+ 1);
end if;
end Shift_Right_Arithmetic;
function Shift_Right_A is new Shift_Right_Arithmetic (signed_int,
Unsigned_32,
Shift_Right);
function Shift_Right_A is new Shift_Right_Arithmetic (signed_short,
Unsigned_16,
Shift_Right);
function Shift_Right_A is new Shift_Right_Arithmetic (signed_char,
Unsigned_8,
Shift_Right);
--------------
-- To_Pixel --
--------------
function To_Pixel (Source : unsigned_short) return Pixel_16 is
-- This conversion should not depend on the host endianness;
-- therefore, we cannot use an unchecked conversion.
Target : Pixel_16;
begin
Target.T := Unsigned_1 (Bits (Source, 0, 0) mod 2 ** 1);
Target.R := Unsigned_5 (Bits (Source, 1, 5) mod 2 ** 5);
Target.G := Unsigned_5 (Bits (Source, 6, 10) mod 2 ** 5);
Target.B := Unsigned_5 (Bits (Source, 11, 15) mod 2 ** 5);
return Target;
end To_Pixel;
function To_Pixel (Source : unsigned_int) return Pixel_32 is
-- This conversion should not depend on the host endianness;
-- therefore, we cannot use an unchecked conversion.
Target : Pixel_32;
begin
Target.T := unsigned_char (Bits (Source, 0, 7));
Target.R := unsigned_char (Bits (Source, 8, 15));
Target.G := unsigned_char (Bits (Source, 16, 23));
Target.B := unsigned_char (Bits (Source, 24, 31));
return Target;
end To_Pixel;
---------------------
-- To_unsigned_int --
---------------------
function To_unsigned_int (Source : Pixel_32) return unsigned_int is
-- This conversion should not depend on the host endianness;
-- therefore, we cannot use an unchecked conversion.
-- It should also be the same result, value-wise, on two hosts
-- with the same endianness.
Target : unsigned_int := 0;
begin
-- In big endian bit ordering, Pixel_32 looks like:
-- -------------------------------------
-- | T | R | G | B |
-- -------------------------------------
-- 0 (MSB) 7 15 23 32
--
-- Sizes of the components: (8/8/8/8)
--
Target := Target or unsigned_int (Source.T);
Target := Shift_Left (Target, 8);
Target := Target or unsigned_int (Source.R);
Target := Shift_Left (Target, 8);
Target := Target or unsigned_int (Source.G);
Target := Shift_Left (Target, 8);
Target := Target or unsigned_int (Source.B);
return Target;
end To_unsigned_int;
-----------------------
-- To_unsigned_short --
-----------------------
function To_unsigned_short (Source : Pixel_16) return unsigned_short is
-- This conversion should not depend on the host endianness;
-- therefore, we cannot use an unchecked conversion.
-- It should also be the same result, value-wise, on two hosts
-- with the same endianness.
Target : unsigned_short := 0;
begin
-- In big endian bit ordering, Pixel_16 looks like:
-- -------------------------------------
-- | T | R | G | B |
-- -------------------------------------
-- 0 (MSB) 1 5 11 15
--
-- Sizes of the components: (1/5/5/5)
--
Target := Target or unsigned_short (Source.T);
Target := Shift_Left (Target, 5);
Target := Target or unsigned_short (Source.R);
Target := Shift_Left (Target, 5);
Target := Target or unsigned_short (Source.G);
Target := Shift_Left (Target, 5);
Target := Target or unsigned_short (Source.B);
return Target;
end To_unsigned_short;
---------------
-- abs_v16qi --
---------------
function abs_v16qi (A : LL_VSC) return LL_VSC is
VA : constant VSC_View := To_View (A);
begin
return To_Vector ((Values =>
LL_VSC_Operations.abs_vxi (VA.Values)));
end abs_v16qi;
--------------
-- abs_v8hi --
--------------
function abs_v8hi (A : LL_VSS) return LL_VSS is
VA : constant VSS_View := To_View (A);
begin
return To_Vector ((Values =>
LL_VSS_Operations.abs_vxi (VA.Values)));
end abs_v8hi;
--------------
-- abs_v4si --
--------------
function abs_v4si (A : LL_VSI) return LL_VSI is
VA : constant VSI_View := To_View (A);
begin
return To_Vector ((Values =>
LL_VSI_Operations.abs_vxi (VA.Values)));
end abs_v4si;
--------------
-- abs_v4sf --
--------------
function abs_v4sf (A : LL_VF) return LL_VF is
D : Varray_float;
VA : constant VF_View := To_View (A);
begin
for J in Varray_float'Range loop
D (J) := abs (VA.Values (J));
end loop;
return To_Vector ((Values => D));
end abs_v4sf;
----------------
-- abss_v16qi --
----------------
function abss_v16qi (A : LL_VSC) return LL_VSC is
VA : constant VSC_View := To_View (A);
begin
return To_Vector ((Values =>
LL_VSC_Operations.abss_vxi (VA.Values)));
end abss_v16qi;
---------------
-- abss_v8hi --
---------------
function abss_v8hi (A : LL_VSS) return LL_VSS is
VA : constant VSS_View := To_View (A);
begin
return To_Vector ((Values =>
LL_VSS_Operations.abss_vxi (VA.Values)));
end abss_v8hi;
---------------
-- abss_v4si --
---------------
function abss_v4si (A : LL_VSI) return LL_VSI is
VA : constant VSI_View := To_View (A);
begin
return To_Vector ((Values =>
LL_VSI_Operations.abss_vxi (VA.Values)));
end abss_v4si;
-------------
-- vaddubm --
-------------
function vaddubm (A : LL_VSC; B : LL_VSC) return LL_VSC is
UC : constant GNAT.Altivec.Low_Level_Vectors.LL_VUC :=
To_LL_VUC (A);
VA : constant VUC_View :=
To_View (UC);
VB : constant VUC_View := To_View (To_LL_VUC (B));
D : Varray_unsigned_char;
begin
D := LL_VUC_Operations.vadduxm (VA.Values, VB.Values);
return To_LL_VSC (To_Vector (VUC_View'(Values => D)));
end vaddubm;
-------------
-- vadduhm --
-------------
function vadduhm (A : LL_VSS; B : LL_VSS) return LL_VSS is
VA : constant VUS_View := To_View (To_LL_VUS (A));
VB : constant VUS_View := To_View (To_LL_VUS (B));
D : Varray_unsigned_short;
begin
D := LL_VUS_Operations.vadduxm (VA.Values, VB.Values);
return To_LL_VSS (To_Vector (VUS_View'(Values => D)));
end vadduhm;
-------------
-- vadduwm --
-------------
function vadduwm (A : LL_VSI; B : LL_VSI) return LL_VSI is
VA : constant VUI_View := To_View (To_LL_VUI (A));
VB : constant VUI_View := To_View (To_LL_VUI (B));
D : Varray_unsigned_int;
begin
D := LL_VUI_Operations.vadduxm (VA.Values, VB.Values);
return To_LL_VSI (To_Vector (VUI_View'(Values => D)));
end vadduwm;
------------
-- vaddfp --
------------
function vaddfp (A : LL_VF; B : LL_VF) return LL_VF is
VA : constant VF_View := To_View (A);
VB : constant VF_View := To_View (B);
D : Varray_float;
begin
for J in Varray_float'Range loop
D (J) := NJ_Truncate (NJ_Truncate (VA.Values (J))
+ NJ_Truncate (VB.Values (J)));
end loop;
return To_Vector (VF_View'(Values => D));
end vaddfp;
-------------
-- vaddcuw --
-------------
function vaddcuw (A : LL_VSI; B : LL_VSI) return LL_VSI is
Addition_Result : UI64;
D : VUI_View;
VA : constant VUI_View := To_View (To_LL_VUI (A));
VB : constant VUI_View := To_View (To_LL_VUI (B));
begin
for J in Varray_unsigned_int'Range loop
Addition_Result := UI64 (VA.Values (J)) + UI64 (VB.Values (J));
D.Values (J) :=
(if Addition_Result > UI64 (unsigned_int'Last) then 1 else 0);
end loop;
return To_LL_VSI (To_Vector (D));
end vaddcuw;
-------------
-- vaddubs --
-------------
function vaddubs (A : LL_VSC; B : LL_VSC) return LL_VSC is
VA : constant VUC_View := To_View (To_LL_VUC (A));
VB : constant VUC_View := To_View (To_LL_VUC (B));
begin
return To_LL_VSC (To_Vector
(VUC_View'(Values =>
(LL_VUC_Operations.vadduxs
(VA.Values,
VB.Values)))));
end vaddubs;
-------------
-- vaddsbs --
-------------
function vaddsbs (A : LL_VSC; B : LL_VSC) return LL_VSC is
VA : constant VSC_View := To_View (A);
VB : constant VSC_View := To_View (B);
D : VSC_View;
begin
D.Values := LL_VSC_Operations.vaddsxs (VA.Values, VB.Values);
return To_Vector (D);
end vaddsbs;
-------------
-- vadduhs --
-------------
function vadduhs (A : LL_VSS; B : LL_VSS) return LL_VSS is
VA : constant VUS_View := To_View (To_LL_VUS (A));
VB : constant VUS_View := To_View (To_LL_VUS (B));
D : VUS_View;
begin
D.Values := LL_VUS_Operations.vadduxs (VA.Values, VB.Values);
return To_LL_VSS (To_Vector (D));
end vadduhs;
-------------
-- vaddshs --
-------------
function vaddshs (A : LL_VSS; B : LL_VSS) return LL_VSS is
VA : constant VSS_View := To_View (A);
VB : constant VSS_View := To_View (B);
D : VSS_View;
begin
D.Values := LL_VSS_Operations.vaddsxs (VA.Values, VB.Values);
return To_Vector (D);
end vaddshs;
-------------
-- vadduws --
-------------
function vadduws (A : LL_VSI; B : LL_VSI) return LL_VSI is
VA : constant VUI_View := To_View (To_LL_VUI (A));
VB : constant VUI_View := To_View (To_LL_VUI (B));
D : VUI_View;
begin
D.Values := LL_VUI_Operations.vadduxs (VA.Values, VB.Values);
return To_LL_VSI (To_Vector (D));
end vadduws;
-------------
-- vaddsws --
-------------
function vaddsws (A : LL_VSI; B : LL_VSI) return LL_VSI is
VA : constant VSI_View := To_View (A);
VB : constant VSI_View := To_View (B);
D : VSI_View;
begin
D.Values := LL_VSI_Operations.vaddsxs (VA.Values, VB.Values);
return To_Vector (D);
end vaddsws;
----------
-- vand --
----------
function vand (A : LL_VSI; B : LL_VSI) return LL_VSI is
VA : constant VUI_View := To_View (To_LL_VUI (A));
VB : constant VUI_View := To_View (To_LL_VUI (B));
D : VUI_View;
begin
for J in Varray_unsigned_int'Range loop
D.Values (J) := VA.Values (J) and VB.Values (J);
end loop;
return To_LL_VSI (To_Vector (D));
end vand;
-----------
-- vandc --
-----------
function vandc (A : LL_VSI; B : LL_VSI) return LL_VSI is
VA : constant VUI_View := To_View (To_LL_VUI (A));
VB : constant VUI_View := To_View (To_LL_VUI (B));
D : VUI_View;
begin
for J in Varray_unsigned_int'Range loop
D.Values (J) := VA.Values (J) and not VB.Values (J);
end loop;
return To_LL_VSI (To_Vector (D));
end vandc;
------------
-- vavgub --
------------
function vavgub (A : LL_VSC; B : LL_VSC) return LL_VSC is
VA : constant VUC_View := To_View (To_LL_VUC (A));
VB : constant VUC_View := To_View (To_LL_VUC (B));
D : VUC_View;
begin
D.Values := LL_VUC_Operations.vavgux (VA.Values, VB.Values);
return To_LL_VSC (To_Vector (D));
end vavgub;
------------
-- vavgsb --
------------
function vavgsb (A : LL_VSC; B : LL_VSC) return LL_VSC is
VA : constant VSC_View := To_View (A);
VB : constant VSC_View := To_View (B);
D : VSC_View;
begin
D.Values := LL_VSC_Operations.vavgsx (VA.Values, VB.Values);
return To_Vector (D);
end vavgsb;
------------
-- vavguh --
------------
function vavguh (A : LL_VSS; B : LL_VSS) return LL_VSS is
VA : constant VUS_View := To_View (To_LL_VUS (A));
VB : constant VUS_View := To_View (To_LL_VUS (B));
D : VUS_View;
begin
D.Values := LL_VUS_Operations.vavgux (VA.Values, VB.Values);
return To_LL_VSS (To_Vector (D));
end vavguh;
------------
-- vavgsh --
------------
function vavgsh (A : LL_VSS; B : LL_VSS) return LL_VSS is
VA : constant VSS_View := To_View (A);
VB : constant VSS_View := To_View (B);
D : VSS_View;
begin
D.Values := LL_VSS_Operations.vavgsx (VA.Values, VB.Values);
return To_Vector (D);
end vavgsh;
------------
-- vavguw --
------------
function vavguw (A : LL_VSI; B : LL_VSI) return LL_VSI is
VA : constant VUI_View := To_View (To_LL_VUI (A));
VB : constant VUI_View := To_View (To_LL_VUI (B));
D : VUI_View;
begin
D.Values := LL_VUI_Operations.vavgux (VA.Values, VB.Values);
return To_LL_VSI (To_Vector (D));
end vavguw;
------------
-- vavgsw --
------------
function vavgsw (A : LL_VSI; B : LL_VSI) return LL_VSI is
VA : constant VSI_View := To_View (A);
VB : constant VSI_View := To_View (B);
D : VSI_View;
begin
D.Values := LL_VSI_Operations.vavgsx (VA.Values, VB.Values);
return To_Vector (D);
end vavgsw;
-----------
-- vrfip --
-----------
function vrfip (A : LL_VF) return LL_VF is
VA : constant VF_View := To_View (A);
D : VF_View;
begin
for J in Varray_float'Range loop
-- If A (J) is infinite, D (J) should be infinite; With
-- IEEE floating points, we can use 'Ceiling for that purpose.
D.Values (J) := C_float'Ceiling (NJ_Truncate (VA.Values (J)));
end loop;
return To_Vector (D);
end vrfip;
-------------
-- vcmpbfp --
-------------
function vcmpbfp (A : LL_VF; B : LL_VF) return LL_VSI is
VA : constant VF_View := To_View (A);
VB : constant VF_View := To_View (B);
D : VUI_View;
K : Vint_Range;
begin
for J in Varray_float'Range loop
K := Vint_Range (J);
D.Values (K) := 0;
if NJ_Truncate (VB.Values (J)) < 0.0 then
-- [PIM-4.4 vec_cmpb] "If any single-precision floating-point
-- word element in B is negative; the corresponding element in A
-- is out of bounds.
D.Values (K) := Write_Bit (D.Values (K), 0, 1);
D.Values (K) := Write_Bit (D.Values (K), 1, 1);
else
D.Values (K) :=
(if NJ_Truncate (VA.Values (J)) <= NJ_Truncate (VB.Values (J))
then Write_Bit (D.Values (K), 0, 0)
else Write_Bit (D.Values (K), 0, 1));
D.Values (K) :=
(if NJ_Truncate (VA.Values (J)) >= -NJ_Truncate (VB.Values (J))
then Write_Bit (D.Values (K), 1, 0)
else Write_Bit (D.Values (K), 1, 1));
end if;
end loop;
return To_LL_VSI (To_Vector (D));
end vcmpbfp;
--------------
-- vcmpequb --
--------------
function vcmpequb (A : LL_VSC; B : LL_VSC) return LL_VSC is
VA : constant VUC_View := To_View (To_LL_VUC (A));
VB : constant VUC_View := To_View (To_LL_VUC (B));
D : VUC_View;
begin
D.Values := LL_VUC_Operations.vcmpequx (VA.Values, VB.Values);
return To_LL_VSC (To_Vector (D));
end vcmpequb;
--------------
-- vcmpequh --
--------------
function vcmpequh (A : LL_VSS; B : LL_VSS) return LL_VSS is
VA : constant VUS_View := To_View (To_LL_VUS (A));
VB : constant VUS_View := To_View (To_LL_VUS (B));
D : VUS_View;
begin
D.Values := LL_VUS_Operations.vcmpequx (VA.Values, VB.Values);
return To_LL_VSS (To_Vector (D));
end vcmpequh;
--------------
-- vcmpequw --
--------------
function vcmpequw (A : LL_VSI; B : LL_VSI) return LL_VSI is
VA : constant VUI_View := To_View (To_LL_VUI (A));
VB : constant VUI_View := To_View (To_LL_VUI (B));
D : VUI_View;
begin
D.Values := LL_VUI_Operations.vcmpequx (VA.Values, VB.Values);
return To_LL_VSI (To_Vector (D));
end vcmpequw;
--------------
-- vcmpeqfp --
--------------
function vcmpeqfp (A : LL_VF; B : LL_VF) return LL_VSI is
VA : constant VF_View := To_View (A);
VB : constant VF_View := To_View (B);
D : VUI_View;
begin
for J in Varray_float'Range loop
D.Values (Vint_Range (J)) :=
(if VA.Values (J) = VB.Values (J) then unsigned_int'Last else 0);
end loop;
return To_LL_VSI (To_Vector (D));
end vcmpeqfp;
--------------
-- vcmpgefp --
--------------
function vcmpgefp (A : LL_VF; B : LL_VF) return LL_VSI is
VA : constant VF_View := To_View (A);
VB : constant VF_View := To_View (B);
D : VSI_View;
begin
for J in Varray_float'Range loop
D.Values (Vint_Range (J)) :=
(if VA.Values (J) >= VB.Values (J) then Signed_Bool_True
else Signed_Bool_False);
end loop;
return To_Vector (D);
end vcmpgefp;
--------------
-- vcmpgtub --
--------------
function vcmpgtub (A : LL_VSC; B : LL_VSC) return LL_VSC is
VA : constant VUC_View := To_View (To_LL_VUC (A));
VB : constant VUC_View := To_View (To_LL_VUC (B));
D : VUC_View;
begin
D.Values := LL_VUC_Operations.vcmpgtux (VA.Values, VB.Values);
return To_LL_VSC (To_Vector (D));
end vcmpgtub;
--------------
-- vcmpgtsb --
--------------
function vcmpgtsb (A : LL_VSC; B : LL_VSC) return LL_VSC is
VA : constant VSC_View := To_View (A);
VB : constant VSC_View := To_View (B);
D : VSC_View;
begin
D.Values := LL_VSC_Operations.vcmpgtsx (VA.Values, VB.Values);
return To_Vector (D);
end vcmpgtsb;
--------------
-- vcmpgtuh --
--------------
function vcmpgtuh (A : LL_VSS; B : LL_VSS) return LL_VSS is
VA : constant VUS_View := To_View (To_LL_VUS (A));
VB : constant VUS_View := To_View (To_LL_VUS (B));
D : VUS_View;
begin
D.Values := LL_VUS_Operations.vcmpgtux (VA.Values, VB.Values);
return To_LL_VSS (To_Vector (D));
end vcmpgtuh;
--------------
-- vcmpgtsh --
--------------
function vcmpgtsh (A : LL_VSS; B : LL_VSS) return LL_VSS is
VA : constant VSS_View := To_View (A);
VB : constant VSS_View := To_View (B);
D : VSS_View;
begin
D.Values := LL_VSS_Operations.vcmpgtsx (VA.Values, VB.Values);
return To_Vector (D);
end vcmpgtsh;
--------------
-- vcmpgtuw --
--------------
function vcmpgtuw (A : LL_VSI; B : LL_VSI) return LL_VSI is
VA : constant VUI_View := To_View (To_LL_VUI (A));
VB : constant VUI_View := To_View (To_LL_VUI (B));
D : VUI_View;
begin
D.Values := LL_VUI_Operations.vcmpgtux (VA.Values, VB.Values);
return To_LL_VSI (To_Vector (D));
end vcmpgtuw;
--------------
-- vcmpgtsw --
--------------
function vcmpgtsw (A : LL_VSI; B : LL_VSI) return LL_VSI is
VA : constant VSI_View := To_View (A);
VB : constant VSI_View := To_View (B);
D : VSI_View;
begin
D.Values := LL_VSI_Operations.vcmpgtsx (VA.Values, VB.Values);
return To_Vector (D);
end vcmpgtsw;
--------------
-- vcmpgtfp --
--------------
function vcmpgtfp (A : LL_VF; B : LL_VF) return LL_VSI is
VA : constant VF_View := To_View (A);
VB : constant VF_View := To_View (B);
D : VSI_View;
begin
for J in Varray_float'Range loop
D.Values (Vint_Range (J)) :=
(if NJ_Truncate (VA.Values (J)) > NJ_Truncate (VB.Values (J))
then Signed_Bool_True else Signed_Bool_False);
end loop;
return To_Vector (D);
end vcmpgtfp;
-----------
-- vcfux --
-----------
function vcfux (A : LL_VUI; B : c_int) return LL_VF is
VA : constant VUI_View := To_View (A);
D : VF_View;
K : Vfloat_Range;
begin
for J in Varray_signed_int'Range loop
K := Vfloat_Range (J);
-- Note: The conversion to Integer is safe, as Integers are required
-- to include the range -2 ** 15 + 1 .. 2 ** 15 + 1 and therefore
-- include the range of B (should be 0 .. 255).
D.Values (K) :=
C_float (VA.Values (J)) / (2.0 ** Integer (B));
end loop;
return To_Vector (D);
end vcfux;
-----------
-- vcfsx --
-----------
function vcfsx (A : LL_VSI; B : c_int) return LL_VF is
VA : constant VSI_View := To_View (A);
D : VF_View;
K : Vfloat_Range;
begin
for J in Varray_signed_int'Range loop
K := Vfloat_Range (J);
D.Values (K) := C_float (VA.Values (J))
/ (2.0 ** Integer (B));
end loop;
return To_Vector (D);
end vcfsx;
------------
-- vctsxs --
------------
function vctsxs (A : LL_VF; B : c_int) return LL_VSI is
VA : constant VF_View := To_View (A);
D : VSI_View;
K : Vfloat_Range;
begin
for J in Varray_signed_int'Range loop
K := Vfloat_Range (J);
D.Values (J) :=
LL_VSI_Operations.Saturate
(F64 (NJ_Truncate (VA.Values (K)))
* F64 (2.0 ** Integer (B)));
end loop;
return To_Vector (D);
end vctsxs;
------------
-- vctuxs --
------------
function vctuxs (A : LL_VF; B : c_int) return LL_VUI is
VA : constant VF_View := To_View (A);
D : VUI_View;
K : Vfloat_Range;
begin
for J in Varray_unsigned_int'Range loop
K := Vfloat_Range (J);
D.Values (J) :=
LL_VUI_Operations.Saturate
(F64 (NJ_Truncate (VA.Values (K)))
* F64 (2.0 ** Integer (B)));
end loop;
return To_Vector (D);
end vctuxs;
---------
-- dss --
---------
-- No-ops, as allowed by [PEM-5.2.1.1 Data Stream Touch (dst)]:
procedure dss (A : c_int) is
pragma Unreferenced (A);
begin
null;
end dss;
------------
-- dssall --
------------
-- No-ops, as allowed by [PEM-5.2.1.1 Data Stream Touch (dst)]:
procedure dssall is
begin
null;
end dssall;
---------
-- dst --
---------
-- No-ops, as allowed by [PEM-5.2.1.1 Data Stream Touch (dst)]:
procedure dst (A : c_ptr; B : c_int; C : c_int) is
pragma Unreferenced (A);
pragma Unreferenced (B);
pragma Unreferenced (C);
begin
null;
end dst;
-----------
-- dstst --
-----------
-- No-ops, as allowed by [PEM-5.2.1.1 Data Stream Touch (dst)]:
procedure dstst (A : c_ptr; B : c_int; C : c_int) is
pragma Unreferenced (A);
pragma Unreferenced (B);
pragma Unreferenced (C);
begin
null;
end dstst;
------------
-- dststt --
------------
-- No-ops, as allowed by [PEM-5.2.1.1 Data Stream Touch (dst)]:
procedure dststt (A : c_ptr; B : c_int; C : c_int) is
pragma Unreferenced (A);
pragma Unreferenced (B);
pragma Unreferenced (C);
begin
null;
end dststt;
----------
-- dstt --
----------
-- No-ops, as allowed by [PEM-5.2.1.1 Data Stream Touch (dst)]:
procedure dstt (A : c_ptr; B : c_int; C : c_int) is
pragma Unreferenced (A);
pragma Unreferenced (B);
pragma Unreferenced (C);
begin
null;
end dstt;
--------------
-- vexptefp --
--------------
function vexptefp (A : LL_VF) return LL_VF is
use C_float_Operations;
VA : constant VF_View := To_View (A);
D : VF_View;
begin
for J in Varray_float'Range loop
-- ??? Check the precision of the operation.
-- As described in [PEM-6 vexptefp]:
-- If theoretical_result is equal to 2 at the power of A (J) with
-- infinite precision, we should have:
-- abs ((D (J) - theoretical_result) / theoretical_result) <= 1/16
D.Values (J) := 2.0 ** NJ_Truncate (VA.Values (J));
end loop;
return To_Vector (D);
end vexptefp;
-----------
-- vrfim --
-----------
function vrfim (A : LL_VF) return LL_VF is
VA : constant VF_View := To_View (A);
D : VF_View;
begin
for J in Varray_float'Range loop
-- If A (J) is infinite, D (J) should be infinite; With
-- IEEE floating point, we can use 'Ceiling for that purpose.
D.Values (J) := C_float'Ceiling (NJ_Truncate (VA.Values (J)));
-- Vrfim rounds toward -Infinity, whereas 'Ceiling rounds toward
-- +Infinity:
if D.Values (J) /= VA.Values (J) then
D.Values (J) := D.Values (J) - 1.0;
end if;
end loop;
return To_Vector (D);
end vrfim;
---------
-- lvx --
---------
function lvx (A : c_long; B : c_ptr) return LL_VSI is
-- Simulate the altivec unit behavior regarding what Effective Address
-- is accessed, stripping off the input address least significant bits
-- wrt to vector alignment.
-- On targets where VECTOR_ALIGNMENT is less than the vector size (16),
-- an address within a vector is not necessarily rounded back at the
-- vector start address. Besides, rounding on 16 makes no sense on such
-- targets because the address of a properly aligned vector (that is,
-- a proper multiple of VECTOR_ALIGNMENT) could be affected, which we
-- want never to happen.
EA : constant System.Address :=
To_Address
(Bound_Align
(Integer_Address (A) + To_Integer (B), VECTOR_ALIGNMENT));
D : LL_VSI;
for D'Address use EA;
begin
return D;
end lvx;
-----------
-- lvebx --
-----------
function lvebx (A : c_long; B : c_ptr) return LL_VSC is
D : VSC_View;
begin
D.Values := LL_VSC_Operations.lvexx (A, B);
return To_Vector (D);
end lvebx;
-----------
-- lvehx --
-----------
function lvehx (A : c_long; B : c_ptr) return LL_VSS is
D : VSS_View;
begin
D.Values := LL_VSS_Operations.lvexx (A, B);
return To_Vector (D);
end lvehx;
-----------
-- lvewx --
-----------
function lvewx (A : c_long; B : c_ptr) return LL_VSI is
D : VSI_View;
begin
D.Values := LL_VSI_Operations.lvexx (A, B);
return To_Vector (D);
end lvewx;
----------
-- lvxl --
----------
function lvxl (A : c_long; B : c_ptr) return LL_VSI renames
lvx;
-------------
-- vlogefp --
-------------
function vlogefp (A : LL_VF) return LL_VF is
VA : constant VF_View := To_View (A);
D : VF_View;
begin
for J in Varray_float'Range loop
-- ??? Check the precision of the operation.
-- As described in [PEM-6 vlogefp]:
-- If theorical_result is equal to the log2 of A (J) with
-- infinite precision, we should have:
-- abs (D (J) - theorical_result) <= 1/32,
-- unless abs(D(J) - 1) <= 1/8.
D.Values (J) :=
C_float_Operations.Log (NJ_Truncate (VA.Values (J)), 2.0);
end loop;
return To_Vector (D);
end vlogefp;
----------
-- lvsl --
----------
function lvsl (A : c_long; B : c_ptr) return LL_VSC is
type bit4_type is mod 16#F# + 1;
for bit4_type'Alignment use 1;
EA : Integer_Address;
D : VUC_View;
SH : bit4_type;
begin
EA := Integer_Address (A) + To_Integer (B);
SH := bit4_type (EA mod 2 ** 4);
for J in D.Values'Range loop
D.Values (J) := unsigned_char (SH) + unsigned_char (J)
- unsigned_char (D.Values'First);
end loop;
return To_LL_VSC (To_Vector (D));
end lvsl;
----------
-- lvsr --
----------
function lvsr (A : c_long; B : c_ptr) return LL_VSC is
type bit4_type is mod 16#F# + 1;
for bit4_type'Alignment use 1;
EA : Integer_Address;
D : VUC_View;
SH : bit4_type;
begin
EA := Integer_Address (A) + To_Integer (B);
SH := bit4_type (EA mod 2 ** 4);
for J in D.Values'Range loop
D.Values (J) := (16#F# - unsigned_char (SH)) + unsigned_char (J);
end loop;
return To_LL_VSC (To_Vector (D));
end lvsr;
-------------
-- vmaddfp --
-------------
function vmaddfp (A : LL_VF; B : LL_VF; C : LL_VF) return LL_VF is
VA : constant VF_View := To_View (A);
VB : constant VF_View := To_View (B);
VC : constant VF_View := To_View (C);
D : VF_View;
begin
for J in Varray_float'Range loop
D.Values (J) :=
Rnd_To_FP_Nearest (F64 (VA.Values (J))
* F64 (VB.Values (J))
+ F64 (VC.Values (J)));
end loop;
return To_Vector (D);
end vmaddfp;
---------------
-- vmhaddshs --
---------------
function vmhaddshs (A : LL_VSS; B : LL_VSS; C : LL_VSS) return LL_VSS is
VA : constant VSS_View := To_View (A);
VB : constant VSS_View := To_View (B);
VC : constant VSS_View := To_View (C);
D : VSS_View;
begin
for J in Varray_signed_short'Range loop
D.Values (J) := LL_VSS_Operations.Saturate
((SI64 (VA.Values (J)) * SI64 (VB.Values (J)))
/ SI64 (2 ** 15) + SI64 (VC.Values (J)));
end loop;
return To_Vector (D);
end vmhaddshs;
------------
-- vmaxub --
------------
function vmaxub (A : LL_VSC; B : LL_VSC) return LL_VSC is
VA : constant VUC_View := To_View (To_LL_VUC (A));
VB : constant VUC_View := To_View (To_LL_VUC (B));
D : VUC_View;
begin
D.Values := LL_VUC_Operations.vmaxux (VA.Values, VB.Values);
return To_LL_VSC (To_Vector (D));
end vmaxub;
------------
-- vmaxsb --
------------
function vmaxsb (A : LL_VSC; B : LL_VSC) return LL_VSC is
VA : constant VSC_View := To_View (A);
VB : constant VSC_View := To_View (B);
D : VSC_View;
begin
D.Values := LL_VSC_Operations.vmaxsx (VA.Values, VB.Values);
return To_Vector (D);
end vmaxsb;
------------
-- vmaxuh --
------------
function vmaxuh (A : LL_VSS; B : LL_VSS) return LL_VSS is
VA : constant VUS_View := To_View (To_LL_VUS (A));
VB : constant VUS_View := To_View (To_LL_VUS (B));
D : VUS_View;
begin
D.Values := LL_VUS_Operations.vmaxux (VA.Values, VB.Values);
return To_LL_VSS (To_Vector (D));
end vmaxuh;
------------
-- vmaxsh --
------------
function vmaxsh (A : LL_VSS; B : LL_VSS) return LL_VSS is
VA : constant VSS_View := To_View (A);
VB : constant VSS_View := To_View (B);
D : VSS_View;
begin
D.Values := LL_VSS_Operations.vmaxsx (VA.Values, VB.Values);
return To_Vector (D);
end vmaxsh;
------------
-- vmaxuw --
------------
function vmaxuw (A : LL_VSI; B : LL_VSI) return LL_VSI is
VA : constant VUI_View := To_View (To_LL_VUI (A));
VB : constant VUI_View := To_View (To_LL_VUI (B));
D : VUI_View;
begin
D.Values := LL_VUI_Operations.vmaxux (VA.Values, VB.Values);
return To_LL_VSI (To_Vector (D));
end vmaxuw;
------------
-- vmaxsw --
------------
function vmaxsw (A : LL_VSI; B : LL_VSI) return LL_VSI is
VA : constant VSI_View := To_View (A);
VB : constant VSI_View := To_View (B);
D : VSI_View;
begin
D.Values := LL_VSI_Operations.vmaxsx (VA.Values, VB.Values);
return To_Vector (D);
end vmaxsw;
--------------
-- vmaxsxfp --
--------------
function vmaxfp (A : LL_VF; B : LL_VF) return LL_VF is
VA : constant VF_View := To_View (A);
VB : constant VF_View := To_View (B);
D : VF_View;
begin
for J in Varray_float'Range loop
D.Values (J) := (if VA.Values (J) > VB.Values (J) then VA.Values (J)
else VB.Values (J));
end loop;
return To_Vector (D);
end vmaxfp;
------------
-- vmrghb --
------------
function vmrghb (A : LL_VSC; B : LL_VSC) return LL_VSC is
VA : constant VSC_View := To_View (A);
VB : constant VSC_View := To_View (B);
D : VSC_View;
begin
D.Values := LL_VSC_Operations.vmrghx (VA.Values, VB.Values);
return To_Vector (D);
end vmrghb;
------------
-- vmrghh --
------------
function vmrghh (A : LL_VSS; B : LL_VSS) return LL_VSS is
VA : constant VSS_View := To_View (A);
VB : constant VSS_View := To_View (B);
D : VSS_View;
begin
D.Values := LL_VSS_Operations.vmrghx (VA.Values, VB.Values);
return To_Vector (D);
end vmrghh;
------------
-- vmrghw --
------------
function vmrghw (A : LL_VSI; B : LL_VSI) return LL_VSI is
VA : constant VSI_View := To_View (A);
VB : constant VSI_View := To_View (B);
D : VSI_View;
begin
D.Values := LL_VSI_Operations.vmrghx (VA.Values, VB.Values);
return To_Vector (D);
end vmrghw;
------------
-- vmrglb --
------------
function vmrglb (A : LL_VSC; B : LL_VSC) return LL_VSC is
VA : constant VSC_View := To_View (A);
VB : constant VSC_View := To_View (B);
D : VSC_View;
begin
D.Values := LL_VSC_Operations.vmrglx (VA.Values, VB.Values);
return To_Vector (D);
end vmrglb;
------------
-- vmrglh --
------------
function vmrglh (A : LL_VSS; B : LL_VSS) return LL_VSS is
VA : constant VSS_View := To_View (A);
VB : constant VSS_View := To_View (B);
D : VSS_View;
begin
D.Values := LL_VSS_Operations.vmrglx (VA.Values, VB.Values);
return To_Vector (D);
end vmrglh;
------------
-- vmrglw --
------------
function vmrglw (A : LL_VSI; B : LL_VSI) return LL_VSI is
VA : constant VSI_View := To_View (A);
VB : constant VSI_View := To_View (B);
D : VSI_View;
begin
D.Values := LL_VSI_Operations.vmrglx (VA.Values, VB.Values);
return To_Vector (D);
end vmrglw;
------------
-- mfvscr --
------------
function mfvscr return LL_VSS is
D : VUS_View;
begin
for J in Varray_unsigned_short'Range loop
D.Values (J) := 0;
end loop;
D.Values (Varray_unsigned_short'Last) :=
unsigned_short (VSCR mod 2 ** unsigned_short'Size);
D.Values (Varray_unsigned_short'Last - 1) :=
unsigned_short (VSCR / 2 ** unsigned_short'Size);
return To_LL_VSS (To_Vector (D));
end mfvscr;
------------
-- vminfp --
------------
function vminfp (A : LL_VF; B : LL_VF) return LL_VF is
VA : constant VF_View := To_View (A);
VB : constant VF_View := To_View (B);
D : VF_View;
begin
for J in Varray_float'Range loop
D.Values (J) := (if VA.Values (J) < VB.Values (J) then VA.Values (J)
else VB.Values (J));
end loop;
return To_Vector (D);
end vminfp;
------------
-- vminsb --
------------
function vminsb (A : LL_VSC; B : LL_VSC) return LL_VSC is
VA : constant VSC_View := To_View (A);
VB : constant VSC_View := To_View (B);
D : VSC_View;
begin
D.Values := LL_VSC_Operations.vminsx (VA.Values, VB.Values);
return To_Vector (D);
end vminsb;
------------
-- vminub --
------------
function vminub (A : LL_VSC; B : LL_VSC) return LL_VSC is
VA : constant VUC_View := To_View (To_LL_VUC (A));
VB : constant VUC_View := To_View (To_LL_VUC (B));
D : VUC_View;
begin
D.Values := LL_VUC_Operations.vminux (VA.Values, VB.Values);
return To_LL_VSC (To_Vector (D));
end vminub;
------------
-- vminsh --
------------
function vminsh (A : LL_VSS; B : LL_VSS) return LL_VSS is
VA : constant VSS_View := To_View (A);
VB : constant VSS_View := To_View (B);
D : VSS_View;
begin
D.Values := LL_VSS_Operations.vminsx (VA.Values, VB.Values);
return To_Vector (D);
end vminsh;
------------
-- vminuh --
------------
function vminuh (A : LL_VSS; B : LL_VSS) return LL_VSS is
VA : constant VUS_View := To_View (To_LL_VUS (A));
VB : constant VUS_View := To_View (To_LL_VUS (B));
D : VUS_View;
begin
D.Values := LL_VUS_Operations.vminux (VA.Values, VB.Values);
return To_LL_VSS (To_Vector (D));
end vminuh;
------------
-- vminsw --
------------
function vminsw (A : LL_VSI; B : LL_VSI) return LL_VSI is
VA : constant VSI_View := To_View (A);
VB : constant VSI_View := To_View (B);
D : VSI_View;
begin
D.Values := LL_VSI_Operations.vminsx (VA.Values, VB.Values);
return To_Vector (D);
end vminsw;
------------
-- vminuw --
------------
function vminuw (A : LL_VSI; B : LL_VSI) return LL_VSI is
VA : constant VUI_View := To_View (To_LL_VUI (A));
VB : constant VUI_View := To_View (To_LL_VUI (B));
D : VUI_View;
begin
D.Values := LL_VUI_Operations.vminux (VA.Values,
VB.Values);
return To_LL_VSI (To_Vector (D));
end vminuw;
---------------
-- vmladduhm --
---------------
function vmladduhm (A : LL_VSS; B : LL_VSS; C : LL_VSS) return LL_VSS is
VA : constant VUS_View := To_View (To_LL_VUS (A));
VB : constant VUS_View := To_View (To_LL_VUS (B));
VC : constant VUS_View := To_View (To_LL_VUS (C));
D : VUS_View;
begin
for J in Varray_unsigned_short'Range loop
D.Values (J) := VA.Values (J) * VB.Values (J)
+ VC.Values (J);
end loop;
return To_LL_VSS (To_Vector (D));
end vmladduhm;
----------------
-- vmhraddshs --
----------------
function vmhraddshs (A : LL_VSS; B : LL_VSS; C : LL_VSS) return LL_VSS is
VA : constant VSS_View := To_View (A);
VB : constant VSS_View := To_View (B);
VC : constant VSS_View := To_View (C);
D : VSS_View;
begin
for J in Varray_signed_short'Range loop
D.Values (J) :=
LL_VSS_Operations.Saturate (((SI64 (VA.Values (J))
* SI64 (VB.Values (J))
+ 2 ** 14)
/ 2 ** 15
+ SI64 (VC.Values (J))));
end loop;
return To_Vector (D);
end vmhraddshs;
--------------
-- vmsumubm --
--------------
function vmsumubm (A : LL_VSC; B : LL_VSC; C : LL_VSI) return LL_VSI is
Offset : Vchar_Range;
VA : constant VUC_View := To_View (To_LL_VUC (A));
VB : constant VUC_View := To_View (To_LL_VUC (B));
VC : constant VUI_View := To_View (To_LL_VUI (C));
D : VUI_View;
begin
for J in 0 .. 3 loop
Offset := Vchar_Range (4 * J + Integer (Vchar_Range'First));
D.Values (Vint_Range
(J + Integer (Vint_Range'First))) :=
(unsigned_int (VA.Values (Offset))
* unsigned_int (VB.Values (Offset)))
+ (unsigned_int (VA.Values (Offset + 1))
* unsigned_int (VB.Values (1 + Offset)))
+ (unsigned_int (VA.Values (2 + Offset))
* unsigned_int (VB.Values (2 + Offset)))
+ (unsigned_int (VA.Values (3 + Offset))
* unsigned_int (VB.Values (3 + Offset)))
+ VC.Values (Vint_Range
(J + Integer (Varray_unsigned_int'First)));
end loop;
return To_LL_VSI (To_Vector (D));
end vmsumubm;
--------------
-- vmsumumbm --
--------------
function vmsummbm (A : LL_VSC; B : LL_VSC; C : LL_VSI) return LL_VSI is
Offset : Vchar_Range;
VA : constant VSC_View := To_View (A);
VB : constant VUC_View := To_View (To_LL_VUC (B));
VC : constant VSI_View := To_View (C);
D : VSI_View;
begin
for J in 0 .. 3 loop
Offset := Vchar_Range (4 * J + Integer (Vchar_Range'First));
D.Values (Vint_Range
(J + Integer (Varray_unsigned_int'First))) := 0
+ LL_VSI_Operations.Modular_Result (SI64 (VA.Values (Offset))
* SI64 (VB.Values (Offset)))
+ LL_VSI_Operations.Modular_Result (SI64 (VA.Values (Offset + 1))
* SI64 (VB.Values
(1 + Offset)))
+ LL_VSI_Operations.Modular_Result (SI64 (VA.Values (2 + Offset))
* SI64 (VB.Values
(2 + Offset)))
+ LL_VSI_Operations.Modular_Result (SI64 (VA.Values (3 + Offset))
* SI64 (VB.Values
(3 + Offset)))
+ VC.Values (Vint_Range
(J + Integer (Varray_unsigned_int'First)));
end loop;
return To_Vector (D);
end vmsummbm;
--------------
-- vmsumuhm --
--------------
function vmsumuhm (A : LL_VSS; B : LL_VSS; C : LL_VSI) return LL_VSI is
Offset : Vshort_Range;
VA : constant VUS_View := To_View (To_LL_VUS (A));
VB : constant VUS_View := To_View (To_LL_VUS (B));
VC : constant VUI_View := To_View (To_LL_VUI (C));
D : VUI_View;
begin
for J in 0 .. 3 loop
Offset :=
Vshort_Range (2 * J + Integer (Vshort_Range'First));
D.Values (Vint_Range
(J + Integer (Varray_unsigned_int'First))) :=
(unsigned_int (VA.Values (Offset))
* unsigned_int (VB.Values (Offset)))
+ (unsigned_int (VA.Values (Offset + 1))
* unsigned_int (VB.Values (1 + Offset)))
+ VC.Values (Vint_Range
(J + Integer (Vint_Range'First)));
end loop;
return To_LL_VSI (To_Vector (D));
end vmsumuhm;
--------------
-- vmsumshm --
--------------
function vmsumshm (A : LL_VSS; B : LL_VSS; C : LL_VSI) return LL_VSI is
VA : constant VSS_View := To_View (A);
VB : constant VSS_View := To_View (B);
VC : constant VSI_View := To_View (C);
Offset : Vshort_Range;
D : VSI_View;
begin
for J in 0 .. 3 loop
Offset :=
Vshort_Range (2 * J + Integer (Varray_signed_char'First));
D.Values (Vint_Range
(J + Integer (Varray_unsigned_int'First))) := 0
+ LL_VSI_Operations.Modular_Result (SI64 (VA.Values (Offset))
* SI64 (VB.Values (Offset)))
+ LL_VSI_Operations.Modular_Result (SI64 (VA.Values (Offset + 1))
* SI64 (VB.Values
(1 + Offset)))
+ VC.Values (Vint_Range
(J + Integer (Varray_unsigned_int'First)));
end loop;
return To_Vector (D);
end vmsumshm;
--------------
-- vmsumuhs --
--------------
function vmsumuhs (A : LL_VSS; B : LL_VSS; C : LL_VSI) return LL_VSI is
Offset : Vshort_Range;
VA : constant VUS_View := To_View (To_LL_VUS (A));
VB : constant VUS_View := To_View (To_LL_VUS (B));
VC : constant VUI_View := To_View (To_LL_VUI (C));
D : VUI_View;
begin
for J in 0 .. 3 loop
Offset :=
Vshort_Range (2 * J + Integer (Varray_signed_short'First));
D.Values (Vint_Range
(J + Integer (Varray_unsigned_int'First))) :=
LL_VUI_Operations.Saturate
(UI64 (VA.Values (Offset))
* UI64 (VB.Values (Offset))
+ UI64 (VA.Values (Offset + 1))
* UI64 (VB.Values (1 + Offset))
+ UI64 (VC.Values
(Vint_Range
(J + Integer (Varray_unsigned_int'First)))));
end loop;
return To_LL_VSI (To_Vector (D));
end vmsumuhs;
--------------
-- vmsumshs --
--------------
function vmsumshs (A : LL_VSS; B : LL_VSS; C : LL_VSI) return LL_VSI is
VA : constant VSS_View := To_View (A);
VB : constant VSS_View := To_View (B);
VC : constant VSI_View := To_View (C);
Offset : Vshort_Range;
D : VSI_View;
begin
for J in 0 .. 3 loop
Offset :=
Vshort_Range (2 * J + Integer (Varray_signed_short'First));
D.Values (Vint_Range
(J + Integer (Varray_signed_int'First))) :=
LL_VSI_Operations.Saturate
(SI64 (VA.Values (Offset))
* SI64 (VB.Values (Offset))
+ SI64 (VA.Values (Offset + 1))
* SI64 (VB.Values (1 + Offset))
+ SI64 (VC.Values
(Vint_Range
(J + Integer (Varray_signed_int'First)))));
end loop;
return To_Vector (D);
end vmsumshs;
------------
-- mtvscr --
------------
procedure mtvscr (A : LL_VSI) is
VA : constant VUI_View := To_View (To_LL_VUI (A));
begin
VSCR := VA.Values (Varray_unsigned_int'Last);
end mtvscr;
-------------
-- vmuleub --
-------------
function vmuleub (A : LL_VSC; B : LL_VSC) return LL_VSS is
VA : constant VUC_View := To_View (To_LL_VUC (A));
VB : constant VUC_View := To_View (To_LL_VUC (B));
D : VUS_View;
begin
D.Values := LL_VUC_LL_VUS_Operations.vmulxux (True,
VA.Values,
VB.Values);
return To_LL_VSS (To_Vector (D));
end vmuleub;
-------------
-- vmuleuh --
-------------
function vmuleuh (A : LL_VSS; B : LL_VSS) return LL_VSI is
VA : constant VUS_View := To_View (To_LL_VUS (A));
VB : constant VUS_View := To_View (To_LL_VUS (B));
D : VUI_View;
begin
D.Values := LL_VUS_LL_VUI_Operations.vmulxux (True,
VA.Values,
VB.Values);
return To_LL_VSI (To_Vector (D));
end vmuleuh;
-------------
-- vmulesb --
-------------
function vmulesb (A : LL_VSC; B : LL_VSC) return LL_VSS is
VA : constant VSC_View := To_View (A);
VB : constant VSC_View := To_View (B);
D : VSS_View;
begin
D.Values := LL_VSC_LL_VSS_Operations.vmulxsx (True,
VA.Values,
VB.Values);
return To_Vector (D);
end vmulesb;
-------------
-- vmulesh --
-------------
function vmulesh (A : LL_VSS; B : LL_VSS) return LL_VSI is
VA : constant VSS_View := To_View (A);
VB : constant VSS_View := To_View (B);
D : VSI_View;
begin
D.Values := LL_VSS_LL_VSI_Operations.vmulxsx (True,
VA.Values,
VB.Values);
return To_Vector (D);
end vmulesh;
-------------
-- vmuloub --
-------------
function vmuloub (A : LL_VSC; B : LL_VSC) return LL_VSS is
VA : constant VUC_View := To_View (To_LL_VUC (A));
VB : constant VUC_View := To_View (To_LL_VUC (B));
D : VUS_View;
begin
D.Values := LL_VUC_LL_VUS_Operations.vmulxux (False,
VA.Values,
VB.Values);
return To_LL_VSS (To_Vector (D));
end vmuloub;
-------------
-- vmulouh --
-------------
function vmulouh (A : LL_VSS; B : LL_VSS) return LL_VSI is
VA : constant VUS_View := To_View (To_LL_VUS (A));
VB : constant VUS_View := To_View (To_LL_VUS (B));
D : VUI_View;
begin
D.Values :=
LL_VUS_LL_VUI_Operations.vmulxux (False, VA.Values, VB.Values);
return To_LL_VSI (To_Vector (D));
end vmulouh;
-------------
-- vmulosb --
-------------
function vmulosb (A : LL_VSC; B : LL_VSC) return LL_VSS is
VA : constant VSC_View := To_View (A);
VB : constant VSC_View := To_View (B);
D : VSS_View;
begin
D.Values := LL_VSC_LL_VSS_Operations.vmulxsx (False,
VA.Values,
VB.Values);
return To_Vector (D);
end vmulosb;
-------------
-- vmulosh --
-------------
function vmulosh (A : LL_VSS; B : LL_VSS) return LL_VSI is
VA : constant VSS_View := To_View (A);
VB : constant VSS_View := To_View (B);
D : VSI_View;
begin
D.Values := LL_VSS_LL_VSI_Operations.vmulxsx (False,
VA.Values,
VB.Values);
return To_Vector (D);
end vmulosh;
--------------
-- vnmsubfp --
--------------
function vnmsubfp (A : LL_VF; B : LL_VF; C : LL_VF) return LL_VF is
VA : constant VF_View := To_View (A);
VB : constant VF_View := To_View (B);
VC : constant VF_View := To_View (C);
D : VF_View;
begin
for J in Vfloat_Range'Range loop
D.Values (J) :=
-Rnd_To_FP_Nearest (F64 (VA.Values (J))
* F64 (VB.Values (J))
- F64 (VC.Values (J)));
end loop;
return To_Vector (D);
end vnmsubfp;
----------
-- vnor --
----------
function vnor (A : LL_VSI; B : LL_VSI) return LL_VSI is
VA : constant VUI_View := To_View (To_LL_VUI (A));
VB : constant VUI_View := To_View (To_LL_VUI (B));
D : VUI_View;
begin
for J in Vint_Range'Range loop
D.Values (J) := not (VA.Values (J) or VB.Values (J));
end loop;
return To_LL_VSI (To_Vector (D));
end vnor;
----------
-- vor --
----------
function vor (A : LL_VSI; B : LL_VSI) return LL_VSI is
VA : constant VUI_View := To_View (To_LL_VUI (A));
VB : constant VUI_View := To_View (To_LL_VUI (B));
D : VUI_View;
begin
for J in Vint_Range'Range loop
D.Values (J) := VA.Values (J) or VB.Values (J);
end loop;
return To_LL_VSI (To_Vector (D));
end vor;
-------------
-- vpkuhum --
-------------
function vpkuhum (A : LL_VSS; B : LL_VSS) return LL_VSC is
VA : constant VUS_View := To_View (To_LL_VUS (A));
VB : constant VUS_View := To_View (To_LL_VUS (B));
D : VUC_View;
begin
D.Values := LL_VUC_LL_VUS_Operations.vpkuxum (VA.Values, VB.Values);
return To_LL_VSC (To_Vector (D));
end vpkuhum;
-------------
-- vpkuwum --
-------------
function vpkuwum (A : LL_VSI; B : LL_VSI) return LL_VSS is
VA : constant VUI_View := To_View (To_LL_VUI (A));
VB : constant VUI_View := To_View (To_LL_VUI (B));
D : VUS_View;
begin
D.Values := LL_VUS_LL_VUI_Operations.vpkuxum (VA.Values, VB.Values);
return To_LL_VSS (To_Vector (D));
end vpkuwum;
-----------
-- vpkpx --
-----------
function vpkpx (A : LL_VSI; B : LL_VSI) return LL_VSS is
VA : constant VUI_View := To_View (To_LL_VUI (A));
VB : constant VUI_View := To_View (To_LL_VUI (B));
D : VUS_View;
Offset : Vint_Range;
P16 : Pixel_16;
P32 : Pixel_32;
begin
for J in 0 .. 3 loop
Offset := Vint_Range (J + Integer (Vshort_Range'First));
P32 := To_Pixel (VA.Values (Offset));
P16.T := Unsigned_1 (P32.T mod 2 ** 1);
P16.R := Unsigned_5 (Shift_Right (P32.R, 3) mod 2 ** 5);
P16.G := Unsigned_5 (Shift_Right (P32.G, 3) mod 2 ** 5);
P16.B := Unsigned_5 (Shift_Right (P32.B, 3) mod 2 ** 5);
D.Values (Vshort_Range (Offset)) := To_unsigned_short (P16);
P32 := To_Pixel (VB.Values (Offset));
P16.T := Unsigned_1 (P32.T mod 2 ** 1);
P16.R := Unsigned_5 (Shift_Right (P32.R, 3) mod 2 ** 5);
P16.G := Unsigned_5 (Shift_Right (P32.G, 3) mod 2 ** 5);
P16.B := Unsigned_5 (Shift_Right (P32.B, 3) mod 2 ** 5);
D.Values (Vshort_Range (Offset) + 4) := To_unsigned_short (P16);
end loop;
return To_LL_VSS (To_Vector (D));
end vpkpx;
-------------
-- vpkuhus --
-------------
function vpkuhus (A : LL_VSS; B : LL_VSS) return LL_VSC is
VA : constant VUS_View := To_View (To_LL_VUS (A));
VB : constant VUS_View := To_View (To_LL_VUS (B));
D : VUC_View;
begin
D.Values := LL_VUC_LL_VUS_Operations.vpkuxus (VA.Values, VB.Values);
return To_LL_VSC (To_Vector (D));
end vpkuhus;
-------------
-- vpkuwus --
-------------
function vpkuwus (A : LL_VSI; B : LL_VSI) return LL_VSS is
VA : constant VUI_View := To_View (To_LL_VUI (A));
VB : constant VUI_View := To_View (To_LL_VUI (B));
D : VUS_View;
begin
D.Values := LL_VUS_LL_VUI_Operations.vpkuxus (VA.Values, VB.Values);
return To_LL_VSS (To_Vector (D));
end vpkuwus;
-------------
-- vpkshss --
-------------
function vpkshss (A : LL_VSS; B : LL_VSS) return LL_VSC is
VA : constant VSS_View := To_View (A);
VB : constant VSS_View := To_View (B);
D : VSC_View;
begin
D.Values := LL_VSC_LL_VSS_Operations.vpksxss (VA.Values, VB.Values);
return To_Vector (D);
end vpkshss;
-------------
-- vpkswss --
-------------
function vpkswss (A : LL_VSI; B : LL_VSI) return LL_VSS is
VA : constant VSI_View := To_View (A);
VB : constant VSI_View := To_View (B);
D : VSS_View;
begin
D.Values := LL_VSS_LL_VSI_Operations.vpksxss (VA.Values, VB.Values);
return To_Vector (D);
end vpkswss;
-------------
-- vpksxus --
-------------
generic
type Signed_Component_Type is range <>;
type Signed_Index_Type is range <>;
type Signed_Varray_Type is
array (Signed_Index_Type) of Signed_Component_Type;
type Unsigned_Component_Type is mod <>;
type Unsigned_Index_Type is range <>;
type Unsigned_Varray_Type is
array (Unsigned_Index_Type) of Unsigned_Component_Type;
function vpksxus
(A : Signed_Varray_Type;
B : Signed_Varray_Type) return Unsigned_Varray_Type;
function vpksxus
(A : Signed_Varray_Type;
B : Signed_Varray_Type) return Unsigned_Varray_Type
is
N : constant Unsigned_Index_Type :=
Unsigned_Index_Type (Signed_Index_Type'Last);
Offset : Unsigned_Index_Type;
Signed_Offset : Signed_Index_Type;
D : Unsigned_Varray_Type;
function Saturate
(X : Signed_Component_Type) return Unsigned_Component_Type;
-- Saturation, as defined in
-- [PIM-4.1 Vector Status and Control Register]
--------------
-- Saturate --
--------------
function Saturate
(X : Signed_Component_Type) return Unsigned_Component_Type
is
D : Unsigned_Component_Type;
begin
D := Unsigned_Component_Type
(Signed_Component_Type'Max
(Signed_Component_Type (Unsigned_Component_Type'First),
Signed_Component_Type'Min
(Signed_Component_Type (Unsigned_Component_Type'Last),
X)));
if Signed_Component_Type (D) /= X then
VSCR := Write_Bit (VSCR, SAT_POS, 1);
end if;
return D;
end Saturate;
-- Start of processing for vpksxus
begin
for J in 0 .. N - 1 loop
Offset :=
Unsigned_Index_Type (Integer (J)
+ Integer (Unsigned_Index_Type'First));
Signed_Offset :=
Signed_Index_Type (Integer (J)
+ Integer (Signed_Index_Type'First));
D (Offset) := Saturate (A (Signed_Offset));
D (Offset + N) := Saturate (B (Signed_Offset));
end loop;
return D;
end vpksxus;
-------------
-- vpkshus --
-------------
function vpkshus (A : LL_VSS; B : LL_VSS) return LL_VSC is
function vpkshus_Instance is
new vpksxus (signed_short,
Vshort_Range,
Varray_signed_short,
unsigned_char,
Vchar_Range,
Varray_unsigned_char);
VA : constant VSS_View := To_View (A);
VB : constant VSS_View := To_View (B);
D : VUC_View;
begin
D.Values := vpkshus_Instance (VA.Values, VB.Values);
return To_LL_VSC (To_Vector (D));
end vpkshus;
-------------
-- vpkswus --
-------------
function vpkswus (A : LL_VSI; B : LL_VSI) return LL_VSS is
function vpkswus_Instance is
new vpksxus (signed_int,
Vint_Range,
Varray_signed_int,
unsigned_short,
Vshort_Range,
Varray_unsigned_short);
VA : constant VSI_View := To_View (A);
VB : constant VSI_View := To_View (B);
D : VUS_View;
begin
D.Values := vpkswus_Instance (VA.Values, VB.Values);
return To_LL_VSS (To_Vector (D));
end vpkswus;
---------------
-- vperm_4si --
---------------
function vperm_4si (A : LL_VSI; B : LL_VSI; C : LL_VSC) return LL_VSI is
VA : constant VUC_View := To_View (To_LL_VUC (A));
VB : constant VUC_View := To_View (To_LL_VUC (B));
VC : constant VUC_View := To_View (To_LL_VUC (C));
J : Vchar_Range;
D : VUC_View;
begin
for N in Vchar_Range'Range loop
J := Vchar_Range (Integer (Bits (VC.Values (N), 4, 7))
+ Integer (Vchar_Range'First));
D.Values (N) :=
(if Bits (VC.Values (N), 3, 3) = 0 then VA.Values (J)
else VB.Values (J));
end loop;
return To_LL_VSI (To_Vector (D));
end vperm_4si;
-----------
-- vrefp --
-----------
function vrefp (A : LL_VF) return LL_VF is
VA : constant VF_View := To_View (A);
D : VF_View;
begin
for J in Vfloat_Range'Range loop
D.Values (J) := FP_Recip_Est (VA.Values (J));
end loop;
return To_Vector (D);
end vrefp;
----------
-- vrlb --
----------
function vrlb (A : LL_VSC; B : LL_VSC) return LL_VSC is
VA : constant VUC_View := To_View (To_LL_VUC (A));
VB : constant VUC_View := To_View (To_LL_VUC (B));
D : VUC_View;
begin
D.Values := LL_VUC_Operations.vrlx (VA.Values, VB.Values, ROTL'Access);
return To_LL_VSC (To_Vector (D));
end vrlb;
----------
-- vrlh --
----------
function vrlh (A : LL_VSS; B : LL_VSS) return LL_VSS is
VA : constant VUS_View := To_View (To_LL_VUS (A));
VB : constant VUS_View := To_View (To_LL_VUS (B));
D : VUS_View;
begin
D.Values := LL_VUS_Operations.vrlx (VA.Values, VB.Values, ROTL'Access);
return To_LL_VSS (To_Vector (D));
end vrlh;
----------
-- vrlw --
----------
function vrlw (A : LL_VSI; B : LL_VSI) return LL_VSI is
VA : constant VUI_View := To_View (To_LL_VUI (A));
VB : constant VUI_View := To_View (To_LL_VUI (B));
D : VUI_View;
begin
D.Values := LL_VUI_Operations.vrlx (VA.Values, VB.Values, ROTL'Access);
return To_LL_VSI (To_Vector (D));
end vrlw;
-----------
-- vrfin --
-----------
function vrfin (A : LL_VF) return LL_VF is
VA : constant VF_View := To_View (A);
D : VF_View;
begin
for J in Vfloat_Range'Range loop
D.Values (J) := C_float (Rnd_To_FPI_Near (F64 (VA.Values (J))));
end loop;
return To_Vector (D);
end vrfin;
---------------
-- vrsqrtefp --
---------------
function vrsqrtefp (A : LL_VF) return LL_VF is
VA : constant VF_View := To_View (A);
D : VF_View;
begin
for J in Vfloat_Range'Range loop
D.Values (J) := Recip_SQRT_Est (VA.Values (J));
end loop;
return To_Vector (D);
end vrsqrtefp;
--------------
-- vsel_4si --
--------------
function vsel_4si (A : LL_VSI; B : LL_VSI; C : LL_VSI) return LL_VSI is
VA : constant VUI_View := To_View (To_LL_VUI (A));
VB : constant VUI_View := To_View (To_LL_VUI (B));
VC : constant VUI_View := To_View (To_LL_VUI (C));
D : VUI_View;
begin
for J in Vint_Range'Range loop
D.Values (J) := ((not VC.Values (J)) and VA.Values (J))
or (VC.Values (J) and VB.Values (J));
end loop;
return To_LL_VSI (To_Vector (D));
end vsel_4si;
----------
-- vslb --
----------
function vslb (A : LL_VSC; B : LL_VSC) return LL_VSC is
VA : constant VUC_View := To_View (To_LL_VUC (A));
VB : constant VUC_View := To_View (To_LL_VUC (B));
D : VUC_View;
begin
D.Values :=
LL_VUC_Operations.vsxx (VA.Values, VB.Values, Shift_Left'Access);
return To_LL_VSC (To_Vector (D));
end vslb;
----------
-- vslh --
----------
function vslh (A : LL_VSS; B : LL_VSS) return LL_VSS is
VA : constant VUS_View := To_View (To_LL_VUS (A));
VB : constant VUS_View := To_View (To_LL_VUS (B));
D : VUS_View;
begin
D.Values :=
LL_VUS_Operations.vsxx (VA.Values, VB.Values, Shift_Left'Access);
return To_LL_VSS (To_Vector (D));
end vslh;
----------
-- vslw --
----------
function vslw (A : LL_VSI; B : LL_VSI) return LL_VSI is
VA : constant VUI_View := To_View (To_LL_VUI (A));
VB : constant VUI_View := To_View (To_LL_VUI (B));
D : VUI_View;
begin
D.Values :=
LL_VUI_Operations.vsxx (VA.Values, VB.Values, Shift_Left'Access);
return To_LL_VSI (To_Vector (D));
end vslw;
----------------
-- vsldoi_4si --
----------------
function vsldoi_4si (A : LL_VSI; B : LL_VSI; C : c_int) return LL_VSI is
VA : constant VUC_View := To_View (To_LL_VUC (A));
VB : constant VUC_View := To_View (To_LL_VUC (B));
Offset : c_int;
Bound : c_int;
D : VUC_View;
begin
for J in Vchar_Range'Range loop
Offset := c_int (J) + C;
Bound := c_int (Vchar_Range'First)
+ c_int (Varray_unsigned_char'Length);
if Offset < Bound then
D.Values (J) := VA.Values (Vchar_Range (Offset));
else
D.Values (J) :=
VB.Values (Vchar_Range (Offset - Bound
+ c_int (Vchar_Range'First)));
end if;
end loop;
return To_LL_VSI (To_Vector (D));
end vsldoi_4si;
----------------
-- vsldoi_8hi --
----------------
function vsldoi_8hi (A : LL_VSS; B : LL_VSS; C : c_int) return LL_VSS is
begin
return To_LL_VSS (vsldoi_4si (To_LL_VSI (A), To_LL_VSI (B), C));
end vsldoi_8hi;
-----------------
-- vsldoi_16qi --
-----------------
function vsldoi_16qi (A : LL_VSC; B : LL_VSC; C : c_int) return LL_VSC is
begin
return To_LL_VSC (vsldoi_4si (To_LL_VSI (A), To_LL_VSI (B), C));
end vsldoi_16qi;
----------------
-- vsldoi_4sf --
----------------
function vsldoi_4sf (A : LL_VF; B : LL_VF; C : c_int) return LL_VF is
begin
return To_LL_VF (vsldoi_4si (To_LL_VSI (A), To_LL_VSI (B), C));
end vsldoi_4sf;
---------
-- vsl --
---------
function vsl (A : LL_VSI; B : LL_VSI) return LL_VSI is
VA : constant VUI_View := To_View (To_LL_VUI (A));
VB : constant VUI_View := To_View (To_LL_VUI (B));
D : VUI_View;
M : constant Natural :=
Natural (Bits (VB.Values (Vint_Range'Last), 29, 31));
-- [PIM-4.4 vec_sll] "Note that the three low-order byte elements in B
-- must be the same. Otherwise the value placed into D is undefined."
-- ??? Shall we add a optional check for B?
begin
for J in Vint_Range'Range loop
D.Values (J) := 0;
D.Values (J) := D.Values (J) + Shift_Left (VA.Values (J), M);
if J /= Vint_Range'Last then
D.Values (J) :=
D.Values (J) + Shift_Right (VA.Values (J + 1),
signed_int'Size - M);
end if;
end loop;
return To_LL_VSI (To_Vector (D));
end vsl;
----------
-- vslo --
----------
function vslo (A : LL_VSI; B : LL_VSI) return LL_VSI is
VA : constant VUC_View := To_View (To_LL_VUC (A));
VB : constant VUC_View := To_View (To_LL_VUC (B));
D : VUC_View;
M : constant Natural :=
Natural (Bits (VB.Values (Vchar_Range'Last), 1, 4));
J : Natural;
begin
for N in Vchar_Range'Range loop
J := Natural (N) + M;
D.Values (N) :=
(if J <= Natural (Vchar_Range'Last) then VA.Values (Vchar_Range (J))
else 0);
end loop;
return To_LL_VSI (To_Vector (D));
end vslo;
------------
-- vspltb --
------------
function vspltb (A : LL_VSC; B : c_int) return LL_VSC is
VA : constant VSC_View := To_View (A);
D : VSC_View;
begin
D.Values := LL_VSC_Operations.vspltx (VA.Values, B);
return To_Vector (D);
end vspltb;
------------
-- vsplth --
------------
function vsplth (A : LL_VSS; B : c_int) return LL_VSS is
VA : constant VSS_View := To_View (A);
D : VSS_View;
begin
D.Values := LL_VSS_Operations.vspltx (VA.Values, B);
return To_Vector (D);
end vsplth;
------------
-- vspltw --
------------
function vspltw (A : LL_VSI; B : c_int) return LL_VSI is
VA : constant VSI_View := To_View (A);
D : VSI_View;
begin
D.Values := LL_VSI_Operations.vspltx (VA.Values, B);
return To_Vector (D);
end vspltw;
--------------
-- vspltisb --
--------------
function vspltisb (A : c_int) return LL_VSC is
D : VSC_View;
begin
D.Values := LL_VSC_Operations.vspltisx (A);
return To_Vector (D);
end vspltisb;
--------------
-- vspltish --
--------------
function vspltish (A : c_int) return LL_VSS is
D : VSS_View;
begin
D.Values := LL_VSS_Operations.vspltisx (A);
return To_Vector (D);
end vspltish;
--------------
-- vspltisw --
--------------
function vspltisw (A : c_int) return LL_VSI is
D : VSI_View;
begin
D.Values := LL_VSI_Operations.vspltisx (A);
return To_Vector (D);
end vspltisw;
----------
-- vsrb --
----------
function vsrb (A : LL_VSC; B : LL_VSC) return LL_VSC is
VA : constant VUC_View := To_View (To_LL_VUC (A));
VB : constant VUC_View := To_View (To_LL_VUC (B));
D : VUC_View;
begin
D.Values :=
LL_VUC_Operations.vsxx (VA.Values, VB.Values, Shift_Right'Access);
return To_LL_VSC (To_Vector (D));
end vsrb;
----------
-- vsrh --
----------
function vsrh (A : LL_VSS; B : LL_VSS) return LL_VSS is
VA : constant VUS_View := To_View (To_LL_VUS (A));
VB : constant VUS_View := To_View (To_LL_VUS (B));
D : VUS_View;
begin
D.Values :=
LL_VUS_Operations.vsxx (VA.Values, VB.Values, Shift_Right'Access);
return To_LL_VSS (To_Vector (D));
end vsrh;
----------
-- vsrw --
----------
function vsrw (A : LL_VSI; B : LL_VSI) return LL_VSI is
VA : constant VUI_View := To_View (To_LL_VUI (A));
VB : constant VUI_View := To_View (To_LL_VUI (B));
D : VUI_View;
begin
D.Values :=
LL_VUI_Operations.vsxx (VA.Values, VB.Values, Shift_Right'Access);
return To_LL_VSI (To_Vector (D));
end vsrw;
-----------
-- vsrab --
-----------
function vsrab (A : LL_VSC; B : LL_VSC) return LL_VSC is
VA : constant VSC_View := To_View (A);
VB : constant VSC_View := To_View (B);
D : VSC_View;
begin
D.Values :=
LL_VSC_Operations.vsrax (VA.Values, VB.Values, Shift_Right_A'Access);
return To_Vector (D);
end vsrab;
-----------
-- vsrah --
-----------
function vsrah (A : LL_VSS; B : LL_VSS) return LL_VSS is
VA : constant VSS_View := To_View (A);
VB : constant VSS_View := To_View (B);
D : VSS_View;
begin
D.Values :=
LL_VSS_Operations.vsrax (VA.Values, VB.Values, Shift_Right_A'Access);
return To_Vector (D);
end vsrah;
-----------
-- vsraw --
-----------
function vsraw (A : LL_VSI; B : LL_VSI) return LL_VSI is
VA : constant VSI_View := To_View (A);
VB : constant VSI_View := To_View (B);
D : VSI_View;
begin
D.Values :=
LL_VSI_Operations.vsrax (VA.Values, VB.Values, Shift_Right_A'Access);
return To_Vector (D);
end vsraw;
---------
-- vsr --
---------
function vsr (A : LL_VSI; B : LL_VSI) return LL_VSI is
VA : constant VUI_View := To_View (To_LL_VUI (A));
VB : constant VUI_View := To_View (To_LL_VUI (B));
M : constant Natural :=
Natural (Bits (VB.Values (Vint_Range'Last), 29, 31));
D : VUI_View;
begin
for J in Vint_Range'Range loop
D.Values (J) := 0;
D.Values (J) := D.Values (J) + Shift_Right (VA.Values (J), M);
if J /= Vint_Range'First then
D.Values (J) :=
D.Values (J)
+ Shift_Left (VA.Values (J - 1), signed_int'Size - M);
end if;
end loop;
return To_LL_VSI (To_Vector (D));
end vsr;
----------
-- vsro --
----------
function vsro (A : LL_VSI; B : LL_VSI) return LL_VSI is
VA : constant VUC_View := To_View (To_LL_VUC (A));
VB : constant VUC_View := To_View (To_LL_VUC (B));
M : constant Natural :=
Natural (Bits (VB.Values (Vchar_Range'Last), 1, 4));
J : Natural;
D : VUC_View;
begin
for N in Vchar_Range'Range loop
J := Natural (N) - M;
if J >= Natural (Vchar_Range'First) then
D.Values (N) := VA.Values (Vchar_Range (J));
else
D.Values (N) := 0;
end if;
end loop;
return To_LL_VSI (To_Vector (D));
end vsro;
----------
-- stvx --
----------
procedure stvx (A : LL_VSI; B : c_int; C : c_ptr) is
-- Simulate the altivec unit behavior regarding what Effective Address
-- is accessed, stripping off the input address least significant bits
-- wrt to vector alignment (see comment in lvx for further details).
EA : constant System.Address :=
To_Address
(Bound_Align
(Integer_Address (B) + To_Integer (C), VECTOR_ALIGNMENT));
D : LL_VSI;
for D'Address use EA;
begin
D := A;
end stvx;
------------
-- stvewx --
------------
procedure stvebx (A : LL_VSC; B : c_int; C : c_ptr) is
VA : constant VSC_View := To_View (A);
begin
LL_VSC_Operations.stvexx (VA.Values, B, C);
end stvebx;
------------
-- stvehx --
------------
procedure stvehx (A : LL_VSS; B : c_int; C : c_ptr) is
VA : constant VSS_View := To_View (A);
begin
LL_VSS_Operations.stvexx (VA.Values, B, C);
end stvehx;
------------
-- stvewx --
------------
procedure stvewx (A : LL_VSI; B : c_int; C : c_ptr) is
VA : constant VSI_View := To_View (A);
begin
LL_VSI_Operations.stvexx (VA.Values, B, C);
end stvewx;
-----------
-- stvxl --
-----------
procedure stvxl (A : LL_VSI; B : c_int; C : c_ptr) renames stvx;
-------------
-- vsububm --
-------------
function vsububm (A : LL_VSC; B : LL_VSC) return LL_VSC is
VA : constant VUC_View := To_View (To_LL_VUC (A));
VB : constant VUC_View := To_View (To_LL_VUC (B));
D : VUC_View;
begin
D.Values := LL_VUC_Operations.vsubuxm (VA.Values, VB.Values);
return To_LL_VSC (To_Vector (D));
end vsububm;
-------------
-- vsubuhm --
-------------
function vsubuhm (A : LL_VSS; B : LL_VSS) return LL_VSS is
VA : constant VUS_View := To_View (To_LL_VUS (A));
VB : constant VUS_View := To_View (To_LL_VUS (B));
D : VUS_View;
begin
D.Values := LL_VUS_Operations.vsubuxm (VA.Values, VB.Values);
return To_LL_VSS (To_Vector (D));
end vsubuhm;
-------------
-- vsubuwm --
-------------
function vsubuwm (A : LL_VSI; B : LL_VSI) return LL_VSI is
VA : constant VUI_View := To_View (To_LL_VUI (A));
VB : constant VUI_View := To_View (To_LL_VUI (B));
D : VUI_View;
begin
D.Values := LL_VUI_Operations.vsubuxm (VA.Values, VB.Values);
return To_LL_VSI (To_Vector (D));
end vsubuwm;
------------
-- vsubfp --
------------
function vsubfp (A : LL_VF; B : LL_VF) return LL_VF is
VA : constant VF_View := To_View (A);
VB : constant VF_View := To_View (B);
D : VF_View;
begin
for J in Vfloat_Range'Range loop
D.Values (J) :=
NJ_Truncate (NJ_Truncate (VA.Values (J))
- NJ_Truncate (VB.Values (J)));
end loop;
return To_Vector (D);
end vsubfp;
-------------
-- vsubcuw --
-------------
function vsubcuw (A : LL_VSI; B : LL_VSI) return LL_VSI is
Subst_Result : SI64;
VA : constant VUI_View := To_View (To_LL_VUI (A));
VB : constant VUI_View := To_View (To_LL_VUI (B));
D : VUI_View;
begin
for J in Vint_Range'Range loop
Subst_Result := SI64 (VA.Values (J)) - SI64 (VB.Values (J));
D.Values (J) :=
(if Subst_Result < SI64 (unsigned_int'First) then 0 else 1);
end loop;
return To_LL_VSI (To_Vector (D));
end vsubcuw;
-------------
-- vsububs --
-------------
function vsububs (A : LL_VSC; B : LL_VSC) return LL_VSC is
VA : constant VUC_View := To_View (To_LL_VUC (A));
VB : constant VUC_View := To_View (To_LL_VUC (B));
D : VUC_View;
begin
D.Values := LL_VUC_Operations.vsubuxs (VA.Values, VB.Values);
return To_LL_VSC (To_Vector (D));
end vsububs;
-------------
-- vsubsbs --
-------------
function vsubsbs (A : LL_VSC; B : LL_VSC) return LL_VSC is
VA : constant VSC_View := To_View (A);
VB : constant VSC_View := To_View (B);
D : VSC_View;
begin
D.Values := LL_VSC_Operations.vsubsxs (VA.Values, VB.Values);
return To_Vector (D);
end vsubsbs;
-------------
-- vsubuhs --
-------------
function vsubuhs (A : LL_VSS; B : LL_VSS) return LL_VSS is
VA : constant VUS_View := To_View (To_LL_VUS (A));
VB : constant VUS_View := To_View (To_LL_VUS (B));
D : VUS_View;
begin
D.Values := LL_VUS_Operations.vsubuxs (VA.Values, VB.Values);
return To_LL_VSS (To_Vector (D));
end vsubuhs;
-------------
-- vsubshs --
-------------
function vsubshs (A : LL_VSS; B : LL_VSS) return LL_VSS is
VA : constant VSS_View := To_View (A);
VB : constant VSS_View := To_View (B);
D : VSS_View;
begin
D.Values := LL_VSS_Operations.vsubsxs (VA.Values, VB.Values);
return To_Vector (D);
end vsubshs;
-------------
-- vsubuws --
-------------
function vsubuws (A : LL_VSI; B : LL_VSI) return LL_VSI is
VA : constant VUI_View := To_View (To_LL_VUI (A));
VB : constant VUI_View := To_View (To_LL_VUI (B));
D : VUI_View;
begin
D.Values := LL_VUI_Operations.vsubuxs (VA.Values, VB.Values);
return To_LL_VSI (To_Vector (D));
end vsubuws;
-------------
-- vsubsws --
-------------
function vsubsws (A : LL_VSI; B : LL_VSI) return LL_VSI is
VA : constant VSI_View := To_View (A);
VB : constant VSI_View := To_View (B);
D : VSI_View;
begin
D.Values := LL_VSI_Operations.vsubsxs (VA.Values, VB.Values);
return To_Vector (D);
end vsubsws;
--------------
-- vsum4ubs --
--------------
function vsum4ubs (A : LL_VSC; B : LL_VSI) return LL_VSI is
VA : constant VUC_View := To_View (To_LL_VUC (A));
VB : constant VUI_View := To_View (To_LL_VUI (B));
Offset : Vchar_Range;
D : VUI_View;
begin
for J in 0 .. 3 loop
Offset := Vchar_Range (4 * J + Integer (Vchar_Range'First));
D.Values (Vint_Range (J + Integer (Vint_Range'First))) :=
LL_VUI_Operations.Saturate
(UI64 (VA.Values (Offset))
+ UI64 (VA.Values (Offset + 1))
+ UI64 (VA.Values (Offset + 2))
+ UI64 (VA.Values (Offset + 3))
+ UI64 (VB.Values (Vint_Range (J + Integer (Vint_Range'First)))));
end loop;
return To_LL_VSI (To_Vector (D));
end vsum4ubs;
--------------
-- vsum4sbs --
--------------
function vsum4sbs (A : LL_VSC; B : LL_VSI) return LL_VSI is
VA : constant VSC_View := To_View (A);
VB : constant VSI_View := To_View (B);
Offset : Vchar_Range;
D : VSI_View;
begin
for J in 0 .. 3 loop
Offset := Vchar_Range (4 * J + Integer (Vchar_Range'First));
D.Values (Vint_Range (J + Integer (Vint_Range'First))) :=
LL_VSI_Operations.Saturate
(SI64 (VA.Values (Offset))
+ SI64 (VA.Values (Offset + 1))
+ SI64 (VA.Values (Offset + 2))
+ SI64 (VA.Values (Offset + 3))
+ SI64 (VB.Values (Vint_Range (J + Integer (Vint_Range'First)))));
end loop;
return To_Vector (D);
end vsum4sbs;
--------------
-- vsum4shs --
--------------
function vsum4shs (A : LL_VSS; B : LL_VSI) return LL_VSI is
VA : constant VSS_View := To_View (A);
VB : constant VSI_View := To_View (B);
Offset : Vshort_Range;
D : VSI_View;
begin
for J in 0 .. 3 loop
Offset := Vshort_Range (2 * J + Integer (Vchar_Range'First));
D.Values (Vint_Range (J + Integer (Vint_Range'First))) :=
LL_VSI_Operations.Saturate
(SI64 (VA.Values (Offset))
+ SI64 (VA.Values (Offset + 1))
+ SI64 (VB.Values (Vint_Range (J + Integer (Vint_Range'First)))));
end loop;
return To_Vector (D);
end vsum4shs;
--------------
-- vsum2sws --
--------------
function vsum2sws (A : LL_VSI; B : LL_VSI) return LL_VSI is
VA : constant VSI_View := To_View (A);
VB : constant VSI_View := To_View (B);
Offset : Vint_Range;
D : VSI_View;
begin
for J in 0 .. 1 loop
Offset := Vint_Range (2 * J + Integer (Vchar_Range'First));
D.Values (Offset) := 0;
D.Values (Offset + 1) :=
LL_VSI_Operations.Saturate
(SI64 (VA.Values (Offset))
+ SI64 (VA.Values (Offset + 1))
+ SI64 (VB.Values (Vint_Range (Offset + 1))));
end loop;
return To_Vector (D);
end vsum2sws;
-------------
-- vsumsws --
-------------
function vsumsws (A : LL_VSI; B : LL_VSI) return LL_VSI is
VA : constant VSI_View := To_View (A);
VB : constant VSI_View := To_View (B);
D : VSI_View;
Sum_Buffer : SI64 := 0;
begin
for J in Vint_Range'Range loop
D.Values (J) := 0;
Sum_Buffer := Sum_Buffer + SI64 (VA.Values (J));
end loop;
Sum_Buffer := Sum_Buffer + SI64 (VB.Values (Vint_Range'Last));
D.Values (Vint_Range'Last) := LL_VSI_Operations.Saturate (Sum_Buffer);
return To_Vector (D);
end vsumsws;
-----------
-- vrfiz --
-----------
function vrfiz (A : LL_VF) return LL_VF is
VA : constant VF_View := To_View (A);
D : VF_View;
begin
for J in Vfloat_Range'Range loop
D.Values (J) := C_float (Rnd_To_FPI_Trunc (F64 (VA.Values (J))));
end loop;
return To_Vector (D);
end vrfiz;
-------------
-- vupkhsb --
-------------
function vupkhsb (A : LL_VSC) return LL_VSS is
VA : constant VSC_View := To_View (A);
D : VSS_View;
begin
D.Values := LL_VSC_LL_VSS_Operations.vupkxsx (VA.Values, 0);
return To_Vector (D);
end vupkhsb;
-------------
-- vupkhsh --
-------------
function vupkhsh (A : LL_VSS) return LL_VSI is
VA : constant VSS_View := To_View (A);
D : VSI_View;
begin
D.Values := LL_VSS_LL_VSI_Operations.vupkxsx (VA.Values, 0);
return To_Vector (D);
end vupkhsh;
-------------
-- vupkxpx --
-------------
function vupkxpx (A : LL_VSS; Offset : Natural) return LL_VSI;
-- For vupkhpx and vupklpx (depending on Offset)
function vupkxpx (A : LL_VSS; Offset : Natural) return LL_VSI is
VA : constant VUS_View := To_View (To_LL_VUS (A));
K : Vshort_Range;
D : VUI_View;
P16 : Pixel_16;
P32 : Pixel_32;
function Sign_Extend (X : Unsigned_1) return unsigned_char;
function Sign_Extend (X : Unsigned_1) return unsigned_char is
begin
if X = 1 then
return 16#FF#;
else
return 16#00#;
end if;
end Sign_Extend;
begin
for J in Vint_Range'Range loop
K := Vshort_Range (Integer (J)
- Integer (Vint_Range'First)
+ Integer (Vshort_Range'First)
+ Offset);
P16 := To_Pixel (VA.Values (K));
P32.T := Sign_Extend (P16.T);
P32.R := unsigned_char (P16.R);
P32.G := unsigned_char (P16.G);
P32.B := unsigned_char (P16.B);
D.Values (J) := To_unsigned_int (P32);
end loop;
return To_LL_VSI (To_Vector (D));
end vupkxpx;
-------------
-- vupkhpx --
-------------
function vupkhpx (A : LL_VSS) return LL_VSI is
begin
return vupkxpx (A, 0);
end vupkhpx;
-------------
-- vupklsb --
-------------
function vupklsb (A : LL_VSC) return LL_VSS is
VA : constant VSC_View := To_View (A);
D : VSS_View;
begin
D.Values :=
LL_VSC_LL_VSS_Operations.vupkxsx (VA.Values,
Varray_signed_short'Length);
return To_Vector (D);
end vupklsb;
-------------
-- vupklsh --
-------------
function vupklsh (A : LL_VSS) return LL_VSI is
VA : constant VSS_View := To_View (A);
D : VSI_View;
begin
D.Values :=
LL_VSS_LL_VSI_Operations.vupkxsx (VA.Values,
Varray_signed_int'Length);
return To_Vector (D);
end vupklsh;
-------------
-- vupklpx --
-------------
function vupklpx (A : LL_VSS) return LL_VSI is
begin
return vupkxpx (A, Varray_signed_int'Length);
end vupklpx;
----------
-- vxor --
----------
function vxor (A : LL_VSI; B : LL_VSI) return LL_VSI is
VA : constant VUI_View := To_View (To_LL_VUI (A));
VB : constant VUI_View := To_View (To_LL_VUI (B));
D : VUI_View;
begin
for J in Vint_Range'Range loop
D.Values (J) := VA.Values (J) xor VB.Values (J);
end loop;
return To_LL_VSI (To_Vector (D));
end vxor;
----------------
-- vcmpequb_p --
----------------
function vcmpequb_p (A : c_int; B : LL_VSC; C : LL_VSC) return c_int is
D : LL_VSC;
begin
D := vcmpequb (B, C);
return LL_VSC_Operations.Check_CR6 (A, To_View (D).Values);
end vcmpequb_p;
----------------
-- vcmpequh_p --
----------------
function vcmpequh_p (A : c_int; B : LL_VSS; C : LL_VSS) return c_int is
D : LL_VSS;
begin
D := vcmpequh (B, C);
return LL_VSS_Operations.Check_CR6 (A, To_View (D).Values);
end vcmpequh_p;
----------------
-- vcmpequw_p --
----------------
function vcmpequw_p (A : c_int; B : LL_VSI; C : LL_VSI) return c_int is
D : LL_VSI;
begin
D := vcmpequw (B, C);
return LL_VSI_Operations.Check_CR6 (A, To_View (D).Values);
end vcmpequw_p;
----------------
-- vcmpeqfp_p --
----------------
function vcmpeqfp_p (A : c_int; B : LL_VF; C : LL_VF) return c_int is
D : LL_VSI;
begin
D := vcmpeqfp (B, C);
return LL_VSI_Operations.Check_CR6 (A, To_View (D).Values);
end vcmpeqfp_p;
----------------
-- vcmpgtub_p --
----------------
function vcmpgtub_p (A : c_int; B : LL_VSC; C : LL_VSC) return c_int is
D : LL_VSC;
begin
D := vcmpgtub (B, C);
return LL_VSC_Operations.Check_CR6 (A, To_View (D).Values);
end vcmpgtub_p;
----------------
-- vcmpgtuh_p --
----------------
function vcmpgtuh_p (A : c_int; B : LL_VSS; C : LL_VSS) return c_int is
D : LL_VSS;
begin
D := vcmpgtuh (B, C);
return LL_VSS_Operations.Check_CR6 (A, To_View (D).Values);
end vcmpgtuh_p;
----------------
-- vcmpgtuw_p --
----------------
function vcmpgtuw_p (A : c_int; B : LL_VSI; C : LL_VSI) return c_int is
D : LL_VSI;
begin
D := vcmpgtuw (B, C);
return LL_VSI_Operations.Check_CR6 (A, To_View (D).Values);
end vcmpgtuw_p;
----------------
-- vcmpgtsb_p --
----------------
function vcmpgtsb_p (A : c_int; B : LL_VSC; C : LL_VSC) return c_int is
D : LL_VSC;
begin
D := vcmpgtsb (B, C);
return LL_VSC_Operations.Check_CR6 (A, To_View (D).Values);
end vcmpgtsb_p;
----------------
-- vcmpgtsh_p --
----------------
function vcmpgtsh_p (A : c_int; B : LL_VSS; C : LL_VSS) return c_int is
D : LL_VSS;
begin
D := vcmpgtsh (B, C);
return LL_VSS_Operations.Check_CR6 (A, To_View (D).Values);
end vcmpgtsh_p;
----------------
-- vcmpgtsw_p --
----------------
function vcmpgtsw_p (A : c_int; B : LL_VSI; C : LL_VSI) return c_int is
D : LL_VSI;
begin
D := vcmpgtsw (B, C);
return LL_VSI_Operations.Check_CR6 (A, To_View (D).Values);
end vcmpgtsw_p;
----------------
-- vcmpgefp_p --
----------------
function vcmpgefp_p (A : c_int; B : LL_VF; C : LL_VF) return c_int is
D : LL_VSI;
begin
D := vcmpgefp (B, C);
return LL_VSI_Operations.Check_CR6 (A, To_View (D).Values);
end vcmpgefp_p;
----------------
-- vcmpgtfp_p --
----------------
function vcmpgtfp_p (A : c_int; B : LL_VF; C : LL_VF) return c_int is
D : LL_VSI;
begin
D := vcmpgtfp (B, C);
return LL_VSI_Operations.Check_CR6 (A, To_View (D).Values);
end vcmpgtfp_p;
----------------
-- vcmpbfp_p --
----------------
function vcmpbfp_p (A : c_int; B : LL_VF; C : LL_VF) return c_int is
D : VSI_View;
begin
D := To_View (vcmpbfp (B, C));
for J in Vint_Range'Range loop
-- vcmpbfp is not returning the usual bool vector; do the conversion
D.Values (J) :=
(if D.Values (J) = 0 then Signed_Bool_False else Signed_Bool_True);
end loop;
return LL_VSI_Operations.Check_CR6 (A, D.Values);
end vcmpbfp_p;
end GNAT.Altivec.Low_Level_Vectors;
|
Transynther/x86/_processed/NONE/_xt_/i9-9900K_12_0xca_notsx.log_21829_204.asm | ljhsiun2/medusa | 9 | 81901 | .global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r12
push %r9
push %rax
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_normal_ht+0x1a989, %rax
nop
nop
xor %rdx, %rdx
movb (%rax), %r12b
nop
nop
nop
add %r12, %r12
lea addresses_WC_ht+0x185e9, %r9
nop
xor $62686, %rdx
mov $0x6162636465666768, %rcx
movq %rcx, %xmm6
and $0xffffffffffffffc0, %r9
vmovaps %ymm6, (%r9)
nop
nop
nop
nop
nop
cmp %rdx, %rdx
lea addresses_WC_ht+0x131e9, %r11
nop
cmp $49960, %r12
mov (%r11), %r9w
nop
nop
sub %rax, %rax
lea addresses_WC_ht+0xf3c9, %rsi
lea addresses_WC_ht+0x161a9, %rdi
nop
nop
nop
dec %rdx
mov $16, %rcx
rep movsb
nop
cmp $24125, %rdi
lea addresses_WC_ht+0xc79d, %rsi
lea addresses_UC_ht+0xc1c9, %rdi
nop
nop
nop
cmp %r9, %r9
mov $50, %rcx
rep movsl
nop
add $9688, %r9
lea addresses_WT_ht+0xd099, %r9
nop
nop
nop
and $7172, %rcx
movl $0x61626364, (%r9)
nop
xor %rax, %rax
lea addresses_WC_ht+0xc109, %rsi
clflush (%rsi)
nop
nop
nop
nop
nop
and %r9, %r9
mov $0x6162636465666768, %rcx
movq %rcx, %xmm4
and $0xffffffffffffffc0, %rsi
vmovntdq %ymm4, (%rsi)
nop
and %r9, %r9
lea addresses_normal_ht+0xba9, %rax
clflush (%rax)
nop
nop
nop
nop
nop
add $2291, %rsi
mov $0x6162636465666768, %rdx
movq %rdx, %xmm2
vmovups %ymm2, (%rax)
nop
add $56693, %rsi
lea addresses_D_ht+0xf2a9, %r9
nop
dec %rax
mov (%r9), %r11w
nop
nop
nop
and %rdx, %rdx
lea addresses_normal_ht+0x189e9, %rcx
clflush (%rcx)
nop
nop
nop
nop
nop
dec %rdi
mov $0x6162636465666768, %r9
movq %r9, %xmm2
movups %xmm2, (%rcx)
nop
nop
nop
nop
inc %rdx
lea addresses_UC_ht+0x1a5e9, %rsi
lea addresses_UC_ht+0x1ba91, %rdi
nop
nop
cmp $55971, %rdx
mov $15, %rcx
rep movsb
nop
xor $42699, %rsi
lea addresses_WC_ht+0x9701, %r9
cmp $2222, %r12
mov (%r9), %rsi
nop
sub $3580, %r12
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rax
pop %r9
pop %r12
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r15
push %r8
push %rbx
push %rdx
push %rsi
// Load
lea addresses_PSE+0x5ae9, %r8
nop
cmp %r15, %r15
mov (%r8), %ebx
nop
nop
nop
cmp %rbx, %rbx
// Store
lea addresses_A+0x9a69, %rsi
nop
dec %rdx
mov $0x5152535455565758, %r10
movq %r10, %xmm5
vmovups %ymm5, (%rsi)
nop
nop
nop
dec %r15
// Faulty Load
lea addresses_RW+0x65e9, %r15
clflush (%r15)
sub $63567, %rbx
movb (%r15), %dl
lea oracles, %r11
and $0xff, %rdx
shlq $12, %rdx
mov (%r11,%rdx,1), %rdx
pop %rsi
pop %rdx
pop %rbx
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': 16, 'congruent': 0}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_PSE', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 7}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_A', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 6}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_RW', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': True, 'size': 1, 'congruent': 5}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WC_ht', 'NT': False, 'AVXalign': True, 'size': 32, 'congruent': 10}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WC_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 10}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 5, 'type': 'addresses_WC_ht'}, 'dst': {'same': False, 'congruent': 6, 'type': 'addresses_WC_ht'}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 2, 'type': 'addresses_WC_ht'}, 'dst': {'same': False, 'congruent': 5, 'type': 'addresses_UC_ht'}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 4}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WC_ht', 'NT': True, 'AVXalign': False, 'size': 32, 'congruent': 5}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 6}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 5}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 7}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 5, 'type': 'addresses_UC_ht'}, 'dst': {'same': False, 'congruent': 1, 'type': 'addresses_UC_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WC_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 1}}
{'32': 21829}
32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
*/
|
day18/tests/day-test.adb | jwarwick/aoc_2020 | 3 | 4211 | <gh_stars>1-10
with AUnit.Assertions; use AUnit.Assertions;
package body Day.Test is
procedure Test_Part1 (T : in out AUnit.Test_Cases.Test_Case'Class) is
pragma Unreferenced (T);
t1 : constant Long_Integer := eval_string("1 + 2 * 3 + 4 * 5 + 6");
t2 : constant Long_Integer := eval_string("1 + (2 * 3) + (4 * (5 + 6))");
t3 : constant Long_Integer := eval_string("2 * 3 + (4 * 5)");
t4 : constant Long_Integer := eval_string("((2 + 4 * 9) * (6 + 9 * 8 + 6) + 6) + 2 + 4 * 2");
begin
Assert(t1 = 71, "Wrong number, expected 71, got" & t1'IMAGE);
Assert(t2 = 51, "Wrong number, expected 51, got" & t2'IMAGE);
Assert(t3 = 26, "Wrong number, expected 26, got" & t3'IMAGE);
Assert(t4 = 13632, "Wrong number, expected 13632, got" & t4'IMAGE);
end Test_Part1;
procedure Test_Part2 (T : in out AUnit.Test_Cases.Test_Case'Class) is
pragma Unreferenced (T);
t1 : constant Long_Integer := eval_newmath_string("1 + 2 * 3 + 4 * 5 + 6");
t2 : constant Long_Integer := eval_newmath_string("1 + (2 * 3) + (4 * (5 + 6))");
t3 : constant Long_Integer := eval_newmath_string("2 * 3 + (4 * 5)");
t5 : constant Long_Integer := eval_newmath_string("5 + (8 * 3 + 9 + 3 * 4 * 3)");
t6 : constant Long_Integer := eval_newmath_string("5 * 9 * (7 * 3 * 3 + 9 * 3 + (8 + 6 * 4))");
t4 : constant Long_Integer := eval_newmath_string("((2 + 4 * 9) * (6 + 9 * 8 + 6) + 6) + 2 + 4 * 2");
begin
Assert(t1 = 231, "Wrong number, expected 231, got" & t1'IMAGE);
Assert(t2 = 51, "Wrong number, expected 51, got" & t2'IMAGE);
Assert(t3 = 46, "Wrong number, expected 46, got" & t3'IMAGE);
Assert(t5 = 1445, "Wrong number, expected 1445, got" & t5'IMAGE);
Assert(t6 = 669060, "Wrong number, expected 669060, got" & t6'IMAGE);
Assert(t4 = 23340, "Wrong number, expected 23340, got" & t4'IMAGE);
end Test_Part2;
function Name (T : Test) return AUnit.Message_String is
pragma Unreferenced (T);
begin
return AUnit.Format ("Test Day package");
end Name;
procedure Register_Tests (T : in out Test) is
use AUnit.Test_Cases.Registration;
begin
Register_Routine (T, Test_Part1'Access, "Test Part 1");
Register_Routine (T, Test_Part2'Access, "Test Part 2");
end Register_Tests;
end Day.Test;
|
data/ouagadougou.asm | BlockoS/up-kos | 1 | 85729 | ; Song Ouagadougou in Lightweight format.
; Generated by Arkos Tracker 2.
Ouagadougou_SongStart:
defb "ATLW" ; Format marker (LightWeight).
defb 0 ; Format version.
defw Ouagadougou_FmInstrumentTable
defw Ouagadougou_ArpeggioTable
defw Ouagadougou_PitchTable
; Table of the Subsongs.
defw Ouagadougou_Subsong0
; The Arpeggio table.
Ouagadougou_ArpeggioTable:
defw 0
; The Pitch table.
Ouagadougou_PitchTable:
defw 0
; The FM Instrument table.
Ouagadougou_FmInstrumentTable:
defw Ouagadougou_FmInstrument0
defw Ouagadougou_FmInstrument1
defw Ouagadougou_FmInstrument2
Ouagadougou_FmInstrument0:
defb 255 ; Speed.
Ouagadougou_FmInstrument0_Loop: defb 0 ; Volume: 0.
defb 4 ; End the instrument.
defw Ouagadougou_FmInstrument0_Loop ; Loops.
Ouagadougou_FmInstrument1:
defb 0 ; Speed.
defb 189 ; Volume: 15.
defb 25 ; Arpeggio: 12.
defb 11 ; Noise: 11.
defb 185 ; Volume: 14.
defb 27 ; Arpeggio: 13.
defb 10 ; Noise: 10.
defb 181 ; Volume: 13.
defb 33 ; Arpeggio: 16.
defb 9 ; Noise: 9.
defb 181 ; Volume: 13.
defb 19 ; Arpeggio: 9.
defb 8 ; Noise: 8.
defb 177 ; Volume: 12.
defb 1 ; Arpeggio: 0.
defb 7 ; Noise: 7.
defb 169 ; Volume: 10.
defb 19 ; Arpeggio: 9.
defb 6 ; Noise: 6.
defb 161 ; Volume: 8.
defb 29 ; Arpeggio: 14.
defb 5 ; Noise: 5.
defb 153 ; Volume: 6.
defb 1 ; Arpeggio: 0.
defb 4 ; Noise: 4.
defb 145 ; Volume: 4.
defb 1 ; Arpeggio: 0.
defb 3 ; Noise: 3.
defb 141 ; Volume: 3.
defb 1 ; Arpeggio: 0.
defb 2 ; Noise: 2.
defb 4 ; End the instrument.
defw Ouagadougou_FmInstrument0_Loop ; Loop to silence.
Ouagadougou_FmInstrument2:
defb 0 ; Speed.
defb 61 ; Volume: 15.
defb 57 ; Volume: 14.
defb 53 ; Volume: 13.
defb 49 ; Volume: 12.
defb 45 ; Volume: 11.
Ouagadougou_FmInstrument2_Loop: defb 41 ; Volume: 10.
defb 4 ; End the instrument.
defw Ouagadougou_FmInstrument2_Loop ; Loops.
; Song Ouagadougou, Subsong 0 - Main - in Lightweight format.
; Generated by Arkos Tracker 2.
Ouagadougou_Subsong0:
; The Linker.
; Pattern 0
Ouagadougou_Subsong0_Loop:
defb 15 ; State byte.
defb 4 ; New speed.
defb 63 ; New height.
defb 0, 0, 0 ; The transpositions.
defw Ouagadougou_Subsong0_Track0, Ouagadougou_Subsong0_Track1, Ouagadougou_Subsong0_Track2 ; The tracks.
; Pattern 1
defb 1 ; State byte.
defw Ouagadougou_Subsong0_Track5, Ouagadougou_Subsong0_Track1, Ouagadougou_Subsong0_Track2 ; The tracks.
; Pattern 2
defb 1 ; State byte.
defw Ouagadougou_Subsong0_Track0, Ouagadougou_Subsong0_Track1, Ouagadougou_Subsong0_Track2 ; The tracks.
; Pattern 3
defb 1 ; State byte.
defw Ouagadougou_Subsong0_Track7, Ouagadougou_Subsong0_Track1, Ouagadougou_Subsong0_Track2 ; The tracks.
; Pattern 4
defb 1 ; State byte.
defw Ouagadougou_Subsong0_Track3, Ouagadougou_Subsong0_Track1, Ouagadougou_Subsong0_Track2 ; The tracks.
; Pattern 5
defb 1 ; State byte.
defw Ouagadougou_Subsong0_Track6, Ouagadougou_Subsong0_Track1, Ouagadougou_Subsong0_Track2 ; The tracks.
; Pattern 6
defb 1 ; State byte.
defw Ouagadougou_Subsong0_Track3, Ouagadougou_Subsong0_Track1, Ouagadougou_Subsong0_Track2 ; The tracks.
; Pattern 7
defb 1 ; State byte.
defw Ouagadougou_Subsong0_Track9, Ouagadougou_Subsong0_Track1, Ouagadougou_Subsong0_Track2 ; The tracks.
; Pattern 8
defb 1 ; State byte.
defw Ouagadougou_Subsong0_Track4, Ouagadougou_Subsong0_Track1, Ouagadougou_Subsong0_Track2 ; The tracks.
; Pattern 9
defb 1 ; State byte.
defw Ouagadougou_Subsong0_Track8, Ouagadougou_Subsong0_Track1, Ouagadougou_Subsong0_Track2 ; The tracks.
; Pattern 10
defb 1 ; State byte.
defw Ouagadougou_Subsong0_Track4, Ouagadougou_Subsong0_Track1, Ouagadougou_Subsong0_Track2 ; The tracks.
; Pattern 11
defb 1 ; State byte.
defw Ouagadougou_Subsong0_Track10, Ouagadougou_Subsong0_Track1, Ouagadougou_Subsong0_Track2 ; The tracks.
; Pattern 12
defb 1 ; State byte.
defw Ouagadougou_Subsong0_Track21, Ouagadougou_Subsong0_Track1, Ouagadougou_Subsong0_Track2 ; The tracks.
; Pattern 13
defb 1 ; State byte.
defw Ouagadougou_Subsong0_Track0, Ouagadougou_Subsong0_Track1, Ouagadougou_Subsong0_Track2 ; The tracks.
; Pattern 14
defb 1 ; State byte.
defw Ouagadougou_Subsong0_Track5, Ouagadougou_Subsong0_Track1, Ouagadougou_Subsong0_Track2 ; The tracks.
; Pattern 15
defb 1 ; State byte.
defw Ouagadougou_Subsong0_Track0, Ouagadougou_Subsong0_Track1, Ouagadougou_Subsong0_Track2 ; The tracks.
; Pattern 16
defb 1 ; State byte.
defw Ouagadougou_Subsong0_Track7, Ouagadougou_Subsong0_Track1, Ouagadougou_Subsong0_Track2 ; The tracks.
; Pattern 17
defb 1 ; State byte.
defw Ouagadougou_Subsong0_Track11, Ouagadougou_Subsong0_Track1, Ouagadougou_Subsong0_Track2 ; The tracks.
; Pattern 18
defb 1 ; State byte.
defw Ouagadougou_Subsong0_Track12, Ouagadougou_Subsong0_Track1, Ouagadougou_Subsong0_Track2 ; The tracks.
; Pattern 19
defb 1 ; State byte.
defw Ouagadougou_Subsong0_Track11, Ouagadougou_Subsong0_Track1, Ouagadougou_Subsong0_Track2 ; The tracks.
; Pattern 20
defb 1 ; State byte.
defw Ouagadougou_Subsong0_Track13, Ouagadougou_Subsong0_Track1, Ouagadougou_Subsong0_Track2 ; The tracks.
; Pattern 21
defb 1 ; State byte.
defw Ouagadougou_Subsong0_Track14, Ouagadougou_Subsong0_Track1, Ouagadougou_Subsong0_Track2 ; The tracks.
; Pattern 22
defb 1 ; State byte.
defw Ouagadougou_Subsong0_Track15, Ouagadougou_Subsong0_Track1, Ouagadougou_Subsong0_Track2 ; The tracks.
; Pattern 23
defb 1 ; State byte.
defw Ouagadougou_Subsong0_Track14, Ouagadougou_Subsong0_Track1, Ouagadougou_Subsong0_Track2 ; The tracks.
; Pattern 24
defb 1 ; State byte.
defw Ouagadougou_Subsong0_Track16, Ouagadougou_Subsong0_Track1, Ouagadougou_Subsong0_Track2 ; The tracks.
; Pattern 25
defb 1 ; State byte.
defw Ouagadougou_Subsong0_Track17, Ouagadougou_Subsong0_Track1, Ouagadougou_Subsong0_Track2 ; The tracks.
; Pattern 26
defb 1 ; State byte.
defw Ouagadougou_Subsong0_Track18, Ouagadougou_Subsong0_Track1, Ouagadougou_Subsong0_Track2 ; The tracks.
; Pattern 27
defb 1 ; State byte.
defw Ouagadougou_Subsong0_Track17, Ouagadougou_Subsong0_Track1, Ouagadougou_Subsong0_Track2 ; The tracks.
; Pattern 28
defb 1 ; State byte.
defw Ouagadougou_Subsong0_Track19, Ouagadougou_Subsong0_Track1, Ouagadougou_Subsong0_Track2 ; The tracks.
defb 0 ; End of the subsong.
defw Ouagadougou_Subsong0_Loop
; The Tracks.
Ouagadougou_Subsong0_Track0:
defb 128 ; Note: 24.
defb 4 ; New instrument: 2.
defb 61, 6 ; Long wait: 7.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 190 ; Short wait: 3.
defb 140 ; Note: 36.
defb 4 ; New instrument: 2.
defb 62 ; Short wait: 1.
defb 10 ; Note: 34.
defb 62 ; Short wait: 1.
defb 0 ; Note: 24.
defb 190 ; Short wait: 3.
defb 63, 22 ; Escaped note: 22.
defb 62 ; Short wait: 1.
defb 0 ; Note: 24.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 190 ; Short wait: 3.
defb 128 ; Note: 24.
defb 4 ; New instrument: 2.
defb 190 ; Short wait: 3.
defb 63, 19 ; Escaped note: 19.
defb 61, 6 ; Long wait: 7.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 190 ; Short wait: 3.
defb 191, 19 ; Escaped note: 19.
defb 4 ; New instrument: 2.
defb 62 ; Short wait: 1.
defb 63, 19 ; Escaped note: 19.
defb 62 ; Short wait: 1.
defb 63, 22 ; Escaped note: 22.
defb 190 ; Short wait: 3.
defb 63, 19 ; Escaped note: 19.
defb 62 ; Short wait: 1.
defb 63, 22 ; Escaped note: 22.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 131 ; Note: 27.
defb 4 ; New instrument: 2.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 17 ; Note: 41.
defb 62 ; Short wait: 1.
Ouagadougou_Subsong0_Track1:
defb 61, 63 ; Long wait: 64.
Ouagadougou_Subsong0_Track2:
defb 61, 63 ; Long wait: 64.
Ouagadougou_Subsong0_Track3:
defb 128 ; Note: 24.
defb 4 ; New instrument: 2.
defb 190 ; Short wait: 3.
defb 31 ; Note: 55.
defb 62 ; Short wait: 1.
defb 29 ; Note: 53.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 159 ; Note: 55.
defb 4 ; New instrument: 2.
defb 62 ; Short wait: 1.
defb 12 ; Note: 36.
defb 62 ; Short wait: 1.
defb 10 ; Note: 34.
defb 62 ; Short wait: 1.
defb 0 ; Note: 24.
defb 190 ; Short wait: 3.
defb 63, 22 ; Escaped note: 22.
defb 62 ; Short wait: 1.
defb 0 ; Note: 24.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 159 ; Note: 55.
defb 4 ; New instrument: 2.
defb 62 ; Short wait: 1.
defb 0 ; Note: 24.
defb 62 ; Short wait: 1.
defb 36 ; Note: 60.
defb 62 ; Short wait: 1.
defb 63, 19 ; Escaped note: 19.
defb 62 ; Short wait: 1.
defb 34 ; Note: 58.
defb 62 ; Short wait: 1.
defb 33 ; Note: 57.
defb 62 ; Short wait: 1.
defb 34 ; Note: 58.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 159 ; Note: 55.
defb 4 ; New instrument: 2.
defb 62 ; Short wait: 1.
defb 63, 19 ; Escaped note: 19.
defb 62 ; Short wait: 1.
defb 63, 19 ; Escaped note: 19.
defb 62 ; Short wait: 1.
defb 63, 22 ; Escaped note: 22.
defb 62 ; Short wait: 1.
defb 27 ; Note: 51.
defb 62 ; Short wait: 1.
defb 63, 19 ; Escaped note: 19.
defb 62 ; Short wait: 1.
defb 29 ; Note: 53.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 159 ; Note: 55.
defb 4 ; New instrument: 2.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 17 ; Note: 41.
defb 62 ; Short wait: 1.
Ouagadougou_Subsong0_Track4:
defb 128 ; Note: 24.
defb 4 ; New instrument: 2.
defb 62 ; Short wait: 1.
defb 63, 77 ; Escaped note: 77.
defb 62 ; Short wait: 1.
defb 31 ; Note: 55.
defb 63, 79 ; Escaped note: 79.
defb 29 ; Note: 53.
defb 63, 77 ; Escaped note: 77.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 159 ; Note: 55.
defb 4 ; New instrument: 2.
defb 63, 72 ; Escaped note: 72.
defb 12 ; Note: 36.
defb 62 ; Short wait: 1.
defb 10 ; Note: 34.
defb 63, 75 ; Escaped note: 75.
defb 0 ; Note: 24.
defb 62 ; Short wait: 1.
defb 46 ; Note: 70.
defb 63, 72 ; Escaped note: 72.
defb 63, 22 ; Escaped note: 22.
defb 62 ; Short wait: 1.
defb 0 ; Note: 24.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 191, 75 ; Escaped note: 75.
defb 4 ; New instrument: 2.
defb 31 ; Note: 55.
defb 62 ; Short wait: 1.
defb 0 ; Note: 24.
defb 63, 72 ; Escaped note: 72.
defb 36 ; Note: 60.
defb 46 ; Note: 70.
defb 63, 19 ; Escaped note: 19.
defb 62 ; Short wait: 1.
defb 34 ; Note: 58.
defb 63, 72 ; Escaped note: 72.
defb 33 ; Note: 57.
defb 43 ; Note: 67.
defb 34 ; Note: 58.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 159 ; Note: 55.
defb 4 ; New instrument: 2.
defb 62 ; Short wait: 1.
defb 63, 19 ; Escaped note: 19.
defb 46 ; Note: 70.
defb 63, 19 ; Escaped note: 19.
defb 63, 72 ; Escaped note: 72.
defb 63, 22 ; Escaped note: 22.
defb 62 ; Short wait: 1.
defb 27 ; Note: 51.
defb 63, 75 ; Escaped note: 75.
defb 63, 19 ; Escaped note: 19.
defb 63, 72 ; Escaped note: 72.
defb 29 ; Note: 53.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 191, 75 ; Escaped note: 75.
defb 4 ; New instrument: 2.
defb 3 ; Note: 27.
defb 43 ; Note: 67.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 174 ; Note: 70.
defb 4 ; New instrument: 2.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
Ouagadougou_Subsong0_Track5:
defb 128 ; Note: 24.
defb 4 ; New instrument: 2.
defb 61, 6 ; Long wait: 7.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 190 ; Short wait: 3.
defb 140 ; Note: 36.
defb 4 ; New instrument: 2.
defb 62 ; Short wait: 1.
defb 10 ; Note: 34.
defb 62 ; Short wait: 1.
defb 0 ; Note: 24.
defb 190 ; Short wait: 3.
defb 63, 22 ; Escaped note: 22.
defb 62 ; Short wait: 1.
defb 0 ; Note: 24.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 190 ; Short wait: 3.
defb 128 ; Note: 24.
defb 4 ; New instrument: 2.
defb 190 ; Short wait: 3.
defb 3 ; Note: 27.
defb 61, 4 ; Long wait: 5.
defb 3 ; Note: 27.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 131 ; Note: 27.
defb 4 ; New instrument: 2.
defb 62 ; Short wait: 1.
defb 3 ; Note: 27.
defb 62 ; Short wait: 1.
defb 7 ; Note: 31.
defb 62 ; Short wait: 1.
defb 63, 22 ; Escaped note: 22.
defb 190 ; Short wait: 3.
defb 63, 19 ; Escaped note: 19.
defb 62 ; Short wait: 1.
defb 63, 22 ; Escaped note: 22.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 191, 19 ; Escaped note: 19.
defb 4 ; New instrument: 2.
defb 62 ; Short wait: 1.
defb 3 ; Note: 27.
defb 190 ; Short wait: 3.
Ouagadougou_Subsong0_Track6:
defb 128 ; Note: 24.
defb 4 ; New instrument: 2.
defb 190 ; Short wait: 3.
defb 31 ; Note: 55.
defb 62 ; Short wait: 1.
defb 29 ; Note: 53.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 159 ; Note: 55.
defb 4 ; New instrument: 2.
defb 62 ; Short wait: 1.
defb 12 ; Note: 36.
defb 62 ; Short wait: 1.
defb 10 ; Note: 34.
defb 62 ; Short wait: 1.
defb 0 ; Note: 24.
defb 190 ; Short wait: 3.
defb 63, 22 ; Escaped note: 22.
defb 62 ; Short wait: 1.
defb 0 ; Note: 24.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 159 ; Note: 55.
defb 4 ; New instrument: 2.
defb 62 ; Short wait: 1.
defb 0 ; Note: 24.
defb 62 ; Short wait: 1.
defb 31 ; Note: 55.
defb 62 ; Short wait: 1.
defb 3 ; Note: 27.
defb 62 ; Short wait: 1.
defb 36 ; Note: 60.
defb 62 ; Short wait: 1.
defb 39 ; Note: 63.
defb 62 ; Short wait: 1.
defb 43 ; Note: 67.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 131 ; Note: 27.
defb 4 ; New instrument: 2.
defb 62 ; Short wait: 1.
defb 3 ; Note: 27.
defb 62 ; Short wait: 1.
defb 7 ; Note: 31.
defb 62 ; Short wait: 1.
defb 63, 22 ; Escaped note: 22.
defb 62 ; Short wait: 1.
defb 29 ; Note: 53.
defb 62 ; Short wait: 1.
defb 63, 19 ; Escaped note: 19.
defb 62 ; Short wait: 1.
defb 63, 22 ; Escaped note: 22.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 162 ; Note: 58.
defb 4 ; New instrument: 2.
defb 62 ; Short wait: 1.
defb 3 ; Note: 27.
defb 62 ; Short wait: 1.
defb 31 ; Note: 55.
defb 62 ; Short wait: 1.
Ouagadougou_Subsong0_Track7:
defb 128 ; Note: 24.
defb 4 ; New instrument: 2.
defb 61, 6 ; Long wait: 7.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 190 ; Short wait: 3.
defb 140 ; Note: 36.
defb 4 ; New instrument: 2.
defb 62 ; Short wait: 1.
defb 10 ; Note: 34.
defb 62 ; Short wait: 1.
defb 0 ; Note: 24.
defb 190 ; Short wait: 3.
defb 63, 22 ; Escaped note: 22.
defb 62 ; Short wait: 1.
defb 0 ; Note: 24.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 190 ; Short wait: 3.
defb 128 ; Note: 24.
defb 4 ; New instrument: 2.
defb 190 ; Short wait: 3.
defb 3 ; Note: 27.
defb 61, 4 ; Long wait: 5.
defb 3 ; Note: 27.
defb 190 ; Short wait: 3.
defb 3 ; Note: 27.
defb 62 ; Short wait: 1.
defb 3 ; Note: 27.
defb 62 ; Short wait: 1.
defb 7 ; Note: 31.
defb 62 ; Short wait: 1.
defb 63, 22 ; Escaped note: 22.
defb 190 ; Short wait: 3.
defb 63, 19 ; Escaped note: 19.
defb 62 ; Short wait: 1.
defb 63, 22 ; Escaped note: 22.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 17 ; Note: 41.
defb 62 ; Short wait: 1.
defb 17 ; Note: 41.
defb 62 ; Short wait: 1.
defb 17 ; Note: 41.
defb 62 ; Short wait: 1.
Ouagadougou_Subsong0_Track8:
defb 128 ; Note: 24.
defb 4 ; New instrument: 2.
defb 62 ; Short wait: 1.
defb 63, 77 ; Escaped note: 77.
defb 62 ; Short wait: 1.
defb 31 ; Note: 55.
defb 63, 79 ; Escaped note: 79.
defb 29 ; Note: 53.
defb 63, 77 ; Escaped note: 77.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 159 ; Note: 55.
defb 4 ; New instrument: 2.
defb 63, 72 ; Escaped note: 72.
defb 12 ; Note: 36.
defb 62 ; Short wait: 1.
defb 10 ; Note: 34.
defb 63, 79 ; Escaped note: 79.
defb 0 ; Note: 24.
defb 62 ; Short wait: 1.
defb 63, 77 ; Escaped note: 77.
defb 63, 72 ; Escaped note: 72.
defb 63, 22 ; Escaped note: 22.
defb 62 ; Short wait: 1.
defb 0 ; Note: 24.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 191, 79 ; Escaped note: 79.
defb 4 ; New instrument: 2.
defb 31 ; Note: 55.
defb 63, 77 ; Escaped note: 77.
defb 0 ; Note: 24.
defb 63, 72 ; Escaped note: 72.
defb 31 ; Note: 55.
defb 46 ; Note: 70.
defb 3 ; Note: 27.
defb 62 ; Short wait: 1.
defb 36 ; Note: 60.
defb 63, 72 ; Escaped note: 72.
defb 39 ; Note: 63.
defb 41 ; Note: 65.
defb 43 ; Note: 67.
defb 43 ; Note: 67.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 174 ; Note: 70.
defb 4 ; New instrument: 2.
defb 3 ; Note: 27.
defb 62 ; Short wait: 1.
defb 3 ; Note: 27.
defb 46 ; Note: 70.
defb 7 ; Note: 31.
defb 63, 72 ; Escaped note: 72.
defb 63, 22 ; Escaped note: 22.
defb 62 ; Short wait: 1.
defb 29 ; Note: 53.
defb 63, 75 ; Escaped note: 75.
defb 63, 19 ; Escaped note: 19.
defb 63, 72 ; Escaped note: 72.
defb 63, 22 ; Escaped note: 22.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 191, 75 ; Escaped note: 75.
defb 4 ; New instrument: 2.
defb 34 ; Note: 58.
defb 43 ; Note: 67.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 191, 72 ; Escaped note: 72.
defb 4 ; New instrument: 2.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
Ouagadougou_Subsong0_Track9:
defb 128 ; Note: 24.
defb 4 ; New instrument: 2.
defb 190 ; Short wait: 3.
defb 31 ; Note: 55.
defb 62 ; Short wait: 1.
defb 29 ; Note: 53.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 159 ; Note: 55.
defb 4 ; New instrument: 2.
defb 62 ; Short wait: 1.
defb 12 ; Note: 36.
defb 62 ; Short wait: 1.
defb 10 ; Note: 34.
defb 62 ; Short wait: 1.
defb 0 ; Note: 24.
defb 190 ; Short wait: 3.
defb 63, 22 ; Escaped note: 22.
defb 62 ; Short wait: 1.
defb 0 ; Note: 24.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 159 ; Note: 55.
defb 4 ; New instrument: 2.
defb 62 ; Short wait: 1.
defb 0 ; Note: 24.
defb 62 ; Short wait: 1.
defb 31 ; Note: 55.
defb 62 ; Short wait: 1.
defb 3 ; Note: 27.
defb 62 ; Short wait: 1.
defb 36 ; Note: 60.
defb 62 ; Short wait: 1.
defb 39 ; Note: 63.
defb 62 ; Short wait: 1.
defb 36 ; Note: 60.
defb 62 ; Short wait: 1.
defb 152 ; Note: 48.
defb 0 ; New instrument: 0.
defb 62 ; Short wait: 1.
defb 131 ; Note: 27.
defb 4 ; New instrument: 2.
defb 62 ; Short wait: 1.
defb 3 ; Note: 27.
defb 62 ; Short wait: 1.
defb 31 ; Note: 55.
defb 62 ; Short wait: 1.
defb 63, 22 ; Escaped note: 22.
defb 62 ; Short wait: 1.
defb 36 ; Note: 60.
defb 62 ; Short wait: 1.
defb 63, 19 ; Escaped note: 19.
defb 62 ; Short wait: 1.
defb 63, 22 ; Escaped note: 22.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 17 ; Note: 41.
defb 62 ; Short wait: 1.
defb 17 ; Note: 41.
defb 62 ; Short wait: 1.
defb 17 ; Note: 41.
defb 62 ; Short wait: 1.
Ouagadougou_Subsong0_Track10:
defb 128 ; Note: 24.
defb 4 ; New instrument: 2.
defb 62 ; Short wait: 1.
defb 63, 77 ; Escaped note: 77.
defb 62 ; Short wait: 1.
defb 31 ; Note: 55.
defb 63, 79 ; Escaped note: 79.
defb 29 ; Note: 53.
defb 63, 77 ; Escaped note: 77.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 159 ; Note: 55.
defb 4 ; New instrument: 2.
defb 63, 72 ; Escaped note: 72.
defb 12 ; Note: 36.
defb 62 ; Short wait: 1.
defb 10 ; Note: 34.
defb 63, 79 ; Escaped note: 79.
defb 0 ; Note: 24.
defb 62 ; Short wait: 1.
defb 63, 77 ; Escaped note: 77.
defb 63, 72 ; Escaped note: 72.
defb 63, 22 ; Escaped note: 22.
defb 62 ; Short wait: 1.
defb 0 ; Note: 24.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 191, 79 ; Escaped note: 79.
defb 4 ; New instrument: 2.
defb 31 ; Note: 55.
defb 63, 77 ; Escaped note: 77.
defb 0 ; Note: 24.
defb 63, 72 ; Escaped note: 72.
defb 31 ; Note: 55.
defb 46 ; Note: 70.
defb 3 ; Note: 27.
defb 61, 14 ; Long wait: 15.
defb 63, 22 ; Escaped note: 22.
defb 61, 6 ; Long wait: 7.
defb 63, 19 ; Escaped note: 19.
defb 61, 6 ; Long wait: 7.
Ouagadougou_Subsong0_Track11:
defb 128 ; Note: 24.
defb 4 ; New instrument: 2.
defb 62 ; Short wait: 1.
defb 31 ; Note: 55.
defb 62 ; Short wait: 1.
defb 36 ; Note: 60.
defb 62 ; Short wait: 1.
defb 43 ; Note: 67.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 167 ; Note: 63.
defb 4 ; New instrument: 2.
defb 62 ; Short wait: 1.
defb 12 ; Note: 36.
defb 62 ; Short wait: 1.
defb 10 ; Note: 34.
defb 62 ; Short wait: 1.
defb 0 ; Note: 24.
defb 62 ; Short wait: 1.
defb 41 ; Note: 65.
defb 62 ; Short wait: 1.
defb 63, 22 ; Escaped note: 22.
defb 62 ; Short wait: 1.
defb 0 ; Note: 24.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 171 ; Note: 67.
defb 4 ; New instrument: 2.
defb 62 ; Short wait: 1.
defb 0 ; Note: 24.
defb 62 ; Short wait: 1.
defb 39 ; Note: 63.
defb 62 ; Short wait: 1.
defb 63, 19 ; Escaped note: 19.
defb 62 ; Short wait: 1.
defb 36 ; Note: 60.
defb 62 ; Short wait: 1.
defb 39 ; Note: 63.
defb 62 ; Short wait: 1.
defb 34 ; Note: 58.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 164 ; Note: 60.
defb 4 ; New instrument: 2.
defb 62 ; Short wait: 1.
defb 63, 19 ; Escaped note: 19.
defb 62 ; Short wait: 1.
defb 63, 19 ; Escaped note: 19.
defb 62 ; Short wait: 1.
defb 63, 22 ; Escaped note: 22.
defb 62 ; Short wait: 1.
defb 31 ; Note: 55.
defb 62 ; Short wait: 1.
defb 63, 19 ; Escaped note: 19.
defb 62 ; Short wait: 1.
defb 63, 22 ; Escaped note: 22.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 131 ; Note: 27.
defb 4 ; New instrument: 2.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 17 ; Note: 41.
defb 62 ; Short wait: 1.
Ouagadougou_Subsong0_Track12:
defb 128 ; Note: 24.
defb 4 ; New instrument: 2.
defb 62 ; Short wait: 1.
defb 43 ; Note: 67.
defb 62 ; Short wait: 1.
defb 41 ; Note: 65.
defb 62 ; Short wait: 1.
defb 43 ; Note: 67.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 174 ; Note: 70.
defb 4 ; New instrument: 2.
defb 62 ; Short wait: 1.
defb 12 ; Note: 36.
defb 62 ; Short wait: 1.
defb 10 ; Note: 34.
defb 62 ; Short wait: 1.
defb 0 ; Note: 24.
defb 62 ; Short wait: 1.
defb 43 ; Note: 67.
defb 62 ; Short wait: 1.
defb 63, 22 ; Escaped note: 22.
defb 62 ; Short wait: 1.
defb 0 ; Note: 24.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 174 ; Note: 70.
defb 4 ; New instrument: 2.
defb 62 ; Short wait: 1.
defb 0 ; Note: 24.
defb 62 ; Short wait: 1.
defb 41 ; Note: 65.
defb 62 ; Short wait: 1.
defb 3 ; Note: 27.
defb 62 ; Short wait: 1.
defb 39 ; Note: 63.
defb 62 ; Short wait: 1.
defb 34 ; Note: 58.
defb 62 ; Short wait: 1.
defb 3 ; Note: 27.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 131 ; Note: 27.
defb 4 ; New instrument: 2.
defb 62 ; Short wait: 1.
defb 3 ; Note: 27.
defb 62 ; Short wait: 1.
defb 7 ; Note: 31.
defb 62 ; Short wait: 1.
defb 63, 22 ; Escaped note: 22.
defb 62 ; Short wait: 1.
defb 43 ; Note: 67.
defb 62 ; Short wait: 1.
defb 41 ; Note: 65.
defb 62 ; Short wait: 1.
defb 63, 22 ; Escaped note: 22.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 191, 19 ; Escaped note: 19.
defb 4 ; New instrument: 2.
defb 62 ; Short wait: 1.
defb 3 ; Note: 27.
defb 62 ; Short wait: 1.
defb 43 ; Note: 67.
defb 62 ; Short wait: 1.
Ouagadougou_Subsong0_Track13:
defb 128 ; Note: 24.
defb 4 ; New instrument: 2.
defb 62 ; Short wait: 1.
defb 43 ; Note: 67.
defb 62 ; Short wait: 1.
defb 41 ; Note: 65.
defb 62 ; Short wait: 1.
defb 43 ; Note: 67.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 191, 72 ; Escaped note: 72.
defb 4 ; New instrument: 2.
defb 62 ; Short wait: 1.
defb 12 ; Note: 36.
defb 62 ; Short wait: 1.
defb 10 ; Note: 34.
defb 62 ; Short wait: 1.
defb 0 ; Note: 24.
defb 62 ; Short wait: 1.
defb 39 ; Note: 63.
defb 62 ; Short wait: 1.
defb 63, 22 ; Escaped note: 22.
defb 62 ; Short wait: 1.
defb 0 ; Note: 24.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 174 ; Note: 70.
defb 4 ; New instrument: 2.
defb 62 ; Short wait: 1.
defb 0 ; Note: 24.
defb 62 ; Short wait: 1.
defb 41 ; Note: 65.
defb 62 ; Short wait: 1.
defb 3 ; Note: 27.
defb 62 ; Short wait: 1.
defb 39 ; Note: 63.
defb 62 ; Short wait: 1.
defb 41 ; Note: 65.
defb 62 ; Short wait: 1.
defb 3 ; Note: 27.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 131 ; Note: 27.
defb 4 ; New instrument: 2.
defb 62 ; Short wait: 1.
defb 3 ; Note: 27.
defb 62 ; Short wait: 1.
defb 7 ; Note: 31.
defb 62 ; Short wait: 1.
defb 63, 22 ; Escaped note: 22.
defb 62 ; Short wait: 1.
defb 46 ; Note: 70.
defb 62 ; Short wait: 1.
defb 43 ; Note: 67.
defb 62 ; Short wait: 1.
defb 63, 22 ; Escaped note: 22.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 17 ; Note: 41.
defb 62 ; Short wait: 1.
defb 17 ; Note: 41.
defb 62 ; Short wait: 1.
defb 17 ; Note: 41.
defb 62 ; Short wait: 1.
Ouagadougou_Subsong0_Track14:
defb 128 ; Note: 24.
defb 4 ; New instrument: 2.
defb 62 ; Short wait: 1.
defb 31 ; Note: 55.
defb 63, 79 ; Escaped note: 79.
defb 36 ; Note: 60.
defb 63, 77 ; Escaped note: 77.
defb 43 ; Note: 67.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 167 ; Note: 63.
defb 4 ; New instrument: 2.
defb 63, 75 ; Escaped note: 75.
defb 12 ; Note: 36.
defb 63, 77 ; Escaped note: 77.
defb 10 ; Note: 34.
defb 62 ; Short wait: 1.
defb 0 ; Note: 24.
defb 62 ; Short wait: 1.
defb 41 ; Note: 65.
defb 63, 82 ; Escaped note: 82.
defb 63, 22 ; Escaped note: 22.
defb 63, 79 ; Escaped note: 79.
defb 0 ; Note: 24.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 191, 77 ; Escaped note: 77.
defb 4 ; New instrument: 2.
defb 43 ; Note: 67.
defb 63, 79 ; Escaped note: 79.
defb 0 ; Note: 24.
defb 62 ; Short wait: 1.
defb 39 ; Note: 63.
defb 63, 79 ; Escaped note: 79.
defb 63, 19 ; Escaped note: 19.
defb 62 ; Short wait: 1.
defb 36 ; Note: 60.
defb 62 ; Short wait: 1.
defb 39 ; Note: 63.
defb 62 ; Short wait: 1.
defb 34 ; Note: 58.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 164 ; Note: 60.
defb 4 ; New instrument: 2.
defb 63, 77 ; Escaped note: 77.
defb 63, 19 ; Escaped note: 19.
defb 63, 79 ; Escaped note: 79.
defb 63, 19 ; Escaped note: 19.
defb 63, 82 ; Escaped note: 82.
defb 63, 22 ; Escaped note: 22.
defb 63, 79 ; Escaped note: 79.
defb 31 ; Note: 55.
defb 62 ; Short wait: 1.
defb 63, 19 ; Escaped note: 19.
defb 63, 77 ; Escaped note: 77.
defb 63, 22 ; Escaped note: 22.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 191, 79 ; Escaped note: 79.
defb 4 ; New instrument: 2.
defb 3 ; Note: 27.
defb 63, 75 ; Escaped note: 75.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 191, 72 ; Escaped note: 72.
defb 4 ; New instrument: 2.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
Ouagadougou_Subsong0_Track15:
defb 128 ; Note: 24.
defb 4 ; New instrument: 2.
defb 62 ; Short wait: 1.
defb 43 ; Note: 67.
defb 62 ; Short wait: 1.
defb 41 ; Note: 65.
defb 63, 79 ; Escaped note: 79.
defb 43 ; Note: 67.
defb 63, 82 ; Escaped note: 82.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 174 ; Note: 70.
defb 4 ; New instrument: 2.
defb 63, 84 ; Escaped note: 84.
defb 12 ; Note: 36.
defb 62 ; Short wait: 1.
defb 10 ; Note: 34.
defb 63, 84 ; Escaped note: 84.
defb 0 ; Note: 24.
defb 62 ; Short wait: 1.
defb 43 ; Note: 67.
defb 62 ; Short wait: 1.
defb 63, 22 ; Escaped note: 22.
defb 63, 82 ; Escaped note: 82.
defb 0 ; Note: 24.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 174 ; Note: 70.
defb 4 ; New instrument: 2.
defb 62 ; Short wait: 1.
defb 0 ; Note: 24.
defb 63, 79 ; Escaped note: 79.
defb 41 ; Note: 65.
defb 63, 82 ; Escaped note: 82.
defb 3 ; Note: 27.
defb 62 ; Short wait: 1.
defb 39 ; Note: 63.
defb 62 ; Short wait: 1.
defb 34 ; Note: 58.
defb 63, 82 ; Escaped note: 82.
defb 3 ; Note: 27.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 191, 79 ; Escaped note: 79.
defb 4 ; New instrument: 2.
defb 3 ; Note: 27.
defb 62 ; Short wait: 1.
defb 3 ; Note: 27.
defb 62 ; Short wait: 1.
defb 7 ; Note: 31.
defb 63, 77 ; Escaped note: 77.
defb 63, 22 ; Escaped note: 22.
defb 63, 79 ; Escaped note: 79.
defb 43 ; Note: 67.
defb 62 ; Short wait: 1.
defb 41 ; Note: 65.
defb 63, 79 ; Escaped note: 79.
defb 63, 22 ; Escaped note: 22.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 191, 77 ; Escaped note: 77.
defb 4 ; New instrument: 2.
defb 63, 19 ; Escaped note: 19.
defb 63, 82 ; Escaped note: 82.
defb 3 ; Note: 27.
defb 62 ; Short wait: 1.
defb 63, 79 ; Escaped note: 79.
defb 63, 77 ; Escaped note: 77.
Ouagadougou_Subsong0_Track16:
defb 128 ; Note: 24.
defb 4 ; New instrument: 2.
defb 63, 84 ; Escaped note: 84.
defb 43 ; Note: 67.
defb 63, 82 ; Escaped note: 82.
defb 41 ; Note: 65.
defb 63, 79 ; Escaped note: 79.
defb 43 ; Note: 67.
defb 63, 82 ; Escaped note: 82.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 191, 72 ; Escaped note: 72.
defb 4 ; New instrument: 2.
defb 62 ; Short wait: 1.
defb 12 ; Note: 36.
defb 63, 79 ; Escaped note: 79.
defb 10 ; Note: 34.
defb 62 ; Short wait: 1.
defb 0 ; Note: 24.
defb 62 ; Short wait: 1.
defb 39 ; Note: 63.
defb 63, 82 ; Escaped note: 82.
defb 63, 22 ; Escaped note: 22.
defb 63, 79 ; Escaped note: 79.
defb 0 ; Note: 24.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 174 ; Note: 70.
defb 4 ; New instrument: 2.
defb 63, 77 ; Escaped note: 77.
defb 0 ; Note: 24.
defb 63, 79 ; Escaped note: 79.
defb 41 ; Note: 65.
defb 62 ; Short wait: 1.
defb 3 ; Note: 27.
defb 62 ; Short wait: 1.
defb 39 ; Note: 63.
defb 63, 82 ; Escaped note: 82.
defb 41 ; Note: 65.
defb 63, 79 ; Escaped note: 79.
defb 3 ; Note: 27.
defb 62 ; Short wait: 1.
defb 63, 84 ; Escaped note: 84.
defb 63, 82 ; Escaped note: 82.
defb 3 ; Note: 27.
defb 63, 79 ; Escaped note: 79.
defb 3 ; Note: 27.
defb 62 ; Short wait: 1.
defb 7 ; Note: 31.
defb 63, 77 ; Escaped note: 77.
defb 63, 22 ; Escaped note: 22.
defb 62 ; Short wait: 1.
defb 46 ; Note: 70.
defb 63, 79 ; Escaped note: 79.
defb 43 ; Note: 67.
defb 62 ; Short wait: 1.
defb 63, 22 ; Escaped note: 22.
defb 63, 84 ; Escaped note: 84.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 191, 82 ; Escaped note: 82.
defb 4 ; New instrument: 2.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 17 ; Note: 41.
defb 191, 77 ; Escaped note: 77.
defb 4 ; New instrument: 2.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 191, 79 ; Escaped note: 79.
defb 4 ; New instrument: 2.
Ouagadougou_Subsong0_Track17:
defb 191, 84 ; Escaped note: 84.
defb 4 ; New instrument: 2.
defb 63, 82 ; Escaped note: 82.
defb 63, 79 ; Escaped note: 79.
defb 63, 82 ; Escaped note: 82.
defb 62 ; Short wait: 1.
defb 63, 79 ; Escaped note: 79.
defb 63, 77 ; Escaped note: 77.
defb 63, 79 ; Escaped note: 79.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 191, 77 ; Escaped note: 77.
defb 4 ; New instrument: 2.
defb 63, 75 ; Escaped note: 75.
defb 63, 77 ; Escaped note: 77.
defb 254 ; Short wait: 4.
defb 63, 72 ; Escaped note: 72.
defb 63, 75 ; Escaped note: 75.
defb 63, 77 ; Escaped note: 77.
defb 63, 79 ; Escaped note: 79.
defb 254 ; Short wait: 4.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 191, 79 ; Escaped note: 79.
defb 4 ; New instrument: 2.
defb 63, 82 ; Escaped note: 82.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 191, 84 ; Escaped note: 84.
defb 4 ; New instrument: 2.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 191, 77 ; Escaped note: 77.
defb 4 ; New instrument: 2.
defb 63, 79 ; Escaped note: 79.
defb 63, 84 ; Escaped note: 84.
defb 63, 82 ; Escaped note: 82.
defb 126 ; Short wait: 2.
defb 63, 79 ; Escaped note: 79.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 17 ; Note: 41.
defb 62 ; Short wait: 1.
defb 191, 77 ; Escaped note: 77.
defb 4 ; New instrument: 2.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 191, 79 ; Escaped note: 79.
defb 4 ; New instrument: 2.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 191, 72 ; Escaped note: 72.
defb 4 ; New instrument: 2.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 17 ; Note: 41.
defb 62 ; Short wait: 1.
defb 191, 82 ; Escaped note: 82.
defb 4 ; New instrument: 2.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 17 ; Note: 41.
defb 62 ; Short wait: 1.
Ouagadougou_Subsong0_Track18:
defb 191, 84 ; Escaped note: 84.
defb 4 ; New instrument: 2.
defb 63, 87 ; Escaped note: 87.
defb 63, 79 ; Escaped note: 79.
defb 63, 82 ; Escaped note: 82.
defb 126 ; Short wait: 2.
defb 63, 79 ; Escaped note: 79.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 191, 77 ; Escaped note: 77.
defb 4 ; New instrument: 2.
defb 63, 79 ; Escaped note: 79.
defb 190 ; Short wait: 3.
defb 63, 82 ; Escaped note: 82.
defb 190 ; Short wait: 3.
defb 63, 84 ; Escaped note: 84.
defb 126 ; Short wait: 2.
defb 63, 87 ; Escaped note: 87.
defb 63, 84 ; Escaped note: 84.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 191, 82 ; Escaped note: 82.
defb 4 ; New instrument: 2.
defb 63, 84 ; Escaped note: 84.
defb 126 ; Short wait: 2.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 191, 72 ; Escaped note: 72.
defb 4 ; New instrument: 2.
defb 63, 75 ; Escaped note: 75.
defb 63, 77 ; Escaped note: 77.
defb 63, 79 ; Escaped note: 79.
defb 126 ; Short wait: 2.
defb 63, 82 ; Escaped note: 82.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 191, 84 ; Escaped note: 84.
defb 4 ; New instrument: 2.
defb 63, 82 ; Escaped note: 82.
defb 63, 79 ; Escaped note: 79.
defb 62 ; Short wait: 1.
defb 63, 82 ; Escaped note: 82.
defb 190 ; Short wait: 3.
defb 63, 79 ; Escaped note: 79.
defb 62 ; Short wait: 1.
defb 63, 77 ; Escaped note: 77.
defb 62 ; Short wait: 1.
defb 63, 75 ; Escaped note: 75.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 174 ; Note: 70.
defb 4 ; New instrument: 2.
defb 62 ; Short wait: 1.
defb 63, 72 ; Escaped note: 72.
defb 62 ; Short wait: 1.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
Ouagadougou_Subsong0_Track19:
defb 191, 82 ; Escaped note: 82.
defb 4 ; New instrument: 2.
defb 63, 84 ; Escaped note: 84.
defb 63, 87 ; Escaped note: 87.
defb 63, 84 ; Escaped note: 84.
defb 63, 82 ; Escaped note: 82.
defb 63, 84 ; Escaped note: 84.
defb 126 ; Short wait: 2.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 191, 87 ; Escaped note: 87.
defb 4 ; New instrument: 2.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 191, 89 ; Escaped note: 89.
defb 4 ; New instrument: 2.
defb 190 ; Short wait: 3.
defb 63, 91 ; Escaped note: 91.
defb 190 ; Short wait: 3.
defb 63, 89 ; Escaped note: 89.
defb 63, 87 ; Escaped note: 87.
defb 63, 84 ; Escaped note: 84.
defb 126 ; Short wait: 2.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 191, 82 ; Escaped note: 82.
defb 4 ; New instrument: 2.
defb 63, 84 ; Escaped note: 84.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 191, 84 ; Escaped note: 84.
defb 4 ; New instrument: 2.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 126 ; Short wait: 2.
defb 191, 84 ; Escaped note: 84.
defb 4 ; New instrument: 2.
defb 63, 82 ; Escaped note: 82.
defb 62 ; Short wait: 1.
defb 63, 87 ; Escaped note: 87.
defb 63, 84 ; Escaped note: 84.
defb 62 ; Short wait: 1.
defb 63, 79 ; Escaped note: 79.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 191, 79 ; Escaped note: 79.
defb 4 ; New instrument: 2.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 191, 82 ; Escaped note: 82.
defb 4 ; New instrument: 2.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 191, 84 ; Escaped note: 84.
defb 4 ; New instrument: 2.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 191, 75 ; Escaped note: 75.
defb 4 ; New instrument: 2.
defb 63, 72 ; Escaped note: 72.
defb 62 ; Short wait: 1.
defb 46 ; Note: 70.
defb 63, 72 ; Escaped note: 72.
defb 0 ; Note: 24.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 171 ; Note: 67.
defb 4 ; New instrument: 2.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 128 ; Note: 24.
defb 4 ; New instrument: 2.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 174 ; Note: 70.
defb 4 ; New instrument: 2.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 191, 72 ; Escaped note: 72.
defb 4 ; New instrument: 2.
defb 145 ; Note: 41.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
Ouagadougou_Subsong0_Track21:
defb 128 ; Note: 24.
defb 4 ; New instrument: 2.
defb 61, 30 ; Long wait: 31.
defb 0 ; Note: 24.
defb 62 ; Short wait: 1.
defb 0 ; Note: 24.
defb 62 ; Short wait: 1.
defb 0 ; Note: 24.
defb 61, 16 ; Long wait: 17.
defb 130 ; Note: 26.
defb 2 ; New instrument: 1.
defb 62 ; Short wait: 1.
defb 63, 15 ; Escaped note: 15.
defb 62 ; Short wait: 1.
defb 63, 2 ; Escaped note: 2.
defb 63, 2 ; Escaped note: 2.
defb 63, 2 ; Escaped note: 2.
defb 190 ; Short wait: 3.
|
programs/oeis/055/A055585.asm | karttu/loda | 1 | 7760 | ; A055585: Second column of triangle A055584.
; 1,6,25,88,280,832,2352,6400,16896,43520,109824,272384,665600,1605632,3829760,9043968,21168128,49152000,113311744,259522560,590872576,1337982976,3014656000,6761218048,15099494400,33587986432,74440507392
mov $1,$0
mov $2,2
add $2,$0
mov $0,2
pow $0,$1
add $1,8
pow $2,2
sub $2,1
mul $2,$0
mul $1,$2
sub $1,24
div $1,24
add $1,1
|
programs/oeis/268/A268414.asm | jmorken/loda | 1 | 4467 | <gh_stars>1-10
; A268414: a(n) = 5*a(n - 1) - 2*n for n>0, a(0) = 1.
; 1,3,11,49,237,1175,5863,29301,146489,732427,3662115,18310553,91552741,457763679,2288818367,11444091805,57220458993,286102294931,1430511474619,7152557373057,35762786865245,178813934326183,894069671630871,4470348358154309
mov $2,$0
mov $4,2
lpb $0
sub $0,1
add $1,1
add $3,$4
add $1,$3
sub $1,3
mov $4,$3
sub $3,2
mul $4,4
lpe
lpb $2
add $1,2
sub $2,1
lpe
add $1,1
|
coco.g4 | JaMort/CoCo | 0 | 2761 | <filename>coco.g4<gh_stars>0
grammar coco;
/* Compiler-compiler */
start : dtd+=dataTypeDef+ EOF ;
// definition of an algebraic data type
dataTypeDef : 'DATA'
name=ID 'WITH' fun=JAVACODE '=' as=alternatives ';' ;
// alternatives of an algebraic data type and concrete syntax for it.
alternatives : as+=alternative ('|' as+=alternative)* ;
alternative : cons=ID '(' as=arguments ')' code=JAVACODE ;
// an argument consists of a type and a name (both are IDs for the lexer)
arguments : as+=argument (',' as+=argument)* ;
argument : type=ID name=ID ;
ID : ('A'..'Z'|'a'..'z'|'_')('A'..'Z'|'a'..'z'|'_'|'0'..'9'|'<'|'>')* ;
WHITESPACE : [ \n\t\r]+ -> skip;
COMMENT : '//'(~[\n])* -> skip;
JAVACODE : '^' ~[^~]* '~'; // allowing no further braces in code.
|
roses.asm | yarneo/alonandyarden-os-ass2 | 0 | 83768 | <gh_stars>0
_roses: file format elf32-i386
Disassembly of section .text:
00000000 <charCat>:
}
}
void
charCat(char* str, char c) {
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
char* point = str;
while((*point) != '\0') {
3: 8b 45 08 mov 0x8(%ebp),%eax
}
}
void
charCat(char* str, char c) {
6: 0f b6 55 0c movzbl 0xc(%ebp),%edx
char* point = str;
while((*point) != '\0') {
a: 80 38 00 cmpb $0x0,(%eax)
d: 74 09 je 18 <charCat+0x18>
f: 90 nop
point++;
10: 83 c0 01 add $0x1,%eax
void
charCat(char* str, char c) {
char* point = str;
while((*point) != '\0') {
13: 80 38 00 cmpb $0x0,(%eax)
16: 75 f8 jne 10 <charCat+0x10>
point++;
}
(*point) = c;
18: 88 10 mov %dl,(%eax)
point++;
(*point) = '\0';
1a: c6 40 01 00 movb $0x0,0x1(%eax)
}
1e: 5d pop %ebp
1f: c3 ret
00000020 <addNewRequest>:
return -1;
}
return 0;
}
void addNewRequest( Request* newReq) {
20: 55 push %ebp
21: 89 e5 mov %esp,%ebp
23: 83 ec 18 sub $0x18,%esp
semaphore_put(RBB,(void*)newReq);
26: 8b 45 08 mov 0x8(%ebp),%eax
29: 89 44 24 04 mov %eax,0x4(%esp)
2d: a1 f4 18 00 00 mov 0x18f4,%eax
32: 89 04 24 mov %eax,(%esp)
35: e8 56 15 00 00 call 1590 <semaphore_put>
}
3a: c9 leave
3b: c3 ret
3c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
00000040 <readFromFile>:
(*point) = '\0';
}
void
readFromFile()
{
40: 55 push %ebp
41: 89 e5 mov %esp,%ebp
43: 57 push %edi
44: 56 push %esi
45: 53 push %ebx
46: 83 ec 7c sub $0x7c,%esp
int counter = 0;
int flag = 0;
char Bstr[11] = "\0";
49: 0f b7 05 15 17 00 00 movzwl 0x1715,%eax
50: c7 45 de 00 00 00 00 movl $0x0,-0x22(%ebp)
57: c7 45 e2 00 00 00 00 movl $0x0,-0x1e(%ebp)
5e: c6 45 e6 00 movb $0x0,-0x1a(%ebp)
62: 66 89 45 dc mov %ax,-0x24(%ebp)
char Hstr[11] = "\0";;
66: 66 89 45 d1 mov %ax,-0x2f(%ebp)
6a: c7 45 d3 00 00 00 00 movl $0x0,-0x2d(%ebp)
71: c7 45 d7 00 00 00 00 movl $0x0,-0x29(%ebp)
78: c6 45 db 00 movb $0x0,-0x25(%ebp)
char Rstr[11] = "\0";;
7c: 66 89 45 c6 mov %ax,-0x3a(%ebp)
80: c7 45 c8 00 00 00 00 movl $0x0,-0x38(%ebp)
87: c7 45 cc 00 00 00 00 movl $0x0,-0x34(%ebp)
8e: c6 45 d0 00 movb $0x0,-0x30(%ebp)
char Cstr[11] = "\0";;
92: 66 89 45 bb mov %ax,-0x45(%ebp)
96: c7 45 bd 00 00 00 00 movl $0x0,-0x43(%ebp)
9d: c7 45 c1 00 00 00 00 movl $0x0,-0x3f(%ebp)
a4: c6 45 c5 00 movb $0x0,-0x3b(%ebp)
char totalRequestsstr[11];
int fd = open("configuration.conf",O_RDONLY);
a8: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
af: 00
b0: c7 04 24 b0 16 00 00 movl $0x16b0,(%esp)
b7: e8 7c 0c 00 00 call d38 <open>
if(fd < 0) {
bc: 85 c0 test %eax,%eax
char Bstr[11] = "\0";
char Hstr[11] = "\0";;
char Rstr[11] = "\0";;
char Cstr[11] = "\0";;
char totalRequestsstr[11];
int fd = open("configuration.conf",O_RDONLY);
be: 89 c6 mov %eax,%esi
if(fd < 0) {
c0: 0f 88 05 02 00 00 js 2cb <readFromFile+0x28b>
c6: c7 45 94 00 00 00 00 movl $0x0,-0x6c(%ebp)
cd: 8d 7d e7 lea -0x19(%ebp),%edi
printf(2,"problem opening file");
exit();
}
char readbuf;
while(read(fd,&readbuf,1) > 0)
d0: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
d7: 00
d8: 89 7c 24 04 mov %edi,0x4(%esp)
dc: 89 34 24 mov %esi,(%esp)
df: e8 2c 0c 00 00 call d10 <read>
e4: 85 c0 test %eax,%eax
e6: 0f 8e bc 00 00 00 jle 1a8 <readFromFile+0x168>
{
if(readbuf == 'B') {
ec: 0f b6 55 e7 movzbl -0x19(%ebp),%edx
f0: 80 fa 42 cmp $0x42,%dl
f3: 0f 84 af 01 00 00 je 2a8 <readFromFile+0x268>
flag = 1;
counter++;
}
if(readbuf == 'H') {
f9: 80 fa 48 cmp $0x48,%dl
fc: 0f 84 96 01 00 00 je 298 <readFromFile+0x258>
flag = 2;
counter++;
}
if(readbuf == 'R') {
102: 80 fa 52 cmp $0x52,%dl
105: 0f 85 ad 01 00 00 jne 2b8 <readFromFile+0x278>
flag = 3;
counter++;
10b: 83 45 94 01 addl $0x1,-0x6c(%ebp)
10f: bb 03 00 00 00 mov $0x3,%ebx
114: eb 06 jmp 11c <readFromFile+0xdc>
116: 66 90 xchg %ax,%ax
counter++;
}
}
if(flag > 0) { //if one of the conditions above apply, we need to extract the number
while((readbuf < '0') || (readbuf > '9')) { //read untill we reach a number
if(read(fd,&readbuf,1) <= 0)
118: 0f b6 55 e7 movzbl -0x19(%ebp),%edx
flag = 5;
counter++;
}
}
if(flag > 0) { //if one of the conditions above apply, we need to extract the number
while((readbuf < '0') || (readbuf > '9')) { //read untill we reach a number
11c: 8d 42 d0 lea -0x30(%edx),%eax
11f: 3c 09 cmp $0x9,%al
121: 76 21 jbe 144 <readFromFile+0x104>
if(read(fd,&readbuf,1) <= 0)
123: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
12a: 00
12b: 89 7c 24 04 mov %edi,0x4(%esp)
12f: 89 34 24 mov %esi,(%esp)
132: e8 d9 0b 00 00 call d10 <read>
137: 85 c0 test %eax,%eax
139: 7f dd jg 118 <readFromFile+0xd8>
13b: 90 nop
13c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
if(flag == 4)
charCat(Cstr,readbuf);
if(flag == 5)
charCat(totalRequestsstr,readbuf);
if(read(fd,&readbuf,1) <= 0)
140: 0f b6 55 e7 movzbl -0x19(%ebp),%edx
if(flag > 0) { //if one of the conditions above apply, we need to extract the number
while((readbuf < '0') || (readbuf > '9')) { //read untill we reach a number
if(read(fd,&readbuf,1) <= 0)
break;
}
while((readbuf >= '0') && (readbuf <= '9')) { //when we reach an number, we read it and concat it to a string
144: 8d 42 d0 lea -0x30(%edx),%eax
147: 3c 09 cmp $0x9,%al
149: 77 53 ja 19e <readFromFile+0x15e>
if(flag == 1)
14b: 83 fb 01 cmp $0x1,%ebx
14e: 0f 84 d4 00 00 00 je 228 <readFromFile+0x1e8>
charCat(Bstr,readbuf);
if(flag == 2)
154: 83 fb 02 cmp $0x2,%ebx
157: 0f 84 ab 00 00 00 je 208 <readFromFile+0x1c8>
charCat(Hstr,readbuf);
if(flag == 3)
15d: 83 fb 03 cmp $0x3,%ebx
160: 0f 85 e2 00 00 00 jne 248 <readFromFile+0x208>
void
charCat(char* str, char c) {
char* point = str;
while((*point) != '\0') {
166: 80 7d c6 00 cmpb $0x0,-0x3a(%ebp)
16a: 8d 45 c6 lea -0x3a(%ebp),%eax
16d: 8d 76 00 lea 0x0(%esi),%esi
170: 74 0e je 180 <readFromFile+0x140>
172: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
point++;
178: 83 c0 01 add $0x1,%eax
void
charCat(char* str, char c) {
char* point = str;
while((*point) != '\0') {
17b: 80 38 00 cmpb $0x0,(%eax)
17e: 75 f8 jne 178 <readFromFile+0x138>
point++;
}
(*point) = c;
180: 88 10 mov %dl,(%eax)
point++;
(*point) = '\0';
182: c6 40 01 00 movb $0x0,0x1(%eax)
if(flag == 4)
charCat(Cstr,readbuf);
if(flag == 5)
charCat(totalRequestsstr,readbuf);
if(read(fd,&readbuf,1) <= 0)
186: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
18d: 00
18e: 89 7c 24 04 mov %edi,0x4(%esp)
192: 89 34 24 mov %esi,(%esp)
195: e8 76 0b 00 00 call d10 <read>
19a: 85 c0 test %eax,%eax
19c: 7f a2 jg 140 <readFromFile+0x100>
break;
}
flag = 0;
}
if(counter >=5) {//if we read all 5 numbers we stop
19e: 83 7d 94 04 cmpl $0x4,-0x6c(%ebp)
1a2: 0f 8e 28 ff ff ff jle d0 <readFromFile+0x90>
break;
}
}
B = atoi(Bstr);
1a8: 8d 45 dc lea -0x24(%ebp),%eax
1ab: 89 04 24 mov %eax,(%esp)
1ae: e8 1d 0a 00 00 call bd0 <atoi>
1b3: a3 0c 19 00 00 mov %eax,0x190c
H = atoi(Hstr);
1b8: 8d 45 d1 lea -0x2f(%ebp),%eax
1bb: 89 04 24 mov %eax,(%esp)
1be: e8 0d 0a 00 00 call bd0 <atoi>
1c3: a3 18 19 00 00 mov %eax,0x1918
R = atoi(Rstr);
1c8: 8d 45 c6 lea -0x3a(%ebp),%eax
1cb: 89 04 24 mov %eax,(%esp)
1ce: e8 fd 09 00 00 call bd0 <atoi>
1d3: a3 1c 19 00 00 mov %eax,0x191c
C = atoi(Cstr);
1d8: 8d 45 bb lea -0x45(%ebp),%eax
1db: 89 04 24 mov %eax,(%esp)
1de: e8 ed 09 00 00 call bd0 <atoi>
1e3: a3 14 19 00 00 mov %eax,0x1914
totalRequests = atoi(totalRequestsstr);
1e8: 8d 45 b0 lea -0x50(%ebp),%eax
1eb: 89 04 24 mov %eax,(%esp)
1ee: e8 dd 09 00 00 call bd0 <atoi>
close(fd);
1f3: 89 34 24 mov %esi,(%esp)
}
B = atoi(Bstr);
H = atoi(Hstr);
R = atoi(Rstr);
C = atoi(Cstr);
totalRequests = atoi(totalRequestsstr);
1f6: a3 f0 18 00 00 mov %eax,0x18f0
close(fd);
1fb: e8 20 0b 00 00 call d20 <close>
}
200: 83 c4 7c add $0x7c,%esp
203: 5b pop %ebx
204: 5e pop %esi
205: 5f pop %edi
206: 5d pop %ebp
207: c3 ret
void
charCat(char* str, char c) {
char* point = str;
while((*point) != '\0') {
208: 80 7d d1 00 cmpb $0x0,-0x2f(%ebp)
20c: 8d 45 d1 lea -0x2f(%ebp),%eax
20f: 0f 84 6b ff ff ff je 180 <readFromFile+0x140>
215: 8d 76 00 lea 0x0(%esi),%esi
point++;
218: 83 c0 01 add $0x1,%eax
void
charCat(char* str, char c) {
char* point = str;
while((*point) != '\0') {
21b: 80 38 00 cmpb $0x0,(%eax)
21e: 75 f8 jne 218 <readFromFile+0x1d8>
220: e9 5b ff ff ff jmp 180 <readFromFile+0x140>
225: 8d 76 00 lea 0x0(%esi),%esi
228: 80 7d dc 00 cmpb $0x0,-0x24(%ebp)
22c: 8d 45 dc lea -0x24(%ebp),%eax
22f: 90 nop
230: 0f 84 4a ff ff ff je 180 <readFromFile+0x140>
236: 66 90 xchg %ax,%ax
point++;
238: 83 c0 01 add $0x1,%eax
void
charCat(char* str, char c) {
char* point = str;
while((*point) != '\0') {
23b: 80 38 00 cmpb $0x0,(%eax)
23e: 66 90 xchg %ax,%ax
240: 75 f6 jne 238 <readFromFile+0x1f8>
242: e9 39 ff ff ff jmp 180 <readFromFile+0x140>
247: 90 nop
charCat(Bstr,readbuf);
if(flag == 2)
charCat(Hstr,readbuf);
if(flag == 3)
charCat(Rstr,readbuf);
if(flag == 4)
248: 83 fb 04 cmp $0x4,%ebx
24b: 90 nop
24c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
250: 75 1b jne 26d <readFromFile+0x22d>
void
charCat(char* str, char c) {
char* point = str;
while((*point) != '\0') {
252: 80 7d bb 00 cmpb $0x0,-0x45(%ebp)
256: 8d 45 bb lea -0x45(%ebp),%eax
259: 0f 84 21 ff ff ff je 180 <readFromFile+0x140>
25f: 90 nop
point++;
260: 83 c0 01 add $0x1,%eax
void
charCat(char* str, char c) {
char* point = str;
while((*point) != '\0') {
263: 80 38 00 cmpb $0x0,(%eax)
266: 75 f8 jne 260 <readFromFile+0x220>
268: e9 13 ff ff ff jmp 180 <readFromFile+0x140>
charCat(Hstr,readbuf);
if(flag == 3)
charCat(Rstr,readbuf);
if(flag == 4)
charCat(Cstr,readbuf);
if(flag == 5)
26d: 83 fb 05 cmp $0x5,%ebx
270: 0f 85 10 ff ff ff jne 186 <readFromFile+0x146>
void
charCat(char* str, char c) {
char* point = str;
while((*point) != '\0') {
276: 80 7d b0 00 cmpb $0x0,-0x50(%ebp)
27a: 8d 45 b0 lea -0x50(%ebp),%eax
27d: 8d 76 00 lea 0x0(%esi),%esi
280: 0f 84 fa fe ff ff je 180 <readFromFile+0x140>
286: 66 90 xchg %ax,%ax
point++;
288: 83 c0 01 add $0x1,%eax
void
charCat(char* str, char c) {
char* point = str;
while((*point) != '\0') {
28b: 80 38 00 cmpb $0x0,(%eax)
28e: 75 f8 jne 288 <readFromFile+0x248>
290: e9 eb fe ff ff jmp 180 <readFromFile+0x140>
295: 8d 76 00 lea 0x0(%esi),%esi
flag = 1;
counter++;
}
if(readbuf == 'H') {
flag = 2;
counter++;
298: 83 45 94 01 addl $0x1,-0x6c(%ebp)
29c: bb 02 00 00 00 mov $0x2,%ebx
2a1: e9 72 fe ff ff jmp 118 <readFromFile+0xd8>
2a6: 66 90 xchg %ax,%ax
char readbuf;
while(read(fd,&readbuf,1) > 0)
{
if(readbuf == 'B') {
flag = 1;
counter++;
2a8: 83 45 94 01 addl $0x1,-0x6c(%ebp)
2ac: bb 01 00 00 00 mov $0x1,%ebx
2b1: e9 62 fe ff ff jmp 118 <readFromFile+0xd8>
2b6: 66 90 xchg %ax,%ax
}
if(readbuf == 'R') {
flag = 3;
counter++;
}
if(readbuf == 'C') {
2b8: 80 fa 43 cmp $0x43,%dl
2bb: 75 27 jne 2e4 <readFromFile+0x2a4>
flag = 4;
counter++;
2bd: 83 45 94 01 addl $0x1,-0x6c(%ebp)
2c1: bb 04 00 00 00 mov $0x4,%ebx
2c6: e9 51 fe ff ff jmp 11c <readFromFile+0xdc>
char Rstr[11] = "\0";;
char Cstr[11] = "\0";;
char totalRequestsstr[11];
int fd = open("configuration.conf",O_RDONLY);
if(fd < 0) {
printf(2,"problem opening file");
2cb: c7 44 24 04 c3 16 00 movl $0x16c3,0x4(%esp)
2d2: 00
2d3: c7 04 24 02 00 00 00 movl $0x2,(%esp)
2da: e8 b1 0b 00 00 call e90 <printf>
exit();
2df: e8 14 0a 00 00 call cf8 <exit>
}
if(readbuf == 'C') {
flag = 4;
counter++;
}
if(readbuf == 't') {
2e4: 80 fa 74 cmp $0x74,%dl
2e7: 0f 85 b1 fe ff ff jne 19e <readFromFile+0x15e>
char teststr[12];
read(fd,teststr,12);
2ed: 8d 45 a4 lea -0x5c(%ebp),%eax
2f0: c7 44 24 08 0c 00 00 movl $0xc,0x8(%esp)
2f7: 00
2f8: 89 44 24 04 mov %eax,0x4(%esp)
2fc: 89 34 24 mov %esi,(%esp)
2ff: e8 0c 0a 00 00 call d10 <read>
if(strcmp(teststr, "otalRequests")==0) {
304: 8d 45 a4 lea -0x5c(%ebp),%eax
307: c7 44 24 04 d8 16 00 movl $0x16d8,0x4(%esp)
30e: 00
30f: 89 04 24 mov %eax,(%esp)
312: e8 e9 07 00 00 call b00 <strcmp>
317: 85 c0 test %eax,%eax
319: 0f 85 7f fe ff ff jne 19e <readFromFile+0x15e>
flag = 5;
counter++;
31f: 83 45 94 01 addl $0x1,-0x6c(%ebp)
323: bb 05 00 00 00 mov $0x5,%ebx
328: 0f b6 55 e7 movzbl -0x19(%ebp),%edx
32c: e9 eb fd ff ff jmp 11c <readFromFile+0xdc>
331: eb 0d jmp 340 <main>
333: 90 nop
334: 90 nop
335: 90 nop
336: 90 nop
337: 90 nop
338: 90 nop
339: 90 nop
33a: 90 nop
33b: 90 nop
33c: 90 nop
33d: 90 nop
33e: 90 nop
33f: 90 nop
00000340 <main>:
C = atoi(Cstr);
totalRequests = atoi(totalRequestsstr);
close(fd);
}
int main() {
340: 8d 4c 24 04 lea 0x4(%esp),%ecx
344: 83 e4 f0 and $0xfffffff0,%esp
347: ff 71 fc pushl -0x4(%ecx)
34a: 55 push %ebp
34b: 89 e5 mov %esp,%ebp
34d: 56 push %esi
34e: 53 push %ebx
34f: 51 push %ecx
350: 83 ec 1c sub $0x1c,%esp
int i;
void* ustack;
readFromFile();
353: e8 e8 fc ff ff call 40 <readFromFile>
//printf(1,"%d %d %d %d %d\n",B,H,R,C,totalRequests);
filedes = open("ass2_log.txt",(O_WRONLY | O_CREATE));
358: c7 44 24 04 01 02 00 movl $0x201,0x4(%esp)
35f: 00
360: c7 04 24 e5 16 00 00 movl $0x16e5,(%esp)
367: e8 cc 09 00 00 call d38 <open>
if(filedes < 0) {
36c: 85 c0 test %eax,%eax
int main() {
int i;
void* ustack;
readFromFile();
//printf(1,"%d %d %d %d %d\n",B,H,R,C,totalRequests);
filedes = open("ass2_log.txt",(O_WRONLY | O_CREATE));
36e: a3 e4 18 00 00 mov %eax,0x18e4
if(filedes < 0) {
373: 0f 88 37 02 00 00 js 5b0 <main+0x270>
printf(2,"problem opening file\n");
exit();
}
RBB = BB_create(R);
379: a1 1c 19 00 00 mov 0x191c,%eax
37e: 89 04 24 mov %eax,(%esp)
381: e8 9a 12 00 00 call 1620 <BB_create>
386: a3 f4 18 00 00 mov %eax,0x18f4
CBB = BB_create(C);
38b: a1 14 19 00 00 mov 0x1914,%eax
390: 89 04 24 mov %eax,(%esp)
393: e8 88 12 00 00 call 1620 <BB_create>
dirtyCups = 0;
398: c7 05 f8 18 00 00 00 movl $0x0,0x18f8
39f: 00 00 00
requests = 0;
3a2: c7 05 04 19 00 00 00 movl $0x0,0x1904
3a9: 00 00 00
printf(2,"problem opening file\n");
exit();
}
RBB = BB_create(R);
CBB = BB_create(C);
3ac: a3 20 19 00 00 mov %eax,0x1920
dirtyCups = 0;
requests = 0;
binsem_counter_dirty_cups = binary_sem_create();
3b1: e8 0a 0a 00 00 call dc0 <binary_sem_create>
3b6: a3 e8 18 00 00 mov %eax,0x18e8
binsem_counter_requests = binary_sem_create();
3bb: e8 00 0a 00 00 call dc0 <binary_sem_create>
3c0: a3 ec 18 00 00 mov %eax,0x18ec
binsem_wake_busboy = binary_sem_create();
3c5: e8 f6 09 00 00 call dc0 <binary_sem_create>
3ca: a3 fc 18 00 00 mov %eax,0x18fc
binsem_on_cups_array = binary_sem_create();
3cf: e8 ec 09 00 00 call dc0 <binary_sem_create>
3d4: a3 00 19 00 00 mov %eax,0x1900
binsem_printing = binary_sem_create();
3d9: e8 e2 09 00 00 call dc0 <binary_sem_create>
3de: a3 08 19 00 00 mov %eax,0x1908
binary_sem_down(binsem_wake_busboy);
3e3: a1 fc 18 00 00 mov 0x18fc,%eax
3e8: 89 04 24 mov %eax,(%esp)
3eb: e8 d8 09 00 00 call dc8 <binary_sem_down>
cups = malloc(sizeof(Cup) * C);
3f0: a1 14 19 00 00 mov 0x1914,%eax
3f5: c1 e0 02 shl $0x2,%eax
3f8: 89 04 24 mov %eax,(%esp)
3fb: e8 30 0d 00 00 call 1130 <malloc>
for(i=0;i<C;i++) {
400: 8b 15 14 19 00 00 mov 0x1914,%edx
406: 85 d2 test %edx,%edx
binsem_wake_busboy = binary_sem_create();
binsem_on_cups_array = binary_sem_create();
binsem_printing = binary_sem_create();
binary_sem_down(binsem_wake_busboy);
cups = malloc(sizeof(Cup) * C);
408: a3 10 19 00 00 mov %eax,0x1910
for(i=0;i<C;i++) {
40d: 7e 3e jle 44d <main+0x10d>
40f: 31 db xor %ebx,%ebx
411: eb 0a jmp 41d <main+0xdd>
413: 90 nop
414: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
418: a1 10 19 00 00 mov 0x1910,%eax
cups[i].clean = 1;
41d: c7 04 98 01 00 00 00 movl $0x1,(%eax,%ebx,4)
//printf(1,"im here %d",C);
semaphore_put(CBB, (void*)(&(cups[i])));
424: a1 20 19 00 00 mov 0x1920,%eax
binsem_on_cups_array = binary_sem_create();
binsem_printing = binary_sem_create();
binary_sem_down(binsem_wake_busboy);
cups = malloc(sizeof(Cup) * C);
for(i=0;i<C;i++) {
429: 8d 14 9d 00 00 00 00 lea 0x0(,%ebx,4),%edx
cups[i].clean = 1;
//printf(1,"im here %d",C);
semaphore_put(CBB, (void*)(&(cups[i])));
430: 03 15 10 19 00 00 add 0x1910,%edx
binsem_on_cups_array = binary_sem_create();
binsem_printing = binary_sem_create();
binary_sem_down(binsem_wake_busboy);
cups = malloc(sizeof(Cup) * C);
for(i=0;i<C;i++) {
436: 83 c3 01 add $0x1,%ebx
cups[i].clean = 1;
//printf(1,"im here %d",C);
semaphore_put(CBB, (void*)(&(cups[i])));
439: 89 54 24 04 mov %edx,0x4(%esp)
43d: 89 04 24 mov %eax,(%esp)
440: e8 4b 11 00 00 call 1590 <semaphore_put>
binsem_on_cups_array = binary_sem_create();
binsem_printing = binary_sem_create();
binary_sem_down(binsem_wake_busboy);
cups = malloc(sizeof(Cup) * C);
for(i=0;i<C;i++) {
445: 39 1d 14 19 00 00 cmp %ebx,0x1914
44b: 7f cb jg 418 <main+0xd8>
cups[i].clean = 1;
//printf(1,"im here %d",C);
semaphore_put(CBB, (void*)(&(cups[i])));
}
int tid[B+H+2];
44d: a1 0c 19 00 00 mov 0x190c,%eax
452: 03 05 18 19 00 00 add 0x1918,%eax
458: 8d 14 85 26 00 00 00 lea 0x26(,%eax,4),%edx
45f: 83 e2 f0 and $0xfffffff0,%edx
462: 29 d4 sub %edx,%esp
464: 8d 74 24 1b lea 0x1b(%esp),%esi
468: 83 e6 f0 and $0xfffffff0,%esi
for(i=0;i<(B+H+2);i++) {
46b: 83 f8 ff cmp $0xffffffff,%eax
46e: 0f 8c f4 00 00 00 jl 568 <main+0x228>
474: 31 db xor %ebx,%ebx
476: eb 44 jmp 4bc <main+0x17c>
}
else {
if(i<B) {
tid[i] = thread_create(bartender, ustack, STK_SIZE);
}
else if((i>=B) && (i<(B+H))) {
478: 03 15 18 19 00 00 add 0x1918,%edx
47e: 39 da cmp %ebx,%edx
480: 0f 8f 92 00 00 00 jg 518 <main+0x1d8>
tid[i] = thread_create(hostess, ustack, STK_SIZE);
}
else if(i==(B+H)){
486: 74 70 je 4f8 <main+0x1b8>
tid[i] = thread_create(busboy, ustack, STK_SIZE);
}
else {
tid[i] = thread_create(printout, ustack, STK_SIZE);
488: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp)
48f: 00
490: 89 44 24 04 mov %eax,0x4(%esp)
494: c7 04 24 d0 05 00 00 movl $0x5d0,(%esp)
49b: e8 f8 08 00 00 call d98 <thread_create>
4a0: 89 04 9e mov %eax,(%esi,%ebx,4)
//printf(1,"im here %d",C);
semaphore_put(CBB, (void*)(&(cups[i])));
}
int tid[B+H+2];
for(i=0;i<(B+H+2);i++) {
4a3: a1 18 19 00 00 mov 0x1918,%eax
4a8: 83 c3 01 add $0x1,%ebx
4ab: 03 05 0c 19 00 00 add 0x190c,%eax
4b1: 8d 50 01 lea 0x1(%eax),%edx
4b4: 39 da cmp %ebx,%edx
4b6: 0f 8c 7c 00 00 00 jl 538 <main+0x1f8>
if((ustack = malloc(STK_SIZE)) <= 0) {
4bc: c7 04 24 00 10 00 00 movl $0x1000,(%esp)
4c3: e8 68 0c 00 00 call 1130 <malloc>
4c8: 85 c0 test %eax,%eax
4ca: 0f 84 c0 00 00 00 je 590 <main+0x250>
printf(2,"cant malloc the stack for the thread\n");
exit();
}
else {
if(i<B) {
4d0: 8b 15 0c 19 00 00 mov 0x190c,%edx
4d6: 39 da cmp %ebx,%edx
4d8: 7e 9e jle 478 <main+0x138>
tid[i] = thread_create(bartender, ustack, STK_SIZE);
4da: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp)
4e1: 00
4e2: 89 44 24 04 mov %eax,0x4(%esp)
4e6: c7 04 24 60 09 00 00 movl $0x960,(%esp)
4ed: e8 a6 08 00 00 call d98 <thread_create>
4f2: 89 04 9e mov %eax,(%esi,%ebx,4)
4f5: eb ac jmp 4a3 <main+0x163>
4f7: 90 nop
}
else if((i>=B) && (i<(B+H))) {
tid[i] = thread_create(hostess, ustack, STK_SIZE);
}
else if(i==(B+H)){
tid[i] = thread_create(busboy, ustack, STK_SIZE);
4f8: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp)
4ff: 00
500: 89 44 24 04 mov %eax,0x4(%esp)
504: c7 04 24 90 07 00 00 movl $0x790,(%esp)
50b: e8 88 08 00 00 call d98 <thread_create>
510: 89 04 9e mov %eax,(%esi,%ebx,4)
513: eb 8e jmp 4a3 <main+0x163>
515: 8d 76 00 lea 0x0(%esi),%esi
else {
if(i<B) {
tid[i] = thread_create(bartender, ustack, STK_SIZE);
}
else if((i>=B) && (i<(B+H))) {
tid[i] = thread_create(hostess, ustack, STK_SIZE);
518: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp)
51f: 00
520: 89 44 24 04 mov %eax,0x4(%esp)
524: c7 04 24 30 08 00 00 movl $0x830,(%esp)
52b: e8 68 08 00 00 call d98 <thread_create>
530: 89 04 9e mov %eax,(%esi,%ebx,4)
}
else {
if(i<B) {
tid[i] = thread_create(bartender, ustack, STK_SIZE);
}
else if((i>=B) && (i<(B+H))) {
533: e9 6b ff ff ff jmp 4a3 <main+0x163>
else {
tid[i] = thread_create(printout, ustack, STK_SIZE);
}
}
}
for(i=0;i<(B+H+2);i++) {
538: 83 f8 ff cmp $0xffffffff,%eax
53b: 7c 2b jl 568 <main+0x228>
53d: 31 db xor %ebx,%ebx
53f: 90 nop
thread_join(tid[i],0);
540: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
547: 00
548: 8b 04 9e mov (%esi,%ebx,4),%eax
else {
tid[i] = thread_create(printout, ustack, STK_SIZE);
}
}
}
for(i=0;i<(B+H+2);i++) {
54b: 83 c3 01 add $0x1,%ebx
thread_join(tid[i],0);
54e: 89 04 24 mov %eax,(%esp)
551: e8 62 08 00 00 call db8 <thread_join>
else {
tid[i] = thread_create(printout, ustack, STK_SIZE);
}
}
}
for(i=0;i<(B+H+2);i++) {
556: a1 0c 19 00 00 mov 0x190c,%eax
55b: 03 05 18 19 00 00 add 0x1918,%eax
561: 83 c0 01 add $0x1,%eax
564: 39 d8 cmp %ebx,%eax
566: 7d d8 jge 540 <main+0x200>
thread_join(tid[i],0);
}
close(filedes);
568: a1 e4 18 00 00 mov 0x18e4,%eax
56d: 89 04 24 mov %eax,(%esp)
570: e8 ab 07 00 00 call d20 <close>
printf(1,"\n");
575: c7 44 24 04 06 17 00 movl $0x1706,0x4(%esp)
57c: 00
57d: c7 04 24 01 00 00 00 movl $0x1,(%esp)
584: e8 07 09 00 00 call e90 <printf>
exit();
589: e8 6a 07 00 00 call cf8 <exit>
58e: 66 90 xchg %ax,%ax
}
int tid[B+H+2];
for(i=0;i<(B+H+2);i++) {
if((ustack = malloc(STK_SIZE)) <= 0) {
printf(2,"cant malloc the stack for the thread\n");
590: c7 44 24 04 20 17 00 movl $0x1720,0x4(%esp)
597: 00
598: c7 04 24 02 00 00 00 movl $0x2,(%esp)
59f: e8 ec 08 00 00 call e90 <printf>
exit();
5a4: e8 4f 07 00 00 call cf8 <exit>
5a9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
void* ustack;
readFromFile();
//printf(1,"%d %d %d %d %d\n",B,H,R,C,totalRequests);
filedes = open("ass2_log.txt",(O_WRONLY | O_CREATE));
if(filedes < 0) {
printf(2,"problem opening file\n");
5b0: c7 44 24 04 f2 16 00 movl $0x16f2,0x4(%esp)
5b7: 00
5b8: c7 04 24 02 00 00 00 movl $0x2,(%esp)
5bf: e8 cc 08 00 00 call e90 <printf>
exit();
5c4: e8 2f 07 00 00 call cf8 <exit>
5c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
000005d0 <printout>:
binary_sem_up(binsem_printing);
}
}
void*
printout() {
5d0: 55 push %ebp
5d1: 89 e5 mov %esp,%ebp
5d3: 83 ec 18 sub $0x18,%esp
printf(1,"Processing");
5d6: c7 44 24 04 08 17 00 movl $0x1708,0x4(%esp)
5dd: 00
5de: c7 04 24 01 00 00 00 movl $0x1,(%esp)
5e5: e8 a6 08 00 00 call e90 <printf>
5ea: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
while(1) {
printf(1,".");
5f0: c7 44 24 04 13 17 00 movl $0x1713,0x4(%esp)
5f7: 00
5f8: c7 04 24 01 00 00 00 movl $0x1,(%esp)
5ff: e8 8c 08 00 00 call e90 <printf>
sleep(50);
604: c7 04 24 32 00 00 00 movl $0x32,(%esp)
60b: e8 78 07 00 00 call d88 <sleep>
610: eb de jmp 5f0 <printout+0x20>
612: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
619: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000620 <washCups>:
Cup* getCleanCup() {
return (Cup*)semaphore_pop(CBB);
}
int washCups() {
620: 55 push %ebp
621: 89 e5 mov %esp,%ebp
623: 57 push %edi
624: 56 push %esi
625: 53 push %ebx
626: 83 ec 3c sub $0x3c,%esp
int i;
int counter = 0;
for(i=0;(i<C && counter<((int)(C*0.85)));i++) {
629: a1 14 19 00 00 mov 0x1914,%eax
62e: 85 c0 test %eax,%eax
630: 0f 8e fa 00 00 00 jle 730 <washCups+0x110>
636: d9 7d e2 fnstcw -0x1e(%ebp)
639: 31 ff xor %edi,%edi
63b: 31 db xor %ebx,%ebx
63d: 89 45 e4 mov %eax,-0x1c(%ebp)
640: db 45 e4 fildl -0x1c(%ebp)
643: dd 05 08 18 00 00 fldl 0x1808
649: 0f b7 55 e2 movzwl -0x1e(%ebp),%edx
64d: dc c9 fmul %st,%st(1)
64f: d9 c9 fxch %st(1)
651: b6 0c mov $0xc,%dh
653: 66 89 55 e0 mov %dx,-0x20(%ebp)
657: d9 6d e0 fldcw -0x20(%ebp)
65a: db 5d e4 fistpl -0x1c(%ebp)
65d: d9 6d e2 fldcw -0x1e(%ebp)
660: 8b 55 e4 mov -0x1c(%ebp),%edx
663: 85 d2 test %edx,%edx
665: 7f 25 jg 68c <washCups+0x6c>
667: dd d8 fstp %st(0)
669: e9 b4 00 00 00 jmp 722 <washCups+0x102>
66e: 66 90 xchg %ax,%ax
670: 89 45 e4 mov %eax,-0x1c(%ebp)
673: db 45 e4 fildl -0x1c(%ebp)
676: d8 c9 fmul %st(1),%st
678: d9 6d e0 fldcw -0x20(%ebp)
67b: db 5d e4 fistpl -0x1c(%ebp)
67e: d9 6d e2 fldcw -0x1e(%ebp)
681: 8b 55 e4 mov -0x1c(%ebp),%edx
684: 39 d7 cmp %edx,%edi
686: 0f 8d 94 00 00 00 jge 720 <washCups+0x100>
if(cups[i].clean != 1) {
68c: 8b 15 10 19 00 00 mov 0x1910,%edx
}
int washCups() {
int i;
int counter = 0;
for(i=0;(i<C && counter<((int)(C*0.85)));i++) {
692: 8d 34 9d 00 00 00 00 lea 0x0(,%ebx,4),%esi
if(cups[i].clean != 1) {
699: 01 f2 add %esi,%edx
69b: 83 3a 01 cmpl $0x1,(%edx)
69e: 74 59 je 6f9 <washCups+0xd9>
cups[i].clean = 1;
6a0: c7 02 01 00 00 00 movl $0x1,(%edx)
binary_sem_down(binsem_counter_dirty_cups);
6a6: a1 e8 18 00 00 mov 0x18e8,%eax
6ab: dd 5d c8 fstpl -0x38(%ebp)
dirtyCups--;
binary_sem_up(binsem_counter_dirty_cups);
counter++;
6ae: 83 c7 01 add $0x1,%edi
int i;
int counter = 0;
for(i=0;(i<C && counter<((int)(C*0.85)));i++) {
if(cups[i].clean != 1) {
cups[i].clean = 1;
binary_sem_down(binsem_counter_dirty_cups);
6b1: 89 04 24 mov %eax,(%esp)
6b4: e8 0f 07 00 00 call dc8 <binary_sem_down>
dirtyCups--;
binary_sem_up(binsem_counter_dirty_cups);
6b9: a1 e8 18 00 00 mov 0x18e8,%eax
int counter = 0;
for(i=0;(i<C && counter<((int)(C*0.85)));i++) {
if(cups[i].clean != 1) {
cups[i].clean = 1;
binary_sem_down(binsem_counter_dirty_cups);
dirtyCups--;
6be: 83 2d f8 18 00 00 01 subl $0x1,0x18f8
binary_sem_up(binsem_counter_dirty_cups);
6c5: 89 04 24 mov %eax,(%esp)
6c8: e8 03 07 00 00 call dd0 <binary_sem_up>
counter++;
semaphore_put(CBB,(void*)(&cups[i]));
6cd: a1 20 19 00 00 mov 0x1920,%eax
6d2: 03 35 10 19 00 00 add 0x1910,%esi
6d8: 89 04 24 mov %eax,(%esp)
6db: 89 74 24 04 mov %esi,0x4(%esp)
6df: e8 ac 0e 00 00 call 1590 <semaphore_put>
6e4: a1 14 19 00 00 mov 0x1914,%eax
6e9: d9 7d e2 fnstcw -0x1e(%ebp)
6ec: dd 45 c8 fldl -0x38(%ebp)
6ef: 0f b7 55 e2 movzwl -0x1e(%ebp),%edx
6f3: b6 0c mov $0xc,%dh
6f5: 66 89 55 e0 mov %dx,-0x20(%ebp)
}
int washCups() {
int i;
int counter = 0;
for(i=0;(i<C && counter<((int)(C*0.85)));i++) {
6f9: 83 c3 01 add $0x1,%ebx
6fc: 39 d8 cmp %ebx,%eax
6fe: 0f 8f 6c ff ff ff jg 670 <washCups+0x50>
704: dd d8 fstp %st(0)
706: 89 45 e4 mov %eax,-0x1c(%ebp)
709: db 45 e4 fildl -0x1c(%ebp)
70c: dc 0d 08 18 00 00 fmull 0x1808
712: d9 6d e0 fldcw -0x20(%ebp)
715: db 5d e4 fistpl -0x1c(%ebp)
718: d9 6d e2 fldcw -0x1e(%ebp)
71b: 8b 55 e4 mov -0x1c(%ebp),%edx
71e: eb 02 jmp 722 <washCups+0x102>
720: dd d8 fstp %st(0)
binary_sem_up(binsem_counter_dirty_cups);
counter++;
semaphore_put(CBB,(void*)(&cups[i]));
}
}
if(counter != ((int)(C*0.85))) {
722: 31 c0 xor %eax,%eax
724: 39 d7 cmp %edx,%edi
726: 75 31 jne 759 <washCups+0x139>
printf(2,"less or more than 85% cups!! percentage is: %d",((int)(counter*0.85)));
return -1;
}
return 0;
}
728: 83 c4 3c add $0x3c,%esp
72b: 5b pop %ebx
72c: 5e pop %esi
72d: 5f pop %edi
72e: 5d pop %ebp
72f: c3 ret
}
int washCups() {
int i;
int counter = 0;
for(i=0;(i<C && counter<((int)(C*0.85)));i++) {
730: d9 7d e2 fnstcw -0x1e(%ebp)
733: 31 ff xor %edi,%edi
735: 89 45 e4 mov %eax,-0x1c(%ebp)
738: db 45 e4 fildl -0x1c(%ebp)
73b: dc 0d 08 18 00 00 fmull 0x1808
741: 0f b7 45 e2 movzwl -0x1e(%ebp),%eax
745: b4 0c mov $0xc,%ah
747: 66 89 45 e0 mov %ax,-0x20(%ebp)
74b: d9 6d e0 fldcw -0x20(%ebp)
74e: db 5d e4 fistpl -0x1c(%ebp)
751: d9 6d e2 fldcw -0x1e(%ebp)
754: 8b 55 e4 mov -0x1c(%ebp),%edx
757: eb c9 jmp 722 <washCups+0x102>
counter++;
semaphore_put(CBB,(void*)(&cups[i]));
}
}
if(counter != ((int)(C*0.85))) {
printf(2,"less or more than 85% cups!! percentage is: %d",((int)(counter*0.85)));
759: 89 7d e4 mov %edi,-0x1c(%ebp)
75c: db 45 e4 fildl -0x1c(%ebp)
75f: dc 0d 08 18 00 00 fmull 0x1808
765: c7 44 24 04 48 17 00 movl $0x1748,0x4(%esp)
76c: 00
76d: c7 04 24 02 00 00 00 movl $0x2,(%esp)
774: d9 6d e0 fldcw -0x20(%ebp)
777: db 5c 24 08 fistpl 0x8(%esp)
77b: d9 6d e2 fldcw -0x1e(%ebp)
77e: e8 0d 07 00 00 call e90 <printf>
783: b8 ff ff ff ff mov $0xffffffff,%eax
return -1;
788: eb 9e jmp 728 <washCups+0x108>
78a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
00000790 <busboy>:
thread_exit(0);
return 0;
}
void*
busboy() {
790: 55 push %ebp
791: 89 e5 mov %esp,%ebp
793: 53 push %ebx
794: 83 ec 24 sub $0x24,%esp
797: eb 68 jmp 801 <busboy+0x71>
799: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
binary_sem_down(binsem_wake_busboy);
if(washCups() < 0) {
printf(2,"problem with the washing of cups");
exit();
}
binary_sem_down(binsem_printing);
7a0: a1 08 19 00 00 mov 0x1908,%eax
7a5: 89 04 24 mov %eax,(%esp)
7a8: e8 1b 06 00 00 call dc8 <binary_sem_down>
printf(filedes,"Busboy %d added %d clean cups.\n",thread_getid(),(int)(C*0.85));
7ad: d9 7d f6 fnstcw -0xa(%ebp)
7b0: db 05 14 19 00 00 fildl 0x1914
7b6: dc 0d 08 18 00 00 fmull 0x1808
7bc: 0f b7 45 f6 movzwl -0xa(%ebp),%eax
7c0: b4 0c mov $0xc,%ah
7c2: 66 89 45 f4 mov %ax,-0xc(%ebp)
7c6: d9 6d f4 fldcw -0xc(%ebp)
7c9: db 5d f0 fistpl -0x10(%ebp)
7cc: d9 6d f6 fldcw -0xa(%ebp)
7cf: 8b 5d f0 mov -0x10(%ebp),%ebx
7d2: e8 c9 05 00 00 call da0 <thread_getid>
7d7: c7 44 24 04 9c 17 00 movl $0x179c,0x4(%esp)
7de: 00
7df: 89 5c 24 0c mov %ebx,0xc(%esp)
7e3: 89 44 24 08 mov %eax,0x8(%esp)
7e7: a1 e4 18 00 00 mov 0x18e4,%eax
7ec: 89 04 24 mov %eax,(%esp)
7ef: e8 9c 06 00 00 call e90 <printf>
binary_sem_up(binsem_printing);
7f4: a1 08 19 00 00 mov 0x1908,%eax
7f9: 89 04 24 mov %eax,(%esp)
7fc: e8 cf 05 00 00 call dd0 <binary_sem_up>
}
void*
busboy() {
while(1) {
binary_sem_down(binsem_wake_busboy);
801: a1 fc 18 00 00 mov 0x18fc,%eax
806: 89 04 24 mov %eax,(%esp)
809: e8 ba 05 00 00 call dc8 <binary_sem_down>
if(washCups() < 0) {
80e: e8 0d fe ff ff call 620 <washCups>
813: 85 c0 test %eax,%eax
815: 79 89 jns 7a0 <busboy+0x10>
printf(2,"problem with the washing of cups");
817: c7 44 24 04 78 17 00 movl $0x1778,0x4(%esp)
81e: 00
81f: c7 04 24 02 00 00 00 movl $0x2,(%esp)
826: e8 65 06 00 00 call e90 <printf>
exit();
82b: e8 c8 04 00 00 call cf8 <exit>
00000830 <hostess>:
sleep(10);
}
}
void*
hostess() {
830: 55 push %ebp
831: 89 e5 mov %esp,%ebp
833: 56 push %esi
834: 53 push %ebx
835: 83 ec 10 sub $0x10,%esp
while(requests < totalRequests) {
838: a1 04 19 00 00 mov 0x1904,%eax
83d: 3b 05 f0 18 00 00 cmp 0x18f0,%eax
843: 7c 35 jl 87a <hostess+0x4a>
845: e9 b6 00 00 00 jmp 900 <hostess+0xd0>
84a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
binary_sem_down(binsem_printing);
printf(filedes,"Hostess %d added a new request #%d\n",thread_getid(),req->id);
binary_sem_up(binsem_printing);
addNewRequest(req);
}
binary_sem_up(binsem_counter_requests);
850: a1 ec 18 00 00 mov 0x18ec,%eax
855: 89 04 24 mov %eax,(%esp)
858: e8 73 05 00 00 call dd0 <binary_sem_up>
sleep(10);
85d: c7 04 24 0a 00 00 00 movl $0xa,(%esp)
864: e8 1f 05 00 00 call d88 <sleep>
}
}
void*
hostess() {
while(requests < totalRequests) {
869: a1 04 19 00 00 mov 0x1904,%eax
86e: 3b 05 f0 18 00 00 cmp 0x18f0,%eax
874: 0f 8d 86 00 00 00 jge 900 <hostess+0xd0>
binary_sem_down(binsem_counter_requests);
87a: a1 ec 18 00 00 mov 0x18ec,%eax
87f: 89 04 24 mov %eax,(%esp)
882: e8 41 05 00 00 call dc8 <binary_sem_down>
if(requests < totalRequests) {
887: a1 04 19 00 00 mov 0x1904,%eax
88c: 3b 05 f0 18 00 00 cmp 0x18f0,%eax
892: 7d bc jge 850 <hostess+0x20>
Request* req = malloc(sizeof(Request));
894: c7 04 24 04 00 00 00 movl $0x4,(%esp)
89b: e8 90 08 00 00 call 1130 <malloc>
8a0: 89 c3 mov %eax,%ebx
requests++;
8a2: a1 04 19 00 00 mov 0x1904,%eax
8a7: 83 c0 01 add $0x1,%eax
8aa: a3 04 19 00 00 mov %eax,0x1904
req->id = requests;
8af: 89 03 mov %eax,(%ebx)
binary_sem_down(binsem_printing);
8b1: a1 08 19 00 00 mov 0x1908,%eax
8b6: 89 04 24 mov %eax,(%esp)
8b9: e8 0a 05 00 00 call dc8 <binary_sem_down>
printf(filedes,"Hostess %d added a new request #%d\n",thread_getid(),req->id);
8be: 8b 33 mov (%ebx),%esi
8c0: e8 db 04 00 00 call da0 <thread_getid>
8c5: c7 44 24 04 bc 17 00 movl $0x17bc,0x4(%esp)
8cc: 00
8cd: 89 74 24 0c mov %esi,0xc(%esp)
8d1: 89 44 24 08 mov %eax,0x8(%esp)
8d5: a1 e4 18 00 00 mov 0x18e4,%eax
8da: 89 04 24 mov %eax,(%esp)
8dd: e8 ae 05 00 00 call e90 <printf>
binary_sem_up(binsem_printing);
8e2: a1 08 19 00 00 mov 0x1908,%eax
8e7: 89 04 24 mov %eax,(%esp)
8ea: e8 e1 04 00 00 call dd0 <binary_sem_up>
addNewRequest(req);
8ef: 89 1c 24 mov %ebx,(%esp)
8f2: e8 29 f7 ff ff call 20 <addNewRequest>
8f7: e9 54 ff ff ff jmp 850 <hostess+0x20>
8fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
}
binary_sem_up(binsem_counter_requests);
sleep(10);
}
//printf(1,"exit hostess\n");
thread_exit(0);
900: c7 04 24 00 00 00 00 movl $0x0,(%esp)
907: e8 a4 04 00 00 call db0 <thread_exit>
return 0;
}
90c: 83 c4 10 add $0x10,%esp
90f: 31 c0 xor %eax,%eax
911: 5b pop %ebx
912: 5e pop %esi
913: 5d pop %ebp
914: c3 ret
915: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
919: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000920 <getRequest>:
void addNewRequest( Request* newReq) {
semaphore_put(RBB,(void*)newReq);
}
Request* getRequest() {
920: 55 push %ebp
921: 89 e5 mov %esp,%ebp
923: 83 ec 18 sub $0x18,%esp
return (Request*)semaphore_pop(RBB);
926: a1 f4 18 00 00 mov 0x18f4,%eax
92b: 89 04 24 mov %eax,(%esp)
92e: e8 4d 0b 00 00 call 1480 <semaphore_pop>
}
933: c9 leave
934: c3 ret
935: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
939: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000940 <getCleanCup>:
int binsem_wake_busboy; //lock on the waking and sleeping of the busboy to clean the cups
int binsem_on_cups_array; //lock on the array of cups
int filedes; //file descriptor of the log file
int binsem_printing; //synchronizing the print
Cup* getCleanCup() {
940: 55 push %ebp
941: 89 e5 mov %esp,%ebp
943: 83 ec 18 sub $0x18,%esp
return (Cup*)semaphore_pop(CBB);
946: a1 20 19 00 00 mov 0x1920,%eax
94b: 89 04 24 mov %eax,(%esp)
94e: e8 2d 0b 00 00 call 1480 <semaphore_pop>
}
953: c9 leave
954: c3 ret
955: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
959: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000960 <bartender>:
Request* getRequest() {
return (Request*)semaphore_pop(RBB);
}
void*
bartender() {
960: 55 push %ebp
961: 89 e5 mov %esp,%ebp
963: 56 push %esi
964: 53 push %ebx
965: 83 ec 20 sub $0x20,%esp
968: eb 73 jmp 9dd <bartender+0x7d>
96a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
dirtyCups++;
cup->clean = 0;
if(dirtyCups == ((int)(C*0.85))) {
binary_sem_up(binsem_wake_busboy);
}
binary_sem_up(binsem_counter_dirty_cups);
970: a1 e8 18 00 00 mov 0x18e8,%eax
975: 89 04 24 mov %eax,(%esp)
978: e8 53 04 00 00 call dd0 <binary_sem_up>
binary_sem_down(binsem_printing);
97d: a1 08 19 00 00 mov 0x1908,%eax
982: 89 04 24 mov %eax,(%esp)
985: e8 3e 04 00 00 call dc8 <binary_sem_down>
printf(filedes,"Bartender %d completed request #%d\n",thread_getid(),req->id);
98a: 8b 33 mov (%ebx),%esi
98c: e8 0f 04 00 00 call da0 <thread_getid>
991: c7 44 24 04 e0 17 00 movl $0x17e0,0x4(%esp)
998: 00
999: 89 74 24 0c mov %esi,0xc(%esp)
99d: 89 44 24 08 mov %eax,0x8(%esp)
9a1: a1 e4 18 00 00 mov 0x18e4,%eax
9a6: 89 04 24 mov %eax,(%esp)
9a9: e8 e2 04 00 00 call e90 <printf>
binary_sem_up(binsem_printing);
9ae: a1 08 19 00 00 mov 0x1908,%eax
9b3: 89 04 24 mov %eax,(%esp)
9b6: e8 15 04 00 00 call dd0 <binary_sem_up>
if(req->id == totalRequests) {
9bb: 8b 03 mov (%ebx),%eax
9bd: 3b 05 f0 18 00 00 cmp 0x18f0,%eax
9c3: 0f 84 7f 00 00 00 je a48 <bartender+0xe8>
binary_sem_clear(binsem_on_cups_array);
binary_sem_clear(binsem_printing);
//
exit_all_threads();//need to leave the main process on so he can do thread_join
}
free(req);
9c9: 89 1c 24 mov %ebx,(%esp)
9cc: e8 cf 06 00 00 call 10a0 <free>
sleep(10);
9d1: c7 04 24 0a 00 00 00 movl $0xa,(%esp)
9d8: e8 ab 03 00 00 call d88 <sleep>
}
void*
bartender() {
while(1) {
Request* req = getRequest();
9dd: e8 3e ff ff ff call 920 <getRequest>
9e2: 89 c3 mov %eax,%ebx
binary_sem_down(binsem_counter_dirty_cups);
9e4: a1 e8 18 00 00 mov 0x18e8,%eax
9e9: 89 04 24 mov %eax,(%esp)
9ec: e8 d7 03 00 00 call dc8 <binary_sem_down>
Cup* cup = getCleanCup();
9f1: e8 4a ff ff ff call 940 <getCleanCup>
dirtyCups++;
9f6: 83 05 f8 18 00 00 01 addl $0x1,0x18f8
cup->clean = 0;
9fd: c7 00 00 00 00 00 movl $0x0,(%eax)
if(dirtyCups == ((int)(C*0.85))) {
a03: d9 7d f6 fnstcw -0xa(%ebp)
a06: db 05 14 19 00 00 fildl 0x1914
a0c: dc 0d 08 18 00 00 fmull 0x1808
a12: 0f b7 45 f6 movzwl -0xa(%ebp),%eax
a16: b4 0c mov $0xc,%ah
a18: 66 89 45 f4 mov %ax,-0xc(%ebp)
a1c: d9 6d f4 fldcw -0xc(%ebp)
a1f: db 5d f0 fistpl -0x10(%ebp)
a22: d9 6d f6 fldcw -0xa(%ebp)
a25: 8b 45 f0 mov -0x10(%ebp),%eax
a28: 3b 05 f8 18 00 00 cmp 0x18f8,%eax
a2e: 0f 85 3c ff ff ff jne 970 <bartender+0x10>
binary_sem_up(binsem_wake_busboy);
a34: a1 fc 18 00 00 mov 0x18fc,%eax
a39: 89 04 24 mov %eax,(%esp)
a3c: e8 8f 03 00 00 call dd0 <binary_sem_up>
a41: e9 2a ff ff ff jmp 970 <bartender+0x10>
a46: 66 90 xchg %ax,%ax
binary_sem_down(binsem_printing);
printf(filedes,"Bartender %d completed request #%d\n",thread_getid(),req->id);
binary_sem_up(binsem_printing);
if(req->id == totalRequests) {
//clean all of it!
free(req);
a48: 89 1c 24 mov %ebx,(%esp)
a4b: e8 50 06 00 00 call 10a0 <free>
free(cups);
a50: a1 10 19 00 00 mov 0x1910,%eax
a55: 89 04 24 mov %eax,(%esp)
a58: e8 43 06 00 00 call 10a0 <free>
semaphore_clear(RBB);
a5d: a1 f4 18 00 00 mov 0x18f4,%eax
a62: 89 04 24 mov %eax,(%esp)
a65: e8 a6 09 00 00 call 1410 <semaphore_clear>
semaphore_clear(CBB);
a6a: a1 20 19 00 00 mov 0x1920,%eax
a6f: 89 04 24 mov %eax,(%esp)
a72: e8 99 09 00 00 call 1410 <semaphore_clear>
binary_sem_clear(binsem_counter_dirty_cups);
a77: a1 e8 18 00 00 mov 0x18e8,%eax
a7c: 89 04 24 mov %eax,(%esp)
a7f: e8 54 03 00 00 call dd8 <binary_sem_clear>
binary_sem_clear(binsem_counter_requests);
a84: a1 ec 18 00 00 mov 0x18ec,%eax
a89: 89 04 24 mov %eax,(%esp)
a8c: e8 47 03 00 00 call dd8 <binary_sem_clear>
binary_sem_clear(binsem_wake_busboy);
a91: a1 fc 18 00 00 mov 0x18fc,%eax
a96: 89 04 24 mov %eax,(%esp)
a99: e8 3a 03 00 00 call dd8 <binary_sem_clear>
binary_sem_clear(binsem_on_cups_array);
a9e: a1 00 19 00 00 mov 0x1900,%eax
aa3: 89 04 24 mov %eax,(%esp)
aa6: e8 2d 03 00 00 call dd8 <binary_sem_clear>
binary_sem_clear(binsem_printing);
aab: a1 08 19 00 00 mov 0x1908,%eax
ab0: 89 04 24 mov %eax,(%esp)
ab3: e8 20 03 00 00 call dd8 <binary_sem_clear>
//
exit_all_threads();//need to leave the main process on so he can do thread_join
ab8: e8 23 03 00 00 call de0 <exit_all_threads>
abd: e9 07 ff ff ff jmp 9c9 <bartender+0x69>
ac2: 90 nop
ac3: 90 nop
ac4: 90 nop
ac5: 90 nop
ac6: 90 nop
ac7: 90 nop
ac8: 90 nop
ac9: 90 nop
aca: 90 nop
acb: 90 nop
acc: 90 nop
acd: 90 nop
ace: 90 nop
acf: 90 nop
00000ad0 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, char *t)
{
ad0: 55 push %ebp
ad1: 31 d2 xor %edx,%edx
ad3: 89 e5 mov %esp,%ebp
ad5: 8b 45 08 mov 0x8(%ebp),%eax
ad8: 53 push %ebx
ad9: 8b 5d 0c mov 0xc(%ebp),%ebx
adc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
char *os;
os = s;
while((*s++ = *t++) != 0)
ae0: 0f b6 0c 13 movzbl (%ebx,%edx,1),%ecx
ae4: 88 0c 10 mov %cl,(%eax,%edx,1)
ae7: 83 c2 01 add $0x1,%edx
aea: 84 c9 test %cl,%cl
aec: 75 f2 jne ae0 <strcpy+0x10>
;
return os;
}
aee: 5b pop %ebx
aef: 5d pop %ebp
af0: c3 ret
af1: eb 0d jmp b00 <strcmp>
af3: 90 nop
af4: 90 nop
af5: 90 nop
af6: 90 nop
af7: 90 nop
af8: 90 nop
af9: 90 nop
afa: 90 nop
afb: 90 nop
afc: 90 nop
afd: 90 nop
afe: 90 nop
aff: 90 nop
00000b00 <strcmp>:
int
strcmp(const char *p, const char *q)
{
b00: 55 push %ebp
b01: 89 e5 mov %esp,%ebp
b03: 53 push %ebx
b04: 8b 4d 08 mov 0x8(%ebp),%ecx
b07: 8b 55 0c mov 0xc(%ebp),%edx
while(*p && *p == *q)
b0a: 0f b6 01 movzbl (%ecx),%eax
b0d: 84 c0 test %al,%al
b0f: 75 14 jne b25 <strcmp+0x25>
b11: eb 25 jmp b38 <strcmp+0x38>
b13: 90 nop
b14: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
p++, q++;
b18: 83 c1 01 add $0x1,%ecx
b1b: 83 c2 01 add $0x1,%edx
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
b1e: 0f b6 01 movzbl (%ecx),%eax
b21: 84 c0 test %al,%al
b23: 74 13 je b38 <strcmp+0x38>
b25: 0f b6 1a movzbl (%edx),%ebx
b28: 38 d8 cmp %bl,%al
b2a: 74 ec je b18 <strcmp+0x18>
b2c: 0f b6 db movzbl %bl,%ebx
b2f: 0f b6 c0 movzbl %al,%eax
b32: 29 d8 sub %ebx,%eax
p++, q++;
return (uchar)*p - (uchar)*q;
}
b34: 5b pop %ebx
b35: 5d pop %ebp
b36: c3 ret
b37: 90 nop
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
b38: 0f b6 1a movzbl (%edx),%ebx
b3b: 31 c0 xor %eax,%eax
b3d: 0f b6 db movzbl %bl,%ebx
b40: 29 d8 sub %ebx,%eax
p++, q++;
return (uchar)*p - (uchar)*q;
}
b42: 5b pop %ebx
b43: 5d pop %ebp
b44: c3 ret
b45: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
b49: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000b50 <strlen>:
uint
strlen(char *s)
{
b50: 55 push %ebp
int n;
for(n = 0; s[n]; n++)
b51: 31 d2 xor %edx,%edx
return (uchar)*p - (uchar)*q;
}
uint
strlen(char *s)
{
b53: 89 e5 mov %esp,%ebp
int n;
for(n = 0; s[n]; n++)
b55: 31 c0 xor %eax,%eax
return (uchar)*p - (uchar)*q;
}
uint
strlen(char *s)
{
b57: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
for(n = 0; s[n]; n++)
b5a: 80 39 00 cmpb $0x0,(%ecx)
b5d: 74 0c je b6b <strlen+0x1b>
b5f: 90 nop
b60: 83 c2 01 add $0x1,%edx
b63: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1)
b67: 89 d0 mov %edx,%eax
b69: 75 f5 jne b60 <strlen+0x10>
;
return n;
}
b6b: 5d pop %ebp
b6c: c3 ret
b6d: 8d 76 00 lea 0x0(%esi),%esi
00000b70 <memset>:
void*
memset(void *dst, int c, uint n)
{
b70: 55 push %ebp
b71: 89 e5 mov %esp,%ebp
b73: 8b 55 08 mov 0x8(%ebp),%edx
b76: 57 push %edi
}
static inline void
stosb(void *addr, int data, int cnt)
{
asm volatile("cld; rep stosb" :
b77: 8b 4d 10 mov 0x10(%ebp),%ecx
b7a: 8b 45 0c mov 0xc(%ebp),%eax
b7d: 89 d7 mov %edx,%edi
b7f: fc cld
b80: f3 aa rep stos %al,%es:(%edi)
stosb(dst, c, n);
return dst;
}
b82: 89 d0 mov %edx,%eax
b84: 5f pop %edi
b85: 5d pop %ebp
b86: c3 ret
b87: 89 f6 mov %esi,%esi
b89: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000b90 <strchr>:
char*
strchr(const char *s, char c)
{
b90: 55 push %ebp
b91: 89 e5 mov %esp,%ebp
b93: 8b 45 08 mov 0x8(%ebp),%eax
b96: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx
for(; *s; s++)
b9a: 0f b6 10 movzbl (%eax),%edx
b9d: 84 d2 test %dl,%dl
b9f: 75 11 jne bb2 <strchr+0x22>
ba1: eb 15 jmp bb8 <strchr+0x28>
ba3: 90 nop
ba4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
ba8: 83 c0 01 add $0x1,%eax
bab: 0f b6 10 movzbl (%eax),%edx
bae: 84 d2 test %dl,%dl
bb0: 74 06 je bb8 <strchr+0x28>
if(*s == c)
bb2: 38 ca cmp %cl,%dl
bb4: 75 f2 jne ba8 <strchr+0x18>
return (char*) s;
return 0;
}
bb6: 5d pop %ebp
bb7: c3 ret
}
char*
strchr(const char *s, char c)
{
for(; *s; s++)
bb8: 31 c0 xor %eax,%eax
if(*s == c)
return (char*) s;
return 0;
}
bba: 5d pop %ebp
bbb: 90 nop
bbc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
bc0: c3 ret
bc1: eb 0d jmp bd0 <atoi>
bc3: 90 nop
bc4: 90 nop
bc5: 90 nop
bc6: 90 nop
bc7: 90 nop
bc8: 90 nop
bc9: 90 nop
bca: 90 nop
bcb: 90 nop
bcc: 90 nop
bcd: 90 nop
bce: 90 nop
bcf: 90 nop
00000bd0 <atoi>:
return r;
}
int
atoi(const char *s)
{
bd0: 55 push %ebp
int n;
n = 0;
while('0' <= *s && *s <= '9')
bd1: 31 c0 xor %eax,%eax
return r;
}
int
atoi(const char *s)
{
bd3: 89 e5 mov %esp,%ebp
bd5: 8b 4d 08 mov 0x8(%ebp),%ecx
bd8: 53 push %ebx
int n;
n = 0;
while('0' <= *s && *s <= '9')
bd9: 0f b6 11 movzbl (%ecx),%edx
bdc: 8d 5a d0 lea -0x30(%edx),%ebx
bdf: 80 fb 09 cmp $0x9,%bl
be2: 77 1c ja c00 <atoi+0x30>
be4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
n = n*10 + *s++ - '0';
be8: 0f be d2 movsbl %dl,%edx
beb: 83 c1 01 add $0x1,%ecx
bee: 8d 04 80 lea (%eax,%eax,4),%eax
bf1: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax
atoi(const char *s)
{
int n;
n = 0;
while('0' <= *s && *s <= '9')
bf5: 0f b6 11 movzbl (%ecx),%edx
bf8: 8d 5a d0 lea -0x30(%edx),%ebx
bfb: 80 fb 09 cmp $0x9,%bl
bfe: 76 e8 jbe be8 <atoi+0x18>
n = n*10 + *s++ - '0';
return n;
}
c00: 5b pop %ebx
c01: 5d pop %ebp
c02: c3 ret
c03: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
c09: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000c10 <memmove>:
void*
memmove(void *vdst, void *vsrc, int n)
{
c10: 55 push %ebp
c11: 89 e5 mov %esp,%ebp
c13: 56 push %esi
c14: 8b 45 08 mov 0x8(%ebp),%eax
c17: 53 push %ebx
c18: 8b 5d 10 mov 0x10(%ebp),%ebx
c1b: 8b 75 0c mov 0xc(%ebp),%esi
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
c1e: 85 db test %ebx,%ebx
c20: 7e 14 jle c36 <memmove+0x26>
n = n*10 + *s++ - '0';
return n;
}
void*
memmove(void *vdst, void *vsrc, int n)
c22: 31 d2 xor %edx,%edx
c24: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
*dst++ = *src++;
c28: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx
c2c: 88 0c 10 mov %cl,(%eax,%edx,1)
c2f: 83 c2 01 add $0x1,%edx
{
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
c32: 39 da cmp %ebx,%edx
c34: 75 f2 jne c28 <memmove+0x18>
*dst++ = *src++;
return vdst;
}
c36: 5b pop %ebx
c37: 5e pop %esi
c38: 5d pop %ebp
c39: c3 ret
c3a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
00000c40 <stat>:
return buf;
}
int
stat(char *n, struct stat *st)
{
c40: 55 push %ebp
c41: 89 e5 mov %esp,%ebp
c43: 83 ec 18 sub $0x18,%esp
int fd;
int r;
fd = open(n, O_RDONLY);
c46: 8b 45 08 mov 0x8(%ebp),%eax
return buf;
}
int
stat(char *n, struct stat *st)
{
c49: 89 5d f8 mov %ebx,-0x8(%ebp)
c4c: 89 75 fc mov %esi,-0x4(%ebp)
int fd;
int r;
fd = open(n, O_RDONLY);
if(fd < 0)
c4f: be ff ff ff ff mov $0xffffffff,%esi
stat(char *n, struct stat *st)
{
int fd;
int r;
fd = open(n, O_RDONLY);
c54: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
c5b: 00
c5c: 89 04 24 mov %eax,(%esp)
c5f: e8 d4 00 00 00 call d38 <open>
if(fd < 0)
c64: 85 c0 test %eax,%eax
stat(char *n, struct stat *st)
{
int fd;
int r;
fd = open(n, O_RDONLY);
c66: 89 c3 mov %eax,%ebx
if(fd < 0)
c68: 78 19 js c83 <stat+0x43>
return -1;
r = fstat(fd, st);
c6a: 8b 45 0c mov 0xc(%ebp),%eax
c6d: 89 1c 24 mov %ebx,(%esp)
c70: 89 44 24 04 mov %eax,0x4(%esp)
c74: e8 d7 00 00 00 call d50 <fstat>
close(fd);
c79: 89 1c 24 mov %ebx,(%esp)
int r;
fd = open(n, O_RDONLY);
if(fd < 0)
return -1;
r = fstat(fd, st);
c7c: 89 c6 mov %eax,%esi
close(fd);
c7e: e8 9d 00 00 00 call d20 <close>
return r;
}
c83: 89 f0 mov %esi,%eax
c85: 8b 5d f8 mov -0x8(%ebp),%ebx
c88: 8b 75 fc mov -0x4(%ebp),%esi
c8b: 89 ec mov %ebp,%esp
c8d: 5d pop %ebp
c8e: c3 ret
c8f: 90 nop
00000c90 <gets>:
return 0;
}
char*
gets(char *buf, int max)
{
c90: 55 push %ebp
c91: 89 e5 mov %esp,%ebp
c93: 57 push %edi
c94: 56 push %esi
c95: 31 f6 xor %esi,%esi
c97: 53 push %ebx
c98: 83 ec 2c sub $0x2c,%esp
c9b: 8b 7d 08 mov 0x8(%ebp),%edi
int i, cc;
char c;
for(i=0; i+1 < max; ){
c9e: eb 06 jmp ca6 <gets+0x16>
cc = read(0, &c, 1);
if(cc < 1)
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
ca0: 3c 0a cmp $0xa,%al
ca2: 74 39 je cdd <gets+0x4d>
ca4: 89 de mov %ebx,%esi
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
ca6: 8d 5e 01 lea 0x1(%esi),%ebx
ca9: 3b 5d 0c cmp 0xc(%ebp),%ebx
cac: 7d 31 jge cdf <gets+0x4f>
cc = read(0, &c, 1);
cae: 8d 45 e7 lea -0x19(%ebp),%eax
cb1: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
cb8: 00
cb9: 89 44 24 04 mov %eax,0x4(%esp)
cbd: c7 04 24 00 00 00 00 movl $0x0,(%esp)
cc4: e8 47 00 00 00 call d10 <read>
if(cc < 1)
cc9: 85 c0 test %eax,%eax
ccb: 7e 12 jle cdf <gets+0x4f>
break;
buf[i++] = c;
ccd: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
cd1: 88 44 1f ff mov %al,-0x1(%edi,%ebx,1)
if(c == '\n' || c == '\r')
cd5: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
cd9: 3c 0d cmp $0xd,%al
cdb: 75 c3 jne ca0 <gets+0x10>
cdd: 89 de mov %ebx,%esi
break;
}
buf[i] = '\0';
cdf: c6 04 37 00 movb $0x0,(%edi,%esi,1)
return buf;
}
ce3: 89 f8 mov %edi,%eax
ce5: 83 c4 2c add $0x2c,%esp
ce8: 5b pop %ebx
ce9: 5e pop %esi
cea: 5f pop %edi
ceb: 5d pop %ebp
cec: c3 ret
ced: 90 nop
cee: 90 nop
cef: 90 nop
00000cf0 <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
cf0: b8 01 00 00 00 mov $0x1,%eax
cf5: cd 40 int $0x40
cf7: c3 ret
00000cf8 <exit>:
SYSCALL(exit)
cf8: b8 02 00 00 00 mov $0x2,%eax
cfd: cd 40 int $0x40
cff: c3 ret
00000d00 <wait>:
SYSCALL(wait)
d00: b8 03 00 00 00 mov $0x3,%eax
d05: cd 40 int $0x40
d07: c3 ret
00000d08 <pipe>:
SYSCALL(pipe)
d08: b8 04 00 00 00 mov $0x4,%eax
d0d: cd 40 int $0x40
d0f: c3 ret
00000d10 <read>:
SYSCALL(read)
d10: b8 06 00 00 00 mov $0x6,%eax
d15: cd 40 int $0x40
d17: c3 ret
00000d18 <write>:
SYSCALL(write)
d18: b8 05 00 00 00 mov $0x5,%eax
d1d: cd 40 int $0x40
d1f: c3 ret
00000d20 <close>:
SYSCALL(close)
d20: b8 07 00 00 00 mov $0x7,%eax
d25: cd 40 int $0x40
d27: c3 ret
00000d28 <kill>:
SYSCALL(kill)
d28: b8 08 00 00 00 mov $0x8,%eax
d2d: cd 40 int $0x40
d2f: c3 ret
00000d30 <exec>:
SYSCALL(exec)
d30: b8 09 00 00 00 mov $0x9,%eax
d35: cd 40 int $0x40
d37: c3 ret
00000d38 <open>:
SYSCALL(open)
d38: b8 0a 00 00 00 mov $0xa,%eax
d3d: cd 40 int $0x40
d3f: c3 ret
00000d40 <mknod>:
SYSCALL(mknod)
d40: b8 0b 00 00 00 mov $0xb,%eax
d45: cd 40 int $0x40
d47: c3 ret
00000d48 <unlink>:
SYSCALL(unlink)
d48: b8 0c 00 00 00 mov $0xc,%eax
d4d: cd 40 int $0x40
d4f: c3 ret
00000d50 <fstat>:
SYSCALL(fstat)
d50: b8 0d 00 00 00 mov $0xd,%eax
d55: cd 40 int $0x40
d57: c3 ret
00000d58 <link>:
SYSCALL(link)
d58: b8 0e 00 00 00 mov $0xe,%eax
d5d: cd 40 int $0x40
d5f: c3 ret
00000d60 <mkdir>:
SYSCALL(mkdir)
d60: b8 0f 00 00 00 mov $0xf,%eax
d65: cd 40 int $0x40
d67: c3 ret
00000d68 <chdir>:
SYSCALL(chdir)
d68: b8 10 00 00 00 mov $0x10,%eax
d6d: cd 40 int $0x40
d6f: c3 ret
00000d70 <dup>:
SYSCALL(dup)
d70: b8 11 00 00 00 mov $0x11,%eax
d75: cd 40 int $0x40
d77: c3 ret
00000d78 <getpid>:
SYSCALL(getpid)
d78: b8 12 00 00 00 mov $0x12,%eax
d7d: cd 40 int $0x40
d7f: c3 ret
00000d80 <sbrk>:
SYSCALL(sbrk)
d80: b8 13 00 00 00 mov $0x13,%eax
d85: cd 40 int $0x40
d87: c3 ret
00000d88 <sleep>:
SYSCALL(sleep)
d88: b8 14 00 00 00 mov $0x14,%eax
d8d: cd 40 int $0x40
d8f: c3 ret
00000d90 <uptime>:
SYSCALL(uptime)
d90: b8 15 00 00 00 mov $0x15,%eax
d95: cd 40 int $0x40
d97: c3 ret
00000d98 <thread_create>:
SYSCALL(thread_create)
d98: b8 16 00 00 00 mov $0x16,%eax
d9d: cd 40 int $0x40
d9f: c3 ret
00000da0 <thread_getid>:
SYSCALL(thread_getid)
da0: b8 17 00 00 00 mov $0x17,%eax
da5: cd 40 int $0x40
da7: c3 ret
00000da8 <thread_getProcId>:
SYSCALL(thread_getProcId)
da8: b8 18 00 00 00 mov $0x18,%eax
dad: cd 40 int $0x40
daf: c3 ret
00000db0 <thread_exit>:
SYSCALL(thread_exit)
db0: b8 1a 00 00 00 mov $0x1a,%eax
db5: cd 40 int $0x40
db7: c3 ret
00000db8 <thread_join>:
SYSCALL(thread_join)
db8: b8 19 00 00 00 mov $0x19,%eax
dbd: cd 40 int $0x40
dbf: c3 ret
00000dc0 <binary_sem_create>:
SYSCALL(binary_sem_create)
dc0: b8 1b 00 00 00 mov $0x1b,%eax
dc5: cd 40 int $0x40
dc7: c3 ret
00000dc8 <binary_sem_down>:
SYSCALL(binary_sem_down)
dc8: b8 1c 00 00 00 mov $0x1c,%eax
dcd: cd 40 int $0x40
dcf: c3 ret
00000dd0 <binary_sem_up>:
SYSCALL(binary_sem_up)
dd0: b8 1d 00 00 00 mov $0x1d,%eax
dd5: cd 40 int $0x40
dd7: c3 ret
00000dd8 <binary_sem_clear>:
SYSCALL(binary_sem_clear)
dd8: b8 1e 00 00 00 mov $0x1e,%eax
ddd: cd 40 int $0x40
ddf: c3 ret
00000de0 <exit_all_threads>:
de0: b8 1f 00 00 00 mov $0x1f,%eax
de5: cd 40 int $0x40
de7: c3 ret
de8: 90 nop
de9: 90 nop
dea: 90 nop
deb: 90 nop
dec: 90 nop
ded: 90 nop
dee: 90 nop
def: 90 nop
00000df0 <printint>:
write(fd, &c, 1);
}
static void
printint(int fd, int xx, int base, int sgn)
{
df0: 55 push %ebp
df1: 89 e5 mov %esp,%ebp
df3: 57 push %edi
df4: 89 cf mov %ecx,%edi
df6: 56 push %esi
df7: 89 c6 mov %eax,%esi
df9: 53 push %ebx
dfa: 83 ec 4c sub $0x4c,%esp
char buf[16];
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
dfd: 8b 4d 08 mov 0x8(%ebp),%ecx
e00: 85 c9 test %ecx,%ecx
e02: 74 04 je e08 <printint+0x18>
e04: 85 d2 test %edx,%edx
e06: 78 70 js e78 <printint+0x88>
neg = 1;
x = -xx;
} else {
x = xx;
e08: 89 d0 mov %edx,%eax
e0a: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp)
e11: 31 c9 xor %ecx,%ecx
e13: 8d 5d d7 lea -0x29(%ebp),%ebx
e16: 66 90 xchg %ax,%ax
}
i = 0;
do{
buf[i++] = digits[x % base];
e18: 31 d2 xor %edx,%edx
e1a: f7 f7 div %edi
e1c: 0f b6 92 17 18 00 00 movzbl 0x1817(%edx),%edx
e23: 88 14 0b mov %dl,(%ebx,%ecx,1)
e26: 83 c1 01 add $0x1,%ecx
}while((x /= base) != 0);
e29: 85 c0 test %eax,%eax
e2b: 75 eb jne e18 <printint+0x28>
if(neg)
e2d: 8b 45 c4 mov -0x3c(%ebp),%eax
e30: 85 c0 test %eax,%eax
e32: 74 08 je e3c <printint+0x4c>
buf[i++] = '-';
e34: c6 44 0d d7 2d movb $0x2d,-0x29(%ebp,%ecx,1)
e39: 83 c1 01 add $0x1,%ecx
while(--i >= 0)
e3c: 8d 79 ff lea -0x1(%ecx),%edi
e3f: 01 fb add %edi,%ebx
e41: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
e48: 0f b6 03 movzbl (%ebx),%eax
e4b: 83 ef 01 sub $0x1,%edi
e4e: 83 eb 01 sub $0x1,%ebx
int binsem_sync_print;
static void
putc(int fd, char c)
{
write(fd, &c, 1);
e51: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
e58: 00
e59: 89 34 24 mov %esi,(%esp)
buf[i++] = digits[x % base];
}while((x /= base) != 0);
if(neg)
buf[i++] = '-';
while(--i >= 0)
e5c: 88 45 e7 mov %al,-0x19(%ebp)
int binsem_sync_print;
static void
putc(int fd, char c)
{
write(fd, &c, 1);
e5f: 8d 45 e7 lea -0x19(%ebp),%eax
e62: 89 44 24 04 mov %eax,0x4(%esp)
e66: e8 ad fe ff ff call d18 <write>
buf[i++] = digits[x % base];
}while((x /= base) != 0);
if(neg)
buf[i++] = '-';
while(--i >= 0)
e6b: 83 ff ff cmp $0xffffffff,%edi
e6e: 75 d8 jne e48 <printint+0x58>
putc(fd, buf[i]);
}
e70: 83 c4 4c add $0x4c,%esp
e73: 5b pop %ebx
e74: 5e pop %esi
e75: 5f pop %edi
e76: 5d pop %ebp
e77: c3 ret
uint x;
neg = 0;
if(sgn && xx < 0){
neg = 1;
x = -xx;
e78: 89 d0 mov %edx,%eax
e7a: f7 d8 neg %eax
e7c: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp)
e83: eb 8c jmp e11 <printint+0x21>
e85: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
e89: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000e90 <printf>:
}
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
e90: 55 push %ebp
e91: 89 e5 mov %esp,%ebp
e93: 57 push %edi
e94: 56 push %esi
e95: 53 push %ebx
e96: 83 ec 3c sub $0x3c,%esp
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
e99: 8b 45 0c mov 0xc(%ebp),%eax
e9c: 0f b6 10 movzbl (%eax),%edx
e9f: 84 d2 test %dl,%dl
ea1: 0f 84 c9 00 00 00 je f70 <printf+0xe0>
char *s;
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
ea7: 8d 4d 10 lea 0x10(%ebp),%ecx
eaa: 31 ff xor %edi,%edi
eac: 89 4d d4 mov %ecx,-0x2c(%ebp)
eaf: 31 db xor %ebx,%ebx
int binsem_sync_print;
static void
putc(int fd, char c)
{
write(fd, &c, 1);
eb1: 8d 75 e7 lea -0x19(%ebp),%esi
eb4: eb 1e jmp ed4 <printf+0x44>
eb6: 66 90 xchg %ax,%ax
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
eb8: 83 fa 25 cmp $0x25,%edx
ebb: 0f 85 b7 00 00 00 jne f78 <printf+0xe8>
ec1: 66 bf 25 00 mov $0x25,%di
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
ec5: 83 c3 01 add $0x1,%ebx
ec8: 0f b6 14 18 movzbl (%eax,%ebx,1),%edx
ecc: 84 d2 test %dl,%dl
ece: 0f 84 9c 00 00 00 je f70 <printf+0xe0>
c = fmt[i] & 0xff;
if(state == 0){
ed4: 85 ff test %edi,%edi
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
c = fmt[i] & 0xff;
ed6: 0f b6 d2 movzbl %dl,%edx
if(state == 0){
ed9: 74 dd je eb8 <printf+0x28>
if(c == '%'){
state = '%';
} else {
putc(fd, c);
}
} else if(state == '%'){
edb: 83 ff 25 cmp $0x25,%edi
ede: 75 e5 jne ec5 <printf+0x35>
if(c == 'd'){
ee0: 83 fa 64 cmp $0x64,%edx
ee3: 0f 84 57 01 00 00 je 1040 <printf+0x1b0>
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
ee9: 83 fa 70 cmp $0x70,%edx
eec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
ef0: 0f 84 aa 00 00 00 je fa0 <printf+0x110>
ef6: 83 fa 78 cmp $0x78,%edx
ef9: 0f 84 a1 00 00 00 je fa0 <printf+0x110>
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
eff: 83 fa 73 cmp $0x73,%edx
f02: 0f 84 c0 00 00 00 je fc8 <printf+0x138>
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
f08: 83 fa 63 cmp $0x63,%edx
f0b: 90 nop
f0c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
f10: 0f 84 52 01 00 00 je 1068 <printf+0x1d8>
putc(fd, *ap);
ap++;
} else if(c == '%'){
f16: 83 fa 25 cmp $0x25,%edx
f19: 0f 84 f9 00 00 00 je 1018 <printf+0x188>
int binsem_sync_print;
static void
putc(int fd, char c)
{
write(fd, &c, 1);
f1f: 8b 4d 08 mov 0x8(%ebp),%ecx
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
f22: 83 c3 01 add $0x1,%ebx
int binsem_sync_print;
static void
putc(int fd, char c)
{
write(fd, &c, 1);
f25: 31 ff xor %edi,%edi
f27: 89 55 cc mov %edx,-0x34(%ebp)
f2a: c6 45 e7 25 movb $0x25,-0x19(%ebp)
f2e: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
f35: 00
f36: 89 0c 24 mov %ecx,(%esp)
f39: 89 74 24 04 mov %esi,0x4(%esp)
f3d: e8 d6 fd ff ff call d18 <write>
f42: 8b 55 cc mov -0x34(%ebp),%edx
f45: 8b 45 08 mov 0x8(%ebp),%eax
f48: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
f4f: 00
f50: 89 74 24 04 mov %esi,0x4(%esp)
f54: 88 55 e7 mov %dl,-0x19(%ebp)
f57: 89 04 24 mov %eax,(%esp)
f5a: e8 b9 fd ff ff call d18 <write>
f5f: 8b 45 0c mov 0xc(%ebp),%eax
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
f62: 0f b6 14 18 movzbl (%eax,%ebx,1),%edx
f66: 84 d2 test %dl,%dl
f68: 0f 85 66 ff ff ff jne ed4 <printf+0x44>
f6e: 66 90 xchg %ax,%ax
putc(fd, c);
}
state = 0;
}
}
}
f70: 83 c4 3c add $0x3c,%esp
f73: 5b pop %ebx
f74: 5e pop %esi
f75: 5f pop %edi
f76: 5d pop %ebp
f77: c3 ret
int binsem_sync_print;
static void
putc(int fd, char c)
{
write(fd, &c, 1);
f78: 8b 45 08 mov 0x8(%ebp),%eax
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
f7b: 88 55 e7 mov %dl,-0x19(%ebp)
int binsem_sync_print;
static void
putc(int fd, char c)
{
write(fd, &c, 1);
f7e: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
f85: 00
f86: 89 74 24 04 mov %esi,0x4(%esp)
f8a: 89 04 24 mov %eax,(%esp)
f8d: e8 86 fd ff ff call d18 <write>
f92: 8b 45 0c mov 0xc(%ebp),%eax
f95: e9 2b ff ff ff jmp ec5 <printf+0x35>
f9a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
} else if(state == '%'){
if(c == 'd'){
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
printint(fd, *ap, 16, 0);
fa0: 8b 45 d4 mov -0x2c(%ebp),%eax
fa3: b9 10 00 00 00 mov $0x10,%ecx
ap++;
fa8: 31 ff xor %edi,%edi
} else if(state == '%'){
if(c == 'd'){
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
printint(fd, *ap, 16, 0);
faa: c7 04 24 00 00 00 00 movl $0x0,(%esp)
fb1: 8b 10 mov (%eax),%edx
fb3: 8b 45 08 mov 0x8(%ebp),%eax
fb6: e8 35 fe ff ff call df0 <printint>
fbb: 8b 45 0c mov 0xc(%ebp),%eax
ap++;
fbe: 83 45 d4 04 addl $0x4,-0x2c(%ebp)
fc2: e9 fe fe ff ff jmp ec5 <printf+0x35>
fc7: 90 nop
} else if(c == 's'){
s = (char*)*ap;
fc8: 8b 55 d4 mov -0x2c(%ebp),%edx
fcb: 8b 3a mov (%edx),%edi
ap++;
fcd: 83 c2 04 add $0x4,%edx
fd0: 89 55 d4 mov %edx,-0x2c(%ebp)
if(s == 0)
fd3: 85 ff test %edi,%edi
fd5: 0f 84 ba 00 00 00 je 1095 <printf+0x205>
s = "(null)";
while(*s != 0){
fdb: 0f b6 17 movzbl (%edi),%edx
fde: 84 d2 test %dl,%dl
fe0: 74 2d je 100f <printf+0x17f>
fe2: 89 5d d0 mov %ebx,-0x30(%ebp)
fe5: 8b 5d 08 mov 0x8(%ebp),%ebx
putc(fd, *s);
s++;
fe8: 83 c7 01 add $0x1,%edi
} else if(c == 's'){
s = (char*)*ap;
ap++;
if(s == 0)
s = "(null)";
while(*s != 0){
feb: 88 55 e7 mov %dl,-0x19(%ebp)
int binsem_sync_print;
static void
putc(int fd, char c)
{
write(fd, &c, 1);
fee: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
ff5: 00
ff6: 89 74 24 04 mov %esi,0x4(%esp)
ffa: 89 1c 24 mov %ebx,(%esp)
ffd: e8 16 fd ff ff call d18 <write>
} else if(c == 's'){
s = (char*)*ap;
ap++;
if(s == 0)
s = "(null)";
while(*s != 0){
1002: 0f b6 17 movzbl (%edi),%edx
1005: 84 d2 test %dl,%dl
1007: 75 df jne fe8 <printf+0x158>
1009: 8b 5d d0 mov -0x30(%ebp),%ebx
100c: 8b 45 0c mov 0xc(%ebp),%eax
int binsem_sync_print;
static void
putc(int fd, char c)
{
write(fd, &c, 1);
100f: 31 ff xor %edi,%edi
1011: e9 af fe ff ff jmp ec5 <printf+0x35>
1016: 66 90 xchg %ax,%ax
1018: 8b 55 08 mov 0x8(%ebp),%edx
101b: 31 ff xor %edi,%edi
s++;
}
} else if(c == 'c'){
putc(fd, *ap);
ap++;
} else if(c == '%'){
101d: c6 45 e7 25 movb $0x25,-0x19(%ebp)
int binsem_sync_print;
static void
putc(int fd, char c)
{
write(fd, &c, 1);
1021: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
1028: 00
1029: 89 74 24 04 mov %esi,0x4(%esp)
102d: 89 14 24 mov %edx,(%esp)
1030: e8 e3 fc ff ff call d18 <write>
1035: 8b 45 0c mov 0xc(%ebp),%eax
1038: e9 88 fe ff ff jmp ec5 <printf+0x35>
103d: 8d 76 00 lea 0x0(%esi),%esi
} else {
putc(fd, c);
}
} else if(state == '%'){
if(c == 'd'){
printint(fd, *ap, 10, 1);
1040: 8b 45 d4 mov -0x2c(%ebp),%eax
1043: b9 0a 00 00 00 mov $0xa,%ecx
ap++;
1048: 66 31 ff xor %di,%di
} else {
putc(fd, c);
}
} else if(state == '%'){
if(c == 'd'){
printint(fd, *ap, 10, 1);
104b: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1052: 8b 10 mov (%eax),%edx
1054: 8b 45 08 mov 0x8(%ebp),%eax
1057: e8 94 fd ff ff call df0 <printint>
105c: 8b 45 0c mov 0xc(%ebp),%eax
ap++;
105f: 83 45 d4 04 addl $0x4,-0x2c(%ebp)
1063: e9 5d fe ff ff jmp ec5 <printf+0x35>
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
1068: 8b 4d d4 mov -0x2c(%ebp),%ecx
putc(fd, *ap);
ap++;
106b: 31 ff xor %edi,%edi
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
106d: 8b 01 mov (%ecx),%eax
int binsem_sync_print;
static void
putc(int fd, char c)
{
write(fd, &c, 1);
106f: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
1076: 00
1077: 89 74 24 04 mov %esi,0x4(%esp)
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
107b: 88 45 e7 mov %al,-0x19(%ebp)
int binsem_sync_print;
static void
putc(int fd, char c)
{
write(fd, &c, 1);
107e: 8b 45 08 mov 0x8(%ebp),%eax
1081: 89 04 24 mov %eax,(%esp)
1084: e8 8f fc ff ff call d18 <write>
1089: 8b 45 0c mov 0xc(%ebp),%eax
putc(fd, *s);
s++;
}
} else if(c == 'c'){
putc(fd, *ap);
ap++;
108c: 83 45 d4 04 addl $0x4,-0x2c(%ebp)
1090: e9 30 fe ff ff jmp ec5 <printf+0x35>
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
s = (char*)*ap;
ap++;
if(s == 0)
1095: bf 10 18 00 00 mov $0x1810,%edi
109a: e9 3c ff ff ff jmp fdb <printf+0x14b>
109f: 90 nop
000010a0 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
10a0: 55 push %ebp
Header *bp, *p;
bp = (Header*) ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
10a1: a1 e0 18 00 00 mov 0x18e0,%eax
static Header base;
static Header *freep;
void
free(void *ap)
{
10a6: 89 e5 mov %esp,%ebp
10a8: 57 push %edi
10a9: 56 push %esi
10aa: 53 push %ebx
10ab: 8b 5d 08 mov 0x8(%ebp),%ebx
Header *bp, *p;
bp = (Header*) ap - 1;
10ae: 8d 4b f8 lea -0x8(%ebx),%ecx
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
10b1: 39 c8 cmp %ecx,%eax
10b3: 73 1d jae 10d2 <free+0x32>
10b5: 8d 76 00 lea 0x0(%esi),%esi
10b8: 8b 10 mov (%eax),%edx
10ba: 39 d1 cmp %edx,%ecx
10bc: 72 1a jb 10d8 <free+0x38>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
10be: 39 d0 cmp %edx,%eax
10c0: 72 08 jb 10ca <free+0x2a>
10c2: 39 c8 cmp %ecx,%eax
10c4: 72 12 jb 10d8 <free+0x38>
10c6: 39 d1 cmp %edx,%ecx
10c8: 72 0e jb 10d8 <free+0x38>
10ca: 89 d0 mov %edx,%eax
free(void *ap)
{
Header *bp, *p;
bp = (Header*) ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
10cc: 39 c8 cmp %ecx,%eax
10ce: 66 90 xchg %ax,%ax
10d0: 72 e6 jb 10b8 <free+0x18>
10d2: 8b 10 mov (%eax),%edx
10d4: eb e8 jmp 10be <free+0x1e>
10d6: 66 90 xchg %ax,%ax
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
break;
if(bp + bp->s.size == p->s.ptr){
10d8: 8b 71 04 mov 0x4(%ecx),%esi
10db: 8d 3c f1 lea (%ecx,%esi,8),%edi
10de: 39 d7 cmp %edx,%edi
10e0: 74 19 je 10fb <free+0x5b>
bp->s.size += p->s.ptr->s.size;
bp->s.ptr = p->s.ptr->s.ptr;
} else
bp->s.ptr = p->s.ptr;
10e2: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
10e5: 8b 50 04 mov 0x4(%eax),%edx
10e8: 8d 34 d0 lea (%eax,%edx,8),%esi
10eb: 39 ce cmp %ecx,%esi
10ed: 74 23 je 1112 <free+0x72>
p->s.size += bp->s.size;
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
10ef: 89 08 mov %ecx,(%eax)
freep = p;
10f1: a3 e0 18 00 00 mov %eax,0x18e0
}
10f6: 5b pop %ebx
10f7: 5e pop %esi
10f8: 5f pop %edi
10f9: 5d pop %ebp
10fa: c3 ret
bp = (Header*) ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
break;
if(bp + bp->s.size == p->s.ptr){
bp->s.size += p->s.ptr->s.size;
10fb: 03 72 04 add 0x4(%edx),%esi
10fe: 89 71 04 mov %esi,0x4(%ecx)
bp->s.ptr = p->s.ptr->s.ptr;
1101: 8b 10 mov (%eax),%edx
1103: 8b 12 mov (%edx),%edx
1105: 89 53 f8 mov %edx,-0x8(%ebx)
} else
bp->s.ptr = p->s.ptr;
if(p + p->s.size == bp){
1108: 8b 50 04 mov 0x4(%eax),%edx
110b: 8d 34 d0 lea (%eax,%edx,8),%esi
110e: 39 ce cmp %ecx,%esi
1110: 75 dd jne 10ef <free+0x4f>
p->s.size += bp->s.size;
1112: 03 51 04 add 0x4(%ecx),%edx
1115: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
1118: 8b 53 f8 mov -0x8(%ebx),%edx
111b: 89 10 mov %edx,(%eax)
} else
p->s.ptr = bp;
freep = p;
111d: a3 e0 18 00 00 mov %eax,0x18e0
}
1122: 5b pop %ebx
1123: 5e pop %esi
1124: 5f pop %edi
1125: 5d pop %ebp
1126: c3 ret
1127: 89 f6 mov %esi,%esi
1129: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00001130 <malloc>:
return freep;
}
void*
malloc(uint nbytes)
{
1130: 55 push %ebp
1131: 89 e5 mov %esp,%ebp
1133: 57 push %edi
1134: 56 push %esi
1135: 53 push %ebx
1136: 83 ec 1c sub $0x1c,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
1139: 8b 5d 08 mov 0x8(%ebp),%ebx
if((prevp = freep) == 0){
113c: 8b 0d e0 18 00 00 mov 0x18e0,%ecx
malloc(uint nbytes)
{
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
1142: 83 c3 07 add $0x7,%ebx
1145: c1 eb 03 shr $0x3,%ebx
1148: 83 c3 01 add $0x1,%ebx
if((prevp = freep) == 0){
114b: 85 c9 test %ecx,%ecx
114d: 0f 84 93 00 00 00 je 11e6 <malloc+0xb6>
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
1153: 8b 01 mov (%ecx),%eax
if(p->s.size >= nunits){
1155: 8b 50 04 mov 0x4(%eax),%edx
1158: 39 d3 cmp %edx,%ebx
115a: 76 1f jbe 117b <malloc+0x4b>
p->s.size -= nunits;
p += p->s.size;
p->s.size = nunits;
}
freep = prevp;
return (void*) (p + 1);
115c: 8d 34 dd 00 00 00 00 lea 0x0(,%ebx,8),%esi
1163: 90 nop
1164: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
}
if(p == freep)
1168: 3b 05 e0 18 00 00 cmp 0x18e0,%eax
116e: 74 30 je 11a0 <malloc+0x70>
1170: 89 c1 mov %eax,%ecx
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
if((prevp = freep) == 0){
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
1172: 8b 01 mov (%ecx),%eax
if(p->s.size >= nunits){
1174: 8b 50 04 mov 0x4(%eax),%edx
1177: 39 d3 cmp %edx,%ebx
1179: 77 ed ja 1168 <malloc+0x38>
if(p->s.size == nunits)
117b: 39 d3 cmp %edx,%ebx
117d: 74 61 je 11e0 <malloc+0xb0>
prevp->s.ptr = p->s.ptr;
else {
p->s.size -= nunits;
117f: 29 da sub %ebx,%edx
1181: 89 50 04 mov %edx,0x4(%eax)
p += p->s.size;
1184: 8d 04 d0 lea (%eax,%edx,8),%eax
p->s.size = nunits;
1187: 89 58 04 mov %ebx,0x4(%eax)
}
freep = prevp;
118a: 89 0d e0 18 00 00 mov %ecx,0x18e0
return (void*) (p + 1);
1190: 83 c0 08 add $0x8,%eax
}
if(p == freep)
if((p = morecore(nunits)) == 0)
return 0;
}
}
1193: 83 c4 1c add $0x1c,%esp
1196: 5b pop %ebx
1197: 5e pop %esi
1198: 5f pop %edi
1199: 5d pop %ebp
119a: c3 ret
119b: 90 nop
119c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
morecore(uint nu)
{
char *p;
Header *hp;
if(nu < 4096)
11a0: 81 fb ff 0f 00 00 cmp $0xfff,%ebx
11a6: b8 00 80 00 00 mov $0x8000,%eax
11ab: bf 00 10 00 00 mov $0x1000,%edi
11b0: 76 04 jbe 11b6 <malloc+0x86>
11b2: 89 f0 mov %esi,%eax
11b4: 89 df mov %ebx,%edi
nu = 4096;
p = sbrk(nu * sizeof(Header));
11b6: 89 04 24 mov %eax,(%esp)
11b9: e8 c2 fb ff ff call d80 <sbrk>
if(p == (char*) -1)
11be: 83 f8 ff cmp $0xffffffff,%eax
11c1: 74 18 je 11db <malloc+0xab>
return 0;
hp = (Header*)p;
hp->s.size = nu;
11c3: 89 78 04 mov %edi,0x4(%eax)
free((void*)(hp + 1));
11c6: 83 c0 08 add $0x8,%eax
11c9: 89 04 24 mov %eax,(%esp)
11cc: e8 cf fe ff ff call 10a0 <free>
return freep;
11d1: 8b 0d e0 18 00 00 mov 0x18e0,%ecx
}
freep = prevp;
return (void*) (p + 1);
}
if(p == freep)
if((p = morecore(nunits)) == 0)
11d7: 85 c9 test %ecx,%ecx
11d9: 75 97 jne 1172 <malloc+0x42>
if((prevp = freep) == 0){
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){
11db: 31 c0 xor %eax,%eax
11dd: eb b4 jmp 1193 <malloc+0x63>
11df: 90 nop
if(p->s.size == nunits)
prevp->s.ptr = p->s.ptr;
11e0: 8b 10 mov (%eax),%edx
11e2: 89 11 mov %edx,(%ecx)
11e4: eb a4 jmp 118a <malloc+0x5a>
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
if((prevp = freep) == 0){
base.s.ptr = freep = prevp = &base;
11e6: c7 05 e0 18 00 00 d8 movl $0x18d8,0x18e0
11ed: 18 00 00
base.s.size = 0;
11f0: b9 d8 18 00 00 mov $0x18d8,%ecx
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
if((prevp = freep) == 0){
base.s.ptr = freep = prevp = &base;
11f5: c7 05 d8 18 00 00 d8 movl $0x18d8,0x18d8
11fc: 18 00 00
base.s.size = 0;
11ff: c7 05 dc 18 00 00 00 movl $0x0,0x18dc
1206: 00 00 00
1209: e9 45 ff ff ff jmp 1153 <malloc+0x23>
120e: 90 nop
120f: 90 nop
00001210 <sem_clear>:
}
binary_sem_up(sem->S1);
}
void sem_clear(struct semaphore* sem )
{
1210: 55 push %ebp
1211: 89 e5 mov %esp,%ebp
1213: 53 push %ebx
1214: 83 ec 14 sub $0x14,%esp
1217: 8b 5d 08 mov 0x8(%ebp),%ebx
binary_sem_clear(sem->S1);
121a: 8b 03 mov (%ebx),%eax
121c: 89 04 24 mov %eax,(%esp)
121f: e8 b4 fb ff ff call dd8 <binary_sem_clear>
binary_sem_clear(sem->S2);
1224: 8b 43 04 mov 0x4(%ebx),%eax
1227: 89 04 24 mov %eax,(%esp)
122a: e8 a9 fb ff ff call dd8 <binary_sem_clear>
free(sem);
122f: 89 5d 08 mov %ebx,0x8(%ebp)
}
1232: 83 c4 14 add $0x14,%esp
1235: 5b pop %ebx
1236: 5d pop %ebp
void sem_clear(struct semaphore* sem )
{
binary_sem_clear(sem->S1);
binary_sem_clear(sem->S2);
free(sem);
1237: e9 64 fe ff ff jmp 10a0 <free>
123c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
00001240 <sem_downs>:
}
binary_sem_up(sem->S1);
}
void sem_downs(struct semaphore* sem, int num )
{
1240: 55 push %ebp
1241: 89 e5 mov %esp,%ebp
1243: 83 ec 18 sub $0x18,%esp
1246: 89 5d f8 mov %ebx,-0x8(%ebp)
1249: 8b 5d 08 mov 0x8(%ebp),%ebx
124c: 89 75 fc mov %esi,-0x4(%ebp)
124f: 8b 75 0c mov 0xc(%ebp),%esi
binary_sem_down(sem->S2);
1252: 8b 43 04 mov 0x4(%ebx),%eax
1255: 89 04 24 mov %eax,(%esp)
1258: e8 6b fb ff ff call dc8 <binary_sem_down>
binary_sem_down(sem->S1);
125d: 8b 03 mov (%ebx),%eax
125f: 89 04 24 mov %eax,(%esp)
1262: e8 61 fb ff ff call dc8 <binary_sem_down>
sem->value -= num;
1267: 8b 43 08 mov 0x8(%ebx),%eax
126a: 29 f0 sub %esi,%eax
if(sem->value > 0) {
126c: 85 c0 test %eax,%eax
void sem_downs(struct semaphore* sem, int num )
{
binary_sem_down(sem->S2);
binary_sem_down(sem->S1);
sem->value -= num;
126e: 89 43 08 mov %eax,0x8(%ebx)
if(sem->value > 0) {
1271: 74 0b je 127e <sem_downs+0x3e>
binary_sem_up(sem->S2);
1273: 8b 43 04 mov 0x4(%ebx),%eax
1276: 89 04 24 mov %eax,(%esp)
1279: e8 52 fb ff ff call dd0 <binary_sem_up>
}
binary_sem_up(sem->S1);
127e: 8b 03 mov (%ebx),%eax
}
1280: 8b 75 fc mov -0x4(%ebp),%esi
1283: 8b 5d f8 mov -0x8(%ebp),%ebx
binary_sem_down(sem->S1);
sem->value -= num;
if(sem->value > 0) {
binary_sem_up(sem->S2);
}
binary_sem_up(sem->S1);
1286: 89 45 08 mov %eax,0x8(%ebp)
}
1289: 89 ec mov %ebp,%esp
128b: 5d pop %ebp
binary_sem_down(sem->S1);
sem->value -= num;
if(sem->value > 0) {
binary_sem_up(sem->S2);
}
binary_sem_up(sem->S1);
128c: e9 3f fb ff ff jmp dd0 <binary_sem_up>
1291: eb 0d jmp 12a0 <sem_down>
1293: 90 nop
1294: 90 nop
1295: 90 nop
1296: 90 nop
1297: 90 nop
1298: 90 nop
1299: 90 nop
129a: 90 nop
129b: 90 nop
129c: 90 nop
129d: 90 nop
129e: 90 nop
129f: 90 nop
000012a0 <sem_down>:
}
binary_sem_up(sem->S1);
}
void sem_down(struct semaphore* sem )
{
12a0: 55 push %ebp
12a1: 89 e5 mov %esp,%ebp
12a3: 53 push %ebx
12a4: 83 ec 14 sub $0x14,%esp
12a7: 8b 5d 08 mov 0x8(%ebp),%ebx
binary_sem_down(sem->S2);
12aa: 8b 43 04 mov 0x4(%ebx),%eax
12ad: 89 04 24 mov %eax,(%esp)
12b0: e8 13 fb ff ff call dc8 <binary_sem_down>
binary_sem_down(sem->S1);
12b5: 8b 03 mov (%ebx),%eax
12b7: 89 04 24 mov %eax,(%esp)
12ba: e8 09 fb ff ff call dc8 <binary_sem_down>
sem->value--;
12bf: 8b 43 08 mov 0x8(%ebx),%eax
12c2: 83 e8 01 sub $0x1,%eax
if(sem->value > 0) {
12c5: 85 c0 test %eax,%eax
void sem_down(struct semaphore* sem )
{
binary_sem_down(sem->S2);
binary_sem_down(sem->S1);
sem->value--;
12c7: 89 43 08 mov %eax,0x8(%ebx)
if(sem->value > 0) {
12ca: 74 0b je 12d7 <sem_down+0x37>
binary_sem_up(sem->S2);
12cc: 8b 43 04 mov 0x4(%ebx),%eax
12cf: 89 04 24 mov %eax,(%esp)
12d2: e8 f9 fa ff ff call dd0 <binary_sem_up>
}
binary_sem_up(sem->S1);
12d7: 8b 03 mov (%ebx),%eax
12d9: 89 45 08 mov %eax,0x8(%ebp)
}
12dc: 83 c4 14 add $0x14,%esp
12df: 5b pop %ebx
12e0: 5d pop %ebp
binary_sem_down(sem->S1);
sem->value--;
if(sem->value > 0) {
binary_sem_up(sem->S2);
}
binary_sem_up(sem->S1);
12e1: e9 ea fa ff ff jmp dd0 <binary_sem_up>
12e6: 8d 76 00 lea 0x0(%esi),%esi
12e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000012f0 <sem_ups>:
}
binary_sem_up(sem->S1);
}
void sem_ups(struct semaphore* sem, int num )
{
12f0: 55 push %ebp
12f1: 89 e5 mov %esp,%ebp
12f3: 83 ec 18 sub $0x18,%esp
12f6: 89 5d f8 mov %ebx,-0x8(%ebp)
12f9: 8b 5d 08 mov 0x8(%ebp),%ebx
12fc: 89 75 fc mov %esi,-0x4(%ebp)
12ff: 8b 75 0c mov 0xc(%ebp),%esi
binary_sem_down(sem->S1);
1302: 8b 03 mov (%ebx),%eax
1304: 89 04 24 mov %eax,(%esp)
1307: e8 bc fa ff ff call dc8 <binary_sem_down>
sem->value+= num;
130c: 03 73 08 add 0x8(%ebx),%esi
if(sem->value == 1) {
130f: 83 fe 01 cmp $0x1,%esi
}
void sem_ups(struct semaphore* sem, int num )
{
binary_sem_down(sem->S1);
sem->value+= num;
1312: 89 73 08 mov %esi,0x8(%ebx)
if(sem->value == 1) {
1315: 74 19 je 1330 <sem_ups+0x40>
binary_sem_up(sem->S2);
}
binary_sem_up(sem->S1);
1317: 8b 03 mov (%ebx),%eax
}
1319: 8b 75 fc mov -0x4(%ebp),%esi
131c: 8b 5d f8 mov -0x8(%ebp),%ebx
binary_sem_down(sem->S1);
sem->value+= num;
if(sem->value == 1) {
binary_sem_up(sem->S2);
}
binary_sem_up(sem->S1);
131f: 89 45 08 mov %eax,0x8(%ebp)
}
1322: 89 ec mov %ebp,%esp
1324: 5d pop %ebp
binary_sem_down(sem->S1);
sem->value+= num;
if(sem->value == 1) {
binary_sem_up(sem->S2);
}
binary_sem_up(sem->S1);
1325: e9 a6 fa ff ff jmp dd0 <binary_sem_up>
132a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
void sem_ups(struct semaphore* sem, int num )
{
binary_sem_down(sem->S1);
sem->value+= num;
if(sem->value == 1) {
binary_sem_up(sem->S2);
1330: 8b 43 04 mov 0x4(%ebx),%eax
1333: 89 04 24 mov %eax,(%esp)
1336: e8 95 fa ff ff call dd0 <binary_sem_up>
133b: eb da jmp 1317 <sem_ups+0x27>
133d: 8d 76 00 lea 0x0(%esi),%esi
00001340 <sem_up>:
}
return ret;
}
void sem_up(struct semaphore* sem )
{
1340: 55 push %ebp
1341: 89 e5 mov %esp,%ebp
1343: 53 push %ebx
1344: 83 ec 14 sub $0x14,%esp
1347: 8b 5d 08 mov 0x8(%ebp),%ebx
binary_sem_down(sem->S1);
134a: 8b 03 mov (%ebx),%eax
134c: 89 04 24 mov %eax,(%esp)
134f: e8 74 fa ff ff call dc8 <binary_sem_down>
sem->value++;
1354: 8b 43 08 mov 0x8(%ebx),%eax
1357: 83 c0 01 add $0x1,%eax
if(sem->value == 1) {
135a: 83 f8 01 cmp $0x1,%eax
}
void sem_up(struct semaphore* sem )
{
binary_sem_down(sem->S1);
sem->value++;
135d: 89 43 08 mov %eax,0x8(%ebx)
if(sem->value == 1) {
1360: 74 16 je 1378 <sem_up+0x38>
binary_sem_up(sem->S2);
}
binary_sem_up(sem->S1);
1362: 8b 03 mov (%ebx),%eax
1364: 89 45 08 mov %eax,0x8(%ebp)
}
1367: 83 c4 14 add $0x14,%esp
136a: 5b pop %ebx
136b: 5d pop %ebp
binary_sem_down(sem->S1);
sem->value++;
if(sem->value == 1) {
binary_sem_up(sem->S2);
}
binary_sem_up(sem->S1);
136c: e9 5f fa ff ff jmp dd0 <binary_sem_up>
1371: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
void sem_up(struct semaphore* sem )
{
binary_sem_down(sem->S1);
sem->value++;
if(sem->value == 1) {
binary_sem_up(sem->S2);
1378: 8b 43 04 mov 0x4(%ebx),%eax
137b: 89 04 24 mov %eax,(%esp)
137e: e8 4d fa ff ff call dd0 <binary_sem_up>
}
binary_sem_up(sem->S1);
1383: 8b 03 mov (%ebx),%eax
1385: 89 45 08 mov %eax,0x8(%ebp)
}
1388: 83 c4 14 add $0x14,%esp
138b: 5b pop %ebx
138c: 5d pop %ebp
binary_sem_down(sem->S1);
sem->value++;
if(sem->value == 1) {
binary_sem_up(sem->S2);
}
binary_sem_up(sem->S1);
138d: e9 3e fa ff ff jmp dd0 <binary_sem_up>
1392: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
1399: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000013a0 <semaphore_create>:
#include "stat.h"
#include "user.h"
#include "semaphore.h"
struct semaphore* semaphore_create(int initial_semaphore_value)
{
13a0: 55 push %ebp
13a1: 89 e5 mov %esp,%ebp
13a3: 83 ec 28 sub $0x28,%esp
struct semaphore* ret;
ret = malloc(sizeof(*ret));
13a6: c7 04 24 0c 00 00 00 movl $0xc,(%esp)
#include "stat.h"
#include "user.h"
#include "semaphore.h"
struct semaphore* semaphore_create(int initial_semaphore_value)
{
13ad: 89 5d f4 mov %ebx,-0xc(%ebp)
13b0: 89 75 f8 mov %esi,-0x8(%ebp)
13b3: 89 7d fc mov %edi,-0x4(%ebp)
13b6: 8b 7d 08 mov 0x8(%ebp),%edi
struct semaphore* ret;
ret = malloc(sizeof(*ret));
13b9: e8 72 fd ff ff call 1130 <malloc>
ret->value = initial_semaphore_value;
13be: 89 78 08 mov %edi,0x8(%eax)
#include "semaphore.h"
struct semaphore* semaphore_create(int initial_semaphore_value)
{
struct semaphore* ret;
ret = malloc(sizeof(*ret));
13c1: 89 c3 mov %eax,%ebx
ret->value = initial_semaphore_value;
if(((ret->S1 = binary_sem_create()) + (ret->S2 = binary_sem_create())) < 0) {
13c3: e8 f8 f9 ff ff call dc0 <binary_sem_create>
13c8: 89 03 mov %eax,(%ebx)
13ca: 89 c6 mov %eax,%esi
13cc: e8 ef f9 ff ff call dc0 <binary_sem_create>
13d1: 01 c6 add %eax,%esi
13d3: 89 43 04 mov %eax,0x4(%ebx)
13d6: 78 20 js 13f8 <semaphore_create+0x58>
printf(2,"couldnt create the 2 binary semaphores");
return 0;
}
if(initial_semaphore_value == 0) {
13d8: 85 ff test %edi,%edi
13da: 75 08 jne 13e4 <semaphore_create+0x44>
binary_sem_down(ret->S2);
13dc: 89 04 24 mov %eax,(%esp)
13df: e8 e4 f9 ff ff call dc8 <binary_sem_down>
}
return ret;
}
13e4: 89 d8 mov %ebx,%eax
13e6: 8b 75 f8 mov -0x8(%ebp),%esi
13e9: 8b 5d f4 mov -0xc(%ebp),%ebx
13ec: 8b 7d fc mov -0x4(%ebp),%edi
13ef: 89 ec mov %ebp,%esp
13f1: 5d pop %ebp
13f2: c3 ret
13f3: 90 nop
13f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
{
struct semaphore* ret;
ret = malloc(sizeof(*ret));
ret->value = initial_semaphore_value;
if(((ret->S1 = binary_sem_create()) + (ret->S2 = binary_sem_create())) < 0) {
printf(2,"couldnt create the 2 binary semaphores");
13f8: c7 44 24 04 28 18 00 movl $0x1828,0x4(%esp)
13ff: 00
1400: 31 db xor %ebx,%ebx
1402: c7 04 24 02 00 00 00 movl $0x2,(%esp)
1409: e8 82 fa ff ff call e90 <printf>
return 0;
140e: eb d4 jmp 13e4 <semaphore_create+0x44>
00001410 <semaphore_clear>:
binary_sem_up(bb->mutex);
sem_up(bb->empty);
return element;
}
void semaphore_clear(struct BB* bb) {
1410: 55 push %ebp
1411: 89 e5 mov %esp,%ebp
1413: 53 push %ebx
1414: 83 ec 14 sub $0x14,%esp
1417: 8b 5d 08 mov 0x8(%ebp),%ebx
free(bb->buffer);
141a: 8b 43 0c mov 0xc(%ebx),%eax
141d: 89 04 24 mov %eax,(%esp)
1420: e8 7b fc ff ff call 10a0 <free>
sem_clear(bb->empty);
1425: 8b 43 04 mov 0x4(%ebx),%eax
1428: 89 04 24 mov %eax,(%esp)
142b: e8 e0 fd ff ff call 1210 <sem_clear>
sem_clear(bb->full);
1430: 8b 43 08 mov 0x8(%ebx),%eax
1433: 89 04 24 mov %eax,(%esp)
1436: e8 d5 fd ff ff call 1210 <sem_clear>
binary_sem_clear(bb->mutex);
143b: 8b 03 mov (%ebx),%eax
143d: 89 04 24 mov %eax,(%esp)
1440: e8 93 f9 ff ff call dd8 <binary_sem_clear>
free(bb);
1445: 89 5d 08 mov %ebx,0x8(%ebp)
}
1448: 83 c4 14 add $0x14,%esp
144b: 5b pop %ebx
144c: 5d pop %ebp
void semaphore_clear(struct BB* bb) {
free(bb->buffer);
sem_clear(bb->empty);
sem_clear(bb->full);
binary_sem_clear(bb->mutex);
free(bb);
144d: e9 4e fc ff ff jmp 10a0 <free>
1452: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
1459: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00001460 <semaphore_release_atomic>:
}
sem_up(bb->full);
}
void semaphore_release_atomic(struct BB* bb)
{
1460: 55 push %ebp
1461: 89 e5 mov %esp,%ebp
1463: 83 ec 08 sub $0x8,%esp
binary_sem_up(bb->mutex);
1466: 8b 45 08 mov 0x8(%ebp),%eax
1469: 8b 00 mov (%eax),%eax
146b: 89 45 08 mov %eax,0x8(%ebp)
}
146e: c9 leave
sem_up(bb->full);
}
void semaphore_release_atomic(struct BB* bb)
{
binary_sem_up(bb->mutex);
146f: e9 5c f9 ff ff jmp dd0 <binary_sem_up>
1474: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
147a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00001480 <semaphore_pop>:
}
void* semaphore_pop(struct BB* bb)
{
1480: 55 push %ebp
1481: 89 e5 mov %esp,%ebp
1483: 56 push %esi
1484: 53 push %ebx
1485: 83 ec 10 sub $0x10,%esp
1488: 8b 5d 08 mov 0x8(%ebp),%ebx
void* element = 0;
sem_down(bb->full);
148b: 8b 43 08 mov 0x8(%ebx),%eax
148e: 89 04 24 mov %eax,(%esp)
1491: e8 0a fe ff ff call 12a0 <sem_down>
binary_sem_down(bb->mutex);
1496: 8b 03 mov (%ebx),%eax
1498: 89 04 24 mov %eax,(%esp)
149b: e8 28 f9 ff ff call dc8 <binary_sem_down>
if(bb->buffer[bb->consume] == 0) {
14a0: 8b 43 14 mov 0x14(%ebx),%eax
14a3: c1 e0 02 shl $0x2,%eax
14a6: 03 43 0c add 0xc(%ebx),%eax
14a9: 8b 30 mov (%eax),%esi
14ab: 85 f6 test %esi,%esi
14ad: 74 42 je 14f1 <semaphore_pop+0x71>
printf(2,"something went wrong! buffer is empty and we are trying to consume\n");
}
else {
element = bb->buffer[bb->consume];
bb->buffer[bb->consume] = 0;
14af: c7 00 00 00 00 00 movl $0x0,(%eax)
if(bb->consume == (bb->capacity - 1)) {
14b5: 8b 53 18 mov 0x18(%ebx),%edx
14b8: 8b 43 14 mov 0x14(%ebx),%eax
14bb: 83 ea 01 sub $0x1,%edx
14be: 39 d0 cmp %edx,%eax
14c0: 74 26 je 14e8 <semaphore_pop+0x68>
bb->consume = 0;
}
else {
bb->consume++;
14c2: 83 c0 01 add $0x1,%eax
14c5: 89 43 14 mov %eax,0x14(%ebx)
}
}
binary_sem_up(bb->mutex);
14c8: 8b 03 mov (%ebx),%eax
14ca: 89 04 24 mov %eax,(%esp)
14cd: e8 fe f8 ff ff call dd0 <binary_sem_up>
sem_up(bb->empty);
14d2: 8b 43 04 mov 0x4(%ebx),%eax
14d5: 89 04 24 mov %eax,(%esp)
14d8: e8 63 fe ff ff call 1340 <sem_up>
return element;
}
14dd: 83 c4 10 add $0x10,%esp
14e0: 89 f0 mov %esi,%eax
14e2: 5b pop %ebx
14e3: 5e pop %esi
14e4: 5d pop %ebp
14e5: c3 ret
14e6: 66 90 xchg %ax,%ax
}
else {
element = bb->buffer[bb->consume];
bb->buffer[bb->consume] = 0;
if(bb->consume == (bb->capacity - 1)) {
bb->consume = 0;
14e8: c7 43 14 00 00 00 00 movl $0x0,0x14(%ebx)
14ef: eb d7 jmp 14c8 <semaphore_pop+0x48>
{
void* element = 0;
sem_down(bb->full);
binary_sem_down(bb->mutex);
if(bb->buffer[bb->consume] == 0) {
printf(2,"something went wrong! buffer is empty and we are trying to consume\n");
14f1: c7 44 24 04 50 18 00 movl $0x1850,0x4(%esp)
14f8: 00
14f9: c7 04 24 02 00 00 00 movl $0x2,(%esp)
1500: e8 8b f9 ff ff call e90 <printf>
1505: eb c1 jmp 14c8 <semaphore_pop+0x48>
1507: 89 f6 mov %esi,%esi
1509: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00001510 <semaphore_put_atomic>:
binary_sem_up(bb->mutex);
sem_up(bb->full);
}
void semaphore_put_atomic(struct BB* bb, void* element)
{
1510: 55 push %ebp
1511: 89 e5 mov %esp,%ebp
1513: 56 push %esi
1514: 53 push %ebx
1515: 83 ec 10 sub $0x10,%esp
1518: 8b 5d 08 mov 0x8(%ebp),%ebx
151b: 8b 75 0c mov 0xc(%ebp),%esi
sem_down(bb->empty);
151e: 8b 43 04 mov 0x4(%ebx),%eax
1521: 89 04 24 mov %eax,(%esp)
1524: e8 77 fd ff ff call 12a0 <sem_down>
binary_sem_down(bb->mutex);
1529: 8b 03 mov (%ebx),%eax
152b: 89 04 24 mov %eax,(%esp)
152e: e8 95 f8 ff ff call dc8 <binary_sem_down>
if(bb->buffer[bb->produce] != 0) {
1533: 8b 43 10 mov 0x10(%ebx),%eax
1536: c1 e0 02 shl $0x2,%eax
1539: 03 43 0c add 0xc(%ebx),%eax
153c: 8b 10 mov (%eax),%edx
153e: 85 d2 test %edx,%edx
1540: 74 26 je 1568 <semaphore_put_atomic+0x58>
printf(2,"something went wrong! buffer is full and we are trying to produce\n");
1542: c7 44 24 04 94 18 00 movl $0x1894,0x4(%esp)
1549: 00
154a: c7 04 24 02 00 00 00 movl $0x2,(%esp)
1551: e8 3a f9 ff ff call e90 <printf>
}
else {
bb->produce++;
}
}
sem_up(bb->full);
1556: 8b 43 08 mov 0x8(%ebx),%eax
1559: 89 45 08 mov %eax,0x8(%ebp)
}
155c: 83 c4 10 add $0x10,%esp
155f: 5b pop %ebx
1560: 5e pop %esi
1561: 5d pop %ebp
}
else {
bb->produce++;
}
}
sem_up(bb->full);
1562: e9 d9 fd ff ff jmp 1340 <sem_up>
1567: 90 nop
binary_sem_down(bb->mutex);
if(bb->buffer[bb->produce] != 0) {
printf(2,"something went wrong! buffer is full and we are trying to produce\n");
}
else {
bb->buffer[bb->produce] = element;
1568: 89 30 mov %esi,(%eax)
if(bb->produce == (bb->capacity - 1)) {
156a: 8b 53 18 mov 0x18(%ebx),%edx
156d: 8b 43 10 mov 0x10(%ebx),%eax
1570: 83 ea 01 sub $0x1,%edx
1573: 39 d0 cmp %edx,%eax
1575: 74 09 je 1580 <semaphore_put_atomic+0x70>
bb->produce = 0;
}
else {
bb->produce++;
1577: 83 c0 01 add $0x1,%eax
157a: 89 43 10 mov %eax,0x10(%ebx)
157d: eb d7 jmp 1556 <semaphore_put_atomic+0x46>
157f: 90 nop
printf(2,"something went wrong! buffer is full and we are trying to produce\n");
}
else {
bb->buffer[bb->produce] = element;
if(bb->produce == (bb->capacity - 1)) {
bb->produce = 0;
1580: c7 43 10 00 00 00 00 movl $0x0,0x10(%ebx)
1587: eb cd jmp 1556 <semaphore_put_atomic+0x46>
1589: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00001590 <semaphore_put>:
ret->capacity = max_capacity;
return ret;
}
void semaphore_put(struct BB* bb, void* element)
{
1590: 55 push %ebp
1591: 89 e5 mov %esp,%ebp
1593: 56 push %esi
1594: 53 push %ebx
1595: 83 ec 10 sub $0x10,%esp
1598: 8b 5d 08 mov 0x8(%ebp),%ebx
159b: 8b 75 0c mov 0xc(%ebp),%esi
sem_down(bb->empty);
159e: 8b 43 04 mov 0x4(%ebx),%eax
15a1: 89 04 24 mov %eax,(%esp)
15a4: e8 f7 fc ff ff call 12a0 <sem_down>
binary_sem_down(bb->mutex);
15a9: 8b 03 mov (%ebx),%eax
15ab: 89 04 24 mov %eax,(%esp)
15ae: e8 15 f8 ff ff call dc8 <binary_sem_down>
if(bb->buffer[bb->produce] != 0) {
15b3: 8b 43 10 mov 0x10(%ebx),%eax
15b6: c1 e0 02 shl $0x2,%eax
15b9: 03 43 0c add 0xc(%ebx),%eax
15bc: 8b 08 mov (%eax),%ecx
15be: 85 c9 test %ecx,%ecx
15c0: 74 36 je 15f8 <semaphore_put+0x68>
printf(2,"something went wrong! buffer is full and we are trying to produce\n");
15c2: c7 44 24 04 94 18 00 movl $0x1894,0x4(%esp)
15c9: 00
15ca: c7 04 24 02 00 00 00 movl $0x2,(%esp)
15d1: e8 ba f8 ff ff call e90 <printf>
}
else {
bb->produce++;
}
}
binary_sem_up(bb->mutex);
15d6: 8b 03 mov (%ebx),%eax
15d8: 89 04 24 mov %eax,(%esp)
15db: e8 f0 f7 ff ff call dd0 <binary_sem_up>
sem_up(bb->full);
15e0: 8b 43 08 mov 0x8(%ebx),%eax
15e3: 89 45 08 mov %eax,0x8(%ebp)
}
15e6: 83 c4 10 add $0x10,%esp
15e9: 5b pop %ebx
15ea: 5e pop %esi
15eb: 5d pop %ebp
else {
bb->produce++;
}
}
binary_sem_up(bb->mutex);
sem_up(bb->full);
15ec: e9 4f fd ff ff jmp 1340 <sem_up>
15f1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
binary_sem_down(bb->mutex);
if(bb->buffer[bb->produce] != 0) {
printf(2,"something went wrong! buffer is full and we are trying to produce\n");
}
else {
bb->buffer[bb->produce] = element;
15f8: 89 30 mov %esi,(%eax)
if(bb->produce == (bb->capacity - 1)) {
15fa: 8b 53 18 mov 0x18(%ebx),%edx
15fd: 8b 43 10 mov 0x10(%ebx),%eax
1600: 83 ea 01 sub $0x1,%edx
1603: 39 d0 cmp %edx,%eax
1605: 74 09 je 1610 <semaphore_put+0x80>
bb->produce = 0;
}
else {
bb->produce++;
1607: 83 c0 01 add $0x1,%eax
160a: 89 43 10 mov %eax,0x10(%ebx)
160d: eb c7 jmp 15d6 <semaphore_put+0x46>
160f: 90 nop
printf(2,"something went wrong! buffer is full and we are trying to produce\n");
}
else {
bb->buffer[bb->produce] = element;
if(bb->produce == (bb->capacity - 1)) {
bb->produce = 0;
1610: c7 43 10 00 00 00 00 movl $0x0,0x10(%ebx)
1617: eb bd jmp 15d6 <semaphore_put+0x46>
1619: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00001620 <BB_create>:
#include "user.h"
#include "semaphore.h"
#include "boundedbuffer.h"
struct BB* BB_create(int max_capacity)
{
1620: 55 push %ebp
1621: 89 e5 mov %esp,%ebp
1623: 83 ec 18 sub $0x18,%esp
1626: 89 75 fc mov %esi,-0x4(%ebp)
1629: 8b 75 08 mov 0x8(%ebp),%esi
162c: 89 5d f8 mov %ebx,-0x8(%ebp)
struct BB* ret;
if(max_capacity < 0)
162f: 85 f6 test %esi,%esi
1631: 79 15 jns 1648 <BB_create+0x28>
return 0;
ret->mutex = binary_sem_create();
ret->produce = 0;
ret->consume = 0;
ret->capacity = max_capacity;
return ret;
1633: 31 db xor %ebx,%ebx
}
1635: 89 d8 mov %ebx,%eax
1637: 8b 75 fc mov -0x4(%ebp),%esi
163a: 8b 5d f8 mov -0x8(%ebp),%ebx
163d: 89 ec mov %ebp,%esp
163f: 5d pop %ebp
1640: c3 ret
1641: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
struct BB* BB_create(int max_capacity)
{
struct BB* ret;
if(max_capacity < 0)
return 0;
if((ret = malloc(sizeof(*ret))) <=0)
1648: c7 04 24 1c 00 00 00 movl $0x1c,(%esp)
164f: e8 dc fa ff ff call 1130 <malloc>
1654: 85 c0 test %eax,%eax
1656: 89 c3 mov %eax,%ebx
1658: 74 db je 1635 <BB_create+0x15>
return 0;
if((ret->buffer = malloc(sizeof(void*) * max_capacity)) <=0)
165a: 8d 04 b5 00 00 00 00 lea 0x0(,%esi,4),%eax
1661: 89 04 24 mov %eax,(%esp)
1664: e8 c7 fa ff ff call 1130 <malloc>
1669: 85 c0 test %eax,%eax
166b: 89 43 0c mov %eax,0xc(%ebx)
166e: 74 c3 je 1633 <BB_create+0x13>
return 0;
if((ret->empty = semaphore_create(max_capacity)) <=0)
1670: 89 34 24 mov %esi,(%esp)
1673: e8 28 fd ff ff call 13a0 <semaphore_create>
1678: 85 c0 test %eax,%eax
167a: 89 43 04 mov %eax,0x4(%ebx)
167d: 74 b4 je 1633 <BB_create+0x13>
return 0;
if((ret->full = semaphore_create(0)) <=0)
167f: c7 04 24 00 00 00 00 movl $0x0,(%esp)
1686: e8 15 fd ff ff call 13a0 <semaphore_create>
168b: 85 c0 test %eax,%eax
168d: 89 43 08 mov %eax,0x8(%ebx)
1690: 74 a1 je 1633 <BB_create+0x13>
return 0;
ret->mutex = binary_sem_create();
1692: e8 29 f7 ff ff call dc0 <binary_sem_create>
ret->produce = 0;
1697: c7 43 10 00 00 00 00 movl $0x0,0x10(%ebx)
ret->consume = 0;
169e: c7 43 14 00 00 00 00 movl $0x0,0x14(%ebx)
ret->capacity = max_capacity;
16a5: 89 73 18 mov %esi,0x18(%ebx)
return 0;
if((ret->empty = semaphore_create(max_capacity)) <=0)
return 0;
if((ret->full = semaphore_create(0)) <=0)
return 0;
ret->mutex = binary_sem_create();
16a8: 89 03 mov %eax,(%ebx)
ret->produce = 0;
ret->consume = 0;
ret->capacity = max_capacity;
return ret;
16aa: eb 89 jmp 1635 <BB_create+0x15>
|
oeis/121/A121958.asm | neoneye/loda-programs | 11 | 170126 | ; A121958: Quadratic n^2-n-1 functional matrix Markov of the A001053 type.
; Submitted by <NAME>
; 0,1,1,6,67,1279,37158,1524757,83898793,5958339060,530376075133,57816950528557,7574550895316100,1174113205724524057,212522064787034170417,44418285653695866141210,10616182793298099041919607,2877029955269438536226354707,877504752539972051648080105242,299231997646085739050531542242229,113409804612619035072203102589910033,47519007364685021780992150516714546056,21906375804924407660072453591307995641849,11062767300494190553358370055761054513679801,6095606688948103919308121973177932345033212200
mov $1,1
mov $3,$0
lpb $3
mov $0,$2
mul $2,$3
add $1,$2
mul $2,$3
sub $2,$0
add $2,$1
mov $1,$0
sub $3,1
lpe
mov $0,$2
|
Tests/yasm-regression/rdrand.asm | 13xforever/x86-assembly-textmate-bundle | 69 | 161774 | [bits 64]
rdrand cx ; out: 66 0f c7 f1
rdrand ecx ; out: 0f c7 f1
rdrand rcx ; out: 48 0f c7 f1
|
progress.applescript | rinchen/fesc | 0 | 3567 | <filename>progress.applescript<gh_stars>0
on opened theObject
-- we are starting up the first time
call method "registerDefaultObjects:forKeys:" with parameters {{"Macintosh HD:Applications:freenet:", "Macintosh HD:Applications:entropy:", "Macintosh HD:Applications:samizdat:"}, {"location", "entropy", "samizdat"}}
try
--freenet status
set theResult to do shell script "ps -ax | grep freenet" as string
if theResult contains "freenet.node.main" then
tell progress indicator "progress" of window "main" to start
else
tell progress indicator "progress" of window "main" to stop
end if
--entropy status
set theResult to do shell script "ps -ax | grep entropy" as string
if theResult contains "./entropy" then
tell progress indicator "eprogress" of window "main" to start
else
tell progress indicator "eprogress" of window "main" to stop
end if
--samizdat status
set theResult to do shell script "ps -ax | grep samizdat" as string
if theResult contains "./samizdat" then
tell progress indicator "sprogress" of window "main" to start
else
tell progress indicator "sprogress" of window "main" to stop
end if
on error
display dialog "Gadzooks! I couldn't find 'ps'!!!"
end try
end opened
on became main theObject
-- we are unhiding. This is to prevent someone from canceling freenet via the terminal
try
--freenet status
set theResult to do shell script "ps -ax | grep freenet" as string
if theResult contains "freenet.node.main" then
tell progress indicator "progress" of window "main" to start
else
tell progress indicator "progress" of window "main" to stop
end if
--entropy status
set theResult to do shell script "ps -ax | grep entropy" as string
if theResult contains "./entropy" then
tell progress indicator "eprogress" of window "main" to start
else
tell progress indicator "eprogress" of window "main" to stop
end if
--samizdat status
set theResult to do shell script "ps -ax | grep samizdat" as string
if theResult contains "./samizdat" then
tell progress indicator "sprogress" of window "main" to start
else
tell progress indicator "sprogress" of window "main" to stop
end if
on error
display dialog "Gadzooks! I couldn't find 'ps'!!!"
end try
end became main
on resigned main theObject
-- if we are hiding, let's turn off the indicators to save cpu cycles
tell progress indicator "progress" of window "main" to stop
tell progress indicator "eprogress" of window "main" to stop
tell progress indicator "sprogress" of window "main" to stop
end resigned main
|
game/logic/game_states/transitions/transitions.asm | benoitryder/super-tilt-bro | 0 | 4320 | <reponame>benoitryder/super-tilt-bro<filename>game/logic/game_states/transitions/transitions.asm
state_transition_id:
.byt STATE_TRANSITION(GAME_STATE_TITLE, GAME_STATE_MODE_SELECTION)
.byt STATE_TRANSITION(GAME_STATE_MODE_SELECTION, GAME_STATE_TITLE)
.byt STATE_TRANSITION(GAME_STATE_MODE_SELECTION, GAME_STATE_CONFIG)
.byt STATE_TRANSITION(GAME_STATE_CONFIG, GAME_STATE_MODE_SELECTION)
.byt STATE_TRANSITION(GAME_STATE_TITLE, GAME_STATE_CREDITS)
.byt STATE_TRANSITION(GAME_STATE_CREDITS, GAME_STATE_TITLE)
.byt STATE_TRANSITION(GAME_STATE_CONFIG, GAME_STATE_CHARACTER_SELECTION)
.byt STATE_TRANSITION(GAME_STATE_CHARACTER_SELECTION, GAME_STATE_CONFIG)
.byt $00
state_transition_pretransition_lsb:
.byt <state_transition_pre_scroll_down
.byt <state_transition_pre_scroll_up
.byt <state_transition_pre_scroll_down
.byt <state_transition_pre_scroll_up
.byt <state_transition_pre_scroll_down
.byt <state_transition_pre_scroll_up
.byt <state_transition_pre_scroll_down
.byt <state_transition_pre_scroll_up
state_transition_pretransition_msb:
.byt >state_transition_pre_scroll_down
.byt >state_transition_pre_scroll_up
.byt >state_transition_pre_scroll_down
.byt >state_transition_pre_scroll_up
.byt >state_transition_pre_scroll_down
.byt >state_transition_pre_scroll_up
.byt >state_transition_pre_scroll_down
.byt >state_transition_pre_scroll_up
state_transition_posttransition_lsb:
.byt <state_transition_post_scroll_down
.byt <state_transition_post_scroll_up
.byt <state_transition_post_scroll_down
.byt <state_transition_post_scroll_up
.byt <state_transition_post_scroll_down
.byt <state_transition_post_scroll_up
.byt <state_transition_post_scroll_down
.byt <state_transition_post_scroll_up
state_transition_posttransition_msb:
.byt >state_transition_post_scroll_down
.byt >state_transition_post_scroll_up
.byt >state_transition_post_scroll_down
.byt >state_transition_post_scroll_up
.byt >state_transition_post_scroll_down
.byt >state_transition_post_scroll_up
.byt >state_transition_post_scroll_down
.byt >state_transition_post_scroll_up
#include "game/logic/game_states/transitions/scroll_transition.asm"
|
Quark.g4 | alanbato/quark | 4 | 5751 | grammar Quark;
@header {
from Compiler import Compiler
c = Compiler()
quadruples = None
func_directory = None
type_directory = None
constants = None
}
ID:[a-z][a-zA-Z0-9_]*;
TYPE_ID: [A-Z][a-zA-Z0-9_]*;
CONST_I: [0-9]+;
CONST_F: [0-9]+ [.][0-9]+;
STRING: ["].*? ["];
SPACE: [\t\r\f\n ]+ -> skip;
function:
'def' ID {c.define_function($ID.text)} '(' params ')' '->' typeRule {
c.set_function_return_type($ID.text, $typeRule.text)
} '{' (cond '{' block '}' {c.process_function_clause()})* 'default {' block '}' {c.process_default_clause()
} '}' {c.process_function_end()
};
params:
ID ':' typeRule {c.process_param($ID.text, $typeRule.text)} moreparams;
moreparams:
',' ID ':' typeRule {c.process_param($ID.text, $typeRule.text)}
|;
moreTypes: ',' typeRule |;
typeRule:
TYPE_ID {c.check_user_def_type($TYPE_ID.text)} # UserType
| 'Int' '?'? # Int
| 'Bool' '?'? # Boolean
| 'Float' '?'? # Float
| 'String' '?'? # String
| 'non' # None
| 'Any' # Any
| '[' typeRule moreTypes ']' # ListOfType;
typevalue: typeRule | typeset;
typedef:
'type' TYPE_ID '<-' typevalue {c.define_type($TYPE_ID.text)};
typeset: '(' typeRule ('|' typeRule)* ')';
cond: '(' expression (',' expression)* ')' {c.condition()};
expression: comp (comp exp)*;
comp:
exp (
(
'>' {c.add_operator('>')}
| '<' {c.add_operator('<')}
| '=' {c.add_operator('=')}
| '>=' {c.add_operator('>=')}
| '<=' {c.add_operator('<=')}
| '!=' {c.add_operator('!=')}
) exp {c.handle_math_operation(">", "<", "=", ">=", "<=", "!=")}
)*;
exp:
term (
('+' {c.add_operator('+')} | '-' {c.add_operator('-')}) term {c.handle_math_operation("+", "-")
}
)*;
term:
factor (
(
'*' {c.add_operator('*')}
| '/' {c.add_operator('/')}
| '%' {c.add_operator('%')}
) factor {c.handle_math_operation("*", "/", "%")}
)*;
factor:
varconst # Positive
| '(-' {c.set_negative()} varconst ')' # Negative
| '(' {c.start_parens()} expression ')' {c.end_parens()} # Parens
| 'True' {c.get_literal(True, "Bool")} # True
| 'False' {c.get_literal(False, "Bool")} # False
| 'non' {c.get_literal('non', "non")} # False
| STRING {c.get_literal($STRING.text, "String")} # StringLiteral
| '[' {c.start_list()} expression {c.create_first(); c.add_to_list()}
(',' expression {c.add_to_list()} )*
']' {c.end_list()} # ListLiteral
| '[' {c.start_list()} ']' {c.end_list()} # EmptyList;
varconst:
func_call
| ID {c.get_variable($ID.text)}
| CONST_I {c.get_literal($CONST_I.text, "Int")}
| CONST_F {c.get_literal($CONST_F.text, "Float")};
block: statement (statement)*;
statement: assignment ';' | expression ';';
func_call:
ID {c.check_function($ID.text)} '(' expression? (
',' expression
)* ')' {c.call_function($ID.text)
};
assignment:
typeRule ID '<-' expression {c.handle_assignment($ID.text, $typeRule.text)};
main: things morethings {c.save_state(self)} EOF;
things:
function
| assignment ';'
| expression ';'
| typedef ';';
morethings: things morethings |;
|
src/Formula.g4 | constcut/spreadsheet_cpp | 0 | 4051 | grammar Formula;
main
: expr EOF
;
expr
: '(' expr ')' # Parens
| (ADD | SUB) expr # UnaryOp
| expr (MUL | DIV) expr # BinaryOp
| expr (ADD | SUB) expr # BinaryOp
| CELL # Cell
| NUMBER # Literal
;
// number literals cannot be signed, or else 1-2 would be lexed as [1] [-2]
fragment INT: [-+]? UINT ;
fragment UINT: [0-9]+ ;
fragment EXPONENT: [eE] INT;
NUMBER
: UINT EXPONENT?
| UINT? '.' UINT EXPONENT?
;
ADD: '+' ;
SUB: '-' ;
MUL: '*' ;
DIV: '/' ;
CELL: [A-Z]+[0-9]+ ;
WS: [ \t\n\r]+ -> skip ;
|
Task/Percentage-difference-between-images/Ada/percentage-difference-between-images-3.ada | LaudateCorpus1/RosettaCodeData | 1 | 3570 | function "-" (Left, Right : Pixel) return Count is
begin
return (Left.R - Right.R) + (Left.G - Left.G) + (Left.B - Right.B);
end "-";
|
136/ada/greet_5a_reverse.adb | notdb/LC-Practice | 0 | 24906 | with Ada.Text_IO; use Ada.Text_IO;
procedure Greet_5a_Reverse is
begin
for I in reverse 1 .. 5 loop
Put_Line ("Hello, World!" & Integer'Image (I));
end loop;
end Greet_5a_Reverse; |
programs/oeis/175/A175604.asm | neoneye/loda | 22 | 167441 | <filename>programs/oeis/175/A175604.asm<gh_stars>10-100
; A175604: a(n) = 8*(10^n-7).
; 24,744,7944,79944,799944,7999944,79999944,799999944,7999999944,79999999944,799999999944,7999999999944,79999999999944,799999999999944,7999999999999944,79999999999999944,799999999999999944,7999999999999999944,79999999999999999944,799999999999999999944,7999999999999999999944,79999999999999999999944,799999999999999999999944,7999999999999999999999944,79999999999999999999999944,799999999999999999999999944,7999999999999999999999999944,79999999999999999999999999944,799999999999999999999999999944,7999999999999999999999999999944,79999999999999999999999999999944,799999999999999999999999999999944,7999999999999999999999999999999944,79999999999999999999999999999999944,799999999999999999999999999999999944
add $0,1
mov $1,10
pow $1,$0
sub $1,6
mul $1,4
div $1,12
mul $1,24
mov $0,$1
|
src/numerics-sparse_matrices-remove_duplicates.adb | sciencylab/lagrangian-solver | 0 | 3614 | <gh_stars>0
separate (Numerics.Sparse_Matrices)
procedure Remove_Duplicates (Mat : in out Sparse_Matrix) is
N, Iter : Pos := 0;
J : Int_Array (1 .. Nat (Mat.P.Length)) := (others => 0);
I : Int_Array (1 .. Pos (Mat.I.Length));
X : Real_Vector (1 .. Pos (Mat.X.Length));
begin
for K in 1 .. Nat (Mat.P.Length) - 1 loop
Iter := 0;
for L in Mat.P (K) .. Mat.P (K + 1) - 1 loop
if Iter /= Mat.I (L) then
N := N + 1;
Iter := Mat.I (L);
I (N) := Iter;
J (K) := J (K) + 1;
X (N) := Mat.X (L);
else
X (N) := X (N) + Mat.X (L);
end if;
end loop;
end loop;
Cumulative_Sum (J);
Set (Mat.I, I (1 .. N));
Set (Mat.X, X (1 .. N));
Set (Mat.P, J);
end Remove_Duplicates;
|
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/addr6.adb | best08618/asylo | 7 | 21738 | <gh_stars>1-10
-- { dg-do compile }
procedure Addr6 is
type Byte is mod 2**8;
type Byte_Arr1 is array (Positive range <>) of Byte;
for Byte_Arr1'Alignment use 4;
type Byte_Arr2 is array (Positive range <>) of Byte;
function Length return Natural is
begin
return 1;
end;
function Empty return Byte_Arr2 is
Null_Arr : Byte_Arr2 (1 .. 0);
begin
return Null_Arr;
end;
A1 : Byte_Arr1 (1 .. Length);
A2 : Byte_Arr2 (A1'Range);
for A2'Alignment use 4;
for A2'Address use A1'Address;
begin
A2 := Empty;
end;
|
programs/oeis/004/A004930.asm | karttu/loda | 1 | 241516 | <reponame>karttu/loda
; A004930: Floor of n*phi^15, where phi is the golden ratio, A001622.
; 0,1364,2728,4092,5456,6820,8184,9548,10912,12276,13640,15004,16368,17732,19096,20460,21824,23188,24552,25916,27280,28644,30008,31372,32736,34100,35464,36828,38192
mov $1,$0
mul $1,1364
|
coverage/IN_CTS/0570-COVERAGE-constant-folding-1830-2496/work/variant/1_spirv_asm/shader.frag.asm | asuonpaa/ShaderTests | 0 | 27360 | ; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 10
; Bound: 95
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %4 "main" %76
OpExecutionMode %4 OriginUpperLeft
OpSource ESSL 320
OpName %4 "main"
OpName %8 "_GLF_global_loop_count"
OpName %11 "a"
OpName %15 "buf0"
OpMemberName %15 0 "_GLF_uniform_int_values"
OpName %17 ""
OpName %33 "i"
OpName %36 "buf1"
OpMemberName %36 0 "injectionSwitch"
OpName %38 ""
OpName %76 "_GLF_color"
OpDecorate %14 ArrayStride 16
OpMemberDecorate %15 0 Offset 0
OpDecorate %15 Block
OpDecorate %17 DescriptorSet 0
OpDecorate %17 Binding 0
OpMemberDecorate %36 0 Offset 0
OpDecorate %36 Block
OpDecorate %38 DescriptorSet 0
OpDecorate %38 Binding 1
OpDecorate %76 Location 0
%2 = OpTypeVoid
%3 = OpTypeFunction %2
%6 = OpTypeInt 32 1
%7 = OpTypePointer Private %6
%8 = OpVariable %7 Private
%9 = OpConstant %6 0
%10 = OpTypePointer Function %6
%12 = OpTypeInt 32 0
%13 = OpConstant %12 4
%14 = OpTypeArray %6 %13
%15 = OpTypeStruct %14
%16 = OpTypePointer Uniform %15
%17 = OpVariable %16 Uniform
%18 = OpConstant %6 1
%19 = OpTypePointer Uniform %6
%28 = OpConstant %6 10
%29 = OpTypeBool
%34 = OpTypeFloat 32
%35 = OpTypeVector %34 2
%36 = OpTypeStruct %35
%37 = OpTypePointer Uniform %36
%38 = OpVariable %37 Uniform
%39 = OpConstant %12 1
%40 = OpTypePointer Uniform %34
%44 = OpTypeVector %6 2
%46 = OpConstantComposite %44 %9 %9
%51 = OpConstant %12 0
%59 = OpConstant %6 2
%68 = OpConstant %6 3
%74 = OpTypeVector %34 4
%75 = OpTypePointer Output %74
%76 = OpVariable %75 Output
%4 = OpFunction %2 None %3
%5 = OpLabel
%11 = OpVariable %10 Function
%33 = OpVariable %10 Function
OpStore %8 %9
%20 = OpAccessChain %19 %17 %9 %18
%21 = OpLoad %6 %20
OpStore %11 %21
OpBranch %22
%22 = OpLabel
OpLoopMerge %24 %25 None
OpBranch %26
%26 = OpLabel
%27 = OpLoad %6 %8
%30 = OpSLessThan %29 %27 %28
OpBranchConditional %30 %23 %24
%23 = OpLabel
%31 = OpLoad %6 %11
%32 = OpIAdd %6 %31 %18
OpStore %11 %32
%41 = OpAccessChain %40 %38 %9 %39
%42 = OpLoad %34 %41
%43 = OpConvertFToS %6 %42
%45 = OpCompositeConstruct %44 %18 %43
%47 = OpAccessChain %19 %17 %9 %9
%48 = OpLoad %6 %47
%49 = OpCompositeConstruct %44 %48 %48
%50 = OpExtInst %44 %1 SClamp %45 %46 %49
%52 = OpCompositeExtract %6 %50 0
OpStore %33 %52
OpBranch %53
%53 = OpLabel
OpLoopMerge %55 %56 None
OpBranch %57
%57 = OpLabel
%58 = OpLoad %6 %33
%60 = OpAccessChain %19 %17 %9 %59
%61 = OpLoad %6 %60
%62 = OpSLessThan %29 %58 %61
OpBranchConditional %62 %54 %55
%54 = OpLabel
%63 = OpLoad %6 %8
%64 = OpIAdd %6 %63 %18
OpStore %8 %64
OpBranch %56
%56 = OpLabel
%65 = OpLoad %6 %33
%66 = OpIAdd %6 %65 %18
OpStore %33 %66
OpBranch %53
%55 = OpLabel
OpBranch %25
%25 = OpLabel
OpBranch %22
%24 = OpLabel
%67 = OpLoad %6 %11
%69 = OpAccessChain %19 %17 %9 %68
%70 = OpLoad %6 %69
%71 = OpIEqual %29 %67 %70
OpSelectionMerge %73 None
OpBranchConditional %71 %72 %90
%72 = OpLabel
%77 = OpAccessChain %19 %17 %9 %9
%78 = OpLoad %6 %77
%79 = OpConvertSToF %34 %78
%80 = OpAccessChain %19 %17 %9 %18
%81 = OpLoad %6 %80
%82 = OpConvertSToF %34 %81
%83 = OpAccessChain %19 %17 %9 %18
%84 = OpLoad %6 %83
%85 = OpConvertSToF %34 %84
%86 = OpAccessChain %19 %17 %9 %9
%87 = OpLoad %6 %86
%88 = OpConvertSToF %34 %87
%89 = OpCompositeConstruct %74 %79 %82 %85 %88
OpStore %76 %89
OpBranch %73
%90 = OpLabel
%91 = OpAccessChain %19 %17 %9 %18
%92 = OpLoad %6 %91
%93 = OpConvertSToF %34 %92
%94 = OpCompositeConstruct %74 %93 %93 %93 %93
OpStore %76 %94
OpBranch %73
%73 = OpLabel
OpReturn
OpFunctionEnd
|
list_iface/src/lists-fixed.adb | gerr135/ada_gems | 6 | 24371 | package body Lists.fixed is
overriding
function List_Constant_Reference (Container : aliased in List; Position : Cursor) return Constant_Reference_Type is
CR : Constant_Reference_Type(Container.data(Position.Index)'Access);
begin
return CR;
end;
overriding
function List_Constant_Reference (Container : aliased in List; Index : in Index_Type) return Constant_Reference_Type is
CR : Constant_Reference_Type(Container.data(Index)'Access);
begin
return CR;
end;
overriding
function List_Reference (Container : aliased in out List; Position : Cursor) return Reference_Type is
R : Reference_Type(Container.data(Position.Index)'Access);
begin
return R;
end;
overriding
function List_Reference (Container : aliased in out List; Index : in Index_Type) return Reference_Type is
R : Reference_Type(Container.data(Index)'Access);
begin
return R;
end;
overriding
function Iterate (Container : in List) return Iterator_Interface'Class is
It : Iterator := (Container'Unrestricted_Access, Index_Base'First);
begin
return It;
end;
function Has_Element (L : List; Position : Index_Base) return Boolean is
-- Iterators are unrolled into calling First/Last to assign index
-- and then increment/decrement it inside a "while Has_Element(Cursor)" loop
-- So we simply check if our index passed outside boundaries..
begin
return (Position >= L.data'First) and (Position <= L.Last);
end;
overriding
function First (Object : Iterator) return Cursor is
C : Cursor := (Object.Container, Index_Type'First);
begin
return C;
end;
overriding
function Last (Object : Iterator) return Cursor is
C : Cursor := (Object.Container, List(Object.Container.all).Last);
begin
return C;
end;
overriding
function Next (Object : Iterator; Position : Cursor) return Cursor is
C : Cursor := (Object.Container, Position.Index + 1);
begin
return C;
end;
overriding
function Previous (Object : Iterator; Position : Cursor) return Cursor is
C : Cursor := (Object.Container, Position.Index - 1);
begin
return C;
end;
end Lists.fixed;
|
Automaton/Pushdown.agda | Lolirofle/stuff-in-agda | 6 | 11541 | <reponame>Lolirofle/stuff-in-agda<gh_stars>1-10
module Automaton.Pushdown where
|
smsq/sbas/turbo.asm | olifink/smsqe | 0 | 174818 | <gh_stars>0
; Turbo Patch(es) 1993 <NAME>
section uq
xdef sb_pturbo
xref sb_litem
include 'dev8_keys_qdos_sms'
include 'dev8_keys_sys'
include 'dev8_keys_sbasic'
include 'dev8_keys_68000'
sbpt_name dc.w 13,'BASIC_POINTER'
sbpt_code moveq #sms.info,d0 ; get SB vars via SuperBASIC base
trap #do.sms2
sbpt_old
move.l sys_sbab(a0),a0
lea sb_offs(a0),a0
rts
sbpt_repl moveq #sms.info,d0 ; get SB vars via Job 0
trap #do.sms2
; @@@@@ tst.l d1 ; actually job 0?
; @@@@@ beq.s sbpt_old ; ... yes, use old code
move.l sys_jbtb(a0),a0
move.l (a0),a0
lea sb_vars(a0),a0
rts
;+++
; Patch Turbo TK
;
; a6 c p pointer to SBASIC area
;
; status return standard
;---
sb_pturbo
lea sbpt_name+1,a1 ; locate "BASIC_POINTER"
jsr sb_litem
ble.s sbpt_done
lea $200(a1),a0 ; search range
movem.l sbpt_code,d1/d2/d3 ; search pattern
sbpt_swap
swap d1
sbpt_check
cmp.l a0,a1 ; end of search?
bge.s sbpt_done ; ... yes
cmp.w (a1)+,d1 ; match?
bne.s sbpt_check ; ... no
swap d1 ; try other half
cmp.w (a1),d1 ; match?
bne.s sbpt_swap ; ... no
cmp.l 2(a1),d2 ; 2nd long word?
bne.s sbpt_swap ; ... no match
cmp.l 6(a1),d3 ; 3nd long word?
bne.s sbpt_swap ; ... no match
lea sbpt_repl,a0 ; replacement code address
move.l a0,(a1)
move.w #jmp.l,-(a1) ; and jump
sbpt_done
moveq #0,d0
rts
end
|
lemmas/saatana-crypto-lemmas.ads | HeisenbugLtd/Saatana | 10 | 19032 | <gh_stars>1-10
------------------------------------------------------------------------------
-- Copyright (C) 2020 by Heisenbug Ltd. (<EMAIL>)
--
-- This work is free. You can redistribute it and/or modify it under the
-- terms of the Do What The Fuck You Want To Public License, Version 2,
-- as published by Sam Hocevar. See the LICENSE file for more details.
------------------------------------------------------------------------------
pragma License (Unrestricted);
private package Saatana.Crypto.Lemmas with
SPARK_Mode => On
is
--
-- Prove additional properties of the types declared in the parent
-- package.
--
-- These proofs are not actively used anywhere, but they should help
-- building confidence in the correctness of certain subprograms.
---------------------------------------------------------------------
-- Stream conversions
---------------------------------------------------------------------
-- Fully prove bijectivity of conversion subprogram(s).
-- Part I
-- Converting a Word_32 into a stream representation and converting
-- the stream back into a Word_32 should result in the same value.
pragma Assert (for all W in Word_32'Range =>
To_Unsigned (General_Stream'(To_Stream (W))) = W);
-- Part II
-- The inverse of the above is harder to accomplish, because there
-- seems no easy way to write a quantifiying expression for
-- different length arrays (at least none of the ones I could think
-- of are less complex than the relatively simple five different
-- expressions below).
-- Luckily, the number of possibilities here is low, so let's simply
-- prove all cases one by one.
-- Proof for Stream'Length = 4
pragma Assert (for all A in Byte =>
(for all B in Byte =>
(for all C in Byte =>
(for all D in Byte =>
General_Stream'(To_Stream (To_Unsigned (General_Stream'(0 => A, 1 => B, 2 => C, 3 => D)))) =
General_Stream'(0 => A, 1 => B, 2 => C, 3 => D)))));
-- Proof for Stream'Length = 3
pragma Assert (for all A in Byte =>
(for all B in Byte =>
(for all C in Byte =>
General_Stream'(To_Stream (To_Unsigned (General_Stream'(0 => A, 1 => B, 2 => C)))) =
General_Stream'(0 => A, 1 => B, 2 => C, 3 => 0))));
-- Proof for Stream'Length = 2
pragma Assert (for all A in Byte =>
(for all B in Byte =>
General_Stream'(To_Stream (To_Unsigned (General_Stream'(0 => A, 1 => B)))) =
General_Stream'(0 => A, 1 => B, 2 .. 3 => 0)));
-- Proof for Stream'Length = 1
pragma Assert (for all A in Byte =>
General_Stream'(To_Stream (To_Unsigned (General_Stream'(0 => A)))) =
General_Stream'(0 => A, 1 .. 3 => 0));
-- Proof for Stream'Length = 0 (i.e. the empty stream).
pragma Assert (General_Stream'(To_Stream (To_Unsigned (General_Stream'(1 .. 0 => 0)))) =
General_Stream'(0 .. 3 => 0));
end Saatana.Crypto.Lemmas;
|
agda/hott/topology/theorems.agda | piyush-kurur/hott | 0 | 6327 | <reponame>piyush-kurur/hott
module hott.topology.theorems where
open import hott.topology
open import hott.topology.loopspace.theorems public
|
oeis/121/A121289.asm | neoneye/loda-programs | 11 | 2481 | <reponame>neoneye/loda-programs
; A121289: a(n) = n/(largest triangular number dividing n).
; Submitted by <NAME>
; 0,1,2,1,4,5,1,7,8,3,1,11,2,13,14,1,16,17,3,19,2,1,22,23,4,25,26,9,1,29,2,31,32,11,34,35,1,37,38,13,4,41,2,43,44,1,46,47,8,49,5,17,52,53,9,1,2,19,58,59,4,61,62,3,64,65,1,67,68,23,7,71,2,73,74,5,76,77,1,79,8,27,82
mov $1,1
mov $2,$0
mov $3,1
mov $4,1
lpb $2
add $3,1
add $4,$3
mov $5,$0
mod $5,$4
cmp $5,0
mov $6,$4
sub $6,$1
mul $6,$5
add $1,$6
mov $5,$0
add $5,1
trn $5,$4
cmp $5,0
cmp $5,0
sub $2,$5
lpe
div $0,$1
|
A01/input2.asm | HeptaDecane/SPOSL_SEM6 | 0 | 101646 | START 100
A DS 3
L1 MOVER AREG B
ADD AREG C
MOVEM BREG ='10'
LTORG
C DC '5'
B DC '19'
END |
g-catiio.ads | ytomino/gnat4drake | 0 | 12937 | <filename>g-catiio.ads
pragma License (Unrestricted);
package GNAT.Calendar.Time_IO is
type Picture_String is new String;
ISO_Date : constant Picture_String := "%Y-%m-%d";
function Image (Date : Ada.Calendar.Time; Picture : Picture_String)
return String;
function Value (Date : String) return Ada.Calendar.Time;
end GNAT.Calendar.Time_IO;
|
hello_world_alternative.asm | badcf00d/BIOS-helloworld | 0 | 82541 | <reponame>badcf00d/BIOS-helloworld<gh_stars>0
; Example to print hello world to the screen from the BIOS
;
; Can be used with:
; nasm -f bin hello_world_alternative.asm -o hello_world.img
; qemu-system-x86_64 -hda hello_world.img
;
bits 16
org 0x7c00
msg: db "Hello world"
msglen equ $-msg
mov ah, 0x13 ; write string mode for bios video services
mov al, 1 ; write mode 1, increment cursor & attributes in BL
mov bl, 7 ; BIOS color attributes, 7 is light gray, low nibble is forground, high is background
mov dh, 10 ; row
mov dl, 0 ; column
mov bp, msg ; base pointer to string
mov cx, msglen ; length of string
int 0x10 ; call bios video services
hlt ; halt
times 510-($-$$) db 0
dw 0xaa55
|
pgada-database.ads | io7m/coreland-postgres-ada | 1 | 16069 | ------------------------------------------------------------------------------
-- --
-- P G A D A . D A T A B A S E --
-- --
-- S p e c --
-- --
-- Copyright (c) <NAME> 2000 --
-- 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. Neither the name of <NAME> 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 SAMUEL TARDIEU 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 SAMUEL --
-- TARDIEU OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, --
-- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES --
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR --
-- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) --
-- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN --
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR --
-- OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, --
-- EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with Ada.Finalization;
with PGAda.Errors;
with PGAda.Thin;
package PGAda.Database is
pragma Preelaborate;
PG_Error : exception;
type Connection_t is
new Ada.Finalization.Limited_Controlled with private;
subtype Error_Field is PGAda.Thin.Error_Field;
procedure Set_DB_Login
(Connection : in out Connection_t;
Host : in String := "";
Port : in Natural := 0;
Options : in String := "";
TTY : in String := "";
DB_Name : in String := "";
Login : in String := "";
Password : in String := "");
-- Connect to a database
function DB (Connection : Connection_t) return String;
function Host (Connection : Connection_t) return String;
function Port (Connection : Connection_t) return Positive;
function Options (Connection : Connection_t) return String;
-- Query characteristics of an open connection
type Connection_Status_t is (Connection_OK, Connection_Bad);
function Status (Connection : Connection_t)
return Connection_Status_t;
function Error_Message (Connection : Connection_t) return String;
procedure Finish (Connection : in out Connection_t);
procedure Reset (Connection : in Connection_t);
type Result_t is
new Ada.Finalization.Controlled with private;
type Exec_Status_t is
(Empty_Query,
Command_OK,
Tuples_OK,
Copy_Out,
Copy_In,
Bad_Response,
Non_Fatal_Error,
Fatal_Error);
procedure Exec
(Connection : in Connection_t'Class;
Query : in String;
Result : out Result_t;
Status : out Exec_Status_t);
procedure Exec
(Connection : in Connection_t'Class;
Query : in String;
Result : out Result_t);
-- Note: the Connection parameter is of type Connection_t'Class
-- because this function cannot be a primitive operation of several
-- tagged types.
function Error_Message (Result : Result_t) return String;
function Exec
(Connection : Connection_t'Class;
Query : String) return Result_t;
-- Function form of the subprogram
procedure Exec
(Connection : in Connection_t'Class;
Query : in String);
-- This procedure executes the query but does not test the result. It
-- can be used for queries that do not require a result and cannot fail.
function Result_Status (Result : Result_t) return Exec_Status_t;
function Error_Code (Result : Result_t) return PGAda.Errors.Error_Value_t;
function Result_Error_Field
(Result : Result_t;
Field : Error_Field) return String;
function Nbr_Tuples (Result : Result_t) return Natural;
function Number_Of_Tuples (Result : Result_t)
return Natural renames Nbr_Tuples;
function Nbr_Fields (Result : Result_t) return Natural;
function Number_Of_Fields (Result : Result_t)
return Natural renames Nbr_Fields;
function Field_Name
(Result : Result_t;
Field_Index : Positive) return String;
function Get_Value
(Result : Result_t;
Tuple_Index : Positive;
Field_Index : Positive) return String;
function Get_Value
(Result : Result_t;
Tuple_Index : Positive;
Field_Name : String) return String;
function Get_Value
(Result : Result_t;
Tuple_Index : Positive;
Field_Index : Positive) return Integer;
function Get_Value
(Result : Result_t;
Tuple_Index : Positive;
Field_Name : String) return Integer;
function Get_Value
(Result : Result_t;
Tuple_Index : Positive;
Field_Index : Positive) return Long_Integer;
function Get_Value
(Result : Result_t;
Tuple_Index : Positive;
Field_Name : String) return Long_Integer;
function Get_Value
(Result : Result_t;
Tuple_Index : Positive;
Field_Index : Positive) return Long_Long_Integer;
function Get_Value
(Result : Result_t;
Tuple_Index : Positive;
Field_Name : String) return Long_Long_Integer;
function Get_Length
(Result : Result_t;
Tuple_Index : Positive;
Field_Index : Positive) return Natural;
function Is_Null
(Result : Result_t;
Tuple_Index : Positive;
Field_Index : Positive) return Boolean;
function Command_Status (Result : Result_t) return String;
function Command_Tuples (Result : Result_t) return String;
function OID_Status (Result : Result_t) return String;
procedure Clear (Result : in out Result_t);
private
type Connection_t is new Ada.Finalization.Limited_Controlled with record
Actual : Thin.PG_Conn_Access_t;
end record;
procedure Finalize (Connection : in out Connection_t);
type Natural_Access_t is access Natural;
type Result_t is new Ada.Finalization.Controlled with record
Actual : Thin.PG_Result_Access_t;
Ref_Count : Natural_Access_t := new Integer'(1);
end record;
procedure Adjust (Result : in out Result_t);
procedure Finalize (Result : in out Result_t);
end PGAda.Database;
|
Application Support/BBEdit/Packages/dStyle.bbpackage/Contents/Scripts/Selection/Text bigger.applescript | bhdicaire/bbeditSetup | 0 | 4176 | <gh_stars>0
tell application "BBEdit"
local dfs
set dfs to display font size of text window 1
set dfs to dfs + 1
set display font size of text window 1 to dfs
end tell |
source/utility/astack.asm | paulscottrobson/lean | 2 | 168827 | <reponame>paulscottrobson/lean
; ******************************************************************************
; ******************************************************************************
;
; Name : astack.asm
; Purpose : Utility routines for compiler stack
; Author : <NAME> (<EMAIL>)
; Created : 27th October 2019
;
; ******************************************************************************
; ******************************************************************************
; ******************************************************************************
;
; Reset the compiler stack
;
; ******************************************************************************
StackReset:
set16 aStackPtr,assemblerStack
lda #SCM_TOP
sta (aStackPtr)
rts
; ******************************************************************************
;
; Push current compile code PC on the stack
;
; ******************************************************************************
StackPushPC:
lda codeBank
jsr StackPush
lda codePtr
jsr StackPush
lda codePtr+1
jsr StackPush
rts
; ******************************************************************************
;
; Push A on the return stack
;
; ******************************************************************************
StackPush:
dec aStackPtr ; decrement TOS pointer.
beq _SPStack
sta (aStackPtr) ; write to new TOS
rts
_SPStack:
derror "RETURN STACK"
; ******************************************************************************
;
; Check top of stack = A
;
; ******************************************************************************
StackCheckStructureMarker:
cmp (aStackPtr) ; check if tos matches
bne _SCSError
rts
_SCSError:
derror "STRUCTURES"
; ******************************************************************************
;
; Compile <opcode>A to address (aStack),y as a 6502 Branch
;
; ******************************************************************************
StackCompileBranch:
pha
phx
phy
jsr CodeWriteByte ; write the opcode.
;
iny
lda (aStackPtr),y
tax
dey
lda (aStackPtr),y
tay
jsr CodeWriteBranch ; write a branch there.
ply
plx
pla
rts
; ******************************************************************************
;
; Pop A bytes off Return Stack
;
; ******************************************************************************
StackPopStack:
clc ; return stack all in same page
adc aStackPtr ; so we don't carry out.
sta aStackPtr
rts
|
fio.nasm | fasync/Syndicate | 1 | 17449 | ;; Copyright (c) 2020, <NAME>
;; All rights reserved.
;;
;; Redistribution and use in source and binary forms, with or without
;; modification, are permitted provided that the following conditions are met:
;; 1. Redistributions of source code must retain the above copyright
;; notice, this list of conditions and the following disclaimer.
;;
;; 2. Redistributions in binary form must reproduce the above copyright notice,
;; this list of conditions and the following disclaimer in the
;; documentation and/or other materials provided with the distribution.
;;
;; THIS SOFTWARE IS PROVIDED BY <copyright holder> ''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 <copyright holder> BE LIABLE FOR ANY
;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
;; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
;; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
;; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;; fio.inc
;; Routines to find the kernel on a FAT32 partition
%include "fat32.nasm"
;; ----------------------------------------------------------
;; Find the kernel on a FAT32 drive
;; ----------------------------------------------------------
detect_kern:
push ax
push bx
push cx
call prepare_fs ; Preparing the bootloader to read the FAT32 drive
;; Getting file informations
mov di, 0x0200 + 0x20 ; Get first file entry
mov dx, WORD[di + 0x001A] ; Offset of the file entry
mov WORD[__cluster], dx
;; Preparing kernel location
mov ax, 0x0100 ; Location
mov es, ax ; Setting extra segment
xor bx, bx
;; Reading kernel cluster
mov cx, 0x0008
mov ax, WORD[__cluster]
call _lba_conv
call _read_disk_sectors
pop cx
pop bx
pop ax
ret
__cluster: dw 0x0000
|
ffight/lcs/boss/3F.asm | zengfr/arcade_game_romhacking_sourcecode_top_secret_data | 6 | 246278 | copyright zengfr site:http://github.com/zengfr/romhack
003CDE move.b #$3, ($3f,A3) [boss+3C]
003CE4 sub.w D5, ($18,A3) [boss+3F]
007340 move.b ($b,A2), ($3f,A3) [boss+16, enemy+16]
007346 bmi $746c [boss+3F, enemy+3F]
03ED34 move.b #$4, ($3,A6) [boss+3F]
copyright zengfr site:http://github.com/zengfr/romhack
|
source/amf/uml/amf-standard_profile_l2-sources-collections.ads | svn2github/matreshka | 24 | 8435 | ------------------------------------------------------------------------------
-- --
-- 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$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Generic_Collections;
package AMF.Standard_Profile_L2.Sources.Collections is
pragma Preelaborate;
package Standard_Profile_L2_Source_Collections is
new AMF.Generic_Collections
(Standard_Profile_L2_Source,
Standard_Profile_L2_Source_Access);
type Set_Of_Standard_Profile_L2_Source is
new Standard_Profile_L2_Source_Collections.Set with null record;
Empty_Set_Of_Standard_Profile_L2_Source : constant Set_Of_Standard_Profile_L2_Source;
type Ordered_Set_Of_Standard_Profile_L2_Source is
new Standard_Profile_L2_Source_Collections.Ordered_Set with null record;
Empty_Ordered_Set_Of_Standard_Profile_L2_Source : constant Ordered_Set_Of_Standard_Profile_L2_Source;
type Bag_Of_Standard_Profile_L2_Source is
new Standard_Profile_L2_Source_Collections.Bag with null record;
Empty_Bag_Of_Standard_Profile_L2_Source : constant Bag_Of_Standard_Profile_L2_Source;
type Sequence_Of_Standard_Profile_L2_Source is
new Standard_Profile_L2_Source_Collections.Sequence with null record;
Empty_Sequence_Of_Standard_Profile_L2_Source : constant Sequence_Of_Standard_Profile_L2_Source;
private
Empty_Set_Of_Standard_Profile_L2_Source : constant Set_Of_Standard_Profile_L2_Source
:= (Standard_Profile_L2_Source_Collections.Set with null record);
Empty_Ordered_Set_Of_Standard_Profile_L2_Source : constant Ordered_Set_Of_Standard_Profile_L2_Source
:= (Standard_Profile_L2_Source_Collections.Ordered_Set with null record);
Empty_Bag_Of_Standard_Profile_L2_Source : constant Bag_Of_Standard_Profile_L2_Source
:= (Standard_Profile_L2_Source_Collections.Bag with null record);
Empty_Sequence_Of_Standard_Profile_L2_Source : constant Sequence_Of_Standard_Profile_L2_Source
:= (Standard_Profile_L2_Source_Collections.Sequence with null record);
end AMF.Standard_Profile_L2.Sources.Collections;
|
base/mvdm/wow16/drivers/comm/ibmcom1.asm | npocmaka/Windows-Server-2003 | 17 | 8974 | <filename>base/mvdm/wow16/drivers/comm/ibmcom1.asm
page
;---------------------------Module-Header-------------------------------;
; Module Name: IBMCOM1.ASM
;
; Copyright (c) Microsoft Corporation 1985-1990. All Rights Reserved.
;
;----------------------------Private-Routine----------------------------;
;
; DoLPT - Do Function To LPT port
;
; The given function (output or reset) is performed to the
; passed LPT port.
;
; Before a character is sent, a check is made to see if the device
; will be able to accept the character. If it can, then the character
; will be sent. If not, then an error will be returned. If the
; printer is selected and busy and no error, then the code returned
; will be CE_TXFULL and the handshake bits will be set in HSFlag
; to simulate that a handshake was received.
;
; If the BIOS ROM code is examined, you will note that they wait for
; the busy character from the last charcater to be cleared before
; they strobe in the current character. This can take a long time
; on the standard EPSON class printer (1 mSec to greater than
; 300 mSec if the last character actually caused printing).
;
; Because of this, several status read retrys will be made before
; declaring that the device is actually busy. If only one status
; read is performed, the spooler will yeild, take a while to get
; back here, and things will be really slow. What difference does
; it really make if we or the BIOS does the delay, at least we can
; break out of it at some point when it seems hopeless.
;
; The OKIHACK: Okidata reports a 50 ns. 2.2 volt pulse on the paper
; out signal on the trailing edge of the Busy signal. If we see this
; glitch then we report paper out. So we try to get the status twice...
; if it changes between the two tries we keep getting the status.
;
;
; Entry:
; AH = cid
; AL = character to output
; CH = Function request. 0 = Output, 1 = Initialize, 2 = Status
; DS:SI -> DEB for the port
; Returns:
; AX = 0 if no errors occured
; Error Returns:
; AX = error code
; Registers Preserved:
; SI,DI
; Registers Destroyed:
; AX,BX,CX,DX,ES,FLAGS
; History:
; sudeepb 10-Jan-1993 changed the costly cli/sti with non-trapping
; FCLI/FSTI macros
;-----------------------------------------------------------------------;
;------------------------------Pseudo-Code------------------------------;
; {
; }
;-----------------------------------------------------------------------;
assumes ds,Data
assumes es,nothing
include vint.inc
externFP OutputDebugString
dbmsg macro msg
.286
push cs
push offset $ + 3 + 5 + 2 ; push + far call + short jump
call OutputDebugString
jmp short @F
db msg,13,10,0
@@:
endm
iodelay macro
jmp $+2
jmp $+2
endm
public DoLPT ;Publics for debugging
public LPT_Reset
public LPT_Outchar
public LPT_Strobe
public LPT_GetStatus
public DoLPT40
; status bit defines
L_BITS equ 0F8h ; the status bits we want
L_BITS_INVERT equ 048h ; must invert to match BIOS
L_DEVBUSY equ 080h ; device busy bit
L_TIMEOUT equ 001h ; timeout bit
; control bit defines
L_NORMAL equ 00Ch ; normal state: selected, no reset
L_RESET equ 008h ; reset state
L_STROBE equ 00Dh ; tell printer we have char
DoLPT proc near
mov dx,Port[si] ;Get port address
; DX = port address
; CH = operation: 0 = write, 1 = init, 2 = status
; AL = character
or ch, ch
jz LPT_OutChar
cmp ch, 1
jz LPT_Reset
jmp LPT_GetStatus
ret
LPT_Reset:
inc dx
inc dx
mov al, L_RESET
iodelay
out dx, al
push dx
cCall GetSystemMsecCount
mov bx, ax
LPT_ResetDelay:
push bx
cCall GetSystemMsecCount
pop bx
sub ax, bx
cmp ax, 300 ; 1/3 sec as good as any
jbe LPT_ResetDelay
pop dx
mov al, L_NORMAL
iodelay
iodelay
out dx, al
dec dx
dec dx
jmp LPT_GetStatus
LPT_OutChar:
push ax ; save character to be written
; first check to see if printer is ready for us
push di
push dx
call GetSystemMSecCount
mov di, ax
pop dx
LPT_WaitReady:
inc dx ; point to status port
iodelay
in al, dx ; get status bits
and al, L_BITS ; mask unused ones
xor al, L_BITS_INVERT ; flip a couple
xchg al, ah
ifndef NOOKIHACK
iodelay
in al, dx
dec dx
and al, L_BITS
xor al, L_BITS_INVERT
cmp al, ah ; did any bits change?
jnz LPT_WaitReady
else
dec dx
endif
test ah, PS_PaperOut or PS_IOError
jnz LPT_PrinterNotReady
test ah, PS_Select
jz LPT_PrinterNotReady
test ah, PS_NotBusy
jnz LPT_PrinterReady
push ax
push dx
call GetSystemMSecCount
pop dx
pop bx
sub ax, di
cmp ax, 300 ; 1/3 sec timeout
jbe LPT_WaitReady
; The device seems to be selected and powered up, but is just
; busy (some printers seem to show selected but busy when they
; are taken offline). Show that the transmit queue is full and
; that the hold handshakes are set. This is so the windows
; spooler will retry (and do yields so that other apps may run).
or ComErr[si],CE_TXFULL ;Show queue full
mov ah,bh
or ah, L_TIMEOUT
LPT_PrinterNotReady:
pop di
pop cx ; throw away character
jmp LPT_ReturnStatus
LPT_PrinterReady:
pop di ; get di back
pop ax ; get character back
iodelay
out dx, al ; write character to port
inc dx ; access status port
LPT_Strobe:
inc dx ; control port
mov al, L_STROBE ; set strobe high
iodelay
iodelay
iodelay
iodelay
out dx, al ; ...
mov al, L_NORMAL ;
iodelay
iodelay
iodelay
iodelay
out dx, al ; set strobe low
sub dx, 2 ; point back to port base
; FALL THRU
LPT_GetStatus:
inc dx ; point to status port
LPT_GS1:
iodelay
iodelay
in al, dx ; get status bits
and al, L_BITS ; mask unused ones
xor al, L_BITS_INVERT ; flip a couple
mov ah, al
ifndef NOOKIHACK
in al, dx
and al, L_BITS
xor al, L_BITS_INVERT
cmp al, ah
jnz LPT_GS1 ; if they changed try again...
endif
LPT_ReturnStatus:
assumes ds,Data
and ax,(PS_PaperOut+PS_Select+PS_IOError+PS_Timeout)*256
shr ah,1
adc ah,al ;Get back Timeout bit
xor ah,HIGH CE_DNS ;Invert selected bit
.errnz LOW CE_DNS
or by ComErr+1[si],ah ;Save comm error
ret
.errnz CE_PTO-0200h
.errnz CE_IOE-0400h
.errnz CE_DNS-0800h
.errnz CE_OOP-1000h
DoLPT40:
assumes ds,Data
or ComErr[si],CE_TXFULL ;Show queue full
ret
DoLPT endp
page
;----------------------------Private-Routine----------------------------;
;
; TXI - Transmit A Character Immediately
;
; Set up a character to be transmitted "immediately".
; by placing the character in a location that guarantees
; it to be the next character transmitted.
;
; The check to see if the immediate character can be placed has
; already been made prior to entry.
;
; Interrupts must be disabled before entering this code
;
; Entry:
; AH = Character
; DS:SI --> DEB
; Returns:
; None
; Error Returns:
; None
; Registers Preserved:
; BX,CX,SI,DI,DS,ES
; Registers Destroyed:
; AL,DX,FLAGS
; History:
;-----------------------------------------------------------------------;
;------------------------------Pseudo-Code------------------------------;
; {
; }
;-----------------------------------------------------------------------;
assumes ds,Data
assumes es,nothing
public TXI ;Public for debugging
TXI proc near
; FCLI ;Must be done by caller!
or EFlags[si],fTxImmed ;Show char to xmit
mov ImmedChar[si],ah ;Set character to transmit next
; jmp short KickTx ;Kick Xmit just in case
errn$ KickTx
TXI endp
page
;----------------------------Private-Routine----------------------------;
;
; KickTx - Kick Transmitter
;
; "Kick" the transmitter interrupt routine into operation.
; If the Transmitter Holding Register isn't empty, then
; nothing needs to be done. If it is empty, then the xmit
; interrupt needs to enabled in the IER.
;
; Entry:
; DS:SI --> DEB
; INTERRUPTS DISABLED!
; Returns:
; None
; Error Returns:
; None
; Registers Preserved:
; BX,CX,SI,DI,DS,ES
; Registers Destroyed:
; AX,DX,FLAGS
; History:
;-----------------------------------------------------------------------;
;------------------------------Pseudo-Code------------------------------;
; {
; }
;-----------------------------------------------------------------------;
assumes ds,Data
assumes es,nothing
public KickTx ;Public for debugging
KickTx proc near
; FCLI ;Done by caller
mov dx,Port[si] ;Get device I/O address
add dl,ACE_LSR ;Point at the line status reg
pin al,dx ;And get it
and al,ACE_THRE ;Check transmitter holding reg status
jz KickTx10 ;Busy, interrupt will hit soon enough
sub dl,ACE_LSR-ACE_IER ;--> Interrupt enable register
pin al,dx ;Get current IER state
test al,ACE_THREI ;Interrupt already enabled?
jnz KickTx10 ; Yes, don't reenable it
or al,ACE_THREI ; No, enable it
pout dx,al
pause ;8250, 8250-B bug requires
pout dx,al ; writting register twice
KickTx10:
; FSTI ;Done by caller
ret
KickTx endp
page
;----------------------------Private-Routine----------------------------;
;
; GetDEB - Get Pointer To Device's DEB
;
; Returns a pointer to appropriate DEB, based on device number.
;
; Entry:
; AH = cid
; Returns:
; 'C' clear
; 'S' set if LPT device
; DS:SI --> DEB is valid cid
; AH = cid
; Error Returns:
; 'C' set if error (cid is invalid)
; AX = 8000h
; Registers Preserved:
; BX,CX,DX,DI,DS,ES
; Registers Destroyed:
; AX,SI,FLAGS
; History:
;-----------------------------------------------------------------------;
;------------------------------Pseudo-Code------------------------------;
; {
; }
;-----------------------------------------------------------------------;
assumes ds,Data
assumes es,nothing
public GetDEB ;Public for debugging
GetDEB proc near
cmp ah,LPTx+MAXLPT ;Within range?
ja GetDEB30 ;No, return invalid ID
mov si,DataOFFSET LPT3 ;Assume LPT3
je GetDEB10 ;It's LPT3
cmp ah,MAXCOM ;Is cid within range for a com port?
ja GetDEB20 ; No, check for a LPT port 1 and 2
mov si,DataOFFSET Comm4 ;Assume COM4 [rkh] ...
je GetDEB10 ;It was COM4
mov si,DataOFFSET Comm3 ;Assume COM3
cmp ah,MAXCOM-1 ;Is cid within range for a com port?
je GetDEB10 ;It was COM3
mov si,DataOFFSET Comm2 ;Assume COM2
cmp ah,MAXCOM-2 ;Is cid within range for a com port?
je GetDEB10 ;It was COM2
mov si,DataOFFSET Comm1 ;It was COM1
GetDEB10:
or ah,ah ;Set 'S' if LPT, clear 'C'
ret
.errnz LPTx-10000000b
GetDEB20:
mov si,DataOFFSET LPT1 ;Assume LPT1
cmp ah,LPTx
je GetDEB10 ;Its LPT1
mov si,DataOFFSET LPT2 ;Assume LPT2
ja GetDEB10 ;Its LPT2
GetDEB30:
mov ax,8000h ;Set error code
stc ;Set 'C' to show error
ret
GetDEB endp
page
;----------------------------Public Routine-----------------------------;
;
; $SETQUE - Set up Queue Pointers
;
; Sets pointers to Receive and Transmit Queues, as provided by the
; caller, and initializes those queues to be empty.
;
; Queues must be set before $INICOM is called!
;
; Entry:
; AH = Device ID
; ES:BX --> Queue Definition Block
; Returns:
; AX = 0 if no errors occured
; Error Returns:
; AX = error code
; Registers Preserved:
; BX,DX,SI,DI,DS
; Registers Destroyed:
; AX,CX,ES,FLAGS
; History:
;-----------------------------------------------------------------------;
;------------------------------Pseudo-Code------------------------------;
; {
; }
;-----------------------------------------------------------------------;
assumes ds,Data
assumes es,nothing
public $SETQUE
$SETQUE proc near
push si ;These will be used
push di
call GetDEB ;Get DEB
jc SetQue10 ;Invalid, ignore the call
js SetQue10 ;Ignore call for LPT ports
push ds ;Set ds:si --> QDB
push es ;Set es:di --> to ComDCB.QInAddr
pop ds
assumes ds,nothing
pop es
assumes es,Data
lea di,QInAddr[si]
mov si,bx
mov cx,(SIZE QDB)/2
.errnz (SIZE QDB) AND 1
xor ax,ax ;Will do some zero filling
cld
FCLI ;No one else can play with queues
rep movsw
mov cl,(EFlags-QInCount)/2
.errnz (EFlags-QInCount) AND 0FE01h
rep stosw
FSTI
push es ;Restore the data segment
pop ds
assumes ds,Data
assumes es,nothing
SetQue10:
pop di ;Restore saved registers
pop si
ret
; The above code made a few assumptions about how memory
; was allocated within the structures:
.errnz (QueueRxSize-QueueRxAddr)-(QInSize-QInAddr)
.errnz (QueueTxAddr-QueueRxSize)-(QOutAddr-QInSize)
.errnz (QueueTxSize-QueueTxAddr)-(QOutSize-QOutAddr)
.errnz QueueRxSize-QueueRxAddr-4
.errnz QueueTxAddr-QueueRxSize-2
.errnz QueueTxSize-QueueTxAddr-4
.errnz QInSize-QInAddr-4
.errnz QOutAddr-QInSize-2
.errnz QOutSize-QOutAddr-4
.errnz QInCount-QOutSize-2
.errnz QInGet-QInCount-2
.errnz QInPut-QInGet-2
.errnz QOutCount-QInPut-2
.errnz QOutGet-QOutCount-2
.errnz QOutPut-QOutGet-2
.errnz EFlags-QOutPut-2 ;First non-queue item
$SETQUE endp
page
;----------------------------Public Routine-----------------------------;
;
; $EVT - Set Event Mask
;
; Set up event word and mask. Returns a pointer to a word in which
; certain bits, as enabled by the mask, will be set when certain
; events occur.
;
; Entry:
; AH = Device ID
; BX = Event enable mask
; Returns:
; DX:AX --> event word.
; Error Returns:
; AX = 0 if error
; Registers Preserved:
; BX,CX,SI,DI,DS,ES
; Registers Destroyed:
; AX,DX,FLAGS
; History:
;-----------------------------------------------------------------------;
;------------------------------Pseudo-Code------------------------------;
; {
; }
;-----------------------------------------------------------------------;
assumes ds,Data
assumes es,nothing
public $EVT
$EVT proc near
push si
xor dx,dx ;In case of error
call GetDEB ;Get pointer to DEB
mov ax,dx ;Finish setting error return value
jc Evt10 ;Illegal id, return error
js Evt10 ;LPTx, return error
mov EvtMask[si],bx ;Save the new event mask
lea ax,EvtWord[si] ;Get address of event word
mov dx,ds ; into dx:ax
Evt10:
pop si
ret
$EVT endp
page
;----------------------------Public Routine-----------------------------;
;
; $EVTGET - Get Event Word
;
; Return and clear fields in the event word. This routine MUST be used
; by applications to read the event word, as it is the ONLY way they
; can be assured that an event is not lost between reading the flags
; and resetting some.
;
; Entry:
; AH = Device ID
; BX = Event clear mask
; Returns:
; AX = event word
; Error Returns:
; None
; Registers Preserved:
; AX,CX,SI,DI,DS,ES
; Registers Destroyed:
; BX,FLAGS
; History:
;-----------------------------------------------------------------------;
;------------------------------Pseudo-Code------------------------------;
; {
; }
;-----------------------------------------------------------------------;
assumes ds,Data
assumes es,nothing
public $EVTGET
$EVTGET proc near
push si
call GetDEB
mov ah,0 ;In case of error (AL already 0)
jc EvtGet10 ;Illegal ID
js EvtGet10 ;Illegal ID
FCLI ;No interrupts allowed
mov ax,EvtWord[si] ;Get the current event word
not bx ;Convert mask for our purposes
and bx,ax ;Clear events that user wants us to
mov EvtWord[si],bx ;And save those results
FSTI ;Magic over
EvtGet10:
pop si
ret
$EVTGET endp
page
;----------------------------Public Routine-----------------------------;
;
; $STACOM - Return Status Information
;
; Returns the number of bytes in both queues.
;
; LPT ports will show both queues empty.
; and resetting some.
;
; Entry:
; AH = Device ID
; ES:BX = Pointer to status structure to be updated.
; = Null if not to update
; Returns:
; AX = comm error word
; Status Structure Updated.
; Error Returns:
; AX = error code
; Registers Preserved:
; SI,DI,DS,ES
; Registers Destroyed:
; AX,BX,CX,DX,FLAGS
; History:
;-----------------------------------------------------------------------;
;------------------------------Pseudo-Code------------------------------;
; {
; }
;-----------------------------------------------------------------------;
assumes ds,Data
assumes es,nothing
public $STACOM
$STACOM proc near
push si
call GetDEB ;Get DEB pointer in SI
jc StaCom30 ;Invalid ID
mov cx,es ;Is the pointer NULL?
or cx,bx
jz StaCom25 ; Yes, just return error code
xor cx,cx
xor dx,dx
or ah,ah ;Set 'S' if LPT port
mov ax,cx ;For LPTs, everything is zero
js StaCom20 ;LPT port
; Need to get the status for a com port. Since not all the
; status is contained within EFlags, it has to be assembled.
; Also note that currently there is no way to specify RLSD
; as a handshaking line, so fRLSDHold is always returned false.
mov al,MSRShadow[si] ;Get state of hardware lines
and al,OutHHSLines[si] ;Mask off required bits
xor al,OutHHSLines[si] ;1 = line low
mov cl,4 ;Align bits
shr al,cl ;al = fCTSHold + fDSRHold
.errnz ACE_CTS-00010000b
.errnz ACE_DSR-00100000b
.errnz fCTSHold-00000001b
.errnz fDSRHold-00000010b
mov ah,HSFlag[si] ;Get fXOffHold+fXOffSent
and ah,XOffReceived+XOffSent
or al,ah
.errnz XOffReceived-fXOFFHold
.errnz XOffSent-fXOFFSent
mov ah,EFlags[si] ;Get fEOF+fTxImmed
and ah,fEOF+fTxImmed
or al,ah
mov cx,QInCount[si] ;Get input queue count
mov dx,QOutCount[si] ;Get tx queue count
StaCom20:
mov es:StatFlags[bx],al
mov es:StatRxCount[bx],cx
mov es:StatTxCount[bx],dx
StaCom25:
xor ax,ax ;Return old com error
xchg ax,ComErr[si] ; and clear it out
StaCom30:
pop si
ret
$STACOM endp
page
;----------------------------Public Routine-----------------------------;
;
; $SetBrk - Set Break
;
; Clamp the Tx data line low. Does not wait for the
; transmitter holding register and shift registers to empty.
;
; LPT ports will just return the comm error word
;
; Entry:
; AH = Device ID
; Returns:
; AX = comm error word
; Error Returns:
; AX = error code
; Registers Preserved:
; SI,DI,DS,ES
; Registers Destroyed:
; AX,BX,CX,DX,FLAGS
; History:
;-----------------------------------------------------------------------;
;------------------------------Pseudo-Code------------------------------;
; {
; }
;-----------------------------------------------------------------------;
assumes ds,Data
assumes es,nothing
public $SETBRK
$SETBRK proc near
mov cx,0FF00h+ACE_SB ;Will be setting break
jmp short ClrBrk10
.errnz BreakSet-ACE_SB ;Must be same bits
$SETBRK endp
page
;----------------------------Public Routine-----------------------------;
;
; $CLRBRK - Clear Break
;
; Release any BREAK clamp on the Tx data line.
;
; LPT ports will just return the comm error word
;
; Entry:
; AH = Device ID
; Returns:
; AX = comm error word
; Error Returns:
; AX = error code
; Registers Preserved:
; SI,DI,DS,ES
; Registers Destroyed:
; AX,BX,CX,DX,FLAGS
; History:
;-----------------------------------------------------------------------;
;------------------------------Pseudo-Code------------------------------;
; {
; }
;-----------------------------------------------------------------------;
assumes ds,Data
assumes es,nothing
public $CLRBRK
$CLRBRK proc near
mov cx,(NOT ACE_SB) SHL 8
.errnz BreakSet-ACE_SB ;Must be same bits
ClrBrk10:
push si
call GetDEB ;Get DEB address
jc ClrBrk30 ;Invalid ID
js ClrBrk20 ;Ignored for LPT ports
FCLI
and HSFlag[si],ch ;Set or clear the BreakSet bit
or HSFlag[si],cl
; ch = mask to remove bits in the Line Control Register
; cl = mask to turn bits on in the Line Control Register
mov dx,Port[si] ;Get comm device base I/O port
add dl,ACE_LCR ;Point at the Line Control Regieter
pin al,dx ;Get old line control value
and al,ch ;Turn off desired bits
or al,cl ;Turn on desired bits
pause
pout dx,al ;Output New LCR.
FSTI
ClrBrk20:
mov ax,ComErr[si] ;Return Status Word
ClrBrk30:
pop si
ret
$CLRBRK endp
page
;----------------------------Public Routine-----------------------------;
;
; $EXTCOM - Extended Comm Functions
;
; A number of extended functions are routed through this entry point.
;
; Functions currently implemented:
;
; 0: Ignored
; 1: SETXOFF - Exactly as if X-OFF character has been received.
; 2: SETXON - Exactly as if X-ON character has been received.
; 3: SETRTS - Set the RTS signal
; 4: CLRRTS - Clear the RTS signal
; 5: SETDTR - Set the DTR signal
; 6: CLRDTR - Clear the DTR signal
; 7: RESET - Yank on reset line if available (LPT devices)
;
; Entry:
; AH = Device ID
; BL = Function Code
; (0-127 are MS-defined, 128-255 are OEM defined)
; Returns:
; AX = comm error word
; Error Returns:
; AX = error code
; Registers Preserved:
; SI,DI,DS
; Registers Destroyed:
; AX,BX,CX,DX,ES,FLAGS
; History:
;-----------------------------------------------------------------------;
;------------------------------Pseudo-Code------------------------------;
; {
; }
;-----------------------------------------------------------------------;
; Dispatch table for the extended functions
ExtTab dw ExtComDummy ;Function 0: Never Mind
dw ExtCom_FN1 ;1: Set X-Off
dw ExtCom_FN2 ;2: Clear X-Off
dw ExtCom_FN3 ;3: Set RTS
dw ExtCom_FN4 ;4: Clear RTS
dw ExtCom_FN5 ;5: Set DSR
dw ExtCom_FN6 ;6: Clear DSR
dw ExtCom_FN7 ;7: Reset printer
assumes ds,Data
assumes es,nothing
public $EXTCOM
$EXTCOM proc near
push si
call GetDEB ;Get DEB pointer
jc ExtCom40 ;Invalid ID, return error
mov dx,Port[si] ; get port address
jns ExtCom10 ;Its a COM port
cmp bl,7 ;RESET extended function?
jne ExtCom30 ; No, return error word
jmp short ExtCom20 ; Yes, invoke the function
ExtCom10:
cmp bl,7 ;Last fcn supported +1
jnc ExtCom30 ;Not an implemented function.
ExtCom20:
xor bh,bh
add bx,bx ;Shift for the call
FCLI ;Consider as critical sections
call ExtTab[bx] ; and perform the function
FSTI
ExtCom30:
mov ax,ComErr[si] ;Return standard error word
ExtCom40:
pop si
ExtComDummy:
ret
$EXTCOM endp
page
;----------------------------Private-Routine----------------------------;
;
; ExtCom_FN1 - Extended Function Set X-Off
;
; Analagous to receiving an X-OFF character. Bufferred transmision of
; characters is halted until an X-ON character is received, or until
; we fake that with a Clear X-Off call.
;
; Entry:
; interrupts disabled
; dx = port base address
; Returns:
; None
; Error Returns:
; None
; Registers Preserved:
; SI,DI,DS
; Registers Destroyed:
; AX,BX,CX,DX,ES,FLAGS
; History:
;-----------------------------------------------------------------------;
;------------------------------Pseudo-Code------------------------------;
; {
; }
;-----------------------------------------------------------------------;
assumes ds,Data
assumes es,nothing
public ExtCom_FN1
ExtCom_FN1 proc near
or HSFlag[si],XOffReceived
ret
ExtCom_FN1 endp
page
;----------------------------Private-Routine----------------------------;
;
; ExtCom_FN2 - Extended Function Clear X-Off
;
; Analagous to receiving an X-ON character. Buffered
; transmission of characters is restarted.
;
; Entry:
; interrupts disabled
; dx = port base address
; Returns:
; None
; Error Returns:
; None
; Registers Preserved:
; SI,DI,DS
; Registers Destroyed:
; AX,BX,CX,DX,ES,FLAGS
; History:
;-----------------------------------------------------------------------;
;------------------------------Pseudo-Code------------------------------;
; {
; }
;-----------------------------------------------------------------------;
assumes ds,Data
assumes es,nothing
public ExtCom_FN2
ExtCom_FN2 proc near
and HSFlag[si],NOT XOffReceived
jmp KickTx ;Kick transmitter interrupts on
ExtCom_FN2 endp
page
;----------------------------Private-Routine----------------------------;
;
; ExtCom_FN3 - Extended Function Set RTS
;
; Set the RTS signal active.
;
; Entry:
; interrupts disabled
; dx = port base address
; Returns:
; None
; Error Returns:
; None
; Registers Preserved:
; SI,DI,DS
; Registers Destroyed:
; AX,BX,CX,DX,ES,FLAGS
; History:
;-----------------------------------------------------------------------;
;------------------------------Pseudo-Code------------------------------;
; {
; }
;-----------------------------------------------------------------------;
assumes ds,Data
assumes es,nothing
public ExtCom_FN3
ExtCom_FN3 proc near
add dl,ACE_MCR ;Point at Modem Control Register
pin al,dx ;Get current settings
or al,ACE_RTS ;Set RTS
pause
pout dx,al ;And update
ret
ExtCom_FN3 endp
page
;----------------------------Private-Routine----------------------------;
;
; ExtCom_FN4 - Extended Function Clear RTS
;
; Set the RTS signal inactive.
;
; Entry:
; interrupts disabled
; dx = port base address
; Returns:
; None
; Error Returns:
; None
; Registers Preserved:
; SI,DI,DS
; Registers Destroyed:
; AX,BX,CX,DX,ES,FLAGS
; History:
;-----------------------------------------------------------------------;
;------------------------------Pseudo-Code------------------------------;
; {
; }
;-----------------------------------------------------------------------;
assumes ds,Data
assumes es,nothing
public ExtCom_FN4
ExtCom_FN4 proc near
add dl,ACE_MCR ;Point at Modem Control Register
pin al,dx ;Get current settings
and al,NOT ACE_RTS ;Clear RTS
pause
pout dx,al ;And update
ret
ExtCom_FN4 endp
page
;----------------------------Private-Routine----------------------------;
;
; ExtCom_FN5 - Extended Function Set DTR
;
; Set the DTR signal active.
;
; Entry:
; interrupts disabled
; dx = port base address
; Returns:
; None
; Error Returns:
; None
; Registers Preserved:
; SI,DI,DS
; Registers Destroyed:
; AX,BX,CX,DX,ES,FLAGS
; History:
;-----------------------------------------------------------------------;
;------------------------------Pseudo-Code------------------------------;
; {
; }
;-----------------------------------------------------------------------;
assumes ds,Data
assumes es,nothing
public ExtCom_FN5
ExtCom_FN5 proc near
add dl,ACE_MCR ;Point at Modem Control Register
pin al,dx ;Get current settings
or al,ACE_DTR ;Set DTR
pause
pout dx,al ;And update
ret
ExtCom_FN5 endp
page
;----------------------------Private-Routine----------------------------;
;
; ExtCom_FN6 - Extended Function Clear DTR
;
; Set the DTR signal inactive.
;
; Entry:
; interrupts disabled
; dx = port base address
; Returns:
; None
; Error Returns:
; None
; Registers Preserved:
; SI,DI,DS
; Registers Destroyed:
; AX,BX,CX,DX,ES,FLAGS
; History:
;-----------------------------------------------------------------------;
;------------------------------Pseudo-Code------------------------------;
; {
; }
;-----------------------------------------------------------------------;
assumes ds,Data
assumes es,nothing
public ExtCom_FN6
ExtCom_FN6 proc near
add dl,ACE_MCR ;Point at Modem Control Register
pin al,dx ;Get current settings
and al,NOT ACE_DTR ;Clear DTR
pause
pout dx,al ;And update
ret
ExtCom_FN6 endp
page
;----------------------------Private-Routine----------------------------;
;
; ExtCom_FN7 - Extended Function Reset Printer
;
; Assert the RESET line on an LPT port
;
; Entry:
; interrupts disabled
; dx = port base address
; Returns:
; None
; Error Returns:
; None
; Registers Preserved:
; SI,DI,DS
; Registers Destroyed:
; AX,BX,CX,DX,ES,FLAGS
; History:
;-----------------------------------------------------------------------;
;------------------------------Pseudo-Code------------------------------;
; {
; }
;-----------------------------------------------------------------------;
assumes ds,Data
assumes es,nothing
public ExtCom_FN7
ExtCom_FN7 proc near
FSTI ;Not called at interrupt time
mov ch,1 ;ROM BIOS Reset Port
call DoLPT ;Perform the function
ret
ExtCom_FN7 endp
page
;----------------------------Public Routine-----------------------------;
;
; $DCBPtr - Return Pointer To DCB
;
; Returns a long pointer to the DCB for the requested device.
;
; Entry:
; AH = Device ID
; Returns:
; DX:AX = pointer to DCB.
; Error Returns:
; DX:AX = 0
; Registers Preserved:
; SI,DI,DS
; Registers Destroyed:
; BX,CX,ES,FLAGS
; History:
;-----------------------------------------------------------------------;
;------------------------------Pseudo-Code------------------------------;
; {
; }
;-----------------------------------------------------------------------;
assumes ds,Data
assumes es,nothing
public $DCBPTR
$DCBPTR proc near
push si
xor dx,dx
call GetDEB ;Get pointer to DEB
mov ax,dx
jc DCBPtr10 ;Jump if invalid device
mov ax,si ;else return value here
mov dx,ds
DCBPtr10:
pop si
ret
$DCBPTR endp
page
;----------------------------Public Routine-----------------------------;
;
; $RECCOM - Receive Characters From Device
;
; Read Byte From RS232 Input Queue If Data Is Ready
;
; LPT ports will return with an indication that no characters are
; available.
;
; Entry:
; AH = Device ID
; Returns:
; 'Z' clear if data available
; AL = byte
; Error Returns:
; 'Z' Set if error or no data
; AX = error code
; AX = 0 if no data
; Registers Preserved:
; SI,DI,DS
; Registers Destroyed:
; AX,BX,CX,DX,ES,FLAGS
; History:
;-----------------------------------------------------------------------;
;------------------------------Pseudo-Code------------------------------;
; {
; }
;-----------------------------------------------------------------------;
assumes ds,Data
assumes es,nothing
public $RECCOM
$RECCOM proc near
push si ;Once again, save some registers
push di
call GetDEB ;Get DEB pointer in SI
jc RecCom10 ;Invalid Port [rkh] ...
js RecCom20 ;LPT port, return no characters
jmp short RecCom30
RecCom10:
jmp RecCom100 ; Invalid Port
RecCom20:
jmp RecCom95 ;LPT port, return no characters
; Before removing any charcters from the input queue, check to see
; if XON needs to be issued. If it needs to be issued, set the
; flag that will force it and arm transmit interrupts.
RecCom30:
test Flags[si],fEnqAck+fEtxAck ;Enq or Etx Ack?
jz RecCom32 ; No
test HSFlag[si],EnqReceived+HHSDropped ;Enq recvd or lines dropped?
jz RecCom60 ; No Enq recvd & no lines dropped
jmp short RecCom34
RecCom32:
test HSFlag[si],HSSent ;Handshake sent?
jz RecCom60 ; No XOFF sent & no lines dropped
RecCom34:
mov ax,QInCount[si] ;Get current count of input chars
cmp ax,XONLim[si] ;See if at XOn limit
ja RecCom60 ;Not at XOn limit yet
; If any hardware lines are down, then raise them. Then see
; about sending XON.
mov dx,Port[si] ;Get the port
mov ah,HHSLines[si] ;Get hardware lines mask
FCLI ;Handle this as a critical section
mov cl,HSFlag[si] ;Get handshaking flags
or ah,ah ;Any hardware lines to play with?
jz RecCom40 ; No
add dl,ACE_MCR ;--> Modem control register
pin al,dx
or al,ah ;Turn on the hardware bits
pause
pout dx,al
and cl,NOT HHSDropped ;Show hardware lines back up
RecCom40:
test Flags[si],fEnqAck+fEtxAck ;Enq or Etx Ack?
jz RecCom47 ; No
test cl,EnqReceived ;Did we receive Enq?
jz RecCom55 ; No
and cl,NOT EnqReceived
jmp short RecCom50
RecCom47:
test cl,XOffSent ;Did we send XOFF?
jz RecCom55 ; No
and cl,NOT XOffSent ;Remove XOFF sent flag
RecCom50:
or cl,XOnPending ;Show XON or ACK must be sent
call KickTx ;Kick xmit if needed
RecCom55:
mov HSFlag[si],cl ;Store handshake flag
FSTI ;Can allow interrupts now
; Now we can get down to the business at hand, and remove a character
; from the receive queue. If a communications error exists, we return
; that, and nothing else.
RecCom60:
xor ax,ax
or ax,ComErr[si] ;Any Errors?
jnz RecCom100 ; Yes, return the error code
or ax,QInCount[si] ;Get current input char count
jz RecCom90 ;No characters in the queue
les di,QInAddr[si] ;Get queue pointer
assumes es,nothing
mov bx,QInGet[si] ;Also get the index to head
mov al,es:[bx][di] ;Finally, get byte from queue
inc bx ;Update queue index
cmp bx,QInSize[si] ;See if time for wrap-around
jc RecCom70 ;Jump if no wrap
xor bx,bx ;wrap by zeroing the index
RecCom70:
mov QInGet[si],bx ;Save new head pointer
dec QInCount[si] ;Dec # of bytes in queue
RecCom80:
or sp,sp ;Reset PSW.Z
pop di
pop si
ret
; No characters in the input queue. Check to see if EOF
; was received, and return it if it was. Otherwise show
; no characters.
RecCom90:
test Flags[si],fBinary ;Are we doing binary stuff?
jnz RecCom95 ; Yes, show no characters
mov al,EOFChar[si] ;Assume EOF
test EFlags[si],fEOF ;Has end of file char been received?
jnz RecCom80 ; Yes, show end of file
RecCom95:
xor ax,ax ;Show no more characters
; Return with 'Z' to show error or no characters
RecCom100:
xor cx,cx ;Set PSW.Z
pop di
pop si
ret
$RECCOM endp
page
;----------------------------Public Routine-----------------------------;
;
; $FLUSH - Flush The Input and Output Queues
;
; This is a hard initialization of the transmit and receive queue's,
; which immediately empties the given queue.
;
; LPT ports will just return the device error word
;
; Entry:
; AH = Device ID
; BH = Queue # to clear (0=Tx, 1=Rx)
; Returns:
; AX = Device Error Word. (Not reset)
; Error Returns:
; AX = error code
; Registers Preserved:
; SI,DI,DS
; Registers Destroyed:
; AX,BX,CX,DX,ES,FLAGS
; History:
;-----------------------------------------------------------------------;
;------------------------------Pseudo-Code------------------------------;
; {
; }
;-----------------------------------------------------------------------;
assumes ds,Data
assumes es,nothing
public $FLUSH
$FLUSH proc near
push si
push di
call GetDEB ;si --> DEB
jc Flush40 ;Invalid ID
js Flush30 ;LPT port, return any error
mov cx,QOutCount-QInCount ;# of bytes to zero
lea di,QInCount[si] ;--> receive queue data
or bh,bh ;Transmit queue?
jnz Flush10 ; No, input queue
add di,cx ; Yes, --> xmit queue data
Flush10:
cld
push ds
pop es
assumes es,nothing
xor al,al
FCLI ;Time to worry about critical sections
rep stosb
FSTI
.errnz QInGet-QInCount-2
.errnz QInPut-QInGet-2
.errnz QOutCount-QInPut-2
.errnz QOutGet-QOutCount-2
.errnz QOutPut-QOutGet-2
or bh,bh ;Rx queue?
jz Flush30 ; No, xmit queue
; If the queue to be cleared is the receive queue, any
; hardware handshake must be cleared to prevent a possible
; deadlock situation. Since we just zeroed the queue count,
; a quick call to $RecCom should do wonders to clear any
; receive handshake (i.e. send XON if needed).
Flush20:
call $RECCOM ;Take care of handshakes here
Flush30:
mov ax,ComErr[si] ;And return the error word.
Flush40:
pop di
pop si
ret
$FLUSH endp
ifdef DEBUG
public KickTx10
public GetDEB10
public GetDEB20
public GetDEB30
public SetQue10
public Evt10
public EvtGet10
public StaCom20
public StaCom25
public StaCom30
public ClrBrk10
public ClrBrk20
public ClrBrk30
public ExtCom10
public ExtCom20
public ExtCom30
public ExtCom40
public ExtComDummy
public DCBPtr10
public RecCom30
public RecCom40
public RecCom50
public RecCom60
public RecCom70
public RecCom80
public RecCom90
public RecCom95
public RecCom100
public Flush10
public Flush20
public Flush30
public Flush40
endif
|
source/miscellany/indexing.asm | paulscottrobson/rpl-32 | 0 | 86729 | <gh_stars>0
; ******************************************************************************
; ******************************************************************************
;
; Name : indexing.asm
; Purpose : Handle array indexing / subscripts
; Author : <NAME> (<EMAIL>)
; Created : 4th October 2019
;
; ******************************************************************************
; ******************************************************************************
; ******************************************************************************
;
; Address of variable data in idDataAddr - check for indexing.
;
; ******************************************************************************
IndexCheck:
lda (codePtr),y ; check next character
cmp #KWD_LSQPAREN ; is it [ ?
bne _ICExit
iny
lda (codePtr),y ; next is ] ?
cmp #KWD_RSQPAREN
beq _ICArrayAccess
and #$C0 ; is it a constant
cmp #$80
beq _ICConstAccess
_ICSyntax:
jmp SyntaxError
;
_ICExit:
rts
;
; Subscript by constant
;
_ICConstAccess:
lda (codePtr),y ; get constant, copy in.
and #$3F ; to subscript in zTemp1
sta zTemp1
stz zTemp1+1
iny
lda (codePtr),y ; get next
iny
cmp #KWD_CONSTANT_PLUS ; ok if K+
bne _ICSyntax
lda (codePtr),y ; get next
iny
cmp #KWD_RSQPAREN ; ok if ]
bne _ICSyntax
bra _ICAddSubscript
;
; Subscript by TOS
;
_ICArrayAccess:
iny ; point to next
;
lda stack0,x ; copy TOS to zTemp1
sta zTemp1 ; no point in the rest !
lda stack1,x
sta zTemp1+1
dex
;
_ICAddSubscript:
asl zTemp1 ; subscript x 4
rol zTemp1+1
asl zTemp1
rol zTemp1+1
;
phy
lda (idDataAddr) ; check indirecting through 0
ldy #1
ora (idDataAddr),y ; probably means uninitialised
iny
ora (idDataAddr),y
iny
ora (idDataAddr),y
beq _ICZero
clc ; add zTemp1 to value at (idDataAddr)
lda (idDataAddr)
adc zTemp1
pha
;
ldy #1
lda (idDataAddr),y
adc zTemp1+1
sta idDataAddr+1 ; write it out
pla
sta idDataAddr
;
stz idDataAddr+2 ; extend to 32 bits
stz idDataAddr+3
ply
rts
_ICZero:
.rerror "UNINITIALISED ARRAY"
|
src/fltk-widgets-groups-tiled.adb | micahwelf/FLTK-Ada | 1 | 26572 |
with
Interfaces.C,
System;
use type
System.Address;
package body FLTK.Widgets.Groups.Tiled is
procedure tile_set_draw_hook
(W, D : in System.Address);
pragma Import (C, tile_set_draw_hook, "tile_set_draw_hook");
pragma Inline (tile_set_draw_hook);
procedure tile_set_handle_hook
(W, H : in System.Address);
pragma Import (C, tile_set_handle_hook, "tile_set_handle_hook");
pragma Inline (tile_set_handle_hook);
function new_fl_tile
(X, Y, W, H : in Interfaces.C.int;
Text : in Interfaces.C.char_array)
return System.Address;
pragma Import (C, new_fl_tile, "new_fl_tile");
pragma Inline (new_fl_tile);
procedure free_fl_tile
(B : in System.Address);
pragma Import (C, free_fl_tile, "free_fl_tile");
pragma Inline (free_fl_tile);
procedure fl_tile_position
(T : in System.Address;
OX, OY, NX, NY : in Interfaces.C.int);
pragma Import (C, fl_tile_position, "fl_tile_position");
pragma Inline (fl_tile_position);
procedure fl_tile_draw
(W : in System.Address);
pragma Import (C, fl_tile_draw, "fl_tile_draw");
pragma Inline (fl_tile_draw);
function fl_tile_handle
(W : in System.Address;
E : in Interfaces.C.int)
return Interfaces.C.int;
pragma Import (C, fl_tile_handle, "fl_tile_handle");
pragma Inline (fl_tile_handle);
procedure Finalize
(This : in out Tiled_Group) is
begin
if This.Void_Ptr /= System.Null_Address and then
This in Tiled_Group'Class
then
This.Clear;
free_fl_tile (This.Void_Ptr);
This.Void_Ptr := System.Null_Address;
end if;
Finalize (Group (This));
end Finalize;
package body Forge is
function Create
(X, Y, W, H : in Integer;
Text : in String)
return Tiled_Group is
begin
return This : Tiled_Group do
This.Void_Ptr := new_fl_tile
(Interfaces.C.int (X),
Interfaces.C.int (Y),
Interfaces.C.int (W),
Interfaces.C.int (H),
Interfaces.C.To_C (Text));
fl_group_end (This.Void_Ptr);
fl_widget_set_user_data
(This.Void_Ptr,
Widget_Convert.To_Address (This'Unchecked_Access));
tile_set_draw_hook (This.Void_Ptr, Draw_Hook'Address);
tile_set_handle_hook (This.Void_Ptr, Handle_Hook'Address);
end return;
end Create;
end Forge;
procedure Position
(This : in out Tiled_Group;
Old_X, Old_Y : in Integer;
New_X, New_Y : in Integer) is
begin
fl_tile_position
(This.Void_Ptr,
Interfaces.C.int (Old_X), Interfaces.C.int (Old_Y),
Interfaces.C.int (New_X), Interfaces.C.int (New_Y));
end Position;
procedure Draw
(This : in out Tiled_Group) is
begin
fl_tile_draw (This.Void_Ptr);
end Draw;
function Handle
(This : in out Tiled_Group;
Event : in Event_Kind)
return Event_Outcome is
begin
return Event_Outcome'Val
(fl_tile_handle (This.Void_Ptr, Event_Kind'Pos (Event)));
end Handle;
end FLTK.Widgets.Groups.Tiled;
|
oeis/084/A084947.asm | neoneye/loda-programs | 11 | 162456 | ; A084947: a(n) = Product_{i=0..n-1} (7*i+2).
; 1,2,18,288,6624,198720,7352640,323516160,16499324160,956960801280,62202452083200,4478576549990400,353807547449241600,30427449080634777600,2829752764499034316800,282975276449903431680000,30278354580139667189760000,3451732422135922059632640000,417659623078446569215549440000,53460431754041160859590328320000,7217158286795556716044694323200000,1024836476724969053678346593894400000,152700635032020388998073642490265600000,23821299064995180683699488228481433600000
mov $2,4
mov $3,2
mov $4,$0
lpb $4
mul $2,$3
add $3,7
sub $4,1
lpe
mov $0,$2
div $0,4
|
xv6/grep.asm | suriya-1403/suriya-s-XV6 | 2 | 170334 | <filename>xv6/grep.asm
_grep: file format elf32-i386
Disassembly of section .text:
00000000 <grep>:
char buf[1024];
int match(char*, char*);
void
grep(char *pattern, int fd)
{
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 83 ec 18 sub $0x18,%esp
int n, m;
char *p, *q;
m = 0;
6: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
while((n = read(fd, buf+m, sizeof(buf)-m)) > 0){
d: e9 a3 00 00 00 jmp b5 <grep+0xb5>
m += n;
12: 8b 45 ec mov -0x14(%ebp),%eax
15: 01 45 f4 add %eax,-0xc(%ebp)
p = buf;
18: c7 45 f0 60 0b 00 00 movl $0xb60,-0x10(%ebp)
while((q = strchr(p, '\n')) != 0){
1f: eb 44 jmp 65 <grep+0x65>
*q = 0;
21: 8b 45 e8 mov -0x18(%ebp),%eax
24: c6 00 00 movb $0x0,(%eax)
if(match(pattern, p)){
27: 83 ec 08 sub $0x8,%esp
2a: ff 75 f0 push -0x10(%ebp)
2d: ff 75 08 push 0x8(%ebp)
30: e8 91 01 00 00 call 1c6 <match>
35: 83 c4 10 add $0x10,%esp
38: 85 c0 test %eax,%eax
3a: 74 20 je 5c <grep+0x5c>
*q = '\n';
3c: 8b 45 e8 mov -0x18(%ebp),%eax
3f: c6 00 0a movb $0xa,(%eax)
write(1, p, q+1 - p);
42: 8b 45 e8 mov -0x18(%ebp),%eax
45: 83 c0 01 add $0x1,%eax
48: 2b 45 f0 sub -0x10(%ebp),%eax
4b: 83 ec 04 sub $0x4,%esp
4e: 50 push %eax
4f: ff 75 f0 push -0x10(%ebp)
52: 6a 01 push $0x1
54: e8 70 05 00 00 call 5c9 <write>
59: 83 c4 10 add $0x10,%esp
}
p = q+1;
5c: 8b 45 e8 mov -0x18(%ebp),%eax
5f: 83 c0 01 add $0x1,%eax
62: 89 45 f0 mov %eax,-0x10(%ebp)
while((q = strchr(p, '\n')) != 0){
65: 83 ec 08 sub $0x8,%esp
68: 6a 0a push $0xa
6a: ff 75 f0 push -0x10(%ebp)
6d: e8 86 03 00 00 call 3f8 <strchr>
72: 83 c4 10 add $0x10,%esp
75: 89 45 e8 mov %eax,-0x18(%ebp)
78: 83 7d e8 00 cmpl $0x0,-0x18(%ebp)
7c: 75 a3 jne 21 <grep+0x21>
}
if(p == buf)
7e: 81 7d f0 60 0b 00 00 cmpl $0xb60,-0x10(%ebp)
85: 75 07 jne 8e <grep+0x8e>
m = 0;
87: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
if(m > 0){
8e: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
92: 7e 21 jle b5 <grep+0xb5>
m -= p - buf;
94: 8b 45 f0 mov -0x10(%ebp),%eax
97: 2d 60 0b 00 00 sub $0xb60,%eax
9c: 29 45 f4 sub %eax,-0xc(%ebp)
memmove(buf, p, m);
9f: 83 ec 04 sub $0x4,%esp
a2: ff 75 f4 push -0xc(%ebp)
a5: ff 75 f0 push -0x10(%ebp)
a8: 68 60 0b 00 00 push $0xb60
ad: e8 82 04 00 00 call 534 <memmove>
b2: 83 c4 10 add $0x10,%esp
while((n = read(fd, buf+m, sizeof(buf)-m)) > 0){
b5: 8b 55 f4 mov -0xc(%ebp),%edx
b8: b8 00 04 00 00 mov $0x400,%eax
bd: 29 d0 sub %edx,%eax
bf: 89 c2 mov %eax,%edx
c1: 8b 45 f4 mov -0xc(%ebp),%eax
c4: 05 60 0b 00 00 add $0xb60,%eax
c9: 83 ec 04 sub $0x4,%esp
cc: 52 push %edx
cd: 50 push %eax
ce: ff 75 0c push 0xc(%ebp)
d1: e8 eb 04 00 00 call 5c1 <read>
d6: 83 c4 10 add $0x10,%esp
d9: 89 45 ec mov %eax,-0x14(%ebp)
dc: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
e0: 0f 8f 2c ff ff ff jg 12 <grep+0x12>
}
}
}
e6: 90 nop
e7: 90 nop
e8: c9 leave
e9: c3 ret
000000ea <main>:
int
main(int argc, char *argv[])
{
ea: 8d 4c 24 04 lea 0x4(%esp),%ecx
ee: 83 e4 f0 and $0xfffffff0,%esp
f1: ff 71 fc push -0x4(%ecx)
f4: 55 push %ebp
f5: 89 e5 mov %esp,%ebp
f7: 53 push %ebx
f8: 51 push %ecx
f9: 83 ec 10 sub $0x10,%esp
fc: 89 cb mov %ecx,%ebx
int fd, i;
char *pattern;
if(argc <= 1){
fe: 83 3b 01 cmpl $0x1,(%ebx)
101: 7f 17 jg 11a <main+0x30>
printf(2, "usage: grep pattern [file ...]\n");
103: 83 ec 08 sub $0x8,%esp
106: 68 04 0b 00 00 push $0xb04
10b: 6a 02 push $0x2
10d: e8 3b 06 00 00 call 74d <printf>
112: 83 c4 10 add $0x10,%esp
exit();
115: e8 8f 04 00 00 call 5a9 <exit>
}
pattern = argv[1];
11a: 8b 43 04 mov 0x4(%ebx),%eax
11d: 8b 40 04 mov 0x4(%eax),%eax
120: 89 45 f0 mov %eax,-0x10(%ebp)
if(argc <= 2){
123: 83 3b 02 cmpl $0x2,(%ebx)
126: 7f 15 jg 13d <main+0x53>
grep(pattern, 0);
128: 83 ec 08 sub $0x8,%esp
12b: 6a 00 push $0x0
12d: ff 75 f0 push -0x10(%ebp)
130: e8 cb fe ff ff call 0 <grep>
135: 83 c4 10 add $0x10,%esp
exit();
138: e8 6c 04 00 00 call 5a9 <exit>
}
for(i = 2; i < argc; i++){
13d: c7 45 f4 02 00 00 00 movl $0x2,-0xc(%ebp)
144: eb 74 jmp 1ba <main+0xd0>
if((fd = open(argv[i], 0)) < 0){
146: 8b 45 f4 mov -0xc(%ebp),%eax
149: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx
150: 8b 43 04 mov 0x4(%ebx),%eax
153: 01 d0 add %edx,%eax
155: 8b 00 mov (%eax),%eax
157: 83 ec 08 sub $0x8,%esp
15a: 6a 00 push $0x0
15c: 50 push %eax
15d: e8 87 04 00 00 call 5e9 <open>
162: 83 c4 10 add $0x10,%esp
165: 89 45 ec mov %eax,-0x14(%ebp)
168: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
16c: 79 29 jns 197 <main+0xad>
printf(1, "grep: cannot open %s\n", argv[i]);
16e: 8b 45 f4 mov -0xc(%ebp),%eax
171: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx
178: 8b 43 04 mov 0x4(%ebx),%eax
17b: 01 d0 add %edx,%eax
17d: 8b 00 mov (%eax),%eax
17f: 83 ec 04 sub $0x4,%esp
182: 50 push %eax
183: 68 24 0b 00 00 push $0xb24
188: 6a 01 push $0x1
18a: e8 be 05 00 00 call 74d <printf>
18f: 83 c4 10 add $0x10,%esp
exit();
192: e8 12 04 00 00 call 5a9 <exit>
}
grep(pattern, fd);
197: 83 ec 08 sub $0x8,%esp
19a: ff 75 ec push -0x14(%ebp)
19d: ff 75 f0 push -0x10(%ebp)
1a0: e8 5b fe ff ff call 0 <grep>
1a5: 83 c4 10 add $0x10,%esp
close(fd);
1a8: 83 ec 0c sub $0xc,%esp
1ab: ff 75 ec push -0x14(%ebp)
1ae: e8 1e 04 00 00 call 5d1 <close>
1b3: 83 c4 10 add $0x10,%esp
for(i = 2; i < argc; i++){
1b6: 83 45 f4 01 addl $0x1,-0xc(%ebp)
1ba: 8b 45 f4 mov -0xc(%ebp),%eax
1bd: 3b 03 cmp (%ebx),%eax
1bf: 7c 85 jl 146 <main+0x5c>
}
exit();
1c1: e8 e3 03 00 00 call 5a9 <exit>
000001c6 <match>:
int matchhere(char*, char*);
int matchstar(int, char*, char*);
int
match(char *re, char *text)
{
1c6: 55 push %ebp
1c7: 89 e5 mov %esp,%ebp
1c9: 83 ec 08 sub $0x8,%esp
if(re[0] == '^')
1cc: 8b 45 08 mov 0x8(%ebp),%eax
1cf: 0f b6 00 movzbl (%eax),%eax
1d2: 3c 5e cmp $0x5e,%al
1d4: 75 17 jne 1ed <match+0x27>
return matchhere(re+1, text);
1d6: 8b 45 08 mov 0x8(%ebp),%eax
1d9: 83 c0 01 add $0x1,%eax
1dc: 83 ec 08 sub $0x8,%esp
1df: ff 75 0c push 0xc(%ebp)
1e2: 50 push %eax
1e3: e8 38 00 00 00 call 220 <matchhere>
1e8: 83 c4 10 add $0x10,%esp
1eb: eb 31 jmp 21e <match+0x58>
do{ // must look at empty string
if(matchhere(re, text))
1ed: 83 ec 08 sub $0x8,%esp
1f0: ff 75 0c push 0xc(%ebp)
1f3: ff 75 08 push 0x8(%ebp)
1f6: e8 25 00 00 00 call 220 <matchhere>
1fb: 83 c4 10 add $0x10,%esp
1fe: 85 c0 test %eax,%eax
200: 74 07 je 209 <match+0x43>
return 1;
202: b8 01 00 00 00 mov $0x1,%eax
207: eb 15 jmp 21e <match+0x58>
}while(*text++ != '\0');
209: 8b 45 0c mov 0xc(%ebp),%eax
20c: 8d 50 01 lea 0x1(%eax),%edx
20f: 89 55 0c mov %edx,0xc(%ebp)
212: 0f b6 00 movzbl (%eax),%eax
215: 84 c0 test %al,%al
217: 75 d4 jne 1ed <match+0x27>
return 0;
219: b8 00 00 00 00 mov $0x0,%eax
}
21e: c9 leave
21f: c3 ret
00000220 <matchhere>:
// matchhere: search for re at beginning of text
int matchhere(char *re, char *text)
{
220: 55 push %ebp
221: 89 e5 mov %esp,%ebp
223: 83 ec 08 sub $0x8,%esp
if(re[0] == '\0')
226: 8b 45 08 mov 0x8(%ebp),%eax
229: 0f b6 00 movzbl (%eax),%eax
22c: 84 c0 test %al,%al
22e: 75 0a jne 23a <matchhere+0x1a>
return 1;
230: b8 01 00 00 00 mov $0x1,%eax
235: e9 99 00 00 00 jmp 2d3 <matchhere+0xb3>
if(re[1] == '*')
23a: 8b 45 08 mov 0x8(%ebp),%eax
23d: 83 c0 01 add $0x1,%eax
240: 0f b6 00 movzbl (%eax),%eax
243: 3c 2a cmp $0x2a,%al
245: 75 21 jne 268 <matchhere+0x48>
return matchstar(re[0], re+2, text);
247: 8b 45 08 mov 0x8(%ebp),%eax
24a: 8d 50 02 lea 0x2(%eax),%edx
24d: 8b 45 08 mov 0x8(%ebp),%eax
250: 0f b6 00 movzbl (%eax),%eax
253: 0f be c0 movsbl %al,%eax
256: 83 ec 04 sub $0x4,%esp
259: ff 75 0c push 0xc(%ebp)
25c: 52 push %edx
25d: 50 push %eax
25e: e8 72 00 00 00 call 2d5 <matchstar>
263: 83 c4 10 add $0x10,%esp
266: eb 6b jmp 2d3 <matchhere+0xb3>
if(re[0] == '$' && re[1] == '\0')
268: 8b 45 08 mov 0x8(%ebp),%eax
26b: 0f b6 00 movzbl (%eax),%eax
26e: 3c 24 cmp $0x24,%al
270: 75 1d jne 28f <matchhere+0x6f>
272: 8b 45 08 mov 0x8(%ebp),%eax
275: 83 c0 01 add $0x1,%eax
278: 0f b6 00 movzbl (%eax),%eax
27b: 84 c0 test %al,%al
27d: 75 10 jne 28f <matchhere+0x6f>
return *text == '\0';
27f: 8b 45 0c mov 0xc(%ebp),%eax
282: 0f b6 00 movzbl (%eax),%eax
285: 84 c0 test %al,%al
287: 0f 94 c0 sete %al
28a: 0f b6 c0 movzbl %al,%eax
28d: eb 44 jmp 2d3 <matchhere+0xb3>
if(*text!='\0' && (re[0]=='.' || re[0]==*text))
28f: 8b 45 0c mov 0xc(%ebp),%eax
292: 0f b6 00 movzbl (%eax),%eax
295: 84 c0 test %al,%al
297: 74 35 je 2ce <matchhere+0xae>
299: 8b 45 08 mov 0x8(%ebp),%eax
29c: 0f b6 00 movzbl (%eax),%eax
29f: 3c 2e cmp $0x2e,%al
2a1: 74 10 je 2b3 <matchhere+0x93>
2a3: 8b 45 08 mov 0x8(%ebp),%eax
2a6: 0f b6 10 movzbl (%eax),%edx
2a9: 8b 45 0c mov 0xc(%ebp),%eax
2ac: 0f b6 00 movzbl (%eax),%eax
2af: 38 c2 cmp %al,%dl
2b1: 75 1b jne 2ce <matchhere+0xae>
return matchhere(re+1, text+1);
2b3: 8b 45 0c mov 0xc(%ebp),%eax
2b6: 8d 50 01 lea 0x1(%eax),%edx
2b9: 8b 45 08 mov 0x8(%ebp),%eax
2bc: 83 c0 01 add $0x1,%eax
2bf: 83 ec 08 sub $0x8,%esp
2c2: 52 push %edx
2c3: 50 push %eax
2c4: e8 57 ff ff ff call 220 <matchhere>
2c9: 83 c4 10 add $0x10,%esp
2cc: eb 05 jmp 2d3 <matchhere+0xb3>
return 0;
2ce: b8 00 00 00 00 mov $0x0,%eax
}
2d3: c9 leave
2d4: c3 ret
000002d5 <matchstar>:
// matchstar: search for c*re at beginning of text
int matchstar(int c, char *re, char *text)
{
2d5: 55 push %ebp
2d6: 89 e5 mov %esp,%ebp
2d8: 83 ec 08 sub $0x8,%esp
do{ // a * matches zero or more instances
if(matchhere(re, text))
2db: 83 ec 08 sub $0x8,%esp
2de: ff 75 10 push 0x10(%ebp)
2e1: ff 75 0c push 0xc(%ebp)
2e4: e8 37 ff ff ff call 220 <matchhere>
2e9: 83 c4 10 add $0x10,%esp
2ec: 85 c0 test %eax,%eax
2ee: 74 07 je 2f7 <matchstar+0x22>
return 1;
2f0: b8 01 00 00 00 mov $0x1,%eax
2f5: eb 29 jmp 320 <matchstar+0x4b>
}while(*text!='\0' && (*text++==c || c=='.'));
2f7: 8b 45 10 mov 0x10(%ebp),%eax
2fa: 0f b6 00 movzbl (%eax),%eax
2fd: 84 c0 test %al,%al
2ff: 74 1a je 31b <matchstar+0x46>
301: 8b 45 10 mov 0x10(%ebp),%eax
304: 8d 50 01 lea 0x1(%eax),%edx
307: 89 55 10 mov %edx,0x10(%ebp)
30a: 0f b6 00 movzbl (%eax),%eax
30d: 0f be c0 movsbl %al,%eax
310: 39 45 08 cmp %eax,0x8(%ebp)
313: 74 c6 je 2db <matchstar+0x6>
315: 83 7d 08 2e cmpl $0x2e,0x8(%ebp)
319: 74 c0 je 2db <matchstar+0x6>
return 0;
31b: b8 00 00 00 00 mov $0x0,%eax
}
320: c9 leave
321: c3 ret
00000322 <stosb>:
"cc");
}
static inline void
stosb(void *addr, int data, int cnt)
{
322: 55 push %ebp
323: 89 e5 mov %esp,%ebp
325: 57 push %edi
326: 53 push %ebx
asm volatile("cld; rep stosb" :
327: 8b 4d 08 mov 0x8(%ebp),%ecx
32a: 8b 55 10 mov 0x10(%ebp),%edx
32d: 8b 45 0c mov 0xc(%ebp),%eax
330: 89 cb mov %ecx,%ebx
332: 89 df mov %ebx,%edi
334: 89 d1 mov %edx,%ecx
336: fc cld
337: f3 aa rep stos %al,%es:(%edi)
339: 89 ca mov %ecx,%edx
33b: 89 fb mov %edi,%ebx
33d: 89 5d 08 mov %ebx,0x8(%ebp)
340: 89 55 10 mov %edx,0x10(%ebp)
"=D" (addr), "=c" (cnt) :
"0" (addr), "1" (cnt), "a" (data) :
"memory", "cc");
}
343: 90 nop
344: 5b pop %ebx
345: 5f pop %edi
346: 5d pop %ebp
347: c3 ret
00000348 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, char *t)
{
348: 55 push %ebp
349: 89 e5 mov %esp,%ebp
34b: 83 ec 10 sub $0x10,%esp
char *os;
os = s;
34e: 8b 45 08 mov 0x8(%ebp),%eax
351: 89 45 fc mov %eax,-0x4(%ebp)
while((*s++ = *t++) != 0)
354: 90 nop
355: 8b 55 0c mov 0xc(%ebp),%edx
358: 8d 42 01 lea 0x1(%edx),%eax
35b: 89 45 0c mov %eax,0xc(%ebp)
35e: 8b 45 08 mov 0x8(%ebp),%eax
361: 8d 48 01 lea 0x1(%eax),%ecx
364: 89 4d 08 mov %ecx,0x8(%ebp)
367: 0f b6 12 movzbl (%edx),%edx
36a: 88 10 mov %dl,(%eax)
36c: 0f b6 00 movzbl (%eax),%eax
36f: 84 c0 test %al,%al
371: 75 e2 jne 355 <strcpy+0xd>
;
return os;
373: 8b 45 fc mov -0x4(%ebp),%eax
}
376: c9 leave
377: c3 ret
00000378 <strcmp>:
int
strcmp(const char *p, const char *q)
{
378: 55 push %ebp
379: 89 e5 mov %esp,%ebp
while(*p && *p == *q)
37b: eb 08 jmp 385 <strcmp+0xd>
p++, q++;
37d: 83 45 08 01 addl $0x1,0x8(%ebp)
381: 83 45 0c 01 addl $0x1,0xc(%ebp)
while(*p && *p == *q)
385: 8b 45 08 mov 0x8(%ebp),%eax
388: 0f b6 00 movzbl (%eax),%eax
38b: 84 c0 test %al,%al
38d: 74 10 je 39f <strcmp+0x27>
38f: 8b 45 08 mov 0x8(%ebp),%eax
392: 0f b6 10 movzbl (%eax),%edx
395: 8b 45 0c mov 0xc(%ebp),%eax
398: 0f b6 00 movzbl (%eax),%eax
39b: 38 c2 cmp %al,%dl
39d: 74 de je 37d <strcmp+0x5>
return (uchar)*p - (uchar)*q;
39f: 8b 45 08 mov 0x8(%ebp),%eax
3a2: 0f b6 00 movzbl (%eax),%eax
3a5: 0f b6 d0 movzbl %al,%edx
3a8: 8b 45 0c mov 0xc(%ebp),%eax
3ab: 0f b6 00 movzbl (%eax),%eax
3ae: 0f b6 c8 movzbl %al,%ecx
3b1: 89 d0 mov %edx,%eax
3b3: 29 c8 sub %ecx,%eax
}
3b5: 5d pop %ebp
3b6: c3 ret
000003b7 <strlen>:
uint
strlen(char *s)
{
3b7: 55 push %ebp
3b8: 89 e5 mov %esp,%ebp
3ba: 83 ec 10 sub $0x10,%esp
int n;
for(n = 0; s[n]; n++)
3bd: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
3c4: eb 04 jmp 3ca <strlen+0x13>
3c6: 83 45 fc 01 addl $0x1,-0x4(%ebp)
3ca: 8b 55 fc mov -0x4(%ebp),%edx
3cd: 8b 45 08 mov 0x8(%ebp),%eax
3d0: 01 d0 add %edx,%eax
3d2: 0f b6 00 movzbl (%eax),%eax
3d5: 84 c0 test %al,%al
3d7: 75 ed jne 3c6 <strlen+0xf>
;
return n;
3d9: 8b 45 fc mov -0x4(%ebp),%eax
}
3dc: c9 leave
3dd: c3 ret
000003de <memset>:
void*
memset(void *dst, int c, uint n)
{
3de: 55 push %ebp
3df: 89 e5 mov %esp,%ebp
stosb(dst, c, n);
3e1: 8b 45 10 mov 0x10(%ebp),%eax
3e4: 50 push %eax
3e5: ff 75 0c push 0xc(%ebp)
3e8: ff 75 08 push 0x8(%ebp)
3eb: e8 32 ff ff ff call 322 <stosb>
3f0: 83 c4 0c add $0xc,%esp
return dst;
3f3: 8b 45 08 mov 0x8(%ebp),%eax
}
3f6: c9 leave
3f7: c3 ret
000003f8 <strchr>:
char*
strchr(const char *s, char c)
{
3f8: 55 push %ebp
3f9: 89 e5 mov %esp,%ebp
3fb: 83 ec 04 sub $0x4,%esp
3fe: 8b 45 0c mov 0xc(%ebp),%eax
401: 88 45 fc mov %al,-0x4(%ebp)
for(; *s; s++)
404: eb 14 jmp 41a <strchr+0x22>
if(*s == c)
406: 8b 45 08 mov 0x8(%ebp),%eax
409: 0f b6 00 movzbl (%eax),%eax
40c: 38 45 fc cmp %al,-0x4(%ebp)
40f: 75 05 jne 416 <strchr+0x1e>
return (char*)s;
411: 8b 45 08 mov 0x8(%ebp),%eax
414: eb 13 jmp 429 <strchr+0x31>
for(; *s; s++)
416: 83 45 08 01 addl $0x1,0x8(%ebp)
41a: 8b 45 08 mov 0x8(%ebp),%eax
41d: 0f b6 00 movzbl (%eax),%eax
420: 84 c0 test %al,%al
422: 75 e2 jne 406 <strchr+0xe>
return 0;
424: b8 00 00 00 00 mov $0x0,%eax
}
429: c9 leave
42a: c3 ret
0000042b <gets>:
char*
gets(char *buf, int max)
{
42b: 55 push %ebp
42c: 89 e5 mov %esp,%ebp
42e: 83 ec 18 sub $0x18,%esp
int i, cc;
char c;
for(i=0; i+1 < max; ){
431: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
438: eb 42 jmp 47c <gets+0x51>
cc = read(0, &c, 1);
43a: 83 ec 04 sub $0x4,%esp
43d: 6a 01 push $0x1
43f: 8d 45 ef lea -0x11(%ebp),%eax
442: 50 push %eax
443: 6a 00 push $0x0
445: e8 77 01 00 00 call 5c1 <read>
44a: 83 c4 10 add $0x10,%esp
44d: 89 45 f0 mov %eax,-0x10(%ebp)
if(cc < 1)
450: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
454: 7e 33 jle 489 <gets+0x5e>
break;
buf[i++] = c;
456: 8b 45 f4 mov -0xc(%ebp),%eax
459: 8d 50 01 lea 0x1(%eax),%edx
45c: 89 55 f4 mov %edx,-0xc(%ebp)
45f: 89 c2 mov %eax,%edx
461: 8b 45 08 mov 0x8(%ebp),%eax
464: 01 c2 add %eax,%edx
466: 0f b6 45 ef movzbl -0x11(%ebp),%eax
46a: 88 02 mov %al,(%edx)
if(c == '\n' || c == '\r')
46c: 0f b6 45 ef movzbl -0x11(%ebp),%eax
470: 3c 0a cmp $0xa,%al
472: 74 16 je 48a <gets+0x5f>
474: 0f b6 45 ef movzbl -0x11(%ebp),%eax
478: 3c 0d cmp $0xd,%al
47a: 74 0e je 48a <gets+0x5f>
for(i=0; i+1 < max; ){
47c: 8b 45 f4 mov -0xc(%ebp),%eax
47f: 83 c0 01 add $0x1,%eax
482: 39 45 0c cmp %eax,0xc(%ebp)
485: 7f b3 jg 43a <gets+0xf>
487: eb 01 jmp 48a <gets+0x5f>
break;
489: 90 nop
break;
}
buf[i] = '\0';
48a: 8b 55 f4 mov -0xc(%ebp),%edx
48d: 8b 45 08 mov 0x8(%ebp),%eax
490: 01 d0 add %edx,%eax
492: c6 00 00 movb $0x0,(%eax)
return buf;
495: 8b 45 08 mov 0x8(%ebp),%eax
}
498: c9 leave
499: c3 ret
0000049a <stat>:
int
stat(char *n, struct stat *st)
{
49a: 55 push %ebp
49b: 89 e5 mov %esp,%ebp
49d: 83 ec 18 sub $0x18,%esp
int fd;
int r;
fd = open(n, O_RDONLY);
4a0: 83 ec 08 sub $0x8,%esp
4a3: 6a 00 push $0x0
4a5: ff 75 08 push 0x8(%ebp)
4a8: e8 3c 01 00 00 call 5e9 <open>
4ad: 83 c4 10 add $0x10,%esp
4b0: 89 45 f4 mov %eax,-0xc(%ebp)
if(fd < 0)
4b3: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
4b7: 79 07 jns 4c0 <stat+0x26>
return -1;
4b9: b8 ff ff ff ff mov $0xffffffff,%eax
4be: eb 25 jmp 4e5 <stat+0x4b>
r = fstat(fd, st);
4c0: 83 ec 08 sub $0x8,%esp
4c3: ff 75 0c push 0xc(%ebp)
4c6: ff 75 f4 push -0xc(%ebp)
4c9: e8 33 01 00 00 call 601 <fstat>
4ce: 83 c4 10 add $0x10,%esp
4d1: 89 45 f0 mov %eax,-0x10(%ebp)
close(fd);
4d4: 83 ec 0c sub $0xc,%esp
4d7: ff 75 f4 push -0xc(%ebp)
4da: e8 f2 00 00 00 call 5d1 <close>
4df: 83 c4 10 add $0x10,%esp
return r;
4e2: 8b 45 f0 mov -0x10(%ebp),%eax
}
4e5: c9 leave
4e6: c3 ret
000004e7 <atoi>:
int
atoi(const char *s)
{
4e7: 55 push %ebp
4e8: 89 e5 mov %esp,%ebp
4ea: 83 ec 10 sub $0x10,%esp
int n;
n = 0;
4ed: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
while('0' <= *s && *s <= '9')
4f4: eb 25 jmp 51b <atoi+0x34>
n = n*10 + *s++ - '0';
4f6: 8b 55 fc mov -0x4(%ebp),%edx
4f9: 89 d0 mov %edx,%eax
4fb: c1 e0 02 shl $0x2,%eax
4fe: 01 d0 add %edx,%eax
500: 01 c0 add %eax,%eax
502: 89 c1 mov %eax,%ecx
504: 8b 45 08 mov 0x8(%ebp),%eax
507: 8d 50 01 lea 0x1(%eax),%edx
50a: 89 55 08 mov %edx,0x8(%ebp)
50d: 0f b6 00 movzbl (%eax),%eax
510: 0f be c0 movsbl %al,%eax
513: 01 c8 add %ecx,%eax
515: 83 e8 30 sub $0x30,%eax
518: 89 45 fc mov %eax,-0x4(%ebp)
while('0' <= *s && *s <= '9')
51b: 8b 45 08 mov 0x8(%ebp),%eax
51e: 0f b6 00 movzbl (%eax),%eax
521: 3c 2f cmp $0x2f,%al
523: 7e 0a jle 52f <atoi+0x48>
525: 8b 45 08 mov 0x8(%ebp),%eax
528: 0f b6 00 movzbl (%eax),%eax
52b: 3c 39 cmp $0x39,%al
52d: 7e c7 jle 4f6 <atoi+0xf>
return n;
52f: 8b 45 fc mov -0x4(%ebp),%eax
}
532: c9 leave
533: c3 ret
00000534 <memmove>:
void*
memmove(void *vdst, void *vsrc, int n)
{
534: 55 push %ebp
535: 89 e5 mov %esp,%ebp
537: 83 ec 10 sub $0x10,%esp
char *dst, *src;
dst = vdst;
53a: 8b 45 08 mov 0x8(%ebp),%eax
53d: 89 45 fc mov %eax,-0x4(%ebp)
src = vsrc;
540: 8b 45 0c mov 0xc(%ebp),%eax
543: 89 45 f8 mov %eax,-0x8(%ebp)
while(n-- > 0)
546: eb 17 jmp 55f <memmove+0x2b>
*dst++ = *src++;
548: 8b 55 f8 mov -0x8(%ebp),%edx
54b: 8d 42 01 lea 0x1(%edx),%eax
54e: 89 45 f8 mov %eax,-0x8(%ebp)
551: 8b 45 fc mov -0x4(%ebp),%eax
554: 8d 48 01 lea 0x1(%eax),%ecx
557: 89 4d fc mov %ecx,-0x4(%ebp)
55a: 0f b6 12 movzbl (%edx),%edx
55d: 88 10 mov %dl,(%eax)
while(n-- > 0)
55f: 8b 45 10 mov 0x10(%ebp),%eax
562: 8d 50 ff lea -0x1(%eax),%edx
565: 89 55 10 mov %edx,0x10(%ebp)
568: 85 c0 test %eax,%eax
56a: 7f dc jg 548 <memmove+0x14>
return vdst;
56c: 8b 45 08 mov 0x8(%ebp),%eax
}
56f: c9 leave
570: c3 ret
00000571 <restorer>:
571: 83 c4 0c add $0xc,%esp
574: 5a pop %edx
575: 59 pop %ecx
576: 58 pop %eax
577: c3 ret
00000578 <signal>:
"pop %ecx\n\t"
"pop %eax\n\t"
"ret\n\t");
int signal(int signum, void(*handler)(int))
{
578: 55 push %ebp
579: 89 e5 mov %esp,%ebp
57b: 83 ec 08 sub $0x8,%esp
signal_restorer(restorer);
57e: 83 ec 0c sub $0xc,%esp
581: 68 71 05 00 00 push $0x571
586: e8 ce 00 00 00 call 659 <signal_restorer>
58b: 83 c4 10 add $0x10,%esp
return signal_register(signum, handler);
58e: 83 ec 08 sub $0x8,%esp
591: ff 75 0c push 0xc(%ebp)
594: ff 75 08 push 0x8(%ebp)
597: e8 b5 00 00 00 call 651 <signal_register>
59c: 83 c4 10 add $0x10,%esp
59f: c9 leave
5a0: c3 ret
000005a1 <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
5a1: b8 01 00 00 00 mov $0x1,%eax
5a6: cd 40 int $0x40
5a8: c3 ret
000005a9 <exit>:
SYSCALL(exit)
5a9: b8 02 00 00 00 mov $0x2,%eax
5ae: cd 40 int $0x40
5b0: c3 ret
000005b1 <wait>:
SYSCALL(wait)
5b1: b8 03 00 00 00 mov $0x3,%eax
5b6: cd 40 int $0x40
5b8: c3 ret
000005b9 <pipe>:
SYSCALL(pipe)
5b9: b8 04 00 00 00 mov $0x4,%eax
5be: cd 40 int $0x40
5c0: c3 ret
000005c1 <read>:
SYSCALL(read)
5c1: b8 05 00 00 00 mov $0x5,%eax
5c6: cd 40 int $0x40
5c8: c3 ret
000005c9 <write>:
SYSCALL(write)
5c9: b8 10 00 00 00 mov $0x10,%eax
5ce: cd 40 int $0x40
5d0: c3 ret
000005d1 <close>:
SYSCALL(close)
5d1: b8 15 00 00 00 mov $0x15,%eax
5d6: cd 40 int $0x40
5d8: c3 ret
000005d9 <kill>:
SYSCALL(kill)
5d9: b8 06 00 00 00 mov $0x6,%eax
5de: cd 40 int $0x40
5e0: c3 ret
000005e1 <exec>:
SYSCALL(exec)
5e1: b8 07 00 00 00 mov $0x7,%eax
5e6: cd 40 int $0x40
5e8: c3 ret
000005e9 <open>:
SYSCALL(open)
5e9: b8 0f 00 00 00 mov $0xf,%eax
5ee: cd 40 int $0x40
5f0: c3 ret
000005f1 <mknod>:
SYSCALL(mknod)
5f1: b8 11 00 00 00 mov $0x11,%eax
5f6: cd 40 int $0x40
5f8: c3 ret
000005f9 <unlink>:
SYSCALL(unlink)
5f9: b8 12 00 00 00 mov $0x12,%eax
5fe: cd 40 int $0x40
600: c3 ret
00000601 <fstat>:
SYSCALL(fstat)
601: b8 08 00 00 00 mov $0x8,%eax
606: cd 40 int $0x40
608: c3 ret
00000609 <link>:
SYSCALL(link)
609: b8 13 00 00 00 mov $0x13,%eax
60e: cd 40 int $0x40
610: c3 ret
00000611 <mkdir>:
SYSCALL(mkdir)
611: b8 14 00 00 00 mov $0x14,%eax
616: cd 40 int $0x40
618: c3 ret
00000619 <chdir>:
SYSCALL(chdir)
619: b8 09 00 00 00 mov $0x9,%eax
61e: cd 40 int $0x40
620: c3 ret
00000621 <dup>:
SYSCALL(dup)
621: b8 0a 00 00 00 mov $0xa,%eax
626: cd 40 int $0x40
628: c3 ret
00000629 <getpid>:
SYSCALL(getpid)
629: b8 0b 00 00 00 mov $0xb,%eax
62e: cd 40 int $0x40
630: c3 ret
00000631 <sbrk>:
SYSCALL(sbrk)
631: b8 0c 00 00 00 mov $0xc,%eax
636: cd 40 int $0x40
638: c3 ret
00000639 <sleep>:
SYSCALL(sleep)
639: b8 0d 00 00 00 mov $0xd,%eax
63e: cd 40 int $0x40
640: c3 ret
00000641 <uptime>:
SYSCALL(uptime)
641: b8 0e 00 00 00 mov $0xe,%eax
646: cd 40 int $0x40
648: c3 ret
00000649 <halt>:
SYSCALL(halt)
649: b8 16 00 00 00 mov $0x16,%eax
64e: cd 40 int $0x40
650: c3 ret
00000651 <signal_register>:
SYSCALL(signal_register)
651: b8 17 00 00 00 mov $0x17,%eax
656: cd 40 int $0x40
658: c3 ret
00000659 <signal_restorer>:
SYSCALL(signal_restorer)
659: b8 18 00 00 00 mov $0x18,%eax
65e: cd 40 int $0x40
660: c3 ret
00000661 <mprotect>:
SYSCALL(mprotect)
661: b8 19 00 00 00 mov $0x19,%eax
666: cd 40 int $0x40
668: c3 ret
00000669 <cowfork>:
SYSCALL(cowfork)
669: b8 1a 00 00 00 mov $0x1a,%eax
66e: cd 40 int $0x40
670: c3 ret
00000671 <dsbrk>:
SYSCALL(dsbrk)
671: b8 1b 00 00 00 mov $0x1b,%eax
676: cd 40 int $0x40
678: c3 ret
00000679 <putc>:
#include "stat.h"
#include "user.h"
static void
putc(int fd, char c)
{
679: 55 push %ebp
67a: 89 e5 mov %esp,%ebp
67c: 83 ec 18 sub $0x18,%esp
67f: 8b 45 0c mov 0xc(%ebp),%eax
682: 88 45 f4 mov %al,-0xc(%ebp)
write(fd, &c, 1);
685: 83 ec 04 sub $0x4,%esp
688: 6a 01 push $0x1
68a: 8d 45 f4 lea -0xc(%ebp),%eax
68d: 50 push %eax
68e: ff 75 08 push 0x8(%ebp)
691: e8 33 ff ff ff call 5c9 <write>
696: 83 c4 10 add $0x10,%esp
}
699: 90 nop
69a: c9 leave
69b: c3 ret
0000069c <printint>:
static void
printint(int fd, int xx, int base, int sgn)
{
69c: 55 push %ebp
69d: 89 e5 mov %esp,%ebp
69f: 83 ec 28 sub $0x28,%esp
static char digits[] = "0123456789ABCDEF";
char buf[16];
int i, neg;
uint x;
neg = 0;
6a2: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
if(sgn && xx < 0){
6a9: 83 7d 14 00 cmpl $0x0,0x14(%ebp)
6ad: 74 17 je 6c6 <printint+0x2a>
6af: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
6b3: 79 11 jns 6c6 <printint+0x2a>
neg = 1;
6b5: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp)
x = -xx;
6bc: 8b 45 0c mov 0xc(%ebp),%eax
6bf: f7 d8 neg %eax
6c1: 89 45 ec mov %eax,-0x14(%ebp)
6c4: eb 06 jmp 6cc <printint+0x30>
} else {
x = xx;
6c6: 8b 45 0c mov 0xc(%ebp),%eax
6c9: 89 45 ec mov %eax,-0x14(%ebp)
}
i = 0;
6cc: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
do{
buf[i++] = digits[x % base];
6d3: 8b 4d 10 mov 0x10(%ebp),%ecx
6d6: 8b 45 ec mov -0x14(%ebp),%eax
6d9: ba 00 00 00 00 mov $0x0,%edx
6de: f7 f1 div %ecx
6e0: 89 d1 mov %edx,%ecx
6e2: 8b 45 f4 mov -0xc(%ebp),%eax
6e5: 8d 50 01 lea 0x1(%eax),%edx
6e8: 89 55 f4 mov %edx,-0xc(%ebp)
6eb: 0f b6 91 44 0b 00 00 movzbl 0xb44(%ecx),%edx
6f2: 88 54 05 dc mov %dl,-0x24(%ebp,%eax,1)
}while((x /= base) != 0);
6f6: 8b 4d 10 mov 0x10(%ebp),%ecx
6f9: 8b 45 ec mov -0x14(%ebp),%eax
6fc: ba 00 00 00 00 mov $0x0,%edx
701: f7 f1 div %ecx
703: 89 45 ec mov %eax,-0x14(%ebp)
706: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
70a: 75 c7 jne 6d3 <printint+0x37>
if(neg)
70c: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
710: 74 2d je 73f <printint+0xa3>
buf[i++] = '-';
712: 8b 45 f4 mov -0xc(%ebp),%eax
715: 8d 50 01 lea 0x1(%eax),%edx
718: 89 55 f4 mov %edx,-0xc(%ebp)
71b: c6 44 05 dc 2d movb $0x2d,-0x24(%ebp,%eax,1)
while(--i >= 0)
720: eb 1d jmp 73f <printint+0xa3>
putc(fd, buf[i]);
722: 8d 55 dc lea -0x24(%ebp),%edx
725: 8b 45 f4 mov -0xc(%ebp),%eax
728: 01 d0 add %edx,%eax
72a: 0f b6 00 movzbl (%eax),%eax
72d: 0f be c0 movsbl %al,%eax
730: 83 ec 08 sub $0x8,%esp
733: 50 push %eax
734: ff 75 08 push 0x8(%ebp)
737: e8 3d ff ff ff call 679 <putc>
73c: 83 c4 10 add $0x10,%esp
while(--i >= 0)
73f: 83 6d f4 01 subl $0x1,-0xc(%ebp)
743: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
747: 79 d9 jns 722 <printint+0x86>
}
749: 90 nop
74a: 90 nop
74b: c9 leave
74c: c3 ret
0000074d <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
74d: 55 push %ebp
74e: 89 e5 mov %esp,%ebp
750: 83 ec 28 sub $0x28,%esp
char *s;
int c, i, state;
uint *ap;
state = 0;
753: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
ap = (uint*)(void*)&fmt + 1;
75a: 8d 45 0c lea 0xc(%ebp),%eax
75d: 83 c0 04 add $0x4,%eax
760: 89 45 e8 mov %eax,-0x18(%ebp)
for(i = 0; fmt[i]; i++){
763: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
76a: e9 59 01 00 00 jmp 8c8 <printf+0x17b>
c = fmt[i] & 0xff;
76f: 8b 55 0c mov 0xc(%ebp),%edx
772: 8b 45 f0 mov -0x10(%ebp),%eax
775: 01 d0 add %edx,%eax
777: 0f b6 00 movzbl (%eax),%eax
77a: 0f be c0 movsbl %al,%eax
77d: 25 ff 00 00 00 and $0xff,%eax
782: 89 45 e4 mov %eax,-0x1c(%ebp)
if(state == 0){
785: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
789: 75 2c jne 7b7 <printf+0x6a>
if(c == '%'){
78b: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
78f: 75 0c jne 79d <printf+0x50>
state = '%';
791: c7 45 ec 25 00 00 00 movl $0x25,-0x14(%ebp)
798: e9 27 01 00 00 jmp 8c4 <printf+0x177>
} else {
putc(fd, c);
79d: 8b 45 e4 mov -0x1c(%ebp),%eax
7a0: 0f be c0 movsbl %al,%eax
7a3: 83 ec 08 sub $0x8,%esp
7a6: 50 push %eax
7a7: ff 75 08 push 0x8(%ebp)
7aa: e8 ca fe ff ff call 679 <putc>
7af: 83 c4 10 add $0x10,%esp
7b2: e9 0d 01 00 00 jmp 8c4 <printf+0x177>
}
} else if(state == '%'){
7b7: 83 7d ec 25 cmpl $0x25,-0x14(%ebp)
7bb: 0f 85 03 01 00 00 jne 8c4 <printf+0x177>
if(c == 'd'){
7c1: 83 7d e4 64 cmpl $0x64,-0x1c(%ebp)
7c5: 75 1e jne 7e5 <printf+0x98>
printint(fd, *ap, 10, 1);
7c7: 8b 45 e8 mov -0x18(%ebp),%eax
7ca: 8b 00 mov (%eax),%eax
7cc: 6a 01 push $0x1
7ce: 6a 0a push $0xa
7d0: 50 push %eax
7d1: ff 75 08 push 0x8(%ebp)
7d4: e8 c3 fe ff ff call 69c <printint>
7d9: 83 c4 10 add $0x10,%esp
ap++;
7dc: 83 45 e8 04 addl $0x4,-0x18(%ebp)
7e0: e9 d8 00 00 00 jmp 8bd <printf+0x170>
} else if(c == 'x' || c == 'p'){
7e5: 83 7d e4 78 cmpl $0x78,-0x1c(%ebp)
7e9: 74 06 je 7f1 <printf+0xa4>
7eb: 83 7d e4 70 cmpl $0x70,-0x1c(%ebp)
7ef: 75 1e jne 80f <printf+0xc2>
printint(fd, *ap, 16, 0);
7f1: 8b 45 e8 mov -0x18(%ebp),%eax
7f4: 8b 00 mov (%eax),%eax
7f6: 6a 00 push $0x0
7f8: 6a 10 push $0x10
7fa: 50 push %eax
7fb: ff 75 08 push 0x8(%ebp)
7fe: e8 99 fe ff ff call 69c <printint>
803: 83 c4 10 add $0x10,%esp
ap++;
806: 83 45 e8 04 addl $0x4,-0x18(%ebp)
80a: e9 ae 00 00 00 jmp 8bd <printf+0x170>
} else if(c == 's'){
80f: 83 7d e4 73 cmpl $0x73,-0x1c(%ebp)
813: 75 43 jne 858 <printf+0x10b>
s = (char*)*ap;
815: 8b 45 e8 mov -0x18(%ebp),%eax
818: 8b 00 mov (%eax),%eax
81a: 89 45 f4 mov %eax,-0xc(%ebp)
ap++;
81d: 83 45 e8 04 addl $0x4,-0x18(%ebp)
if(s == 0)
821: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
825: 75 25 jne 84c <printf+0xff>
s = "(null)";
827: c7 45 f4 3a 0b 00 00 movl $0xb3a,-0xc(%ebp)
while(*s != 0){
82e: eb 1c jmp 84c <printf+0xff>
putc(fd, *s);
830: 8b 45 f4 mov -0xc(%ebp),%eax
833: 0f b6 00 movzbl (%eax),%eax
836: 0f be c0 movsbl %al,%eax
839: 83 ec 08 sub $0x8,%esp
83c: 50 push %eax
83d: ff 75 08 push 0x8(%ebp)
840: e8 34 fe ff ff call 679 <putc>
845: 83 c4 10 add $0x10,%esp
s++;
848: 83 45 f4 01 addl $0x1,-0xc(%ebp)
while(*s != 0){
84c: 8b 45 f4 mov -0xc(%ebp),%eax
84f: 0f b6 00 movzbl (%eax),%eax
852: 84 c0 test %al,%al
854: 75 da jne 830 <printf+0xe3>
856: eb 65 jmp 8bd <printf+0x170>
}
} else if(c == 'c'){
858: 83 7d e4 63 cmpl $0x63,-0x1c(%ebp)
85c: 75 1d jne 87b <printf+0x12e>
putc(fd, *ap);
85e: 8b 45 e8 mov -0x18(%ebp),%eax
861: 8b 00 mov (%eax),%eax
863: 0f be c0 movsbl %al,%eax
866: 83 ec 08 sub $0x8,%esp
869: 50 push %eax
86a: ff 75 08 push 0x8(%ebp)
86d: e8 07 fe ff ff call 679 <putc>
872: 83 c4 10 add $0x10,%esp
ap++;
875: 83 45 e8 04 addl $0x4,-0x18(%ebp)
879: eb 42 jmp 8bd <printf+0x170>
} else if(c == '%'){
87b: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
87f: 75 17 jne 898 <printf+0x14b>
putc(fd, c);
881: 8b 45 e4 mov -0x1c(%ebp),%eax
884: 0f be c0 movsbl %al,%eax
887: 83 ec 08 sub $0x8,%esp
88a: 50 push %eax
88b: ff 75 08 push 0x8(%ebp)
88e: e8 e6 fd ff ff call 679 <putc>
893: 83 c4 10 add $0x10,%esp
896: eb 25 jmp 8bd <printf+0x170>
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
898: 83 ec 08 sub $0x8,%esp
89b: 6a 25 push $0x25
89d: ff 75 08 push 0x8(%ebp)
8a0: e8 d4 fd ff ff call 679 <putc>
8a5: 83 c4 10 add $0x10,%esp
putc(fd, c);
8a8: 8b 45 e4 mov -0x1c(%ebp),%eax
8ab: 0f be c0 movsbl %al,%eax
8ae: 83 ec 08 sub $0x8,%esp
8b1: 50 push %eax
8b2: ff 75 08 push 0x8(%ebp)
8b5: e8 bf fd ff ff call 679 <putc>
8ba: 83 c4 10 add $0x10,%esp
}
state = 0;
8bd: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
for(i = 0; fmt[i]; i++){
8c4: 83 45 f0 01 addl $0x1,-0x10(%ebp)
8c8: 8b 55 0c mov 0xc(%ebp),%edx
8cb: 8b 45 f0 mov -0x10(%ebp),%eax
8ce: 01 d0 add %edx,%eax
8d0: 0f b6 00 movzbl (%eax),%eax
8d3: 84 c0 test %al,%al
8d5: 0f 85 94 fe ff ff jne 76f <printf+0x22>
}
}
}
8db: 90 nop
8dc: 90 nop
8dd: c9 leave
8de: c3 ret
000008df <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
8df: 55 push %ebp
8e0: 89 e5 mov %esp,%ebp
8e2: 83 ec 10 sub $0x10,%esp
Header *bp, *p;
bp = (Header*)ap - 1;
8e5: 8b 45 08 mov 0x8(%ebp),%eax
8e8: 83 e8 08 sub $0x8,%eax
8eb: 89 45 f8 mov %eax,-0x8(%ebp)
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
8ee: a1 68 0f 00 00 mov 0xf68,%eax
8f3: 89 45 fc mov %eax,-0x4(%ebp)
8f6: eb 24 jmp 91c <free+0x3d>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
8f8: 8b 45 fc mov -0x4(%ebp),%eax
8fb: 8b 00 mov (%eax),%eax
8fd: 39 45 fc cmp %eax,-0x4(%ebp)
900: 72 12 jb 914 <free+0x35>
902: 8b 45 f8 mov -0x8(%ebp),%eax
905: 3b 45 fc cmp -0x4(%ebp),%eax
908: 77 24 ja 92e <free+0x4f>
90a: 8b 45 fc mov -0x4(%ebp),%eax
90d: 8b 00 mov (%eax),%eax
90f: 39 45 f8 cmp %eax,-0x8(%ebp)
912: 72 1a jb 92e <free+0x4f>
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
914: 8b 45 fc mov -0x4(%ebp),%eax
917: 8b 00 mov (%eax),%eax
919: 89 45 fc mov %eax,-0x4(%ebp)
91c: 8b 45 f8 mov -0x8(%ebp),%eax
91f: 3b 45 fc cmp -0x4(%ebp),%eax
922: 76 d4 jbe 8f8 <free+0x19>
924: 8b 45 fc mov -0x4(%ebp),%eax
927: 8b 00 mov (%eax),%eax
929: 39 45 f8 cmp %eax,-0x8(%ebp)
92c: 73 ca jae 8f8 <free+0x19>
break;
if(bp + bp->s.size == p->s.ptr){
92e: 8b 45 f8 mov -0x8(%ebp),%eax
931: 8b 40 04 mov 0x4(%eax),%eax
934: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
93b: 8b 45 f8 mov -0x8(%ebp),%eax
93e: 01 c2 add %eax,%edx
940: 8b 45 fc mov -0x4(%ebp),%eax
943: 8b 00 mov (%eax),%eax
945: 39 c2 cmp %eax,%edx
947: 75 24 jne 96d <free+0x8e>
bp->s.size += p->s.ptr->s.size;
949: 8b 45 f8 mov -0x8(%ebp),%eax
94c: 8b 50 04 mov 0x4(%eax),%edx
94f: 8b 45 fc mov -0x4(%ebp),%eax
952: 8b 00 mov (%eax),%eax
954: 8b 40 04 mov 0x4(%eax),%eax
957: 01 c2 add %eax,%edx
959: 8b 45 f8 mov -0x8(%ebp),%eax
95c: 89 50 04 mov %edx,0x4(%eax)
bp->s.ptr = p->s.ptr->s.ptr;
95f: 8b 45 fc mov -0x4(%ebp),%eax
962: 8b 00 mov (%eax),%eax
964: 8b 10 mov (%eax),%edx
966: 8b 45 f8 mov -0x8(%ebp),%eax
969: 89 10 mov %edx,(%eax)
96b: eb 0a jmp 977 <free+0x98>
} else
bp->s.ptr = p->s.ptr;
96d: 8b 45 fc mov -0x4(%ebp),%eax
970: 8b 10 mov (%eax),%edx
972: 8b 45 f8 mov -0x8(%ebp),%eax
975: 89 10 mov %edx,(%eax)
if(p + p->s.size == bp){
977: 8b 45 fc mov -0x4(%ebp),%eax
97a: 8b 40 04 mov 0x4(%eax),%eax
97d: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
984: 8b 45 fc mov -0x4(%ebp),%eax
987: 01 d0 add %edx,%eax
989: 39 45 f8 cmp %eax,-0x8(%ebp)
98c: 75 20 jne 9ae <free+0xcf>
p->s.size += bp->s.size;
98e: 8b 45 fc mov -0x4(%ebp),%eax
991: 8b 50 04 mov 0x4(%eax),%edx
994: 8b 45 f8 mov -0x8(%ebp),%eax
997: 8b 40 04 mov 0x4(%eax),%eax
99a: 01 c2 add %eax,%edx
99c: 8b 45 fc mov -0x4(%ebp),%eax
99f: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
9a2: 8b 45 f8 mov -0x8(%ebp),%eax
9a5: 8b 10 mov (%eax),%edx
9a7: 8b 45 fc mov -0x4(%ebp),%eax
9aa: 89 10 mov %edx,(%eax)
9ac: eb 08 jmp 9b6 <free+0xd7>
} else
p->s.ptr = bp;
9ae: 8b 45 fc mov -0x4(%ebp),%eax
9b1: 8b 55 f8 mov -0x8(%ebp),%edx
9b4: 89 10 mov %edx,(%eax)
freep = p;
9b6: 8b 45 fc mov -0x4(%ebp),%eax
9b9: a3 68 0f 00 00 mov %eax,0xf68
}
9be: 90 nop
9bf: c9 leave
9c0: c3 ret
000009c1 <morecore>:
static Header*
morecore(uint nu)
{
9c1: 55 push %ebp
9c2: 89 e5 mov %esp,%ebp
9c4: 83 ec 18 sub $0x18,%esp
char *p;
Header *hp;
if(nu < 4096)
9c7: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp)
9ce: 77 07 ja 9d7 <morecore+0x16>
nu = 4096;
9d0: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp)
p = sbrk(nu * sizeof(Header));
9d7: 8b 45 08 mov 0x8(%ebp),%eax
9da: c1 e0 03 shl $0x3,%eax
9dd: 83 ec 0c sub $0xc,%esp
9e0: 50 push %eax
9e1: e8 4b fc ff ff call 631 <sbrk>
9e6: 83 c4 10 add $0x10,%esp
9e9: 89 45 f4 mov %eax,-0xc(%ebp)
if(p == (char*)-1)
9ec: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp)
9f0: 75 07 jne 9f9 <morecore+0x38>
return 0;
9f2: b8 00 00 00 00 mov $0x0,%eax
9f7: eb 26 jmp a1f <morecore+0x5e>
hp = (Header*)p;
9f9: 8b 45 f4 mov -0xc(%ebp),%eax
9fc: 89 45 f0 mov %eax,-0x10(%ebp)
hp->s.size = nu;
9ff: 8b 45 f0 mov -0x10(%ebp),%eax
a02: 8b 55 08 mov 0x8(%ebp),%edx
a05: 89 50 04 mov %edx,0x4(%eax)
free((void*)(hp + 1));
a08: 8b 45 f0 mov -0x10(%ebp),%eax
a0b: 83 c0 08 add $0x8,%eax
a0e: 83 ec 0c sub $0xc,%esp
a11: 50 push %eax
a12: e8 c8 fe ff ff call 8df <free>
a17: 83 c4 10 add $0x10,%esp
return freep;
a1a: a1 68 0f 00 00 mov 0xf68,%eax
}
a1f: c9 leave
a20: c3 ret
00000a21 <malloc>:
void*
malloc(uint nbytes)
{
a21: 55 push %ebp
a22: 89 e5 mov %esp,%ebp
a24: 83 ec 18 sub $0x18,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
a27: 8b 45 08 mov 0x8(%ebp),%eax
a2a: 83 c0 07 add $0x7,%eax
a2d: c1 e8 03 shr $0x3,%eax
a30: 83 c0 01 add $0x1,%eax
a33: 89 45 ec mov %eax,-0x14(%ebp)
if((prevp = freep) == 0){
a36: a1 68 0f 00 00 mov 0xf68,%eax
a3b: 89 45 f0 mov %eax,-0x10(%ebp)
a3e: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
a42: 75 23 jne a67 <malloc+0x46>
base.s.ptr = freep = prevp = &base;
a44: c7 45 f0 60 0f 00 00 movl $0xf60,-0x10(%ebp)
a4b: 8b 45 f0 mov -0x10(%ebp),%eax
a4e: a3 68 0f 00 00 mov %eax,0xf68
a53: a1 68 0f 00 00 mov 0xf68,%eax
a58: a3 60 0f 00 00 mov %eax,0xf60
base.s.size = 0;
a5d: c7 05 64 0f 00 00 00 movl $0x0,0xf64
a64: 00 00 00
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
a67: 8b 45 f0 mov -0x10(%ebp),%eax
a6a: 8b 00 mov (%eax),%eax
a6c: 89 45 f4 mov %eax,-0xc(%ebp)
if(p->s.size >= nunits){
a6f: 8b 45 f4 mov -0xc(%ebp),%eax
a72: 8b 40 04 mov 0x4(%eax),%eax
a75: 39 45 ec cmp %eax,-0x14(%ebp)
a78: 77 4d ja ac7 <malloc+0xa6>
if(p->s.size == nunits)
a7a: 8b 45 f4 mov -0xc(%ebp),%eax
a7d: 8b 40 04 mov 0x4(%eax),%eax
a80: 39 45 ec cmp %eax,-0x14(%ebp)
a83: 75 0c jne a91 <malloc+0x70>
prevp->s.ptr = p->s.ptr;
a85: 8b 45 f4 mov -0xc(%ebp),%eax
a88: 8b 10 mov (%eax),%edx
a8a: 8b 45 f0 mov -0x10(%ebp),%eax
a8d: 89 10 mov %edx,(%eax)
a8f: eb 26 jmp ab7 <malloc+0x96>
else {
p->s.size -= nunits;
a91: 8b 45 f4 mov -0xc(%ebp),%eax
a94: 8b 40 04 mov 0x4(%eax),%eax
a97: 2b 45 ec sub -0x14(%ebp),%eax
a9a: 89 c2 mov %eax,%edx
a9c: 8b 45 f4 mov -0xc(%ebp),%eax
a9f: 89 50 04 mov %edx,0x4(%eax)
p += p->s.size;
aa2: 8b 45 f4 mov -0xc(%ebp),%eax
aa5: 8b 40 04 mov 0x4(%eax),%eax
aa8: c1 e0 03 shl $0x3,%eax
aab: 01 45 f4 add %eax,-0xc(%ebp)
p->s.size = nunits;
aae: 8b 45 f4 mov -0xc(%ebp),%eax
ab1: 8b 55 ec mov -0x14(%ebp),%edx
ab4: 89 50 04 mov %edx,0x4(%eax)
}
freep = prevp;
ab7: 8b 45 f0 mov -0x10(%ebp),%eax
aba: a3 68 0f 00 00 mov %eax,0xf68
return (void*)(p + 1);
abf: 8b 45 f4 mov -0xc(%ebp),%eax
ac2: 83 c0 08 add $0x8,%eax
ac5: eb 3b jmp b02 <malloc+0xe1>
}
if(p == freep)
ac7: a1 68 0f 00 00 mov 0xf68,%eax
acc: 39 45 f4 cmp %eax,-0xc(%ebp)
acf: 75 1e jne aef <malloc+0xce>
if((p = morecore(nunits)) == 0)
ad1: 83 ec 0c sub $0xc,%esp
ad4: ff 75 ec push -0x14(%ebp)
ad7: e8 e5 fe ff ff call 9c1 <morecore>
adc: 83 c4 10 add $0x10,%esp
adf: 89 45 f4 mov %eax,-0xc(%ebp)
ae2: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
ae6: 75 07 jne aef <malloc+0xce>
return 0;
ae8: b8 00 00 00 00 mov $0x0,%eax
aed: eb 13 jmp b02 <malloc+0xe1>
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
aef: 8b 45 f4 mov -0xc(%ebp),%eax
af2: 89 45 f0 mov %eax,-0x10(%ebp)
af5: 8b 45 f4 mov -0xc(%ebp),%eax
af8: 8b 00 mov (%eax),%eax
afa: 89 45 f4 mov %eax,-0xc(%ebp)
if(p->s.size >= nunits){
afd: e9 6d ff ff ff jmp a6f <malloc+0x4e>
}
}
b02: c9 leave
b03: c3 ret
|
Library/Chart/CGrObj/cgrobjSpline.asm | steakknife/pcgeos | 504 | 101465 | COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) GeoWorks 1992 -- All Rights Reserved
PROJECT: PC GEOS
MODULE:
FILE: cgrobjSpline.asm
AUTHOR: <NAME>
ROUTINES:
Name Description
---- -----------
REVISION HISTORY:
Name Date Description
---- ---- -----------
cdb 6/ 2/92 Initial version.
DESCRIPTION:
$Id: cgrobjSpline.asm,v 1.1 97/04/04 17:48:05 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ChartSplineGuardianInvertHandles
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION: send a message to the spline
PASS: *ds:si = ChartSplineGuardianClass object
ds:di = ChartSplineGuardianClass instance data
es = segment of ChartSplineGuardianClass
dx - gstate handle
RETURN:
DESTROYED: nothing
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
cdb 6/ 8/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ChartSplineGuardianInvertHandles method dynamic ChartSplineGuardianClass,
MSG_GO_INVERT_HANDLES
uses cx,dx,bp
.enter
mov di, dx ; gstate
call GrSaveTransform
call GrObjApplyNormalTransform
mov dx, di ; gstate
mov ax, MSG_GOVG_APPLY_OBJECT_TO_VIS_TRANSFORM
call ObjCallInstanceNoLock
push dx ; gstate
mov ax, MSG_GOVG_GET_VIS_WARD_OD
call ObjCallInstanceNoLock ; cx:dx - ward
movdw bxsi, cxdx
pop bp ; gstate
mov ax, MSG_SPLINE_INVERT_HOLLOW_HANDLES
mov di, mask MF_FIXUP_DS
call ObjMessage
mov di, bp ; gstate
call GrRestoreTransform
.leave
ret
ChartSplineGuardianInvertHandles endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ChartSplineGuardianInitialize
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION: set the GrObjMessageOptimizationFlags so that
MSG_GO_DRAW_LINE is always sent (so that markers will
be drawn)
PASS: *ds:si - ChartSplineGuardianClass object
ds:di - ChartSplineGuardianClass instance data
es - segment of ChartSplineGuardianClass
RETURN: nothing
DESTROYED: ax
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
chrisb 12/28/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ChartSplineGuardianInitialize method dynamic ChartSplineGuardianClass,
MSG_GO_INITIALIZE
uses cx,dx,bp
.enter
mov di, offset ChartSplineGuardianClass
call ObjCallSuperNoLock
;
; Set the GOMOF_DRAW_FG_LINE flag
;
mov di, ds:[si]
add di, ds:[di].GrObj_offset
ornf ds:[di].GOI_msgOptFlags, mask GOMOF_DRAW_FG_LINE
.leave
ret
ChartSplineGuardianInitialize endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ChartSplineGuardianGetClass
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION:
PASS: *ds:si - ChartSplineGuardianClass object
ds:di - ChartSplineGuardianClass instance data
es - segment of ChartSplineGuardianClass
RETURN:
DESTROYED: nothing
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
chrisb 1/19/93 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ChartSplineGuardianGetClass method dynamic ChartSplineGuardianClass,
MSG_META_GET_CLASS
mov cx, segment SplineGuardianClass
mov dx, offset SplineGuardianClass
ret
ChartSplineGuardianGetClass endm
|
scripts/chrometabs2markdown.scpt | eloypnd/dropbox | 0 | 4379 | <filename>scripts/chrometabs2markdown.scpt
(* Copy all open tabs from the Google Chrome windows that have focus
*
* @param targetWindow -- chrome window to copy tabs
*
* version: 0.2
* author: <NAME> <<EMAIL>>
* license: MIT
*)
on run (arg)
set targetWindow to 1 -- default window is 1
if arg's length is 1 then set targetWindow to arg's item 1 as number
set urlList to {}
tell application "Google Chrome"
activate
set chromeWindow to window targetWindow
repeat with w in chromeWindow
try
repeat with t in (tabs of w)
set tabTitle to (title of t)
set tabUrl to (URL of t)
set tabLine to ("- [" & tabTitle & "](" & tabUrl & ")")
copy tabLine to the end of urlList
end repeat
end try
end repeat
end tell
set text item delimiters to linefeed
set the clipboard to urlList as text
return urlList as text
end run
|
libsrc/_DEVELOPMENT/sound/bit/c/sdcc_iy/bit_play_fastcall.asm | meesokim/z88dk | 0 | 96160 |
; char *bit_play_fastcall(char *melody)
SECTION code_sound_bit
PUBLIC _bit_play_fastcall
EXTERN asm_bit_play
defc _bit_play_fastcall = asm_bit_play
|
oeis/141/A141975.asm | neoneye/loda-programs | 11 | 160151 | <filename>oeis/141/A141975.asm
; A141975: Primes congruent to 25 mod 28.
; Submitted by <NAME>
; 53,109,137,193,277,389,557,613,641,809,977,1033,1061,1117,1201,1229,1453,1481,1621,1733,1789,1873,1901,2069,2153,2237,2293,2377,2657,2713,2741,2797,2909,3049,3217,3301,3329,3413,3469,3581,3637,3833,3889,3917,4001,4057,4253,4337,4421,4561,4673,4729,4813,5009,5233,5261,5569,5653,5737,5821,5849,6073,6101,6269,6353,6521,6577,6661,6689,6829,6857,6997,7109,7193,7333,7417,7529,7669,7753,7949,8089,8117,8369,8537,8677,8761,8929,9013,9041,9181,9209,9293,9349,9377,9433,9461,9601,9629,9769,10133
mov $2,$0
add $2,6
pow $2,2
mov $4,24
lpb $2
mov $3,$4
seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0.
sub $0,$3
mov $1,$0
max $1,0
cmp $1,$0
mul $2,$1
sub $2,1
add $4,28
lpe
mov $0,$4
add $0,1
|
src/main/antlr4/imports/Declarations.g4 | Yucukof/edu-antlr4-toy-parser-to-nbc | 0 | 7732 | grammar Declarations;
import Instructions
, Types
, Words;
varDecl: varType ';'
;
fctDecl: ID AS FUNCTION '(' (varType (',' varType)* )? ')' ':' (scalar | VOID)
(DECLARE LOCAL varDecl+)?
DO instruction*
(RETURN (expression | VOID))?
DONE
;
varType: ID AS type
; |
hacks/images/m6502/sflake.asm | MBrassey/xscreensaver_BlueMatrix | 2 | 13410 | ;; <NAME> 01-December-2008
;; Snowflakes
;; Main loop Count
lda #7
sta $f
;; pattern number
lda #0
sta $10
;;Cells
lda #$00
sta $4
lda #$10
sta $5
;;Tmp
lda #$00
sta $6
lda #$11
sta $7
;;Init Cells Buffer
;;------------------------------------------------------------
ldy #$ff
initCells:
lda #0
sta ($4),y
sta ($6),y
dey
bne initCells
;;Set start position
ldy #115
lda #1
sta ($4),y
;;Setup offset
lda #15
sta $d
lda #16
sta $e
;;Start of main loop
;;------------------------------------------------------------
mainloop:
;;init indent
;;We want to indent every other line
lda #0
sta $a
lda #0
sta $9
;; Display Cells
;;------------------------------------------------------------
;; 248 is the total number of cells
ldy #248
display:
lda #0
sta $8
lda $a
beq stop16
lda #15
sta $b
lda #1
sta $8
jmp toggle
stop16:
lda #16
sta $b
toggle:
lda $a
eor #1
sta $a
;; Set the stop position
ldx $b
inner_display:
dex
txa
pha
dey
tya
pha
lda ($4),y
beq display_continue
ldx $8
ldy $9
lda #1
jsr paint
ldx $8
ldy $9
inx
jsr paint
ldx $8
ldy $9
iny
jsr paint
ldx $8
ldy $9
inx
iny
jsr paint
display_continue:
inc $8
inc $8
;;Life Cycle
;;------------------------------------------------------------
pla
tay
pha ;;Store y on the stack
tax
dey
lda ($4),y
iny
iny
clc
adc ($4),y
sta $c
txa
sec
sbc $d
tay
lda $c
clc
adc ($4),y
sta $c
txa
sec
sbc $e
tay
lda $c
clc
adc ($4),y
sta $c
txa
clc
adc $d
tay
lda $c
clc
adc ($4),y
sta $c
txa
clc
adc $e
tay
lda $c
clc
adc ($4),y
sta $c
pla
tay ;;Pull Y off of the stack
lda $c
and #1
beq dontset
sta ($6),y
dontset:
pla
tax ;;Pull x off of the stack
beq exit_inner_display
jmp inner_display
exit_inner_display:
inc $9
inc $9
tya
beq display_exit
jmp display
display_exit:
;;Copy Temporary Buffer
;;------------------------------------------------------------
ldy #248
copybuf:
dey
lda ($6),y
sta ($4),y
tya
bne copybuf
dec $f
lda $f
beq reset_main
jmp mainloop
;;Reset main counter
;;------------------------------------------------------------
reset_main:
lda #7
sta $f
lda #$ff ;;Delay Count
sta $11
delay:
ldy #$a0
inner_delay:
nop
dey
bne inner_delay
dec $11
lda $11
bne delay
;; init buffer
;; and clear screen
clrscr:
lda $fe
and $f
cmp #1
beq clrscr ;We don't want a white background
ldy #$00
ldx #$0
cs_loop:
sta $200,x
sta $300,x
sta $400,x
sta $500,x
pha
lda #0
sta ($6),y
sta ($4),y
pla
inx
dey
bne cs_loop
;; Setup new pattern
;;------------------------------------------------------------
inc $10
lda $10
and #3
sta $10
cmp #0
beq pattern1
cmp #1
beq pattern2
cmp #2
beq pattern3
cmp #3
beq pattern4
pattern1:
ldy #114
lda #1
sta ($4),y
ldy #115
lda #1
sta ($4),y
ldy #116
lda #1
sta ($4),y
jmp mainloop
pattern2:
ldy #113
lda #1
sta ($4),y
ldy #118
lda #1
sta ($4),y
jmp mainloop
pattern3:
ldy #115
lda #1
sta ($4),y
jmp mainloop
pattern4:
ldy #102
lda #1
sta ($4),y
ldy #128
lda #1
sta ($4),y
jmp mainloop
;;Paint subroutine
;;------------------------------------------------------------
paint:
pha
lda yl,y
sta $2
lda yh,y
sta $3
txa
tay
pla
sta ($2),y
rts
;; Y cord MSB
yh:
dcb $02, $02, $02, $02, $02, $02, $02, $02
dcb $03, $03, $03, $03, $03, $03, $03, $03
dcb $04, $04, $04, $04, $04, $04, $04, $04
dcb $05, $05, $05, $05, $05, $05, $05, $05
;; Y cord LSB
yl:
dcb $00, $20, $40, $60, $80, $a0, $c0, $e0
dcb $00, $20, $40, $60, $80, $a0, $c0, $e0
dcb $00, $20, $40, $60, $80, $a0, $c0, $e0
dcb $00, $20, $40, $60, $80, $a0, $c0, $e0
|
source/modules/basic/expressions/number/sgn.asm | paulscottrobson/mega-basic | 3 | 23426 | ; *******************************************************************************************
; *******************************************************************************************
;
; Name : sgn.asm
; Purpose : Sgn( unary function
; Date : 22nd August 2019
; Review : 1st September 2019
; Author : <NAME> (<EMAIL>)
;
; *******************************************************************************************
; *******************************************************************************************
Unary_Sgn: ;; sgn(
jsr EvaluateNumberX ; get value
jsr CheckNextRParen ; check right bracket.
;
jsr GetSignCurrent ; get sign.
ora #0
bpl UnarySetAInteger ; if 0,1 return that.
bra UnarySetAMinus1 ; -1 return $FFFFF...
; *******************************************************************************************
;
; Helper routines to return an integer or -1
;
; *******************************************************************************************
UnarySetAMinus1:
lda #$FF ; put -1 in all four slots.
sta XS_Mantissa,x
bra UnarySetAFill
;
UnarySetAInteger: ; put A in slot, 0 in all the rest
sta XS_Mantissa,x
lda #0
UnarySetAFill:
sta XS_Mantissa+1,x
sta XS_Mantissa+2,x
sta XS_Mantissa+3,x
lda #1 ; set type to integer.
sta XS_Type,x
rts
; *******************************************************************************************
;
; Get sign of current
;
; *******************************************************************************************
GetSignCurrent:
lda XS_Type,x ; identify type.
lsr a ; if LSB set it is integer.
bcc _GSCFloat ; if clear do the float code.
;
lda XS_Mantissa+3,x ; if msb of integer set, it's negative
bmi _GSCMinus1
ora XS_Mantissa+0,x
ora XS_Mantissa+1,x
ora XS_Mantissa+2,x
bne _GSCPlus1 ; check if zero by oring all together.
;
_GSCZero: ; return 0
lda #0
rts
_GSCPlus1: ; return 1
lda #$01
rts
_GSCMinus1: ; return -1
lda #$FF
rts
;
; Get float sign.
;
_GSCFloat:
bit XS_Type,x ; check bits
bvs _GSCZero ; if zero flag set return zero
bmi _GSCMinus1 ; if sign set return -1
bra _GSCPlus1 ; else return +1
|
programs/oeis/280/A280173.asm | neoneye/loda | 22 | 12897 | ; A280173: a(0) = 1, a(n+1) = 2*a(n) + periodic sequence of length 2: repeat [5, -4].
; 1,7,10,25,46,97,190,385,766,1537,3070,6145,12286,24577,49150,98305,196606,393217,786430,1572865,3145726,6291457,12582910,25165825,50331646,100663297,201326590,402653185,805306366,1610612737,3221225470,6442450945,12884901886,25769803777,51539607550,103079215105,206158430206,412316860417,824633720830,1649267441665,3298534883326,6597069766657,13194139533310,26388279066625,52776558133246,105553116266497,211106232532990,422212465065985,844424930131966,1688849860263937,3377699720527870,6755399441055745,13510798882111486,27021597764222977,54043195528445950,108086391056891905,216172782113783806,432345564227567617,864691128455135230,1729382256910270465,3458764513820540926,6917529027641081857,13835058055282163710,27670116110564327425,55340232221128654846,110680464442257309697,221360928884514619390,442721857769029238785,885443715538058477566,1770887431076116955137,3541774862152233910270,7083549724304467820545,14167099448608935641086,28334198897217871282177,56668397794435742564350,113336795588871485128705,226673591177742970257406,453347182355485940514817,906694364710971881029630,1813388729421943762059265,3626777458843887524118526,7253554917687775048237057,14507109835375550096474110,29014219670751100192948225,58028439341502200385896446,116056878683004400771792897,232113757366008801543585790,464227514732017603087171585,928455029464035206174343166,1856910058928070412348686337,3713820117856140824697372670,7427640235712281649394745345,14855280471424563298789490686,29710560942849126597578981377,59421121885698253195157962750,118842243771396506390315925505,237684487542793012780631851006,475368975085586025561263702017,950737950171172051122527404030,1901475900342344102245054808065
mov $1,2
pow $1,$0
mov $2,$0
mod $2,2
add $1,$2
mul $1,3
sub $1,2
mov $0,$1
|
src/demo-atmospheres.ads | onox/orka-demo | 3 | 24099 | <filename>src/demo-atmospheres.ads<gh_stars>1-10
with Orka.Features.Atmosphere.Earth;
with Orka.Features.Atmosphere.Rendering;
with Orka.Resources.Locations;
with Orka.Behaviors;
with Orka.Cameras;
with Orka.Rendering.Programs.Modules;
with Planets;
package Demo.Atmospheres is
type Atmosphere is tagged limited private;
function Create
(Planet_Model : aliased Orka.Features.Atmosphere.Model_Data;
Planet_Data : Planets.Planet_Characteristics;
Location_Shaders : Orka.Resources.Locations.Location_Ptr;
Location_Precomputed : Orka.Resources.Locations.Writable_Location_Ptr) return Atmosphere;
function Shader_Module (Object : Atmosphere)
return Orka.Rendering.Programs.Modules.Module;
procedure Render
(Object : in out Atmosphere;
Camera : Orka.Cameras.Camera_Ptr;
Planet, Star : Orka.Behaviors.Behavior_Ptr);
private
type Atmosphere is tagged limited record
Program : Orka.Features.Atmosphere.Rendering.Atmosphere;
Textures : Orka.Features.Atmosphere.Precomputed_Textures;
end record;
end Demo.Atmospheres;
|
oeis/085/A085744.asm | neoneye/loda-programs | 11 | 247098 | ; A085744: a(n) = A000217(n^3) - n^3.
; 0,0,28,351,2016,7750,23220,58653,130816,265356,499500,885115,1492128,2412306,3763396,5693625,8386560,12066328,17003196,23519511,31996000,42878430,56684628,74011861,95544576,122062500,154449100,193700403,240934176,297399466,364486500,443736945,536854528,645716016,772382556,919111375,1088367840,1282837878,1505440756,1759342221,2047968000,2375017660,2744478828,3160641771,3628114336,4151837250,4737099780,5389555753,6115239936,6920584776,7812437500,8798077575,9885234528,11082106126,12397376916
pow $0,3
bin $0,2
|
Categories/Product/Projections.agda | copumpkin/categories | 98 | 17005 | <reponame>copumpkin/categories
{-# OPTIONS --universe-polymorphism #-}
open import Level
open import Categories.Category
open import Categories.Product
module Categories.Product.Projections
{o ℓ e o′ ℓ′ e′}
(C : Category o ℓ e)
(D : Category o′ ℓ′ e′)
where
open import Categories.Functor
open import Data.Product using (_×_; Σ; _,_; proj₁; proj₂; zip; map; <_,_>; swap)
∏₁ : Functor (Product C D) C
∏₁ = record
{ F₀ = proj₁
; F₁ = proj₁
; identity = refl
; homomorphism = refl
; F-resp-≡ = proj₁
} where
open Category.Equiv C
∏₂ : Functor (Product C D) D
∏₂ = record
{ F₀ = proj₂
; F₁ = proj₂
; identity = refl
; homomorphism = refl
; F-resp-≡ = proj₂
} where
open Category.Equiv D
|
FormalAnalyzer/models/meta/cap_audioMute.als | Mohannadcse/IoTCOM_BehavioralRuleExtractor | 0 | 2443 | <reponame>Mohannadcse/IoTCOM_BehavioralRuleExtractor
// filename: cap_audioMute.als
module cap_audioMute
open IoTBottomUp
one sig cap_audioMute extends Capability {}
{
attributes = cap_audioMute_attr
}
abstract sig cap_audioMute_attr extends Attribute {}
one sig cap_audioMute_attr_mute extends cap_audioMute_attr {}
{
values = cap_audioMute_attr_mute_val
}
abstract sig cap_audioMute_attr_mute_val extends AttrValue {}
one sig cap_audioMute_attr_mute_val_muted extends cap_audioMute_attr_mute_val {}
one sig cap_audioMute_attr_mute_val_unmuted extends cap_audioMute_attr_mute_val {}
|
libsrc/_DEVELOPMENT/math/integer/z80_zxn/l_z80_zxn_mulu_32_16x16.asm | rjcorrig/z88dk | 0 | 174085 | <reponame>rjcorrig/z88dk
; 2018 <NAME>
SECTION code_clib
SECTION code_math
PUBLIC l_z80_zxn_mulu_32_16x16
l_z80_zxn_mulu_32_16x16:
; multiplication of two 16-bit numbers into a 32-bit product
;
; enter : de = 16-bit multiplicand = y
; hl = 16-bit multiplicand = x
;
; exit : dehl = 32-bit product
; carry reset
;
; uses : af, bc, de, hl
ld b,l ; x0
ld c,e ; y0
ld e,l ; x0
ld l,d
push hl ; x1 y1
ld l,c ; y0
; bc = x0 y0
; de = y1 x0
; hl = x1 y0
; stack = x1 y1
mul de ; y1*x0
ex de,hl
mul de ; x1*y0
xor a ; zero A
add hl,de ; sum cross products p2 p1
adc a,a ; capture carry p3
ld e,c ; x0
ld d,b ; y0
mul de ; y0*x0
ld b,a ; carry from cross products
ld c,h ; LSB of MSW from cross products
ld a,d
add a,l
ld h,a
ld l,e ; LSW in HL p1 p0
pop de
mul de ; x1*y1
ex de,hl
adc hl,bc
ex de,hl ; de = final MSW
ret
|
kernel/src/spinlock.asm | Stoozy/osdev | 0 | 100453 | global acquire_lock
global release_lock
extern print_spin_wait
acquire_lock:
lock bts dword [rdi], 0
jc .spin_wait
ret
.spin_wait:
call print_spin_wait
test dword [rdi], 1
jnz .spin_wait
release_lock:
mov dword [rdi], 0
ret
|
specification_scanner.ads | annexi-strayline/AURA | 13 | 20634 | ------------------------------------------------------------------------------
-- --
-- Ada User Repository Annex (AURA) --
-- ANNEXI-STRAYLINE Reference Implementation --
-- --
-- Command Line Interface --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2020, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * <NAME> (ANNEXI-STRAYLINE) --
-- --
-- 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 copyright holder 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 --
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- This package offers a generic tool for scanning the identifiers declare in
-- a package specification.
--
-- The result is a tree that represents all explicitly declared entities within
-- a package specification, as well as their defining name, kind, and any child
-- declarations.
--
-- The scanner is not strict, and will ignore more than a few syntax and
-- legality errors. It is intended that scanner sources will be passing through
-- an actual compiler at some later time.
with Ada.Strings.Wide_Wide_Unbounded;
with Ada.Containers.Multiway_Trees;
with Ada_Lexical_Parser;
with Registrar.Library_Units;
package Specification_Scanner is
package WWU renames Ada.Strings.Wide_Wide_Unbounded;
use type Registrar.Library_Units.Library_Unit_Kind;
Syntax_Error: exception;
type Entity_Kind is (Type_Declaration,
Subtype_Declaration,
Object_Declaration,
Number_Declaration,
Subprogram_Declaration,
Expression_Function_Declaration,
Package_Declaration,
Exception_Declaration);
-- Generally following ARM 3.1 with contractions
type Declared_Entity is
record
Name: WWU.Unbounded_Wide_Wide_String;
Kind: Entity_Kind;
Is_Generic : Boolean := False;
Is_Constant : Boolean := False;
Is_Renaming : Boolean := False;
Is_Anon_Access: Boolean := False;
Subtype_Mark: WWU.Unbounded_Wide_Wide_String;
Expression : WWU.Unbounded_Wide_Wide_String;
-- Expression does not include the terminating delimiter (;)
Renamed_Entity_Name: WWU.Unbounded_Wide_Wide_String;
end record;
package Declaration_Trees is
new Ada.Containers.Multiway_Trees (Declared_Entity);
procedure Scan_Package_Spec
(Unit : in Registrar.Library_Units.Library_Unit;
Unit_Tree: out Declaration_Trees.Tree)
with Pre => Unit.Kind = Registrar.Library_Units.Package_Unit;
-- This takes a library_unit which shall be a library package. The
-- specifcation is scanned, and a declaration tree is returned.
-- If the source is malformed, Syntax_Error is raised
end Specification_Scanner;
|
programs/oeis/129/A129953.asm | neoneye/loda | 22 | 4341 | ; A129953: First differences of A129952.
; 0,1,4,10,24,56,128,288,640,1408,3072,6656,14336,30720,65536,139264,294912,622592,1310720,2752512,5767168,12058624,25165824,52428800,109051904,226492416,469762048,973078528,2013265920,4160749568,8589934592,17716740096,36507222016,75161927680,154618822656,317827579904,652835028992,1340029796352,2748779069440,5634997092352,11544872091648,23639499997184,48378511622144,98956046499840,202310139510784,413416372043776,844424930131968,1724034232352768,3518437208883200,7177611906121728,14636698788954112,29836347531329536,60798594969501696,123848989752688640,252201579132747776,513410357520236544,1044835113549955072,2125699024118874112,4323455642275676160,8791026472627208192,17870283321406128128,36317027395115679744,73786976294838206464,149879795598890106880,304371277216207601664,617965926469269979136,1254378597012249509888,2545650682171918123008,5165088340638674452480,10477750633867025317888,21250649172913403461632,43091594156185512574976,87363779933088436453376,177088743107611695513600,358899852698093036240896,727244438361925362909184,1473378342655329306673152,2984535617173615775055872,6044629098073145873530880,12240373923598120393900032,24782979302099898081476608,50170421514007110750306304,101549768847628850675318784,205517389334486959700049920,415870481947432436098924544,841412370451781905595498496,1702167554017397877986295808,3443020734262463889563189248,6963412720980264046307573760,14081567946871200626977538048,28472620903563746322679857152,57564211826770182782809276416,116366363692825745840517677056,235208607464222252230833602560,475368975085586025561263702016,960641470485455093321720397824,1941089981599476271041826783232,3921794044456084710880425541632,7922816251426433759354395033600,16004088827881396193895877967872
mov $1,2
pow $1,$0
add $0,2
mul $1,$0
div $1,4
mov $0,$1
|
a/applescript.scpt | ozcanyarimdunya/FuckYouGithub | 0 | 91 | display dialog "Fuck You Github"
|
oeis/280/A280014.asm | neoneye/loda-programs | 11 | 172727 | <reponame>neoneye/loda-programs<filename>oeis/280/A280014.asm
; A280014: Numbers m == +- 2 (mod 10) but not m == 2 (mod 6).
; Submitted by <NAME>
; 12,18,22,28,42,48,52,58,72,78,82,88,102,108,112,118,132,138,142,148,162,168,172,178,192,198,202,208,222,228,232,238,252,258,262,268,282,288,292,298,312,318,322,328,342,348,352,358,372,378,382,388,402,408,412,418,432,438,442,448,462,468,472,478,492,498,502,508,522,528,532,538,552,558,562,568,582,588,592,598,612,618,622,628,642,648,652,658,672,678,682,688,702,708,712,718,732,738,742,748
mov $1,$0
mul $0,7
add $0,1
div $0,4
add $0,$1
add $0,$1
mod $1,4
sub $0,$1
mul $0,2
add $0,12
|
src/fixed_pointers.asm | pwk4m1/TinyBIOS | 23 | 93624 | ; BSD 3-Clause License
;
; Copyright (c) 2019, k4m1 <<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 copyright holder 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.
;
%ifndef FIXED_PTRS
%define FIXED_PTRS
; entry.asm
%define TMP_BOOTSECTOR_ADDR 0x3000
; mm.asm
%define __MM_MEM_START 0xC000
%define __MM_MEM_END 0xCFFF
; ata.asm
%define ata_disk_addr_list 0x3200
; pci.asm
%define pci_dev_ptr_array 0x5002
%define pci_dev_cnt 0x5000
%define EBDA_BASE_ADDR 0x8000 ; shifted right by 4 bytes.
; disk int handler for statuses 'n all other disk related
; info that we use internally.
;
%define DISK_DRIVE_LAST_STATUS 0x00080000
%endif
|
programs/oeis/194/A194825.asm | neoneye/loda | 22 | 171648 | ; A194825: Digital roots of the nonzero 9-gonal (nonagonal) numbers.
; 1,9,6,1,3,3,1,6,9,1,9,6,1,3,3,1,6,9,1,9,6,1,3,3,1,6,9,1,9,6,1,3,3,1,6,9,1,9,6,1,3,3,1,6,9,1,9,6,1,3,3,1,6,9,1,9,6,1,3,3,1,6,9,1,9,6,1,3,3,1,6,9,1,9,6,1,3,3,1,6,9,1,9,6,1,3
pow $0,2
mul $0,1331
mod $0,9
add $0,1
|
programs/oeis/017/A017742.asm | neoneye/loda | 22 | 1916 | ; A017742: Binomial coefficients C(n,78).
; 1,79,3160,85320,1749060,29034396,406481544,4935847320,53060358690,512916800670,4513667845896,36519676207704,273897571557780,1917283000904460,12599288291657880,78115587408278856,458929076023638279,2564603660132096265,13677886187371180080,69829208430263393040,342163121308290625896,1613054714739084379224,7332066885177656269200,32197337191432316660400,136838683063587345806700,563775374221979864723604,2255101496887919458894416,8769839154564131229033840,33200105370849925367056680,122496940506239379802588440,440988985822461767289318384,1550574175956397826920506576,5330098729850117530039241355,17928513909495849873768357285,59058634054809858407707529880,190675018519814685716312882184,603804225312746504768324126916,1876688808404482379685331745820,5728839520392630422197328487240,17186518561177891266591985461720,50700229755474779236446357112074,147154325387841432417978451130166,420440929679546949765652717514760,1183101220726166998177766949285720,3280417021104372131311081086655860,8966473191018617158916954970192684,24170492949702359297950052528345496,64283225930059466217952267362621000,168743468066406098822124701826880125,437355519274154582661425247592117875
add $0,78
bin $0,78
|
symbex-parse.adb | io7m/coreland-symbex | 1 | 10472 | with Interfaces;
use type Interfaces.Unsigned_32;
package body Symbex.Parse is
package body Internal is
function Get_Data (Node : in Node_t)
return UBW_Strings.Unbounded_Wide_String is
begin
case Node.Kind is
when Node_Symbol => return Node.Name;
when Node_String => return Node.Data;
when others => raise Constraint_Error with "invalid node type";
end case;
end Get_Data;
function Get_List_ID (Node : in Node_t) return List_ID_t is
begin
case Node.Kind is
when Node_List => return Node.List;
when others => raise Constraint_Error with "invalid node type";
end case;
end Get_List_ID;
procedure List_Iterate
(List : in List_t;
Process : access procedure (Node : in Node_t))
is
procedure Inner_Process (Cursor : in Lists.Cursor) is
begin
Lists.Query_Element (Cursor, Process);
end Inner_Process;
begin
Lists.Iterate
(Container => List.Nodes,
Process => Inner_Process'Access);
end List_Iterate;
function Get_List
(Tree : in Tree_t;
List_ID : in List_ID_t) return List_t is
begin
return List_Arrays.Element
(Container => Tree.Lists,
Index => List_ID);
end Get_List;
end Internal;
--
-- Append Node to list List_ID
--
procedure Append_Node
(Tree : in out Tree_t;
Node : in Node_t;
List_ID : in List_ID_t)
is
procedure Process (List : in out List_t) is
begin
Lists.Append
(Container => List.Nodes,
New_Item => Node);
end Process;
begin
List_Arrays.Update_Element
(Container => Tree.Lists,
Index => List_ID,
Process => Process'Access);
end Append_Node;
--
-- Append list to list array and push list ID onto stack.
--
procedure Append_List
(Tree : in out Tree_t;
List : in List_t;
List_ID : in List_ID_t) is
begin
-- Add list to tree.
List_Arrays.Append
(Container => Tree.Lists,
New_Item => List);
pragma Assert (List_Arrays.Last_Index (Tree.Lists) = List_ID);
-- Push list onto stack.
List_ID_Stack.Push
(Stack => Tree.List_Stack,
Element => List_ID);
end Append_List;
--
-- Token processors.
--
--
-- Add quoted string to current list.
--
procedure Process_Quoted_String
(Tree : in out Tree_t;
Token : in Lex.Token_t)
is
Current_List : List_ID_t;
Node : Node_t (Kind => Node_String);
begin
Node.Data := Token.Text;
-- Fetch current list.
List_ID_Stack.Peek
(Stack => Tree.List_Stack,
Element => Current_List);
-- Add node to list.
Append_Node
(Tree => Tree,
List_ID => Current_List,
Node => Node);
end Process_Quoted_String;
--
-- Add symbol to current list.
--
procedure Process_Symbol
(Tree : in out Tree_t;
Token : in Lex.Token_t)
is
Current_List : List_ID_t;
Node : Node_t (Kind => Node_Symbol);
begin
Node.Name := Token.Text;
-- Fetch current list.
List_ID_Stack.Peek
(Stack => Tree.List_Stack,
Element => Current_List);
-- Add node to list.
Append_Node
(Tree => Tree,
List_ID => Current_List,
Node => Node);
end Process_Symbol;
--
-- Open new list. Create new node pointing to new list in current.
-- Push list onto stack.
--
procedure Process_List_Open (Tree : in out Tree_t) is
List : List_t;
New_ID : List_ID_t;
Node : Node_t (Kind => Node_List);
begin
New_ID := List_Arrays.Last_Index (Tree.Lists) + 1;
-- Fetch list parent, if available.
List_ID_Stack.Peek
(Stack => Tree.List_Stack,
Element => List.Parent);
-- Append node to parent pointing to this list.
Node.List := New_ID;
Append_Node
(Tree => Tree,
List_ID => List.Parent,
Node => Node);
-- Add list to tree.
Append_List
(Tree => Tree,
List => List,
List_ID => New_ID);
pragma Assert (List_Arrays.Last_Index (Tree.Lists) = New_ID);
end Process_List_Open;
--
-- Close list and remove from stack.
--
procedure Process_List_Close
(Tree : in out Tree_t;
Status : in out Tree_Status_t) is
begin
if List_ID_Stack.Size (Tree.List_Stack) > 1 then
List_ID_Stack.Pop_Discard (Tree.List_Stack);
else
Status := Tree_Error_Excess_Closing_Parentheses;
end if;
end Process_List_Close;
--
-- Check for premature EOF.
--
procedure Process_EOF
(Tree : in out Tree_t;
Status : in out Tree_Status_t) is
begin
if List_ID_Stack.Size (Tree.List_Stack) > 1 then
Status := Tree_Error_Unterminated_List;
end if;
Tree.Completed := True;
end Process_EOF;
--
-- Add initial empty root list.
--
procedure Add_Root_List (Tree : in out Tree_t) is
List : List_t;
New_ID : List_ID_t;
begin
New_ID := List_ID_t'First;
-- Root list is parent of itself.
List.Parent := New_ID;
-- Add list to tree.
Append_List
(Tree => Tree,
List => List,
List_ID => New_ID);
end Add_Root_List;
--
-- Public API.
--
function Initialized
(Tree : in Tree_t) return Boolean is
begin
return Tree.Inited;
end Initialized;
function Completed
(Tree : in Tree_t) return Boolean is
begin
return Tree.Completed;
end Completed;
--
-- Initialize tree state.
--
procedure Initialize_Tree
(Tree : in out Tree_t;
Status : out Tree_Status_t) is
begin
Tree := Tree_t'
(Inited => True,
Completed => False,
List_Stack => <>,
Lists => <>,
Current_List => List_ID_t'First);
Add_Root_List (Tree);
Status := Tree_OK;
end Initialize_Tree;
--
-- Process token.
--
procedure Process_Token
(Tree : in out Tree_t;
Token : in Lex.Token_t;
Status : out Tree_Status_t) is
begin
-- Status is OK by default.
Status := Tree_OK;
case Token.Kind is
when Lex.Token_Quoted_String =>
Process_Quoted_String
(Tree => Tree,
Token => Token);
when Lex.Token_Symbol =>
Process_Symbol
(Tree => Tree,
Token => Token);
when Lex.Token_List_Open =>
Process_List_Open (Tree);
when Lex.Token_List_Close =>
Process_List_Close
(Tree => Tree,
Status => Status);
when Lex.Token_EOF =>
Process_EOF
(Tree => Tree,
Status => Status);
end case;
end Process_Token;
--
-- Node accessors.
--
function Node_Kind (Node : in Node_t) return Node_Kind_t is
begin
return Node.Kind;
end Node_Kind;
--
-- List accessors.
--
function List_Length (List : in List_t) return List_Length_t is
begin
return List_Length_t (Lists.Length (List.Nodes));
end List_Length;
end Symbex.Parse;
|
Assignment-1/fibonacci.asm | sameermuhd/CS311-Computer-Architecture-Lab | 0 | 15568 | <reponame>sameermuhd/CS311-Computer-Architecture-Lab
.data
n:
10
.text
main:
load %x0, $n, %x6 ;x6 = n
addi %x0, 0, %x3 ;x3 = 0 [F0]
addi %x0, 1, %x4 ;x4 = 1 [F1]
addi %x0, 0, %x5 ;x5 = index i = 0
addi %x0, 65535, %x8 ;starting address x8 = 65535 = 2^16 -1
addi %x0, 0, %x10 ;stores 0
addi %x0, 1, %x11 ;stores 1
loop:
beq %x5, %x6, endl ;loop condition check if x5 == x6, endl
beq %x5, %x10, b0 ;if x5 == x10, then b0
beq %x5, %x11, b1 ;if x5 == x11, then b1
jmp loopcont
b0:
store %x3, $n, %x8 ;n[x8] = x3
jmp loopup
b1:
store %x4, $n, %x8 ;n[x8] = x3
jmp loopup
loopcont:
add %x4, $x3, %x7 ;x7 = Fi = x4 + x3 = F1 + F0
store %x7, $n, %x8 ;n[x8] = x7
addi %x4, 0, %x3 ;x3 = x4
addi %x7, 0, %x4 ;x4 = x7
loopup:
subi %x8, 1, %x8 ;x8 -= 1
addi %x5, 1, %x5 ;x5 -= 1
jmp loop
endl:
end
|
alloy4fun_models/trashltl/models/4/AmpMtMsf8qiLqDfqs.als | Kaixi26/org.alloytools.alloy | 0 | 4510 | <gh_stars>0
open main
pred idAmpMtMsf8qiLqDfqs_prop5 {
eventually some f:File | File' = File - f
}
pred __repair { idAmpMtMsf8qiLqDfqs_prop5 }
check __repair { idAmpMtMsf8qiLqDfqs_prop5 <=> prop5o } |
Transynther/x86/_processed/NC/_zr_/i7-7700_9_0x48.log_21829_1535.asm | ljhsiun2/medusa | 9 | 18810 | <reponame>ljhsiun2/medusa
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r12
push %r8
push %rax
push %rbp
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_normal_ht+0x5ca2, %r12
nop
nop
nop
cmp %rsi, %rsi
movl $0x61626364, (%r12)
nop
nop
nop
cmp %r12, %r12
lea addresses_WC_ht+0x12727, %rax
nop
nop
nop
and %r8, %r8
mov $0x6162636465666768, %rdx
movq %rdx, %xmm1
vmovups %ymm1, (%rax)
nop
nop
nop
nop
nop
and $6825, %rax
lea addresses_normal_ht+0x80e7, %rsi
add $57770, %rbp
movw $0x6162, (%rsi)
nop
nop
nop
nop
nop
sub $65078, %rsi
lea addresses_WC_ht+0x183a9, %rsi
lea addresses_WC_ht+0x34e7, %rdi
nop
nop
nop
xor $21538, %rax
mov $8, %rcx
rep movsq
nop
nop
xor $33423, %rax
lea addresses_UC_ht+0xa087, %rdi
and %rbp, %rbp
movl $0x61626364, (%rdi)
nop
nop
nop
nop
nop
inc %rax
lea addresses_WT_ht+0x8e7, %rdi
nop
nop
nop
nop
nop
dec %rdx
mov (%rdi), %r8
nop
nop
nop
nop
inc %rcx
lea addresses_UC_ht+0x172e7, %rax
nop
add %rbp, %rbp
movb $0x61, (%rax)
xor $20408, %rax
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbp
pop %rax
pop %r8
pop %r12
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r13
push %r14
push %r15
push %rax
push %rbp
push %rdx
// Store
lea addresses_RW+0x11ba6, %r13
nop
nop
sub $33682, %rdx
mov $0x5152535455565758, %rbp
movq %rbp, %xmm3
movups %xmm3, (%r13)
nop
nop
xor %rax, %rax
// Store
lea addresses_normal+0x3a47, %r15
nop
add %r14, %r14
movw $0x5152, (%r15)
nop
nop
nop
nop
nop
add $14702, %r12
// Store
lea addresses_normal+0x78e7, %r14
nop
nop
add %r15, %r15
mov $0x5152535455565758, %rax
movq %rax, (%r14)
cmp %rbp, %rbp
// Faulty Load
mov $0x7c215b0000000ce7, %rax
sub $25443, %r14
mov (%rax), %r15d
lea oracles, %r13
and $0xff, %r15
shlq $12, %r15
mov (%r13,%r15,1), %r15
pop %rdx
pop %rbp
pop %rax
pop %r15
pop %r14
pop %r13
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_NC', 'AVXalign': False, 'congruent': 0, 'size': 8, 'same': False, 'NT': True}}
{'OP': 'STOR', 'dst': {'type': 'addresses_RW', 'AVXalign': False, 'congruent': 0, 'size': 16, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal', 'AVXalign': False, 'congruent': 5, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal', 'AVXalign': False, 'congruent': 5, 'size': 8, 'same': False, 'NT': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_NC', 'AVXalign': False, 'congruent': 0, 'size': 4, 'same': True, 'NT': False}}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 0, 'size': 4, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 5, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 10, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 11, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 5, 'size': 4, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 8, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 9, 'size': 1, 'same': False, 'NT': False}}
{'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
*/
|
programs/oeis/192/A192736.asm | karttu/loda | 0 | 178941 | <reponame>karttu/loda<gh_stars>0
; A192736: Right edge of the triangle in A033291.
; 1,4,12,28,50,84,133,192,270,370,484,624,793,980,1200,1456,1734,2052,2413,2800,3234,3718,4232,4800,5425,6084,6804,7588,8410,9300,10261,11264,12342,13498,14700,15984,17353,18772,20280,21880,23534,25284,27133,29040
add $0,2
mov $1,$0
mov $3,$0
pow $3,2
mov $0,$3
mov $2,$3
sub $2,$1
sub $1,1
lpb $0,1
mov $0,2
add $2,1
mov $4,$2
div $4,3
lpe
mul $1,$4
|
Transynther/x86/_processed/NC/_zr_/i9-9900K_12_0xa0_notsx.log_21829_242.asm | ljhsiun2/medusa | 9 | 176418 | .global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r14
push %r9
push %rbx
push %rdi
push %rdx
push %rsi
lea addresses_D_ht+0x17a2c, %rsi
nop
nop
nop
nop
cmp $7993, %r14
and $0xffffffffffffffc0, %rsi
vmovaps (%rsi), %ymm1
vextracti128 $0, %ymm1, %xmm1
vpextrq $1, %xmm1, %rdx
nop
nop
nop
xor $2325, %rbx
lea addresses_UC_ht+0xf38c, %r11
nop
and $45621, %rdi
movl $0x61626364, (%r11)
cmp %rdi, %rdi
lea addresses_UC_ht+0x1750c, %rbx
nop
nop
nop
nop
dec %r11
vmovups (%rbx), %ymm0
vextracti128 $0, %ymm0, %xmm0
vpextrq $0, %xmm0, %rsi
nop
nop
nop
nop
nop
dec %r11
lea addresses_D_ht+0x380c, %r11
nop
nop
nop
xor $27446, %rbx
mov (%r11), %di
nop
nop
nop
nop
nop
add $39217, %rsi
pop %rsi
pop %rdx
pop %rdi
pop %rbx
pop %r9
pop %r14
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r8
push %rax
push %rbx
push %rcx
push %rdi
push %rsi
// REPMOV
lea addresses_RW+0x90c, %rsi
lea addresses_WC+0xa50c, %rdi
nop
nop
nop
nop
cmp $18109, %r8
mov $41, %rcx
rep movsw
nop
nop
nop
nop
xor $55506, %rcx
// Faulty Load
mov $0x4ae5c10000000d0c, %rdi
nop
dec %rsi
movb (%rdi), %r11b
lea oracles, %rax
and $0xff, %r11
shlq $12, %r11
mov (%rax,%r11,1), %r11
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r8
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_NC', 'AVXalign': False, 'size': 32, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_RW', 'congruent': 10, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC', 'congruent': 7, 'same': False}}
[Faulty Load]
{'src': {'type': 'addresses_NC', 'AVXalign': False, 'size': 1, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_D_ht', 'AVXalign': True, 'size': 32, 'NT': True, 'same': False, 'congruent': 5}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 6}}
{'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 11}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_D_ht', 'AVXalign': False, 'size': 2, 'NT': False, 'same': False, 'congruent': 8}, 'OP': 'LOAD'}
{'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
*/
|
oeis/037/A037739.asm | neoneye/loda-programs | 11 | 16382 | <gh_stars>10-100
; A037739: Base 6 digits are, in order, the first n terms of the periodic sequence with initial period 2,1,3,0.
; Submitted by <NAME>
; 2,13,81,486,2918,17509,105057,630342,3782054,22692325,136153953,816923718,4901542310,29409253861,176455523169,1058733139014,6352398834086,38114393004517,228686358027105,1372118148162630
mov $2,2
lpb $0
sub $0,1
sub $2,1
add $1,$2
add $1,1
mul $1,6
add $2,14
bin $2,2
mod $2,4
lpe
add $1,$2
mov $0,$1
|
lib/Haskell/Prim/Maybe.agda | ioanasv/agda2hs | 1 | 4342 | <filename>lib/Haskell/Prim/Maybe.agda
module Haskell.Prim.Maybe where
open import Agda.Builtin.List public
open import Haskell.Prim
open import Haskell.Prim.List
--------------------------------------------------
-- Maybe
data Maybe {ℓ} (a : Set ℓ) : Set ℓ where
Nothing : Maybe a
Just : a -> Maybe a
maybe : ∀ {ℓ₁ ℓ₂} {a : Set ℓ₁} {b : Set ℓ₂} → b → (a → b) → Maybe a → b
maybe n j Nothing = n
maybe n j (Just x) = j x
mapMaybe : (a -> Maybe b) -> List a -> List b
mapMaybe _ [] = []
mapMaybe f (x ∷ xs) =
case f x of λ where
Nothing -> mapMaybe f xs
(Just v) -> v ∷ (mapMaybe f xs) |
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/alignment6.adb | best08618/asylo | 7 | 13196 | -- { dg-do compile }
-- { dg-options "-gnatws -fdump-tree-gimple" }
procedure Alignment6 is
type MY_REC is
record
A1 : INTEGER range -3 .. 3 ; -- symmetric
A2 : BOOLEAN ;
A3 : INTEGER range 0 .. 15 ; -- positive
A4 : INTEGER range 10 .. 100 ; -- arbitrary
A5 : BOOLEAN ; --5
end record ;
for MY_REC use
record
A1 at 0 range 0 .. 2 ;
A2 at 0 range 3 .. 3 ;
A3 at 0 range 4 .. 7 ;
A4 at 0 range 8 .. 15 ;
A5 at 0 range 16 .. 16 ;
end record ;
A_REC : MY_REC := ( 1 , TRUE , 7 , 11 , FALSE );
B_REC : MY_REC;
begin
B_REC := A_REC;
end;
-- { dg-final { scan-tree-dump-not "VIEW_CONVERT_EXPR" "gimple" } }
|
tests/window/main.adb | Fabien-Chouteau/ASFML | 0 | 28212 | <reponame>Fabien-Chouteau/ASFML
with Ada.Text_IO; use Ada.Text_IO;
with Sf.Window.Window; use Sf, Sf.Window, Sf.Window.Window;
with Sf.Window.VideoMode; use Sf.Window.VideoMode;
with Sf.Window.Event; use Sf.Window.Event;
with Sf.Window.Keyboard; use Sf.Window.Keyboard;
with Sf.Window.Clipboard;
with Sf.Window.Cursor;
with Sf.System.Time; use Sf.System.Time;
with Sf.System.Sleep; use Sf.System.Sleep;
procedure Main is
Window : sfWindow_Ptr;
Mode : sfVideoMode := (640, 480, 32);
Event : aliased sfEvent;
CursorHand : sfCursor_Ptr := Cursor.createFromSystem(Cursor.sfCursorHand);
begin
Window := Create (Mode, "Window");
if Window = null then
Put_Line ("Failed to create window");
return;
end if;
setMouseCursor (Window, CursorHand);
SetFramerateLimit (Window, 32);
SetVerticalSyncEnabled (Window, sfTrue);
while IsOpen (Window) = sfTrue loop
while PollEvent (Window, Event'Access) = sfTrue loop
if Event.eventType = sfEvtClosed then
Close (Window);
Put_Line ("Attempting to close");
end if;
if Event.eventType = sfEvtKeyPressed then
if Event.key.code = sfKeyEscape then
Close (Window);
Put_Line ("Attempting to close");
elsif
Event.key.code = sfKeyC and
Event.key.control = sfTrue then
sf.Window.Clipboard.setString ("ASFML has copied to Clipboard");
setTitle (Window, "ASFML has copied to Clipboard");
elsif Event.key.code = sfKeyV and
Event.key.control = sfTrue then
Put_Line (sf.Window.Clipboard.getString);
setTitle (Window, "ASFML has pasted to standard output");
end if;
end if;
end loop;
Display (Window);
sfSleep (sfSeconds (0.001));
end loop;
Destroy (Window);
end Main;
|
pixy/src/host/pantilt_in_ada/specs/x86_64_linux_gnu_bits_types_h.ads | GambuzX/Pixy-SIW | 1 | 2611 | --
-- 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 System;
with Interfaces.C.Strings;
package x86_64_linux_gnu_bits_types_h is
subtype uu_u_char is unsigned_char; -- /usr/include/x86_64-linux-gnu/bits/types.h:30
subtype uu_u_short is unsigned_short; -- /usr/include/x86_64-linux-gnu/bits/types.h:31
subtype uu_u_int is unsigned; -- /usr/include/x86_64-linux-gnu/bits/types.h:32
subtype uu_u_long is unsigned_long; -- /usr/include/x86_64-linux-gnu/bits/types.h:33
subtype uu_int8_t is signed_char; -- /usr/include/x86_64-linux-gnu/bits/types.h:36
subtype uu_uint8_t is unsigned_char; -- /usr/include/x86_64-linux-gnu/bits/types.h:37
subtype uu_int16_t is short; -- /usr/include/x86_64-linux-gnu/bits/types.h:38
subtype uu_uint16_t is unsigned_short; -- /usr/include/x86_64-linux-gnu/bits/types.h:39
subtype uu_int32_t is int; -- /usr/include/x86_64-linux-gnu/bits/types.h:40
subtype uu_uint32_t is unsigned; -- /usr/include/x86_64-linux-gnu/bits/types.h:41
subtype uu_int64_t is long; -- /usr/include/x86_64-linux-gnu/bits/types.h:43
subtype uu_uint64_t is unsigned_long; -- /usr/include/x86_64-linux-gnu/bits/types.h:44
subtype uu_quad_t is long; -- /usr/include/x86_64-linux-gnu/bits/types.h:52
subtype uu_u_quad_t is unsigned_long; -- /usr/include/x86_64-linux-gnu/bits/types.h:53
subtype uu_dev_t is unsigned_long; -- /usr/include/x86_64-linux-gnu/bits/types.h:124
subtype uu_uid_t is unsigned; -- /usr/include/x86_64-linux-gnu/bits/types.h:125
subtype uu_gid_t is unsigned; -- /usr/include/x86_64-linux-gnu/bits/types.h:126
subtype uu_ino_t is unsigned_long; -- /usr/include/x86_64-linux-gnu/bits/types.h:127
subtype uu_ino64_t is unsigned_long; -- /usr/include/x86_64-linux-gnu/bits/types.h:128
subtype uu_mode_t is unsigned; -- /usr/include/x86_64-linux-gnu/bits/types.h:129
subtype uu_nlink_t is unsigned_long; -- /usr/include/x86_64-linux-gnu/bits/types.h:130
subtype uu_off_t is long; -- /usr/include/x86_64-linux-gnu/bits/types.h:131
subtype uu_off64_t is long; -- /usr/include/x86_64-linux-gnu/bits/types.h:132
subtype uu_pid_t is int; -- /usr/include/x86_64-linux-gnu/bits/types.h:133
type uu_fsid_t_uu_val_array is array (0 .. 1) of aliased int;
type uu_fsid_t is record
uu_val : aliased uu_fsid_t_uu_val_array; -- /usr/include/x86_64-linux-gnu/bits/types.h:134
end record;
pragma Convention (C_Pass_By_Copy, uu_fsid_t); -- /usr/include/x86_64-linux-gnu/bits/types.h:134
-- skipped anonymous struct anon_0
subtype uu_clock_t is long; -- /usr/include/x86_64-linux-gnu/bits/types.h:135
subtype uu_rlim_t is unsigned_long; -- /usr/include/x86_64-linux-gnu/bits/types.h:136
subtype uu_rlim64_t is unsigned_long; -- /usr/include/x86_64-linux-gnu/bits/types.h:137
subtype uu_id_t is unsigned; -- /usr/include/x86_64-linux-gnu/bits/types.h:138
subtype uu_time_t is long; -- /usr/include/x86_64-linux-gnu/bits/types.h:139
subtype uu_useconds_t is unsigned; -- /usr/include/x86_64-linux-gnu/bits/types.h:140
subtype uu_suseconds_t is long; -- /usr/include/x86_64-linux-gnu/bits/types.h:141
subtype uu_daddr_t is int; -- /usr/include/x86_64-linux-gnu/bits/types.h:143
subtype uu_key_t is int; -- /usr/include/x86_64-linux-gnu/bits/types.h:144
subtype uu_clockid_t is int; -- /usr/include/x86_64-linux-gnu/bits/types.h:147
type uu_timer_t is new System.Address; -- /usr/include/x86_64-linux-gnu/bits/types.h:150
subtype uu_blksize_t is long; -- /usr/include/x86_64-linux-gnu/bits/types.h:153
subtype uu_blkcnt_t is long; -- /usr/include/x86_64-linux-gnu/bits/types.h:158
subtype uu_blkcnt64_t is long; -- /usr/include/x86_64-linux-gnu/bits/types.h:159
subtype uu_fsblkcnt_t is unsigned_long; -- /usr/include/x86_64-linux-gnu/bits/types.h:162
subtype uu_fsblkcnt64_t is unsigned_long; -- /usr/include/x86_64-linux-gnu/bits/types.h:163
subtype uu_fsfilcnt_t is unsigned_long; -- /usr/include/x86_64-linux-gnu/bits/types.h:166
subtype uu_fsfilcnt64_t is unsigned_long; -- /usr/include/x86_64-linux-gnu/bits/types.h:167
subtype uu_fsword_t is long; -- /usr/include/x86_64-linux-gnu/bits/types.h:170
subtype uu_ssize_t is long; -- /usr/include/x86_64-linux-gnu/bits/types.h:172
subtype uu_syscall_slong_t is long; -- /usr/include/x86_64-linux-gnu/bits/types.h:175
subtype uu_syscall_ulong_t is unsigned_long; -- /usr/include/x86_64-linux-gnu/bits/types.h:177
subtype uu_loff_t is uu_off64_t; -- /usr/include/x86_64-linux-gnu/bits/types.h:181
type uu_qaddr_t is access all uu_quad_t; -- /usr/include/x86_64-linux-gnu/bits/types.h:182
type uu_caddr_t is new Interfaces.C.Strings.chars_ptr; -- /usr/include/x86_64-linux-gnu/bits/types.h:183
subtype uu_intptr_t is long; -- /usr/include/x86_64-linux-gnu/bits/types.h:186
subtype uu_socklen_t is unsigned; -- /usr/include/x86_64-linux-gnu/bits/types.h:189
end x86_64_linux_gnu_bits_types_h;
|
lib/Runtime/Library/amd64/JavascriptFunctionA.asm | Taritsyn/ChakraCore | 8,664 | 247229 | ;-------------------------------------------------------------------------------------------------------
; Copyright (C) Microsoft. All rights reserved.
; Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
;-------------------------------------------------------------------------------------------------------
include ksamd64.inc
_TEXT SEGMENT
extrn __chkstk: PROC
ifdef _CONTROL_FLOW_GUARD
extrn __guard_check_icall_fptr:QWORD
extrn __guard_dispatch_icall_fptr:QWORD
subttl "Control Flow Guard ICall Check Stub"
;++
;
; Routine Description:
;
; This routine is a stub that is called for the CFG icall check. Its
; function is to create a new stack frame for (*__guard_check_icall_fptr)
; which performs the actual indirect call check.
;
; N.B. A new stack frame is required since amd64_CallFunction requires the
; parameter home area of the icall check subroutine to be preserved.
; (The saved non-volatiles in amd64_CallFunction would overlap with
; the *guard_check_icall_fptr home parameter region.)
;
; N.B. The (*guard_check_icall_fptr) call is guaranteed to preserve rcx.
; This stub preserves that behavior, allowing callers to assume rcx
; is preserved across the call.
;
; Arguments:
;
; ICallTarget (rcx) - Supplies a pointer to a function to check.
;
; Implicit Arguments:
;
; (rsp+08h - rsp+30h) - Supplies the preserved home area.
;
; Return Value:
;
; None. Should the indirect call check fail, a fast fail event is raised.
;
;--
IcFrame struct
P1Home dq ? ; child function parameter home addresses
P2Home dq ? ;
P3Home dq ? ;
P4Home dq ? ;
Fill dq ? ;
IcFrame ends
NESTED_ENTRY amd64_CheckICall, _TEXT$00
alloc_stack (sizeof IcFrame) ; allocate stack frame
END_PROLOGUE
call [__guard_check_icall_fptr] ; verify that the call target is valid
add rsp, (sizeof IcFrame) ; deallocate stack frame
ret ; return to dispatch invoke
NESTED_END amd64_CheckICall, _TEXT$00
endif
align 16
amd64_CallFunction PROC FRAME
;;
;; Stack layout: A, B, C indicate what the stack looks like at specific
;; points in code.
;;
;; ----------------------------
;; argv
;; rbp + 48h ----------------------------
;; argc [r9] -\
;; rbp + 40h ---------------------------- |
;; callInfo [r8] |
;; rbp + 38h ---------------------------- -- argument register spill
;; entryPoint [rdx] |
;; rbp + 30h ---------------------------- |
;; function [rcx] -/
;; rbp + 28h ----------------------------
;; return address
;; rbp + 20h ---------------------------- <-- (A) function entry
;; rbx -\
;; rbp + 18h ---------------------------- |
;; rsi |
;; rbp + 10h ---------------------------- -- saved non-volatile registers
;; rdi |
;; rbp + 08h ---------------------------- |
;; rbp -/
;; rbp ---------------------------- <-- (B) frame pointer established
;; padding
;; ----------------------------
;; ~ ~
;; ~ (argc&1)?(argc+1):argc ~
;; ~ QWORDS ~ <-- argv[2] ... argv[N - 1] + padding
;; ~ ~
;; ----------------------------
;; argv[1] [r9] -\
;; ---------------------------- |
;; argv[0] [r8] |
;; ---------------------------- -- argument register spill
;; callInfo [rdx] |
;; ---------------------------- |
;; function [rcx] -/
;; ---------------------------- <-- (C) callsite
;;
;; (A) function entry
push rbx
.pushreg rbx
push rsi
.pushreg rsi
push rdi
.pushreg rdi
push rbp
.pushreg rbp
lea rbp, [rsp]
.setframe rbp, 0
.endprolog
;; (B) frame pointer established
;; The first 4 QWORD args are passed in rcx, rdx, r8 and r9. rcx = function *,
;; rdx = CallInfo.
;; upon entry rcx contains function *.
sub rsp, 8h
;; rbx = argc
mov rbx, r9
;; save entry point (rdx) and move CallInfo (r8) into rdx.
mov rax, rdx
mov rdx, r8
mov r10, 0
;; rsi = argv
mov rsi, qword ptr [rsp + 50h]
;; If argc > 2 then r8 = argv[0] and r9 = argv[1]. The rest are copied onto
;; the stack.
cmp rbx, 2h
jg setup_stack_and_reg_args
je setup_reg_args_2
cmp rbx, 1h
je setup_reg_args_1
jmp setup_args_done
;; *args labels handle copying the script args (argv) into either registers or the stack.
setup_stack_and_reg_args:
;; calculate the number of args to be copied onto the stack. Adjust the allocation
;; size so that the stack pointer is a multiple of 10h at the callsite.
mov r10, rbx
and r10, -2
;; Calculate the size of stack to be allocated in bytes and allocate.
push rax
mov rax, r10
shl rax, 3h
;; Call __chkstk to ensure the stack is extended properly. It expects size in rax.
cmp rax, 1000h
jl stack_alloc
call __chkstk
stack_alloc:
mov r10, rax
pop rax
sub rsp, r10
;; (rsp[0]..rsp[N - 3]) = (argv[2]..argv[N - 1])
mov r10, rbx ; r10 = N - 1 i.e. (argc - 2) - 1
sub r10, 3h
shl r10, 3h
lea r11, [rsi + 10h]
copy_stack_args:
mov rdi, qword ptr [r11 + r10]
mov qword ptr [rsp + r10], rdi
sub r10, 8h
cmp r10, 0
jge copy_stack_args
;; The first two script args are passed in r8 and r9.
setup_reg_args_2:
mov r9, qword ptr [rsi + 8h]
setup_reg_args_1:
mov r8, qword ptr [rsi]
setup_args_done:
;; allocate args register spill
sub rsp, 20h
ifdef _CONTROL_FLOW_GUARD
call [__guard_dispatch_icall_fptr]
else
;; (C) callsite
call rax
endif
done:
mov rsp, rbp
pop rbp
pop rdi
pop rsi
pop rbx
ret
amd64_CallFunction ENDP
ifdef _ENABLE_DYNAMIC_THUNKS
extrn ?GetStackSizeForAsmJsUnboxing@Js@@YAHPEAVScriptFunction@1@@Z: PROC
extrn ?GetArgsSizesArray@Js@@YAPEAIPEAVScriptFunction@1@@Z : PROC
; int64 JavascriptFunction::CallAsmJsFunction<int64>(RecyclableObject * function, JavascriptMethod entryPoint, Var * argv, uint argsSize, byte* reg)
align 16
??$CallAsmJsFunction@_J@JavascriptFunction@Js@@SA_JPEAVRecyclableObject@1@P6APEAX0UCallInfo@1@ZZPEAPEAXIPEAE@Z PROC FRAME
.setframe rbp, 0
.endprolog
rex_jmp_reg ??$CallAsmJsFunction@H@JavascriptFunction@Js@@SAHPEAVRecyclableObject@1@P6APEAX0UCallInfo@1@ZZPEAPEAXIPEAE@Z
??$CallAsmJsFunction@_J@JavascriptFunction@Js@@SA_JPEAVRecyclableObject@1@P6APEAX0UCallInfo@1@ZZPEAPEAXIPEAE@Z ENDP
; float JavascriptFunction::CallAsmJsFunction<float>(RecyclableObject * function, JavascriptMethod entryPoint, Var * argv, uint argsSize, byte* reg)
align 16
??$CallAsmJsFunction@N@JavascriptFunction@Js@@SANPEAVRecyclableObject@1@P6APEAX0UCallInfo@1@ZZPEAPEAXIPEAE@Z PROC FRAME
.setframe rbp, 0
.endprolog
rex_jmp_reg ??$CallAsmJsFunction@H@JavascriptFunction@Js@@SAHPEAVRecyclableObject@1@P6APEAX0UCallInfo@1@ZZPEAPEAXIPEAE@Z
??$CallAsmJsFunction@N@JavascriptFunction@Js@@SANPEAVRecyclableObject@1@P6APEAX0UCallInfo@1@ZZPEAPEAXIPEAE@Z ENDP
; double JavascriptFunction::CallAsmJsFunction<double>(RecyclableObject * function, JavascriptMethod entryPoint, Var * argv, uint argsSize, byte* reg)
align 16
??$CallAsmJsFunction@M@JavascriptFunction@Js@@SAMPEAVRecyclableObject@1@P6APEAX0UCallInfo@1@ZZPEAPEAXIPEAE@Z PROC FRAME
.setframe rbp, 0
.endprolog
rex_jmp_reg ??$CallAsmJsFunction@H@JavascriptFunction@Js@@SAHPEAVRecyclableObject@1@P6APEAX0UCallInfo@1@ZZPEAPEAXIPEAE@Z
??$CallAsmJsFunction@M@JavascriptFunction@Js@@SAMPEAVRecyclableObject@1@P6APEAX0UCallInfo@1@ZZPEAPEAXIPEAE@Z ENDP
; __m128 JavascriptFunction::CallAsmJsFunction<__m128>(RecyclableObject * function, JavascriptMethod entryPoint, Var * argv, uint argsSize, byte* reg)
align 16
??$CallAsmJsFunction@T__m128@@@JavascriptFunction@Js@@SA?AT__m128@@PEAVRecyclableObject@1@P6APEAX0UCallInfo@1@ZZPEAPEAXIPEAE@Z PROC FRAME
.setframe rbp, 0
.endprolog
rex_jmp_reg ??$CallAsmJsFunction@H@JavascriptFunction@Js@@SAHPEAVRecyclableObject@1@P6APEAX0UCallInfo@1@ZZPEAPEAXIPEAE@Z
??$CallAsmJsFunction@T__m128@@@JavascriptFunction@Js@@SA?AT__m128@@PEAVRecyclableObject@1@P6APEAX0UCallInfo@1@ZZPEAPEAXIPEAE@Z ENDP
; int JavascriptFunction::CallAsmJsFunction<int>(RecyclableObject * function, JavascriptMethod entryPoint, Var * argv, uint argsSize, byte* reg)
align 16
??$CallAsmJsFunction@H@JavascriptFunction@Js@@SAHPEAVRecyclableObject@1@P6APEAX0UCallInfo@1@ZZPEAPEAXIPEAE@Z PROC FRAME
; save arguments to stack for interpreter
mov qword ptr [rsp + 8h], rcx ;; function
mov qword ptr [rsp + 10h], rdx ;; entrypoint
mov qword ptr [rsp + 18h], r8 ;; argv
mov qword ptr [rsp + 20h], r9 ;; argsSize
;; reg is at [rsp + 28h]
; push rbx unused
; .pushreg rbx
push rsi
.pushreg rsi
push rdi
.pushreg rdi
; push r12 unused
; .pushreg r12
; push r13 unused
; .pushreg r13
push rbp
.pushreg rbp
mov rbp, rsp
.setframe rbp, 0
.endprolog
and rsp, -16 ; Make sure the stack is 16 bytes aligned
lea rax, [r9 + 16] ; add 16 bytes to argsSize to account for ScriptFunction and stay 16 bytes aligned
; Check if we need to commit more stack
cmp rax, 2000h ; x64 has 2 guard pages
jl stack_alloc
call __chkstk
stack_alloc:
sub rsp, rax
;; Make sure ScriptFunction* is first argument
mov qword ptr [r8], rcx
;; copy all args to the new stack frame.
;; Move argSize in rcx for rep movs
mov rcx, rax
shr rcx, 3 ;; rcx = rcx / 8 for qword size mov
mov rsi, r8 ;; rsi = argv
mov rdi, rsp ;; rdi = arguments destination
rep movsq
;; Move entrypoint in rax
mov rax, rdx
;; Load 4 first arguments in registers
;; First argument (aka ScriptFunction*)
mov rcx, qword ptr [rsp]
mov r10, [rbp + 40h] ;; r10 = byte* reg
;; Second argument
mov rdx, qword ptr [r10]
movaps xmm1, xmmword ptr [r10]
;; Third argument
mov r8, qword ptr [r10 + 10h]
movaps xmm2, xmmword ptr [r10 + 10h]
;; Fourth argument
mov r9, qword ptr [r10 + 20h]
movaps xmm3, xmmword ptr [r10 + 20h]
ifdef _CONTROL_FLOW_GUARD
call [__guard_dispatch_icall_fptr]
else
call rax
endif
lea rsp, [rbp]
pop rbp
; pop r13
; pop r12
pop rdi
pop rsi
; pop rbx
ret
??$CallAsmJsFunction@H@JavascriptFunction@Js@@SAHPEAVRecyclableObject@1@P6APEAX0UCallInfo@1@ZZPEAPEAXIPEAE@Z ENDP
endif ;; _ENABLE_DYNAMIC_THUNKS
extrn ?DeferredParse@JavascriptFunction@Js@@SAP6APEAXPEAVRecyclableObject@2@UCallInfo@2@ZZPEAPEAVScriptFunction@2@@Z : PROC
align 16
?DeferredParsingThunk@JavascriptFunction@Js@@SAPEAXPEAVRecyclableObject@2@UCallInfo@2@ZZ PROC FRAME
;; save volatile registers
mov qword ptr [rsp + 8h], rcx
mov qword ptr [rsp + 10h], rdx
mov qword ptr [rsp + 18h], r8
mov qword ptr [rsp + 20h], r9
push rbp
.pushreg rbp
lea rbp, [rsp]
.setframe rbp, 0
.endprolog
sub rsp, 20h
lea rcx, [rsp + 30h]
call ?DeferredParse@JavascriptFunction@Js@@SAP6APEAXPEAVRecyclableObject@2@UCallInfo@2@ZZPEAPEAVScriptFunction@2@@Z
ifdef _CONTROL_FLOW_GUARD
mov rcx, rax ; __guard_check_icall_fptr requires the call target in rcx.
call [__guard_check_icall_fptr] ; verify that the call target is valid
mov rax, rcx ;restore call target
endif
add rsp, 20h
lea rsp, [rbp]
pop rbp
;; restore volatile registers
mov rcx, qword ptr [rsp + 8h]
mov rdx, qword ptr [rsp + 10h]
mov r8, qword ptr [rsp + 18h]
mov r9, qword ptr [rsp + 20h]
rex_jmp_reg rax
?DeferredParsingThunk@JavascriptFunction@Js@@SAPEAXPEAVRecyclableObject@2@UCallInfo@2@ZZ ENDP
extrn ?DeferredDeserialize@JavascriptFunction@Js@@SAP6APEAXPEAVRecyclableObject@2@UCallInfo@2@ZZPEAVScriptFunction@2@@Z : PROC
align 16
?DeferredDeserializeThunk@JavascriptFunction@Js@@SAPEAXPEAVRecyclableObject@2@UCallInfo@2@ZZ PROC FRAME
;; save volatile registers
mov qword ptr [rsp + 8h], rcx
mov qword ptr [rsp + 10h], rdx
mov qword ptr [rsp + 18h], r8
mov qword ptr [rsp + 20h], r9
push rbp
.pushreg rbp
lea rbp, [rsp]
.setframe rbp, 0
.endprolog
sub rsp, 20h
call ?DeferredDeserialize@JavascriptFunction@Js@@SAP6APEAXPEAVRecyclableObject@2@UCallInfo@2@ZZPEAVScriptFunction@2@@Z
ifdef _CONTROL_FLOW_GUARD
mov rcx, rax ; __guard_check_icall_fptr requires the call target in rcx.
call [__guard_check_icall_fptr] ; verify that the call target is valid
mov rax, rcx ;restore call target
endif
add rsp, 20h
lea rsp, [rbp]
pop rbp
;; restore volatile registers
mov rcx, qword ptr [rsp + 8h]
mov rdx, qword ptr [rsp + 10h]
mov r8, qword ptr [rsp + 18h]
mov r9, qword ptr [rsp + 20h]
rex_jmp_reg rax
?DeferredDeserializeThunk@JavascriptFunction@Js@@SAPEAXPEAVRecyclableObject@2@UCallInfo@2@ZZ ENDP
align 16
BreakSpeculation PROC
cmp rcx, rcx
cmove rax, rcx
ret
BreakSpeculation ENDP
_TEXT ENDS
end
|
Mockingbird/Problems/Chapter18.agda | splintah/combinatory-logic | 1 | 13872 | <filename>Mockingbird/Problems/Chapter18.agda
open import Mockingbird.Forest using (Forest)
import Mockingbird.Forest.Birds as Birds
-- The Master Forest
module Mockingbird.Problems.Chapter18 {b ℓ} (forest : Forest {b} {ℓ})
⦃ _ : Birds.HasStarling forest ⦄
⦃ _ : Birds.HasKestrel forest ⦄ where
open import Data.Maybe using (Maybe; nothing; just)
open import Data.Product using (_×_; _,_; proj₁; ∃-syntax)
open import Data.Vec using (Vec; []; _∷_; _++_)
open import Data.Vec.Relation.Unary.Any.Properties using (++⁺ʳ)
open import Function using (_$_)
open import Level using (_⊔_)
open import Mockingbird.Forest.Combination.Vec forest using (⟨_⟩; here; there; [_]; _⟨∙⟩_∣_; _⟨∙⟩_; [#_])
open import Mockingbird.Forest.Combination.Vec.Properties forest using (subst′; weaken-++ˡ; weaken-++ʳ; ++-comm)
open import Relation.Unary using (_∈_)
open Forest forest
open import Mockingbird.Forest.Birds forest
problem₁ : HasIdentity
problem₁ = record
{ I = S ∙ K ∙ K
; isIdentity = λ x → begin
S ∙ K ∙ K ∙ x ≈⟨ isStarling K K x ⟩
K ∙ x ∙ (K ∙ x) ≈⟨ isKestrel x (K ∙ x) ⟩
x ∎
}
private instance hasIdentity = problem₁
problem₂ : HasMockingbird
problem₂ = record
{ M = S ∙ I ∙ I
; isMockingbird = λ x → begin
S ∙ I ∙ I ∙ x ≈⟨ isStarling I I x ⟩
I ∙ x ∙ (I ∙ x) ≈⟨ congʳ $ isIdentity x ⟩
x ∙ (I ∙ x) ≈⟨ congˡ $ isIdentity x ⟩
x ∙ x ∎
}
private instance hasMockingbird = problem₂
problem₃ : HasThrush
problem₃ = record
{ T = S ∙ (K ∙ (S ∙ I)) ∙ K
; isThrush = λ x y → begin
S ∙ (K ∙ (S ∙ I)) ∙ K ∙ x ∙ y ≈⟨ congʳ $ isStarling (K ∙ (S ∙ I)) K x ⟩
K ∙ (S ∙ I) ∙ x ∙ (K ∙ x) ∙ y ≈⟨ (congʳ $ congʳ $ isKestrel (S ∙ I) x) ⟩
S ∙ I ∙ (K ∙ x) ∙ y ≈⟨ isStarling I (K ∙ x) y ⟩
I ∙ y ∙ (K ∙ x ∙ y) ≈⟨ congʳ $ isIdentity y ⟩
y ∙ (K ∙ x ∙ y) ≈⟨ congˡ $ isKestrel x y ⟩
y ∙ x ∎
}
-- TODO: Problem 4.
I∈⟨S,K⟩ : I ∈ ⟨ S ∷ K ∷ [] ⟩
I∈⟨S,K⟩ = subst′ refl $ [# 0 ] ⟨∙⟩ [# 1 ] ⟨∙⟩ [# 1 ]
-- Try to strengthen a proof of X ∈ ⟨ y ∷ xs ⟩ to X ∈ ⟨ xs ⟩, which can be done
-- if y does not occur in X.
strengthen : ∀ {n X y} {xs : Vec Bird n} → X ∈ ⟨ y ∷ xs ⟩ → Maybe (X ∈ ⟨ xs ⟩)
-- NOTE: it could be the case that y ∈ xs, but checking that requires decidable
-- equality.
strengthen [ here X≈y ] = nothing
strengthen [ there X∈xs ] = just [ X∈xs ]
strengthen (Y∈⟨y,xs⟩ ⟨∙⟩ Z∈⟨y,xs⟩ ∣ YZ≈X) = do
Y∈⟨xs⟩ ← strengthen Y∈⟨y,xs⟩
Z∈⟨xs⟩ ← strengthen Z∈⟨y,xs⟩
just $ Y∈⟨xs⟩ ⟨∙⟩ Z∈⟨xs⟩ ∣ YZ≈X
where
open import Data.Maybe.Categorical using (monad)
open import Category.Monad using (RawMonad)
open RawMonad (monad {b ⊔ ℓ})
eliminate : ∀ {n X y} {xs : Vec Bird n} → X ∈ ⟨ y ∷ xs ⟩ → ∃[ X′ ] (X′ ∈ ⟨ S ∷ K ∷ xs ⟩ × X′ ∙ y ≈ X)
eliminate {X = X} {y} [ here X≈y ] = (I , weaken-++ˡ I∈⟨S,K⟩ , trans (isIdentity y) (sym X≈y))
eliminate {X = X} {y} [ there X∈xs ] = (K ∙ X , [# 1 ] ⟨∙⟩ [ ++⁺ʳ (S ∷ K ∷ []) X∈xs ] , isKestrel X y)
eliminate {X = X} {y} (_⟨∙⟩_∣_ {Y} {Z} Y∈⟨y,xs⟩ [ here Z≈y ] YZ≈X) with strengthen Y∈⟨y,xs⟩
... | just Y∈⟨xs⟩ = (Y , weaken-++ʳ (S ∷ K ∷ []) Y∈⟨xs⟩ , trans (congˡ (sym Z≈y)) YZ≈X)
... | nothing =
let (Y′ , Y′∈⟨S,K,xs⟩ , Y′y≈Y) = eliminate Y∈⟨y,xs⟩
SY′Iy≈X : S ∙ Y′ ∙ I ∙ y ≈ X
SY′Iy≈X = begin
S ∙ Y′ ∙ I ∙ y ≈⟨ isStarling Y′ I y ⟩
Y′ ∙ y ∙ (I ∙ y) ≈⟨ congʳ $ Y′y≈Y ⟩
Y ∙ (I ∙ y) ≈⟨ congˡ $ isIdentity y ⟩
Y ∙ y ≈˘⟨ congˡ Z≈y ⟩
Y ∙ Z ≈⟨ YZ≈X ⟩
X ∎
in (S ∙ Y′ ∙ I , [# 0 ] ⟨∙⟩ Y′∈⟨S,K,xs⟩ ⟨∙⟩ weaken-++ˡ I∈⟨S,K⟩ , SY′Iy≈X)
eliminate {X = X} {y} (_⟨∙⟩_∣_ {Y} {Z} Y∈⟨y,xs⟩ Z∈⟨y,xs⟩ YZ≈X) =
let (Y′ , Y′∈⟨S,K,xs⟩ , Y′y≈Y) = eliminate Y∈⟨y,xs⟩
(Z′ , Z′∈⟨S,K,xs⟩ , Z′y≈Z) = eliminate Z∈⟨y,xs⟩
SY′Z′y≈X : S ∙ Y′ ∙ Z′ ∙ y ≈ X
SY′Z′y≈X = begin
S ∙ Y′ ∙ Z′ ∙ y ≈⟨ isStarling Y′ Z′ y ⟩
Y′ ∙ y ∙ (Z′ ∙ y) ≈⟨ congʳ Y′y≈Y ⟩
Y ∙ (Z′ ∙ y) ≈⟨ congˡ Z′y≈Z ⟩
Y ∙ Z ≈⟨ YZ≈X ⟩
X ∎
in (S ∙ Y′ ∙ Z′ , [# 0 ] ⟨∙⟩ Y′∈⟨S,K,xs⟩ ⟨∙⟩ Z′∈⟨S,K,xs⟩ , SY′Z′y≈X)
module _ (x y : Bird) where
-- Example: y-eliminating the expression y should give I.
_ : proj₁ (eliminate {y = y} {xs = x ∷ []} $ [# 0 ]) ≈ I
_ = refl
-- Example: y-eliminating the expression x should give Kx.
_ : proj₁ (eliminate {y = y} {xs = x ∷ []} $ [# 1 ]) ≈ K ∙ x
_ = refl
-- Example: y-eliminating the expression xy should give x (Principle 3).
_ : proj₁ (eliminate {y = y} {xs = x ∷ []} $ [# 1 ] ⟨∙⟩ [# 0 ]) ≈ x
_ = refl
-- Example: y-eliminating the expression yx should give SI(Kx).
_ : proj₁ (eliminate {y = y} {xs = x ∷ []} $ [# 0 ] ⟨∙⟩ [# 1 ]) ≈ S ∙ I ∙ (K ∙ x)
_ = refl
-- Example: y-eliminating the expression yy should give SII.
_ : proj₁ (eliminate {y = y} {xs = x ∷ []} $ [# 0 ] ⟨∙⟩ [# 0 ]) ≈ S ∙ I ∙ I
_ = refl
strengthen-SK : ∀ {n X y} {xs : Vec Bird n} → X ∈ ⟨ S ∷ K ∷ y ∷ xs ⟩ → Maybe (X ∈ ⟨ S ∷ K ∷ xs ⟩)
strengthen-SK {y = y} {xs} X∈⟨S,K,y,xs⟩ = do
let X∈⟨y,xs,S,K⟩ = ++-comm (S ∷ K ∷ []) (y ∷ xs) X∈⟨S,K,y,xs⟩
X∈⟨xs,S,K⟩ ← strengthen X∈⟨y,xs,S,K⟩
let X∈⟨S,K,xs⟩ = ++-comm xs (S ∷ K ∷ []) X∈⟨xs,S,K⟩
just X∈⟨S,K,xs⟩
where
open import Data.Maybe.Categorical using (monad)
open import Category.Monad using (RawMonad)
open RawMonad (monad {b ⊔ ℓ})
-- TODO: formulate eliminate or eliminate-SK in terms of the other.
eliminate-SK : ∀ {n X y} {xs : Vec Bird n} → X ∈ ⟨ S ∷ K ∷ y ∷ xs ⟩ → ∃[ X′ ] (X′ ∈ ⟨ S ∷ K ∷ xs ⟩ × X′ ∙ y ≈ X)
eliminate-SK {X = X} {y} [ here X≈S ] = (K ∙ S , [# 1 ] ⟨∙⟩ [# 0 ] , trans (isKestrel S y) (sym X≈S))
eliminate-SK {X = X} {y} [ there (here X≈K) ] = (K ∙ K , [# 1 ] ⟨∙⟩ [# 1 ] , trans (isKestrel K y) (sym X≈K))
eliminate-SK {X = X} {y} [ there (there (here X≈y)) ] = (I , weaken-++ˡ I∈⟨S,K⟩ , trans (isIdentity y) (sym X≈y))
eliminate-SK {X = X} {y} [ there (there (there X∈xs)) ] = (K ∙ X , ([# 1 ] ⟨∙⟩ [ (++⁺ʳ (S ∷ K ∷ []) X∈xs) ]) , isKestrel X y)
eliminate-SK {X = X} {y} (_⟨∙⟩_∣_ {Y} {Z} Y∈⟨S,K,y,xs⟩ [ there (there (here Z≈y)) ] YZ≈X) with strengthen-SK Y∈⟨S,K,y,xs⟩
... | just Y∈⟨S,K,xs⟩ = (Y , Y∈⟨S,K,xs⟩ , trans (congˡ (sym Z≈y)) YZ≈X)
... | nothing =
let (Y′ , Y′∈⟨S,K,xs⟩ , Y′y≈Y) = eliminate-SK Y∈⟨S,K,y,xs⟩
SY′Iy≈X : S ∙ Y′ ∙ I ∙ y ≈ X
SY′Iy≈X = begin
S ∙ Y′ ∙ I ∙ y ≈⟨ isStarling Y′ I y ⟩
Y′ ∙ y ∙ (I ∙ y) ≈⟨ congʳ $ Y′y≈Y ⟩
Y ∙ (I ∙ y) ≈⟨ congˡ $ isIdentity y ⟩
Y ∙ y ≈˘⟨ congˡ Z≈y ⟩
Y ∙ Z ≈⟨ YZ≈X ⟩
X ∎
in (S ∙ Y′ ∙ I , [# 0 ] ⟨∙⟩ Y′∈⟨S,K,xs⟩ ⟨∙⟩ weaken-++ˡ I∈⟨S,K⟩ , SY′Iy≈X)
eliminate-SK {X = X} {y} (_⟨∙⟩_∣_ {Y} {Z} Y∈⟨S,K,y,xs⟩ Z∈⟨S,K,y,xs⟩ YZ≈X) =
let (Y′ , Y′∈⟨S,K,xs⟩ , Y′y≈Y) = eliminate-SK Y∈⟨S,K,y,xs⟩
(Z′ , Z′∈⟨S,K,xs⟩ , Z′y≈Z) = eliminate-SK Z∈⟨S,K,y,xs⟩
SY′Z′y≈X : S ∙ Y′ ∙ Z′ ∙ y ≈ X
SY′Z′y≈X = begin
S ∙ Y′ ∙ Z′ ∙ y ≈⟨ isStarling Y′ Z′ y ⟩
Y′ ∙ y ∙ (Z′ ∙ y) ≈⟨ congʳ Y′y≈Y ⟩
Y ∙ (Z′ ∙ y) ≈⟨ congˡ Z′y≈Z ⟩
Y ∙ Z ≈⟨ YZ≈X ⟩
X ∎
in (S ∙ Y′ ∙ Z′ , [# 0 ] ⟨∙⟩ Y′∈⟨S,K,xs⟩ ⟨∙⟩ Z′∈⟨S,K,xs⟩ , SY′Z′y≈X)
module _ (x y : Bird) where
-- Example: y-eliminating the expression y should give I.
_ : proj₁ (eliminate-SK {y = y} {xs = x ∷ []} $ [# 2 ]) ≈ I
_ = refl
-- Example: y-eliminating the expression x should give Kx.
_ : proj₁ (eliminate-SK {y = y} {xs = x ∷ []} $ [# 3 ]) ≈ K ∙ x
_ = refl
-- Example: y-eliminating the expression xy should give x (Principle 3).
_ : proj₁ (eliminate-SK {y = y} {xs = x ∷ []} $ [# 3 ] ⟨∙⟩ [# 2 ]) ≈ x
_ = refl
-- Example: y-eliminating the expression yx should give SI(Kx).
_ : proj₁ (eliminate-SK {y = y} {xs = x ∷ []} $ [# 2 ] ⟨∙⟩ [# 3 ]) ≈ S ∙ I ∙ (K ∙ x)
_ = refl
-- Example: y-eliminating the expression yy should give SII.
_ : proj₁ (eliminate-SK {y = y} {xs = x ∷ []} $ [# 2 ] ⟨∙⟩ [# 2 ]) ≈ S ∙ I ∙ I
_ = refl
infixl 6 _∙ⁿ_
_∙ⁿ_ : ∀ {n} → (A : Bird) (xs : Vec Bird n) → Bird
A ∙ⁿ [] = A
A ∙ⁿ (x ∷ xs) = A ∙ⁿ xs ∙ x
eliminateAll′ : ∀ {n X} {xs : Vec Bird n} → X ∈ ⟨ S ∷ K ∷ xs ⟩ → ∃[ X′ ] (X′ ∈ ⟨ S ∷ K ∷ [] ⟩ × X′ ∙ⁿ xs ≈ X)
eliminateAll′ {X = X} {[]} X∈⟨S,K⟩ = (X , X∈⟨S,K⟩ , refl)
eliminateAll′ {X = X} {x ∷ xs} X∈⟨S,K,x,xs⟩ =
let (X′ , X′∈⟨S,K,xs⟩ , X′x≈X) = eliminate-SK X∈⟨S,K,x,xs⟩
(X″ , X″∈⟨S,K⟩ , X″xs≈X′) = eliminateAll′ X′∈⟨S,K,xs⟩
X″∙ⁿxs∙x≈X : X″ ∙ⁿ xs ∙ x ≈ X
X″∙ⁿxs∙x≈X = begin
X″ ∙ⁿ xs ∙ x ≈⟨ congʳ X″xs≈X′ ⟩
X′ ∙ x ≈⟨ X′x≈X ⟩
X ∎
in (X″ , X″∈⟨S,K⟩ , X″∙ⁿxs∙x≈X)
-- TOOD: can we do this in some way without depending on xs : Vec Bird n?
eliminateAll : ∀ {n X} {xs : Vec Bird n} → X ∈ ⟨ xs ⟩ → ∃[ X′ ] (X′ ∈ ⟨ S ∷ K ∷ [] ⟩ × X′ ∙ⁿ xs ≈ X)
eliminateAll X∈⟨xs⟩ = eliminateAll′ $ weaken-++ʳ (S ∷ K ∷ []) X∈⟨xs⟩
|
vm/grammar/TLexer.g4 | verbum-lang/verbum-language | 0 | 6962 |
/*
** Copyright (c) 2022, the Verbum project authors. Please see the AUTHORS file
** for details. All rights reserved. Use of this source code is governed by a
** BSD-style license that can be found in the LICENSE file.
**
** In principio erat Verbum et Verbum erat apud Deum et Deus erat Verbum - John 1
**
** Gramática da linguagem.
*/
lexer grammar TLexer;
@lexer::postinclude {
#ifndef _WIN32
#pragma GCC diagnostic ignored "-Wunused-parameter"
#endif
}
// Comandos e palavras reservadas.
Use : 'use' ;
Var : 'var' ;
If : 'if';
Elif : 'elif';
Else : 'else';
For : 'for';
Ret : 'ret';
Function : 'fn';
Pub : 'pub';
Pro : 'pro';
Priv : 'priv';
Static : 'static';
Final : 'final';
Interface : 'interface';
Abstract : 'abstract';
Extends : 'extends';
Class : 'class';
Implements : 'implements';
New : 'new';
Break : 'break';
Next : 'next';
Async : 'async';
Await : 'await';
Try : 'try';
Catch : 'catch';
// Operadores.
ArrowRight : '->';
ARightLB : '=>';
End : ';' ;
Attr : '=' ;
Point : '.';
TwoPoint : ':';
TwoTwoPoint : '::';
PointPoint : '..';
Separator : ',' ;
OpenArIndex : '[' ;
CloseArIndex : ']' ;
OpenBlock : '{' ;
CloseBlock : '}' ;
OpenOp : '(';
CloseOp :')';
// Operações aritméticas.
ArithmeticOperator
: '+' | '-' | '*' | '/' | '%'
;
AssignmentOperator
: '+=' | '-=' | '*=' | '/=' | '%='
| '>' | '<' | '>=' | '<='
| '&&' | '||'
| '==' | '!='
;
Not : '!';
// Incremento e decremento.
IncDecOperators
: ( '++' | '--' )
;
Identifier
: IDPrefix
| IDPrefix ( Words | [0-9]+ | [_] )*
;
IDPrefix
: ( [_] | Words )
;
TypeSpec
: [:] ( Identifier )
;
Words
: [a-zA-Z\u0080-\u{10FFFF}]+
;
Integer
: [0-9]+ | [-][0-9]+
;
Float
: FloatLiteral | [-] FloatLiteral
;
String
: '"' ( ~('"') | ('\\' '"') )* '"'
| '\'' ( ~('\'') | ('\\' '\'') )* '\''
;
// Comentários.
BlockComment
: '/*' .*? '*/'
-> skip
;
LineComment
: '//' ~[\r\n]*
-> skip
;
// Espaço em branco e nova-linha.
Whitespace
: [ \t]+
-> skip
;
Newline
: ( '\r' '\n'?
| '\n'
)
-> skip
;
// Fragments... (uso futuro)
fragment DecimalExponent : 'e' | 'E' | 'e+' | 'E+' | 'e-' | 'E-' DecimalDigits;
fragment DecimalDigits : ('0'..'9'|'_')+ ;
fragment FloatLiteral : FloatFrag ImaginarySuffix?;
fragment IntegerLiteral : IntegerFrag IntSuffix?;
fragment FloatTypeSuffix : 'f' | 'F' | 'L';
fragment ImaginarySuffix : 'i';
fragment IntSuffix : 'L'|'u'|'U'|'Lu'|'LU'|'uL'|'UL' ;
fragment IntegerFrag : Decimal| Binary| Octal| Hexadecimal ;
fragment Decimal : '0' | '1'..'9' (DecimalDigit | '_')* ;
fragment Binary : ('0b' | '0B') ('0' | '1' | '_')+ ;
fragment Octal : '0' (OctalDigit | '_')+ ;
fragment Hexadecimal : ('0x' | '0X') (HexDigit | '_')+;
fragment DecimalDigit : '0'..'9' ;
fragment OctalDigit : '0'..'7' ;
fragment HexDigit : ('0'..'9'|'a'..'f'|'A'..'F') ;
fragment FloatFrag
: DecimalDigits ( FloatTypeSuffix
| '.' DecimalDigits DecimalExponent?
)
| '.' DecimalDigits DecimalExponent?
;
fragment NUMBER: DIGITS | OCTAL_DIGITS | HEX_DIGITS;
fragment DIGITS: '1'..'9' '0'..'9'*;
fragment OCTAL_DIGITS: '0' '0'..'7'+;
fragment HEX_DIGITS: '0x' ('0'..'9' | 'a'..'f' | 'A'..'F')+;
/* Tokens desconhecidos. */
// Unknown : . ;
|
unittests/ASM/H0F38/66_1E.asm | cobalt2727/FEX | 628 | 80895 | %ifdef CONFIG
{
"RegData": {
"XMM0": ["0x0", "0x0"],
"XMM1": ["0x0000000100000001", "0x0000000100000001"],
"XMM2": ["0x0000000100000001", "0x0000000100000001"],
"XMM3": ["0x0000000100000000", "0x0000000100000001"]
}
}
%endif
mov rdx, 0xe0000000
mov rax, 0x0000000000000000
mov [rdx + 8 * 0], rax
mov [rdx + 8 * 1], rax
mov rax, 0xFFFFFFFFFFFFFFFF
mov [rdx + 8 * 2], rax
mov [rdx + 8 * 3], rax
mov rax, 0x0000000100000001
mov [rdx + 8 * 4], rax
mov [rdx + 8 * 5], rax
mov rax, 0xFFFFFFFF00000000
mov [rdx + 8 * 6], rax
mov rax, 0x00000001FFFFFFFF
mov [rdx + 8 * 7], rax
; Test with full zero
pabsd xmm0, [rdx + 8 * 0]
; Test with full negative
pabsd xmm1, [rdx + 8 * 2]
; Test with full positive
pabsd xmm2, [rdx + 8 * 4]
; Test a mix
pabsd xmm3, [rdx + 8 * 6]
hlt
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.