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/199/A199553.asm | neoneye/loda | 22 | 20815 | <filename>programs/oeis/199/A199553.asm
; A199553: 5*8^n+1.
; 6,41,321,2561,20481,163841,1310721,10485761,83886081,671088641,5368709121,42949672961,343597383681,2748779069441,21990232555521,175921860444161,1407374883553281,11258999068426241,90071992547409921,720575940379279361,5764607523034234881,46116860184273879041,368934881474191032321,2951479051793528258561,23611832414348226068481,188894659314785808547841,1511157274518286468382721,12089258196146291747061761,96714065569170333976494081,773712524553362671811952641,6189700196426901374495621121,49517601571415210995964968961,396140812571321687967719751681,3169126500570573503741758013441,25353012004564588029934064107521,202824096036516704239472512860161,1622592768292133633915780102881281,12980742146337069071326240823050241,103845937170696552570609926584401921,830767497365572420564879412675215361
mov $1,8
pow $1,$0
mul $1,5
add $1,1
mov $0,$1
|
src/lexing.asm | POBIX/asm-lang | 1 | 179768 | dataseg
curr_line dw 1
codeseg
struc Lex
tok db ? ; Token
source dw ? ; string
line dw ? ; int
ends
; Lex* get_token(string word)
proc get_token
push bp
mov bp, sp
push di
push bx
push cx
push si
mov di, [bp + 4] ; word
; create a Lex, address stored in si
push size Lex
call malloc
mov si, ax
; initialize it
SI_PTR equ (Lex ptr si)
mov [byte ptr SI_PTR.tok], TOK_NONE
mov [SI_PTR.source], di
mov ax, [curr_line]
mov [SI_PTR.line], ax
xor ah, ah
mov cx, 1
__loop:
; check if [word] is equal to the token
push di
mov bx, offset tokens
add bx, cx
add bx, cx ; adding twice beacuse it's a word
push [word ptr bx]
call strequ
cmp ax, true
je __equal
; try again with the next token
inc cx
cmp cx, TOK_EOF
jl __loop
; if we reached this point, none of the tokens match.
; we've initialized si.token to TOK_NONE already, so just return.
jmp __return
__equal:
mov [SI_PTR.tok], cl
__return:
mov ax, si
pop si
pop cx
pop bx
pop di
pop bp
ret 2 * 1
endp
; vecword* do_lex(string source) - takes source code and converts into a vector of Lexes.
proc do_lex
push bp
mov bp, sp
push bx
push cx
push dx
push di
push si
mov bx, [bp + 4]
; create and initialize a vecword in si, to be fed into the split function
push size vecword
call malloc
mov si, ax
push si
push 1024
call vw_newcap
SI_PTR equ (vecword ptr si)
push bx
push offset separators
push si
call split
; create and initialize the output, stored in di
push size vecword
call malloc
mov di, ax
push di
push 1024
call vw_newcap
DI_PTR equ (vecword ptr di)
xor ah, ah
xor cx, cx
jmp __loop
__inc_line:
; this gets called whenever we've reached a newline.
inc [curr_line]
jmp __continue
__loop:
push si
push cx
call vw_index
mov dx, ax
; if our current character is a newline, incrememnt the line number.
push dx
push 10
call strequ_char
cmp ax, true
je __inc_line
; check whether the split[i] is a whitespace character, if it is then continue.
push dx
call is_whitespace
cmp ax, true
je __continue_near
; if this character is a part of a double token, we have to check whether this + the next element make a token together.
push dx
call strsize
cmp ax, 1
jne __skip
push offset double_toks
mov bx, dx
mov al, [byte ptr bx]
push ax
call strcontains
cmp ax, true
jne __skip
; get the next token for the double token without incrementing the loop
mov ax, cx
inc ax
push si
push ax
call vw_index
dataseg
__dtok db "%s%s",0
codeseg
push dx
push ax
push offset __dtok
callva format 2
push ax
call get_token
mov bx, ax
BX_PTR equ (Lex ptr bx)
cmp [BX_PTR.tok], TOK_COMMENT
je __comment
cmp [BX_PTR.tok], TOK_NONE
je __skip
inc cx
jmp __push
; relative jump out of range
__loop_near: jmp __loop
__continue_near: jmp __continue
__comment:
; as long as we don't reach a newline, increment cx.
inc cx
push si
push cx
call vw_index
push ax
push 10
call strequ_char
cmp ax, false
je __comment
jmp __loop
__skip:
; push the split[i] token representation.
push dx
call get_token
mov bx, ax
__push:
push di
push bx
call vw_push
__continue:
inc cx
cmp cx, [SI_PTR.len]
jb __loop_near
__insert_eof:
; create an {EOF, null} Lex
push size Lex
call malloc
mov bx, ax
BX_PTR equ (Lex ptr bx)
mov [BX_PTR.tok], TOK_EOF
mov [BX_PTR.source], 0
push di
push bx
call vw_push
push si
call free
mov ax, di
pop si
pop di
pop dx
pop cx
pop bx
pop bp
ret 2 * 1
endp
|
libsrc/_DEVELOPMENT/adt/bv_stack/c/sccz80/bv_stack_init.asm | jpoikela/z88dk | 640 | 86931 | <filename>libsrc/_DEVELOPMENT/adt/bv_stack/c/sccz80/bv_stack_init.asm
; bv_stack_t *bv_stack_init(void *p, size_t capacity, size_t max_size)
SECTION code_clib
SECTION code_adt_bv_stack
PUBLIC bv_stack_init
EXTERN b_vector_init
defc bv_stack_init = b_vector_init
; SDCC bridge for Classic
IF __CLASSIC
PUBLIC _bv_stack_init
defc _bv_stack_init = bv_stack_init
ENDIF
|
libsrc/_DEVELOPMENT/math/float/am9511/lam32/c/sdcc/sin.asm | ahjelm/z88dk | 640 | 241763 | <filename>libsrc/_DEVELOPMENT/math/float/am9511/lam32/c/sdcc/sin.asm
SECTION code_fp_am9511
PUBLIC _sin
EXTERN cam32_sdcc_sin
defc _sin = cam32_sdcc_sin
|
programs/oeis/006/A006062.asm | neoneye/loda | 22 | 244476 | ; A006062: Star-hex numbers.
; 1,37,1261,42841,1455337,49438621,1679457781,57052125937,1938092824081,65838103892821,2236557439531837,75977114840189641,2580985347126915961,87677524687474953037,2978454854027021487301,101179787512231255615201
seq $0,2315 ; NSW numbers: a(n) = 6*a(n-1) - a(n-2); also a(n)^2 - 2*b(n)^2 = -1 with b(n)=A001653(n+1).
pow $0,2
div $0,48
mul $0,36
add $0,1
|
test/mouse.adb | Fabien-Chouteau/sdlada | 1 | 17603 | with SDL;
with SDL.Error;
with SDL.Events.Events;
with SDL.Events.Keyboards;
with SDL.Inputs.Mice;
with SDL.Log;
with SDL.Video.Palettes;
with SDL.Video.Pixel_Formats;
with SDL.Video.Renderers.Makers;
with SDL.Video.Textures.Makers;
with SDL.Video.Windows.Makers;
with SDL.Versions;
procedure Mouse is
use type SDL.Dimension;
use type SDL.Positive_Sizes;
Window_Size : constant SDL.Positive_Sizes := SDL.Positive_Sizes'(800, 640);
W : SDL.Video.Windows.Window;
Renderer : SDL.Video.Renderers.Renderer;
Texture : SDL.Video.Textures.Texture;
begin
SDL.Log.Set (Category => SDL.Log.Application, Priority => SDL.Log.Debug);
if SDL.Initialise = True then
SDL.Video.Windows.Makers.Create (Win => W,
Title => "Mouse",
Position => SDL.Natural_Coordinates'(X => 300, Y => 300),
Size => Window_Size,
Flags => SDL.Video.Windows.Resizable);
SDL.Video.Renderers.Makers.Create (Renderer, W);
SDL.Video.Textures.Makers.Create (Tex => Texture,
Renderer => Renderer,
Format => SDL.Video.Pixel_Formats.Pixel_Format_ARGB_8888,
Kind => SDL.Video.Textures.Streaming,
Size => Window_Size);
-- Main loop.
declare
Event : SDL.Events.Events.Events;
Finished : Boolean := False;
Mouse_Shown : Boolean := True;
Warp_Rel : Boolean := True;
Warp_Screen : Boolean := False;
use type SDL.Events.Event_Types;
use type SDL.Events.Keyboards.Key_Codes;
use type SDL.Events.Keyboards.Scan_Codes;
begin
loop
while SDL.Events.Events.Poll (Event) loop
case Event.Common.Event_Type is
when SDL.Events.Quit =>
Finished := True;
when SDL.Events.Keyboards.Key_Down =>
case Event.Keyboard.Key_Sym.Key_Code is
when SDL.Events.Keyboards.Code_Escape =>
Finished := True;
when SDL.Events.Keyboards.Code_M =>
Mouse_Shown := not Mouse_Shown;
SDL.Inputs.Mice.Show_Cursor (Mouse_Shown);
SDL.Log.Put_Debug ("Mouse Shown : " & Boolean'Image (Mouse_Shown));
when SDL.Events.Keyboards.Code_R =>
Warp_Rel := True;
SDL.Log.Put_Debug ("Mouse warp relative: " & Boolean'Image (Warp_Rel));
when SDL.Events.Keyboards.Code_A =>
Warp_Rel := False;
SDL.Log.Put_Debug ("Mouse warp relative: " & Boolean'Image (Warp_Rel));
when SDL.Events.Keyboards.Code_W =>
SDL.Log.Put_Debug ("Warping mouse!");
if Warp_Screen then
SDL.Inputs.Mice.Warp ((0, 0));
else
SDL.Inputs.Mice.Warp (W, (0, 0));
end if;
when SDL.Events.Keyboards.Code_S =>
Warp_Screen := not Warp_Screen;
SDL.Log.Put_Debug ("Mouse warp to " & (if Warp_Screen then "screen!" else "window!"));
when others =>
null;
end case;
when others =>
null;
end case;
end loop;
Renderer.Clear;
Renderer.Copy (Texture);
Renderer.Present;
exit when Finished;
end loop;
end;
W.Finalize;
SDL.Finalise;
end if;
end Mouse;
|
oeis/017/A017118.asm | neoneye/loda-programs | 11 | 8577 | <filename>oeis/017/A017118.asm
; A017118: a(n) = (8*n + 4)^6.
; 4096,2985984,64000000,481890304,2176782336,7256313856,19770609664,46656000000,98867482624,192699928576,351298031616,606355001344,1000000000000,1586874322944,2436396322816,3635215077376,5289852801024,7529536000000,10509215371264,14412774445056,19456426971136,25892303048704,34012224000000,44151665987584,56693912375296,72074394832896,90785223184384,113379904000000,140478247931904,172771465793536,211027453382656,256096265048064,308915776000000,370517533364224,442032795979776,524698762940416
mul $0,8
add $0,4
pow $0,6
|
src/ada/src/services/example_spark_service/uxas-comms-lmcp_net_client-service-example_spark_service.adb | VVCAS-Sean/OpenUxAS | 88 | 10465 | <gh_stars>10-100
with AFRL.CMASI.AutomationResponse.SPARK_Boundary; use AFRL.CMASI.AutomationResponse.SPARK_Boundary;
with AFRL.CMASI.MissionCommand; use AFRL.CMASI.MissionCommand;
with AVTAS.LMCP.Object.SPARK_Boundary; use AVTAS.LMCP.Object.SPARK_Boundary;
with UxAS.Comms.LMCP_Net_Client.Service.Example_Spark_Service.SPARK;
with AFRL.CMASI.AutomationResponse;
use AFRL.CMASI.AutomationResponse;
package body UxAS.comms.LMCP_net_client.service.Example_Spark_Service is
---------------
-- Configure --
---------------
overriding
procedure Configure
(This : in out Example_Spark_Service;
XML_Node : DOM.Core.Element;
Result : out Boolean)
is
pragma Unreferenced (XML_Node);
Unused : Boolean;
begin
This.Add_Subscription_Address (AFRL.CMASI.AutomationResponse.Subscription, Unused);
This.Add_Subscription_Address (AFRL.CMASI.MissionCommand.Subscription, Unused);
Result := True;
end Configure;
---------------
-- Construct --
---------------
procedure Construct
(This : in out Example_Spark_Service)
is
begin
This.Construct_Service
(Service_Type => Type_Name,
Work_Directory_Name => Directory_Name);
end Construct;
------------
-- Create --
------------
function Create return Any_Service is
Result : Example_Spark_Service_Ref;
begin
Result := new Example_Spark_Service;
Result.Construct; -- Specific to Ada version
return Any_Service (Result);
end Create;
-----------------------------------
-- Handle_AutomationResponse_Msg --
-----------------------------------
procedure Handle_AutomationResponse_Msg
(This : in out Example_Spark_Service;
Response : Object_Any)
is
begin
This.Configs.AutomationIds :=
Int64_Sets.Union
(This.Configs.AutomationIds,
Get_WaypointEntity_Set (AutomationResponse (Response.all)));
end Handle_AutomationResponse_Msg;
-------------------------------
-- Handle_MissionCommand_Msg --
-------------------------------
procedure Handle_MissionCommand_Msg
(This : in out Example_Spark_Service;
Command : Object_Any)
is
Result : Boolean;
begin
SPARK.Handle_MissionCommand (This, Wrap (Command), Result);
end Handle_MissionCommand_Msg;
----------------
-- Initialize --
----------------
overriding
procedure Initialize
(This : in out Example_Spark_Service;
Result : out Boolean)
is
pragma Unreferenced (This); -- since not doing the Timers
begin
Result := True;
end Initialize;
-----------------------------------
-- Process_Received_LMCP_Message --
-----------------------------------
overriding
procedure Process_Received_LMCP_Message
(This : in out Example_Spark_Service;
Received_Message : not null Any_LMCP_Message;
Should_Terminate : out Boolean)
is
begin
if Received_Message.Payload.all in AutomationResponse'Class then
This.Handle_AutomationResponse_Msg (Received_Message.Payload);
end if;
if Received_Message.Payload.all in MissionCommand'Class then
This.Handle_MissionCommand_Msg (Received_Message.Payload);
end if;
Should_Terminate := False;
end Process_Received_LMCP_Message;
---------------------------------
-- Registry_Service_Type_Names --
---------------------------------
function Registry_Service_Type_Names return Service_Type_Names_List is
(Service_Type_Names_List'(1 => Instance (Service_Type_Name_Max_Length, Content => Type_Name)));
-----------------------------
-- Package Executable Part --
-----------------------------
-- This is the executable part for the package, invoked automatically and only once.
begin
-- All concrete service subclasses must call this procedure in their
-- own package like this, with their own params.
Register_Service_Creation_Function_Pointers (Registry_Service_Type_Names, Create'Access);
end UxAS.Comms.LMCP_Net_Client.Service.Example_Spark_Service;
|
test/Succeed/Issue1890.agda | cruhland/agda | 1,989 | 10038 | <reponame>cruhland/agda<gh_stars>1000+
open import Common.Reflection
macro
round-trip : Term → Tactic
round-trip v hole = unify v hole
module M (A : Set) where
data D : Set where
test : Set
test = round-trip D
|
_maps/SSUPblock.asm | NatsumiFox/AMPS-Sonic-1-2005 | 2 | 165000 | <filename>_maps/SSUPblock.asm
; ---------------------------------------------------------------------------
; Sprite mappings - special stage "UP" block
; ---------------------------------------------------------------------------
dc.w byte_1B944-Map_SS_Up
dc.w byte_1B94A-Map_SS_Up
byte_1B944: dc.b 1
dc.b $F4, $A, 0, 0, $F4
byte_1B94A: dc.b 1
dc.b $F4, $A, 0, $12, $F4
even |
test.asm | byteManiak/POKEY-Player | 0 | 171030 |
org $2000
instrument_length .byte $06
instrument_property .byte $aa, $a8, $a6, $a4, $a2, $a2
instrument_envelope .byte $38, $38, $38, $38, $38, $38
instrument_property_2 .byte $a0, $a0, $a0, $a0, $a8, $a2
instrument_envelope_2 .byte $38, $38, $38, $38, $38, $38
current_length .byte $00
ticks .byte $02
current_tick .byte $00
notes .byte $00, $13, $09, $06, $00, $13, $15, $13, $09, $19, $11, $0e, $09, $19, $1b, $19, $f9, $03, $00, $0e, $f9, $00, $03, $00, $00, $13, $00, $09, $00, $13, $15, $13
note_count .byte $1f
current_note .byte $00
start lda #0
sta 559
ldx #0
loop lda #1
sta $d40a
jsr routine
jmp loop
routine ldy current_length
lda instrument_property,y
sta $d201
lda instrument_property_2,y
sta $d203
lda instrument_envelope,y
ldy current_note
sbc notes,y
sta $d200
asl
asl
asl
asl
sta $d01a
ldy current_length
lda instrument_envelope_2,y
ldy current_note
sbc notes,y
sta $d202
ldy current_length
routine_timer inx
cpx #$0
bne end_routine
lda current_tick
cmp ticks
bne next_tick
lda #$0
sta current_tick
iny
cpy instrument_length
beq next_note
sty current_length
jmp end_routine
next_note lda current_note
cmp note_count
beq reset_note
jmp next_note_inc
reset_note lda #$0
sta current_note
jmp next_note_end
next_note_inc adc #$1
sta current_note
next_note_end ldy #$0
sty current_length
jmp end_routine
next_tick lda current_tick
adc #$1
sta current_tick
end_routine rts
run start
|
Categories/Category/Construction/EnrichedFunctors.agda | Taneb/agda-categories | 0 | 8239 | {-# OPTIONS --without-K --safe #-}
open import Categories.Category using () renaming (Category to Setoid-Category)
open import Categories.Category.Monoidal
module Categories.Category.Construction.EnrichedFunctors
{o ℓ e} {V : Setoid-Category o ℓ e} (M : Monoidal V) where
-- The (enriched) functor category for a given pair of V-enriched categories
open import Level
open import Data.Product using (_,_; uncurry′)
open import Categories.Enriched.Category M
open import Categories.Enriched.Functor M renaming (id to idF)
open import Categories.Enriched.NaturalTransformation M renaming (id to idNT)
open import Categories.Functor.Bifunctor using (Bifunctor)
open NaturalTransformation using (_[_])
EnrichedFunctors : ∀ {c d} (C : Category c) (D : Category d) →
Setoid-Category (ℓ ⊔ e ⊔ c ⊔ d) (ℓ ⊔ e ⊔ c) (e ⊔ c)
EnrichedFunctors C D = record
{ Obj = Functor C D
; _⇒_ = NaturalTransformation
; _≈_ = λ α β → ∀ {X} → α [ X ] ≈ β [ X ]
; id = idNT
; _∘_ = _∘ᵥ_
; assoc = assoc
; sym-assoc = sym-assoc
; identityˡ = identityˡ
; identityʳ = identityʳ
; identity² = identity²
; equiv = record
{ refl = Equiv.refl
; sym = λ α≈β → Equiv.sym α≈β
; trans = λ α≈β β≈γ → Equiv.trans α≈β β≈γ
}
; ∘-resp-≈ = λ α₁≈β₁ α₂≈β₂ → ∘-resp-≈ α₁≈β₁ α₂≈β₂
}
where open Underlying D
-- Horizontal composition of natural transformations (aka the Godement
-- product) induces a composition functor over functor categories.
--
-- Note that all the equational reasoning happens in the underlying
-- (ordinary) categories!
⊚ : ∀ {c d e} {C : Category c} {D : Category d} {E : Category e} →
Bifunctor (EnrichedFunctors D E) (EnrichedFunctors C D) (EnrichedFunctors C E)
⊚ {_} {_} {_} {_} {D} {E} = record
{ F₀ = uncurry′ _∘F_
; F₁ = uncurry′ _∘ₕ_
; identity = λ{ {F , G} {X} →
begin
(F $₁ D.id) ∘ E.id ≈⟨ identityʳ ⟩
F $₁ D.id ≈⟨ identity F ⟩
E.id ∎ }
; homomorphism = λ{ {_ , F₂} {G₁ , G₂} {H₁ , _} {α₁ , α₂} {β₁ , β₂} {X} →
begin
H₁ $₁ (β₂ [ X ] D.∘ α₂ [ X ]) ∘ β₁ [ F₂ $₀ X ] ∘ α₁ [ F₂ $₀ X ]
≈⟨ homomorphism H₁ ⟩∘⟨refl ⟩
(H₁ $₁ β₂ [ X ] ∘ H₁ $₁ α₂ [ X ]) ∘ β₁ [ F₂ $₀ X ] ∘ α₁ [ F₂ $₀ X ]
≈⟨ ⟺ assoc ○ ∘-resp-≈ˡ assoc ⟩
(H₁ $₁ β₂ [ X ] ∘ (H₁ $₁ α₂ [ X ] ∘ β₁ [ F₂ $₀ X ])) ∘ α₁ [ F₂ $₀ X ]
≈˘⟨ (refl⟩∘⟨ commute β₁ (α₂ [ X ])) ⟩∘⟨refl ⟩
(H₁ $₁ β₂ [ X ] ∘ (β₁ [ G₂ $₀ X ] ∘ G₁ $₁ α₂ [ X ])) ∘ α₁ [ F₂ $₀ X ]
≈˘⟨ ⟺ assoc ○ ∘-resp-≈ˡ assoc ⟩
(H₁ $₁ β₂ [ X ] ∘ β₁ [ G₂ $₀ X ]) ∘ G₁ $₁ α₂ [ X ] ∘ α₁ [ F₂ $₀ X ]
∎ }
; F-resp-≈ = λ{ {_} {F , _} (eq₁ , eq₂) → ∘-resp-≈ (F-resp-≈ F eq₂) eq₁ }
}
where
module D = Underlying D
module E = Underlying E
open E hiding (id)
open HomReasoning
open UnderlyingFunctor hiding (F₀; F₁)
open UnderlyingNT
-- Aliases used to shorten some proof expressions
infixr 14 _$₀_ _$₁_
_$₀_ = UnderlyingFunctor.F₀
_$₁_ = UnderlyingFunctor.F₁
|
audio/sfx/battle_16.asm | adhi-thirumala/EvoYellow | 16 | 97968 | SFX_Battle_16_Ch1:
unknownnoise0x20 1, 148, 35
unknownnoise0x20 1, 180, 34
unknownnoise0x20 8, 241, 68
endchannel
|
jm-illuminance/main.asm | KittenBot/jacdac-padauk | 4 | 177053 | .CHIP PMS171B
//{{PADAUK_CODE_OPTION
.Code_Option Security Disable
.Code_Option Bootup_Time Fast
.Code_Option LVR 3.0V
.Code_Option Comparator_Edge All_Edge
.Code_Option GPC_PWM Disable
.Code_Option TM2_Out1 PB2
.Code_Option TMx_Bit 6BIT
.Code_Option TMx_Source 16MHz
.Code_Option Interrupt_Src1 PB.0
.Code_Option Interrupt_Src0 PA.0
.Code_Option PB4_PB5_Drive Strong
//}}PADAUK_CODE_OPTION
//#define RELEASE 1
/*
Assignment (S8 package, or lower pins of S14/S16):
VDD | GND
PA7 - | PA0 - Jacdac
PA6 - | PA4 - sensor
PA5 - sink of status LED | PA3
*/
// all pins on PA
#define PIN_LED 5
#define LED_SINK 1
#define PIN_JACDAC 0
// #define PIN_LOG 1
// Cost given in comment: words of flash/bytes of RAM
// #define CFG_T16_32BIT 1 // 1/1
#define CFG_BROADCAST 1 // 20/0
#define CFG_RESET_IN 1 // 24/1
#define CFG_FW_ID 0x35627a49 // 24/0
.include ../jd/jdheader.asm
#define PIN_ADC PA4
#define LX_MULT 46 // ADC*LX_MULT/4 == LUX
// assume 3 LSB error (which is probably too low)
#define LX_ERROR (LX_MULT*3)
.include ../services/illuminance.asm
main:
.ADJUST_IC SYSCLK=IHRC/2, IHRC=16MHz, VDD=3.3V
PADIER = (1 << PIN_JACDAC)
PBDIER = 0
.include ../jd/jdmain.asm
|
oeis/203/A203829.asm | neoneye/loda-programs | 11 | 10764 | ; A203829: Number of (n+1) X 3 0..2 arrays with every 2 X 2 subblock having equal diagonal elements or equal antidiagonal elements.
; Submitted by <NAME>(s2)
; 225,1971,17289,151659,1330353,11669859,102368025,897972507,7877016513,69097203603,606120799401,5316892787403,46639793487825,409124355815619,3588839615364921,31481307826653051,276154091209147617,2422424205229022451,21249509664642906825,186400738571328116523,1635107627812667235057,14343167173171348882467,125818289302916805472089,1103678269379908551483867,9681467845813343352410625,84925854073560273068727891,744969750970415770913729769,6534876050586621392086112139,57323944953338760986947549713
add $0,1
mov $1,6
mov $2,8
lpb $0
sub $0,1
mul $2,2
add $2,$1
add $1,$2
add $1,$2
add $2,$1
lpe
mov $0,$1
div $0,2
mul $0,9
|
src/include/transfer_from_computer.asm | rondnelson99/sram-39sf-flasher | 0 | 167379 | INIT_TOKEN = 42;sent by the GB
RECIEVED_TOKEN = 43;recieved by the gb 2nd
START_TOKEN = 44;sent by the GB 2nd
WAIT_TOKEN = 45;sent by the computer instead of RECIEVED_TOKEN when it needs more time to download stuff from the computer.
CopyRom:: ; this needs to be called during Vblank
call ClearLowerScreen
ld a, INIT_TOKEN; Special token to start a transfer with computer
ldh [rSB], a
ld a, $83 ;we're the master, and we're initiating a fast transfer
ldh [rSC], a
call WaitTransferCompletion
CheckReply:
ld a, START_TOKEN
call TransferAndWait
ldh a, [rSB]
cp WAIT_TOKEN
jr z, NoRomFail
cp RECIEVED_TOKEN
jr nz, ConnectFail
EraseRom:
xor a
.loop
ld b, a
call SectorErase
ld a, b
add $10 ;move on to the next sector
cp $80 ;have we erased 32KB?
jr nz, .loop
lb bc, HIGH(wFlashBuffer1), 0
ld d, c
ld e, c ; ld de, 0
ld hl, wFlashBuffer2
LoadFirstPage:;since the main copy routine flashes and downloads at the same time, we need to fetch the first 256 bytes ahead of time.
/*
Registers:
D - The sum of the incoming bytes from Serial. This will be used to verify the block's integrity
HL - The destination buffer of this copy
*/
ld a, d ; d should be 0 when this starts
call TransferAndWait
ldh a, [rSB]
ld [hl], a
add d
ld d, a
inc l
jr nz, LoadFirstPage
ld d, 0
FlashROM0:
push de ;pushed de holds the block number
call LoadBlock
pop de
inc e ; advance to the next block
ld a, e
cp $7F ; are we one page away from the end of ROM0?
jr nz, FlashROM0
FlashLastPage:
ld a, b ;this is the pointer to the downloading buffer
xor $01 ;but this makes it the flashing buffer
ld d, a
ld h, e ; this is the rom location we're flashing to
ld e, l ; this is zero, we'll use it as the low byte of the pointer to the downloading buffer
.lastPageByte
ld a, [de]; grab the byte to flash
call FlashByteProgram ;write the byte
inc e ;this won't overflow
ld c, 3 ;number of times to check if the write goes through before quitting. This shouldn't take long.
.waitProgramCompletion
cp [hl] ;has the write gone through?
jr z, .writeSuccessful
dec c
jr nz, .waitProgramCompletion
jr FlashFail
.writeSuccessful
inc l
jr nz, .lastPageByte
;now jump over to our shiny new rom!
jp $0100
NoRomFail:
ld de, WaitingOnRomString
call WaitVblank
call StrcpyAboveProgressBar
jp ResetTilemap ;don't wait for the button press this time
WaitFailPop: ;when run during the flash loop we have to pop a couple times to prevent a stack overflow
add sp, 4 ;pop off the stacked block number as well as 1 return address
WaitFail:
ld de, PacketTimeoutString
call WaitVblank
call StrcpyAboveProgressBar
jp ResetTilemapAfterButtonPress
ConnectFail:
ld de, NoConnectionString
call WaitVblank
call StrcpyAboveProgressBar
jp ResetTilemap ;don't wait for the button press this time
FlashFailPop:
add sp, 4 ;pop off the stacked block number as well as 1 return address
FlashFail:
ld de, ProgramFailedString
call WaitVblank
call StrcpyAboveProgressBar
jp ResetTilemapAfterButtonPress
;this will return to the caller of CopyRom
LoadBlock:
call WaitTransferCompletion
ld h, 0 ;ld hl, 0
.checkBlockReady
ld a, INIT_TOKEN; Special token to start a transfer with computer
ldh [rSB], a
ld a, $83 ;we're the master, and we're initiating a fast transfer
ldh [rSC], a
call WaitTransferCompletion
.checkReply:
ld a, START_TOKEN
call TransferAndWait
ldh a, [rSB]
cp WAIT_TOKEN
jr nz, .nonWaitReply
dec hl ;decrement our counter
ld a, h
or l ;is it zero?
jr nz, .checkBlockReady
; I think this counter reaching zero indicates that we've been waiting on the arduino for like 1 or 2 seconds.
;time to error out
jr WaitFailPop
.nonWaitReply ;it's not telling us to wait. Either we're good to go or there's a connection issue
cp RECIEVED_TOKEN
jr nz, BadPacketStartFailPop
ld l, 0 ;start with the first byte
ld d, l ;l is 0, start a fresh checksum
PrepareFirstTransferOfBlock:
call TransferAndWait ;the main flashing routine starts with grabbing the byte out of rSB, so it needs the byte to already be transferd
LoadByte:; simultaneously read a byte from serial into the loading buffer, and write a byte to the flash from the flashing buffer
/*
Registers:
B - The high byte of the downloading buffer's location. Xor it with 1 to get the flashing buffer's location instead
C - The byte previously written to the flash. This is checked to see that the byte was written properly before writing the next one
D - The sum of the incoming bytes from Serial. This will be used to verify the block's integrity
E - The high byte of the pointer to the ROM(flash) location being currently written to
L - The low byte of all pointers. Also functions as the counter for the block.
*/
;Flash a Byte
ld a, b ; get the pointer to the downloading buffer
xor $01 ;now it points to the other buffer (which is now the flashing buffer)
ld h, a ;so now hl has the index in that buffer, which should be prorammed.
ld a , $AA ;send the byte-program command sequence
ld [$5555], a
cpl ;ld a, $55
ld [$2AAA], a
ld a, $A0
ld [$5555], a
ld a, [hl] ;fetch the byte to program
ld h, e ;this will be the high byte of the destination address
ld [hl], a ;actually write the byte
ld c,a ;store it to check later
;Fetch a Byte
ldh a, [rSB] ;get the byte previously sent by the arduino
ld h, b ; hl now points to the fetch buffer
ld [hl],a ; write to the buffer
add d
ld d, a
;Request a Byte
;ld a, d ;send out the checksum so far
ldh [rSB], a
ld a, $83 ;we're the master, and we're initiating a fast transfer
ldh [rSC], a
ld h, e ;point hl to the flash location
ld a, c ;get the previously written byte
cp [hl] ; check if the write has gone through yet
;that already took 20 cycles, so in single-speed mode, the byte should be done writing.
jr nz, FlashFailPop
inc l ; move to the next byte of the 256 byte block
jr nz, LoadByte
;Finishing The Block
ld a, b
xor $01
ld b, a; switch the buffers around
ret
BadPacketStartFailPop:
add sp, 4 ;pop off the stacked block number as well as 1 return address
BadPacketStartFail:
ld de, PacketTimeoutString
call WaitVblank
call StrcpyAboveProgressBar
jp ResetTilemapAfterButtonPress
BadPacketHeaderString:
db "BAD PKT HEADER", $FF
PacketTimeoutString:
db "PACKET TIMEOUT", $FF
NoConnectionString:
db "NO CONNECTION ", $FF
WaitingOnRomString:
db "WAITING ON ROM", $FF
PUSHS
SECTION "Flash Wram Buffers", WRAM0, ALIGN[9]
wFlashBuffer1: ; these will alternate between storing validated data to be flashed and downloaded data to be verified
ds 256
wFlashBuffer2:
ds 256
POPS |
src/yaml/text-pool.adb | My-Colaborations/dynamo | 15 | 21848 | -- part of ParserTools, (c) 2017 <NAME>
-- released under the terms of the MIT license, see the file "copying.txt"
package body Text.Pool is
procedure Create (P : in out Reference'Class;
Initial_Size : Pool_Offset := Default_Size)
is
Initial_Chunk : constant Chunk := new Pool_Array
(Pool_Offset (1) .. Round_To_Header_Size (Initial_Size));
begin
P.Data := new Pool_Data;
P.Data.Chunks (1) := Initial_Chunk;
P.Data.Pos := 1;
declare
H : Header with Import;
for H'Address use Initial_Chunk.all (1)'Address;
begin
H.Refcount := 0;
H.Last := Pool_Offset (Initial_Chunk'Last) - Header_Size;
end;
end Create;
function With_Capacity (Size : Pool_Offset) return Reference is
begin
return Ret : Reference do
Create (Ret, Size);
end return;
end With_Capacity;
function From_String (P : Reference'Class; Data : String)
return Text.Reference is
pragma Unreferenced (P);
begin
return Ada.Strings.Unbounded.To_Unbounded_String (Data);
end From_String;
end Text.Pool;
|
kv-avm-messages.ads | davidkristola/vole | 4 | 26236 | with Ada.Streams;
with Ada.Finalization;
with Interfaces;
with kv.avm.Actor_References;
with kv.avm.Actor_References.Sets;
with kv.avm.Registers;
with kv.avm.Tuples;
package kv.avm.Messages is
use Interfaces;
use kv.avm.Registers;
use kv.avm.Tuples;
type Message_Type is tagged private;
procedure Initialize
(Self : in out Message_Type);
procedure Adjust
(Self : in out Message_Type);
procedure Finalize
(Self : in out Message_Type);
procedure Initialize
(Self : in out Message_Type;
Source : in kv.avm.Actor_References.Actor_Reference_Type;
Reply_To : in kv.avm.Actor_References.Actor_Reference_Type;
Destination : in kv.avm.Actor_References.Actor_Reference_Type;
Message_Name : in String;
Data : in kv.avm.Tuples.Tuple_Type;
Future : in Interfaces.Unsigned_32);
function Get_Name(Self : Message_Type) return String;
function Get_Source(Self : Message_Type) return kv.avm.Actor_References.Actor_Reference_Type;
function Get_Reply_To(Self : Message_Type) return kv.avm.Actor_References.Actor_Reference_Type;
function Get_Destination(Self : Message_Type) return kv.avm.Actor_References.Actor_Reference_Type;
function Get_Data(Self : Message_Type) return kv.avm.Tuples.Tuple_Type;
function Get_Future(Self : Message_Type) return Interfaces.Unsigned_32;
function Image(Self : Message_Type) return String;
function Debug(Self : Message_Type) return String;
function Reachable(Self : Message_Type) return kv.avm.Actor_References.Sets.Set;
function "="(L, R: Message_Type) return Boolean;
procedure Message_Write(Stream : not null access Ada.Streams.Root_Stream_Type'CLASS; Item : in Message_Type);
for Message_Type'WRITE use Message_Write;
procedure Message_Read(Stream : not null access Ada.Streams.Root_Stream_Type'CLASS; Item : out Message_Type);
for Message_Type'READ use Message_Read;
private
type Reference_Counted_Message_Type;
type Reference_Counted_Message_Access is access all Reference_Counted_Message_Type;
type Message_Type is new Ada.Finalization.Controlled with
record
Ref : Reference_Counted_Message_Access;
end record;
end kv.avm.Messages;
|
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/cc/cc1307b.ada | best08618/asylo | 7 | 15380 | -- CC1307B.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.
--*
-- OBJECTIVE:
-- CHECK THAT AN ENUMERATION LITERAL (BOTH AN IDENTIFIER AND A
-- CHARACTER LITERAL) MAY BE USED AS A DEFAULT SUBPROGRAM NAME
-- AND AS A DEFAULT INITIAL VALUE FOR AN OBJECT PARAMETER.
-- HISTORY:
-- BCB 08/09/88 CREATED ORIGINAL TEST.
WITH REPORT; USE REPORT;
PROCEDURE CC1307B IS
TYPE ENUM IS (R, 'S', R1);
BEGIN
TEST ("CC1307B", "CHECK THAT AN ENUMERATION LITERAL (BOTH AN " &
"IDENTIFIER AND A CHARACTER LITERAL) MAY BE " &
"USED AS A DEFAULT SUBPROGRAM NAME AND AS A " &
"DEFAULT INITIAL VALUE FOR AN OBJECT PARAMETER");
DECLARE
GENERIC
WITH FUNCTION J RETURN ENUM IS R;
WITH FUNCTION K RETURN ENUM IS 'S';
OBJ1 : ENUM := R;
OBJ2 : ENUM := 'S';
PACKAGE P IS
END P;
PACKAGE BODY P IS
VAR1, VAR2 : ENUM := R1;
BEGIN
VAR1 := J;
IF VAR1 /= R THEN
FAILED ("WRONG VALUE FOR DEFAULT SUBPROGRAM " &
"NAME - IDENTIFIER");
END IF;
VAR2 := K;
IF VAR2 /= 'S' THEN
FAILED ("WRONG VALUE FOR DEFAULT SUBPROGRAM " &
"NAME - CHARACTER LITERAL");
END IF;
IF OBJ1 /= R THEN
FAILED ("WRONG VALUE FOR OBJECT PARAMETER - " &
"IDENTIFIER");
END IF;
IF OBJ2 /= 'S' THEN
FAILED ("WRONG VALUE FOR OBJECT PARAMETER - " &
"CHARACTER LITERAL");
END IF;
END P;
PACKAGE NEW_P IS NEW P;
BEGIN
NULL;
END;
RESULT;
END CC1307B;
|
alloy4fun_models/trainstlt/models/13/o7sNEfGK2ow78R8tu.als | Kaixi26/org.alloytools.alloy | 0 | 2228 | <gh_stars>0
open main
pred ido7sNEfGK2ow78R8tu_prop14 {
always ( all t:Train | (some t.pos and one (t.pos.signal :>Green) )implies (t.pos'.signal in Signal-Green) )
}
pred __repair { ido7sNEfGK2ow78R8tu_prop14 }
check __repair { ido7sNEfGK2ow78R8tu_prop14 <=> prop14o } |
core/lib/groups/CommutingSquare.agda | mikeshulman/HoTT-Agda | 0 | 12286 | {-# OPTIONS --without-K --rewriting #-}
open import lib.Basics
open import lib.types.Group
open import lib.types.CommutingSquare
open import lib.groups.Homomorphism
open import lib.groups.Isomorphism
module lib.groups.CommutingSquare where
-- A new type to keep the parameters.
record CommSquareᴳ {i₀ i₁ j₀ j₁}
{G₀ : Group i₀} {G₁ : Group i₁} {H₀ : Group j₀} {H₁ : Group j₁}
(φ₀ : G₀ →ᴳ H₀) (φ₁ : G₁ →ᴳ H₁) (ξG : G₀ →ᴳ G₁) (ξH : H₀ →ᴳ H₁)
: Type (lmax (lmax i₀ i₁) (lmax j₀ j₁)) where
constructor comm-sqrᴳ
field
commutesᴳ : ∀ g₀ → GroupHom.f (ξH ∘ᴳ φ₀) g₀ == GroupHom.f (φ₁ ∘ᴳ ξG) g₀
infix 0 _□$ᴳ_
_□$ᴳ_ = CommSquareᴳ.commutesᴳ
CommSquareᴳ-∘v : ∀ {i₀ i₁ i₂ j₀ j₁ j₂}
{G₀ : Group i₀} {G₁ : Group i₁} {G₂ : Group i₂}
{H₀ : Group j₀} {H₁ : Group j₁} {H₂ : Group j₂}
{φ : G₀ →ᴳ H₀} {ψ : G₁ →ᴳ H₁} {χ : G₂ →ᴳ H₂}
{ξG : G₀ →ᴳ G₁} {ξH : H₀ →ᴳ H₁}
{μA : G₁ →ᴳ G₂} {μB : H₁ →ᴳ H₂}
→ CommSquareᴳ ψ χ μA μB
→ CommSquareᴳ φ ψ ξG ξH
→ CommSquareᴳ φ χ (μA ∘ᴳ ξG) (μB ∘ᴳ ξH)
CommSquareᴳ-∘v {ξG = ξG} {μB = μB} (comm-sqrᴳ □₁₂) (comm-sqrᴳ □₀₁) =
comm-sqrᴳ λ g₀ → ap (GroupHom.f μB) (□₀₁ g₀) ∙ □₁₂ (GroupHom.f ξG g₀)
CommSquareᴳ-inverse-v : ∀ {i₀ i₁ j₀ j₁}
{G₀ : Group i₀} {G₁ : Group i₁} {H₀ : Group j₀} {H₁ : Group j₁}
{φ₀ : G₀ →ᴳ H₀} {φ₁ : G₁ →ᴳ H₁} {ξG : G₀ →ᴳ G₁} {ξH : H₀ →ᴳ H₁}
→ CommSquareᴳ φ₀ φ₁ ξG ξH
→ (ξG-ise : is-equiv (GroupHom.f ξG)) (ξH-ise : is-equiv (GroupHom.f ξH))
→ CommSquareᴳ φ₁ φ₀ (GroupIso.g-hom (ξG , ξG-ise)) (GroupIso.g-hom (ξH , ξH-ise))
CommSquareᴳ-inverse-v (comm-sqrᴳ □) ξG-ise ξH-ise =
comm-sqrᴳ (commutes (CommSquare-inverse-v (comm-sqr □) ξG-ise ξH-ise))
|
msutest.asm | RobertTheSable/fe3-voice-poc | 0 | 240192 | <reponame>RobertTheSable/fe3-voice-poc
lorom
!INDEX_FLAG = $10
!MEMORY_FLAG = $20
MSU_STATUS = $2000
MSU_READ = $2001
MSU_ID = $2002
MSU_SEEK = $2000
MSU_TRACK = $2004
MSU_VOLUME = $2006
MSU_CONTROL = $2007
MSU_STATE_NOT_FOUND = %00001000
MSU_STATE_PLAYING = %00010000
MSU_STATE_BUSY = %01000000
TRACK_INDEX = $06C0
TRACK_STATUS = $06C2
; original algorithm for queueing text sfx
GOTO_SFX = $87c998
;
incsrc hooks.asm
ORG $87ed00
msu1StatusCheck:
db "S-MSU1"
playMSU:
pha
phx
phy
php
rep #(!MEMORY_FLAG|!INDEX_FLAG)
lda TRACK_INDEX
beq originalOperation ; if no track number is stored, use normal sound effects.
dec
tax
sep #!MEMORY_FLAG
ldy #$0005
availabilityCheckLoop:
; check that MSU1 is set up and available.
lda.w MSU_ID,y
cmp msu1StatusCheck,y
bne originalOperation
dey
bpl availabilityCheckLoop
loadTrack:
; if Track status is not zero, another track was played.
lda TRACK_STATUS
bne end
; I thought checking the audio busy flag was required
; but it looks like audio is always busy and it can be ignored.
; lda.w MSU_STATUS
; bit.b #MSU_STATE_BUSY
; bne end
lda.b #$00
sta.w MSU_CONTROL
lda.b #$FF
sta.w MSU_VOLUME
stx.w MSU_TRACK
lda.b #$01
sta.w MSU_CONTROL
lda.w MSU_STATUS
bit.b #MSU_STATE_NOT_FOUND
bne originalOperation
inc.w TRACK_INDEX
lda.b #$01
sta.w TRACK_STATUS
end:
plp
ply
plx
pla
rts
originalOperation:
plp
ply
plx
pla
jmp normalTextSFX
storeTrackHook:
; use the dialogue table index to load the track number as well.
lda [$0f],y
pha
phx
php
rep #$10
asl
tax
lda.w trackIndexes,x
sta $06C0
plp
plx
pla
asl
rts
trackIndexes:
incsrc trackindexes.asm
forceStopTrack:
; set the track status to zero after text is unpaused so that the next track can be played.
php
sep #!MEMORY_FLAG
lda.w TRACK_STATUS
beq nothingPlaying
stz.w TRACK_STATUS
nothingPlaying:
plp
jml $87b0ff
endTextHook:
; once text is done, we need to 0 out the memory locations used for track info
phx
php
sep #(!MEMORY_FLAG|!INDEX_FLAG)
ldx #$02
resetTrackInfo:
stz.w TRACK_INDEX,x
dex
bpl resetTrackInfo
plp
plx
jmp endText
|
libsrc/stdio/ansi/sharp-mz/f_ansi_char.asm | jpoikela/z88dk | 640 | 164819 | <reponame>jpoikela/z88dk<filename>libsrc/stdio/ansi/sharp-mz/f_ansi_char.asm
;
; ANSI Video handling for the SHARP MZ
;
; set it up with:
; .__console_w = max columns
; .__console_h = max rows
;
; Display a char in location (__console_y),(__console_x)
; A=char to display
;
;
; $Id: f_ansi_char.asm,v 1.6 2016-06-12 16:06:43 dom Exp $
;
SECTION code_clib
PUBLIC ansi_CHAR
EXTERN __console_y
EXTERN __console_x
EXTERN current_attr
EXTERN sharpmz_from_ascii
; 0=space
; 1=A..Z
; 128=a..z
; 32=0..9
; 96=!..
.ansi_CHAR
call sharpmz_from_ascii
.setout
ld hl,$D000 - 40
ld bc,(__console_x)
inc b
ld de,40
.r_loop
add hl,de
djnz r_loop
.r_zero
add hl,bc
ld (hl),a
ld a,8 ; Set the character color
add a,h
ld h,a
ld a,(current_attr)
ld (hl),a
ret
|
theorems/groups/ExactSequence.agda | timjb/HoTT-Agda | 294 | 5566 | <filename>theorems/groups/ExactSequence.agda<gh_stars>100-1000
open import HoTT
open import groups.Exactness
open import groups.HomSequence
module groups.ExactSequence where
is-exact-seq : ∀ {i} {G H : Group i}
→ HomSequence G H → Type i
is-exact-seq (_ ⊣|ᴳ) = Lift ⊤
is-exact-seq (_ →⟨ φ ⟩ᴳ _ ⊣|ᴳ) = Lift ⊤
is-exact-seq (_ →⟨ φ ⟩ᴳ _ →⟨ ψ ⟩ᴳ seq) =
is-exact φ ψ × is-exact-seq (_ →⟨ ψ ⟩ᴳ seq)
ExactSequence : ∀ {i} (G H : Group i) → Type (lsucc i)
ExactSequence G H = Σ (HomSequence G H) is-exact-seq
{- equivalences preserve exactness -}
abstract
seq-equiv-preserves-exact : ∀ {i₀ i₁} {G₀ H₀ : Group i₀} {G₁ H₁ : Group i₁}
{seq₀ : HomSequence G₀ H₀} {seq₁ : HomSequence G₁ H₁}
{ξG : G₀ →ᴳ G₁} {ξH : H₀ →ᴳ H₁}
→ HomSeqEquiv seq₀ seq₁ ξG ξH
→ is-exact-seq seq₀ → is-exact-seq seq₁
seq-equiv-preserves-exact ((_ ↓|ᴳ) , _) _ = lift tt
seq-equiv-preserves-exact ((_ ↓⟨ _ ⟩ᴳ _ ↓|ᴳ) , _) _ = lift tt
seq-equiv-preserves-exact
( (ξG ↓⟨ φ□ ⟩ᴳ _↓⟨_⟩ᴳ_ ξH {ξK} ψ□ seq-map)
, (ξG-ise , ξH-ise , seq-map-ise))
(φ₀-ψ₀-is-exact , ψ₀-seq₀-is-exact-seq) =
equiv-preserves-exact
φ□ ψ□ ξG-ise ξH-ise (is-seqᴳ-equiv.head seq-map-ise)
φ₀-ψ₀-is-exact ,
seq-equiv-preserves-exact
((ξH ↓⟨ ψ□ ⟩ᴳ seq-map) , (ξH-ise , seq-map-ise))
ψ₀-seq₀-is-exact-seq
seq-equiv-preserves'-exact : ∀ {i} {G₀ G₁ H₀ H₁ : Group i}
{seq₀ : HomSequence G₀ H₀} {seq₁ : HomSequence G₁ H₁}
{ξG : G₀ →ᴳ G₁} {ξH : H₀ →ᴳ H₁}
→ HomSeqEquiv seq₀ seq₁ ξG ξH
→ is-exact-seq seq₁ → is-exact-seq seq₀
seq-equiv-preserves'-exact seq-equiv =
seq-equiv-preserves-exact (HomSeqEquiv-inverse seq-equiv)
private
exact-seq-index-type : ∀ {i} {G H : Group i} → ℕ → HomSequence G H → Type i
exact-seq-index-type _ (G ⊣|ᴳ) = Lift ⊤
exact-seq-index-type _ (G →⟨ φ ⟩ᴳ H ⊣|ᴳ) = Lift ⊤
exact-seq-index-type O (G →⟨ φ ⟩ᴳ H →⟨ ψ ⟩ᴳ s) = is-exact φ ψ
exact-seq-index-type (S n) (_ →⟨ _ ⟩ᴳ s) = exact-seq-index-type n s
abstract
exact-seq-index : ∀ {i} {G H : Group i}
→ (n : ℕ) (seq : ExactSequence G H)
→ exact-seq-index-type n (fst seq)
exact-seq-index _ ((G ⊣|ᴳ) , _) = lift tt
exact-seq-index _ ((G →⟨ φ ⟩ᴳ H ⊣|ᴳ) , _) = lift tt
exact-seq-index O ((G →⟨ φ ⟩ᴳ H →⟨ ψ ⟩ᴳ seq) , ise-seq) = fst ise-seq
exact-seq-index (S n) ((G →⟨ φ ⟩ᴳ H →⟨ ψ ⟩ᴳ seq) , ise-seq) =
exact-seq-index n ((H →⟨ ψ ⟩ᴳ seq) , snd ise-seq)
{-
private
exact-build-arg-type : ∀ {i} {G H : Group i} → HomSequence G H → List (Type i)
exact-build-arg-type (G ⊣|) = nil
exact-build-arg-type (G ⟨ φ ⟩→ H ⊣|) = nil
exact-build-arg-type (G ⟨ φ ⟩→ H ⟨ ψ ⟩→ s) =
is-exact φ ψ :: exact-build-arg-type (H ⟨ ψ ⟩→ s)
exact-build-helper : ∀ {i} {G H : Group i} (seq : HomSequence G H)
→ HList (exact-build-arg-type seq) → is-exact-seq seq
exact-build-helper (G ⊣|) nil = exact-seq-zero
exact-build-helper (G ⟨ φ ⟩→ H ⊣|) nil = exact-seq-one
exact-build-helper (G ⟨ φ ⟩→ H ⟨ ψ ⟩→ s) (ie :: ies) =
exact-seq-more ie (exact-build-helper (H ⟨ ψ ⟩→ s) ies)
exact-build : ∀ {i} {G H : Group i} (seq : HomSequence G H)
→ hlist-curry-type (exact-build-arg-type seq) (λ _ → is-exact-seq seq)
exact-build seq = hlist-curry (exact-build-helper seq)
hom-seq-concat : ∀ {i} {G H K : Group i}
→ HomSequence G H → HomSequence H K → HomSequence G K
hom-seq-concat (G ⊣|) s₂ = s₂
hom-seq-concat (G ⟨ φ ⟩→ s₁) s₂ = G ⟨ φ ⟩→ (hom-seq-concat s₁ s₂)
abstract
exact-concat : ∀ {i} {G H K L : Group i}
{seq₁ : HomSequence G H} {φ : H →ᴳ K} {seq₂ : HomSequence K L}
→ is-exact-seq (hom-seq-snoc seq₁ φ) → is-exact-seq (H ⟨ φ ⟩→ seq₂)
→ is-exact-seq (hom-seq-concat seq₁ (H ⟨ φ ⟩→ seq₂))
exact-concat {seq₁ = G ⊣|} exact-seq-one es₂ = es₂
exact-concat {seq₁ = G ⟨ ψ ⟩→ H ⊣|} (exact-seq-more ex _) es₂ =
exact-seq-more ex es₂
exact-concat {seq₁ = G ⟨ ψ ⟩→ H ⟨ χ ⟩→ s} (exact-seq-more ex es₁) es₂ =
exact-seq-more ex (exact-concat {seq₁ = H ⟨ χ ⟩→ s} es₁ es₂)
-}
|
Transynther/x86/_processed/AVXALIGN/_st_/i9-9900K_12_0xa0.log_21829_814.asm | ljhsiun2/medusa | 9 | 243881 | <reponame>ljhsiun2/medusa<gh_stars>1-10
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r12
push %r13
push %r15
push %r9
push %rbx
push %rdx
lea addresses_A_ht+0x165a9, %r9
clflush (%r9)
nop
nop
nop
nop
cmp $33149, %r11
movl $0x61626364, (%r9)
nop
nop
cmp %r12, %r12
lea addresses_WT_ht+0xcba9, %r15
nop
nop
nop
nop
and $31433, %r13
vmovups (%r15), %ymm4
vextracti128 $1, %ymm4, %xmm4
vpextrq $1, %xmm4, %rbx
nop
nop
nop
and %r11, %r11
pop %rdx
pop %rbx
pop %r9
pop %r15
pop %r13
pop %r12
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r13
push %r14
push %r9
push %rbp
push %rbx
push %rcx
// Store
lea addresses_UC+0x93e9, %r9
nop
nop
nop
nop
nop
inc %rbx
mov $0x5152535455565758, %r11
movq %r11, %xmm3
vmovups %ymm3, (%r9)
nop
nop
nop
inc %rbx
// Load
lea addresses_normal+0xa669, %r11
nop
nop
inc %rbp
movups (%r11), %xmm3
vpextrq $0, %xmm3, %r9
nop
add %rbx, %rbx
// Faulty Load
lea addresses_D+0x7da9, %r13
inc %r11
movb (%r13), %r9b
lea oracles, %rbx
and $0xff, %r9
shlq $12, %r9
mov (%rbx,%r9,1), %r9
pop %rcx
pop %rbx
pop %rbp
pop %r9
pop %r14
pop %r13
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_D', 'AVXalign': False, 'size': 4}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 6, 'type': 'addresses_UC', 'AVXalign': False, 'size': 32}}
{'src': {'NT': False, 'same': True, 'congruent': 5, 'type': 'addresses_normal', 'AVXalign': False, 'size': 16}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_D', 'AVXalign': True, 'size': 1}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 9, 'type': 'addresses_A_ht', 'AVXalign': False, 'size': 4}}
{'src': {'NT': False, 'same': False, 'congruent': 9, 'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 32}, 'OP': 'LOAD'}
{'36': 21829}
36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36
*/
|
bootdict/x86/rstack.asm | ikysil/ikforth | 8 | 244670 | ;******************************************************************************
;
; rstack.asm
; IKForth
;
; Unlicense since 1999 by <NAME>
;
;******************************************************************************
; Return stack manipulation
;******************************************************************************
; 6.1.0580 >R
; Move value from the data stack to return stack
; D: a --
; R: -- a
$CODE '>R',$TO_R,VEF_COMPILE_ONLY
POPDS EAX
PUSHRS EAX
$NEXT
; 6.1.2060 R>
; Interpretation: Interpretation semantics for this word are undefined.
; Execution: ( -- x ) ( R: x -- )
; Move x from the return stack to the data stack.
$CODE 'R>',$R_FROM,VEF_COMPILE_ONLY
POPRS EAX
PUSHDS EAX
$NEXT
; 6.1.2070 R@
; Copy value from the return stack to data stack
; R: a -- a
; D: -- a
$CODE 'R@',$R_FETCH,VEF_USUAL
FETCHRS EAX
PUSHDS EAX
$NEXT
; 6.2.0340 2>R
; D: a b --
; R: -- a b
$CODE '2>R',$TWO_TO_R,VEF_COMPILE_ONLY
POPDS EBX
POPDS EAX
PUSHRS EAX
PUSHRS EBX
$NEXT
; 6.2.0410 2R>
; D: -- a b
; R: a b --
$CODE '2R>',$TWO_R_FROM,VEF_COMPILE_ONLY
POPRS EBX
POPRS EAX
PUSHDS EAX
PUSHDS EBX
$NEXT
; 6.2.0415 2R@
; D: -- a b
; R: a b -- a b
$CODE '2R@',$TWO_R_FETCH,VEF_USUAL
FETCHRS EBX,0
FETCHRS EAX,1
PUSHDS EAX
PUSHDS EBX
$NEXT
; R-PICK
$CODE 'R-PICK',$R_PICK,VEF_USUAL
POPDS EBX
FETCHRS EAX,EBX
PUSHDS EAX
$NEXT
; RS-SIZE
$CONST 'RS-SIZE',,RETURN_STACK_SIZE
; RP0
$CODE 'RP0',$RP0,VEF_USUAL
LEA EAX,DWORD [EDI + VAR_RSTACK]
PUSHDS EAX
$NEXT
; RP@
$CODE 'RP@',$RPFETCH,VEF_USUAL
PUSHDS EBP
$NEXT
; RP!
$CODE 'RP!',$RPSTORE,VEF_COMPILE_ONLY
POPDS EBP
$NEXT
; +R
; D: x - x
; R: - x
$CODE '+R',$PLUS_R,VEF_COMPILE_ONLY
FETCHDS EAX
PUSHRS EAX
$NEXT
; 2+R
; D: x1 x2 - x1 x2
; R: - x1 x2
$CODE '2+R',$2PLUS_R,VEF_COMPILE_ONLY
FETCHDS EAX
FETCHDS EBX,1
PUSHRS EBX
PUSHRS EAX
$NEXT
; N>R
; D: xn .. x1 n -
; R: - x1 .. xn n
$CODE 'N>R',$N_TO_R,VEF_COMPILE_ONLY
POPDS ECX
MOV EAX,ECX
OR ECX,ECX
@@N_TO_R_LOOP:
JECXZ SHORT @@N_TO_R_EXIT
POPDS EBX
PUSHRS EBX
DEC ECX
JMP SHORT @@N_TO_R_LOOP
@@N_TO_R_EXIT:
PUSHRS EAX
$NEXT
; NR>
; D: - xn .. x1 n
; R: x1 .. xn n -
$CODE 'NR>',$N_R_FROM,VEF_COMPILE_ONLY
POPRS ECX
MOV EAX,ECX
OR ECX,ECX
@@N_R_FROM_LOOP:
JECXZ SHORT @@N_R_FROM_EXIT
POPRS EBX
PUSHDS EBX
DEC ECX
JMP SHORT @@N_R_FROM_LOOP
@@N_R_FROM_EXIT:
PUSHDS EAX
$NEXT
|
oeis/025/A025958.asm | neoneye/loda-programs | 11 | 24815 | <reponame>neoneye/loda-programs
; A025958: Expansion of 1/((1-2x)(1-4x)(1-5x)(1-6x)).
; Submitted by <NAME>
; 1,17,185,1645,13041,96117,674185,4565165,30122081,194911717,1242462585,7828123485,48869031121,302849847317,1865814241385,11440608686605,69880858180161,425505538990917,2584272622186585,15662382429614525,94760227082369201,572499821108550517,3454726404090874185,20827136549223067245,125457272868664158241,755218156878393854117,4543690546801595280185,27324087337262617204765,164254388421028738267281,987076228974189371349717,5930209171928229076780585,35620023245356873411387085
mov $1,1
mov $2,$0
mov $3,$0
lpb $2
mov $0,$3
sub $2,1
sub $0,$2
seq $0,16295 ; Expansion of 1/((1-2x)(1-5x)(1-6x)).
mul $1,4
add $1,$0
lpe
mov $0,$1
|
src/notify.adb | VitalijBondarenko/notifyada | 0 | 27723 | ------------------------------------------------------------------------------
-- --
-- Copyright (c) 2014-2021 <NAME> <<EMAIL>> --
-- --
------------------------------------------------------------------------------
-- --
-- The MIT License (MIT) --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, sublicense, and/or sell copies of the Software, and to --
-- permit persons to whom the Software is furnished to do so, subject to --
-- the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY --
-- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, --
-- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE --
-- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
------------------------------------------------------------------------------
with Interfaces.C.Strings; use Interfaces.C.Strings;
with System; use System;
package body Notify is
-----------------
-- Notify_Init --
-----------------
function Notify_Init (App_Name : UTF8_String) return Boolean is
function Internal (App_Name : chars_ptr) return Gboolean;
pragma Import (C, Internal, "notify_init");
begin
return 0 /= Internal (New_String (App_Name));
end Notify_Init;
-----------------
-- Notify_Init --
-----------------
procedure Notify_Init (App_Name : UTF8_String) is
Success : Boolean;
begin
Success := Notify_Init (App_Name);
end Notify_Init;
-------------------
-- Notify_Uninit --
-------------------
procedure Notify_Uninit is
procedure Internal;
pragma Import (C, Internal, "notify_uninit");
begin
Internal;
end Notify_Uninit;
-----------------------
-- Notify_Is_Initted --
-----------------------
function Notify_Is_Initted return Boolean is
function Internal return Gboolean;
pragma Import (C, Internal, "notify_is_initted");
begin
return 0 /= Internal;
end Notify_Is_Initted;
-------------------------
-- Notify_Get_App_Name --
-------------------------
function Notify_Get_App_Name return UTF8_String is
function Internal return chars_ptr;
pragma Import (C, Internal, "notify_get_app_name");
Name : chars_ptr := Internal;
begin
if Name = Null_Ptr then
return "";
else
declare N : UTF8_String := Value (Name);
begin
Free (Name);
return N;
end;
end if;
end Notify_Get_App_Name;
-------------------------
-- Notify_Set_App_Name --
-------------------------
procedure Notify_Set_App_Name (App_Name : UTF8_String) is
procedure Internal (App_Name : chars_ptr);
pragma Import (C, Internal, "notify_set_app_name");
begin
Internal (New_String (App_Name));
end Notify_Set_App_Name;
----------------------------
-- Notify_Get_Server_Caps --
----------------------------
function Notify_Get_Server_Caps return Gtk.Enums.String_List.Glist is
function Internal return System.Address;
pragma Import (C, Internal, "notify_get_server_caps");
List : Gtk.Enums.String_List.Glist;
begin
String_List.Set_Object (List, Internal);
return List;
end Notify_Get_Server_Caps;
----------------------------
-- Notify_Get_Server_Info --
----------------------------
function Notify_Get_Server_Info
(Name : out String_Ptr;
Vendor : out String_Ptr;
Version : out String_Ptr;
Spec_Version : out String_Ptr) return Boolean
is
function Internal
(Name : access chars_ptr;
Vendor : access chars_ptr;
Version : access chars_ptr;
Spec_Version : access chars_ptr) return Gboolean;
pragma Import (C, internal, "notify_get_server_info");
R : Boolean;
N : aliased chars_ptr;
Ven : aliased chars_ptr;
Ver : aliased chars_ptr;
Spec : aliased chars_ptr;
begin
R := 0 /= Internal (N'Access, Ven'Access, Ver'Access, Spec'Access);
if R then
Name := new String'(Value (N));
Vendor := new String'(Value (Ven));
Version := new String'(Value (Ver));
Spec_Version := new String'(Value (Spec));
end if;
return R;
end Notify_Get_Server_Info;
end Notify;
|
source/asis/asis-ada_environments-containers.ads | faelys/gela-asis | 4 | 12838 | ------------------------------------------------------------------------------
-- G E L A A S I S --
-- ASIS implementation for Gela project, a portable Ada compiler --
-- http://gela.ada-ru.org --
-- - - - - - - - - - - - - - - - --
-- --
-- This specification is derived from the Ada Semantic Interface --
-- Specification Standard (ISO/IEC 15291) and ASIS 1999 Issues. --
-- --
-- The copyright notice and the license provisions that follow apply to the --
-- part following the private keyword. --
-- --
-- Read copyright and license at the end of this file --
------------------------------------------------------------------------------
-- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- 9 package Asis.Ada_Environments.Containers
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
package Asis.Ada_Environments.Containers is
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- Asis.Ada_Environments.Containers
--
-- If an Ada implementation supports the notion of a program library or
-- "library" as specified in Subclause 10(2) of the Ada Reference Manual,
-- then an ASIS Context value can be mapped onto one or more implementor
-- libraries represented by Containers.
--
-------------------------------------------------------------------------------
-- 9.1 type Container
-------------------------------------------------------------------------------
--
-- The Container abstraction is a logical collection of compilation units.
-- For example, one container might hold compilation units which include Ada
-- predefined library units, another container might hold implementation-
-- defined packages. Alternatively, there might be 26 containers, each holding
-- compilation units that begin with their respective letter of the alphabet.
-- The point is that no implementation-independent semantics are associated
-- with a container; it is simply a logical collection.
--
-- ASIS implementations shall minimally map the Asis.Context to a list of
-- one ASIS Container whose Name is that of the Asis.Context Name.
-------------------------------------------------------------------------------
type Container is private;
Nil_Container : constant Container;
function "=" (Left : in Container;
Right : in Container)
return Boolean is abstract;
-------------------------------------------------------------------------------
-- 9.2 type Container_List
-------------------------------------------------------------------------------
type Container_List is
array (List_Index range <>) of Container;
-------------------------------------------------------------------------------
-- 9.3 function Defining_Containers
-------------------------------------------------------------------------------
function Defining_Containers (The_Context : in Asis.Context)
return Container_List;
-------------------------------------------------------------------------------
-- The_Context - Specifies the Context to define
--
-- Returns a Container_List value that defines the single environment Context.
-- Each Container will have an Enclosing_Context that Is_Identical to the
-- argument The_Context. The order of Container values in the list is not
-- defined.
--
-- Returns a minimal list of length one if the ASIS Ada implementation does
-- not support the concept of a program library. In this case, the Container
-- will have the same name as the given Context.
--
-- Raises ASIS_Inappropriate_Context if The_Context is not open.
--
-------------------------------------------------------------------------------
-- 9.4 function Enclosing_Context
-------------------------------------------------------------------------------
function Enclosing_Context (The_Container : in Container)
return Asis.Context;
-------------------------------------------------------------------------------
-- The_Container - Specifies the Container to query
--
-- Returns the Context value associated with the Container.
--
-- Returns the Context for which the Container value was originally obtained.
-- Container values obtained through the Defining_Containers query will always
-- remember the Context from which they were defined.
--
-- Because Context is limited private, this function is only intended to be
-- used to supply a Context parameter for other queries.
--
-- Raises ASIS_Inappropriate_Container if the Container is a Nil_Container.
--
-------------------------------------------------------------------------------
-- 9.5 function Library_Unit_Declaration
-------------------------------------------------------------------------------
function Library_Unit_Declarations (The_Container : in Container)
return Asis.Compilation_Unit_List;
-------------------------------------------------------------------------------
-- The_Container - Specifies the Container to query
--
-- Returns a list of all library_unit_declaration and
-- library_unit_renaming_declaration elements contained in the Container.
-- Individual units will appear only once in an order that is not defined.
--
-- A Nil_Compilation_Unit_List is returned if there are no declarations of
-- library units within the Container.
--
-- This query will never return a unit with A_Configuration_Compilation or
-- a Nonexistent unit kind. It will never return a unit with A_Procedure_Body
-- or A_Function_Body unit kind even though the unit is interpreted as both
-- the declaration and body of a library procedure or library function.
-- (Reference Manual 10.1.4(4).
--
-- All units in the result will have an Enclosing_Container value that
-- Is_Identical to the Container.
--
-- Raises ASIS_Inappropriate_Context if the Enclosing_Context(Container)
-- is not open.
--
-------------------------------------------------------------------------------
-- 9.6 function Compilation_Unit_Bodies
-------------------------------------------------------------------------------
function Compilation_Unit_Bodies (The_Container : in Container)
return Asis.Compilation_Unit_List;
-------------------------------------------------------------------------------
-- The_Container - Specifies the Container to query
--
-- Returns a list of all library_unit_body and subunit elements contained in
-- the Container. Individual units will appear only once in an order that is
-- not defined.
--
-- A Nil_Compilation_Unit_List is returned if there are no bodies within the
-- Container.
--
-- This query will never return a unit with A_Configuration_Compilation or
-- a nonexistent unit kind.
--
-- All units in the result will have an Enclosing_Container value that
-- Is_Identical to the Container.
--
-- Raises ASIS_Inappropriate_Context if the Enclosing_Context(Container)
-- is not open.
--
-------------------------------------------------------------------------------
-- 9.7 function Compilation_Units
-------------------------------------------------------------------------------
function Compilation_Units (The_Container : in Container)
return Asis.Compilation_Unit_List;
-------------------------------------------------------------------------------
-- The_Container - Specifies the Container to query
--
-- Returns a list of all compilation units contained in the Container.
-- Individual units will appear only once in an order that is not defined.
--
-- A Nil_Compilation_Unit_List is returned if there are no units within the
-- Container.
--
-- This query will never return a unit with A_Configuration_Compilation or
-- a nonexistent unit kind.
--
-- All units in the result will have an Enclosing_Container value that
-- Is_Identical to the Container.
--
-- Raises ASIS_Inappropriate_Context if the Enclosing_Context(Container)
-- is not open.
--
-------------------------------------------------------------------------------
-- 9.8 function Is_Equal
-------------------------------------------------------------------------------
function Is_Equal (Left : in Container;
Right : in Container) return Boolean;
-------------------------------------------------------------------------------
-- Left - Specifies the first Container
-- Right - Specifies the second Container
--
-- Returns True if Left and Right designate Container values that contain the
-- same set of compilation units. The Container values may have been defined
-- from different Context values.
--
-------------------------------------------------------------------------------
-- 9.9 function Is_Identical
-------------------------------------------------------------------------------
function Is_Identical (Left : in Container;
Right : in Container) return Boolean;
-------------------------------------------------------------------------------
-- Left - Specifies the first Container
-- Right - Specifies the second Container
--
-- Returns True if Is_Equal(Left, Right) and the Container values have been
-- defined from Is_Equal Context values.
--
-------------------------------------------------------------------------------
-- 9.10 function Name
-------------------------------------------------------------------------------
function Name (The_Container : in Container) return Wide_String;
-------------------------------------------------------------------------------
-- The_Container - Specifies the Container to name
--
-- Returns the Name value associated with the Container.
--
-- Returns a null string if the Container is a Nil_Container.
--
-------------------------------------------------------------------------------
private
type Container is record
The_Context : Asis.Context;
end record;
Nil_Container : constant Container := (The_Context => Asis.Nil_Context);
end Asis.Ada_Environments.Containers;
------------------------------------------------------------------------------
-- Copyright (c) 2006-2013, <NAME>
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- * Redistributions of source code must retain the above copyright notice,
-- this list of conditions and the following disclaimer.
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- * Neither the name of the <NAME>, 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 OWNER OR CONTRIBUTORS BE
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
|
llvm-gcc-4.2-2.9/gcc/ada/a-dirval-mingw.adb | vidkidz/crossbridge | 1 | 19685 | <gh_stars>1-10
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . D I R E C T O R I E S . V A L I D I T Y --
-- --
-- B o d y --
-- (Windows Version) --
-- --
-- Copyright (C) 2004-2005, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This is the Windows version of this package
with Ada.Characters.Latin_1; use Ada.Characters.Latin_1;
package body Ada.Directories.Validity is
Invalid_Character : constant array (Character) of Boolean :=
(NUL .. US | '\' => True,
'/' | ':' | '*' | '?' => True,
'"' | '<' | '>' | '|' => True,
DEL .. NBSP => True,
others => False);
---------------------------------
-- Is_Path_Name_Case_Sensitive --
---------------------------------
function Is_Path_Name_Case_Sensitive return Boolean is
begin
return False;
end Is_Path_Name_Case_Sensitive;
------------------------
-- Is_Valid_Path_Name --
------------------------
function Is_Valid_Path_Name (Name : String) return Boolean is
Start : Positive := Name'First;
Last : Natural;
begin
-- A path name cannot be empty, cannot contain more than 256 characters,
-- cannot contain invalid characters and each directory/file name need
-- to be valid.
if Name'Length = 0 or else Name'Length > 256 then
return False;
else
-- A drive letter may be specified at the beginning
if Name'Length >= 2
and then Name (Start + 1) = ':'
and then
(Name (Start) in 'A' .. 'Z' or else
Name (Start) in 'a' .. 'z')
then
Start := Start + 2;
end if;
loop
-- Look for the start of the next directory or file name
while Start <= Name'Last and then
(Name (Start) = '\' or Name (Start) = '/')
loop
Start := Start + 1;
end loop;
-- If all directories/file names are OK, return True
exit when Start > Name'Last;
Last := Start;
-- Look for the end of the directory/file name
while Last < Name'Last loop
exit when Name (Last + 1) = '\' or Name (Last + 1) = '/';
Last := Last + 1;
end loop;
-- Check if the directory/file name is valid
if not Is_Valid_Simple_Name (Name (Start .. Last)) then
return False;
end if;
-- Move to the next name
Start := Last + 1;
end loop;
end if;
-- If Name follows the rules, it is valid
return True;
end Is_Valid_Path_Name;
--------------------------
-- Is_Valid_Simple_Name --
--------------------------
function Is_Valid_Simple_Name (Name : String) return Boolean is
Only_Spaces : Boolean;
begin
-- A file name cannot be empty, cannot contain more than 256 characters,
-- and cannot contain invalid characters.
if Name'Length = 0 or else Name'Length > 256 then
return False;
-- Name length is OK
else
Only_Spaces := True;
for J in Name'Range loop
if Invalid_Character (Name (J)) then
return False;
elsif Name (J) /= ' ' then
Only_Spaces := False;
end if;
end loop;
-- If no invalid chars, and not all spaces, file name is valid
return not Only_Spaces;
end if;
end Is_Valid_Simple_Name;
-------------
-- OpenVMS --
-------------
function OpenVMS return Boolean is
begin
return False;
end OpenVMS;
end Ada.Directories.Validity;
|
src/Similarity/General.agda | nad/up-to | 0 | 16194 | <gh_stars>0
------------------------------------------------------------------------
-- A parametrised coinductive definition that can be used to define
-- various forms of similarity
------------------------------------------------------------------------
{-# OPTIONS --sized-types #-}
open import Prelude
open import Labelled-transition-system
module Similarity.General
{ℓ}
(lts : LTS ℓ)
(open LTS lts)
(_[_]↝_ : Proc → Label → Proc → Type ℓ)
(⟶→↝ : ∀ {p μ q} → p [ μ ]⟶ q → p [ μ ]↝ q)
where
open import Equality.Propositional as Eq hiding (Extensionality)
open import Prelude.Size
open import Bijection equality-with-J using (_↔_)
open import Function-universe equality-with-J hiding (id; _∘_)
open import Indexed-container hiding (⟨_⟩)
open import Relation
open import Similarity.Step lts _[_]↝_ as Step public
using (StepC)
open Indexed-container public using (force)
open StepC public using (⟨_⟩; challenge)
-- Similarity. Note that this definition is small.
infix 4 _≤_ _≤′_ [_]_≤_ [_]_≤′_
Similarity : Size → Rel₂ ℓ Proc
Similarity i = ν StepC i
Similarity′ : Size → Rel₂ ℓ Proc
Similarity′ i = ν′ StepC i
[_]_≤_ : Size → Proc → Proc → Type ℓ
[_]_≤_ i = curry (Similarity i)
[_]_≤′_ : Size → Proc → Proc → Type ℓ
[_]_≤′_ i = curry (Similarity′ i)
_≤_ : Proc → Proc → Type ℓ
_≤_ = [ ∞ ]_≤_
_≤′_ : Proc → Proc → Type ℓ
_≤′_ = [ ∞ ]_≤′_
-- Similarity is reflexive.
mutual
reflexive-≤ : ∀ {p i} → [ i ] p ≤ p
reflexive-≤ =
StepC.⟨ (λ p⟶p′ → _ , ⟶→↝ p⟶p′ , reflexive-≤′)
⟩
reflexive-≤′ : ∀ {p i} → [ i ] p ≤′ p
force reflexive-≤′ = reflexive-≤
≡⇒≤ : ∀ {p q} → p ≡ q → p ≤ q
≡⇒≤ refl = reflexive-≤
-- Functions that can be used to aid the instance resolution
-- mechanism.
infix -2 ≤:_ ≤′:_
≤:_ : ∀ {i p q} → [ i ] p ≤ q → [ i ] p ≤ q
≤:_ = id
≤′:_ : ∀ {i p q} → [ i ] p ≤′ q → [ i ] p ≤′ q
≤′:_ = id
-- Bisimilarity of similarity proofs.
infix 4 [_]_≡_ [_]_≡′_
[_]_≡_ : ∀ {p q} → Size → (_ _ : ν StepC ∞ (p , q)) → Type ℓ
[_]_≡_ i = curry (ν-bisimilar i)
[_]_≡′_ : ∀ {p q} → Size → (_ _ : ν′ StepC ∞ (p , q)) → Type ℓ
[_]_≡′_ i = curry (ν′-bisimilar i)
-- An alternative characterisation of bisimilarity of similarity
-- proofs.
[]≡↔ :
Eq.Extensionality ℓ ℓ →
∀ {p q} {i : Size} (p≤q₁ p≤q₂ : ν StepC ∞ (p , q)) →
[ i ] p≤q₁ ≡ p≤q₂
↔
(∀ {p′ μ} (p⟶p′ : p [ μ ]⟶ p′) →
let q′₁ , q⟶q′₁ , p′≤q′₁ = StepC.challenge p≤q₁ p⟶p′
q′₂ , q⟶q′₂ , p′≤q′₂ = StepC.challenge p≤q₂ p⟶p′
in ∃ λ (q′₁≡q′₂ : q′₁ ≡ q′₂) →
subst (q [ μ ]↝_) q′₁≡q′₂ q⟶q′₁ ≡ q⟶q′₂
×
[ i ] subst (ν′ StepC ∞ ∘ (p′ ,_)) q′₁≡q′₂ p′≤q′₁ ≡′ p′≤q′₂)
[]≡↔ ext {p} {q} {i} p≤q₁@(s₁ , f₁) p≤q₂@(s₂ , f₂) =
[ i ] p≤q₁ ≡ p≤q₂ ↝⟨ ν-bisimilar↔ ext (s₁ , f₁) (s₂ , f₂) ⟩
(∃ λ (eq : s₁ ≡ s₂) →
∀ {o} (p : Container.Position StepC s₁ o) →
[ i ] f₁ p ≡′ f₂ (subst (λ s → Container.Position StepC s o) eq p)) ↝⟨ Step.⟦StepC⟧₂↔ ext (ν′-bisimilar i) p≤q₁ p≤q₂ ⟩□
(∀ {p′ μ} (p⟶p′ : p [ μ ]⟶ p′) →
let q′₁ , q⟶q′₁ , p′≤q′₁ = StepC.challenge p≤q₁ p⟶p′
q′₂ , q⟶q′₂ , p′≤q′₂ = StepC.challenge p≤q₂ p⟶p′
in ∃ λ (q′₁≡q′₂ : q′₁ ≡ q′₂) →
subst (q [ μ ]↝_) q′₁≡q′₂ q⟶q′₁ ≡ q⟶q′₂
×
[ i ] subst (ν′ StepC ∞ ∘ (p′ ,_)) q′₁≡q′₂ p′≤q′₁ ≡′ p′≤q′₂) □
-- A statement of extensionality for similarity.
Extensionality : Type ℓ
Extensionality = ν′-extensionality StepC
-- This form of extensionality can be used to derive another form (in
-- the presence of extensionality for functions).
extensionality :
Eq.Extensionality ℓ ℓ →
Extensionality →
∀ {p q} {p≤q₁ p≤q₂ : ν StepC ∞ (p , q)} →
[ ∞ ] p≤q₁ ≡ p≤q₂ → p≤q₁ ≡ p≤q₂
extensionality ext ν-ext = ν-extensionality ext ν-ext
|
Library/Text/TextLine/tlLargeDraw.asm | steakknife/pcgeos | 504 | 171817 | <gh_stars>100-1000
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) GeoWorks 1991 -- All Rights Reserved
PROJECT: PC GEOS
MODULE:
FILE: tlLargeDraw.asm
AUTHOR: <NAME>, Dec 26, 1991
ROUTINES:
Name Description
---- -----------
REVISION HISTORY:
Name Date Description
---- ---- -----------
John 12/26/91 Initial revision
DESCRIPTION:
Drawing related code for large text objects.
$Id: tlLargeDraw.asm,v 1.1 97/04/07 11:20:48 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
TextDrawCode segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
LargeLineDraw
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Draw a line of text
CALLED BY: TL_LineDraw via CallLineHandler
PASS: *ds:si = Instance ptr
bx.cx = Line to draw
ax = TextClearBehindFlags
ss:bp = LICL_vars
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
If the TCBF_PRINT bit is *clear* (not printing) then line is
marked as no longer needing to be drawn
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jcw 12/26/91 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
LargeLineDraw proc near
uses ax, bx, cx, dx, di, es, bp
params local CommonDrawParameters
ForceRef params
.enter
call LargeLineCommonDrawSetup
;
; *ds:si= Instance ptr
; es:di = Line
; cx = Size of line/field data
; ss:bp = CommonDrawParameters
; ax = TextClearBehindFlags
;
call CommonLineDraw
call LargeReleaseLineBlock ; Release the line block
.leave
ret
LargeLineDraw endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
LargeLineCommonDrawSetup
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Do common setup for LargeLineDraw and LargeLineDrawBreakIfAny
CALLED BY: LargeLineDraw, LargeLineDrawBreakIfAny
PASS: *ds:si = Instance
ss:bp = Inheritable CommonDrawParameters
RETURN: es:di = Line
cx = Size of line/field data
CommonDrawParameters filled in
DESTROYED: dx
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jcw 5/21/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
LargeLineCommonDrawSetup proc near
uses ax
params local CommonDrawParameters
.enter inherit
mov ax, ss:[bp] ; ax <- LICL_vars
mov params.CDP_liclVars, ax ; Save it for later
pushdw bxcx ; Save line
mov di, cx ; bx.di <- line
call TR_RegionFromLine ; cx <- region
mov params.CDP_region, cx
;
; We need to get the left/top position of the line.
;
mov cx, di ; bx.cx <- line (again)
call LargeLineGetTopLeftAndStart
;
; dx.bl = Top edge
; ax = Left edge
; di.cx = Start of line
;
; Set the positions to draw at in the parameter block
;
mov params.CDP_drawPos.PWBF_x.WBF_int, ax
mov params.CDP_drawPos.PWBF_x.WBF_frac, 0
movwbf params.CDP_drawPos.PWBF_y, dxbl
movdw params.CDP_lineStart, dicx
popdw bxdi ; bx.di <- line
call LargeGetLinePointer ; es:di <- ptr to element
; cx <- size of line/field data
.leave
ret
LargeLineCommonDrawSetup endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
LargeLineDrawLastNChars
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Draw last <dx> characters of a line of text
CALLED BY: TL_LineDrawLastNChars via CallLineHandler
PASS: *ds:si = Instance ptr
ss:bp = LICL_vars
ss:bx = LICL_vars w/ these set:
LICL_firstLine*
LICL_region
cx = Number of characters to draw at end
ax = TextClearBehindFlags
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
If the TCBF_PRINT bit is *clear* (not printing) then line is
marked as no longer needing to be drawn
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jcw 12/26/91 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
LargeLineDrawLastNChars proc near
uses cx, dx, di, bp, es
params local CommonDrawParameters
.enter
ForceRef params
mov dx, cx ; dx <- # of characters to draw
push bx ; Save frame ptr
mov di, ss:[bx].LICL_firstLine.low ; bx.di <- line to draw
mov bx, ss:[bx].LICL_firstLine.high
call LargeGetLinePointer ; es:di <- ptr to line
; cx <- size of line/field data
pop bx ; Restore frame ptr
;
; es:di = Line
; cx = Size of line data
; dx = Number of characters to draw
; ss:bx = LICL_vars
;
; Initialize the CommonDrawParameters from the LICL_vars.
; We need to set:
; Y pos = Top edge
; X pos = Left edge
; Line start
;
call CommonDrawLastNCharsSetup
;
; *ds:si= Instance ptr
; es:di = Line
; cx = Size of line/field data
; ss:bp = CommonDrawParameters
; dx = Number of chars to draw
;
call CommonLineDrawLastNChars ; Do the drawing
call LargeReleaseLineBlock ; Release the line block
.leave
ret
LargeLineDrawLastNChars endp
TextDrawCode ends
|
programs/oeis/008/A008233.asm | karttu/loda | 0 | 90011 | ; A008233: a(n) = floor(n/4)*floor((n+1)/4)*floor((n+2)/4)*floor((n+3)/4).
; 0,0,0,0,1,2,4,8,16,24,36,54,81,108,144,192,256,320,400,500,625,750,900,1080,1296,1512,1764,2058,2401,2744,3136,3584,4096,4608,5184,5832,6561,7290,8100,9000,10000,11000,12100,13310,14641,15972,17424,19008,20736,22464,24336,26364,28561,30758,33124,35672,38416,41160,44100,47250,50625,54000,57600,61440,65536,69632,73984,78608,83521,88434,93636,99144,104976,110808,116964,123462,130321,137180,144400,152000,160000,168000,176400,185220,194481,203742,213444,223608,234256,244904,256036,267674,279841,292008,304704,317952,331776,345600,360000,375000,390625,406250,422500,439400,456976,474552,492804,511758,531441,551124,571536,592704,614656,636608,659344,682892,707281,731670,756900,783000,810000,837000,864900,893730,923521,953312,984064,1015808,1048576,1081344,1115136,1149984,1185921,1221858,1258884,1297032,1336336,1375640,1416100,1457750,1500625,1543500,1587600,1632960,1679616,1726272,1774224,1823508,1874161,1924814,1976836,2030264,2085136,2140008,2196324,2254122,2313441,2372760,2433600,2496000,2560000,2624000,2689600,2756840,2825761,2894682,2965284,3037608,3111696,3185784,3261636,3339294,3418801,3498308,3579664,3662912,3748096,3833280,3920400,4009500,4100625,4191750,4284900,4380120,4477456,4574792,4674244,4775858,4879681,4983504,5089536,5197824,5308416,5419008,5531904,5647152,5764801,5882450,6002500,6125000,6250000,6375000,6502500,6632550,6765201,6897852,7033104,7171008,7311616,7452224,7595536,7741604,7890481,8039358,8191044,8345592,8503056,8660520,8820900,8984250,9150625,9317000,9486400,9658880,9834496,10010112,10188864,10370808,10556001,10741194,10929636,11121384,11316496,11511608,11710084,11911982,12117361,12322740,12531600,12744000,12960000,13176000,13395600,13618860,13845841,14072822,14303524,14538008,14776336,15014664
mov $14,$0
mov $16,$0
lpb $16,1
clr $0,14
mov $0,$14
sub $16,1
sub $0,$16
mov $13,$0
lpb $13,1
mov $0,$11
sub $13,1
sub $0,$13
mov $7,$0
mov $9,2
lpb $9,1
clr $0,7
mov $0,$7
sub $9,1
add $0,$9
sub $0,1
add $3,$0
div $3,2
sub $0,$3
div $0,2
pow $3,2
div $3,2
add $4,$3
add $1,$4
add $5,$0
mul $5,$1
mov $1,$5
mov $10,$9
lpb $10,1
mov $8,$1
sub $10,1
lpe
lpe
lpb $7,1
mov $7,0
sub $8,$1
lpe
mov $1,$8
div $1,2
add $12,$1
lpe
add $15,$12
lpe
mov $1,$15
|
projects/batfish/src/main/antlr4/org/batfish/grammar/arista/Arista_common.g4 | jeffkala/batfish | 0 | 1946 | <filename>projects/batfish/src/main/antlr4/org/batfish/grammar/arista/Arista_common.g4
parser grammar Arista_common;
options {
tokenVocab = AristaLexer;
}
bgp_local_pref
:
// full range of values: 0-4294967295
p = uint32
;
interface_address
:
ip = IP_ADDRESS subnet = IP_ADDRESS
| prefix = IP_PREFIX
;
ip_prefix
:
address = IP_ADDRESS mask = IP_ADDRESS
| prefix = IP_PREFIX
;
ipv6_prefix
:
prefix = IPV6_PREFIX
;
ospf_area
:
id_ip = IP_ADDRESS
| id = uint32
;
port_number
:
// 1-65535
uint16
;
protocol_distance:
// 1-255
uint8
;
uint8: UINT8;
uint16: UINT8 | UINT16;
uint32: UINT8 | UINT16 | UINT32;
// TODO: delete all uses of dec, replace with named rules that have a toInt/LongInSpace function
dec: UINT8 | UINT16 | UINT32 | DEC;
vrf_name
:
//1-100 characters
WORD
;
word
:
WORD
;
vni_number
:
// 0-16777214
uint32
;
vlan_id
:
// 1-4094
uint16
;
vlan_range
:
(
vlan_range_list += vlan_subrange
(
COMMA vlan_range_list += vlan_subrange
)*
)
| NONE
;
vlan_subrange
:
low = vlan_id
(
DASH high = vlan_id
)?
;
vni_range
:
(
vni_range_list += vni_subrange
(
COMMA vni_range_list += vni_subrange
)*
)
;
vni_subrange
:
low = vni_number
(
DASH high = vni_number
)?
; |
windowResizeHeightMinus.applescript | rcmdnk/AppleScript | 11 | 1965 | <reponame>rcmdnk/AppleScript<filename>windowResizeHeightMinus.applescript<gh_stars>10-100
set scriptPath to ((path to me as text) & "::")
set windowResizeScpt to scriptPath & "windowResize.scpt"
set windowResize to load script file windowResizeScpt
windowResize's windowResize(0, -1)
|
libsrc/_DEVELOPMENT/arch/zx/ulaplus/c/sdcc/ulap_attr_from_pentp_penti.asm | jpoikela/z88dk | 640 | 3894 | ; unsigned char ulap_attr_from_pentp_penti(unsigned char pentp,unsigned char penti)
SECTION code_clib
SECTION code_arch
PUBLIC _ulap_attr_from_pentp_penti
EXTERN asm_ulap_attr_from_pentp_penti
_ulap_attr_from_pentp_penti:
pop af
pop hl
push hl
push af
jp asm_ulap_attr_from_pentp_penti
|
Transynther/x86/_processed/AVXALIGN/_ht_zr_/i7-8650U_0xd2_notsx.log_899_519.asm | ljhsiun2/medusa | 9 | 21023 | <filename>Transynther/x86/_processed/AVXALIGN/_ht_zr_/i7-8650U_0xd2_notsx.log_899_519.asm<gh_stars>1-10
.global s_prepare_buffers
s_prepare_buffers:
push %r15
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_WT_ht+0x10d76, %rsi
lea addresses_normal_ht+0x4c0f, %rdi
nop
nop
nop
nop
nop
sub $28197, %r15
mov $23, %rcx
rep movsl
nop
nop
nop
nop
nop
cmp $47487, %rbp
lea addresses_normal_ht+0x1b22f, %rsi
lea addresses_A_ht+0x16248, %rdi
nop
nop
nop
nop
xor $53218, %r15
mov $42, %rcx
rep movsl
nop
nop
inc %r15
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %r15
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r12
push %r13
push %r15
push %r8
push %rax
// Faulty Load
lea addresses_PSE+0x9def, %rax
nop
nop
nop
add $5015, %r11
movaps (%rax), %xmm1
vpextrq $1, %xmm1, %r12
lea oracles, %r15
and $0xff, %r12
shlq $12, %r12
mov (%r15,%r12,1), %r12
pop %rax
pop %r8
pop %r15
pop %r13
pop %r12
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_PSE', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_PSE', 'size': 16, 'AVXalign': True, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 5, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 0, 'same': False}}
{'49': 559, '44': 319, '00': 21}
49 49 44 49 49 49 49 49 44 49 49 49 49 49 44 49 44 00 49 49 44 44 49 44 49 49 49 44 49 49 44 44 49 49 49 49 44 49 49 49 49 44 49 49 00 44 49 49 49 49 49 49 49 49 49 44 49 49 49 44 49 49 49 49 49 49 49 49 44 49 49 49 49 49 49 44 44 49 44 49 49 49 49 44 49 49 49 49 49 49 49 49 49 44 49 49 44 49 44 44 44 49 49 49 49 49 44 49 49 44 49 49 49 49 00 44 49 44 49 44 00 44 49 00 49 49 49 49 49 49 44 49 49 44 49 44 49 49 49 44 44 49 49 49 49 49 49 44 49 49 44 44 49 49 49 44 44 49 49 49 44 44 49 44 49 49 49 49 49 49 44 49 49 49 44 49 00 49 44 44 44 44 44 49 49 49 49 00 44 49 44 49 44 49 44 49 44 44 49 49 49 49 49 44 44 49 44 49 49 49 49 44 00 49 44 49 44 44 49 49 44 49 49 49 44 44 49 49 49 44 49 49 44 44 49 44 44 49 44 49 49 49 44 49 49 49 49 49 44 49 49 44 49 49 49 49 49 49 44 44 49 44 44 49 44 49 49 44 49 49 49 49 49 49 44 49 44 49 49 44 44 49 49 44 44 44 49 44 49 44 49 49 44 49 44 44 49 49 44 44 44 44 49 44 44 49 49 49 44 49 49 49 49 49 49 49 44 44 44 49 49 44 44 44 49 49 49 49 49 49 49 49 44 49 44 49 44 49 49 49 49 49 44 49 44 49 49 49 44 44 49 49 49 44 44 49 49 49 49 49 44 49 49 49 44 49 49 44 44 44 44 49 49 44 44 49 44 49 44 49 44 44 00 49 49 49 49 49 49 44 44 00 44 44 49 49 49 44 49 49 44 44 49 44 49 49 49 44 44 49 49 49 49 49 49 44 49 00 49 49 49 44 44 49 49 49 49 49 49 44 44 49 49 44 44 44 44 49 49 49 44 49 44 49 44 49 44 44 49 00 44 49 44 49 44 49 44 49 44 49 44 44 49 44 49 44 49 49 44 44 49 49 44 49 44 49 44 49 49 49 00 49 44 44 49 44 49 49 49 44 49 49 49 49 44 49 49 44 49 49 49 44 44 49 44 49 44 44 44 49 44 49 49 49 49 49 49 49 49 49 49 49 49 49 44 44 44 49 49 49 49 44 44 44 49 49 49 49 49 49 44 49 44 49 44 49 44 49 44 49 49 44 44 44 49 49 49 00 49 49 49 49 49 44 49 49 49 44 49 44 44 49 49 44 49 49 49 49 49 49 44 44 00 49 44 49 44 49 44 49 44 49 44 49 44 44 49 49 49 49 49 44 44 49 49 44 49 49 49 49 44 49 49 49 44 49 44 44 49 44 49 49 49 44 49 44 49 44 49 49 49 49 49 49 44 44 49 49 49 49 49 49 49 49 44 49 44 44 49 49 44 44 44 44 49 44 49 49 44 49 44 44 44 49 49 49 44 44 44 49 44 44 49 44 49 49 49 49 44 44 49 44 49 44 44 44 49 49 49 44 49 00 44 49 49 49 49 44 49 49 44 49 44 49 49 49 49 49 49 44 44 49 44 49 49 49 49 49 49 49 44 49 49 49 44 49 49 44 49 49 49 44 49 49 49 44 49 44 49 49 44 00 49 44 49 49 44 44 44 44 49 44 44 49 49 44 44 49 49 49 44 49 44 00 49 49 44 44 44 49 49 49 49 44 49 49 44 49 49 44 44 49 44 49 49 49 49 44 00 44 44 44 49 49 44 49 44 49 49 49 49 49 44 44 44 49 49 49 49 44 49 44 49 49 49 49 44 49 44 49 49 49 44 44 49 44 49 49 49 49 49 49 44 49 49 49 49 49 44 49 49 44 49 49 49 49 44 44 49 44 49 49 49 49 49 49 44 49 44 00 49 49 44 44 00 49 49 44 49 44 44 44 49 49 49 49 44 44 49 49 44 49 49 49 44 44 49 49 44 49 49 44 44 49 49 44 44 44 49
*/
|
source/containers/a-cbtrsi.ads | ytomino/drake | 33 | 567 | <filename>source/containers/a-cbtrsi.ads<gh_stars>10-100
pragma License (Unrestricted);
-- implementation unit
package Ada.Containers.Binary_Trees.Simple is
pragma Preelaborate;
Node_Size : constant := Standard'Address_Size * 3;
type Node is new Binary_Trees.Node;
for Node'Size use Node_Size;
procedure Insert (
Container : in out Node_Access;
Length : in out Count_Type;
Before : Node_Access;
New_Item : not null Node_Access);
procedure Remove (
Container : in out Node_Access;
Length : in out Count_Type;
Position : not null Node_Access);
procedure Copy (
Target : out Node_Access;
Length : out Count_Type;
Source : Node_Access;
Copy : not null access procedure (
Target : out Node_Access;
Source : not null Node_Access));
-- set operations
procedure Merge is
new Binary_Trees.Merge (Insert => Insert, Remove => Remove);
procedure Copying_Merge is
new Binary_Trees.Copying_Merge (Insert => Insert);
end Ada.Containers.Binary_Trees.Simple;
|
oeis/016/A016298.asm | neoneye/loda-programs | 11 | 89182 | ; A016298: Expansion of 1/((1-2x)(1-5x)(1-9x)).
; Submitted by <NAME>
; 1,16,183,1850,17681,164316,1504843,13673710,123714261,1116683216,10066424303,90679197570,816519676441,7350711587716,66166576804563,595550053849430,5360204797752221,48243114745437816
mov $1,1
mov $3,2
lpb $0
sub $0,1
mul $1,5
div $3,2
mul $3,9
add $3,2
sub $3,$2
add $1,$3
mul $2,2
sub $2,2
mul $3,2
lpe
mov $0,$1
|
Applications/Finder/open/open (path to home folder).applescript | looking-for-a-job/applescript-examples | 1 | 3717 | <filename>Applications/Finder/open/open (path to home folder).applescript<gh_stars>1-10
#!/usr/bin/osascript
tell application "Finder"
open (path to home folder)
activate
end tell |
gramaticaSin.g4 | adgaol/PruebaANTLRDesc | 0 | 3287 | <reponame>adgaol/PruebaANTLRDesc
grammar gramaticaSin;
exp returns [Integer expO]
:{
//Node node=writer.addPasoNoTerminalDes("EXP", expO, false, null, null, false, null, null);
}
bO=b[true] aO=a[((ExpContext)_localctx).bO.bO,true,false] PuntoComa {
//writer.updateNoTerminals("EXP::= B A ;", ((ExpContext)_localctx).aO.aO.getValue(), expO, ((ExpContext)_localctx).bO.bO);
System.out.println(((ExpContext)_localctx).aO.aO);
_localctx.expO=((ExpContext)_localctx).aO.aO;
//writer.writeXML();
}
;
a [Integer her,Boolean haveBrother,Boolean a1] returns [Integer aO]
:{
//Node node=writer.addPasoNoTerminalDes("A", aO, haveBrother, her.toString(), nodeAnt, a1, "valor", "result");
}
Mas bO=b[true] aeO=a[((AContext)_localctx).bO.bO + her,false,true] {
// writer.updateNoTerminals("A::= + B A1", ((AContext)_localctx).aeO.aO.getValue(), aO, ((AContext)_localctx).masO.m);
_localctx.aO=((AContext)_localctx).aeO.aO;
}
|
{
//writer.addPasoLambdaDes("A", "valor", "result", her.toString(), aO, haveBrother, nodeAnt, a1);
_localctx.aO=her;
}
;
b [Boolean haveBrother] returns [Integer bO]
:{
//Node node=writer.addPasoNoTerminalDes("B", bO, haveBrother, null, nodeAnt, false, null, "result");
}
numO=Number cO=c[ Integer.parseInt(((BContext)_localctx).numO.getText()),false,false] {
//writer.updateNoTerminals("B::= num C", ((BContext)_localctx).cO.cO.getValue(), bO, ((BContext)_localctx).numO.numO);
_localctx.bO=((BContext)_localctx).cO.cO;}
;
c [Integer her,Boolean haveBrother,Boolean c1] returns [Integer cO]
:{
//Node node=writer.addPasoNoTerminalDes("C", cO, haveBrother, her.toString(), nodeAnt, c1, "valor", "result");
}
Por numO=Number ceO=c[her*Integer.parseInt(((CContext)_localctx).numO.getText()),false,true] {
//writer.updateNoTerminals("C::= * num C1", ((CContext)_localctx).ceO.cO.getValue(), cO, ((CContext)_localctx).porO.pr);
_localctx.cO=((CContext)_localctx).ceO.cO;}
|{
//writer.addPasoLambdaDes("C", "valor", "result", her.toString(), cO, haveBrother, nodeAnt, c1);
_localctx.cO=her;}
;
Number
: ('0'..'9')+ {
}
;
Por
: '*'{
}
;
Mas
: '+'{
}
;
PuntoComa
: ';'{
}
; |
test/Fail/ModuleArityMismatchEmptyTel.agda | cruhland/agda | 1,989 | 1669 | <filename>test/Fail/ModuleArityMismatchEmptyTel.agda
-- Andreas, 2015-12-01, test case to trigger error ModuleArityMismatch EmptyTel
module _ where
module M where
module M′ = M Set
|
Application Support/BBEdit/AppleScript/Copy Line Down.applescript | bhdicaire/bbeditSetup | 0 | 304 | <filename>Application Support/BBEdit/AppleScript/Copy Line Down.applescript
# Copies selected lines down and moves selection to the new lines.
tell application "BBEdit"
set start_line to startLine of selection
set end_line to endLine of selection
tell window 1
set line_data to contents of lines start_line thru end_line
set copy_offset to length of line_data
try
set testChar to last character of line_data
on error
set testChar to ""
end try
if (linefeed ≠ testChar) then
make new line at line end_line
end if
select insertion point before line (end_line + 1)
set selection to line_data
end tell
end tell |
test/Fail/Issue4189.agda | shlevy/agda | 1,989 | 5082 | -- Andreas, 2019-11-11, issue #4189, reported by nad.
-- Record constructors living in the record module are problematic
-- as the record module is parameterized over the record value,
-- but the constructor not.
-- Thus, a record constructor does not live in the record module
-- any more.
-- {-# OPTIONS -v tc.mod.apply:100 #-}
record ⊤ : Set where
constructor tt
module Unit = ⊤ renaming (tt to unit)
-- WAS: internal error
-- NOW: warning about tt not being in scope
tt′ : ⊤
tt′ = ⊤.tt
-- WAS: success
-- NOW: Not in scope: ⊤.tt
|
experiments/test-suite/mutation-based/20/2/sll.als | kaiyuanw/AlloyFLCore | 1 | 1613 | pred test4 {
some disj List0: List {some disj Node0, Node1, Node2: Node {
List = List0
header = List0->Node0 + List0->Node1 + List0->Node2
Node = Node0 + Node1 + Node2
link = Node0->Node2 + Node1->Node1 + Node2->Node0
}}
}
run test4 for 3 expect 0
pred test3 {
some disj Node0: Node {
no List
no header
Node = Node0
no link
}
}
run test3 for 3 expect 1
pred test18 {
some disj List0: List {some disj Node0, Node1, Node2: Node {
List = List0
header = List0->Node2
Node = Node0 + Node1 + Node2
link = Node0->Node2 + Node1->Node1 + Node2->Node0
Acyclic[List0]
}}
}
run test18 for 3 expect 0
pred test8 {
some disj List0, List1: List {some disj Node0, Node1, Node2: Node {
List = List0 + List1
header = List0->Node1 + List1->Node0
Node = Node0 + Node1 + Node2
link = Node2->Node0 + Node2->Node1 + Node2->Node2
}}
}
run test8 for 3 expect 0
|
tools-src/gnu/gcc/gcc/ada/sem_ch10.adb | enfoTek/tomato.linksys.e2000.nvram-mod | 80 | 26112 | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S E M _ C H 1 0 --
-- --
-- B o d y --
-- --
-- $Revision$
-- --
-- Copyright (C) 1992-2001 Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, USA. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Atree; use Atree;
with Debug; use Debug;
with Einfo; use Einfo;
with Errout; use Errout;
with Exp_Util; use Exp_Util;
with Fname; use Fname;
with Fname.UF; use Fname.UF;
with Freeze; use Freeze;
with Impunit; use Impunit;
with Inline; use Inline;
with Lib; use Lib;
with Lib.Load; use Lib.Load;
with Lib.Xref; use Lib.Xref;
with Namet; use Namet;
with Nlists; use Nlists;
with Nmake; use Nmake;
with Opt; use Opt;
with Output; use Output;
with Restrict; use Restrict;
with Sem; use Sem;
with Sem_Ch6; use Sem_Ch6;
with Sem_Ch7; use Sem_Ch7;
with Sem_Ch8; use Sem_Ch8;
with Sem_Dist; use Sem_Dist;
with Sem_Prag; use Sem_Prag;
with Sem_Util; use Sem_Util;
with Sem_Warn; use Sem_Warn;
with Stand; use Stand;
with Sinfo; use Sinfo;
with Sinfo.CN; use Sinfo.CN;
with Sinput; use Sinput;
with Snames; use Snames;
with Style; use Style;
with Tbuild; use Tbuild;
with Ttypes; use Ttypes;
with Uname; use Uname;
package body Sem_Ch10 is
-----------------------
-- Local Subprograms --
-----------------------
procedure Analyze_Context (N : Node_Id);
-- Analyzes items in the context clause of compilation unit
procedure Check_With_Type_Clauses (N : Node_Id);
-- If N is a body, verify that any with_type clauses on the spec, or
-- on the spec of any parent, have a matching with_clause.
procedure Check_Private_Child_Unit (N : Node_Id);
-- If a with_clause mentions a private child unit, the compilation
-- unit must be a member of the same family, as described in 10.1.2 (8).
procedure Check_Stub_Level (N : Node_Id);
-- Verify that a stub is declared immediately within a compilation unit,
-- and not in an inner frame.
procedure Expand_With_Clause (Nam : Node_Id; N : Node_Id);
-- When a child unit appears in a context clause, the implicit withs on
-- parents are made explicit, and with clauses are inserted in the context
-- clause before the one for the child. If a parent in the with_clause
-- is a renaming, the implicit with_clause is on the renaming whose name
-- is mentioned in the with_clause, and not on the package it renames.
-- N is the compilation unit whose list of context items receives the
-- implicit with_clauses.
procedure Implicit_With_On_Parent (Child_Unit : Node_Id; N : Node_Id);
-- If the main unit is a child unit, implicit withs are also added for
-- all its ancestors.
procedure Install_Context_Clauses (N : Node_Id);
-- Subsidiary to previous one. Process only with_ and use_clauses for
-- current unit and its library unit if any.
procedure Install_Withed_Unit (With_Clause : Node_Id);
-- If the unit is not a child unit, make unit immediately visible.
-- The caller ensures that the unit is not already currently installed.
procedure Install_Parents (Lib_Unit : Node_Id; Is_Private : Boolean);
-- This procedure establishes the context for the compilation of a child
-- unit. If Lib_Unit is a child library spec then the context of the parent
-- is installed, and the parent itself made immediately visible, so that
-- the child unit is processed in the declarative region of the parent.
-- Install_Parents makes a recursive call to itself to ensure that all
-- parents are loaded in the nested case. If Lib_Unit is a library body,
-- the only effect of Install_Parents is to install the private decls of
-- the parents, because the visible parent declarations will have been
-- installed as part of the context of the corresponding spec.
procedure Install_Siblings (U_Name : Entity_Id; N : Node_Id);
-- In the compilation of a child unit, a child of any of the ancestor
-- units is directly visible if it is visible, because the parent is in
-- an enclosing scope. Iterate over context to find child units of U_Name
-- or of some ancestor of it.
function Is_Child_Spec (Lib_Unit : Node_Id) return Boolean;
-- Lib_Unit is a library unit which may be a spec or a body. Is_Child_Spec
-- returns True if Lib_Unit is a library spec which is a child spec, i.e.
-- a library spec that has a parent. If the call to Is_Child_Spec returns
-- True, then Parent_Spec (Lib_Unit) is non-Empty and points to the
-- compilation unit for the parent spec.
--
-- Lib_Unit can also be a subprogram body that acts as its own spec. If
-- the Parent_Spec is non-empty, this is also a child unit.
procedure Remove_With_Type_Clause (Name : Node_Id);
-- Remove imported type and its enclosing package from visibility, and
-- remove attributes of imported type so they don't interfere with its
-- analysis (should it appear otherwise in the context).
procedure Remove_Context_Clauses (N : Node_Id);
-- Subsidiary of previous one. Remove use_ and with_clauses.
procedure Remove_Parents (Lib_Unit : Node_Id);
-- Remove_Parents checks if Lib_Unit is a child spec. If so then the parent
-- contexts established by the corresponding call to Install_Parents are
-- removed. Remove_Parents contains a recursive call to itself to ensure
-- that all parents are removed in the nested case.
procedure Remove_Unit_From_Visibility (Unit_Name : Entity_Id);
-- Reset all visibility flags on unit after compiling it, either as a
-- main unit or as a unit in the context.
procedure Analyze_Proper_Body (N : Node_Id; Nam : Entity_Id);
-- Common processing for all stubs (subprograms, tasks, packages, and
-- protected cases). N is the stub to be analyzed. Once the subunit
-- name is established, load and analyze. Nam is the non-overloadable
-- entity for which the proper body provides a completion. Subprogram
-- stubs are handled differently because they can be declarations.
------------------------------
-- Analyze_Compilation_Unit --
------------------------------
procedure Analyze_Compilation_Unit (N : Node_Id) is
Unit_Node : constant Node_Id := Unit (N);
Lib_Unit : Node_Id := Library_Unit (N);
Spec_Id : Node_Id;
Main_Cunit : constant Node_Id := Cunit (Main_Unit);
Par_Spec_Name : Unit_Name_Type;
Unum : Unit_Number_Type;
procedure Generate_Parent_References (N : Node_Id; P_Id : Entity_Id);
-- Generate cross-reference information for the parents of child units.
-- N is a defining_program_unit_name, and P_Id is the immediate parent.
--------------------------------
-- Generate_Parent_References --
--------------------------------
procedure Generate_Parent_References (N : Node_Id; P_Id : Entity_Id) is
Pref : Node_Id;
P_Name : Entity_Id := P_Id;
begin
Pref := Name (Parent (Defining_Entity (N)));
if Nkind (Pref) = N_Expanded_Name then
-- Done already, if the unit has been compiled indirectly as
-- part of the closure of its context because of inlining.
return;
end if;
while Nkind (Pref) = N_Selected_Component loop
Change_Selected_Component_To_Expanded_Name (Pref);
Set_Entity (Pref, P_Name);
Set_Etype (Pref, Etype (P_Name));
Generate_Reference (P_Name, Pref, 'r');
Pref := Prefix (Pref);
P_Name := Scope (P_Name);
end loop;
-- The guard here on P_Name is to handle the error condition where
-- the parent unit is missing because the file was not found.
if Present (P_Name) then
Set_Entity (Pref, P_Name);
Set_Etype (Pref, Etype (P_Name));
Generate_Reference (P_Name, Pref, 'r');
Style.Check_Identifier (Pref, P_Name);
end if;
end Generate_Parent_References;
-- Start of processing for Analyze_Compilation_Unit
begin
Process_Compilation_Unit_Pragmas (N);
-- If the unit is a subunit whose parent has not been analyzed (which
-- indicates that the main unit is a subunit, either the current one or
-- one of its descendents) then the subunit is compiled as part of the
-- analysis of the parent, which we proceed to do. Basically this gets
-- handled from the top down and we don't want to do anything at this
-- level (i.e. this subunit will be handled on the way down from the
-- parent), so at this level we immediately return. If the subunit
-- ends up not analyzed, it means that the parent did not contain a
-- stub for it, or that there errors were dectected in some ancestor.
if Nkind (Unit_Node) = N_Subunit
and then not Analyzed (Lib_Unit)
then
Semantics (Lib_Unit);
if not Analyzed (Proper_Body (Unit_Node)) then
if Errors_Detected > 0 then
Error_Msg_N ("subunit not analyzed (errors in parent unit)", N);
else
Error_Msg_N ("missing stub for subunit", N);
end if;
end if;
return;
end if;
-- Analyze context (this will call Sem recursively for with'ed units)
Analyze_Context (N);
-- If the unit is a package body, the spec is already loaded and must
-- be analyzed first, before we analyze the body.
if Nkind (Unit_Node) = N_Package_Body then
-- If no Lib_Unit, then there was a serious previous error, so
-- just ignore the entire analysis effort
if No (Lib_Unit) then
return;
else
Semantics (Lib_Unit);
Check_Unused_Withs (Get_Cunit_Unit_Number (Lib_Unit));
-- Verify that the library unit is a package declaration.
if Nkind (Unit (Lib_Unit)) /= N_Package_Declaration
and then
Nkind (Unit (Lib_Unit)) /= N_Generic_Package_Declaration
then
Error_Msg_N
("no legal package declaration for package body", N);
return;
-- Otherwise, the entity in the declaration is visible. Update
-- the version to reflect dependence of this body on the spec.
else
Spec_Id := Defining_Entity (Unit (Lib_Unit));
Set_Is_Immediately_Visible (Spec_Id, True);
Version_Update (N, Lib_Unit);
if Nkind (Defining_Unit_Name (Unit_Node))
= N_Defining_Program_Unit_Name
then
Generate_Parent_References (Unit_Node, Scope (Spec_Id));
end if;
end if;
end if;
-- If the unit is a subprogram body, then we similarly need to analyze
-- its spec. However, things are a little simpler in this case, because
-- here, this analysis is done only for error checking and consistency
-- purposes, so there's nothing else to be done.
elsif Nkind (Unit_Node) = N_Subprogram_Body then
if Acts_As_Spec (N) then
-- If the subprogram body is a child unit, we must create a
-- declaration for it, in order to properly load the parent(s).
-- After this, the original unit does not acts as a spec, because
-- there is an explicit one. If this unit appears in a context
-- clause, then an implicit with on the parent will be added when
-- installing the context. If this is the main unit, there is no
-- Unit_Table entry for the declaration, (It has the unit number
-- of the main unit) and code generation is unaffected.
Unum := Get_Cunit_Unit_Number (N);
Par_Spec_Name := Get_Parent_Spec_Name (Unit_Name (Unum));
if Par_Spec_Name /= No_Name then
Unum :=
Load_Unit
(Load_Name => Par_Spec_Name,
Required => True,
Subunit => False,
Error_Node => N);
if Unum /= No_Unit then
-- Build subprogram declaration and attach parent unit to it
-- This subprogram declaration does not come from source!
declare
Loc : constant Source_Ptr := Sloc (N);
SCS : constant Boolean :=
Get_Comes_From_Source_Default;
begin
Set_Comes_From_Source_Default (False);
Lib_Unit :=
Make_Compilation_Unit (Loc,
Context_Items => New_Copy_List (Context_Items (N)),
Unit =>
Make_Subprogram_Declaration (Sloc (N),
Specification =>
Copy_Separate_Tree
(Specification (Unit_Node))),
Aux_Decls_Node =>
Make_Compilation_Unit_Aux (Loc));
Set_Library_Unit (N, Lib_Unit);
Set_Parent_Spec (Unit (Lib_Unit), Cunit (Unum));
Semantics (Lib_Unit);
Set_Acts_As_Spec (N, False);
Set_Comes_From_Source_Default (SCS);
end;
end if;
end if;
-- Here for subprogram with separate declaration
else
Semantics (Lib_Unit);
Check_Unused_Withs (Get_Cunit_Unit_Number (Lib_Unit));
Version_Update (N, Lib_Unit);
end if;
if Nkind (Defining_Unit_Name (Specification (Unit_Node))) =
N_Defining_Program_Unit_Name
then
Generate_Parent_References (
Specification (Unit_Node),
Scope (Defining_Entity (Unit (Lib_Unit))));
end if;
end if;
-- If it is a child unit, the parent must be elaborated first
-- and we update version, since we are dependent on our parent.
if Is_Child_Spec (Unit_Node) then
-- The analysis of the parent is done with style checks off
declare
Save_Style_Check : constant Boolean := Opt.Style_Check;
Save_C_Restrict : constant Save_Compilation_Unit_Restrictions :=
Compilation_Unit_Restrictions_Save;
begin
if not GNAT_Mode then
Style_Check := False;
end if;
Semantics (Parent_Spec (Unit_Node));
Version_Update (N, Parent_Spec (Unit_Node));
Style_Check := Save_Style_Check;
Compilation_Unit_Restrictions_Restore (Save_C_Restrict);
end;
end if;
-- With the analysis done, install the context. Note that we can't
-- install the context from the with clauses as we analyze them,
-- because each with clause must be analyzed in a clean visibility
-- context, so we have to wait and install them all at once.
Install_Context (N);
if Is_Child_Spec (Unit_Node) then
-- Set the entities of all parents in the program_unit_name.
Generate_Parent_References (
Unit_Node, Defining_Entity (Unit (Parent_Spec (Unit_Node))));
end if;
-- All components of the context: with-clauses, library unit, ancestors
-- if any, (and their context) are analyzed and installed. Now analyze
-- the unit itself, which is either a package, subprogram spec or body.
Analyze (Unit_Node);
-- The above call might have made Unit_Node an N_Subprogram_Body
-- from something else, so propagate any Acts_As_Spec flag.
if Nkind (Unit_Node) = N_Subprogram_Body
and then Acts_As_Spec (Unit_Node)
then
Set_Acts_As_Spec (N);
end if;
-- Treat compilation unit pragmas that appear after the library unit
if Present (Pragmas_After (Aux_Decls_Node (N))) then
declare
Prag_Node : Node_Id := First (Pragmas_After (Aux_Decls_Node (N)));
begin
while Present (Prag_Node) loop
Analyze (Prag_Node);
Next (Prag_Node);
end loop;
end;
end if;
-- Generate distribution stub files if requested and no error
if N = Main_Cunit
and then (Distribution_Stub_Mode = Generate_Receiver_Stub_Body
or else
Distribution_Stub_Mode = Generate_Caller_Stub_Body)
and then not Fatal_Error (Main_Unit)
then
if Is_RCI_Pkg_Spec_Or_Body (N) then
-- Regular RCI package
Add_Stub_Constructs (N);
elsif (Nkind (Unit_Node) = N_Package_Declaration
and then Is_Shared_Passive (Defining_Entity
(Specification (Unit_Node))))
or else (Nkind (Unit_Node) = N_Package_Body
and then
Is_Shared_Passive (Corresponding_Spec (Unit_Node)))
then
-- Shared passive package
Add_Stub_Constructs (N);
elsif Nkind (Unit_Node) = N_Package_Instantiation
and then
Is_Remote_Call_Interface
(Defining_Entity (Specification (Instance_Spec (Unit_Node))))
then
-- Instantiation of a RCI generic package
Add_Stub_Constructs (N);
end if;
-- Reanalyze the unit with the new constructs
Analyze (Unit_Node);
end if;
if Nkind (Unit_Node) = N_Package_Declaration
or else Nkind (Unit_Node) in N_Generic_Declaration
or else Nkind (Unit_Node) = N_Package_Renaming_Declaration
or else Nkind (Unit_Node) = N_Subprogram_Declaration
then
Remove_Unit_From_Visibility (Defining_Entity (Unit_Node));
elsif Nkind (Unit_Node) = N_Package_Body
or else (Nkind (Unit_Node) = N_Subprogram_Body
and then not Acts_As_Spec (Unit_Node))
then
-- Bodies that are not the main unit are compiled if they
-- are generic or contain generic or inlined units. Their
-- analysis brings in the context of the corresponding spec
-- (unit declaration) which must be removed as well, to
-- return the compilation environment to its proper state.
Remove_Context (Lib_Unit);
Set_Is_Immediately_Visible (Defining_Entity (Unit (Lib_Unit)), False);
end if;
-- Last step is to deinstall the context we just installed
-- as well as the unit just compiled.
Remove_Context (N);
-- If this is the main unit and we are generating code, we must
-- check that all generic units in the context have a body if they
-- need it, even if they have not been instantiated. In the absence
-- of .ali files for generic units, we must force the load of the body,
-- just to produce the proper error if the body is absent. We skip this
-- verification if the main unit itself is generic.
if Get_Cunit_Unit_Number (N) = Main_Unit
and then Operating_Mode = Generate_Code
and then Expander_Active
then
-- Indicate that the main unit is now analyzed, to catch possible
-- circularities between it and generic bodies. Remove main unit
-- from visibility. This might seem superfluous, but the main unit
-- must not be visible in the generic body expansions that follow.
Set_Analyzed (N, True);
Set_Is_Immediately_Visible (Cunit_Entity (Main_Unit), False);
declare
Item : Node_Id;
Nam : Entity_Id;
Un : Unit_Number_Type;
Save_Style_Check : constant Boolean := Opt.Style_Check;
Save_C_Restrict : constant Save_Compilation_Unit_Restrictions :=
Compilation_Unit_Restrictions_Save;
begin
Item := First (Context_Items (N));
while Present (Item) loop
if Nkind (Item) = N_With_Clause
and then not Implicit_With (Item)
then
Nam := Entity (Name (Item));
if (Ekind (Nam) = E_Generic_Procedure
and then not Is_Intrinsic_Subprogram (Nam))
or else (Ekind (Nam) = E_Generic_Function
and then not Is_Intrinsic_Subprogram (Nam))
or else (Ekind (Nam) = E_Generic_Package
and then Unit_Requires_Body (Nam))
then
Opt.Style_Check := False;
if Present (Renamed_Object (Nam)) then
Un :=
Load_Unit
(Load_Name => Get_Body_Name
(Get_Unit_Name
(Unit_Declaration_Node
(Renamed_Object (Nam)))),
Required => False,
Subunit => False,
Error_Node => N,
Renamings => True);
else
Un :=
Load_Unit
(Load_Name => Get_Body_Name
(Get_Unit_Name (Item)),
Required => False,
Subunit => False,
Error_Node => N,
Renamings => True);
end if;
if Un = No_Unit then
Error_Msg_NE
("body of generic unit& not found", Item, Nam);
exit;
elsif not Analyzed (Cunit (Un))
and then Un /= Main_Unit
then
Opt.Style_Check := False;
Semantics (Cunit (Un));
end if;
end if;
end if;
Next (Item);
end loop;
Style_Check := Save_Style_Check;
Compilation_Unit_Restrictions_Restore (Save_C_Restrict);
end;
end if;
-- Deal with creating elaboration Boolean if needed. We create an
-- elaboration boolean only for units that come from source since
-- units manufactured by the compiler never need elab checks.
if Comes_From_Source (N)
and then
(Nkind (Unit (N)) = N_Package_Declaration or else
Nkind (Unit (N)) = N_Generic_Package_Declaration or else
Nkind (Unit (N)) = N_Subprogram_Declaration or else
Nkind (Unit (N)) = N_Generic_Subprogram_Declaration)
then
declare
Loc : constant Source_Ptr := Sloc (N);
Unum : constant Unit_Number_Type := Get_Source_Unit (Loc);
begin
Spec_Id := Defining_Entity (Unit (N));
Generate_Definition (Spec_Id);
-- See if an elaboration entity is required for possible
-- access before elaboration checking. Note that we must
-- allow for this even if -gnatE is not set, since a client
-- may be compiled in -gnatE mode and reference the entity.
-- Case of units which do not require elaboration checks
if
-- Pure units do not need checks
Is_Pure (Spec_Id)
-- Preelaborated units do not need checks
or else Is_Preelaborated (Spec_Id)
-- No checks needed if pagma Elaborate_Body present
or else Has_Pragma_Elaborate_Body (Spec_Id)
-- No checks needed if unit does not require a body
or else not Unit_Requires_Body (Spec_Id)
-- No checks needed for predefined files
or else Is_Predefined_File_Name (Unit_File_Name (Unum))
-- No checks required if no separate spec
or else Acts_As_Spec (N)
then
-- This is a case where we only need the entity for
-- checking to prevent multiple elaboration checks.
Set_Elaboration_Entity_Required (Spec_Id, False);
-- Case of elaboration entity is required for access before
-- elaboration checking (so certainly we must build it!)
else
Set_Elaboration_Entity_Required (Spec_Id, True);
end if;
Build_Elaboration_Entity (N, Spec_Id);
end;
end if;
-- Finally, freeze the compilation unit entity. This for sure is needed
-- because of some warnings that can be output (see Freeze_Subprogram),
-- but may in general be required. If freezing actions result, place
-- them in the compilation unit actions list, and analyze them.
declare
Loc : constant Source_Ptr := Sloc (N);
L : constant List_Id :=
Freeze_Entity (Cunit_Entity (Current_Sem_Unit), Loc);
begin
while Is_Non_Empty_List (L) loop
Insert_Library_Level_Action (Remove_Head (L));
end loop;
end;
Set_Analyzed (N);
if Nkind (Unit_Node) = N_Package_Declaration
and then Get_Cunit_Unit_Number (N) /= Main_Unit
and then Front_End_Inlining
and then Expander_Active
then
Check_Body_For_Inlining (N, Defining_Entity (Unit_Node));
end if;
end Analyze_Compilation_Unit;
---------------------
-- Analyze_Context --
---------------------
procedure Analyze_Context (N : Node_Id) is
Item : Node_Id;
begin
-- Loop through context items
Item := First (Context_Items (N));
while Present (Item) loop
-- For with clause, analyze the with clause, and then update
-- the version, since we are dependent on a unit that we with.
if Nkind (Item) = N_With_Clause then
-- Skip analyzing with clause if no unit, nothing to do (this
-- happens for a with that references a non-existent unit)
if Present (Library_Unit (Item)) then
Analyze (Item);
end if;
if not Implicit_With (Item) then
Version_Update (N, Library_Unit (Item));
end if;
-- But skip use clauses at this stage, since we don't want to do
-- any installing of potentially use visible entities until we
-- we actually install the complete context (in Install_Context).
-- Otherwise things can get installed in the wrong context.
-- Similarly, pragmas are analyzed in Install_Context, after all
-- the implicit with's on parent units are generated.
else
null;
end if;
Next (Item);
end loop;
end Analyze_Context;
-------------------------------
-- Analyze_Package_Body_Stub --
-------------------------------
procedure Analyze_Package_Body_Stub (N : Node_Id) is
Id : constant Entity_Id := Defining_Identifier (N);
Nam : Entity_Id;
begin
-- The package declaration must be in the current declarative part.
Check_Stub_Level (N);
Nam := Current_Entity_In_Scope (Id);
if No (Nam) or else not Is_Package (Nam) then
Error_Msg_N ("missing specification for package stub", N);
elsif Has_Completion (Nam)
and then Present (Corresponding_Body (Unit_Declaration_Node (Nam)))
then
Error_Msg_N ("duplicate or redundant stub for package", N);
else
-- Indicate that the body of the package exists. If we are doing
-- only semantic analysis, the stub stands for the body. If we are
-- generating code, the existence of the body will be confirmed
-- when we load the proper body.
Set_Has_Completion (Nam);
Set_Scope (Defining_Entity (N), Current_Scope);
Analyze_Proper_Body (N, Nam);
end if;
end Analyze_Package_Body_Stub;
-------------------------
-- Analyze_Proper_Body --
-------------------------
procedure Analyze_Proper_Body (N : Node_Id; Nam : Entity_Id) is
Subunit_Name : constant Unit_Name_Type := Get_Unit_Name (N);
Unum : Unit_Number_Type;
Subunit_Not_Found : Boolean := False;
procedure Optional_Subunit;
-- This procedure is called when the main unit is a stub, or when we
-- are not generating code. In such a case, we analyze the subunit if
-- present, which is user-friendly and in fact required for ASIS, but
-- we don't complain if the subunit is missing.
----------------------
-- Optional_Subunit --
----------------------
procedure Optional_Subunit is
Comp_Unit : Node_Id;
begin
-- Try to load subunit, but ignore any errors that occur during
-- the loading of the subunit, by using the special feature in
-- Errout to ignore all errors. Note that Fatal_Error will still
-- be set, so we will be able to check for this case below.
Ignore_Errors_Enable := Ignore_Errors_Enable + 1;
Unum :=
Load_Unit
(Load_Name => Subunit_Name,
Required => False,
Subunit => True,
Error_Node => N);
Ignore_Errors_Enable := Ignore_Errors_Enable - 1;
-- All done if we successfully loaded the subunit
if Unum /= No_Unit and then not Fatal_Error (Unum) then
Comp_Unit := Cunit (Unum);
Set_Corresponding_Stub (Unit (Comp_Unit), N);
Analyze_Subunit (Comp_Unit);
Set_Library_Unit (N, Comp_Unit);
elsif Unum = No_Unit
and then Present (Nam)
then
if Is_Protected_Type (Nam) then
Set_Corresponding_Body (Parent (Nam), Defining_Identifier (N));
else
Set_Corresponding_Body (
Unit_Declaration_Node (Nam), Defining_Identifier (N));
end if;
end if;
end Optional_Subunit;
-- Start of processing for Analyze_Proper_Body
begin
-- If the subunit is already loaded, it means that the main unit
-- is a subunit, and that the current unit is one of its parents
-- which was being analyzed to provide the needed context for the
-- analysis of the subunit. In this case we analyze the subunit and
-- continue with the parent, without looking a subsequent subunits.
if Is_Loaded (Subunit_Name) then
-- If the proper body is already linked to the stub node,
-- the stub is in a generic unit and just needs analyzing.
if Present (Library_Unit (N)) then
Set_Corresponding_Stub (Unit (Library_Unit (N)), N);
Analyze_Subunit (Library_Unit (N));
-- Otherwise we must load the subunit and link to it
else
-- Load the subunit, this must work, since we originally
-- loaded the subunit earlier on. So this will not really
-- load it, just give access to it.
Unum :=
Load_Unit
(Load_Name => Subunit_Name,
Required => True,
Subunit => False,
Error_Node => N);
-- And analyze the subunit in the parent context (note that we
-- do not call Semantics, since that would remove the parent
-- context). Because of this, we have to manually reset the
-- compiler state to Analyzing since it got destroyed by Load.
if Unum /= No_Unit then
Compiler_State := Analyzing;
Set_Corresponding_Stub (Unit (Cunit (Unum)), N);
Analyze_Subunit (Cunit (Unum));
Set_Library_Unit (N, Cunit (Unum));
end if;
end if;
-- If the main unit is a subunit, then we are just performing semantic
-- analysis on that subunit, and any other subunits of any parent unit
-- should be ignored, except that if we are building trees for ASIS
-- usage we want to annotate the stub properly.
elsif Nkind (Unit (Cunit (Main_Unit))) = N_Subunit
and then Subunit_Name /= Unit_Name (Main_Unit)
then
if Tree_Output then
Optional_Subunit;
end if;
-- But before we return, set the flag for unloaded subunits. This
-- will suppress junk warnings of variables in the same declarative
-- part (or a higher level one) that are in danger of looking unused
-- when in fact there might be a declaration in the subunit that we
-- do not intend to load.
Unloaded_Subunits := True;
return;
-- If the subunit is not already loaded, and we are generating code,
-- then this is the case where compilation started from the parent,
-- and we are generating code for an entire subunit tree. In that
-- case we definitely need to load the subunit.
-- In order to continue the analysis with the rest of the parent,
-- and other subunits, we load the unit without requiring its
-- presence, and emit a warning if not found, rather than terminating
-- the compilation abruptly, as for other missing file problems.
elsif Operating_Mode = Generate_Code then
-- If the proper body is already linked to the stub node,
-- the stub is in a generic unit and just needs analyzing.
-- We update the version. Although we are not technically
-- semantically dependent on the subunit, given our approach
-- of macro substitution of subunits, it makes sense to
-- include it in the version identification.
if Present (Library_Unit (N)) then
Set_Corresponding_Stub (Unit (Library_Unit (N)), N);
Analyze_Subunit (Library_Unit (N));
Version_Update (Cunit (Main_Unit), Library_Unit (N));
-- Otherwise we must load the subunit and link to it
else
Unum :=
Load_Unit
(Load_Name => Subunit_Name,
Required => False,
Subunit => True,
Error_Node => N);
if Operating_Mode = Generate_Code
and then Unum = No_Unit
then
Error_Msg_Name_1 := Subunit_Name;
Error_Msg_Name_2 :=
Get_File_Name (Subunit_Name, Subunit => True);
Error_Msg_N
("subunit% in file{ not found!?", N);
Subunits_Missing := True;
Subunit_Not_Found := True;
end if;
-- Load_Unit may reset Compiler_State, since it may have been
-- necessary to parse an additional units, so we make sure
-- that we reset it to the Analyzing state.
Compiler_State := Analyzing;
if Unum /= No_Unit and then not Fatal_Error (Unum) then
if Debug_Flag_L then
Write_Str ("*** Loaded subunit from stub. Analyze");
Write_Eol;
end if;
declare
Comp_Unit : constant Node_Id := Cunit (Unum);
begin
-- Check for child unit instead of subunit
if Nkind (Unit (Comp_Unit)) /= N_Subunit then
Error_Msg_N
("expected SEPARATE subunit, found child unit",
Cunit_Entity (Unum));
-- OK, we have a subunit, so go ahead and analyze it,
-- and set Scope of entity in stub, for ASIS use.
else
Set_Corresponding_Stub (Unit (Comp_Unit), N);
Analyze_Subunit (Comp_Unit);
Set_Library_Unit (N, Comp_Unit);
-- We update the version. Although we are not technically
-- semantically dependent on the subunit, given our
-- approach of macro substitution of subunits, it makes
-- sense to include it in the version identification.
Version_Update (Cunit (Main_Unit), Comp_Unit);
end if;
end;
end if;
end if;
-- The remaining case is when the subunit is not already loaded and
-- we are not generating code. In this case we are just performing
-- semantic analysis on the parent, and we are not interested in
-- the subunit. For subprograms, analyze the stub as a body. For
-- other entities the stub has already been marked as completed.
else
Optional_Subunit;
end if;
end Analyze_Proper_Body;
----------------------------------
-- Analyze_Protected_Body_Stub --
----------------------------------
procedure Analyze_Protected_Body_Stub (N : Node_Id) is
Nam : Entity_Id := Current_Entity_In_Scope (Defining_Identifier (N));
begin
Check_Stub_Level (N);
-- First occurrence of name may have been as an incomplete type.
if Present (Nam) and then Ekind (Nam) = E_Incomplete_Type then
Nam := Full_View (Nam);
end if;
if No (Nam)
or else not Is_Protected_Type (Etype (Nam))
then
Error_Msg_N ("missing specification for Protected body", N);
else
Set_Scope (Defining_Entity (N), Current_Scope);
Set_Has_Completion (Etype (Nam));
Analyze_Proper_Body (N, Etype (Nam));
end if;
end Analyze_Protected_Body_Stub;
----------------------------------
-- Analyze_Subprogram_Body_Stub --
----------------------------------
-- A subprogram body stub can appear with or without a previous
-- specification. If there is one, the analysis of the body will
-- find it and verify conformance. The formals appearing in the
-- specification of the stub play no role, except for requiring an
-- additional conformance check. If there is no previous subprogram
-- declaration, the stub acts as a spec, and provides the defining
-- entity for the subprogram.
procedure Analyze_Subprogram_Body_Stub (N : Node_Id) is
Decl : Node_Id;
begin
Check_Stub_Level (N);
-- Verify that the identifier for the stub is unique within this
-- declarative part.
if Nkind (Parent (N)) = N_Block_Statement
or else Nkind (Parent (N)) = N_Package_Body
or else Nkind (Parent (N)) = N_Subprogram_Body
then
Decl := First (Declarations (Parent (N)));
while Present (Decl)
and then Decl /= N
loop
if Nkind (Decl) = N_Subprogram_Body_Stub
and then (Chars (Defining_Unit_Name (Specification (Decl)))
= Chars (Defining_Unit_Name (Specification (N))))
then
Error_Msg_N ("identifier for stub is not unique", N);
end if;
Next (Decl);
end loop;
end if;
-- Treat stub as a body, which checks conformance if there is a previous
-- declaration, or else introduces entity and its signature.
Analyze_Subprogram_Body (N);
if Errors_Detected = 0 then
Analyze_Proper_Body (N, Empty);
end if;
end Analyze_Subprogram_Body_Stub;
---------------------
-- Analyze_Subunit --
---------------------
-- A subunit is compiled either by itself (for semantic checking)
-- or as part of compiling the parent (for code generation). In
-- either case, by the time we actually process the subunit, the
-- parent has already been installed and analyzed. The node N is
-- a compilation unit, whose context needs to be treated here,
-- because we come directly here from the parent without calling
-- Analyze_Compilation_Unit.
-- The compilation context includes the explicit context of the
-- subunit, and the context of the parent, together with the parent
-- itself. In order to compile the current context, we remove the
-- one inherited from the parent, in order to have a clean visibility
-- table. We restore the parent context before analyzing the proper
-- body itself. On exit, we remove only the explicit context of the
-- subunit.
procedure Analyze_Subunit (N : Node_Id) is
Lib_Unit : constant Node_Id := Library_Unit (N);
Par_Unit : constant Entity_Id := Current_Scope;
Lib_Spec : Node_Id := Library_Unit (Lib_Unit);
Num_Scopes : Int := 0;
Use_Clauses : array (1 .. Scope_Stack.Last) of Node_Id;
Enclosing_Child : Entity_Id := Empty;
procedure Analyze_Subunit_Context;
-- Capture names in use clauses of the subunit. This must be done
-- before re-installing parent declarations, because items in the
-- context must not be hidden by declarations local to the parent.
procedure Re_Install_Parents (L : Node_Id; Scop : Entity_Id);
-- Recursive procedure to restore scope of all ancestors of subunit,
-- from outermost in. If parent is not a subunit, the call to install
-- context installs context of spec and (if parent is a child unit)
-- the context of its parents as well. It is confusing that parents
-- should be treated differently in both cases, but the semantics are
-- just not identical.
procedure Re_Install_Use_Clauses;
-- As part of the removal of the parent scope, the use clauses are
-- removed, to be reinstalled when the context of the subunit has
-- been analyzed. Use clauses may also have been affected by the
-- analysis of the context of the subunit, so they have to be applied
-- again, to insure that the compilation environment of the rest of
-- the parent unit is identical.
procedure Remove_Scope;
-- Remove current scope from scope stack, and preserve the list
-- of use clauses in it, to be reinstalled after context is analyzed.
------------------------------
-- Analyze_Subunit_Context --
------------------------------
procedure Analyze_Subunit_Context is
Item : Node_Id;
Nam : Node_Id;
Unit_Name : Entity_Id;
begin
Analyze_Context (N);
Item := First (Context_Items (N));
-- make withed units immediately visible. If child unit, make the
-- ultimate parent immediately visible.
while Present (Item) loop
if Nkind (Item) = N_With_Clause then
Unit_Name := Entity (Name (Item));
while Is_Child_Unit (Unit_Name) loop
Set_Is_Visible_Child_Unit (Unit_Name);
Unit_Name := Scope (Unit_Name);
end loop;
if not Is_Immediately_Visible (Unit_Name) then
Set_Is_Immediately_Visible (Unit_Name);
Set_Context_Installed (Item);
end if;
elsif Nkind (Item) = N_Use_Package_Clause then
Nam := First (Names (Item));
while Present (Nam) loop
Analyze (Nam);
Next (Nam);
end loop;
elsif Nkind (Item) = N_Use_Type_Clause then
Nam := First (Subtype_Marks (Item));
while Present (Nam) loop
Analyze (Nam);
Next (Nam);
end loop;
end if;
Next (Item);
end loop;
Item := First (Context_Items (N));
-- reset visibility of withed units. They will be made visible
-- again when we install the subunit context.
while Present (Item) loop
if Nkind (Item) = N_With_Clause then
Unit_Name := Entity (Name (Item));
while Is_Child_Unit (Unit_Name) loop
Set_Is_Visible_Child_Unit (Unit_Name, False);
Unit_Name := Scope (Unit_Name);
end loop;
if Context_Installed (Item) then
Set_Is_Immediately_Visible (Unit_Name, False);
Set_Context_Installed (Item, False);
end if;
end if;
Next (Item);
end loop;
end Analyze_Subunit_Context;
------------------------
-- Re_Install_Parents --
------------------------
procedure Re_Install_Parents (L : Node_Id; Scop : Entity_Id) is
E : Entity_Id;
begin
if Nkind (Unit (L)) = N_Subunit then
Re_Install_Parents (Library_Unit (L), Scope (Scop));
end if;
Install_Context (L);
-- If the subunit occurs within a child unit, we must restore the
-- immediate visibility of any siblings that may occur in context.
if Present (Enclosing_Child) then
Install_Siblings (Enclosing_Child, L);
end if;
New_Scope (Scop);
if Scop /= Par_Unit then
Set_Is_Immediately_Visible (Scop);
end if;
E := First_Entity (Current_Scope);
while Present (E) loop
Set_Is_Immediately_Visible (E);
Next_Entity (E);
end loop;
-- A subunit appears within a body, and for a nested subunits
-- all the parents are bodies. Restore full visibility of their
-- private entities.
if Ekind (Scop) = E_Package then
Set_In_Package_Body (Scop);
Install_Private_Declarations (Scop);
end if;
end Re_Install_Parents;
----------------------------
-- Re_Install_Use_Clauses --
----------------------------
procedure Re_Install_Use_Clauses is
U : Node_Id;
begin
for J in reverse 1 .. Num_Scopes loop
U := Use_Clauses (J);
Scope_Stack.Table (Scope_Stack.Last - J + 1).First_Use_Clause := U;
Install_Use_Clauses (U);
end loop;
end Re_Install_Use_Clauses;
------------------
-- Remove_Scope --
------------------
procedure Remove_Scope is
E : Entity_Id;
begin
Num_Scopes := Num_Scopes + 1;
Use_Clauses (Num_Scopes) :=
Scope_Stack.Table (Scope_Stack.Last).First_Use_Clause;
E := First_Entity (Current_Scope);
while Present (E) loop
Set_Is_Immediately_Visible (E, False);
Next_Entity (E);
end loop;
if Is_Child_Unit (Current_Scope) then
Enclosing_Child := Current_Scope;
end if;
Pop_Scope;
end Remove_Scope;
-- Start of processing for Analyze_Subunit
begin
if not Is_Empty_List (Context_Items (N)) then
-- Save current use clauses.
Remove_Scope;
Remove_Context (Lib_Unit);
-- Now remove parents and their context, including enclosing
-- subunits and the outer parent body which is not a subunit.
if Present (Lib_Spec) then
Remove_Context (Lib_Spec);
while Nkind (Unit (Lib_Spec)) = N_Subunit loop
Lib_Spec := Library_Unit (Lib_Spec);
Remove_Scope;
Remove_Context (Lib_Spec);
end loop;
if Nkind (Unit (Lib_Unit)) = N_Subunit then
Remove_Scope;
end if;
if Nkind (Unit (Lib_Spec)) = N_Package_Body then
Remove_Context (Library_Unit (Lib_Spec));
end if;
end if;
Analyze_Subunit_Context;
Re_Install_Parents (Lib_Unit, Par_Unit);
-- If the context includes a child unit of the parent of the
-- subunit, the parent will have been removed from visibility,
-- after compiling that cousin in the context. The visibility
-- of the parent must be restored now. This also applies if the
-- context includes another subunit of the same parent which in
-- turn includes a child unit in its context.
if Ekind (Par_Unit) = E_Package then
if not Is_Immediately_Visible (Par_Unit)
or else (Present (First_Entity (Par_Unit))
and then not Is_Immediately_Visible
(First_Entity (Par_Unit)))
then
Set_Is_Immediately_Visible (Par_Unit);
Install_Visible_Declarations (Par_Unit);
Install_Private_Declarations (Par_Unit);
end if;
end if;
Re_Install_Use_Clauses;
Install_Context (N);
-- If the subunit is within a child unit, then siblings of any
-- parent unit that appear in the context clause of the subunit
-- must also be made immediately visible.
if Present (Enclosing_Child) then
Install_Siblings (Enclosing_Child, N);
end if;
end if;
Analyze (Proper_Body (Unit (N)));
Remove_Context (N);
end Analyze_Subunit;
----------------------------
-- Analyze_Task_Body_Stub --
----------------------------
procedure Analyze_Task_Body_Stub (N : Node_Id) is
Nam : Entity_Id := Current_Entity_In_Scope (Defining_Identifier (N));
Loc : constant Source_Ptr := Sloc (N);
begin
Check_Stub_Level (N);
-- First occurrence of name may have been as an incomplete type.
if Present (Nam) and then Ekind (Nam) = E_Incomplete_Type then
Nam := Full_View (Nam);
end if;
if No (Nam)
or else not Is_Task_Type (Etype (Nam))
then
Error_Msg_N ("missing specification for task body", N);
else
Set_Scope (Defining_Entity (N), Current_Scope);
Set_Has_Completion (Etype (Nam));
Analyze_Proper_Body (N, Etype (Nam));
-- Set elaboration flag to indicate that entity is callable.
-- This cannot be done in the expansion of the body itself,
-- because the proper body is not in a declarative part. This
-- is only done if expansion is active, because the context
-- may be generic and the flag not defined yet.
if Expander_Active then
Insert_After (N,
Make_Assignment_Statement (Loc,
Name =>
Make_Identifier (Loc,
New_External_Name (Chars (Etype (Nam)), 'E')),
Expression => New_Reference_To (Standard_True, Loc)));
end if;
end if;
end Analyze_Task_Body_Stub;
-------------------------
-- Analyze_With_Clause --
-------------------------
-- Analyze the declaration of a unit in a with clause. At end,
-- label the with clause with the defining entity for the unit.
procedure Analyze_With_Clause (N : Node_Id) is
Unit_Kind : constant Node_Kind := Nkind (Unit (Library_Unit (N)));
E_Name : Entity_Id;
Par_Name : Entity_Id;
Pref : Node_Id;
U : Node_Id;
Intunit : Boolean;
-- Set True if the unit currently being compiled is an internal unit
Save_Style_Check : constant Boolean := Opt.Style_Check;
Save_C_Restrict : constant Save_Compilation_Unit_Restrictions :=
Compilation_Unit_Restrictions_Save;
begin
-- We reset ordinary style checking during the analysis of a with'ed
-- unit, but we do NOT reset GNAT special analysis mode (the latter
-- definitely *does* apply to with'ed units).
if not GNAT_Mode then
Style_Check := False;
end if;
-- If the library unit is a predefined unit, and we are in no
-- run time mode, then temporarily reset No_Run_Time mode for the
-- analysis of the with'ed unit. The No_Run_Time pragma does not
-- prevent explicit with'ing of run-time units.
if No_Run_Time
and then
Is_Predefined_File_Name
(Unit_File_Name (Get_Source_Unit (Unit (Library_Unit (N)))))
then
No_Run_Time := False;
Semantics (Library_Unit (N));
No_Run_Time := True;
else
Semantics (Library_Unit (N));
end if;
U := Unit (Library_Unit (N));
Intunit := Is_Internal_File_Name (Unit_File_Name (Current_Sem_Unit));
-- Following checks are skipped for dummy packages (those supplied
-- for with's where no matching file could be found). Such packages
-- are identified by the Sloc value being set to No_Location
if Sloc (U) /= No_Location then
-- Check restrictions, except that we skip the check if this
-- is an internal unit unless we are compiling the internal
-- unit as the main unit. We also skip this for dummy packages.
if not Intunit or else Current_Sem_Unit = Main_Unit then
Check_Restricted_Unit (Unit_Name (Get_Source_Unit (U)), N);
end if;
-- Check for inappropriate with of internal implementation unit
-- if we are currently compiling the main unit and the main unit
-- is itself not an internal unit.
if Implementation_Unit_Warnings
and then Current_Sem_Unit = Main_Unit
and then Implementation_Unit (Get_Source_Unit (U))
and then not Intunit
then
Error_Msg_N ("& is an internal 'G'N'A'T unit?", Name (N));
Error_Msg_N
("\use of this unit is non-portable and version-dependent?",
Name (N));
end if;
end if;
-- Semantic analysis of a generic unit is performed on a copy of
-- the original tree. Retrieve the entity on which semantic info
-- actually appears.
if Unit_Kind in N_Generic_Declaration then
E_Name := Defining_Entity (U);
-- Note: in the following test, Unit_Kind is the original Nkind, but
-- in the case of an instantiation, semantic analysis above will
-- have replaced the unit by its instantiated version. If the instance
-- body has been generated, the instance now denotes the body entity.
-- For visibility purposes we need the entity of its spec.
elsif (Unit_Kind = N_Package_Instantiation
or else Nkind (Original_Node (Unit (Library_Unit (N)))) =
N_Package_Instantiation)
and then Nkind (U) = N_Package_Body
then
E_Name := Corresponding_Spec (U);
elsif Unit_Kind = N_Package_Instantiation
and then Nkind (U) = N_Package_Instantiation
then
-- If the instance has not been rewritten as a package declaration,
-- then it appeared already in a previous with clause. Retrieve
-- the entity from the previous instance.
E_Name := Defining_Entity (Specification (Instance_Spec (U)));
elsif Unit_Kind = N_Procedure_Instantiation
or else Unit_Kind = N_Function_Instantiation
then
-- Instantiation node is replaced with a package that contains
-- renaming declarations and instance itself. The subprogram
-- Instance is declared in the visible part of the wrapper package.
E_Name := First_Entity (Defining_Entity (U));
while Present (E_Name) loop
exit when Is_Subprogram (E_Name)
and then Is_Generic_Instance (E_Name);
E_Name := Next_Entity (E_Name);
end loop;
elsif Unit_Kind = N_Package_Renaming_Declaration
or else Unit_Kind in N_Generic_Renaming_Declaration
then
E_Name := Defining_Entity (U);
elsif Unit_Kind = N_Subprogram_Body
and then Nkind (Name (N)) = N_Selected_Component
and then not Acts_As_Spec (Library_Unit (N))
then
-- For a child unit that has no spec, one has been created and
-- analyzed. The entity required is that of the spec.
E_Name := Corresponding_Spec (U);
else
E_Name := Defining_Entity (U);
end if;
if Nkind (Name (N)) = N_Selected_Component then
-- Child unit in a with clause
Change_Selected_Component_To_Expanded_Name (Name (N));
end if;
-- Restore style checks and restrictions
Style_Check := Save_Style_Check;
Compilation_Unit_Restrictions_Restore (Save_C_Restrict);
-- Record the reference, but do NOT set the unit as referenced, we
-- want to consider the unit as unreferenced if this is the only
-- reference that occurs.
Set_Entity_With_Style_Check (Name (N), E_Name);
Generate_Reference (E_Name, Name (N), Set_Ref => False);
if Is_Child_Unit (E_Name) then
Pref := Prefix (Name (N));
Par_Name := Scope (E_Name);
while Nkind (Pref) = N_Selected_Component loop
Change_Selected_Component_To_Expanded_Name (Pref);
Set_Entity_With_Style_Check (Pref, Par_Name);
Generate_Reference (Par_Name, Pref);
Pref := Prefix (Pref);
Par_Name := Scope (Par_Name);
end loop;
if Present (Entity (Pref))
and then not Analyzed (Parent (Parent (Entity (Pref))))
then
-- If the entity is set without its unit being compiled,
-- the original parent is a renaming, and Par_Name is the
-- renamed entity. For visibility purposes, we need the
-- original entity, which must be analyzed now, because
-- Load_Unit retrieves directly the renamed unit, and the
-- renaming declaration itself has not been analyzed.
Analyze (Parent (Parent (Entity (Pref))));
pragma Assert (Renamed_Object (Entity (Pref)) = Par_Name);
Par_Name := Entity (Pref);
end if;
Set_Entity_With_Style_Check (Pref, Par_Name);
Generate_Reference (Par_Name, Pref);
end if;
-- If the withed unit is System, and a system extension pragma is
-- present, compile the extension now, rather than waiting for
-- a visibility check on a specific entity.
if Chars (E_Name) = Name_System
and then Scope (E_Name) = Standard_Standard
and then Present (System_Extend_Pragma_Arg)
and then Present_System_Aux (N)
then
-- If the extension is not present, an error will have been emitted.
null;
end if;
end Analyze_With_Clause;
------------------------------
-- Analyze_With_Type_Clause --
------------------------------
procedure Analyze_With_Type_Clause (N : Node_Id) is
Loc : constant Source_Ptr := Sloc (N);
Nam : Node_Id := Name (N);
Pack : Node_Id;
Decl : Node_Id;
P : Entity_Id;
Unum : Unit_Number_Type;
Sel : Node_Id;
procedure Decorate_Tagged_Type (T : Entity_Id; Kind : Entity_Kind);
-- Set basic attributes of type, including its class_wide type.
function In_Chain (E : Entity_Id) return Boolean;
-- Check that the imported type is not already in the homonym chain,
-- for example through a with_type clause in a parent unit.
--------------------------
-- Decorate_Tagged_Type --
--------------------------
procedure Decorate_Tagged_Type (T : Entity_Id; Kind : Entity_Kind) is
CW : Entity_Id;
begin
Set_Ekind (T, E_Record_Type);
Set_Is_Tagged_Type (T);
Set_Etype (T, T);
Set_From_With_Type (T);
Set_Scope (T, P);
if not In_Chain (T) then
Set_Homonym (T, Current_Entity (T));
Set_Current_Entity (T);
end if;
-- Build bogus class_wide type, if not previously done.
if No (Class_Wide_Type (T)) then
CW := Make_Defining_Identifier (Loc, New_Internal_Name ('S'));
Set_Ekind (CW, E_Class_Wide_Type);
Set_Etype (CW, T);
Set_Scope (CW, P);
Set_Is_Tagged_Type (CW);
Set_Is_First_Subtype (CW, True);
Init_Size_Align (CW);
Set_Has_Unknown_Discriminants
(CW, True);
Set_Class_Wide_Type (CW, CW);
Set_Equivalent_Type (CW, Empty);
Set_From_With_Type (CW);
Set_Class_Wide_Type (T, CW);
end if;
end Decorate_Tagged_Type;
--------------
-- In_Chain --
--------------
function In_Chain (E : Entity_Id) return Boolean is
H : Entity_Id := Current_Entity (E);
begin
while Present (H) loop
if H = E then
return True;
else
H := Homonym (H);
end if;
end loop;
return False;
end In_Chain;
-- Start of processing for Analyze_With_Type_Clause
begin
if Nkind (Nam) = N_Selected_Component then
Pack := New_Copy_Tree (Prefix (Nam));
Sel := Selector_Name (Nam);
else
Error_Msg_N ("illegal name for imported type", Nam);
return;
end if;
Decl :=
Make_Package_Declaration (Loc,
Specification =>
(Make_Package_Specification (Loc,
Defining_Unit_Name => Pack,
Visible_Declarations => New_List,
End_Label => Empty)));
Unum :=
Load_Unit
(Load_Name => Get_Unit_Name (Decl),
Required => True,
Subunit => False,
Error_Node => Nam);
if Unum = No_Unit
or else Nkind (Unit (Cunit (Unum))) /= N_Package_Declaration
then
Error_Msg_N ("imported type must be declared in package", Nam);
return;
elsif Unum = Current_Sem_Unit then
-- If type is defined in unit being analyzed, then the clause
-- is redundant.
return;
else
P := Cunit_Entity (Unum);
end if;
-- Find declaration for imported type, and set its basic attributes
-- if it has not been analyzed (which will be the case if there is
-- circular dependence).
declare
Decl : Node_Id;
Typ : Entity_Id;
begin
if not Analyzed (Cunit (Unum))
and then not From_With_Type (P)
then
Set_Ekind (P, E_Package);
Set_Etype (P, Standard_Void_Type);
Set_From_With_Type (P);
Set_Scope (P, Standard_Standard);
Set_Homonym (P, Current_Entity (P));
Set_Current_Entity (P);
elsif Analyzed (Cunit (Unum))
and then Is_Child_Unit (P)
then
-- If the child unit is already in scope, indicate that it is
-- visible, and remains so after intervening calls to rtsfind.
Set_Is_Visible_Child_Unit (P);
end if;
if Nkind (Parent (P)) = N_Defining_Program_Unit_Name then
-- Make parent packages visible.
declare
Parent_Comp : Node_Id;
Parent_Id : Entity_Id;
Child : Entity_Id;
begin
Child := P;
Parent_Comp := Parent_Spec (Unit (Cunit (Unum)));
loop
Parent_Id := Defining_Entity (Unit (Parent_Comp));
Set_Scope (Child, Parent_Id);
-- The type may be imported from a child unit, in which
-- case the current compilation appears in the name. Do
-- not change its visibility here because it will conflict
-- with the subsequent normal processing.
if not Analyzed (Unit_Declaration_Node (Parent_Id))
and then Parent_Id /= Cunit_Entity (Current_Sem_Unit)
then
Set_Ekind (Parent_Id, E_Package);
Set_Etype (Parent_Id, Standard_Void_Type);
-- The same package may appear is several with_type
-- clauses.
if not From_With_Type (Parent_Id) then
Set_Homonym (Parent_Id, Current_Entity (Parent_Id));
Set_Current_Entity (Parent_Id);
Set_From_With_Type (Parent_Id);
end if;
end if;
Set_Is_Immediately_Visible (Parent_Id);
Child := Parent_Id;
Parent_Comp := Parent_Spec (Unit (Parent_Comp));
exit when No (Parent_Comp);
end loop;
Set_Scope (Parent_Id, Standard_Standard);
end;
end if;
-- Even if analyzed, the package may not be currently visible. It
-- must be while the with_type clause is active.
Set_Is_Immediately_Visible (P);
Decl :=
First (Visible_Declarations (Specification (Unit (Cunit (Unum)))));
while Present (Decl) loop
if Nkind (Decl) = N_Full_Type_Declaration
and then Chars (Defining_Identifier (Decl)) = Chars (Sel)
then
Typ := Defining_Identifier (Decl);
if Tagged_Present (N) then
-- The declaration must indicate that this is a tagged
-- type or a type extension.
if (Nkind (Type_Definition (Decl)) = N_Record_Definition
and then Tagged_Present (Type_Definition (Decl)))
or else
(Nkind (Type_Definition (Decl))
= N_Derived_Type_Definition
and then Present
(Record_Extension_Part (Type_Definition (Decl))))
then
null;
else
Error_Msg_N ("imported type is not a tagged type", Nam);
return;
end if;
if not Analyzed (Decl) then
-- Unit is not currently visible. Add basic attributes
-- to type and build its class-wide type.
Init_Size_Align (Typ);
Decorate_Tagged_Type (Typ, E_Record_Type);
end if;
else
if Nkind (Type_Definition (Decl))
/= N_Access_To_Object_Definition
then
Error_Msg_N
("imported type is not an access type", Nam);
elsif not Analyzed (Decl) then
Set_Ekind (Typ, E_Access_Type);
Set_Etype (Typ, Typ);
Set_Scope (Typ, P);
Init_Size (Typ, System_Address_Size);
Init_Alignment (Typ);
Set_Directly_Designated_Type (Typ, Standard_Integer);
Set_From_With_Type (Typ);
if not In_Chain (Typ) then
Set_Homonym (Typ, Current_Entity (Typ));
Set_Current_Entity (Typ);
end if;
end if;
end if;
Set_Entity (Sel, Typ);
return;
elsif ((Nkind (Decl) = N_Private_Type_Declaration
and then Tagged_Present (Decl))
or else (Nkind (Decl) = N_Private_Extension_Declaration))
and then Chars (Defining_Identifier (Decl)) = Chars (Sel)
then
Typ := Defining_Identifier (Decl);
if not Tagged_Present (N) then
Error_Msg_N ("type must be declared tagged", N);
elsif not Analyzed (Decl) then
Decorate_Tagged_Type (Typ, E_Private_Type);
end if;
Set_Entity (Sel, Typ);
Set_From_With_Type (Typ);
return;
end if;
Decl := Next (Decl);
end loop;
Error_Msg_NE ("not a visible access or tagged type in&", Nam, P);
end;
end Analyze_With_Type_Clause;
-----------------------------
-- Check_With_Type_Clauses --
-----------------------------
procedure Check_With_Type_Clauses (N : Node_Id) is
Lib_Unit : constant Node_Id := Unit (N);
procedure Check_Parent_Context (U : Node_Id);
-- Examine context items of parent unit to locate with_type clauses.
--------------------------
-- Check_Parent_Context --
--------------------------
procedure Check_Parent_Context (U : Node_Id) is
Item : Node_Id;
begin
Item := First (Context_Items (U));
while Present (Item) loop
if Nkind (Item) = N_With_Type_Clause
and then not Error_Posted (Item)
and then
From_With_Type (Scope (Entity (Selector_Name (Name (Item)))))
then
Error_Msg_Sloc := Sloc (Item);
Error_Msg_N ("Missing With_Clause for With_Type_Clause#", N);
end if;
Next (Item);
end loop;
end Check_Parent_Context;
-- Start of processing for Check_With_Type_Clauses
begin
if Extensions_Allowed
and then (Nkind (Lib_Unit) = N_Package_Body
or else Nkind (Lib_Unit) = N_Subprogram_Body)
then
Check_Parent_Context (Library_Unit (N));
if Is_Child_Spec (Unit (Library_Unit (N))) then
Check_Parent_Context (Parent_Spec (Unit (Library_Unit (N))));
end if;
end if;
end Check_With_Type_Clauses;
------------------------------
-- Check_Private_Child_Unit --
------------------------------
procedure Check_Private_Child_Unit (N : Node_Id) is
Lib_Unit : constant Node_Id := Unit (N);
Item : Node_Id;
Curr_Unit : Entity_Id;
Sub_Parent : Node_Id;
Priv_Child : Entity_Id;
Par_Lib : Entity_Id;
Par_Spec : Node_Id;
function Is_Private_Library_Unit (Unit : Entity_Id) return Boolean;
-- Returns true if and only if the library unit is declared with
-- an explicit designation of private.
function Is_Private_Library_Unit (Unit : Entity_Id) return Boolean is
begin
return Private_Present (Parent (Unit_Declaration_Node (Unit)));
end Is_Private_Library_Unit;
-- Start of processing for Check_Private_Child_Unit
begin
if Nkind (Lib_Unit) = N_Package_Body
or else Nkind (Lib_Unit) = N_Subprogram_Body
then
Curr_Unit := Defining_Entity (Unit (Library_Unit (N)));
Par_Lib := Curr_Unit;
elsif Nkind (Lib_Unit) = N_Subunit then
-- The parent is itself a body. The parent entity is to be found
-- in the corresponding spec.
Sub_Parent := Library_Unit (N);
Curr_Unit := Defining_Entity (Unit (Library_Unit (Sub_Parent)));
-- If the parent itself is a subunit, Curr_Unit is the entity
-- of the enclosing body, retrieve the spec entity which is
-- the proper ancestor we need for the following tests.
if Ekind (Curr_Unit) = E_Package_Body then
Curr_Unit := Spec_Entity (Curr_Unit);
end if;
Par_Lib := Curr_Unit;
else
Curr_Unit := Defining_Entity (Lib_Unit);
Par_Lib := Curr_Unit;
Par_Spec := Parent_Spec (Lib_Unit);
if No (Par_Spec) then
Par_Lib := Empty;
else
Par_Lib := Defining_Entity (Unit (Par_Spec));
end if;
end if;
-- Loop through context items
Item := First (Context_Items (N));
while Present (Item) loop
if Nkind (Item) = N_With_Clause
and then not Implicit_With (Item)
and then Is_Private_Descendant (Entity (Name (Item)))
then
Priv_Child := Entity (Name (Item));
declare
Curr_Parent : Entity_Id := Par_Lib;
Child_Parent : Entity_Id := Scope (Priv_Child);
Prv_Ancestor : Entity_Id := Child_Parent;
Curr_Private : Boolean := Is_Private_Library_Unit (Curr_Unit);
begin
-- If the child unit is a public child then locate
-- the nearest private ancestor; Child_Parent will
-- then be set to the parent of that ancestor.
if not Is_Private_Library_Unit (Priv_Child) then
while Present (Prv_Ancestor)
and then not Is_Private_Library_Unit (Prv_Ancestor)
loop
Prv_Ancestor := Scope (Prv_Ancestor);
end loop;
if Present (Prv_Ancestor) then
Child_Parent := Scope (Prv_Ancestor);
end if;
end if;
while Present (Curr_Parent)
and then Curr_Parent /= Standard_Standard
and then Curr_Parent /= Child_Parent
loop
Curr_Private :=
Curr_Private or else Is_Private_Library_Unit (Curr_Parent);
Curr_Parent := Scope (Curr_Parent);
end loop;
if not Present (Curr_Parent) then
Curr_Parent := Standard_Standard;
end if;
if Curr_Parent /= Child_Parent then
if Ekind (Priv_Child) = E_Generic_Package
and then Chars (Priv_Child) in Text_IO_Package_Name
and then Chars (Scope (Scope (Priv_Child))) = Name_Ada
then
Error_Msg_NE
("& is a nested package, not a compilation unit",
Name (Item), Priv_Child);
else
Error_Msg_N
("unit in with clause is private child unit!", Item);
Error_Msg_NE
("current unit must also have parent&!",
Item, Child_Parent);
end if;
elsif not Curr_Private
and then Nkind (Lib_Unit) /= N_Package_Body
and then Nkind (Lib_Unit) /= N_Subprogram_Body
and then Nkind (Lib_Unit) /= N_Subunit
then
Error_Msg_NE
("current unit must also be private descendant of&",
Item, Child_Parent);
end if;
end;
end if;
Next (Item);
end loop;
end Check_Private_Child_Unit;
----------------------
-- Check_Stub_Level --
----------------------
procedure Check_Stub_Level (N : Node_Id) is
Par : constant Node_Id := Parent (N);
Kind : constant Node_Kind := Nkind (Par);
begin
if (Kind = N_Package_Body
or else Kind = N_Subprogram_Body
or else Kind = N_Task_Body
or else Kind = N_Protected_Body)
and then (Nkind (Parent (Par)) = N_Compilation_Unit
or else Nkind (Parent (Par)) = N_Subunit)
then
null;
-- In an instance, a missing stub appears at any level. A warning
-- message will have been emitted already for the missing file.
elsif not In_Instance then
Error_Msg_N ("stub cannot appear in an inner scope", N);
elsif Expander_Active then
Error_Msg_N ("missing proper body", N);
end if;
end Check_Stub_Level;
------------------------
-- Expand_With_Clause --
------------------------
procedure Expand_With_Clause (Nam : Node_Id; N : Node_Id) is
Loc : constant Source_Ptr := Sloc (Nam);
Ent : constant Entity_Id := Entity (Nam);
Withn : Node_Id;
P : Node_Id;
function Build_Unit_Name (Nam : Node_Id) return Node_Id;
function Build_Unit_Name (Nam : Node_Id) return Node_Id is
Result : Node_Id;
begin
if Nkind (Nam) = N_Identifier then
return New_Occurrence_Of (Entity (Nam), Loc);
else
Result :=
Make_Expanded_Name (Loc,
Chars => Chars (Entity (Nam)),
Prefix => Build_Unit_Name (Prefix (Nam)),
Selector_Name => New_Occurrence_Of (Entity (Nam), Loc));
Set_Entity (Result, Entity (Nam));
return Result;
end if;
end Build_Unit_Name;
begin
New_Nodes_OK := New_Nodes_OK + 1;
Withn :=
Make_With_Clause (Loc, Name => Build_Unit_Name (Nam));
P := Parent (Unit_Declaration_Node (Ent));
Set_Library_Unit (Withn, P);
Set_Corresponding_Spec (Withn, Ent);
Set_First_Name (Withn, True);
Set_Implicit_With (Withn, True);
Prepend (Withn, Context_Items (N));
Mark_Rewrite_Insertion (Withn);
Install_Withed_Unit (Withn);
if Nkind (Nam) = N_Expanded_Name then
Expand_With_Clause (Prefix (Nam), N);
end if;
New_Nodes_OK := New_Nodes_OK - 1;
end Expand_With_Clause;
-----------------------------
-- Implicit_With_On_Parent --
-----------------------------
procedure Implicit_With_On_Parent
(Child_Unit : Node_Id;
N : Node_Id)
is
Loc : constant Source_Ptr := Sloc (N);
P : constant Node_Id := Parent_Spec (Child_Unit);
P_Unit : constant Node_Id := Unit (P);
P_Name : Entity_Id := Defining_Entity (P_Unit);
Withn : Node_Id;
function Build_Ancestor_Name (P : Node_Id) return Node_Id;
-- Build prefix of child unit name. Recurse if needed.
function Build_Unit_Name return Node_Id;
-- If the unit is a child unit, build qualified name with all
-- ancestors.
-------------------------
-- Build_Ancestor_Name --
-------------------------
function Build_Ancestor_Name (P : Node_Id) return Node_Id is
P_Ref : Node_Id := New_Reference_To (Defining_Entity (P), Loc);
begin
if No (Parent_Spec (P)) then
return P_Ref;
else
return
Make_Selected_Component (Loc,
Prefix => Build_Ancestor_Name (Unit (Parent_Spec (P))),
Selector_Name => P_Ref);
end if;
end Build_Ancestor_Name;
---------------------
-- Build_Unit_Name --
---------------------
function Build_Unit_Name return Node_Id is
Result : Node_Id;
begin
if No (Parent_Spec (P_Unit)) then
return New_Reference_To (P_Name, Loc);
else
Result :=
Make_Expanded_Name (Loc,
Chars => Chars (P_Name),
Prefix => Build_Ancestor_Name (Unit (Parent_Spec (P_Unit))),
Selector_Name => New_Reference_To (P_Name, Loc));
Set_Entity (Result, P_Name);
return Result;
end if;
end Build_Unit_Name;
-- Start of processing for Implicit_With_On_Parent
begin
New_Nodes_OK := New_Nodes_OK + 1;
Withn := Make_With_Clause (Loc, Name => Build_Unit_Name);
Set_Library_Unit (Withn, P);
Set_Corresponding_Spec (Withn, P_Name);
Set_First_Name (Withn, True);
Set_Implicit_With (Withn, True);
-- Node is placed at the beginning of the context items, so that
-- subsequent use clauses on the parent can be validated.
Prepend (Withn, Context_Items (N));
Mark_Rewrite_Insertion (Withn);
Install_Withed_Unit (Withn);
if Is_Child_Spec (P_Unit) then
Implicit_With_On_Parent (P_Unit, N);
end if;
New_Nodes_OK := New_Nodes_OK - 1;
end Implicit_With_On_Parent;
---------------------
-- Install_Context --
---------------------
procedure Install_Context (N : Node_Id) is
Lib_Unit : Node_Id := Unit (N);
begin
Install_Context_Clauses (N);
if Is_Child_Spec (Lib_Unit) then
Install_Parents (Lib_Unit, Private_Present (Parent (Lib_Unit)));
end if;
Check_With_Type_Clauses (N);
end Install_Context;
-----------------------------
-- Install_Context_Clauses --
-----------------------------
procedure Install_Context_Clauses (N : Node_Id) is
Lib_Unit : Node_Id := Unit (N);
Item : Node_Id;
Uname_Node : Entity_Id;
Check_Private : Boolean := False;
Decl_Node : Node_Id;
Lib_Parent : Entity_Id;
begin
-- Loop through context clauses to find the with/use clauses
Item := First (Context_Items (N));
while Present (Item) loop
-- Case of explicit WITH clause
if Nkind (Item) = N_With_Clause
and then not Implicit_With (Item)
then
-- If Name (Item) is not an entity name, something is wrong, and
-- this will be detected in due course, for now ignore the item
if not Is_Entity_Name (Name (Item)) then
goto Continue;
end if;
Uname_Node := Entity (Name (Item));
if Is_Private_Descendant (Uname_Node) then
Check_Private := True;
end if;
Install_Withed_Unit (Item);
Decl_Node := Unit_Declaration_Node (Uname_Node);
-- If the unit is a subprogram instance, it appears nested
-- within a package that carries the parent information.
if Is_Generic_Instance (Uname_Node)
and then Ekind (Uname_Node) /= E_Package
then
Decl_Node := Parent (Parent (Decl_Node));
end if;
if Is_Child_Spec (Decl_Node) then
if Nkind (Name (Item)) = N_Expanded_Name then
Expand_With_Clause (Prefix (Name (Item)), N);
else
-- if not an expanded name, the child unit must be a
-- renaming, nothing to do.
null;
end if;
elsif Nkind (Decl_Node) = N_Subprogram_Body
and then not Acts_As_Spec (Parent (Decl_Node))
and then Is_Child_Spec (Unit (Library_Unit (Parent (Decl_Node))))
then
Implicit_With_On_Parent
(Unit (Library_Unit (Parent (Decl_Node))), N);
end if;
-- Check license conditions unless this is a dummy unit
if Sloc (Library_Unit (Item)) /= No_Location then
License_Check : declare
Withl : constant License_Type :=
License (Source_Index
(Get_Source_Unit
(Library_Unit (Item))));
Unitl : constant License_Type :=
License (Source_Index (Current_Sem_Unit));
procedure License_Error;
-- Signal error of bad license
-------------------
-- License_Error --
-------------------
procedure License_Error is
begin
Error_Msg_N
("?license of with'ed unit & is incompatible",
Name (Item));
end License_Error;
-- Start of processing for License_Check
begin
case Unitl is
when Unknown =>
null;
when Restricted =>
if Withl = GPL then
License_Error;
end if;
when GPL =>
if Withl = Restricted then
License_Error;
end if;
when Modified_GPL =>
if Withl = Restricted or else Withl = GPL then
License_Error;
end if;
when Unrestricted =>
null;
end case;
end License_Check;
end if;
-- Case of USE PACKAGE clause
elsif Nkind (Item) = N_Use_Package_Clause then
Analyze_Use_Package (Item);
-- Case of USE TYPE clause
elsif Nkind (Item) = N_Use_Type_Clause then
Analyze_Use_Type (Item);
-- Case of WITH TYPE clause
-- A With_Type_Clause is processed when installing the context,
-- because it is a visibility mechanism and does not create a
-- semantic dependence on other units, as a With_Clause does.
elsif Nkind (Item) = N_With_Type_Clause then
Analyze_With_Type_Clause (Item);
-- case of PRAGMA
elsif Nkind (Item) = N_Pragma then
Analyze (Item);
end if;
<<Continue>>
Next (Item);
end loop;
if Is_Child_Spec (Lib_Unit) then
-- The unit also has implicit withs on its own parents.
if No (Context_Items (N)) then
Set_Context_Items (N, New_List);
end if;
Implicit_With_On_Parent (Lib_Unit, N);
end if;
-- If the unit is a body, the context of the specification must also
-- be installed.
if Nkind (Lib_Unit) = N_Package_Body
or else (Nkind (Lib_Unit) = N_Subprogram_Body
and then not Acts_As_Spec (N))
then
Install_Context (Library_Unit (N));
if Is_Child_Spec (Unit (Library_Unit (N))) then
-- If the unit is the body of a public child unit, the private
-- declarations of the parent must be made visible. If the child
-- unit is private, the private declarations have been installed
-- already in the call to Install_Parents for the spec. Installing
-- private declarations must be done for all ancestors of public
-- child units. In addition, sibling units mentioned in the
-- context clause of the body are directly visible.
declare
Lib_Spec : Node_Id := Unit (Library_Unit (N));
P : Node_Id;
P_Name : Entity_Id;
begin
while Is_Child_Spec (Lib_Spec) loop
P := Unit (Parent_Spec (Lib_Spec));
if not (Private_Present (Parent (Lib_Spec))) then
P_Name := Defining_Entity (P);
Install_Private_Declarations (P_Name);
Set_Use (Private_Declarations (Specification (P)));
end if;
Lib_Spec := P;
end loop;
end;
end if;
-- For a package body, children in context are immediately visible
Install_Siblings (Defining_Entity (Unit (Library_Unit (N))), N);
end if;
if Nkind (Lib_Unit) = N_Generic_Package_Declaration
or else Nkind (Lib_Unit) = N_Generic_Subprogram_Declaration
or else Nkind (Lib_Unit) = N_Package_Declaration
or else Nkind (Lib_Unit) = N_Subprogram_Declaration
then
if Is_Child_Spec (Lib_Unit) then
Lib_Parent := Defining_Entity (Unit (Parent_Spec (Lib_Unit)));
Set_Is_Private_Descendant
(Defining_Entity (Lib_Unit),
Is_Private_Descendant (Lib_Parent)
or else Private_Present (Parent (Lib_Unit)));
else
Set_Is_Private_Descendant
(Defining_Entity (Lib_Unit),
Private_Present (Parent (Lib_Unit)));
end if;
end if;
if Check_Private then
Check_Private_Child_Unit (N);
end if;
end Install_Context_Clauses;
---------------------
-- Install_Parents --
---------------------
procedure Install_Parents (Lib_Unit : Node_Id; Is_Private : Boolean) is
P : Node_Id;
E_Name : Entity_Id;
P_Name : Entity_Id;
P_Spec : Node_Id;
begin
P := Unit (Parent_Spec (Lib_Unit));
P_Name := Defining_Entity (P);
if Etype (P_Name) = Any_Type then
return;
end if;
if Ekind (P_Name) = E_Generic_Package
and then Nkind (Lib_Unit) /= N_Generic_Subprogram_Declaration
and then Nkind (Lib_Unit) /= N_Generic_Package_Declaration
and then Nkind (Lib_Unit) not in N_Generic_Renaming_Declaration
then
Error_Msg_N
("child of a generic package must be a generic unit", Lib_Unit);
elsif not Is_Package (P_Name) then
Error_Msg_N
("parent unit must be package or generic package", Lib_Unit);
raise Unrecoverable_Error;
elsif Present (Renamed_Object (P_Name)) then
Error_Msg_N ("parent unit cannot be a renaming", Lib_Unit);
raise Unrecoverable_Error;
-- Verify that a child of an instance is itself an instance, or
-- the renaming of one. Given that an instance that is a unit is
-- replaced with a package declaration, check against the original
-- node.
elsif Nkind (Original_Node (P)) = N_Package_Instantiation
and then Nkind (Lib_Unit)
not in N_Renaming_Declaration
and then Nkind (Original_Node (Lib_Unit))
not in N_Generic_Instantiation
then
Error_Msg_N
("child of an instance must be an instance or renaming", Lib_Unit);
end if;
-- This is the recursive call that ensures all parents are loaded
if Is_Child_Spec (P) then
Install_Parents (P,
Is_Private or else Private_Present (Parent (Lib_Unit)));
end if;
-- Now we can install the context for this parent
Install_Context_Clauses (Parent_Spec (Lib_Unit));
Install_Siblings (P_Name, Parent (Lib_Unit));
-- The child unit is in the declarative region of the parent. The
-- parent must therefore appear in the scope stack and be visible,
-- as when compiling the corresponding body. If the child unit is
-- private or it is a package body, private declarations must be
-- accessible as well. Use declarations in the parent must also
-- be installed. Finally, other child units of the same parent that
-- are in the context are immediately visible.
-- Find entity for compilation unit, and set its private descendant
-- status as needed.
E_Name := Defining_Entity (Lib_Unit);
Set_Is_Child_Unit (E_Name);
Set_Is_Private_Descendant (E_Name,
Is_Private_Descendant (P_Name)
or else Private_Present (Parent (Lib_Unit)));
P_Spec := Specification (Unit_Declaration_Node (P_Name));
New_Scope (P_Name);
-- Save current visibility of unit
Scope_Stack.Table (Scope_Stack.Last).Previous_Visibility :=
Is_Immediately_Visible (P_Name);
Set_Is_Immediately_Visible (P_Name);
Install_Visible_Declarations (P_Name);
Set_Use (Visible_Declarations (P_Spec));
if Is_Private
or else Private_Present (Parent (Lib_Unit))
then
Install_Private_Declarations (P_Name);
Set_Use (Private_Declarations (P_Spec));
end if;
end Install_Parents;
----------------------
-- Install_Siblings --
----------------------
procedure Install_Siblings (U_Name : Entity_Id; N : Node_Id) is
Item : Node_Id;
Id : Entity_Id;
Prev : Entity_Id;
function Is_Ancestor (E : Entity_Id) return Boolean;
-- Determine whether the scope of a child unit is an ancestor of
-- the current unit.
-- Shouldn't this be somewhere more general ???
function Is_Ancestor (E : Entity_Id) return Boolean is
Par : Entity_Id;
begin
Par := U_Name;
while Present (Par)
and then Par /= Standard_Standard
loop
if Par = E then
return True;
end if;
Par := Scope (Par);
end loop;
return False;
end Is_Ancestor;
-- Start of processing for Install_Siblings
begin
-- Iterate over explicit with clauses, and check whether the
-- scope of each entity is an ancestor of the current unit.
Item := First (Context_Items (N));
while Present (Item) loop
if Nkind (Item) = N_With_Clause
and then not Implicit_With (Item)
then
Id := Entity (Name (Item));
if Is_Child_Unit (Id)
and then Is_Ancestor (Scope (Id))
then
Set_Is_Immediately_Visible (Id);
Prev := Current_Entity (Id);
-- Check for the presence of another unit in the context,
-- that may be inadvertently hidden by the child.
if Present (Prev)
and then Is_Immediately_Visible (Prev)
and then not Is_Child_Unit (Prev)
then
declare
Clause : Node_Id;
begin
Clause := First (Context_Items (N));
while Present (Clause) loop
if Nkind (Clause) = N_With_Clause
and then Entity (Name (Clause)) = Prev
then
Error_Msg_NE
("child unit& hides compilation unit " &
"with the same name?",
Name (Item), Id);
exit;
end if;
Next (Clause);
end loop;
end;
end if;
-- the With_Clause may be on a grand-child, which makes
-- the child immediately visible.
elsif Is_Child_Unit (Scope (Id))
and then Is_Ancestor (Scope (Scope (Id)))
then
Set_Is_Immediately_Visible (Scope (Id));
end if;
end if;
Next (Item);
end loop;
end Install_Siblings;
-------------------------
-- Install_Withed_Unit --
-------------------------
procedure Install_Withed_Unit (With_Clause : Node_Id) is
Uname : Entity_Id := Entity (Name (With_Clause));
P : constant Entity_Id := Scope (Uname);
begin
-- We do not apply the restrictions to an internal unit unless
-- we are compiling the internal unit as a main unit. This check
-- is also skipped for dummy units (for missing packages).
if Sloc (Uname) /= No_Location
and then (not Is_Internal_File_Name (Unit_File_Name (Current_Sem_Unit))
or else Current_Sem_Unit = Main_Unit)
then
Check_Restricted_Unit
(Unit_Name (Get_Source_Unit (Uname)), With_Clause);
end if;
if P /= Standard_Standard then
-- If the unit is not analyzed after analysis of the with clause,
-- and it is an instantiation, then it awaits a body and is the main
-- unit. Its appearance in the context of some other unit indicates
-- a circular dependency (DEC suite perversity).
if not Analyzed (Uname)
and then Nkind (Parent (Uname)) = N_Package_Instantiation
then
Error_Msg_N
("instantiation depends on itself", Name (With_Clause));
elsif not Is_Visible_Child_Unit (Uname) then
Set_Is_Visible_Child_Unit (Uname);
if Is_Generic_Instance (Uname)
and then Ekind (Uname) in Subprogram_Kind
then
-- Set flag as well on the visible entity that denotes the
-- instance, which renames the current one.
Set_Is_Visible_Child_Unit
(Related_Instance
(Defining_Entity (Unit (Library_Unit (With_Clause)))));
null;
end if;
-- The parent unit may have been installed already, and
-- may have appeared in a use clause.
if In_Use (Scope (Uname)) then
Set_Is_Potentially_Use_Visible (Uname);
end if;
Set_Context_Installed (With_Clause);
end if;
elsif not Is_Immediately_Visible (Uname) then
Set_Is_Immediately_Visible (Uname);
Set_Context_Installed (With_Clause);
end if;
-- A with-clause overrides a with-type clause: there are no restric-
-- tions on the use of package entities.
if Ekind (Uname) = E_Package then
Set_From_With_Type (Uname, False);
end if;
end Install_Withed_Unit;
-------------------
-- Is_Child_Spec --
-------------------
function Is_Child_Spec (Lib_Unit : Node_Id) return Boolean is
K : constant Node_Kind := Nkind (Lib_Unit);
begin
return (K in N_Generic_Declaration or else
K in N_Generic_Instantiation or else
K in N_Generic_Renaming_Declaration or else
K = N_Package_Declaration or else
K = N_Package_Renaming_Declaration or else
K = N_Subprogram_Declaration or else
K = N_Subprogram_Renaming_Declaration)
and then Present (Parent_Spec (Lib_Unit));
end Is_Child_Spec;
-----------------------
-- Load_Needed_Body --
-----------------------
-- N is a generic unit named in a with clause, or else it is
-- a unit that contains a generic unit or an inlined function.
-- In order to perform an instantiation, the body of the unit
-- must be present. If the unit itself is generic, we assume
-- that an instantiation follows, and load and analyze the body
-- unconditionally. This forces analysis of the spec as well.
-- If the unit is not generic, but contains a generic unit, it
-- is loaded on demand, at the point of instantiation (see ch12).
procedure Load_Needed_Body (N : Node_Id; OK : out Boolean) is
Body_Name : Unit_Name_Type;
Unum : Unit_Number_Type;
Save_Style_Check : constant Boolean := Opt.Style_Check;
-- The loading and analysis is done with style checks off
begin
if not GNAT_Mode then
Style_Check := False;
end if;
Body_Name := Get_Body_Name (Get_Unit_Name (Unit (N)));
Unum :=
Load_Unit
(Load_Name => Body_Name,
Required => False,
Subunit => False,
Error_Node => N,
Renamings => True);
if Unum = No_Unit then
OK := False;
else
Compiler_State := Analyzing; -- reset after load
if not Fatal_Error (Unum) then
if Debug_Flag_L then
Write_Str ("*** Loaded generic body");
Write_Eol;
end if;
Semantics (Cunit (Unum));
end if;
OK := True;
end if;
Style_Check := Save_Style_Check;
end Load_Needed_Body;
--------------------
-- Remove_Context --
--------------------
procedure Remove_Context (N : Node_Id) is
Lib_Unit : constant Node_Id := Unit (N);
begin
-- If this is a child unit, first remove the parent units.
if Is_Child_Spec (Lib_Unit) then
Remove_Parents (Lib_Unit);
end if;
Remove_Context_Clauses (N);
end Remove_Context;
----------------------------
-- Remove_Context_Clauses --
----------------------------
procedure Remove_Context_Clauses (N : Node_Id) is
Item : Node_Id;
Unit_Name : Entity_Id;
begin
-- Loop through context items and undo with_clauses and use_clauses.
Item := First (Context_Items (N));
while Present (Item) loop
-- We are interested only in with clauses which got installed
-- on entry, as indicated by their Context_Installed flag set
if Nkind (Item) = N_With_Clause
and then Context_Installed (Item)
then
-- Remove items from one with'ed unit
Unit_Name := Entity (Name (Item));
Remove_Unit_From_Visibility (Unit_Name);
Set_Context_Installed (Item, False);
elsif Nkind (Item) = N_Use_Package_Clause then
End_Use_Package (Item);
elsif Nkind (Item) = N_Use_Type_Clause then
End_Use_Type (Item);
elsif Nkind (Item) = N_With_Type_Clause then
Remove_With_Type_Clause (Name (Item));
end if;
Next (Item);
end loop;
end Remove_Context_Clauses;
--------------------
-- Remove_Parents --
--------------------
procedure Remove_Parents (Lib_Unit : Node_Id) is
P : Node_Id;
P_Name : Entity_Id;
E : Entity_Id;
Vis : constant Boolean :=
Scope_Stack.Table (Scope_Stack.Last).Previous_Visibility;
begin
if Is_Child_Spec (Lib_Unit) then
P := Unit (Parent_Spec (Lib_Unit));
P_Name := Defining_Entity (P);
Remove_Context_Clauses (Parent_Spec (Lib_Unit));
End_Package_Scope (P_Name);
Set_Is_Immediately_Visible (P_Name, Vis);
-- Remove from visibility the siblings as well, which are directly
-- visible while the parent is in scope.
E := First_Entity (P_Name);
while Present (E) loop
if Is_Child_Unit (E) then
Set_Is_Immediately_Visible (E, False);
end if;
Next_Entity (E);
end loop;
Set_In_Package_Body (P_Name, False);
-- This is the recursive call to remove the context of any
-- higher level parent. This recursion ensures that all parents
-- are removed in the reverse order of their installation.
Remove_Parents (P);
end if;
end Remove_Parents;
-----------------------------
-- Remove_With_Type_Clause --
-----------------------------
procedure Remove_With_Type_Clause (Name : Node_Id) is
Typ : Entity_Id;
P : Entity_Id;
procedure Unchain (E : Entity_Id);
-- Remove entity from visibility list.
procedure Unchain (E : Entity_Id) is
Prev : Entity_Id;
begin
Prev := Current_Entity (E);
-- Package entity may appear is several with_type_clauses, and
-- may have been removed already.
if No (Prev) then
return;
elsif Prev = E then
Set_Name_Entity_Id (Chars (E), Homonym (E));
else
while Present (Prev)
and then Homonym (Prev) /= E
loop
Prev := Homonym (Prev);
end loop;
if (Present (Prev)) then
Set_Homonym (Prev, Homonym (E));
end if;
end if;
end Unchain;
begin
if Nkind (Name) = N_Selected_Component then
Typ := Entity (Selector_Name (Name));
if No (Typ) then -- error in declaration.
return;
end if;
else
return;
end if;
P := Scope (Typ);
-- If the exporting package has been analyzed, it has appeared in the
-- context already and should be left alone. Otherwise, remove from
-- visibility.
if not Analyzed (Unit_Declaration_Node (P)) then
Unchain (P);
Unchain (Typ);
Set_Is_Frozen (Typ, False);
end if;
if Ekind (Typ) = E_Record_Type then
Set_From_With_Type (Class_Wide_Type (Typ), False);
Set_From_With_Type (Typ, False);
end if;
Set_From_With_Type (P, False);
-- If P is a child unit, remove parents as well.
P := Scope (P);
while Present (P)
and then P /= Standard_Standard
loop
Set_From_With_Type (P, False);
if not Analyzed (Unit_Declaration_Node (P)) then
Unchain (P);
end if;
P := Scope (P);
end loop;
-- The back-end needs to know that an access type is imported, so it
-- does not need elaboration and can appear in a mutually recursive
-- record definition, so the imported flag on an access type is
-- preserved.
end Remove_With_Type_Clause;
---------------------------------
-- Remove_Unit_From_Visibility --
---------------------------------
procedure Remove_Unit_From_Visibility (Unit_Name : Entity_Id) is
P : Entity_Id := Scope (Unit_Name);
begin
if Debug_Flag_I then
Write_Str ("remove withed unit ");
Write_Name (Chars (Unit_Name));
Write_Eol;
end if;
if P /= Standard_Standard then
Set_Is_Visible_Child_Unit (Unit_Name, False);
end if;
Set_Is_Potentially_Use_Visible (Unit_Name, False);
Set_Is_Immediately_Visible (Unit_Name, False);
end Remove_Unit_From_Visibility;
end Sem_Ch10;
|
3-mid/opengl/source/lean/opengl-frame_buffer.adb | charlie5/lace | 20 | 25821 | <filename>3-mid/opengl/source/lean/opengl-frame_buffer.adb
with
GL.lean,
GL.Binding,
openGL.Tasks,
openGL.Errors;
package body openGL.Frame_Buffer
is
package body Forge
is
function to_Frame_Buffer (Width,
Height : in Positive) return Item
is
use openGL.Texture,
GL,
GL.Binding,
GL.lean;
Self : Item;
begin
Tasks.check;
Self.Texture := openGL.Texture.Forge.to_Texture (Dimensions' (Width, Height));
glGenFramebuffers (1, Self.Name'Access);
-- Attach each texture to the first color buffer of an frame buffer object and clear it.
--
glBindFramebuffer (GL_FRAMEBUFFER, Self.Name);
glFramebufferTexture2D (GL_FRAMEBUFFER,
GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D,
Self.Texture.Name,
0);
glClear (GL_COLOR_BUFFER_BIT);
glBindFramebuffer (GL_FRAMEBUFFER, 0);
return Self;
end to_frame_Buffer;
function to_Frame_Buffer return Item
is
use openGL.Texture,
GL,
GL.lean;
Self : Item;
begin
Tasks.check;
Self.Texture := openGL.Texture.null_Object;
glGenFramebuffers (1, Self.Name'Access);
return Self;
end to_frame_Buffer;
end Forge;
procedure destruct (Self : in out Item)
is
use GL.lean;
begin
Tasks.check;
glDeleteFramebuffers (1, Self.Name'Access);
Self.Texture.destroy;
end destruct;
--------------
--- Attributes
--
function Name (Self : in Item) return Buffer_Name
is
begin
return Self.Name;
end Name;
function Texture (Self : in Item) return openGL.Texture.Object
is
begin
return Self.Texture;
end Texture;
procedure Texture_is (Self : in out Item; Now : in openGL.Texture.Object)
is
use GL,
GL.Binding,
GL.lean;
begin
Tasks.check;
openGL.Errors.log;
Self.Texture := Now;
-- Attach each texture to the first color buffer of an FBO and clear it.
--
glBindFramebuffer (GL_FRAMEBUFFER, Self.Name);
openGL.Errors.log;
glFramebufferTexture2D (GL_FRAMEBUFFER,
GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D,
Self.Texture.Name,
0);
openGL.Errors.log;
glClear (GL_COLOR_BUFFER_BIT);
openGL.Errors.log;
end Texture_is;
function is_complete (Self : in Item) return Boolean
is
use GL,
GL.lean;
use type GL.GLenum;
check_is_OK : constant Boolean := Tasks.check with Unreferenced;
Result : constant Boolean := glCheckFramebufferStatus (GL_FRAMEBUFFER) = GL_FRAMEBUFFER_COMPLETE;
begin
openGL.Errors.log;
return Result;
end is_complete;
--------------
--- Operations
--
procedure enable (Self : in Item)
is
use GL,
GL.lean;
check_is_OK : constant Boolean := Tasks.check with Unreferenced;
begin
glBindFramebuffer (GL_FRAMEBUFFER, Self.Name);
if not Self.is_Complete
then
raise openGL.Error with "GL_FRAMEBUFFER" & Self.Name'Image & " is not 'complete'";
end if;
end enable;
procedure disable (Self : in Item)
is
use GL,
GL.lean;
check_is_OK : constant Boolean := Tasks.check with Unreferenced;
begin
glBindFramebuffer (GL_FRAMEBUFFER, 0);
end disable;
end openGL.Frame_Buffer;
|
iod/con2/atmono/spray.asm | olifink/smsqe | 0 | 160390 | * Spray pixels in blob v0.00 Oct 1987 J.R.Oakley QJUMP
*
* Registers:
* Entry Exit
* D1 x,y position
* D2 number of pixels to spray
* A1 pointer to blob smashed
* A2 pointer to pattern
*
section driver
*
include 'dev8_keys_qdos_pt'
include 'dev8_keys_qdos_sms'
include 'dev8_keys_con'
*
xref pt_chkbp
xref pt_doblb
*
xdef pt_spray
xdef ptm_spray
ptm_spray
*
spryreg reg d1-d3/a1-a3
stk_a1 equ $0c
stk_a2 equ $10
stk_a3 equ $14
*
pts_exit
movem.l (sp)+,spryreg ; only come here on error
move.l (sp)+,a0
rts
*
pt_spray
move.l a0,-(sp)
movem.l spryreg,-(sp)
jsr pt_chkbp(pc) ; check blob and pattern
bne.s pts_exit ; not OK, do nothing
move.l a2,stk_a2(sp) ; keep (reset?) pattern
*
* Find out which mode we're using
*
moveq #0,d6 ; assume mode 4
; tst.b sd_wmode(a0) ; is it?
; beq.s pts_fsiz ; yes
; moveq #m8tab-m4tab,d6 ; no, get offset to mode 8 mask table
*
* Ensure there's enough space for a reduced version of the
* blob in the spray buffer: otherwise allocate a new, larger one.
*
pts_fsiz
move.w pto_xsiz(a1),d0 ; get X size of blob...
add.w #$f,d0 ; ...and round it up... $$$$$
and.w #$fff0,d0 ; ...to nearest 16 pixels (1 word)
lsr.w #3,d0 ; thus width in bytes $$$$$
move.w d0,d5 ; keep this safe
mulu pto_ysiz(a1),d0 ; thus total size...
moveq #pto.hdrl,d4 ; ...plus header...
add.l d0,d4 ; ...makes space required
*
move.l pt_spbuf(a3),d0 ; do we have a spray buffer?
move.l d0,a0
beq.s pts_achp ; no, allocate one
cmp.l pt_spbsz(a3),d4 ; yes, is it big enough?
ble.s pts_mkbl ; yes, make the blob
clr.l pt_spbuf(a3) ; no, we're going to throw it away
moveq #sms.rchp,d0
trap #1 ; return old buffer
pts_achp
move.l d4,d1 ; get size required
moveq #0,d2 ; it belongs to the system
moveq #sms.achp,d0
trap #1 ; allocate space for buffer
tst.l d0
bne.s pts_exit ; ...oops
subq.l #8,d1 ; space allocated...
subq.l #8,d1 ; ...is this much
move.l stk_a3(sp),a3 ; restore pointer to dddb
move.l a0,pt_spbuf(a3) ; fill in address
move.l d1,pt_spbsz(a3) ; and size
move.l d1,d4
movem.l (sp),spryreg
*
* Copy the actual blob's header into the spray buffer
*
pts_mkbl
move.l a0,stk_a1(sp) ; change blob to point to buffer
move.l a1,a4 ; smashable copy of blob
move.l (a4)+,(a0)+ ; copy form and adaption
move.l (a4)+,(a0)+ ; and size
move.l (a4)+,(a0)+ ; and repeat
clr.l (a0)+ ; shouldn't have a pattern anyway
move.l #8,(a0)+ ; mask is after header in buffer
clr.l (a0)+ ; and there's no next
*
moveq #pto.hdrl,d0 ; rest is...
sub.l d0,d4 ; ...this long...
lsr.l #2,d4 ; ...in long words
move.l a0,a4 ; it's here
moveq #0,d0
bra.s pts_clre ; so
pts_clrl
move.l d0,(a4)+ ; clear it
pts_clre
dbra d4,pts_clrl
*
move.w pt_randi(a3),d4 ; get current random number
move.w d4,d7 ; keep a copy
move.l pto_mask(a1),a4 ; point to...
lea pto_mask(a1,a4.l),a4 ; ...blob's mask
move.l pto_size(a1),d3 ; size of blob
*
* We now have
*
* D2 number of pixels to set
* D3 x,y size of blob
* D4 random number
* D5 mask line length in bytes
* D6 offset of pixel table from M4TAB
* D7 original random number
* A0 pointer to mask in buffer
* A4 pointer to mask in blob
*
bra.s pts_rnde
pts_rndl
move.l a4,a2 ; point to blob mask
move.l a0,a3 ; and buffer mask
mulu #pt.randm,d4 ; make a new random number
addq.w #pt.randa,d4
move.w d4,d0 ; pretend it's 0 to .9999
mulu d3,d0 ; and make 0 to...
swap d0 ; ...n-1
swap d3 ; get x for later
mulu d5,d0 ; giving offset in mask
add.l d0,a2 ; point to line in mask
add.l d0,a3 ; and in buffer
*
mulu #pt.randm,d4 ; now another random number
addq.w #pt.randa,d4
move.w d4,d0 ; same trick for X
mulu d3,d0 ; to get
swap d0 ; 0..n-1
swap d3 ; get Y size for later
move.w d0,d1 ; word offset is...
and.w #$fff0,d1 ; ...all but three LSBs $$$$$
sub.w d1,d0 ; make bit offset
add.w d0,d0 ; offset in table
add.w d6,d0 ; this is the table to use
move.w m4tab(pc,d0.w),d0 ; get appropriate mask
*
lsr.w #3,d1 ; offset in this line of blob... $$$$
and.w 0(a2,d1.w),d0 ; ...gives pixel to spray
beq.s pts_chkr ; no pixel, just check random number
add.w d1,a3 ; where to set pixel
move.w d0,d1
and.w (a3),d1 ; is pixel already set?
bne.s pts_chkr ; yes, can't count it then
or.w d0,(a3) ; add pixel to any in buffer
subq.w #1,d2 ; it's a new one
pts_chkr
cmp.w d4,d7 ; back to the first random number?
beq.s pts_fend ; yes, give up
pts_rnde
tst.w d2 ; more to do?
bne.s pts_rndl ; yes
pts_fend
*
movem.l (sp)+,spryreg
move.l (sp)+,a0
move.w d4,pt_randi(a3) ; keep new random number
jmp pt_doblb(pc) ; and do 'blob'
*
m4tab
dc.w $8000,$4000,$2000,$1000
dc.w $0800,$0400,$0200,$0100
dc.w $0080,$0040,$0020,$0010
dc.w $0008,$0004,$0002,$0001
m8tab
; dc.w $c0c0,$c0c0,$3030,$3030
; dc.w $0c0c,$0c0c,$0303,$0303
*
end
|
test/Fail/ModuleInMutual.agda | cruhland/agda | 1,989 | 6929 | <reponame>cruhland/agda
-- Currently modules are not allowed in mutual blocks.
-- This might change.
module ModuleInMutual where
mutual
module A where
T : Set -> Set
T A = A
module B where
U : Set -> Set
U B = B
|
programs/oeis/051/A051801.asm | neoneye/loda | 22 | 100738 | ; A051801: Product of the nonzero digits of n.
; 1,1,2,3,4,5,6,7,8,9,1,1,2,3,4,5,6,7,8,9,2,2,4,6,8,10,12,14,16,18,3,3,6,9,12,15,18,21,24,27,4,4,8,12,16,20,24,28,32,36,5,5,10,15,20,25,30,35,40,45,6,6,12,18,24,30,36,42,48,54,7,7,14,21,28,35,42,49,56,63,8,8,16,24,32,40,48,56,64,72,9,9,18,27,36,45,54,63,72,81
mov $1,8
lpb $0
mov $2,$0
div $0,10
mod $2,10
mov $3,$2
cmp $3,0
add $2,$3
mul $1,$2
lpe
div $1,8
mov $0,$1
|
programs/oeis/189/A189574.asm | neoneye/loda | 22 | 10654 | ; A189574: Partial sums of A189572.
; 0,1,1,1,2,2,3,3,4,4,4,5,5,6,6,6,7,7,8,8,8,9,9,10,10,11,11,11,12,12,13,13,13,14,14,15,15,16,16,16,17,17,18,18,18,19,19,20,20,21,21,21,22,22,23,23,23,24,24,25,25,25,26,26,27,27,28,28,28,29,29,30,30,30,31,31,32,32,33,33,33,34,34
mov $1,$0
seq $0,1953 ; a(n) = floor((n + 1/2) * sqrt(2)).
sub $0,$1
|
out/UTLC/Syntax.agda | JoeyEremondi/agda-soas | 39 | 10123 | {-
This second-order term syntax was created from the following second-order syntax description:
syntax UTLC | Λ
type
* : 0-ary
term
app : * * -> * | _$_ l20
lam : *.* -> * | ƛ_ r10
theory
(ƛβ) b : *.* a : * |> app (lam (x.b[x]), a) = b[a]
(ƛη) f : * |> lam (x.app (f, x)) = f
(lβ) b : *.* a : * |> letd (a, x. b) = b[a]
-}
module UTLC.Syntax where
open import SOAS.Common
open import SOAS.Context
open import SOAS.Variable
open import SOAS.Families.Core
open import SOAS.Construction.Structure
open import SOAS.ContextMaps.Inductive
open import SOAS.Metatheory.Syntax
open import UTLC.Signature
private
variable
Γ Δ Π : Ctx
α : *T
𝔛 : Familyₛ
-- Inductive term declaration
module Λ:Terms (𝔛 : Familyₛ) where
data Λ : Familyₛ where
var : ℐ ⇾̣ Λ
mvar : 𝔛 α Π → Sub Λ Π Γ → Λ α Γ
_$_ : Λ * Γ → Λ * Γ → Λ * Γ
ƛ_ : Λ * (* ∙ Γ) → Λ * Γ
infixl 20 _$_
infixr 10 ƛ_
open import SOAS.Metatheory.MetaAlgebra ⅀F 𝔛
Λᵃ : MetaAlg Λ
Λᵃ = record
{ 𝑎𝑙𝑔 = λ where
(appₒ ⋮ a , b) → _$_ a b
(lamₒ ⋮ a) → ƛ_ a
; 𝑣𝑎𝑟 = var ; 𝑚𝑣𝑎𝑟 = λ 𝔪 mε → mvar 𝔪 (tabulate mε) }
module Λᵃ = MetaAlg Λᵃ
module _ {𝒜 : Familyₛ}(𝒜ᵃ : MetaAlg 𝒜) where
open MetaAlg 𝒜ᵃ
𝕤𝕖𝕞 : Λ ⇾̣ 𝒜
𝕊 : Sub Λ Π Γ → Π ~[ 𝒜 ]↝ Γ
𝕊 (t ◂ σ) new = 𝕤𝕖𝕞 t
𝕊 (t ◂ σ) (old v) = 𝕊 σ v
𝕤𝕖𝕞 (mvar 𝔪 mε) = 𝑚𝑣𝑎𝑟 𝔪 (𝕊 mε)
𝕤𝕖𝕞 (var v) = 𝑣𝑎𝑟 v
𝕤𝕖𝕞 (_$_ a b) = 𝑎𝑙𝑔 (appₒ ⋮ 𝕤𝕖𝕞 a , 𝕤𝕖𝕞 b)
𝕤𝕖𝕞 (ƛ_ a) = 𝑎𝑙𝑔 (lamₒ ⋮ 𝕤𝕖𝕞 a)
𝕤𝕖𝕞ᵃ⇒ : MetaAlg⇒ Λᵃ 𝒜ᵃ 𝕤𝕖𝕞
𝕤𝕖𝕞ᵃ⇒ = record
{ ⟨𝑎𝑙𝑔⟩ = λ{ {t = t} → ⟨𝑎𝑙𝑔⟩ t }
; ⟨𝑣𝑎𝑟⟩ = refl
; ⟨𝑚𝑣𝑎𝑟⟩ = λ{ {𝔪 = 𝔪}{mε} → cong (𝑚𝑣𝑎𝑟 𝔪) (dext (𝕊-tab mε)) } }
where
open ≡-Reasoning
⟨𝑎𝑙𝑔⟩ : (t : ⅀ Λ α Γ) → 𝕤𝕖𝕞 (Λᵃ.𝑎𝑙𝑔 t) ≡ 𝑎𝑙𝑔 (⅀₁ 𝕤𝕖𝕞 t)
⟨𝑎𝑙𝑔⟩ (appₒ ⋮ _) = refl
⟨𝑎𝑙𝑔⟩ (lamₒ ⋮ _) = refl
𝕊-tab : (mε : Π ~[ Λ ]↝ Γ)(v : ℐ α Π) → 𝕊 (tabulate mε) v ≡ 𝕤𝕖𝕞 (mε v)
𝕊-tab mε new = refl
𝕊-tab mε (old v) = 𝕊-tab (mε ∘ old) v
module _ (g : Λ ⇾̣ 𝒜)(gᵃ⇒ : MetaAlg⇒ Λᵃ 𝒜ᵃ g) where
open MetaAlg⇒ gᵃ⇒
𝕤𝕖𝕞! : (t : Λ α Γ) → 𝕤𝕖𝕞 t ≡ g t
𝕊-ix : (mε : Sub Λ Π Γ)(v : ℐ α Π) → 𝕊 mε v ≡ g (index mε v)
𝕊-ix (x ◂ mε) new = 𝕤𝕖𝕞! x
𝕊-ix (x ◂ mε) (old v) = 𝕊-ix mε v
𝕤𝕖𝕞! (mvar 𝔪 mε) rewrite cong (𝑚𝑣𝑎𝑟 𝔪) (dext (𝕊-ix mε))
= trans (sym ⟨𝑚𝑣𝑎𝑟⟩) (cong (g ∘ mvar 𝔪) (tab∘ix≈id mε))
𝕤𝕖𝕞! (var v) = sym ⟨𝑣𝑎𝑟⟩
𝕤𝕖𝕞! (_$_ a b) rewrite 𝕤𝕖𝕞! a | 𝕤𝕖𝕞! b = sym ⟨𝑎𝑙𝑔⟩
𝕤𝕖𝕞! (ƛ_ a) rewrite 𝕤𝕖𝕞! a = sym ⟨𝑎𝑙𝑔⟩
-- Syntax instance for the signature
Λ:Syn : Syntax
Λ:Syn = record
{ ⅀F = ⅀F
; ⅀:CS = ⅀:CompatStr
; mvarᵢ = Λ:Terms.mvar
; 𝕋:Init = λ 𝔛 → let open Λ:Terms 𝔛 in record
{ ⊥ = Λ ⋉ Λᵃ
; ⊥-is-initial = record { ! = λ{ {𝒜 ⋉ 𝒜ᵃ} → 𝕤𝕖𝕞 𝒜ᵃ ⋉ 𝕤𝕖𝕞ᵃ⇒ 𝒜ᵃ }
; !-unique = λ{ {𝒜 ⋉ 𝒜ᵃ} (f ⋉ fᵃ⇒) {x = t} → 𝕤𝕖𝕞! 𝒜ᵃ f fᵃ⇒ t } } } }
-- Instantiation of the syntax and metatheory
open Syntax Λ:Syn public
open Λ:Terms public
open import SOAS.Families.Build public
open import SOAS.Syntax.Shorthands Λᵃ public
open import SOAS.Metatheory Λ:Syn public
-- Derived operations
letd : Λ 𝔛 * Γ → Λ 𝔛 * (* ∙ Γ) → Λ 𝔛 * Γ
letd a b = (ƛ b) $ a
|
cohomology/ProductRepr.agda | danbornside/HoTT-Agda | 0 | 14062 | {-# OPTIONS --without-K #-}
open import HoTT
open import cohomology.Exactness
open import cohomology.FunctionOver
module cohomology.ProductRepr where
{- Given the following commutative diagram of homomorphisms,
H₁ i₁ i₂ H₂
↘ ↙
id ↓ G ↓ id
↙ ↘
H₁ j₁ j₂ H₂
- there exists an isomorphism G == H₁ × H₂ such that i₁,i₂ correspond
- to the natural injections and j₁,j₂ correspond to the natural
- projections. -}
module ProductRepr {i j}
{G : Group (lmax i j)} {H₁ : Group i} {H₂ : Group j}
(i₁ : H₁ →ᴳ G) (i₂ : H₂ →ᴳ G) (j₁ : G →ᴳ H₁) (j₂ : G →ᴳ H₂)
(p₁ : ∀ h₁ → GroupHom.f j₁ (GroupHom.f i₁ h₁) == h₁)
(p₂ : ∀ h₂ → GroupHom.f j₂ (GroupHom.f i₂ h₂) == h₂)
(ex₁ : is-exact (GroupHom.⊙f i₁) (GroupHom.⊙f j₂))
(ex₂ : is-exact (GroupHom.⊙f i₂) (GroupHom.⊙f j₁))
where
zero-ker : (g : Group.El G)
→ GroupHom.f (×ᴳ-hom-in j₁ j₂) g == Group.ident (H₁ ×ᴳ H₂)
→ g == Group.ident G
zero-ker g q = Trunc-rec (Group.El-level G _ _)
(lemma g (fst×= q))
(ktoi ex₁ g (snd×= q))
where
lemma : (g : Group.El G) (r : GroupHom.f j₁ g == Group.ident H₁)
→ Σ (Group.El H₁) (λ h → GroupHom.f i₁ h == g)
→ g == Group.ident G
lemma ._ r (h , idp) =
ap (GroupHom.f i₁) (! (p₁ h) ∙ r) ∙ GroupHom.pres-ident i₁
β₁ : (h₁ : Group.El H₁) (h₂ : Group.El H₂)
→ GroupHom.f j₁ (Group.comp G (GroupHom.f i₁ h₁) (GroupHom.f i₂ h₂)) == h₁
β₁ h₁ h₂ =
GroupHom.pres-comp j₁ (GroupHom.f i₁ h₁) (GroupHom.f i₂ h₂)
∙ ap2 (Group.comp H₁) (p₁ h₁) (itok ex₂ _ [ h₂ , idp ])
∙ Group.unitr H₁ h₁
β₂ : (h₁ : Group.El H₁) (h₂ : Group.El H₂)
→ GroupHom.f j₂ (Group.comp G (GroupHom.f i₁ h₁) (GroupHom.f i₂ h₂)) == h₂
β₂ h₁ h₂ =
GroupHom.pres-comp j₂ (GroupHom.f i₁ h₁) (GroupHom.f i₂ h₂)
∙ ap2 (Group.comp H₂) (itok ex₁ _ [ h₁ , idp ]) (p₂ h₂)
∙ Group.unitl H₂ h₂
iso : G == H₁ ×ᴳ H₂
iso = surj-inj-= (×ᴳ-hom-in j₁ j₂)
(zero-kernel-injective (×ᴳ-hom-in j₁ j₂) zero-ker)
(λ {(h₁ , h₂) → [ Group.comp G (GroupHom.f i₁ h₁) (GroupHom.f i₂ h₂) ,
pair×= (β₁ h₁ h₂) (β₂ h₁ h₂) ]})
fst-over : j₁ == ×ᴳ-fst [ (λ U → U →ᴳ H₁) ↓ iso ]
fst-over = domain-over-iso _ _ _ _ $ domain-over-equiv fst _
snd-over : j₂ == ×ᴳ-snd {G = H₁} [ (λ U → U →ᴳ H₂) ↓ iso ]
snd-over = domain-over-iso _ _ _ _ $ domain-over-equiv snd _
inl-over : i₁ == ×ᴳ-inl [ (λ V → H₁ →ᴳ V) ↓ iso ]
inl-over = codomain-over-iso _ _ _ _ $
codomain-over-equiv (GroupHom.f i₁) _
▹ λ= (λ h₁ → pair×= (p₁ h₁) (itok ex₁ _ [ h₁ , idp ]))
inr-over : i₂ == ×ᴳ-inr {G = H₁} [ (λ V → H₂ →ᴳ V) ↓ iso ]
inr-over = codomain-over-iso _ _ _ _ $
codomain-over-equiv (GroupHom.f i₂) _
▹ λ= (λ h₂ → pair×= (itok ex₂ _ [ h₂ , idp ]) (p₂ h₂))
{- Given additionally maps
i₀ j₀
K –––→ G ––→ L
- such that j₀∘i₀ = 0, we have j₀(i₁(j₁(i₀ k)))⁻¹ = j₀(i₂(j₂(i₀ k))).
- (This is called the hexagon lemma in Eilenberg & Steenrod's book.
- The hexagon is not visible in this presentation.)
-}
module HexagonLemma {k l}
{K : Group k} {L : Group l}
(i₀ : K →ᴳ G) (j₀ : G →ᴳ L)
(ex₀ : ∀ g → GroupHom.f j₀ (GroupHom.f i₀ g) == Group.ident L)
where
decomp : ∀ g → Group.comp G (GroupHom.f i₁ (GroupHom.f j₁ g))
(GroupHom.f i₂ (GroupHom.f j₂ g))
== g
decomp = transport
(λ {(G' , i₁' , i₂' , j₁' , j₂') → ∀ g →
Group.comp G' (GroupHom.f i₁' (GroupHom.f j₁' g))
(GroupHom.f i₂' (GroupHom.f j₂' g))
== g})
(! (pair= iso (↓-×-in inl-over (↓-×-in inr-over
(↓-×-in fst-over snd-over)))))
(λ {(h₁ , h₂) → pair×= (Group.unitr H₁ h₁) (Group.unitl H₂ h₂)})
cancel : ∀ k →
Group.comp L (GroupHom.f (j₀ ∘ᴳ i₁ ∘ᴳ j₁ ∘ᴳ i₀) k)
(GroupHom.f (j₀ ∘ᴳ i₂ ∘ᴳ j₂ ∘ᴳ i₀) k)
== Group.ident L
cancel k = ! (GroupHom.pres-comp j₀ _ _)
∙ ap (GroupHom.f j₀) (decomp (GroupHom.f i₀ k))
∙ ex₀ k
inv₁ : ∀ k → Group.inv L (GroupHom.f (j₀ ∘ᴳ i₁ ∘ᴳ j₁ ∘ᴳ i₀) k)
== GroupHom.f (j₀ ∘ᴳ i₂ ∘ᴳ j₂ ∘ᴳ i₀) k
inv₁ k = group-inv-unique-r L _ _ (cancel k)
inv₂ : ∀ k → Group.inv L (GroupHom.f (j₀ ∘ᴳ i₂ ∘ᴳ j₂ ∘ᴳ i₀) k)
== GroupHom.f (j₀ ∘ᴳ i₁ ∘ᴳ j₁ ∘ᴳ i₀) k
inv₂ k = group-inv-unique-l L _ _ (cancel k)
|
src/main/java/org/shaneking/book/isbn9787111566489/s4c4two/Data.g4 | ShaneKingStudy/org.shaenking.study.book.isbn9787111566489 | 0 | 1086 | <gh_stars>0
grammar Data ;
file : group+ ;
group : INT sequence[$INT.int] ;
sequence[int n]
locals [int i = 1;] : ( {$i <= $n}? INT {$i++;} )* ; // match n integer
INT : [0-9]+ ;
WS: [ \t\r\n]+ -> skip;
|
programs/oeis/022/A022368.asm | neoneye/loda | 22 | 5059 | <reponame>neoneye/loda
; A022368: Fibonacci sequence beginning 2, 12.
; 2,12,14,26,40,66,106,172,278,450,728,1178,1906,3084,4990,8074,13064,21138,34202,55340,89542,144882,234424,379306,613730,993036,1606766,2599802,4206568,6806370,11012938,17819308,28832246,46651554,75483800,122135354,197619154,319754508,517373662,837128170,1354501832,2191630002,3546131834,5737761836,9283893670,15021655506,24305549176,39327204682,63632753858,102959958540,166592712398,269552670938,436145383336,705698054274,1141843437610,1847541491884,2989384929494,4836926421378,7826311350872,12663237772250,20489549123122,33152786895372,53642336018494,86795122913866,140437458932360,227232581846226,367670040778586,594902622624812,962572663403398,1557475286028210,2520047949431608,4077523235459818,6597571184891426,10675094420351244,17272665605242670,27947760025593914,45220425630836584,73168185656430498,118388611287267082,191556796943697580,309945408230964662,501502205174662242,811447613405626904,1312949818580289146,2124397431985916050,3437347250566205196,5561744682552121246,8999091933118326442,14560836615670447688,23559928548788774130,38120765164459221818,61680693713247995948,99801458877707217766,161482152590955213714,261283611468662431480,422765764059617645194,684049375528280076674,1106815139587897721868,1790864515116177798542,2897679654704075520410
mov $1,1
mov $3,6
lpb $0
sub $0,1
mov $2,$1
mov $1,$3
add $3,$2
lpe
mul $1,2
mov $0,$1
|
src/coreclr/vm/amd64/thunktemplates.asm | berkansasmaz/runtime | 8 | 241226 | ; Licensed to the .NET Foundation under one or more agreements.
; The .NET Foundation licenses this file to you under the MIT license.
include <AsmMacros.inc>
include AsmConstants.inc
PAGE_SIZE = 4096
DATA_SLOT macro stub, field
exitm @CatStr(stub, <Code + PAGE_SIZE + >, stub, <Data__>, field)
endm
LEAF_ENTRY StubPrecodeCode, _TEXT
mov r10, QWORD PTR [DATA_SLOT(StubPrecode, MethodDesc)]
jmp QWORD PTR [DATA_SLOT(StubPrecode, Target)]
LEAF_END_MARKED StubPrecodeCode, _TEXT
LEAF_ENTRY FixupPrecodeCode, _TEXT
jmp QWORD PTR [DATA_SLOT(FixupPrecode, Target)]
PATCH_LABEL FixupPrecodeCode_Fixup
mov r10, QWORD PTR [DATA_SLOT(FixupPrecode, MethodDesc)]
jmp QWORD PTR [DATA_SLOT(FixupPrecode, PrecodeFixupThunk)]
LEAF_END_MARKED FixupPrecodeCode, _TEXT
LEAF_ENTRY CallCountingStubCode, _TEXT
mov rax,QWORD PTR [DATA_SLOT(CallCountingStub, RemainingCallCountCell)]
dec WORD PTR [rax]
je CountReachedZero
jmp QWORD PTR [DATA_SLOT(CallCountingStub, TargetForMethod)]
CountReachedZero:
jmp QWORD PTR [DATA_SLOT(CallCountingStub, TargetForThresholdReached)]
LEAF_END_MARKED CallCountingStubCode, _TEXT
end
|
Screen Rotation Toggle.applescript | matatk/ScreenRotationToggle | 3 | 4661 | <gh_stars>1-10
-- Thanks to https://github.com/pykler/applescripts/blob/master/rotate_screen/RotateScreen.applescript
-- Had to add the "first" for the dropdown menu to work on 10.9
on assistive_access_check()
tell application "System Events"
if not (UI elements enabled) then
return false
else
return true
end if
end tell
end assistive_access_check
on enable_assistive_access()
-- Thanks to https://gist.github.com/iloveitaly/2ff08138091afd69cf2b
set scriptRunner to name of current application
display alert "GUI Scripting is not enabled for " & scriptRunner & "." message "Open System Preferences, unlock the Security & Privacy preference, select " & scriptRunner & " in the Privacy Pane's Accessibility list, and then run this script again." buttons {"Open System Preferences", "Cancel"} default button "Cancel"
if button returned of result is "Open System Preferences" then
tell application "System Preferences"
tell pane id "com.apple.preference.security" to reveal anchor "Privacy_Accessibility"
activate
end tell
end if
end enable_assistive_access
on main()
if assistive_access_check() then
set desktopList to {}
tell application "System Events"
set desktopList to a reference to every desktop
set targetDisplay to display name of item 1 of desktopList
end tell
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.displays"
tell application "System Events"
tell process "System Preferences"
tell window targetDisplay
-- get the old value
set oldval to value of pop up button "Rotation:" of tab group 1
if oldval is equal to "Standard" then
-- select the button, or it won't take a menu click
click pop up button "Rotation:" of tab group 1
set thedropdown to first menu of pop up button "Rotation:" of tab group 1
click menu item 2 of thedropdown
-- It takes a little while for confirm dialog to pop up
delay 2
click button "Confirm" of sheet 1
else
-- select the button, or it won't take a menu click
click pop up button "Rotation:" of tab group 1
set thedropdown to first menu of pop up button "Rotation:" of tab group 1
click menu item 1 of thedropdown
-- The sheet does not appear when switching to standard rotation
end if
end tell
end tell
end tell
quit
end tell
else
enable_assistive_access()
end if
end main
main()
|
utils/render.ads | Fabien-Chouteau/GESTE-examples | 1 | 23368 | <reponame>Fabien-Chouteau/GESTE-examples
with GESTE;
with GESTE_Config;
package Render is
procedure Push_Pixels (Buffer : GESTE.Output_Buffer);
procedure Set_Drawing_Area (Area : GESTE.Pix_Rect);
procedure Set_Screen_Offset (Pt : GESTE.Pix_Point);
procedure Render_All (Background : GESTE_Config.Output_Color);
procedure Render_Dirty (Background : GESTE_Config.Output_Color);
procedure Kill;
function Dark_Cyan return GESTE_Config.Output_Color;
function Black return GESTE_Config.Output_Color;
end Render;
|
tools/ada-larl/writers.adb | optikos/oasis | 0 | 12535 | ------------------------------------------------------------------------------
-- <NAME> <NAME> --
-- Library for dealing with grammars for Gela project, --
-- a portable Ada compiler --
-- http://gela.ada-ru.org/ --
-- - - - - - - - - - - - - - - - --
-- Read copyright and license in gela.ads file --
------------------------------------------------------------------------------
with League.String_Vectors;
with League.Characters;
package body Writers is
New_Line : constant Wide_Wide_Character := Wide_Wide_Character'Val (10);
-----------
-- Clear --
-----------
procedure Clear (Self : in out Writer) is
begin
Self.Text.Clear;
Self.Last_Line.Clear;
end Clear;
procedure N (Self : in out Writer; Text : Wide_Wide_String) is
begin
Self.Last_Line.Append (Text);
end N;
procedure N
(Self : in out Writer;
Text : League.Strings.Universal_String) is
begin
Self.N (Text.To_Wide_Wide_String);
end N;
procedure N
(Self : in out Writer;
Text : Wide_Wide_String;
Copy : in out Writer'Class) is
begin
Self.N (Text);
Copy.N (Text);
end N;
procedure N
(Self : in out Writer;
Text : League.Strings.Universal_String;
Copy : in out Writer'Class) is
begin
Self.N (Text);
Copy.N (Text);
end N;
-------
-- N --
-------
procedure N
(Self : in out Writer;
Value : Natural)
is
Image : constant Wide_Wide_String := Natural'Wide_Wide_Image (Value);
begin
Self.N (Image (2 .. Image'Last));
end N;
procedure N
(Self : in out Writer;
Value : Writer'Class)
is
Text : constant League.Strings.Universal_String := Value.Text;
List : constant League.String_Vectors.Universal_String_Vector :=
Text.Split (New_Line);
begin
for J in 1 .. List.Length loop
Self.P (List.Element (J));
end loop;
end N;
procedure P
(Self : in out Writer;
Text : Wide_Wide_String := "";
Copy : in out Writer'Class) is
begin
Self.P (Text);
Copy.P (Text);
end P;
procedure P
(Self : in out Writer;
Text : League.Strings.Universal_String;
Copy : in out Writer'Class) is
begin
Self.P (Text);
Copy.P (Text);
end P;
procedure P
(Self : in out Writer;
Text : League.Strings.Universal_String) is
begin
if Text.Index (New_Line) > 0 then
declare
List : League.String_Vectors.Universal_String_Vector;
begin
List := Text.Split (New_Line);
for J in 1 .. List.Length loop
Self.P (List.Element (J));
end loop;
end;
else
Self.P (Text.To_Wide_Wide_String);
end if;
end P;
procedure P
(Self : in out Writer;
Text : Wide_Wide_String := "")
is
function Get_Prefix
(X : League.Strings.Universal_String)
return League.Strings.Universal_String;
----------------
-- Get_Prefix --
----------------
function Get_Prefix
(X : League.Strings.Universal_String)
return League.Strings.Universal_String
is
use type League.Characters.Universal_Character;
begin
for J in 1 .. X.Length loop
if X.Element (J) /= ' ' then
return X.Slice (1, J - 1);
end if;
end loop;
raise Constraint_Error;
end Get_Prefix;
begin
Self.N (Text);
if Self.Last_Line.Length > 78 then
declare
Length : Natural;
List : constant League.String_Vectors.Universal_String_Vector :=
Self.Last_Line.Split ('.');
Prefix : League.Strings.Universal_String :=
Get_Prefix (Self.Last_Line);
begin
Self.Text.Append (List.Element (1));
Length := List.Element (1).Length;
for J in 2 .. List.Length loop
if Length + List.Element (J).Length < 78 then
Self.Text.Append ('.');
Self.Text.Append (List.Element (J));
Length := Length + List.Element (J).Length + 1;
else
Self.Text.Append ('.');
Self.Text.Append (New_Line);
Prefix.Append (" ");
Self.Text.Append (Prefix);
Self.Text.Append (List.Element (J));
Length := Prefix.Length + List.Element (J).Length;
end if;
end loop;
end;
else
Self.Text.Append (Self.Last_Line);
end if;
Self.Last_Line.Clear;
Self.Text.Append (New_Line);
end P;
----------
-- Text --
----------
function Text
(Self : Writer) return League.Strings.Universal_String
is
use type League.Strings.Universal_String;
begin
return Self.Text & Self.Last_Line;
end Text;
end Writers;
|
libsrc/_DEVELOPMENT/temp/sp1/zx/c/sccz80/sp1_IterateUpdateSpr_callee.asm | jpoikela/z88dk | 640 | 169850 | <filename>libsrc/_DEVELOPMENT/temp/sp1/zx/c/sccz80/sp1_IterateUpdateSpr_callee.asm
; void __CALLEE__ sp1_IterateUpdateSpr_callee(struct sp1_ss *s, void *hook2)
; 11.2006 aralbrec, Sprite Pack v3.0
; sinclair zx version
SECTION code_clib
SECTION code_temp_sp1
PUBLIC sp1_IterateUpdateSpr_callee
EXTERN asm_sp1_IterateUpdateSpr
sp1_IterateUpdateSpr_callee:
pop hl
pop ix
ex (sp),hl
jp asm_sp1_IterateUpdateSpr
|
contrib/libs/openssl/asm/windows/engines/e_padlock-x86_64.asm | ZhekehZ/catboost | 4 | 23548 | <reponame>ZhekehZ/catboost
default rel
%define XMMWORD
%define YMMWORD
%define ZMMWORD
section .text code align=64
global padlock_capability
ALIGN 16
padlock_capability:
mov r8,rbx
xor eax,eax
cpuid
xor eax,eax
cmp ebx,0x746e6543
jne NEAR $L$zhaoxin
cmp edx,0x48727561
jne NEAR $L$noluck
cmp ecx,0x736c7561
jne NEAR $L$noluck
jmp NEAR $L$zhaoxinEnd
$L$zhaoxin:
cmp ebx,0x68532020
jne NEAR $L$noluck
cmp edx,0x68676e61
jne NEAR $L$noluck
cmp ecx,0x20206961
jne NEAR $L$noluck
$L$zhaoxinEnd:
mov eax,0xC0000000
cpuid
mov edx,eax
xor eax,eax
cmp edx,0xC0000001
jb NEAR $L$noluck
mov eax,0xC0000001
cpuid
mov eax,edx
and eax,0xffffffef
or eax,0x10
$L$noluck:
mov rbx,r8
DB 0F3h,0C3h ;repret
global padlock_key_bswap
ALIGN 16
padlock_key_bswap:
mov edx,DWORD[240+rcx]
$L$bswap_loop:
mov eax,DWORD[rcx]
bswap eax
mov DWORD[rcx],eax
lea rcx,[4+rcx]
sub edx,1
jnz NEAR $L$bswap_loop
DB 0F3h,0C3h ;repret
global padlock_verify_context
ALIGN 16
padlock_verify_context:
mov rdx,rcx
pushf
lea rax,[$L$padlock_saved_context]
call _padlock_verify_ctx
lea rsp,[8+rsp]
DB 0F3h,0C3h ;repret
ALIGN 16
_padlock_verify_ctx:
mov r8,QWORD[8+rsp]
bt r8,30
jnc NEAR $L$verified
cmp rdx,QWORD[rax]
je NEAR $L$verified
pushf
popf
$L$verified:
mov QWORD[rax],rdx
DB 0F3h,0C3h ;repret
global padlock_reload_key
ALIGN 16
padlock_reload_key:
pushf
popf
DB 0F3h,0C3h ;repret
global padlock_aes_block
ALIGN 16
padlock_aes_block:
mov QWORD[8+rsp],rdi ;WIN64 prologue
mov QWORD[16+rsp],rsi
mov rax,rsp
$L$SEH_begin_padlock_aes_block:
mov rdi,rcx
mov rsi,rdx
mov rdx,r8
mov r8,rbx
mov rcx,1
lea rbx,[32+rdx]
lea rdx,[16+rdx]
DB 0xf3,0x0f,0xa7,0xc8
mov rbx,r8
mov rdi,QWORD[8+rsp] ;WIN64 epilogue
mov rsi,QWORD[16+rsp]
DB 0F3h,0C3h ;repret
$L$SEH_end_padlock_aes_block:
global padlock_xstore
ALIGN 16
padlock_xstore:
mov QWORD[8+rsp],rdi ;WIN64 prologue
mov QWORD[16+rsp],rsi
mov rax,rsp
$L$SEH_begin_padlock_xstore:
mov rdi,rcx
mov rsi,rdx
mov edx,esi
DB 0x0f,0xa7,0xc0
mov rdi,QWORD[8+rsp] ;WIN64 epilogue
mov rsi,QWORD[16+rsp]
DB 0F3h,0C3h ;repret
$L$SEH_end_padlock_xstore:
global padlock_sha1_oneshot
ALIGN 16
padlock_sha1_oneshot:
mov QWORD[8+rsp],rdi ;WIN64 prologue
mov QWORD[16+rsp],rsi
mov rax,rsp
$L$SEH_begin_padlock_sha1_oneshot:
mov rdi,rcx
mov rsi,rdx
mov rdx,r8
mov rcx,rdx
mov rdx,rdi
movups xmm0,XMMWORD[rdi]
sub rsp,128+8
mov eax,DWORD[16+rdi]
movaps XMMWORD[rsp],xmm0
mov rdi,rsp
mov DWORD[16+rsp],eax
xor rax,rax
DB 0xf3,0x0f,0xa6,0xc8
movaps xmm0,XMMWORD[rsp]
mov eax,DWORD[16+rsp]
add rsp,128+8
movups XMMWORD[rdx],xmm0
mov DWORD[16+rdx],eax
mov rdi,QWORD[8+rsp] ;WIN64 epilogue
mov rsi,QWORD[16+rsp]
DB 0F3h,0C3h ;repret
$L$SEH_end_padlock_sha1_oneshot:
global padlock_sha1_blocks
ALIGN 16
padlock_sha1_blocks:
mov QWORD[8+rsp],rdi ;WIN64 prologue
mov QWORD[16+rsp],rsi
mov rax,rsp
$L$SEH_begin_padlock_sha1_blocks:
mov rdi,rcx
mov rsi,rdx
mov rdx,r8
mov rcx,rdx
mov rdx,rdi
movups xmm0,XMMWORD[rdi]
sub rsp,128+8
mov eax,DWORD[16+rdi]
movaps XMMWORD[rsp],xmm0
mov rdi,rsp
mov DWORD[16+rsp],eax
mov rax,-1
DB 0xf3,0x0f,0xa6,0xc8
movaps xmm0,XMMWORD[rsp]
mov eax,DWORD[16+rsp]
add rsp,128+8
movups XMMWORD[rdx],xmm0
mov DWORD[16+rdx],eax
mov rdi,QWORD[8+rsp] ;WIN64 epilogue
mov rsi,QWORD[16+rsp]
DB 0F3h,0C3h ;repret
$L$SEH_end_padlock_sha1_blocks:
global padlock_sha256_oneshot
ALIGN 16
padlock_sha256_oneshot:
mov QWORD[8+rsp],rdi ;WIN64 prologue
mov QWORD[16+rsp],rsi
mov rax,rsp
$L$SEH_begin_padlock_sha256_oneshot:
mov rdi,rcx
mov rsi,rdx
mov rdx,r8
mov rcx,rdx
mov rdx,rdi
movups xmm0,XMMWORD[rdi]
sub rsp,128+8
movups xmm1,XMMWORD[16+rdi]
movaps XMMWORD[rsp],xmm0
mov rdi,rsp
movaps XMMWORD[16+rsp],xmm1
xor rax,rax
DB 0xf3,0x0f,0xa6,0xd0
movaps xmm0,XMMWORD[rsp]
movaps xmm1,XMMWORD[16+rsp]
add rsp,128+8
movups XMMWORD[rdx],xmm0
movups XMMWORD[16+rdx],xmm1
mov rdi,QWORD[8+rsp] ;WIN64 epilogue
mov rsi,QWORD[16+rsp]
DB 0F3h,0C3h ;repret
$L$SEH_end_padlock_sha256_oneshot:
global padlock_sha256_blocks
ALIGN 16
padlock_sha256_blocks:
mov QWORD[8+rsp],rdi ;WIN64 prologue
mov QWORD[16+rsp],rsi
mov rax,rsp
$L$SEH_begin_padlock_sha256_blocks:
mov rdi,rcx
mov rsi,rdx
mov rdx,r8
mov rcx,rdx
mov rdx,rdi
movups xmm0,XMMWORD[rdi]
sub rsp,128+8
movups xmm1,XMMWORD[16+rdi]
movaps XMMWORD[rsp],xmm0
mov rdi,rsp
movaps XMMWORD[16+rsp],xmm1
mov rax,-1
DB 0xf3,0x0f,0xa6,0xd0
movaps xmm0,XMMWORD[rsp]
movaps xmm1,XMMWORD[16+rsp]
add rsp,128+8
movups XMMWORD[rdx],xmm0
movups XMMWORD[16+rdx],xmm1
mov rdi,QWORD[8+rsp] ;WIN64 epilogue
mov rsi,QWORD[16+rsp]
DB 0F3h,0C3h ;repret
$L$SEH_end_padlock_sha256_blocks:
global padlock_sha512_blocks
ALIGN 16
padlock_sha512_blocks:
mov QWORD[8+rsp],rdi ;WIN64 prologue
mov QWORD[16+rsp],rsi
mov rax,rsp
$L$SEH_begin_padlock_sha512_blocks:
mov rdi,rcx
mov rsi,rdx
mov rdx,r8
mov rcx,rdx
mov rdx,rdi
movups xmm0,XMMWORD[rdi]
sub rsp,128+8
movups xmm1,XMMWORD[16+rdi]
movups xmm2,XMMWORD[32+rdi]
movups xmm3,XMMWORD[48+rdi]
movaps XMMWORD[rsp],xmm0
mov rdi,rsp
movaps XMMWORD[16+rsp],xmm1
movaps XMMWORD[32+rsp],xmm2
movaps XMMWORD[48+rsp],xmm3
DB 0xf3,0x0f,0xa6,0xe0
movaps xmm0,XMMWORD[rsp]
movaps xmm1,XMMWORD[16+rsp]
movaps xmm2,XMMWORD[32+rsp]
movaps xmm3,XMMWORD[48+rsp]
add rsp,128+8
movups XMMWORD[rdx],xmm0
movups XMMWORD[16+rdx],xmm1
movups XMMWORD[32+rdx],xmm2
movups XMMWORD[48+rdx],xmm3
mov rdi,QWORD[8+rsp] ;WIN64 epilogue
mov rsi,QWORD[16+rsp]
DB 0F3h,0C3h ;repret
$L$SEH_end_padlock_sha512_blocks:
global padlock_ecb_encrypt
ALIGN 16
padlock_ecb_encrypt:
mov QWORD[8+rsp],rdi ;WIN64 prologue
mov QWORD[16+rsp],rsi
mov rax,rsp
$L$SEH_begin_padlock_ecb_encrypt:
mov rdi,rcx
mov rsi,rdx
mov rdx,r8
mov rcx,r9
push rbp
push rbx
xor eax,eax
test rdx,15
jnz NEAR $L$ecb_abort
test rcx,15
jnz NEAR $L$ecb_abort
lea rax,[$L$padlock_saved_context]
pushf
cld
call _padlock_verify_ctx
lea rdx,[16+rdx]
xor eax,eax
xor ebx,ebx
test DWORD[rdx],32
jnz NEAR $L$ecb_aligned
test rdi,0x0f
setz al
test rsi,0x0f
setz bl
test eax,ebx
jnz NEAR $L$ecb_aligned
neg rax
mov rbx,512
not rax
lea rbp,[rsp]
cmp rcx,rbx
cmovc rbx,rcx
and rax,rbx
mov rbx,rcx
neg rax
and rbx,512-1
lea rsp,[rbp*1+rax]
mov rax,512
cmovz rbx,rax
cmp rcx,rbx
ja NEAR $L$ecb_loop
mov rax,rsi
cmp rbp,rsp
cmove rax,rdi
add rax,rcx
neg rax
and rax,0xfff
cmp rax,128
mov rax,-128
cmovae rax,rbx
and rbx,rax
jz NEAR $L$ecb_unaligned_tail
jmp NEAR $L$ecb_loop
ALIGN 16
$L$ecb_loop:
cmp rbx,rcx
cmova rbx,rcx
mov r8,rdi
mov r9,rsi
mov r10,rcx
mov rcx,rbx
mov r11,rbx
test rdi,0x0f
cmovnz rdi,rsp
test rsi,0x0f
jz NEAR $L$ecb_inp_aligned
shr rcx,3
DB 0xf3,0x48,0xa5
sub rdi,rbx
mov rcx,rbx
mov rsi,rdi
$L$ecb_inp_aligned:
lea rax,[((-16))+rdx]
lea rbx,[16+rdx]
shr rcx,4
DB 0xf3,0x0f,0xa7,200
mov rdi,r8
mov rbx,r11
test rdi,0x0f
jz NEAR $L$ecb_out_aligned
mov rcx,rbx
lea rsi,[rsp]
shr rcx,3
DB 0xf3,0x48,0xa5
sub rdi,rbx
$L$ecb_out_aligned:
mov rsi,r9
mov rcx,r10
add rdi,rbx
add rsi,rbx
sub rcx,rbx
mov rbx,512
jz NEAR $L$ecb_break
cmp rcx,rbx
jae NEAR $L$ecb_loop
$L$ecb_unaligned_tail:
xor eax,eax
cmp rbp,rsp
cmove rax,rcx
mov r8,rdi
mov rbx,rcx
sub rsp,rax
shr rcx,3
lea rdi,[rsp]
DB 0xf3,0x48,0xa5
mov rsi,rsp
mov rdi,r8
mov rcx,rbx
jmp NEAR $L$ecb_loop
ALIGN 16
$L$ecb_break:
cmp rsp,rbp
je NEAR $L$ecb_done
pxor xmm0,xmm0
lea rax,[rsp]
$L$ecb_bzero:
movaps XMMWORD[rax],xmm0
lea rax,[16+rax]
cmp rbp,rax
ja NEAR $L$ecb_bzero
$L$ecb_done:
lea rsp,[rbp]
jmp NEAR $L$ecb_exit
ALIGN 16
$L$ecb_aligned:
lea rbp,[rcx*1+rsi]
neg rbp
and rbp,0xfff
xor eax,eax
cmp rbp,128
mov rbp,128-1
cmovae rbp,rax
and rbp,rcx
sub rcx,rbp
jz NEAR $L$ecb_aligned_tail
lea rax,[((-16))+rdx]
lea rbx,[16+rdx]
shr rcx,4
DB 0xf3,0x0f,0xa7,200
test rbp,rbp
jz NEAR $L$ecb_exit
$L$ecb_aligned_tail:
mov r8,rdi
mov rbx,rbp
mov rcx,rbp
lea rbp,[rsp]
sub rsp,rcx
shr rcx,3
lea rdi,[rsp]
DB 0xf3,0x48,0xa5
lea rdi,[r8]
lea rsi,[rsp]
mov rcx,rbx
jmp NEAR $L$ecb_loop
$L$ecb_exit:
mov eax,1
lea rsp,[8+rsp]
$L$ecb_abort:
pop rbx
pop rbp
mov rdi,QWORD[8+rsp] ;WIN64 epilogue
mov rsi,QWORD[16+rsp]
DB 0F3h,0C3h ;repret
$L$SEH_end_padlock_ecb_encrypt:
global padlock_cbc_encrypt
ALIGN 16
padlock_cbc_encrypt:
mov QWORD[8+rsp],rdi ;WIN64 prologue
mov QWORD[16+rsp],rsi
mov rax,rsp
$L$SEH_begin_padlock_cbc_encrypt:
mov rdi,rcx
mov rsi,rdx
mov rdx,r8
mov rcx,r9
push rbp
push rbx
xor eax,eax
test rdx,15
jnz NEAR $L$cbc_abort
test rcx,15
jnz NEAR $L$cbc_abort
lea rax,[$L$padlock_saved_context]
pushf
cld
call _padlock_verify_ctx
lea rdx,[16+rdx]
xor eax,eax
xor ebx,ebx
test DWORD[rdx],32
jnz NEAR $L$cbc_aligned
test rdi,0x0f
setz al
test rsi,0x0f
setz bl
test eax,ebx
jnz NEAR $L$cbc_aligned
neg rax
mov rbx,512
not rax
lea rbp,[rsp]
cmp rcx,rbx
cmovc rbx,rcx
and rax,rbx
mov rbx,rcx
neg rax
and rbx,512-1
lea rsp,[rbp*1+rax]
mov rax,512
cmovz rbx,rax
cmp rcx,rbx
ja NEAR $L$cbc_loop
mov rax,rsi
cmp rbp,rsp
cmove rax,rdi
add rax,rcx
neg rax
and rax,0xfff
cmp rax,64
mov rax,-64
cmovae rax,rbx
and rbx,rax
jz NEAR $L$cbc_unaligned_tail
jmp NEAR $L$cbc_loop
ALIGN 16
$L$cbc_loop:
cmp rbx,rcx
cmova rbx,rcx
mov r8,rdi
mov r9,rsi
mov r10,rcx
mov rcx,rbx
mov r11,rbx
test rdi,0x0f
cmovnz rdi,rsp
test rsi,0x0f
jz NEAR $L$cbc_inp_aligned
shr rcx,3
DB 0xf3,0x48,0xa5
sub rdi,rbx
mov rcx,rbx
mov rsi,rdi
$L$cbc_inp_aligned:
lea rax,[((-16))+rdx]
lea rbx,[16+rdx]
shr rcx,4
DB 0xf3,0x0f,0xa7,208
movdqa xmm0,XMMWORD[rax]
movdqa XMMWORD[(-16)+rdx],xmm0
mov rdi,r8
mov rbx,r11
test rdi,0x0f
jz NEAR $L$cbc_out_aligned
mov rcx,rbx
lea rsi,[rsp]
shr rcx,3
DB 0xf3,0x48,0xa5
sub rdi,rbx
$L$cbc_out_aligned:
mov rsi,r9
mov rcx,r10
add rdi,rbx
add rsi,rbx
sub rcx,rbx
mov rbx,512
jz NEAR $L$cbc_break
cmp rcx,rbx
jae NEAR $L$cbc_loop
$L$cbc_unaligned_tail:
xor eax,eax
cmp rbp,rsp
cmove rax,rcx
mov r8,rdi
mov rbx,rcx
sub rsp,rax
shr rcx,3
lea rdi,[rsp]
DB 0xf3,0x48,0xa5
mov rsi,rsp
mov rdi,r8
mov rcx,rbx
jmp NEAR $L$cbc_loop
ALIGN 16
$L$cbc_break:
cmp rsp,rbp
je NEAR $L$cbc_done
pxor xmm0,xmm0
lea rax,[rsp]
$L$cbc_bzero:
movaps XMMWORD[rax],xmm0
lea rax,[16+rax]
cmp rbp,rax
ja NEAR $L$cbc_bzero
$L$cbc_done:
lea rsp,[rbp]
jmp NEAR $L$cbc_exit
ALIGN 16
$L$cbc_aligned:
lea rbp,[rcx*1+rsi]
neg rbp
and rbp,0xfff
xor eax,eax
cmp rbp,64
mov rbp,64-1
cmovae rbp,rax
and rbp,rcx
sub rcx,rbp
jz NEAR $L$cbc_aligned_tail
lea rax,[((-16))+rdx]
lea rbx,[16+rdx]
shr rcx,4
DB 0xf3,0x0f,0xa7,208
movdqa xmm0,XMMWORD[rax]
movdqa XMMWORD[(-16)+rdx],xmm0
test rbp,rbp
jz NEAR $L$cbc_exit
$L$cbc_aligned_tail:
mov r8,rdi
mov rbx,rbp
mov rcx,rbp
lea rbp,[rsp]
sub rsp,rcx
shr rcx,3
lea rdi,[rsp]
DB 0xf3,0x48,0xa5
lea rdi,[r8]
lea rsi,[rsp]
mov rcx,rbx
jmp NEAR $L$cbc_loop
$L$cbc_exit:
mov eax,1
lea rsp,[8+rsp]
$L$cbc_abort:
pop rbx
pop rbp
mov rdi,QWORD[8+rsp] ;WIN64 epilogue
mov rsi,QWORD[16+rsp]
DB 0F3h,0C3h ;repret
$L$SEH_end_padlock_cbc_encrypt:
global padlock_cfb_encrypt
ALIGN 16
padlock_cfb_encrypt:
mov QWORD[8+rsp],rdi ;WIN64 prologue
mov QWORD[16+rsp],rsi
mov rax,rsp
$L$SEH_begin_padlock_cfb_encrypt:
mov rdi,rcx
mov rsi,rdx
mov rdx,r8
mov rcx,r9
push rbp
push rbx
xor eax,eax
test rdx,15
jnz NEAR $L$cfb_abort
test rcx,15
jnz NEAR $L$cfb_abort
lea rax,[$L$padlock_saved_context]
pushf
cld
call _padlock_verify_ctx
lea rdx,[16+rdx]
xor eax,eax
xor ebx,ebx
test DWORD[rdx],32
jnz NEAR $L$cfb_aligned
test rdi,0x0f
setz al
test rsi,0x0f
setz bl
test eax,ebx
jnz NEAR $L$cfb_aligned
neg rax
mov rbx,512
not rax
lea rbp,[rsp]
cmp rcx,rbx
cmovc rbx,rcx
and rax,rbx
mov rbx,rcx
neg rax
and rbx,512-1
lea rsp,[rbp*1+rax]
mov rax,512
cmovz rbx,rax
jmp NEAR $L$cfb_loop
ALIGN 16
$L$cfb_loop:
cmp rbx,rcx
cmova rbx,rcx
mov r8,rdi
mov r9,rsi
mov r10,rcx
mov rcx,rbx
mov r11,rbx
test rdi,0x0f
cmovnz rdi,rsp
test rsi,0x0f
jz NEAR $L$cfb_inp_aligned
shr rcx,3
DB 0xf3,0x48,0xa5
sub rdi,rbx
mov rcx,rbx
mov rsi,rdi
$L$cfb_inp_aligned:
lea rax,[((-16))+rdx]
lea rbx,[16+rdx]
shr rcx,4
DB 0xf3,0x0f,0xa7,224
movdqa xmm0,XMMWORD[rax]
movdqa XMMWORD[(-16)+rdx],xmm0
mov rdi,r8
mov rbx,r11
test rdi,0x0f
jz NEAR $L$cfb_out_aligned
mov rcx,rbx
lea rsi,[rsp]
shr rcx,3
DB 0xf3,0x48,0xa5
sub rdi,rbx
$L$cfb_out_aligned:
mov rsi,r9
mov rcx,r10
add rdi,rbx
add rsi,rbx
sub rcx,rbx
mov rbx,512
jnz NEAR $L$cfb_loop
cmp rsp,rbp
je NEAR $L$cfb_done
pxor xmm0,xmm0
lea rax,[rsp]
$L$cfb_bzero:
movaps XMMWORD[rax],xmm0
lea rax,[16+rax]
cmp rbp,rax
ja NEAR $L$cfb_bzero
$L$cfb_done:
lea rsp,[rbp]
jmp NEAR $L$cfb_exit
ALIGN 16
$L$cfb_aligned:
lea rax,[((-16))+rdx]
lea rbx,[16+rdx]
shr rcx,4
DB 0xf3,0x0f,0xa7,224
movdqa xmm0,XMMWORD[rax]
movdqa XMMWORD[(-16)+rdx],xmm0
$L$cfb_exit:
mov eax,1
lea rsp,[8+rsp]
$L$cfb_abort:
pop rbx
pop rbp
mov rdi,QWORD[8+rsp] ;WIN64 epilogue
mov rsi,QWORD[16+rsp]
DB 0F3h,0C3h ;repret
$L$SEH_end_padlock_cfb_encrypt:
global padlock_ofb_encrypt
ALIGN 16
padlock_ofb_encrypt:
mov QWORD[8+rsp],rdi ;WIN64 prologue
mov QWORD[16+rsp],rsi
mov rax,rsp
$L$SEH_begin_padlock_ofb_encrypt:
mov rdi,rcx
mov rsi,rdx
mov rdx,r8
mov rcx,r9
push rbp
push rbx
xor eax,eax
test rdx,15
jnz NEAR $L$ofb_abort
test rcx,15
jnz NEAR $L$ofb_abort
lea rax,[$L$padlock_saved_context]
pushf
cld
call _padlock_verify_ctx
lea rdx,[16+rdx]
xor eax,eax
xor ebx,ebx
test DWORD[rdx],32
jnz NEAR $L$ofb_aligned
test rdi,0x0f
setz al
test rsi,0x0f
setz bl
test eax,ebx
jnz NEAR $L$ofb_aligned
neg rax
mov rbx,512
not rax
lea rbp,[rsp]
cmp rcx,rbx
cmovc rbx,rcx
and rax,rbx
mov rbx,rcx
neg rax
and rbx,512-1
lea rsp,[rbp*1+rax]
mov rax,512
cmovz rbx,rax
jmp NEAR $L$ofb_loop
ALIGN 16
$L$ofb_loop:
cmp rbx,rcx
cmova rbx,rcx
mov r8,rdi
mov r9,rsi
mov r10,rcx
mov rcx,rbx
mov r11,rbx
test rdi,0x0f
cmovnz rdi,rsp
test rsi,0x0f
jz NEAR $L$ofb_inp_aligned
shr rcx,3
DB 0xf3,0x48,0xa5
sub rdi,rbx
mov rcx,rbx
mov rsi,rdi
$L$ofb_inp_aligned:
lea rax,[((-16))+rdx]
lea rbx,[16+rdx]
shr rcx,4
DB 0xf3,0x0f,0xa7,232
movdqa xmm0,XMMWORD[rax]
movdqa XMMWORD[(-16)+rdx],xmm0
mov rdi,r8
mov rbx,r11
test rdi,0x0f
jz NEAR $L$ofb_out_aligned
mov rcx,rbx
lea rsi,[rsp]
shr rcx,3
DB 0xf3,0x48,0xa5
sub rdi,rbx
$L$ofb_out_aligned:
mov rsi,r9
mov rcx,r10
add rdi,rbx
add rsi,rbx
sub rcx,rbx
mov rbx,512
jnz NEAR $L$ofb_loop
cmp rsp,rbp
je NEAR $L$ofb_done
pxor xmm0,xmm0
lea rax,[rsp]
$L$ofb_bzero:
movaps XMMWORD[rax],xmm0
lea rax,[16+rax]
cmp rbp,rax
ja NEAR $L$ofb_bzero
$L$ofb_done:
lea rsp,[rbp]
jmp NEAR $L$ofb_exit
ALIGN 16
$L$ofb_aligned:
lea rax,[((-16))+rdx]
lea rbx,[16+rdx]
shr rcx,4
DB 0xf3,0x0f,0xa7,232
movdqa xmm0,XMMWORD[rax]
movdqa XMMWORD[(-16)+rdx],xmm0
$L$ofb_exit:
mov eax,1
lea rsp,[8+rsp]
$L$ofb_abort:
pop rbx
pop rbp
mov rdi,QWORD[8+rsp] ;WIN64 epilogue
mov rsi,QWORD[16+rsp]
DB 0F3h,0C3h ;repret
$L$SEH_end_padlock_ofb_encrypt:
global padlock_ctr32_encrypt
ALIGN 16
padlock_ctr32_encrypt:
mov QWORD[8+rsp],rdi ;WIN64 prologue
mov QWORD[16+rsp],rsi
mov rax,rsp
$L$SEH_begin_padlock_ctr32_encrypt:
mov rdi,rcx
mov rsi,rdx
mov rdx,r8
mov rcx,r9
push rbp
push rbx
xor eax,eax
test rdx,15
jnz NEAR $L$ctr32_abort
test rcx,15
jnz NEAR $L$ctr32_abort
lea rax,[$L$padlock_saved_context]
pushf
cld
call _padlock_verify_ctx
lea rdx,[16+rdx]
xor eax,eax
xor ebx,ebx
test DWORD[rdx],32
jnz NEAR $L$ctr32_aligned
test rdi,0x0f
setz al
test rsi,0x0f
setz bl
test eax,ebx
jnz NEAR $L$ctr32_aligned
neg rax
mov rbx,512
not rax
lea rbp,[rsp]
cmp rcx,rbx
cmovc rbx,rcx
and rax,rbx
mov rbx,rcx
neg rax
and rbx,512-1
lea rsp,[rbp*1+rax]
mov rax,512
cmovz rbx,rax
$L$ctr32_reenter:
mov eax,DWORD[((-4))+rdx]
bswap eax
neg eax
and eax,31
mov rbx,512
shl eax,4
cmovz rax,rbx
cmp rcx,rax
cmova rbx,rax
cmovbe rbx,rcx
cmp rcx,rbx
ja NEAR $L$ctr32_loop
mov rax,rsi
cmp rbp,rsp
cmove rax,rdi
add rax,rcx
neg rax
and rax,0xfff
cmp rax,32
mov rax,-32
cmovae rax,rbx
and rbx,rax
jz NEAR $L$ctr32_unaligned_tail
jmp NEAR $L$ctr32_loop
ALIGN 16
$L$ctr32_loop:
cmp rbx,rcx
cmova rbx,rcx
mov r8,rdi
mov r9,rsi
mov r10,rcx
mov rcx,rbx
mov r11,rbx
test rdi,0x0f
cmovnz rdi,rsp
test rsi,0x0f
jz NEAR $L$ctr32_inp_aligned
shr rcx,3
DB 0xf3,0x48,0xa5
sub rdi,rbx
mov rcx,rbx
mov rsi,rdi
$L$ctr32_inp_aligned:
lea rax,[((-16))+rdx]
lea rbx,[16+rdx]
shr rcx,4
DB 0xf3,0x0f,0xa7,216
mov eax,DWORD[((-4))+rdx]
test eax,0xffff0000
jnz NEAR $L$ctr32_no_carry
bswap eax
add eax,0x10000
bswap eax
mov DWORD[((-4))+rdx],eax
$L$ctr32_no_carry:
mov rdi,r8
mov rbx,r11
test rdi,0x0f
jz NEAR $L$ctr32_out_aligned
mov rcx,rbx
lea rsi,[rsp]
shr rcx,3
DB 0xf3,0x48,0xa5
sub rdi,rbx
$L$ctr32_out_aligned:
mov rsi,r9
mov rcx,r10
add rdi,rbx
add rsi,rbx
sub rcx,rbx
mov rbx,512
jz NEAR $L$ctr32_break
cmp rcx,rbx
jae NEAR $L$ctr32_loop
mov rbx,rcx
mov rax,rsi
cmp rbp,rsp
cmove rax,rdi
add rax,rcx
neg rax
and rax,0xfff
cmp rax,32
mov rax,-32
cmovae rax,rbx
and rbx,rax
jnz NEAR $L$ctr32_loop
$L$ctr32_unaligned_tail:
xor eax,eax
cmp rbp,rsp
cmove rax,rcx
mov r8,rdi
mov rbx,rcx
sub rsp,rax
shr rcx,3
lea rdi,[rsp]
DB 0xf3,0x48,0xa5
mov rsi,rsp
mov rdi,r8
mov rcx,rbx
jmp NEAR $L$ctr32_loop
ALIGN 16
$L$ctr32_break:
cmp rsp,rbp
je NEAR $L$ctr32_done
pxor xmm0,xmm0
lea rax,[rsp]
$L$ctr32_bzero:
movaps XMMWORD[rax],xmm0
lea rax,[16+rax]
cmp rbp,rax
ja NEAR $L$ctr32_bzero
$L$ctr32_done:
lea rsp,[rbp]
jmp NEAR $L$ctr32_exit
ALIGN 16
$L$ctr32_aligned:
mov eax,DWORD[((-4))+rdx]
bswap eax
neg eax
and eax,0xffff
mov rbx,1048576
shl eax,4
cmovz rax,rbx
cmp rcx,rax
cmova rbx,rax
cmovbe rbx,rcx
jbe NEAR $L$ctr32_aligned_skip
$L$ctr32_aligned_loop:
mov r10,rcx
mov rcx,rbx
mov r11,rbx
lea rax,[((-16))+rdx]
lea rbx,[16+rdx]
shr rcx,4
DB 0xf3,0x0f,0xa7,216
mov eax,DWORD[((-4))+rdx]
bswap eax
add eax,0x10000
bswap eax
mov DWORD[((-4))+rdx],eax
mov rcx,r10
sub rcx,r11
mov rbx,1048576
jz NEAR $L$ctr32_exit
cmp rcx,rbx
jae NEAR $L$ctr32_aligned_loop
$L$ctr32_aligned_skip:
lea rbp,[rcx*1+rsi]
neg rbp
and rbp,0xfff
xor eax,eax
cmp rbp,32
mov rbp,32-1
cmovae rbp,rax
and rbp,rcx
sub rcx,rbp
jz NEAR $L$ctr32_aligned_tail
lea rax,[((-16))+rdx]
lea rbx,[16+rdx]
shr rcx,4
DB 0xf3,0x0f,0xa7,216
test rbp,rbp
jz NEAR $L$ctr32_exit
$L$ctr32_aligned_tail:
mov r8,rdi
mov rbx,rbp
mov rcx,rbp
lea rbp,[rsp]
sub rsp,rcx
shr rcx,3
lea rdi,[rsp]
DB 0xf3,0x48,0xa5
lea rdi,[r8]
lea rsi,[rsp]
mov rcx,rbx
jmp NEAR $L$ctr32_loop
$L$ctr32_exit:
mov eax,1
lea rsp,[8+rsp]
$L$ctr32_abort:
pop rbx
pop rbp
mov rdi,QWORD[8+rsp] ;WIN64 epilogue
mov rsi,QWORD[16+rsp]
DB 0F3h,0C3h ;repret
$L$SEH_end_padlock_ctr32_encrypt:
DB 86,73,65,32,80,97,100,108,111,99,107,32,120,56,54,95
DB 54,52,32,109,111,100,117,108,101,44,32,67,82,89,80,84
DB 79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64
DB 111,112,101,110,115,115,108,46,111,114,103,62,0
ALIGN 16
section .data data align=8
ALIGN 8
$L$padlock_saved_context:
DQ 0
|
binutils-2.21.1/gcc-4.5.1/libgcc/config/ia64/_fixtfdi.asm | cberner12/xv6 | 51 | 80976 | #ifdef SHARED
#define __fixtfti __fixtfti_compat
#endif
#define L_fixtfdi
#include "config/ia64/lib1funcs.asm"
#ifdef SHARED
#undef __fixtfti
.symver __fixtfti_compat, __fixtfti@GCC_3.0
#endif
|
oeis/142/A142286.asm | neoneye/loda-programs | 11 | 91299 | ; A142286: Primes congruent to 37 mod 43.
; Submitted by <NAME>(w2)
; 37,467,811,983,1069,1327,1499,2273,2531,2617,2789,3391,3821,3907,4079,4337,4423,5197,6143,6229,6659,6917,7433,7691,7949,8293,9067,9239,9497,10099,10271,10357,10529,11131,12163,12421,13109,13367,13711,13883,14657,15173,15259,16033,16979,17581,17839,18097,18269,19301,19387,19559,20161,20333,20849,21107,21193,21881,22397,22483,22741,23687,23773,24203,24547,24977,25321,25579,26267,26783,27127,27299,27901,28933,29191,29363,29879,30137,30223,30911,31513,31771,32029,32717,32803,33577,33749,34351,34781
mov $1,42
mov $2,$0
add $2,2
pow $2,2
lpb $2
sub $1,24
sub $2,1
mov $3,$1
mul $3,2
seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0.
sub $0,$3
add $1,67
mov $4,$0
max $4,0
cmp $4,$0
mul $2,$4
lpe
mov $0,$1
mul $0,2
sub $0,133
|
src/gl/implementation/gl-blending.adb | Roldak/OpenGLAda | 79 | 29455 | -- part of OpenGLAda, (c) 2017 <NAME>
-- released under the terms of the MIT license, see the file "COPYING"
with GL.API;
with GL.Enums.Getter;
package body GL.Blending is
procedure Set_Blend_Func (Src_Factor, Dst_Factor : Blend_Factor) is
begin
API.Blend_Func (Src_Factor, Dst_Factor);
Raise_Exception_On_OpenGL_Error;
end Set_Blend_Func;
procedure Set_Blend_Func (Draw_Buffer : Buffers.Draw_Buffer_Index;
Src_Factor, Dst_Factor : Blend_Factor) is
begin
API.Blend_Func_I (Draw_Buffer, Src_Factor, Dst_Factor);
Raise_Exception_On_OpenGL_Error;
end Set_Blend_Func;
procedure Set_Blend_Func_Separate (Src_RGB, Dst_RGB, Src_Alpha, Dst_Alpha
: Blend_Factor) is
begin
API.Blend_Func_Separate (Src_RGB, Dst_RGB, Src_Alpha, Dst_Alpha);
Raise_Exception_On_OpenGL_Error;
end Set_Blend_Func_Separate;
procedure Set_Blend_Func_Separate (Draw_Buffer : Buffers.Draw_Buffer_Index;
Src_RGB, Dst_RGB, Src_Alpha, Dst_Alpha
: Blend_Factor) is
begin
API.Blend_Func_Separate_I (Draw_Buffer, Src_RGB, Dst_RGB,
Src_Alpha, Dst_Alpha);
Raise_Exception_On_OpenGL_Error;
end Set_Blend_Func_Separate;
function Blend_Func_Src_RGB return Blend_Factor is
Ret : aliased Blend_Factor;
begin
API.Get_Blend_Factor (Enums.Getter.Blend_Src_RGB, Ret'Access);
Raise_Exception_On_OpenGL_Error;
return Ret;
end Blend_Func_Src_RGB;
function Blend_Func_Src_Alpha return Blend_Factor is
Ret : aliased Blend_Factor;
begin
API.Get_Blend_Factor (Enums.Getter.Blend_Src_Alpha, Ret'Access);
Raise_Exception_On_OpenGL_Error;
return Ret;
end Blend_Func_Src_Alpha;
function Blend_Func_Dst_RGB return Blend_Factor is
Ret : aliased Blend_Factor;
begin
API.Get_Blend_Factor (Enums.Getter.Blend_Dst_RGB, Ret'Access);
Raise_Exception_On_OpenGL_Error;
return Ret;
end Blend_Func_Dst_RGB;
function Blend_Func_Dst_Alpha return Blend_Factor is
Ret : aliased Blend_Factor;
begin
API.Get_Blend_Factor (Enums.Getter.Blend_Dst_Alpha, Ret'Access);
Raise_Exception_On_OpenGL_Error;
return Ret;
end Blend_Func_Dst_Alpha;
procedure Set_Blend_Color (Value : Types.Colors.Color) is
use Types.Colors;
begin
API.Blend_Color (Value (R), Value (G), Value (B), Value (A));
Raise_Exception_On_OpenGL_Error;
end Set_Blend_Color;
function Blend_Color return Types.Colors.Color is
Ret : Types.Colors.Color;
begin
API.Get_Color (Enums.Getter.Blend_Color, Ret);
return Ret;
end Blend_Color;
procedure Set_Blend_Equation (Value : Equation) is
begin
API.Blend_Equation (Value);
Raise_Exception_On_OpenGL_Error;
end Set_Blend_Equation;
procedure Set_Blend_Equation (Draw_Buffer : Buffers.Draw_Buffer_Index;
Value : Equation) is
begin
API.Blend_Equation_I (Draw_Buffer, Value);
Raise_Exception_On_OpenGL_Error;
end Set_Blend_Equation;
procedure Set_Blend_Equation_Separate (RGB, Alpha : Equation) is
begin
API.Blend_Equation_Separate (RGB, Alpha);
Raise_Exception_On_OpenGL_Error;
end Set_Blend_Equation_Separate;
procedure Set_Blend_Equation_Separate
(Draw_Buffer : Buffers.Draw_Buffer_Index; RGB, Alpha : Equation) is
begin
API.Blend_Equation_Separate_I (Draw_Buffer, RGB, Alpha);
Raise_Exception_On_OpenGL_Error;
end Set_Blend_Equation_Separate;
function Blend_Equation_RGB return Equation is
Ret : aliased Equation;
begin
API.Get_Blend_Equation (Enums.Getter.Blend_Equation_RGB, Ret'Access);
Raise_Exception_On_OpenGL_Error;
return Ret;
end Blend_Equation_RGB;
function Blend_Equation_Alpha return Equation is
Ret : aliased Equation;
begin
API.Get_Blend_Equation (Enums.Getter.Blend_Equation_Alpha, Ret'Access);
Raise_Exception_On_OpenGL_Error;
return Ret;
end Blend_Equation_Alpha;
end GL.Blending;
|
projects/batfish/src/main/antlr4/org/batfish/grammar/palo_alto/PaloAlto_deviceconfig.g4 | anubhavnidhi/batfish | 10 | 811 | parser grammar PaloAlto_deviceconfig;
import PaloAlto_common;
options {
tokenVocab = PaloAltoLexer;
}
s_deviceconfig
:
DEVICECONFIG
(
sd_system
)
;
sd_system
:
SYSTEM
(
sds_dns_setting
| sds_hostname
| sds_ntp_servers
)
;
sds_dns_setting
:
DNS_SETTING
(
sdsd_servers
)
;
sdsd_servers
:
SERVERS
(
PRIMARY primary_name = IP_ADDRESS
| SECONDARY secondary_name = IP_ADDRESS
)
;
sds_hostname
:
HOSTNAME name = variable
;
sds_ntp_servers
:
NTP_SERVERS
(
PRIMARY_NTP_SERVER
| SECONDARY_NTP_SERVER
)
(
sdsn_ntp_server_address
)
;
sdsn_ntp_server_address
:
NTP_SERVER_ADDRESS address = variable
;
|
oeis/131/A131951.asm | neoneye/loda-programs | 11 | 9802 | ; A131951: 2^n+n*(n+3).
; Submitted by <NAME>(s3.)
; 1,6,14,26,44,72,118,198,344,620,1154,2202,4276,8400,16622,33038,65840,131412,262522,524706,1049036,2097656,4194854,8389206,16777864,33555132,67109618
mov $1,2
pow $1,$0
add $1,$0
add $0,1
pow $0,2
add $1,$0
mov $0,$1
sub $0,1
|
Data/ships/Moray.asm | ped7g/EliteNext | 0 | 26465 | <filename>Data/ships/Moray.asm
Moray: DB $01, $03, $84
DW MorayEdges
DB MorayEdgesSize
DB $00, $1A
DB MorayVertSize
DB MorayEdgesCnt
DB $00, $32
DB MorayNormalsSize
DB $28, $59, $19
DW MorayNormals
DB $02, $2A
DW MorayVertices
DB 0,0 ; Type and Tactics
MorayVertices: DB $0F, $00, $41, $1F, $02, $78
DB $0F, $00, $41, $9F, $01, $67
DB $00, $12, $28, $31, $FF, $FF
DB $3C, $00, $00, $9F, $13, $66
DB $3C, $00, $00, $1F, $25, $88
DB $1E, $1B, $0A, $78, $45, $78
DB $1E, $1B, $0A, $F8, $34, $67
DB $09, $04, $19, $E7, $44, $44
DB $09, $04, $19, $67, $44, $44
DB $00, $12, $10, $67, $44, $44
DB $0D, $03, $31, $05, $00, $00
DB $06, $00, $41, $05, $00, $00
DB $0D, $03, $31, $85, $00, $00
DB $06, $00, $41, $85, $00, $00
MorayVertSize: equ $ - MorayVertices
MorayEdges: DB $1F, $07, $00, $04
DB $1F, $16, $04, $0C
DB $18, $36, $0C, $18
DB $18, $47, $14, $18
DB $18, $58, $10, $14
DB $1F, $28, $00, $10
DB $0F, $67, $04, $18
DB $0F, $78, $00, $14
DB $0F, $02, $00, $08
DB $0F, $01, $04, $08
DB $11, $13, $08, $0C
DB $11, $25, $08, $10
DB $0D, $45, $08, $14
DB $0D, $34, $08, $18
DB $05, $44, $1C, $20
DB $07, $44, $1C, $24
DB $07, $44, $20, $24
DB $05, $00, $28, $2C
DB $05, $00, $30, $34
MorayEdgesSize: equ $ - MorayEdges
MorayEdgesCnt: equ MorayEdgesSize/4
MorayNormals: DB $1F, $00, $2B, $07
DB $9F, $0A, $31, $07
DB $1F, $0A, $31, $07
DB $F8, $3B, $1C, $65
DB $78, $00, $34, $4E
DB $78, $3B, $1C, $65
DB $DF, $48, $63, $32
DB $5F, $00, $53, $1E
DB $5F, $48, $63, $32
MorayNormalsSize: equ $ - MorayNormals
MorayLen: equ $ - Moray
|
oeis/158/A158488.asm | neoneye/loda-programs | 11 | 19639 | <gh_stars>10-100
; A158488: a(n) = 64*n^2 + 8.
; Submitted by <NAME>
; 72,264,584,1032,1608,2312,3144,4104,5192,6408,7752,9224,10824,12552,14408,16392,18504,20744,23112,25608,28232,30984,33864,36872,40008,43272,46664,50184,53832,57608,61512,65544,69704,73992,78408,82952,87624,92424,97352,102408,107592,112904,118344,123912,129608,135432,141384,147464,153672,160008,166472,173064,179784,186632,193608,200712,207944,215304,222792,230408,238152,246024,254024,262152,270408,278792,287304,295944,304712,313608,322632,331784,341064,350472,360008,369672,379464,389384,399432
add $0,1
pow $0,2
mul $0,8
add $0,1
mul $0,8
|
oeis/255/A255634.asm | neoneye/loda-programs | 11 | 247449 | ; A255634: Numbers n such that 1 + 16n^2 is prime.
; Submitted by <NAME>
; 1,4,5,6,9,10,14,21,29,30,31,39,40,44,45,46,51,56,59,60,64,65,66,70,71,75,85,96,99,100,105,109,110,111,116,124,134,136,139,144,146,159,161,170,174,175,176,179,185,190,191,195,196,204,215,216,230,234,240,251,259,265,270,274,281
mov $2,$0
add $2,1
pow $2,2
lpb $2
add $1,4
sub $2,1
mov $3,$1
pow $3,2
seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0.
sub $0,$3
mov $4,$0
max $4,0
cmp $4,$0
mul $2,$4
lpe
mov $0,$1
div $0,4
|
programs/oeis/188/A188501.asm | neoneye/loda | 22 | 81066 | ; A188501: Number of n X 2 binary arrays without the pattern 0 1 0 diagonally, vertically or horizontally.
; 4,16,49,144,441,1369,4225,12996,40000,123201,379456,1168561,3598609,11082241,34128964,105103504,323676081,996791184,3069714025,9453478441,29112890625,89655929476,276104007936,850288696321,2618545348864,8064060793441,24834046324129,76478820377089,235523840529796,725318188519824,2233686718991025,6878851844056336,21184082033625625,65238406318446201,200907910581805441,618715122152505156,1905392382368878144,5867838041777202241,18070568352813588544,55650043213327461649,171379629526872726961,527779957046541708289,1625348845887029468100,5005417192440556471056,15414660879588742200625,47470922182386183471376,146191244195979151595721,450209915818705596154441,1386464486407734827944449,4269749964467565594208516,13149103303977041272259584,40493920987764514159799809,124704901851927717725848576,384040669971126019193051329,1182689966485799705727330625,3642206844736905186779417601,11216524258902335509935562500,34542359018501186285902767376,106376497658446284288374084401,327596596631298462944444044176,1008865045256436965039966289529,3106896378065215603201570399641,9567984488531040564467360965249,29465523156514164903579466645444,90741896156686667103762830910016,279448346271446869482731409845569,860587904169467905180330344769600,2650262743309963085912617585764721,8161737545399776756848958307180625,25134851224898910676616100302067201,77405177829307114709691692149868356,238376646878710738206080642071758736,734103678470241731217852461962617009
add $0,2
seq $0,164394 ; Number of binary strings of length n with no substrings equal to 0001 or 0100.
pow $0,2
div $0,4
|
test/table-test/test_tabelle.adb | fintatarta/protypo | 0 | 2261 | <reponame>fintatarta/protypo<gh_stars>0
with Protypo.Api.Interpreters;
with Protypo.Api.Consumers.File_Writer;
with Protypo.Api.Engine_Values.Basic_Array_Wrappers;
-- with User_Records;
with Integer_Arrays;
with Ada.Command_Line;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Exceptions;
with Protypo.Api.Engine_Values.Table_Wrappers;
procedure Test_Tabelle is
use Ada.Command_Line;
use Protypo.Api.Interpreters;
use Protypo.Api.Engine_Values;
use Protypo.Api.Consumers;
use Protypo.Api;
Default_Source_File : constant String := "test-data/prova_tabelle.txt";
function Source_File return String
is (if Argument_Count = 0 then Default_Source_File else Argument (1));
use Protypo.Api.Engine_Values;
type User_Record is
record
Age : Integer;
Serial : Integer;
Address : Integer;
end record;
type User_Field is (Age, Serial, Address);
package User_Package is
new Table_Wrappers.Enumerated_Rows (User_Field);
type Aggregate_Array is array (Positive range <>) of User_Record;
function Convert (X : User_Record) return User_Package.Aggregate_Type
is
begin
return User_Package.Aggregate_Type'(Age => Create (X.Age),
Serial => Create (X.Serial),
Address => Create (X.Address));
end Convert;
procedure Fill is
new User_Package.Append_Array (Ada_Aggregate => User_Record,
Aggregate_Index => Positive,
Generic_Aggregate_Array => Aggregate_Array,
Convert => Convert);
DB : constant Aggregate_Array := (1 => (Age => 42,
Serial => 12345,
Address => 99),
2 => (Age => 53,
Serial => 23451,
Address => 0),
3 => (Age => 66,
Serial => 34512,
Address => 44),
4 => (Age => 88,
Serial => 54321,
Address => 112));
-- Program : constant Template_Type := Slurp (Source_File);
Code : Compiled_Code;
Consumer : constant Consumer_Access :=
File_Writer.Open (File_Writer.Standard_Error);
Scores : constant Engine_Value :=
Integer_Arrays.Wrappers.Create (Value => (1 => 18,
2 => 33,
3 => 42,
4 => -5));
User_Dir : constant Table_Wrappers.Table_Wrapper_Access :=
User_Package.Make_Table;
Engine : Interpreter_Type;
begin
Fill (User_Dir.all, Db);
Engine.Define (Name => "users",
Value => Create (Ambivalent_Interface_Access (User_Dir)));
Engine.Define (Name => "scores",
Value => Scores);
-- Engine.Define (Name => "splitbit",
-- Value => Create (Val => User_Records.Split_Bit'Access,
-- Min_Parameters => 1,
-- Max_Parameters => 2));
Compile (Target => Code,
Program => Slurp(Source_File));
Engine.Run (Program => Code,
Consumer => Consumer);
Set_Exit_Status (Success);
exception
when E : Protypo.Run_Time_Error =>
Put_Line (Standard_Error, "Run time error: " & Ada.Exceptions.Exception_Message (E));
Set_Exit_Status (Failure);
when E : Protypo.Parsing_Error =>
Put_Line (Standard_Error, "parsing error: " & Ada.Exceptions.Exception_Message (E));
Set_Exit_Status (Failure);
when E : others =>
Put_Line (Standard_Error, "other: " & Ada.Exceptions.Exception_Message (E));
Put_Line (Ada.Exceptions.Exception_Information (E));
end Test_Tabelle;
|
src/test/resources/ada-sources/delimiters.adb | WinterAlexander/Ada-IntelliJ | 17 | 2048 | <filename>src/test/resources/ada-sources/delimiters.adb
-- Single Delimiters
& ' ( ) * + , - . / : ; < = > |
-- Compound Delimiters
=> .. ** := /= >= <= << >> <>
-- Special cases
=>=
<=>
<<>
<<>>
<>>
character_literal('a')
apostrophe'delimiter
Variable'Access
Character'('a')
|
tools/tape_turbo_save_load.asm | alexanderbazhenoff/zx-spectrum-various | 0 | 81637 | <filename>tools/tape_turbo_save_load.asm
; This Source Code Form is subject to the terms of the MIT
; hLicense. If a copy of the MPL was not distributed with
; this file, You can obtain one at https://github.com/aws/mit-0
; ----------------------------------------------------
; TURBO TAPE SAVE/LOAD ROUTINES
; You can set your custom look and speed via constants.
; (You can also check original non-turbo and ROM-like values
; in the comments).
ORG #6000
LOMODE EQU 0 ;разновидность бордюрных выебонов
DEXOR EQU 1 ;расксоривание при загрузке
LPILOT EQU #0D98 ;длительность пилота [#0C98-stanandard]
TPILOT EQU #98 ;частота пилота [#A4-standard]
PPILOT EQU #2F ;пауза после пилота [#2F-standard]
CPILOT EQU #020F ;цвета при пилоте (цвет/xor) [#020F]
BITSUB EQU #23 ;разница в длит. импульса для битов
;0 и 1 [#42]
BITPAU EQU #22 ;мин длина импульса [#3E]
ENDPAU EQU #3B ;пауза после сохранения данных [#3B]
COLETC EQU #3B0E ;цвета при сохр. данных [#3B0E]
LFLP EQU #2 ;пауза при сканинге пилот-тона [#415]
; ------------ Programm kernel -------------------------
JR LOA
LD HL,SCR
LD DE,#4000
LD BC,#1B00
LDIR
LD IX,#4000
LD DE,#1B00
LD A,#FF
CALL SAVE
RET
LD HL,#4000
LD DE,#4001
LD BC,#1AFF
LD (HL),L
LDIR
LOA
LD IX,#4000
LD DE,#1B00
LD A,#FF
SCF
CALL load
; ---- dexor
LD HL,#4000
LD BC,#1B00
DEXORL LD A,(HL)
XOR L
LD (HL),A
INC HL
DEC BC
LD A,B
OR C
JR NZ,DEXORL
RET
;JP NC,error
; -------- SAVE/LOAD routines
;---- save pilot
SAVE LD HL,LPILOT
LL04D0 EX AF,AF'
INC DE
DEC IX
DI
LD A,'CPILOT
LD B,A
LL04D8 DJNZ LL04D8
OUT (#FE),A
XOR .CPILOT
LD B,TPILOT
PILLEN EQU $-1
DEC L
JR NZ,LL04D8
; PUSH HL
; LD HL,PILLEN
; DEC (HL)
; POP HL
DEC B
DEC H
JP P,LL04D8
;----- pause after pilot
LD B,PPILOT
LL04EA DJNZ LL04EA
;----- save data
OUT (#FE),A
LD A,#0D
LD B,#37
LL04F2 DJNZ LL04F2
OUT (#FE),A
LD BC,#3B0E
EX AF,AF'
LD L,A
JP LL0507
LL04FE LD A,D
OR E
JR Z,LL050E
LD L,(IX+#00)
LL0505 LD A,H
XOR L
LL0507 LD H,A
LD A,#01
SCF
JP LL0525
LL050E LD L,H
JR LL0505
LL0511 LD A,C
BIT 7,B
LL0514 DJNZ LL0514
JR NC,LL051C
LD B,BITSUB
LL051A DJNZ LL051A
LL051C OUT (#FE),A
LD B,BITPAU
JR NZ,LL0511
DEC B
XOR A
INC A
LL0525 RL L
JP NZ,LL0514
DEC DE
INC IX
LD B,#31
LD A,#7F
IN A,(#FE)
RRA
RET NC
LD A,D
INC A
JP NZ,LL04FE
LD B,#3B
LL053C DJNZ LL053C
RET
load INC D
EX AF,AF'
DEC D
DI
LD A,8
OUT (#FE),A
LD HL,#053F
PUSH HL
IN A,(#FE)
RRA
AND #20
OR 2
LD C,A
CP A
LL822 RET NZ
LL823 CALL LL946
JR NC,LL822
LD HL,LFLP
LL831 DJNZ LL831
DEC HL
LD A,H
OR L
JR NZ,LL831
CALL LL942
JR NC,LL822
LL843 LD B,#96 ;#9C
CALL LL942
JR NC,LL822
LD A,#C6
CP B
JR NC,LL823
INC H
JR NZ,LL843
LL858 LD B,#C9
CALL LL946
JR NC,LL822
LD A,B
CP #D6
JR NC,LL858
;--- load data
CALL LL946
RET NC
LD A,C
XOR 3
LD C,A
LD H,0
LD B,#A8 ;#B0
JR LL915
LL884 EX AF,AF'
JR NZ,LL894
JR NC,LL904
IFN DEXOR
EXA
LD A,L
XOR LX
LD (IX),A
EXA
ELSE
LD (IX),L
ENDIF
JR LL909
LL894 RL C
XOR L
RET NZ
LD A,C
RRA
LD C,A
INC DE
JR LL911
LL904 LD A,(IX)
XOR L
RET NZ
LL909 INC IX
LL911 DEC DE
EX AF,AF'
LD B,#AA ;#B2
LL915 LD L,1
LL917 CALL LL942
RET NC
LD A,#B4 ;#CB
CP B
RL L
LD B,#A8 ;#B0
JP NC,LL917
LD A,H
XOR L
LD H,A
LD A,D
OR E
JR NZ,LL884
LD A,H
CP 1
RET
LL942 CALL LL946
RET NC
IFN LOMODE
LL946 LD A,#12 ;#16
LL948 DEC A
JR NZ,LL948
; NOP
; NOP
AND A
LL952 INC B
RET Z
LD A,#7F
IN A,(#FE)
RRA
NOP
XOR C
AND #20
JR Z,LL952
LD A,C
CPL
LD C,A
IF0 LOMODE-1
LD R,A
AND 7
OR 8
OUT (#FE),A
SCF
ENDIF
IF0 LOMODE-2
LD R,A
AND 4
OR 8
OUT (#FE),A
SCF
RET
ENDIF
RET
ELSE
LL946 LD A,#12 ;#16
LL948 DEC A
JR NZ,LL948
AND A
LL952 INC B
RET Z
LD A,#7F
IN A,(#FE)
RRA
; NOP
XOR C
AND #20
JR Z,LL952
LD A,C
CPL
LD C,A
PUSH BC
AND 4
LD C,A
RRA
OR C
RRA
OR C
AND 7
OR 8
NOP
OUT (#FE),A
POP BC
SCF
RET
ENDIF
SCR INCBIN "Castle0"
|
kernel/arch/x86_shared/sse.asm | feliwir/benny | 3 | 8045 | .code32
.global setup_SSE
.section .text
setup_SSE:
# check for SSE
movl $0x1, %eax
cpuid
test $(1<<25), %edx
jz .no_SSE
# enable SSE
movl %cr0, %eax
and $0xFFFB, %ax # clear coprocessor emulation CR0.EM
or $0x2, %ax # set coprocessor monitoring CR0.MP
mov %eax, %cr0
mov %cr4, %eax
or $(3 << 9),%ax # set CR4.OSFXSR and CR4.OSXMMEXCPT at the same time
mov %eax, %cr4
ret
.no_SSE:
movb $'0', %al
jmp error |
Transynther/x86/_processed/NONE/_xt_/i3-7100_9_0x84_notsx.log_21829_2779.asm | ljhsiun2/medusa | 9 | 13396 | <filename>Transynther/x86/_processed/NONE/_xt_/i3-7100_9_0x84_notsx.log_21829_2779.asm
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r12
push %r15
push %rax
push %rcx
push %rdi
push %rsi
lea addresses_WC_ht+0x190dc, %rsi
lea addresses_WT_ht+0xc4, %rdi
nop
nop
nop
and %r11, %r11
mov $93, %rcx
rep movsl
nop
nop
sub %r12, %r12
lea addresses_UC_ht+0xb2dc, %rsi
inc %r12
movb $0x61, (%rsi)
nop
nop
nop
nop
nop
dec %rdi
lea addresses_A_ht+0x1c01c, %r15
nop
nop
nop
nop
dec %rax
movb (%r15), %cl
nop
nop
nop
add %rcx, %rcx
lea addresses_A_ht+0x1b5dc, %rcx
nop
nop
and $41387, %rdi
movb $0x61, (%rcx)
nop
nop
nop
nop
inc %r15
pop %rsi
pop %rdi
pop %rcx
pop %rax
pop %r15
pop %r12
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r12
push %r9
push %rbx
push %rdx
push %rsi
// Faulty Load
lea addresses_WC+0x147dc, %r9
nop
nop
nop
cmp $58261, %rdx
movups (%r9), %xmm4
vpextrq $0, %xmm4, %r12
lea oracles, %r9
and $0xff, %r12
shlq $12, %r12
mov (%r9,%r12,1), %r12
pop %rsi
pop %rdx
pop %rbx
pop %r9
pop %r12
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_WC', 'same': False, 'size': 4, 'congruent': 0, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'type': 'addresses_WC', 'same': True, 'size': 16, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_WC_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM'}
{'dst': {'type': 'addresses_UC_ht', 'same': False, 'size': 1, 'congruent': 6, 'NT': True, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_A_ht', 'same': False, 'size': 1, 'congruent': 5, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_A_ht', 'same': False, 'size': 1, 'congruent': 6, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'38': 21829}
38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38
*/
|
programs/oeis/243/A243581.asm | karttu/loda | 1 | 85142 | <filename>programs/oeis/243/A243581.asm
; A243581: Integers of the form 8k + 7 that can be written as a sum of four distinct squares of the form m, m + 2, m + 3, m + 4, where m == 2 (mod 4).
; 119,351,711,1199,1815,2559,3431,4431,5559,6815,8199,9711,11351,13119,15015,17039,19191,21471,23879,26415,29079,31871,34791,37839,41015,44319,47751,51311,54999,58815,62759,66831,71031,75359,79815,84399,89111,93951,98919,104015,109239,114591,120071,125679,131415,137279,143271,149391,155639,162015,168519,175151,181911,188799,195815,202959,210231,217631,225159,232815,240599,248511,256551,264719,273015,281439,289991,298671,307479,316415,325479,334671,343991,353439,363015,372719,382551,392511,402599,412815,423159,433631,444231,454959,465815,476799,487911,499151,510519,522015,533639,545391,557271,569279,581415,593679,606071,618591,631239,644015,656919,669951,683111,696399,709815,723359,737031,750831,764759,778815,792999,807311,821751,836319,851015,865839,880791,895871,911079,926415,941879,957471,973191,989039,1005015,1021119,1037351,1053711,1070199,1086815,1103559,1120431,1137431,1154559,1171815,1189199,1206711,1224351,1242119,1260015,1278039,1296191,1314471,1332879,1351415,1370079,1388871,1407791,1426839,1446015,1465319,1484751,1504311,1523999,1543815,1563759,1583831,1604031,1624359,1644815,1665399,1686111,1706951,1727919,1749015,1770239,1791591,1813071,1834679,1856415,1878279,1900271,1922391,1944639,1967015,1989519,2012151,2034911,2057799,2080815,2103959,2127231,2150631,2174159,2197815,2221599,2245511,2269551,2293719,2318015,2342439,2366991,2391671,2416479,2441415,2466479,2491671,2516991,2542439,2568015,2593719,2619551,2645511,2671599,2697815,2724159,2750631,2777231,2803959,2830815,2857799,2884911,2912151,2939519,2967015,2994639,3022391,3050271,3078279,3106415,3134679,3163071,3191591,3220239,3249015,3277919,3306951,3336111,3365399,3394815,3424359,3454031,3483831,3513759,3543815,3573999,3604311,3634751,3665319,3696015,3726839,3757791,3788871,3820079,3851415,3882879,3914471,3946191,3978039,4010015
mov $1,8
mul $1,$0
add $1,21
mul $1,$0
mul $1,8
add $1,119
|
4.5.ReverseArray.asm | souzaitor/Assembly | 0 | 29167 | <filename>4.5.ReverseArray.asm
TITLE Reverse Array
;--------------------
; Autor: <NAME>
; Data: 15/07/2021
;
; Capítulo 4 Exercício 5
; Descrição: Este programa inverte um vetor sem usar outra outro array para tal.
;--------------------
INCLUDE Irvine32.inc
.data
array1 DWORD 10d,20d,30d,40d,50d,60d,70d,80d,90d
.code
main PROC
mov ESI, OFFSET array1 ;ESI now points to the first item of array1
mov EDI, SIZEOF array1
add EDI, OFFSET array1
sub EDI, TYPE array1 ;EDI now points to the last item of array1
mov ECX, LENGTHOF array1
shr ECX, 1 ;now ecx is half the length of the array1
L1: mov EAX, [ESI] ;in this loop we reverse the items of the array
mov EBX, [EDI]
mov [EDI],EAX
mov [ESI],EBX
add ESI, TYPE array1
sub EDI, TYPE array1
LOOP L1
mov ECX, LENGTHOF array1;here we just print the array
mov ESI, OFFSET array1
L2: MOV EAX, [ESI]
call WriteInt
call Crlf
add ESI, TYPE array1
LOOP L2
exit
main ENDP
END main |
Transynther/x86/_processed/NONE/_xt_/i7-7700_9_0x48.log_21829_2616.asm | ljhsiun2/medusa | 9 | 169126 | <reponame>ljhsiun2/medusa
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %rax
push %rbp
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_WC_ht+0x12c52, %rcx
nop
nop
nop
nop
nop
sub %rax, %rax
mov (%rcx), %rbx
xor %rbx, %rbx
lea addresses_A_ht+0x18e64, %rsi
lea addresses_A_ht+0xdc72, %rdi
sub %r11, %r11
mov $81, %rcx
rep movsl
nop
nop
nop
nop
xor $7092, %rax
lea addresses_WC_ht+0x14c32, %rdi
nop
nop
sub %rbp, %rbp
vmovups (%rdi), %ymm6
vextracti128 $0, %ymm6, %xmm6
vpextrq $1, %xmm6, %r11
nop
nop
and %rcx, %rcx
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %rax
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r13
push %r14
push %rbp
push %rbx
push %rdx
push %rsi
// Store
lea addresses_US+0xc7e2, %rsi
nop
add %r10, %r10
mov $0x5152535455565758, %r13
movq %r13, %xmm4
vmovups %ymm4, (%rsi)
sub %r10, %r10
// Load
mov $0x6405120000000472, %r14
nop
nop
nop
nop
and $17211, %rdx
movups (%r14), %xmm3
vpextrq $1, %xmm3, %rbp
nop
nop
nop
nop
nop
and %r10, %r10
// Faulty Load
lea addresses_PSE+0x18472, %r13
nop
nop
nop
nop
add %r10, %r10
mov (%r13), %rsi
lea oracles, %rbx
and $0xff, %rsi
shlq $12, %rsi
mov (%rbx,%rsi,1), %rsi
pop %rsi
pop %rdx
pop %rbx
pop %rbp
pop %r14
pop %r13
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_PSE', 'AVXalign': False, 'congruent': 0, 'size': 4, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_US', 'AVXalign': False, 'congruent': 3, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_NC', 'AVXalign': False, 'congruent': 11, 'size': 16, 'same': False, 'NT': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_PSE', 'AVXalign': False, 'congruent': 0, 'size': 8, 'same': True, 'NT': False}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 5, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 10, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 6, 'size': 32, 'same': False, 'NT': False}}
{'33': 21829}
33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33
*/
|
src/graphics.adb | JeremyGrosser/the_grid | 0 | 25594 | --
-- Copyright (C) 2021 <NAME> <<EMAIL>>
--
-- SPDX-License-Identifier: BSD-3-Clause
--
package body Graphics is
type Buffer_Index is mod 2;
Buffers : array (Buffer_Index) of aliased Picosystem.Screen.Scanline;
Swap : Buffer_Index := Buffer_Index'First;
procedure Initialize is
Default_Color : constant Color_Value := Color_Value'First;
begin
Picosystem.Screen.Initialize;
Current :=
(Palette => Grayscale,
Bitmap => (others => (others => Default_Color)));
Update;
end Initialize;
function Scanline
(This : Plane;
Y : Row)
return Picosystem.Screen.Scanline
is
Line : Picosystem.Screen.Scanline;
begin
for X in Column'Range loop
Line (X) := This.Palette (This.Bitmap (Y, X));
end loop;
return Line;
end Scanline;
procedure Update is
begin
Picosystem.Screen.Wait_VSync;
for Y in Row'Range loop
Swap := Swap + 1;
Buffers (Swap) := Scanline (Current, Y);
Picosystem.Screen.Write (Buffers (Swap)'Access);
if HBlank /= null then
HBlank.all (Y);
end if;
end loop;
if VBlank /= null then
VBlank.all (Frame);
end if;
Frame := Frame + 1;
end Update;
end Graphics;
|
src/Microsoft Outlook/Attach Selected from DEVONthink.applescript | kotfu/DEVONthink-scripts | 16 | 2991 | -- Attach the selected files from DEVONthink to the current Outlook draft
-- Tested with Outlook 15.33, i.e. Outlook 2016 for Mac
-- get the posix paths of the currently selected records in DEVONthink
tell application id "DNtp"
-- go find the first viewer window
-- this doesn't seem to select the topmost viewer window
-- if you have multiple viewer windows open, but it works great
-- if you only have one
set theWindow to false as boolean
repeat with x from 1 to (count windows)
if class of window x is viewer window then
set theWindow to window x
exit repeat
end if
end repeat
if theWindow is false then
display notification "No DEVONthink viewer window found."
return
end if
set theRecords to selection of theWindow
set thePaths to {}
repeat with theRecord in theRecords
set thePath to the path of theRecord as POSIX file
copy thePath to end of thePaths
end repeat
end tell
tell application "Microsoft Outlook"
-- loop through the open Outlook windows looking for
-- draft message windows. If there is only one draft window open
-- this finds it. Experimentation indicates that when multiple
-- draft windows are open this finds the topmost one first
set theWindow to false as boolean
repeat with x from 1 to (count windows)
if class of window x is draft window then
set theWindow to window x
exit repeat
end if
end repeat
if theWindow is false then
display notification "No draft messages are currently open."
return
end if
--display notification "have draft window"
get the id of the object of theWindow
set myObjectID to id of (object of theWindow)
set theMessage to message id myObjectID
-- loop through the paths from the records and add them
-- as attachments to the message
repeat with thePath in thePaths
tell theMessage
make new attachment with properties {file:thePath}
end tell
end repeat
end tell
|
alloy4fun_models/trainstlt/models/8/n2KhQaTMvtqih9apa.als | Kaixi26/org.alloytools.alloy | 0 | 3454 | open main
pred idn2KhQaTMvtqih9apa_prop9 {
all t:Train | some tk:Entry | (t.pos not in Entry) implies eventually (t->tk in pos and before no t.pos)
}
pred __repair { idn2KhQaTMvtqih9apa_prop9 }
check __repair { idn2KhQaTMvtqih9apa_prop9 <=> prop9o } |
tests/String/hello_world_string.asm | ZubinGou/8086-emulator | 39 | 161015 | <reponame>ZubinGou/8086-emulator
; Hello world!
NAME String
TITLE hello_world_string
assume cs:code,ds:data
data segment
msg db "Hello,World!$"
data ends
code segment
start: mov ax,data ;intialize DS to address
mov ds,ax ;of data segment
lea dx,msg ;load effect address of message
out 0,dx
mov ah,09h ;display string function
int 21h ;display message
exit: mov ax,4c00h ;DOS function: Exit program
int 21h ;Call DOS, terminate program
code ends
end start |
1-source-files/main-sources/elite-loader.asm | markmoxon/elite-beebasm | 251 | 102946 | \ ******************************************************************************
\
\ ELITE LOADER SOURCE
\
\ Elite was written by <NAME> and <NAME> and is copyright Acornsoft 1984
\
\ The code on this site is identical to the source discs released on Ian Bell's
\ personal website at http://www.elitehomepage.org/ (it's just been reformatted
\ to be more readable)
\
\ The commentary is copyright <NAME>, and any misunderstandings or mistakes
\ in the documentation are entirely my fault
\
\ The terminology and notations used in this commentary are explained at
\ https://www.bbcelite.com/about_site/terminology_used_in_this_commentary.html
\
\ The deep dive articles referred to in this commentary can be found at
\ https://www.bbcelite.com/deep_dives
\
\ ------------------------------------------------------------------------------
\
\ This source file produces the following binary file:
\
\ * ELITE.unprot.bin
\
\ after reading in the following files:
\
\ * DIALS.bin
\ * P.ELITE.bin
\ * P.A-SOFT.bin
\ * P.(C)ASFT.bin
\ * WORDS9.bin
\ * PYTHON.bin
\
\ ******************************************************************************
INCLUDE "1-source-files/main-sources/elite-header.h.asm"
_SOURCE_DISC = (_RELEASE = 1)
_TEXT_SOURCES = (_RELEASE = 2)
GUARD &6000 \ Guard against assembling over screen memory
\ ******************************************************************************
\
\ Configuration variables
\
\ ******************************************************************************
DISC = TRUE \ Set to TRUE to load the code above DFS and relocate
\ down, so we can load the cassette version from disc
PROT = FALSE \ Set to TRUE to enable the tape protection code
LEN1 = 15 \ Size of the BEGIN% routine that gets pushed onto the
\ stack and executed there
LEN2 = 18 \ Size of the MVDL routine that gets pushed onto the
\ stack and executed there
LEN = LEN1 + LEN2 \ Total number of bytes that get pushed on the stack for
\ execution there (33)
VSCAN = 57-1 \ Defines the split position in the split-screen mode
LE% = &0B00 \ LE% is the address to which the code from UU% onwards
\ is copied in part 3. It contains:
\
\ * ENTRY2, the entry point for the second block of
\ loader code
\
\ * IRQ1, the interrupt routine for the split-screen
\ mode
\
\ * BLOCK, which by this point has already been put
\ on the stack by this point
\
\ * The variables used by the above
NETV = &0224 \ The NETV vector that we intercept as part of the copy
\ protection
IRQ1V = &0204 \ The IRQ1V vector that we intercept to implement the
\ split-sceen mode
OSPRNT = &0234 \ The address for the OSPRNT vector
C% = &0F40 \ C% is set to the location that the main game code gets
\ moved to after it is loaded
S% = C% \ S% points to the entry point for the main game code
L% = &1128 \ L% points to the start of the actual game code from
\ elite-source.asm, after the &28 bytes of header code
\ that are inserted by elite-bcfs.asm
IF _SOURCE_DISC
D% = &563A \ D% is set to the size of the main game code
ELIF _TEXT_SOURCES
D% = &5638 \ D% is set to the size of the main game code
ENDIF
LC% = &6000 - C% \ LC% is set to the maximum size of the main game code
\ (as the code starts at C% and screen memory starts
\ at &6000)
N% = 67 \ N% is set to the number of bytes in the VDU table, so
\ we can loop through them in part 2 below
SVN = &7FFD \ SVN is where we store the "saving in progress" flag,
\ and it matches the location in elite-source.asm
VEC = &7FFE \ VEC is where we store the original value of the IRQ1
\ vector, and it matches the value in elite-source.asm
VIA = &FE00 \ Memory-mapped space for accessing internal hardware,
\ such as the video ULA, 6845 CRTC and 6522 VIAs (also
\ known as SHEILA)
OSWRCH = &FFEE \ The address for the OSWRCH routine
OSBYTE = &FFF4 \ The address for the OSBYTE routine
OSWORD = &FFF1 \ The address for the OSWORD routine
\ ******************************************************************************
\
\ Name: ZP
\ Type: Workspace
\ Address: &0004 to &0005 and &0070 to &0086
\ Category: Workspaces
\ Summary: Important variables used by the loader
\
\ ******************************************************************************
ORG &0004
.TRTB%
SKIP 2 \ Contains the address of the keyboard translation
\ table, which is used to translate internal key
\ numbers to ASCII
ORG &0070
.ZP
SKIP 2 \ Stores addresses used for moving content around
.P
SKIP 1 \ Temporary storage, used in a number of places
.Q
SKIP 1 \ Temporary storage, used in a number of places
.YY
SKIP 1 \ Temporary storage, used in a number of places
.T
SKIP 1 \ Temporary storage, used in a number of places
.SC
SKIP 1 \ Screen address (low byte)
\
\ Elite draws on-screen by poking bytes directly into
\ screen memory, and SC(1 0) is typically set to the
\ address of the character block containing the pixel
\ we want to draw (see the deep dives on "Drawing
\ monochrome pixels in mode 4" and "Drawing colour
\ pixels in mode 5" for more details)
.SCH
SKIP 1 \ Screen address (high byte)
.BLPTR
SKIP 2 \ Gets set to &03CA as part of the obfuscation code
.V219
SKIP 2 \ Gets set to &0218 as part of the obfuscation code
SKIP 4 \ These bytes appear to be unused
.K3
SKIP 1 \ Temporary storage, used in a number of places
.BLCNT
SKIP 2 \ Stores the tape loader block count as part of the copy
\ protection code in IRQ1
.BLN
SKIP 2 \ Gets set to &03C6 as part of the obfuscation code
.EXCN
SKIP 2 \ Gets set to &03C2 as part of the obfuscation code
\ ******************************************************************************
\
\ ELITE LOADER
\
\ ******************************************************************************
IF DISC
CODE% = &1100 \ CODE% is set to the assembly address of the loader
\ code file that we assemble in this file ("ELITE"),
\ which is at the lowest DFS page value of &1100 for the
\ version that loads from disc
ELSE
CODE% = &0E00 \ CODE% is set to the assembly address of the loader
\ code file that we assemble in this file ("ELITE"),
\ which is at the standard &0E00 address for the version
\ that loads from cassette
ENDIF
LOAD% = &1100 \ LOAD% is the load address of the main game code file
\ ("ELTcode" for loading from disc, "ELITEcode" for
\ loading from tape)
ORG CODE%
\ ******************************************************************************
\
\ Name: Elite loader (Part 1 of 6)
\ Type: Subroutine
\ Category: Loader
\ Summary: Include binaries for recursive tokens, Python blueprint and images
\
\ ------------------------------------------------------------------------------
\
\ The loader bundles a number of binary files in with the loader code, and moves
\ them to their correct memory locations in part 3 below.
\
\ There are two files containing code:
\
\ * WORDS9.bin contains the recursive token table, which is moved to &0400
\ before the main game is loaded
\
\ * PYTHON.bin contains the Python ship blueprint, which gets moved to &7F00
\ before the main game is loaded
\
\ and four files containing images, which are all moved into screen memory by
\ the loader:
\
\ * P.A-SOFT.bin contains the "ACORNSOFT" title across the top of the loading
\ screen, which gets moved to screen address &6100, on the second character
\ row of the monochrome mode 4 screen
\
\ * P.ELITE.bin contains the "ELITE" title across the top of the loading
\ screen, which gets moved to screen address &6300, on the fourth character
\ row of the monochrome mode 4 screen
\
\ * P.(C)ASFT.bin contains the "(C) Acornsoft 1984" title across the bottom
\ of the loading screen, which gets moved to screen address &7600, the
\ penultimate character row of the monochrome mode 4 screen, just above the
\ dashboard
\
\ * P.DIALS.bin contains the dashboard, which gets moved to screen address
\ &7800, which is the starting point of the four-colour mode 5 portion at
\ the bottom of the split screen
\
\ The routine ends with a jump to the start of the loader code at ENTRY.
\
\ ******************************************************************************
PRINT "WORDS9 = ",~P%
INCBIN "3-assembled-output/WORDS9.bin"
ALIGN 256
PRINT "P.DIALS = ",~P%
INCBIN "1-source-files/images/P.DIALS.bin"
PRINT "PYTHON = ",~P%
INCBIN "3-assembled-output/PYTHON.bin"
PRINT "P.ELITE = ",~P%
INCBIN "1-source-files/images/P.ELITE.bin"
PRINT "P.A-SOFT = ",~P%
INCBIN "1-source-files/images/P.A-SOFT.bin"
PRINT "P.(C)ASFT = ",~P%
INCBIN "1-source-files/images/P.(C)ASFT.bin"
.run
JMP ENTRY \ Jump to ENTRY to start the loading process
\ ******************************************************************************
\
\ Name: B%
\ Type: Variable
\ Category: Screen mode
\ Summary: VDU commands for setting the square mode 4 screen
\ Deep dive: The split-screen mode
\ Drawing monochrome pixels in mode 4
\
\ ------------------------------------------------------------------------------
\
\ This block contains the bytes that get written by OSWRCH to set up the screen
\ mode (this is equivalent to using the VDU statement in BASIC).
\
\ It defines the whole screen using a square, monochrome mode 4 configuration;
\ the mode 5 part for the dashboard is implemented in the IRQ1 routine.
\
\ The top part of Elite's screen mode is based on mode 4 but with the following
\ differences:
\
\ * 32 columns, 31 rows (256 x 248 pixels) rather than 40, 32
\
\ * The horizontal sync position is at character 45 rather than 49, which
\ pushes the screen to the right (which centres it as it's not as wide as
\ the normal screen modes)
\
\ * Screen memory goes from &6000 to &7EFF, which leaves another whole page
\ for code (i.e. 256 bytes) after the end of the screen. This is where the
\ Python ship blueprint slots in
\
\ * The text window is 1 row high and 13 columns wide, and is at (2, 16)
\
\ * The cursor is disabled
\
\ This almost-square mode 4 variant makes life a lot easier when drawing to the
\ screen, as there are 256 pixels on each row (or, to put it in screen memory
\ terms, there's one page of memory per row of pixels). For more details of the
\ screen mode, see the deep dive on "Drawing monochrome pixels in mode 4".
\
\ There is also an interrupt-driven routine that switches the bytes-per-pixel
\ setting from that of mode 4 to that of mode 5, when the raster reaches the
\ split between the space view and the dashboard. See the deep dive on "The
\ split-screen mode" for details.
\
\ ******************************************************************************
.B%
EQUB 22, 4 \ Switch to screen mode 4
EQUB 28 \ Define a text window as follows:
EQUB 2, 17, 15, 16 \
\ * Left = 2
\ * Right = 15
\ * Top = 16
\ * Bottom = 17
\
\ i.e. 1 row high, 13 columns wide at (2, 16)
EQUB 23, 0, 6, 31 \ Set 6845 register R6 = 31
EQUB 0, 0, 0 \
EQUB 0, 0, 0 \ This is the "vertical displayed" register, and sets
\ the number of displayed character rows to 31. For
\ comparison, this value is 32 for standard modes 4 and
\ 5, but we claw back the last row for storing code just
\ above the end of screen memory
EQUB 23, 0, 12, &0C \ Set 6845 register R12 = &0C and R13 = &00
EQUB 0, 0, 0 \
EQUB 0, 0, 0 \ This sets 6845 registers (R12 R13) = &0C00 to point
EQUB 23, 0, 13, &00 \ to the start of screen memory in terms of character
EQUB 0, 0, 0 \ rows. There are 8 pixel lines in each character row,
EQUB 0, 0, 0 \ so to get the actual address of the start of screen
\ memory, we multiply by 8:
\
\ &0C00 * 8 = &6000
\
\ So this sets the start of screen memory to &6000
EQUB 23, 0, 1, 32 \ Set 6845 register R1 = 32
EQUB 0, 0, 0 \
EQUB 0, 0, 0 \ This is the "horizontal displayed" register, which
\ defines the number of character blocks per horizontal
\ character row. For comparison, this value is 40 for
\ modes 4 and 5, but our custom screen is not as wide at
\ only 32 character blocks across
EQUB 23, 0, 2, 45 \ Set 6845 register R2 = 45
EQUB 0, 0, 0 \
EQUB 0, 0, 0 \ This is the "horizontal sync position" register, which
\ defines the position of the horizontal sync pulse on
\ the horizontal line in terms of character widths from
\ the left-hand side of the screen. For comparison this
\ is 49 for modes 4 and 5, but needs to be adjusted for
\ our custom screen's width
EQUB 23, 0, 10, 32 \ Set 6845 register R10 = 32
EQUB 0, 0, 0 \
EQUB 0, 0, 0 \ This is the "cursor start" register, so this sets the
\ cursor start line at 0, effectively disabling the
\ cursor
\ ******************************************************************************
\
\ Name: E%
\ Type: Variable
\ Category: Sound
\ Summary: Sound envelope definitions
\
\ ------------------------------------------------------------------------------
\
\ This table contains the sound envelope data, which is passed to OSWORD by the
\ FNE macro to create the four sound envelopes used in-game. Refer to chapter 30
\ of the BBC Micro User Guide for details of sound envelopes and what all the
\ parameters mean.
\
\ The envelopes are as follows:
\
\ * Envelope 1 is the sound of our own laser firing
\
\ * Envelope 2 is the sound of lasers hitting us, or hyperspace
\
\ * Envelope 3 is the first sound in the two-part sound of us dying, or the
\ second sound in the two-part sound of us making hitting or killing an
\ enemy ship
\
\ * Envelope 4 is the sound of E.C.M. firing
\
\ ******************************************************************************
.E%
EQUB 1, 1, 0, 111, -8, 4, 1, 8, 8, -2, 0, -1, 112, 44
EQUB 2, 1, 14, -18, -1, 44, 32, 50, 6, 1, 0, -2, 120, 126
EQUB 3, 1, 1, -1, -3, 17, 32, 128, 1, 0, 0, -1, 1, 1
EQUB 4, 1, 4, -8, 44, 4, 6, 8, 22, 0, 0, -127, 126, 0
\ ******************************************************************************
\
\ Name: swine
\ Type: Subroutine
\ Category: Copy protection
\ Summary: Resets the machine if the copy protection detects a problem
\
\ ******************************************************************************
.swine
LDA #%01111111 \ Set 6522 System VIA interrupt enable register IER
STA &FE4E \ (SHEILA &4E) bits 0-6 (i.e. disable all hardware
\ interrupts from the System VIA)
JMP (&FFFC) \ Jump to the address in &FFFC to reset the machine
\ ******************************************************************************
\
\ Name: OSB
\ Type: Subroutine
\ Category: Utility routines
\ Summary: A convenience routine for calling OSBYTE with Y = 0
\
\ ******************************************************************************
.OSB
LDY #0 \ Call OSBYTE with Y = 0, returning from the subroutine
JMP OSBYTE \ using a tail call (so we can call OSB to call OSBYTE
\ for when we know we want Y set to 0)
\ ******************************************************************************
\
\ Name: Authors' names
\ Type: Variable
\ Category: Copy protection
\ Summary: The authors' names, buried in the code
\
\ ------------------------------------------------------------------------------
\
\ Contains the authors' names, plus an unused OS command string that would
\ *RUN the main game code, which isn't what actually happens (so presumably
\ this is to throw the crackers off the scent).
\
\ ******************************************************************************
EQUS "R.ELITEcode" \ This is short for "*RUN ELITEcode"
EQUB 13
EQUS "By D.Braben/I.Bell"
EQUB 13
EQUB &B0
\ ******************************************************************************
\
\ Name: oscliv
\ Type: Variable
\ Category: Utility routines
\ Summary: Contains the address of OSCLIV, for executing OS commands
\
\ ******************************************************************************
.oscliv
EQUW &FFF7 \ Address of OSCLIV, for executing OS commands
\ (specifically the *LOAD that loads the main game code)
\ ******************************************************************************
\
\ Name: David9
\ Type: Variable
\ Category: Copy protection
\ Summary: Address used as part of the stack-based decryption loop
\
\ ------------------------------------------------------------------------------
\
\ This address is used in the decryption loop starting at David2 in part 4, and
\ is used to jump back into the loop at David5.
\
\ ******************************************************************************
.David9
EQUW David5 \ The address of David5
CLD \ This instruction is not used
\ ******************************************************************************
\
\ Name: David23
\ Type: Variable
\ Category: Copy protection
\ Summary: Address pointer to the start of the 6502 stack
\
\ ------------------------------------------------------------------------------
\
\ This two-byte address points to the start of the 6502 stack, which descends
\ from the end of page 2, less LEN bytes, which comes out as &01DF. So when we
\ push 33 bytes onto the stack (LEN being 33), this address will point to the
\ start of those bytes, which means we can push executable code onto the stack
\ and run it by calling this address with a JMP (David23) instruction. Sneaky
\ stuff!
\
\ ******************************************************************************
.David23
EQUW (512-LEN) \ The address of LEN bytes before the start of the stack
\ ******************************************************************************
\
\ Name: doPROT1
\ Type: Subroutine
\ Category: Copy protection
\ Summary: Routine to self-modify the loader code
\
\ ------------------------------------------------------------------------------
\
\ This routine modifies various bits of code in-place as part of the copy
\ protection mechanism. It is called with A = &48 and X = 255.
\
\ ******************************************************************************
.doPROT1
LDY #&DB \ Store &EFDB in TRTB%(1 0) to point to the keyboard
STY TRTB% \ translation table for OS 0.1 (which we will overwrite
LDY #&EF \ with a call to OSBYTE later)
STY TRTB%+1
LDY #2 \ Set the high byte of V219(1 0) to 2
STY V219+1
STA PROT1-255,X \ Poke &48 into PROT1, which changes the instruction
\ there to a PHA
LDY #&18 \ Set the low byte of V219(1 0) to &18 (as X = 255), so
STY V219+1,X \ V219(1 0) now contains &0218
RTS \ Return from the subroutine
\ ******************************************************************************
\
\ Name: MHCA
\ Type: Variable
\ Category: Copy protection
\ Summary: Used to set one of the vectors in the copy protection code
\
\ ------------------------------------------------------------------------------
\
\ This value is used to set the low byte of BLPTR(1 0), when it's set in PLL1
\ as part of the copy protection.
\
\ ******************************************************************************
.MHCA
EQUB &CA \ The low byte of BLPTR(1 0)
\ ******************************************************************************
\
\ Name: David7
\ Type: Subroutine
\ Category: Copy protection
\ Summary: Part of the multi-jump obfuscation code in PROT1
\
\ ------------------------------------------------------------------------------
\
\ This instruction is part of the multi-jump obfuscation in PROT1 (see part 2 of
\ the loader), which does the following jumps:
\
\ David8 -> FRED1 -> David7 -> Ian1 -> David3
\
\ ******************************************************************************
.David7
BCC Ian1 \ This instruction is part of the multi-jump obfuscation
\ in PROT1
\ ******************************************************************************
\
\ Name: FNE
\ Type: Macro
\ Category: Sound
\ Summary: Macro definition for defining a sound envelope
\
\ ------------------------------------------------------------------------------
\
\ The following macro is used to define the four sound envelopes used in the
\ game. It uses OSWORD 8 to create an envelope using the 14 parameters in the
\ the I%-th block of 14 bytes at location E%. This OSWORD call is the same as
\ BBC BASIC's ENVELOPE command.
\
\ See variable E% for more details of the envelopes themselves.
\
\ ******************************************************************************
MACRO FNE I%
LDX #LO(E%+I%*14) \ Set (Y X) to point to the I%-th set of envelope data
LDY #HI(E%+I%*14) \ in E%
LDA #8 \ Call OSWORD with A = 8 to set up sound envelope I%
JSR OSWORD
ENDMACRO
\ ******************************************************************************
\
\ Name: Elite loader (Part 2 of 6)
\ Type: Subroutine
\ Category: Loader
\ Summary: Perform a number of OS calls, set up sound, push routines on stack
\
\ ------------------------------------------------------------------------------
\
\ This part of the loader does a number of calls to OS routines, sets up the
\ sound envelopes, pushes 33 bytes onto the stack that will be used later, and
\ sends us on a wild goose chase, just for kicks.
\
\ ******************************************************************************
.ENTRY
SEI \ Disable all interrupts
CLD \ Clear the decimal flag, so we're not in decimal mode
IF DISC = 0
LDA #0 \ Call OSBYTE with A = 0 and X = 255 to fetch the
LDX #255 \ operating system version into X
JSR OSBYTE
TXA \ If X = 0 then this is OS 1.00, so jump down to OS100
BEQ OS100 \ to skip the following
LDY &FFB6 \ Otherwise this is OS 1.20, so set Y to the contents of
\ &FFB6, which contains the length of the default vector
\ table
LDA &FFB7 \ Set ZP(1 0) to the location stored in &FFB7-&FFB8,
STA ZP \ which contains the address of the default vector table
LDA &FFB8
STA ZP+1
DEY \ Decrement Y so we can use it as an index for setting
\ all the vectors to their default states
.ABCDEFG
LDA (ZP),Y \ Copy the Y-th byte from the default vector table into
STA &0200,Y \ the vector table in &0200
DEY \ Decrement the loop counter
BPL ABCDEFG \ Loop back for the next vector until we have done them
\ all
.OS100
ENDIF
LDA #%01111111 \ Set 6522 System VIA interrupt enable register IER
STA &FE4E \ (SHEILA &4E) bits 0-6 (i.e. disable all hardware
\ interrupts from the System VIA)
STA &FE6E \ Set 6522 User VIA interrupt enable register IER
\ (SHEILA &6E) bits 0-6 (i.e. disable all hardware
\ interrupts from the User VIA)
LDA &FFFC \ Fetch the low byte of the reset address in &FFFC,
\ which will reset the machine if called
STA &0200 \ Set the low bytes of USERV, BRKV, IRQ2V and EVENTV
STA &0202
STA &0206
STA &0220
LDA &FFFD \ Fetch the high byte of the reset address in &FFFD,
\ which will reset the machine if called
STA &0201 \ Set the high bytes of USERV, BRKV, IRQ2V and EVENTV
STA &0203
STA &0207
STA &0221
LDX #&2F-2 \ We now step through all the vectors from &0204 to
\ &022F and OR their high bytes with &C0, so they all
\ point into the MOS ROM space (which is from &C000 and
\ upwards), so we set a counter in X to count through
\ them
.purge
LDA &0202,X \ Set the high byte of the vector in &0202+X so it
ORA #&C0 \ points to the MOS ROM
STA &0202,X
DEX \ Increment the counter to point to the next high byte
DEX
BPL purge \ Loop back until we have done all the vectors
LDA #&60 \ Store an RTS instruction in location &0232
STA &0232
LDA #&2 \ Point the NETV vector to &0232, which we just filled
STA NETV+1 \ with an RTS
LDA #&32
STA NETV
LDA #&20 \ Set A to the op code for a JSR call with absolute
\ addressing
EQUB &2C \ Skip the next instruction by turning it into
\ &2C &D0 &66, or BIT &66D0, which does nothing apart
\ from affect the flags
.Ian1
BNE David3 \ This instruction is skipped if we came from above,
\ otherwise this is part of the multi-jump obfuscation
\ in PROT1
STA David2 \ Store &20 in location David2, which modifies the
\ instruction there (see David2 for details)
LSR A \ Set A = 16
LDX #3 \ Set the high bytes of BLPTR(1 0), BLN(1 0) and
STX BLPTR+1 \ EXCN(1 0) to &3. We will fill in the high bytes in
STX BLN+1 \ the PLL1 routine, and will then use these values in
STX EXCN+1 \ the IRQ1 handler
DEX \ Set X = 2
JSR OSBYTE \ Call OSBYTE with A = 16 and X = 2 to set the ADC to
\ sample 2 channels from the joystick
EQUB &2C \ Skip the next instruction by turning it into
\ &2C &D0 &A1, or BIT &A1D0, which does nothing apart
\ from affect the flags
.FRED1
BNE David7 \ This instruction is skipped if we came from above,
\ otherwise this is part of the multi-jump obfuscation
\ in PROT1
LDX #255 \ Call doPROT1 to change an instruction in the PROT1
LDA #&48 \ routine and set up another couple of variables
JSR doPROT1
LDA #144 \ Call OSBYTE with A = 144, X = 255 and Y = 0 to move
JSR OSB \ the screen down one line and turn screen interlace on
LDA #247 \ Call OSBYTE with A = 247 and X = Y = 0 to disable the
LDX #0 \ BREAK intercept code by poking 0 into the first value
JSR OSB
\LDA #129 \ These instructions are commented out in the original
\LDY #255 \ source, along with the comment "Damn 0.1", so
\LDX #1 \ presumably MOS version 0.1 was a bit of a pain to
\JSR OSBYTE \ support - which is probably why Elite doesn't bother
\TXA \ and only supports 1.0 and 1.2
\BPL OS01
\Damn 0.1
LDA #190 \ Call OSBYTE with A = 190, X = 8 and Y = 0 to set the
LDX #8 \ ADC conversion type to 8 bits, for the joystick
JSR OSB
EQUB &2C \ Skip the next instruction by turning it into
\ &2C &D0 &E1, or BIT &E1D0, which does nothing apart
\ from affect the flags
.David8
BNE FRED1 \ This instruction is skipped if we came from above,
\ otherwise this is part of the multi-jump obfuscation
\ in PROT1
LDA #143 \ Call OSBYTE 143 to issue a paged ROM service call of
LDX #&C \ type &C with argument &FF, which is the "NMI claim"
LDY #&FF \ service call that asks the current user of the NMI
JSR OSBYTE \ space to clear it out
LDA #13 \ Set A = 13 for the next OSBYTE call
.abrk
LDX #0 \ Call OSBYTE with A = 13, X = 0 and Y = 0 to disable
JSR OSB \ the "output buffer empty" event
LDA #225 \ Call OSBYTE with A = 225, X = 128 and Y = 0 to set
LDX #128 \ the function keys to return ASCII codes for SHIFT-fn
JSR OSB \ keys (i.e. add 128)
LDA #172 \ Call OSBYTE 172 to read the address of the MOS
LDX #0 \ keyboard translation table into (Y X)
LDY #255
JSR OSBYTE
STX TRTB% \ Store the address of the keyboard translation table in
STY TRTB%+1 \ TRTB%(1 0)
LDA #200 \ Call OSBYTE with A = 200, X = 3 and Y = 0 to disable
LDX #3 \ the ESCAPE key and clear memory if the BREAK key is
JSR OSB \ pressed
IF PROT AND DISC = 0
CPX #3 \ If the previous value of X from the call to OSBYTE 200
BNE abrk+1 \ was not 3 (ESCAPE disabled, clear memory), jump to
\ abrk+1, which contains a BRK instruction which will
\ reset the computer (as we set BRKV to point to the
\ reset address above)
ENDIF
LDA #13 \ Call OSBYTE with A = 13, X = 2 and Y = 0 to disable
LDX #2 \ the "character entering keyboard buffer" event
JSR OSB
.OS01
LDX #&FF \ Set the stack pointer to &01FF, which is the standard
TXS \ location for the 6502 stack, so this instruction
\ effectively resets the stack
INX \ Set X = 0, to use as a counter in the following loop
.David3
LDA BEGIN%,X \ This routine pushes 33 bytes from BEGIN% onto the
\ stack, so fetch the X-th byte from BEGIN%
.PROT1
INY \ This instruction gets changed to a PHA instruction by
\ the doPROT1 routine that's called above, so by the
\ time we get here, this instruction actually pushes the
\ X-th byte from BEGIN% onto the stack
INX \ Increment the loop counter
CPX #LEN \ If X < #LEN (which is 33), loop back for the next one.
BNE David8 \ This branch actually takes us on wold goose chase
\ through the following locations, where each BNE is
\ prefaced by an EQUB &2C that disables the branch
\ instruction during the normal instruction flow:
\
\ David8 -> FRED1 -> David7 -> Ian1 -> David3
\
\ so in the end this just loops back to push the next
\ byte onto the stack, but in a really sneaky way
LDA #LO(B%) \ Set the low byte of ZP(1 0) to point to the VDU code
STA ZP \ table at B%
LDA #&C8 \ Poke &C8 into PROT1 to change the instruction that we
STA PROT1 \ modified back to an INY instruction, rather than a PHA
LDA #HI(B%) \ Set the high byte of ZP(1 0) to point to the VDU code
STA ZP+1 \ table at B%
LDY #0 \ We are now going to send the N% VDU bytes in the table
\ at B% to OSWRCH to set up the special mode 4 screen
\ that forms the basis for the split-screen mode
.LOOP
LDA (ZP),Y \ Pass the Y-th byte of the B% table to OSWRCH
JSR OSWRCH
INY \ Increment the loop counter
CPY #N% \ Loop back for the next byte until we have done them
BNE LOOP \ all (the number of bytes was set in N% above)
LDA #1 \ In doPROT1 above we set V219(1 0) = &0218, so this
TAX \ code sets the contents of &0219 (the high byte of
TAY \ BPUTV) to 1. We will see why this later, at the start
STA (V219),Y \ of part 4
LDA #4 \ Call OSBYTE with A = 4, X = 1 and Y = 0 to disable
JSR OSB \ cursor editing, so the cursor keys return ASCII values
\ and can therefore be used in-game
LDA #9 \ Call OSBYTE with A = 9, X = 0 and Y = 0 to disable
LDX #0 \ flashing colours
JSR OSB
LDA #&6C \ Poke &6C into crunchit after EOR'ing it first (which
EOR crunchit \ has no effect as crunchit contains a BRK instruction
STA crunchit \ with opcode 0), to change crunchit to an indirect JMP
FNE 0 \ Set up sound envelopes 0-3 using the FNE macro
FNE 1
FNE 2
FNE 3
\ ******************************************************************************
\
\ Name: Elite loader (Part 3 of 6)
\ Type: Subroutine
\ Category: Loader
\ Summary: Move and decrypt recursive tokens, Python blueprint and images
\
\ ------------------------------------------------------------------------------
\
\ Move and decrypt the following memory blocks:
\
\ * WORDS9: move 4 pages (1024 bytes) from CODE% to &0400
\
\ * P.ELITE: move 1 page (256 bytes) from CODE% + &0C00 to &6300
\
\ * P.A-SOFT: move 1 page (256 bytes) from CODE% + &0D00 to &6100
\
\ * P.(C)ASFT: move 1 page (256 bytes) from CODE% + &0E00 to &7600
\
\ * P.DIALS and PYTHON: move 8 pages (2048 bytes) from CODE% + &0400 to &7800
\
\ * Move 2 pages (512 bytes) from UU% to &0B00-&0CFF
\
\ and call the routine to draw Saturn between P.(C)ASFT and P.DIALS.
\
\ See part 1 above for more details on the above files and the locations that
\ they are moved to.
\
\ The code at UU% (see below) forms part of the loader code and is moved before
\ being run, so it's tucked away safely while the main game code is loaded and
\ decrypted.
\
\ ******************************************************************************
LDX #4 \ Set the following:
STX P+1 \
LDA #HI(CODE%) \ P(1 0) = &0400
STA ZP+1 \ ZP(1 0) = CODE%
LDY #0 \ (X Y) = &400 = 1024
LDA #256-LEN1 \
STA (V219-4,X) \ In doPROT1 above we set V219(1 0) = &0218, so this
STY ZP \ also sets the contents of &0218 (the low byte of
STY P \ BPUTV) to 256 - LEN1, or &F1. We set the low byte to
\ 1 above, so BPUTV now contains &01F1, which we will
\ use at the start of part 4
JSR crunchit \ Call crunchit, which has now been modified to call the
\ MVDL routine on the stack, to move and decrypt &400
\ bytes from CODE% to &0400. We loaded WORDS9.bin to
\ CODE% in part 1, so this moves WORDS9
LDX #1 \ Set the following:
LDA #(HI(CODE%)+&C) \
STA ZP+1 \ P(1 0) = &6300
LDA #&63 \ ZP(1 0) = CODE% + &C
STA P+1 \ (X Y) = &100 = 256
LDY #0
JSR crunchit \ Call crunchit to move and decrypt &100 bytes from
\ CODE% + &C to &6300, so this moves P.ELITE
LDX #1 \ Set the following:
LDA #(HI(CODE%)+&D) \
STA ZP+1 \ P(1 0) = &6100
LDA #&61 \ ZP(1 0) = CODE% + &D
STA P+1 \ (X Y) = &100 = 256
LDY #0
JSR crunchit \ Call crunchit to move and decrypt &100 bytes from
\ CODE% + &D to &6100, so this moves P.A-SOFT
LDX #1 \ Set the following:
LDA #(HI(CODE%)+&E) \
STA ZP+1 \ P(1 0) = &7600
LDA #&76 \ ZP(1 0) = CODE% + &E
STA P+1 \ (X Y) = &100 = 256
LDY #0
JSR crunchit \ Call crunchit to move and decrypt &100 bytes from
\ CODE% + &E to &7600, so this moves P.(C)ASFT
JSR PLL1 \ Call PLL1 to draw Saturn
LDX #8 \ Set the following:
LDA #(HI(CODE%)+4) \
STA ZP+1 \ P(1 0) = &7800
LDA #&78 \ ZP(1 0) = CODE% + &4
STA P+1 \ (X Y) = &800 = 2048
LDY #0 \
STY ZP \ Also set BLCNT = 0
STY BLCNT
STY P
JSR crunchit \ Call crunchit to move and decrypt &800 bytes from
\ CODE% + &4 to &7800, so this moves P.DIALS and PYTHON
LDX #(3-(DISC AND 1)) \ Set the following:
LDA #HI(UU%) \
STA ZP+1 \ P(1 0) = LE%
LDA #LO(UU%) \ ZP(1 0) = UU%
STA ZP \ (X Y) = &300 = 768 (if we are building for tape)
LDA #HI(LE%) \ or &200 = 512 (if we are building for disc)
STA P+1
LDY #0
STY P
JSR crunchit \ Call crunchit to move and decrypt either &200 or &300
\ bytes from UU% to LE%, leaving X = 0
\ ******************************************************************************
\
\ Name: Elite loader (Part 4 of 6)
\ Type: Subroutine
\ Category: Loader
\ Summary: Copy more code onto stack, decrypt TUT block, set up IRQ1 handler
\
\ ------------------------------------------------------------------------------
\
\ This part copies more code onto the stack (from BLOCK to ENDBLOCK), decrypts
\ the code from TUT onwards, and sets up the IRQ1 handler for the split-screen
\ mode.
\
\ ******************************************************************************
STY David3-2 \ Y was set to 0 above, so this modifies the OS01
\ routine above by changing the TXS instruction to BRK,
\ so calls to OS01 will now do this:
\
\ LDX #&FF
\ BRK
\
\ This is presumably just to confuse any cracker, as we
\ don't call OS01 again
\ We now enter a loop that starts with the counter in Y
\ (initially set to 0). It calls JSR &01F1 on the stack,
\ which pushes the Y-th byte of BLOCK on the stack
\ before encrypting the Y-th byte of BLOCK in-place. It
\ then jumps back to David5 below, where we increment Y
\ until it reaches a value of ENDBLOCK - BLOCK. So this
\ loop basically decrypts the code from TUT onwards, and
\ at the same time it pushes the code between BLOCK and
\ ENDBLOCK onto the stack, so it's there ready to be run
\ (at address &0163)
.David2
EQUB &AC \ This byte was changed to &20 by part 2, so by the time
EQUW &FFD4 \ we get here, these three bytes together become JSR
\ &FFD4, or JSR OSBPUT. Amongst all the code above,
\ we've also managed to set BPUTV to &01F1, and as BPUTV
\ is the vector that OSBPUT goes through, these three
\ bytes are actually doing JSR &01F1
\
\ That address is in the stack, and is the address of
\ the first routine, that we pushed onto the stack in
\ the modified PROT1 routine. That routine doesn't
\ return with an RTS, but instead it removes the return
\ address from the stack and jumps to David5 below after
\ pushing the Y-th byte of BLOCK onto the stack and
\ EOR'ing the Y-th byte of TUT with the Y-th byte of
\ BLOCK
\
\ This obfuscation probably kept the crackers busy for a
\ while - it's difficult enough to work out when you
\ have the source code in front of you!
.LBLa
\ If, for some reason, the above JSR doesn't call the
\ routine on the stack and returns normally, which might
\ happen if crackers manage to unpick the BPUTV
\ redirection, then we end up here. We now obfuscate the
\ the first 255 bytes of the location where the main
\ game gets loaded (which is set in C%), just to make
\ things hard, and then we reset the machine... all in
\ a completely twisted manner, of course
LDA C%,X \ Obfuscate the X-th byte of C% by EOR'ing with &A5
EOR #&A5
STA C%,X
DEX \ Decrement the loop counter
BNE LBLa \ Loop back until X wraps around, after EOR'ing a whole
\ page
JMP (C%+&CF) \ C%+&CF is &100F, which in the main game code contains
\ an LDA KY17 instruction (it's in the main loader in
\ the MA76 section). This has opcode &A5 &4E, and the
\ EOR above changes the first of these to &00, so this
\ jump goes to a BRK instruction, which in turn goes to
\ BRKV, which in turn resets the computer (as we set
\ BRKV to point to the reset address in part 2)
.swine2
JMP swine \ Jump to swine to reset the machine
EQUW &4CFF \ This data doesn't appear to be used
.crunchit
BRK \ This instruction gets changed to an indirect JMP at
EQUW David23 \ the end of part 2, so this does JMP (David23). David23
\ contains &01DF, so these bytes are actually doing JMP
\ &01DF. That address is in the stack, and is the
\ address of the MVDL routine, which we pushed onto the
\ stack in the modified PROT1 routine... so this
\ actually does the following:
\
\ JMP MVDL
\
\ meaning that this instruction:
\
\ JSR crunchit
\
\ actually does this, because it's a tail call:
\
\ JSR MVDL
\
\ It's yet another impressive bit of obfuscation and
\ misdirection
.RAND
EQUD &6C785349 \ The random number seed used for drawing Saturn
.David5
INY \ Increment the loop counter
CPY #(ENDBLOCK-BLOCK) \ Loop back to copy the next byte until we have copied
BNE David2 \ all the bytes between BLOCK and ENDBLOCK
SEI \ Disable interrupts while we set up our interrupt
\ handler to support the split-screen mode
LDA #%11000010 \ Clear 6522 System VIA interrupt enable register IER
STA VIA+&4E \ (SHEILA &4E) bits 1 and 7 (i.e. enable CA1 and TIMER1
\ interrupts from the System VIA, which enable vertical
\ sync and the 1 MHz timer, which we need enabled for
\ the split-screen interrupt code to work)
LDA #%01111111 \ Set 6522 User VIA interrupt enable register IER
STA &FE6E \ (SHEILA &6E) bits 0-7 (i.e. disable all hardware
\ interrupts from the User VIA)
LDA IRQ1V \ Store the low byte of the current IRQ1V vector in VEC
STA VEC
LDA IRQ1V+1 \ If the current high byte of the IRQ1V vector is less
BPL swine2 \ than &80, which means it points to user RAM rather
\ the MOS ROM, then something is probably afoot, so jump
\ to swine2 to reset the machine
STA VEC+1 \ Otherwise all is well, so store the high byte of the
\ current IRQ1V vector in VEC+1, so VEC(1 0) now
\ contains the original address of the IRQ1 handler
LDA #HI(IRQ1) \ Set the IRQ1V vector to IRQ1, so IRQ1 is now the
STA IRQ1V+1 \ interrupt handler
LDA #LO(IRQ1)
STA IRQ1V
LDA #VSCAN \ Set 6522 System VIA T1C-L timer 1 high-order counter
STA VIA+&45 \ (SHEILA &45) to VSCAN (56) to start the T1 counter
\ counting down from 14080 at a rate of 1 MHz (this is
\ a different value to the main game code)
CLI \ Re-enable interrupts
IF DISC
LDA #%10000001 \ Clear 6522 System VIA interrupt enable register IER
STA &FE4E \ (SHEILA &4E) bit 1 (i.e. enable the CA2 interrupt,
\ which comes from the keyboard)
LDY #20 \ Set Y = 20 for the following OSBYTE call
IF _REMOVE_CHECKSUMS
NOP \ If we have disabled checksums, skip the OSBYTE call
NOP
NOP
ELSE
JSR OSBYTE \ A was set to 129 above, so this calls OSBYTE with
\ A = 129 and Y = 20, which reads the keyboard with a
\ time limit, in this case 20 centiseconds, or 0.2
\ seconds
ENDIF
LDA #%00000001 \ Set 6522 System VIA interrupt enable register IER
STA &FE4E \ (SHEILA &4E) bit 1 (i.e. disable the CA2 interrupt,
\ which comes from the keyboard)
ENDIF
RTS \ This RTS actually does a jump to ENTRY2, to the next
\ step of the loader in part 5. See the documentation
\ for the stack routine at BEGIN% for more details
\ ******************************************************************************
\
\ Name: PLL1
\ Type: Subroutine
\ Category: Drawing planets
\ Summary: Draw Saturn on the loading screen
\ Deep dive: Drawing Saturn on the loading screen
\
\ ******************************************************************************
.PLL1
\ The following loop iterates CNT(1 0) times, i.e. &500
\ or 1280 times, and draws the planet part of the
\ loading screen's Saturn
LDA VIA+&44 \ Read the 6522 System VIA T1C-L timer 1 low-order
STA RAND+1 \ counter (SHEILA &44), which increments 1000 times a
\ second so this will be pretty random, and store it in
\ RAND+1 among the hard-coded random seeds in RAND
JSR DORND \ Set A and X to random numbers, say A = r1
JSR SQUA2 \ Set (A P) = A * A
\ = r1^2
STA ZP+1 \ Set ZP(1 0) = (A P)
LDA P \ = r1^2
STA ZP
JSR DORND \ Set A and X to random numbers, say A = r2
STA YY \ Set YY = A
\ = r2
JSR SQUA2 \ Set (A P) = A * A
\ = r2^2
TAX \ Set (X P) = (A P)
\ = r2^2
LDA P \ Set (A ZP) = (X P) + ZP(1 0)
ADC ZP \
STA ZP \ first adding the low bytes
TXA \ And then adding the high bytes
ADC ZP+1
BCS PLC1 \ If the addition overflowed, jump down to PLC1 to skip
\ to the next pixel
STA ZP+1 \ Set ZP(1 0) = (A ZP)
\ = r1^2 + r2^2
LDA #1 \ Set ZP(1 0) = &4001 - ZP(1 0) - (1 - C)
SBC ZP \ = 128^2 - ZP(1 0)
STA ZP \
\ (as the C flag is clear), first subtracting the low
\ bytes
LDA #&40 \ And then subtracting the high bytes
SBC ZP+1
STA ZP+1
BCC PLC1 \ If the subtraction underflowed, jump down to PLC1 to
\ skip to the next pixel
\ If we get here, then both calculations fitted into
\ 16 bits, and we have:
\
\ ZP(1 0) = 128^2 - (r1^2 + r2^2)
\
\ where ZP(1 0) >= 0
JSR ROOT \ Set ZP = SQRT(ZP(1 0))
LDA ZP \ Set X = ZP >> 1
LSR A \ = SQRT(128^2 - (a^2 + b^2)) / 2
TAX
LDA YY \ Set A = YY
\ = r2
CMP #128 \ If YY >= 128, set the C flag (so the C flag is now set
\ to bit 7 of A)
ROR A \ Rotate A and set the sign bit to the C flag, so bits
\ 6 and 7 are now the same, i.e. A is a random number in
\ one of these ranges:
\
\ %00000000 - %00111111 = 0 to 63 (r2 = 0 - 127)
\ %11000000 - %11111111 = 192 to 255 (r2 = 128 - 255)
\
\ The PIX routine flips bit 7 of A before drawing, and
\ that makes -A in these ranges:
\
\ %10000000 - %10111111 = 128-191
\ %01000000 - %01111111 = 64-127
\
\ so that's in the range 64 to 191
JSR PIX \ Draw a pixel at screen coordinate (X, -A), i.e. at
\
\ (ZP / 2, -A)
\
\ where ZP = SQRT(128^2 - (r1^2 + r2^2))
\
\ So this is the same as plotting at (x, y) where:
\
\ r1 = random number from 0 to 255
\ r1 = random number from 0 to 255
\ (r1^2 + r1^2) < 128^2
\
\ y = r2, squished into 64 to 191 by negation
\
\ x = SQRT(128^2 - (r1^2 + r1^2)) / 2
\
\ which is what we want
.PLC1
DEC CNT \ Decrement the counter in CNT (the low byte)
BNE PLL1 \ Loop back to PLL1 until CNT = 0
DEC CNT+1 \ Decrement the counter in CNT+1 (the high byte)
BNE PLL1 \ Loop back to PLL1 until CNT+1 = 0
LDX #&C2 \ Set the low byte of EXCN(1 0) to &C2, so we now have
STX EXCN \ EXCN(1 0) = &03C2, which we will use in the IRQ1
\ handler (this has nothing to do with drawing Saturn,
\ it's all part of the copy protection)
\ The following loop iterates CNT2(1 0) times, i.e. &1DD
\ or 477 times, and draws the background stars on the
\ loading screen
.PLL2
JSR DORND \ Set A and X to random numbers, say A = r3
TAX \ Set X = A
\ = r3
JSR SQUA2 \ Set (A P) = A * A
\ = r3^2
STA ZP+1 \ Set ZP+1 = A
\ = r3^2 / 256
JSR DORND \ Set A and X to random numbers, say A = r4
STA YY \ Set YY = r4
JSR SQUA2 \ Set (A P) = A * A
\ = r4^2
ADC ZP+1 \ Set A = A + r3^2 / 256
\ = r4^2 / 256 + r3^2 / 256
\ = (r3^2 + r4^2) / 256
CMP #&11 \ If A < 17, jump down to PLC2 to skip to the next pixel
BCC PLC2
LDA YY \ Set A = r4
JSR PIX \ Draw a pixel at screen coordinate (X, -A), i.e. at
\ (r3, -r4), where (r3^2 + r4^2) / 256 >= 17
\
\ Negating a random number from 0 to 255 still gives a
\ random number from 0 to 255, so this is the same as
\ plotting at (x, y) where:
\
\ x = random number from 0 to 255
\ y = random number from 0 to 255
\ (x^2 + y^2) div 256 >= 17
\
\ which is what we want
.PLC2
DEC CNT2 \ Decrement the counter in CNT2 (the low byte)
BNE PLL2 \ Loop back to PLL2 until CNT2 = 0
DEC CNT2+1 \ Decrement the counter in CNT2+1 (the high byte)
BNE PLL2 \ Loop back to PLL2 until CNT2+1 = 0
LDX MHCA \ Set the low byte of BLPTR(1 0) to the contents of MHCA
STX BLPTR \ (which is &CA), so we now have BLPTR(1 0) = &03CA,
\ which we will use in the IRQ1 handler (this has
\ nothing to do with drawing Saturn, it's all part of
\ the copy protection)
LDX #&C6 \ Set the low byte of BLN(1 0) to &C6, so we now have
STX BLN \ BLN(1 0) = &03C6, which we will use in the IRQ1
\ handler (this has nothing to do with drawing Saturn,
\ it's all part of the copy protection)
\ The following loop iterates CNT3(1 0) times, i.e. &500
\ or 1280 times, and draws the rings around the loading
\ screen's Saturn
.PLL3
JSR DORND \ Set A and X to random numbers, say A = r5
STA ZP \ Set ZP = r5
JSR SQUA2 \ Set (A P) = A * A
\ = r5^2
STA ZP+1 \ Set ZP+1 = A
\ = r5^2 / 256
JSR DORND \ Set A and X to random numbers, say A = r6
STA YY \ Set YY = r6
JSR SQUA2 \ Set (A P) = A * A
\ = r6^2
STA T \ Set T = A
\ = r6^2 / 256
ADC ZP+1 \ Set ZP+1 = A + r5^2 / 256
STA ZP+1 \ = r6^2 / 256 + r5^2 / 256
\ = (r5^2 + r6^2) / 256
LDA ZP \ Set A = ZP
\ = r5
CMP #128 \ If A >= 128, set the C flag (so the C flag is now set
\ to bit 7 of ZP, i.e. bit 7 of A)
ROR A \ Rotate A and set the sign bit to the C flag, so bits
\ 6 and 7 are now the same
CMP #128 \ If A >= 128, set the C flag (so again, the C flag is
\ set to bit 7 of A)
ROR A \ Rotate A and set the sign bit to the C flag, so bits
\ 5-7 are now the same, i.e. A is a random number in one
\ of these ranges:
\
\ %00000000 - %00011111 = 0-31
\ %11100000 - %11111111 = 224-255
\
\ In terms of signed 8-bit integers, this is a random
\ number from -32 to 31. Let's call it r7
ADC YY \ Set X = A + YY
TAX \ = r7 + r6
JSR SQUA2 \ Set (A P) = r7 * r7
TAY \ Set Y = A
\ = r7 * r7 / 256
ADC ZP+1 \ Set A = A + ZP+1
\ = r7^2 / 256 + (r5^2 + r6^2) / 256
\ = (r5^2 + r6^2 + r7^2) / 256
BCS PLC3 \ If the addition overflowed, jump down to PLC3 to skip
\ to the next pixel
CMP #80 \ If A >= 80, jump down to PLC3 to skip to the next
BCS PLC3 \ pixel
CMP #32 \ If A < 32, jump down to PLC3 to skip to the next pixel
BCC PLC3
TYA \ Set A = Y + T
ADC T \ = r7^2 / 256 + r6^2 / 256
\ = (r6^2 + r7^2) / 256
CMP #16 \ If A > 16, skip to PL1 to plot the pixel
BCS PL1
LDA ZP \ If ZP is positive (50% chance), jump down to PLC3 to
BPL PLC3 \ skip to the next pixel
.PL1
LDA YY \ Set A = YY
\ = r6
JSR PIX \ Draw a pixel at screen coordinate (X, -A), where:
\
\ X = (random -32 to 31) + r6
\ A = r6
\
\ Negating a random number from 0 to 255 still gives a
\ random number from 0 to 255, so this is the same as
\ plotting at (x, y) where:
\
\ r5 = random number from 0 to 255
\ r6 = random number from 0 to 255
\ r7 = r5, squashed into -32 to 31
\
\ x = r5 + r7
\ y = r5
\
\ 32 <= (r5^2 + r6^2 + r7^2) / 256 <= 79
\ Draw 50% fewer pixels when (r6^2 + r7^2) / 256 <= 16
\
\ which is what we want
.PLC3
DEC CNT3 \ Decrement the counter in CNT3 (the low byte)
BNE PLL3 \ Loop back to PLL3 until CNT3 = 0
DEC CNT3+1 \ Decrement the counter in CNT3+1 (the high byte)
BNE PLL3 \ Loop back to PLL3 until CNT3+1 = 0
\ ******************************************************************************
\
\ Name: DORND
\ Type: Subroutine
\ Category: Utility routines
\ Summary: Generate random numbers
\ Deep dive: Generating random numbers
\ Fixing ship positions
\
\ ------------------------------------------------------------------------------
\
\ Set A and X to random numbers (though note that X is set to the random number
\ that was returned in A the last time DORND was called).
\
\ The C and V flags are also set randomly.
\
\ This is a simplified version of the DORND routine in the main game code. It
\ swaps the two calculations around and omits the ROL A instruction, but is
\ otherwise very similar. See the DORND routine in the main game code for more
\ details.
\
\ ******************************************************************************
.DORND
LDA RAND+1 \ r1´ = r1 + r3 + C
TAX \ r3´ = r1
ADC RAND+3
STA RAND+1
STX RAND+3
LDA RAND \ X = r2´ = r0
TAX \ A = r0´ = r0 + r2
ADC RAND+2
STA RAND
STX RAND+2
RTS \ Return from the subroutine
\ ******************************************************************************
\
\ Name: SQUA2
\ Type: Subroutine
\ Category: Maths (Arithmetic)
\ Summary: Calculate (A P) = A * A
\
\ ------------------------------------------------------------------------------
\
\ Do the following multiplication of unsigned 8-bit numbers:
\
\ (A P) = A * A
\
\ This uses the same approach as routine SQUA2 in the main game code, which
\ itself uses the MU11 routine to do the multiplication. See those routines for
\ more details.
\
\ ******************************************************************************
.SQUA2
BPL SQUA \ If A > 0, jump to SQUA
EOR #&FF \ Otherwise we need to negate A for the SQUA algorithm
CLC \ to work, so we do this using two's complement, by
ADC #1 \ setting A = ~A + 1
.SQUA
STA Q \ Set Q = A and P = A
STA P \ Set P = A
LDA #0 \ Set A = 0 so we can start building the answer in A
LDY #8 \ Set up a counter in Y to count the 8 bits in P
LSR P \ Set P = P >> 1
\ and C flag = bit 0 of P
.SQL1
BCC SQ1 \ If C (i.e. the next bit from P) is set, do the
CLC \ addition for this bit of P:
ADC Q \
\ A = A + Q
.SQ1
ROR A \ Shift A right to catch the next digit of our result,
\ which the next ROR sticks into the left end of P while
\ also extracting the next bit of P
ROR P \ Add the overspill from shifting A to the right onto
\ the start of P, and shift P right to fetch the next
\ bit for the calculation into the C flag
DEY \ Decrement the loop counter
BNE SQL1 \ Loop back for the next bit until P has been rotated
\ all the way
RTS \ Return from the subroutine
\ ******************************************************************************
\
\ Name: PIX
\ Type: Subroutine
\ Category: Drawing pixels
\ Summary: Draw a single pixel at a specific coordinate
\
\ ------------------------------------------------------------------------------
\
\ Draw a pixel at screen coordinate (X, -A). The sign bit of A gets flipped
\ before drawing, and then the routine uses the same approach as the PIXEL
\ routine in the main game code, except it plots a single pixel from TWOS
\ instead of a two pixel dash from TWOS2. This applies to the top part of the
\ screen (the monochrome mode 4 space view).
\
\ See the PIXEL routine in the main game code for more details.
\
\ Arguments:
\
\ X The screen x-coordinate of the pixel to draw
\
\ A The screen y-coordinate of the pixel to draw, negated
\
\ ******************************************************************************
.PIX
TAY \ Copy A into Y, for use later
EOR #%10000000 \ Flip the sign of A
LSR A \ Set ZP+1 = &60 + A >> 3
LSR A
LSR A
ORA #&60
STA ZP+1
TXA \ Set ZP = (X >> 3) * 8
EOR #%10000000
AND #%11111000
STA ZP
TYA \ Set Y = Y AND %111
AND #%00000111
TAY
TXA \ Set X = X AND %111
AND #%00000111
TAX
LDA TWOS,X \ Fetch a pixel from TWOS and OR it into ZP+Y
ORA (ZP),Y
STA (ZP),Y
RTS \ Return from the subroutine
\ ******************************************************************************
\
\ Name: TWOS
\ Type: Variable
\ Category: Drawing pixels
\ Summary: Ready-made single-pixel character row bytes for mode 4
\
\ ------------------------------------------------------------------------------
\
\ Ready-made bytes for plotting one-pixel points in mode 4 (the top part of the
\ split screen). See the PIX routine for details.
\
\ ******************************************************************************
.TWOS
EQUB %10000000
EQUB %01000000
EQUB %00100000
EQUB %00010000
EQUB %00001000
EQUB %00000100
EQUB %00000010
EQUB %00000001
\ ******************************************************************************
\
\ Name: CNT
\ Type: Variable
\ Category: Drawing planets
\ Summary: A counter for use in drawing Saturn's planetary body
\
\ ------------------------------------------------------------------------------
\
\ Defines the number of iterations of the PLL1 loop, which draws the planet part
\ of the loading screen's Saturn.
\
\ ******************************************************************************
.CNT
EQUW &0500 \ The number of iterations of the PLL1 loop (1280)
\ ******************************************************************************
\
\ Name: CNT2
\ Type: Variable
\ Category: Drawing planets
\ Summary: A counter for use in drawing Saturn's background stars
\
\ ------------------------------------------------------------------------------
\
\ Defines the number of iterations of the PLL2 loop, which draws the background
\ stars on the loading screen.
\
\ ******************************************************************************
.CNT2
EQUW &01DD \ The number of iterations of the PLL2 loop (477)
\ ******************************************************************************
\
\ Name: CNT3
\ Type: Variable
\ Category: Drawing planets
\ Summary: A counter for use in drawing Saturn's rings
\
\ ------------------------------------------------------------------------------
\
\ Defines the number of iterations of the PLL3 loop, which draws the rings
\ around the loading screen's Saturn.
\
\ ******************************************************************************
.CNT3
EQUW &0500 \ The number of iterations of the PLL3 loop (1280)
\ ******************************************************************************
\
\ Name: ROOT
\ Type: Subroutine
\ Category: Maths (Arithmetic)
\ Summary: Calculate ZP = SQRT(ZP(1 0))
\
\ ------------------------------------------------------------------------------
\
\ Calculate the following square root:
\
\ ZP = SQRT(ZP(1 0))
\
\ This routine is identical to LL5 in the main game code - it even has the same
\ label names. The only difference is that LL5 calculates Q = SQRT(R Q), but
\ apart from the variables used, the instructions are identical, so see the LL5
\ routine in the main game code for more details on the algorithm used here.
\
\ ******************************************************************************
.ROOT
LDY ZP+1 \ Set (Y Q) = ZP(1 0)
LDA ZP
STA Q
\ So now to calculate ZP = SQRT(Y Q)
LDX #0 \ Set X = 0, to hold the remainder
STX ZP \ Set ZP = 0, to hold the result
LDA #8 \ Set P = 8, to use as a loop counter
STA P
.LL6
CPX ZP \ If X < ZP, jump to LL7
BCC LL7
BNE LL8 \ If X > ZP, jump to LL8
CPY #64 \ If Y < 64, jump to LL7 with the C flag clear,
BCC LL7 \ otherwise fall through into LL8 with the C flag set
.LL8
TYA \ Set Y = Y - 64
SBC #64 \
TAY \ This subtraction will work as we know C is set from
\ the BCC above, and the result will not underflow as we
\ already checked that Y >= 64, so the C flag is also
\ set for the next subtraction
TXA \ Set X = X - ZP
SBC ZP
TAX
.LL7
ROL ZP \ Shift the result in Q to the left, shifting the C flag
\ into bit 0 and bit 7 into the C flag
ASL Q \ Shift the dividend in (Y S) to the left, inserting
TYA \ bit 7 from above into bit 0
ROL A
TAY
TXA \ Shift the remainder in X to the left
ROL A
TAX
ASL Q \ Shift the dividend in (Y S) to the left
TYA
ROL A
TAY
TXA \ Shift the remainder in X to the left
ROL A
TAX
DEC P \ Decrement the loop counter
BNE LL6 \ Loop back to LL6 until we have done 8 loops
RTS \ Return from the subroutine
\ ******************************************************************************
\
\ Name: BEGIN%
\ Type: Subroutine
\ Category: Copy protection
\ Summary: Single-byte decryption and copying routine, run on the stack
\
\ ------------------------------------------------------------------------------
\
\ This routine is copied to the stack at &01F1. It pushes BLOCK to ENDBLOCK onto
\ the stack, and decrypts the code from TUT onwards.
\
\ The 15 instructions for this routine are pushed onto the stack and executed
\ there. The instructions are pushed onto the stack in reverse (as the stack
\ grows downwards in memory), so first the JMP gets pushed, then the STA, and
\ so on.
\
\ This is the code that is pushed onto the stack. It gets run by a JMP call to
\ David2, which then calls the routine on the stack with JSR &01F1.
\
\ 01F1 : PLA \ Remove the return address from the stack that was
\ 01F2 : PLA \ put here by the JSR that called this routine
\
\ 01F3 : LDA BLOCK,Y \ Set A = the Y-th byte of BLOCK
\
\ 01F6 : PHA \ Push A onto the stack
\
\ 01F7 : EOR TUT,Y \ EOR the Y-th byte of TUT with A
\ 01FA : STA TUT,Y
\
\ 01FD : JMP (David9) \ Jump to the address in David9
\
\ The routine is called inside a loop with Y as the counter. It counts from 0 to
\ ENDBLOCK - BLOCK, so the routine eventually pushes every byte between BLOCK
\ and ENDBLOCK onto the stack, as well as EOR'ing each byte from TUT onwards to
\ decrypt that section.
\
\ The elite-checksums.py script reverses the order of the bytes between BLOCK
\ and ENDBLOCK in the final file, so pushing them onto the stack (which is a
\ descending stack) realigns them in memory as assembled below. Not only that,
\ but the last two bytes pushed on the stack are the ones that are at the start
\ of the block at BLOCK, and these contain the address of ENTRY2. This is why
\ the RTS at the end of part 4 above actually jumps to ENTRY2 in part 5.
\
\ ******************************************************************************
.BEGIN%
EQUB HI(David9) \ JMP (David9)
EQUB LO(David9)
EQUB &6C
EQUB HI(TUT) \ STA TUT,Y
EQUB LO(TUT)
EQUB &99
IF _REMOVE_CHECKSUMS
EQUB HI(TUT) \ If we have disabled checksums, then just load the Y-th
EQUB LO(TUT) \ byte of TUT with LDA TUT,Y
EQUB &B9
ELSE
EQUB HI(TUT) \ EOR TUT,Y
EQUB LO(TUT)
EQUB &59
ENDIF
PHA \ PHA
EQUB HI(BLOCK) \ LDA BLOCK,Y
EQUB LO(BLOCK)
EQUB &B9
PLA \ PLA
PLA \ PLA
\ ******************************************************************************
\
\ Name: DOMOVE
\ Type: Subroutine
\ Category: Copy protection
\ Summary: Multi-byte decryption and copying routine, run on the stack
\
\ ------------------------------------------------------------------------------
\
\ This routine is copied to the stack at &01DF. It moves and decrypts a block of
\ memory. The original source refers to the stack routine as MVDL.
\
\ The 18 instructions for this routine are pushed onto the stack and executed
\ there. The instructions are pushed onto the stack in reverse (as the stack
\ grows downwards in memory), so first the RTS gets pushed, then the BNE, and
\ so on.
\
\ This is the code that is pushed onto the stack. It gets run by a JMP call to
\ crunchit, which then calls the routine on the stack at MVDL, or &01DF. The
\ label MVDL comes from a comment in the original source file ELITES.
\
\ 01DF : .MVDL
\
\ 01DF : LDA (ZP),Y \ Set A = the Y-th byte from the block whose address
\ \ is in ZP(1 0)
\
\ 01E1 : EOR OSB,Y \ EOR A with the Y-th byte on from OSB
\
\ 01E4 : STA (P),Y \ Store A in the Y-th byte of the block whose
\ \ address is in P(1 0)
\
\ 01E6 : DEY \ Decrement the loop counter
\
\ 01E7 : BNE MVDL \ Loop back to copy and EOR the next byte until we
\ \ have copied an entire page (256 bytes)
\
\ 01E9 : INC P+1 \ Increment the high byte of P(1 0) so it points to
\ \ the next page of 256 bytes
\
\ 01EB : INC ZP+1 \ Increment ZP(1 0) so it points to the next page of
\ \ 256 bytes
\
\ 01ED : DEX \ Decrement X
\
\ 01EE : BNE MVDL \ Loop back to copy the next page
\
\ 01F0 : RTS \ Return from the subroutine, which takes us back
\ \ to the caller of the crunchit routine using a
\ \ tail call, as we called this with JMP crunchit
\
\ We call MVDL with the following arguments:
\
\ (X Y) The number of bytes to copy
\
\ ZP(1 0) The source address
\
\ P(1 0) The destination address
\
\ The routine moves and decrypts a block of memory, and is used in part 3 to
\ move blocks of code and images that are embedded within the loader binary,
\ either into low memory locations below PAGE (for the recursive token table and
\ page at UU%), or into screen memory (for the loading screen and dashboard
\ images).
\
\ If checksums are disabled in the build, we don't do the EOR instruction, so
\ the routine just moves and doesn't decrypt.
\
\ ******************************************************************************
.DOMOVE
RTS \ RTS
EQUW &D0EF \ BNE MVDL
DEX \ DEX
EQUB ZP+1 \ INC ZP+1
INC P+1 \ INC P+1
EQUB &E6
EQUW &D0F6 \ BNE MVDL
DEY \ DEY
EQUB P \ STA(P),Y
EQUB &91
IF _REMOVE_CHECKSUMS
NOP \ If we have disabled checksums, skip the EOR so the
NOP \ routine just does the copying part
NOP
ELSE
EQUB HI(OSB) \ EOR OSB,Y
EQUB LO(OSB)
EQUB &59
ENDIF
EQUB ZP \ LDA(ZP),Y
EQUB &B1
\ ******************************************************************************
\
\ Name: UU%
\ Type: Workspace
\ Address: &0B00
\ Category: Workspaces
\ Summary: Marker for a block that is moved as part of the obfuscation
\
\ ------------------------------------------------------------------------------
\
\ The code from here to the end of the file gets copied to &0B00 (LE%) by part
\ 3. It is called from the end of part 4, via ENTRY2 in part 5 below.
\
\ ******************************************************************************
.UU%
Q% = P% - LE%
ORG LE%
\ ******************************************************************************
\
\ Name: CHECKbyt
\ Type: Variable
\ Category: Copy protection
\ Summary: Checksum for the validity of the UU% workspace
\
\ ------------------------------------------------------------------------------
\
\ We calculate the value of the CHECKbyt checksum in elite-checksum.py, so this
\ just reserves a byte. It checks the validity of the first two pages of the UU%
\ workspace, which gets copied to LE%.
\
\ ******************************************************************************
.CHECKbyt
BRK \ This could be an EQUB 0 directive instead of a BRK,
\ but this is what's in the source code
\ ******************************************************************************
\
\ Name: MAINSUM
\ Type: Variable
\ Category: Copy protection
\ Summary: Two checksums for the decryption header and text token table
\
\ ------------------------------------------------------------------------------
\
\ Contains two checksum values, one for the header code at LBL, and the other
\ for the recursive token table from &0400 to &07FF.
\
\ ******************************************************************************
.MAINSUM
EQUB &CB \ This is the checksum value of the decryption header
\ code (from LBL to elitea) that gets prepended to the
\ main game code by elite-bcfs.asm and saved as
\ ELThead.bin
EQUB 0 \ This is the checksum value for the recursive token
\ table from &0400 to &07FF. We calculate the value in
\ elite-checksum.py, so this just reserves a byte
\ ******************************************************************************
\
\ Name: FOOLV
\ Type: Variable
\ Category: Copy protection
\ Summary: Part of the AFOOL roundabout obfuscation routine
\
\ ------------------------------------------------------------------------------
\
\ FOOLV contains the address of FOOL. This is part of the JSR AFOOL obfuscation
\ routine, which calls AFOOL, which then jumps to the address in FOOLV, which
\ contains the address of FOOL, which contains an RTS instruction... so overall
\ it does nothing, but in a rather roundabout fashion.
\
\ ******************************************************************************
.FOOLV
EQUW FOOL \ The address of FOOL, which contains an RTS
\ ******************************************************************************
\
\ Name: CHECKV
\ Type: Variable
\ Category: Copy protection
\ Summary: The address of the LBL routine in the decryption header
\
\ ------------------------------------------------------------------------------
\
\ CHECKV contains the address of the LBL routine at the very start of the main
\ game code file, in the decryption header code that gets prepended to the main
\ game code by elite-bcfs.asm and saved as ELThead.bin
\
\ ******************************************************************************
.CHECKV
EQUW LOAD%+1 \ The address of the LBL routine
\ ******************************************************************************
\
\ Name: block1
\ Type: Variable
\ Category: Screen mode
\ Summary: Palette data for the two dashboard colour scheme
\
\ ------------------------------------------------------------------------------
\
\ Palette bytes for use with the split-screen mode 5. See TVT1 in the main game
\ code for an explanation.
\
\ ******************************************************************************
.block1
EQUB &F5, &E5
EQUB &B5, &A5
EQUB &76, &66
EQUB &36, &26
EQUB &D4, &C4
EQUB &94, &84
\ ******************************************************************************
\
\ Name: block2
\ Type: Variable
\ Category: Screen mode
\ Summary: Palette data for the space part of the screen
\
\ ------------------------------------------------------------------------------
\
\ Palette bytes for use with the split-screen mode 4. See TVT1 in the main game
\ code for an explanation.
\
\ ******************************************************************************
.block2
EQUB &D0, &C0
EQUB &B0, &A0
EQUB &F0, &E0
EQUB &90, &80
EQUB &77, &67
EQUB &37, &27
\ ******************************************************************************
\
\ Name: TT26
\ Type: Subroutine
\ Category: Text
\ Summary: Print a character at the text cursor (WRCHV points here)
\
\ ------------------------------------------------------------------------------
\
\ This routine prints a character at the text cursor (XC, YC). It is very
\ similar to the routine of the same name in the main game code, so refer to
\ that routine for a more detailed description.
\
\ This routine, however, only works within a small 14x14 character text window,
\ which we use for the tape loading messages, so there is extra code for fitting
\ the text into the window (and it also reverses the effect of line feeds and
\ carriage returns).
\
\ Arguments:
\
\ A The character to be printed
\
\ XC Contains the text column to print at (the x-coordinate)
\
\ YC Contains the line number to print on (the y-coordinate)
\
\ Returns:
\
\ A A is preserved
\
\ X X is preserved
\
\ Y Y is preserved
\
\ ******************************************************************************
.TT26
STA K3 \ Store the A, X and Y registers (in K3 for A, and on
TYA \ the stack for the others), so we can restore them at
PHA \ the end (so they don't get changed by this routine)
TXA
PHA
.rr
LDA K3 \ Set A = the character to be printed
CMP #7 \ If this is a beep character (A = 7), jump to R5,
BEQ R5 \ which will emit the beep, restore the registers and
\ return from the subroutine
CMP #32 \ If this is an ASCII character (A >= 32), jump to RR1
BCS RR1 \ below, which will print the character, restore the
\ registers and return from the subroutine
CMP #13 \ If this is control code 13 (carriage return) then jump
BEQ RRX1 \ to RRX1, which will move along on character, restore
\ the registers and return from the subroutine (as we
\ don't have room in the text window for new lines)
INC YC \ If we get here, then this is control code 10, a line
\ feed, so move down one line and fall through into RRX1
\ to move the cursor to the start of the line
.RRX1
LDX #7 \ Set the column number (x-coordinate) of the text
STX XC \ to 7
BNE RR4 \ Jump to RR4 to restore the registers and return from
\ the subroutine (this BNE is effectively a JMP as Y
\ will never be zero)
.RR1
LDX #&BF \ Set X to point to the first font page in ROM minus 1,
\ which is &C0 - 1, or &BF
ASL A \ If bit 6 of the character is clear (A is 32-63)
ASL A \ then skip the following instruction
BCC P%+4
LDX #&C1 \ A is 64-126, so set X to point to page &C1
ASL A \ If bit 5 of the character is clear (A is 64-95)
BCC P%+3 \ then skip the following instruction
INX \ Increment X, so X now contains the high byte
\ (the page) of the address of the definition that we
\ want, while A contains the low byte (the offset into
\ the page) of the address
STA P \ Store the address of this character's definition in
STX P+1 \ P(1 0)
LDA XC \ If the column number (x-coordinate) of the text is
CMP #20 \ less than 20, skip to NOLF
BCC NOLF
LDA #7 \ Otherwise we just reached the end of the line, so
STA XC \ move the text cursor to column 7, and down onto the
INC YC \ next line
.NOLF
ASL A \ Multiply the x-coordinate (column) of the text by 8
ASL A \ and store in ZP, to get the low byte of the screen
ASL A \ address for the character we want to print
STA ZP
INC XC \ Once we print the character, we want to move the text
\ cursor to the right, so we do this by incrementing XC
LDA YC \ If the row number (y-coordinate) of the text is less
CMP #19 \ than 19, skip to RR3
BCC RR3
\ Otherwise we just reached the bottom of the screen,
\ which is a small 14x14 character text window we use
\ for showing the tape loading messages, so now we need
\ to clear that window and move the cursor to the top
LDA #7 \ Move the text cursor to column 7
STA XC
LDA #&65 \ Set the high byte of the SC(1 0) to &65, for character
STA SC+1 \ row 5 of the screen
LDY #7*8 \ Set Y = 7 * 8, for column 7 (as there are 8 bytes per
\ character block)
LDX #14 \ Set X = 14, to count the number of character rows we
\ need to clear
STY SC \ Set the low byte of SC(1 0) to 7*8, so SC(1 0) now
\ points to the character block at row 5, column 7, at
\ the top-left corner of the small text window
LDA #0 \ Set A = 0 for use in clearing the screen (which we do
\ by setting the screen memory to 0)
TAY \ Set Y = 0
.David1
STA (SC),Y \ Clear the Y-th byte of the block pointed to by SC(1 0)
INY \ Increment the counter in Y
CPY #14*8 \ Loop back to clear the next byte until we have done 14
BCC David1 \ lots of 8 bytes (i.e. 14 characters, the width of the
\ small text window)
TAY \ Set Y = 0, ready for the next row
INC SC+1 \ Point SC(1 0) to the next page in memory, i.e. the
\ next character row
DEX \ Decrement the counter in X
BPL David1 \ Loop back to David1 until we have done 14 character
\ rows (the height of the small text window)
LDA #5 \ Move the text cursor to row 5
STA YC
BNE rr \ Jump to rr to print the character we were about to
\ print when we ran out of space (this BNE is
\ effectively a JMP as A will never be zero)
.RR3
ORA #&60 \ Add &60 to YC, giving us the page number that we want
STA ZP+1 \ Store the page number of the destination screen
\ location in ZP+1, so ZP now points to the full screen
\ location where this character should go
LDY #7 \ We want to print the 8 bytes of character data to the
\ screen (one byte per row), so set up a counter in Y
\ to count these bytes
.RRL1
LDA (P),Y \ The character definition is at P(1 0) - we set this up
\ above - so load the Y-th byte from P(1 0)
STA (ZP),Y \ Store the Y-th byte at the screen address for this
\ character location
DEY \ Decrement the loop counter
BPL RRL1 \ Loop back for the next byte to print to the screen
.RR4
PLA \ We're done printing, so restore the values of the
TAX \ A, X and Y registers that we saved above, loading them
PLA \ from K3 (for A) and the stack (for X and Y)
TAY
LDA K3
.FOOL
RTS \ Return from the subroutine
.R5
LDA #7 \ Control code 7 makes a beep, so load this into A
JSR osprint \ Call OSPRINT to "print" the beep character
JMP RR4 \ Jump to RR4 to restore the registers and return from
\ the subroutine using a tail call
\ ******************************************************************************
\
\ Name: osprint
\ Type: Subroutine
\ Category: Utility routines
\ Summary: Print a character
\
\ ------------------------------------------------------------------------------
\
\ Arguments:
\
\ A The character to print
\
\ ******************************************************************************
.TUT
.osprint
JMP (OSPRNT) \ Jump to the address in OSPRNT and return using a
\ tail call
EQUB &6C \ This byte appears to be unused
\ ******************************************************************************
\
\ Name: command
\ Type: Subroutine
\ Category: Utility routines
\ Summary: Execute an OS command
\
\ ------------------------------------------------------------------------------
\
\ Arguments:
\
\ (Y X) The address of the OS command string to execute
\
\ ******************************************************************************
.command
JMP (oscliv) \ Jump to &FFF7 to execute the OS command pointed to
\ by (Y X) and return using a tail call
\ ******************************************************************************
\
\ Name: MESS1
\ Type: Variable
\ Category: Utility routines
\ Summary: Contains an OS command string for loading the main game code
\
\ ******************************************************************************
.MESS1
IF DISC
EQUS "L.ELTcode 1100" \ This is short for "*LOAD ELTcode 1100"
ELSE
EQUS "L.ELITEcode F1F" \ This is short for "*LOAD ELITEcode F1F"
ENDIF
EQUB 13
\ ******************************************************************************
\
\ Name: Elite loader (Part 5 of 6)
\ Type: Subroutine
\ Category: Loader
\ Summary: Load main game code, decrypt it, move it to the correct location
\
\ ------------------------------------------------------------------------------
\
\ This part loads the main game code, decrypts it and moves it to the correct
\ location for it to run.
\
\ The code in this part is encrypted by elite-checksum.py and is decrypted in
\ part 4 by the same routine that moves part 6 onto the stack.
\
\ ******************************************************************************
.ENTRY2
\ We start this part of the loader by setting the
\ following:
\
\ OSPRNT(1 0) = WRCHV
\ WRCHV(1 0) = TT26
\ (Y X) = MESS1(1 0)
\
\ so any character printing will use the TT26 routine
LDA &020E \ Copy the low byte of WRCHV to the low byte of OSPRNT
STA OSPRNT
LDA #LO(TT26) \ Set the low byte of WRCHV to the low byte of TT26
STA &020E
LDX #LO(MESS1) \ Set X to the low byte of MESS1
LDA &020F \ Copy the high byte of WRCHV to the high byte of OSPRNT
STA OSPRNT+1
LDA #HI(TT26) \ Set the high byte of WRCHV to the high byte of TT26
LDY #HI(MESS1) \ and set Y to the high byte of MESS1
STA &020F
JSR AFOOL \ This calls AFOOL, which jumps to the address in FOOLV,
\ which contains the address of FOOL, which contains an
\ RTS instruction... so overall this does nothing, but
\ in a rather roundabout fashion
JSR command \ Call command to execute the OSCLI command pointed to
\ by (Y X) in MESS1, which starts loading the main game
\ code
JSR 512-LEN+CHECKER-ENDBLOCK \ Call the CHECKER routine in its new location on
\ the stack, to run a number of checksums on the
\ code (this routine, along with the whole of part
\ 6, was pushed onto the stack in part 4)
JSR AFOOL \ Another call to the round-the-houses routine to try
\ and distract the crackers, presumably
IF DISC
LDA #140 \ Call OSBYTE with A = 140 and X = 12 to select the
LDX #12 \ tape filing system (i.e. do a *TAPE command)
JSR OSBYTE
ENDIF
LDA #0 \ Set SVN to 0, as the main game code checks the value
STA SVN \ of this location in its IRQ1 routine, so it needs to
\ be set to 0 so it can work properly once it takes over
\ when the game itself runs
\ We now decrypt and move the main game code from &1128
\ to &0F40
LDX #HI(LC%) \ Set X = high byte of LC%, the maximum size of the main
\ game code, so if we move this number of pages, we will
\ have definitely moved all the game code down
LDA #LO(L%) \ Set ZP(1 0) = L% (the start of the game code)
STA ZP
LDA #HI(L%)
STA ZP+1
LDA #LO(C%) \ Set P(1 0) = C% = &0F40
STA P
LDA #HI(C%)
STA P+1
LDY #0 \ Set Y as a counter for working our way through every
\ byte of the game code. We EOR the counter with the
\ current byte to decrypt it
.ML1
TYA \ Copy the counter into A
IF _REMOVE_CHECKSUMS
LDA (ZP),Y \ If we have disabled checksums, just fetch the byte to
\ copy from the Y-th block pointed to by ZP(1 0)
ELSE
EOR (ZP),Y \ Fetch the byte and EOR it with the counter
ENDIF
STA (P),Y \ Store the copied (and decrypted) byte in the Y-th byte
\ of the block pointed to by P(1 0)
INY \ Increment the loop counter
BNE ML1 \ Loop back for the next byte until we have finished the
\ first 256 bytes
INC ZP+1 \ Increment the high bytes of both ZP(1 0) and P(1 0) to
INC P+1 \ point to the next 256 bytes
DEX \ Decrement the number of pages we need to copy in X
BPL ML1 \ Loop back to copy and decrypt the next page of bytes
\ until we have done them all
\ S% points to the entry point for the main game code,
\ so the following copies the addresses from the start
\ of the main code (see the S% label in the main game
\ code for the vector values)
LDA S%+6 \ Set BRKV to point to the BR1 routine in the main game
STA &0202 \ code
LDA S%+7
STA &0203
LDA S%+2 \ Set WRCHV to point to the TT26 routine in the main
STA &020E \ game code
LDA S%+3
STA &020F
RTS \ This RTS actually does a jump to the first instruction
\ in BLOCK, after the two EQUW operatives, which is now
\ on the stack. This takes us to the next and final
\ step of the loader in part 6. See the documentation
\ for the stack routine at BEGIN% for more details
.AFOOL
JMP (FOOLV) \ This jumps to the address in FOOLV as part of the
\ JSR AFOOL instruction above, which does nothing except
\ take us on wild goose chase
\ ******************************************************************************
\
\ Name: M2
\ Type: Variable
\ Category: Utility routines
\ Summary: Used for testing the 6522 System VIA status byte in IRQ1
\
\ ------------------------------------------------------------------------------
\
\ Used for testing bit 1 of the 6522 System VIA status byte in the IRQ1 routine,
\ as well as bit 1 of the block flag.
\
\ ******************************************************************************
.M2
EQUB %00000010 \ Bit 1 is set
\ ******************************************************************************
\
\ Name: IRQ1
\ Type: Subroutine
\ Category: Screen mode
\ Summary: The loader's screen-mode interrupt handler (IRQ1V points here)
\ Deep dive: The split-screen mode
\
\ ------------------------------------------------------------------------------
\
\ The main interrupt handler, which implements Elite's split-screen mode.
\
\ This routine is similar to the main IRQ1 routine in the main game code, except
\ it's a bit simpler (it doesn't need to support the mode-flashing effect of
\ hyperspace, for example).
\
\ It also sets Timer 1 to a different value, 14386 instead of 14622. The split
\ in the split-screen mode does overlap more in the loader than in the game, so
\ it's interesting that they didn't fine-tune this version as much.
\
\ For more details on how the following works, see the IRQ1 routine in the main
\ game code.
\
\ ******************************************************************************
.VIA2
LDA #%00000100 \ Set the Video ULA control register (SHEILA &20) to
STA &FE20 \ %00000100, which is the same as switching to mode 5,
\ (i.e. the bottom part of the screen) but with no
\ cursor
LDY #11 \ We now apply the palette bytes from block1 to the
\ mode 5 screen, so set a counter in Y for 12 bytes
.inlp1
LDA block1,Y \ Copy the Y-th palette byte from block1 to SHEILA &21
STA &FE21 \ to map logical to actual colours for the bottom part
\ of the screen (i.e. the dashboard)
DEY \ Decrement the palette byte counter
BPL inlp1 \ Loop back to the inlp1 until we have copied all the
\ palette bytes
PLA \ Restore Y from the stack
TAY
JMP (VEC) \ Jump to the address in VEC, which was set to the
\ original IRQ1V vector in part 4, so this instruction
\ passes control to the next interrupt handler
.IRQ1
TYA \ Store Y on the stack
PHA
IF PROT AND DISC = 0
\ By this point, we have set up the following in
\ various places throughout the loader code (such as
\ part 2 and PLL1):
\
\ BLPTR(1 0) = &03CA
\ BLN(1 0) = &03C6
\ EXCN(1 0) = &03C2
\
\ BLPTR (&03CA) is a byte in the MOS workspace that
\ stores the block flag of the most recent block loaded
\ from tape
\
\ BLN (&03C6) is the low byte of the number of the last
\ block loaded from tape
\
\ EXCN (&03C2) is the low byte of the execution address
\ of the file being loaded
LDY #0 \ Set A to the block flag of the most recent block
LDA (BLPTR),Y \ loaded from tape
BIT M2 \ If bit 1 of the block flag is set, jump to itdone
BNE itdone
EOR #%10000011 \ Otherwise flip bits 0, 1 and 7 of A. This has two
\ main effects:
\
\ * Bit 0 of the block flag gets cleared. Most
\ cassette versions of Acornsoft games are saved to
\ tape with locked blocks, so you can't just load
\ the game into memory (you'll get a "Locked" error
\ for each block). Locked blocks have bit 0 set, so
\ this clears the locked status, so when the MOS
\ gets round to checking whether the block is
\ locked, we've already cleared it and updated it in
\ memory (which we do below), so the block loads
\ without throwing an error
\
\ * Bit 1 of the block flag gets set, so we won't
\ increment BLCNT again until the next block starts
\ loading (so in this way we count the number of
\ blocks loaded in BLCNT)
INC BLCNT \ Increment BLCNT, which was initialised to 0 in part 3
BNE ZQK \ If BLCNT is non-zero, skip the next instruction
DEC BLCNT \ If incrementing BLCNT set it to zero, decrement it, so
\ this sets a maximum of 255 on BLCNT
.ZQK
STA (BLPTR),Y \ Store the updated value of A in the block flag, so the
\ block gets unlocked
LDA #35 \ If the block number in BLN is 35, skip the next
CMP (BLN),Y \ instruction, leaving A = 32 = &23
BEQ P%+4
EOR #17 \ Set A = 35 EOR 17 = 50 = &32
CMP (EXCN),Y \ If the low byte of the execution address of the file
BEQ itdone \ we are loading is equal to A (which is either &23 or
\ &32), skip to itdone
DEC LOAD% \ Otherwise decrement LOAD%, which is the address of the
\ first byte of the main game code file (i.e. the load
\ address of "ELTcode"), so this decrements the first
\ byte of the file we are loading, i.e. the LBL variable
\ added by the Big Code File source
.itdone
ENDIF
LDA VIA+&4D \ Read the 6522 System VIA status byte bit 1 (SHEILA
BIT M2 \ &4D), which is set if vertical sync has occurred on
\ the video system
BNE LINSCN \ If we are on the vertical sync pulse, jump to LINSCN
\ to set up the timers to enable us to switch the
\ screen mode between the space view and dashboard
AND #%01000000 \ If the 6522 System VIA status byte bit 6 is set, which
BNE VIA2 \ means timer 1 has timed out, jump to VIA2
PLA \ Restore Y from the stack
TAY
JMP (VEC) \ Jump to the address in VEC, which was set to the
\ original IRQ1V vector in part 4, so this instruction
\ passes control to the next interrupt handler
.LINSCN
LDA #50 \ Set 6522 System VIA T1C-L timer 1 low-order counter
STA VIA+&44 \ (SHEILA &44) to 50
LDA #VSCAN \ Set 6522 System VIA T1C-L timer 1 high-order counter
STA VIA+&45 \ (SHEILA &45) to VSCAN (56) to start the T1 counter
\ counting down from 14386 at a rate of 1 MHz
LDA #8 \ Set the Video ULA control register (SHEILA &20) to
STA &FE20 \ %00001000, which is the same as switching to mode 4
\ (i.e. the top part of the screen) but with no cursor
LDY #11 \ We now apply the palette bytes from block2 to the
\ mode 4 screen, so set a counter in Y for 12 bytes
.inlp2
LDA block2,Y \ Copy the Y-th palette byte from block2 to SHEILA &21
STA &FE21 \ to map logical to actual colours for the top part of
\ the screen (i.e. the space view)
DEY \ Decrement the palette byte counter
BPL inlp2 \ Loop back to the inlp1 until we have copied all the
\ palette bytes
PLA \ Restore Y from the stack
TAY
JMP (VEC) \ Jump to the address in VEC, which was set to the
\ original IRQ1V vector in part 4, so this instruction
\ passes control to the next interrupt handler
\ ******************************************************************************
\
\ Name: BLOCK
\ Type: Variable
\ Category: Copy protection
\ Summary: Addresses for the obfuscated jumps that use RTS not JMP
\
\ ------------------------------------------------------------------------------
\
\ These two addresses get pushed onto the stack in part 4. The first EQUW is the
\ address of ENTRY2, while the second is the address of the first instruction in
\ part 6, after it is pushed onto the stack.
\
\ This entire section from BLOCK to ENDBLOCK gets copied into the stack at
\ location &015E by part 4, so by the time we call the routine at the second
\ EQUW address at the start, the entry point is on the stack at &0163.
\
\ This means that the RTS instructions at the end of parts 4 and 5 jump to
\ ENTRY2 and the start of part 6 respectively. See part 4 for details.
\
\ ******************************************************************************
.BLOCK
EQUW ENTRY2-1
EQUW 512-LEN+BLOCK-ENDBLOCK+3
\ ******************************************************************************
\
\ Name: Elite loader (Part 6 of 6)
\ Type: Subroutine
\ Category: Loader
\ Summary: Set up interrupt vectors, calculate checksums, run main game code
\
\ ------------------------------------------------------------------------------
\
\ This is the final part of the loader. It sets up some of the main game's
\ interrupt vectors and calculates various checksums, before finally handing
\ over to the main game.
\
\ ******************************************************************************
LDA VIA+&44 \ Read the 6522 System VIA T1C-L timer 1 low-order
STA 1 \ counter (SHEILA &44) which increments 1000 times a
\ second so this will be pretty random, and store it in
\ location 1, which is among the main game code's random
\ seeds in RAND (so this seeds the random numbers for
\ the main game)
SEI \ Disable all interrupts
LDA #%00111001 \ Set 6522 System VIA interrupt enable register IER
STA VIA+&4E \ (SHEILA &4E) bits 0 and 3-5 (i.e. disable the Timer1,
\ CB1, CB2 and CA2 interrupts from the System VIA)
\LDA #&7F \ These instructions are commented out in the original
\STA &FE6E \ source with the comment "already done", which they
\LDA IRQ1V \ were, in part 4
\STA VEC
\LDA IRQ1V+1
\STA VEC+1
LDA S%+4 \ S% points to the entry point for the main game code,
STA IRQ1V \ so this copies the address of the main game's IRQ1
LDA S%+5 \ routine from the start of the main code into IRQ1V
STA IRQ1V+1
LDA #VSCAN \ Set 6522 System VIA T1C-L timer 1 high-order counter
STA VIA+&45 \ (SHEILA &45) to VSCAN (56) to start the T1 counter
\ counting down from 14080 at a rate of 1 MHz (this is
\ a different value to the main game code)
CLI \ Re-enable interrupts
\LDA #129 \ These instructions are commented out in the original
\LDY #&FF \ source. They call OSBYTE with A = 129, X = 1 and
\LDX #1 \ Y = &FF, which returns the machine type in X, so
\JSR OSBYTE \ this code would detect the MOS version
\TXA
\EOR #&FF
\STA MOS
\BMI BLAST
LDY #0 \ Call OSBYTE with A = 200, X = 3 and Y = 0 to disable
LDA #200 \ the ESCAPE key and clear memory if the BREAK key is
LDX #3 \ pressed
JSR OSBYTE
\ The rest of the routine calculates various checksums
\ and makes sure they are correct before proceeding, to
\ prevent code tampering. We start by calculating the
\ checksum for the main game code from &0F40 to &5540,
\ which just adds up every byte and checks it against
\ the checksum stored at the end of the main game code
.BLAST
LDA #HI(S%) \ Set ZP(1 0) = S%
STA ZP+1 \
LDA #LO(S%) \ so ZP(1 0) points to the start of the main game code
STA ZP
LDX #&45 \ We are going to checksum &45 pages from &0F40 to &5540
\ so set a page counter in X
LDY #0 \ Set Y to count through each byte within each page
TYA \ Set A = 0 for building the checksum
.CHK
CLC \ Add the Y-th byte of this page of the game code to A
ADC (ZP),Y
INY \ Increment the counter for this page
BNE CHK \ Loop back for the next byte until we have finished
\ adding up this page
INC ZP+1 \ Increment the high byte of ZP(1 0) to point to the
\ next page
DEX \ Decrement the page counter we set in X
BPL CHK \ Loop back to add up the next page until we have done
\ them all
IF _REMOVE_CHECKSUMS
LDA #0 \ If we have disabled checksums, just set A to 0 so the
NOP \ BEQ below jumps to itsOK
ELSE
CMP D%-1 \ D% is set to the size of the main game code, so this
\ compares the result to the last byte in the main game
\ code, at location checksum0
ENDIF
BEQ itsOK \ If the checksum we just calculated matches the value
\ in location checksum0, jump to itsOK
.nononono
STA S%+1 \ If we get here then the checksum was wrong, so first
\ we store the incorrect checksum value in the low byte
\ of the address stored at the start of the main game
\ code, which contains the address of TT170, the entry
\ point for the main game (so this hides this address
\ from prying eyes)
LDA #%01111111 \ Set 6522 System VIA interrupt enable register IER
STA &FE4E \ (SHEILA &4E) bits 0-6 (i.e. disable all hardware
\ interrupts from the System VIA)
JMP (&FFFC) \ Jump to the address in &FFFC to reset the machine
.itsOK
JMP (S%) \ The checksum was correct, so we call the address held
\ in the first two bytes of the main game code, which
\ point to TT170, the entry point for the main game
\ code, so this, finally, is where we hand over to the
\ game itself
\ ******************************************************************************
\
\ Name: CHECKER
\ Type: Subroutine
\ Category: Copy protection
\ Summary: Run checksum checks on tokens, loader and tape block count
\
\ ------------------------------------------------------------------------------
\
\ This routine runs checksum checks on the recursive token table and the loader
\ code at the start of the main game code file, to prevent tampering with these
\ areas of memory. It also runs a check on the tape loading block count.
\
\ ******************************************************************************
.CHECKER
\ First we check the MAINSUM+1 checksum for the
\ recursive token table from &0400 to &07FF
LDY #0 \ Set Y = 0 to count through each byte within each page
LDX #4 \ We are going to checksum 4 pages from &0400 to &07FF
\ so set a page counter in X
STX ZP+1 \ Set ZP(1 0) = &0400, to point to the start of the code
STY ZP \ we want to checksum
TYA \ Set A = 0 for building the checksum
.CHKq
CLC \ Add the Y-th byte of this page of the token table to A
ADC (ZP),Y
INY \ Increment the counter for this page
BNE CHKq \ Loop back for the next byte until we have finished
\ adding up this page
INC ZP+1 \ Increment the high byte of ZP(1 0) to point to the
\ next page
DEX \ Decrement the page counter we set in X
BNE CHKq \ Loop back to add up the next page until we have done
\ them all
CMP MAINSUM+1 \ Compare the result to the contents of MAINSUM+1, which
\ contains the checksum for the table (this gets set by
\ elite-checksum.py)
IF _REMOVE_CHECKSUMS
NOP \ If we have disabled checksums, do nothing
NOP
ELSE
BNE nononono \ If the checksum we just calculated does not match the
\ contents of MAINSUM+1, jump to nononono to reset the
\ machine
ENDIF
\ Next, we check the LBL routine in the header that's
\ appended to the main game code in elite-bcfs.asm, and
\ which is currently loaded at LOAD% (which contains the
\ load address of the main game code file)
TYA \ Set A = 0 for building the checksum (as Y is still 0
\ from the above checksum loop)
.CHKb
CLC \ Add the Y-th byte of LOAD% to A
ADC LOAD%,Y
INY \ Increment the counter
CPY #40 \ There are 40 bytes in the loader, so loop back until
BNE CHKb \ we have added them all
CMP MAINSUM \ Compare the result to the contents of MAINSUM, which
\ contains the checksum for loader code
IF _REMOVE_CHECKSUMS
NOP \ If we have disabled checksums, do nothing
NOP
ELSE
BNE nononono \ If the checksum we just calculated does not match the
\ contents of MAINSUM, jump to nononono to reset the
\ machine
ENDIF
\ Finally, we check the block count from the tape
\ loading code in the IRQ1 routine, which counts the
\ number of blocks in the main game code
IF PROT AND DISC = 0
LDA BLCNT \ If the tape protection is enabled and we are loading
CMP #&4F \ from tape (as opposed to disc), check that the block
BCC nononono \ count in BLCNT is &4F, and if it isn't, jump to
\ nononono to reset the machine
ENDIF
IF _REMOVE_CHECKSUMS
RTS \ If we have disabled checksums, return from the
NOP \ subroutine
NOP
ELSE
JMP (CHECKV) \ Call the LBL routine in the header (whose address is
\ in CHECKV). This routine is inserted before the main
\ game code by elite-bcfs.asm, and it checks the
\ validity of the first two pages of the UU% routine,
\ which was copied to LE% above, and which contains a
\ checksum byte in CHECKbyt. We then return from the
\ subroutine using a tail call
ENDIF
.ENDBLOCK
\ ******************************************************************************
\
\ Name: XC
\ Type: Variable
\ Category: Text
\ Summary: The x-coordinate of the text cursor
\
\ ------------------------------------------------------------------------------
\
\ Contains the x-coordinate of the text cursor (i.e. the text column) with an
\ initial value of column 7, at the top-left corner of the 14x14 text window
\ where we show the tape loading messages (see TT26 for details).
\
\ ******************************************************************************
.XC
EQUB 7
\ ******************************************************************************
\
\ Name: YC
\ Type: Variable
\ Category: Text
\ Summary: The y-coordinate of the text cursor
\
\ ------------------------------------------------------------------------------
\
\ Contains the y-coordinate of the text cursor (i.e. the text row) with an
\ initial value of row 6, at the top-left corner of the 14x14 text window where
\ we show the tape loading messages (see TT26 for details).
\
\ ******************************************************************************
.YC
EQUB 6
\ ******************************************************************************
\
\ Save ELITE.unprot.bin
\
\ ******************************************************************************
COPYBLOCK LE%, P%, UU% \ Copy the block that we assembled at LE% to UU%, which
\ is where it will actually run
PRINT "BLOCK offset = ", ~(BLOCK - LE%) + (UU% - CODE%)
PRINT "ENDBLOCK offset = ",~(ENDBLOCK - LE%) + (UU% - CODE%)
PRINT "MAINSUM offset = ",~(MAINSUM - LE%) + (UU% - CODE%)
PRINT "TUT offset = ",~(TUT - LE%) + (UU% - CODE%)
PRINT "UU% = ",~UU%," Q% = ",~Q%, " OSB = ",~OSB
PRINT "Memory usage: ", ~LE%, " - ",~P%
PRINT "Stack: ",LEN + ENDBLOCK - BLOCK
PRINT "S. ELITE ", ~CODE%, " ", ~UU% + (P% - LE%), " ", ~run, " ", ~CODE%
SAVE "3-assembled-output/ELITE.unprot.bin", CODE%, UU% + (P% - LE%), run, CODE%
|
mc-sema/validator/x86_64/tests/PEXTRWmr.asm | randolphwong/mcsema | 2 | 162565 | <gh_stars>1-10
BITS 64
;TEST_FILE_META_BEGIN
;TEST_TYPE=TEST_F
;TEST_IGNOREFLAGS=FLAG_SF|FLAG_PF
;TEST_FILE_META_END
mov eax, 0
mov ecx, 0
;TEST_BEGIN_RECORDING
lea rbx, [rsp-4]
mov dword [rbx], 0
lea rcx, [rsp-0x30]
and rcx, 0xFFFFFFFFFFFFFFF0
mov dword [rcx+0x00], 0xAAAAAAAA
mov dword [rcx+0x04], 0xBBBBBBBB
mov dword [rcx+0x08], 0xCCCCCCCC
mov dword [rcx+0x0C], 0xDDDDDDDD
movdqu xmm1, [rcx]
pextrw [rbx], xmm1, 7
mov ebx, [rbx]
mov ecx, 0
;TEST_END_RECORDING
cvtsi2sd xmm1, ecx
|
task.asm | tristanred/micros | 4 | 170882 | global ks_suspend
global ks_get_stacked_registers
global ks_do_activate
extern Debugger
extern ks_suspend_stage2
; Pushes all registers on the stack, this must be done early in the process so
; we can save all register values before they are changed by the following code.
; We get the ESP, EBP and EIP from the previous stack frame so that when we
; recover the task it will be on the next instruction right after ks_suspend.
ks_suspend: ; void ks_suspend(void)
push ebp
mov ebp, esp
pushf ; EFLAGS
push DWORD 0x8 ; CS
pusha ; regs 8 DW
push ebp ; Previous frame ESP
add DWORD [esp], 8 ; Adjust for the 2 frames that we pushed ebp's on
push DWORD [ebp+4] ; Return addr (EIP)
push DWORD [ebp] ; Previous frame EBP
call ks_suspend_stage2
; Technically we will never reach this point because we call ks_activate
; and go to another thread. The function ks_suspend never returns.
add esp, 52
pop esp
ret
; This function should be called from ks_suspend_stage2, this is because
; this function goes up 2 stack frames in search of the saved registers.
; We can't just get them here because they would have been changed by the time
; we get here. The alternative is to write the whole pipeline of task transfer
; in assemblyto avoid clobbering registers. We would still have to go back up
; to grab the original EBP and ESP so meh.
ks_get_stacked_registers: ; struct regs_t ks_get_stacked_registers(void)
push ebp
mov ebp, esp
sub esp, 48 ; 44 byte for struct and 4 for pushed eax(?)
; Select two stackframes above, frame with the flags stacked
mov ebx, DWORD [ebp]
mov ebx, DWORD [ebx]
mov eax, [ebp+8] ; Where we drop the data
mov edx, [ebx-44] ; ESP
mov [eax+24], edx
mov edx, [ebx-48] ; EIP
mov [eax], edx
mov edx, [ebx-4] ; EFLAGS
mov [eax+8], edx
mov edx, [ebx-8] ; CS
mov [eax+4], edx
mov edx, [ebx-40] ; EDI
mov [eax+12], edx
mov edx, [ebx-36] ; ESI
mov [eax+16], edx
mov edx, [ebx-52] ; EBP
mov [eax+20], edx
mov edx, [ebx-24] ; EBX
mov [eax+28], edx
mov edx, [ebx-20] ; EDX
mov [eax+32], edx
mov edx, [ebx-16] ; ECX
mov [eax+36], edx
mov edx, [ebx-12] ; EAX
mov [eax+40], edx
add esp, 48
pop ebp
ret
ks_do_activate: ; void ks_do_activate(struct task_t*)
push ebp
mov ebp, esp
mov eax, [ebp+8]
mov ebx, [eax+28] ; Target stack
; ---> $ebp+4 <--- contains the saved EIP
; Move all the registers to target stack
; SUB target ESP to top of target stack
; Switch current stack to target stack
; pop registers back
; pop flags
; pop cs
; execute ret, which will pop eip
; Registers : EAX = target task_t structure
; EBX = target stack address
; ECX = scratch register
mov ecx, [eax+44] ; Emplace EAX
mov [ebx-12], ecx
mov ecx, [eax+40] ; Emplace ECX
mov [ebx-16], ecx
mov ecx, [eax+36] ; Emplace EDX
mov [ebx-20], ecx
mov ecx, [eax+32] ; Emplace EBX
mov [ebx-24], ecx
mov ecx, [eax+28] ; Emplace ESP STUB
mov [ebx-28], DWORD 0
; ESP not needed because we manually switch ESP rather than using the
; popped value.
mov ecx, [eax+24] ; Emplace EBP
mov [ebx-32], ecx
mov ecx, [eax+20] ; Emplace ESI
mov [ebx-36], ecx
mov ecx, [eax+16] ; Emplace EDI
mov [ebx-40], ecx
mov ecx, [eax+12] ; Emplace EFLAGS
mov [ebx-8], ecx
; TODO : Cannot switch CS during normal switching operations
; mov ecx, [eax+8] ; Emplace CS
; mov [ebx-52], ecx
mov ecx, [eax+4] ; Emplace EIP
mov [ebx-4], ecx
mov ebp, [eax+24] ; Use the new ebp
mov esp, [eax+28] ; Use the new stack
sub esp, 40
popa
popfd
;pop ebp ; Not needed because we manually place it back
ret
|
test/Fail/DontPrune.agda | cruhland/agda | 1,989 | 6741 | <gh_stars>1000+
-- Andreas, 2012-05-09
module DontPrune where
open import Common.Equality
open import Common.Product
data Bool : Set where
true false : Bool
test : (A : Set) →
let IF : Bool → A → A → A
IF = _
in (a b : A) →
(IF true a b ≡ a) × (IF false a b ≡ b)
test A a b = refl , refl
-- Expected result: unsolved metas
--
-- (unless someone implemented unification that produces definitions by case).
--
-- The test case should prevent overzealous pruning:
-- If the first equation pruned away the b, then the second
-- would have an unbound rhs.
|
programs/oeis/051/A051340.asm | neoneye/loda | 22 | 88579 | ; A051340: A simple 2-dimensional array, read by antidiagonals: T[i,j] = 1 for j>0, T[i,0] = i+1; i,j = 0,1,2,3,...
; 1,1,2,1,1,3,1,1,1,4,1,1,1,1,5,1,1,1,1,1,6,1,1,1,1,1,1,7,1,1,1,1,1,1,1,8,1,1,1,1,1,1,1,1,9,1,1,1,1,1,1,1,1,1,10,1,1,1,1,1,1,1,1,1,1,11,1,1,1,1,1,1,1,1,1,1,1,12,1,1,1,1,1,1,1,1,1,1,1,1,13,1,1,1,1,1,1
mov $1,1
mov $2,1
lpb $2
lpb $0
add $1,1
sub $0,$1
mov $2,$0
lpe
lpe
mov $0,$1
|
scripts/astro.applescript | djl/rio | 0 | 2142 | --
-- astro
--
set path_ to "" & (path to home folder) & ".config:astro:config"
on lower(this_text)
set the comparison_string to "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
set the source_string to "abcdefghijklmnopqrstuvwxyz"
set the new_text to ""
repeat with thisChar in this_text
set x to the offset of thisChar in the comparison_string
if x is not 0 then
set the new_text to (the new_text & character x of the source_string) as string
else
set the new_text to (the new_text & thisChar) as string
end if
end repeat
return the new_text
end change_case
on slurp(theFile)
set fileHandle to open for access theFile
set theLines to paragraphs of (read fileHandle)
close access fileHandle
return theLines
end fileToList
on replace(input, x, y)
set text item delimiters to x
set ti to text items of input
set text item delimiters to y
ti as text
end replace
tell application "Finder"
set fbounds to bounds of window of desktop
end tell
set lines_ to slurp(path_)
set res to "" & (item 3 of fbounds) & "x" & (item 4 of fbounds)
set app_name to short name of (info for (path to frontmost application))
set needle to replace(app_name, " ", "-")
set needle to lower(needle)
repeat with line_ in lines_
try
if (word 1 of line_) is equal to needle then
if (word 2 of line_) is equal to res then
set width to (word 3 of line_) as integer
set height to (word 4 of line_) as integer
set x to (word 5 of line_) as integer
set y to (word 6 of line_) as integer
tell application app_name
try
set allWindows to every window
repeat with wind in allWindows
if wind is closeable and wind is resizable then
set the bounds of wind to {x, y, width, height}
exit repeat
end if
end repeat
end try
end tell
end if
end if
end try
end repeat
|
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/discr16_cont.ads | best08618/asylo | 7 | 11644 | with Discr16_Pkg; use Discr16_Pkg;
package Discr16_Cont is
type ES6a is new ET3a range E2..E4;
end;
|
oeis/138/A138976.asm | neoneye/loda-programs | 11 | 10332 | ; A138976: The discriminant of the characteristic polynomial of the O+ and O- submatrix for spin 3 of the nuclear electric quadrupole Hamiltonian is a perfect square for these values.
; Submitted by <NAME>
; 0,-3,-18,-45,-192,-459,-1914,-4557,-18960,-45123,-187698,-446685,-1858032,-4421739,-18392634,-43770717,-182068320,-433285443,-1802290578,-4289083725,-17840837472,-42457551819,-176606084154,-420286434477,-1748220004080,-4160406792963
seq $0,233450 ; Numbers n such that 3*T(n)+1 is a square, where T = A000217.
mul $0,-3
|
libsrc/_DEVELOPMENT/input/basic/z80/asm_in_inkey.asm | ahjelm/z88dk | 640 | 87972 |
; ===============================================================
; feilipu Sept 2020
; ===============================================================
;
; int in_inkey(void)
;
; Read instantaneous state of the keyboard and return ascii code
; if only one key is pressed.
;
; Note: Limited by basic here as it can only register one keypress.
;
; ===============================================================
SECTION code_clib
SECTION code_input
PUBLIC asm_in_inkey
.asm_in_inkey
; exit : if one key is pressed
;
; hl = ascii code
; carry reset
;
; if no keys are pressed
;
; hl = 0
; carry reset
;
; if more than one key is pressed
;
; hl = 0
; carry set
;
; uses : potentially all (ix, iy saved for sdcc)
rst 18h ; # waiting keys in A
ld hl,0 ; prepare exit
or a
ret Z ; return for no keys
dec a
scf
ret NZ ; return carry set for too many keys
rst 10h ; key in A
ld l,a
or a ; reset carry
ret
|
src/sdl-cpus.ads | treggit/sdlada | 89 | 17329 | <filename>src/sdl-cpus.ads
--------------------------------------------------------------------------------------------------------------------
-- Copyright (c) 2013-2020, <NAME>
--
-- This software is provided 'as-is', without any express or implied
-- warranty. In no event will the authors be held liable for any damages
-- arising from the use of this software.
--
-- Permission is granted to anyone to use this software for any purpose,
-- including commercial applications, and to alter it and redistribute it
-- freely, subject to the following restrictions:
--
-- 1. The origin of this software must not be misrepresented; you must not
-- claim that you wrote the original software. If you use this software
-- in a product, an acknowledgment in the product documentation would be
-- appreciated but is not required.
--
-- 2. Altered source versions must be plainly marked as such, and must not be
-- misrepresented as being the original software.
--
-- 3. This notice may not be removed or altered from any source
-- distribution.
--------------------------------------------------------------------------------------------------------------------
-- SDL.CPUS
--
-- Platform CPU information retrieval.
--------------------------------------------------------------------------------------------------------------------
package SDL.CPUS is
pragma Preelaborate;
-- TODO: Add a subprogram to return CPU architecture as not all platforms will have the same one, i.e.
-- Android on ARM, MIPS, x86.
function Count return Positive;
function Cache_Line_Size return Positive with
Inline => True;
function Has_3DNow return Boolean with
Inline => True;
function Has_AltiVec return Boolean with
Inline => True;
function Has_MMX return Boolean with
Inline => True;
function Has_RDTSC return Boolean with
Inline => True;
function Has_SSE return Boolean with
Inline => True;
function Has_SSE_2 return Boolean with
Inline => True;
function Has_SSE_3 return Boolean with
Inline => True;
function Has_SSE_4_1 return Boolean with
Inline => True;
function Has_SSE_4_2 return Boolean with
Inline => True;
end SDL.CPUS;
|
Tests/base/Z80N/UIcode.i.asm | MrKWatkins/ZXSpectrumNextTests | 23 | 8387 | ; symbols to be defined externally:
; -- main data --
; TEST_OPT_BIT_FULL - option "full" bit number
; TestOptions - currently selected options by user
; HelpTxt - chain of strings (will be printed per line), empty string marks total end
; MachineInfoLabels - top line labels (two, first is "machineID", second "core")
; INSTRUCTIONS_CNT - amount of Z80N instructions (arrays size, loop size, etc)
; InstructionsData_KeyLegends - array of pair<byte ASCII_key,byte key_code>
; InstructionsData_Details - array of 4-byte structs
; InstructionsData_Encoding - array of 4-byte encoding
; InstructionMnemonics - series of INSTRUCTIONS_CNT strings
; -- various positional configuration (position of attributes, etc) --
; KEY_ATTR_OFS_HELP, KEY_ATTR_OFS_TURBO, KEY_ATTR_OFS_FULL, KEY_ATTR_OFS_RUN
; KEY_ATTR_OFS_INSTR, KEY_ATTR_OFS_CORE
; CHARPOS_ENCODING, CHARPOS_INS_END, CHARPOS_INS_KEY, CHARPOS_STATUS
; -- code --
; RunZ80nTest - A: 0..(INSTRUCTIONS_CNT-1) - index of instruction to run test
; possible results (levels of OK are how many tests sub-parts were skipped)
; these are offsets into ResultStringBase texts definitions
RESULT_NONE equ 3
RESULT_ERR equ 0
RESULT_OK equ 4 ; i.e. OK0
RESULT_OK1 equ 7
RESULT_OK2 equ 11
ALIGN 16
ResultStringBase:
db 'ERR',0,'OK',0,'OK1',0,'OK2',0
; if opcode is "special", these are offsets into SpecialOpcodeMnemonics string
OPCODE_TXT_NONE equ 0
OPCODE_TXT_VALUE equ 2
OPCODE_TXT_LOW equ 4
OPCODE_TXT_HIGH equ 6
OPCODE_TXT_REG equ 8
ALIGN 16
SpecialOpcodeMnemonics:
db ' nnlohirr'
;;;;;;;;;;;;;; test heartbeat progress bar routines ;;;;;;;;;;;;;
Heartbeat_Line0Attribs:
ds 32
Heartbeat_InitialAttribute:
db A_BRIGHT|P_BLACK|BLACK
; macros to initialize heartbeat to expect at least N-many beats. It's OK-ish to
; call Heartbeat more than N times, but the progress bar will be "full" after N.
MACRO INIT_HEARTBEAT_256
ld a,A_BRIGHT|P_BLACK|BLACK
call InitHeartbeat
ENDM
MACRO INIT_HEARTBEAT_32 ; this is minimal size, there's no less than 32
ld a,A_BRIGHT|P_WHITE|WHITE
call InitHeartbeat
ENDM
InitHeartbeat:
push af
push hl
push de
push bc
ld (Heartbeat_InitialAttribute),a
; backup current attributes of first line
ld hl,MEM_ZX_ATTRIB_5800
ld de,Heartbeat_Line0Attribs
ld bc,32
ldir
; reset current beat position
ld hl,MEM_ZX_ATTRIB_5800
ld (TestHeartbeat.CurrentBeatPos+1),hl
; "clear" first line
ld de,MEM_ZX_ATTRIB_5800+1
ld bc,31
ld (hl),P_MAGENTA|MAGENTA ; make first line pixels "invisible"
ldir
pop bc
pop de
pop hl
pop af
ret
TestHeartbeatFour:
call TestHeartbeatTwo
TestHeartbeatTwo:
call TestHeartbeat
; preserves everything (by using stack)
TestHeartbeat:
push af
push hl
.CurrentBeatPos:
ld hl,0
ld a,h
or l
jr z,.FullProgressBarOrUninitialized
ld a,(Heartbeat_InitialAttribute)
bit 6,(hl) ; check for BRIGHT = no bright = first time this square
jr z,.SetUpNewColour
; already some progress there, just increment by "one"
ld a,(hl)
add a,P_BLUE|BLUE
jp p,.SetUpNewColour ; when top bit (A_FLASH) becomes set, it's over...
; move to next square, if possible
inc l
ld a,l
cp 32
jr nc,.Full
ld (.CurrentBeatPos+1),hl
ld a,(Heartbeat_InitialAttribute)
.SetUpNewColour:
ld (hl),a
.FullProgressBarOrUninitialized:
pop hl
pop af
ret
.Full:
ld hl,0
ld (.CurrentBeatPos+1),hl
jr .FullProgressBarOrUninitialized
DeinitHeartbeat:
; restore attributes of first line (making pixels probably visible)
ld hl,Heartbeat_Line0Attribs
ld de,MEM_ZX_ATTRIB_5800
ld bc,32
ldir
ret
;;;;;;;;;;;;;; main screen full-redraw routine ;;;;;;;;;;;;;;;;;;
RedrawMainScreen:
ld a,GREEN
out (ULA_P_FE),a
; create attribute stripes to make lines easier to read
FILL_AREA MEM_ZX_ATTRIB_5800+1*32, 3*32, P_WHITE|BLACK ; restore "white" on 2nd+4th
FILL_AREA MEM_ZX_ATTRIB_5800+2*32, 32, P_CYAN|BLACK ; cyan at third line
; copy this white/cyan paper over full screen
ld hl,MEM_ZX_ATTRIB_5800+2*32
ld de,MEM_ZX_ATTRIB_5800+4*32
ld bc,32*24-4*32
ldir
; make top line green
FILL_AREA MEM_ZX_ATTRIB_5800, 32, P_GREEN|BLACK ; cyan at second line
;; this main screen drawing expect first line of screen to be clear(!)
; create vertical lines (over full screen, because I'm super lazy)
ld a,$08
ld hl,MEM_ZX_SCREEN_4000
push hl
push hl
pop ix
ld (ix+CHARPOS_ENCODING-1),a
ld (ix+CHARPOS_ENCODING+2),a
ld (ix+CHARPOS_ENCODING+5),a
ld (ix+CHARPOS_ENCODING+8),a
ld (ix+CHARPOS_INS_KEY-1),a
ld (ix+CHARPOS_STATUS-1),a
; now copy first line over full screen, so it will also clear it
ld de,MEM_ZX_SCREEN_4000+32
ld bc,32*191
ldir
; erase first line pixels
pop hl
ld bc, 32
.ClearLine0Loop:
xor a
ld l,a
call FillArea
inc h
ld a,h
cp $48
jr nz,.ClearLine0Loop
; highlight control keys
ld ix,MEM_ZX_ATTRIB_5800
set 6,(ix+KEY_ATTR_OFS_HELP) ; set BRIGHT bit of attributes
set 6,(ix+KEY_ATTR_OFS_TURBO)
set 6,(ix+KEY_ATTR_OFS_FULL)
set 6,(ix+KEY_ATTR_OFS_RUN)
; update options status
call UpdateToplineOptionsStatus
; highlight keys for particular tests
ld de,32
ld b,INSTRUCTIONS_CNT
ld hl,InstructionsData_KeyLegends
xor a
.HighlightKeysLoop:
add ix,de
cp (hl)
jr z,.skipInstructionKeyHighlight
set 6,(ix+KEY_ATTR_OFS_INSTR)
.skipInstructionKeyHighlight:
inc hl
inc hl
djnz .HighlightKeysLoop
; show Main line legend, MachineID and core version
ld de,MEM_ZX_SCREEN_4000
ld bc,MEM_ZX_SCREEN_4000+KEY_ATTR_OFS_CORE
; move core version +1 pos right if sub-minor version is under 100
NEXTREG2A NEXT_VERSION_MINOR_NR_0E
cp 100
jr nc,.SubMinorAboveEqual100
inc c
.SubMinorAboveEqual100:
ld ix,0 ; simple info only
ld hl,MachineInfoLabels
call OutMachineIdAndCore
;; print instruction table
; print instruction mnemonics
ld b,INSTRUCTIONS_CNT
ld de,MEM_ZX_SCREEN_4000+32
ld hl,InstructionMnemonics
.PrintInstructionMnemonics:
call OutStringAtDe
ex de,hl
call AdvanceVramHlToNextLine
ex de,hl
djnz .PrintInstructionMnemonics
;; print instruction opcodes, key-shortcut and status
ld de,0 ; number of instruction*4
ld hl,MEM_ZX_SCREEN_4000+32+CHARPOS_STATUS
.PrintInstructionDetails:
push hl
ld ix,InstructionsData_Details
add ix,de
; display status
call PrintTestStatus ; 3-letter statuses may advance OutCurrentAdr to next third!
; display key
ld a,l
sub CHARPOS_STATUS-CHARPOS_INS_KEY
ld l,a
ld (OutCurrentAdr),hl ; set up VRAM position (whole HL to reset VRAM third!)
push hl
ld hl,InstructionsData_KeyLegends
rrc e
add hl,de ; += instruction_inde*2
rlc e
ld a,(hl) ; shortcut-key ASCII
or a
call nz,OutChar
pop hl
; display instruction encoding
ld a,l
sub CHARPOS_INS_KEY-CHARPOS_ENCODING
ld (OutCurrentAdr),a ; set up VRAM output position
ld a,(ix) ; encoding bytes [2:0], special mask [7:3] (from top to bottom)
ld c,a ; special mask into C
and 7
ld b,a ; bytes count into B
ld ix,InstructionsData_Encoding
add ix,de
; b = number of bytes, c = special mask (at top bits)
.PrintSingleOpcodeByte:
ld a,(ix)
inc ix
rl c
jr c,.SpecialOpcodeByte
; ordinary opcode byte
call OutHexaValue
jr .SkipVerticalLineInOpcodes
.SpecialOpcodeByte:
add a,SpecialOpcodeMnemonics&$FF
ld l,a
ld h,SpecialOpcodeMnemonics>>8
ld a,(hl)
call OutChar
inc hl
ld a,(hl)
call OutChar
.SkipVerticalLineInOpcodes:
ld a,' '
call OutChar
djnz .PrintSingleOpcodeByte
pop hl
; advance to "next line"
call AdvanceVramHlToNextLine
ld a,4
add a,e
ld e,a
cp INSTRUCTIONS_CNT*4
jr nz,.PrintInstructionDetails
ret
;IX: instruction details data, HL: VRAM address for output
PrintTestStatus:
ld (OutCurrentAdr),hl ; set up VRAM output position
push hl
; display status
ld a,(ix+1) ; fetch status
cp RESULT_ERR
jr nz,.KeepBorderAsIs
; set red border in case any "ERR" status is displayed
ld a,RED
out (ULA_P_FE),a
ld a,RESULT_ERR ; restore value
.KeepBorderAsIs:
; print status string
add a,ResultStringBase&$FF
ld l,a
ld h,ResultStringBase>>8
call OutString
pop hl
ret
UpdateToplineOptionsStatus:
; update "turbo" attributes
ld hl,MEM_ZX_ATTRIB_5800+KEY_ATTR_OFS_TURBO+1
ld a,(TestOptions)
and 1<<TEST_OPT_BIT_TURBO
ld a,P_BLACK|GREEN
jr nz,.TurboIsOn
ld a,P_GREEN|BLACK
.TurboIsOn:
ld (hl),a
inc l
ld (hl),a
inc l
ld (hl),a
; update "full" attributes
ld l,KEY_ATTR_OFS_FULL+1
ld a,(TestOptions)
and 1<<TEST_OPT_BIT_FULL
ld a,P_BLACK|GREEN
jr nz,.FullIsOn
ld a,P_GREEN|BLACK
.FullIsOn:
ld (hl),a
inc l
ld (hl),a
inc l
ld (hl),a
ret
;;;;;;;;;;;;;; help screen full-redraw routine ;;;;;;;;;;;;;;;;;;
HelpKeyHandler:
; draw help screen
FILL_AREA MEM_ZX_SCREEN_4000, 192*32, 0
FILL_AREA MEM_ZX_ATTRIB_5800, 24*32, P_WHITE|BLACK
ld de, MEM_ZX_SCREEN_4000
ld hl, HelpTxt
.DisplayAllHelpStrings:
call OutStringAtDe
ex de,hl
call AdvanceVramHlToNextLine
ex de,hl
ld a,(hl)
or a
jr nz,.DisplayAllHelpStrings
; wait for any key, and then redraw main screen
call WaitForAnyKey
jp RedrawMainScreen ; restore main screen + return
;;;;;;;;;;;;;;;; key controls routines (setup + handlers) ;;;;;;;;;;;;
SetupKeyControl:
REGISTER_KEY KEY_1, HelpKeyHandler
REGISTER_KEY KEY_2, TurboKeyHandler
REGISTER_KEY KEY_3, FullKeyHandler
REGISTER_KEY KEY_5, GoKeyHandler
; register all single-test keys
ld hl,InstructionsData_KeyLegends
ld de,SingleTestKeyHandler
ld b,INSTRUCTIONS_CNT
.RegisterSingleTestHandlersLoop:
inc hl
ld a,(hl)
inc hl
call RegisterKeyhandler ; KEY_NONE will be rejected by Register function
djnz .RegisterSingleTestHandlersLoop
ret
TurboKeyHandler:
; flip turbo ON/OFF option
ld a,(TestOptions)
xor 1<<TEST_OPT_BIT_TURBO
ld (TestOptions),a
; refresh main screen top line status
call UpdateToplineOptionsStatus
; switch the turbo ON/OFF actually
jp SetTurboModeByOption ; + ret
FullKeyHandler: ; "Full" is selecting faster/slower test variants
; flip full ON/OFF option
ld a,(TestOptions)
xor 1<<TEST_OPT_BIT_FULL
ld (TestOptions),a
; refresh main screen top line status
call UpdateToplineOptionsStatus
; switch the tests set by full-option
jp SetTestsModeByOption ; + ret
GoKeyHandler: ; run all tests sequentially with current settings
xor a
.runTestLoop: ; runn all tests 0..22 (nullptr tests will be skipped safely)
push af
call RunZ80nTest
pop af
inc a
cp INSTRUCTIONS_CNT
jr nz,.runTestLoop
ret
SingleTestKeyHandler: ; DE = keycode
; find which test line was picked
ld hl,InstructionsData_KeyLegends
ld bc,INSTRUCTIONS_CNT<<8 ; C=0, B=INSTRUCTIONS_CNT
.findTestLoop:
inc hl
ld a,(hl)
inc hl
cp e
jr z,.testFound
inc c
djnz .findTestLoop
; test not found?! how??
ret
.testFound:
ld a,c ; A = 0..22 number of test
jp RunZ80nTest
|
test/Succeed/RewritingNat.agda | alhassy/agda | 3 | 11227 | <filename>test/Succeed/RewritingNat.agda
{-# OPTIONS --rewriting #-}
module RewritingNat where
open import Common.Equality
{-# BUILTIN REWRITE _≡_ #-}
data Nat : Set where
zero : Nat
suc : Nat → Nat
_+_ : Nat → Nat → Nat
zero + n = n
(suc m) + n = suc (m + n)
plusAssoc : ∀ x {y z : Nat} → ((x + y) + z) ≡ (x + (y + z))
plusAssoc zero = refl
plusAssoc (suc x) {y} {z} rewrite plusAssoc x {y} {z} = refl
plus0T : Set
plus0T = ∀{x} → (x + zero) ≡ x
plusSucT : Set
plusSucT = ∀{x y} → (x + (suc y)) ≡ suc (x + y)
postulate
plus0p : plus0T
{-# REWRITE plus0p #-}
plusSucp : plusSucT
{-# REWRITE plusSucp plusAssoc #-}
plus0 : plus0T
plus0 = refl
data Vec (A : Set) : Nat → Set where
[] : Vec A zero
_∷_ : ∀ {n} (x : A) (xs : Vec A n) → Vec A (suc n)
-- Needs REWRITE plus0p plusSucp
reverseAcc : ∀{A n m} → Vec A n → Vec A m → Vec A (n + m)
reverseAcc [] acc = acc
reverseAcc (x ∷ xs) acc = reverseAcc xs (x ∷ acc)
append : ∀{A n m} → Vec A n → Vec A m → Vec A (n + m)
append [] ys = ys
append (x ∷ xs) ys = x ∷ append xs ys
-- Note: appendAssoc needs REWRITE plusAssoc to be well-typed.
appendAssoc : ∀{A n m l} (u : Vec A n) {v : Vec A m}{w : Vec A l} →
append (append u v) w ≡ append u (append v w)
appendAssoc [] = refl
appendAssoc (x ∷ xs) {v} {w} rewrite appendAssoc xs {v} {w} = refl
|
dropin/src/lexer-source-c_handler.ads | robdaemon/AdaYaml | 32 | 9750 | -- part of AdaYaml, (c) 2017 <NAME>
-- released under the terms of the MIT license, see the file "copying.txt"
with System;
with Yaml.C;
package Lexer.Source.C_Handler is
type Instance is new Source.Instance with private;
overriding procedure Read_Data (S : in out Instance; Buffer : out String;
Length : out Natural);
function As_Source (Data : System.Address; Handler : Yaml.C.Read_Handler)
return Pointer;
private
type Instance is new Source.Instance with record
Handler : Yaml.C.Read_Handler;
Data : System.Address;
end record;
end Lexer.Source.C_Handler;
|
programs/oeis/342/A342482.asm | neoneye/loda | 22 | 245716 | <gh_stars>10-100
; A342482: a(n) = n*(2^(n-1) - n - 1).
; 0,12,50,150,392,952,2214,5010,11132,24420,53066,114478,245520,524016,1113806,2358954,4980356,10485340,22019634,46136838,96468440,201325992,419429750,872414530,1811938572,3758095572,7784627354,16106126430,33285995552,68719475680
add $0,3
mov $1,2
pow $1,$0
mul $1,$0
div $1,2
sub $1,$0
pow $0,2
sub $1,$0
mov $0,$1
|
programs/oeis/287/A287893.asm | neoneye/loda | 22 | 163986 | <filename>programs/oeis/287/A287893.asm
; A287893: a(n) = floor(n*(n+2)/9).
; 0,0,0,1,2,3,5,7,8,11,13,15,18,21,24,28,32,35,40,44,48,53,58,63,69,75,80,87,93,99,106,113,120,128,136,143,152,160,168,177,186,195,205,215,224,235,245,255,266,277,288,300,312,323,336,348,360,373,386,399,413,427,440,455,469,483,498,513,528,544,560,575,592,608,624,641,658,675,693,711,728,747,765,783,802,821,840,860,880,899,920,940,960,981,1002,1023,1045,1067,1088,1111
mov $1,$0
add $0,2
mul $0,$1
div $0,9
|
programs/oeis/193/A193433.asm | jmorken/loda | 1 | 8752 | <gh_stars>1-10
; A193433: Sum of the divisors of n^2+1.
; 1,3,6,18,18,42,38,93,84,126,102,186,180,324,198,342,258,540,434,546,402,756,588,972,578,942,678,1332,948,1266,972,1596,1302,1980,1260,1842,1298,2484,1842,2286,1602,2613,2124,3534,2100,3042,2220,4536,2772,3606,2604,3906,3252,5076,2918,4860,3138,6552,4044,5226,3892,5586,4620,7164,4356,6342,4358,8100,5928,7146,5490,7566,6696,10584,5478,8820,5940,10692,7308,9366,6612,10476,8370,13608,7058,10842,7980,13644,9300,12636,8102,12852,10164,16182,8838,13542,9940,16956,12312,16470,10212,15306,12492,19116,11220,17100,11916,21390,14004,19236,12102,18972,16296,23004,13356,21060,13458,25326,17298,21756,14402,21966,19320,29160,15378,25284,15878,29052,20520,25596,16902,25746,23436,33480,17958,29484,18900,33804,24696,28986,20772,29826,25080,38130,21060,31542,21318,38916,28392,35316,22502,36876,27732,42156,24396,37044,24338,50220,29964,37926,25602,41916,32760,47844,28980,40842,29196,50220,35030,42846,28902,43866,36456,55944,34776,45942,30978,60984,38028,49476,32402,49146,42174,64152,33858,52140,35820,68040,42420,54756,38892,61560,45288,70200,38316,57042,39396,69876,47052,59406,45864,60606,48972,80136,41618,63042,42438,79794,55080,65526,44102,67716,55080,88200,46956,71820,52136,90072,58962,71946,50100,73266,59148,89532,50178,80460,55020,92772,64296,84756,52902,80046,66774,100440,57996,84564,55698,104328,67980,92823,57602,88236,81648,109926,61620,90042,61420,109836,73812,96300
pow $0,2
cal $0,325299 ; a(n) = 9 * sigma(n).
mov $1,$0
sub $1,9
div $1,9
add $1,1
|
dino/lcs/123p/53.asm | zengfr/arcade_game_romhacking_sourcecode_top_secret_data | 6 | 11101 | <filename>dino/lcs/123p/53.asm<gh_stars>1-10
copyright zengfr site:http://github.com/zengfr/romhack
006080 tst.b ($53,A6)
006084 ble $60e0 [123p+ 53, enemy+53]
0060E2 tst.b ($53,A6)
0060E6 ble $6146 [123p+ 53]
009C0C tst.b ($53,A6)
009C10 bge $9c20 [123p+ 53]
01302C move.b ($a,A0), ($53,A6)
013032 tst.w (A0) [123p+ 53, enemy+53, etc+53, item+53]
014136 move.b ($53,A0), D0
01413A move.w ($8,A0), D1 [123p+ 53]
014146 clr.b ($53,A0)
01414A move.w ($3c,A0), D0 [123p+ 53]
01416C move.b D0, ($53,A0)
014170 move.w D1, ($8,A0) [123p+ 53]
0142BE tst.b ($53,A0)
0142C2 beq $142d8 [123p+ 53, enemy+53, item+53]
01439C bset #$7, ($53,A0)
0143A2 btst #$5, ($25,A0) [123p+ 53, enemy+53, item+53]
014494 tst.b ($53,A0)
014498 beq $144ae [123p+ 53, enemy+53, etc+53, item+53]
01463E bset #$7, ($53,A0)
014644 btst #$5, ($25,A0) [123p+ 53, enemy+53, item+53]
014EE8 tst.b ($53,A0) [123p+ 56, enemy+56, item+56]
014EEC beq $14f06 [123p+ 53, enemy+53, item+53]
014EF0 btst #$7, ($53,A0)
014EF6 bne $14f92 [123p+ 53, enemy+53]
0192DE tst.b ($53,A6)
0192E2 beq $1931e [123p+ 53]
01A020 tst.b ($53,A6)
01A024 beq $1a064 [123p+ 53]
092E64 tst.b ($53,A6)
092E68 beq $92e76 [123p+ 53, enemy+53]
copyright zengfr site:http://github.com/zengfr/romhack
|
mat/src/frames/mat-frames.ads | stcarrez/mat | 7 | 9488 | <reponame>stcarrez/mat
-----------------------------------------------------------------------
-- mat-frames - Representation of stack frames
-- Copyright (C) 2014, 2015, 2021 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with MAT.Types;
package MAT.Frames is
Not_Found : exception;
type Frame_Type is private;
type Frame_Table is array (Natural range <>) of MAT.Types.Target_Addr;
-- Return the parent frame.
function Parent (Frame : in Frame_Type) return Frame_Type;
-- Returns the backtrace of the current frame (up to the root).
-- When <tt>Max_Level</tt> is positive, limit the number of PC frames to the value.
function Backtrace (Frame : in Frame_Type;
Max_Level : in Natural := 0) return Frame_Table;
-- Returns all the direct calls made by the current frame.
function Calls (Frame : in Frame_Type) return Frame_Table;
-- Returns the number of children in the frame.
-- When recursive is true, compute in the sub-tree.
function Count_Children (Frame : in Frame_Type;
Recursive : in Boolean := False) return Natural;
-- Returns the current stack depth (# of calls from the root
-- to reach the frame).
function Current_Depth (Frame : in Frame_Type) return Natural;
-- Find the child frame which has the given PC address.
-- Returns that frame pointer or raises the Not_Found exception.
function Find (Frame : in Frame_Type;
Pc : in MAT.Types.Target_Addr) return Frame_Type;
-- Check whether the frame contains a call to the function described by the address range.
function In_Function (Frame : in Frame_Type;
From : in MAT.Types.Target_Addr;
To : in MAT.Types.Target_Addr) return Boolean;
-- Check whether the inner most frame contains a call to the function described by
-- the address range. This function looks only at the inner most frame and not the
-- whole stack frame.
function By_Function (Frame : in Frame_Type;
From : in MAT.Types.Target_Addr;
To : in MAT.Types.Target_Addr) return Boolean;
private
type Frame;
type Frame_Type is access all Frame;
-- The frame information is readonly and we can safely use the By_Function, In_Function
-- and Backtrace without protection. Insertion and creation of stack frame must be
-- protected through a protected type managed by Target_Frames. All the frame instances
-- are released when the Target_Frames protected type is released.
type Frame (Parent : Frame_Type;
Depth : Natural;
Pc : MAT.Types.Target_Addr) is limited
record
Next : Frame_Type := null;
Children : Frame_Type := null;
Used : Natural := 0;
end record;
-- Create a root for stack frame representation.
function Create_Root return Frame_Type;
-- Insert in the frame tree the new stack frame represented by <tt>Pc</tt>.
-- If the frame is already known, the frame reference counter is incremented.
-- The frame represented by <tt>Pc</tt> is returned in <tt>Result</tt>.
procedure Insert (Frame : in Frame_Type;
Pc : in Frame_Table;
Result : out Frame_Type);
-- Destroy the frame tree recursively.
procedure Destroy (Frame : in out Frame_Type);
end MAT.Frames;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.