max_stars_repo_path stringlengths 4 261 | max_stars_repo_name stringlengths 6 106 | max_stars_count int64 0 38.8k | id stringlengths 1 6 | text stringlengths 7 1.05M |
|---|---|---|---|---|
programs/oeis/073/A073850.asm | neoneye/loda | 22 | 82891 | <reponame>neoneye/loda
; A073850: Cumulative sum of initial digits of (n base 4).
; 0,1,3,6,7,8,9,10,12,14,16,18,21,24,27,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,81,84,87,90,93,96,99,102,105,108,111,114,117,120,123,126,127,128,129,130
mov $2,$0
mov $4,$0
lpb $2
mov $0,$4
sub $2,1
sub $0,$2
mov $3,$0
lpb $0
div $3,4
sub $0,$3
lpe
add $1,$3
lpe
mov $0,$1
|
externals/ffmpeg/libavcodec/x86/sbrdsp.asm | vuece/vuece-libjingle | 0 | 83871 | ;******************************************************************************
;* AAC Spectral Band Replication decoding functions
;* Copyright (C) 2012 <NAME> <<EMAIL>>
;*
;* This file is part of Libav.
;*
;* Libav is free software; you can redistribute it and/or
;* modify it under the terms of the GNU Lesser General Public
;* License as published by the Free Software Foundation; either
;* version 2.1 of the License, or (at your option) any later version.
;*
;* Libav is distributed in the hope that it will be useful,
;* but WITHOUT ANY WARRANTY; without even the implied warranty of
;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;* Lesser General Public License for more details.
;*
;* You should have received a copy of the GNU Lesser General Public
;* License along with Libav; if not, write to the Free Software
;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
;******************************************************************************
%include "x86inc.asm"
%include "x86util.asm"
;SECTION_RODATA
SECTION .text
INIT_XMM sse
cglobal sbr_sum_square, 2, 3, 6
mov r2, r1
xorps m0, m0
xorps m1, m1
sar r2, 3
jz .prepare
.loop:
movu m2, [r0 + 0]
movu m3, [r0 + 16]
movu m4, [r0 + 32]
movu m5, [r0 + 48]
mulps m2, m2
mulps m3, m3
mulps m4, m4
mulps m5, m5
addps m0, m2
addps m1, m3
addps m0, m4
addps m1, m5
add r0, 64
dec r2
jnz .loop
.prepare:
and r1, 7
sar r1, 1
jz .end
; len is a multiple of 2, thus there are at least 4 elements to process
.endloop:
movu m2, [r0]
add r0, 16
mulps m2, m2
dec r1
addps m0, m2
jnz .endloop
.end:
addps m0, m1
movhlps m2, m0
addps m0, m2
movss m1, m0
shufps m0, m0, 1
addss m0, m1
%if ARCH_X86_64 == 0
movss r0m, m0
fld dword r0m
%endif
RET
%define STEP 40*4*2
cglobal sbr_hf_g_filt, 5, 6, 5
lea r1, [r1 + 8*r4] ; offset by ixh elements into X_high
mov r5, r3
and r3, 0xFC
lea r2, [r2 + r3*4]
lea r0, [r0 + r3*8]
neg r3
jz .loop1
.loop4:
movlps m0, [r2 + 4*r3 + 0]
movlps m1, [r2 + 4*r3 + 8]
movlps m2, [r1 + 0*STEP]
movlps m3, [r1 + 2*STEP]
movhps m2, [r1 + 1*STEP]
movhps m3, [r1 + 3*STEP]
unpcklps m0, m0
unpcklps m1, m1
mulps m0, m2
mulps m1, m3
movu [r0 + 8*r3 + 0], m0
movu [r0 + 8*r3 + 16], m1
add r1, 4*STEP
add r3, 4
jnz .loop4
and r5, 3 ; number of single element loops
jz .end
.loop1: ; element 0 and 1 can be computed at the same time
movss m0, [r2]
movlps m2, [r1]
unpcklps m0, m0
mulps m2, m0
movlps [r0], m2
add r0, 8
add r2, 4
add r1, STEP
dec r5
jnz .loop1
.end:
RET
|
etc/itermv3_debates.scpt | wbez/budget-address-factcheck-2017 | 0 | 470 | <reponame>wbez/budget-address-factcheck-2017
tell application "iTerm2"
tell current window
tell current session
-- debates tool pane
set name to "debates"
set server to (split vertically with default profile)
-- CHANGE path to your needs
write text "cd ~/npr/projects/debates/"
write text "workon debates"
write text "git pull"
end tell
tell server
-- server pane
set name to "server"
set daemon to (split horizontally with default profile)
-- CHANGE path to your needs
write text "cd ~/npr/projects/debates/"
write text "workon debates"
write text "fab app"
end tell
tell daemon
-- daemon pane
set name to "daemon"
-- CHANGE path to your needs
write text "cd ~/npr/projects/debates/"
write text "workon debates"
write text "fab daemons.main"
end tell
end tell
end tell
|
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c5/c52011b.ada | best08618/asylo | 7 | 3159 | -- C52011B.ADA
-- Grant of Unlimited Rights
--
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- released technical data and computer software in whole or in part, in
-- any manner and for any purpose whatsoever, and to have or permit others
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- CHECK DISCRIMINANT CONSTRAINTS FOR ASSIGNMENT OF ACCESS SUBTYPES.
-- SPECIFICALLY, CHECK THAT:
-- A) ANY ACCESS TYPE VARIABLE AND CONSTRAINED SUBTYPE VARIABLES OF THAT
-- TYPE MAY BE ASSIGNED TO ONE ANOTHER IF THE VALUE BEING ASSIGNED
-- IS NULL.
-- B) VARIABLES OF THE SAME CONSTRAINED ACCESS SUBTYPE MAY BE ASSIGNED
-- TO ONE ANOTHER OR TO VARIABLES OF THE BASE ACCESS TYPE.
-- C) CONSTRAINT_ERROR IS RAISED UPON ASSIGNMENT OF NON-NULL OBJECTS
-- BETWEEN DIFFERENTLY CONSTRAINED ACCESS SUBTYPES.
-- D) CONSTRAINT_ERROR IS RAISED UPON ASSIGNMENT OF A NON-NULL OBJECT
-- OF A BASE ACCESS TYPE VARIABLE TO A VARIABLE OF ONE OF ITS
-- CONSTRAINED SUBTYPES IF THE CONSTRAINTS ON THE OBJECT DIFFER
-- FROM THOSE ON THE SUBTYPE.
-- E) NULL CAN BE ASSIGNED TO BASE ACCESS TYPES AND ANY CONSTRAINED
-- SUBTYPES OF THIS TYPE.
-- ASL 7/06/81
-- RM 6/17/82
-- RLB 6/29/01 - FIXED TO ALLOW AGGRESIVE OPTIMIZATION.
WITH REPORT;
PROCEDURE C52011B IS
USE REPORT;
TYPE REC(DISC : INTEGER := -1 ) IS
RECORD
NULL;
END RECORD;
TYPE REC_NAME IS ACCESS REC;
SUBTYPE S1 IS REC_NAME(IDENT_INT(5));
SUBTYPE S2 IS REC_NAME(IDENT_INT(3));
W : REC_NAME := NULL; -- E.
X1,X2 : S1 := NULL; -- E.
Y1,Y2 : S2 := NULL; -- E.
W_NONNULL : REC_NAME := NEW REC(7) ;
X1_NONNULL : S1 := NEW REC(IDENT_INT(5));
Y1_NONNULL : S2 := NEW REC(IDENT_INT(3));
TOO_EARLY : BOOLEAN := TRUE;
BEGIN
TEST ("C52011B", "DISCRIMINANT CONSTRAINTS ON ACCESS SUBTYPE " &
"OBJECTS MUST BE SATISFIED FOR ASSIGNMENT");
BEGIN
IF EQUAL(3,3) THEN
W_NONNULL := X1; -- A.
END IF;
IF W_NONNULL /= X1 THEN
FAILED ("ASSIGNMENT FAILED - 1");
END IF;
IF EQUAL(3,3) THEN
W := Y1; -- A.
END IF;
IF W /= Y1 THEN
FAILED ("ASSIGNMENT FAILED - 2");
END IF;
IF EQUAL(3,3) THEN
X1_NONNULL := Y1; -- A.
END IF;
IF X1_NONNULL /= Y1 THEN
FAILED ("ASSIGNMENT FAILED - 3");
END IF;
IF EQUAL(3,3) THEN
Y1_NONNULL := Y2; -- A.
END IF;
IF Y1_NONNULL /= Y2 THEN
FAILED ("ASSIGNMENT FAILED - 4");
END IF;
X1 := NEW REC(IDENT_INT(5));
IF EQUAL(3,3) THEN
X2 := X1; -- B.
END IF;
IF X1 /= X2 THEN
FAILED ("ASSIGNMENT FAILED - 5");
END IF;
IF EQUAL(3,3) THEN
W := X1; -- B.
END IF;
IF W /= X1 THEN
FAILED ("ASSIGNMENT FAILED - 6");
END IF;
BEGIN
Y1 := X1; -- C.
IF Y1.DISC /= REPORT.IDENT_INT(3) THEN
FAILED ("NON-NULL ASSIGNMENT MADE BETWEEN TWO " &
"VARIABLES OF DIFFERENT CONSTRAINED ACCESS SUBTYPES " &
"AND CONSTRAINT IS CHANGED");
ELSE
FAILED ("NON-NULL ASSIGNMENT MADE BETWEEN TWO " &
"VARIABLES OF DIFFERENT CONSTRAINED ACCESS SUBTYPES " &
"AND CONSTRAINT IS NOT CHANGED");
END IF;
EXCEPTION
WHEN CONSTRAINT_ERROR => NULL;
WHEN OTHERS =>
FAILED ("WRONG EXCEPTION - 1");
END;
W := NEW REC(IDENT_INT(3));
BEGIN
X1 := W; -- D.
IF X1.DISC /= REPORT.IDENT_INT(5) THEN
FAILED ("NON-NULL ASSIGNMENT MADE FROM UNCONSTRAINED " &
"ACCESS TYPE DESIGNATING CONSTRAINED OBJECT TO "&
"ACCESS SUBTYPE WITH DIFFERENT CONSTRAINT " &
"AND CONSTRAINT IS CHANGED");
ELSE
FAILED ("NON-NULL ASSIGNMENT MADE FROM UNCONSTRAINED " &
"ACCESS TYPE DESIGNATING CONSTRAINED OBJECT TO "&
"ACCESS SUBTYPE WITH DIFFERENT CONSTRAINT " &
"AND CONSTRAINT IS NOT CHANGED");
END IF;
EXCEPTION
WHEN CONSTRAINT_ERROR =>
NULL ;
WHEN OTHERS =>
FAILED ("WRONG EXCEPTION - 2");
END;
EXCEPTION
WHEN OTHERS =>
FAILED ("EXCEPTION RAISED");
END;
RESULT;
END C52011B;
|
software/modules/estimator.adb | TUM-EI-RCS/StratoX | 12 | 14701 | -- Institution: Technische Universitaet Muenchen
-- Department: Realtime Computer Systems (RCS)
-- Project: StratoX
-- Module: Estimator
--
-- Authors: <NAME> (<EMAIL>)
--with Generic_Signal;
--with Generic_Sensor;
with Generic_Queue;
with Ada.Real_Time; use Ada.Real_Time;
with Ada.Numerics.Elementary_Functions; use Ada.Numerics.Elementary_Functions;
with Config.Software;
with Units.Numerics; use Units.Numerics;
with Bounded_Image; use Bounded_Image;
with HIL;
with IMU;
with GPS;
with Barometer;
with Magnetometer;
with Units; use Units;
with Types;
with Logger;
with ULog;
with Profiler;
with Kalman;
with NVRAM;
pragma Elaborate_All(generic_queue);
package body Estimator with SPARK_Mode is
---------------------
-- TYPE DEFS
---------------------
type Height_Index_Type is mod 10;
type IMU_Index_Type is mod 10;
type Baro_Call_Type is mod 2;
type Logger_Call_Type is mod Config.Software.CFG_LOGGER_CALL_SKIP; -- set log ratio
package Height_Buffer_Pack is new Generic_Queue(Index_Type => Height_Index_Type,
Element_Type => Altitude_Type);
use Height_Buffer_Pack;
package GPS_Buffer_Pack is new Generic_Queue(Index_Type => Height_Index_Type,
Element_Type => GPS_Loacation_Type);
use GPS_Buffer_Pack;
package IMU_Buffer_Pack is new Generic_Queue(Index_Type => IMU_Index_Type,
Element_Type => Orientation_Type);
use IMU_Buffer_Pack;
type GPS_info is record
fix : GPS_Fix_Type := NO_FIX;
gps_speed : Linear_Velocity_Type := 0.0 * Meter/Second; -- 2D projected ground speed
nsat : Unsigned_8 := 0;
gps_datetime : GPS.GPS_DateTime;
vacc : Units.Length_Type := 100.0 * Meter; -- vertical accuracy
had_good_accuracy : Boolean := False;
end record;
type State_Type is record
init_time : Time := Time_First;
gpsinfo : GPS_info;
avg_gps_height : Altitude_Type := 0.0 * Meter;
max_gps_height : Altitude_Type := 0.0 * Meter;
avg_baro_height : Altitude_Type := 0.0 * Meter;
max_baro_height : Altitude_Type := 0.0 * Meter;
height_deviation : Linear_Velocity_Type := 0.0 * Meter/Second;
baro_calls : Baro_Call_Type := 0;
baro_press : Pressure_Type := 0.0 * Pascal;
baro_temp : Temperature_Type := CELSIUS_0;
baro_alt : Units.Length_Type := 0.0 * Meter;
logger_calls : Logger_Call_Type := 0; -- counter for log ratio
logger_console_calls : Logger_Call_Type := 0;
stable_Time : Time_Type := 0.0 * Second;
last_stable_check : Ada.Real_Time.Time := Ada.Real_Time.Time_First;
home_pos : GPS_Loacation_Type; -- takeoff location
home_baro_alt : Altitude_Type := 0.0 * Meter; -- takeoff altitude
kmObservations : Kalman.Observation_Vector;
end record;
-- type Sensor_Record is record
-- GPS1 : GPS.GPS_Tag;
-- Baro1 : Barometer.Barometer_Tag;
-- IMU1 : IMU.IMU_Tag;
-- Mag1 : Magnetometer.Magnetometer_Tag;
-- end record;
type IMU_Data_Type is record
Acc : Linear_Acceleration_Vector;
Gyro : Angular_Velocity_Vector;
end record;
---------------------
-- INTERNAL STATES
---------------------
G_state : State_Type; -- all the states
G_imu : IMU_Data_Type;
G_mag : Magnetic_Flux_Density_Vector;
-- G_Sensor : Sensor_Record;
G_height_buffer : Height_Buffer_Pack.Buffer_Tag;
G_pos_buffer : GPS_Buffer_Pack.Buffer_Tag;
G_orientation_buffer : IMU_Buffer_Pack.Buffer_Tag;
G_Profiler : Profiler.Profile_Tag;
---------------------
-- PROTOTYPES
---------------------
function Len_to_Alt (len : Units.Length_Type) return Altitude_Type
with Pre => True; -- need this fake contract as workaround for GNATprove bug
---------------------
-- initialize
---------------------
procedure initialize is
begin
G_state.init_time := Clock;
G_state.max_gps_height := 0.0 * Meter;
G_state.max_baro_height := 0.0 * Meter;
-- Orientation Sensors
IMU.Sensor.initialize;
Magnetometer.Sensor.initialize;
-- Position Sensors
Barometer.Sensor.initialize;
Barometer.Sensor.read_Measurement;
GPS.Sensor.initialize;
-- Profiler
G_Profiler.init("Estimator");
Kalman.reset;
Logger.log_console(Logger.INFO, "Estimator initialized");
end initialize;
procedure reset is
init_state : Kalman.State_Vector := Kalman.DEFAULT_INIT_STATES;
bias_raw : HIL.Byte;
begin
NVRAM.Load(NVRAM.VAR_GYRO_BIAS_X, bias_raw );
init_state.bias(X) := Unit_Type( HIL.toInteger_8(bias_raw)) * Deci * Degree / Second;
Kalman.reset;
end reset;
---------------------
-- Len_to_Alt
---------------------
-- handle the different ranges of Length_Type and Altitude_Type
function Len_to_Alt (len : Units.Length_Type) return Altitude_Type is
alt : Altitude_Type;
begin
if len < Altitude_Type'First then
alt := Altitude_Type'First;
elsif len > Altitude_Type'Last then
alt := Altitude_Type'Last;
else
alt := Altitude_Type (len);
end if;
return alt;
end Len_to_Alt;
---------------------
-- update
---------------------
-- fetch fresh measurement data
procedure update( input : Kalman.Input_Vector ) is
Acc_Orientation : Orientation_Type;
CF_Orientation : Orientation_Type;
GFixS : String := "NO";
pragma Unreferenced (GFixS);
begin
G_Profiler.start;
-- Estimate Object Orientation
IMU.Sensor.read_Measurement;
G_imu.Acc := IMU.Sensor.get_Linear_Acceleration;
G_imu.Gyro := IMU.Sensor.get_Angular_Velocity;
-- Logger.log_console(Logger.DEBUG,"Acc: " & Image(G_imu.Acc(X)) & ", "
-- & Image(G_imu.Acc(Y)) & ", " & Image(G_imu.Acc(Z)) );
-- Logger.log_console(Logger.DEBUG,"Gyro: " & AImage(G_imu.Gyro(X)*Second)
-- & ", " & AImage(G_imu.Gyro(Y)*Second) & ", " & AImage(G_imu.Gyro(Z)*Second) );
-- Logger.log_console(Logger.DEBUG,"Gyro: " & RImage(G_imu.Gyro(Roll)*Second)
-- & ", " & RImage(G_imu.Gyro(Pitch)*Second) & ", " & RImage(G_imu.Gyro(YAW)*Second) );
Acc_Orientation := Orientation( G_imu.Acc );
-- CF_Orientation := IMU.Fused_Orientation( IMU.Sensor, Acc_Orientation, Gyro);
-- IMU.perform_Kalman_Filtering( IMU.Sensor, Acc_Orientation );
-- G_Object_Orientation := IMU.Sensor.get_Orientation;
-- Logger.log_console(Logger.INFO, "RPY: " & AImage( Acc_Orientation.Roll ) & ", "
-- & AImage( Acc_Orientation.Pitch ) & ", " & AImage( Acc_Orientation.Yaw ) );
-- Logger.log_console(Logger.INFO, "CF : " & AImage( CF_Orientation.Roll ) & ", "
-- & AImage( CF_Orientation.Pitch ) & ", " & AImage( CF_Orientation.Yaw ) );
-- Logger.log_console(Logger.INFO, "KM : " & AImage( G_Object_Orientation.Roll ) & ", "
-- & AImage( G_Object_Orientation.Pitch ) & ", " & AImage( G_Object_Orientation.Yaw ) );
Magnetometer.Sensor.read_Measurement;
G_mag := Magnetometer.Sensor.get_Sample.data;
Acc_Orientation.Yaw := Heading (G_mag, G_Object_Orientation);
G_Object_Orientation.Yaw := Acc_Orientation.Yaw; -- copy for kalman filter
--Logger.log_console(Logger.DEBUG, "Mag (uT):" & Image(G_Mag(X) * 1.0e6) &
-- ", " & Image(G_Mag(Y) * 1.0e6) &
-- ", " & Image(G_Mag(Z) * 1.0e6) &
-- ", Yaw=" & Float'Image (To_Degree (G_Object_Orientation.Yaw)));
-- Estimate Object Position
Barometer.Sensor.read_Measurement; -- >= 4 calls for new data
G_state.baro_calls := Baro_Call_Type'Succ( G_state.baro_calls );
if G_state.baro_calls = 0 then
declare
previous_height : Altitude_Type := 0.0*Meter;
begin
if not Height_Buffer_Pack.Empty( G_height_buffer ) then
Height_Buffer_Pack.get_front( G_height_buffer, previous_height );
-- G_state.height_deviation := (Barometer.Sensor.get_Altitude - previous_height ) / dt;
end if;
end;
G_state.baro_temp := Barometer.Sensor.get_Temperature;
G_state.baro_press := Barometer.Sensor.get_Pressure;
G_state.baro_alt := Barometer.Sensor.get_Altitude;
Height_Buffer_Pack.push_back( G_height_buffer, Len_to_Alt (Barometer.Sensor.get_Altitude));
update_Max_Height;
end if;
GPS.Sensor.read_Measurement;
G_state.gpsinfo.fix := GPS.Sensor.get_GPS_Fix;
G_state.gpsinfo.nsat := GPS.Sensor.get_Num_Sats;
G_state.gpsinfo.gps_speed := GPS.Sensor.get_Speed;
G_state.gpsinfo.vacc := GPS.Sensor.get_Pos_Accuracy;
G_state.gpsinfo.gps_datetime := GPS.Sensor.get_Time;
-- this is for GPS startup: trust in it only when it reached the accuracy goal once
G_state.gpsinfo.had_good_accuracy := G_state.gpsinfo.had_good_accuracy or
G_state.gpsinfo.vacc < Config.Software.POSITION_LEAST_ACCURACY;
-- FIXME: Sprung durch Baro Offset, falls GPS wegfaellt (QNH muss eingearbeitet werden)
if G_state.gpsinfo.fix = FIX_3D then
G_Object_Position := GPS.Sensor.get_Position;
-- overwrite/ignore altitude when too shabby at boot. Note position is consumed (we have no alternative)
if not G_state.gpsinfo.had_good_accuracy then
G_Object_Position.Altitude := Len_to_Alt (Barometer.Sensor.get_Altitude);
end if;
GFixS := "3D";
elsif G_state.gpsinfo.fix = FIX_2D then
GFixS := "2D";
G_Object_Position := GPS.Sensor.get_Position;
G_Object_Position.Altitude := Len_to_Alt (Barometer.Sensor.get_Altitude); -- Overwrite Alt (too imprecise)
else
GFixS := "NO";
G_Object_Position.Altitude := Len_to_Alt (Barometer.Sensor.get_Altitude);
end if;
-- perform Kalman filtering
G_state.kmObservations := ( G_Object_Position, G_state.avg_baro_height, Acc_Orientation, G_imu.Gyro, abs(G_imu.Acc) );
Kalman.perform_Filter_Step( input, G_state.kmObservations );
G_Object_Orientation.Roll := Kalman.get_States.orientation.Roll;
G_Object_Orientation.Pitch := Kalman.get_States.orientation.Pitch;
G_Object_Orientation.Yaw := Kalman.get_States.orientation.Yaw; -- new: not active, although it is looking quiet good
-- update stable measurements
check_stable_Time;
-- Outputs
G_state.logger_calls := Logger_Call_Type'Succ( G_state.logger_calls );
if G_state.logger_calls = 0 then
log_Info;
-- FIXME: the GPS does weird things the first seconds after getting a fix. The altitude
-- is far too high and then slowly comes back. We should not trust that
if G_state.gpsinfo.fix = FIX_2D or G_state.gpsinfo.fix = FIX_3D then
G_pos_buffer.push_back( GPS.Sensor.get_Position );
end if;
G_orientation_buffer.push_back( G_Object_Orientation );
end if;
G_Profiler.stop;
end update;
---------------------
-- reset_log_calls
---------------------
procedure reset_log_calls is
begin
G_state.logger_calls := 0;
end reset_log_calls;
---------------------
-- log_info
---------------------
-- write Estimator info to logs
procedure log_Info is
imu_msg : ULog.Message (ULog.IMU);
mag_msg : ULog.Message (ULog.MAG);
gps_msg : ULog.Message (ULog.GPS);
bar_msg : ULog.Message (ULog.BARO);
now : constant Ada.Real_Time.Time := Ada.Real_Time.Clock;
begin
G_state.logger_console_calls := Logger_Call_Type'Succ( G_state.logger_console_calls );
if G_state.logger_console_calls = 0 then
Logger.log_console(Logger.DEBUG,
"Time: " & GPS.Image (G_state.gpsinfo.gps_datetime) &
", RPY: " & AImage( G_Object_Orientation.Roll ) &
", " & AImage( G_Object_Orientation.Pitch ) &
", " & AImage( G_Object_Orientation.Yaw ) &
" LG,LT,A: " & AImage( G_Object_Position.Longitude ) &
", " & AImage( G_Object_Position.Latitude ) &
", " & Image( get_current_Height ) & "m, Fix: " &
Unsigned8_Img( GPS_Fix_Type'Pos( G_state.gpsinfo.fix ) ) &
" sat: " & Unsigned8_Img (G_state.gpsinfo.nsat) &
" acc: " & Natural_Img (Types.Sat_Cast_Natural (Float (G_state.gpsinfo.vacc))));
--G_Profiler.log;
end if;
-- log to SD
imu_msg := ( Typ => ULog.IMU,
t => now,
accX => Float( G_imu.Acc(X) ),
accY => Float( G_imu.Acc(Y) ),
accZ => Float( G_imu.Acc(Z) ),
gyroX => Float( G_imu.Gyro(X) ),
gyroY => Float( G_imu.Gyro(Y) ),
gyroZ => Float( G_imu.Gyro(Z) ),
roll => Float( G_Object_Orientation.Roll ),
pitch => Float( G_Object_Orientation.Pitch ),
yaw => Float( G_Object_Orientation.Yaw )
);
mag_msg := ( Typ => ULog.MAG,
t => now,
magX => Float( G_mag(X) ),
magY => Float( G_mag(Y) ),
magZ => Float( G_mag(Z) ));
bar_msg := (Typ => ULog.BARO,
t => now,
pressure => Float (G_state.baro_press),
temp => Float (G_state.baro_temp),
press_alt => Float (G_state.baro_alt));
declare
gps_year : constant Year_Type := G_state.gpsinfo.gps_datetime.year;
gps_year_u16 : Unsigned_16;
begin
if gps_year > Natural (Unsigned_16'Last) then
gps_year_u16 := Unsigned_16'Last;
else
gps_year_u16 := Unsigned_16 (gps_year);
end if;
gps_msg := ( Typ => ULog.GPS,
t => now,
gps_year => gps_year_u16,
gps_month => Unsigned_8 (G_state.gpsinfo.gps_datetime.mon),
gps_day => Unsigned_8 (G_state.gpsinfo.gps_datetime.day),
gps_hour => Unsigned_8 (G_state.gpsinfo.gps_datetime.hour),
gps_min => Unsigned_8 (G_state.gpsinfo.gps_datetime.min),
gps_sec => Unsigned_8 (G_state.gpsinfo.gps_datetime.sec),
fix => Unsigned_8 (GPS_Fix_Type'Pos( G_state.gpsinfo.fix )),
nsat => G_state.gpsinfo.nsat,
lat => Float (G_Object_Position.Latitude / Degree),
lon => Float (G_Object_Position.Longitude / Degree),
alt => Float (G_Object_Position.Altitude),
vel => Float (G_state.gpsinfo.gps_speed),
pos_acc => Float (G_state.gpsinfo.vacc)
);
end;
-- order by priority (log queue might be full)
Logger.log_sd( Logger.SENSOR, gps_msg );
Logger.log_sd( Logger.SENSOR, imu_msg );
Logger.log_sd( Logger.SENSOR, bar_msg );
Logger.log_sd( Logger.SENSOR, mag_msg );
end log_Info;
---------------------
-- lock_home
---------------------
-- memorize home position
procedure lock_Home(position : GPS_Loacation_Type; baro_height : Altitude_Type) is
begin
G_state.home_pos := position;
G_state.home_baro_alt := baro_height;
G_state.avg_baro_height := baro_height;
G_state.avg_gps_height := position.Altitude;
end lock_Home;
---------------------
-- get_Orientation
---------------------
function get_Orientation return Orientation_Type is (G_Object_Orientation);
---------------------
-- get_Position
---------------------
function get_Position return GPS_Loacation_Type is
begin
-- G_Object_Position.Altitude := 0.0 * Meter - G_state.avg_baro_height;
return G_Object_Position;
end get_Position;
---------------------
-- get_Pos_Accuracy
---------------------
function get_Pos_Accuracy return Units.Length_Type is (G_state.gpsinfo.vacc);
---------------------
-- get_GPS_Fix
---------------------
function get_GPS_Fix return GPS_Fix_Type is (G_state.gpsinfo.fix);
---------------------
-- get_Num_Sat
---------------------
function get_Num_Sat return Unsigned_8 is (G_state.gpsinfo.nsat);
-----------------------
-- get_current_Height
-----------------------
function get_current_Height return Altitude_Type is
result : Altitude_Type;
begin
if G_state.gpsinfo.fix = FIX_3D then
result := G_state.avg_gps_height;
else
result := G_state.avg_baro_height;
end if;
return result;
end get_current_Height;
-----------------------
-- get_max_Height
-----------------------
function get_max_Height return Altitude_Type is
result : Altitude_Type;
begin
if G_state.gpsinfo.fix = FIX_3D then
result := G_state.max_gps_height;
else
result := G_state.max_baro_height;
end if;
return result;
end get_max_Height;
-----------------------
-- get_relative_Height
-----------------------
function get_relative_Height return Altitude_Type is
result : Altitude_Type;
function Sat_Sub_Alt is new Units.Saturated_Subtraction (T => Altitude_Type);
begin
if G_state.gpsinfo.fix = FIX_3D then
result := Sat_Sub_Alt (G_state.avg_gps_height, G_state.home_pos.Altitude);
else
result := Sat_Sub_Alt (G_state.avg_baro_height, G_state.home_baro_alt);
end if;
return result;
end get_relative_Height;
-----------------------
-- get_Baro_Height
-----------------------
function get_Baro_Height return Altitude_Type is
begin
return G_state.avg_baro_height;
end get_Baro_Height;
-----------------------
-- Orientation
-----------------------
-- estimate orientation based only on acceleration data
function Orientation(acc_vector : Linear_Acceleration_Vector) return Orientation_Type is
angles : Orientation_Type;
g_length : Float;
gravity_vector : Linear_Acceleration_Vector := acc_vector;
function Sat_Sub_LinAcc is new Saturated_Subtraction (Linear_Acceleration_Type);
function Sat_Cast_Pitch is new Saturated_Cast (Pitch_Type);
function Sat_Add_Float is new Saturated_Addition (Float);
begin
-- normalize vector
if abs(gravity_vector) < 0.9*GRAVITY or 1.1*GRAVITY < abs(gravity_vector) then
gravity_vector(Z) := Sat_Sub_LinAcc (gravity_vector(Z), ( sgn (gravity_vector(Z)) *
Sat_Sub_LinAcc (abs (gravity_vector), GRAVITY)));
end if;
-- check valid
if gravity_vector(Y) = 0.0 * Meter / Second**2 and gravity_vector(Z) = 0.0 * Meter / Second**2 then
angles.Roll := 0.0 * Degree;
angles.Pitch := 0.0 * Degree;
angles.Yaw := 0.0 * Degree;
else
-- Arctan: Only X = Y = 0 raises exception
-- Output range: -Cycle/2.0 to Cycle/2.0, thus -180° to 180°
angles.Roll := Roll_Type ( Arctan(
Base_Unit_Type (-gravity_vector(Y)), -- minus
Base_Unit_Type (-gravity_vector(Z))
) );
g_length := Sqrt (Sat_Add_Float (Float (gravity_vector(Y))**2, Float (gravity_vector(Z))**2));
angles.Pitch := Sat_Cast_Pitch (Float (Arctan (Base_Unit_Type (gravity_Vector(X)), Base_Unit_Type (Linear_Acceleration_Type (g_length)))));
angles.Yaw := 0.0 * Degree;
end if;
return angles;
end Orientation;
-----------------------
-- update_Max_Height
-----------------------
-- keep track of maximum altitude
procedure update_Max_Height is
function gps_average( signal : GPS_Buffer_Pack.Element_Array ) return Altitude_Type is
avg : Altitude_Type;
begin
avg := Altitude_Type( 0.0 );
for index in GPS_Buffer_Pack.Length_Type range 1 .. 2 loop
avg := avg + signal( index ).Altitude / Unit_Type( 2.0 );
end loop;
return avg;
end gps_average;
function baro_average( signal : Height_Buffer_Pack.Element_Array ) return Altitude_Type is
avg : Altitude_Type;
begin
avg := signal( signal'First ) / Unit_Type( signal'Length );
if signal'Length > 1 then
for index in Height_Buffer_Pack.Length_Type range 2 .. signal'Length loop
avg := avg + signal( index ) / Unit_Type( signal'Length );
end loop;
end if;
return avg;
end baro_average;
begin
-- GPS
declare
buf : GPS_Buffer_Pack.Element_Array(1 .. GPS_Buffer_Pack.Length_Type'Last ); -- Buffer
maxitem : constant GPS_Buffer_Pack.Length_Type := Length (G_pos_buffer);
begin
-- this is a bit wonky: SPARK cannot see the length of the queue because it's private
-- and thus the precondition cannot be checked. So we must check here for matching
-- buffer lengths.
if maxitem = buf'Length then
get_all( G_pos_buffer, buf );
if maxitem > 1 then
G_state.avg_gps_height := gps_average( buf );
end if;
else
null; -- TODO: what if it dosn't match?
end if;
end;
if G_state.avg_gps_height > G_state.max_gps_height then
G_state.max_gps_height := G_state.avg_gps_height;
end if;
-- Baro
declare
-- TODO: we can tell SPARK about the queue length because we have a specification function
-- (which is Length). But we must use 'maxitem' to declare size of "buf".
buf : Height_Buffer_Pack.Element_Array(1 .. Height_Buffer_Pack.Length_Type'Last);
maxitem : constant Height_Buffer_Pack.Length_Type := Length (G_height_buffer);
begin
-- this is a bit wonky: SPARK cannot see the length of the queue because it's private
-- and thus the precondition cannot be checked. So we must check here for matching
-- buffer lengths.
if maxitem = buf'Length then
get_all( G_height_buffer, buf );
if Length(G_height_buffer) = Height_Buffer_Pack.Length_Type'Last then
G_state.avg_baro_height := baro_average( buf );
end if;
else
null; -- TODO
end if;
end;
if G_state.avg_baro_height > G_state.max_baro_height then
G_state.max_baro_height := G_state.avg_baro_height;
end if;
end update_Max_Height;
-----------------------
-- check_stable_Time
-----------------------
-- checks how long the airframe has been standing still (roll+pitch+pos)
procedure check_stable_Time is
or_values : IMU_Buffer_Pack.Element_Array(1 .. IMU_Buffer_Pack.Length_Type'Last);
or_ref : Orientation_Type;
pos_values : GPS_Buffer_Pack.Element_Array(1 .. GPS_Buffer_Pack.Length_Type'Last);
pos_ref : GPS_Loacation_Type;
function Sat_Add is new Saturated_Addition (Time_Type);
now : constant Ada.Real_Time.Time := Ada.Real_Time.Clock;
stable : Boolean := True;
begin
if G_orientation_buffer.Length > 1 and G_pos_buffer.Length > 1 then
G_state.stable_Time := Sat_Add (G_state.stable_Time, Units.To_Time (now - G_state.last_stable_check));
if or_values'Length = G_orientation_buffer.Length then
G_orientation_buffer.get_all(or_values);
or_ref := or_values(1);
for index in Integer range 1 .. G_orientation_buffer.Length loop
if or_values(index).Roll - or_ref.Roll > 1.5 * Degree or
or_values(index).Pitch - or_ref.Pitch > 1.5 * Degree
then
G_state.stable_Time := 0.0 * Second;
end if;
end loop;
else
null; -- TODO
end if;
if G_pos_buffer.Length = pos_values'Length then
G_pos_buffer.get_all(pos_values);
pos_ref := pos_values(1);
for index in Integer range 1 .. G_pos_buffer.Length loop
if pos_values(index).Longitude - pos_ref.Longitude > 0.002 * Degree or -- 0.002° ≈ 111 Meter
pos_values(index).Latitude - pos_ref.Latitude > 0.002 * Degree or
pos_values(index).Altitude - pos_ref.Altitude > 10.0 * Meter
then
G_state.stable_Time := 0.0 * Second;
end if;
end loop;
else
null; -- TODO
end if;
else
G_state.stable_Time := 0.0 * Second;
end if;
G_state.last_stable_check := now;
end check_stable_Time;
-----------------------
-- get_Stable_Time
-----------------------
function get_Stable_Time return Time_Type is
begin
return G_state.stable_Time;
end get_Stable_Time;
end Estimator;
|
examples/subpool.adb | ytomino/drake | 33 | 4281 | -- for MR_Pool
with System.Storage_Pools.Subpools;
with System.Storage_Elements;
with Ada.Unchecked_Deallocate_Subpool;
-- for dummy item type
with Ada.Finalization;
with System.Storage_Elements.Formatting;
procedure subpool is
-- RM 13-11-6
package MR_Pool is
use System.Storage_Pools;
-- For uses of Subpools.
use System.Storage_Elements;
-- For uses of Storage_Count and Storage_Array.]
-- Mark and Release work in a stack fashion, and allocations are not allowed
-- from a subpool other than the one at the top of the stack. This is also
-- the default pool.
subtype Subpool_Handle is Subpools.Subpool_Handle;
type Mark_Release_Pool_Type (Pool_Size : Storage_Count) is new
Subpools.Root_Storage_Pool_With_Subpools with private;
function Mark (Pool : in out Mark_Release_Pool_Type)
return not null Subpool_Handle;
procedure Release (Subpool : in out Subpool_Handle) renames
Ada.Unchecked_Deallocate_Subpool;
private
type MR_Subpool is new Subpools.Root_Subpool with record
Start : Storage_Count;
end record;
subtype Subpool_Indexes is Positive range 1 .. 10;
type Subpool_Array is array (Subpool_Indexes) of aliased MR_Subpool;
type Mark_Release_Pool_Type (Pool_Size : Storage_Count) is new
Subpools.Root_Storage_Pool_With_Subpools with record
Storage : Storage_Array (0 .. Pool_Size);
Next_Allocation : Storage_Count := 1;
Markers : Subpool_Array;
Current_Pool : Subpool_Indexes := 1;
end record;
overriding
function Create_Subpool (Pool : in out Mark_Release_Pool_Type)
return not null Subpool_Handle;
function Mark (Pool : in out Mark_Release_Pool_Type)
return not null Subpool_Handle renames Create_Subpool;
overriding
procedure Allocate_From_Subpool (
Pool : in out Mark_Release_Pool_Type;
Storage_Address : out System.Address;
Size_In_Storage_Elements : in Storage_Count;
Alignment : in Storage_Count;
Subpool : not null Subpool_Handle);
overriding
procedure Deallocate_Subpool (
Pool : in out Mark_Release_Pool_Type;
Subpool : in out Subpool_Handle);
overriding
function Default_Subpool_for_Pool (Pool : in out Mark_Release_Pool_Type)
return not null Subpool_Handle;
overriding
procedure Initialize (Pool : in out Mark_Release_Pool_Type);
-- We don't need Finalize.
end MR_Pool;
package body MR_Pool is
use type Subpool_Handle;
procedure Initialize (Pool : in out Mark_Release_Pool_Type) is
-- Initialize the first default subpool.
begin
Subpools.Initialize (Subpools.Root_Storage_Pool_With_Subpools (Pool)); -- drake
Pool.Markers(1).Start := 1;
Subpools.Set_Pool_of_Subpool
(Pool.Markers(1)'Unchecked_Access, Pool);
end Initialize;
function Create_Subpool (Pool : in out Mark_Release_Pool_Type)
return not null Subpool_Handle is
-- Mark the current allocation location.
begin
if Pool.Current_Pool = Subpool_Indexes'Last then
raise Storage_Error; -- No more subpools.
end if;
Pool.Current_Pool := Pool.Current_Pool + 1; -- Move to the next subpool
return Result : constant not null Subpool_Handle :=
Pool.Markers(Pool.Current_Pool)'Unchecked_Access
do
MR_Subpool (Result.all).Start := Pool.Next_Allocation;
Subpools.Set_Pool_of_Subpool (Result, Pool);
end return;
end Create_Subpool;
procedure Deallocate_Subpool (
Pool : in out Mark_Release_Pool_Type;
Subpool : in out Subpool_Handle) is
begin
if Subpool /= Pool.Markers(Pool.Current_Pool)'Unchecked_Access then
raise Program_Error; -- Only the last marked subpool can be released.
end if;
if Pool.Current_Pool /= 1 then
Pool.Next_Allocation := Pool.Markers(Pool.Current_Pool).Start;
Pool.Current_Pool := Pool.Current_Pool - 1; -- Move to the previous subpool
else -- Reinitialize the default subpool:
Pool.Next_Allocation := 1;
Subpools.Set_Pool_of_Subpool
(Pool.Markers(1)'Unchecked_Access, Pool);
end if;
end Deallocate_Subpool;
function Default_Subpool_for_Pool (Pool : in out Mark_Release_Pool_Type)
return not null Subpool_Handle is
begin
return Pool.Markers(Pool.Current_Pool)
'Unrestricted_Access; -- 'Unchecked_Access; / different gcc from Standard
end Default_Subpool_for_Pool;
procedure Allocate_From_Subpool (
Pool : in out Mark_Release_Pool_Type;
Storage_Address : out System.Address;
Size_In_Storage_Elements : in Storage_Count;
Alignment : in Storage_Count;
Subpool : not null Subpool_Handle) is
begin
if Subpool /= Pool.Markers(Pool.Current_Pool)'Unchecked_Access then
raise Program_Error; -- Only the last marked subpool can be used for allocations.
end if;
-- Correct the alignment if necessary:
Pool.Next_Allocation := Pool.Next_Allocation
+ ((-Pool.Next_Allocation) mod Alignment);
if Pool.Next_Allocation + Size_In_Storage_Elements >
Pool.Pool_Size then
raise Storage_Error; -- Out of space.
end if;
Storage_Address := Pool.Storage (Pool.Next_Allocation)'Address;
Pool.Next_Allocation :=
Pool.Next_Allocation + Size_In_Storage_Elements;
end Allocate_From_Subpool;
end MR_Pool;
use type System.Storage_Elements.Storage_Offset;
Pool : MR_Pool.Mark_Release_Pool_Type (Pool_Size => 1024 - 1);
package Dummy is
type Dummy is new Ada.Finalization.Controlled with null record;
overriding procedure Initialize (Object : in out Dummy);
overriding procedure Adjust (Object : in out Dummy);
overriding procedure Finalize (Object : in out Dummy);
end Dummy;
package body Dummy is
package SSEF renames System.Storage_Elements.Formatting;
overriding procedure Initialize (Object : in out Dummy) is
begin
Ada.Debug.Put ("at " & SSEF.Image (Object'Address));
end Initialize;
overriding procedure Adjust (Object : in out Dummy) is
begin
Ada.Debug.Put ("at " & SSEF.Image (Object'Address));
end Adjust;
overriding procedure Finalize (Object : in out Dummy) is
begin
Ada.Debug.Put ("at " & SSEF.Image (Object'Address));
end Finalize;
end Dummy;
type A is access Dummy.Dummy;
for A'Storage_Pool use Pool;
X : array (1 .. 3) of A;
Mark : MR_Pool.Subpool_Handle;
begin
Mark := MR_Pool.Mark (Pool);
for I in X'Range loop
X (I) := new Dummy.Dummy;
end loop;
MR_Pool.Release (Mark);
pragma Debug (Ada.Debug.Put ("OK"));
end subpool;
|
src/demo/vertical_toy.asm | hallorant/bitmit | 6 | 29904 | ; Toy program that draws some vertical lines on the screen
org $4a00
import '../lib/barden_fill.asm'
space equ $20
screen equ $3c00
char_ct equ 64*16
vlinel equ $95
vliner equ $aa
; Draw a vertical line at IX which should be along the
; top line of the screen.
vline:
ld a,16
draw:
ld (ix),vlinel
ld bc,64
add ix,bc
dec a
jr nz,draw
ret
main:
; Clear the screen.
ld d,space
ld hl,screen
ld bc,char_ct
call barden_fill
; Draw a vertical line on some columns on the screen
ld ix,screen
call vline
ld ix,screen+5
call vline
ld ix,screen+10
call vline
ld ix,screen+23
call vline
ld ix,screen+33
call vline
ld ix,screen+50
call vline
ld ix,screen+63
call vline
hcf:
jr hcf
end main
|
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/ca/ca1014a0.ada | best08618/asylo | 7 | 19797 | <filename>gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/ca/ca1014a0.ada
-- CA1014A0M.ADA
-- Grant of Unlimited Rights
--
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- released technical data and computer software in whole or in part, in
-- any manner and for any purpose whatsoever, and to have or permit others
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- CHECK THAT A SUBUNIT CAN BE SUBMITTED FOR COMPILATION
-- SEPARATELY FROM ITS PARENT UNIT.
-- SEPARATE FILES ARE:
-- CA1014A0M THE MAIN PROCEDURE.
-- CA1014A1 A SUBUNIT PROCEDURE BODY.
-- CA1014A2 A SUBUNIT PACKAGE BODY.
-- CA1014A3 A SUBUNIT FUNCTION BODY.
-- JRK 5/20/81
WITH REPORT;
USE REPORT;
PROCEDURE CA1014A0M IS
I : INTEGER := 0;
PACKAGE CALL_TEST IS
END CALL_TEST;
PACKAGE BODY CALL_TEST IS
BEGIN
TEST ("CA1014A", "SUBUNITS SUBMITTED FOR COMPILATION " &
"SEPARATELY FROM PARENT UNIT");
END CALL_TEST;
PROCEDURE CA1014A1 (I : IN OUT INTEGER) IS SEPARATE;
PACKAGE CA1014A2 IS
I : INTEGER := 10;
PROCEDURE P (I : IN OUT INTEGER);
END CA1014A2;
PACKAGE BODY CA1014A2 IS SEPARATE;
FUNCTION CA1014A3 (I : INTEGER) RETURN INTEGER IS SEPARATE;
BEGIN
CA1014A1 (I);
IF I /= 1 THEN
FAILED ("SUBUNIT PROCEDURE NOT ELABORATED/EXECUTED");
END IF;
IF CA1014A2.I /= 15 THEN
FAILED ("SUBUNIT PACKAGE BODY NOT ELABORATED/EXECUTED");
END IF;
I := 0;
CA1014A2.P (I);
IF I /= -20 THEN
FAILED ("SUBUNIT PACKAGED PROCEDURE NOT ELABORATED/EXECUTED");
END IF;
IF CA1014A3(50) /= -50 THEN
FAILED ("SUBUNIT FUNCTION NOT ELABORATED/EXECUTED");
END IF;
RESULT;
END CA1014A0M;
|
Scratch/print_string_pm.asm | SwordYork/slef | 8 | 25954 | [bits 32]
VIDEO_MEMORY equ 0xa0000
WHITE_ON_BLACK equ 0x0f
print_string_pm:
pusha
mov edx,VIDEO_MEMORY
print_string_pm_loop:
mov al,[ebx]
mov ah, WHITE_ON_BLACK
cmp al,0
je print_string_pm_done
mov [edx],ax
add ebx, 1
add edx,2
jmp print_string_pm_loop
print_string_pm_done:
popa
ret
|
oeis/189/A189071.asm | neoneye/loda-programs | 11 | 8306 | ; A189071: The n-th derivative of x^10 evaluated at x=2.
; Submitted by <NAME>
; 1024,5120,23040,92160,322560,967680,2419200,4838400,7257600,7257600,3628800,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
mov $1,4
mov $2,11
lpb $0
sub $0,1
sub $2,1
mul $1,$2
div $1,2
lpe
mov $0,$1
mul $0,256
|
source/oasis/program-elements-real_range_specifications.ads | optikos/oasis | 0 | 666 | -- Copyright (c) 2019 <NAME> <<EMAIL>>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Elements.Definitions;
with Program.Lexical_Elements;
with Program.Elements.Expressions;
package Program.Elements.Real_Range_Specifications is
pragma Pure (Program.Elements.Real_Range_Specifications);
type Real_Range_Specification is
limited interface and Program.Elements.Definitions.Definition;
type Real_Range_Specification_Access is
access all Real_Range_Specification'Class with Storage_Size => 0;
not overriding function Lower_Bound
(Self : Real_Range_Specification)
return not null Program.Elements.Expressions.Expression_Access
is abstract;
not overriding function Upper_Bound
(Self : Real_Range_Specification)
return not null Program.Elements.Expressions.Expression_Access
is abstract;
type Real_Range_Specification_Text is limited interface;
type Real_Range_Specification_Text_Access is
access all Real_Range_Specification_Text'Class with Storage_Size => 0;
not overriding function To_Real_Range_Specification_Text
(Self : aliased in out Real_Range_Specification)
return Real_Range_Specification_Text_Access is abstract;
not overriding function Range_Token
(Self : Real_Range_Specification_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Double_Dot_Token
(Self : Real_Range_Specification_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
end Program.Elements.Real_Range_Specifications;
|
electrum/src/main/resources/models/examples/case_studies/ins.als | haslab/Electrum | 29 | 1351 | module examples/case_studies/ins
/*
* Models an Intentional Naming System (INS), a scheme for
* dynamic resource discovery in a dynamic environment.
*
* For a detailed description, see:
* http://sdg.lcs.mit.edu/pubs/2000/INS_ASE00.pdf
*
* author: <NAME>
*/
open util/relation as rel
sig Attribute {}
sig Value {}
sig Record {}
one sig Wildcard extends Value {}
sig AVTree {
values: set Value,
attributes: set Attribute,
root: values - Wildcard,
av: attributes one -> some (values - root),
va: (values - Wildcard) one -> attributes
}{
// values (and attributes) of tree are those reachable from root
values = root.*(va.av)
}
sig Query extends AVTree {} {all a:attributes | one a.av}
sig DB extends AVTree {
records : set Record,
recs: (values - root) some -> records,
lookup : Query -> (values -> records)
}{
Wildcard !in values
}
fact AddInvariants {
all db: DB {
all v: db.values | no v.(db.recs) & v.^(~(db.av).~(db.va)).(db.recs)
all a: db.attributes | all disj v1, v2: a.(db.av) |
(some rr: *((db.va).(db.av)).(db.recs) | no v1.rr & v2.rr)
}
}
pred Get [db: DB, r: Record, q: Query] {
q.values = r.~(db.recs).*(~(db.av).~(db.va))
q.attributes = q.values.~(db.av)
q.root = db.root
all a : attributes| a.~(q.va) = a.~(db.va)
all v : values | v.~(q.av) = v.~(db.av)
}
pred Conforms [db: DB, q: Query, r: Record] {
some p: Query {
db.Get[r, p]
q.va in p.va
(q.av - Attribute -> Wildcard) in p.av
}
}
pred indSubset[db : DB, q: Query, r: set Record, v: Value] {
all a : v.(q.va) |
(a.(q.av) in a.(db.av) => r in (a.(q.av)).(q.(db.lookup))) &&
(a.(q.av) = Wildcard => r in a.(db.av).*((db.va).(db.av)).(db.recs))
}
pred Lookup[db: DB, q: Query, found: set Record] {
all v: Value | not v.(q.va) in v.(db.va) => no v.(q.(db.lookup))
all v: Value | all a : v.(q.va) |
a.(q.av) != Wildcard && not a.(q.av) in a.(db.av) => no v.(q.(db.lookup))
all v: Value - Wildcard |
no v.(q.va) => v.(q.(db.lookup)) = v.*((db.va).(db.av)).(db.recs)
all v: Value |
some v.(q.va) => indSubset[db, q, v.(q.(db.lookup)), v] &&
(no r: Record - v.(q.(db.lookup)) | indSubset[db, q, v.(q.(db.lookup)) + r, v])
found = db.root.(q.(db.lookup))
}
assert CorrectLookup {
all db: DB | all q : Query | all r : Record |
Conforms [db,q,r] <=> db.Lookup[q, r]
}
pred Add [me: DB, adv: Query, r: Record, db: DB] {
// restricted version - only advertisements with fresh attributes and values added
no me.attributes & adv.attributes
me.values & adv.values = me.root
me.root = adv.root
Wildcard !in adv.values
r !in me.records
db.values = me.values + adv.values
db.attributes = me.attributes + adv.attributes
db.root = me.root
db.av = me.av + adv.av
db.va = me.va + adv.va
db.recs = me.recs + ((db.values - dom[db.va]) -> r)
}
pred RemoveWildCard[me: Query, q: Query] {
q.values = me.values - Wildcard
q.attributes = me.attributes - Wildcard.~(me.av)
q.root = me.root
q.av = me.av - Attribute -> Wildcard
q.va = me.va - Value -> Wildcard.~(me.av)
}
assert MissingAttributeAsWildcard {
all db : DB, q, q1 : Query, found: set Record |
db.Lookup[q, found] && q.RemoveWildCard[q1] => db.Lookup[q1, found]
}
|
programs/oeis/246/A246604.asm | neoneye/loda | 22 | 17558 | <filename>programs/oeis/246/A246604.asm<gh_stars>10-100
; A246604: a(n) = Catalan(n) - n.
; 1,0,0,2,10,37,126,422,1422,4853,16786,58775,208000,742887,2674426,9694830,35357654,129644773,477638682,1767263171,6564120400,24466266999,91482563618,343059613627,1289904147300,4861946401427,18367353072126,69533550915977,263747951750332,1002242216651339,3814986502092274,14544636039226878,55534064877048166,212336130412243077,812944042149730730,3116285494907301227,11959798385860453456,45950804324621742327,176733862787006701362,680425371729975800351,2622127042276492108780,10113918591637898133979,39044429911904443959198,150853479205085351660657,583300119592996693087996,2257117854077248073253675,8740328711533173390046274,33868773757191046886429443,131327898242169365477991852,509552245179617138054608523,1978261657756160653623774406,7684785670514316385230816105,29869166945772625950142417460,116157871455782434250553845827,451959718027953471447609509370,1759414616608818870992479875917,6852456927844873497549658464256,26700952856774851904245220912607,104088460289122304033498318812022,405944995127576985730643443367053,1583850964596120042686772779038836,6182127958584855650487080847216275,24139737743045626825711458546273250,94295850558771979787935384946380062,368479169875816659479009042713546886
mov $1,$0
mul $1,2
bin $1,$0
mov $2,$0
add $0,1
div $1,$0
sub $1,$2
mov $0,$1
|
sw/asm/bubble16.asm | brianbennett/fpga_nes | 190 | 85030 | ; bubble16.asm
;
; Bubble sort of an array of 16-bit integers. Code taken from:
;
; http://www.6502.org/source/sorting/bubble16.htm
;
.word $8000
.org $8000
ldx #$FF
txs
;THIS SUBROUTINE ARRANGES THE 16-BIT ELEMENTS OF A LIST IN
;ASCENDING ORDER. THE STARTING ADDRESS OF THE LIST IS IN LOCATIONS
;$30 AND $31. THE LENGTH OF THE LIST IS IN THE FIRST BYTE OF THE LIST.
;LOCATION $32 IS USED TO HOLD AN EXCHANGE FLAG.
SORT16: LDY #$00 ;TURN EXCHANGE FLAG OFF (= 0)
STY $32
LDA ($30),Y ;FETCH ELEMENT COUNT
TAY ; AND USE IT TO INDEX LAST ELEMENT
NXTEL: LDA ($30),Y ;FETCH MSBY
PHA ; AND PUSH IT ONTO STACK
DEY
LDA ($30),Y ;FETCH LSBY
SEC
DEY
DEY
SBC ($30),Y ; AND SUBTRACT LSBY OF PRECEDING ELEMENT
PLA
INY
SBC ($30),Y ; AND SUBTRACT MSBY OF PRECEDING ELEMENT
BCC SWAP ;ARE THESE ELEMENTS OUT OF ORDER?
CPY #$02 ;NO. LOOP UNTIL ALL ELEMENTS COMPARED
BNE NXTEL
BIT $32 ;EXCHANGE FLAG STILL OFF?
BMI SORT16 ;NO. GO THROUGH LIST AGAIN
.byte $02 ; HLT
;THIS ROUTINE BELOW EXCHANGES TWO 16-BIT ELEMENTS IN MEMORY
SWAP: LDA ($30),Y ;SAVE MSBY1 ON STACK
PHA
DEY
LDA ($30),Y ;SAVE LSBY1 ON STACK
PHA
INY
INY
INY
LDA ($30),Y ;SAVE MSBY2 ON STACK
PHA
DEY
LDA ($30),Y ;LOAD LSBY2 INTO ACCUMULATOR
DEY
DEY
STA ($30),Y ; AND STORE IT AT LSBY1 POSITION
LDX #$03
SLOOP: INY ;STORE THE OTHER THREE BYTES
PLA
STA ($30),Y
DEX
BNE SLOOP ;LOOP UNTIL THREE BYTE STORED
LDA #$FF ;TURN EXCHANGE FLAG ON (= -1)
STA $32
CPY #04 ;WAS EXCHANGE DONE AT START OF LIST?
BEQ SORT16 ;YES. GO THROUGH LIST AGAIN.
DEY ;NO. COMPARE NEXT ELEMENT PAIR
DEY
JMP NXTEL
|
Sources/Playcount.scpt | ckd/music-scripts | 0 | 1412 | <gh_stars>0
-- Playcount
-- Dumb script to set a track's played count.
tell application "Music"
set sel to selection of front browser window
if sel is {} then
display dialog "Nothing is selected." buttons {"Quit"} with icon 0
return
end if
set newPlaycount to text returned of (display dialog "New Playcount:" default answer "0")
repeat with i from 1 to (count of sel)
set thisTrack to item i of sel
set played count of thisTrack to newPlaycount
end repeat
end tell
|
SVD2ada/svd/stm32_svd-i2c.ads | JCGobbi/Nucleo-STM32H743ZI | 0 | 18558 | <reponame>JCGobbi/Nucleo-STM32H743ZI
pragma Style_Checks (Off);
-- This spec has been automatically generated from STM32H743x.svd
pragma Restrictions (No_Elaboration_Code);
with HAL;
with System;
package STM32_SVD.I2C is
pragma Preelaborate;
---------------
-- Registers --
---------------
subtype CR1_DNF_Field is HAL.UInt4;
-- Access: No wait states, except if a write access occurs while a write
-- access to this register is ongoing. In this case, wait states are
-- inserted in the second write access until the previous one is completed.
-- The latency of the second write access can be up to 2 x PCLK1 + 6 x
-- I2CCLK.
type CR1_Register is record
-- Peripheral enable Note: When PE=0, the I2C SCL and SDA lines are
-- released. Internal state machines and status bits are put back to
-- their reset value. When cleared, PE must be kept low for at least 3
-- APB clock cycles.
PE : Boolean := False;
-- TX Interrupt enable
TXIE : Boolean := False;
-- RX Interrupt enable
RXIE : Boolean := False;
-- Address match Interrupt enable (slave only)
ADDRIE : Boolean := False;
-- Not acknowledge received Interrupt enable
NACKIE : Boolean := False;
-- STOP detection Interrupt enable
STOPIE : Boolean := False;
-- Transfer Complete interrupt enable Note: Any of these events will
-- generate an interrupt: Transfer Complete (TC) Transfer Complete
-- Reload (TCR)
TCIE : Boolean := False;
-- Error interrupts enable Note: Any of these errors generate an
-- interrupt: Arbitration Loss (ARLO) Bus Error detection (BERR)
-- Overrun/Underrun (OVR) Timeout detection (TIMEOUT) PEC error
-- detection (PECERR) Alert pin event detection (ALERT)
ERRIE : Boolean := False;
-- Digital noise filter These bits are used to configure the digital
-- noise filter on SDA and SCL input. The digital filter will filter
-- spikes with a length of up to DNF[3:0] * tI2CCLK ... Note: If the
-- analog filter is also enabled, the digital filter is added to the
-- analog filter. This filter can only be programmed when the I2C is
-- disabled (PE = 0).
DNF : CR1_DNF_Field := 16#0#;
-- Analog noise filter OFF Note: This bit can only be programmed when
-- the I2C is disabled (PE = 0).
ANFOFF : Boolean := False;
-- unspecified
Reserved_13_13 : HAL.Bit := 16#0#;
-- DMA transmission requests enable
TXDMAEN : Boolean := False;
-- DMA reception requests enable
RXDMAEN : Boolean := False;
-- Slave byte control This bit is used to enable hardware byte control
-- in slave mode.
SBC : Boolean := False;
-- Clock stretching disable This bit is used to disable clock stretching
-- in slave mode. It must be kept cleared in master mode. Note: This bit
-- can only be programmed when the I2C is disabled (PE = 0).
NOSTRETCH : Boolean := False;
-- Wakeup from Stop mode enable Note: If the Wakeup from Stop mode
-- feature is not supported, this bit is reserved and forced by hardware
-- to 0. Please refer to Section25.3: I2C implementation. Note: WUPEN
-- can be set only when DNF = 0000
WUPEN : Boolean := False;
-- General call enable
GCEN : Boolean := False;
-- SMBus Host address enable Note: If the SMBus feature is not
-- supported, this bit is reserved and forced by hardware to 0. Please
-- refer to Section25.3: I2C implementation.
SMBHEN : Boolean := False;
-- SMBus Device Default address enable Note: If the SMBus feature is not
-- supported, this bit is reserved and forced by hardware to 0. Please
-- refer to Section25.3: I2C implementation.
SMBDEN : Boolean := False;
-- SMBus alert enable Device mode (SMBHEN=0): Host mode (SMBHEN=1):
-- Note: When ALERTEN=0, the SMBA pin can be used as a standard GPIO. If
-- the SMBus feature is not supported, this bit is reserved and forced
-- by hardware to 0. Please refer to Section25.3: I2C implementation.
ALERTEN : Boolean := False;
-- PEC enable Note: If the SMBus feature is not supported, this bit is
-- reserved and forced by hardware to 0. Please refer to Section25.3:
-- I2C implementation.
PECEN : Boolean := False;
-- unspecified
Reserved_24_31 : HAL.UInt8 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CR1_Register use record
PE at 0 range 0 .. 0;
TXIE at 0 range 1 .. 1;
RXIE at 0 range 2 .. 2;
ADDRIE at 0 range 3 .. 3;
NACKIE at 0 range 4 .. 4;
STOPIE at 0 range 5 .. 5;
TCIE at 0 range 6 .. 6;
ERRIE at 0 range 7 .. 7;
DNF at 0 range 8 .. 11;
ANFOFF at 0 range 12 .. 12;
Reserved_13_13 at 0 range 13 .. 13;
TXDMAEN at 0 range 14 .. 14;
RXDMAEN at 0 range 15 .. 15;
SBC at 0 range 16 .. 16;
NOSTRETCH at 0 range 17 .. 17;
WUPEN at 0 range 18 .. 18;
GCEN at 0 range 19 .. 19;
SMBHEN at 0 range 20 .. 20;
SMBDEN at 0 range 21 .. 21;
ALERTEN at 0 range 22 .. 22;
PECEN at 0 range 23 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
subtype CR2_SADD_Field is HAL.UInt10;
subtype CR2_NBYTES_Field is HAL.UInt8;
-- Access: No wait states, except if a write access occurs while a write
-- access to this register is ongoing. In this case, wait states are
-- inserted in the second write access until the previous one is completed.
-- The latency of the second write access can be up to 2 x PCLK1 + 6 x
-- I2CCLK.
type CR2_Register is record
-- Slave address bit 7:1 (master mode) In 7-bit addressing mode (ADD10 =
-- 0): These bits should be written with the 7-bit slave address to be
-- sent In 10-bit addressing mode (ADD10 = 1): These bits should be
-- written with bits 10:1 of the slave address to be sent. Note:
-- Changing these bits when the START bit is set is not allowed.
SADD : CR2_SADD_Field := 16#0#;
-- Transfer direction (master mode) Note: Changing this bit when the
-- START bit is set is not allowed.
RD_WRN : Boolean := False;
-- 10-bit addressing mode (master mode) Note: Changing this bit when the
-- START bit is set is not allowed.
ADD10 : Boolean := False;
-- 10-bit address header only read direction (master receiver mode)
-- Note: Changing this bit when the START bit is set is not allowed.
HEAD10R : Boolean := False;
-- Start generation This bit is set by software, and cleared by hardware
-- after the Start followed by the address sequence is sent, by an
-- arbitration loss, by a timeout error detection, or when PE = 0. It
-- can also be cleared by software by writing 1 to the ADDRCF bit in the
-- I2C_ICR register. If the I2C is already in master mode with AUTOEND =
-- 0, setting this bit generates a Repeated Start condition when
-- RELOAD=0, after the end of the NBYTES transfer. Otherwise setting
-- this bit will generate a START condition once the bus is free. Note:
-- Writing 0 to this bit has no effect. The START bit can be set even if
-- the bus is BUSY or I2C is in slave mode. This bit has no effect when
-- RELOAD is set.
START : Boolean := False;
-- Stop generation (master mode) The bit is set by software, cleared by
-- hardware when a Stop condition is detected, or when PE = 0. In Master
-- Mode: Note: Writing 0 to this bit has no effect.
STOP : Boolean := False;
-- NACK generation (slave mode) The bit is set by software, cleared by
-- hardware when the NACK is sent, or when a STOP condition or an
-- Address matched is received, or when PE=0. Note: Writing 0 to this
-- bit has no effect. This bit is used in slave mode only: in master
-- receiver mode, NACK is automatically generated after last byte
-- preceding STOP or RESTART condition, whatever the NACK bit value.
-- When an overrun occurs in slave receiver NOSTRETCH mode, a NACK is
-- automatically generated whatever the NACK bit value. When hardware
-- PEC checking is enabled (PECBYTE=1), the PEC acknowledge value does
-- not depend on the NACK value.
NACK : Boolean := False;
-- Number of bytes The number of bytes to be transmitted/received is
-- programmed there. This field is dont care in slave mode with SBC=0.
-- Note: Changing these bits when the START bit is set is not allowed.
NBYTES : CR2_NBYTES_Field := 16#0#;
-- NBYTES reload mode This bit is set and cleared by software.
RELOAD : Boolean := False;
-- Automatic end mode (master mode) This bit is set and cleared by
-- software. Note: This bit has no effect in slave mode or when the
-- RELOAD bit is set.
AUTOEND : Boolean := False;
-- Packet error checking byte This bit is set by software, and cleared
-- by hardware when the PEC is transferred, or when a STOP condition or
-- an Address matched is received, also when PE=0. Note: Writing 0 to
-- this bit has no effect. This bit has no effect when RELOAD is set.
-- This bit has no effect is slave mode when SBC=0. If the SMBus feature
-- is not supported, this bit is reserved and forced by hardware to 0.
-- Please refer to Section25.3: I2C implementation.
PECBYTE : Boolean := False;
-- unspecified
Reserved_27_31 : HAL.UInt5 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CR2_Register use record
SADD at 0 range 0 .. 9;
RD_WRN at 0 range 10 .. 10;
ADD10 at 0 range 11 .. 11;
HEAD10R at 0 range 12 .. 12;
START at 0 range 13 .. 13;
STOP at 0 range 14 .. 14;
NACK at 0 range 15 .. 15;
NBYTES at 0 range 16 .. 23;
RELOAD at 0 range 24 .. 24;
AUTOEND at 0 range 25 .. 25;
PECBYTE at 0 range 26 .. 26;
Reserved_27_31 at 0 range 27 .. 31;
end record;
subtype OAR1_OA1_Field is HAL.UInt10;
-- Access: No wait states, except if a write access occurs while a write
-- access to this register is ongoing. In this case, wait states are
-- inserted in the second write access until the previous one is completed.
-- The latency of the second write access can be up to 2 x PCLK1 + 6 x
-- I2CCLK.
type OAR1_Register is record
-- Interface address 7-bit addressing mode: dont care 10-bit addressing
-- mode: bits 9:8 of address Note: These bits can be written only when
-- OA1EN=0. OA1[7:1]: Interface address Bits 7:1 of address Note: These
-- bits can be written only when OA1EN=0. OA1[0]: Interface address
-- 7-bit addressing mode: dont care 10-bit addressing mode: bit 0 of
-- address Note: This bit can be written only when OA1EN=0.
OA1 : OAR1_OA1_Field := 16#0#;
-- Own Address 1 10-bit mode Note: This bit can be written only when
-- OA1EN=0.
OA1MODE : Boolean := False;
-- unspecified
Reserved_11_14 : HAL.UInt4 := 16#0#;
-- Own Address 1 enable
OA1EN : Boolean := False;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for OAR1_Register use record
OA1 at 0 range 0 .. 9;
OA1MODE at 0 range 10 .. 10;
Reserved_11_14 at 0 range 11 .. 14;
OA1EN at 0 range 15 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype OAR2_OA2_Field is HAL.UInt7;
subtype OAR2_OA2MSK_Field is HAL.UInt3;
-- Access: No wait states, except if a write access occurs while a write
-- access to this register is ongoing. In this case, wait states are
-- inserted in the second write access until the previous one is completed.
-- The latency of the second write access can be up to 2 x PCLK1 + 6 x
-- I2CCLK.
type OAR2_Register is record
-- unspecified
Reserved_0_0 : HAL.Bit := 16#0#;
-- Interface address bits 7:1 of address Note: These bits can be written
-- only when OA2EN=0.
OA2 : OAR2_OA2_Field := 16#0#;
-- Own Address 2 masks Note: These bits can be written only when
-- OA2EN=0. As soon as OA2MSK is not equal to 0, the reserved I2C
-- addresses (0b0000xxx and 0b1111xxx) are not acknowledged even if the
-- comparison matches.
OA2MSK : OAR2_OA2MSK_Field := 16#0#;
-- unspecified
Reserved_11_14 : HAL.UInt4 := 16#0#;
-- Own Address 2 enable
OA2EN : Boolean := False;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for OAR2_Register use record
Reserved_0_0 at 0 range 0 .. 0;
OA2 at 0 range 1 .. 7;
OA2MSK at 0 range 8 .. 10;
Reserved_11_14 at 0 range 11 .. 14;
OA2EN at 0 range 15 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype TIMINGR_SCLL_Field is HAL.UInt8;
subtype TIMINGR_SCLH_Field is HAL.UInt8;
subtype TIMINGR_SDADEL_Field is HAL.UInt4;
subtype TIMINGR_SCLDEL_Field is HAL.UInt4;
subtype TIMINGR_PRESC_Field is HAL.UInt4;
-- Access: No wait states
type TIMINGR_Register is record
-- SCL low period (master mode) This field is used to generate the SCL
-- low period in master mode. tSCLL = (SCLL+1) x tPRESC Note: SCLL is
-- also used to generate tBUF and tSU:STA timings.
SCLL : TIMINGR_SCLL_Field := 16#0#;
-- SCL high period (master mode) This field is used to generate the SCL
-- high period in master mode. tSCLH = (SCLH+1) x tPRESC Note: SCLH is
-- also used to generate tSU:STO and tHD:STA timing.
SCLH : TIMINGR_SCLH_Field := 16#0#;
-- Data hold time This field is used to generate the delay tSDADEL
-- between SCL falling edge and SDA edge. In master mode and in slave
-- mode with NOSTRETCH = 0, the SCL line is stretched low during
-- tSDADEL. tSDADEL= SDADEL x tPRESC Note: SDADEL is used to generate
-- tHD:DAT timing.
SDADEL : TIMINGR_SDADEL_Field := 16#0#;
-- Data setup time This field is used to generate a delay tSCLDEL
-- between SDA edge and SCL rising edge. In master mode and in slave
-- mode with NOSTRETCH = 0, the SCL line is stretched low during
-- tSCLDEL. tSCLDEL = (SCLDEL+1) x tPRESC Note: tSCLDEL is used to
-- generate tSU:DAT timing.
SCLDEL : TIMINGR_SCLDEL_Field := 16#0#;
-- unspecified
Reserved_24_27 : HAL.UInt4 := 16#0#;
-- Timing prescaler This field is used to prescale I2CCLK in order to
-- generate the clock period tPRESC used for data setup and hold
-- counters (refer to I2C timings on page9) and for SCL high and low
-- level counters (refer to I2C master initialization on page24). tPRESC
-- = (PRESC+1) x tI2CCLK
PRESC : TIMINGR_PRESC_Field := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for TIMINGR_Register use record
SCLL at 0 range 0 .. 7;
SCLH at 0 range 8 .. 15;
SDADEL at 0 range 16 .. 19;
SCLDEL at 0 range 20 .. 23;
Reserved_24_27 at 0 range 24 .. 27;
PRESC at 0 range 28 .. 31;
end record;
subtype TIMEOUTR_TIMEOUTA_Field is HAL.UInt12;
subtype TIMEOUTR_TIMEOUTB_Field is HAL.UInt12;
-- Access: No wait states, except if a write access occurs while a write
-- access to this register is ongoing. In this case, wait states are
-- inserted in the second write access until the previous one is completed.
-- The latency of the second write access can be up to 2 x PCLK1 + 6 x
-- I2CCLK.
type TIMEOUTR_Register is record
-- Bus Timeout A This field is used to configure: The SCL low timeout
-- condition tTIMEOUT when TIDLE=0 tTIMEOUT= (TIMEOUTA+1) x 2048 x
-- tI2CCLK The bus idle condition (both SCL and SDA high) when TIDLE=1
-- tIDLE= (TIMEOUTA+1) x 4 x tI2CCLK Note: These bits can be written
-- only when TIMOUTEN=0.
TIMEOUTA : TIMEOUTR_TIMEOUTA_Field := 16#0#;
-- Idle clock timeout detection Note: This bit can be written only when
-- TIMOUTEN=0.
TIDLE : Boolean := False;
-- unspecified
Reserved_13_14 : HAL.UInt2 := 16#0#;
-- Clock timeout enable
TIMOUTEN : Boolean := False;
-- Bus timeout B This field is used to configure the cumulative clock
-- extension timeout: In master mode, the master cumulative clock low
-- extend time (tLOW:MEXT) is detected In slave mode, the slave
-- cumulative clock low extend time (tLOW:SEXT) is detected tLOW:EXT=
-- (TIMEOUTB+1) x 2048 x tI2CCLK Note: These bits can be written only
-- when TEXTEN=0.
TIMEOUTB : TIMEOUTR_TIMEOUTB_Field := 16#0#;
-- unspecified
Reserved_28_30 : HAL.UInt3 := 16#0#;
-- Extended clock timeout enable
TEXTEN : Boolean := False;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for TIMEOUTR_Register use record
TIMEOUTA at 0 range 0 .. 11;
TIDLE at 0 range 12 .. 12;
Reserved_13_14 at 0 range 13 .. 14;
TIMOUTEN at 0 range 15 .. 15;
TIMEOUTB at 0 range 16 .. 27;
Reserved_28_30 at 0 range 28 .. 30;
TEXTEN at 0 range 31 .. 31;
end record;
subtype ISR_ADDCODE_Field is HAL.UInt7;
-- Access: No wait states
type ISR_Register is record
-- Transmit data register empty (transmitters) This bit is set by
-- hardware when the I2C_TXDR register is empty. It is cleared when the
-- next data to be sent is written in the I2C_TXDR register. This bit
-- can be written to 1 by software in order to flush the transmit data
-- register I2C_TXDR. Note: This bit is set by hardware when PE=0.
TXE : Boolean := True;
-- Transmit interrupt status (transmitters) This bit is set by hardware
-- when the I2C_TXDR register is empty and the data to be transmitted
-- must be written in the I2C_TXDR register. It is cleared when the next
-- data to be sent is written in the I2C_TXDR register. This bit can be
-- written to 1 by software when NOSTRETCH=1 only, in order to generate
-- a TXIS event (interrupt if TXIE=1 or DMA request if TXDMAEN=1). Note:
-- This bit is cleared by hardware when PE=0.
TXIS : Boolean := False;
-- Read-only. Receive data register not empty (receivers) This bit is
-- set by hardware when the received data is copied into the I2C_RXDR
-- register, and is ready to be read. It is cleared when I2C_RXDR is
-- read. Note: This bit is cleared by hardware when PE=0.
RXNE : Boolean := False;
-- Read-only. Address matched (slave mode) This bit is set by hardware
-- as soon as the received slave address matched with one of the enabled
-- slave addresses. It is cleared by software by setting ADDRCF bit.
-- Note: This bit is cleared by hardware when PE=0.
ADDR : Boolean := False;
-- Read-only. Not Acknowledge received flag This flag is set by hardware
-- when a NACK is received after a byte transmission. It is cleared by
-- software by setting the NACKCF bit. Note: This bit is cleared by
-- hardware when PE=0.
NACKF : Boolean := False;
-- Read-only. Stop detection flag This flag is set by hardware when a
-- Stop condition is detected on the bus and the peripheral is involved
-- in this transfer: either as a master, provided that the STOP
-- condition is generated by the peripheral. or as a slave, provided
-- that the peripheral has been addressed previously during this
-- transfer. It is cleared by software by setting the STOPCF bit. Note:
-- This bit is cleared by hardware when PE=0.
STOPF : Boolean := False;
-- Read-only. Transfer Complete (master mode) This flag is set by
-- hardware when RELOAD=0, AUTOEND=0 and NBYTES data have been
-- transferred. It is cleared by software when START bit or STOP bit is
-- set. Note: This bit is cleared by hardware when PE=0.
TC : Boolean := False;
-- Read-only. Transfer Complete Reload This flag is set by hardware when
-- RELOAD=1 and NBYTES data have been transferred. It is cleared by
-- software when NBYTES is written to a non-zero value. Note: This bit
-- is cleared by hardware when PE=0. This flag is only for master mode,
-- or for slave mode when the SBC bit is set.
TCR : Boolean := False;
-- Read-only. Bus error This flag is set by hardware when a misplaced
-- Start or Stop condition is detected whereas the peripheral is
-- involved in the transfer. The flag is not set during the address
-- phase in slave mode. It is cleared by software by setting BERRCF bit.
-- Note: This bit is cleared by hardware when PE=0.
BERR : Boolean := False;
-- Read-only. Arbitration lost This flag is set by hardware in case of
-- arbitration loss. It is cleared by software by setting the ARLOCF
-- bit. Note: This bit is cleared by hardware when PE=0.
ARLO : Boolean := False;
-- Read-only. Overrun/Underrun (slave mode) This flag is set by hardware
-- in slave mode with NOSTRETCH=1, when an overrun/underrun error
-- occurs. It is cleared by software by setting the OVRCF bit. Note:
-- This bit is cleared by hardware when PE=0.
OVR : Boolean := False;
-- Read-only. PEC Error in reception This flag is set by hardware when
-- the received PEC does not match with the PEC register content. A NACK
-- is automatically sent after the wrong PEC reception. It is cleared by
-- software by setting the PECCF bit. Note: This bit is cleared by
-- hardware when PE=0. If the SMBus feature is not supported, this bit
-- is reserved and forced by hardware to 0. Please refer to Section25.3:
-- I2C implementation.
PECERR : Boolean := False;
-- Read-only. Timeout or tLOW detection flag This flag is set by
-- hardware when a timeout or extended clock timeout occurred. It is
-- cleared by software by setting the TIMEOUTCF bit. Note: This bit is
-- cleared by hardware when PE=0. If the SMBus feature is not supported,
-- this bit is reserved and forced by hardware to 0. Please refer to
-- Section25.3: I2C implementation.
TIMEOUT : Boolean := False;
-- Read-only. SMBus alert This flag is set by hardware when SMBHEN=1
-- (SMBus host configuration), ALERTEN=1 and a SMBALERT event (falling
-- edge) is detected on SMBA pin. It is cleared by software by setting
-- the ALERTCF bit. Note: This bit is cleared by hardware when PE=0. If
-- the SMBus feature is not supported, this bit is reserved and forced
-- by hardware to 0. Please refer to Section25.3: I2C implementation.
ALERT : Boolean := False;
-- unspecified
Reserved_14_14 : HAL.Bit := 16#0#;
-- Read-only. Bus busy This flag indicates that a communication is in
-- progress on the bus. It is set by hardware when a START condition is
-- detected. It is cleared by hardware when a Stop condition is
-- detected, or when PE=0.
BUSY : Boolean := False;
-- Read-only. Transfer direction (Slave mode) This flag is updated when
-- an address match event occurs (ADDR=1).
DIR : Boolean := False;
-- Read-only. Address match code (Slave mode) These bits are updated
-- with the received address when an address match event occurs (ADDR =
-- 1). In the case of a 10-bit address, ADDCODE provides the 10-bit
-- header followed by the 2 MSBs of the address.
ADDCODE : ISR_ADDCODE_Field := 16#0#;
-- unspecified
Reserved_24_31 : HAL.UInt8 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for ISR_Register use record
TXE at 0 range 0 .. 0;
TXIS at 0 range 1 .. 1;
RXNE at 0 range 2 .. 2;
ADDR at 0 range 3 .. 3;
NACKF at 0 range 4 .. 4;
STOPF at 0 range 5 .. 5;
TC at 0 range 6 .. 6;
TCR at 0 range 7 .. 7;
BERR at 0 range 8 .. 8;
ARLO at 0 range 9 .. 9;
OVR at 0 range 10 .. 10;
PECERR at 0 range 11 .. 11;
TIMEOUT at 0 range 12 .. 12;
ALERT at 0 range 13 .. 13;
Reserved_14_14 at 0 range 14 .. 14;
BUSY at 0 range 15 .. 15;
DIR at 0 range 16 .. 16;
ADDCODE at 0 range 17 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
-- Access: No wait states
type ICR_Register is record
-- unspecified
Reserved_0_2 : HAL.UInt3 := 16#0#;
-- Write-only. Address matched flag clear Writing 1 to this bit clears
-- the ADDR flag in the I2C_ISR register. Writing 1 to this bit also
-- clears the START bit in the I2C_CR2 register.
ADDRCF : Boolean := False;
-- Write-only. Not Acknowledge flag clear Writing 1 to this bit clears
-- the ACKF flag in I2C_ISR register.
NACKCF : Boolean := False;
-- Write-only. Stop detection flag clear Writing 1 to this bit clears
-- the STOPF flag in the I2C_ISR register.
STOPCF : Boolean := False;
-- unspecified
Reserved_6_7 : HAL.UInt2 := 16#0#;
-- Write-only. Bus error flag clear Writing 1 to this bit clears the
-- BERRF flag in the I2C_ISR register.
BERRCF : Boolean := False;
-- Write-only. Arbitration Lost flag clear Writing 1 to this bit clears
-- the ARLO flag in the I2C_ISR register.
ARLOCF : Boolean := False;
-- Write-only. Overrun/Underrun flag clear Writing 1 to this bit clears
-- the OVR flag in the I2C_ISR register.
OVRCF : Boolean := False;
-- Write-only. PEC Error flag clear Writing 1 to this bit clears the
-- PECERR flag in the I2C_ISR register. Note: If the SMBus feature is
-- not supported, this bit is reserved and forced by hardware to 0.
-- Please refer to Section25.3: I2C implementation.
PECCF : Boolean := False;
-- Write-only. Timeout detection flag clear Writing 1 to this bit clears
-- the TIMEOUT flag in the I2C_ISR register. Note: If the SMBus feature
-- is not supported, this bit is reserved and forced by hardware to 0.
-- Please refer to Section25.3: I2C implementation.
TIMOUTCF : Boolean := False;
-- Write-only. Alert flag clear Writing 1 to this bit clears the ALERT
-- flag in the I2C_ISR register. Note: If the SMBus feature is not
-- supported, this bit is reserved and forced by hardware to 0. Please
-- refer to Section25.3: I2C implementation.
ALERTCF : Boolean := False;
-- unspecified
Reserved_14_31 : HAL.UInt18 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for ICR_Register use record
Reserved_0_2 at 0 range 0 .. 2;
ADDRCF at 0 range 3 .. 3;
NACKCF at 0 range 4 .. 4;
STOPCF at 0 range 5 .. 5;
Reserved_6_7 at 0 range 6 .. 7;
BERRCF at 0 range 8 .. 8;
ARLOCF at 0 range 9 .. 9;
OVRCF at 0 range 10 .. 10;
PECCF at 0 range 11 .. 11;
TIMOUTCF at 0 range 12 .. 12;
ALERTCF at 0 range 13 .. 13;
Reserved_14_31 at 0 range 14 .. 31;
end record;
subtype PECR_PEC_Field is HAL.UInt8;
-- Access: No wait states
type PECR_Register is record
-- Read-only. Packet error checking register This field contains the
-- internal PEC when PECEN=1. The PEC is cleared by hardware when PE=0.
PEC : PECR_PEC_Field;
-- unspecified
Reserved_8_31 : HAL.UInt24;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for PECR_Register use record
PEC at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype RXDR_RXDATA_Field is HAL.UInt8;
-- Access: No wait states
type RXDR_Register is record
-- Read-only. 8-bit receive data Data byte received from the I2C bus.
RXDATA : RXDR_RXDATA_Field;
-- unspecified
Reserved_8_31 : HAL.UInt24;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for RXDR_Register use record
RXDATA at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype TXDR_TXDATA_Field is HAL.UInt8;
-- Access: No wait states
type TXDR_Register is record
-- 8-bit transmit data Data byte to be transmitted to the I2C bus. Note:
-- These bits can be written only when TXE=1.
TXDATA : TXDR_TXDATA_Field := 16#0#;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for TXDR_Register use record
TXDATA at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- I2C
type I2C_Peripheral is record
-- Access: No wait states, except if a write access occurs while a write
-- access to this register is ongoing. In this case, wait states are
-- inserted in the second write access until the previous one is
-- completed. The latency of the second write access can be up to 2 x
-- PCLK1 + 6 x I2CCLK.
CR1 : aliased CR1_Register;
-- Access: No wait states, except if a write access occurs while a write
-- access to this register is ongoing. In this case, wait states are
-- inserted in the second write access until the previous one is
-- completed. The latency of the second write access can be up to 2 x
-- PCLK1 + 6 x I2CCLK.
CR2 : aliased CR2_Register;
-- Access: No wait states, except if a write access occurs while a write
-- access to this register is ongoing. In this case, wait states are
-- inserted in the second write access until the previous one is
-- completed. The latency of the second write access can be up to 2 x
-- PCLK1 + 6 x I2CCLK.
OAR1 : aliased OAR1_Register;
-- Access: No wait states, except if a write access occurs while a write
-- access to this register is ongoing. In this case, wait states are
-- inserted in the second write access until the previous one is
-- completed. The latency of the second write access can be up to 2 x
-- PCLK1 + 6 x I2CCLK.
OAR2 : aliased OAR2_Register;
-- Access: No wait states
TIMINGR : aliased TIMINGR_Register;
-- Access: No wait states, except if a write access occurs while a write
-- access to this register is ongoing. In this case, wait states are
-- inserted in the second write access until the previous one is
-- completed. The latency of the second write access can be up to 2 x
-- PCLK1 + 6 x I2CCLK.
TIMEOUTR : aliased TIMEOUTR_Register;
-- Access: No wait states
ISR : aliased ISR_Register;
-- Access: No wait states
ICR : aliased ICR_Register;
-- Access: No wait states
PECR : aliased PECR_Register;
-- Access: No wait states
RXDR : aliased RXDR_Register;
-- Access: No wait states
TXDR : aliased TXDR_Register;
end record
with Volatile;
for I2C_Peripheral use record
CR1 at 16#0# range 0 .. 31;
CR2 at 16#4# range 0 .. 31;
OAR1 at 16#8# range 0 .. 31;
OAR2 at 16#C# range 0 .. 31;
TIMINGR at 16#10# range 0 .. 31;
TIMEOUTR at 16#14# range 0 .. 31;
ISR at 16#18# range 0 .. 31;
ICR at 16#1C# range 0 .. 31;
PECR at 16#20# range 0 .. 31;
RXDR at 16#24# range 0 .. 31;
TXDR at 16#28# range 0 .. 31;
end record;
-- I2C
I2C1_Periph : aliased I2C_Peripheral
with Import, Address => I2C1_Base;
-- I2C
I2C2_Periph : aliased I2C_Peripheral
with Import, Address => I2C2_Base;
-- I2C
I2C3_Periph : aliased I2C_Peripheral
with Import, Address => I2C3_Base;
-- I2C
I2C4_Periph : aliased I2C_Peripheral
with Import, Address => I2C4_Base;
end STM32_SVD.I2C;
|
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/specs/elab2.ads | best08618/asylo | 7 | 11206 | -- { dg-do compile }
with Elab2_Pkg; use Elab2_Pkg;
package Elab2 is
type Num is (One, Two);
type Rec2 (D : Index_Type := 0) is record
Data : Rec1(D);
end record;
type Rec3 (D : Num) is record
case D is
when One => R : Rec2;
when others => null;
end case;
end record;
end Elab2;
|
agda/Number/Bundles2.agda | mchristianl/synthetic-reals | 3 | 16913 | {-# OPTIONS --cubical --no-import-sorts #-}
module Number.Bundles2 where
open import Agda.Primitive renaming (_⊔_ to ℓ-max; lsuc to ℓ-suc; lzero to ℓ-zero)
open import Cubical.Foundations.Everything renaming (_⁻¹ to _⁻¹ᵖ; assoc to ∙-assoc)
-- open import Cubical.Foundations.Logic
-- open import Cubical.Structures.Ring
-- open import Cubical.Structures.Group
-- open import Cubical.Structures.AbGroup
open import Cubical.Relation.Nullary.Base -- ¬_
open import Cubical.Relation.Binary.Base
open import Cubical.Data.Sum.Base renaming (_⊎_ to infixr 4 _⊎_)
open import Cubical.Data.Sigma.Base renaming (_×_ to infixr 4 _×_)
open import Cubical.Data.Empty renaming (elim to ⊥-elim; ⊥ to ⊥⊥) -- `⊥` and `elim`
open import Cubical.Foundations.Logic renaming (¬_ to ¬ᵖ_; inl to inlᵖ; inr to inrᵖ)
open import Function.Base using (it; _∋_)
open import Cubical.HITs.PropositionalTruncation --.Properties
open import Utils using (!_; !!_)
open import MoreLogic.Reasoning
open import MoreLogic.Definitions
open import MoreLogic.Properties
open import MorePropAlgebra.Definitions hiding (_≤''_)
open import MorePropAlgebra.Consequences
open import Number.Structures2
{-
| name | struct | apart | abs | order | cauchy | sqrt₀⁺ | exp | final name |
|------|---------------------|-------|-----|-------|--------|---------|-----|------------------------------------------------------------------------|
| ℕ | CommSemiring | (✓) | (✓) | lin. | | (on x²) | | LinearlyOrderedCommSemiring |
| ℤ | CommRing | (✓) | (✓) | lin. | | (on x²) | | LinearlyOrderedCommRing |
| ℚ | Field | (✓) | (✓) | lin. | | (on x²) | (✓) | LinearlyOrderedField |
| ℝ | Field | (✓) | (✓) | part. | ✓ | ✓ | (✓) | CompletePartiallyOrderedFieldWithSqrt |
| ℂ | euclidean 2-Product | (✓) | (✓) | | (✓) | | ? | EuclideanTwoProductOfCompletePartiallyOrderedFieldWithSqrt |
| R | Ring | ✓ | ✓ | | | | ? | ApartnessRingWithAbsIntoCompletePartiallyOrderedFieldWithSqrt |
| G | Group | ✓ | ✓ | | | | ? | ApartnessGroupWithAbsIntoCompletePartiallyOrderedFieldWithSqrt |
| K | Field | ✓ | ✓ | | ✓ | | ? | CompleteApartnessFieldWithAbsIntoCompletePartiallyOrderedFieldWithSqrt |
-}
record LinearlyOrderedCommSemiring {ℓ ℓ'} : Type (ℓ-suc (ℓ-max ℓ ℓ')) where
constructor linearlyorderedcommsemiring
field
Carrier : Type ℓ
0f 1f : Carrier
_+_ : Carrier → Carrier → Carrier
_·_ : Carrier → Carrier → Carrier
min max : Carrier → Carrier → Carrier
_<_ : hPropRel Carrier Carrier ℓ'
is-LinearlyOrderedCommSemiring : [ isLinearlyOrderedCommSemiring 0f 1f _+_ _·_ _<_ min max ] -- defines `_≤_` and `_#_`
infixl 7 _·_
infixl 5 _+_
infixl 4 _<_
open IsLinearlyOrderedCommSemiring is-LinearlyOrderedCommSemiring public
record LinearlyOrderedCommRing {ℓ ℓ'} : Type (ℓ-suc (ℓ-max ℓ ℓ')) where
constructor linearlyorderedcommring
field
Carrier : Type ℓ
0f 1f : Carrier
_+_ : Carrier → Carrier → Carrier
-_ : Carrier → Carrier
_·_ : Carrier → Carrier → Carrier
min max : Carrier → Carrier → Carrier
_<_ : hPropRel Carrier Carrier ℓ'
is-LinearlyOrderedCommRing : [ isLinearlyOrderedCommRing 0f 1f _+_ _·_ -_ _<_ min max ] -- defines `_≤_` and `_#_`
infixl 7 _·_
infix 6 -_
infixl 5 _+_
infixl 4 _<_
open IsLinearlyOrderedCommRing is-LinearlyOrderedCommRing public
record LinearlyOrderedField {ℓ ℓ'} : Type (ℓ-suc (ℓ-max ℓ ℓ')) where
constructor linearlyorderedfield
field
Carrier : Type ℓ
0f 1f : Carrier
_+_ : Carrier → Carrier → Carrier
-_ : Carrier → Carrier
_·_ : Carrier → Carrier → Carrier
min max : Carrier → Carrier → Carrier
_<_ : hPropRel Carrier Carrier ℓ'
is-LinearlyOrderedField : [ isLinearlyOrderedField 0f 1f _+_ _·_ -_ _<_ min max ] -- defines `_≤_` and `_#_`
infixl 7 _·_
infix 6 -_
infixl 5 _+_
infixl 4 _<_
open IsLinearlyOrderedField is-LinearlyOrderedField public
-- NOTE: this smells like "CPO" https://en.wikipedia.org/wiki/Complete_partial_order
record CompletePartiallyOrderedFieldWithSqrt {ℓ ℓ' : Level} : Type (ℓ-suc (ℓ-max ℓ ℓ')) where
field
Carrier : Type ℓ
is-set : isSet Carrier
0f : Carrier
1f : Carrier
_<_ : hPropRel Carrier Carrier ℓ'
min : Carrier → Carrier → Carrier
max : Carrier → Carrier → Carrier
_+_ : Carrier → Carrier → Carrier
_·_ : Carrier → Carrier → Carrier
-_ : Carrier → Carrier
<-irrefl : [ isIrrefl _<_ ]
<-trans : [ isTrans _<_ ]
<-cotrans : [ isCotrans _<_ ]
-- NOTE: these intermediate definitions are restricted and behave like let-definitions
-- e.g. they show up in goal contexts and they do not allow for `where` blocks
_-_ : Carrier → Carrier → Carrier
a - b = a + (- b)
<-asym : [ isAsym _<_ ]
<-asym = irrefl+trans⇒asym _<_ <-irrefl <-trans
_#_ : hPropRel Carrier Carrier ℓ'
x # y = [ <-asym x y ] (x < y) ⊎ᵖ (y < x)
field
#-tight : [ isTightˢ''' _#_ is-set ]
_≤_ : hPropRel Carrier Carrier ℓ'
x ≤ y = ¬ᵖ(y < x)
_>_ = flip _<_
_≥_ = flip _≤_
≤-refl : [ isRefl _≤_ ]
≤-refl = <-irrefl
≤-trans : [ isTrans _≤_ ]
≤-trans = <-cotrans⇒≤-trans _<_ <-cotrans
-- if x > y then x > y ≥ x, wich contradicts 4. Hence ¬(x > y). Similarly, ¬(y > x), so ¬(x ≠ y) and therefore by axiom R2(3), x = y.
-- NOTE: this makes use of #-tight to proof ≤-antisym
-- but we are alrady using ≤-antisym to proof #-tight
-- so I guess that we have to assume one of them?
-- Bridges lists tightness a property of _<_, so he seems to assume #-tight
-- Booij assumes `≤-isLattice : IsLattice _≤_ min max` which gives ≤-refl, ≤-antisym and ≤-trans and proofs #-tight from it
-- ≤-antisym : (∀ x y → [ ¬ᵖ (x # y) ] → x ≡ y) → [ isAntisymˢ is-set _≤_ ]
≤-antisym : [ isAntisymˢ _≤_ is-set ]
≤-antisym = fst (isTightˢ'''⇔isAntisymˢ _<_ is-set <-asym) #-tight
-- NOTE: we have `R3-8 = ∀[ x ] ∀[ y ] (¬(x ≤ y) ⇔ ¬ ¬(y < x))`
-- so I guess that we do not have `dne-over-< : ¬ ¬(y < x) ⇔ (y < x)`
-- and that would be my plan to prove `≤-cotrans` with `<-asym`
-- ≤-cotrans : [ isCotrans _≤_ ]
-- ≤-cotrans x y x≤y z = [ (x ≤ z) ⊔ (z ≤ y) ] ∋ {! (≤-antisym x y x≤y) !}
abs : Carrier → Carrier
abs x = max x (- x)
field
-- `R3.12` in [Bridges 1999]
-- bridges-R2-2 : ∀ x y → [ y < x ] → ∀ z → [ (z < x) ⊔ (y < z) ]
sqrt : (x : Carrier) → {{ ! [ 0f ≤ x ] }} → Carrier
0≤sqrt : ∀ x → {{ p : ! [ 0f ≤ x ] }} → [ 0f ≤ sqrt x {{p}} ]
0≤x² : ∀ x → [ 0f ≤ (x · x) ]
instance _ = λ {x} → !! 0≤x² x
field
-- NOTE: all "interface" instance arguments (i.e. those that appear in the goal) need to be passed in as arguments
-- sqrt-of-² : ∀ x → {{ p₁ : ! [ 0f ≤ x ] }} → {{ p₂ : ! [ 0f ≤ x · x ] }} → sqrt (x · x) {{p₂}} ≡ x
-- sqrt-unique-existence : ∀ x → {{ p : ! [ 0f ≤ x ] }} → Σ[ y ∈ Carrier ] y · y ≡ x
-- sqrt-uniqueness : ∀ x y z → {{ p : ! [ 0f ≤ x ] }} → y · y ≡ x → z · z ≡ x → y ≡ z
·-uniqueness : ∀ x y → {{ p₁ : ! [ 0f ≤ x ] }} → {{ p₂ : ! [ 0f ≤ y ] }} → x · x ≡ y · y → x ≡ y
sqrt-existence : ∀ x → {{ p : ! [ 0f ≤ x ] }} → sqrt x {{p}} · sqrt x {{p}} ≡ x
sqrt-preserves-· : ∀ x y → {{ p₁ : ! [ 0f ≤ x ] }} → {{ p₁ : ! [ 0f ≤ y ] }} → {{ p₁ : ! [ 0f ≤ x · y ] }} → sqrt (x · y) ≡ sqrt x · sqrt y
sqrt0≡0 : {{ p : ! [ 0f ≤ 0f ] }} → sqrt 0f {{p}} ≡ 0f
sqrt1≡1 : {{ p : ! [ 0f ≤ 1f ] }} → sqrt 1f {{p}} ≡ 1f
-- √x √x = x ⇒ √xx = x
-- √x √x √x √x = x x
-- √(√x √x √x √x) = √(x x)
-- ²-of-sqrt' : ∀ x → {{ p : ! [ 0f ≤ x ] }} → sqrt x {{p}} · sqrt x {{p}} ≡ x
-- ²-of-sqrt' x {{p}} = let y = sqrt x; instance q = !! 0≤sqrt x in transport (
-- sqrt (y · y) ≡ y ≡⟨ {! !} ⟩
-- sqrt (y · y) · sqrt (y · y) ≡ y · sqrt (y · y) ≡⟨ {! !} ⟩
-- sqrt (y · y) · sqrt (y · y) ≡ y · y ≡⟨ {! λ x → x !} ⟩
-- sqrt x · sqrt x ≡ x ∎) (sqrt-of-² y)
-- {! !} ⇒⟨ {! !} ⟩
-- {! !} ◼) {! (sqrt-of-² y ) !}
-- sqrt (x · x) ≡ x
-- sqrt (x · x) · sqrt (x · x) ≡ x · sqrt (x · x)
-- sqrt (x · x) · sqrt (x · x) ≡ x · x
-- x = sqrt y
-- sqrt y · sqrt y ≡ y
sqrt-test : (x y z : Carrier) → [ 0f ≤ x ] → [ 0f ≤ y ] → Carrier
sqrt-test x y z 0≤x 0≤y = let instance _ = !! 0≤x
instance _ = !! 0≤y
in (sqrt x) + (sqrt y) + (sqrt (z · z))
field
_⁻¹ : (x : Carrier) → {{p : [ x # 0f ]}} → Carrier
_/_ : (x y : Carrier) → {{p : [ y # 0f ]}} → Carrier
(x / y) {{p}} = x · (y ⁻¹) {{p}}
infix 9 _⁻¹
infixl 7 _·_
infixl 7 _/_
infix 6 -_
infix 5 _-_
infixl 5 _+_
infixl 4 _#_
infixl 4 _≤_
infixl 4 _<_
open import MorePropAlgebra.Bridges1999
-- mkBridges : ∀{ℓ ℓ'} → CompletePartiallyOrderedFieldWithSqrt {ℓ} {ℓ'} → BooijResults {ℓ} {ℓ'}
-- mkBridges CPOFS = record { CompletePartiallyOrderedFieldWithSqrt CPOFS }
-----------8<--------------------------------------------8<------------------------------------------8<------------------
{- currently, we have that IsAbs works on "rigs" (rings where `-_` is not necessary)
but in our applications, we do want to take the square root immediately on modules
therefore, `abs` is defined here as always mapping into `CompletePartiallyOrderedFieldWithSqrt` although more general `abs`es would be possible
-}
module _ -- mathematical structures with `abs` into the real numbers
{ℝℓ ℝℓ' : Level}
(ℝbundle : CompletePartiallyOrderedFieldWithSqrt {ℝℓ} {ℝℓ'})
where
module ℝ = CompletePartiallyOrderedFieldWithSqrt ℝbundle
open ℝ using () renaming (Carrier to ℝ; is-set to is-setʳ; _≤_ to _≤ʳ_; 0f to 0ʳ; 1f to 1ʳ; _+_ to _+ʳ_; _·_ to _·ʳ_; -_ to -ʳ_; _-_ to _-ʳ_)
-- this makes the complex numbers ℂ
module EuclideanTwoProductOfCompletePartiallyOrderedFieldWithSqrt where
Carrier : Type ℝℓ
Carrier = ℝ × ℝ
re im : Carrier → ℝ
re = fst
im = snd
0f : Carrier
0f = 0ʳ , 0ʳ
1f : Carrier
1f = 1ʳ , 0ʳ
_+_ : Carrier → Carrier → Carrier
(ar , ai) + (br , bi) = (ar +ʳ br) , (ai +ʳ bi)
_·_ : Carrier → Carrier → Carrier
(ar , ai) · (br , bi) = (ar ·ʳ br -ʳ ai ·ʳ bi) , (ar ·ʳ bi +ʳ br ·ʳ ai)
-_ : Carrier → Carrier
- (ar , ai) = (-ʳ ar , -ʳ ai)
is-set : isSet Carrier
is-set = isSetΣ ℝ.is-set (λ _ → ℝ.is-set)
-- this makes the `R` in `RModule`
record ApartnessRingWithAbsIntoCompletePartiallyOrderedFieldWithSqrt {ℓ ℓ' : Level} : Type (ℓ-suc (ℓ-max (ℓ-max ℓ ℓ') (ℓ-max ℝℓ ℝℓ'))) where
field
Carrier : Type ℓ
0f : Carrier
1f : Carrier
_+_ : Carrier → Carrier → Carrier
_·_ : Carrier → Carrier → Carrier
-_ : Carrier → Carrier
_#_ : hPropRel Carrier Carrier ℓ'
abs : Carrier → ℝ
-- this makes the `G` in `GModule`
record ApartnessGroupWithAbsIntoCompletePartiallyOrderedFieldWithSqrt {ℓ ℓ' : Level} : Type (ℓ-suc (ℓ-max (ℓ-max ℓ ℓ') (ℓ-max ℝℓ ℝℓ'))) where
field
Carrier : Type ℓ
1f : Carrier
_·_ : Carrier → Carrier → Carrier
_⁻¹ : Carrier → Carrier
_#_ : hPropRel Carrier Carrier ℓ'
abs : Carrier → ℝ
-- this makes the `K` in `KModule`
record CompleteApartnessFieldWithAbsIntoCompletePartiallyOrderedFieldWithSqrt {ℓ ℓ' : Level} : Type (ℓ-suc (ℓ-max (ℓ-max ℓ ℓ') (ℓ-max ℝℓ ℝℓ'))) where
field
Carrier : Type ℓ
0f : Carrier
1f : Carrier
_+_ : Carrier → Carrier → Carrier
_·_ : Carrier → Carrier → Carrier
-_ : Carrier → Carrier
_#_ : hPropRel Carrier Carrier ℓ'
_⁻¹ : (x : Carrier) → {{p : [ x # 0f ]}} → Carrier
abs : Carrier → ℝ
is-set : isSet Carrier
is-abs : [ isAbs is-set 0f _+_ _·_ is-setʳ 0ʳ _+ʳ_ _·ʳ_ _≤ʳ_ abs ]
-- TODO: complete this
|
libsrc/math/mbf64/c/sccz80/pow.asm | jpoikela/z88dk | 640 | 86739 | SECTION code_fp_mbf64
PUBLIC pow
EXTERN ___mbf64_setup_two_single
EXTERN ___mbf32_POW
EXTERN ___mbf64_return_single
EXTERN msbios
pow:
call ___mbf64_setup_two_single
ld ix,___mbf32_POW
call msbios
jp ___mbf64_return_single
|
mc-sema/validator/x86/tests/FABS.asm | randolphwong/mcsema | 2 | 163671 | BITS 32
;TEST_FILE_META_BEGIN
;TEST_TYPE=TEST_F
;TEST_IGNOREFLAGS=
;TEST_FILE_META_END
; FADDP
lea edi, [esp-0x8]
; load -1.25 in st0
mov DWORD [edi], 0xbfa00000
fld DWORD [edi]
;TEST_BEGIN_RECORDING
fabs
mov edi, 0x0
;TEST_END_RECORDING
|
Appl/Calendar/Misc/miscManager.asm | steakknife/pcgeos | 504 | 95485 | COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) GeoWorks 1989 -- All Rights Reserved
PROJECT: PC GEOS
MODULE: Calendar/Misc
FILE: miscManager.asm
AUTHOR: <NAME>, March 2, 1991
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 3/2/91 Initial revision
DESCRIPTION:
Manager file for Misc module
$Id: miscManager.asm,v 1.1 97/04/04 14:48:36 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
_Misc = 1 ; module being defined
; Included definitions
;
include calendarGeode.def ; geode declarations
include calendarConstant.def ; structure definitions
include calendarGlobal.def ; global definitions
include calendarMacro.def ; macro definitions
include vm.def ; definitions for kernel VM
include input.def
include system.def ; localization entry point
include initfile.def ; initfile routines
UseLib dbase.def ; definitions for database
; Additonal information
;
udata segment
printWidth word (?) ; printable width
printHeight word (?) ; printable height
printMarginLeft word (?) ; set by MyPrintGetMargins
printMarginTop word (?) ; set by MyPrintGetMargins
udata ends
;Included source files
;
include miscCustomSpin.asm
include miscDateArrows.asm
include miscMonthValue.asm
include miscPrint.asm
include miscSearch.asm
end
|
TurtleTools/Examples/delay.asm | foxostro/TurtleTTL | 1 | 160264 | beginning:
LI A, 0
LI B, 0
LI D, 0
LI X, 0
LI Y, 0
LI U, 0
LI V, 0
LI A, 0
delay65536_0:
MOV U, A
LI A, 0
delay256_0:
LI B, 1
ADD A
LI B, 255
CMP
LXY delay256_0
JNE
NOP
NOP
MOV A, U
LI B, 1
ADD A
LI B, 255
CMP
LXY delay65536_0
JNE
NOP
NOP
LI D, 255
LI A, 0
delay65536_1:
MOV U, A
LI A, 0
delay256_1:
LI B, 1
ADD A
LI B, 255
CMP
LXY delay256_1
JNE
NOP
NOP
MOV A, U
LI B, 1
ADD A
LI B, 255
CMP
LXY delay65536_1
JNE
NOP
NOP
LXY beginning
JMP
NOP
NOP
HLT |
test/Common/Issue481ParametrizedModule.agda | shlevy/agda | 1,989 | 1738 | module Common.Issue481ParametrizedModule (A : Set1) where
id : A → A
id x = x
postulate
Bla : Set
|
Transynther/x86/_processed/NONE/_xt_/i7-7700_9_0xca_notsx.log_21829_1506.asm | ljhsiun2/medusa | 9 | 17519 | .global s_prepare_buffers
s_prepare_buffers:
push %r14
push %r9
push %rcx
push %rdi
push %rsi
lea addresses_UC_ht+0x10753, %rsi
lea addresses_D_ht+0x4453, %rdi
clflush (%rsi)
nop
nop
and %r9, %r9
mov $104, %rcx
rep movsl
cmp %r14, %r14
pop %rsi
pop %rdi
pop %rcx
pop %r9
pop %r14
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r12
push %r13
push %r8
push %r9
push %rbx
// Store
mov $0x5e7, %rbx
nop
nop
inc %r13
mov $0x5152535455565758, %r9
movq %r9, %xmm6
vmovups %ymm6, (%rbx)
nop
nop
nop
nop
cmp %r11, %r11
// Faulty Load
lea addresses_D+0xc753, %r10
nop
nop
nop
nop
inc %r8
mov (%r10), %ebx
lea oracles, %r8
and $0xff, %rbx
shlq $12, %rbx
mov (%r8,%rbx,1), %rbx
pop %rbx
pop %r9
pop %r8
pop %r13
pop %r12
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 0, 'same': True, 'type': 'addresses_D'}, 'OP': 'LOAD'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 2, 'same': False, 'type': 'addresses_P'}, 'OP': 'STOR'}
[Faulty Load]
{'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0, 'same': True, 'type': 'addresses_D'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'congruent': 10, 'same': False, 'type': 'addresses_UC_ht'}, 'dst': {'congruent': 6, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'REPM'}
{'36': 21829}
36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36
*/
|
programs/oeis/272/A272705.asm | jmorken/loda | 1 | 10676 | ; A272705: Number of active (ON,black) cells in n-th stage of growth of two-dimensional cellular automaton defined by "Rule 515", based on the 5-celled von Neumann neighborhood.
; 1,5,13,25,49,69,109,137,193,229,301,345,433,485,589,649,769,837,973,1049,1201,1285,1453,1545,1729,1829,2029,2137,2353,2469,2701,2825,3073,3205,3469,3609,3889,4037,4333,4489,4801,4965,5293,5465,5809,5989,6349
mov $1,1
mov $2,$0
sub $2,2
mov $3,$0
trn $0,1
lpb $0
add $1,$0
sub $0,1
trn $0,1
add $1,$2
lpe
mul $1,2
trn $2,$1
add $2,$1
add $1,$2
lpb $3
add $1,4
sub $3,1
lpe
sub $1,3
|
core.agda | hazelgrove/agda-popl17 | 14 | 6781 | <filename>core.agda
open import Nat
open import Prelude
module core where
-- types
data τ̇ : Set where
num : τ̇
⦇-⦈ : τ̇
_==>_ : τ̇ → τ̇ → τ̇
-- expressions, prefixed with a · to distinguish name clashes with agda
-- built-ins
data ė : Set where
_·:_ : ė → τ̇ → ė
X : Nat → ė
·λ : Nat → ė → ė
N : Nat → ė
_·+_ : ė → ė → ė
⦇-⦈ : ė
⦇⌜_⌟⦈ : ė → ė
_∘_ : ė → ė → ė
---- contexts and some operations on them
-- variables are named with naturals in ė. therefore we represent
-- contexts as functions from names for variables (nats) to possible
-- bindings.
·ctx : Set
·ctx = Nat → Maybe τ̇
-- convenient shorthand for the (unique up to fun. ext.) empty context
∅ : ·ctx
∅ _ = None
-- add a new binding to the context, clobbering anything that might have
-- been there before.
_,,_ : ·ctx → (Nat × τ̇) → ·ctx
(Γ ,, (x , t)) y with natEQ x y
(Γ ,, (x , t)) .x | Inl refl = Some t
(Γ ,, (x , t)) y | Inr neq = Γ y
-- membership, or presence, in a context
_∈_ : (p : Nat × τ̇) → (Γ : ·ctx) → Set
(x , t) ∈ Γ = (Γ x) == Some t
-- apartness for contexts, so that we can follow barendregt's convention
_#_ : (n : Nat) → (Γ : ·ctx) → Set
x # Γ = (Γ x) == None
-- without: remove a variable from a context
_/_ : ·ctx → Nat → ·ctx
(Γ / x) y with natEQ x y
(Γ / x) .x | Inl refl = None
(Γ / x) y | Inr neq = Γ y
-- the type consistency judgement
data _~_ : (t1 : τ̇) → (t2 : τ̇) → Set where
TCRefl : {t : τ̇} → t ~ t
TCHole1 : {t : τ̇} → t ~ ⦇-⦈
TCHole2 : {t : τ̇} → ⦇-⦈ ~ t
TCArr : {t1 t2 t1' t2' : τ̇} →
t1 ~ t1' →
t2 ~ t2' →
(t1 ==> t2) ~ (t1' ==> t2')
-- type inconsistency. a judgmental version and associated proofs are in
-- judgemental-inconsistency.agda. each definition implies the other, but
-- the two are isomorphic only if you treat proofs of inconsistency at
-- arrow types as being proof-irrelevant---that is, if you don't
-- distinguish between cases where the inconsistency between a pair of
-- function types stems from the domain, range, or both. we use the form
-- below throughout the rest of the development because we do not care to
-- make that distinction.
_~̸_ : τ̇ → τ̇ → Set
t1 ~̸ t2 = (t1 ~ t2) → ⊥
--- matching for arrows
data _▸arr_ : τ̇ → τ̇ → Set where
MAHole : ⦇-⦈ ▸arr (⦇-⦈ ==> ⦇-⦈)
MAArr : {t1 t2 : τ̇} → (t1 ==> t2) ▸arr (t1 ==> t2)
-- matching produces unique answers
matcharrunicity : ∀{ t t2 t3 } →
t ▸arr t2 →
t ▸arr t3 →
t2 == t3
matcharrunicity MAHole MAHole = refl
matcharrunicity MAArr MAArr = refl
-- if a type matches, then it's consistent with the least restrictive
-- function type
matchconsist : ∀{t t'} →
t ▸arr t' →
t ~ (⦇-⦈ ==> ⦇-⦈)
matchconsist MAHole = TCHole2
matchconsist MAArr = TCArr TCHole1 TCHole1
matchnotnum : ∀{t1 t2} → num ▸arr (t1 ==> t2) → ⊥
matchnotnum ()
-- bidirectional type checking judgements for ė
mutual
-- synthesis
data _⊢_=>_ : (Γ : ·ctx) → (e : ė) → (t : τ̇) → Set where
SAsc : {Γ : ·ctx} {e : ė} {t : τ̇} →
Γ ⊢ e <= t →
Γ ⊢ (e ·: t) => t
SVar : {Γ : ·ctx} {t : τ̇} {n : Nat} →
(n , t) ∈ Γ →
Γ ⊢ X n => t
SAp : {Γ : ·ctx} {e1 e2 : ė} {t t' t2 : τ̇} →
Γ ⊢ e1 => t →
t ▸arr (t2 ==> t') →
Γ ⊢ e2 <= t2 →
Γ ⊢ (e1 ∘ e2) => t'
SNum : {Γ : ·ctx} {n : Nat} →
Γ ⊢ N n => num
SPlus : {Γ : ·ctx} {e1 e2 : ė} →
Γ ⊢ e1 <= num →
Γ ⊢ e2 <= num →
Γ ⊢ (e1 ·+ e2) => num
SEHole : {Γ : ·ctx} → Γ ⊢ ⦇-⦈ => ⦇-⦈
SNEHole : {Γ : ·ctx} {e : ė} {t : τ̇} →
Γ ⊢ e => t →
Γ ⊢ ⦇⌜ e ⌟⦈ => ⦇-⦈
-- analysis
data _⊢_<=_ : (Γ : ·ctx) → (e : ė) → (t : τ̇) → Set where
ASubsume : {Γ : ·ctx} {e : ė} {t t' : τ̇} →
Γ ⊢ e => t' →
t ~ t' →
Γ ⊢ e <= t
ALam : {Γ : ·ctx} {e : ė} {t t1 t2 : τ̇} {x : Nat} →
x # Γ →
t ▸arr (t1 ==> t2) →
(Γ ,, (x , t1)) ⊢ e <= t2 →
Γ ⊢ (·λ x e) <= t
----- some theorems about the rules and judgement presented so far.
-- a variable is apart from any context from which it is removed
aar : (Γ : ·ctx) (x : Nat) → x # (Γ / x)
aar Γ x with natEQ x x
aar Γ x | Inl refl = refl
aar Γ x | Inr x≠x = abort (x≠x refl)
-- contexts give at most one binding for each variable
ctxunicity : {Γ : ·ctx} {n : Nat} {t t' : τ̇} →
(n , t) ∈ Γ →
(n , t') ∈ Γ →
t == t'
ctxunicity {n = n} p q with natEQ n n
ctxunicity p q | Inl refl = someinj (! p · q)
ctxunicity _ _ | Inr x≠x = abort (x≠x refl)
-- type consistency is symmetric
~sym : {t1 t2 : τ̇} → t1 ~ t2 → t2 ~ t1
~sym TCRefl = TCRefl
~sym TCHole1 = TCHole2
~sym TCHole2 = TCHole1
~sym (TCArr p1 p2) = TCArr (~sym p1) (~sym p2)
-- type consistency isn't transitive
not-trans : ((t1 t2 t3 : τ̇) → t1 ~ t2 → t2 ~ t3 → t1 ~ t3) → ⊥
not-trans t with t (num ==> num) ⦇-⦈ num TCHole1 TCHole2
... | ()
-- if the domain or codomain of a pair of arrows isn't consistent, the
-- whole arrow isn't consistent.
lemarr1 : {t1 t2 t3 t4 : τ̇} → (t1 ~ t3 → ⊥) → (t1 ==> t2) ~ (t3 ==> t4) → ⊥
lemarr1 v TCRefl = v TCRefl
lemarr1 v (TCArr p _) = v p
lemarr2 : {t1 t2 t3 t4 : τ̇} → (t2 ~ t4 → ⊥) → (t1 ==> t2) ~ (t3 ==> t4) → ⊥
lemarr2 v TCRefl = v TCRefl
lemarr2 v (TCArr _ p) = v p
-- every pair of types is either consistent or not consistent
~dec : (t1 t2 : τ̇) → ((t1 ~ t2) + (t1 ~̸ t2))
-- this takes care of all hole cases, so we don't consider them below
~dec _ ⦇-⦈ = Inl TCHole1
~dec ⦇-⦈ _ = Inl TCHole2
-- num cases
~dec num num = Inl TCRefl
~dec num (t2 ==> t3) = Inr (λ ())
-- arrow cases
~dec (t1 ==> t2) num = Inr (λ ())
~dec (t1 ==> t2) (t3 ==> t4) with ~dec t1 t3 | ~dec t2 t4
... | Inl x | Inl y = Inl (TCArr x y)
... | Inl _ | Inr y = Inr (lemarr2 y)
... | Inr x | _ = Inr (lemarr1 x)
-- theorem: no pair of types is both consistent and not consistent. this
-- is immediate from our encoding of the ~̸ judgement in the formalism
-- here; in the exact mathematics presented in the paper, this would
-- require induction to relate the two judgements.
~apart : {t1 t2 : τ̇} → (t1 ~̸ t2) → (t1 ~ t2) → ⊥
~apart v p = v p
-- synthesis only produces equal types. note that there is no need for an
-- analagous theorem for analytic positions because we think of
-- the type as an input
synthunicity : {Γ : ·ctx} {e : ė} {t t' : τ̇} →
(Γ ⊢ e => t)
→ (Γ ⊢ e => t')
→ t == t'
synthunicity (SAsc _) (SAsc _) = refl
synthunicity {Γ = G} (SVar in1) (SVar in2) = ctxunicity {Γ = G} in1 in2
synthunicity (SAp D1 MAHole b) (SAp D2 MAHole y) = refl
synthunicity (SAp D1 MAHole b) (SAp D2 MAArr y) with synthunicity D1 D2
... | ()
synthunicity (SAp D1 MAArr b) (SAp D2 MAHole y) with synthunicity D1 D2
... | ()
synthunicity (SAp D1 MAArr b) (SAp D2 MAArr y) with synthunicity D1 D2
... | refl = refl
synthunicity SNum SNum = refl
synthunicity (SPlus _ _ ) (SPlus _ _ ) = refl
synthunicity SEHole SEHole = refl
synthunicity (SNEHole _) (SNEHole _) = refl
----- the zippered form of the forms above and the rules for actions on them
-- those types without holes anywhere
tcomplete : τ̇ → Set
tcomplete num = ⊤
tcomplete ⦇-⦈ = ⊥
tcomplete (t1 ==> t2) = (tcomplete t1) × (tcomplete t2)
-- similarly to the complete types, the complete expressions
ecomplete : ė → Set
ecomplete (e1 ·: t) = ecomplete e1 × tcomplete t
ecomplete (X _) = ⊤
ecomplete (·λ _ e1) = ecomplete e1
ecomplete (N x) = ⊤
ecomplete (e1 ·+ e2) = ecomplete e1 × ecomplete e2
ecomplete ⦇-⦈ = ⊥
ecomplete ⦇⌜ e1 ⌟⦈ = ⊥
ecomplete (e1 ∘ e2) = ecomplete e1 × ecomplete e2
-- zippered form of types
data τ̂ : Set where
▹_◃ : τ̇ → τ̂
_==>₁_ : τ̂ → τ̇ → τ̂
_==>₂_ : τ̇ → τ̂ → τ̂
-- zippered form of expressions
data ê : Set where
▹_◃ : ė → ê
_·:₁_ : ê → τ̇ → ê
_·:₂_ : ė → τ̂ → ê
·λ : Nat → ê → ê
_∘₁_ : ê → ė → ê
_∘₂_ : ė → ê → ê
_·+₁_ : ê → ė → ê
_·+₂_ : ė → ê → ê
⦇⌜_⌟⦈ : ê → ê
-- erasure of cursor for types and expressions, judgementally. see
-- jugemental-erase.agda for an argument that this defines an isomorphic
-- object to the direct metafunction provided in the text of the paper
data erase-t : τ̂ → τ̇ → Set where
ETTop : ∀{t} → erase-t (▹ t ◃) t
ETArrL : ∀{t1 t1' t2} → erase-t t1 t1' → erase-t (t1 ==>₁ t2) (t1' ==> t2)
ETArrR : ∀{t1 t2 t2'} → erase-t t2 t2' → erase-t (t1 ==>₂ t2) (t1 ==> t2')
data erase-e : ê → ė → Set where
EETop : ∀{x} → erase-e (▹ x ◃) x
EEAscL : ∀{e e' t} → erase-e e e' → erase-e (e ·:₁ t) (e' ·: t)
EEAscR : ∀{e t t'} → erase-t t t' → erase-e (e ·:₂ t) (e ·: t')
EELam : ∀{x e e'} → erase-e e e' → erase-e (·λ x e) (·λ x e')
EEApL : ∀{e1 e1' e2} → erase-e e1 e1' → erase-e (e1 ∘₁ e2) (e1' ∘ e2)
EEApR : ∀{e1 e2 e2'} → erase-e e2 e2' → erase-e (e1 ∘₂ e2) (e1 ∘ e2')
EEPlusL : ∀{e1 e1' e2} → erase-e e1 e1' → erase-e (e1 ·+₁ e2) (e1' ·+ e2)
EEPlusR : ∀{e1 e2 e2'} → erase-e e2 e2' → erase-e (e1 ·+₂ e2) (e1 ·+ e2')
EENEHole : ∀{e e'} → erase-e e e' → erase-e ⦇⌜ e ⌟⦈ ⦇⌜ e' ⌟⦈
-- the three grammars that define actions
data direction : Set where
child : Nat → direction
parent : direction
data shape : Set where
arrow : shape
num : shape
asc : shape
var : Nat → shape
lam : Nat → shape
ap : shape
numlit : Nat → shape
plus : shape
nehole : shape
data action : Set where
move : direction → action
construct : shape → action
del : action
finish : action
-- type actions
data _+_+>_ : (t : τ̂) → (α : action) → (t' : τ̂) → Set where
TMArrChild1 : {t1 t2 : τ̇} →
▹ t1 ==> t2 ◃ + move (child 1) +> (▹ t1 ◃ ==>₁ t2)
TMArrChild2 : {t1 t2 : τ̇} →
▹ t1 ==> t2 ◃ + move (child 2) +> (t1 ==>₂ ▹ t2 ◃)
TMArrParent1 : {t1 t2 : τ̇} →
(▹ t1 ◃ ==>₁ t2) + move parent +> ▹ t1 ==> t2 ◃
TMArrParent2 : {t1 t2 : τ̇} →
(t1 ==>₂ ▹ t2 ◃) + move parent +> ▹ t1 ==> t2 ◃
TMDel : {t : τ̇} →
(▹ t ◃) + del +> (▹ ⦇-⦈ ◃)
TMConArrow : {t : τ̇} →
(▹ t ◃) + construct arrow +> (t ==>₂ ▹ ⦇-⦈ ◃)
TMConNum : (▹ ⦇-⦈ ◃) + construct num +> (▹ num ◃)
TMArrZip1 : {t1 t1' : τ̂} {t2 : τ̇} {α : action} →
(t1 + α +> t1') →
((t1 ==>₁ t2) + α +> (t1' ==>₁ t2))
TMArrZip2 : {t2 t2' : τ̂} {t1 : τ̇} {α : action} →
(t2 + α +> t2') →
((t1 ==>₂ t2) + α +> (t1 ==>₂ t2'))
-- expression movement
data _+_+>e_ : (e : ê) → (α : action) → (e' : ê) → Set where
-- rules for ascriptions
EMAscChild1 : {e : ė} {t : τ̇} →
(▹ e ·: t ◃) + move (child 1) +>e (▹ e ◃ ·:₁ t)
EMAscChild2 : {e : ė} {t : τ̇} →
(▹ e ·: t ◃) + move (child 2) +>e (e ·:₂ ▹ t ◃)
EMAscParent1 : {e : ė} {t : τ̇} →
(▹ e ◃ ·:₁ t) + move parent +>e (▹ e ·: t ◃)
EMAscParent2 : {e : ė} {t : τ̇} →
(e ·:₂ ▹ t ◃) + move parent +>e (▹ e ·: t ◃)
-- rules for lambdas
EMLamChild1 : {e : ė} {x : Nat} →
▹ (·λ x e) ◃ + move (child 1) +>e ·λ x (▹ e ◃)
EMLamParent : {e : ė} {x : Nat} →
·λ x (▹ e ◃) + move parent +>e ▹ (·λ x e) ◃
-- rules for 2-ary constructors
EMPlusChild1 : {e1 e2 : ė} →
(▹ e1 ·+ e2 ◃) + move (child 1) +>e (▹ e1 ◃ ·+₁ e2)
EMPlusChild2 : {e1 e2 : ė} →
(▹ e1 ·+ e2 ◃) + move (child 2) +>e (e1 ·+₂ ▹ e2 ◃)
EMPlusParent1 : {e1 e2 : ė} →
(▹ e1 ◃ ·+₁ e2) + move parent +>e (▹ e1 ·+ e2 ◃)
EMPlusParent2 : {e1 e2 : ė} →
(e1 ·+₂ ▹ e2 ◃) + move parent +>e (▹ e1 ·+ e2 ◃)
EMApChild1 : {e1 e2 : ė} →
(▹ e1 ∘ e2 ◃) + move (child 1)+>e (▹ e1 ◃ ∘₁ e2)
EMApChild2 : {e1 e2 : ė} →
(▹ e1 ∘ e2 ◃) + move (child 2) +>e (e1 ∘₂ ▹ e2 ◃)
EMApParent1 : {e1 e2 : ė} →
(▹ e1 ◃ ∘₁ e2) + move parent +>e (▹ e1 ∘ e2 ◃)
EMApParent2 : {e1 e2 : ė} →
(e1 ∘₂ ▹ e2 ◃) + move parent +>e (▹ e1 ∘ e2 ◃)
-- rules for non-empty holes
EMNEHoleChild1 : {e : ė} →
(▹ ⦇⌜ e ⌟⦈ ◃) + move (child 1) +>e ⦇⌜ ▹ e ◃ ⌟⦈
EMNEHoleParent : {e : ė} →
⦇⌜ ▹ e ◃ ⌟⦈ + move parent +>e (▹ ⦇⌜ e ⌟⦈ ◃)
mutual
-- synthetic action expressions
data _⊢_=>_~_~>_=>_ : (Γ : ·ctx) → (e1 : ê) → (t1 : τ̇)
→ (α : action) → (e2 : ê) → (t2 : τ̇) → Set where
SAMove : {δ : direction} {e e' : ê} {Γ : ·ctx} {t : τ̇} →
(e + move δ +>e e') →
Γ ⊢ e => t ~ move δ ~> e' => t
SADel : {Γ : ·ctx} {e : ė} {t : τ̇} →
Γ ⊢ ▹ e ◃ => t ~ del ~> ▹ ⦇-⦈ ◃ => ⦇-⦈
SAConAsc : {Γ : ·ctx} {e : ė} {t : τ̇} →
Γ ⊢ ▹ e ◃ => t ~ construct asc ~> (e ·:₂ ▹ t ◃ ) => t
SAConVar : {Γ : ·ctx} {x : Nat} {t : τ̇} →
(p : (x , t) ∈ Γ) →
Γ ⊢ ▹ ⦇-⦈ ◃ => ⦇-⦈ ~ construct (var x) ~> ▹ X x ◃ => t
SAConLam : {Γ : ·ctx} {x : Nat} →
(x # Γ) →
Γ ⊢ ▹ ⦇-⦈ ◃ => ⦇-⦈ ~ construct (lam x) ~>
((·λ x ⦇-⦈) ·:₂ (▹ ⦇-⦈ ◃ ==>₁ ⦇-⦈)) => (⦇-⦈ ==> ⦇-⦈)
SAConApArr : {Γ : ·ctx} {t t1 t2 : τ̇} {e : ė} →
t ▸arr (t1 ==> t2) →
Γ ⊢ ▹ e ◃ => t ~ construct ap ~> e ∘₂ ▹ ⦇-⦈ ◃ => t2
SAConApOtw : {Γ : ·ctx} {t : τ̇} {e : ė} →
(t ~̸ (⦇-⦈ ==> ⦇-⦈)) →
Γ ⊢ ▹ e ◃ => t ~ construct ap ~> ⦇⌜ e ⌟⦈ ∘₂ ▹ ⦇-⦈ ◃ => ⦇-⦈
SAConNumlit : {Γ : ·ctx} {n : Nat} →
Γ ⊢ ▹ ⦇-⦈ ◃ => ⦇-⦈ ~ construct (numlit n) ~> ▹ N n ◃ => num
SAConPlus1 : {Γ : ·ctx} {e : ė} {t : τ̇} →
(t ~ num) →
Γ ⊢ ▹ e ◃ => t ~ construct plus ~> e ·+₂ ▹ ⦇-⦈ ◃ => num
SAConPlus2 : {Γ : ·ctx} {e : ė} {t : τ̇} →
(t ~̸ num) →
Γ ⊢ ▹ e ◃ => t ~ construct plus ~> ⦇⌜ e ⌟⦈ ·+₂ ▹ ⦇-⦈ ◃ => num
SAConNEHole : {Γ : ·ctx} {e : ė} {t : τ̇} →
Γ ⊢ ▹ e ◃ => t ~ construct nehole ~> ⦇⌜ ▹ e ◃ ⌟⦈ => ⦇-⦈
SAFinish : {Γ : ·ctx} {e : ė} {t : τ̇} →
(Γ ⊢ e => t) →
Γ ⊢ ▹ ⦇⌜ e ⌟⦈ ◃ => ⦇-⦈ ~ finish ~> ▹ e ◃ => t
SAZipAsc1 : {Γ : ·ctx} {e e' : ê} {α : action} {t : τ̇} →
(Γ ⊢ e ~ α ~> e' ⇐ t) →
Γ ⊢ (e ·:₁ t) => t ~ α ~> (e' ·:₁ t) => t
SAZipAsc2 : {Γ : ·ctx} {e : ė} {α : action} {t t' : τ̂} {t◆ t'◆ : τ̇} →
(t + α +> t') →
(erase-t t' t'◆) →
(erase-t t t◆) →
(Γ ⊢ e <= t'◆) →
Γ ⊢ (e ·:₂ t) => t◆ ~ α ~> (e ·:₂ t') => t'◆
SAZipApArr : {Γ : ·ctx} {t t1 t2 t3 t4 : τ̇} {α : action} {eh eh' : ê} {e eh◆ : ė} →
(t ▸arr (t3 ==> t4)) →
(erase-e eh eh◆) →
(Γ ⊢ (eh◆) => t2) →
(Γ ⊢ eh => t2 ~ α ~> eh' => t) →
(Γ ⊢ e <= t3) →
Γ ⊢ (eh ∘₁ e) => t1 ~ α ~> (eh' ∘₁ e) => t4
SAZipApAna : {Γ : ·ctx} {t' t2 t : τ̇} {e : ė} {eh eh' : ê} {α : action} →
(t' ▸arr (t2 ==> t)) →
(Γ ⊢ e => t') →
(Γ ⊢ eh ~ α ~> eh' ⇐ t2) →
Γ ⊢ (e ∘₂ eh) => t ~ α ~> (e ∘₂ eh') => t
SAZipPlus1 : {Γ : ·ctx} {e : ė} {eh eh' : ê} {α : action} →
(Γ ⊢ eh ~ α ~> eh' ⇐ num) →
Γ ⊢ (eh ·+₁ e) => num ~ α ~> (eh' ·+₁ e) => num
SAZipPlus2 : {Γ : ·ctx} {e : ė} {eh eh' : ê} {α : action} →
(Γ ⊢ eh ~ α ~> eh' ⇐ num) →
Γ ⊢ (e ·+₂ eh) => num ~ α ~> (e ·+₂ eh') => num
SAZipHole : {Γ : ·ctx} {e e' : ê} {t t' : τ̇} {α : action} {e◆ : ė} →
(erase-e e e◆) →
(Γ ⊢ e◆ => t) →
(Γ ⊢ e => t ~ α ~> e' => t') →
Γ ⊢ ⦇⌜ e ⌟⦈ => ⦇-⦈ ~ α ~> ⦇⌜ e' ⌟⦈ => ⦇-⦈
-- analytic action expressions
data _⊢_~_~>_⇐_ : (Γ : ·ctx) → (e : ê) → (α : action) →
(e' : ê) → (t : τ̇) → Set where
AASubsume : {Γ : ·ctx} {e e' : ê} {t t' t'' : τ̇} {α : action} {e◆ : ė} →
(erase-e e e◆) →
(Γ ⊢ e◆ => t') →
(Γ ⊢ e => t' ~ α ~> e' => t'') →
(t ~ t'') →
Γ ⊢ e ~ α ~> e' ⇐ t
AAMove : {e e' : ê} {δ : direction} {Γ : ·ctx} {t : τ̇} →
(e + move δ +>e e') →
Γ ⊢ e ~ move δ ~> e' ⇐ t
AADel : {e : ė} {Γ : ·ctx} {t : τ̇} →
Γ ⊢ ▹ e ◃ ~ del ~> ▹ ⦇-⦈ ◃ ⇐ t
AAConAsc : {Γ : ·ctx} {e : ė} {t : τ̇} →
Γ ⊢ ▹ e ◃ ~ construct asc ~> (e ·:₂ ▹ t ◃) ⇐ t
AAConVar : {Γ : ·ctx} {t t' : τ̇} {x : Nat} →
(t ~̸ t') →
(p : (x , t') ∈ Γ) →
Γ ⊢ ▹ ⦇-⦈ ◃ ~ construct (var x) ~> ⦇⌜ ▹ X x ◃ ⌟⦈ ⇐ t
AAConLam1 : {Γ : ·ctx} {x : Nat} {t t1 t2 : τ̇} →
(x # Γ) →
(t ▸arr (t1 ==> t2)) →
Γ ⊢ ▹ ⦇-⦈ ◃ ~ construct (lam x) ~>
·λ x (▹ ⦇-⦈ ◃) ⇐ t
AAConLam2 : {Γ : ·ctx} {x : Nat} {t : τ̇} →
(x # Γ) →
(t ~̸ (⦇-⦈ ==> ⦇-⦈)) →
Γ ⊢ ▹ ⦇-⦈ ◃ ~ construct (lam x) ~>
⦇⌜ ·λ x ⦇-⦈ ·:₂ (▹ ⦇-⦈ ◃ ==>₁ ⦇-⦈) ⌟⦈ ⇐ t
AAConNumlit : {Γ : ·ctx} {t : τ̇} {n : Nat} →
(t ~̸ num) →
Γ ⊢ ▹ ⦇-⦈ ◃ ~ construct (numlit n) ~> ⦇⌜ ▹ (N n) ◃ ⌟⦈ ⇐ t
AAFinish : {Γ : ·ctx} {e : ė} {t : τ̇} →
(Γ ⊢ e <= t) →
Γ ⊢ ▹ ⦇⌜ e ⌟⦈ ◃ ~ finish ~> ▹ e ◃ ⇐ t
AAZipLam : {Γ : ·ctx} {x : Nat} {t t1 t2 : τ̇} {e e' : ê} {α : action} →
x # Γ →
(t ▸arr (t1 ==> t2)) →
((Γ ,, (x , t1)) ⊢ e ~ α ~> e' ⇐ t2) →
Γ ⊢ (·λ x e) ~ α ~> (·λ x e') ⇐ t
|
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/sso/u11.adb | best08618/asylo | 7 | 22398 | <gh_stars>1-10
-- { dg-do run }
with Init11; use Init11;
with Text_IO; use Text_IO;
with Dump;
procedure U11 is
Local_R1 : R1;
Local_R2 : R2;
C1 : My_Integer;
C2 : My_Integer;
begin
Local_R1 := (I => 1, A => (16#AB0012#, 16#CD0034#, 16#EF0056#));
Put ("Local_R1 :");
Dump (Local_R1'Address, R1'Max_Size_In_Storage_Elements);
New_Line;
-- { dg-output "Local_R1 : 01 00 00 00 12 00 ab 00 34 00 cd 00 56 00 ef 00.*\n" }
Local_R2 := (I => 1, A => (16#AB0012#, 16#CD0034#, 16#EF0056#));
Put ("Local_R2 :");
Dump (Local_R2'Address, R2'Max_Size_In_Storage_Elements);
New_Line;
-- { dg-output "Local_R2 : 00 00 00 01 00 ab 00 12 00 cd 00 34 00 ef 00 56.*\n" }
C1 := Local_R1.A (Integer(Local_R1.I));
Put_Line ("C1 :" & C1'Img);
-- { dg-output "C1 : 11206674.*\n" }
Local_R1.I := Local_R1.I + 1;
C1 := Local_R1.A (Integer(Local_R1.I));
Put_Line ("C1 :" & C1'Img);
-- { dg-output "C1 : 13434932.*\n" }
C2 := Local_R2.A (Integer(Local_R2.I));
Put_Line ("C2 :" & C2'Img);
-- { dg-output "C2 : 11206674.*\n" }
Local_R2.I := Local_R2.I + 1;
C2 := Local_R2.A (Integer(Local_R2.I));
Put_Line ("C2 :" & C2'Img);
-- { dg-output "C2 : 13434932.*\n" }
end;
|
src/main/antlr4/com/github/gundy/semver4j/generated/grammar/NodeSemverExpression.g4 | gundy/semver4j | 6 | 3924 | <filename>src/main/antlr4/com/github/gundy/semver4j/generated/grammar/NodeSemverExpression.g4<gh_stars>1-10
grammar NodeSemverExpression;
SPACE: ' ' | '\t';
LOGICAL_OR_OPERATOR: SPACE* '||' SPACE*;
wildcard
: ASTERISK
| 'X'|'x'
;
basicRange: range;
part
: integer # integerIdentifier
| (HYPHEN | NON_ZERO_NUMBER | letter) (HYPHEN | ZERO | NON_ZERO_NUMBER | letter)+ # nonIntegerIdentifier
;
range
: left=fullSemver SPACE HYPHEN SPACE right=fullSemver # hyphenatedRangeOfFullySpecifiedVersions
| simple (SPACE simple)* # logicalAndOfSimpleExpressions
| # emptyRange
;
simple
: partialWildcardSemver # wildcardRange
| unaryOperator SPACE* partialWildcardSemver # operator
| (GT EQ | LT EQ)? ASTERISK # wildcardOperator
| TILDE SPACE* fullSemver # tildeRange
| CARET SPACE* fullSemver # caretRange
| fullSemver # fullySpecifiedSemver
;
rangeSet
: basicRange (LOGICAL_OR_OPERATOR basicRange)* EOF # logicalOrOfMultipleRanges
;
unaryOperator
: (GT EQ? | LT EQ? | EQ)
;
LT: '<';
GT: '>';
EQ: '=';
fullSemver
: EQ? ('V'|'v')? major=integer ('.' minor=integer ('.' patch=integer (HYPHEN? preReleaseIdentifiers=identifiers)? (PLUS buildIdentifiers=identifiers)?)?)?
;
partialWildcardSemver
: EQ? ('V'|'v')? major=integer ('.' wildcard ('.' wildcard)? )?
| EQ? ('V'|'v')? major=integer ('.' minor=integer ('.' wildcard)? )?
| EQ? ('V'|'v')? major=integer ('.' minor=integer ('.' patch=integer (HYPHEN? preReleaseIdentifiers=identifiers)? (PLUS buildIdentifiers=identifiers)?)?)?
;
TILDE: '~';
CARET: '^';
HYPHEN: '-';
ZERO: '0';
NON_ZERO_NUMBER: '1'..'9';
integer
: ZERO
| NON_ZERO_NUMBER (ZERO | NON_ZERO_NUMBER)*
;
ASTERISK: '*';
letter: 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K'
| 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V'
| 'W' | 'X' | 'Y' | 'Z'
| 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k'
| 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v'
| 'w' | 'x' | 'y' | 'z';
PLUS: '+';
identifiers
: part (PERIOD part)*
;
PERIOD
: '.'
;
|
src/Data/FingerTree.agda | oisdk/agda-indexed-fingertree | 1 | 7663 | <filename>src/Data/FingerTree.agda
{-# OPTIONS --without-K --safe #-}
open import Algebra
module Data.FingerTree
{c m}
(ℳ : Monoid c m)
where
open import Data.FingerTree.Measures ℳ
open import Data.FingerTree.Structures ℳ
open import Data.FingerTree.Cons ℳ
open import Data.FingerTree.View ℳ
open import Data.FingerTree.Split ℳ
|
src/grammar/Expressions.g4 | craterdog-bali/js-bali-document-framework | 1 | 1052 | grammar Expressions;
import Components;
expression: // Precedence (highest to lowest)
component #componentExpression |
variable #variableExpression |
funcxion '(' arguments ')' #functionExpression |
'(' expression ')' #precedenceExpression |
'@' expression #dereferenceExpression |
expression operator=('.' | '<-') message '(' arguments ')' #messageExpression |
expression '[' indices ']' #attributeExpression |
expression '&' expression #chainExpression |
expression '!' #factorialExpression |
<assoc=right> expression '^' expression #exponentialExpression |
operator=('-' | '/' | '*') expression #inversionExpression |
expression operator=('*' | '/' | '//' | '+' | '-') expression #arithmeticExpression |
'|' expression '|' #magnitudeExpression |
expression operator=('<' | '=' | '>' | 'IS' | 'MATCHES') expression #comparisonExpression |
'NOT' expression #complementExpression |
expression operator=('AND' | 'SANS' | 'XOR' | 'OR') expression #logicalExpression |
expression '?' expression #defaultExpression
;
variable: IDENTIFIER;
funcxion: IDENTIFIER;
message: IDENTIFIER;
arguments:
expression (',' expression)* |
/* no expressions */
;
indices: expression (',' expression)*;
|
source/adam-a_package.ads | charlie5/aIDE | 3 | 6596 | <filename>source/adam-a_package.ads
with
AdaM.Declaration.of_package;
package AdaM.a_Package
renames AdaM.Declaration.of_package;
|
nicolai/pseudotruncations/PseudoTruncs-wconst-seq.agda | nicolaikraus/HoTT-Agda | 1 | 13020 | <gh_stars>1-10
{-# OPTIONS --without-K #-}
open import lib.Basics
open import lib.NType2
open import lib.PathFunctor
open import lib.PathGroupoid
open import lib.types.Bool
open import lib.types.IteratedSuspension
open import lib.types.LoopSpace
open import lib.types.Nat
open import lib.types.Paths
open import lib.types.Pi
open import lib.types.Pointed
open import lib.types.Sigma
open import lib.types.Suspension
open import lib.types.TLevel
open import lib.types.Unit
open import nicolai.pseudotruncations.Preliminary-definitions
open import nicolai.pseudotruncations.Liblemmas
open import nicolai.pseudotruncations.SeqColim
open import nicolai.pseudotruncations.wconstSequence
module nicolai.pseudotruncations.PseudoTruncs-wconst-seq where
open import nicolai.pseudotruncations.pointed-O-Sphere
open import nicolai.pseudotruncations.LoopsAndSpheres
open import nicolai.pseudotruncations.PseudoTruncs
{- The special sequence that we consider -}
module PtruncsSeq {i} (X : Type i) where
A : ℕ → Type i
A O = X
A (S n) = Pseudo n -1-trunc (A n)
f : (n : ℕ) → A n → A (S n)
f n x = point n -1 x
C : Sequence {i}
C = (A , f)
{- A main result: If we have an inhabitant of X, then the sequence is weakly constant.
This is Lemma 6.2 ! -}
module PtruncSeqWC {i} (X : Type i) (x₀ : X) where
open PtruncsSeq {i} X
fs : (n : ℕ) → A n
fs O = x₀
fs (S n) = f n (fs n)
P : (n : ℕ) → (x : A n) → Type i
P n x = f n x == fs (S n)
{- This is the easy 'Case j ≡ -2' -}
f₀-x₀ : (y : X) → P O y
f₀-x₀ y = (spoke O -1 r (lift false)) ∙ ! (spoke O -1 r (lift true)) where
r : Sphere {i} O → X
r (lift true) = x₀
r (lift false) = y
{- Now, the general case is done by induction on n
(note that this variable is called 'j' in the paper).
Hence, what is 'j' in the paper is now 'S n'.
Unfortunately, we have to do everything in one "big"
step with many "where" clauses due to the mutual dependencies. -}
fₙ-x₀ : (n : ℕ) → (y : A n) → P n y
fₙ-x₀ O y = f₀-x₀ y
fₙ-x₀ (S n) = Pseudotrunc-ind n Point Hub Spoke where
-- just for convenience - saves brackets
norₙ' : Sphere' {i} n
norₙ' = nor' n
fⁿx₀ = fs n
Point : (w : A n) → P (S n) (point n -1 w)
Point w = ap (point (S n) -1) (fₙ-x₀ n w)
Hub : (r : Sphere' n → A n) → point S n -1 _ == _
Hub r = ap (point (S n) -1) (! (spoke n -1 r norₙ') ∙ fₙ-x₀ n (r norₙ'))
{- The definition of [Spoke] is the hard part.
First, we do the easy things that we have to do... -}
Spoke : (r : _) → (x : Sphere' n) → _
Spoke r = λ x → from-transp (P (S n))
(spoke n -1 r x)
(
transport (P (S n)) (spoke n -1 r x) (Point (r x))
=⟨ trans-ap₁ (f (S n)) (fs (S (S n))) (spoke n -1 r x) (Point (r x)) ⟩
! (ap (point (S n) -1) (spoke n -1 r x)) ∙ Point (r x)
=⟨ ! (ap (point (S n) -1) (spoke n -1 r x)) ∙ₗ ! (∙-unit-r (Point (r x))) ⟩
! (ap (point (S n) -1) (spoke n -1 r x)) ∙ Point (r x) ∙ idp
{- Now comes the hard step which requires A LOT of work in the where clause
below: we can compose with something which, for a complicated reason, is idp! -}
=⟨ ! (ap (point (S n) -1) (spoke n -1 r x)) ∙ₗ (Point (r x) ∙ₗ ! (k-const x)) ⟩
! (ap (point (S n) -1) (spoke n -1 r x)) ∙ Point (r x) ∙ k x
{- From here, it's easy; we just have to re-associate paths and cancel inverses.
This could be done with standard library lemmas, but it's easier to just use
an 'ad-hoc' lemma. -}
=⟨ multi-cancelling (ap (point S n -1) (spoke n -1 r x)) (Point (r x)) (Hub r) ⟩
Hub r
∎
)
where
{- Now, the actual work follows! -}
{- First, we define the interesting loop.
In the paper, it is called [kₓ].
Here, it is just [k x]. -}
k : (x : Sphere' {i} n)
→ Ω (Pseudo S n -1-trunc (A (S n)) ,
f (S n) (f n fⁿx₀))
k x = ! (Point (r x)) ∙ ap (point (S n) -1) (spoke n -1 r x) ∙ (Hub r)
{- We want to show that [k] factors as [ap pₙ ∘ h].
First, we define h. -}
h : Sphere' {i} n
→ Ω (Pseudo n -1-trunc (A n) ,
f n fⁿx₀)
h x = ! (fₙ-x₀ n (r x))
∙ (spoke n -1 r x)
∙ (! (spoke n -1 r norₙ') ∙ fₙ-x₀ n (r norₙ'))
{- The statement that k == ap pₙ ∘ h: -}
k-p-h : k == ap (point S n -1) ∘ h
k-p-h = λ= (λ (x : Sphere' {i} n)
→ k x
=⟨ idp ⟩
! (Point (r x))
∙ (ap (point (S n) -1) (spoke n -1 r x) ∙ (Hub r))
=⟨ !-ap (point S n -1) (fₙ-x₀ n (r x))
∙ᵣ ( ap (point S n -1) (spoke n -1 r x)
∙ Hub r) ⟩
ap (point (S n) -1) (! (fₙ-x₀ n (r x)))
∙ ap (point (S n) -1) (spoke n -1 r x)
∙ (Hub r)
=⟨ ! (ap (point (S n) -1) (! (fₙ-x₀ n (r x)))
∙ₗ ap-∙ point S n -1
(spoke n -1 r x)
_ ) ⟩
ap (point (S n) -1) (! (fₙ-x₀ n (r x)))
∙ ap (point (S n) -1)
( spoke n -1 r x
∙ (! (spoke n -1 r norₙ')
∙ fₙ-x₀ n (r norₙ')))
=⟨ ! (ap-∙ point S n -1 (! (fₙ-x₀ n (r x))) _) ⟩
ap (point S n -1) (h x)
∎)
{- [h] can be made into a a pointed map, written [ĥ] -}
ĥ : (⊙Sphere' {i} n)
→̇ ⊙Ω (A (S n) ,
f n fⁿx₀)
ĥ = h ,
(! (fₙ-x₀ n (r _))
∙ (spoke n -1 r _)
∙ ! (spoke n -1 r norₙ')
∙ fₙ-x₀ n (r norₙ')
=⟨ (! (fₙ-x₀ n (r _)))
∙ₗ (! (∙-assoc (spoke n -1 r _)
(! (spoke n -1 r norₙ'))
(fₙ-x₀ n (r norₙ')))) ⟩
! (fₙ-x₀ n (r _))
∙ ((spoke n -1 r _) ∙ (! (spoke n -1 r norₙ')))
∙ fₙ-x₀ n (r norₙ')
=⟨ ! (fₙ-x₀ n (r _))
∙ₗ !-inv-r (spoke n -1 r _)
∙ᵣ fₙ-x₀ n (r norₙ') ⟩
! (fₙ-x₀ n (r _))
∙ idp
∙ fₙ-x₀ n (r norₙ')
=⟨ !-inv-l (fₙ-x₀ n (r _)) ⟩
idp
∎ )
{- A pointed version of the first constructor. -}
pointsₙ : (A (S n) , f n fⁿx₀) →̇ A (S (S n)) , f (S n) (f n fⁿx₀)
pointsₙ = point S n -1 , idp
open null
open hom-adjoint
points-Φ⁻¹-null : isNull∙ (pointsₙ ⊙∘ Φ⁻¹ _ _ ĥ)
points-Φ⁻¹-null = <– (isNull-equiv (pointsₙ ⊙∘ Φ⁻¹ _ _ ĥ))
-- translate from isNull∙'
(null-lequiv (pointsₙ ⊙∘ Φ⁻¹ _ _ ĥ)
-- translate from isNulld; this,
-- we have done already!
(cmp-nll'.from-sphere-null'∙ n (Φ⁻¹ _ _ ĥ)))
ap-points-ĥ-null : isNull∙ (⊙ap (point S n -1 , idp) ⊙∘ ĥ)
ap-points-ĥ-null = –> (combine-isnull-nat' ĥ (point S n -1 , idp)) points-Φ⁻¹-null
{- ... consequently, h is always refl [in the library "idp"]: -}
points-h-const : (x : Sphere' n) → ap (point S n -1) (h x) == idp
points-h-const x = null-lequiv-easy _ ap-points-ĥ-null x
{- ... and so is k: -}
k-const : (x : Sphere' n) → k x == idp
k-const x = app= k-p-h x ∙ points-h-const x
{- Main result: each function in the sequence is propositional! -}
wconst-f : wconst-chain C
wconst-f n w₁ w₂ = fₙ-x₀ n w₁ ∙ ! (fₙ-x₀ n w₂)
{- Another important result:
if we want to show a proposition, we can assume A₀ instead of Aω
But this should follow from the general induction principle, so... TODO
-}
module PtruncSeqResult' {i} (X : Type i) where
open PtruncsSeq {i} X -- this defines the chain C of pseudo-truncations
SC = SeqCo C
reduction-lemma : (P : Type i) → (is-prop P) → (A O → P) → (SC → P)
reduction-lemma P ip ff = SeqCo-rec {C = C} {B = P} Ins Glue where
Ins : (n : ℕ) → A n → P
Ins O = ff
Ins (S n) = Pseudotrunc-rec {P = P} n Point-1 Hub-1 Spoke-1 where
Point-1 : _ → P
Point-1 x = Ins n x
Hub-1 : (Sphere' n → A n) → P
Hub-1 r = Ins n (r (nor' n))
Spoke-1 : (r : Sphere' n → A n) (x : Sphere' n) → Point-1 (r x) == Hub-1 r
Spoke-1 r x = prop-has-all-paths {A = P} ip _ _
Glue : (n : ℕ) (a : A n) → Ins n a == Ins (S n) (f n a)
Glue n a = prop-has-all-paths ip _ _
{- Corollary of the main result: The colimit of the considered sequence is propositional! -}
module PtruncSeqResult {i} (X : Type i) where
open PtruncsSeq {i} X -- this defines the chain C of pseudo-truncations
colim-is-prp : is-prop (SeqCo C)
colim-is-prp =
inhab-to-contr-is-prop
(PtruncSeqResult'.reduction-lemma X (is-contr (SeqCo C)) has-level-is-prop
(λ x₀ → ins O x₀ , prop-has-all-paths (wconst-prop C (PtruncSeqWC.wconst-f X x₀))
(ins O x₀)))
open PtruncSeqResult' X
{- If we have the propositional truncation in the theory: -}
open import lib.types.Truncation
colim-is-trunc : (Trunc ⟨-1⟩ X) ≃ SeqCo C
colim-is-trunc = equiv (Trunc-rec (colim-is-prp) (ins 0))
(reduction-lemma (Trunc ⟨-1⟩ X) Trunc-level [_])
(λ _ → prop-has-all-paths colim-is-prp _ _)
(λ _ → prop-has-all-paths Trunc-level _ _)
|
Library/Sound/soundCommon.asm | steakknife/pcgeos | 504 | 18991 | <reponame>steakknife/pcgeos<filename>Library/Sound/soundCommon.asm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) GeoWorks 1992 -- All Rights Reserved
PROJECT: PC GEOS Sound system
FILE: soundCommon.asm
AUTHOR: <NAME>, Aug 3, 1992
ROUTINES:
Name Description
---- -----------
global SoundEntry Sets up library
intern SoundAttachLibrary Load library into system
intern SoundDetachLibrary Remove Library from system
intern SoundNewClient A new process uses the library
intern SoundNewClientThread A new thread of a process was created
intern SoundThreadExit A thread using the library has exited
intern SoundExit A process using the library has exited
global
REVISION HISTORY:
Name Date Description
---- ---- -----------
TS 8/ 3/92 Initial revision
TS 9/23/92 Changed for simplified interface
DESCRIPTION:
These are the library routines for sound library for PC/GEOS.
$Id: soundCommon.asm,v 1.1 97/04/07 10:46:31 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
include product.def
udata segment
; All driver routines invoked by the library are done so by
; loading the driver function you wish to execute in di and then
; calling the strategy routine of the driver. The strategy
; routine is the first element in the DriverInfo struct.
;
soundSynthStrategy fptr ; sound driver strategy fptr
soundSynthHandle hptr ; handle for synth driver
streamStrategy fptr ; stream driver strategy fptr
; Each driver will require stream-specific information (what
; the current controller values are, what instruments are
; assigned to which channel, etc. This storage space is
; appended to the end of the SoundStreamStatus structure.
; To keep from querying the driver constantly, we query it
; at start up and store it here.
driverVoices word ; # of voice on device
driverDACs word ; # of dacs on device
driverVoiceFormat SupportedInstrumentFormat
driverCapability SoundDriverCapability
driverDACCapability SoundDriverDACCapability
; We can't let an application grab excusive access
; until all the threads are out of the library routines.
libraryAccess word
exclusiveAccess word
;
; Inorder to use the UI, and not get into a problem where
; the UI needs the sound library to loaded first,
; and the sound library needs the UI to be loaded
; first, we load the UI ourselves, after we have
; been loaded, but before anyone else can do anything...
userInterfaceHandle word
udata ends
idata segment
exclusiveSemaphore Semaphore <1,> ; mutEx for get excluisve code
librarySemaphore Semaphore <1,> ; mutEx for library
idata ends
InitCode segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SoundEntry
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Call driver to initialize the sound board
CALLED BY: global
PASS: di -> LibraryCallType
cx -> handle of client geode if LCT_NEW_CLIENT or
LCT_CLIENT_EXIT
ds -> dgroup
RETURN: carry set on error
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
call appropriate routine
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
TS 8/ 4/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SoundEntry proc far
uses di
.enter
shl di,1 ; index words (nptr actually..)
call cs:LibraryCallJumpTable[di]
.leave
ret
SoundEntry endp
LibraryCallJumpTable nptr SoundAttachLibrary,
SoundDetachLibrary,
SoundNewClient,
SoundNewClientThread,
SoundThreadExit,
SoundExit
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SoundAttachLibrary
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Load the driver and set up the system stream
CALLED BY: SoundEntry
PASS: ds -> dgroup
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
loads the standard sound driver and creates
a system stream.
PSEUDO CODE/STRATEGY:
When we first get set up, we need to contact the
driver and see what its capabilities are and how much
information it has.
We also need to set up the exclusive access semaphore
REVISION HISTORY:
Name Date Description
---- ---- -----------
TS 9/ 8/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SoundAttachLibrary proc near
uses ax,bx,cx,dx,si,di,bp
.enter
; Now, we need to load the selected sound drivers.
; The current selections are probably stored in the
; .ini file. If they are not, we use the standard
; PC/Speaker driver, and don't load any DAC driver.
call SoundGetDrivers ; load driver
jc chokeChokeChoke ; damn. an error.
;
; With that, we need to query the drivers as to their
; capabilities so we know how many voices
; and DACs they support, as well as the quality
; of the sound they produces.
; To help support different types of DACs (like
; DMA vs FIFO), we also let the drivers
; specify a particular stream driver to
; use. This allows the Sound Blaster to
; customize its stream driver for the
; utmost speed, while letting others
; use the regular stream driver.
mov di, DRE_SOUND_QUERY_DEVICE_CAPABILITY
call ds:[soundSynthStrategy]
mov ds:[driverVoices], ax ; store # of voices
mov ds:[driverVoiceFormat], bx
mov ds:[driverCapability], cx ; store capabilities
mov ds:[driverDACs], dx ; store # of DACs
mov ds:[driverDACCapability], di ; store DAC capability
cmpdw bpsi, 0
jnz storeSampleStreamStrategy
mov bp, segment StreamStrategy ; bp:si <- default
mov si, offset StreamStrategy
storeSampleStreamStrategy:
movdw ds:[streamStrategy], bpsi ; store stream strat
;
; The voice allocation depends upon the # of
; voices the driver supports. Thus, we need to
; set it up, now that we know how many voices there
; are.
call SoundVoiceInitialize ; set up voice nodes
jc chokeChokeChoke
ifdef GPC_VERSION
; mov ax, (10h shl 8) or 10h ; set volume to medium
call ReadInitFileForSettingMasterVolume
endif
done:
clc
.leave
ret
chokeChokeChoke:
;
; Ok. We have had an error loading the sound driver.
; What we want to do is make sure no one tries to get
; ahold of the non-existant driver.
; To do this, we just P the mutEx semaphore for the
; driver and return.
PSem ds, exclusiveSemaphore, TRASH_AX_BX
mov ds:[exclusiveAccess], 1
stc
jmp short done
SoundAttachLibrary endp
ifdef GPC_VERSION
;
; Read from the ini file for the volume and balance setting, then
; set the sound mixer master volume.
; Pass: none
; Return: none
;
soundCat char "sound",0
volume char "volume", 0
balance char "balance", 0
ReadInitFileForSettingMasterVolume proc near
uses ds,ax,bx,cx,dx,si,di,bp
.enter
segmov ds, cs, cx
mov si, offset soundCat
mov dx, offset volume
call InitFileReadInteger ; ax
jnc ok
; No key found.
; So set default volume: MIXER_LVL_MAX / 2
mov ax, MIXER_LVL_MAX / 2
ok:
push ax
mov dx, offset balance
call InitFileReadInteger ; ax
jnc ok2
; No balance found.
; set default balance: SOUND_BALANCE_MAX / 2
mov ax, SOUND_BALANCE_MAX / 2
ok2:
; ax - balance
pop dx ; dx - volume
mov cx, dx ; cx - volume
; Fixing channel volume strategy:
; Multiply the "other" channel volume by the balance value that
; the user selected in the balance UI gadget, divide by MAX/2.
; The selected value is between 0 and MAX/2.
; Don't bother rounding off.
cmp ax, SOUND_BALANCE_MAX / 2
ja fixLeftChannel
fixRightChannel::
mul dl ; ax = vol * bal
mov cl, SOUND_BALANCE_MAX / 2
div cl ; al = vol * (bal / (MAX/2))
mov ah, al
mov al, dl
jmp done
fixLeftChannel:
sub al, SOUND_BALANCE_MAX
neg al ; al = bal
mul dl ; ax = vol * bal
mov cl, SOUND_BALANCE_MAX / 2
div cl ; al = vol * (bal / (MAX/2))
mov ah, dl
done:
; al - left channel volume,
; ah - right channel volume.
call SoundMixerSetMasterVolume
.leave
ret
ReadInitFileForSettingMasterVolume endp
endif
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SoundGetDrivers
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Examine the .ini file and get the current sound drivers
CALLED BY: SoundAttachLibrary
PASS: nothing
RETURN: carry set on error
DESTROYED: nothing
SIDE EFFECTS:
sets driverStrategys in dgroup
PSEUDO CODE/STRATEGY:
look in .ini file
create category if not there
if there, read current driver
load driver
save routine
return
REVISION HISTORY:
Name Date Description
---- ---- -----------
TS 10/21/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
soundDriverCategory char "sound",0
soundSynthDriverKey char "synthDriver",0
if DBCS_PCGEOS
soundDriverDir wchar "sound",0
endif
LocalDefNLString soundDefaultDriver <"standard.geo",0>
SoundGetDrivers proc near
uses ax, bx, cx, dx, di, si, ds, es, bp
driverNameBuffer local FileLongName
.enter
push bp ; save bp for later
call FILEPUSHDIR ; save current dir
;
; Move dir to ../SYSTEM/SOUND
segmov ds, cs, si ; ds:dx <- path name
mov bx, SP_SYSTEM ; start in system dir
SBCS < mov dx, offset soundDriverCategory ; move to SYSTEM/SOUND >
DBCS < mov dx, offset soundDriverDir ; move to SYSTEM/SOUND >
call FileSetCurrentPath
NOFXIP <LONG jc done ; error moving to directory
;
; Attempt to load the Driver for Synthesized sound
;
;
; Set es:di to point to base of driverNameBuffer
mov di, ss ; es:di <- driverNameBuffer
mov es, di
mov di, bp ; di <- base of frame
add di, offset driverNameBuffer ; di <- offset to buffer
;
; Read Category/Key value for driver
push bp
mov si, offset soundDriverCategory ; ds:si <- category asciiz
mov cx, cs ; cx:dx <- key asciiz
mov dx, offset soundSynthDriverKey
mov bp, InitFileReadFlags <IFCC_INTACT,,,size driverNameBuffer>
call InitFileReadString ; read driver name
pop bp
LONG jc loadStandardSynthDriver
;
; Load in the given sound driver and
; determine its strategy routine.
; Save a fptr to the routine in dgroup
segmov ds, es, si ; ds:si <- driver name
mov si, di ; ds:si <- name of driver
clr ax ; who cares what ver.
clr bx
call GeodeUseDriver ; get it
jc loadStandardSynthDriver ; pass carry back
; if error loading
readStrategyRoutine:
call GeodeInfoDriver ; ds:si <- DriverInfoStruct
mov ax, segment dgroup ; es <- dgroup of library
mov es, ax
; copy the far pointer
movdw es:[soundSynthStrategy],ds:[si].DIS_strategy, ax
mov es:[soundSynthHandle], bx
clc ; everything ok
done:
; flags preserved across popdir
call FILEPOPDIR ; return to old dir
pop bp ; restore bp
.leave
ret
loadStandardSynthDriver:
;
; Either there was not category, or the category was corrupted,
; or the file specified in the catagory did not exists.
; In any event, we want to load the standard.geo driver
; for PC-SPEAKER. Hopefully that's here.
segmov ds, cs, si ; ds:si <- driver name
mov si, offset soundDefaultDriver
mov ax, SOUND_PROTO_MAJOR ; get latest version
mov bx, SOUND_PROTO_MINOR
call GeodeUseDriver
jc done ; was there an error?
jmp readStrategyRoutine
SoundGetDrivers endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SoundDetachLibrary
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Free up the voices we previously allocated
CALLED BY: SoundEntry
PASS: ds -> dgroup of library
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
frees up fixed memory
PSEUDO CODE/STRATEGY:
let voice manager clean itself up.
REVISION HISTORY:
Name Date Description
---- ---- -----------
TS 9/ 8/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SoundDetachLibrary proc near
.enter
;
; Remove voice list
call SoundVoiceDetach ; free up voice nodes
if 0
; Because the sound library doesn't get unloaded until GEOS gets
; unloaded, and GEOS unloads with a very heavy hand, it is possible
; that the kernel has already unloaded the sound drivers "for us",
; and if we try to do so as well, we die with HANDLE_FREE.
; This is somewhat related to the UI death below.
; -- todd 05/20/93
;
; Free up synth driver
mov bx, ds:[soundSynthHandle]
tst bx
jz UI
call GeodeFreeDriver
freeUI:
;
; Free up UI
mov bx, ds:[userInterfaceHandle]
tst bx
jz done
call GeodeFreeLibrary
endif
done::
.leave
ret
SoundDetachLibrary endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SoundNewClient
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Called when a new client is created. Deal with it.
CALLED BY: SoundEntry
PASS: nothing
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
none
PSEUDO CODE/STRATEGY:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
TS 9/ 8/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SoundNewClient proc near
.enter
clc
.leave
ret
SoundNewClient endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SoundNewClientThread
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Called when a new thread is created. Deal with it.
CALLED BY: SoundEntry
PASS: ds -> dgroup
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
calls GeodeUseLib on UI
PSEUDO CODE/STRATEGY:
We need to be able to send a message to the UI,
so we need to get at its process thread. The
trick is, we can't actually put a library clause
in our .gp file becuase the UI has a library sound
clause in its .gp file and that causes a circular
recursion problem that kills the system.
So, what we do is wait until the UI has been loaded,
and we have been notified alla SoundNewClient, and
such.
Then, when it tires to create the first UI thread,
it calls this routine and we "load" the UI and
gets its handle.
Armed with this and a call to ProcInfo, we can
get the the UI's thread ID and send it messages.
Believe me, it wasn't easy. -- todd
REVISION HISTORY:
Name Date Description
---- ---- -----------
TS 9/ 8/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
EC <LocalDefNLString userName <"uiec.geo",0> >
NEC <LocalDefNLString userName <"ui.geo",0> >
SoundNewClientThread proc near
.enter
tst ds:[userInterfaceHandle]
jnz done
push ax, bx, si
push ds
segmov ds, cs, ax
mov si, offset userName
clr ax
clr bx
call GeodeUseLibrary
jc error
pop ds
mov ds:[userInterfaceHandle], bx
doneError:
pop ax, bx, si
done:
.leave
ret
error:
;
; We had an error loading the UI. This is bad.
; mark the thread as unsupported.
stc
EC< ERROR -1 >
NEC < pop ds >
NEC< jmp doneError >
SoundNewClientThread endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SoundThreadExit
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Called when a thread is done. Deal with it.
CALLED BY: SoundEntry
PASS: nothing
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
TS 9/ 8/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SoundThreadExit proc near
.enter
clc
.leave
ret
SoundThreadExit endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SoundExit
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: A Client Process has exited. Deal with it.
CALLED BY: SoundEntry
PASS: nothing
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
none
PSEUDO CODE/STRATEGY:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
TS 9/ 8/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SoundExit proc near
.enter
clc
.leave
ret
SoundExit endp
InitCode ends
CommonCode segment resource
;-----------------------------------------------------------------------------
;
; SIMPLE FM ROUTINES
;
;-----------------------------------------------------------------------------
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SoundAllocMusic
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Allocate a SoundControl block to play FM sounds
CALLED BY: GLOBAL
PASS: bx:si -> far ptr to buffer
cx -> # of voices used by buffer
(Use SoundPlayMusic to play)
- or -
^lbx:si -> handle:chunk for buffer if in lmem heap
cx -> # of voices used by buffer
(Use SoundPlayMusicLMem to play)
RETURN: carry clear
bx <- handle to SoundControl (owned by calling thread)
ax destroyed
- or -
carry set
ax <- SOUND_ERROR reason for refusal
bx destroyed
DESTROYED: see above
SIDE EFFECTS:
possible errors and causes include:
SOUND_ERROR_OUT_OF_MEMORY
The library tried to do a memory allocation,
but failed.
PSEUDO CODE/STRATEGY:
call driver routine
REVISION HISTORY:
Name Date Description
---- ---- -----------
TS 9/29/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SoundAllocMusic proc far
uses di
.enter
mov di, DR_SOUND_ALLOC_MUSIC
call SoundLibDriverStrategy
.leave
ret
SoundAllocMusic endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SoundAllocMusicStream
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Allocate a stream to play FM sounds on
CALLED BY: GLOBAL
PASS: ax -> SoundStreamSize
bx -> starting priority for sound
cx -> # of voices for sound
dx -> starting tempo for sound
RETURN: carry clear
bx <- handle to SoundControl (owned by calling thread)
ax destroyed
- or -
carry set
ax <- SOUND_ERROR reason for failure
bx destroyed
DESTROYED: see above
SIDE EFFECTS:
allocates space on global heap
allocates stream
PSEUDO CODE/STRATEGY:
call driver
REVISION HISTORY:
Name Date Description
---- ---- -----------
TS 10/29/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SoundAllocMusicStream proc far
uses di
.enter
mov di, DR_SOUND_ALLOC_MUSIC_STREAM
call SoundCallLibraryDriverRoutine
.leave
ret
SoundAllocMusicStream endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SoundAllocMusicNote
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Allocate a note and return its handle
CALLED BY: GLOBAL
PASS: bx -> instrument table seg. (zero for system default)
si -> instrument # for note
ax -> frequency
cx -> volume
dx -> SoundStreamDeltaTimeType
di -> duration (in DeltaTimerType units)
RETURN: carry clear
bx <- token for sound (owned by calling thread)
ax destroyed
- or -
ax <- SOUND_ERROR reason for failure
bx destroyed
DESTROYED: nothing
SIDE EFFECTS:
could allocate space on the global heap
PSEUDO CODE/STRATEGY:
call driver routine
REVISION HISTORY:
Name Date Description
---- ---- -----------
TS 9/29/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SoundAllocMusicNote proc far
uses di, bp
.enter
mov bp, di ; bp <- timer interval
mov di, DR_SOUND_ALLOC_MUSIC_NOTE
call SoundCallLibraryDriverRoutine
.leave
ret
SoundAllocMusicNote endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SoundPlayMusic
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Play a simple FM sound
CALLED BY: GLOBAL
PASS: bx -> handle for SoundControl
ax -> starting priority for sound
cx -> starting tempo setting for sound
dl -> EndOfSongFlags for sound
RETURN: carry clear
ax destroyed
- or -
carry set
ax <- SOUND_ERROR reason for failure
DESTROYED: nothing
SIDE EFFECTS:
If the simple sound is currently playing, it will
be re-started at the beginning of the song with the
new tempo and priority.
PSEUDO CODE/STRATEGY:
check the mutEx semaphore
call the driver routine
REVISION HISTORY:
Name Date Description
---- ---- -----------
TS 9/29/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SoundPlayMusic proc far
uses di
.enter
mov di, DR_SOUND_PLAY_MUSIC
call SoundCallLibraryDriverRoutine
.leave
ret
SoundPlayMusic endp
if _FXIP
CommonCode ends
ResidentCode segment resource
endif
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SoundPlayToMusicStream
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Play an FM Sound to a Stream
CALLED BY: GLOBAL
PASS: bx -> handle for SoundControl
dx:si -> start of event buffer to write to sound stream
cx -> bytes in buffer (zero if unknown)
NOTE: Every buffer written to the stream must
be made of whole events. It is not possible
to break events between two writes to the
stream, but it is ok to have a buffer end
with an event and begin with a deltaEvent.
Similarly, you can end with a deltaEvent and
start with a soundEvent.
Also, if the size of the buffer is unknown,
all the events up to the first GE_END_OF_SONG
event will be written to the stream. Any
remaining data will be ignored.
A stream of unknown size must have a GE_END_OF_SONG.
A stream of known size need not end in GE_END_OF_SONG.
RETURN: carry clear
ax destroyed
- or -
carry set
ax <- SOUND_ERROR reason for failure
DESTROYED: nothing
SIDE EFFECTS:
none
PSEUDO CODE/STRATEGY:
check exclusive lock
call driver
REVISION HISTORY:
Name Date Description
---- ---- -----------
TS 10/29/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SoundPlayToMusicStream proc far
uses di
.enter
mov di, DR_SOUND_PLAY_TO_MUSIC_STREAM
call SoundLibDriverStrategy
.leave
ret
SoundPlayToMusicStream endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SoundPlayToMusicStreamNB
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Play an FM Sound to a Stream
CALLED BY: GLOBAL
PASS: bx -> handle for SoundControl
dx:si -> start of event buffer to write to sound stream
cx -> bytes in buffer (zero if unknown)
NOTE: Every buffer written to the stream must
be made of whole events. It is not possible
to break events between two writes to the
stream, but it is ok to have a buffer end
with an event and begin with a deltaEvent.
Similarly, you can end with a deltaEvent and
start with a soundEvent.
Also, if the size of the buffer is unknown,
all the events up to the first GE_END_OF_SONG
event will be written to the stream. Any
remaining data will be ignored.
A stream of unknown size must have a GE_END_OF_SONG.
A stream of known size need not end in GE_END_OF_SONG.
RETURN: cx <- # of bytes written
carry clear
ax destroyed
- or -
carry set
ax <- SoundWriteStreamStatus
DESTROYED: ax
SIDE EFFECTS:
none
PSEUDO CODE/STRATEGY:
check exclusive lock
call driver
REVISION HISTORY:
Name Date Description
---- ---- -----------
TS 10/29/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SoundPlayToMusicStreamNB proc far
uses di
.enter
mov di, DR_SOUND_PLAY_TO_MUSIC_STREAM_NB
call SoundLibDriverStrategy
.leave
ret
SoundPlayToMusicStreamNB endp
if _FXIP
ResidentCode ends
CommonCode segment resource
endif
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SoundStopMusic
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Stop a simple stream
CALLED BY: GLOBAL
PASS: bx -> handle of SoundControl
RETURN: carry clear
ax destroyed
- or -
carry set
ax <- SOUND_ERROR reason for failure
DESTROYED: see above
SIDE EFFECTS:
Stops the simple piece. All voices are turned off.
Triggers EndOfSongFlags
PSEUDO CODE/STRATEGY:
check mutEx semaphore
call driver routine
REVISION HISTORY:
Name Date Description
---- ---- -----------
TS 9/29/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SoundStopMusic proc far
uses di
.enter
mov di, DR_SOUND_STOP_MUSIC
call SoundCallLibraryDriverRoutine
.leave
ret
SoundStopMusic endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SoundStopMusicStream
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Stop an FM stream
CALLED BY: GLOBAL
PASS: bx -> handle for SoundControl
RETURN: carry clear
ax destroyed
- or -
carry set
ax <- SOUND_ERROR reason for failure
DESTROYED: see above
SIDE EFFECTS:
Stops the stream.
All sounds are flushed from stream
PSEUDO CODE/STRATEGY:
check exclusive access
call driver
REVISION HISTORY:
Name Date Description
---- ---- -----------
TS 10/29/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SoundStopMusicStream proc far
uses di
.enter
mov di, DR_SOUND_STOP_MUSIC_STREAM
call SoundCallLibraryDriverRoutine
.leave
ret
SoundStopMusicStream endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SoundReallocMusic
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Change the song setting for a simple stream
CALLED BY: GLOBAL
PASS: bx -> handle for SoundControl
ds:si -> new sound buffer
RETURN: carry clear
ax destroyed
- or -
carry set
ax <- SOUND_ERROR reason for failure
DESTROYED: nothing
SIDE EFFECTS:
Re-starts a simple stream playing on a new sound buffer,
but leaves the voices in the state they were at the end
of the last song. Thus, this allows someone to play a
very long song by breaking it up into smaller buffers.
NOTE: Each buffer section must still end with and
END_OF_SONG
PSEUDO CODE/STRATEGY:
check mutEx
call driver function
REVISION HISTORY:
Name Date Description
---- ---- -----------
TS 9/29/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SoundReallocMusic proc far
uses di
.enter
mov di, DR_SOUND_REALLOC_MUSIC
call SoundCallLibraryDriverRoutine
.leave
ret
SoundReallocMusic endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SoundReallocMusicLMem
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Change the song setting for a simple stream
CALLED BY: GLOBAL
PASS: bx -> handle for SoundControl
^ldx:si -> new sound buffer
RETURN: carry clear
ax destroyed
- or -
carry set
ax <- SOUND_ERROR reason for failure
DESTROYED: nothing
SIDE EFFECTS:
Re-starts a simple stream playing on a new sound buffer,
but leaves the voices in the state they were at the end
of the last song. Thus, this allows someone to play a
very long song by breaking it up into smaller buffers.
NOTE: Each buffer section must still end with and
END_OF_SONG
PSEUDO CODE/STRATEGY:
check mutEx
call driver function
REVISION HISTORY:
Name Date Description
---- ---- -----------
TS 9/29/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SoundReallocMusicLMem proc far
uses di
.enter
mov di, DR_SOUND_REALLOC_MUSIC_LMEM
call SoundCallLibraryDriverRoutine
.leave
ret
SoundReallocMusicLMem endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SoundReallocMusicNote
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Change the settings for a note
CALLED BY: GLOBAL
PASS: bx -> handle for SoundControl
ax -> frequnecy for note
cx -> volume for note
dx -> timer type
di -> timer value
ds:si -> new instrument setting
RETURN: carry clear
ax destroyed
- or -
carry set
ax <- SOUND_ERROR reason for failure
DESTROYED: see above
SIDE EFFECTS:
locks and unlocks block on global heap
PSEUDO CODE/STRATEGY:
* You must stop the note before reallocating *
check mutEx semaphore
lock down block
make changes
unlock block
REVISION HISTORY:
Name Date Description
---- ---- -----------
TS 9/29/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SoundReallocMusicNote proc far
uses bp, di
.enter
mov bp, di ; bp <- timer value
mov di, DR_SOUND_REALLOC_MUSIC_NOTE
call SoundCallLibraryDriverRoutine
.leave
ret
SoundReallocMusicNote endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SoundFreeMusic
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Free up a simple FM sound stream
CALLED BY: GLOBAL
PASS: bx -> handle for SoundControl
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
frees up a block on the global heap
PSEUDO CODE/STRATEGY:
call driver routine
REVISION HISTORY:
Name Date Description
---- ---- -----------
TS 9/29/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SoundFreeMusic proc far
uses di
.enter
mov di, DR_SOUND_FREE_SIMPLE
call SoundLibDriverStrategy
.leave
ret
SoundFreeMusic endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SoundFreeMusicStream
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Free an FM sound stream
CALLED BY: GLOBAL
PASS: bx -> handle for SoundControl
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
flushes the stream, frees up the stream
frees up the block on the global heap
PSEUDO CODE/STRATEGY:
call driver
REVISION HISTORY:
Name Date Description
---- ---- -----------
TS 10/29/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SoundFreeMusicStream proc far
uses di
.enter
mov di, DR_SOUND_FREE_STREAM
call SoundLibDriverStrategy
.leave
ret
SoundFreeMusicStream endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SoundInitMusic
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Initialize a pre-defined simple FM sound structure
CALLED BY: GLOBAL
PASS: bx -> handle to block with empty SoundControl
cx -> # of voices for sound
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
initialize the sound structure
initialize the voices
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
TS 10/21/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SoundInitMusic proc far
uses ax, cx, dx, si, di
.enter
;
; Calculate offset to song in block
mov ax, size SoundVoiceStatus ; al <- size of 1 voice
mul cx ; ax <- size of voices
add ax, size SoundControl ; ax <- offset to song
mov si, ax ; si <- offset to song
;
; SoundLibDriverInitSimple expects the block to
; be locked when it recieves it.
call MemLock ; ax <- segment, bx <- handle
EC< ERROR_C SOUND_CONTROL_BLOCK_IN_DISCARDED_RESOURCE >
clr dx ; mark as in block
mov di, DR_SOUND_INIT_MUSIC
call SoundLibDriverStrategy ; init the sound
call MemUnlock ; free up the block
done::
.leave
ret
SoundInitMusic endp
;-----------------------------------------------------------------------------
;
; SOUND MAINTENANCE AND ADMINISTRATION ROUTINES
;
;-----------------------------------------------------------------------------
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SoundChangeOwnerSimple
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Change the owner of a sound
CALLED BY: GLOBAL
PASS: bx -> handle of SoundControl
ax -> handle of new owner for sound
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
alters ownership of the block itself as well
as any semaphores.
PSEUDO CODE/STRATEGY:
call the driver routine
REVISION HISTORY:
Name Date Description
---- ---- -----------
TS 10/ 7/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SoundChangeOwnerMusic proc far
uses di
.enter
mov di, DR_SOUND_CHANGE_OWNER_SIMPLE
call SoundLibDriverStrategy
.leave
ret
SoundChangeOwnerMusic endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SoundChangeOwnerStream
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Change the Owner of a sound Stream
CALLED BY: GLOBAL
PASS: bx -> handle of SoundControl
ax -> handle of new owner for sound
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
alters ownership of the block itself as well
as any semaphores.
PSEUDO CODE/STRATEGY:
call the driver
REVISION HISTORY:
Name Date Description
---- ---- -----------
TS 10/29/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SoundChangeOwnerStream proc far
uses di
.enter
mov di, DR_SOUND_CHANGE_OWNER_STREAM
call SoundLibDriverStrategy
.leave
ret
SoundChangeOwnerStream endp
;-----------------------------------------------------------------------------
;
; DAC Sound Routines
;
;-----------------------------------------------------------------------------
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SoundAllocSampleStream
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Allocate a sound handle for the sound
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry clear
bx <- handle of SoundControl
ax destroyed
- or -
carry set
ax <- SOUND_ERROR reason for failure
bx destroyed
DESTROYED: see above
SIDE EFFECTS:
check mutEx
allocates a handle for Sound
allocates semaphores
PSEUDO CODE/STRATEGY:
call driver
REVISION HISTORY:
Name Date Description
---- ---- -----------
TS 11/10/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SoundAllocSampleStream proc far
uses di
.enter
mov di, DR_SOUND_ALLOC_SAMPLE_STREAM
call SoundCallLibraryDriverRoutine
.leave
ret
SoundAllocSampleStream endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SoundEnableSampleStream
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Associate a real DAC to Sound
CALLED BY: GLOBAL
PASS: bx -> handle of SoundControl
ax -> priority for DAC (SoundPriority)
cx -> rate for sample
dx -> ManufacturerID of sample
si -> SampleFormat of sample
RETURN: carry clear
ax destroyed
- or -
carry set
ax <- SOUND_ERROR reason for failure
DESTROYED: nothing
SIDE EFFECTS:
allocates stream
contacts device driver and a attach DAC to stream
PSEUDO CODE/STRATEGY:
check exclusive access to driver
call driver
REVISION HISTORY:
Name Date Description
---- ---- -----------
TS 11/18/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SoundEnableSampleStream proc far
uses di
.enter
mov di, DR_SOUND_ENABLE_SAMPLE_STREAM
call SoundCallLibraryDriverRoutine
.leave
ret
SoundEnableSampleStream endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SoundDisableSampleStream
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Removes association of DAC and Sound
CALLED BY: GLOBAL
PASS: bx -> handle for SoundControl
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
contacts device driver and dettaches DAC from stream
frees stream
PSEUDO CODE/STRATEGY:
call driver
REVISION HISTORY:
Name Date Description
---- ---- -----------
TS 11/18/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SoundDisableSampleStream proc far
uses di
.enter
mov di, DR_SOUND_DISABLE_SAMPLE_STREAM
call SoundLibDriverStrategy
.leave
ret
SoundDisableSampleStream endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SoundFreeSampleStream
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Frees up the Sound structure of the sound
CALLED BY: GLOBAL
PASS: bx -> handle of SoundControl
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
frees up a block
frees up semaphore handles
PSEUDO CODE/STRATEGY:
We can't check for exclusives as an application
may be trying to exit.
REVISION HISTORY:
Name Date Description
---- ---- -----------
TS 11/10/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SoundFreeSampleStream proc far
uses di
.enter
mov di, DR_SOUND_FREE_SAMPLE_STREAM
call SoundLibDriverStrategy
.leave
ret
SoundFreeSampleStream endp
if _FXIP
CommonCode ends
ResidentCode segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SoundPlayToSampleStream
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Play a given piece of DAC data to the DAC
CALLED BY: GLOBAL
PASS: bx = handle of SoundControl
dx:si = buffer of DAX data to put on stream
cx = length of buffer (in bytes)
ax:bp = SampleFormatDescription of buffer
RETURN: carry clear
ax destroyed
- or -
carry set
ax = SOUND_ERROR reason for failure
DESTROYED: nothing
SIDE EFFECTS:
gives the DAC something to play
blocks on writing to stream
PSEUDO CODE/STRATEGY:
call driver
REVISION HISTORY:
Name Date Description
---- ---- -----------
TS 11/10/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SoundPlayToSampleStream proc far
uses bx, dx, di, si, ds
.enter
mov di, bx ; di = SoundControl
mov ds, dx ; ds:si = event buffer
call SysCopyToBlock ; ^hbx = block
; ds:si = copied event buffer
jc outOfMemory
mov dx, ds ; dx:si = copied event buffer
push bx ; save block handle
mov bx, di ; ^hbx = SoundControl
call SoundPlayToSampleStreamReal
pop bx
call MemFree
exit:
.leave
ret
outOfMemory:
mov ax, SOUND_ERROR_OUT_OF_MEMORY
jmp short exit
SoundPlayToSampleStream endp
ResidentCode ends
CommonCode segment resource
else
SoundPlayToSampleStream proc far
FALL_THRU SoundPlayToSampleStreamReal
SoundPlayToSampleStream endp
endif
SoundPlayToSampleStreamReal proc far
uses di
.enter
mov di, DR_SOUND_PLAY_TO_SAMPLE_STREAM
call SoundCallLibraryDriverRoutine
.leave
ret
SoundPlayToSampleStreamReal endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SoundCallLibraryDriverRoutine
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Call library driver routine
CALLED BY: Everything. Almost.
;PASS: di -> driver routine to call
others -> see specific routine
RETURN: carry clear
ax destroyed
bx,cx,dx,si,di,bp,es,ds as routine
- or -
carry set
di destroyed
ax <- SOUND_ERROR reason for failure
DESTROYED: see above
SIDE EFFECTS:
calls driver
PSEUDO CODE/STRATEGY:
try to enter library
if fails return error
try to call routine
if fails propgate error
exit library
REVISION HISTORY:
Name Date Description
---- ---- -----------
TS 4/12/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SoundCallLibraryDriverRoutine proc near
.enter
push di ; save routine
mov di, DR_SOUND_ENTER_LIBRARY_ROUTINE
call SoundLibDriverStrategy
jc error ; set error?
pop di ; restore routine
call SoundLibDriverStrategy
jc routineFailure
push di ; save result
mov di, DR_SOUND_EXIT_LIBRARY_ROUTINE
call SoundLibDriverStrategy
clc
error:
pop di ; clean up stack
mov ax, SOUND_ERROR_EXCLUSIVE_ACCESS_GRANTED
done:
.leave
ret
routineFailure:
;
; We failed somewhere in the SoundLibDriver routine.
; Propogate error after exiting the library routine
mov di, DR_SOUND_EXIT_LIBRARY_ROUTINE ; exit library
call SoundLibDriverStrategy
stc ; propogate error
jmp short done
SoundCallLibraryDriverRoutine endp
;-----------------------------------------------------------------------------
;
; EXCLUSIVE DRIVER ACCESS ROUTINES
;
;-----------------------------------------------------------------------------
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SoundGetExclusive
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Get exclusive access to the lower level routines
CALLED BY: GLOBAL
PASS: nothing
RETURN: ax:si <- fptr to Synth sound driver strategy routine
bx:di <- fptr to DAC sound driver strategy routine
cx:dx <- fptr to sound library's Driver strategy routine
DESTROYED: nothing
SIDE EFFECTS:
Causes thread to block until get exclusive
PSEUDO CODE/STRATEGY:
Do a P on the semaphore
REVISION HISTORY:
Name Date Description
---- ---- -----------
TS 9/29/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SoundGetExclusive proc far
uses ds
.enter
mov ax, segment dgroup
mov ds, ax
PSem ds, exclusiveSemaphore, TRASH_AX_BX
;
; We are now the only thread in this section
; of code. We need only wait for all the
; threads to clear out, then we have
; exclusive access
inc ds:[exclusiveAccess]
PSem ds, librarySemaphore, TRASH_AX_BX
;
; Load up pointers to the strategy routines.
mov ax, ds:[soundSynthStrategy].segment
mov si, ds:[soundSynthStrategy].offset
mov bx, ax
mov di, si
mov cx, segment SoundLibDriverStrategy
mov dx, offset SoundLibDriverStrategy
.leave
ret
SoundGetExclusive endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SoundGetExclusiveNB
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Get exclusive access to lower level routines
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry clear if exclusive access granted:
ax:si <- fptr to Synth sound driver strategy routine
bx:di <- fptr to DAC sound driver strategy routine
cx:dx <- fptr to sound library's Driver strategy routine
carry set someone already has exclusive access.
DESTROYED: nothing
SIDE EFFECTS:
none
PSEUDO CODE/STRATEGY:
TimedP on the semaphore
REVISION HISTORY:
Name Date Description
---- ---- -----------
TS 9/29/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SoundGetExclusiveNB proc far
uses cx,ds
.enter
mov ax, segment dgroup
mov ds, ax
clr cx
PTimedSem ds,exclusiveSemaphore,cx,TRASH_AX_BX_CX
jc done
inc ds:[exclusiveAccess]
clr cx
PTimedSem ds,librarySemaphore,cx,TRASH_AX_BX_CX
jc error
;
; Load up pointers to the strategy routines.
mov ax, ds:[soundSynthStrategy].segment
mov si, ds:[soundSynthStrategy].offset
mov bx, ax
mov di, si
mov cx, segment SoundLibDriverStrategy
mov dx, offset SoundLibDriverStrategy
done:
.leave
ret
error:
;
; We got the 1st semaphore, but not the 2nd.
; V the first handle.
dec ds:[exclusiveAccess]
VSem ds, exclusiveSemaphore, TRASH_AX_BX
jmp short done
SoundGetExclusiveNB endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SoundReleaseExclusive
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Give up exclusive access to lower level routines
CALLED BY: GLOBAL
PASS: nothing
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
frees up the semaphore
PSEUDO CODE/STRATEGY:
V the semaphore
REVISION HISTORY:
Name Date Description
---- ---- -----------
TS 9/29/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SoundReleaseExclusive proc far
uses ax,bx,ds
.enter
mov ax, segment dgroup
mov ds, ax
VSem ds,librarySemaphore,TRASH_AX_BX
dec ds:[exclusiveAccess]
VSem ds,exclusiveSemaphore,TRASH_AX_BX
.leave
ret
SoundReleaseExclusive endp
;-----------------------------------------------------------------------------
;
; Driver Manipulation/Query routines
;
;-----------------------------------------------------------------------------
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SoundSynthDriverInfo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Get information on Synth Driver
CALLED BY: GLOBAL
PASS: nothing
RETURN: ax <- # of Voices
bx <- SupportedInstrumentFormat
cx <- SoundDriverCapability
DESTROYED: nothing
SIDE EFFECTS:
none
PSEUDO CODE/STRATEGY:
load up existing data and return
REVISION HISTORY:
Name Date Description
---- ---- -----------
TS 3/12/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SoundSynthDriverInfo proc far
uses ds
.enter
mov ax, segment dgroup
mov ds, ax
mov ax, ds:[driverVoices]
mov bx, ds:[driverVoiceFormat]
mov cx, ds:[driverCapability]
.leave
ret
SoundSynthDriverInfo endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SoundSampleDriverInfo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Get information on Sample Driver
CALLED BY: GLOBAL
PASS: nothing
RETURN: ax <- # of DACs
bx <- SoundDriverDACCapability
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
TS 3/12/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SoundSampleDriverInfo proc far
uses ds
.enter
mov ax, segment dgroup
mov ds, ax
mov ax, ds:[driverDACs]
mov bx, ds:[driverDACCapability]
.leave
ret
SoundSampleDriverInfo endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SoundPlayMusicLMem
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Play a simple FM sound in an LMem chunk
CALLED BY: GLOBAL
PASS: bx -> handle for SoundControl
ax -> starting priority for sound
cx -> starting tempo setting for sound
dl -> EndOfSongFlags for sound
RETURN: carry clear
ax destroyed
- or -
carry set
ax <- SOUND_ERROR reason for failure
DESTROYED: nothing
SIDE EFFECTS:
If the simple sound is currently playing, it will
be re-started at the beginning of the song with the
new tempo and priority.
PSEUDO CODE/STRATEGY:
call the driver routine
REVISION HISTORY:
Name Date Description
---- ---- -----------
JV 3/31/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SoundPlayMusicLMem proc far
uses di
.enter
mov di, DR_SOUND_PLAY_MUSIC_LMEM
call SoundCallLibraryDriverRoutine
.leave
ret
SoundPlayMusicLMem endp
CommonCode ends
|
.emacs.d/elpa/ada-mode-7.1.4/gpr_mode_wisi_parse.ads | caqg/linux-home | 0 | 16830 | <filename>.emacs.d/elpa/ada-mode-7.1.4/gpr_mode_wisi_parse.ads
-- Abstract :
--
-- External process parser for gpr mode
--
-- Copyright (C) 2017 - 2019 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or
-- modify it under terms of the GNU General Public License as
-- published by the Free Software Foundation; either version 3, or (at
-- your option) any later version. This program is distributed in the
-- hope that it will be useful, but WITHOUT ANY WARRANTY; without even
-- the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-- PURPOSE. See the GNU General Public License for more details. You
-- should have received a copy of the GNU General Public License
-- distributed with this program; see file COPYING. If not, write to
-- the Free Software Foundation, 51 Franklin Street, Suite 500, Boston,
-- MA 02110-1335, USA.
pragma License (GPL);
with Gen_Emacs_Wisi_LR_Parse;
with Gpr_Process_Actions;
with Gpr_Process_Main;
with Wisi.Gpr;
procedure Gpr_Mode_Wisi_Parse is new Gen_Emacs_Wisi_LR_Parse
(Parse_Data_Type => Wisi.Gpr.Parse_Data_Type,
Language_Protocol_Version => Wisi.Gpr.Language_Protocol_Version,
Name => "gpr_mode_wisi_parse",
Descriptor => Gpr_Process_Actions.Descriptor,
Partial_Parse_Active => Gpr_Process_Actions.Partial_Parse_Active,
Language_Fixes => null,
Language_Matching_Begin_Tokens => null,
Language_String_ID_Set => null,
Create_Parser => Gpr_Process_Main.Create_Parser);
|
bb-runtimes/arm/sam/samg55/svd/i-sam-pmc.ads | JCGobbi/Nucleo-STM32G474RE | 0 | 1103 | --
-- Copyright (C) 2017, AdaCore
--
-- This spec has been automatically generated from ATSAMG55J19.svd
pragma Ada_2012;
pragma Style_Checks (Off);
with System;
-- Power Management Controller
package Interfaces.SAM.PMC is
pragma Preelaborate;
pragma No_Elaboration_Code_All;
---------------
-- Registers --
---------------
-- PMC_SCER_PCK array
type PMC_SCER_PCK_Field_Array is array (0 .. 7) of Boolean
with Component_Size => 1, Size => 8;
-- Type definition for PMC_SCER_PCK
type PMC_SCER_PCK_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- PCK as a value
Val : Interfaces.SAM.Byte;
when True =>
-- PCK as an array
Arr : PMC_SCER_PCK_Field_Array;
end case;
end record
with Unchecked_Union, Size => 8;
for PMC_SCER_PCK_Field use record
Val at 0 range 0 .. 7;
Arr at 0 range 0 .. 7;
end record;
-- System Clock Enable Register
type PMC_SCER_Register is record
-- unspecified
Reserved_0_5 : Interfaces.SAM.UInt6 := 16#0#;
-- Write-only. USB Host Port Clock Enable
UHP : Boolean := False;
-- Write-only. USB Device Port Clock Enable
UDP : Boolean := False;
-- Write-only. Programmable Clock 0 Output Enable
PCK : PMC_SCER_PCK_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_16_31 : Interfaces.SAM.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PMC_SCER_Register use record
Reserved_0_5 at 0 range 0 .. 5;
UHP at 0 range 6 .. 6;
UDP at 0 range 7 .. 7;
PCK at 0 range 8 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-- PMC_SCDR_PCK array
type PMC_SCDR_PCK_Field_Array is array (0 .. 7) of Boolean
with Component_Size => 1, Size => 8;
-- Type definition for PMC_SCDR_PCK
type PMC_SCDR_PCK_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- PCK as a value
Val : Interfaces.SAM.Byte;
when True =>
-- PCK as an array
Arr : PMC_SCDR_PCK_Field_Array;
end case;
end record
with Unchecked_Union, Size => 8;
for PMC_SCDR_PCK_Field use record
Val at 0 range 0 .. 7;
Arr at 0 range 0 .. 7;
end record;
-- System Clock Disable Register
type PMC_SCDR_Register is record
-- unspecified
Reserved_0_5 : Interfaces.SAM.UInt6 := 16#0#;
-- Write-only. USB Host Port Clock Disable
UHP : Boolean := False;
-- Write-only.
UDP : Boolean := False;
-- Write-only. Programmable Clock 0 Output Disable
PCK : PMC_SCDR_PCK_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_16_31 : Interfaces.SAM.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PMC_SCDR_Register use record
Reserved_0_5 at 0 range 0 .. 5;
UHP at 0 range 6 .. 6;
UDP at 0 range 7 .. 7;
PCK at 0 range 8 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-- PMC_SCSR_PCK array
type PMC_SCSR_PCK_Field_Array is array (0 .. 7) of Boolean
with Component_Size => 1, Size => 8;
-- Type definition for PMC_SCSR_PCK
type PMC_SCSR_PCK_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- PCK as a value
Val : Interfaces.SAM.Byte;
when True =>
-- PCK as an array
Arr : PMC_SCSR_PCK_Field_Array;
end case;
end record
with Unchecked_Union, Size => 8;
for PMC_SCSR_PCK_Field use record
Val at 0 range 0 .. 7;
Arr at 0 range 0 .. 7;
end record;
-- System Clock Status Register
type PMC_SCSR_Register is record
-- unspecified
Reserved_0_5 : Interfaces.SAM.UInt6;
-- Read-only. USB Host Port Clock Status
UHP : Boolean;
-- Read-only.
UDP : Boolean;
-- Read-only. Programmable Clock 0 Output Status
PCK : PMC_SCSR_PCK_Field;
-- unspecified
Reserved_16_31 : Interfaces.SAM.UInt16;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PMC_SCSR_Register use record
Reserved_0_5 at 0 range 0 .. 5;
UHP at 0 range 6 .. 6;
UDP at 0 range 7 .. 7;
PCK at 0 range 8 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-- PMC_PCER0_PID array
type PMC_PCER0_PID_Field_Array is array (8 .. 29) of Boolean
with Component_Size => 1, Size => 22;
-- Type definition for PMC_PCER0_PID
type PMC_PCER0_PID_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- PID as a value
Val : Interfaces.SAM.UInt22;
when True =>
-- PID as an array
Arr : PMC_PCER0_PID_Field_Array;
end case;
end record
with Unchecked_Union, Size => 22;
for PMC_PCER0_PID_Field use record
Val at 0 range 0 .. 21;
Arr at 0 range 0 .. 21;
end record;
-- Peripheral Clock Enable Register 0
type PMC_PCER0_Register is record
-- unspecified
Reserved_0_7 : Interfaces.SAM.Byte := 16#0#;
-- Write-only. Peripheral Clock 8 Enable
PID : PMC_PCER0_PID_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_30_31 : Interfaces.SAM.UInt2 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PMC_PCER0_Register use record
Reserved_0_7 at 0 range 0 .. 7;
PID at 0 range 8 .. 29;
Reserved_30_31 at 0 range 30 .. 31;
end record;
-- PMC_PCDR0_PID array
type PMC_PCDR0_PID_Field_Array is array (8 .. 29) of Boolean
with Component_Size => 1, Size => 22;
-- Type definition for PMC_PCDR0_PID
type PMC_PCDR0_PID_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- PID as a value
Val : Interfaces.SAM.UInt22;
when True =>
-- PID as an array
Arr : PMC_PCDR0_PID_Field_Array;
end case;
end record
with Unchecked_Union, Size => 22;
for PMC_PCDR0_PID_Field use record
Val at 0 range 0 .. 21;
Arr at 0 range 0 .. 21;
end record;
-- Peripheral Clock Disable Register 0
type PMC_PCDR0_Register is record
-- unspecified
Reserved_0_7 : Interfaces.SAM.Byte := 16#0#;
-- Write-only. Peripheral Clock 8 Disable
PID : PMC_PCDR0_PID_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_30_31 : Interfaces.SAM.UInt2 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PMC_PCDR0_Register use record
Reserved_0_7 at 0 range 0 .. 7;
PID at 0 range 8 .. 29;
Reserved_30_31 at 0 range 30 .. 31;
end record;
-- PMC_PCSR0_PID array
type PMC_PCSR0_PID_Field_Array is array (8 .. 29) of Boolean
with Component_Size => 1, Size => 22;
-- Type definition for PMC_PCSR0_PID
type PMC_PCSR0_PID_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- PID as a value
Val : Interfaces.SAM.UInt22;
when True =>
-- PID as an array
Arr : PMC_PCSR0_PID_Field_Array;
end case;
end record
with Unchecked_Union, Size => 22;
for PMC_PCSR0_PID_Field use record
Val at 0 range 0 .. 21;
Arr at 0 range 0 .. 21;
end record;
-- Peripheral Clock Status Register 0
type PMC_PCSR0_Register is record
-- unspecified
Reserved_0_7 : Interfaces.SAM.Byte;
-- Read-only. Peripheral Clock 8 Status
PID : PMC_PCSR0_PID_Field;
-- unspecified
Reserved_30_31 : Interfaces.SAM.UInt2;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PMC_PCSR0_Register use record
Reserved_0_7 at 0 range 0 .. 7;
PID at 0 range 8 .. 29;
Reserved_30_31 at 0 range 30 .. 31;
end record;
-- Main On-Chip RC Oscillator Frequency Selection
type CKGR_MOR_MOSCRCF_Field is
(
-- The Fast RC Oscillator Frequency is at 8 MHz (default)
CKGR_MOR_MOSCRCF_Field_8_Mhz,
-- The Fast RC Oscillator Frequency is at 16 MHz
CKGR_MOR_MOSCRCF_Field_16_Mhz,
-- The Fast RC Oscillator Frequency is at 24 MHz
CKGR_MOR_MOSCRCF_Field_24_Mhz)
with Size => 3;
for CKGR_MOR_MOSCRCF_Field use
(CKGR_MOR_MOSCRCF_Field_8_Mhz => 0,
CKGR_MOR_MOSCRCF_Field_16_Mhz => 1,
CKGR_MOR_MOSCRCF_Field_24_Mhz => 2);
subtype CKGR_MOR_MOSCXTST_Field is Interfaces.SAM.Byte;
-- Write Access Password
type CKGR_MOR_KEY_Field is
(
-- Reset value for the field
Ckgr_Mor_Key_Field_Reset,
-- Writing any other value in this field aborts the write
-- operation.Always reads as 0.
Passwd)
with Size => 8;
for CKGR_MOR_KEY_Field use
(Ckgr_Mor_Key_Field_Reset => 0,
Passwd => 55);
-- Main Oscillator Register
type CKGR_MOR_Register is record
-- Main Crystal Oscillator Enable
MOSCXTEN : Boolean := False;
-- Main Crystal Oscillator Bypass
MOSCXTBY : Boolean := False;
-- Wait Mode Command (Write-only)
WAITMODE : Boolean := False;
-- Main On-Chip RC Oscillator Enable
MOSCRCEN : Boolean := True;
-- Main On-Chip RC Oscillator Frequency Selection
MOSCRCF : CKGR_MOR_MOSCRCF_Field :=
Interfaces.SAM.PMC.CKGR_MOR_MOSCRCF_Field_8_Mhz;
-- unspecified
Reserved_7_7 : Interfaces.SAM.Bit := 16#0#;
-- Main Crystal Oscillator Start-up Time
MOSCXTST : CKGR_MOR_MOSCXTST_Field := 16#0#;
-- Write Access Password
KEY : CKGR_MOR_KEY_Field := Ckgr_Mor_Key_Field_Reset;
-- Main Oscillator Selection
MOSCSEL : Boolean := False;
-- Clock Failure Detector Enable
CFDEN : Boolean := False;
-- unspecified
Reserved_26_31 : Interfaces.SAM.UInt6 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CKGR_MOR_Register use record
MOSCXTEN at 0 range 0 .. 0;
MOSCXTBY at 0 range 1 .. 1;
WAITMODE at 0 range 2 .. 2;
MOSCRCEN at 0 range 3 .. 3;
MOSCRCF at 0 range 4 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
MOSCXTST at 0 range 8 .. 15;
KEY at 0 range 16 .. 23;
MOSCSEL at 0 range 24 .. 24;
CFDEN at 0 range 25 .. 25;
Reserved_26_31 at 0 range 26 .. 31;
end record;
subtype CKGR_MCFR_MAINF_Field is Interfaces.SAM.UInt16;
-- Main Clock Frequency Register
type CKGR_MCFR_Register is record
-- Main Clock Frequency
MAINF : CKGR_MCFR_MAINF_Field := 16#0#;
-- Main Clock Frequency Measure Ready
MAINFRDY : Boolean := False;
-- unspecified
Reserved_17_19 : Interfaces.SAM.UInt3 := 16#0#;
-- RC Oscillator Frequency Measure (write-only)
RCMEAS : Boolean := False;
-- unspecified
Reserved_21_31 : Interfaces.SAM.UInt11 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CKGR_MCFR_Register use record
MAINF at 0 range 0 .. 15;
MAINFRDY at 0 range 16 .. 16;
Reserved_17_19 at 0 range 17 .. 19;
RCMEAS at 0 range 20 .. 20;
Reserved_21_31 at 0 range 21 .. 31;
end record;
subtype CKGR_PLLAR_PLLAEN_Field is Interfaces.SAM.Byte;
subtype CKGR_PLLAR_PLLACOUNT_Field is Interfaces.SAM.UInt6;
subtype CKGR_PLLAR_MULA_Field is Interfaces.SAM.UInt12;
-- PLLA Register
type CKGR_PLLAR_Register is record
-- PLLA Control
PLLAEN : CKGR_PLLAR_PLLAEN_Field := 16#0#;
-- PLLA Counter
PLLACOUNT : CKGR_PLLAR_PLLACOUNT_Field := 16#3F#;
-- unspecified
Reserved_14_15 : Interfaces.SAM.UInt2 := 16#0#;
-- PLLA Multiplier
MULA : CKGR_PLLAR_MULA_Field := 16#0#;
-- unspecified
Reserved_28_28 : Interfaces.SAM.Bit := 16#0#;
-- Must be written to 0
ZERO : Boolean := False;
-- unspecified
Reserved_30_31 : Interfaces.SAM.UInt2 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CKGR_PLLAR_Register use record
PLLAEN at 0 range 0 .. 7;
PLLACOUNT at 0 range 8 .. 13;
Reserved_14_15 at 0 range 14 .. 15;
MULA at 0 range 16 .. 27;
Reserved_28_28 at 0 range 28 .. 28;
ZERO at 0 range 29 .. 29;
Reserved_30_31 at 0 range 30 .. 31;
end record;
subtype CKGR_PLLBR_PLLBEN_Field is Interfaces.SAM.Byte;
subtype CKGR_PLLBR_PLLBCOUNT_Field is Interfaces.SAM.UInt6;
subtype CKGR_PLLBR_MULB_Field is Interfaces.SAM.UInt11;
-- PLLB Register
type CKGR_PLLBR_Register is record
-- PLLB Control
PLLBEN : CKGR_PLLBR_PLLBEN_Field := 16#0#;
-- PLLB Counter
PLLBCOUNT : CKGR_PLLBR_PLLBCOUNT_Field := 16#3F#;
-- unspecified
Reserved_14_15 : Interfaces.SAM.UInt2 := 16#0#;
-- PLLB Multiplier
MULB : CKGR_PLLBR_MULB_Field := 16#0#;
-- unspecified
Reserved_27_28 : Interfaces.SAM.UInt2 := 16#0#;
-- Must be written to 0
ZERO : Boolean := False;
-- unspecified
Reserved_30_31 : Interfaces.SAM.UInt2 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CKGR_PLLBR_Register use record
PLLBEN at 0 range 0 .. 7;
PLLBCOUNT at 0 range 8 .. 13;
Reserved_14_15 at 0 range 14 .. 15;
MULB at 0 range 16 .. 26;
Reserved_27_28 at 0 range 27 .. 28;
ZERO at 0 range 29 .. 29;
Reserved_30_31 at 0 range 30 .. 31;
end record;
-- Master Clock Source Selection
type PMC_MCKR_CSS_Field is
(
-- Slow Clock is selected
Slow_Clk,
-- Main Clock is selected
Main_Clk,
-- PLLA Clock is selected
Plla_Clk,
-- PLLBClock is selected
Pllb_Clk)
with Size => 2;
for PMC_MCKR_CSS_Field use
(Slow_Clk => 0,
Main_Clk => 1,
Plla_Clk => 2,
Pllb_Clk => 3);
-- Processor Clock Prescaler
type PMC_MCKR_PRES_Field is
(
-- Selected clock
Clk_1,
-- Selected clock divided by 2
Clk_2,
-- Selected clock divided by 4
Clk_4,
-- Selected clock divided by 8
Clk_8,
-- Selected clock divided by 16
Clk_16,
-- Selected clock divided by 32
Clk_32,
-- Selected clock divided by 64
Clk_64,
-- Selected clock divided by 3
Clk_3)
with Size => 3;
for PMC_MCKR_PRES_Field use
(Clk_1 => 0,
Clk_2 => 1,
Clk_4 => 2,
Clk_8 => 3,
Clk_16 => 4,
Clk_32 => 5,
Clk_64 => 6,
Clk_3 => 7);
-- Master Clock Register
type PMC_MCKR_Register is record
-- Master Clock Source Selection
CSS : PMC_MCKR_CSS_Field := Interfaces.SAM.PMC.Main_Clk;
-- unspecified
Reserved_2_3 : Interfaces.SAM.UInt2 := 16#0#;
-- Processor Clock Prescaler
PRES : PMC_MCKR_PRES_Field := Interfaces.SAM.PMC.Clk_1;
-- unspecified
Reserved_7_11 : Interfaces.SAM.UInt5 := 16#0#;
-- PLLA Divisor by 2
PLLADIV2 : Boolean := False;
PLLBDIV2 : Boolean := False;
-- unspecified
Reserved_14_31 : Interfaces.SAM.UInt18 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PMC_MCKR_Register use record
CSS at 0 range 0 .. 1;
Reserved_2_3 at 0 range 2 .. 3;
PRES at 0 range 4 .. 6;
Reserved_7_11 at 0 range 7 .. 11;
PLLADIV2 at 0 range 12 .. 12;
PLLBDIV2 at 0 range 13 .. 13;
Reserved_14_31 at 0 range 14 .. 31;
end record;
subtype PMC_USB_USBDIV_Field is Interfaces.SAM.UInt4;
-- USB Clock Register
type PMC_USB_Register is record
-- USB Input Clock Selection
USBS : Boolean := False;
-- unspecified
Reserved_1_7 : Interfaces.SAM.UInt7 := 16#0#;
-- Divider for USB Clock
USBDIV : PMC_USB_USBDIV_Field := 16#0#;
-- unspecified
Reserved_12_31 : Interfaces.SAM.UInt20 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PMC_USB_Register use record
USBS at 0 range 0 .. 0;
Reserved_1_7 at 0 range 1 .. 7;
USBDIV at 0 range 8 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
-- Master Clock Source Selection
type PMC_PCK_CSS_Field is
(
-- Slow Clock is selected
Slow_Clk,
-- Main Clock is selected
Main_Clk,
-- PLLA Clock is selected
Plla_Clk,
-- PLLB Clock is selected
Pllb_Clk,
-- Master Clock is selected
Mck)
with Size => 3;
for PMC_PCK_CSS_Field use
(Slow_Clk => 0,
Main_Clk => 1,
Plla_Clk => 2,
Pllb_Clk => 3,
Mck => 4);
subtype PMC_PCK_PRES_Field is Interfaces.SAM.Byte;
-- Programmable Clock 0 Register
type PMC_PCK_Register is record
-- Master Clock Source Selection
CSS : PMC_PCK_CSS_Field := Interfaces.SAM.PMC.Slow_Clk;
-- unspecified
Reserved_3_3 : Interfaces.SAM.Bit := 16#0#;
-- Programmable Clock Prescaler
PRES : PMC_PCK_PRES_Field := 16#0#;
-- unspecified
Reserved_12_31 : Interfaces.SAM.UInt20 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PMC_PCK_Register use record
CSS at 0 range 0 .. 2;
Reserved_3_3 at 0 range 3 .. 3;
PRES at 0 range 4 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
-- Programmable Clock 0 Register
type PMC_PCK_Registers is array (0 .. 7) of PMC_PCK_Register
with Volatile;
-- PMC_IER_PCKRDY array
type PMC_IER_PCKRDY_Field_Array is array (0 .. 7) of Boolean
with Component_Size => 1, Size => 8;
-- Type definition for PMC_IER_PCKRDY
type PMC_IER_PCKRDY_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- PCKRDY as a value
Val : Interfaces.SAM.Byte;
when True =>
-- PCKRDY as an array
Arr : PMC_IER_PCKRDY_Field_Array;
end case;
end record
with Unchecked_Union, Size => 8;
for PMC_IER_PCKRDY_Field use record
Val at 0 range 0 .. 7;
Arr at 0 range 0 .. 7;
end record;
-- Interrupt Enable Register
type PMC_IER_Register is record
-- Write-only. Main Crystal Oscillator Status Interrupt Enable
MOSCXTS : Boolean := False;
-- Write-only. PLLA Lock Interrupt Enable
LOCKA : Boolean := False;
-- Write-only. PLLB Lock Interrupt Enable
LOCKB : Boolean := False;
-- Write-only. Master Clock Ready Interrupt Enable
MCKRDY : Boolean := False;
-- unspecified
Reserved_4_7 : Interfaces.SAM.UInt4 := 16#0#;
-- Write-only. Programmable Clock Ready 0 Interrupt Enable
PCKRDY : PMC_IER_PCKRDY_Field :=
(As_Array => False, Val => 16#0#);
-- Write-only. Main Oscillator Selection Status Interrupt Enable
MOSCSELS : Boolean := False;
-- Write-only. Main On-Chip RC Status Interrupt Enable
MOSCRCS : Boolean := False;
-- Write-only. Clock Failure Detector Event Interrupt Enable
CFDEV : Boolean := False;
-- unspecified
Reserved_19_31 : Interfaces.SAM.UInt13 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PMC_IER_Register use record
MOSCXTS at 0 range 0 .. 0;
LOCKA at 0 range 1 .. 1;
LOCKB at 0 range 2 .. 2;
MCKRDY at 0 range 3 .. 3;
Reserved_4_7 at 0 range 4 .. 7;
PCKRDY at 0 range 8 .. 15;
MOSCSELS at 0 range 16 .. 16;
MOSCRCS at 0 range 17 .. 17;
CFDEV at 0 range 18 .. 18;
Reserved_19_31 at 0 range 19 .. 31;
end record;
-- PMC_IDR_PCKRDY array
type PMC_IDR_PCKRDY_Field_Array is array (0 .. 7) of Boolean
with Component_Size => 1, Size => 8;
-- Type definition for PMC_IDR_PCKRDY
type PMC_IDR_PCKRDY_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- PCKRDY as a value
Val : Interfaces.SAM.Byte;
when True =>
-- PCKRDY as an array
Arr : PMC_IDR_PCKRDY_Field_Array;
end case;
end record
with Unchecked_Union, Size => 8;
for PMC_IDR_PCKRDY_Field use record
Val at 0 range 0 .. 7;
Arr at 0 range 0 .. 7;
end record;
-- Interrupt Disable Register
type PMC_IDR_Register is record
-- Write-only. Main Crystal Oscillator Status Interrupt Disable
MOSCXTS : Boolean := False;
-- Write-only. PLLA Lock Interrupt Disable
LOCKA : Boolean := False;
-- Write-only. PLLB Lock Interrupt Disable
LOCKB : Boolean := False;
-- Write-only. Master Clock Ready Interrupt Disable
MCKRDY : Boolean := False;
-- unspecified
Reserved_4_7 : Interfaces.SAM.UInt4 := 16#0#;
-- Write-only. Programmable Clock Ready 0 Interrupt Disable
PCKRDY : PMC_IDR_PCKRDY_Field :=
(As_Array => False, Val => 16#0#);
-- Write-only. Main Oscillator Selection Status Interrupt Disable
MOSCSELS : Boolean := False;
-- Write-only. Main On-Chip RC Status Interrupt Disable
MOSCRCS : Boolean := False;
-- Write-only. Clock Failure Detector Event Interrupt Disable
CFDEV : Boolean := False;
-- unspecified
Reserved_19_31 : Interfaces.SAM.UInt13 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PMC_IDR_Register use record
MOSCXTS at 0 range 0 .. 0;
LOCKA at 0 range 1 .. 1;
LOCKB at 0 range 2 .. 2;
MCKRDY at 0 range 3 .. 3;
Reserved_4_7 at 0 range 4 .. 7;
PCKRDY at 0 range 8 .. 15;
MOSCSELS at 0 range 16 .. 16;
MOSCRCS at 0 range 17 .. 17;
CFDEV at 0 range 18 .. 18;
Reserved_19_31 at 0 range 19 .. 31;
end record;
-- PMC_SR_PCKRDY array
type PMC_SR_PCKRDY_Field_Array is array (0 .. 7) of Boolean
with Component_Size => 1, Size => 8;
-- Type definition for PMC_SR_PCKRDY
type PMC_SR_PCKRDY_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- PCKRDY as a value
Val : Interfaces.SAM.Byte;
when True =>
-- PCKRDY as an array
Arr : PMC_SR_PCKRDY_Field_Array;
end case;
end record
with Unchecked_Union, Size => 8;
for PMC_SR_PCKRDY_Field use record
Val at 0 range 0 .. 7;
Arr at 0 range 0 .. 7;
end record;
-- Status Register
type PMC_SR_Register is record
-- Read-only. Main Crystal Oscillator Status
MOSCXTS : Boolean;
-- Read-only. PLLA Lock Status
LOCKA : Boolean;
-- Read-only. PLLB Lock Status
LOCKB : Boolean;
-- Read-only. Master Clock Status
MCKRDY : Boolean;
-- unspecified
Reserved_4_6 : Interfaces.SAM.UInt3;
-- Read-only. Slow Clock Oscillator Selection
OSCSELS : Boolean;
-- Read-only. Programmable Clock Ready Status
PCKRDY : PMC_SR_PCKRDY_Field;
-- Read-only. Main Oscillator Selection Status
MOSCSELS : Boolean;
-- Read-only. Main On-Chip RC Oscillator Status
MOSCRCS : Boolean;
-- Read-only. Clock Failure Detector Event
CFDEV : Boolean;
-- Read-only. Clock Failure Detector Status
CFDS : Boolean;
-- Read-only. Clock Failure Detector Fault Output Status
FOS : Boolean;
-- unspecified
Reserved_21_31 : Interfaces.SAM.UInt11;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PMC_SR_Register use record
MOSCXTS at 0 range 0 .. 0;
LOCKA at 0 range 1 .. 1;
LOCKB at 0 range 2 .. 2;
MCKRDY at 0 range 3 .. 3;
Reserved_4_6 at 0 range 4 .. 6;
OSCSELS at 0 range 7 .. 7;
PCKRDY at 0 range 8 .. 15;
MOSCSELS at 0 range 16 .. 16;
MOSCRCS at 0 range 17 .. 17;
CFDEV at 0 range 18 .. 18;
CFDS at 0 range 19 .. 19;
FOS at 0 range 20 .. 20;
Reserved_21_31 at 0 range 21 .. 31;
end record;
-- PMC_IMR_PCKRDY array
type PMC_IMR_PCKRDY_Field_Array is array (0 .. 2) of Boolean
with Component_Size => 1, Size => 3;
-- Type definition for PMC_IMR_PCKRDY
type PMC_IMR_PCKRDY_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- PCKRDY as a value
Val : Interfaces.SAM.UInt3;
when True =>
-- PCKRDY as an array
Arr : PMC_IMR_PCKRDY_Field_Array;
end case;
end record
with Unchecked_Union, Size => 3;
for PMC_IMR_PCKRDY_Field use record
Val at 0 range 0 .. 2;
Arr at 0 range 0 .. 2;
end record;
-- Interrupt Mask Register
type PMC_IMR_Register is record
-- Read-only. Main Crystal Oscillator Status Interrupt Mask
MOSCXTS : Boolean;
-- Read-only. PLLA Lock Interrupt Mask
LOCKA : Boolean;
-- Read-only. PLLB Lock Interrupt Mask
LOCKB : Boolean;
-- Read-only. Master Clock Ready Interrupt Mask
MCKRDY : Boolean;
-- unspecified
Reserved_4_7 : Interfaces.SAM.UInt4;
-- Read-only. Programmable Clock Ready 0 Interrupt Mask
PCKRDY : PMC_IMR_PCKRDY_Field;
-- unspecified
Reserved_11_15 : Interfaces.SAM.UInt5;
-- Read-only. Main Oscillator Selection Status Interrupt Mask
MOSCSELS : Boolean;
-- Read-only. Main On-Chip RC Status Interrupt Mask
MOSCRCS : Boolean;
-- Read-only. Clock Failure Detector Event Interrupt Mask
CFDEV : Boolean;
-- unspecified
Reserved_19_31 : Interfaces.SAM.UInt13;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PMC_IMR_Register use record
MOSCXTS at 0 range 0 .. 0;
LOCKA at 0 range 1 .. 1;
LOCKB at 0 range 2 .. 2;
MCKRDY at 0 range 3 .. 3;
Reserved_4_7 at 0 range 4 .. 7;
PCKRDY at 0 range 8 .. 10;
Reserved_11_15 at 0 range 11 .. 15;
MOSCSELS at 0 range 16 .. 16;
MOSCRCS at 0 range 17 .. 17;
CFDEV at 0 range 18 .. 18;
Reserved_19_31 at 0 range 19 .. 31;
end record;
-- PMC_FSMR_FSTT array
type PMC_FSMR_FSTT_Field_Array is array (0 .. 15) of Boolean
with Component_Size => 1, Size => 16;
-- Type definition for PMC_FSMR_FSTT
type PMC_FSMR_FSTT_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- FSTT as a value
Val : Interfaces.SAM.UInt16;
when True =>
-- FSTT as an array
Arr : PMC_FSMR_FSTT_Field_Array;
end case;
end record
with Unchecked_Union, Size => 16;
for PMC_FSMR_FSTT_Field use record
Val at 0 range 0 .. 15;
Arr at 0 range 0 .. 15;
end record;
-- Flash Low-power Mode
type PMC_FSMR_FLPM_Field is
(
-- Flash is in Standby Mode when system enters Wait Mode
Flash_Standby,
-- Flash is in Deep-power-down mode when system enters Wait Mode
Flash_Deep_Powerdown,
-- Idle mode
Flash_Idle)
with Size => 2;
for PMC_FSMR_FLPM_Field use
(Flash_Standby => 0,
Flash_Deep_Powerdown => 1,
Flash_Idle => 2);
-- Fast Startup Mode Register
type PMC_FSMR_Register is record
-- Fast Startup Input Enable 0
FSTT : PMC_FSMR_FSTT_Field :=
(As_Array => False, Val => 16#0#);
-- RTT Alarm Enable
RTTAL : Boolean := False;
-- RTC Alarm Enable
RTCAL : Boolean := False;
-- USB Alarm Enable
USBAL : Boolean := False;
-- unspecified
Reserved_19_19 : Interfaces.SAM.Bit := 16#0#;
-- Low-power Mode
LPM : Boolean := False;
-- Flash Low-power Mode
FLPM : PMC_FSMR_FLPM_Field :=
Interfaces.SAM.PMC.Flash_Standby;
-- unspecified
Reserved_23_31 : Interfaces.SAM.UInt9 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PMC_FSMR_Register use record
FSTT at 0 range 0 .. 15;
RTTAL at 0 range 16 .. 16;
RTCAL at 0 range 17 .. 17;
USBAL at 0 range 18 .. 18;
Reserved_19_19 at 0 range 19 .. 19;
LPM at 0 range 20 .. 20;
FLPM at 0 range 21 .. 22;
Reserved_23_31 at 0 range 23 .. 31;
end record;
-- PMC_FSPR_FSTP array
type PMC_FSPR_FSTP_Field_Array is array (0 .. 15) of Boolean
with Component_Size => 1, Size => 16;
-- Type definition for PMC_FSPR_FSTP
type PMC_FSPR_FSTP_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- FSTP as a value
Val : Interfaces.SAM.UInt16;
when True =>
-- FSTP as an array
Arr : PMC_FSPR_FSTP_Field_Array;
end case;
end record
with Unchecked_Union, Size => 16;
for PMC_FSPR_FSTP_Field use record
Val at 0 range 0 .. 15;
Arr at 0 range 0 .. 15;
end record;
-- Fast Startup Polarity Register
type PMC_FSPR_Register is record
-- Fast Startup Input Polarityx
FSTP : PMC_FSPR_FSTP_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_16_31 : Interfaces.SAM.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PMC_FSPR_Register use record
FSTP at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-- Fault Output Clear Register
type PMC_FOCR_Register is record
-- Write-only. Fault Output Clear
FOCLR : Boolean := False;
-- unspecified
Reserved_1_31 : Interfaces.SAM.UInt31 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PMC_FOCR_Register use record
FOCLR at 0 range 0 .. 0;
Reserved_1_31 at 0 range 1 .. 31;
end record;
-- Write Protection Key
type PMC_WPMR_WPKEY_Field is
(
-- Reset value for the field
Pmc_Wpmr_Wpkey_Field_Reset,
-- Writing any other value in this field aborts the write operation of
-- the WPEN bit. Always reads as 0.
Passwd)
with Size => 24;
for PMC_WPMR_WPKEY_Field use
(Pmc_Wpmr_Wpkey_Field_Reset => 0,
Passwd => <PASSWORD>);
-- Write Protection Mode Register
type PMC_WPMR_Register is record
-- Write Protection Enable
WPEN : Boolean := False;
-- unspecified
Reserved_1_7 : Interfaces.SAM.UInt7 := 16#0#;
-- Write Protection Key
WPKEY : PMC_WPMR_WPKEY_Field := Pmc_Wpmr_Wpkey_Field_Reset;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PMC_WPMR_Register use record
WPEN at 0 range 0 .. 0;
Reserved_1_7 at 0 range 1 .. 7;
WPKEY at 0 range 8 .. 31;
end record;
subtype PMC_WPSR_WPVSRC_Field is Interfaces.SAM.UInt16;
-- Write Protection Status Register
type PMC_WPSR_Register is record
-- Read-only. Write Protection Violation Status
WPVS : Boolean;
-- unspecified
Reserved_1_7 : Interfaces.SAM.UInt7;
-- Read-only. Write Protection Violation Source
WPVSRC : PMC_WPSR_WPVSRC_Field;
-- unspecified
Reserved_24_31 : Interfaces.SAM.Byte;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PMC_WPSR_Register use record
WPVS at 0 range 0 .. 0;
Reserved_1_7 at 0 range 1 .. 7;
WPVSRC at 0 range 8 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
subtype PMC_PCR_PID_Field is Interfaces.SAM.UInt6;
-- Divisor Value
type PMC_PCR_DIV_Field is
(
-- Peripheral clock is MCK
Periph_Div_Mck,
-- Peripheral clock is MCK/2
Periph_Div2_Mck,
-- Peripheral clock is MCK/4
Periph_Div4_Mck,
-- Peripheral clock is MCK/8
Periph_Div8_Mck)
with Size => 2;
for PMC_PCR_DIV_Field use
(Periph_Div_Mck => 0,
Periph_Div2_Mck => 1,
Periph_Div4_Mck => 2,
Periph_Div8_Mck => 3);
-- Peripheral Control Register
type PMC_PCR_Register is record
-- Peripheral ID
PID : PMC_PCR_PID_Field := 16#0#;
-- unspecified
Reserved_6_11 : Interfaces.SAM.UInt6 := 16#0#;
-- Command
CMD : Boolean := False;
-- unspecified
Reserved_13_15 : Interfaces.SAM.UInt3 := 16#0#;
-- Divisor Value
DIV : PMC_PCR_DIV_Field := Interfaces.SAM.PMC.Periph_Div_Mck;
-- unspecified
Reserved_18_27 : Interfaces.SAM.UInt10 := 16#0#;
-- Enable
EN : Boolean := False;
-- unspecified
Reserved_29_31 : Interfaces.SAM.UInt3 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PMC_PCR_Register use record
PID at 0 range 0 .. 5;
Reserved_6_11 at 0 range 6 .. 11;
CMD at 0 range 12 .. 12;
Reserved_13_15 at 0 range 13 .. 15;
DIV at 0 range 16 .. 17;
Reserved_18_27 at 0 range 18 .. 27;
EN at 0 range 28 .. 28;
Reserved_29_31 at 0 range 29 .. 31;
end record;
subtype PMC_OCR_CAL8_Field is Interfaces.SAM.UInt7;
subtype PMC_OCR_CAL16_Field is Interfaces.SAM.UInt7;
subtype PMC_OCR_CAL24_Field is Interfaces.SAM.UInt7;
-- Oscillator Calibration Register
type PMC_OCR_Register is record
-- RC Oscillator Calibration bits for 8 MHz
CAL8 : PMC_OCR_CAL8_Field := 16#40#;
-- Selection of RC Oscillator Calibration bits for 8 MHz
SEL8 : Boolean := False;
-- RC Oscillator Calibration bits for 16 MHz
CAL16 : PMC_OCR_CAL16_Field := 16#40#;
-- Selection of RC Oscillator Calibration bits for 16 MHz
SEL16 : Boolean := False;
-- RC Oscillator Calibration bits for 24 MHz
CAL24 : PMC_OCR_CAL24_Field := 16#40#;
-- Selection of RC Oscillator Calibration bits for 24 MHz
SEL24 : Boolean := False;
-- unspecified
Reserved_24_31 : Interfaces.SAM.Byte := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PMC_OCR_Register use record
CAL8 at 0 range 0 .. 6;
SEL8 at 0 range 7 .. 7;
CAL16 at 0 range 8 .. 14;
SEL16 at 0 range 15 .. 15;
CAL24 at 0 range 16 .. 22;
SEL24 at 0 range 23 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
-- PMC_SLPWK_ER0_PID array
type PMC_SLPWK_ER0_PID_Field_Array is array (8 .. 29) of Boolean
with Component_Size => 1, Size => 22;
-- Type definition for PMC_SLPWK_ER0_PID
type PMC_SLPWK_ER0_PID_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- PID as a value
Val : Interfaces.SAM.UInt22;
when True =>
-- PID as an array
Arr : PMC_SLPWK_ER0_PID_Field_Array;
end case;
end record
with Unchecked_Union, Size => 22;
for PMC_SLPWK_ER0_PID_Field use record
Val at 0 range 0 .. 21;
Arr at 0 range 0 .. 21;
end record;
-- SleepWalking Enable Register 0
type PMC_SLPWK_ER0_Register is record
-- unspecified
Reserved_0_7 : Interfaces.SAM.Byte := 16#0#;
-- Write-only. Peripheral 8 SleepWalking Enable
PID : PMC_SLPWK_ER0_PID_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_30_31 : Interfaces.SAM.UInt2 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PMC_SLPWK_ER0_Register use record
Reserved_0_7 at 0 range 0 .. 7;
PID at 0 range 8 .. 29;
Reserved_30_31 at 0 range 30 .. 31;
end record;
-- PMC_SLPWK_DR0_PID array
type PMC_SLPWK_DR0_PID_Field_Array is array (8 .. 29) of Boolean
with Component_Size => 1, Size => 22;
-- Type definition for PMC_SLPWK_DR0_PID
type PMC_SLPWK_DR0_PID_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- PID as a value
Val : Interfaces.SAM.UInt22;
when True =>
-- PID as an array
Arr : PMC_SLPWK_DR0_PID_Field_Array;
end case;
end record
with Unchecked_Union, Size => 22;
for PMC_SLPWK_DR0_PID_Field use record
Val at 0 range 0 .. 21;
Arr at 0 range 0 .. 21;
end record;
-- SleepWalking Disable Register 0
type PMC_SLPWK_DR0_Register is record
-- unspecified
Reserved_0_7 : Interfaces.SAM.Byte := 16#0#;
-- Write-only. Peripheral 8 SleepWalking Disable
PID : PMC_SLPWK_DR0_PID_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_30_31 : Interfaces.SAM.UInt2 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PMC_SLPWK_DR0_Register use record
Reserved_0_7 at 0 range 0 .. 7;
PID at 0 range 8 .. 29;
Reserved_30_31 at 0 range 30 .. 31;
end record;
-- PMC_SLPWK_SR0_PID array
type PMC_SLPWK_SR0_PID_Field_Array is array (8 .. 29) of Boolean
with Component_Size => 1, Size => 22;
-- Type definition for PMC_SLPWK_SR0_PID
type PMC_SLPWK_SR0_PID_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- PID as a value
Val : Interfaces.SAM.UInt22;
when True =>
-- PID as an array
Arr : PMC_SLPWK_SR0_PID_Field_Array;
end case;
end record
with Unchecked_Union, Size => 22;
for PMC_SLPWK_SR0_PID_Field use record
Val at 0 range 0 .. 21;
Arr at 0 range 0 .. 21;
end record;
-- SleepWalking Status Register 0
type PMC_SLPWK_SR0_Register is record
-- unspecified
Reserved_0_7 : Interfaces.SAM.Byte;
-- Read-only. Peripheral 8 SleepWalking Status
PID : PMC_SLPWK_SR0_PID_Field;
-- unspecified
Reserved_30_31 : Interfaces.SAM.UInt2;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PMC_SLPWK_SR0_Register use record
Reserved_0_7 at 0 range 0 .. 7;
PID at 0 range 8 .. 29;
Reserved_30_31 at 0 range 30 .. 31;
end record;
-- PMC_SLPWK_ASR0_PID array
type PMC_SLPWK_ASR0_PID_Field_Array is array (8 .. 29) of Boolean
with Component_Size => 1, Size => 22;
-- Type definition for PMC_SLPWK_ASR0_PID
type PMC_SLPWK_ASR0_PID_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- PID as a value
Val : Interfaces.SAM.UInt22;
when True =>
-- PID as an array
Arr : PMC_SLPWK_ASR0_PID_Field_Array;
end case;
end record
with Unchecked_Union, Size => 22;
for PMC_SLPWK_ASR0_PID_Field use record
Val at 0 range 0 .. 21;
Arr at 0 range 0 .. 21;
end record;
-- SleepWalking Activity Status Register 0
type PMC_SLPWK_ASR0_Register is record
-- unspecified
Reserved_0_7 : Interfaces.SAM.Byte;
-- Read-only. Peripheral 8 Activity Status
PID : PMC_SLPWK_ASR0_PID_Field;
-- unspecified
Reserved_30_31 : Interfaces.SAM.UInt2;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PMC_SLPWK_ASR0_Register use record
Reserved_0_7 at 0 range 0 .. 7;
PID at 0 range 8 .. 29;
Reserved_30_31 at 0 range 30 .. 31;
end record;
subtype PMC_PMMR_PLLA_MMAX_Field is Interfaces.SAM.UInt11;
-- PLL Maximum Multiplier Value Register
type PMC_PMMR_Register is record
-- PLLA Maximum Allowed Multiplier Value
PLLA_MMAX : PMC_PMMR_PLLA_MMAX_Field := 16#7FF#;
-- unspecified
Reserved_11_31 : Interfaces.SAM.UInt21 := 16#FFE0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PMC_PMMR_Register use record
PLLA_MMAX at 0 range 0 .. 10;
Reserved_11_31 at 0 range 11 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Power Management Controller
type PMC_Peripheral is record
-- System Clock Enable Register
PMC_SCER : aliased PMC_SCER_Register;
-- System Clock Disable Register
PMC_SCDR : aliased PMC_SCDR_Register;
-- System Clock Status Register
PMC_SCSR : aliased PMC_SCSR_Register;
-- Peripheral Clock Enable Register 0
PMC_PCER0 : aliased PMC_PCER0_Register;
-- Peripheral Clock Disable Register 0
PMC_PCDR0 : aliased PMC_PCDR0_Register;
-- Peripheral Clock Status Register 0
PMC_PCSR0 : aliased PMC_PCSR0_Register;
-- Main Oscillator Register
CKGR_MOR : aliased CKGR_MOR_Register;
-- Main Clock Frequency Register
CKGR_MCFR : aliased CKGR_MCFR_Register;
-- PLLA Register
CKGR_PLLAR : aliased CKGR_PLLAR_Register;
-- PLLB Register
CKGR_PLLBR : aliased CKGR_PLLBR_Register;
-- Master Clock Register
PMC_MCKR : aliased PMC_MCKR_Register;
-- USB Clock Register
PMC_USB : aliased PMC_USB_Register;
-- Programmable Clock 0 Register
PMC_PCK : aliased PMC_PCK_Registers;
-- Interrupt Enable Register
PMC_IER : aliased PMC_IER_Register;
-- Interrupt Disable Register
PMC_IDR : aliased PMC_IDR_Register;
-- Status Register
PMC_SR : aliased PMC_SR_Register;
-- Interrupt Mask Register
PMC_IMR : aliased PMC_IMR_Register;
-- Fast Startup Mode Register
PMC_FSMR : aliased PMC_FSMR_Register;
-- Fast Startup Polarity Register
PMC_FSPR : aliased PMC_FSPR_Register;
-- Fault Output Clear Register
PMC_FOCR : aliased PMC_FOCR_Register;
-- Write Protection Mode Register
PMC_WPMR : aliased PMC_WPMR_Register;
-- Write Protection Status Register
PMC_WPSR : aliased PMC_WPSR_Register;
-- Peripheral Control Register
PMC_PCR : aliased PMC_PCR_Register;
-- Oscillator Calibration Register
PMC_OCR : aliased PMC_OCR_Register;
-- SleepWalking Enable Register 0
PMC_SLPWK_ER0 : aliased PMC_SLPWK_ER0_Register;
-- SleepWalking Disable Register 0
PMC_SLPWK_DR0 : aliased PMC_SLPWK_DR0_Register;
-- SleepWalking Status Register 0
PMC_SLPWK_SR0 : aliased PMC_SLPWK_SR0_Register;
-- SleepWalking Activity Status Register 0
PMC_SLPWK_ASR0 : aliased PMC_SLPWK_ASR0_Register;
-- PLL Maximum Multiplier Value Register
PMC_PMMR : aliased PMC_PMMR_Register;
end record
with Volatile;
for PMC_Peripheral use record
PMC_SCER at 16#0# range 0 .. 31;
PMC_SCDR at 16#4# range 0 .. 31;
PMC_SCSR at 16#8# range 0 .. 31;
PMC_PCER0 at 16#10# range 0 .. 31;
PMC_PCDR0 at 16#14# range 0 .. 31;
PMC_PCSR0 at 16#18# range 0 .. 31;
CKGR_MOR at 16#20# range 0 .. 31;
CKGR_MCFR at 16#24# range 0 .. 31;
CKGR_PLLAR at 16#28# range 0 .. 31;
CKGR_PLLBR at 16#2C# range 0 .. 31;
PMC_MCKR at 16#30# range 0 .. 31;
PMC_USB at 16#38# range 0 .. 31;
PMC_PCK at 16#40# range 0 .. 255;
PMC_IER at 16#60# range 0 .. 31;
PMC_IDR at 16#64# range 0 .. 31;
PMC_SR at 16#68# range 0 .. 31;
PMC_IMR at 16#6C# range 0 .. 31;
PMC_FSMR at 16#70# range 0 .. 31;
PMC_FSPR at 16#74# range 0 .. 31;
PMC_FOCR at 16#78# range 0 .. 31;
PMC_WPMR at 16#E4# range 0 .. 31;
PMC_WPSR at 16#E8# range 0 .. 31;
PMC_PCR at 16#10C# range 0 .. 31;
PMC_OCR at 16#110# range 0 .. 31;
PMC_SLPWK_ER0 at 16#114# range 0 .. 31;
PMC_SLPWK_DR0 at 16#118# range 0 .. 31;
PMC_SLPWK_SR0 at 16#11C# range 0 .. 31;
PMC_SLPWK_ASR0 at 16#120# range 0 .. 31;
PMC_PMMR at 16#130# range 0 .. 31;
end record;
-- Power Management Controller
PMC_Periph : aliased PMC_Peripheral
with Import, Address => PMC_Base;
end Interfaces.SAM.PMC;
|
3-mid/opengl/source/lean/io/opengl-io-wavefront.ads | charlie5/lace | 20 | 22188 | package openGL.IO.wavefront
--
-- Provides a function to convert a Wavefront model file (*.obj) to an openGL IO model.
--
is
---------
-- Group
--
type group_Kind is (object_Name, group_Name,
smoothing_Group, merging_Group);
type Group (Kind : group_Kind := group_Name) is
record
case Kind
is
when object_Name => object_Name : Text;
when group_Name => group_Name : Text;
when smoothing_Group => smooth_group_Id : Natural;
when merging_Group => null;
end case;
end record;
function Image (Self : in Group) return String;
--------
-- Face
--
type face_Kind is (a_Group, a_Facet);
type Face (Kind : face_Kind := a_Facet) is
record
case Kind
is
when a_Group => Group : wavefront.Group;
when a_Facet => Facet : openGL.IO.Face;
end case;
end record;
type Faces is array (long_Index_t range <>) of Face;
function Image (Self : in wavefront.Face) return String;
function to_Model (model_File : in String) return IO.Model;
--------------
-- Deprecated
--
type Model is
record
Sites : access openGL.Sites;
Coords : access openGL.Coordinates_2D;
Normals : access openGL.Normals;
Faces : access wavefront.Faces;
end record;
function to_Model (model_Path : in String) return wavefront.Model;
procedure write (the_Model : in wavefront.Model;
to_File : in String);
end openGL.IO.wavefront;
|
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/concat2.ads | best08618/asylo | 7 | 27647 | <filename>gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/concat2.ads
package Concat2 is
procedure Browse;
end Concat2;
|
pkgs/tools/yasm/src/libyasm/tests/opt-circular1-err.asm | manggoguy/parsec-modified | 2,151 | 88904 | <gh_stars>1000+
times (label-$) db 0
label: db 'Where am I?'
|
programs/oeis/058/A058665.asm | jmorken/loda | 1 | 25719 | ; A058665: a(n) = gcd(n+1, n-Phi(n)).
; 2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,1,1,1,1,3,1,1,1,1,1,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,5,1,1,1,1,1,1,1,1,1,1,3,1,1,1,5,1,1,1,1,1,1,1,3,1,1,1,1,1,1,1,1,1,1,1,7,1,1,1,1,1,1,1,1,1,1,1,3,1,1,1,11,1,1,1,1,1,1,1,1,5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,1,1,1,1,3,1,1,1,1,1,1,1,1,1,1,11,3,1,1,1,1,1,1,1,1,1,1,1,3,1,1,1,1,1,1,1,1,1,1,1,3,1,1,1,5,1,1,1,1,1,1,1,3,1,1,1,1,1,1,5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,1,1,1,1,1,3,1,1,1,1,31,1,5,1
mov $2,$0
cal $0,10 ; Euler totient function phi(n): count numbers <= n and prime to n.
add $0,1
add $2,2
gcd $2,$0
mov $0,4
mul $2,2
sub $2,4
add $3,$2
add $3,1
add $0,$3
mov $1,$0
sub $1,3
div $1,2
add $1,1
|
src/gramatica.g4 | ritanpessoa/Compiladores-CIn | 0 | 3332 | grammar gramatica;
goal : mainClass ( classDeclaration )* EOF;
mainClass : 'class' IDENTIFIER '{' 'public' 'static' 'void' 'main' '(' 'String' '[' ']' IDENTIFIER ')' '{' statement '}' '}';
classDeclaration : 'class' IDENTIFIER ( 'extends' IDENTIFIER )? '{' ( varDeclaration )* ( methodDeclaration )* '}';
varDeclaration : type IDENTIFIER;
methodDeclaration : 'public' type IDENTIFIER '(' ( type IDENTIFIER ( ',' type IDENTIFIER )* )? ')' '{' ( varDeclaration )* ( statement )* 'return' expression ';' '}';
type : 'int' '[' ']' | 'boolean' | 'int' | IDENTIFIER;
statement : '{' ( statement )* '}'
| 'if' '(' expression ')' statement 'else' statement
| 'while' '(' expression ')' statement
| 'System.out.println' '(' expression ')' ';'
| IDENTIFIER '=' expression ';'
| IDENTIFIER '[' expression ']' '=' expression ';';
expression : expression OPERAND expression
| expression '[' expression ']'
| expression '.' 'length'
| expression '.' IDENTIFIER '(' ( expression ( ',' expression )* )? ')'
| INTEGER_LITERAL
| 'true'
| 'false'
| IDENTIFIER
| 'this'
| 'new' 'int' '[' expression ']'
| 'new' IDENTIFIER '(' ')'
| '!' expression
| '(' expression ')';
IDENTIFIER : ([a-zA-Z]|'_')([a-zA-Z]|'_'|[0-9])* ;
OPERAND : ('&&'|'<'|'+'|'-'|'*');
INTEGER_LITERAL : ('-')?[0-9]+;
WS : [' \r\n\t']+ -> skip;
|
src/Tuples.agda | ice1k/Theorems | 1 | 7576 | <filename>src/Tuples.agda
module Tuples where
open import Data.Product
_² : ∀ {a} (A : Set a) → Set a
A ² = A × A
_³ : ∀ {a} (A : Set a) → Set a
A ³ = A × A ²
_⁴ : ∀ {a} (A : Set a) → Set a
A ⁴ = A × A ³
_⁵ : ∀ {a} (A : Set a) → Set a
A ⁵ = A × A ⁴
_⁶ : ∀ {a} (A : Set a) → Set a
A ⁶ = A × A ⁵
_⁷ : ∀ {a} (A : Set a) → Set a
A ⁷ = A × A ⁶
|
oeis/214/A214885.asm | neoneye/loda-programs | 11 | 241454 | ; A214885: a(n) = Sum_{k=0..n} (-1)^k*F(k)*F(k+3), where F=A000045 (Fibonacci numbers).
; Submitted by <NAME>
; 0,-3,2,-14,25,-80,192,-523,1346,-3550,9265,-24288,63552,-166419,435650,-1140590,2986057,-7817648,20466816,-53582875,140281730,-367262398,961505377,-2517253824,6590256000,-17253514275,45170286722,-118257345998
mov $2,$0
seq $0,77916 ; Expansion of (1-x)^(-1)/(1 + 2*x - 2*x^2 - x^3).
sub $0,$2
sub $0,1
|
src/medit.asm | pmwasson/apple2 | 0 | 92917 | <reponame>pmwasson/apple2<filename>src/medit.asm
;-----------------------------------------------------------------------------
; <NAME> - 2021
;-----------------------------------------------------------------------------
; medit - Map editor
;------------------------------------------------
; Zero page usage
;------------------------------------------------
; tilePtr0 := $60 ; Tile pointer
; tilePtr1 := $61
; screenPtr0 := $52 ; Screen pointer
; screenPtr1 := $53
mapPtr0 := $68
mapPtr1 := $69
;-----------------------------------------------------------------------------
; Map Edit
;-----------------------------------------------------------------------------
.proc medit
.proc medit_main
jsr HOME ; clear screen
lda #23 ; put cursor on last line
sta CV
jsr VTAB
; display a greeting
jsr inline_print
.byte "Map editor - ? for help",13,0
jsr HGR
lda #4
sta mapX
sta mapY
lda #3
jsr drawTile
jsr drawBackground
jsr drawMap
command_loop:
jsr inline_print
.byte "Command:",0
skip_prompt:
jsr RDKEY
; Parse command
;------------------
; Q = QUIT
;------------------
cmp #$80 | 'Q'
bne :+
jsr inline_print
.byte "Quit",13,0
bit TXTSET
jmp MONZ ; enter monitor
:
;------------------
; ? = HELP
;------------------
cmp #$80 + '?'
bne :+
jsr inline_print
.byte "Help (ESC when done)",13,0
jsr printHelp
jmp command_loop
:
;------------------
; ESC = Toggle Text
;------------------
cmp #KEY_ESC
bne :+
; dont display anything
lda TEXTMODE
bmi toggle_text_off
bit TXTSET
jmp skip_prompt
toggle_text_off:
bit TXTCLR
jmp skip_prompt
:
;------------------
; TAB = switch tool
;------------------
cmp #$89
bne :+
jsr inline_print
.byte "Switch tool",13,0
rts
:
;------------------
; Unknown
;------------------
jsr inline_print
.byte "Unknown command (? for help)",13,0
jmp command_loop
.endproc
;-----------------------------------------------------------------------------
; printHelp
;-----------------------------------------------------------------------------
.proc printHelp
bit TXTSET
jsr inline_print
.byte " Arrows: Move cursor",13
.byte " !: Dump map",13
.byte " ?: HELP",13
.byte " Q: Quit",13
.byte " Tab: Switch tool",13
.byte " Escape: Toggle text/graphics",13
.byte 0
rts
.endproc
;-----------------------------------------------------------------------------
; drawBackground
;-----------------------------------------------------------------------------
.proc drawBackground
; edit window
lda #1
sta charTop
sta charLeft
lda #18
sta charBottom
lda #38
sta charRight
jsr drawBox
rts
.endproc
;-----------------------------------------------------------------------------
; drawMap
;-----------------------------------------------------------------------------
.proc drawMap
lda #<map
sta mapPtr0
lda #>map
sta mapPtr1
lda #2
sta mapY
vloop:
lda #2
sta mapX
lda #0
sta xoffset
hloop:
ldy xoffset
lda (mapPtr0),y
and #$3f
jsr drawTile
inc xoffset
clc
lda mapX
adc #4
sta mapX
cmp #38
bmi hloop
clc
lda mapPtr0
adc #32
sta mapPtr0
lda mapPtr1
adc #0
sta mapPtr1
clc
lda mapY
adc #2
sta mapY
cmp #18
bmi vloop
;
lda #0
sta charX
sta charY
jsr drawString
.byte "LOC:01,23",0
rts
xoffset: .byte 0
.endproc
;-----------------------------------------------------------------------------
; drawTile
;-----------------------------------------------------------------------------
.proc drawTile
; calculate sprite pointer
sta temp0 ; Save a copy of A
ror
ror
ror ; Multiply by 64
and #$c0
clc
adc tileSheetStart
sta tilePtr0
lda #0
adc tileSheetStart+1
sta tilePtr1
lda temp0
lsr
lsr ; Divide by 4
clc
adc tilePtr1
sta tilePtr1
; calculate screen pointer
ldx mapY
lda mapX
clc
adc lineOffset,x ; + lineOffset
sta screenPtr0
lda linePage,x
sta screenPtr1
clc ; Carry not set in loop, so clear outside of loop
ldx #$08
drawLoop1:
ldy #0
lda (tilePtr0),y
sta (screenPtr0),y
ldy #1
lda (tilePtr0),y
sta (screenPtr0),y
ldy #2
lda (tilePtr0),y
sta (screenPtr0),y
ldy #3
lda (tilePtr0),y
sta (screenPtr0),y
; assumes aligned such that there are no page crossing
lda tilePtr0
adc #4
sta tilePtr0
lda screenPtr1
adc #4
sta screenPtr1
dex
bne drawLoop1
; move to next byte
lda screenPtr0
clc
adc #$80
sta screenPtr0
lda screenPtr1
sbc #$1f ; subtract 20 if no carry, 19 if carry
sta screenPtr1
clc ; Carry not set in loop, so clear outside of loop
ldx #$08
drawLoop2:
ldy #0
lda (tilePtr0),y
sta (screenPtr0),y
ldy #1
lda (tilePtr0),y
sta (screenPtr0),y
ldy #2
lda (tilePtr0),y
sta (screenPtr0),y
ldy #3
lda (tilePtr0),y
sta (screenPtr0),y
; assumes aligned such that there are no page crossing
lda tilePtr0
adc #4
sta tilePtr0
lda screenPtr1
adc #4
sta screenPtr1
dex
bne drawLoop2
rts
; locals
temp0: .byte 0
.endproc
;-----------------------------------------------------------------------------
; data
;-----------------------------------------------------------------------------
mapX: .byte 0
mapY: .byte 0
.align 256
; 32x32 map
map:
.byte "A@@@@GBLBGGGGGAAAAA@@@@@@@@@@@@@"
.byte "A@@@AGAAAAAAAAAAAAAAAAAAAAAAAAAA"
.byte "A@@@AAGAGGGGGGAAAA@@@@@@@@@@@@@@"
.byte "A@@@AGGAAAAAAAAAAAA@@@@@@@@@@@@@"
.byte "AA@@AABBBBAAAAAAAAAAA@@@@@@@@@@@"
.byte "AAHHAIBKBAABAAAAAAAA@@@@@@@@@@@@"
.byte "AAEEAAAAAAAAAAAAAAAAA@@@@@@@@@@@"
.byte "AA@@JJAABAAAAAAAAAA@@@@@@@@@@@@@"
.byte "A@@@@@AABAAAAAAAAA@@@@@@@@@@@@@@"
.byte "@@@@@@JJJJJJJJJJJJ@@@@@@@@@@@@@@"
.byte "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
.byte "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
.byte "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
.byte "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
.byte "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
.byte "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
.byte "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
.byte "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
.byte "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
.byte "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
.byte "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
.byte "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
.byte "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
.byte "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
.byte "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
.byte "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
.byte "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
.byte "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
.byte "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
.byte "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
.byte "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
.byte "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
.endproc |
src/kernel/drivers/motors/motor_cseg.asm | rostislav-nikitin/socOS | 1 | 20099 | <gh_stars>1-10
;=======================================================================================================================
; ;
; Name: socOS (System On Chip Operation System) ;
; Year: 2020 ;
; License: MIT License ;
; ;
;=======================================================================================================================
; Require:
;.include "m8def.inc"
;.include "kernel/drivers/soc/timer2_int.asm"
;.include "kernel/drivers/soc/timer2_dseg.asm"
;.include "kernel/kernel_def.asm"
;.include "kernel/drivers/device_def.asm"
;.include "kernel/drivers/soc/timer_base_def.asm"
;.include "kernel/drivers/soc/timer_w_pwm_base_def.asm"
;.include "kernel/drivers/soc/timer2_def.asm"
;.include "kernel/kernel_cseg.asm"
;.include "kernel/drivers/device_cseg.asm"
;.include "kernel/drivers/soc/timer_base_cseg.asm"
;.include "kernel/drivers/soc/timer_w_pwm_base_cseg.asm"
;.include "kernel/drivers/soc/timer2_cseg.asm"
;.include "../soc/timer2_cseg.asm"
; PWM at PINB[3]
.macro m_motor_init
m_save_r23_Z_registers
; parameters:
; @0 byte TIMER_W_PWM_DIVIDER
; @1 byte power [0x00:0xff]
m_timer2_init @0, POINTER_NULL, TIMER_W_PWM_MODE_FAST, @1, POINTER_NULL
rcall motor_init
.endm
motor_init:
ret
.macro m_motor_start
rcall motor_start
.endm
motor_start:
rcall timer2_counter_control_register_set_mode
ret
.macro m_motor_stop
rcall motor_stop
.endm
motor_stop:
rcall timer2_counter_control_register_set_mode_off
ret
.macro m_motor_power_set
; parameters
; @0 byte power [0x00:0xff]
m_save_r23_registers
ldi r23, @0
rcall motor_power_set
m_restore_r23_registers
.endm
motor_power_set:
; parameters
; r23 byte power [0x00:0xff]
; set mode off (required to change compare control register)
rcall timer2_counter_control_register_set_mode_off
; set compare thershole (to the st_timer2)
rcall timer2_compare_threshold_set
; set compare control register from the st_timer2::compare_threshold
rcall timer2_compare_control_register_set_compare_threshold
; restore mode
rcall timer2_counter_control_register_set_mode
ret |
src/frontend/Experimental_Ada_ROSE_Connection/parser/asis_adapter/source/asis_adapter.ads | rose-compiler/rose | 488 | 13195 | with Ada.Strings.Unbounded;
with A_Nodes;
with Dot;
with Indented_Text;
private with Ada.Exceptions;
private with Ada.Text_IO;
private with Ada.Wide_Text_IO;
private with Asis;
private with Asis.Set_Get;
private with Interfaces.C.Extensions;
private with Interfaces.C.Strings;
private with Unchecked_Conversion;
-- GNAT-specific:
private with A4G.A_Types;
private with Types;
private with a_nodes_h.Support;
-- Contains supporting declarations for child packages
package Asis_Adapter is
-- Controls behavior of Trace_ routines. Renamed here so clients have to
-- with fewer packages:
Trace_On : Boolean renames Indented_Text.Trace_On;
Log_On : Boolean ;
type Outputs_Record is record -- Initialized
Output_Dir : Ada.Strings.Unbounded.Unbounded_String; -- Initialized
A_Nodes : Standard.A_Nodes.Access_Class; -- Initialized
Graph : Dot.Graphs.Access_Class; -- Initialized
Text : Indented_Text.Access_Class; -- Initialized
end record;
-- Raised when a subprogram is called incorrectly:
Usage_Error : Exception;
-- Raised when an external routine fails and the subprogram cannot continue:
External_Error : Exception;
-- Raised when an external routine raises a usage-error-like exception or
-- there is an internal logic error:
Internal_Error : Exception;
private
Module_Name : constant String := "Asis_Adapter";
package AEX renames Ada.Exceptions;
package ASU renames Ada.Strings.Unbounded;
package ATI renames Ada.Text_IO;
package AWTI renames Ada.Wide_Text_IO;
package IC renames Interfaces.C;
package ICE renames Interfaces.C.Extensions;
package ICS renames Interfaces.C.Strings;
package anhS renames a_nodes_h.Support;
function To_String (Item : in Wide_String) return String;
function To_Quoted_String (Item : in Wide_String) return String;
function "+"(Item : in Wide_String) return String renames To_String;
function To_Wide_String (Item : in String) return Wide_String;
function "+"(Item : in String) return Wide_String renames To_Wide_String;
function To_Chars_Ptr (Item : in Wide_String)
return Interfaces.C.Strings.chars_ptr;
function To_Chars_Ptr (Item : in String)
return Interfaces.C.Strings.chars_ptr
renames Interfaces.C.Strings.New_String;
procedure Put (Item : in String) renames ATI.Put;
procedure Put_Line (Item : in String) renames ATI.Put_Line;
procedure Put_Wide (Item : in Wide_String) renames AWTI.Put;
procedure Put_Line_Wide (Item : in Wide_String) renames AWTI.Put_Line;
procedure Trace_Put (Message : in Wide_String) renames
Indented_Text.Trace_Put;
procedure Trace_Put_Line (Message : in Wide_String) renames
Indented_Text.Trace_Put_Line;
-- Provides routines that peofix the output with the name of the current
-- module:
generic
Module_Name : in string;
package Generic_Logging is
procedure Log (Message : in String);
procedure Log_Wide (Message : in Wide_String);
procedure Log_Exception (X : in Aex.Exception_Occurrence);
end Generic_Logging;
-- Returns the image minus the leading space:
function Spaceless_Image (Item : in Natural) return String;
function NLB_Image (Item : in Natural) return String renames Spaceless_Image;
type ID_Kind is (Unit_ID_Kind, Element_ID_Kind);
function To_String
(Id : in IC.int;
Kind : in ID_Kind) return String;
function To_Dot_ID_Type
(Id : in IC.int;
Kind : in ID_Kind)
return Dot.ID_Type;
-- String:
-- Add <Name> => <Value> to the label, and print it if trace is on:
procedure Add_To_Dot_Label
(Dot_Label : in out Dot.HTML_Like_Labels.Class;
Outputs : in out Outputs_Record;
Name : in String;
Value : in String);
-- Boolean:
-- Add <Name> => <Value> to the label, and print it if trace is on:
-- ONLY acts if Value = True:
procedure Add_To_Dot_Label
(Dot_Label : in out Dot.HTML_Like_Labels.Class;
Outputs : in out Outputs_Record;
Name : in String;
Value : in Boolean);
-- String:
-- Add <Value> to the label, and print it if trace is on:
procedure Add_To_Dot_Label
(Dot_Label : in out Dot.HTML_Like_Labels.Class;
Outputs : in out Outputs_Record;
Value : in String);
-- Unit_ID or Element_ID:
-- Add an edge node to the the dot graph:
-- Use for both Unit_ID and Element_ID:
procedure Add_Dot_Edge
(Outputs : in out Outputs_Record;
From : in IC.int;
From_Kind : in ID_Kind;
To : in IC.int;
To_Kind : in ID_Kind;
Label : in String);
-- Order below is alphabetical:
function To_Access_Definition_Kinds is new Unchecked_Conversion
(Source => Asis.Access_Definition_Kinds,
Target => a_nodes_h.Access_Definition_Kinds);
function To_Access_Type_Kinds is new Unchecked_Conversion
(Source => Asis.Access_Type_Kinds,
Target => a_nodes_h.Access_Type_Kinds);
function To_Association_Kinds is new Unchecked_Conversion
(Source => Asis.Association_Kinds,
Target => a_nodes_h.Association_Kinds);
function To_Attribute_Kinds is new Unchecked_Conversion
(Source => Asis.Attribute_Kinds,
Target => a_nodes_h.Attribute_Kinds);
function To_Clause_Kinds is new Unchecked_Conversion
(Source => Asis.Clause_Kinds,
Target => a_nodes_h.Clause_Kinds);
function To_Representation_Clause_Kinds is new Unchecked_Conversion
(Source => Asis.Representation_Clause_Kinds,
Target => a_nodes_h.Representation_Clause_Kinds);
function To_Constraint_Kinds is new Unchecked_Conversion
(Source => Asis.Constraint_Kinds,
Target => a_nodes_h.Constraint_Kinds);
function To_Declaration_Kinds is new Unchecked_Conversion
(Source => Asis.Declaration_Kinds,
Target => a_nodes_h.Declaration_Kinds);
function To_Declaration_Origins is new Unchecked_Conversion
(Source => Asis.Declaration_Origins,
Target => a_nodes_h.Declaration_Origins);
function To_Defining_Name_Kinds is new Unchecked_Conversion
(Source => Asis.Defining_Name_Kinds,
Target => a_nodes_h.Defining_Name_Kinds);
function To_Definition_Kinds is new Unchecked_Conversion
(Source => Asis.Definition_Kinds,
Target => a_nodes_h.Definition_Kinds);
function To_Discrete_Range_Kinds is new Unchecked_Conversion
(Source => Asis.Discrete_Range_Kinds,
Target => a_nodes_h.Discrete_Range_Kinds);
function To_Element_Kinds is new Unchecked_Conversion
(Source => Asis.Element_Kinds,
Target => a_nodes_h.Element_Kinds);
function To_Expression_Kinds is new Unchecked_Conversion
(Source => Asis.Expression_Kinds,
Target => a_nodes_h.Expression_Kinds);
function To_Formal_Type_Kinds is new Unchecked_Conversion
(Source => Asis.Formal_Type_Kinds,
Target => a_nodes_h.Formal_Type_Kinds);
function To_Mode_Kinds is new Unchecked_Conversion
(Source => Asis.Mode_Kinds,
Target => a_nodes_h.Mode_Kinds);
function To_Operator_Kinds is new Unchecked_Conversion
(Source => Asis.Operator_Kinds,
Target => a_nodes_h.Operator_Kinds);
function To_Path_Kinds is new Unchecked_Conversion
(Source => Asis.Path_Kinds,
Target => a_nodes_h.Path_Kinds);
function To_Pragma_Kinds is new Unchecked_Conversion
(Source => Asis.Pragma_Kinds,
Target => a_nodes_h.Pragma_Kinds);
function To_Root_Type_Kinds is new Unchecked_Conversion
(Source => Asis.Root_Type_Kinds,
Target => a_nodes_h.Root_Type_Kinds);
function To_Statement_Kinds is new Unchecked_Conversion
(Source => Asis.Statement_Kinds,
Target => a_nodes_h.Statement_Kinds);
function To_Subprogram_Default_Kinds is new Unchecked_Conversion
(Source => Asis.Subprogram_Default_Kinds,
Target => a_nodes_h.Subprogram_Default_Kinds);
function To_Type_Kinds is new Unchecked_Conversion
(Source => Asis.Type_Kinds,
Target => a_nodes_h.Type_Kinds);
function To_Unit_Classes is new Unchecked_Conversion
(Source => Asis.Unit_Classes,
Target => a_nodes_h.Unit_Classes);
function To_Unit_Kinds is new Unchecked_Conversion
(Source => Asis.Unit_Kinds,
Target => a_nodes_h.Unit_Kinds);
function To_Unit_Origins is new Unchecked_Conversion
(Source => Asis.Unit_Origins,
Target => a_nodes_h.Unit_Origins);
-- End alphabetical order
end Asis_Adapter;
|
src/websitegenerator.adb | bracke/websitegenerator | 1 | 691 | <filename>src/websitegenerator.adb
with Server;
with Templates_Parser;
with Ada.Text_IO; use Ada.Text_IO;
with Generator;
with Ada.Directories;
with Ada.Calendar;
with GNAT.Command_Line; use GNAT.Command_Line;
with Ada.Wide_Wide_Text_IO;
with Ada.Wide_Wide_Text_IO.Text_Streams;
with Ada.Command_Line;
with Ada.Exceptions; use Ada.Exceptions;
with CLIC.Subcommand;
with Commands;
with CLIC.TTY;
procedure Websitegenerator is
use Ada.Calendar;
use Ada.Wide_Wide_Text_IO.Text_Streams;
use Generator.aString;
use Templates_Parser;
Start_Processing, End_Processing : Time;
How_Long : Duration;
S : constant Stream_Access := Stream (Ada.Wide_Wide_Text_IO.Current_Output);
begin
Ada.Text_IO.New_Line;
Start_Processing := Clock;
Commands.Execute;
End_Processing := Clock;
How_Long := (End_Processing - Start_Processing) * 1_000;
Character'Write (S, ASCII.LF);
String'Write (S, "Website generated in ");
Wide_Wide_String'Write (S, How_Long'Wide_Wide_Image);
String'Write (S, "ms!");
Character'Write (S, ASCII.LF);
exception
when E : others =>
Ada.Text_IO.Put_Line (Exception_Message (E));
end Websitegenerator; |
programs/oeis/250/A250756.asm | neoneye/loda | 22 | 25392 | <filename>programs/oeis/250/A250756.asm
; A250756: Number of (1+1) X (n+1) 0..2 arrays with nondecreasing x(i,j)-x(i,j-1) in the i direction and nondecreasing x(i,j)+x(i-1,j) in the j direction.
; 32,72,129,203,294,402,527,669,828,1004,1197,1407,1634,1878,2139,2417,2712,3024,3353,3699,4062,4442,4839,5253,5684,6132,6597,7079,7578,8094,8627,9177,9744,10328,10929,11547,12182,12834,13503,14189,14892,15612,16349,17103,17874,18662,19467,20289,21128,21984,22857,23747,24654,25578,26519,27477,28452,29444,30453,31479,32522,33582,34659,35753,36864,37992,39137,40299,41478,42674,43887,45117,46364,47628,48909,50207,51522,52854,54203,55569,56952,58352,59769,61203,62654,64122,65607,67109,68628,70164,71717,73287,74874,76478,78099,79737,81392,83064,84753,86459
add $0,2
mov $1,$0
mul $0,4
bin $0,2
bin $1,2
add $1,$0
mov $0,$1
add $0,3
|
oeis/135/A135376.asm | neoneye/loda-programs | 11 | 104382 | <reponame>neoneye/loda-programs
; A135376: a(n) = the smallest prime that does not divide n(n+1)/2.
; Submitted by <NAME>
; 2,2,5,3,2,2,3,5,2,2,5,5,2,2,7,3,2,2,3,11,2,2,5,7,2,2,5,3,2,2,3,5,2,2,11,5,2,2,7,3,2,2,3,7,2,2,5,5,2,2,5,3,2,2,3,5,2,2,7,7,2,2,5,3,2,2,3,5,2,2,5,5,2,2,7,3,2,2,3,7,2,2,5,11,2,2,5,3,2,2,3,5,2,2,7,5,2,2,7,3
add $0,2
bin $0,2
pow $0,12
sub $0,1
seq $0,55881 ; a(n) = largest m such that m! divides n.
add $0,1
|
programs/oeis/346/A346878.asm | neoneye/loda | 0 | 247608 | ; A346878: Sum of the divisors, except the largest, of the n-th positive even number.
; 1,3,6,7,8,16,10,15,21,22,14,36,16,28,42,31,20,55,22,50,54,40,26,76,43,46,66,64,32,108,34,63,78,58,74,123,40,64,90,106,44,140,46,92,144,76,50,156,73,117,114,106,56,172,106,136,126,94,62,240,64,100,186,127
add $0,1
mov $1,4
mov $2,$0
lpb $0
mov $3,$2
mov $4,$0
cmp $4,0
add $0,$4
dif $3,$0
cmp $3,$2
cmp $3,0
mul $3,$0
sub $0,1
add $1,$3
add $2,1
lpe
mov $0,$1
sub $0,3
|
tests/dispatch/ulog-gps.adb | TUM-EI-RCS/StratoX | 12 | 29904 | -- Institution: Technische Universitaet Muenchen
-- Department: Realtime Computer Systems (RCS)
-- Project: StratoX
-- Author: <NAME> (<EMAIL>)
with Ada.Text_IO; -- TODO: remove
-- @summary
-- implements ULOG GPS message
package body ULog.GPS with SPARK_Mode is
overriding
procedure Get_Serialization (msg : in Message; bytes : out HIL.Byte_Array) is
begin
-- TODO: serialize the extensions in GPS message
null;
end Get_Serialization;
overriding
procedure Get_Format (msg : in Message; bytes : out HIL.Byte_Array) is
begin
null;
end Get_Format;
function Copy (msg : in Message) return Message is
begin
Ada.Text_IO.Put_Line ("gps copy");
return msg;
end Copy;
overriding
function Get_Size (msg : in Message) return Interfaces.Unsigned_16 is
begin
return 10; -- TODO
end Get_Size;
procedure Describe_Func (msg : in Message; namestring : out String) is
begin
namestring := "gps";
end Describe_Func;
overriding
function Self (msg : in Message) return ULog.Message'Class is
begin
Ada.Text_IO.Put_Line ("Self of ulog.gps");
return Message'(msg);
end Self;
end ULog.GPS;
|
kernel/mm/paging.asm | UtkarshMe/Jazz | 7 | 25588 | <reponame>UtkarshMe/Jazz
; vi:filetype=nasm
global page_directory_load
page_directory_load:
mov eax, [esp + 4]
mov cr3, eax
ret
global paging_enable
paging_enable:
mov eax, cr0
or eax, 0x80000000
_paging_enabling:
mov cr0, eax
ret
|
projects/07/MemoryAccess/PointerTest/PointerTest.asm | l-const/nand2tetris | 0 | 175512 |
//push constant 3030
@3030
D=A
@SP
A=M
M=D
@SP
M=M+1
//pop pointer 0
@3
D=A
@R13
M=D
@SP
AM=M-1
D=M
@R13
A=M
M=D
//push constant 3040
@3040
D=A
@SP
A=M
M=D
@SP
M=M+1
//pop pointer 1
@4
D=A
@R13
M=D
@SP
AM=M-1
D=M
@R13
A=M
M=D
//push constant 32
@32
D=A
@SP
A=M
M=D
@SP
M=M+1
//pop this 2
@2
D=A
@3
A=D+M
D=A
@R13
M=D
@SP
AM=M-1
D=M
@R13
A=M
M=D
//push constant 46
@46
D=A
@SP
A=M
M=D
@SP
M=M+1
//pop that 6
@6
D=A
@4
A=D+M
D=A
@R13
M=D
@SP
AM=M-1
D=M
@R13
A=M
M=D
//push pointer 0
@3
D=M
@SP
A=M
M=D
@SP
M=M+1
//push pointer 1
@4
D=M
@SP
A=M
M=D
@SP
M=M+1
//add
@SP
AM=M-1
D=M
A=A-1
M=M+D
//push this 2
@2
D=A
@3
A=D+M
D=M
@SP
A=M
M=D
@SP
M=M+1
//sub
@SP
AM=M-1
D=M
A=A-1
M=M-D
//push that 6
@6
D=A
@4
A=D+M
D=M
@SP
A=M
M=D
@SP
M=M+1
//add
@SP
AM=M-1
D=M
A=A-1
M=M+D |
dependencies/agar/ada-core/agar-core-database.adb | amvb/GUCEF | 5 | 6905 | with Interfaces.C;
with System.Address_To_Access_Conversions;
with System;
package body Agar.Core.Database is
package C renames Interfaces.C;
use type C.int;
use type C.size_t;
procedure New_Database
(Database_Type : in Type_t;
Database : out Database_Access_t) is
begin
null;
end New_Database;
package body Generic_Database is
package Data_Access_Conversion is new
System.Address_To_Access_Conversions (Object => Data_Type);
function Exists
(Database : in Database_Not_Null_Access_t;
Key : in Key_Type) return Boolean is
begin
return 1 = Thin.DB.Exists_Binary_Key
(DB => Database,
Key_Data => Key'Address,
Key_Size => Key'Size / System.Storage_Unit);
end Exists;
procedure Lookup
(Database : in Database_Not_Null_Access_t;
Key : in Key_Type;
Database_Entry : out Entry_t;
Found : out Boolean)
is
DB_Entry : aliased Thin.DB.Entry_t;
begin
Found := 0 = Thin.DB.Lookup_Binary_Key
(DB => Database,
DB_Entry => DB_Entry'Unchecked_Access,
Key_Data => Key'Address,
Key_Size => Key'Size / System.Storage_Unit);
if Found then
Database_Entry.Data := Data_Type_Access (Data_Access_Conversion.To_Pointer (DB_Entry.Data));
Database_Entry.Data_Size := Natural (DB_Entry.Data_Size);
else
Database_Entry := Null_Entry;
end if;
end Lookup;
function Delete
(Database : in Database_Not_Null_Access_t;
Key : in Key_Type) return Boolean is
begin
return 0 = Thin.DB.Delete_Binary_Key
(DB => Database,
Key_Data => Key'Address,
Key_Size => Key'Size / System.Storage_Unit);
end Delete;
function Put
(Database : in Database_Not_Null_Access_t;
Key : in Key_Type_Access;
Data : in Data_Type_Access) return Boolean
is
DB_Entry : aliased Thin.DB.Entry_t;
begin
DB_Entry.DB := Database;
DB_Entry.Key := Key.all'Address;
DB_Entry.Key_Size := Key'Size / System.Storage_Unit;
DB_Entry.Data := Data.all'Address;
DB_Entry.Data_Size := Data'Size / System.Storage_Unit;
return 0 = Thin.DB.Put
(DB => Database,
DB_Entry => DB_Entry'Unchecked_Access);
end Put;
end Generic_Database;
end Agar.Core.Database;
|
Transynther/x86/_processed/AVXALIGN/_st_zr_sm_/i7-7700_9_0xca_notsx.log_53_1635.asm | ljhsiun2/medusa | 9 | 104563 | .global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r14
push %r8
push %rax
lea addresses_UC_ht+0x735e, %r8
nop
and %rax, %rax
mov $0x6162636465666768, %r14
movq %r14, %xmm2
movups %xmm2, (%r8)
nop
nop
sub %r10, %r10
pop %rax
pop %r8
pop %r14
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r13
push %r9
push %rbx
push %rcx
push %rsi
// Store
mov $0xf9e, %r13
nop
nop
nop
and $34034, %rsi
mov $0x5152535455565758, %r10
movq %r10, %xmm0
movups %xmm0, (%r13)
nop
nop
nop
add $37007, %rsi
// Faulty Load
mov $0xf9e, %r9
nop
nop
xor %r10, %r10
vmovntdqa (%r9), %ymm0
vextracti128 $0, %ymm0, %xmm0
vpextrq $0, %xmm0, %r13
lea oracles, %rbx
and $0xff, %r13
shlq $12, %r13
mov (%rbx,%r13,1), %r13
pop %rsi
pop %rcx
pop %rbx
pop %r9
pop %r13
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0, 'same': False, 'type': 'addresses_P'}, 'OP': 'LOAD'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 0, 'same': True, 'type': 'addresses_P'}, 'OP': 'STOR'}
[Faulty Load]
{'src': {'NT': True, 'AVXalign': False, 'size': 32, 'congruent': 0, 'same': True, 'type': 'addresses_P'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'dst': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 6, 'same': True, 'type': 'addresses_UC_ht'}, 'OP': 'STOR'}
{'00': 20, '58': 33}
58 00 58 00 58 58 58 00 00 00 58 58 00 00 00 58 58 58 58 58 58 58 58 00 58 00 00 00 58 00 00 58 58 58 58 58 00 58 00 58 58 58 58 58 00 58 58 58 58 58 00 00 00
*/
|
smallest/OneByOne/smallest.asm | AbderrhmanAbdellatif/SysPro | 0 | 102262 | segment .text
global smallest
smallest:
push ebp
mov ebp,esp
sub esp,4 ; smallest will be here
mov eax,[ebp+8]
mov [ebp-4],eax ; 1st no is the smallest
mov eax,[ebp+12]
cmp eax,[ebp-4]
jge next1
mov [ebp-4],eax ; 2nd no is the smallest
next1:
mov eax,[ebp+16]
cmp eax,[ebp-4]
jge next2
mov [ebp-4],eax ; 3rd no is the smallest
next2:
mov eax,[ebp+20]
cmp eax,[ebp-4]
jge ending
mov [ebp-4],eax ; 4th no is the smallest
ending:
mov eax,[ebp-4] ; [ebp-4] holds the smallest
mov esp,ebp
pop ebp
ret
|
source/rom10/r10_maps_dl.asm | evanbowman/Red | 5 | 88177 | ;; generated by encode_room_layouts.py
r10_room_data_dl::
;;0.json
DB $0e, $0e, $0e, $0e, $0e, $0e, $0b, $13, $13, $13, $13, $13, $13, $39, $39, $13, $0e, $0e, $0e, $0e, $0e, $0a, $0e, $0b, $3b, $13, $13, $13, $13, $11, $11, $13, $0e, $0e, $0e, $0e, $08, $39, $02, $0e, $0d, $0d, $0d, $0b, $13, $12, $12, $13, $0e, $0e, $0e, $0c, $39, $39, $39, $02, $0a, $0a, $0e, $0c, $3b, $13, $13, $3b, $0e, $0e, $0e, $08, $39, $39, $39, $39, $39, $39, $02, $0e, $0b, $3b, $13, $11, $0a, $0a, $08, $39, $38, $39, $39, $39, $38, $39, $39, $02, $0e, $0b, $13, $12, $39, $39, $39, $39, $39, $38, $39, $39, $39, $39, $39, $39, $0e, $0e, $0b, $3b, $39, $39, $39, $39, $39, $39, $39, $39, $39, $39, $39, $39, $02, $0e, $0e, $0e, $39, $39, $38, $39, $39, $39, $39, $39, $39, $38, $39, $39, $39, $06, $0e, $0e, $38, $39, $39, $39, $39, $39, $39, $39, $39, $39, $39, $39, $39, $06, $0e, $0e, $0d, $0d, $0d, $0d, $0b, $39, $39, $39, $39, $39, $38, $39, $05, $0e, $0e, $0e, $0e, $0e, $0e, $0e, $0c, $39, $39, $39, $39, $39, $39, $39, $06, $0e, $0e, $0e, $0e, $0e, $0e, $0e, $0c, $39, $39, $38, $39, $39, $39, $05, $0e, $0e, $0e, $0e, $0e, $0e, $0e, $0e, $0c, $39, $39, $39, $39, $39, $39, $06, $0e, $0e, $0e, $0e, $0e, $0e, $0e, $0e, $0e, $0b, $39, $39, $39, $39, $05, $0e, $0e, $0e, $0e, $0e, $0e, $0e, $0e, $0e, $0e, $0c, $39, $39, $39, $39, $06, $0e, $0e, $0e, $0e, $0e,
;;1.json
DB $0e, $0e, $08, $11, $11, $11, $11, $11, $11, $11, $11, $11, $02, $0a, $0a, $0e, $0e, $0c, $11, $12, $12, $12, $12, $12, $12, $12, $12, $12, $11, $11, $11, $06, $0e, $0c, $12, $13, $13, $13, $13, $13, $13, $13, $13, $13, $12, $12, $12, $06, $0e, $08, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $06, $0c, $11, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $06, $08, $12, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $06, $39, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $13, $13, $13, $13, $13, $02, $39, $39, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $13, $13, $13, $13, $13, $11, $39, $11, $14, $14, $14, $14, $14, $14, $3a, $3a, $13, $13, $13, $13, $13, $12, $39, $13, $13, $13, $13, $13, $13, $13, $3a, $3a, $13, $13, $13, $13, $13, $13, $0b, $13, $13, $13, $13, $13, $13, $13, $3a, $3a, $13, $13, $13, $13, $13, $13, $0c, $13, $13, $13, $13, $13, $13, $13, $3a, $3a, $13, $13, $13, $13, $13, $13, $0c, $13, $13, $13, $13, $13, $13, $13, $3a, $3a, $13, $13, $13, $13, $13, $13, $0e, $0b, $13, $13, $13, $13, $13, $13, $3a, $3a, $13, $13, $13, $13, $13, $13, $0e, $0e, $0d, $0d, $0d, $0b, $39, $39, $3a, $3a, $05, $0d, $0d, $0d, $0b, $13, $0e, $0e, $0e, $0e, $0e, $0c, $39, $39, $39, $39, $06, $0e, $0e, $0e, $0e, $0b,
r10_room_data_dl_end::
|
Formalization/ClassicalPropositionalLogic/Syntax/Proofs.agda | Lolirofle/stuff-in-agda | 6 | 4083 | module Formalization.ClassicalPropositionalLogic.Syntax.Proofs where
import Lvl
open import Formalization.ClassicalPropositionalLogic.Syntax
open import Relator.Equals.Proofs.Equiv
open import Type.Size.Countable
open import Type
private variable ℓₚ ℓ : Lvl.Level
private variable P : Type{ℓₚ}
-- TODO: How would a proof of this look like?
instance
postulate Formula-is-countably-infinite : ⦃ _ : CountablyInfinite(P) ⦄ → CountablyInfinite(Formula(P))
{-
open import Type.WellOrdering
Formula-W-bijectivity : Bijective(W{A = 𝕟(8)}())
Formula-W-bijectivity = {!!
-}
|
Transynther/x86/_processed/AVXALIGN/_ht_zr_un_/i3-7100_9_0x84_notsx.log_559_1501.asm | ljhsiun2/medusa | 9 | 685 | .global s_prepare_buffers
s_prepare_buffers:
push %r13
push %r15
push %rax
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_D_ht+0x92c6, %rsi
lea addresses_UC_ht+0xb25b, %rdi
nop
nop
nop
add %r15, %r15
mov $15, %rcx
rep movsl
dec %rcx
lea addresses_D_ht+0x1665b, %rax
nop
nop
inc %rbx
mov $0x6162636465666768, %rdi
movq %rdi, %xmm3
movups %xmm3, (%rax)
nop
add $30239, %r15
lea addresses_UC_ht+0x3b13, %rax
nop
xor %r13, %r13
mov $0x6162636465666768, %rdi
movq %rdi, (%rax)
nop
nop
nop
nop
dec %rbx
lea addresses_A_ht+0x5db, %rax
nop
nop
add %rdi, %rdi
and $0xffffffffffffffc0, %rax
vmovntdqa (%rax), %ymm3
vextracti128 $0, %ymm3, %xmm3
vpextrq $0, %xmm3, %rbx
add %r13, %r13
lea addresses_normal_ht+0x1ce5b, %rcx
nop
nop
nop
nop
nop
xor $20714, %rdi
mov $0x6162636465666768, %rsi
movq %rsi, %xmm1
movups %xmm1, (%rcx)
nop
nop
nop
and %rax, %rax
lea addresses_UC_ht+0x84b3, %rsi
lea addresses_UC_ht+0x1b48b, %rdi
nop
nop
sub $21345, %rax
mov $4, %rcx
rep movsq
nop
nop
nop
cmp $31028, %rax
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r15
pop %r13
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r13
push %r9
push %rbx
push %rdx
// Load
mov $0x6de05a0000000093, %rbx
nop
nop
add $3421, %r9
mov (%rbx), %r12w
nop
nop
and $41886, %r13
// Store
lea addresses_A+0x1715b, %r12
nop
nop
nop
nop
inc %r9
mov $0x5152535455565758, %r13
movq %r13, %xmm0
movntdq %xmm0, (%r12)
nop
add %r9, %r9
// Faulty Load
lea addresses_PSE+0x1a65b, %rbx
nop
dec %rdx
vmovaps (%rbx), %ymm5
vextracti128 $1, %ymm5, %xmm5
vpextrq $0, %xmm5, %r9
lea oracles, %r12
and $0xff, %r9
shlq $12, %r9
mov (%r12,%r9,1), %r9
pop %rdx
pop %rbx
pop %r9
pop %r13
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_PSE', 'same': False, 'size': 8, 'congruent': 0, 'NT': True, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_NC', 'same': False, 'size': 2, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_A', 'same': False, 'size': 16, 'congruent': 3, 'NT': True, 'AVXalign': False}, 'OP': 'STOR'}
[Faulty Load]
{'src': {'type': 'addresses_PSE', 'same': True, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_D_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 4, 'same': False}, 'OP': 'REPM'}
{'dst': {'type': 'addresses_D_ht', 'same': False, 'size': 16, 'congruent': 11, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_UC_ht', 'same': False, 'size': 8, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_A_ht', 'same': False, 'size': 32, 'congruent': 5, 'NT': True, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_normal_ht', 'same': False, 'size': 16, 'congruent': 11, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_UC_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM'}
{'ed': 1, 'f8': 2, 'd4': 1, 'e4': 1, 'ca': 1, '44': 1, '02': 14, '45': 535, '00': 2, 'ee': 1}
45 45 45 45 45 45 00 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 02 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 ca 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 02 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 ee 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 ed 45 45 45 02 45 02 45 45 45 45 45 45 45 45 02 45 45 45 45 45 45 45 45 45 45 45 45 45 02 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 02 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 02 45 45 45 45 02 45 45 45 02 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 02 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 44 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 02 45 d4 45 45 45 45 45 45 45 45 45 f8 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 02 45 45 45 45 45 45 45 e4 45 00 45 45 45 45 45 45 45 45 f8 45 45 45 45 45 45 45 02 45 45 45 45 45 45 45 45
*/
|
src/gen/gstreamer-gst_low_level-gstreamer_0_10_gst_basecamerabinsrc_gstcamerabinpreview_h.ads | persan/A-gst | 1 | 24142 | <reponame>persan/A-gst<filename>src/gen/gstreamer-gst_low_level-gstreamer_0_10_gst_basecamerabinsrc_gstcamerabinpreview_h.ads
pragma Ada_2005;
pragma Style_Checks (Off);
pragma Warnings (Off);
with Interfaces.C; use Interfaces.C;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h;
with glib;
with glib.Values;
with System;
-- limited -- with GStreamer.GST_Low_Level.glib_2_0_glib_gthread_h;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h;
package GStreamer.GST_Low_Level.gstreamer_0_10_gst_basecamerabinsrc_gstcamerabinpreview_h is
-- * GStreamer
-- * Copyright (C) 2008 Nokia Corporation <<EMAIL>>
-- * Copyright (C) 2010 <NAME> <<EMAIL>>
-- *
-- * This library is free software; you can redistribute it and/or
-- * modify it under the terms of the GNU Library General Public
-- * License as published by the Free Software Foundation; either
-- * version 2 of the License, or (at your option) any later version.
-- *
-- * This library is distributed in the hope that it will be useful,
-- * but WITHOUT ANY WARRANTY; without even the implied warranty of
-- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- * Library General Public License for more details.
-- *
-- * You should have received a copy of the GNU Library General Public
-- * License along with this library; if not, write to the
-- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-- * Boston, MA 02111-1307, USA.
--
type GstCameraBinPreviewPipelineData is record
pipeline : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElement; -- gst/basecamerabinsrc/gstcamerabinpreview.h:34
appsrc : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElement; -- gst/basecamerabinsrc/gstcamerabinpreview.h:36
filter : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElement; -- gst/basecamerabinsrc/gstcamerabinpreview.h:37
appsink : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElement; -- gst/basecamerabinsrc/gstcamerabinpreview.h:38
vscale : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElement; -- gst/basecamerabinsrc/gstcamerabinpreview.h:39
element : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElement; -- gst/basecamerabinsrc/gstcamerabinpreview.h:41
pending_preview_caps : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps; -- gst/basecamerabinsrc/gstcamerabinpreview.h:43
processing : aliased GLIB.guint; -- gst/basecamerabinsrc/gstcamerabinpreview.h:44
processing_lock : access GStreamer.GST_Low_Level.glib_2_0_glib_gthread_h.GMutex; -- gst/basecamerabinsrc/gstcamerabinpreview.h:45
processing_cond : access GStreamer.GST_Low_Level.glib_2_0_glib_gthread_h.GCond; -- gst/basecamerabinsrc/gstcamerabinpreview.h:46
end record;
pragma Convention (C_Pass_By_Copy, GstCameraBinPreviewPipelineData); -- gst/basecamerabinsrc/gstcamerabinpreview.h:48
-- skipped anonymous struct anon_421
function gst_camerabin_create_preview_pipeline (element : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElement; filter : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElement) return access GstCameraBinPreviewPipelineData; -- gst/basecamerabinsrc/gstcamerabinpreview.h:50
pragma Import (C, gst_camerabin_create_preview_pipeline, "gst_camerabin_create_preview_pipeline");
procedure gst_camerabin_destroy_preview_pipeline (preview : access GstCameraBinPreviewPipelineData); -- gst/basecamerabinsrc/gstcamerabinpreview.h:51
pragma Import (C, gst_camerabin_destroy_preview_pipeline, "gst_camerabin_destroy_preview_pipeline");
function gst_camerabin_preview_pipeline_post (preview : access GstCameraBinPreviewPipelineData; buffer : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer) return GLIB.gboolean; -- gst/basecamerabinsrc/gstcamerabinpreview.h:52
pragma Import (C, gst_camerabin_preview_pipeline_post, "gst_camerabin_preview_pipeline_post");
procedure gst_camerabin_preview_set_caps (preview : access GstCameraBinPreviewPipelineData; caps : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps); -- gst/basecamerabinsrc/gstcamerabinpreview.h:53
pragma Import (C, gst_camerabin_preview_set_caps, "gst_camerabin_preview_set_caps");
function gst_camerabin_preview_set_filter (preview : access GstCameraBinPreviewPipelineData; filter : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElement) return GLIB.gboolean; -- gst/basecamerabinsrc/gstcamerabinpreview.h:54
pragma Import (C, gst_camerabin_preview_set_filter, "gst_camerabin_preview_set_filter");
end GStreamer.GST_Low_Level.gstreamer_0_10_gst_basecamerabinsrc_gstcamerabinpreview_h;
|
C5515_Support_Files/C5515_Lib/dsplib_2.40.00/55x_src/unpacki32.asm | HeroSizy/Sizy | 0 | 28443 | ;***********************************************************
; Version 2.40.00
;***********************************************************
; Function UNPACKI32
; Processor: C55xx
; Decription: Unpacks the output of a Radix-2 DIF complex FFT using bit-reversed input
; data and bit-reversed twiddle table (length N/2, cosine/sine format).
;
; Usage: void unpacki32(DATA *xy, ushort nx);
;
; Copyright Texas instruments Inc, 2000
; History;
; - 11/20/2003 <NAME> initial implementation
;
;************************************************************************************
;
; IDFT of N-point frequency domain sequence obtained from
; a real-valued sequence.
;
; Implementation of the rifft based on the derivation
;
; g(n) n=0:N-1 is a real valued sequence. The RFFT of this signal is
; denoted G(k) k=0:N-1 complex sequence. The objective of the code is to
; recover g(n) based on G(k).
;
; g(n) is split in two real sequences, odd and even part
;
; xe(n) = g(2n) n=0:N/2-1
; xo(n) = g(2n+1) n=0:N/2-1
;
; Form the complex sequence:
;
; x(n) = xe(n) + jxo(n) n=0:N/2-1
;
; The CFFT of x(n)can be expressed as:
;
; X(k) k=0:N/2-1
;
; X(k) = Xe(k) +j*Xo(k) k=0:N/2-1 (1)
;
; The RFFT of g(n)can be expressed as:
;
; G(k) = Xe(k) + W(k,N)Xo(k) k = 0:N/2-1 (2)
; G(N/2+k) = Xe(k) - W(k,N)Xo(k) k = 0:N/2-1 (3)
;
; where W(k,n) = cos(2*PI*k/N)-j*sin(2*PI*k/N)
; W(k,n) = Wr(k)-j*Wi(k)
;
; (2) and (3) yield
;
; Xe(k) = (G(k) + G(N/2+k))/2 k = 0:N/2-1
; Xo(k) = (G(k) - G(N/2+k))/(2*W(k,N)) k = 0:N/2-1
;
; since g(n) is a real valued sequence the DFT has the complex
; conjugate symmetry:
;
; G(k) = G*(N-k) k = 0:N-1 (4)
;
; And since 1/W(k,N) = W(-k, N)
; Therefore:
;
; Xe(k) = (G(k) + G*(N/2-k))/2 k = 0:N/2-1 (5)
; Xo(k) = W(-k,N)(G(k) - G*(N/2-k))/2 k = 0:N/2-1 (6)
;
; Separate in Real and Imag parts:
;
; Xr(k)+j*Xi(k) = (Xer(k)+ j*Xei(k)) +j*(Xor(k)+jXoi(k)) k=0:N/2-1
;
; define:
;
; Grp(k) = (Gr(k) + Gr(N/2-k))/2 k = 0:N/2-1 (7)
; Grm(k) = (Gr(k) - Gr(N/2-k))/2 k = 0:N/2-1 (8)
; Gip(k) = (Gi(k) + Gi(N/2-k))/2 k = 0:N/2-1 (9)
; Gim(k) = (Gi(k) - Gi(N/2-k))/2 k = 0:N/2-1 (10)
;
;
; Xr(k) = 0.5 [Grp(k)-Gip(k)*Wr(k)-Grm(k)*Wi(k)] k = 0:N/2-1 (11)
; Xi(k) = 0.5 [Gim(k)+Grm(k)*Wr(k)-Gip(k)*Wi(k)] k = 0:N/2-1 (12)
; Xr(N/2-k) = 0.5 [Grp(k)+Gip(k)*Wr(k)+Grm(k)*Wi(k)] k = 0:N/2-1 (13)
; Xi(N/2-k) = 0.5 [-Gim(k)+Grm(k)*Wr(k)-Gip(k)*Wi(k)] k = 0:N/2-1 (14)
;
; Special values:
;
; * DC Offset k = 0
;
; Xr(0) = 0.5*0.5*(Gr(0)+Gr(N/2))
; Xi(0) = 0.5*0.5*(Gr(0)-Gr(N/2))
;
; This was derived based on:
;
; Wr(0) = 1
; Wi(0) = 0
; Gi(0) = Gi(N/2) = 0
;
; * Nyquist Frequency k = N/4
;
; Xr(N/4) = 0.5*Gr(N/4)
; Xi(N/4) = -0.5*Gi(N/4)
;
; This was derived based on:
;
; Wr(N/4) = 0
; Wi(N/4) = 1
;
;
;****************************************************************
.mmregs
.cpl_on
.arms_off
.ref twiddle32
;//-----------------------------------------------------------------------------
;// Program section
;//-----------------------------------------------------------------------------
.sect ".text:unpacki32"
.global _unpacki32
_unpacki32:
;//-----------------------------------------------------------------------------
;// Context save / get arguments
;//-----------------------------------------------------------------------------
; upon entry stack aligned on 32-bit boundary
PSH mmap(ST0_55)
PSH mmap(ST1_55)
PSH mmap(ST2_55)
PSH mmap(ST3_55)
AADD #-21,SP ; create local frame
;//-----------------------------------------------------------------------------
;// Initialization code
;//-----------------------------------------------------------------------------
Initialize:
AND #0FF00h,mmap(ST2_55) ; linear addr for CDP,AR2,AR3,AR0, AR1
BSET #6,ST1_55 ; set FRCT
BSET #8,ST1_55 ; set SXMD
; SATD = 0 required for 32-bit multiplication
BCLR #9,ST1_55 ; set SATD
BCLR #15,ST2_55 ; reset ARMS
BCLR #10,ST1_55 ; reset M40
;//-----------------------------------------------------------------------------
;// Unpack for RIFFT
;//
;// T0 = N (Rfft size)
;//
;//
;//
;//-----------------------------------------------------------------------------
MOV XAR0,XAR1 ; AR0 = start ptr input data = Xr[0]
ADD T0,AR1 ; AR1 = end ptr input data
ADD T0,AR1 ; 32-bit data
MOV T0,T1 ; T1 = T0 = RFFT size/2
SFTS T1,#-1 ; T1 = RFFT size/2
SFTS T1,#-1 ; T1 = RFFT size/4 (req. for loop)
SUB #4,AR1 ; AR1 = Xr[N/2-1] - last 32-bit elt
SUB #2,T1 ; loop = N/4 - 2
MOV T1,BRC0 ; and store in repeat counter
AMOV #twiddle32,XAR2 ; pointer to sin and cos tables
AMOV #(twiddle32+2),XAR3 ; 32-bit values (add 2)
AMAR *(AR2+T0B) ; set to 2nd entry of bit reversed
AMAR *(AR3+T0B) ; sin/cos table
; T0 = RFFT size for bitrev because 32-bit values
MOV XSP,XAR4 ; XAR4 local var ptr (stack)
ADD #4, AR4
;--------------------------------------------------------------------------------
; Step1:
; Special values X(0):
;
; * DC Offset k = 0
;
; Xr(0) = 0.5*0.5 (Gr(0)+Gi(N/2))
; Xi(0) = 0.5*0.5 (Gr(0)-Gi(N/2))
;
; Note: Gi(N/2) is stored as the imag part of G(0).
;
;--------------------------------------------------------------------------------
MOV dbl(*AR0+),AC1 ; AC1 = Gr[0]
ADD dbl(*AR0),AC1,AC0 ; AC0 = Gr[0] + Gi[N/2]
SUB dbl(*AR0-),AC1,AC1 ; AC1 = Gr[0] - Gi[N/2]
SFTS AC0, #-2 ; 0.25x
SFTS AC1, #-2 ; 0.25x
MOV AC0, dbl(*AR0+) ; Xr(0)
MOV AC1, dbl(*AR0+) ; Xi(0)
;--------------------------------------------------------------------------------
; Step 2:
;
; General loop X(k) k=1:N/2-1 k<>N/4 (X(k)&X(N/2-k) computed in same iteration)
;
; Grp(k) = 0.5 (Gr(k) + Gr(N/2-k)) k = 1:N/4-1
; Grm(k) = 0.5 (Gr(k) - Gr(N/2-k)) k = 1:N/4-1
; Gip(k) = 0.5 (Gi(k) + Gi(N/2-k)) k = 1:N/4-1
; Gim(k) = 0.5 (Gi(k) - Gi(N/2-k)) k = 1:N/4-1
;
;--------------------------------------------------------------------------------
RPTB unpack_end ; setup loopcounter (RFFT-size)/4 - 2
MOV dbl(*AR0+),AC1 ; AC1 = Gr[k]
ADD dbl(*AR1),AC1,AC0 ; Grp = AC0 = Gr[k] + Gr[N/2-k]
SUB dbl(*AR1+),AC1,AC3 ; Grm = AC3 = Gr[k] - Gr[N/2-k]
MOV dbl(*AR0-),AC2 ; AC2 = Gi[k]
ADD dbl(*AR1), AC2, AC1 ; Gip = AC1 = Gi[k] + Gi[N/2-k]
SUB dbl(*AR1-),AC2,AC2 ; Gim = AC2 = Gi[k] - Gi[N/2-k]
SFTS AC0,#-1 ; Grp = 0.5*AC0
SFTS AC1,#-1 ; Gip = 0.5*AC1
SFTS AC2,#-1 ; Gim = 0.5*AC2
SFTS AC3,#-1 ; Grm = 0.5*AC3
MOV AC0 ,dbl(*SP(#00h)) ; save Grp
MOV AC1 ,dbl(*SP(#04h)) ; save Gip
MOV AC2 ,dbl(*SP(#02h)) ; save Gim
MOV AC3 ,dbl(*SP(#06h)) ; save Grm
;-----------------------------------------------------------------------
;
; Output for N/2-point CIFFT
;
; Xr(k) = 0.5 [Grp(k)-Gip(k)*Wr(k)-Grm(k)*Wi(k)]
; Xi(k) = 0.5 [Gim(k)+Grm(k)*Wr(k)-Gip(k)*Wi(k)]
; Xr(N/2-k) = 0.5 [Grp(k)+Gip(k)*Wr(k)+Grm(k)*Wi(k)]
; Xi(N/2-k) = 0.5 [-Gim(k)+Grm(k)*Wr(k)-Gip(k)*Wi(k)]
;
; Wr(k) = cos(2Pik/N)
; Wi(k) = sin(2Pik/N)
;
;--------------------------------------------------------------------------------
; Wr(k)Gip(k)
; AR2 -> cos_H
; cos_L
;
; AR4 -> Gip_H
; Gip_L
;
AMAR *AR2+
MPYM uns(*AR2-), *AR4+, AC0 ; AC0 = cos_L*Gip_H
MACM *AR2, uns(*AR4-), AC0 ; AC0 = AC0 + cos_H*Gip_L
MACM *AR2+, *AR4, AC0 >> #16, AC0 ; AC0 = AC0>>16 + cos_H*Gip_H
MOV AC0 ,dbl(*SP(#08h)) ; save cos*Gip
; Wi(k)Gip(k)
; AR3 -> sin_H
; sin_L
;
; AR4 -> Gip_H
; Gip_L
;
AMAR *AR3+
MPYM uns(*AR3-), *AR4+, AC0 ; AC0 = sin_L*Gip_H
MACM *AR3, uns(*AR4-), AC0 ; AC0 = AC0 + sin_H*Gip_L
MACM *AR3+, *AR4+, AC0 >> #16, AC0 ; AC0 = AC0>>16 + sin_H*Gip_H
MOV AC0 ,dbl(*SP(#0Ah)) ; save sin*Gip
AMAR *AR4+
; Wr(k)Grm(k)
; cos_H
; AR2 -> cos_L
;
; AR4 -> Grm_H
; Grm_L
;
MPYM uns(*AR2-), *AR4+, AC0 ; AC0 = cos_L*Grm_H
MACM *AR2, uns(*AR4-), AC0 ; AC0 = AC0 + cos_H*Grm_L
MACM *AR2, *AR4, AC0 >> #16, AC0 ; AC0 = AC0>>16 + cos_H*Grm_H
MOV AC0 ,dbl(*SP(#0Ch)) ; save cos*Grm
; Wi(k)Grm(k)
; sin_H
; AR3 -> sin_L
;
; AR4 -> Grm_H
; Grm_L
;
MPYM uns(*AR3-), *AR4+, AC0 ; AC0 = sin_L*Grm_H
MACM *AR3, uns(*AR4-), AC0 ; AC0 = AC0 + sin_H*Grm_L
MACM *AR3, *AR4, AC0 >> #16, AC0 ; AC0 = AC0>>16 + sin_H*Grm_H
MOV AC0 ,dbl(*SP(#0Eh)) ; save sin*Grm
; update AR4, local var pointer for next loop iteration
SUB #2, AR4
; update the sin/cos pointers
; bit-reversed addressing used because twiddle table
; is in bit-reversed format and normal format is needed
; in this algorithm.
; AR2 -> cos_H
; cos_L
; AR3 -> sin_H
; sin_L
AMAR *(AR3+T0B) ; sin
AMAR *(AR2+T0B) ; cos
; Xr(k) =0.5 [Grp(k)-Gip(k)*Wr(k)-Grm(k)*Wi(k)]
MOV dbl(*SP(#00h)),AC0 ; AC0 = Grp(k)
SUB dbl(*SP(#08h)),AC0,AC1 ; AC1 = Grp(k)-Wr(k)Gip(k)
SUB dbl(*SP(#0Eh)),AC1,AC1 ; AC1 = Grp(k)-Wr(k)Gip(k)-Wi(k)Grm(k)
SFTS AC1, #-1 ; 0.5x
MOV AC1, dbl(*AR0+) ; Xr(k)
; Xi(k) =0.5 [Gim(k)+Grm(k)*Wr(k)-Gip(k)*Wi(k)]
MOV dbl(*SP(#02h)),AC1 ; AC1 = Gim(k)
ADD dbl(*SP(#0Ch)),AC1,AC2 ; AC2 = Gim(k)+ Wr(k)Grm(k)
SUB dbl(*SP(#0Ah)),AC2,AC2 ; AC2 = Gim(k)+ Wr(k)Grm(k)-Wi(k)Gip(k)
SFTS AC2, #-1 ; 0.5x
MOV AC2, dbl(*AR0+) ; Xi(k)
; Xr(N/2-k) =0.5 [Grp(k)+Gip(k)*Wr(k)+Grm(k)*Wi(k)]
MOV dbl(*SP(#00h)),AC1 ; AC1 = Grp(k)
ADD dbl(*SP(#08h)),AC1,AC2 ; AC2 = Grp(k)+ Wr(k)Gip(k)
ADD dbl(*SP(#0Eh)),AC2,AC2 ; AC2 = Grp(k)+ Wr(k)Gip(k)+Wi(k)Grm(k)
SFTS AC2, #-1 ; 0.5x
MOV AC2, dbl(*AR1+) ; Xr(N/2-k)
; Xi(N/2-k) =0.5 [-Gim(k)+Grm(k)*Wr(k)-Gip(k)*Wi(k)]
MOV dbl(*SP(#0Ch)),AC1 ; AC1 = Wr(k)Grm(k)
SUB dbl(*SP(#02h)),AC1,AC2 ; AC2 = -Gim(k)+ Wr(k)Grm(k)
SUB dbl(*SP(#0Ah)),AC2,AC2 ; AC2 = -Gim(k)+ Wr(k)Grm(k)-Wi(k)Gip(k)
SFTS AC2, #-1 ; 0.5x
MOV AC2, dbl(*AR1) ; Xi(N/2-k)
unpack_end: SUB #6,AR1 ; adjust to Gr(N/2-k-1)
;--------------------------------------------------------------------------------
; Step3:
; Special values G(N/4):
;
; Gr(N/4) = 0.5 Xr(N/4)
; Gi(N/4) =-0.5 Xi(N/4)
;
;//-----------------------------------------------------------------------------
MOV dbl(*AR0+),AC0 ; Xr(N/4)
MOV dbl(*AR0-) ,AC1 ; Xi(N/4)
NEG AC1,AC1 ;-Xi(N/4)
SFTS AC0,#-1,AC0 ; 0.5*Xr(N/4)
SFTS AC1,#-1,AC1 ;-0.5*Xi(N/4)
MOV AC0 ,dbl(*AR0+) ;Gr(N/4) = 0.5 Xr(N/4)
MOV AC1 ,dbl(*AR0+) ;Gi(N/4) =-0.5 Xi(N/4)
;//-----------------------------------------------------------------------------
;// Context restore
;//-----------------------------------------------------------------------------
AADD #21,SP ; destroy local frame
;//-----------------------------------------------------------------------------
;// Return
;//-----------------------------------------------------------------------------
POP mmap(ST3_55)
POP mmap(ST2_55)
POP mmap(ST1_55)
POP mmap(ST0_55)
RET
.end
|
src/model/hyperion-agents-models.ads | stcarrez/hyperion | 0 | 28295 | <reponame>stcarrez/hyperion
-----------------------------------------------------------------------
-- Hyperion.Agents.Models -- Hyperion.Agents.Models
-----------------------------------------------------------------------
-- File generated by ada-gen DO NOT MODIFY
-- Template used: templates/model/package-spec.xhtml
-- Ada Generator: https://ada-gen.googlecode.com/svn/trunk Revision 1095
-----------------------------------------------------------------------
-- Copyright (C) 2019 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
pragma Warnings (Off);
with ADO.Sessions;
with ADO.Objects;
with ADO.Statements;
with ADO.SQL;
with ADO.Schemas;
with Ada.Calendar;
with Ada.Containers.Vectors;
with Ada.Strings.Unbounded;
with Util.Beans.Objects;
with Util.Beans.Basic.Lists;
pragma Warnings (On);
package Hyperion.Agents.Models is
pragma Style_Checks ("-mr");
type Agent_Ref is new ADO.Objects.Object_Ref with null record;
-- --------------------
-- The Agent table holds the information about a monitoring agent
-- who is allowed to connect to the Hyperion server.
-- --------------------
-- Create an object key for Agent.
function Agent_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key;
-- Create an object key for Agent from a string.
-- Raises Constraint_Error if the string cannot be converted into the object key.
function Agent_Key (Id : in String) return ADO.Objects.Object_Key;
Null_Agent : constant Agent_Ref;
function "=" (Left, Right : Agent_Ref'Class) return Boolean;
-- Set the agent identifier
procedure Set_Id (Object : in out Agent_Ref;
Value : in ADO.Identifier);
-- Get the agent identifier
function Get_Id (Object : in Agent_Ref)
return ADO.Identifier;
-- Set the agent host name
procedure Set_Hostname (Object : in out Agent_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Set_Hostname (Object : in out Agent_Ref;
Value : in String);
-- Get the agent host name
function Get_Hostname (Object : in Agent_Ref)
return Ada.Strings.Unbounded.Unbounded_String;
function Get_Hostname (Object : in Agent_Ref)
return String;
-- Set the IP address
procedure Set_Ip (Object : in out Agent_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Set_Ip (Object : in out Agent_Ref;
Value : in String);
-- Get the IP address
function Get_Ip (Object : in Agent_Ref)
return Ada.Strings.Unbounded.Unbounded_String;
function Get_Ip (Object : in Agent_Ref)
return String;
-- Set the agent key
procedure Set_Key (Object : in out Agent_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Set_Key (Object : in out Agent_Ref;
Value : in String);
-- Get the agent key
function Get_Key (Object : in Agent_Ref)
return Ada.Strings.Unbounded.Unbounded_String;
function Get_Key (Object : in Agent_Ref)
return String;
-- Set the date when the agent was registered
procedure Set_Create_Date (Object : in out Agent_Ref;
Value : in Ada.Calendar.Time);
-- Get the date when the agent was registered
function Get_Create_Date (Object : in Agent_Ref)
return Ada.Calendar.Time;
-- Load the entity identified by 'Id'.
-- Raises the NOT_FOUND exception if it does not exist.
procedure Load (Object : in out Agent_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier);
-- Load the entity identified by 'Id'.
-- Returns True in <b>Found</b> if the object was found and False if it does not exist.
procedure Load (Object : in out Agent_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean);
-- Find and load the entity.
overriding
procedure Find (Object : in out Agent_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
-- Save the entity. If the entity does not have an identifier, an identifier is allocated
-- and it is inserted in the table. Otherwise, only data fields which have been changed
-- are updated.
overriding
procedure Save (Object : in out Agent_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
-- Delete the entity.
overriding
procedure Delete (Object : in out Agent_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
function Get_Value (From : in Agent_Ref;
Name : in String) return Util.Beans.Objects.Object;
-- Table definition
AGENT_TABLE : constant ADO.Schemas.Class_Mapping_Access;
-- Internal method to allocate the Object_Record instance
overriding
procedure Allocate (Object : in out Agent_Ref);
-- Copy of the object.
procedure Copy (Object : in Agent_Ref;
Into : in out Agent_Ref);
private
AGENT_NAME : aliased constant String := "hyperion_agent";
COL_0_1_NAME : aliased constant String := "id";
COL_1_1_NAME : aliased constant String := "hostname";
COL_2_1_NAME : aliased constant String := "ip";
COL_3_1_NAME : aliased constant String := "key";
COL_4_1_NAME : aliased constant String := "create_date";
AGENT_DEF : aliased constant ADO.Schemas.Class_Mapping :=
(Count => 5,
Table => AGENT_NAME'Access,
Members => (
1 => COL_0_1_NAME'Access,
2 => COL_1_1_NAME'Access,
3 => COL_2_1_NAME'Access,
4 => COL_3_1_NAME'Access,
5 => COL_4_1_NAME'Access)
);
AGENT_TABLE : constant ADO.Schemas.Class_Mapping_Access
:= AGENT_DEF'Access;
Null_Agent : constant Agent_Ref
:= Agent_Ref'(ADO.Objects.Object_Ref with null record);
type Agent_Impl is
new ADO.Objects.Object_Record (Key_Type => ADO.Objects.KEY_INTEGER,
Of_Class => AGENT_DEF'Access)
with record
Hostname : Ada.Strings.Unbounded.Unbounded_String;
Ip : Ada.Strings.Unbounded.Unbounded_String;
Key : Ada.Strings.Unbounded.Unbounded_String;
Create_Date : Ada.Calendar.Time;
end record;
type Agent_Access is access all Agent_Impl;
overriding
procedure Destroy (Object : access Agent_Impl);
overriding
procedure Find (Object : in out Agent_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
overriding
procedure Load (Object : in out Agent_Impl;
Session : in out ADO.Sessions.Session'Class);
procedure Load (Object : in out Agent_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class);
overriding
procedure Save (Object : in out Agent_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Create (Object : in out Agent_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
procedure Delete (Object : in out Agent_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Set_Field (Object : in out Agent_Ref'Class;
Impl : out Agent_Access);
end Hyperion.Agents.Models;
|
Task/Parsing-RPN-to-infix-conversion/Ada/parsing-rpn-to-infix-conversion-1.ada | LaudateCorpus1/RosettaCodeData | 1 | 29920 | type Priority is range 1..4;
type Infix is record
Precedence : Priority;
Expression : Unbounded_String;
end record;
package Expression_Stack is new Generic_Stack (Infix);
use Expression_Stack;
function Convert (RPN : String) return String is
Arguments : Stack;
procedure Pop
( Operation : Character;
Precedence : Priority;
Association : Priority
) is
Right, Left : Infix;
Result : Infix;
begin
Pop (Right, Arguments);
Pop (Left, Arguments);
Result.Precedence := Association;
if Left.Precedence < Precedence then
Append (Result.Expression, '(');
Append (Result.Expression, Left.Expression);
Append (Result.Expression, ')');
else
Append (Result.Expression, Left.Expression);
end if;
Append (Result.Expression, ' ');
Append (Result.Expression, Operation);
Append (Result.Expression, ' ');
if Right.Precedence < Precedence then
Append (Result.Expression, '(');
Append (Result.Expression, Right.Expression);
Append (Result.Expression, ')');
else
Append (Result.Expression, Right.Expression);
end if;
Push (Result, Arguments);
end Pop;
Pointer : Integer := RPN'First;
begin
while Pointer <= RPN'Last loop
case RPN (Pointer) is
when ' ' =>
Pointer := Pointer + 1;
when '0'..'9' =>
declare
Start : constant Integer := Pointer;
begin
loop
Pointer := Pointer + 1;
exit when Pointer > RPN'Last
or else RPN (Pointer) not in '0'..'9';
end loop;
Push
( ( 4,
To_Unbounded_String (RPN (Start..Pointer - 1))
),
Arguments
);
end;
when '+' | '-' =>
Pop (RPN (Pointer), 1, 1);
Pointer := Pointer + 1;
when '*' | '/' =>
Pop (RPN (Pointer), 2, 2);
Pointer := Pointer + 1;
when '^' =>
Pop (RPN (Pointer), 4, 3);
Pointer := Pointer + 1;
when others =>
raise Constraint_Error with "Syntax";
end case;
end loop;
declare
Result : Infix;
begin
Pop (Result, Arguments);
return To_String (Result.Expression);
end;
end Convert;
|
oeis/068/A068079.asm | neoneye/loda-programs | 11 | 161979 | <reponame>neoneye/loda-programs<gh_stars>10-100
; A068079: Decimal expansion of 355 / 113.
; Submitted by <NAME>
; 3,1,4,1,5,9,2,9,2,0,3,5,3,9,8,2,3,0,0,8,8,4,9,5,5,7,5,2,2,1,2,3,8,9,3,8,0,5,3,0,9,7,3,4,5,1,3,2,7,4,3,3,6,2,8,3,1,8,5,8,4,0,7,0,7,9,6,4,6,0,1,7,6,9,9,1,1,5,0,4,4,2,4,7,7,8,7,6,1,0,6,1,9,4,6,9,0,2,6,5
mov $2,10
pow $2,$0
mul $2,1420
div $2,452
mov $0,$2
mod $0,10
|
programs/oeis/026/A026646.asm | neoneye/loda | 22 | 96185 | <filename>programs/oeis/026/A026646.asm<gh_stars>10-100
; A026646: a(n) = Sum_{0<=i,j<=n} A026637(i,j).
; 1,3,7,17,37,79,163,333,673,1355,2719,5449,10909,21831,43675,87365,174745,349507,699031,1398081,2796181,5592383,11184787,22369597,44739217,89478459,178956943,357913913,715827853,1431655735
mov $2,$0
add $0,3
mov $1,2
pow $1,$0
div $1,3
sub $1,$2
sub $1,1
mov $0,$1
|
alloy4fun_models/trashltl/models/6/oggr4hLQ5YZBtBZhb.als | Kaixi26/org.alloytools.alloy | 0 | 4239 | open main
pred idoggr4hLQ5YZBtBZhb_prop7 {
some f: File | f in File implies eventually f' in Protected
}
pred __repair { idoggr4hLQ5YZBtBZhb_prop7 }
check __repair { idoggr4hLQ5YZBtBZhb_prop7 <=> prop7o } |
alloy4fun_models/trainstlt/models/8/hR6xXsXco5e9GdZxY.als | Kaixi26/org.alloytools.alloy | 0 | 5157 | <gh_stars>0
open main
pred idhR6xXsXco5e9GdZxY_prop9 {
(all t:Train |some (t.pos.prox & Entry )implies eventually ( some t.pos and t.pos in Entry) )
}
pred __repair { idhR6xXsXco5e9GdZxY_prop9 }
check __repair { idhR6xXsXco5e9GdZxY_prop9 <=> prop9o } |
programs/oeis/054/A054868.asm | neoneye/loda | 22 | 160742 | <gh_stars>10-100
; A054868: Sum of bits of sum of bits of n: a(n) = wt(wt(n)).
; 0,1,1,1,1,1,1,2,1,1,1,2,1,2,2,1,1,1,1,2,1,2,2,1,1,2,2,1,2,1,1,2,1,1,1,2,1,2,2,1,1,2,2,1,2,1,1,2,1,2,2,1,2,1,1,2,2,1,1,2,1,2,2,2,1,1,1,2,1,2,2,1,1,2,2,1,2,1,1,2,1,2,2,1,2,1,1,2,2,1,1,2,1,2,2,2,1,2,2,1
seq $0,120 ; 1's-counting sequence: number of 1's in binary expansion of n (or the binary weight of n).
seq $0,120 ; 1's-counting sequence: number of 1's in binary expansion of n (or the binary weight of n).
|
Type/Dependent.agda | Lolirofle/stuff-in-agda | 6 | 11635 | module Type.Dependent where
import Lvl
open import Type
private
module Module where
-- Dependent product type (pi-type).
-- Also called: Dependent function type.
-- The right-hand side's type is a function type that uses the left-hand side's type as its "domain".
-- And then the type of the resulting function of the two types depends on the argument.
record Π {ℓ₁ ℓ₂} (A : Type{ℓ₁}) (B : A → Type{ℓ₂}) : Type{ℓ₁ Lvl.⊔ ℓ₂} where
constructor intro
field
apply : (a : A) → B(a)
-- Dependent sum type (sigma-type).
-- Also called: Dependent pair type.
-- The right-hand side's type is a function type that uses the left-hand side's type as its "domain".
-- And then the type of the resulting pair depends on the left-hand side.
record Σ {ℓ₁ ℓ₂} (A : Type{ℓ₁}) (B : A → Type{ℓ₂}) : Type{ℓ₁ Lvl.⊔ ℓ₂} where
constructor intro
field
left : A
right : B(left)
ℰ : ∀{ℓ₁ ℓ₂}{A : Type{ℓ₁}} → (A → Type{ℓ₂}) → Type{ℓ₁ Lvl.⊔ ℓ₂}
ℰ {A = A} B = Module.Σ A B
module ℰ where
pattern intro {left} right = Module.intro left right
open Module public
{-# BUILTIN SIGMA Σ #-}
|
MPI/Lab-5/asc_order.asm | vishwas1101/Misc | 0 | 98699 | <filename>MPI/Lab-5/asc_order.asm
org 100h
MOV SI, 0500H
MOV CL, [SI]
DEC CL
L1:
MOV SI, 0500H
MOV CH, [SI]
DEC CH
INC SI
L2:
MOV AL, [SI]
INC SI
CMP AL, [SI]
JC L3
XCHG AL, [SI]
DEC SI
XCHG AL, [SI]
INC SI
L3:
DEC CH
JNZ L2
DEC CL
JNZ L1
HLT
ret
|
programs/oeis/081/A081598.asm | neoneye/loda | 22 | 13431 | ; A081598: Let n = 10x + y where 0 <= y <= 9, x >= 0. Then a(n) = 7x+y.
; 0,1,2,3,4,5,6,7,8,9,7,8,9,10,11,12,13,14,15,16,14,15,16,17,18,19,20,21,22,23,21,22,23,24,25,26,27,28,29,30,28,29,30,31,32,33,34,35,36,37,35,36,37,38,39,40,41,42,43,44,42,43,44,45,46,47,48,49,50,51,49,50,51,52,53,54,55,56,57,58,56,57,58,59,60,61,62,63,64,65,63,64,65,66,67,68,69,70,71,72
mov $1,$0
div $1,10
mul $1,3
sub $0,$1
|
oeis/270/A270084.asm | neoneye/loda-programs | 11 | 586 | <gh_stars>10-100
; A270084: Number of active (ON,black) cells at stage 2^n-1 of the two-dimensional cellular automaton defined by "Rule 65", based on the 5-celled von Neumann neighborhood.
; Submitted by <NAME>(s4)
; 1,4,36,188,876,3788,15756,64268,259596,1043468,4184076,16756748,67067916,268353548,1073577996,4294639628
mov $1,2
lpb $0
sub $0,1
mov $2,$1
mov $3,2
add $3,$1
add $1,$3
pow $4,2
add $4,5
mov $5,$4
mov $4,$1
sub $5,$2
lpe
mov $0,$5
add $0,1
|
u7si/eop-dropToPresetDestination.asm | JohnGlassmyer/UltimaHacks | 68 | 95058 | <filename>u7si/eop-dropToPresetDestination.asm<gh_stars>10-100
%include "include/u7si-all-includes.asm"
%assign PLACE_ITEM_SOUND 134
%include "../u7-common/patch-eop-dropToPresetDestination.asm"
|
unittests/32Bit_ASM/X87/D9_FF.asm | cobalt2727/FEX | 628 | 85354 | <filename>unittests/32Bit_ASM/X87/D9_FF.asm
%ifdef CONFIG
{
"RegData": {
"MM7": ["0xD51132BA9B902522", "0xBFFD"]
},
"Mode": "32BIT"
}
%endif
lea edx, [data]
fld tword [edx + 8 * 0]
fcos
hlt
align 8
data:
dt 2.0
dq 0
|
programs/oeis/311/A311536.asm | karttu/loda | 0 | 2890 | <reponame>karttu/loda
; A311536: Coordination sequence Gal.6.120.2 where G.u.t.v denotes the coordination sequence for a vertex of type v in tiling number t in the Galebach list of u-uniform tilings.
; 1,4,8,12,17,22,27,32,37,42,46,50,54,58,62,66,71,76,81,86,91,96,100,104,108,112,116,120,125,130,135,140,145,150,154,158,162,166,170,174,179,184,189,194,199,204,208,212,216,220
mov $2,$0
add $2,1
mov $4,$0
lpb $2,1
mov $0,$4
sub $2,1
sub $0,$2
mov $3,$0
lpb $0,1
sub $0,1
add $3,2
div $3,2
mod $3,6
add $3,1
lpe
add $3,1
add $1,$3
lpe
|
tests/natools-smaz-tests.adb | faelys/natools | 0 | 15667 | ------------------------------------------------------------------------------
-- Copyright (c) 2015-2017, <NAME> --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
with Ada.Strings.Unbounded;
with Natools.Smaz.Original;
package body Natools.Smaz.Tests is
function Dict_Without_VLV return Dictionary;
function Image (S : Ada.Streams.Stream_Element_Array) return String;
procedure Roundtrip_Test
(Test : in out NT.Test;
Dict : in Dictionary;
Decompressed : in String;
Compressed : in Ada.Streams.Stream_Element_Array);
------------------------------
-- Local Helper Subprograms --
------------------------------
function Dict_Without_VLV return Dictionary is
begin
return Dict : Dictionary := Original.Dictionary do
Dict.Variable_Length_Verbatim := False;
end return;
end Dict_Without_VLV;
function Image (S : Ada.Streams.Stream_Element_Array) return String is
use Ada.Strings.Unbounded;
Result : Unbounded_String;
begin
for I in S'Range loop
Append (Result, Ada.Streams.Stream_Element'Image (S (I)));
end loop;
return To_String (Result);
end Image;
procedure Roundtrip_Test
(Test : in out NT.Test;
Dict : in Dictionary;
Decompressed : in String;
Compressed : in Ada.Streams.Stream_Element_Array)
is
use type Ada.Streams.Stream_Element_Array;
use type Ada.Streams.Stream_Element_Offset;
begin
declare
First_OK : Boolean := False;
begin
declare
Buffer : constant Ada.Streams.Stream_Element_Array
:= Compress (Dict, Decompressed);
begin
First_OK := True;
if Buffer /= Compressed then
Test.Fail ("Bad compression of """ & Decompressed & '"');
Test.Info ("Found: " & Image (Buffer));
Test.Info ("Expected:" & Image (Compressed));
declare
Round : constant String := Decompress (Dict, Buffer);
begin
if Round /= Decompressed then
Test.Info ("Roundtrip failed, got: """ & Round & '"');
else
Test.Info ("Roundtrip OK");
end if;
end;
end if;
end;
exception
when Error : others =>
if not First_OK then
Test.Info ("During compression of """ & Decompressed & '"');
end if;
Test.Report_Exception (Error, NT.Fail);
end;
declare
First_OK : Boolean := False;
begin
declare
Buffer : constant String := Decompress (Dict, Compressed);
begin
First_OK := True;
if Buffer /= Decompressed then
Test.Fail ("Bad decompression of " & Image (Compressed));
Test.Info ("Found: """ & Buffer & '"');
Test.Info ("Expected:""" & Decompressed & '"');
declare
Round : constant Ada.Streams.Stream_Element_Array
:= Compress (Dict, Buffer);
begin
if Round /= Compressed then
Test.Info ("Roundtrip failed, got: " & Image (Round));
else
Test.Info ("Roundtrip OK");
end if;
end;
end if;
end;
exception
when Error : others =>
if not First_OK then
Test.Info ("During compression of " & Image (Compressed));
end if;
Test.Report_Exception (Error, NT.Fail);
end;
end Roundtrip_Test;
-------------------------
-- Complete Test Suite --
-------------------------
procedure All_Tests (Report : in out NT.Reporter'Class) is
begin
Sample_Strings (Report);
Sample_Strings_Without_VLV (Report);
end All_Tests;
----------------------
-- Individual Tests --
----------------------
procedure Sample_Strings (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Roundtrip on sample strings");
begin
Roundtrip_Test (Test, Original.Dictionary,
"This is a small string",
(254, 84, 76, 56, 172, 62, 173, 152, 62, 195, 70));
Roundtrip_Test (Test, Original.Dictionary,
"foobar",
(220, 6, 90, 79));
Roundtrip_Test (Test, Original.Dictionary,
"the end",
(1, 171, 61));
Roundtrip_Test (Test, Original.Dictionary,
"not-a-g00d-Exampl333",
(132, 204, 4, 204, 59, 255, 12, 48, 48, 100, 45, 69, 120, 97, 109,
112, 108, 51, 51, 51));
Roundtrip_Test (Test, Original.Dictionary,
"Smaz is a simple compression library",
(254, 83, 173, 219, 56, 172, 62, 226, 60, 87, 161, 45, 60, 33, 166,
107, 205, 8, 90, 130, 12, 83));
Roundtrip_Test (Test, Original.Dictionary,
"Nothing is more difficult, and therefore more precious, "
& "than to be able to decide",
(254, 78, 223, 102, 99, 116, 45, 42, 11, 129, 44, 44, 131, 38, 22, 3,
148, 63, 210, 68, 11, 45, 42, 11, 60, 33, 28, 144, 164, 36, 203,
143, 96, 92, 25, 90, 87, 82, 165, 215, 237, 2));
Roundtrip_Test (Test, Original.Dictionary,
"this is an example of what works very well with smaz",
(155, 56, 172, 41, 2, 250, 4, 45, 60, 87, 32, 159, 135, 65, 42, 254,
107, 23, 231, 71, 145, 152, 243, 227, 10, 173, 219));
Roundtrip_Test (Test, Original.Dictionary,
"1000 numbers 2000 will 10 20 30 compress very little",
(255, 3, 49, 48, 48, 48, 236, 38, 45, 92, 221, 0, 255, 3, 50, 48, 48,
48, 243, 152, 0, 255, 7, 49, 48, 32, 50, 48, 32, 51,
48, 161, 45, 60, 33, 166, 0, 231, 71, 151, 3, 3, 87));
Roundtrip_Test (Test, Original.Dictionary,
": : : :",
(255, 6, 58, 32, 58, 32, 58, 32, 58));
Roundtrip_Test (Test, Original.Dictionary,
(1 .. 300 => ':'),
(1 .. 2 => 255, 3 .. 258 => 58,
259 => 255, 260 => 43, 261 .. 304 => 58));
exception
when Error : others => Test.Report_Exception (Error);
end Sample_Strings;
procedure Sample_Strings_Without_VLV (Report : in out NT.Reporter'Class) is
Test : NT.Test
:= Report.Item ("Roundtrip on sample strings without VLV");
Dict : constant Dictionary := Dict_Without_VLV;
begin
Roundtrip_Test (Test, Dict,
"This is a small string",
(255, 84, 76, 56, 172, 62, 173, 152, 62, 195, 70));
Roundtrip_Test (Test, Dict,
"foobar",
(220, 6, 90, 79));
Roundtrip_Test (Test, Dict,
"the end",
(1, 171, 61));
Roundtrip_Test (Test, Dict,
"not-a-g00d-Exampl333",
(132, 204, 4, 204, 59, 254, 48, 48, 24, 204, 255, 69, 250, 4, 45,
60, 22, 254, 51, 51, 255, 51));
Roundtrip_Test (Test, Dict,
"Smaz is a simple compression library",
(255, 83, 173, 219, 56, 172, 62, 226, 60, 87, 161, 45, 60, 33, 166,
107, 205, 8, 90, 130, 12, 83));
Roundtrip_Test (Test, Dict,
"Nothing is more difficult, and therefore more precious, "
& "than to be able to decide",
(255, 78, 223, 102, 99, 116, 45, 42, 11, 129, 44, 44, 131, 38, 22, 3,
148, 63, 210, 68, 11, 45, 42, 11, 60, 33, 28, 144, 164, 36, 203,
143, 96, 92, 25, 90, 87, 82, 165, 215, 237, 2));
Roundtrip_Test (Test, Dict,
"this is an example of what works very well with smaz",
(155, 56, 172, 41, 2, 250, 4, 45, 60, 87, 32, 159, 135, 65, 42, 255,
107, 23, 231, 71, 145, 152, 243, 227, 10, 173, 219));
Roundtrip_Test (Test, Dict,
"1000 numbers 2000 will 10 20 30 compress very little",
(254, 49, 48, 254, 48, 48, 236, 38, 45, 92, 221, 0, 254, 50, 48,
254, 48, 48, 243, 152, 0, 254, 49, 48, 0, 254, 50, 48, 0, 254, 51,
48, 161, 45, 60, 33, 166, 0, 231, 71, 151, 3, 3, 87));
Roundtrip_Test (Test, Dict,
": : : :",
(254, 58, 32, 254, 58, 32, 254, 58, 32, 255, 58));
exception
when Error : others => Test.Report_Exception (Error);
end Sample_Strings_Without_VLV;
end Natools.Smaz.Tests;
|
ex02_sum.asm | gustatarem/assembly-arqsis | 1 | 104554 | include emu8086.inc
ORG 100h
MOV row, 0
JMP getfirstnumber
getfirstnumber:
ADD row, 1
GOTOXY 0, row
PRINT 'Digite um numero inteiro entre 00 e 99: '
MOV AH, 01
INT 21h
MOV BH, AL
INT 21h
MOV BL, AL
CMP BH, 30h
JB iffails
JMP storefirstnumber
storefirstnumber:
MOV AL, BH
SUB AL, 30h
MOV AH, 10
MUL AH
ADD AL, BL
SUB AL, 30h
MOV firstnum, AL
JMP getsecondnumber
getsecondnumber:
ADD row, 1
GOTOXY 0, row
PRINT 'Digite um numero inteiro entre 00 e 99: '
MOV AH, 01
INT 21h
MOV BH, AL
INT 21h
MOV BL, AL
CMP BH, 30h
JB iffails
JMP storesecondnumber
storesecondnumber:
MOV AL, BH
SUB AL, 30h
MOV AH, 10
MUL AH
ADD AL, BL
SUB AL, 30h
MOV secondnum, AL
JMP calculatenumbers
iffails:
ADD row, 1
GOTOXY 0, row
PRINT 'O valor digitado eh invalido, reiniciando programa...'
JMP getfirstnumber
calculatenumbers:
MOV AL, firstnum
MOV AH, secondnum
ADD AL, AH
MOV sum, AL
JMP printsum
printsum:
ADD row, 1
GOTOXY 0, row
PRINT 'A soma eh: '
CMP sum, 100
JNAE print2numbers
MOV AL, sum
MOV AH, 0h
MOV CH, 100
DIV CH
MOV DX, AX
ADD DX, 30h
MOV AH, 02
INT 21h
SUB sum, 100
MOV AL, sum
MOV AH, 0h
MOV CH, 10
DIV CH
MOV DX, AX
ADD DX, 30h
MOV AH, 02
INT 21h
MOV AL, sum
MOV AH, 0h
MOV CH, 10
DIV CH
MOV DL, AH
ADD DX, 30h
MOV AH, 02
INT 21h
RET
print2numbers:
MOV AL, sum
MOV AH, 0h
MOV CH, 10
DIV CH
MOV DX, AX
ADD DX, 30h
MOV AH, 02
INT 21h
MOV AL, sum
MOV AH, 0h
MOV CH, 10
DIV CH
MOV DL, AH
ADD DX, 30h
MOV AH, 02
INT 21h
RET
row DB 0
firstnum DB 0
secondnum DB 0
sum DB 0 |
test/Fail/Issue2494-pattern-instance.agda | shlevy/agda | 1,989 | 12245 | <filename>test/Fail/Issue2494-pattern-instance.agda
-- Andreas, 2017-04-13, issue #2494, reported by identicalsnowflake
-- Consecutive hidden record fields confused the implicit argument insertion
-- due to lack of names in NamedArg.
-- {-# OPTIONS -v tc.lhs:30 #-}
-- {-# OPTIONS -v tc.term.args:100 #-}
postulate
Red Blue : Set
record Colors : Set where
field
{{red}} : Red
{{blue}} : Blue
f : Colors → Red
f record { blue = blue } = blue
|
wc.asm | PieMyth/cs333 | 0 | 17418 | <filename>wc.asm
_wc: file format elf32-i386
Disassembly of section .text:
00000000 <wc>:
char buf[512];
void
wc(int fd, char *name)
{
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 83 ec 28 sub $0x28,%esp
int i, n;
int l, w, c, inword;
l = w = c = 0;
6: c7 45 e8 00 00 00 00 movl $0x0,-0x18(%ebp)
d: 8b 45 e8 mov -0x18(%ebp),%eax
10: 89 45 ec mov %eax,-0x14(%ebp)
13: 8b 45 ec mov -0x14(%ebp),%eax
16: 89 45 f0 mov %eax,-0x10(%ebp)
inword = 0;
19: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp)
while((n = read(fd, buf, sizeof(buf))) > 0){
20: eb 69 jmp 8b <wc+0x8b>
for(i=0; i<n; i++){
22: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
29: eb 58 jmp 83 <wc+0x83>
c++;
2b: 83 45 e8 01 addl $0x1,-0x18(%ebp)
if(buf[i] == '\n')
2f: 8b 45 f4 mov -0xc(%ebp),%eax
32: 05 80 0d 00 00 add $0xd80,%eax
37: 0f b6 00 movzbl (%eax),%eax
3a: 3c 0a cmp $0xa,%al
3c: 75 04 jne 42 <wc+0x42>
l++;
3e: 83 45 f0 01 addl $0x1,-0x10(%ebp)
if(strchr(" \r\t\n\v", buf[i]))
42: 8b 45 f4 mov -0xc(%ebp),%eax
45: 05 80 0d 00 00 add $0xd80,%eax
4a: 0f b6 00 movzbl (%eax),%eax
4d: 0f be c0 movsbl %al,%eax
50: 83 ec 08 sub $0x8,%esp
53: 50 push %eax
54: 68 74 0a 00 00 push $0xa74
59: e8 35 02 00 00 call 293 <strchr>
5e: 83 c4 10 add $0x10,%esp
61: 85 c0 test %eax,%eax
63: 74 09 je 6e <wc+0x6e>
inword = 0;
65: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp)
6c: eb 11 jmp 7f <wc+0x7f>
else if(!inword){
6e: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp)
72: 75 0b jne 7f <wc+0x7f>
w++;
74: 83 45 ec 01 addl $0x1,-0x14(%ebp)
inword = 1;
78: c7 45 e4 01 00 00 00 movl $0x1,-0x1c(%ebp)
int l, w, c, inword;
l = w = c = 0;
inword = 0;
while((n = read(fd, buf, sizeof(buf))) > 0){
for(i=0; i<n; i++){
7f: 83 45 f4 01 addl $0x1,-0xc(%ebp)
83: 8b 45 f4 mov -0xc(%ebp),%eax
86: 3b 45 e0 cmp -0x20(%ebp),%eax
89: 7c a0 jl 2b <wc+0x2b>
int i, n;
int l, w, c, inword;
l = w = c = 0;
inword = 0;
while((n = read(fd, buf, sizeof(buf))) > 0){
8b: 83 ec 04 sub $0x4,%esp
8e: 68 00 02 00 00 push $0x200
93: 68 80 0d 00 00 push $0xd80
98: ff 75 08 pushl 0x8(%ebp)
9b: e8 5f 04 00 00 call 4ff <read>
a0: 83 c4 10 add $0x10,%esp
a3: 89 45 e0 mov %eax,-0x20(%ebp)
a6: 83 7d e0 00 cmpl $0x0,-0x20(%ebp)
aa: 0f 8f 72 ff ff ff jg 22 <wc+0x22>
w++;
inword = 1;
}
}
}
if(n < 0){
b0: 83 7d e0 00 cmpl $0x0,-0x20(%ebp)
b4: 79 17 jns cd <wc+0xcd>
printf(1, "wc: read error\n");
b6: 83 ec 08 sub $0x8,%esp
b9: 68 7a 0a 00 00 push $0xa7a
be: 6a 01 push $0x1
c0: e8 f9 05 00 00 call 6be <printf>
c5: 83 c4 10 add $0x10,%esp
exit();
c8: e8 1a 04 00 00 call 4e7 <exit>
}
printf(1, "%d %d %d %s\n", l, w, c, name);
cd: 83 ec 08 sub $0x8,%esp
d0: ff 75 0c pushl 0xc(%ebp)
d3: ff 75 e8 pushl -0x18(%ebp)
d6: ff 75 ec pushl -0x14(%ebp)
d9: ff 75 f0 pushl -0x10(%ebp)
dc: 68 8a 0a 00 00 push $0xa8a
e1: 6a 01 push $0x1
e3: e8 d6 05 00 00 call 6be <printf>
e8: 83 c4 20 add $0x20,%esp
}
eb: 90 nop
ec: c9 leave
ed: c3 ret
000000ee <main>:
int
main(int argc, char *argv[])
{
ee: 8d 4c 24 04 lea 0x4(%esp),%ecx
f2: 83 e4 f0 and $0xfffffff0,%esp
f5: ff 71 fc pushl -0x4(%ecx)
f8: 55 push %ebp
f9: 89 e5 mov %esp,%ebp
fb: 53 push %ebx
fc: 51 push %ecx
fd: 83 ec 10 sub $0x10,%esp
100: 89 cb mov %ecx,%ebx
int fd, i;
if(argc <= 1){
102: 83 3b 01 cmpl $0x1,(%ebx)
105: 7f 17 jg 11e <main+0x30>
wc(0, "");
107: 83 ec 08 sub $0x8,%esp
10a: 68 97 0a 00 00 push $0xa97
10f: 6a 00 push $0x0
111: e8 ea fe ff ff call 0 <wc>
116: 83 c4 10 add $0x10,%esp
exit();
119: e8 c9 03 00 00 call 4e7 <exit>
}
for(i = 1; i < argc; i++){
11e: c7 45 f4 01 00 00 00 movl $0x1,-0xc(%ebp)
125: e9 83 00 00 00 jmp 1ad <main+0xbf>
if((fd = open(argv[i], 0)) < 0){
12a: 8b 45 f4 mov -0xc(%ebp),%eax
12d: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx
134: 8b 43 04 mov 0x4(%ebx),%eax
137: 01 d0 add %edx,%eax
139: 8b 00 mov (%eax),%eax
13b: 83 ec 08 sub $0x8,%esp
13e: 6a 00 push $0x0
140: 50 push %eax
141: e8 e1 03 00 00 call 527 <open>
146: 83 c4 10 add $0x10,%esp
149: 89 45 f0 mov %eax,-0x10(%ebp)
14c: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
150: 79 29 jns 17b <main+0x8d>
printf(1, "wc: cannot open %s\n", argv[i]);
152: 8b 45 f4 mov -0xc(%ebp),%eax
155: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx
15c: 8b 43 04 mov 0x4(%ebx),%eax
15f: 01 d0 add %edx,%eax
161: 8b 00 mov (%eax),%eax
163: 83 ec 04 sub $0x4,%esp
166: 50 push %eax
167: 68 98 0a 00 00 push $0xa98
16c: 6a 01 push $0x1
16e: e8 4b 05 00 00 call 6be <printf>
173: 83 c4 10 add $0x10,%esp
exit();
176: e8 6c 03 00 00 call 4e7 <exit>
}
wc(fd, argv[i]);
17b: 8b 45 f4 mov -0xc(%ebp),%eax
17e: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx
185: 8b 43 04 mov 0x4(%ebx),%eax
188: 01 d0 add %edx,%eax
18a: 8b 00 mov (%eax),%eax
18c: 83 ec 08 sub $0x8,%esp
18f: 50 push %eax
190: ff 75 f0 pushl -0x10(%ebp)
193: e8 68 fe ff ff call 0 <wc>
198: 83 c4 10 add $0x10,%esp
close(fd);
19b: 83 ec 0c sub $0xc,%esp
19e: ff 75 f0 pushl -0x10(%ebp)
1a1: e8 69 03 00 00 call 50f <close>
1a6: 83 c4 10 add $0x10,%esp
if(argc <= 1){
wc(0, "");
exit();
}
for(i = 1; i < argc; i++){
1a9: 83 45 f4 01 addl $0x1,-0xc(%ebp)
1ad: 8b 45 f4 mov -0xc(%ebp),%eax
1b0: 3b 03 cmp (%ebx),%eax
1b2: 0f 8c 72 ff ff ff jl 12a <main+0x3c>
exit();
}
wc(fd, argv[i]);
close(fd);
}
exit();
1b8: e8 2a 03 00 00 call 4e7 <exit>
000001bd <stosb>:
"cc");
}
static inline void
stosb(void *addr, int data, int cnt)
{
1bd: 55 push %ebp
1be: 89 e5 mov %esp,%ebp
1c0: 57 push %edi
1c1: 53 push %ebx
asm volatile("cld; rep stosb" :
1c2: 8b 4d 08 mov 0x8(%ebp),%ecx
1c5: 8b 55 10 mov 0x10(%ebp),%edx
1c8: 8b 45 0c mov 0xc(%ebp),%eax
1cb: 89 cb mov %ecx,%ebx
1cd: 89 df mov %ebx,%edi
1cf: 89 d1 mov %edx,%ecx
1d1: fc cld
1d2: f3 aa rep stos %al,%es:(%edi)
1d4: 89 ca mov %ecx,%edx
1d6: 89 fb mov %edi,%ebx
1d8: 89 5d 08 mov %ebx,0x8(%ebp)
1db: 89 55 10 mov %edx,0x10(%ebp)
"=D" (addr), "=c" (cnt) :
"0" (addr), "1" (cnt), "a" (data) :
"memory", "cc");
}
1de: 90 nop
1df: 5b pop %ebx
1e0: 5f pop %edi
1e1: 5d pop %ebp
1e2: c3 ret
000001e3 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, char *t)
{
1e3: 55 push %ebp
1e4: 89 e5 mov %esp,%ebp
1e6: 83 ec 10 sub $0x10,%esp
char *os;
os = s;
1e9: 8b 45 08 mov 0x8(%ebp),%eax
1ec: 89 45 fc mov %eax,-0x4(%ebp)
while((*s++ = *t++) != 0)
1ef: 90 nop
1f0: 8b 45 08 mov 0x8(%ebp),%eax
1f3: 8d 50 01 lea 0x1(%eax),%edx
1f6: 89 55 08 mov %edx,0x8(%ebp)
1f9: 8b 55 0c mov 0xc(%ebp),%edx
1fc: 8d 4a 01 lea 0x1(%edx),%ecx
1ff: 89 4d 0c mov %ecx,0xc(%ebp)
202: 0f b6 12 movzbl (%edx),%edx
205: 88 10 mov %dl,(%eax)
207: 0f b6 00 movzbl (%eax),%eax
20a: 84 c0 test %al,%al
20c: 75 e2 jne 1f0 <strcpy+0xd>
;
return os;
20e: 8b 45 fc mov -0x4(%ebp),%eax
}
211: c9 leave
212: c3 ret
00000213 <strcmp>:
int
strcmp(const char *p, const char *q)
{
213: 55 push %ebp
214: 89 e5 mov %esp,%ebp
while(*p && *p == *q)
216: eb 08 jmp 220 <strcmp+0xd>
p++, q++;
218: 83 45 08 01 addl $0x1,0x8(%ebp)
21c: 83 45 0c 01 addl $0x1,0xc(%ebp)
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
220: 8b 45 08 mov 0x8(%ebp),%eax
223: 0f b6 00 movzbl (%eax),%eax
226: 84 c0 test %al,%al
228: 74 10 je 23a <strcmp+0x27>
22a: 8b 45 08 mov 0x8(%ebp),%eax
22d: 0f b6 10 movzbl (%eax),%edx
230: 8b 45 0c mov 0xc(%ebp),%eax
233: 0f b6 00 movzbl (%eax),%eax
236: 38 c2 cmp %al,%dl
238: 74 de je 218 <strcmp+0x5>
p++, q++;
return (uchar)*p - (uchar)*q;
23a: 8b 45 08 mov 0x8(%ebp),%eax
23d: 0f b6 00 movzbl (%eax),%eax
240: 0f b6 d0 movzbl %al,%edx
243: 8b 45 0c mov 0xc(%ebp),%eax
246: 0f b6 00 movzbl (%eax),%eax
249: 0f b6 c0 movzbl %al,%eax
24c: 29 c2 sub %eax,%edx
24e: 89 d0 mov %edx,%eax
}
250: 5d pop %ebp
251: c3 ret
00000252 <strlen>:
uint
strlen(char *s)
{
252: 55 push %ebp
253: 89 e5 mov %esp,%ebp
255: 83 ec 10 sub $0x10,%esp
int n;
for(n = 0; s[n]; n++)
258: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
25f: eb 04 jmp 265 <strlen+0x13>
261: 83 45 fc 01 addl $0x1,-0x4(%ebp)
265: 8b 55 fc mov -0x4(%ebp),%edx
268: 8b 45 08 mov 0x8(%ebp),%eax
26b: 01 d0 add %edx,%eax
26d: 0f b6 00 movzbl (%eax),%eax
270: 84 c0 test %al,%al
272: 75 ed jne 261 <strlen+0xf>
;
return n;
274: 8b 45 fc mov -0x4(%ebp),%eax
}
277: c9 leave
278: c3 ret
00000279 <memset>:
void*
memset(void *dst, int c, uint n)
{
279: 55 push %ebp
27a: 89 e5 mov %esp,%ebp
stosb(dst, c, n);
27c: 8b 45 10 mov 0x10(%ebp),%eax
27f: 50 push %eax
280: ff 75 0c pushl 0xc(%ebp)
283: ff 75 08 pushl 0x8(%ebp)
286: e8 32 ff ff ff call 1bd <stosb>
28b: 83 c4 0c add $0xc,%esp
return dst;
28e: 8b 45 08 mov 0x8(%ebp),%eax
}
291: c9 leave
292: c3 ret
00000293 <strchr>:
char*
strchr(const char *s, char c)
{
293: 55 push %ebp
294: 89 e5 mov %esp,%ebp
296: 83 ec 04 sub $0x4,%esp
299: 8b 45 0c mov 0xc(%ebp),%eax
29c: 88 45 fc mov %al,-0x4(%ebp)
for(; *s; s++)
29f: eb 14 jmp 2b5 <strchr+0x22>
if(*s == c)
2a1: 8b 45 08 mov 0x8(%ebp),%eax
2a4: 0f b6 00 movzbl (%eax),%eax
2a7: 3a 45 fc cmp -0x4(%ebp),%al
2aa: 75 05 jne 2b1 <strchr+0x1e>
return (char*)s;
2ac: 8b 45 08 mov 0x8(%ebp),%eax
2af: eb 13 jmp 2c4 <strchr+0x31>
}
char*
strchr(const char *s, char c)
{
for(; *s; s++)
2b1: 83 45 08 01 addl $0x1,0x8(%ebp)
2b5: 8b 45 08 mov 0x8(%ebp),%eax
2b8: 0f b6 00 movzbl (%eax),%eax
2bb: 84 c0 test %al,%al
2bd: 75 e2 jne 2a1 <strchr+0xe>
if(*s == c)
return (char*)s;
return 0;
2bf: b8 00 00 00 00 mov $0x0,%eax
}
2c4: c9 leave
2c5: c3 ret
000002c6 <gets>:
char*
gets(char *buf, int max)
{
2c6: 55 push %ebp
2c7: 89 e5 mov %esp,%ebp
2c9: 83 ec 18 sub $0x18,%esp
int i, cc;
char c;
for(i=0; i+1 < max; ){
2cc: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
2d3: eb 42 jmp 317 <gets+0x51>
cc = read(0, &c, 1);
2d5: 83 ec 04 sub $0x4,%esp
2d8: 6a 01 push $0x1
2da: 8d 45 ef lea -0x11(%ebp),%eax
2dd: 50 push %eax
2de: 6a 00 push $0x0
2e0: e8 1a 02 00 00 call 4ff <read>
2e5: 83 c4 10 add $0x10,%esp
2e8: 89 45 f0 mov %eax,-0x10(%ebp)
if(cc < 1)
2eb: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
2ef: 7e 33 jle 324 <gets+0x5e>
break;
buf[i++] = c;
2f1: 8b 45 f4 mov -0xc(%ebp),%eax
2f4: 8d 50 01 lea 0x1(%eax),%edx
2f7: 89 55 f4 mov %edx,-0xc(%ebp)
2fa: 89 c2 mov %eax,%edx
2fc: 8b 45 08 mov 0x8(%ebp),%eax
2ff: 01 c2 add %eax,%edx
301: 0f b6 45 ef movzbl -0x11(%ebp),%eax
305: 88 02 mov %al,(%edx)
if(c == '\n' || c == '\r')
307: 0f b6 45 ef movzbl -0x11(%ebp),%eax
30b: 3c 0a cmp $0xa,%al
30d: 74 16 je 325 <gets+0x5f>
30f: 0f b6 45 ef movzbl -0x11(%ebp),%eax
313: 3c 0d cmp $0xd,%al
315: 74 0e je 325 <gets+0x5f>
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
317: 8b 45 f4 mov -0xc(%ebp),%eax
31a: 83 c0 01 add $0x1,%eax
31d: 3b 45 0c cmp 0xc(%ebp),%eax
320: 7c b3 jl 2d5 <gets+0xf>
322: eb 01 jmp 325 <gets+0x5f>
cc = read(0, &c, 1);
if(cc < 1)
break;
324: 90 nop
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
325: 8b 55 f4 mov -0xc(%ebp),%edx
328: 8b 45 08 mov 0x8(%ebp),%eax
32b: 01 d0 add %edx,%eax
32d: c6 00 00 movb $0x0,(%eax)
return buf;
330: 8b 45 08 mov 0x8(%ebp),%eax
}
333: c9 leave
334: c3 ret
00000335 <stat>:
int
stat(char *n, struct stat *st)
{
335: 55 push %ebp
336: 89 e5 mov %esp,%ebp
338: 83 ec 18 sub $0x18,%esp
int fd;
int r;
fd = open(n, O_RDONLY);
33b: 83 ec 08 sub $0x8,%esp
33e: 6a 00 push $0x0
340: ff 75 08 pushl 0x8(%ebp)
343: e8 df 01 00 00 call 527 <open>
348: 83 c4 10 add $0x10,%esp
34b: 89 45 f4 mov %eax,-0xc(%ebp)
if(fd < 0)
34e: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
352: 79 07 jns 35b <stat+0x26>
return -1;
354: b8 ff ff ff ff mov $0xffffffff,%eax
359: eb 25 jmp 380 <stat+0x4b>
r = fstat(fd, st);
35b: 83 ec 08 sub $0x8,%esp
35e: ff 75 0c pushl 0xc(%ebp)
361: ff 75 f4 pushl -0xc(%ebp)
364: e8 d6 01 00 00 call 53f <fstat>
369: 83 c4 10 add $0x10,%esp
36c: 89 45 f0 mov %eax,-0x10(%ebp)
close(fd);
36f: 83 ec 0c sub $0xc,%esp
372: ff 75 f4 pushl -0xc(%ebp)
375: e8 95 01 00 00 call 50f <close>
37a: 83 c4 10 add $0x10,%esp
return r;
37d: 8b 45 f0 mov -0x10(%ebp),%eax
}
380: c9 leave
381: c3 ret
00000382 <atoi>:
int
atoi(const char *s)
{
382: 55 push %ebp
383: 89 e5 mov %esp,%ebp
385: 83 ec 10 sub $0x10,%esp
int n, sign;
n = 0;
388: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
while (*s == ' ') s++;
38f: eb 04 jmp 395 <atoi+0x13>
391: 83 45 08 01 addl $0x1,0x8(%ebp)
395: 8b 45 08 mov 0x8(%ebp),%eax
398: 0f b6 00 movzbl (%eax),%eax
39b: 3c 20 cmp $0x20,%al
39d: 74 f2 je 391 <atoi+0xf>
sign = (*s == '-') ? -1 : 1;
39f: 8b 45 08 mov 0x8(%ebp),%eax
3a2: 0f b6 00 movzbl (%eax),%eax
3a5: 3c 2d cmp $0x2d,%al
3a7: 75 07 jne 3b0 <atoi+0x2e>
3a9: b8 ff ff ff ff mov $0xffffffff,%eax
3ae: eb 05 jmp 3b5 <atoi+0x33>
3b0: b8 01 00 00 00 mov $0x1,%eax
3b5: 89 45 f8 mov %eax,-0x8(%ebp)
if (*s == '+' || *s == '-')
3b8: 8b 45 08 mov 0x8(%ebp),%eax
3bb: 0f b6 00 movzbl (%eax),%eax
3be: 3c 2b cmp $0x2b,%al
3c0: 74 0a je 3cc <atoi+0x4a>
3c2: 8b 45 08 mov 0x8(%ebp),%eax
3c5: 0f b6 00 movzbl (%eax),%eax
3c8: 3c 2d cmp $0x2d,%al
3ca: 75 2b jne 3f7 <atoi+0x75>
s++;
3cc: 83 45 08 01 addl $0x1,0x8(%ebp)
while('0' <= *s && *s <= '9')
3d0: eb 25 jmp 3f7 <atoi+0x75>
n = n*10 + *s++ - '0';
3d2: 8b 55 fc mov -0x4(%ebp),%edx
3d5: 89 d0 mov %edx,%eax
3d7: c1 e0 02 shl $0x2,%eax
3da: 01 d0 add %edx,%eax
3dc: 01 c0 add %eax,%eax
3de: 89 c1 mov %eax,%ecx
3e0: 8b 45 08 mov 0x8(%ebp),%eax
3e3: 8d 50 01 lea 0x1(%eax),%edx
3e6: 89 55 08 mov %edx,0x8(%ebp)
3e9: 0f b6 00 movzbl (%eax),%eax
3ec: 0f be c0 movsbl %al,%eax
3ef: 01 c8 add %ecx,%eax
3f1: 83 e8 30 sub $0x30,%eax
3f4: 89 45 fc mov %eax,-0x4(%ebp)
n = 0;
while (*s == ' ') s++;
sign = (*s == '-') ? -1 : 1;
if (*s == '+' || *s == '-')
s++;
while('0' <= *s && *s <= '9')
3f7: 8b 45 08 mov 0x8(%ebp),%eax
3fa: 0f b6 00 movzbl (%eax),%eax
3fd: 3c 2f cmp $0x2f,%al
3ff: 7e 0a jle 40b <atoi+0x89>
401: 8b 45 08 mov 0x8(%ebp),%eax
404: 0f b6 00 movzbl (%eax),%eax
407: 3c 39 cmp $0x39,%al
409: 7e c7 jle 3d2 <atoi+0x50>
n = n*10 + *s++ - '0';
return sign*n;
40b: 8b 45 f8 mov -0x8(%ebp),%eax
40e: 0f af 45 fc imul -0x4(%ebp),%eax
}
412: c9 leave
413: c3 ret
00000414 <atoo>:
int
atoo(const char *s)
{
414: 55 push %ebp
415: 89 e5 mov %esp,%ebp
417: 83 ec 10 sub $0x10,%esp
int n, sign;
n = 0;
41a: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
while (*s == ' ') s++;
421: eb 04 jmp 427 <atoo+0x13>
423: 83 45 08 01 addl $0x1,0x8(%ebp)
427: 8b 45 08 mov 0x8(%ebp),%eax
42a: 0f b6 00 movzbl (%eax),%eax
42d: 3c 20 cmp $0x20,%al
42f: 74 f2 je 423 <atoo+0xf>
sign = (*s == '-') ? -1 : 1;
431: 8b 45 08 mov 0x8(%ebp),%eax
434: 0f b6 00 movzbl (%eax),%eax
437: 3c 2d cmp $0x2d,%al
439: 75 07 jne 442 <atoo+0x2e>
43b: b8 ff ff ff ff mov $0xffffffff,%eax
440: eb 05 jmp 447 <atoo+0x33>
442: b8 01 00 00 00 mov $0x1,%eax
447: 89 45 f8 mov %eax,-0x8(%ebp)
if (*s == '+' || *s == '-')
44a: 8b 45 08 mov 0x8(%ebp),%eax
44d: 0f b6 00 movzbl (%eax),%eax
450: 3c 2b cmp $0x2b,%al
452: 74 0a je 45e <atoo+0x4a>
454: 8b 45 08 mov 0x8(%ebp),%eax
457: 0f b6 00 movzbl (%eax),%eax
45a: 3c 2d cmp $0x2d,%al
45c: 75 27 jne 485 <atoo+0x71>
s++;
45e: 83 45 08 01 addl $0x1,0x8(%ebp)
while('0' <= *s && *s <= '7')
462: eb 21 jmp 485 <atoo+0x71>
n = n*8 + *s++ - '0';
464: 8b 45 fc mov -0x4(%ebp),%eax
467: 8d 0c c5 00 00 00 00 lea 0x0(,%eax,8),%ecx
46e: 8b 45 08 mov 0x8(%ebp),%eax
471: 8d 50 01 lea 0x1(%eax),%edx
474: 89 55 08 mov %edx,0x8(%ebp)
477: 0f b6 00 movzbl (%eax),%eax
47a: 0f be c0 movsbl %al,%eax
47d: 01 c8 add %ecx,%eax
47f: 83 e8 30 sub $0x30,%eax
482: 89 45 fc mov %eax,-0x4(%ebp)
n = 0;
while (*s == ' ') s++;
sign = (*s == '-') ? -1 : 1;
if (*s == '+' || *s == '-')
s++;
while('0' <= *s && *s <= '7')
485: 8b 45 08 mov 0x8(%ebp),%eax
488: 0f b6 00 movzbl (%eax),%eax
48b: 3c 2f cmp $0x2f,%al
48d: 7e 0a jle 499 <atoo+0x85>
48f: 8b 45 08 mov 0x8(%ebp),%eax
492: 0f b6 00 movzbl (%eax),%eax
495: 3c 37 cmp $0x37,%al
497: 7e cb jle 464 <atoo+0x50>
n = n*8 + *s++ - '0';
return sign*n;
499: 8b 45 f8 mov -0x8(%ebp),%eax
49c: 0f af 45 fc imul -0x4(%ebp),%eax
}
4a0: c9 leave
4a1: c3 ret
000004a2 <memmove>:
void*
memmove(void *vdst, void *vsrc, int n)
{
4a2: 55 push %ebp
4a3: 89 e5 mov %esp,%ebp
4a5: 83 ec 10 sub $0x10,%esp
char *dst, *src;
dst = vdst;
4a8: 8b 45 08 mov 0x8(%ebp),%eax
4ab: 89 45 fc mov %eax,-0x4(%ebp)
src = vsrc;
4ae: 8b 45 0c mov 0xc(%ebp),%eax
4b1: 89 45 f8 mov %eax,-0x8(%ebp)
while(n-- > 0)
4b4: eb 17 jmp 4cd <memmove+0x2b>
*dst++ = *src++;
4b6: 8b 45 fc mov -0x4(%ebp),%eax
4b9: 8d 50 01 lea 0x1(%eax),%edx
4bc: 89 55 fc mov %edx,-0x4(%ebp)
4bf: 8b 55 f8 mov -0x8(%ebp),%edx
4c2: 8d 4a 01 lea 0x1(%edx),%ecx
4c5: 89 4d f8 mov %ecx,-0x8(%ebp)
4c8: 0f b6 12 movzbl (%edx),%edx
4cb: 88 10 mov %dl,(%eax)
{
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
4cd: 8b 45 10 mov 0x10(%ebp),%eax
4d0: 8d 50 ff lea -0x1(%eax),%edx
4d3: 89 55 10 mov %edx,0x10(%ebp)
4d6: 85 c0 test %eax,%eax
4d8: 7f dc jg 4b6 <memmove+0x14>
*dst++ = *src++;
return vdst;
4da: 8b 45 08 mov 0x8(%ebp),%eax
}
4dd: c9 leave
4de: c3 ret
000004df <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
4df: b8 01 00 00 00 mov $0x1,%eax
4e4: cd 40 int $0x40
4e6: c3 ret
000004e7 <exit>:
SYSCALL(exit)
4e7: b8 02 00 00 00 mov $0x2,%eax
4ec: cd 40 int $0x40
4ee: c3 ret
000004ef <wait>:
SYSCALL(wait)
4ef: b8 03 00 00 00 mov $0x3,%eax
4f4: cd 40 int $0x40
4f6: c3 ret
000004f7 <pipe>:
SYSCALL(pipe)
4f7: b8 04 00 00 00 mov $0x4,%eax
4fc: cd 40 int $0x40
4fe: c3 ret
000004ff <read>:
SYSCALL(read)
4ff: b8 05 00 00 00 mov $0x5,%eax
504: cd 40 int $0x40
506: c3 ret
00000507 <write>:
SYSCALL(write)
507: b8 10 00 00 00 mov $0x10,%eax
50c: cd 40 int $0x40
50e: c3 ret
0000050f <close>:
SYSCALL(close)
50f: b8 15 00 00 00 mov $0x15,%eax
514: cd 40 int $0x40
516: c3 ret
00000517 <kill>:
SYSCALL(kill)
517: b8 06 00 00 00 mov $0x6,%eax
51c: cd 40 int $0x40
51e: c3 ret
0000051f <exec>:
SYSCALL(exec)
51f: b8 07 00 00 00 mov $0x7,%eax
524: cd 40 int $0x40
526: c3 ret
00000527 <open>:
SYSCALL(open)
527: b8 0f 00 00 00 mov $0xf,%eax
52c: cd 40 int $0x40
52e: c3 ret
0000052f <mknod>:
SYSCALL(mknod)
52f: b8 11 00 00 00 mov $0x11,%eax
534: cd 40 int $0x40
536: c3 ret
00000537 <unlink>:
SYSCALL(unlink)
537: b8 12 00 00 00 mov $0x12,%eax
53c: cd 40 int $0x40
53e: c3 ret
0000053f <fstat>:
SYSCALL(fstat)
53f: b8 08 00 00 00 mov $0x8,%eax
544: cd 40 int $0x40
546: c3 ret
00000547 <link>:
SYSCALL(link)
547: b8 13 00 00 00 mov $0x13,%eax
54c: cd 40 int $0x40
54e: c3 ret
0000054f <mkdir>:
SYSCALL(mkdir)
54f: b8 14 00 00 00 mov $0x14,%eax
554: cd 40 int $0x40
556: c3 ret
00000557 <chdir>:
SYSCALL(chdir)
557: b8 09 00 00 00 mov $0x9,%eax
55c: cd 40 int $0x40
55e: c3 ret
0000055f <dup>:
SYSCALL(dup)
55f: b8 0a 00 00 00 mov $0xa,%eax
564: cd 40 int $0x40
566: c3 ret
00000567 <getpid>:
SYSCALL(getpid)
567: b8 0b 00 00 00 mov $0xb,%eax
56c: cd 40 int $0x40
56e: c3 ret
0000056f <sbrk>:
SYSCALL(sbrk)
56f: b8 0c 00 00 00 mov $0xc,%eax
574: cd 40 int $0x40
576: c3 ret
00000577 <sleep>:
SYSCALL(sleep)
577: b8 0d 00 00 00 mov $0xd,%eax
57c: cd 40 int $0x40
57e: c3 ret
0000057f <uptime>:
SYSCALL(uptime)
57f: b8 0e 00 00 00 mov $0xe,%eax
584: cd 40 int $0x40
586: c3 ret
00000587 <halt>:
SYSCALL(halt)
587: b8 16 00 00 00 mov $0x16,%eax
58c: cd 40 int $0x40
58e: c3 ret
0000058f <date>:
SYSCALL(date)
58f: b8 17 00 00 00 mov $0x17,%eax
594: cd 40 int $0x40
596: c3 ret
00000597 <getuid>:
SYSCALL(getuid)
597: b8 18 00 00 00 mov $0x18,%eax
59c: cd 40 int $0x40
59e: c3 ret
0000059f <getgid>:
SYSCALL(getgid)
59f: b8 19 00 00 00 mov $0x19,%eax
5a4: cd 40 int $0x40
5a6: c3 ret
000005a7 <getppid>:
SYSCALL(getppid)
5a7: b8 1a 00 00 00 mov $0x1a,%eax
5ac: cd 40 int $0x40
5ae: c3 ret
000005af <setuid>:
SYSCALL(setuid)
5af: b8 1b 00 00 00 mov $0x1b,%eax
5b4: cd 40 int $0x40
5b6: c3 ret
000005b7 <setgid>:
SYSCALL(setgid)
5b7: b8 1c 00 00 00 mov $0x1c,%eax
5bc: cd 40 int $0x40
5be: c3 ret
000005bf <getprocs>:
SYSCALL(getprocs)
5bf: b8 1d 00 00 00 mov $0x1d,%eax
5c4: cd 40 int $0x40
5c6: c3 ret
000005c7 <setpriority>:
SYSCALL(setpriority)
5c7: b8 1e 00 00 00 mov $0x1e,%eax
5cc: cd 40 int $0x40
5ce: c3 ret
000005cf <chmod>:
SYSCALL(chmod)
5cf: b8 1f 00 00 00 mov $0x1f,%eax
5d4: cd 40 int $0x40
5d6: c3 ret
000005d7 <chown>:
SYSCALL(chown)
5d7: b8 20 00 00 00 mov $0x20,%eax
5dc: cd 40 int $0x40
5de: c3 ret
000005df <chgrp>:
SYSCALL(chgrp)
5df: b8 21 00 00 00 mov $0x21,%eax
5e4: cd 40 int $0x40
5e6: c3 ret
000005e7 <putc>:
#include "stat.h"
#include "user.h"
static void
putc(int fd, char c)
{
5e7: 55 push %ebp
5e8: 89 e5 mov %esp,%ebp
5ea: 83 ec 18 sub $0x18,%esp
5ed: 8b 45 0c mov 0xc(%ebp),%eax
5f0: 88 45 f4 mov %al,-0xc(%ebp)
write(fd, &c, 1);
5f3: 83 ec 04 sub $0x4,%esp
5f6: 6a 01 push $0x1
5f8: 8d 45 f4 lea -0xc(%ebp),%eax
5fb: 50 push %eax
5fc: ff 75 08 pushl 0x8(%ebp)
5ff: e8 03 ff ff ff call 507 <write>
604: 83 c4 10 add $0x10,%esp
}
607: 90 nop
608: c9 leave
609: c3 ret
0000060a <printint>:
static void
printint(int fd, int xx, int base, int sgn)
{
60a: 55 push %ebp
60b: 89 e5 mov %esp,%ebp
60d: 53 push %ebx
60e: 83 ec 24 sub $0x24,%esp
static char digits[] = "0123456789ABCDEF";
char buf[16];
int i, neg;
uint x;
neg = 0;
611: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
if(sgn && xx < 0){
618: 83 7d 14 00 cmpl $0x0,0x14(%ebp)
61c: 74 17 je 635 <printint+0x2b>
61e: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
622: 79 11 jns 635 <printint+0x2b>
neg = 1;
624: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp)
x = -xx;
62b: 8b 45 0c mov 0xc(%ebp),%eax
62e: f7 d8 neg %eax
630: 89 45 ec mov %eax,-0x14(%ebp)
633: eb 06 jmp 63b <printint+0x31>
} else {
x = xx;
635: 8b 45 0c mov 0xc(%ebp),%eax
638: 89 45 ec mov %eax,-0x14(%ebp)
}
i = 0;
63b: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
do{
buf[i++] = digits[x % base];
642: 8b 4d f4 mov -0xc(%ebp),%ecx
645: 8d 41 01 lea 0x1(%ecx),%eax
648: 89 45 f4 mov %eax,-0xc(%ebp)
64b: 8b 5d 10 mov 0x10(%ebp),%ebx
64e: 8b 45 ec mov -0x14(%ebp),%eax
651: ba 00 00 00 00 mov $0x0,%edx
656: f7 f3 div %ebx
658: 89 d0 mov %edx,%eax
65a: 0f b6 80 40 0d 00 00 movzbl 0xd40(%eax),%eax
661: 88 44 0d dc mov %al,-0x24(%ebp,%ecx,1)
}while((x /= base) != 0);
665: 8b 5d 10 mov 0x10(%ebp),%ebx
668: 8b 45 ec mov -0x14(%ebp),%eax
66b: ba 00 00 00 00 mov $0x0,%edx
670: f7 f3 div %ebx
672: 89 45 ec mov %eax,-0x14(%ebp)
675: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
679: 75 c7 jne 642 <printint+0x38>
if(neg)
67b: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
67f: 74 2d je 6ae <printint+0xa4>
buf[i++] = '-';
681: 8b 45 f4 mov -0xc(%ebp),%eax
684: 8d 50 01 lea 0x1(%eax),%edx
687: 89 55 f4 mov %edx,-0xc(%ebp)
68a: c6 44 05 dc 2d movb $0x2d,-0x24(%ebp,%eax,1)
while(--i >= 0)
68f: eb 1d jmp 6ae <printint+0xa4>
putc(fd, buf[i]);
691: 8d 55 dc lea -0x24(%ebp),%edx
694: 8b 45 f4 mov -0xc(%ebp),%eax
697: 01 d0 add %edx,%eax
699: 0f b6 00 movzbl (%eax),%eax
69c: 0f be c0 movsbl %al,%eax
69f: 83 ec 08 sub $0x8,%esp
6a2: 50 push %eax
6a3: ff 75 08 pushl 0x8(%ebp)
6a6: e8 3c ff ff ff call 5e7 <putc>
6ab: 83 c4 10 add $0x10,%esp
buf[i++] = digits[x % base];
}while((x /= base) != 0);
if(neg)
buf[i++] = '-';
while(--i >= 0)
6ae: 83 6d f4 01 subl $0x1,-0xc(%ebp)
6b2: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
6b6: 79 d9 jns 691 <printint+0x87>
putc(fd, buf[i]);
}
6b8: 90 nop
6b9: 8b 5d fc mov -0x4(%ebp),%ebx
6bc: c9 leave
6bd: c3 ret
000006be <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
6be: 55 push %ebp
6bf: 89 e5 mov %esp,%ebp
6c1: 83 ec 28 sub $0x28,%esp
char *s;
int c, i, state;
uint *ap;
state = 0;
6c4: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
ap = (uint*)(void*)&fmt + 1;
6cb: 8d 45 0c lea 0xc(%ebp),%eax
6ce: 83 c0 04 add $0x4,%eax
6d1: 89 45 e8 mov %eax,-0x18(%ebp)
for(i = 0; fmt[i]; i++){
6d4: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
6db: e9 59 01 00 00 jmp 839 <printf+0x17b>
c = fmt[i] & 0xff;
6e0: 8b 55 0c mov 0xc(%ebp),%edx
6e3: 8b 45 f0 mov -0x10(%ebp),%eax
6e6: 01 d0 add %edx,%eax
6e8: 0f b6 00 movzbl (%eax),%eax
6eb: 0f be c0 movsbl %al,%eax
6ee: 25 ff 00 00 00 and $0xff,%eax
6f3: 89 45 e4 mov %eax,-0x1c(%ebp)
if(state == 0){
6f6: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
6fa: 75 2c jne 728 <printf+0x6a>
if(c == '%'){
6fc: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
700: 75 0c jne 70e <printf+0x50>
state = '%';
702: c7 45 ec 25 00 00 00 movl $0x25,-0x14(%ebp)
709: e9 27 01 00 00 jmp 835 <printf+0x177>
} else {
putc(fd, c);
70e: 8b 45 e4 mov -0x1c(%ebp),%eax
711: 0f be c0 movsbl %al,%eax
714: 83 ec 08 sub $0x8,%esp
717: 50 push %eax
718: ff 75 08 pushl 0x8(%ebp)
71b: e8 c7 fe ff ff call 5e7 <putc>
720: 83 c4 10 add $0x10,%esp
723: e9 0d 01 00 00 jmp 835 <printf+0x177>
}
} else if(state == '%'){
728: 83 7d ec 25 cmpl $0x25,-0x14(%ebp)
72c: 0f 85 03 01 00 00 jne 835 <printf+0x177>
if(c == 'd'){
732: 83 7d e4 64 cmpl $0x64,-0x1c(%ebp)
736: 75 1e jne 756 <printf+0x98>
printint(fd, *ap, 10, 1);
738: 8b 45 e8 mov -0x18(%ebp),%eax
73b: 8b 00 mov (%eax),%eax
73d: 6a 01 push $0x1
73f: 6a 0a push $0xa
741: 50 push %eax
742: ff 75 08 pushl 0x8(%ebp)
745: e8 c0 fe ff ff call 60a <printint>
74a: 83 c4 10 add $0x10,%esp
ap++;
74d: 83 45 e8 04 addl $0x4,-0x18(%ebp)
751: e9 d8 00 00 00 jmp 82e <printf+0x170>
} else if(c == 'x' || c == 'p'){
756: 83 7d e4 78 cmpl $0x78,-0x1c(%ebp)
75a: 74 06 je 762 <printf+0xa4>
75c: 83 7d e4 70 cmpl $0x70,-0x1c(%ebp)
760: 75 1e jne 780 <printf+0xc2>
printint(fd, *ap, 16, 0);
762: 8b 45 e8 mov -0x18(%ebp),%eax
765: 8b 00 mov (%eax),%eax
767: 6a 00 push $0x0
769: 6a 10 push $0x10
76b: 50 push %eax
76c: ff 75 08 pushl 0x8(%ebp)
76f: e8 96 fe ff ff call 60a <printint>
774: 83 c4 10 add $0x10,%esp
ap++;
777: 83 45 e8 04 addl $0x4,-0x18(%ebp)
77b: e9 ae 00 00 00 jmp 82e <printf+0x170>
} else if(c == 's'){
780: 83 7d e4 73 cmpl $0x73,-0x1c(%ebp)
784: 75 43 jne 7c9 <printf+0x10b>
s = (char*)*ap;
786: 8b 45 e8 mov -0x18(%ebp),%eax
789: 8b 00 mov (%eax),%eax
78b: 89 45 f4 mov %eax,-0xc(%ebp)
ap++;
78e: 83 45 e8 04 addl $0x4,-0x18(%ebp)
if(s == 0)
792: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
796: 75 25 jne 7bd <printf+0xff>
s = "(null)";
798: c7 45 f4 ac 0a 00 00 movl $0xaac,-0xc(%ebp)
while(*s != 0){
79f: eb 1c jmp 7bd <printf+0xff>
putc(fd, *s);
7a1: 8b 45 f4 mov -0xc(%ebp),%eax
7a4: 0f b6 00 movzbl (%eax),%eax
7a7: 0f be c0 movsbl %al,%eax
7aa: 83 ec 08 sub $0x8,%esp
7ad: 50 push %eax
7ae: ff 75 08 pushl 0x8(%ebp)
7b1: e8 31 fe ff ff call 5e7 <putc>
7b6: 83 c4 10 add $0x10,%esp
s++;
7b9: 83 45 f4 01 addl $0x1,-0xc(%ebp)
} else if(c == 's'){
s = (char*)*ap;
ap++;
if(s == 0)
s = "(null)";
while(*s != 0){
7bd: 8b 45 f4 mov -0xc(%ebp),%eax
7c0: 0f b6 00 movzbl (%eax),%eax
7c3: 84 c0 test %al,%al
7c5: 75 da jne 7a1 <printf+0xe3>
7c7: eb 65 jmp 82e <printf+0x170>
putc(fd, *s);
s++;
}
} else if(c == 'c'){
7c9: 83 7d e4 63 cmpl $0x63,-0x1c(%ebp)
7cd: 75 1d jne 7ec <printf+0x12e>
putc(fd, *ap);
7cf: 8b 45 e8 mov -0x18(%ebp),%eax
7d2: 8b 00 mov (%eax),%eax
7d4: 0f be c0 movsbl %al,%eax
7d7: 83 ec 08 sub $0x8,%esp
7da: 50 push %eax
7db: ff 75 08 pushl 0x8(%ebp)
7de: e8 04 fe ff ff call 5e7 <putc>
7e3: 83 c4 10 add $0x10,%esp
ap++;
7e6: 83 45 e8 04 addl $0x4,-0x18(%ebp)
7ea: eb 42 jmp 82e <printf+0x170>
} else if(c == '%'){
7ec: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
7f0: 75 17 jne 809 <printf+0x14b>
putc(fd, c);
7f2: 8b 45 e4 mov -0x1c(%ebp),%eax
7f5: 0f be c0 movsbl %al,%eax
7f8: 83 ec 08 sub $0x8,%esp
7fb: 50 push %eax
7fc: ff 75 08 pushl 0x8(%ebp)
7ff: e8 e3 fd ff ff call 5e7 <putc>
804: 83 c4 10 add $0x10,%esp
807: eb 25 jmp 82e <printf+0x170>
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
809: 83 ec 08 sub $0x8,%esp
80c: 6a 25 push $0x25
80e: ff 75 08 pushl 0x8(%ebp)
811: e8 d1 fd ff ff call 5e7 <putc>
816: 83 c4 10 add $0x10,%esp
putc(fd, c);
819: 8b 45 e4 mov -0x1c(%ebp),%eax
81c: 0f be c0 movsbl %al,%eax
81f: 83 ec 08 sub $0x8,%esp
822: 50 push %eax
823: ff 75 08 pushl 0x8(%ebp)
826: e8 bc fd ff ff call 5e7 <putc>
82b: 83 c4 10 add $0x10,%esp
}
state = 0;
82e: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
835: 83 45 f0 01 addl $0x1,-0x10(%ebp)
839: 8b 55 0c mov 0xc(%ebp),%edx
83c: 8b 45 f0 mov -0x10(%ebp),%eax
83f: 01 d0 add %edx,%eax
841: 0f b6 00 movzbl (%eax),%eax
844: 84 c0 test %al,%al
846: 0f 85 94 fe ff ff jne 6e0 <printf+0x22>
putc(fd, c);
}
state = 0;
}
}
}
84c: 90 nop
84d: c9 leave
84e: c3 ret
0000084f <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
84f: 55 push %ebp
850: 89 e5 mov %esp,%ebp
852: 83 ec 10 sub $0x10,%esp
Header *bp, *p;
bp = (Header*)ap - 1;
855: 8b 45 08 mov 0x8(%ebp),%eax
858: 83 e8 08 sub $0x8,%eax
85b: 89 45 f8 mov %eax,-0x8(%ebp)
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
85e: a1 68 0d 00 00 mov 0xd68,%eax
863: 89 45 fc mov %eax,-0x4(%ebp)
866: eb 24 jmp 88c <free+0x3d>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
868: 8b 45 fc mov -0x4(%ebp),%eax
86b: 8b 00 mov (%eax),%eax
86d: 3b 45 fc cmp -0x4(%ebp),%eax
870: 77 12 ja 884 <free+0x35>
872: 8b 45 f8 mov -0x8(%ebp),%eax
875: 3b 45 fc cmp -0x4(%ebp),%eax
878: 77 24 ja 89e <free+0x4f>
87a: 8b 45 fc mov -0x4(%ebp),%eax
87d: 8b 00 mov (%eax),%eax
87f: 3b 45 f8 cmp -0x8(%ebp),%eax
882: 77 1a ja 89e <free+0x4f>
free(void *ap)
{
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
884: 8b 45 fc mov -0x4(%ebp),%eax
887: 8b 00 mov (%eax),%eax
889: 89 45 fc mov %eax,-0x4(%ebp)
88c: 8b 45 f8 mov -0x8(%ebp),%eax
88f: 3b 45 fc cmp -0x4(%ebp),%eax
892: 76 d4 jbe 868 <free+0x19>
894: 8b 45 fc mov -0x4(%ebp),%eax
897: 8b 00 mov (%eax),%eax
899: 3b 45 f8 cmp -0x8(%ebp),%eax
89c: 76 ca jbe 868 <free+0x19>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
break;
if(bp + bp->s.size == p->s.ptr){
89e: 8b 45 f8 mov -0x8(%ebp),%eax
8a1: 8b 40 04 mov 0x4(%eax),%eax
8a4: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
8ab: 8b 45 f8 mov -0x8(%ebp),%eax
8ae: 01 c2 add %eax,%edx
8b0: 8b 45 fc mov -0x4(%ebp),%eax
8b3: 8b 00 mov (%eax),%eax
8b5: 39 c2 cmp %eax,%edx
8b7: 75 24 jne 8dd <free+0x8e>
bp->s.size += p->s.ptr->s.size;
8b9: 8b 45 f8 mov -0x8(%ebp),%eax
8bc: 8b 50 04 mov 0x4(%eax),%edx
8bf: 8b 45 fc mov -0x4(%ebp),%eax
8c2: 8b 00 mov (%eax),%eax
8c4: 8b 40 04 mov 0x4(%eax),%eax
8c7: 01 c2 add %eax,%edx
8c9: 8b 45 f8 mov -0x8(%ebp),%eax
8cc: 89 50 04 mov %edx,0x4(%eax)
bp->s.ptr = p->s.ptr->s.ptr;
8cf: 8b 45 fc mov -0x4(%ebp),%eax
8d2: 8b 00 mov (%eax),%eax
8d4: 8b 10 mov (%eax),%edx
8d6: 8b 45 f8 mov -0x8(%ebp),%eax
8d9: 89 10 mov %edx,(%eax)
8db: eb 0a jmp 8e7 <free+0x98>
} else
bp->s.ptr = p->s.ptr;
8dd: 8b 45 fc mov -0x4(%ebp),%eax
8e0: 8b 10 mov (%eax),%edx
8e2: 8b 45 f8 mov -0x8(%ebp),%eax
8e5: 89 10 mov %edx,(%eax)
if(p + p->s.size == bp){
8e7: 8b 45 fc mov -0x4(%ebp),%eax
8ea: 8b 40 04 mov 0x4(%eax),%eax
8ed: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
8f4: 8b 45 fc mov -0x4(%ebp),%eax
8f7: 01 d0 add %edx,%eax
8f9: 3b 45 f8 cmp -0x8(%ebp),%eax
8fc: 75 20 jne 91e <free+0xcf>
p->s.size += bp->s.size;
8fe: 8b 45 fc mov -0x4(%ebp),%eax
901: 8b 50 04 mov 0x4(%eax),%edx
904: 8b 45 f8 mov -0x8(%ebp),%eax
907: 8b 40 04 mov 0x4(%eax),%eax
90a: 01 c2 add %eax,%edx
90c: 8b 45 fc mov -0x4(%ebp),%eax
90f: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
912: 8b 45 f8 mov -0x8(%ebp),%eax
915: 8b 10 mov (%eax),%edx
917: 8b 45 fc mov -0x4(%ebp),%eax
91a: 89 10 mov %edx,(%eax)
91c: eb 08 jmp 926 <free+0xd7>
} else
p->s.ptr = bp;
91e: 8b 45 fc mov -0x4(%ebp),%eax
921: 8b 55 f8 mov -0x8(%ebp),%edx
924: 89 10 mov %edx,(%eax)
freep = p;
926: 8b 45 fc mov -0x4(%ebp),%eax
929: a3 68 0d 00 00 mov %eax,0xd68
}
92e: 90 nop
92f: c9 leave
930: c3 ret
00000931 <morecore>:
static Header*
morecore(uint nu)
{
931: 55 push %ebp
932: 89 e5 mov %esp,%ebp
934: 83 ec 18 sub $0x18,%esp
char *p;
Header *hp;
if(nu < 4096)
937: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp)
93e: 77 07 ja 947 <morecore+0x16>
nu = 4096;
940: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp)
p = sbrk(nu * sizeof(Header));
947: 8b 45 08 mov 0x8(%ebp),%eax
94a: c1 e0 03 shl $0x3,%eax
94d: 83 ec 0c sub $0xc,%esp
950: 50 push %eax
951: e8 19 fc ff ff call 56f <sbrk>
956: 83 c4 10 add $0x10,%esp
959: 89 45 f4 mov %eax,-0xc(%ebp)
if(p == (char*)-1)
95c: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp)
960: 75 07 jne 969 <morecore+0x38>
return 0;
962: b8 00 00 00 00 mov $0x0,%eax
967: eb 26 jmp 98f <morecore+0x5e>
hp = (Header*)p;
969: 8b 45 f4 mov -0xc(%ebp),%eax
96c: 89 45 f0 mov %eax,-0x10(%ebp)
hp->s.size = nu;
96f: 8b 45 f0 mov -0x10(%ebp),%eax
972: 8b 55 08 mov 0x8(%ebp),%edx
975: 89 50 04 mov %edx,0x4(%eax)
free((void*)(hp + 1));
978: 8b 45 f0 mov -0x10(%ebp),%eax
97b: 83 c0 08 add $0x8,%eax
97e: 83 ec 0c sub $0xc,%esp
981: 50 push %eax
982: e8 c8 fe ff ff call 84f <free>
987: 83 c4 10 add $0x10,%esp
return freep;
98a: a1 68 0d 00 00 mov 0xd68,%eax
}
98f: c9 leave
990: c3 ret
00000991 <malloc>:
void*
malloc(uint nbytes)
{
991: 55 push %ebp
992: 89 e5 mov %esp,%ebp
994: 83 ec 18 sub $0x18,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
997: 8b 45 08 mov 0x8(%ebp),%eax
99a: 83 c0 07 add $0x7,%eax
99d: c1 e8 03 shr $0x3,%eax
9a0: 83 c0 01 add $0x1,%eax
9a3: 89 45 ec mov %eax,-0x14(%ebp)
if((prevp = freep) == 0){
9a6: a1 68 0d 00 00 mov 0xd68,%eax
9ab: 89 45 f0 mov %eax,-0x10(%ebp)
9ae: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
9b2: 75 23 jne 9d7 <malloc+0x46>
base.s.ptr = freep = prevp = &base;
9b4: c7 45 f0 60 0d 00 00 movl $0xd60,-0x10(%ebp)
9bb: 8b 45 f0 mov -0x10(%ebp),%eax
9be: a3 68 0d 00 00 mov %eax,0xd68
9c3: a1 68 0d 00 00 mov 0xd68,%eax
9c8: a3 60 0d 00 00 mov %eax,0xd60
base.s.size = 0;
9cd: c7 05 64 0d 00 00 00 movl $0x0,0xd64
9d4: 00 00 00
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
9d7: 8b 45 f0 mov -0x10(%ebp),%eax
9da: 8b 00 mov (%eax),%eax
9dc: 89 45 f4 mov %eax,-0xc(%ebp)
if(p->s.size >= nunits){
9df: 8b 45 f4 mov -0xc(%ebp),%eax
9e2: 8b 40 04 mov 0x4(%eax),%eax
9e5: 3b 45 ec cmp -0x14(%ebp),%eax
9e8: 72 4d jb a37 <malloc+0xa6>
if(p->s.size == nunits)
9ea: 8b 45 f4 mov -0xc(%ebp),%eax
9ed: 8b 40 04 mov 0x4(%eax),%eax
9f0: 3b 45 ec cmp -0x14(%ebp),%eax
9f3: 75 0c jne a01 <malloc+0x70>
prevp->s.ptr = p->s.ptr;
9f5: 8b 45 f4 mov -0xc(%ebp),%eax
9f8: 8b 10 mov (%eax),%edx
9fa: 8b 45 f0 mov -0x10(%ebp),%eax
9fd: 89 10 mov %edx,(%eax)
9ff: eb 26 jmp a27 <malloc+0x96>
else {
p->s.size -= nunits;
a01: 8b 45 f4 mov -0xc(%ebp),%eax
a04: 8b 40 04 mov 0x4(%eax),%eax
a07: 2b 45 ec sub -0x14(%ebp),%eax
a0a: 89 c2 mov %eax,%edx
a0c: 8b 45 f4 mov -0xc(%ebp),%eax
a0f: 89 50 04 mov %edx,0x4(%eax)
p += p->s.size;
a12: 8b 45 f4 mov -0xc(%ebp),%eax
a15: 8b 40 04 mov 0x4(%eax),%eax
a18: c1 e0 03 shl $0x3,%eax
a1b: 01 45 f4 add %eax,-0xc(%ebp)
p->s.size = nunits;
a1e: 8b 45 f4 mov -0xc(%ebp),%eax
a21: 8b 55 ec mov -0x14(%ebp),%edx
a24: 89 50 04 mov %edx,0x4(%eax)
}
freep = prevp;
a27: 8b 45 f0 mov -0x10(%ebp),%eax
a2a: a3 68 0d 00 00 mov %eax,0xd68
return (void*)(p + 1);
a2f: 8b 45 f4 mov -0xc(%ebp),%eax
a32: 83 c0 08 add $0x8,%eax
a35: eb 3b jmp a72 <malloc+0xe1>
}
if(p == freep)
a37: a1 68 0d 00 00 mov 0xd68,%eax
a3c: 39 45 f4 cmp %eax,-0xc(%ebp)
a3f: 75 1e jne a5f <malloc+0xce>
if((p = morecore(nunits)) == 0)
a41: 83 ec 0c sub $0xc,%esp
a44: ff 75 ec pushl -0x14(%ebp)
a47: e8 e5 fe ff ff call 931 <morecore>
a4c: 83 c4 10 add $0x10,%esp
a4f: 89 45 f4 mov %eax,-0xc(%ebp)
a52: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
a56: 75 07 jne a5f <malloc+0xce>
return 0;
a58: b8 00 00 00 00 mov $0x0,%eax
a5d: eb 13 jmp a72 <malloc+0xe1>
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){
a5f: 8b 45 f4 mov -0xc(%ebp),%eax
a62: 89 45 f0 mov %eax,-0x10(%ebp)
a65: 8b 45 f4 mov -0xc(%ebp),%eax
a68: 8b 00 mov (%eax),%eax
a6a: 89 45 f4 mov %eax,-0xc(%ebp)
return (void*)(p + 1);
}
if(p == freep)
if((p = morecore(nunits)) == 0)
return 0;
}
a6d: e9 6d ff ff ff jmp 9df <malloc+0x4e>
}
a72: c9 leave
a73: c3 ret
|
HU - Microprocessor Lab/Assignment 3/evenodd.asm | imzaaat/assembly-projects | 1 | 90730 | .MODEL SMALL
.DATA
EXTRN DATAx:WORD
EXTRN Result:BYTE
.CODE
PUBLIC EvenOdd
PUBLIC FinishEvenOdd
EvenOdd PROC FAR
MOV Result, 0
MOV AX, DATAx
MOV DX, 0
MOV CX, 2
DIV CX
CMP DX, 0
JZ FinishEvenOdd
MOV Result, 1
; If the "Result" is 0, then it's even. Otherwise it's odd.
FinishEvenOdd:
RET
EvenOdd ENDP
END |
demo/adainclude/memory_copy.ads | e3l6/SSMDev | 0 | 16130 | --
-- Copyright (C) 2006-2013, AdaCore
--
-- This package provides a general block copy mechanisms analogous to that
-- provided by the C routine memcpy allowing for copies without overlap.
with System; use System;
with Interfaces.C; use Interfaces.C;
package Memory_Copy is
pragma Preelaborate;
procedure memcpy (Dest : Address; Src : Address; N : size_t);
pragma Export (C, memcpy, "memcpy");
-- Copies N storage units from area starting at Src to area starting
-- at Dest without any check for buffer overflow. The memory areas
-- must not overlap, or the result of this call is undefined.
end Memory_Copy;
|
libsrc/_DEVELOPMENT/arch/zxn/esxdos/c/sdcc_iy/esx_ide_mode_get.asm | jpoikela/z88dk | 640 | 242651 | <filename>libsrc/_DEVELOPMENT/arch/zxn/esxdos/c/sdcc_iy/esx_ide_mode_get.asm
; unsigned char esx_ide_mode_get(struct esx_mode *mode)
SECTION code_esxdos
PUBLIC _esx_ide_mode_get
EXTERN _esx_ide_mode_get_fastcall
_esx_ide_mode_get:
pop af
pop hl
push hl
push af
jp _esx_ide_mode_get_fastcall
|
programs/oeis/157/A157001.asm | neoneye/loda | 22 | 26329 | ; A157001: Fractions x/y, with 1<=x,y<=n, that reduce to (odd)/(even).
; 0,1,2,5,7,11,14,21,25,32,37,47,53,63,70,85,93,106,115,132,142,158,169,191,203,222,235,259,273,295,310,341,357,382,399,430,448,476,495,532,552,583,604,642,664,698,721,767,791,828,853,898,924,964,991,1043,1071
mov $2,$0
lpb $2
mov $3,$2
mov $2,0
lpb $3
add $1,$3
add $2,1
trn $3,2
lpe
sub $2,1
lpe
mov $0,$1
|
_maps/Sonic.asm | kodishmediacenter/msu-md-sonic | 9 | 104255 | ; ---------------------------------------------------------------------------
; Sprite mappings - Sonic
; ---------------------------------------------------------------------------
Map_Sonic_internal:
ptr_MS_Null: dc.w MS_Null-Map_Sonic_internal
ptr_MS_Stand: dc.w MS_Stand-Map_Sonic_internal
ptr_MS_Wait1: dc.w MS_Wait1-Map_Sonic_internal
ptr_MS_Wait2: dc.w MS_Wait2-Map_Sonic_internal
ptr_MS_Wait3: dc.w MS_Wait3-Map_Sonic_internal
ptr_MS_LookUp: dc.w MS_LookUp-Map_Sonic_internal
ptr_MS_Walk11: dc.w MS_Walk11-Map_Sonic_internal
ptr_MS_Walk12: dc.w MS_Walk12-Map_Sonic_internal
ptr_MS_Walk13: dc.w MS_Walk13-Map_Sonic_internal
ptr_MS_Walk14: dc.w MS_Walk14-Map_Sonic_internal
ptr_MS_Walk15: dc.w MS_Walk15-Map_Sonic_internal
ptr_MS_Walk16: dc.w MS_Walk16-Map_Sonic_internal
ptr_MS_Walk21: dc.w MS_Walk21-Map_Sonic_internal
ptr_MS_Walk22: dc.w MS_Walk22-Map_Sonic_internal
ptr_MS_Walk23: dc.w MS_Walk23-Map_Sonic_internal
ptr_MS_Walk24: dc.w MS_Walk24-Map_Sonic_internal
ptr_MS_Walk25: dc.w MS_Walk25-Map_Sonic_internal
ptr_MS_Walk26: dc.w MS_Walk26-Map_Sonic_internal
ptr_MS_Walk31: dc.w MS_Walk31-Map_Sonic_internal
ptr_MS_Walk32: dc.w MS_Walk32-Map_Sonic_internal
ptr_MS_Walk33: dc.w MS_Walk33-Map_Sonic_internal
ptr_MS_Walk34: dc.w MS_Walk34-Map_Sonic_internal
ptr_MS_Walk35: dc.w MS_Walk35-Map_Sonic_internal
ptr_MS_Walk36: dc.w MS_Walk36-Map_Sonic_internal
ptr_MS_Walk41: dc.w MS_Walk41-Map_Sonic_internal
ptr_MS_Walk42: dc.w MS_Walk42-Map_Sonic_internal
ptr_MS_Walk43: dc.w MS_Walk43-Map_Sonic_internal
ptr_MS_Walk44: dc.w MS_Walk44-Map_Sonic_internal
ptr_MS_Walk45: dc.w MS_Walk45-Map_Sonic_internal
ptr_MS_Walk46: dc.w MS_Walk46-Map_Sonic_internal
ptr_MS_Run11: dc.w MS_Run11-Map_Sonic_internal
ptr_MS_Run12: dc.w MS_Run12-Map_Sonic_internal
ptr_MS_Run13: dc.w MS_Run13-Map_Sonic_internal
ptr_MS_Run14: dc.w MS_Run14-Map_Sonic_internal
ptr_MS_Run21: dc.w MS_Run21-Map_Sonic_internal
ptr_MS_Run22: dc.w MS_Run22-Map_Sonic_internal
ptr_MS_Run23: dc.w MS_Run23-Map_Sonic_internal
ptr_MS_Run24: dc.w MS_Run24-Map_Sonic_internal
ptr_MS_Run31: dc.w MS_Run31-Map_Sonic_internal
ptr_MS_Run32: dc.w MS_Run32-Map_Sonic_internal
ptr_MS_Run33: dc.w MS_Run33-Map_Sonic_internal
ptr_MS_Run34: dc.w MS_Run34-Map_Sonic_internal
ptr_MS_Run41: dc.w MS_Run41-Map_Sonic_internal
ptr_MS_Run42: dc.w MS_Run42-Map_Sonic_internal
ptr_MS_Run43: dc.w MS_Run43-Map_Sonic_internal
ptr_MS_Run44: dc.w MS_Run44-Map_Sonic_internal
ptr_MS_Roll1: dc.w MS_Roll1-Map_Sonic_internal
ptr_MS_Roll2: dc.w MS_Roll2-Map_Sonic_internal
ptr_MS_Roll3: dc.w MS_Roll3-Map_Sonic_internal
ptr_MS_Roll4: dc.w MS_Roll4-Map_Sonic_internal
ptr_MS_Roll5: dc.w MS_Roll5-Map_Sonic_internal
ptr_MS_Warp1: dc.w MS_Warp1-Map_Sonic_internal
ptr_MS_Warp2: dc.w MS_Warp2-Map_Sonic_internal
ptr_MS_Warp3: dc.w MS_Warp3-Map_Sonic_internal
ptr_MS_Warp4: dc.w MS_Warp4-Map_Sonic_internal
ptr_MS_Stop1: dc.w MS_Stop1-Map_Sonic_internal
ptr_MS_Stop2: dc.w MS_Stop2-Map_Sonic_internal
ptr_MS_Duck: dc.w MS_Duck-Map_Sonic_internal
ptr_MS_Balance1:dc.w MS_Balance1-Map_Sonic_internal
ptr_MS_Balance2:dc.w MS_Balance2-Map_Sonic_internal
ptr_MS_Float1: dc.w MS_Float1-Map_Sonic_internal
ptr_MS_Float2: dc.w MS_Float2-Map_Sonic_internal
ptr_MS_Float3: dc.w MS_Float3-Map_Sonic_internal
ptr_MS_Float4: dc.w MS_Float4-Map_Sonic_internal
ptr_MS_Spring: dc.w MS_Spring-Map_Sonic_internal
ptr_MS_Hang1: dc.w MS_Hang1-Map_Sonic_internal
ptr_MS_Hang2: dc.w MS_Hang2-Map_Sonic_internal
ptr_MS_Leap1: dc.w MS_Leap1-Map_Sonic_internal
ptr_MS_Leap2: dc.w MS_Leap2-Map_Sonic_internal
ptr_MS_Push1: dc.w MS_Push1-Map_Sonic_internal
ptr_MS_Push2: dc.w MS_Push2-Map_Sonic_internal
ptr_MS_Push3: dc.w MS_Push3-Map_Sonic_internal
ptr_MS_Push4: dc.w MS_Push4-Map_Sonic_internal
ptr_MS_Surf: dc.w MS_Surf-Map_Sonic_internal
ptr_MS_BubStand:dc.w MS_BubStand-Map_Sonic_internal
ptr_MS_Burnt: dc.w MS_Burnt-Map_Sonic_internal
ptr_MS_Drown: dc.w MS_Drown-Map_Sonic_internal
ptr_MS_Death: dc.w MS_Death-Map_Sonic_internal
ptr_MS_Shrink1: dc.w MS_Shrink1-Map_Sonic_internal
ptr_MS_Shrink2: dc.w MS_Shrink2-Map_Sonic_internal
ptr_MS_Shrink3: dc.w MS_Shrink3-Map_Sonic_internal
ptr_MS_Shrink4: dc.w MS_Shrink4-Map_Sonic_internal
ptr_MS_Shrink5: dc.w MS_Shrink5-Map_Sonic_internal
ptr_MS_Float5: dc.w MS_Float5-Map_Sonic_internal
ptr_MS_Float6: dc.w MS_Float6-Map_Sonic_internal
ptr_MS_Injury: dc.w MS_Injury-Map_Sonic_internal
ptr_MS_GetAir: dc.w MS_GetAir-Map_Sonic_internal
ptr_MS_WaterSlide:dc.w MS_WaterSlide-Map_Sonic_internal
MS_Null: dc.b 0
MS_Stand: dc.b 4 ; standing
dc.b $EC, 8, 0, 0, $F0
dc.b $F4, $D, 0, 3, $F0
dc.b 4, 8, 0, $B, $F0
dc.b $C, 8, 0, $E, $F8
MS_Wait1: dc.b 3 ; waiting 1
dc.b $EC, 9, 0, 0, $F0
dc.b $FC, 9, 0, 6, $F0
dc.b $C, 8, 0, $C, $F8
MS_Wait2: dc.b 3 ; waiting 2
dc.b $EC, 9, 0, 0, $F0
dc.b $FC, 9, 0, 6, $F0
dc.b $C, 8, 0, $C, $F8
MS_Wait3: dc.b 3 ; waiting 3
dc.b $EC, 9, 0, 0, $F0
dc.b $FC, 9, 0, 6, $F0
dc.b $C, 8, 0, $C, $F8
MS_LookUp: dc.b 3 ; looking up
dc.b $EC, $A, 0, 0, $F0
dc.b 4, 8, 0, 9, $F0
dc.b $C, 8, 0, $C, $F8
MS_Walk11: dc.b 4 ; walking 1-1
dc.b $EB, $D, 0, 0, $EC
dc.b $FB, 9, 0, 8, $EC
dc.b $FB, 6, 0, $E, 4
dc.b $B, 4, 0, $14, $EC
MS_Walk12: dc.b 2 ; walking 1-2
dc.b $EC, $D, 0, 0, $ED
dc.b $FC, $E, 0, 8, $F5
MS_Walk13: dc.b 2 ; walking 1-3
dc.b $ED, 9, 0, 0, $F3
dc.b $FD, $A, 0, 6, $F3
MS_Walk14: dc.b 4 ; walking 1-4
dc.b $EB, 9, 0, 0, $F4
dc.b $FB, 9, 0, 6, $EC
dc.b $FB, 6, 0, $C, 4
dc.b $B, 4, 0, $12, $EC
MS_Walk15: dc.b 2 ; walking 1-5
dc.b $EC, 9, 0, 0, $F3
dc.b $FC, $E, 0, 6, $EB
MS_Walk16: dc.b 3 ; walking 1-6
dc.b $ED, $D, 0, 0, $EC
dc.b $FD, $C, 0, 8, $F4
dc.b 5, 9, 0, $C, $F4
MS_Walk21: dc.b 5 ; walking 2-1
dc.b $EB, 9, 0, 0, $EB
dc.b $EB, 6, 0, 6, 3
dc.b $FB, 8, 0, $C, $EB
dc.b 3, 9, 0, $F, $F3
dc.b $13, 0, 0, $15, $FB
MS_Walk22: dc.b 6 ; walking 2-2
dc.b $EC, 9, 0, 0, $EC
dc.b $EC, 1, 0, 6, 4
dc.b $FC, $C, 0, 8, $EC
dc.b 4, 9, 0, $C, $F4
dc.b $FC, 5, 0, $12, $C
dc.b $F4, 0, 0, $16, $14
MS_Walk23: dc.b 4 ; walking 2-3
dc.b $ED, 9, 0, 0, $ED
dc.b $ED, 1, 0, 6, 5
dc.b $FD, $D, 0, 8, $F5
dc.b $D, 8, 0, $10, $FD
MS_Walk24: dc.b 5 ; walking 2-4
dc.b $EB, 9, 0, 0, $EB
dc.b $EB, 5, 0, 6, 3
dc.b $FB, $D, 0, $A, $F3
dc.b $B, 8, 0, $12, $F3
dc.b $13, 4, 0, $15, $FB
MS_Walk25: dc.b 4 ; walking 2-5
dc.b $EC, 9, 0, 0, $EC
dc.b $EC, 1, 0, 6, 4
dc.b $FC, $D, 0, 8, $F4
dc.b $C, 8, 0, $10, $FC
MS_Walk26: dc.b 5 ; walking 2-6
dc.b $ED, 9, 0, 0, $ED
dc.b $ED, 1, 0, 6, 5
dc.b $FD, 0, 0, 8, $ED
dc.b $FD, $D, 0, 9, $F5
dc.b $D, 8, 0, $11, $FD
MS_Walk31: dc.b 4 ; walking 3-1
dc.b $F4, 7, 0, 0, $EB
dc.b $EC, 9, 0, 8, $FB
dc.b $FC, 4, 0, $E, $FB
dc.b 4, 9, 0, $10, $FB
MS_Walk32: dc.b 2 ; walking 3-2
dc.b $F4, 7, 0, 0, $EC
dc.b $EC, $B, 0, 8, $FC
MS_Walk33: dc.b 2 ; walking 3-3
dc.b $F4, 6, 0, 0, $ED
dc.b $F4, $A, 0, 6, $FD
MS_Walk34: dc.b 4 ; walking 3-4
dc.b $F4, 6, 0, 0, $EB
dc.b $EC, 9, 0, 6, $FB
dc.b $FC, 4, 0, $C, $FB
dc.b 4, 9, 0, $E, $FB
MS_Walk35: dc.b 2 ; walking 3-5
dc.b $F4, 6, 0, 0, $EC
dc.b $F4, $B, 0, 6, $FC
MS_Walk36: dc.b 3 ; walking 3-6
dc.b $F4, 7, 0, 0, $ED
dc.b $EC, 0, 0, 8, $FD
dc.b $F4, $A, 0, 9, $FD
MS_Walk41: dc.b 6 ; walking 4-1
dc.b $FD, 6, 0, 0, $EB
dc.b $ED, 4, 0, 6, $F3
dc.b $F5, 4, 0, 8, $EB
dc.b $F5, $A, 0, $A, $FB
dc.b $D, 0, 0, $13, $FB
dc.b $FD, 0, 0, $14, $13
MS_Walk42: dc.b 6 ; walking 4-2
dc.b $FC, 6, 0, 0, $EC
dc.b $E4, 8, 0, 6, $F4
dc.b $EC, 4, 0, 9, $FC
dc.b $F4, 4, 0, $B, $EC
dc.b $F4, $A, 0, $D, $FC
dc.b $C, 0, 0, $16, $FC
MS_Walk43: dc.b 4 ; walking 4-3
dc.b $FB, 6, 0, 0, $ED
dc.b $F3, 4, 0, 6, $ED
dc.b $EB, $A, 0, 8, $FD
dc.b 3, 4, 0, $11, $FD
MS_Walk44: dc.b 5 ; walking 4-4
dc.b $FD, 6, 0, 0, $EB
dc.b $ED, 8, 0, 6, $F3
dc.b $F5, 4, 0, 9, $EB
dc.b $F5, $D, 0, $B, $FB
dc.b 5, 8, 0, $13, $FB
MS_Walk45: dc.b 4 ; walking 4-5
dc.b $FC, 6, 0, 0, $EC
dc.b $F4, 4, 0, 6, $EC
dc.b $EC, $A, 0, 8, $FC
dc.b 4, 4, 0, $11, $FC
MS_Walk46: dc.b 5 ; walking 4-6
dc.b $FB, 6, 0, 0, $ED
dc.b $EB, $A, 0, 6, $FD
dc.b $F3, 4, 0, $F, $ED
dc.b 3, 4, 0, $11, $FD
dc.b $B, 0, 0, $13, $FD
MS_Run11: dc.b 2 ; running 1-1
dc.b $EE, 9, 0, 0, $F4
dc.b $FE, $E, 0, 6, $EC
MS_Run12: dc.b 2 ; running 1-2
dc.b $EE, 9, 0, 0, $F4
dc.b $FE, $E, 0, 6, $EC
MS_Run13: dc.b 2 ; running 1-3
dc.b $EE, 9, 0, 0, $F4
dc.b $FE, $E, 0, 6, $EC
MS_Run14: dc.b 2 ; running 1-4
dc.b $EE, 9, 0, 0, $F4
dc.b $FE, $E, 0, 6, $EC
MS_Run21: dc.b 4 ; running 2-1
dc.b $EE, 9, 0, 0, $EE
dc.b $EE, 1, 0, 6, 6
dc.b $FE, $E, 0, 8, $F6
dc.b $FE, 0, 0, $14, $EE
MS_Run22: dc.b 3 ; running 2-2
dc.b $EE, 9, 0, 0, $EE
dc.b $EE, 1, 0, 6, 6
dc.b $FE, $E, 0, 8, $F6
MS_Run23: dc.b 4 ; running 2-3
dc.b $EE, 9, 0, 0, $EE
dc.b $EE, 1, 0, 6, 6
dc.b $FE, $E, 0, 8, $F6
dc.b $FE, 0, 0, $14, $EE
MS_Run24: dc.b 3 ; running 2-4
dc.b $EE, 9, 0, 0, $EE
dc.b $EE, 1, 0, 6, 6
dc.b $FE, $E, 0, 8, $F6
MS_Run31: dc.b 2 ; running 3-1
dc.b $F4, 6, 0, 0, $EE
dc.b $F4, $B, 0, 6, $FE
MS_Run32: dc.b 2 ; running 3-2
dc.b $F4, 6, 0, 0, $EE
dc.b $F4, $B, 0, 6, $FE
MS_Run33: dc.b 2 ; running 3-3
dc.b $F4, 6, 0, 0, $EE
dc.b $F4, $B, 0, 6, $FE
MS_Run34: dc.b 2 ; running 3-4
dc.b $F4, 6, 0, 0, $EE
dc.b $F4, $B, 0, 6, $FE
MS_Run41: dc.b 4 ; running 4-1
dc.b $FA, 6, 0, 0, $EE
dc.b $F2, 4, 0, 6, $EE
dc.b $EA, $B, 0, 8, $FE
dc.b $A, 0, 0, $14, $FE
MS_Run42: dc.b 2 ; running 4-2
dc.b $F2, 7, 0, 0, $EE
dc.b $EA, $B, 0, 8, $FE
MS_Run43: dc.b 4 ; running 4-3
dc.b $FA, 6, 0, 0, $EE
dc.b $F2, 4, 0, 6, $EE
dc.b $EA, $B, 0, 8, $FE
dc.b $A, 0, 0, $14, $FE
MS_Run44: dc.b 2 ; running 4-4
dc.b $F2, 7, 0, 0, $EE
dc.b $EA, $B, 0, 8, $FE
MS_Roll1: dc.b 1 ; rolling 1
dc.b $F0, $F, 0, 0, $F0
MS_Roll2: dc.b 1 ; rolling 2
dc.b $F0, $F, 0, 0, $F0
MS_Roll3: dc.b 1 ; rolling 3
dc.b $F0, $F, 0, 0, $F0
MS_Roll4: dc.b 1 ; rolling 4
dc.b $F0, $F, 0, 0, $F0
MS_Roll5: dc.b 1 ; rolling 5
dc.b $F0, $F, 0, 0, $F0
MS_Warp1: dc.b 2 ; warped 1 (unused)
dc.b $F4, $E, 0, 0, $EC
dc.b $F4, 2, 0, $C, $C
MS_Warp2: dc.b 1 ; warped 2 (unused)
dc.b $F0, $F, 0, 0, $F0
MS_Warp3: dc.b 2 ; warped 3 (unused)
dc.b $EC, $B, 0, 0, $F4
dc.b $C, 8, 0, $C, $F4
MS_Warp4: dc.b 1 ; warped 4 (unused)
dc.b $F0, $F, 0, 0, $F0
MS_Stop1: dc.b 2 ; stopping 1
dc.b $ED, 9, 0, 0, $F0
dc.b $FD, $E, 0, 6, $F0
MS_Stop2: dc.b 4 ; stopping 2
dc.b $ED, 9, 0, 0, $F0
dc.b $FD, $D, 0, 6, $F0
dc.b $D, 4, 0, $E, 0
dc.b 5, 0, 0, $10, $E8
MS_Duck: dc.b 4 ; ducking
dc.b $F4, 4, 0, 0, $FC
dc.b $FC, $D, 0, 2, $F4
dc.b $C, 8, 0, $A, $F4
dc.b 4, 0, 0, $D, $EC
MS_Balance1: dc.b 3 ; balancing 1
dc.b $EC, 8, 8, 0, $E8
dc.b $F4, 2, 8, 3, 0
dc.b $F4, $F, 8, 6, $E0
MS_Balance2: dc.b 3 ; balancing 2
dc.b $EC, $E, 8, 0, $E8
dc.b 4, $D, 8, $C, $E0
dc.b $C, 0, $18, $14, 0
MS_Float1: dc.b 3 ; spinning 1 (LZ)
dc.b $F4, $D, 0, 0, $FC
dc.b $FC, 5, 0, 8, $EC
dc.b 4, 8, 0, $C, $FC
MS_Float2: dc.b 2 ; spinning 2 (LZ)
dc.b $F4, $A, 0, 0, $E8
dc.b $F4, $A, 8, 0, 0
MS_Float3: dc.b 3 ; spinning 3 (LZ)
dc.b $F4, $D, 0, 0, $E4
dc.b $FC, 0, 0, 8, 4
dc.b 4, $C, 0, 9, $EC
MS_Float4: dc.b 3 ; spinning 4 (LZ)
dc.b $F4, $D, 0, 0, $FC
dc.b $FC, 5, 0, 8, $EC
dc.b 4, 8, 0, $C, $FC
MS_Spring: dc.b 3 ; bouncing on a spring
dc.b $E8, $B, 0, 0, $F0
dc.b 8, 4, 0, $C, $F8
dc.b $10, 0, 0, $E, $F8
MS_Hang1: dc.b 4 ; hanging 1 (LZ)
dc.b $F8, $E, 0, 0, $E8
dc.b 0, 5, 0, $C, 8
dc.b $F8, 0, 0, $10, 8
dc.b $F0, 0, 0, $11, $F8
MS_Hang2: dc.b 4 ; hanging 2 (LZ)
dc.b $F8, $E, 0, 0, $E8
dc.b 0, 5, 0, $C, 8
dc.b $F8, 0, 0, $10, 8
dc.b $F0, 0, 0, $11, $F8
MS_Leap1: dc.b 5 ; celebration leap 1 (unused)
dc.b $E8, $A, 0, 0, $F4
dc.b $F0, 1, 0, 9, $C
dc.b 0, 9, 0, $B, $F4
dc.b $10, 4, 0, $11, $F4
dc.b 0, 0, 0, $13, $EC
MS_Leap2: dc.b 5 ; celebration leap 2 (unused)
dc.b $E8, $A, 0, 0, $F4
dc.b $E8, 1, 0, 9, $C
dc.b 0, 9, 0, $B, $F4
dc.b $10, 4, 0, $11, $F4
dc.b 0, 0, 0, $13, $EC
MS_Push1: dc.b 2 ; pushing 1
dc.b $ED, $A, 0, 0, $F3
dc.b 5, $D, 0, 9, $EB
MS_Push2: dc.b 3 ; pushing 2
dc.b $EC, $A, 0, 0, $F3
dc.b 4, 8, 0, 9, $F3
dc.b $C, 4, 0, $C, $F3
MS_Push3: dc.b 2 ; pushing 3
dc.b $ED, $A, 0, 0, $F3
dc.b 5, $D, 0, 9, $EB
MS_Push4: dc.b 3 ; pushing 4
dc.b $EC, $A, 0, 0, $F3
dc.b 4, 8, 0, 9, $F3
dc.b $C, 4, 0, $C, $F3
MS_Surf: dc.b 2 ; surfing or sliding (unused)
dc.b $EC, 9, 0, 0, $F0
dc.b $FC, $E, 0, 6, $F0
MS_BubStand: dc.b 3 ; collecting bubble (unused)
dc.b $EC, $A, 0, 0, $F0
dc.b 4, 5, 0, 9, $F8
dc.b $E4, 0, 0, $D, $F8
MS_Burnt: dc.b 3 ; grey death
dc.b $E8, $D, 0, 0, $EC
dc.b $E8, 1, 0, 8, $C
dc.b $F8, $B, 0, $A, $F4
MS_Drown: dc.b 5 ; drowning
dc.b $E8, $D, 0, 0, $EC
dc.b $E8, 1, 0, 8, $C
dc.b $F8, 9, 0, $A, $F4
dc.b 8, $C, 0, $10, $F4
dc.b $10, 0, 0, $14, $F4
MS_Death: dc.b 5 ; death
dc.b $E8, $D, 0, 0, $EC
dc.b $E8, 1, 0, 8, $C
dc.b $F8, 9, 0, $A, $F4
dc.b 8, $C, 0, $10, $F4
dc.b $10, 0, 0, $14, $F4
MS_Shrink1: dc.b 2 ; shrinking 1 (unused)
dc.b $EC, 8, 0, 0, $F0
dc.b $F4, $F, 0, 3, $F0
MS_Shrink2: dc.b 3 ; shrinking 2 (unused)
dc.b $EC, 8, 0, 0, $F0
dc.b $F4, $E, 0, 3, $F0
dc.b $C, 8, 0, $F, $F8
MS_Shrink3: dc.b 1 ; shrinking 3 (unused)
dc.b $F0, $B, 0, 0, $F4
MS_Shrink4: dc.b 1 ; shrinking 4 (unused)
dc.b $F4, 6, 0, 0, $F8
MS_Shrink5: dc.b 1 ; shrinking 5 (unused)
dc.b $F8, 1, 0, 0, $FC
MS_Float5: dc.b 3 ; spinning 5 (LZ)
dc.b $F4, $D, 8, 0, $E4
dc.b $FC, 5, 8, 8, 4
dc.b 4, 8, 8, $C, $EC
MS_Float6: dc.b 3 ; spinning 6 (LZ)
dc.b $F4, $D, 8, 0, $FC
dc.b $FC, 0, 8, 8, $F4
dc.b 4, $C, 8, 9, $F4
MS_Injury: dc.b 3 ; injury
dc.b $F0, $E, 0, 0, $EC
dc.b $F8, 1, 0, $C, $C
dc.b 8, $C, 0, $E, $F4
MS_GetAir: dc.b 3 ; collecting bubble (LZ)
dc.b $EB, 9, 0, 0, $F4
dc.b $FB, $E, 0, 6, $EC
dc.b 3, 1, 0, $12, $C
MS_WaterSlide: dc.b 2 ; water slide (LZ)
dc.b $F0, $F, 0, 0, $EC
dc.b $F8, 2, 0, $10, $C
even
|
src/aco-od.ads | osannolik/ada-canopen | 6 | 11782 | with ACO.States;
with ACO.Messages;
with ACO.Events;
with ACO.OD_Types;
with ACO.SDO_Sessions;
package ACO.OD is
use ACO.OD_Types;
subtype Comm_Profile_Index is Object_Index range 16#1000# .. 16#1FFF#;
Comm_Cycle_Period_Index : constant := 16#1006#;
Heartbeat_Producer_Index : constant := 16#1017#;
Heartbeat_Consumer_Index : constant := 16#1016#;
Sync_Counter_Overflow_Index : constant := 16#1019#;
SDO_Server_Base_Index : constant := 16#1200#;
SDO_Client_Base_Index : constant := 16#1280#;
type Object_Dictionary_Base is abstract tagged limited record
Events : ACO.Events.Node_Event_Manager;
end record;
type Object_Dictionary is abstract new Object_Dictionary_Base with private;
function Objects
(This : Object_Dictionary)
return Profile_Objects_Ref is abstract;
function Index_Map
(This : Object_Dictionary;
Index : Object_Index)
return Index_Type is abstract;
function Object_Exist
(This : Object_Dictionary'Class;
Index : Object_Index)
return Boolean;
function Entry_Exist
(This : Object_Dictionary'Class;
Index : Object_Index;
Subindex : Object_Subindex)
return Boolean;
function Maximum_Nof_Entries
(This : Object_Dictionary;
Index : Object_Index)
return Natural
with Pre => This.Object_Exist (Index);
function Is_Entry_Compatible
(This : Object_Dictionary;
An_Entry : Entry_Base'Class;
Index : Object_Index;
Subindex : Object_Subindex)
return Boolean
with Pre => This.Entry_Exist (Index, Subindex);
function Is_Entry_Writable
(This : Object_Dictionary;
Index : Entry_Index)
return Boolean;
function Is_Entry_Readable
(This : Object_Dictionary;
Index : Entry_Index)
return Boolean;
function Get_Entry
(This : Object_Dictionary;
Index : Object_Index;
Subindex : Object_Subindex) return Entry_Base'Class
with Pre => This.Entry_Exist (Index, Subindex);
procedure Set_Entry
(This : in out Object_Dictionary;
New_Entry : in Entry_Base'Class;
Index : in Object_Index;
Subindex : in Object_Subindex;
Silently : in Boolean := False)
with Pre => This.Entry_Exist (Index, Subindex) and then
This.Is_Entry_Compatible (New_Entry, Index, Subindex);
procedure Set_Node_State
(This : in out Object_Dictionary;
Node_State : in ACO.States.State);
function Get_Node_State
(This : Object_Dictionary)
return ACO.States.State;
procedure Set_Heartbeat_Consumer_Period
(This : in out Object_Dictionary;
Node_Id : in ACO.Messages.Node_Nr;
Period : in Natural)
with Pre => This.Object_Exist (Heartbeat_Consumer_Index);
function Get_Heartbeat_Consumer_Period
(This : Object_Dictionary;
Node_Id : ACO.Messages.Node_Nr)
return Natural;
procedure Set_Heartbeat_Producer_Period
(This : in out Object_Dictionary;
Period : in Natural)
with Pre => This.Entry_Exist (Heartbeat_Producer_Index, 0);
function Get_Heartbeat_Producer_Period
(This : Object_Dictionary)
return Natural;
procedure Set_Communication_Cycle_Period
(This : in out Object_Dictionary;
Period : in Natural)
with Pre => This.Entry_Exist (Comm_Cycle_Period_Index, 0);
function Get_Communication_Cycle_Period
(This : Object_Dictionary)
return Natural
with Pre => This.Entry_Exist (Comm_Cycle_Period_Index, 0);
procedure Set_Sync_Counter_Overflow
(This : in out Object_Dictionary;
Period : in Natural)
with Pre => This.Entry_Exist (Sync_Counter_Overflow_Index, 0);
function Get_Sync_Counter_Overflow
(This : Object_Dictionary)
return Natural
with Pre => This.Entry_Exist (Sync_Counter_Overflow_Index, 0);
function Get_SDO_Server_Parameters
(This : Object_Dictionary)
return ACO.SDO_Sessions.SDO_Parameter_Array
with Pre => This.Object_Exist (SDO_Server_Base_Index);
function Get_SDO_Client_Parameters
(This : Object_Dictionary)
return ACO.SDO_Sessions.SDO_Parameter_Array
with Pre => This.Object_Exist (SDO_Client_Base_Index);
private
type Object_Dictionary is abstract new Object_Dictionary_Base with record
Node_State : ACO.States.State := ACO.States.Unknown_State;
end record;
function Object
(This : Object_Dictionary'Class;
Index : Object_Index)
return Object_Ref
with Inline;
end ACO.OD;
|
oeis/030/A030179.asm | neoneye/loda-programs | 11 | 14963 | ; A030179: Quarter-squares squared: A002620^2.
; 0,0,1,4,16,36,81,144,256,400,625,900,1296,1764,2401,3136,4096,5184,6561,8100,10000,12100,14641,17424,20736,24336,28561,33124,38416,44100,50625,57600,65536,73984,83521,93636,104976,116964,130321,144400,160000,176400,194481,213444,234256,256036,279841,304704,331776,360000,390625,422500,456976,492804,531441,571536,614656,659344,707281,756900,810000,864900,923521,984064,1048576,1115136,1185921,1258884,1336336,1416100,1500625,1587600,1679616,1774224,1874161,1976836,2085136,2196324,2313441,2433600
pow $0,2
div $0,4
pow $0,2
|
oeis/116/A116837.asm | neoneye/loda-programs | 11 | 6515 | <filename>oeis/116/A116837.asm
; A116837: Number of permutations of length n which avoid the patterns 3421, 4123, 4312; or avoid the patterns 2341, 3142, 3214.
; Submitted by <NAME>
; 1,2,6,21,73,250,853,2911,9938,33931,115849,395534,1350437,4610679,15741842,53746011,183500361,626509422,2139036965,7303129015,24934442130,85131510491,290657157705,992365609838,3388148123941
mov $1,1
mov $3,1
lpb $0
sub $0,1
add $2,$1
add $4,$1
add $1,$3
mul $3,2
add $4,$2
add $3,$4
lpe
mov $0,$1
|
test/Succeed/lonesig.agda | shlevy/agda | 1,989 | 3597 | f : Set → Set
module _ (A : Set) where
mutual
g : Set
g = h
h : Set
h = A
f = g
|
alloy4fun_models/trashltl/models/1/hmYECuttyNZ6nL7hu.als | Kaixi26/org.alloytools.alloy | 0 | 4376 | open main
pred idhmYECuttyNZ6nL7hu_prop2 {
historically (no File) until some File
}
pred __repair { idhmYECuttyNZ6nL7hu_prop2 }
check __repair { idhmYECuttyNZ6nL7hu_prop2 <=> prop2o } |
tests/tests.adb | Componolit/AZ3 | 5 | 26293 | with AZ3_Suite;
with AUnit.Run;
with AUnit.Reporter.Text;
with Ada.Command_Line;
with Ada.Text_IO; use Ada.Text_IO;
procedure Tests is
function Run is new AUnit.Run.Test_Runner_With_Status (AZ3_Suite.Suite);
Reporter : AUnit.Reporter.Text.Text_Reporter;
use AUnit;
S : Status;
begin
Put_Line ("Running AZ3 tests...");
Reporter.Set_Use_ANSI_Colors (True);
S := Run (Reporter);
Ada.Command_Line.Set_Exit_Status (if S = Success then 0 else 1);
end Tests;
|
asm/cpu.asm | BenG49/cpu | 0 | 5300 | <reponame>BenG49/cpu
#ruledef
{
nop => 0x00
lda {addr: u8} => 0x01 @ addr`8
lda ${val: i8} => 0x02 @ val`8
sta {addr: u8} => 0x03 @ addr`8
add {addr: u8} => 0x04 @ addr`8
add ${val: i8} => 0x05 @ val`8
sub {addr: u8} => 0x06 @ addr`8
sub ${val: i9} => 0x07 @ val`8
out => 0x08
hlt => 0x09
pha => 0x0a
pla => 0x0b
; NOTE: CALL CLOBBERS A REGISTER
call {addr: u8} => 0x0c @ addr` 8
ret => 0x0d
jmp {addr: u8} => 0x0e @ addr `8
jz {addr: u8} => 0x0f @ addr `8
je {addr: u8} => 0x0f @ addr `8
jnz {addr: u8} => 0x10 @ addr `8
jne {addr: u8} => 0x10 @ addr `8
jc {addr: u8} => 0x11 @ addr `8
jnc {addr: u8} => 0x12 @ addr `8
js {addr: u8} => 0x12 @ addr `8
jns {addr: u8} => 0x14 @ addr `8
jmp #{addr: u8} => 0x15 @ addr`8
jz #{addr: u8} => 0x16 @ addr`8
je #{addr: u8} => 0x16 @ addr`8
jnz #{addr: u8} => 0x17 @ addr`8
jne #{addr: u8} => 0x17 @ addr`8
jc #{addr: u8} => 0x18 @ addr
jnc #{addr: u8} => 0x19 @ addr
js #{addr: u8} => 0x1a @ addr
jns #{addr: u8} => 0x1b @ addr
}
; reset sequence
; sets stack to 0xff
; pushes to underflow stack pointer to 0xff, needs to load lda byte to not overwrite addr zero
lda $2
pha
lda $0
|
oeis/188/A188938.asm | neoneye/loda-programs | 11 | 15680 | <filename>oeis/188/A188938.asm
; A188938: Decimal expansion of (7-sqrt(33))/4.
; Submitted by <NAME>
; 3,1,3,8,5,9,3,3,8,3,6,5,4,9,2,8,3,5,0,3,7,3,4,7,1,3,2,9,4,5,2,6,7,6,7,0,4,4,4,9,3,3,8,8,5,5,0,4,3,0,1,9,0,8,0,7,5,0,3,0,6,3,2,3,5,8,5,2,4,8,1,9,6,3,5,6,4,8,8,4,3,2,4,3,2,1,8,6,5,8,6,0,0,8,0,2,9,6,9,3
add $0,1
mov $2,1
mov $3,$0
mul $3,4
lpb $3
mul $1,$3
mul $2,$3
add $1,$2
mov $7,$5
cmp $7,0
add $5,$7
div $1,$5
mul $1,2
div $2,$5
add $2,$1
mul $1,2
sub $3,1
add $5,1
lpe
mov $4,10
pow $4,$0
div $2,$4
div $1,$2
sub $6,$1
mov $0,$6
sub $0,1
mod $0,10
add $0,10
mod $0,10
|
archive/agda-2/Oscar/Data/Permutation.agda | m0davis/oscar | 0 | 2711 |
module Oscar.Data.Permutation where
--open import Data.Permutation public
import Data.Permutation as P
open import Data.Permutation renaming (delete to deleteP; _∘_ to _∘P_; enum to allInj)
open import Oscar.Data.Vec renaming (delete to deleteV; map to mapV)
open import Relation.Binary.PropositionalEquality
open import Data.Product
open import Data.Fin renaming (inject to injectF)
open ≡-Reasoning
open import Data.Permutation.Properties
open import Oscar.Data.Vec.Properties
open import Function
open import Data.Sum
open import Agda.Builtin.Nat
<>-inv : ∀ {n} (ps : Permutation n) i → i ≡ < ps > (< ps ⁻¹ > i)
<>-inv ps i =
trans
(sym (id-is-id i))
(subst (< P.id > _ ≡_)
(inj-correct (ps ⁻¹) ps i)
(cong (flip <_> _)
(sym (inv-left ps))))
_⋟_÷_ : ∀ {a m n} {A : Set a} → Vec A n → Vec A m → Inj m n → Set a
x ⋟ px ÷ p = ∀ i → lookup i px ≡ lookup (< p > i) x
lookup-ext : ∀ {a n} {A : Set a} {pv₁ pv₂ : Vec A n} → (∀ i → lookup i pv₁ ≡ lookup i pv₂) → pv₁ ≡ pv₂
lookup-ext {pv₁ = []} {[]} x = refl
lookup-ext {pv₁ = x₁ ∷ pv₁} {x₂ ∷ pv₂} x with lookup-ext {pv₁ = pv₁} {pv₂} (x ∘ suc) | x zero
… | refl | refl = refl
injected-inj : ∀ {a n m} {A : Set a} {v : Vec A m} {pv₁ pv₂ : Vec A n} {p : Inj n m} → v ⋟ pv₁ ÷ p → v ⋟ pv₂ ÷ p → pv₁ ≡ pv₂
injected-inj {pv₁ = pv₁} {pv₂} v⋟pv₁÷p v⋟pv₂÷p = lookup-ext foo where
foo : (i : Fin _) → lookup i pv₁ ≡ lookup i pv₂
foo i = trans (v⋟pv₁÷p i) (sym (v⋟pv₂÷p i))
permuted-inj : ∀ {a n} {A : Set a} {v : Vec A n} {pv₁ pv₂ : Vec A n} {p : Permutation n} → v ⋟ pv₁ ÷ p → v ⋟ pv₂ ÷ p → pv₁ ≡ pv₂
permuted-inj {pv₁ = pv₁} {pv₂} v⋟pv₁÷p v⋟pv₂÷p = lookup-ext foo where
foo : (i : Fin _) → lookup i pv₁ ≡ lookup i pv₂
foo i = trans (v⋟pv₁÷p i) (sym (v⋟pv₂÷p i))
permutedLookup : ∀ {a n} {A : Set a} → Permutation n → Vec A n → Fin n → A
permutedLookup p v = flip lookup v ∘ < p >
inject : ∀ {a n m} {A : Set a} → (p : Inj n m) → (v : Vec A m) → Vec A n
inject p v = tabulate (flip lookup v ∘ < p >)
permute : ∀ {a n} {A : Set a} → (p : Permutation n) → (v : Vec A n) → Vec A n
permute p v = tabulate (flip lookup v ∘ < p >)
inject-correct : ∀ {a n m} {A : Set a} → (p : Inj n m) → (v : Vec A m) →
v ⋟ inject p v ÷ p
inject-correct p v = lookup∘tabulate (flip lookup v ∘ < p >)
permute-correct : ∀ {a n} {A : Set a} → (p : Permutation n) → (v : Vec A n) →
v ⋟ permute p v ÷ p
permute-correct p v = lookup∘tabulate (flip lookup v ∘ < p >)
Permute : ∀ {a n} {A : Set a} → (p : Permutation n) → (v : Vec A n) →
∃ (v ⋟_÷ p)
Permute p v = permute p v , permute-correct p v
_⋟_÷? : ∀ {a m n} {A : Set a} → Vec A n → Vec A m → Set a
_⋟_÷? x px = ∃ (x ⋟ px ÷_)
∈-allInj : ∀ {n m} (i : Inj n m) → i ∈ allInj n m
∈-allInj {zero} [] = here
∈-allInj {suc n} (i ∷ is) = ∈-map₂ _∷_ (∈-allFin i) (∈-allInj is)
tabulate₂ : ∀ {n m a} {A : Set a} → (Inj n m → A) → Vec A (size n m)
tabulate₂ f = mapV f (allInj _ _)
∈-tabulate₂ : ∀ {n m a} {A : Set a} (f : Inj n m → A) i → f i ∈ tabulate₂ f
∈-tabulate₂ f i = ∈-map f (∈-allInj i)
ENUM₂ : ∀ {a n} {A : Set a} → (v : Vec A n) → Vec (∃ (v ⋟_÷?)) (size n n)
ENUM₂ v = tabulate₂ (λ p → permute p v , p , permute-correct p v)
enumᵢ : ∀ {a n m} {A : Set a} → Vec A m → Vec (Vec A n) (size n m)
enumᵢ v = tabulate₂ (flip inject v)
enum₂ : ∀ {a n} {A : Set a} → Vec A n → Vec (Vec A n) (size n n)
enum₂ v = tabulate₂ (flip permute v)
enumᵢ-sound : ∀ {a} {A : Set a} {n m} (x : Vec A m) (px : Vec A n) → px ∈ enumᵢ x → x ⋟ px ÷?
enumᵢ-sound x _ px∈enum₂x with map-∈ px∈enum₂x
enumᵢ-sound x _ _ | p , refl = p , inject-correct p x
enum₂-sound : ∀ {a} {A : Set a} {n} (x px : Vec A n) → px ∈ enum₂ x → x ⋟ px ÷?
enum₂-sound x _ px∈enum₂x with map-∈ px∈enum₂x
enum₂-sound x _ _ | p , refl = p , permute-correct p x
remove-÷-zero : ∀ {n a} {A : Set a} {x : A} {xs : Vec A n} {px : A}
{pxs : Vec A n} {ps : Inj n n} →
(x ∷ xs) ⋟ px ∷ pxs ÷ (zero ∷ ps) →
xs ⋟ pxs ÷ ps
remove-÷-zero f i = f (suc i)
enumᵢ-complete : ∀ {a} {A : Set a} {n m} (x : Vec A m) (px : Vec A n) → x ⋟ px ÷? → px ∈ enumᵢ x
enumᵢ-complete x px (p , x⋟px÷p) = proof where
p∈allInj : p ∈ allInj _ _
p∈allInj = ∈-allInj p
permutepx∈enum₂x : inject p x ∈ enumᵢ x
permutepx∈enum₂x = ∈-map (flip inject x) p∈allInj
x⋟permutepx÷p : x ⋟ inject p x ÷ p
x⋟permutepx÷p = inject-correct p x
proof : px ∈ enumᵢ x
proof = subst (_∈ _) (injected-inj {p = p} x⋟permutepx÷p x⋟px÷p) permutepx∈enum₂x
enum₂-complete : ∀ {a} {A : Set a} {n} (x px : Vec A n) → x ⋟ px ÷? → px ∈ enum₂ x
enum₂-complete x px (p , x⋟px÷p) = proof where
p∈allInj : p ∈ allInj _ _
p∈allInj = ∈-allInj p
permutepx∈enum₂x : permute p x ∈ enum₂ x
permutepx∈enum₂x = ∈-map (flip permute x) p∈allInj
x⋟permutepx÷p : x ⋟ permute p x ÷ p
x⋟permutepx÷p = permute-correct p x
proof : px ∈ enum₂ x
proof = subst (_∈ _) (permuted-inj {p = p} x⋟permutepx÷p x⋟px÷p) permutepx∈enum₂x
Enum₂ : ∀ {a n} {A : Set a} → (x : Vec A n) → Σ[ pxs ∈ Vec (Vec A n) (size n n) ] (∀ px → (px ∈ pxs → x ⋟ px ÷?) × (x ⋟ px ÷? → px ∈ pxs))
Enum₂ x = enum₂ x , (λ px → enum₂-sound x px , enum₂-complete x px)
_∃⊎∀_ : ∀ {a} {A : Set a} {l r} (L : A → Set l) (R : A → Set r) {p} (P : A → Set p) → Set _
(L ∃⊎∀ R) P = (∃ λ x → P x × L x) ⊎ (∀ x → P x → R x)
open import Agda.Primitive
stepDecide∃⊎∀ : ∀ {a} {A : Set a} {l r} {L : A → Set l} {R : A → Set r} → (∀ y → L y ⊎ R y) → ∀ {p} (P : A → Set p) →
∀ {d} (done : Vec A d) {nd} (not-done : Vec A nd) →
(∀ y → y ∈ done ⊎ y ∈ not-done → P y) →
(∀ y → P y → y ∈ done ⊎ y ∈ not-done) →
(∀ y → y ∈ done → R y) →
(L ∃⊎∀ R) P
stepDecide∃⊎∀ dec P done {zero} not-done dnd-sound dnd-complete done-R = inj₂ (λ y Py → done-R y (dnd-done y Py)) where
dnd-done : ∀ y → P y → y ∈ done
dnd-done y Py with dnd-complete y Py
dnd-done y Py | inj₁ y∈done = y∈done
dnd-done y Py | inj₂ ()
stepDecide∃⊎∀ dec P done {suc nd} (step ∷ not-dones) dnd-sound dnd-complete done-R with dec step
… | inj₁ l = inj₁ (step , (dnd-sound step (inj₂ here)) , l)
… | inj₂ r = stepDecide∃⊎∀ dec P (step ∷ done) not-dones stepdnd-sound stepdnd-complete (stepdone-R r) where
stepdnd-sound : ∀ y → y ∈ step ∷ done ⊎ y ∈ not-dones → P y
stepdnd-sound _ (inj₁ here) = dnd-sound step (inj₂ here)
stepdnd-sound y (inj₁ (there y∈done)) = dnd-sound y (inj₁ y∈done)
stepdnd-sound y (inj₂ y∈not-dones) = dnd-sound y (inj₂ (there y∈not-dones))
stepdnd-complete : ∀ y → P y → y ∈ step ∷ done ⊎ y ∈ not-dones
stepdnd-complete y Py with dnd-complete y Py
stepdnd-complete y Py | inj₁ y∈done = inj₁ (there y∈done)
stepdnd-complete y Py | inj₂ here = inj₁ here
stepdnd-complete y Py | inj₂ (there y∈not-dones) = inj₂ y∈not-dones
stepdone-R : _ → ∀ y → y ∈ step ∷ done → _
stepdone-R Rstep _ here = Rstep
stepdone-R Rstep y (there y∈done) = done-R y y∈done
decide∃⊎∀ : ∀ {a} {A : Set a} {l r} {L : A → Set l} {R : A → Set r} → (∀ y → L y ⊎ R y) → ∀ {p} (P : A → Set p) →
∀ {nd} (not-done : Vec A nd) →
(∀ y → y ∈ not-done → P y) →
(∀ y → P y → y ∈ not-done) →
(L ∃⊎∀ R) P
decide∃⊎∀ dec P not-done nd-sound nd-complete = stepDecide∃⊎∀ dec P [] not-done []nd-sound []nd-complete (λ {_ ()}) where
[]nd-sound : ∀ y → y ∈ [] ⊎ y ∈ not-done → P y
[]nd-sound y (inj₁ ())
[]nd-sound y (inj₂ y∈not-done) = nd-sound y y∈not-done
[]nd-complete : ∀ y → P y → y ∈ [] ⊎ y ∈ not-done
[]nd-complete y Py = inj₂ (nd-complete y Py)
decidePermutations : ∀ {a n} {A : Set a} {l r} {L : Vec A n → Set l} {R : Vec A n → Set r} → ∀ x → (∀ y → L y ⊎ R y) →
(L ∃⊎∀ R) (x ⋟_÷?)
decidePermutations x f = decide∃⊎∀ f _ (enum₂ x) (enum₂-sound x) (enum₂-complete x)
decideInjections : ∀ {a n m} {A : Set a} {l r} {L : Vec A n → Set l} {R : Vec A n → Set r} → ∀ (x : Vec A m) → (∀ y → L y ⊎ R y) →
(L ∃⊎∀ R) (x ⋟_÷?)
decideInjections x f = decide∃⊎∀ f _ (enumᵢ x) (enumᵢ-sound x) (enumᵢ-complete x)
-- -- sym-⋟∣ : ∀ {a n} {A : Set a} → (y x : Vec A n) → (p : Permutation n) →
-- -- y ⋟ x ∣ p → x ⋟ y ∣ (p ⁻¹)
-- -- sym-⋟∣ y x ps y⋟x∣p i =
-- -- trans (cong (flip lookup x) {x = i} {y = < ps > (< ps ⁻¹ > i)} (<>-inv ps i)) (sym (y⋟x∣p (< ps ⁻¹ > i)))
-- -- open import Oscar.Data.Vec.Properties
-- -- Permute : ∀ {a n} {A : Set a} → (p : Permutation n) → (v : Vec A n) →
-- -- ∃ λ w → w ⋟ v ∥ p
-- -- Permute [] v = v , λ ()
-- -- Permute p@(p' ∷ ps) v@(v' ∷ vs) =
-- -- let ws , [vs≡ws]ps = Permute ps (deleteV p' v)
-- -- w = lookup p' v ∷ ws
-- -- [v≡w]p : w ⋟ v ∥ p
-- -- [v≡w]p = {!!}
-- -- {-
-- -- [v≡w]p = λ
-- -- { zero → here
-- -- ; (suc f) → there (subst (ws [ f ]=_)
-- -- (lookup-delete-thin p' (< ps > f) v)
-- -- ([vs≡ws]ps f)) }
-- -- -}
-- -- in
-- -- w , [v≡w]p
-- -- -- permute : ∀ {a n} {A : Set a} → Permutation n → Vec A n → Vec A n
-- -- -- permute p v = proj₁ (Permute p v)
-- -- -- permute-correct : ∀ {a n} {A : Set a} → (p : Permutation n) → (v : Vec A n) → v ⋟ permute p v ∥ p
-- -- -- permute-correct p v = proj₂ (Permute p v)
-- -- -- open import Function
-- -- -- --∈-map-proj₁ : mapV proj₁ (mapV (λ p → F p , G p) xs) ≡ mapV F xs
-- -- -- open import Data.Nat
-- -- -- ∈-enum : ∀ {n m} (i : Inj n m) → i ∈ enum n m
-- -- -- ∈-enum {zero} [] = here
-- -- -- ∈-enum {suc n} (i ∷ is) = ∈-map₂ _∷_ (∈-allFin i) (∈-enum is)
-- -- -- open import Data.Permutation.Properties
-- -- -- [thin]=→delete[]= : ∀ {a n} {A : Set a} {i j} {v : Vec A (suc n)} {x} → v [ thin i j ]= x → deleteV i v [ j ]= x
-- -- -- [thin]=→delete[]= {i = zero} {v = x ∷ v} (there x₂) = x₂
-- -- -- [thin]=→delete[]= {n = zero} {i = suc ()} x₁
-- -- -- [thin]=→delete[]= {n = suc n} {i = suc i} {zero} {x ∷ v} here = here
-- -- -- [thin]=→delete[]= {n = suc n} {i = suc i} {suc j} {x ∷ v} (there v[thinij]=?) = there ([thin]=→delete[]= {i = i} v[thinij]=?)
-- -- -- delete≡Permutation : ∀ {a n} {A : Set a} {v₀ : A} {v₊ : Vec A n} {w : Vec A (suc n)} {p : Permutation (suc n)} →
-- -- -- (v₀ ∷ v₊) ⋟ w ∥ p →
-- -- -- v₊ ⋟ deleteV (annihilator p) w ∥ delete (annihilator p) p
-- -- -- delete≡Permutation {v₀ = v₀} {v₊} {w} {p} [v₀∷v₊≡w]p f = [thin]=→delete[]= {i = annihilator p} {j = f} qux where
-- -- -- foo : thin (< p > (annihilator p)) (< delete (annihilator p) p > f) ≡ < p > (thin (annihilator p) f)
-- -- -- foo = inj-thin p (annihilator p) f
-- -- -- foo2 : suc (< delete (annihilator p) p > f) ≡ < p > (thin (annihilator p) f)
-- -- -- foo2 = subst (λ y → thin y (< delete (annihilator p) p > f) ≡ < p > (thin (annihilator p) f)) (ann-correct p) foo
-- -- -- bar : w [ thin (annihilator p) f ]= lookup (< p > (thin (annihilator p) f)) (v₀ ∷ v₊)
-- -- -- bar = [v₀∷v₊≡w]p (thin (annihilator p) f)
-- -- -- qux : w [ thin (annihilator p) f ]= lookup (< delete (annihilator p) p > f) v₊
-- -- -- qux = subst (λ y → w [ thin (annihilator p) f ]= lookup y (v₀ ∷ v₊)) (sym foo2) bar
-- -- -- permute-complete-step : ∀ {a n} {A : Set a} {v₀ : A} {w : Vec A (suc n)} {v₊ : Vec A n} (x : Fin (suc n)) →
-- -- -- w [ x ]= v₀ →
-- -- -- deleteV x w ∈ mapV (flip permute v₊) (enum n n) →
-- -- -- w ∈ mapV (flip permute (v₀ ∷ v₊)) (enum (suc n) (suc n))
-- -- -- permute-complete-step {n = zero} {w = x₃ ∷ []} {[]} zero here here = here
-- -- -- permute-complete-step {n = zero} {w = x₃ ∷ []} {[]} zero x₁ (there ())
-- -- -- permute-complete-step {n = zero} {w = x₃ ∷ []} {[]} (suc ()) x₁ x₂
-- -- -- permute-complete-step {n = suc n} {w = w ∷ ws} x w∷ws[x]=v₀ x₂ = {!!}
-- -- -- permute-lemma : ∀ {a n} {A : Set a} (v w : Vec A n) (p : Permutation n) →
-- -- -- v ⋟ w ∥ p →
-- -- -- w ≡ permute (p ⁻¹) v
-- -- -- permute-lemma v w p x = {!permute-correct p w!}
-- -- -- {-
-- -- -- permute-complete' : ∀ {a n} {A : Set a} (v w : Vec A n) (p : Permutation n) →
-- -- -- v ⋟ w ∥ p →
-- -- -- ∀ {m} {ps : Vec (Permutation n) m} → p ∈ ps →
-- -- -- w ≡ permute p v
-- -- -- w ∈ mapV (flip
-- -- -- -}
-- -- -- permute-complete : ∀ {a n} {A : Set a} (v w : Vec A n) →
-- -- -- v ∃≡Permutation w →
-- -- -- w ∈ mapV (flip permute v) (enum n n)
-- -- -- permute-complete [] [] (p , [v≡w]p) = here
-- -- -- permute-complete {n = suc n} v@(v₀ ∷ v₊) w (p , [v≡w]p) = permute-complete-step (annihilator p) w[ap]=v₀ pc' where
-- -- -- w[ap]=v₀ : w [ annihilator p ]= v₀
-- -- -- w[ap]=v₀ = {![v≡w]p (annihilator p)!}
-- -- -- pc' : deleteV (annihilator p) w ∈ mapV (flip permute v₊) (enum n n)
-- -- -- pc' = permute-complete v₊ (deleteV (annihilator p) w) (delete (annihilator p) p , delete≡Permutation {p = p} [v≡w]p)
-- -- -- EnumPermutations : ∀ {a n} {A : Set a} → (v : Vec A n) →
-- -- -- Σ (Vec (∃ (v ∃≡Permutation_)) (size n n)) λ ws
-- -- -- → ∀ w → (v ∃≡Permutation w → w ∈ mapV proj₁ ws)
-- -- -- EnumPermutations {n = n} v = mapV (λ p → permute p v , p , permute-correct p v) (enum n n) , (λ w v∃≡Pw → subst (w ∈_) (map-∘ proj₁ (λ p → permute p v , p , permute-correct p v) (enum n n)) (permute-complete v w v∃≡Pw))
-- -- -- enumPermutations : ∀ {a n} {A : Set a} → Vec A n → Vec (Vec A n) (size n n)
-- -- -- enumPermutations {n = n} xs = mapV (λ p → permute p xs) (enum n n)
-- -- -- tryPermutations : ∀ {a n} {A : Set a} {l r} {L : Vec A n → Set l} {R : Vec A n → Set r} → ∀ x → (f : ∀ y → L y ⊎ R y) → Vec (∃ λ y → x ∃≡Permutation y × L y ⊎ R y) (size n n)
-- -- -- tryPermutations x f = mapV (λ x₁ → x₁ , {!!}) (enumPermutations x)
|
libsrc/target/newbrain/break_status.asm | jpoikela/z88dk | 640 | 6403 | <reponame>jpoikela/z88dk<filename>libsrc/target/newbrain/break_status.asm
;
; Grundy Newbrain Specific libraries
;
; <NAME> - 30/03/2007
;
;
; Check if user pressed BREAK
; 1 if BREAK, otherwise 0
;
;
;
; $Id: break_status.asm,v 1.4 2016-06-19 20:33:40 dom Exp $
;
SECTION code_clib
PUBLIC break_status
PUBLIC _break_status
.break_status
._break_status
rst 20h
defb 36h
ld hl,1
ret c
dec hl
ret
|
ffmpeg/libavfilter/x86/vf_gblur.asm | GustavoGalo/discord-bot-1 | 0 | 4790 | <gh_stars>0
;*****************************************************************************
;* x86-optimized functions for gblur filter
;*
;* This file is part of FFmpeg.
;*
;* FFmpeg is free software; you can redistribute it and/or
;* modify it under the terms of the GNU Lesser General Public
;* License as published by the Free Software Foundation; either
;* version 2.1 of the License, or (at your option) any later version.
;*
;* FFmpeg is distributed in the hope that it will be useful,
;* but WITHOUT ANY WARRANTY; without even the implied warranty of
;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;* Lesser General Public License for more details.
;*
;* You should have received a copy of the GNU Lesser General Public
;* License along with FFmpeg; if not, write to the Free Software
;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
;******************************************************************************
%include "libavutil/x86/x86util.asm"
SECTION .data
gblur_transpose_16x16_indices1: dq 2, 3, 0, 1, 6, 7, 4, 5
gblur_transpose_16x16_indices2: dq 1, 0, 3, 2, 5, 4, 7, 6
gblur_transpose_16x16_indices3: dd 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14
gblur_transpose_16x16_mask: dw 0xcc, 0x33, 0xaa, 0x55, 0xaaaa, 0x5555
gblur_vindex_width: dd 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
SECTION .text
%xdefine AVX2_MMSIZE 32
%xdefine AVX512_MMSIZE 64
%macro MOVSXDIFNIDN 1-*
%rep %0
movsxdifnidn %1q, %1d
%rotate 1
%endrep
%endmacro
%macro KXNOR 2-*
%if mmsize == AVX512_MMSIZE
kxnorw %2, %2, %2
%else
%if %0 == 3
mov %3, -1
%else
vpcmpeqd %1, %1, %1
%endif
%endif
%endmacro
%macro KMOVW 2-4
%if mmsize == AVX2_MMSIZE && %0 == 4
mova %1, %2
%elif mmsize == AVX512_MMSIZE
%if %0 == 4
%rotate 2
%endif
kmovw %1, %2
%endif
%endmacro
%macro PUSH_MASK 5
%if mmsize == AVX2_MMSIZE
%assign %%n mmsize/4
%assign %%i 0
%rep %%n
mov %4, %3
and %4, 1
neg %4
mov dword [%5 + %%i*4], %4
sar %3, 1
%assign %%i %%i+1
%endrep
movu %1, [%5]
%else
kmovd %2, %3
%endif
%endmacro
%macro VMASKMOVPS 4
%if mmsize == AVX2_MMSIZE
vpmaskmovd %1, %3, %2
%else
kmovw k7, %4
vmovups %1{k7}, %2
%endif
%endmacro
%macro VGATHERDPS 4
%if mmsize == AVX2_MMSIZE
vgatherdps %1, %2, %3
%else
vgatherdps %1{%4}, %2
%endif
%endmacro
%macro VSCATTERDPS128 7
%rep 4
mov %7, %6
and %7, 1
cmp %7, 0
je %%end_scatter
movss [%2 + %3*%4], xm%1
vpshufd m%1, m%1, 0x39
add %3, %5
sar %6, 1
%endrep
%%end_scatter:
%endmacro
; %1=register index
; %2=base address %3=vindex
; %4=scale %5=width
; %6=mask %7=tmp
; m15=reserved
%macro VSCATTERDPS256 7
mova m15, m%1
xor %3, %3
VSCATTERDPS128 15, %2, %3, %4, %5, %6, %7
vextractf128 xm15, m%1, 1
VSCATTERDPS128 15, %2, %3, %4, %5, %6, %7
%endmacro
; %1=base address %2=avx2 vindex
; %3=avx512 vindex %4=avx2 mask
; %5=avx512 mask %6=register index
; %7=width %8-*=tmp
%macro VSCATTERDPS 8-*
%if mmsize == AVX2_MMSIZE
%if %0 == 9
mov %9, %4
VSCATTERDPS256 %6, %1, %2, 4, %7, %9, %8
%else
VSCATTERDPS256 %6, %1, %2, 4, %7, %4, %8
%endif
%else
vscatterdps [%1 + %3*4]{%5}, m%6
%endif
%endmacro
%macro INIT_WORD_MASK 1-*
%assign %%i 0
%rep %0
kmovw %1, [gblur_transpose_16x16_mask + %%i * 2]
%assign %%i %%i+1
%rotate 1
%endrep
%endmacro
%macro INIT_INDICES 1-*
%assign %%i 1
%rep %0
movu %1, [gblur_transpose_16x16_indices %+ %%i]
%assign %%i %%i+1
%rotate 1
%endrep
%endmacro
%assign stack_offset 0
%macro PUSH_MM 1
%if mmsize == AVX2_MMSIZE
movu [rsp + stack_offset], %1
%assign stack_offset stack_offset+mmsize
%endif
%endmacro
%macro POP_MM 1
%if mmsize == AVX2_MMSIZE
%assign stack_offset stack_offset-mmsize
movu %1, [rsp + stack_offset]
%endif
%endmacro
%macro READ_LOCAL_BUFFER 1
%if mmsize == AVX512_MMSIZE
%assign %%i 19
%else
%assign %%i 9
%endif
%assign %%j %%i-1
%assign %%k %1-1
%xdefine %%m m %+ %%i
mova %%m, m3
FMULADD_PS %%m, %%m, m0, [localbufq + %%k * mmsize], %%m
%assign %%k %%k-1
%rep %1-1
%xdefine %%m m %+ %%j
mova %%m, m %+ %%i
FMULADD_PS %%m, %%m, m0, [localbufq + %%k * mmsize], %%m
%assign %%i %%i-1
%assign %%j %%j-1
%assign %%k %%k-1
%endrep
%if mmsize == AVX512_MMSIZE
mova m3, m %+ %%i
%endif
%endmacro
%macro FMADD_WRITE 4
FMULADD_PS %1, %1, %2, %3, %1
mova %4, %1
%endmacro
%macro WRITE_LOCAL_BUFFER_INTERNAL 8-16
%assign %%i 0
%rep %0
FMADD_WRITE m3, m0, m %+ %1, [localbufq + %%i * mmsize]
%assign %%i %%i+1
%rotate 1
%endrep
%endmacro
%macro GATHERPS 1
%if mmsize == AVX512_MMSIZE
%assign %%i 4
%else
%assign %%i 2
%endif
movu m %+ %%i, [ptrq]
mov strideq, widthq
%assign %%i %%i+1
%rep %1-2
movu m %+ %%i, [ptrq + strideq*4]
add strideq, widthq
%assign %%i %%i+1
%endrep
movu m %+ %%i, [ptrq + strideq*4]
%endmacro
%macro SCATTERPS_INTERNAL 8-16
movu [ptrq + strideq*0], m %+ %1
mov strideq, widthq
%rotate 1
%rep %0-2
movu [ptrq + strideq*4], m %+ %1
add strideq, widthq
%rotate 1
%endrep
movu [ptrq + strideq*4], m %+ %1
%endmacro
%macro BATCH_INSERT64X4 4-*
%assign %%imm8 %1
%rotate 1
%rep (%0-1)/3
vinserti64x4 m%1, m%2, ym%3, %%imm8
%rotate 3
%endrep
%endmacro
%macro BATCH_EXTRACT_INSERT 2-*
%assign %%imm8 %1
%rotate 1
%rep (%0-1)/2
vextractf64x4 ym%1, m%1, %%imm8
vextractf64x4 ym%2, m%2, %%imm8
vinserti64x4 m%1, m%1, ym%2, %%imm8
%rotate 2
%endrep
%endmacro
%macro BATCH_MOVE 2-*
%rep %0/2
mova m%1, m%2
%rotate 2
%endrep
%endmacro
%macro BATCH_PERMUTE 3-*
%xdefine %%decorator %1
%xdefine %%mask %2
%assign %%index %3
%rotate 3
%rep (%0-3)/2
vperm %+ %%decorator m%1{%%mask}, m %+ %%index, m%2
%rotate 2
%endrep
%endmacro
; input : m3-m19
; output: m8 m5 m9 m15 m16 m7 m17 m27 m24 m21 m25 m19 m12 m23 m13 m11
%macro TRANSPOSE_16X16_AVX512 0
BATCH_INSERT64X4 0x1, 20,4,12, 21,5,13, 22,6,14, 23,7,15
BATCH_INSERT64X4 0x1, 24,8,16, 25,9,17, 26,10,18, 27,11,19
BATCH_EXTRACT_INSERT 0x1, 4,12, 5,13, 6,14, 7,15
BATCH_EXTRACT_INSERT 0x1, 8,16, 9,17, 10,18, 11,19
BATCH_MOVE 12,20, 13,21, 14,22, 15,23
BATCH_PERMUTE q, k6, 28, 12,24, 13,25, 14,26, 15,27
BATCH_PERMUTE q, k5, 28, 24,20, 25,21, 26,22, 27,23
BATCH_MOVE 16,4, 17,5, 18,6, 19,7
BATCH_PERMUTE q, k6, 28, 16,8, 17,9, 18,10, 19,11
BATCH_PERMUTE q, k5, 28, 8,4, 9,5, 10,6, 11,7
BATCH_MOVE 4,12, 5,13, 6,24, 7,25
BATCH_MOVE 20,16, 21,17, 22,8, 23,9
BATCH_PERMUTE q, k4, 29, 4,14, 5,15, 6,26, 7,27
BATCH_PERMUTE q, k3, 29, 14,12, 15,13, 26,24, 27,25
BATCH_PERMUTE q, k4, 29, 20,18, 21,19, 22,10, 23,11
BATCH_PERMUTE q, k3, 29, 18,16, 19,17, 10,8, 11,9
BATCH_MOVE 8,4, 9,14, 16,6, 17,26
BATCH_MOVE 24,20, 25,18, 12,22, 13,10
BATCH_PERMUTE d, k2, 30, 8,5, 9,15, 16,7, 17,27
BATCH_PERMUTE d, k1, 30, 5,4, 15,14, 7,6, 27,26
BATCH_PERMUTE d, k2, 30, 24,21, 25,19, 12,23, 13,11
BATCH_PERMUTE d, k1, 30, 21,20, 19,18, 23,22, 11,10
%endmacro
%macro INSERT_UNPACK 8
vinsertf128 m%5, m%1, xm%3, 0x1
vinsertf128 m%6, m%2, xm%4, 0x1
vunpcklpd m%7, m%5, m%6
vunpckhpd m%8, m%5, m%6
%endmacro
%macro SHUFFLE 4
vshufps m%3, m%1, m%2, 0x88
vshufps m%4, m%1, m%2, 0xDD
mova m%1, m%3
mova m%2, m%4
%endmacro
%macro EXTRACT_INSERT_UNPACK 6
vextractf128 xm%1, m%1, 0x1
vextractf128 xm%2, m%2, 0x1
vinsertf128 m%3, m%3, xm%1, 0x0
vinsertf128 m%4, m%4, xm%2, 0x0
vunpcklpd m%5, m%3, m%4
vunpckhpd m%6, m%3, m%4
%endmacro
; Transpose 8x8 AVX2
; Limit the number ym# register to 16 for compatibility
; Used up registers instead of using stack memory
; Input: m2-m9
; Output: m12, m14, m13, m15, m8, m10, m9, m11
%macro TRANSPOSE_8X8_AVX2 0
INSERT_UNPACK 2, 3, 6, 7, 10, 11, 12, 13
INSERT_UNPACK 4, 5, 8, 9, 10, 11, 14, 15
SHUFFLE 12, 14, 10, 11
SHUFFLE 13, 15, 10, 11
EXTRACT_INSERT_UNPACK 4, 5, 8, 9, 10, 11
EXTRACT_INSERT_UNPACK 2, 3, 6, 7, 8, 9
SHUFFLE 8, 10, 6, 7
SHUFFLE 9, 11, 6, 7
%endmacro
%macro TRANSPOSE 0
%if cpuflag(avx512)
TRANSPOSE_16X16_AVX512
%elif cpuflag(avx2)
TRANSPOSE_8X8_AVX2
%endif
%endmacro
%macro WRITE_LOCAL_BUFFER 0
%if cpuflag(avx512)
WRITE_LOCAL_BUFFER_INTERNAL 8, 5, 9, 15, 16, 7, 17, 27, \
24, 21, 25, 19, 12, 23, 13, 11
%elif cpuflag(avx2)
WRITE_LOCAL_BUFFER_INTERNAL 12, 14, 13, 15, 8, 10, 9, 11
%endif
%endmacro
%macro SCATTERPS 0
%if cpuflag(avx512)
SCATTERPS_INTERNAL 8, 5, 9, 15, 16, 7, 17, 27, \
24, 21, 25, 19, 12, 23, 13, 11
%elif cpuflag(avx2)
SCATTERPS_INTERNAL 12, 14, 13, 15, 8, 10, 9, 11
%endif
%endmacro
%macro OPTIMIZED_LOOP_STEP 0
lea stepd, [stepsd - 1]
cmp stepd, 0
jle %%bscale_scalar
%%loop_step:
sub localbufq, mmsize
mulps m3, m1
movu [localbufq], m3
; Filter leftwards
lea xq, [widthq - 1]
%%loop_step_x_back:
sub localbufq, mmsize
FMULADD_PS m3, m3, m0, [localbufq], m3
movu [localbufq], m3
dec xq
cmp xq, 0
jg %%loop_step_x_back
; Filter rightwards
mulps m3, m1
movu [localbufq], m3
add localbufq, mmsize
lea xq, [widthq - 1]
%%loop_step_x:
FMULADD_PS m3, m3, m0, [localbufq], m3
movu [localbufq], m3
add localbufq, mmsize
dec xq
cmp xq, 0
jg %%loop_step_x
dec stepd
cmp stepd, 0
jg %%loop_step
%%bscale_scalar:
%endmacro
;***************************************************************************
; void ff_horiz_slice(float *ptr, int width, int height, int steps,
; float nu, float bscale)
;***************************************************************************
%macro HORIZ_SLICE 0
%if UNIX64
%if cpuflag(avx512) || cpuflag(avx2)
cglobal horiz_slice, 5, 12, mmnum, 0-mmsize*4, buffer, width, height, steps, \
localbuf, x, y, step, stride, remain, ptr, mask
%else
cglobal horiz_slice, 4, 9, 9, ptr, width, height, steps, x, y, step, stride, remain
%endif
%else
%if cpuflag(avx512) || cpuflag(avx2)
cglobal horiz_slice, 5, 12, mmnum, 0-mmsize*4, buffer, width, height, steps, nu, bscale, \
localbuf, x, y, step, stride, remain, ptr, mask
%else
cglobal horiz_slice, 4, 9, 9, ptr, width, height, steps, nu, bscale, x, y, step, stride, remain
%endif
%endif
%if cpuflag(avx512) || cpuflag(avx2)
%assign rows mmsize/4
%assign cols mmsize/4
%if WIN64
VBROADCASTSS m0, num ; nu
VBROADCASTSS m1, bscalem ; bscale
mov nuq, localbufm
DEFINE_ARGS buffer, width, height, steps, \
localbuf, x, y, step, stride, remain, ptr, mask
%else
VBROADCASTSS m0, xmm0 ; nu
VBROADCASTSS m1, xmm1 ; bscale
%endif
MOVSXDIFNIDN width, height, steps
%if cpuflag(avx512)
vpbroadcastd m2, widthd
INIT_WORD_MASK k6, k5, k4, k3, k2, k1
INIT_INDICES m28, m29, m30
%else
movd xm2, widthd
VBROADCASTSS m2, xm2
%endif
vpmulld m2, m2, [gblur_vindex_width] ; vindex width
xor yq, yq ; y = 0
xor xq, xq ; x = 0
cmp heightq, rows
jl .y_scalar
sub heightq, rows
.loop_y:
; ptr = buffer + y * width;
mov ptrq, yq
imul ptrq, widthq
lea ptrq, [bufferq + ptrq*4]
KXNOR m5, k7
VGATHERDPS m3, [ptrq + m2*4], m5, k7
mulps m3, m1
movu [localbufq], m3
add ptrq, 4
add localbufq, mmsize
; Filter rightwards
PUSH_MM m2
lea xq, [widthq - 1]
.loop_x:
PUSH_MM m3
GATHERPS cols
TRANSPOSE
POP_MM m3
WRITE_LOCAL_BUFFER
add ptrq, mmsize
add localbufq, rows * mmsize
sub xq, cols
cmp xq, cols
jge .loop_x
POP_MM m2
cmp xq, 0
jle .bscale_scalar
.loop_x_scalar:
KXNOR m5, k7
VGATHERDPS m4, [ptrq + m2*4], m5, k7
FMULADD_PS m3, m3, m0, m4, m3
movu [localbufq], m3
add ptrq, 0x4
add localbufq, mmsize
dec xq
cmp xq, 0
jg .loop_x_scalar
.bscale_scalar:
OPTIMIZED_LOOP_STEP
sub ptrq, 4
sub localbufq, mmsize
mulps m3, m1
KXNOR m5, k7, maskq
VSCATTERDPS ptrq, strideq, m2, maskq, k7, 3, widthq, remainq
; Filter leftwards
PUSH_MM m2
lea xq, [widthq - 1]
.loop_x_back:
sub localbufq, rows * mmsize
READ_LOCAL_BUFFER cols
PUSH_MM m2
TRANSPOSE
POP_MM m3
sub ptrq, mmsize
SCATTERPS
sub xq, cols
cmp xq, cols
jge .loop_x_back
POP_MM m2
cmp xq, 0
jle .end_loop_x
.loop_x_back_scalar:
sub ptrq, 0x4
sub localbufq, mmsize
FMULADD_PS m3, m3, m0, [localbufq], m3
KXNOR m5, k7, maskq
VSCATTERDPS ptrq, strideq, m2, maskq, k7, 3, widthq, remainq
dec xq
cmp xq, 0
jg .loop_x_back_scalar
.end_loop_x:
add yq, rows
cmp yq, heightq
jle .loop_y
add heightq, rows
cmp yq, heightq
jge .end_scalar
mov remainq, widthq
imul remainq, mmsize
add ptrq, remainq
.y_scalar:
mov remainq, heightq
sub remainq, yq
mov maskq, 1
shlx maskq, maskq, remainq
sub maskq, 1
mov remainq, maskq
PUSH_MASK m5, k1, remaind, xd, rsp + 0x20
mov ptrq, yq
imul ptrq, widthq
lea ptrq, [bufferq + ptrq * 4] ; ptrq = buffer + y * width
KMOVW m6, m5, k7, k1
VGATHERDPS m3, [ptrq + m2 * 4], m6, k7
mulps m3, m1 ; p0 *= bscale
movu [localbufq], m3
add localbufq, mmsize
; Filter rightwards
lea xq, [widthq - 1]
.y_scalar_loop_x:
add ptrq, 4
KMOVW m6, m5, k7, k1
VGATHERDPS m4, [ptrq + m2 * 4], m6, k7
FMULADD_PS m3, m3, m0, m4, m3
movu [localbufq], m3
add localbufq, mmsize
dec xq
cmp xq, 0
jg .y_scalar_loop_x
OPTIMIZED_LOOP_STEP
sub localbufq, mmsize
mulps m3, m1 ; p0 *= bscale
KMOVW k7, k1
VSCATTERDPS ptrq, strideq, m2, maskq, k7, 3, widthq, remainq, heightq
; Filter leftwards
lea xq, [widthq - 1]
.y_scalar_loop_x_back:
sub ptrq, 4
sub localbufq, mmsize
FMULADD_PS m3, m3, m0, [localbufq], m3
KMOVW k7, k1
VSCATTERDPS ptrq, strideq, m2, maskq, k7, 3, widthq, remainq, heightq
dec xq
cmp xq, 0
jg .y_scalar_loop_x_back
.end_scalar:
RET
%else
%if WIN64
movss m0, num
movss m1, bscalem
DEFINE_ARGS ptr, width, height, steps, x, y, step, stride, remain
%endif
movsxdifnidn widthq, widthd
mulss m2, m0, m0 ; nu ^ 2
mulss m3, m2, m0 ; nu ^ 3
mulss m4, m3, m0 ; nu ^ 4
xor xq, xq
xor yd, yd
mov strideq, widthq
; stride = width * 4
shl strideq, 2
; w = w - ((w - 1) & 3)
mov remainq, widthq
sub remainq, 1
and remainq, 3
sub widthq, remainq
shufps m0, m0, 0
shufps m2, m2, 0
shufps m3, m3, 0
shufps m4, m4, 0
.loop_y:
xor stepd, stepd
.loop_step:
; p0 *= bscale
mulss m5, m1, [ptrq + xq * 4]
movss [ptrq + xq * 4], m5
inc xq
; filter rightwards
; Here we are vectorizing the c version by 4
; for (x = 1; x < width; x++)
; ptr[x] += nu * ptr[x - 1];
; let p0 stands for ptr[x-1], the data from last loop
; and [p1,p2,p3,p4] be the vector data for this loop.
; Unrolling the loop, we get:
; p1' = p1 + p0*nu
; p2' = p2 + p1*nu + p0*nu^2
; p3' = p3 + p2*nu + p1*nu^2 + p0*nu^3
; p4' = p4 + p3*nu + p2*nu^2 + p1*nu^3 + p0*nu^4
; so we can do it in simd:
; [p1',p2',p3',p4'] = [p1,p2,p3,p4] + [p0,p1,p2,p3]*nu +
; [0,p0,p1,p2]*nu^2 + [0,0,p0,p1]*nu^3 +
; [0,0,0,p0]*nu^4
.loop_x:
movu m6, [ptrq + xq * 4] ; s = [p1,p2,p3,p4]
pslldq m7, m6, 4 ; [0, p1,p2,p3]
movss m7, m5 ; [p0,p1,p2,p3]
FMULADD_PS m6, m7, m0, m6, m8 ; s += [p0,p1,p2,p3] * nu
pslldq m7, 4 ; [0,p0,p1,p2]
FMULADD_PS m6, m7, m2, m6, m8 ; s += [0,p0,p1,p2] * nu^2
pslldq m7, 4
FMULADD_PS m6, m7, m3, m6, m8 ; s += [0,0,p0,p1] * nu^3
pslldq m7, 4
FMULADD_PS m6, m7, m4, m6, m8 ; s += [0,0,0,p0] * nu^4
movu [ptrq + xq * 4], m6
shufps m5, m6, m6, q3333
add xq, 4
cmp xq, widthq
jl .loop_x
add widthq, remainq
cmp xq, widthq
jge .end_scalar
.loop_scalar:
; ptr[x] += nu * ptr[x-1]
movss m5, [ptrq + 4*xq - 4]
mulss m5, m0
addss m5, [ptrq + 4*xq]
movss [ptrq + 4*xq], m5
inc xq
cmp xq, widthq
jl .loop_scalar
.end_scalar:
; ptr[width - 1] *= bscale
dec xq
mulss m5, m1, [ptrq + 4*xq]
movss [ptrq + 4*xq], m5
shufps m5, m5, 0
; filter leftwards
; for (; x > 0; x--)
; ptr[x - 1] += nu * ptr[x];
; The idea here is basically the same as filter rightwards.
; But we need to take care as the data layout is different.
; Let p0 stands for the ptr[x], which is the data from last loop.
; The way we do it in simd as below:
; [p-4', p-3', p-2', p-1'] = [p-4, p-3, p-2, p-1]
; + [p-3, p-2, p-1, p0] * nu
; + [p-2, p-1, p0, 0] * nu^2
; + [p-1, p0, 0, 0] * nu^3
; + [p0, 0, 0, 0] * nu^4
.loop_x_back:
sub xq, 4
movu m6, [ptrq + xq * 4] ; s = [p-4, p-3, p-2, p-1]
psrldq m7, m6, 4 ; [p-3, p-2, p-1, 0 ]
blendps m7, m5, 0x8 ; [p-3, p-2, p-1, p0 ]
FMULADD_PS m6, m7, m0, m6, m8 ; s+= [p-3, p-2, p-1, p0 ] * nu
psrldq m7, 4 ;
FMULADD_PS m6, m7, m2, m6, m8 ; s+= [p-2, p-1, p0, 0] * nu^2
psrldq m7, 4
FMULADD_PS m6, m7, m3, m6, m8 ; s+= [p-1, p0, 0, 0] * nu^3
psrldq m7, 4
FMULADD_PS m6, m7, m4, m6, m8 ; s+= [p0, 0, 0, 0] * nu^4
movu [ptrq + xq * 4], m6
shufps m5, m6, m6, 0 ; m5 = [p-4', p-4', p-4', p-4']
cmp xq, remainq
jg .loop_x_back
cmp xq, 0
jle .end_scalar_back
.loop_scalar_back:
; ptr[x-1] += nu * ptr[x]
movss m5, [ptrq + 4*xq]
mulss m5, m0
addss m5, [ptrq + 4*xq - 4]
movss [ptrq + 4*xq - 4], m5
dec xq
cmp xq, 0
jg .loop_scalar_back
.end_scalar_back:
; reset aligned width for next line
sub widthq, remainq
inc stepd
cmp stepd, stepsd
jl .loop_step
add ptrq, strideq
inc yd
cmp yd, heightd
jl .loop_y
RET
%endif
%endmacro
%if ARCH_X86_64
INIT_XMM sse4
HORIZ_SLICE
%if HAVE_AVX2_EXTERNAL
INIT_YMM avx2
%xdefine mmnum 16
HORIZ_SLICE
%endif
%if HAVE_AVX512_EXTERNAL
INIT_ZMM avx512
%xdefine mmnum 32
HORIZ_SLICE
%endif
%endif
%macro POSTSCALE_SLICE 0
cglobal postscale_slice, 2, 2, 4, ptr, length, postscale, min, max
shl lengthd, 2
add ptrq, lengthq
neg lengthq
%if ARCH_X86_32
VBROADCASTSS m0, postscalem
VBROADCASTSS m1, minm
VBROADCASTSS m2, maxm
%elif WIN64
VBROADCASTSS m0, xmm2
VBROADCASTSS m1, xmm3
VBROADCASTSS m2, maxm
%else ; UNIX
VBROADCASTSS m0, xmm0
VBROADCASTSS m1, xmm1
VBROADCASTSS m2, xmm2
%endif
.loop:
%if cpuflag(avx2) || cpuflag(avx512)
mulps m3, m0, [ptrq + lengthq]
%else
movu m3, [ptrq + lengthq]
mulps m3, m0
%endif
maxps m3, m1
minps m3, m2
movu [ptrq+lengthq], m3
add lengthq, mmsize
jl .loop
RET
%endmacro
INIT_XMM sse
POSTSCALE_SLICE
%if HAVE_AVX2_EXTERNAL
INIT_YMM avx2
POSTSCALE_SLICE
%endif
%if HAVE_AVX512_EXTERNAL
INIT_ZMM avx512
POSTSCALE_SLICE
%endif
;*******************************************************************************
; void ff_verti_slice(float *buffer, int width, int height, int column_begin,
; int column_end, int steps, float nu, float bscale);
;*******************************************************************************
%macro VERTI_SLICE 0
%if UNIX64
cglobal verti_slice, 6, 12, 9, 0-mmsize*2, buffer, width, height, cbegin, cend, \
steps, x, y, cwidth, step, ptr, stride
%else
cglobal verti_slice, 6, 12, 9, 0-mmsize*2, buffer, width, height, cbegin, cend, \
steps, nu, bscale, x, y, cwidth, step, \
ptr, stride
%endif
%assign cols mmsize/4
%if WIN64
VBROADCASTSS m0, num
VBROADCASTSS m1, bscalem
DEFINE_ARGS buffer, width, height, cbegin, cend, \
steps, x, y, cwidth, step, ptr, stride
%else
VBROADCASTSS m0, xmm0 ; nu
VBROADCASTSS m1, xmm1 ; bscale
%endif
MOVSXDIFNIDN width, height, cbegin, cend, steps
mov cwidthq, cendq
sub cwidthq, cbeginq
lea strideq, [widthq * 4]
xor xq, xq ; x = 0
cmp cwidthq, cols
jl .x_scalar
cmp cwidthq, 0x0
je .end_scalar
sub cwidthq, cols
.loop_x:
xor stepq, stepq
.loop_step:
; ptr = buffer + x + column_begin;
lea ptrq, [xq + cbeginq]
lea ptrq, [bufferq + ptrq*4]
; ptr[15:0] *= bcale;
movu m2, [ptrq]
mulps m2, m1
movu [ptrq], m2
; Filter downwards
mov yq, 1
.loop_y_down:
add ptrq, strideq ; ptrq += width
movu m3, [ptrq]
FMULADD_PS m2, m2, m0, m3, m2
movu [ptrq], m2
inc yq
cmp yq, heightq
jl .loop_y_down
mulps m2, m1
movu [ptrq], m2
; Filter upwards
dec yq
.loop_y_up:
sub ptrq, strideq
movu m3, [ptrq]
FMULADD_PS m2, m2, m0, m3, m2
movu [ptrq], m2
dec yq
cmp yq, 0
jg .loop_y_up
inc stepq
cmp stepq, stepsq
jl .loop_step
add xq, cols
cmp xq, cwidthq
jle .loop_x
add cwidthq, cols
cmp xq, cwidthq
jge .end_scalar
.x_scalar:
xor stepq, stepq
mov qword [rsp + 0x10], xq
sub cwidthq, xq
mov xq, 1
shlx cwidthq, xq, cwidthq
sub cwidthq, 1
PUSH_MASK m4, k1, cwidthd, xd, rsp + 0x20
mov xq, qword [rsp + 0x10]
.loop_step_scalar:
lea ptrq, [xq + cbeginq]
lea ptrq, [bufferq + ptrq*4]
VMASKMOVPS m2, [ptrq], m4, k1
mulps m2, m1
VMASKMOVPS [ptrq], m2, m4, k1
; Filter downwards
mov yq, 1
.x_scalar_loop_y_down:
add ptrq, strideq
VMASKMOVPS m3, [ptrq], m4, k1
FMULADD_PS m2, m2, m0, m3, m2
VMASKMOVPS [ptrq], m2, m4, k1
inc yq
cmp yq, heightq
jl .x_scalar_loop_y_down
mulps m2, m1
VMASKMOVPS [ptrq], m2, m4, k1
; Filter upwards
dec yq
.x_scalar_loop_y_up:
sub ptrq, strideq
VMASKMOVPS m3, [ptrq], m4, k1
FMULADD_PS m2, m2, m0, m3, m2
VMASKMOVPS [ptrq], m2, m4, k1
dec yq
cmp yq, 0
jg .x_scalar_loop_y_up
inc stepq
cmp stepq, stepsq
jl .loop_step_scalar
.end_scalar:
RET
%endmacro
%if ARCH_X86_64
%if HAVE_AVX2_EXTERNAL
INIT_YMM avx2
VERTI_SLICE
%endif
%if HAVE_AVX512_EXTERNAL
INIT_ZMM avx512
VERTI_SLICE
%endif
%endif
|
oeis/045/A045355.asm | neoneye/loda-programs | 11 | 440 | ; A045355: Primes congruent to {2, 5, 7} mod 8.
; Submitted by <NAME>
; 2,5,7,13,23,29,31,37,47,53,61,71,79,101,103,109,127,149,151,157,167,173,181,191,197,199,223,229,239,263,269,271,277,293,311,317,349,359,367,373,383,389,397,421,431,439,461,463,479,487,503,509,541,557,599,607,613,631,647,653,661,677,701,709,719,727,733,743,751,757,773,797,821,823,829,839,853,863,877,887,911,919,941,967,983,991,997,1013,1021,1031,1039,1061,1063,1069,1087,1093,1103,1109,1117,1151
mov $1,1
mov $2,332202
lpb $2
mov $3,$6
seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0.
sub $0,$3
add $1,8
mov $4,$0
max $4,0
cmp $4,$0
mul $2,$4
sub $2,18
add $5,$1
div $5,6
mov $6,$5
lpe
mov $0,$5
add $0,1
|
oeis/000/A000578.asm | neoneye/loda-programs | 11 | 5293 | ; A000578: The cubes: a(n) = n^3.
; 0,1,8,27,64,125,216,343,512,729,1000,1331,1728,2197,2744,3375,4096,4913,5832,6859,8000,9261,10648,12167,13824,15625,17576,19683,21952,24389,27000,29791,32768,35937,39304,42875,46656,50653,54872,59319,64000,68921,74088,79507,85184,91125,97336,103823,110592,117649,125000,132651,140608,148877,157464,166375,175616,185193,195112,205379,216000,226981,238328,250047,262144,274625,287496,300763,314432,328509,343000,357911,373248,389017,405224,421875,438976,456533,474552,493039,512000,531441,551368
pow $0,3
|
source/league/matreshka-internals-text_codecs-utf16.adb | svn2github/matreshka | 24 | 10565 | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2010-2011, <NAME> <<EMAIL>> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.Internals.Strings.Configuration;
with Matreshka.Internals.Utf16;
package body Matreshka.Internals.Text_Codecs.UTF16 is
use Matreshka.Internals.Strings.Configuration;
use Matreshka.Internals.Unicode;
use Matreshka.Internals.Utf16;
-- Common states for both BE and LE variants.
Accept_State : constant := 0;
Reject_State : constant := 1;
-- States of BE variant.
BE_Second_Byte_Ordinary_State : constant := 2;
BE_Second_Byte_Surrogate_State : constant := 3;
BE_Surrogate_First_Byte_State : constant := 4;
BE_Surrogate_Second_Byte_State : constant := 5;
-- States of LE variant.
LE_Second_Byte_State : constant := 2;
LE_Surrogate_First_Byte_State : constant := 3;
LE_Surrogate_Second_Byte_State : constant := 4;
Meta_Class : constant
array (Ada.Streams.Stream_Element) of UTF16_Meta_Class
:= ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -- 0x00
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -- 0x10
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -- 0x20
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -- 0x30
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -- 0x40
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -- 0x50
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -- 0x60
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -- 0x70
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -- 0x80
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -- 0x90
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -- 0xA0
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -- 0xB0
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -- 0xC0
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, -- 0xD0
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -- 0xE0
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); -- 0xF0
BE_Transition : constant
array (UTF16_DFA_State range 0 .. 23) of UTF16_DFA_State
:= (2, 3, 1, 1, -- Accept
1, 1, 1, 1, -- Reject
0, 0, 0, 1, -- Second_Ordinary,
4, 4, 4, 1, -- Second_Surrogate,
1, 1, 5, 1, -- Surrogate_First
0, 0, 0, 1); -- Surrogate_Second
LE_Transition : constant
array (UTF16_DFA_State range 0 .. 19) of UTF16_DFA_State
:= (2, 2, 2, 1, -- Accept
1, 1, 1, 1, -- Reject
0, 3, 1, 1, -- Second_Byte
4, 4, 4, 1, -- Surrogate_First
1, 1, 0, 1); -- Surrogate_Second
----------------
-- BE_Decoder --
----------------
function BE_Decoder (Mode : Decoder_Mode) return Abstract_Decoder'Class is
begin
case Mode is
when Raw =>
return
UTF16BE_Decoder'
(Skip_LF => False,
Unchecked_Append => Unchecked_Append_Raw'Access,
State => Accept_State,
Code => 0,
Low => 0);
when XML_1_0 =>
return
UTF16BE_Decoder'
(Skip_LF => False,
Unchecked_Append => Unchecked_Append_XML10'Access,
State => Accept_State,
Code => 0,
Low => 0);
when XML_1_1 =>
return
UTF16BE_Decoder'
(Skip_LF => False,
Unchecked_Append => Unchecked_Append_XML11'Access,
State => Accept_State,
Code => 0,
Low => 0);
end case;
end BE_Decoder;
-------------------
-- Decode_Append --
-------------------
overriding procedure Decode_Append
(Self : in out UTF16BE_Decoder;
Data : Ada.Streams.Stream_Element_Array;
String : in out Matreshka.Internals.Strings.Shared_String_Access)
is
Current_State : UTF16_DFA_State := Self.State;
Current_Code : Matreshka.Internals.Unicode.Code_Unit_32 := Self.Code;
Current_Low : Matreshka.Internals.Unicode.Code_Unit_16 := Self.Low;
begin
Matreshka.Internals.Strings.Mutate (String, String.Unused + Data'Length);
for J in Data'Range loop
declare
M : constant UTF16_Meta_Class := Meta_Class (Data (J));
begin
case Current_State is
when Accept_State =>
Current_Code := Code_Unit_32 (Data (J));
when BE_Second_Byte_Ordinary_State
| BE_Second_Byte_Surrogate_State
=>
Current_Code :=
(Current_Code * 16#100#) or Code_Unit_32 (Data (J));
when BE_Surrogate_First_Byte_State =>
Current_Low := Code_Unit_16 (Data (J));
when BE_Surrogate_Second_Byte_State =>
Current_Code :=
Unchecked_Surrogate_Pair_To_Code_Point
(Code_Unit_16 (Current_Code),
(Current_Low * 16#100#) or Code_Unit_16 (Data (J)));
when others =>
null;
end case;
Current_State :=
BE_Transition (Current_State * 4 + UTF16_DFA_State (M));
if Current_State = Accept_State then
Self.Unchecked_Append (Self, String, Current_Code);
end if;
end;
end loop;
Self.State := Current_State;
Self.Code := Current_Code;
Self.Low := Current_Low;
String_Handler.Fill_Null_Terminator (String);
end Decode_Append;
-------------------
-- Decode_Append --
-------------------
overriding procedure Decode_Append
(Self : in out UTF16LE_Decoder;
Data : Ada.Streams.Stream_Element_Array;
String : in out Matreshka.Internals.Strings.Shared_String_Access)
is
Current_State : UTF16_DFA_State := Self.State;
Current_Code : Matreshka.Internals.Unicode.Code_Unit_32 := Self.Code;
Current_Low : Matreshka.Internals.Unicode.Code_Unit_16 := Self.Low;
begin
Matreshka.Internals.Strings.Mutate (String, String.Unused + Data'Length);
for J in Data'Range loop
declare
M : constant UTF16_Meta_Class := Meta_Class (Data (J));
begin
case Current_State is
when Accept_State =>
Current_Code := Code_Unit_32 (Data (J));
when LE_Second_Byte_State =>
Current_Code :=
(Code_Unit_32 (Data (J)) * 16#100#) or Current_Code;
when LE_Surrogate_First_Byte_State =>
Current_Low := Code_Unit_16 (Data (J));
when LE_Surrogate_Second_Byte_State =>
Current_Code :=
Unchecked_Surrogate_Pair_To_Code_Point
(Code_Unit_16 (Current_Code),
(Code_Unit_16 (Data (J)) * 16#100#) or Current_Low);
when others =>
null;
end case;
Current_State :=
LE_Transition (Current_State * 4 + UTF16_DFA_State (M));
if Current_State = Accept_State then
Self.Unchecked_Append (Self, String, Current_Code);
end if;
end;
end loop;
Self.State := Current_State;
Self.Code := Current_Code;
Self.Low := Current_Low;
String_Handler.Fill_Null_Terminator (String);
end Decode_Append;
--------------
-- Is_Error --
--------------
overriding function Is_Error (Self : UTF16BE_Decoder) return Boolean is
begin
return Self.State = Reject_State;
end Is_Error;
--------------
-- Is_Error --
--------------
overriding function Is_Error (Self : UTF16LE_Decoder) return Boolean is
begin
return Self.State = Reject_State;
end Is_Error;
-------------------
-- Is_Mailformed --
-------------------
overriding function Is_Mailformed (Self : UTF16BE_Decoder) return Boolean is
begin
return Self.State /= Accept_State;
end Is_Mailformed;
-------------------
-- Is_Mailformed --
-------------------
overriding function Is_Mailformed (Self : UTF16LE_Decoder) return Boolean is
begin
return Self.State /= Accept_State;
end Is_Mailformed;
----------------
-- LE_Decoder --
----------------
function LE_Decoder (Mode : Decoder_Mode) return Abstract_Decoder'Class is
begin
case Mode is
when Raw =>
return
UTF16LE_Decoder'
(Skip_LF => False,
Unchecked_Append => Unchecked_Append_Raw'Access,
State => Accept_State,
Code => 0,
Low => 0);
when XML_1_0 =>
return
UTF16LE_Decoder'
(Skip_LF => False,
Unchecked_Append => Unchecked_Append_XML10'Access,
State => Accept_State,
Code => 0,
Low => 0);
when XML_1_1 =>
return
UTF16LE_Decoder'
(Skip_LF => False,
Unchecked_Append => Unchecked_Append_XML11'Access,
State => Accept_State,
Code => 0,
Low => 0);
end case;
end LE_Decoder;
end Matreshka.Internals.Text_Codecs.UTF16;
|
programs/oeis/082/A082139.asm | neoneye/loda | 22 | 166794 | ; A082139: A transform of binomial(n,5).
; 1,6,42,224,1008,4032,14784,50688,164736,512512,1537536,4472832,12673024,35094528,95256576,254017536,666796032,1725825024,4410441728,11142168576,27855421440,68975329280,169303080960,412216197120,996189143040,2390853943296,5701267095552,13514114596864,31854698692608,74693776244736,174285477904384,404792077713408,936081679712256,2155824474488832,4945714970886144,11304491362025472,25749119213502464,58457459836059648,132298461734240256,298519605964439552,671669113419988992,1507159961820463104,3373167533598179328,7530792633149423616,16773129046560079872,37273620103466844160,82650201098991697920,182885551367981629440,403872259270959431680,890167428597216706560,1958368342913876754432,4300730478555964637184,9428524510680384012288,20636015910168387649536,45093516248145735974912,98385853632317969399808,214340609698978433335296,466284835134619749711872,1012963607361415318339584,2197615961733240012668928,4761501250422020027449344,10303576476323059731529728,22269020126246612968144896,48072805351897450216947712,103656986540028877030293504,223261201778523735142170624,480349858371975308942245888,1032393725456185738622140416,2216610057597104674100477952,4754467949628572344447401984,10188145606346940738101575680,21811241298094859044949852160,46651821665369559623920517120,99694303832844538374405488640,212860810886343744096703610880,454103063224199987406301036544,967956529504215762629220630528,2061621699203784221703794589696,4387553872664463856446537203712,9330494311488986428898965192704,19827300411914096161410301034496,42102415689496599256328046641152,89339272316736686226842440433664,189442312382477792481015295377408,401437281000964845971675268775936,850102477413807909116488804466688,1799054080108291156502336772243456,3804895985516385894211838690721792,8042166514841452003675022687207424,16987947244833628951583193990955008,35863444183537661120008965092016128,75667926189442098187271662611726336,159560626964693120090551114637770752,336278310592256468147828155580678144,708330909545391283970957178776322048
mov $1,-2
pow $1,$0
mov $2,-6
bin $2,$0
mul $1,$2
mul $1,6
sub $1,6
div $1,12
add $1,1
mov $0,$1
|
oeis/315/A315762.asm | neoneye/loda-programs | 11 | 81885 | ; A315762: Coordination sequence Gal.6.627.5 where G.u.t.v denotes the coordination sequence for a vertex of type v in tiling number t in the Galebach list of u-uniform tilings.
; Submitted by <NAME>
; 1,6,12,18,24,29,35,40,46,52,58,64,70,76,82,88,93,99,104,110,116,122,128,134,140,146,152,157,163,168,174,180,186,192,198,204,210,216,221,227,232,238,244,250,256,262,268,274,280,285
mul $0,16
mov $1,$0
mul $0,2
add $0,6
div $0,11
mul $1,2
sub $1,7
div $1,11
add $1,1
add $0,$1
|
AdaProgrammingAssignment/matrixmult.ads | rohitsaraf17/NYU-ProgrammingLanguages | 3 | 6605 | package MatrixMult is
SIZE : constant Integer := 10;
type Matrix is array(1..SIZE,1..SIZE) of Integer;
procedure MatMult(A, B : Matrix; C : out Matrix);
end MatrixMult;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.