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/039/A039216.asm | karttu/loda | 0 | 2673 | <reponame>karttu/loda<gh_stars>0
; A039216: Numbers n such that representation in base 12 has the same number of 0's and 7's.
; 1,2,3,4,5,6,8,9,10,11,13,14,15,16,17,18,20,21,22,23,25,26,27,28,29,30,32,33,34,35,37,38,39,40,41,42,44,45,46,47,49,50,51,52,53,54,56,57,58,59,61,62,63,64,65,66,68,69,70,71,73,74,75,76,77,78,80,81,82,83
mov $1,$0
div $0,2
mul $0,2
div $0,5
add $1,$0
add $1,1
|
ffight/lcs/1p/5C.asm | zengfr/arcade_game_romhacking_sourcecode_top_secret_data | 6 | 81736 | copyright zengfr site:http://github.com/zengfr/romhack
00A0DA movea.l ($e,PC,D0.w), A0 [1p+5C, 1p+5E]
00A2AC add.l D0, ($5c,A4) [1p+1C]
00A2B0 addi.l #$60, ($5c,A4) [1p+5C, 1p+5E]
00A2B8 rts [1p+5C, 1p+5E]
00A2C6 dbra D0, $a2c0
copyright zengfr site:http://github.com/zengfr/romhack
|
archive/agda-1/FindTermNode.agda | m0davis/oscar | 0 | 10048 | <reponame>m0davis/oscar
{-# OPTIONS --allow-unsolved-metas #-}
module FindTermNode where
open import TermNode
open import OscarPrelude
record FindTermNode (A : Set) : Set
where
field
findTermNode : A → TermNode → Maybe TermNode
open FindTermNode ⦃ … ⦄ public
open import TermCode
open import Term
open import Element
instance
FindTermNodeTermCode : FindTermNode TermCode
FindTermNode.findTermNode FindTermNodeTermCode termCode record { children = [] ; number = number₁ } = nothing
FindTermNode.findTermNode FindTermNodeTermCode termCode 𝔫@record { children = ((fst₁ , snd₁) ∷ children₁) ; number = number₁ } = ifYes fst₁ ≟ termCode then just snd₁ else findTermNode termCode record 𝔫 { children = children₁ }
FindTermNodeTermCodes : FindTermNode (List TermCode)
FindTermNode.findTermNode FindTermNodeTermCodes [] node = just node
FindTermNode.findTermNode FindTermNodeTermCodes (x ∷ termCodes) node = join $ findTermNode termCodes <$> findTermNode x node
FindTermNodeTerm : FindTermNode Term
FindTermNode.findTermNode FindTermNodeTerm term node = findTermNode (encodeTerm term) node
-- This is starting to get difficult. We need Agda to know that the Term is encoded in the TermNode. Then we can drop the Maybe
getInterpretationOfTerm : Term → TermNode → Maybe Element
getInterpretationOfTerm τ node = ⟨_⟩ ∘ number <$> findTermNode (encodeTerm τ) node
open import Membership
FindTermNodeTermCode-ok : ∀ {𝔠 𝔫} → 𝔠 child∈ 𝔫 → IsJust (findTermNode 𝔠 𝔫)
FindTermNodeTermCode-ok {𝔠} {record { children = [] ; number = number₁ }} ()
--FindTermNodeTermCode-ok {𝔠} {record { children = (fst₁ , snd₁) ∷ children₁ ; number = number₁ }} x₁ = case (fst₁ ≟_) 𝔠 , graphAt {B = λ 𝑐 → Dec (fst₁ ≡ 𝑐)} (fst₁ ≟_) 𝔠 of λ { (yes x , snd₂) → {!!} ; (no x , snd₂) → {!!}} --λ { ((yes ===) , (inspect s1)) → {!!} ; ((no =n=) , inspect s2) → {!!} }
--FindTermNodeTermCode-ok {𝔠} {record { children = (fst₁ , snd₁) ∷ children₁ ; number = number₁ }} x₁ = case fst₁ ≟ 𝔠 of λ { (yes refl) → {!!} ; (no x) → {!!}}
FindTermNodeTermCode-ok {𝔠} {record { children = (fst₁ , snd₁) ∷ children₁ ; number = number₁ }} x₁ with fst₁ ≟ 𝔠
FindTermNodeTermCode-ok {𝔠} {record { children = (fst₁ , snd₁) ∷ children₁ ; number = number₁ }} x₁ | yes eq2 = tt
FindTermNodeTermCode-ok {.fst₁} {record { children = (fst₁ , snd₁) ∷ children₁ ; number = number₁ }} (zero) | no neq = ⊥-elim (neq refl)
FindTermNodeTermCode-ok {𝔠} {𝔫@record { children = (fst₁ , snd₁) ∷ children₁ ; number = number₁ }} (suc x₁) | no neq = FindTermNodeTermCode-ok {𝔫 = record 𝔫 { children = children₁ }} x₁
Justified : ∀ {a} {A : Set a} → (m : Maybe A) → IsJust m → ∃ λ x → m ≡ just x
Justified nothing ()
Justified (just x) x₁ = _ , refl
open import FunctionName
open import Vector
storeTerm-ok : ∀ τ 𝔫 𝔑 → IsJust (findTermNode τ (snd (runIdentity (runStateT (runStateT (storeTerm τ) 𝔑) 𝔫))))
storeTerm-ok (variable 𝑥) 𝔫 𝔑 with variable 𝑥 child∈? 𝔫
storeTerm-ok (variable 𝑥) 𝔫 𝔑 | no x with TermCode.variable 𝑥 ≟ variable 𝑥
storeTerm-ok (variable 𝑥) 𝔫 𝔑 | no x | yes _ = tt
storeTerm-ok (variable 𝑥) 𝔫 𝔑 | no x | no variable𝑥≢variable𝑥 = ⊥-elim (variable𝑥≢variable𝑥 refl)
--storeTerm-ok (variable 𝑥) 𝔫 𝔑 | yes vx∈𝔫 rewrite setGet-ok 𝔫 vx∈𝔫 = {!𝔫!}
storeTerm-ok (variable 𝑥) record { children = [] ; number = number₁ } 𝔑 | yes ()
--storeTerm-ok x@(variable 𝑥) 𝔫@record { children = ((fst₁ , snd₁) ∷ children₁) ; number = number₁ } 𝔑 | yes vx∈𝔫 rewrite setGet-ok 𝔫 vx∈𝔫 = {!!}
storeTerm-ok x@(variable 𝑥) 𝔫@record { children = ((fst₁ , snd₁) ∷ children₁) ; number = number₁ } 𝔑 | yes vx∈𝔫 rewrite setGet-ok 𝔫 vx∈𝔫 with fst₁ ≟ variable 𝑥
storeTerm-ok x@(variable 𝑥) 𝔫@record { children = ((fst₁ , snd₁) ∷ children₁) ; number = number₁ } 𝔑 | yes vx∈𝔫 | yes eq = tt
--… | no neq = case vx∈𝔫 of λ { (here .(map fst children₁)) → ⊥-elim (neq refl) ; (there .fst₁ asdf) → case graphAt FindTermNodeTermCode-ok asdf of λ { (ingraph sss) → {!!} } } -- storeTerm-ok x {!record 𝔫 { children = children₁ }!} 𝔑 -- x record 𝔫 { children = children₁ } 𝔑
--… | no neq = case vx∈𝔫 of λ { (here .(map fst children₁)) → ⊥-elim (neq refl) ; (there .fst₁ asdf) → case inspect $ FindTermNodeTermCode-ok {𝔫 = record 𝔫 { children = children₁ }} asdf of λ { (.(FindTermNodeTermCode-ok asdf) , ingraph refl) → {!!}} } -- storeTerm-ok x {!record 𝔫 { children = children₁ }!} 𝔑 -- x record 𝔫 { children = children₁ } 𝔑
storeTerm-ok x@(variable 𝑥) 𝔫@record { children = ((fst₁ , snd₁) ∷ children₁) ; number = number₁ } 𝔑 | yes vx∈𝔫 | no neq with vx∈𝔫
storeTerm-ok x@(variable 𝑥) 𝔫@record { children = ((fst₁ , snd₁) ∷ children₁) ; number = number₁ } 𝔑 | yes vx∈𝔫 | no neq | zero = ⊥-elim (neq refl)
--storeTerm-ok x@(variable 𝑥) 𝔫@record { children = ((fst₁ , snd₁) ∷ children₁) ; number = number₁ } 𝔑 | yes vx∈𝔫 | no neq | there dfdsf fdsdfs with FindTermNodeTermCode-ok {𝔫 = record 𝔫 { children = children₁ }} fdsdfs | graphAt (FindTermNodeTermCode-ok {𝔫 = record 𝔫 { children = children₁ }}) fdsdfs
--… | frfrrf | ingraph tttttt = transport _ (snd $ Justified (FindTermNode.findTermNode FindTermNodeTermCode (variable 𝑥) (record { children = children₁ ; number = number₁ })) (FindTermNodeTermCode-ok {𝔫 = record 𝔫 { children = children₁ }} fdsdfs)) _
storeTerm-ok x@(variable 𝑥) 𝔫@record { children = ((fst₁ , snd₁) ∷ children₁) ; number = number₁ } 𝔑 | yes vx∈𝔫 | no neq | suc fdsdfs rewrite (snd $ Justified (FindTermNode.findTermNode FindTermNodeTermCode (variable 𝑥) (record { children = children₁ ; number = number₁ })) (FindTermNodeTermCode-ok {𝔫 = record 𝔫 { children = children₁ }} fdsdfs)) = tt
storeTerm-ok (function 𝑥 𝑎) 𝔫 𝔑 with (function 𝑥 (arity 𝑎)) child∈? 𝔫
storeTerm-ok (function 𝑥 ⟨ ⟨ [] ⟩ ⟩) 𝔫 𝔑 | no x with Eq._==_ EqFunctionName ⟨ name 𝑥 ⟩ ⟨ name 𝑥 ⟩
storeTerm-ok (function 𝑥 ⟨ ⟨ [] ⟩ ⟩) 𝔫 𝔑 | no x | (yes refl) = tt
… | no neq = ⊥-elim (neq refl)
--storeTerm-ok τ₀@(function 𝑓 ⟨ τ₁ ∷ τ₂s ⟩) 𝔫 𝔑 | no 𝔠₁∉𝔫 = {!τ₁!}
storeTerm-ok (function 𝑓₀ ⟨ ⟨ variable 𝑥 ∷ [] ⟩ ⟩) 𝔫 𝔑 | no 𝔠₁∉𝔫 with variable 𝑥 child∈? 𝔫
storeTerm-ok (function 𝑓₀ ⟨ ⟨ variable 𝑥 ∷ [] ⟩ ⟩) 𝔫 𝔑 | no 𝔠₀∉𝔫 | (yes 𝔠₁∈𝔫) with 𝑓₀ ≟ 𝑓₀
storeTerm-ok (function 𝑓₀ ⟨ ⟨ variable 𝑥 ∷ [] ⟩ ⟩) 𝔫 𝔑 | no 𝔠₀∉𝔫 | (yes 𝔠₁∈𝔫) | yes refl with TermCode.variable 𝑥 ≟ variable 𝑥
storeTerm-ok (function 𝑓₀ ⟨ ⟨ variable 𝑥 ∷ [] ⟩ ⟩) 𝔫 𝔑 | no 𝔠₀∉𝔫 | (yes 𝔠₁∈𝔫) | yes refl | yes eq = tt
storeTerm-ok (function 𝑓₀ ⟨ ⟨ variable 𝑥 ∷ [] ⟩ ⟩) 𝔫 𝔑 | no 𝔠₀∉𝔫 | (yes 𝔠₁∈𝔫) | yes refl | no neq = ⊥-elim (neq refl)
storeTerm-ok (function 𝑓₀ ⟨ ⟨ variable 𝑥 ∷ [] ⟩ ⟩) 𝔫 𝔑 | no 𝔠₀∉𝔫 | (yes 𝔠₁∈𝔫) | no neq = ⊥-elim (neq refl)
storeTerm-ok (function 𝑓₀ ⟨ ⟨ variable 𝑥₁ ∷ [] ⟩ ⟩) 𝔫 𝔑 | no 𝔠₀∉𝔫 | (no 𝔠₁∉𝔫) with 𝑓₀ ≟ 𝑓₀
storeTerm-ok (function 𝑓₀ ⟨ ⟨ variable 𝑥₁ ∷ [] ⟩ ⟩) 𝔫 𝔑 | no 𝔠₀∉𝔫 | (no 𝔠₁∉𝔫) | yes refl with TermCode.variable 𝑥₁ ≟ variable 𝑥₁
storeTerm-ok (function 𝑓₀ ⟨ ⟨ variable 𝑥₁ ∷ [] ⟩ ⟩) 𝔫 𝔑 | no 𝔠₀∉𝔫 | (no 𝔠₁∉𝔫) | yes refl | yes 𝔠₁≡𝔠₁ = tt
storeTerm-ok (function 𝑓₀ ⟨ ⟨ variable 𝑥₁ ∷ [] ⟩ ⟩) 𝔫 𝔑 | no 𝔠₀∉𝔫 | (no 𝔠₁∉𝔫) | yes refl | no 𝔠₁≢𝔠₁ = ⊥-elim (𝔠₁≢𝔠₁ refl)
storeTerm-ok (function 𝑓₀ ⟨ ⟨ variable 𝑥₁ ∷ [] ⟩ ⟩) 𝔫 𝔑 | no 𝔠₀∉𝔫 | (no 𝔠₁∉𝔫) | no 𝑓₀≢𝑓₀ = ⊥-elim (𝑓₀≢𝑓₀ refl) -- rewrite setGet-ok 𝔫 𝔠₁∈𝔫
storeTerm-ok (function 𝑓₀ ⟨ ⟨ variable 𝑥₁ ∷ τ₂ ∷ τ₃s ⟩ ⟩) 𝔫 𝔑 | no 𝔠₀∉𝔫 with variable 𝑥₁ child∈? 𝔫
storeTerm-ok (function 𝑓₀ ⟨ ⟨ variable 𝑥₁ ∷ τ₂ ∷ τ₃s ⟩ ⟩) 𝔫 𝔑 | no 𝔠₀∉𝔫 | yes 𝔠₁∈𝔫 = {!!}
storeTerm-ok (function 𝑓₀ ⟨ ⟨ variable 𝑥₁ ∷ τ₂ ∷ τ₃s ⟩ ⟩) 𝔫 𝔑 | no 𝔠₀∉𝔫 | no 𝔠₁∉𝔫 = {!!}
storeTerm-ok τ₀@(function 𝑓₀ ⟨ ⟨ function 𝑓₁ τ₁s ∷ τ₂s ⟩ ⟩) 𝔫 𝔑 | no 𝔠₁∉𝔫 = {!!}
storeTerm-ok (function 𝑥 x₁) 𝔫 𝔑 | yes x = {!!}
mutual
storeTermVerifiably' : (τ : Term) → StateT Nat (StateT (Σ TermNode λ n → IsJust (findTermNode τ n)) Identity) ⊤
storeTermVerifiably' (variable x) = {!!}
storeTermVerifiably' (function x x₁) = {!!}
storeTermVerifiably : Term → StateT Nat (StateT TermNode Identity) ⊤
storeTermVerifiably τ@(variable _) = storeTermCodes' (encodeTerm τ)
storeTermVerifiably τ@(function _ τs) = storeTermCodes' (encodeTerm τ) ~| storeTermsVerifiably τs
storeTermsVerifiably : Terms → StateT Nat (StateT TermNode Identity) ⊤
storeTermsVerifiably ⟨ ⟨ [] ⟩ ⟩ = return tt
storeTermsVerifiably ⟨ ⟨ τ ∷ τs ⟩ ⟩ = storeTermVerifiably τ ~| storeTermsVerifiably ⟨ ⟨ τs ⟩ ⟩ ~| return tt
|
Source/b1u.asm | Prof9/Boktai-Solar-Sensor-Patches | 55 | 23480 | <filename>Source/b1u.asm<gh_stars>10-100
.gba
.open "Clean\Boktai 1 (U).gba","Boktai 1 (U)(Hack).gba",0x08000000
.org 0x080000D4 // sunlight changer
.area 0xCC
ldr r0,=3004508h
ldr r0,[r0] // r0 = sunlight
bl 80123F0h // r0 = amount of bars
ldr r1,=3004450h
ldrh r2,[r1] // r2 = BUTTON_HELD
ldrh r1,[r1,2h] // r1 = BUTTON_DOWN
ldr r3,=101h
and r2,r3
cmp r2,r3 // if R+A held
bne @@sunwrite
@@righttest:
mov r3,10h
tst r1,r3
beq @@lefttest
cmp r0,8h
bge @@sunwrite
add r0,1h
@@lefttest:
mov r3,20h
tst r1,r3
beq @@sunwrite
cmp r0,0h
ble @@sunwrite
sub r0,1h
@@sunwrite:
add r3,=dataarea
ldrb r3,[r3,r0]
ldr r1,=3004508h
str r3,[r1]
@@end:
pop r15
.pool
dataarea:
dcb 0x00,0x04,0x0B,0x14,0x1F,0x2F,0x4D,0x77,0x8C
.endarea
.org 0x081C03BC // hook
bl 80000D4h
.org 0x080123F4 // treat negative as empty gauge
bgt 80123FAh
.org 0x0801243C // treat negative as empty gauge
bgt 8012442h
.org 0x080124AE // skip sunlight value adjustment
b 80124CEh
.org 0x080122C8 // set default sensor calibration value
mov r0,0E6h
nop
.org 0x081C51B8 // stop sensor from saving sunlight value
nop
.org 0x081C5034 // skip solar sensor reset
nop
.org 0x081C5254 // skip solar sensor reset
nop
.org 0x081C5288 // skip solar sensor reset
nop
.org 0x0804504A // kill "Solar Sensor is broken" screen
b 80450C8h
.close |
c.adb | mikequentel/c2ada | 4 | 8444 | with Ada.Unchecked_Conversion;
package body C is
use Interfaces.C;
function U is new Ada.Unchecked_Conversion (Int, Unsigned);
function I is new Ada.Unchecked_Conversion (Unsigned, Int);
function Bool_to_Int (Val: Boolean) return Int is
begin
if Val = False then return 0; else return 1; end if;
end Bool_to_Int;
function Sizeof (Bits: Integer) return Int is
begin
return Int(Bits/System.Storage_Unit);
end Sizeof;
procedure Call (Ignored_Function_Result: Int) is
begin
null;
end Call;
procedure Call (Ignored_Function_Result: Charp) is
begin
null;
end Call;
function "+" (C: char; I: Int) return char is
begin
return char'val(Int(char'pos(C)) + I);
end "+";
function "+" (C: char; I: Int) return Int is
begin
return (char'pos(C) + I);
end "+";
function To_C (C: Character) return Interfaces.C.Char is
begin
return Interfaces.C.Char'Val(Character'Pos(C));
end To_C;
end C;
|
fallingblocks.asm | soiaf/FallingBlocks | 20 | 246840 | ;
; FallingBlocks.asm
;
; Copyright (c) 2015-2016 <NAME>
;
; All Rights Reserved.
;
; Distributed under the BSD Software License (see license.txt)
;
;
org 24576
; set up our own routines. Two elements, a table that points to where the interrupt code is
; held and the actual interrupt code itself. Due to the strange way interrupts work on spectrum
; our table is a series of the value 200. The idea is that an interrupt call would randomly jump
; to somewhere in this table and read the values 200 (2 reads) 0 this gives a memory location of
; (200*256) + 200 = 51400, which is where we will put our actual interrupt routine
; We put our table out of the way, starting at 65024 (which is 256 * 254)
di ; we are setting up out own interrupt routine, disable while doing this
ld a,254 ; high byte of pointer table location (256 * 254 gives 65024).
ld i,a ; set high byte.
im 2 ; select interrupt mode 2.
ei ; enable interrupts.
jp START
graphics
defb 254, 126, 190, 94, 174, 86, 170, 0 ; basic block
defb 126, 129, 189, 165, 165, 189, 129, 126 ; old side wall graphic
defb 231, 231, 231, 231, 231, 231, 231, 231 ;vertical pipe
defb 60, 126, 126, 231, 231, 231, 231, 231 ;pipe end (top)
defb 231, 231, 231, 231, 231, 126, 126, 60 ; pipe end (bottom)
defb 255, 255, 255, 0, 0, 255, 255, 255 ;horizontal pipe
defb 231, 231, 227, 224, 240, 255, 127, 63 ; pipe corner bottom left
defb 63, 127, 255, 240, 224, 227, 231, 231 ; pipe corner top left
defb 231, 231, 199, 7, 15, 255, 254, 252 ; pipe corner bottom right
defb 252, 254, 255, 15, 7, 199, 231, 231 ; pipe corner top right
defb 8, 4, 2, 255, 2, 4, 8, 0, 56 ; arrow pointing right
;Port array used for the redefine keys routine
port_array: defb $7f ; B-SPACE
defb $bf ; H-ENTER
defb $df ; Y-P
defb $ef ; 6-0
defb $f7 ; 1-5
defb $fb ; Q-T
defb $fd ; A-G
defb $fe ; CAPS-V
key_music_port: defb $7f
key_music_pattern: defb 4
key_left_port: defb $df
key_left_pattern: defb 2
key_right_port: defb $df
key_right_pattern: defb 1
key_anticlockwise_port: defb $7f
key_anticlockwise_pattern: defb 1
key_clockwise_port: defb $bf
key_clockwise_pattern: defb 16
key_drop_port: defb $fd
key_drop_pattern: defb 4
key_ghost_port: defb $fd
key_ghost_pattern: defb 16
key_swap_port: defb $fd
key_swap_pattern: defb 2
ROM_CLS: EQU 3435
CHAN_OPEN: EQU 5633
CC_INK: EQU 16
CC_PAPER: EQU 17
CC_AT: EQU 22
msg_left: defm CC_INK,4,CC_AT,7,8,"Left ?",255
msg_right: defm CC_INK,4,CC_AT,8,8,"Right ?",255
msg_anticlockwise: defm CC_INK,4,CC_AT,9,8,"Anti Clockwise ?",255
msg_clockwise: defm CC_INK,4,CC_AT,10,8,"Clockwise ?",255
msg_drop: defm CC_INK,4,CC_AT,11,8,"Drop ?",255
msg_ghost: defm CC_INK,4,CC_AT,12,8,"Ghost ?",255
msg_swap: defm CC_INK,4,CC_AT,13,8,"Swap/Save ?",255
msg_music: defm CC_INK,4,CC_AT,14,8,"Music On/Off ?",255
msg_define: defm CC_INK,4,CC_AT,1,7,"Press key for ...",255
msg_gameover_score: defm CC_INK,7,CC_AT,17,10,"Your score",255
msg_gameover_newhighscore defm CC_INK,4,CC_AT,21,0,"Congratulations! New high score",255
msg_newscreen_level defm CC_INK,7,CC_AT,12,12,"Level ",255
startx defb 0 ; all blocks start at this position
starty defb 15 ; all blocks start at this position
upsidedownstartx defb 20 ; starting x position if upside down
nextblockx defb 11 ;x position of the next block space
nextblocky defb 25 ;y position of the next block space
scorex defb 4 ;x position where we write the score
scorey defb 25 ; y position where we write the score
highscorex defb 4 ; x position where we write the high score
highscorey defb 3 ; y position where we write the high score
savedblockx defb 11 ;x position of the saved block space
savedblocky defb 4 ;y position of the saved block space
ghostx defb 0 ;x position of the ghost shape
ghosty defb 15 ;y position of the ghost shape
linesx defb 18 ; x position of where we write the lines completed
linesy defb 25 ; y position of where we write the lines completed
shootingstarx defb 0 ; x position of the star
shootingstary defb 0 ; y position of the star
; holds the row that will be shifted one column left or right
slidingrow defb 0
; sliding attempt counter. We try 20 times to find a row to slide, but if not we exit
; this is to prevent the (unlikely) case of no pieces currently being on the playarea
slidingcounter defb 0
; when we slide a row we wrap around the blocks, this holds the value of the wrapped around block
slidingwraparoundcolour defb 0
; this is the temp holder for colours used in the sliding floors routine
slidingtempcolour defb 0
; This holds the colour of the ghost shape (bright white)
ghostcolour defb 71
; this is used for determining whether the ghost is actually showing, for example may not be
; due to shape being too near the top of the piled blocks
ghostshowing defb 0
; This defines the top line starting position, this is used when erasing the line
; after a winning line is detected
playareatoplinex defb 0
playareatopliney defb 12
upsidedownplayareatoplinex defb 21 ; top line when upside down
plx defb 4 ; player's x coordinate.
ply defb 4 ; player's y coordinate.
tmpx defb 16
tmpy defb 16
wallpos defb 3
shapedata
defb 15,0 ; shape 1
defb 68,68
defb 15,0
defb 68,68
defb 142,0 ; shape 2
defb 68,192
defb 14,32
defb 200,128
defb 46,0 ;shape 3
defb 196,64
defb 232,0
defb 136,192
defb 204,0 ;shape 4
defb 204,0
defb 204,0
defb 204,0
defb 108,0 ; shape 5
defb 140,64
defb 108,0
defb 140,64
defb 78,0 ; shape 6
defb 76,64
defb 14,64
defb 140,128
defb 198,0 ; shape 7
defb 76,128
defb 198,0
defb 76,128 ; this is the end of the standard blocks
defb 72,0 ;shape 8
defb 132,0
defb 72,0
defb 132,0
defb 200,192 ;shape 9
defb 174,0
defb 196,192
defb 14,160
defb 12,0 ; shape 10
defb 68,0
defb 12,0
defb 68,0
defb 164,0 ; shape 11
defb 132,128
defb 74,0
defb 72,64
defb 78,64 ; shape 12
defb 78,64
defb 78,64
defb 78,64
; this holds the offset for ghost. Basically it is the number of increments you would
; need to take for a shape to be no longer blocking itself
ghostoffset
defb 1,4,1,4
defb 2,3,2,3
defb 2,3,2,3
defb 2,2,2,2
defb 2,2,2,2
defb 2,3,2,3
defb 2,2,2,2
defb 1,1,1,1
defb 3,2,3,2
defb 1,2,1,2
defb 1,3,1,3
defb 3,3,3,3
; this table helps find the correct ghost offset
ghostlookuptable defb 0,4,8,12,16,20,24,28,32,36,40,44
; ghost offset value pointer
ghostpointer defb 0
; this gives the colour of each of the shapes
colourlookuptable defb 5,1,67,6,4,3,2,66,68,69,70,65
blockshapes defb 142,0
; this holds the current shape being shown
currentshape defb 3
; this holds the next shape that will be played
nextshape defb 2
; this holds the saved shape
savedshape defb 0
currentorientation defb 0
blockpointer defb 0
blocklookuptable defb 0,8,16,24,32,40,48,56,64,72,80,88
; this is the number of complete lines required to win each level
linesneededperlevel defb 10,6,6,5,4,8,5,5,4,25
;linesneededperlevel defb 1,3,4,1,1,1,1,1,1,1
; this holds what level the player is currently on
currentlevel defb 1
; this holds the total number of lines completed so far this level
totalrowscompleted defb '00'
; this holds the total number of lines completed so far this level (as a number)
totalrowscompletednum defb 0
; this holds the lines target for this level (as a string)
targetlinesforthislevel defb '00'
; this holds the lines target for this level (as a number)
targetlinesforthislevelnum defb 0
; this is the colour of the shape currently being played
blockcolour defb 5
; this is the colour used by showshape when showing a shape onscreen
drawcolour defb 0
; this holds the current number of complete lines we have made this level
completedlines defb 0
; this is set to 1 when a winning/complete line is detected
winningline defb 0
; when flashing a winning line, or then erasing it, this sets the colour
winninglinecolour defb 130 ; flashing red
; holds the score
score defb '000000'
; holds the high score
highscore defb '001250'
; shows whether a new high score has been set
newhighscore defb 0
; this holds whether the level is upside down (i.e. falls up rather than usual down)
upsidedown defb 0
; a value of 1 means allowed move
allowedmove defb 1
; a player is only allowed swap once (till the next shape is automatically picked)
; a value of 1 means they are allowed swap, otherwise they are not
allowedswap defb 1
; rows completed holds the number of rows filled, bonus points for 4
rowscompleted defb 0
; this holds the number of pieces played this level
piecesthislevel defb 0
; ghost active. 0 is off, 1 is on. This determines whether the ghost shape is shown
; The ghost shape shows where the shape would go if the player pressed drop
ghostactive defb 0
; this holds whether Kempston joystick support is enabled or not. Can cause
; issues if activated when, say, emulator is not set to support it.
; 0 - disabled, 1 - enabled, 2 - not available
kemsptonactivated defb 0
; this holds the difficulty level, 0 is normal, 1 is hard
difficulty defb 0
; this holds the mainmenu option pointer. If joystick is available then this is the option
; the arrow is pointing at
mainmenuoptionpointer defb 0
; this holds the current settings option pointer. If joystick is available then this is the option
; the arrow is pointing at
settingsmenuoptionpointer defb 0
; this holds the mainmenu option chosen.
mainmenuoptionchosen defb 0
; this holds the current settings option chosen.
settingsmenuoptionchosen defb 0
; this holds the colour of the arrow that points at the menu options
arrowcolour defb 2
; this holds the current x position of the arrow
arrowxpos defb 18
; timer used when deciding to auto drop the block
pretim defb 0
; this holds whether in game music is wanted/enabled (by the player)
gamemusicenabled defb 1
; drop method. When set to 0 if the player presses drop then the piece drops in one go as
; far as it can. If set to 1 then the piece only goes down while the player holds the key
; when set to 1 acts like a 'down' key rather than a drop
; when set to 2, it acts like a mixture. A quick tap causes the piece to drop down fully,
; while holding it down causes it to act like a 'down' key.
dropmethod defb 0
; this is used when the dropmethod is set to 2, used in the case when we want to say drop full
fulldropactive defb 0
; as we support key repeat, this is used to show when it is the first call of the key within a
; possible repeat series. Holds the number of repeated key presses
keypresscount defb 0
; this holds the number of repeated joystick fire button presses
firebuttoncount defb 0
; this holds the key press sensitivity, essentially this is the delay between keypress repeat
; 0 is fast, 1 is normal, 2 is slow
sensitivity defb 1
randomtable:
db 82,97,120,111,102,116,20,12
; holds a value for last action/key pressed.
; a bit is set corresponding to the action done
lastkeypressed defb 0
; holds a value for last joystick action done
; a bit is set corresponding to the action done
lastjoystick defb 0
;; this mask determines if simultaneous key presses are allowed. Set to 255 to allow
keypressmask defb 0
msg_menu_copyright: defm CC_INK,7,CC_AT,13,4,"(c)2015 <NAME>",255
msg_menu_startgame: defm CC_INK,7,CC_AT,18,4,"1 Start Game",255
msg_menu_definekeys: defm CC_INK,7,CC_AT,19,4,"2 Define Keys",255
msg_menu_kempston: defm CC_INK,7,CC_AT,20,4,"3 Kempston Joystick",255
msg_menu_settings: defm CC_INK,7,CC_AT,21,4,"4 Settings",255
msg_menu_kempston_on: defm CC_INK,4,CC_AT,20,23,"(On) ",255
msg_menu_kempston_off: defm CC_INK,2,CC_AT,20,23,"(Off)",255
msg_menu_kempston_na: defm CC_INK,2,CC_AT,20,23,"(n/a)",255 ; we detect if a kempston joystick is present, if not show this
;settings menu text
msg_menu_difficulty: defm CC_INK,7,CC_AT,10,4,"1 Difficulty",255
msg_menu_difficulty_normal: defm CC_INK,4,CC_AT,10,16,"(Normal) ",255
msg_menu_difficulty_hard: defm CC_INK,2,CC_AT,10,16,"(Hard) ",255
msg_menu_dropmethod: defm CC_INK,7,CC_AT,11,4,"2 Drop Method",255
msg_menu_dropmethod_normal: defm CC_INK,4,CC_AT,11,17,"(Full) ",255
msg_menu_dropmethod_likedown: defm CC_INK,2,CC_AT,11,17,"(While Held)",255
msg_menu_dropmethod_mixture: defm CC_INK,6,CC_AT,11,17,"(Mixture) ",255
msg_menu_sensitivity: defm CC_INK,7,CC_AT,12,4,"3 Control Response",255
msg_menu_sensitivity_fast: defm CC_INK,4,CC_AT,12,22,"(Fast) ",255
msg_menu_sensitivity_normal: defm CC_INK,6,CC_AT,12,22,"(Normal)",255
msg_menu_sensitivity_slow: defm CC_INK,2,CC_AT,12,22,"(Slow) ",255
msg_menu_simultaneous: defm CC_INK,7,CC_AT,13,4,"4 Simultaneous Keys",255
msg_menu_simultaneous_off: defm CC_INK,4,CC_AT,13,23,"(Off) ",255
msg_menu_simultaneous_on: defm CC_INK,2,CC_AT,13,23,"(On) ",255
msg_menu_back_to_main_menu: defm CC_INK,7,CC_AT,14,4,"5 Back To Main Menu",255
msg_game_score: defm CC_INK,7,CC_AT,2,25,"Score",255
msg_game_highscore: defm CC_INK,7,CC_AT,2,3,"High",255
msg_game_nextpiece: defm CC_INK,7,CC_AT,9,25,"Next",255
msg_game_savedpiece: defm CC_INK,7,CC_AT,9,3,"Saved",255
msg_game_line: defm CC_INK,7,CC_AT,16,25,"Lines",255
msg_game_ghost: defm CC_INK,7,CC_AT,16,3,"Ghost",255
msg_game_ghost_active: defm CC_INK,4,CC_AT,18,2," Active ",255
msg_game_ghost_inactive: defm CC_INK,2,CC_AT,18,2,"Inactive",255
msg_game_level1: defm CC_INK,7,CC_AT,1,8,"1 - Nice and Easy",255
msg_game_level2: defm CC_INK,7,CC_AT,1,9,"2 - Spice it up ",255
msg_game_level3: defm CC_INK,7,CC_AT,1,10,"3 - G'day Mate",255
msg_game_level4: defm CC_INK,7,CC_AT,1,8,"4 - Shooting Star",255
msg_game_level5: defm CC_INK,7,CC_AT,1,10,"5 - More Stars",255
msg_game_level6: defm CC_INK,7,CC_AT,1,11,"6 - Letter F",255
msg_game_level7: defm CC_INK,7,CC_AT,1,12,"7 - Mirror",255
msg_game_level8: defm CC_INK,7,CC_AT,1,8,"8 - Sliding Floor",255
msg_game_level9: defm CC_INK,7,CC_AT,1,10,"9 - Mix it up",255
msg_game_level10: defm CC_INK,7,CC_AT,1,9,"10 - Rising Fall",255
; date for the main falling blocks logo on the main menu page. 254 means end of line, 255 means end of data
fallingblockslogo
defb 0,0,67,67,67,0,254
defb 0,0,67,0,0,0,0,7,0,0,7,0,0,0,7,0,0,0,7,7,7,0,7,7,0,0,0,7,7,254
defb 0,0,0 ,0,0,0,7,0,3,0,5,0,0,0,7,0,0,0,0,7,0,0,7,0,5,0,7,0,0,254
defb 0,0,7 ,7,0,0,7,3,3,0,5,0,0,0,7,0,0,0,0,7,0,0,7,0,5,0,7,0,2,254
defb 0,0,7 ,0,0,0,7,0,3,0,5,0,0,0,7,0,0,0,0,7,0,0,7,0,5,0,7,0,2,254
defb 0,0,7 ,0,0,0,7,0,7,0,5,7,7,0,7,7,7,0,7,7,7,0,7,0,5,0,0,2,2,254
defb 254
defb 0,0,0,0,7,7,0,0,7,0,0,0,0,7,0,0,0,7,7,0,7,0,7,0,0,7,7,254
defb 0,0,0,0,7,0,7,0,7,0,0,0,7,0,7,0,7,0,0,0,3,0,7,0,7,0,0,254
defb 0,0,0,0,67,7,0,0,7,0,0,0,7,0,7,0,7,0,0,0,3,3,0,0,0,7,0,254
defb 0,0,0,0,67,0,7,0,2,0,0,0,7,0,7,0,7,0,0,0,3,0,7,0,0,0,7,254
defb 0,0,0,0,67,67,0,0,2,2,2,0,0,7,0,0,0,7,7,0,7,0,7,0,7,7,0,254
defb 255
gameoverlogo
defb 254,254,254 ;skip a few lines
defb 0,0,0,0,0,0,0,0,7,7,0,0,7,0,0,7,0,0,0,7,0,7,7,7,254
defb 0,0,0,0,0,0,0,7,0,0,0,7,0,7,0,7,7,0,7,7,0,7,0,0,254
defb 0,0,0,0,0,0,0,7,0,7,0,7,7,7,0,7,0,7,0,7,0,7,7,0,254
defb 0,0,0,0,0,0,0,7,0,7,0,7,0,7,0,7,0,0,0,7,0,7,0,0,254
defb 0,0,0,0,0,0,0,0,7,7,0,7,0,7,0,7,0,0,0,7,0,7,7,7,254
defb 254
defb 0,0,0,0,0,0,0,0,0,7,0,0,7,0,7,0,7,7,7,0,7,7,0,254
defb 0,0,0,0,0,0,0,0,7,0,7,0,7,0,7,0,7,0,0,0,7,0,7,254
defb 0,0,0,0,0,0,0,0,7,0,7,0,7,0,7,0,7,7,0,0,7,7,0,254
defb 0,0,0,0,0,0,0,0,7,0,7,0,0,7,0,0,7,0,0,0,7,0,7,254
defb 0,0,0,0,0,0,0,0,0,7,0,0,0,7,0,0,7,7,7,0,7,0,7,254
defb 255
youwinlogo
defb 254,254,254
defb 0,0,0,0,0,0,0,0,0,0,7,0,7,0,0,7,0,0,7,0,7,254
defb 0,0,0,0,0,0,0,0,0,0,7,0,7,0,7,0,7,0,7,0,7,254
defb 0,0,0,0,0,0,0,0,0,0,0,7,0,0,7,0,7,0,7,0,7,254
defb 0,0,0,0,0,0,0,0,0,0,0,7,0,0,7,0,7,0,7,0,7,254
defb 0,0,0,0,0,0,0,0,0,0,0,7,0,0,0,7,0,0,0,7,0,254
defb 254
defb 0,0,0,0,0,0,0,0,0,7,0,0,0,7,0,7,7,7,0,7,7,0,254
defb 0,0,0,0,0,0,0,0,0,7,0,0,0,7,0,0,7,0,0,7,0,7,254
defb 0,0,0,0,0,0,0,0,0,7,0,7,0,7,0,0,7,0,0,7,0,7,254
defb 0,0,0,0,0,0,0,0,0,7,7,0,7,7,0,0,7,0,0,7,0,7,254
defb 0,0,0,0,0,0,0,0,0,7,0,0,0,7,0,7,7,7,0,7,0,7,254
defb 255
START
; Set up the graphics.
ld de,(23675) ; address of user-defined graphics data.
ld hl, graphics
ld bc,88
ldir
BEGIN
xor a ; black ink (0) on black paper (0*8).
ld (23693),a ; set our screen colours.
call 3503 ; clear the screen.
; We also want to change the border colour
xor a ; 0 is the code for black.
call 8859 ; set border colour.
;open the upper screen for printing (channel 2)
ld a,2
call 5633
; set the main menu music to be 'If I Were A Rich Man'
ld bc,ifiwerearichman
ld (gamemusic),bc
ld a, 8
ld (musicspeed),a
xor a
ld (noteindex),a ; so music plays at start of song
ld (keypresscount),a ; so we show no keys have been pressed before
ld (firebuttoncount),a ; we reset the counter for the joystick fire button presses
ld (mainmenuoptionpointer),a ; we reset where the arrow points to on main menu
ld a,18
ld (arrowxpos),a ; start position on screen for the arrow (if kemptson available)
; before we start the main menu we need to see if a kempston joystick is
; actually there. Otherwise you can have a situation where the user enables
; kempston support but they don't actually have one and strange things happen
; during the game :) This is due to floating bus values
halt
in a,(31) ;read kempston joystick port directly after HALT
and 31
ld b,a ; backup value of a in register b for later usage
and 3
cp 3 ; this is equal to both left and right being active at same time, obviously should not happen with real joystick
jr z, nojoy
ld a,b ; get back that value we saved earlier
and 12
cp 12 ; 12 (8+4) is both up and down, again should not be possible
jr z, nojoy
; a joystick is available, show arrow
call drawarrow
jr mainmenu ; all good, go to main menu
nojoy
ld a,2
ld (kemsptonactivated),a ; set value to not available
mainmenu
ld hl,fallingblockslogo
call printwordswithblocks
ld hl,msg_menu_copyright
call print_message
ld hl,msg_menu_startgame
call print_message
ld hl,msg_menu_definekeys
call print_message
ld hl, msg_menu_kempston
call print_message
ld hl,msg_menu_settings
call print_message
mm11
ld a,(kemsptonactivated)
cp 0
jr z,mm6
cp 2
jr z, mm9
ld hl, msg_menu_kempston_on
call print_message
jp mm1
mm6
ld hl, msg_menu_kempston_off
call print_message
jr mm1
mm9
; kempston is not available
ld hl, msg_menu_kempston_na
call print_message
mm1
; if kempston is active, we check for up, down and fire
ld a,(kemsptonactivated)
cp 2
jp z, mmkey1
mmjoy1
; kempston is available
ld bc,31
in a,(c)
and 31 ; bitmask 5 bits
or 0
jr nz, mmjoy2
jp mmkey1 ; no joystick action
mmjoy2
ld bc,31
in a,(c) ; read input.
and 8 ; check "up" bit.
jr nz,mmjoy3 ; move up.
jr mmjoy4
mmjoy3
; move arrow up if possible
; if mainmenuoptionpointer is 0 then cannot move up
ld a,(mainmenuoptionpointer)
or 0
jp z, mmkey1 ; at top option already, jump to key read section as nothing more to do in joystick section
; possible to move up, so decrement mainmenuoptionpointer and arrowxpos
xor a
ld (arrowcolour),a
call drawarrow ; erase old arrow
ld hl,mainmenuoptionpointer
dec (hl)
ld hl,arrowxpos
dec (hl)
ld a,2
ld (arrowcolour),a
call drawarrow
call smalldelay
jr mmkey1 ; finished in joystick read section
mmjoy4
ld bc,31
in a,(c) ; read input.
and 4 ; check "down" bit.
jr nz,mmjoy5
jr mmjoy6
mmjoy5
; move arrow down if possible
; if mainmenuoptionpointer is 3 then cannot move down
ld a,(mainmenuoptionpointer)
cp 3
jr z, mmkey1 ; at bottom option already, jump to key read section as nothing more to do in joystick section
; possible to move down, so increment mainmenuoptionpointer and arrowxpos
xor a
ld (arrowcolour),a
call drawarrow ; erase old arrow
ld hl,mainmenuoptionpointer
inc (hl)
ld hl,arrowxpos
inc (hl)
ld a,2
ld (arrowcolour),a
call drawarrow
call smalldelay
jr mmkey1 ; finished in joystick read section
mmjoy6
ld bc,31
in a,(c) ; read input.
and 16 ; try the fire bit.
jr nz,mmjoy7 ; fire pressed.
jr mmkey1
mmjoy7
; fire button pressed
ld a,(mainmenuoptionpointer)
cp 1
jr nz, mmjoy8
; the key read routine actually sets all the bits to 1 except the key corresponding to key pressed
ld a,29 ; 11101
ld (mainmenuoptionchosen),a
jr mm20
mmjoy8
cp 2
jr nz, mmjoy9
ld a,27 ; 11011
ld (mainmenuoptionchosen),a
jr mm20
mmjoy9
cp 3
jr nz, mmjoy10
ld a,23 ;10111
ld (mainmenuoptionchosen),a
jr mm20
mmjoy10
; assume it is start game
ld a,30 ;11110
ld (mainmenuoptionchosen),a
jr mm20
mmkey1
;IN 63486 reads the half row 1 to 5
ld bc,63486
in a,(c)
ld (mainmenuoptionchosen),a
mm20
ld a,(mainmenuoptionchosen)
bit 0,a
jr nz,mm2
jr mm5 ;1 key pressed, start game
mm2
ld a, (mainmenuoptionchosen)
bit 1,a
jr nz,mm3
call do_the_redefine
jp BEGIN
mm3
ld a, (mainmenuoptionchosen)
bit 2,a
jr nz,mm7
ld a,(kemsptonactivated)
cp 0
jr z,mm8
cp 2
jr z,mm10
; if here then currently support enabled, so disable
xor a
ld (kemsptonactivated),a
ld hl, msg_menu_kempston_off
call print_message
call mediumdelay
jp mm13
mm8
; if here then currently support disabled, so enable
ld a,1
ld (kemsptonactivated),a
ld hl, msg_menu_kempston_on
call print_message
call mediumdelay
jr mm13
mm10
; if we are set to n/a for kempston we ignore '3' keypresses
jr mm13
mm7
ld a, (mainmenuoptionchosen)
bit 3,a ; check for keypress of number 4
jr nz,mm13
call settingsmenu
jp BEGIN ; need to reset everything after accessing settings menu
mm13
jp mm1
mm5
call 3503
jp maingame
settingsmenu
; settings menu is where difficulty level can be chosen and where the behaviour of the pieces can be altered
call ROM_CLS
xor a
ld (settingsmenuoptionpointer),a ; we reset where the arrow points to on settings menu
ld a,10
ld (arrowxpos),a ; start position on screen for the arrow on settings menu (if kemptson available)
ld hl,msg_menu_difficulty
call print_message
ld a,(difficulty)
cp 0
jr nz,setm1 ; 0 is normal difficulty
ld hl,msg_menu_difficulty_normal
call print_message
jr setm5
setm1
ld hl,msg_menu_difficulty_hard
call print_message
setm5
ld hl,msg_menu_dropmethod
call print_message
ld a,(dropmethod)
cp 0
jr z,setm20 ; 0 is normal drop method
cp 1
jr z,setm6; 1 is when acts like a down key
; otherwise we assume acting like a mixture
jr setm21
setm20
; normal drop method
ld hl,msg_menu_dropmethod_normal
call print_message
jr setm2
setm6
; when drop acts like a down key
ld hl,msg_menu_dropmethod_likedown
call print_message
jr setm2
setm21
; when drop acts like a mixture, quick tap will drop, otherwise
; holding the key down will act like a 'down' key
ld hl,msg_menu_dropmethod_mixture
call print_message
setm2
ld hl,msg_menu_sensitivity
call print_message
ld a,(sensitivity)
cp 0
jr z,setm10
cp 1
jr z,setm11
cp 2
jr z,setm12
jr setm13 ; this line should not be called, here just in case!
setm10
; sensitivity is 0, fast
ld hl, msg_menu_sensitivity_fast
call print_message
jr setm13
setm11
; sensitivity is 1, normal
ld hl, msg_menu_sensitivity_normal
call print_message
jr setm13
setm12
; sensitivity is 2, slow
ld hl, msg_menu_sensitivity_slow
call print_message
setm13
; print the simultaneous keys message
ld hl, msg_menu_simultaneous
call print_message
ld a,(keypressmask)
cp 0
jr z,setm30
cp 255
jr z,setm31
jr setm32 ; this line should not be called, here just in case!
setm30
ld hl, msg_menu_simultaneous_off
call print_message
jr setm32
setm31
ld hl, msg_menu_simultaneous_on
call print_message
setm32
; print the back to main menu message
ld hl, msg_menu_back_to_main_menu
call print_message
call mediumdelay
setm9
; if kempston is active, we check for up, down and fire
ld a,(kemsptonactivated)
cp 2
jp z, smkey1
call drawarrow
smjoy1
; kempston is available
ld bc,31
in a,(c)
and 31 ; bitmask 5 bits
or 0
jr nz, smjoy2
jp smkey1 ; no joystick action
smjoy2
ld bc,31
in a,(c) ; read input.
and 8 ; check "up" bit.
jr nz,smjoy3 ; move up.
jr smjoy4
smjoy3
; move arrow up if possible
; if settingsmenuoptionpointer is 0 then cannot move up
ld a,(settingsmenuoptionpointer)
or 0
jp z, smkey1 ; at top option already, jump to key read section as nothing more to do in joystick section
; possible to move up, so decrement settingsmenuoptionpointer and arrowxpos
xor a
ld (arrowcolour),a
call drawarrow ; erase old arrow
ld hl,settingsmenuoptionpointer
dec (hl)
ld hl, arrowxpos
dec (hl)
ld a,2
ld (arrowcolour),a
call drawarrow
call smalldelay
jr smkey1 ; finished in joystick read section
smjoy4
ld bc,31
in a,(c) ; read input.
and 4 ; check "down" bit.
jr nz,smjoy5
jr smjoy6
smjoy5
; move arrow down if possible
; if settingsmenuoptionpointer is 4 then cannot move down
ld a,(settingsmenuoptionpointer)
cp 4
jr z, smkey1 ; at bottom option already, jump to key read section as nothing more to do in joystick section
; possible to move down, so increment settingsmenuoptionpointer and arrowxpos
xor a
ld (arrowcolour),a
call drawarrow ; erase old arrow
ld hl,settingsmenuoptionpointer
inc (hl)
ld hl, arrowxpos
inc (hl)
ld a,2
ld (arrowcolour),a
call drawarrow
call smalldelay
jr smkey1 ; finished in joystick read section
smjoy6
ld bc,31
in a,(c) ; read input.
and 16 ; try the fire bit.
jr nz,smjoy7 ; fire pressed.
jr smkey1
smjoy7
; fire button pressed
ld a,(settingsmenuoptionpointer)
cp 1
jr nz, smjoy8
; the key read routine actually sets all the bits to 1 except the key corresponding to key pressed
ld a,29 ; 11101
ld (settingsmenuoptionchosen),a
jr setm24
smjoy8
cp 2
jr nz, smjoy9
ld a,27 ; 11011
ld (settingsmenuoptionchosen),a
jr setm24
smjoy9
cp 3
jr nz, smjoy10
ld a,23 ;10111
ld (settingsmenuoptionchosen),a
jr setm24
smjoy10
cp 4
jr nz, smjoy11
ld a,15 ;01111
ld (settingsmenuoptionchosen),a
jr setm24
smjoy11
; assume it is difficulty
ld a,30 ;11110
ld (settingsmenuoptionchosen),a
jr setm24
smkey1
;IN 63486 reads the half row 1 to 5
ld bc,63486
in a,(c)
ld (settingsmenuoptionchosen), a
setm24
ld a, (settingsmenuoptionchosen)
bit 0,a ; check for keypress of number 1 - difficulty
jr nz,setm4
ld a,(difficulty)
cp 0
jr nz,setm3
; difficulty is currently 0 (normal), set to 1
ld a,1
ld (difficulty),a
ld hl,msg_menu_difficulty_hard
call print_message
call mediumdelay
jp setm19
setm3
; difficulty is currently 1 (hard), set to 0
xor a
ld (difficulty),a
ld hl,msg_menu_difficulty_normal
call print_message
call mediumdelay
jp setm19
setm4
ld a, (settingsmenuoptionchosen)
bit 1,a ; check for keypress of number 2 - drop method
jr nz,setm7
ld a,(dropmethod)
cp 1
jr z,setm8 ; currently acts like down key
cp 2
jr z,setm23
setm22
; drop method is currently 0 (normal), set to 1
ld a,1
ld (dropmethod),a
ld hl,msg_menu_dropmethod_likedown
call print_message
call mediumdelay
jp setm19
setm8
; drop method is currently 1 (like down key), set to 2
ld a,2
ld (dropmethod),a
ld hl,msg_menu_dropmethod_mixture
call print_message
call mediumdelay
jp setm19
setm23
; drop method is currently 2 (mixture), set to 0
xor a
ld (dropmethod),a
ld hl,msg_menu_dropmethod_normal
call print_message
call mediumdelay
jp setm19
setm7
ld a, (settingsmenuoptionchosen)
bit 2,a ; check for keypress of number 3 - key sensitivity
jr nz,setm18
ld a,(sensitivity)
cp 0
jr z, setm14
cp 1
jr z, setm15
cp 2
jr z, setm16
jr setm19 ; this line should not be called
setm14
; sensitivity is 0, set to 1
ld a,1
ld (sensitivity),a
ld hl, msg_menu_sensitivity_normal
call print_message
call mediumdelay
jr setm19
setm15
; sensitivity is 1, set to 2
ld a,2
ld (sensitivity),a
ld hl, msg_menu_sensitivity_slow
call print_message
call mediumdelay
jr setm19
setm16
; sensitivity is 2, set to 0
xor a
ld (sensitivity),a
ld hl, msg_menu_sensitivity_fast
call print_message
call mediumdelay
jr setm19
setm18
ld a, (settingsmenuoptionchosen)
bit 4,a ; check for keypress of number 5 - back to main menu
jr nz,setm33
ret ; back to main menu
setm33
ld a, (settingsmenuoptionchosen)
bit 3,a ; check for keypress of number 4 - simultaneous keypress
jr nz,setm19
ld a,(keypressmask)
cp 0
jr z, setm34
cp 255
jr z, setm35
jr setm19 ; this line should not be called
setm34
; keypressmask is 0, set to 255
ld a,255
ld (keypressmask),a
ld hl, msg_menu_simultaneous_on
call print_message
call mediumdelay
jr setm19
setm35
; keypressmask is 255, set to 0
xor a
ld (keypressmask),a
ld hl, msg_menu_simultaneous_off
call print_message
call mediumdelay
jr setm19
setm19
jp setm2
maingame
;seed our random number generator
ld a,(23672)
and 63
ld b,a
seedgen
push bc ; have to push bc to stack as rnd changes value
call rnd
pop bc
djnz seedgen
; Need to reset the score
ld hl,score
ld (hl),'0'
inc hl
ld (hl),'0'
inc hl
ld (hl),'0'
inc hl
ld (hl),'0'
inc hl
ld (hl),'0'
inc hl
ld (hl),'0'
; ghost is set to off
xor a
ld (ghostactive),a
; set the current level to 1 (starting)
ld a,1
ld (currentlevel),a
; reset the saved shape to 0 (long bar)
xor a
ld (savedshape),a
; lets draw the screen
call newlevel
; main game loop
L7
;check key pressed
call get_keys
;The bits in A after checking keys are as follows: A = mlracdgs
main1
cp 0
jr z,nokeypressed
jr main2
nokeypressed
call droppieceiftappedkeyboard
xor a
ld (keypresscount),a
ld (lastkeypressed),a
jp joycon ;no key has been pressed so jump to joystick check part
main2
;check key for right pressed
bit 5,a
jr z,re1
; move right if valid move
push af
ld a,(lastkeypressed)
bit 5,a
jr nz,main5
call moveright
ld a,(lastkeypressed)
set 5,a ; set the 5 bit of lastkeypressed
ld (lastkeypressed),a
call smalldelay
pop af
ld b,a
ld a,(keypressmask)
and b
jp l1
main5
; if last key was right, we do not move right, but we change last key to 8
; effectively this means that right move can be made on next call, so we have
; key repeat but at a slower rate
ld a,(lastkeypressed)
res 5,a ; reset the 5 bit of lastkeypressed
ld (lastkeypressed),a
call smalldelay
pop af
ld b,a
ld a,(keypressmask)
and b
jp l1
re1
push af ; a is holding the key pressed so save to the stack
ld a,(lastkeypressed)
res 5,a ; reset the 5 bit of lastkeypressed
ld (lastkeypressed),a
pop af
l1
bit 6,a
jr z,re2
; move left if valid move
push af
ld a,(lastkeypressed)
bit 6,a
jr nz,main6
call moveleft
ld a,(lastkeypressed)
set 6,a ; set the 6 bit of lastkeypressed
ld (lastkeypressed),a
call smalldelay
pop af
ld b,a
ld a,(keypressmask)
and b
jr l2
main6
ld a,(lastkeypressed)
res 6,a ; reset the 6 bit of lastkeypressed
ld (lastkeypressed),a
call smalldelay
pop af
ld b,a
ld a,(keypressmask)
and b
jr l2
re2
push af ; a is holding the key pressed so save to the stack
ld a,(lastkeypressed)
res 6,a ; reset the 6 bit of lastkeypressed
ld (lastkeypressed),a
pop af
l2
bit 0,a
jr z,l3
; swap shape if valid move
push af
call swapshape
call smalldelay
pop af
ld b,a
ld a,(keypressmask)
and b
l3
bit 1,a
jr z,re3
push af
ld a,(lastkeypressed)
bit 1,a
jr nz,main7
call changeghostsetting
ld a,(lastkeypressed)
set 1,a ; set the 1 bit of lastkeypressed
ld (lastkeypressed),a
call smalldelay
pop af
ld b,a
ld a,(keypressmask)
and b
jr l4
main7
pop af
ld b,a
ld a,(keypressmask)
and b
jr l4
re3
push af ; a is holding the key pressed so save to the stack
ld a,(lastkeypressed)
res 1,a ; reset the 1 bit of lastkeypressed
ld (lastkeypressed),a
pop af
l4
bit 3,a
jr z,l5
push af
ld a,(lastkeypressed)
bit 3,a
jr nz, main4 ; if the last key pressed was moving clockwise then we don't turn clockwise again
call moveclockwise
ld a,(lastkeypressed)
set 3,a ; set the 3 bit of lastkeypressed
ld (lastkeypressed),a
call smalldelay
pop af
ld b,a
ld a,(keypressmask)
and b
jr l5
main4
ld a,(lastkeypressed)
res 3,a ; reset the 3 bit of lastkeypressed
ld (lastkeypressed),a
call smalldelay
pop af
ld b,a
ld a,(keypressmask)
and b
jr l5
re4
push af ; a is holding the key pressed so save to the stack
ld a,(lastkeypressed)
res 3,a ; reset the 3 bit of lastkeypressed
ld (lastkeypressed),a
pop af
l5
bit 4,a
jr z,re5
push af
ld a,(lastkeypressed)
bit 4,a
jr nz,main3
call moveanticlockwise
ld a,(lastkeypressed)
set 4,a ; set the 4 bit of lastkeypressed
ld (lastkeypressed),a
call smalldelay
pop af
ld b,a
ld a,(keypressmask)
and b
jr l6
main3
ld a,(lastkeypressed)
res 4,a ; reset the 4 bit of lastkeypressed
ld (lastkeypressed),a
call smalldelay
pop af
ld b,a
ld a,(keypressmask)
and b
jr l6
re5
push af ; a is holding the key pressed so save to the stack
ld a,(lastkeypressed)
res 4,a ; reset the 4 bit of lastkeypressed
ld (lastkeypressed),a
pop af
l6
bit 2,a
jr z,re6
push af
ld a,(keypresscount)
inc a
ld (keypresscount),a
ld a,(lastkeypressed)
bit 2,a
jr nz,main8
call droppiece
ld a,(lastkeypressed)
set 2,a ; set the 2 bit of lastkeypressed
ld (lastkeypressed),a
call mediumdelay ; drop unusual in that we do not vary delay
pop af
ld b,a
ld a,(keypressmask)
and b
jr main10 ; we skip to the end of the check keyboard key section as the drop key was pressed
main8
; if last key was drop, and our drop method is one square/down we do not drop down on square,
; but we reset bit 2 of lastkeypressed
; effectively this means that down move can be made on next call, so we have
; key repeat but at a slower rate
ld a,(dropmethod)
cp 0
jr z,main12
ld a,(lastkeypressed)
res 2,a ; reset the 2 bit of lastkeypressed
ld (lastkeypressed),a
call mediumdelay ; drop unusual in that we do not vary delay
main12
pop af
ld b,a
ld a,(keypressmask)
and b
jr main10
re6
push af ; a is holding the key pressed so save to the stack
ld a,(lastkeypressed)
res 2,a ; reset the 2 bit of lastkeypressed
ld (lastkeypressed),a
pop af
main10
bit 7,a
jr z,joycon
push af
ld a,(lastkeypressed)
bit 7,a
jr nz,main11
call switchmusiconoff
ld a,(lastkeypressed)
set 7,a ; set the 7 bit of lastkeypressed
ld (lastkeypressed),a
call smalldelay
pop af
ld b,a
ld a,(keypressmask)
and b
jr joycon
main11
pop af
ld b,a
ld a,(keypressmask)
and b
jr joycon
re7
push af ; a is holding the key pressed so save to the stack
ld a,(lastkeypressed)
res 7,a ; reset the 7 bit of lastkeypressed
ld (lastkeypressed),a
pop af
; in addition to key support, we also support Kempston joystick. On zxspin the emulator uses
; the cursor keys with CTRL (for fire)
joycon
ld a,(kemsptonactivated)
cp 2 ; if 2 (n/a) or 0 (deactivated) then skip
jp z,l9 ; if user has not activated kempston support then we skip this section
or 0
jp z,l9
ld bc,31
in a,(c)
and 31 ; bitmask 5 bits
or 0
jr nz, jc10
call droppieceiftappedjoystick
xor a
ld (lastjoystick),a
ld (firebuttoncount),a
jp l9 ; no joystick action, so skip ahead
jc10
ld bc,31 ; Kempston joystick port.
in a,(c) ; read input.
and 2 ; check "left" bit.
jr nz,jc1 ; move left.
jr jc2
jc1
ld a,(lastjoystick)
bit 2,a
jr nz,jc11
call moveleft
ld a,(lastjoystick)
set 2,a
ld (lastjoystick),a
call smalldelay
jr jc2
jc11
res 2,a
ld (lastjoystick),a
call smalldelay
jc2
ld bc,31
in a,(c) ; read input.
and 1 ; test "right" bit.
jr nz,jc3 ; move right.
jr jc4
jc3
ld a,(lastjoystick)
bit 1,a
jr nz,jc12
call moveright
ld a,(lastjoystick)
set 1,a
ld (lastjoystick),a
call smalldelay
jr jc4
jc12
res 1,a
ld (lastjoystick),a
call smalldelay
jc4
ld bc,31
in a,(c) ; read input.
and 8 ; check "up" bit.
jr nz,jc5 ; move up.
jr jc6
jc5
ld a,(lastjoystick)
bit 4,a
jr nz,jc14
call moveclockwise
ld a,(lastjoystick)
set 4,a
ld (lastjoystick),a
call smalldelay
jr jc6
jc14
res 4,a
ld (lastjoystick),a
call smalldelay
jc6
ld bc,31
in a,(c) ; read input.
and 4 ; check "down" bit.
jr nz,jc7
jr jc8
jc7
ld a,(lastjoystick)
bit 3,a
jr nz,jc15
call moveanticlockwise
ld a,(lastjoystick)
set 3,a
ld (lastjoystick),a
call smalldelay
jr jc8
jc15
res 3,a
ld (lastjoystick),a
call smalldelay
jc8
ld bc,31
in a,(c) ; read input.
and 16 ; try the fire bit.
jr nz,jc9 ; fire pressed.
jr l9
jc9
ld a,(firebuttoncount)
inc a
ld (firebuttoncount),a
ld a,(lastjoystick)
bit 5,a
jr nz,jc13
call droppiece
ld a,(lastjoystick)
set 5,a
ld (lastjoystick),a
call mediumdelay ; different (fixed) delay for drop
jr l9
jc13
ld a,(dropmethod)
cp 0
jr z,l9 ; we do not repeat keypresses when drop method is full
ld a,(lastjoystick)
res 5,a
ld (lastjoystick),a
call mediumdelay ; different (fixed) delay for drop
l9
ld a,(difficulty)
cp 0
jr nz,l14
ld hl,pretim ; previous time setting
ld a,(23672) ; current timer setting.
sub (hl) ; difference between the two.
cp 45 ; have 45 frames elapsed yet?
jr nc,l13
jr l15
l14
; difficulty hard
ld hl,pretim ; previous time setting
ld a,(23672) ; current timer setting.
sub (hl) ; difference between the two.
cp 15 ; have 15 frames elapsed yet?
jr nc,l13
jr l15
l15
jp L7 ;not time to drop piece yet, continue main loop
l13
ld hl,pretim
ld a,(23672)
ld (hl),a
call autodroppiece
call checklevelcomplete
jp L7
; random number generator
rnd:
ld hl,randomtable
rndidx:
ld bc,0 ; i
add hl,bc
ld a,c
inc a
and 7
ld (rndidx+1),a ; i = ( i + 1 ) & 7
ld c,(hl) ; y = q[i]
ex de,hl
ld h,c ; t = 256 * y
ld l,b
sbc hl,bc ; t = 255 * y
sbc hl,bc ; t = 254 * y
sbc hl,bc ; t = 253 * y
car:
ld c,0 ; c
add hl,bc ; t = 253 * y + c
ld a,h ; c = t / 256
ld (car+1),a
ld a,l ; x = t % 256
cpl ; x = (b-1) - x = -x - 1 = ~x + 1 - 1 = ~x
ld (de),a
ret
drawblock
ld a,22
rst 16
ld a,(tmpx)
rst 16
ld a,(tmpy)
rst 16
ld a,(blockcolour)
ld (23695),a ; set our temporary screen colours.
ld a,144 ; ASCII code for User Defined Graphic 'A'.
rst 16 ; draw player.
ret
drawarrow
ld a,22
rst 16
ld a,(arrowxpos)
rst 16
ld a,3 ; arrow y pos always 3
rst 16
ld a,(arrowcolour) ; arrow colour
ld (23695),a ; set our temporary screen colours.
ld a,154 ; ASCII code for User Defined Graphic 'K'.
rst 16 ; draw arrow.
ret
;erases the current shape. Same as showcurrentshape except
;colour is hardcoded to 0 (black). So, this redraws over the current
; shape in black, erasing it
erasecurrentshape
ld a,(plx)
ld (tmpx),a
ld a,(ply)
ld (tmpy),a
xor a
ld (drawcolour),a
jp showshape
; shows the current shape
showcurrentshape
ld a,(plx)
ld (tmpx),a
ld a,(ply)
ld (tmpy),a
ld a,(blockcolour)
ld (drawcolour),a
jp showshape
; this draws the ghost shape. It only draws if ghost is active
; and if calculateghostposition determines it is possible/safe to draw
showghostshape
ld a,(ghostactive)
or a
ret z ; if equal to 0 (ghost not active) then return
sgs1
call calculateghostposition
; now determine if possible to show ghost
ld a,(ghostshowing)
or a
ret z ; return if not possible to show ghost
ld a,(ghostx)
ld (tmpx),a
ld a,(ghosty)
ld (tmpy),a
ld a,(ghostcolour)
ld (drawcolour),a
jp showshape
; this erases the ghost shape. It checks ghostshowing and if set to 1
; it erases it. Does not bother checking ghostactive as that is only relevant
; when drawing the ghost
eraseghostshape
ld a,(ghostshowing)
or a
ret z ; return ias ghost not currently showing
ld a,(ghostx)
ld (tmpx),a
ld a,(ghosty)
ld (tmpy),a
xor a
ld (drawcolour),a
xor a
ld (ghostshowing),a ; we set to not showing as should only be set by calculateghostposition
jp showshape
; showshape draws a shape on screen, it is passed a tmpx and tmpy
; The colour used is passed in as drawcolour
; It draws the shape pointed to in blockshapes
showshape
ld a,(tmpx) ; instead of referring to tmpx and tmpy through this routine, we copy the values to d and e registers and use those
ld d,a
ld a,(tmpy)
ld e,a
ld a,(blockshapes)
bit 7,a
jp z, ss1
ld b,d
ld a,(tmpy)
ld c,a
call atadd
ld a,(drawcolour)
ld (hl),a
ss1
inc e
ld a,(blockshapes)
bit 6,a
jp z, ss2
ld b,d
ld c,e
call atadd
ld a,(drawcolour)
ld (hl),a
ss2
inc e
ld a,(blockshapes)
bit 5,a
jp z, ss3
ld b,d
ld c,e
call atadd
ld a,(drawcolour)
ld (hl),a
ss3
inc e
ld a,(blockshapes)
bit 4,a
jp z, ss4
ld b,d
ld c,e
call atadd
ld a,(drawcolour)
ld (hl),a
ss4
inc d
ld a,(blockshapes)
bit 0,a
jp z, ss5
ld b,d
ld c,e
call atadd
ld a,(drawcolour)
ld (hl),a
ss5
dec e
ld a,(blockshapes)
bit 1,a
jp z, ss6
ld b,d
ld c,e
call atadd
ld a,(drawcolour)
ld (hl),a
ss6
dec e
ld a,(blockshapes)
bit 2,a
jp z, ss7
ld b,d
ld c,e
call atadd
ld a,(drawcolour)
ld (hl),a
ss7
dec e
ld a,(blockshapes)
bit 3,a
jp z, ss8
ld b,d
ld c,e
call atadd
ld a,(drawcolour)
ld (hl),a
ss8
inc d
ld a,(blockshapes+1)
bit 7,a
jp z, ss9
ld b,d
ld c,e
call atadd
ld a,(drawcolour)
ld (hl),a
ss9
inc e
ld a,(blockshapes+1)
bit 6,a
jp z, ss10
ld b,d
ld c,e
call atadd
ld a,(drawcolour)
ld (hl),a
ss10
inc e
ld a,(blockshapes+1)
bit 5,a
jp z, ss11
ld b,d
ld c,e
call atadd
ld a,(drawcolour)
ld (hl),a
ss11
inc e
ld a,(blockshapes+1)
bit 4,a
jp z, ss12
ld b,d
ld c,e
call atadd
ld a,(drawcolour)
ld (hl),a
ss12
inc d
ld a,(blockshapes+1)
bit 0,a
jp z, ss13
ld b,d
ld c,e
call atadd
ld a,(drawcolour)
ld (hl),a
ss13
dec e
ld a,(blockshapes+1)
bit 1,a
jp z, ss14
ld b,d
ld c,e
call atadd
ld a,(drawcolour)
ld (hl),a
ss14
dec e
ld a,(blockshapes+1)
bit 2,a
jp z, ss15
ld b,d
ld c,e
call atadd
ld a,(drawcolour)
ld (hl),a
ss15
dec e
ld a,(blockshapes+1)
bit 3,a
jp z, ss16
ld b,d
ld c,e
call atadd
ld a,(drawcolour)
ld (hl),a
ss16
ret
; moves the block right if allowed. First deletes the shape and
; then checks the new location
moveright
call eraseghostshape ; always try to erase ghost, if not showing this call will not do anything
call erasecurrentshape
ld a,(plx)
ld (tmpx),a
ld a,(ply)
inc a ; we are trying to move right
ld (tmpy),a
call checkmove
ld a,(allowedmove)
or 0
jr z,mr1
ld a,(ply) ; move is valid so increment y
inc a
ld (ply),a
mr1
ld hl, colourlookuptable
ld de,(currentshape)
ld d,0 ;de is 16 bit, but we are actually trying to add an 8 bit to a 16bit so remove any possible extras
add hl,de
ld a,(hl)
ld (blockcolour),a ; now draw block in new position
call showcurrentshape
call showghostshape
ret
; moves the block left if allowed. First deletes the shape and
; then checks the new location
moveleft
call eraseghostshape ; always try to erase ghost, if not showing this call will not do anything
call erasecurrentshape
ld a,(plx)
ld (tmpx),a
ld a,(ply)
dec a ; we are trying to move left
ld (tmpy),a
call checkmove
ld a,(allowedmove)
or 0
jr z,ml1
ld a,(ply) ; move is valid so decrement y
dec a
ld (ply),a
ml1
ld hl, colourlookuptable
ld de,(currentshape)
ld d,0 ;de is 16 bit, but we are actually trying to add an 8 bit to a 16bit so remove any possible extras
add hl,de
ld a,(hl)
ld (blockcolour),a ; now draw block in new position
call showcurrentshape
call showghostshape
ret
; this drops the piece when in mixture drop mode and drop key has been tapped
droppieceiftappedkeyboard
; check dropmethod and lastkeypressed and keypresscount
ld a,(dropmethod)
cp 2
ret nz
ld a,(lastkeypressed)
bit 2,a ; drop
jr dpitk1
ret
dpitk1
ld a,(keypresscount)
cp 1
jr z,dpitk2
ret
dpitk2
ld a,1
ld (fulldropactive),a
call droppiece
call smalldelay
ret
droppieceiftappedjoystick
; check dropmethod and lastjoystick and firebuttoncount
ld a,(dropmethod)
cp 2
ret nz
ld a,(lastjoystick)
bit 5,a ; drop
jr dpitj1
ret
dpitj1
ld a,(firebuttoncount)
cp 1
jr z,dpitj2
ret
dpitj2
ld a,1
ld (fulldropactive),a
call droppiece
call smalldelay
ret
;this drops the piece, either by 1 square or till it cannot go any further
droppiece
ld a,(dropmethod)
cp 0
jr z,droppiecefull
cp 1
jr z,droppieceonequare
; we are not 0 or 1 so using a mixture - check for fulldropactive
ld a,(fulldropactive)
cp 0
jr z,droppieceonequare
; if here then using mixture dropmethod and full drop has been requested
xor a
ld (fulldropactive),a
jr droppiecefull
; moves the block down one square if allowed. First deletes the shape and
; then checks the new location
droppieceonequare
call eraseghostshape ; always try to erase ghost, if not showing this call will not do anything
call erasecurrentshape
ld a,(upsidedown)
cp 1
jr z,dpo2
ld a,(plx)
inc a ; going down one square
ld (tmpx),a
jr dpo3
dpo2
ld a,(plx)
dec a ; going up one square (we are upside down)
ld (tmpx),a
dpo3
ld a,(ply)
ld (tmpy),a
call checkmove
ld a,(allowedmove)
or 0
jr z,dpo1
ld a,(upsidedown)
cp 1
jr z,dpo4
ld a,(plx) ; move is valid so increment x
inc a
ld (plx),a
jr dpo1
dpo4
ld a,(plx) ; move is valid so decrement x (as upside down)
dec a
ld (plx),a
dpo1
ld hl, colourlookuptable
ld de,(currentshape)
ld d,0 ;de is 16 bit, but we are actually trying to add an 8 bit to a 16bit so remove any possible extras
add hl,de
ld a,(hl)
ld (blockcolour),a ; now draw block in new position
call showcurrentshape
call showghostshape
; reset the automatic drop timing - we do this as otherwise we would get occasional piece dropping
; down 2 spaces
ld hl,pretim
ld a,(23672)
ld (hl),a
ret
; drop the piece till it cannot go any further
; this is a loop, the exit being when no more moves are available, when dp1 is
; called which exits
droppiecefull
call eraseghostshape ; always try to erase ghost, if not showing this call will not do anything
call erasecurrentshape
ld a,(upsidedown)
cp 1
jr z,dp4
ld a,(plx)
inc a ; we are trying to move down
ld (tmpx),a
jr dp5
dp4
ld a,(plx)
dec a ; we are trying to move up (as upside down)
ld (tmpx),a
dp5
ld a,(ply)
ld (tmpy),a
call checkmove
ld a,(allowedmove)
or 0
jr z,dp1
ld a,(upsidedown)
cp 1
jr z,dp6
ld a,(plx) ; move is valid so increment x
inc a
ld (plx),a
jr dp7
dp6
ld a,(plx) ; move is valid so decrement x (as upside down)
dec a
ld (plx),a
dp7
call dp2
;delay loop to make the drop seem less sudden, but still a very fast drop
ld hl, 500
dp3
dec hl
ld a,h
or l
jr nz,dp3
; we get bonus points for dropping, 5 points per square dropped
ld hl,score+5 ; point to ones column.
ld b,5 ; 5 ones = 5.
call uscor ; up the score.
call printscore ;print this new score
jp droppiecefull
dp1
call dp2
ret ; so, if can't make any more moves then we call dp2 and then return
dp2
ld hl, colourlookuptable
ld de,(currentshape)
ld d,0 ;de is 16 bit, but we are actually trying to add an 8 bit to a 16bit so remove any possible extras
add hl,de
ld a,(hl)
ld (blockcolour),a ; now draw block in new position
call showcurrentshape
ret
; this is where we calculate the ghost x and y position
; we do this by first offsetting till no collision (against the actual current shape)
; then dropping down till we hit the top of the already placed pieces
calculateghostposition
; copy the player x and y to the tmp x and y
ld a,(plx)
ld (tmpx),a
ld a,(ply)
ld (tmpy),a
ld hl, ghostlookuptable
ld de,(currentshape)
ld d,0 ;de is 16 bit, but we are actually trying to add an 8 bit to a 16bit so remove any possible extras
add hl,de
ld a,(hl) ; this now gives us the offset in the ghost offset table
ld (ghostpointer),a
ld hl,ghostoffset
ld de,(ghostpointer)
ld d,0
add hl,de
ld de,(currentorientation)
ld d,0
add hl,de
ld a,(hl) ; a now holds the number of blocks to skip
ld d,a ; save value to d
ld a,(upsidedown)
cp 1
jr z,cgp5
ld a,(tmpx)
add a,d
ld (tmpx),a
cp 22
jp nc,cgp2 ; if a greater or equal to 22 we exit
jr cgp1
cgp5
ld a,(tmpx)
sub d
ld (tmpx),a
cp 0
jp c,cgp2
cgp1
; we have gone the minimum distance required by the ghost offset
; we check if there is an immediate collision, if there is, we exit
call checkmove
ld a,(allowedmove)
or 0
jp nz,cgp3 ; if no collision then determine ghost location
cgp2
; if in here this not possible to determine ghost x and y, set the ghostshowing to 0
xor a
ld (ghostshowing),a
ret
cgp3
; if here then found empty space, now keep dropping, this will be where the ghost shape will be shown
ld a,(upsidedown)
cp 1
jr z,cgp6
ld a,(tmpx)
inc a
ld (tmpx),a
jr cgp7
cgp6
ld a,(tmpx)
dec a ; as we are upside down
ld (tmpx),a
cgp7
call checkmove
ld a,(allowedmove)
or 0
jp nz,cgp3
cgp4
; if we are here then have found the top of the place pieces, allocate ghost x and y
ld a,(upsidedown)
cp 1
jr z,cgp8
ld a,(tmpx)
dec a ; we decrement one as we had gone one too far with previous loop
ld (ghostx),a
jr cgp9
cgp8
ld a,(tmpx)
inc a ; we increment one as we had gone one too far with previous loop
ld (ghostx),a
cgp9
ld a,(tmpy)
ld (ghosty),a
ld a,1
ld (ghostshowing),a
ret
; this swaps the ghost setting from active to inactive (and vice versa)
changeghostsetting
ld a,(ghostactive)
or 0
jr nz, cgs1
; ghost is currently off, switch it on
ld a,1
ld (ghostactive),a
ld hl,msg_game_ghost_active
call print_message
ret
cgs1
; ghost is currently on, switch it off
xor a
ld (ghostactive),a
ld hl,msg_game_ghost_inactive
call print_message
ret
; This handles the swap piece functionality. A player is allowed swap once till a new shape is selected automatically
; by the drop process. We swap the current piece with the saved shape
swapshape
ld a,(allowedswap)
or 0
jr nz, ssh1
ret ;not allowed swap
ssh1
xor a
ld (allowedswap),a ; stop any more swapping of this shape
call eraseghostshape ; always try to erase ghost, if not showing this call will not do anything
; erase our current shape
call erasecurrentshape
ld a,(savedshape)
push af ; save the shape to the stack
ld a,(currentshape)
ld (savedshape),a
call drawsavedshape
pop af ; get the saved shape from the stack
ld (currentshape),a ; now we have swapped shapes
ld a,(startx) ; swapped piece starts from the top of the screen
ld (plx),a
ld a,(starty)
ld (ply),a
; if we are upside down we need to update the x position
ld a,(upsidedown)
cp 1
jr z,ssh3
jr ssh4
ssh3
ld a,(upsidedownstartx)
ld (plx),a
ssh4
; now we work out the colour for this shape
ld hl, colourlookuptable
ld de,(currentshape)
ld d,0 ;de is 16 bit, but we are actually trying to add an 8 bit to a 16bit so remove any possible extras
add hl,de
ld a,(hl)
ld (blockcolour),a ; now draw block in new position
; need to transfer new shape position to tmpx and tmpy for checkmove to correctly work
ld a,(plx)
ld (tmpx),a
ld a,(ply)
ld (tmpy),a
; player has swapped, but maybe the piece will not fit at the top of the screen (and thus game over)
call checkmove
ld a,(allowedmove)
or 0
jr nz,ssh2
; move is not valid so its end game
pop af ; this is popping to ensure stack is back to correct status. This pop is to match the push that is done in the main loop
jp gameover
ssh2
; ok, so we can draw the shape ok
call setblockshapes
call showcurrentshape
call showghostshape
ret
; This drops the piece down by one square if possible, if not possible then it starts a new piece
autodroppiece
call eraseghostshape ; always try to erase ghost, if not showing this call will not do anything
call erasecurrentshape
ld a,(upsidedown)
cp 1
jr z, adp3
ld a,(plx)
inc a ; we are trying to move down
ld (tmpx),a
jr adp4
adp3
; this is the section called if upside down
ld a,(plx)
dec a ; we are trying to move up (as we are upside down)
ld (tmpx),a
adp4
ld a,(ply)
ld (tmpy),a
call checkmove
ld a,(allowedmove)
or 0
jr z,adp1
ld a,(upsidedown)
cp 1
jr z,adp5
ld a,(plx) ; move is valid so increment x
inc a
ld (plx),a
jr adp2
adp5
ld a,(plx) ; move is valid so decrement x (as upside down)
dec a
ld (plx),a
jr adp2
adp1
; if we are here then it was not possible to drop the block, choose a new block
; first we redraw back the piece then choose our new one
; we also add to the score
; Add 50 to the score.
ld hl,score+4 ; point to tens column.
ld b,5 ; 5 tens = 50.
call uscor ; up the score.
call printscore ;print this new score
ld hl, colourlookuptable
ld de,(currentshape)
ld d,0 ;de is 16 bit, but we are actually trying to add an 8 bit to a 16bit so remove any possible extras
add hl,de
ld a,(hl)
ld (blockcolour),a ; now draw block in new position
call showcurrentshape
call checkplayarea ; now see if a winning line (or lines) exists
call selectnewpiece
adp2
ld hl, colourlookuptable
ld de,(currentshape)
ld d,0 ;de is 16 bit, but we are actually trying to add an 8 bit to a 16bit so remove any possible extras
add hl,de
ld a,(hl)
ld (blockcolour),a ; now draw block in new position
call showcurrentshape
call showghostshape
;call autodropnoise
ret
; Routine to pick a new block. Holds this in next shape and makes currentshape the old value of nextshape
; levels 2,5,7 amd 9 have extra shapes added
selectnewpiece
ld a,(nextshape)
push af ; save the nextshape to the stack, this will become currentshape
ld a,(currentlevel)
cp 2
jr z,snp2
cp 5
jr z,snp2
cp 7
jr z,snp2
cp 9
jr z,snp2
; if get to here then using the standard set
;this picks the random numbers when just using standard set
snp1
call rnd
and 7 ;bitmask bits 0, 1 and 2
cp 7
jp nc, snp1
jr snp3
; this picks the random numbers when using the extended set
snp2
call rnd
and 15 ;bitmask bits 0, 1, 2 and 3 (7 for standard set)
cp 12 ; change to 7 for standard set
jp nc, snp2
snp3
ld (nextshape),a
call drawnextshape
pop af
ld (currentshape),a ; now retrieve from the stack
ld a,(startx)
ld (plx),a
ld a,(starty)
ld (ply),a
; if upside down we need to update the starting x position
ld a,(upsidedown)
cp 1
jr z,snp5
jr snp6
snp5
ld a,(upsidedownstartx)
ld (plx),a
snp6
; reset allowed swap
ld a,1
ld (allowedswap),a
; reset last key pressed (if the last key pressed was not 'drop')
ld a,(lastkeypressed)
cp 7 ;7 is drop
jr z,snp7
xor a
ld (lastkeypressed),a
snp7
; now check if end game
ld a,(plx)
ld (tmpx),a
ld a,(ply)
ld (tmpy),a
call checkmove
ld a,(allowedmove)
or 0
jr nz,snp4
; move is not valid so its end game
jp gameover
snp4
xor a
ld (currentorientation),a
call setblockshapes
ld hl,piecesthislevel
inc (hl)
jp levelspecialaction; this does the special action required per level (may not do anything)
; Moves the block anti clockwise if allowed
moveanticlockwise
call eraseghostshape ; always try to erase ghost, if not showing this call will not do anything
call erasecurrentshape
ld a,(currentorientation)
inc a
cp 4 ;if 4 then need to set to 0
jr nz, mac1
xor a
mac1
ld (currentorientation),a
call setblockshapes
ld a,(plx)
ld (tmpx),a
ld a,(ply)
ld (tmpy),a
call checkmove
ld a,(allowedmove)
or 0
jr nz,mac6
; move is not valid so need to reset blockpointer and blockshapes
ld a,(currentorientation)
or 0
jr nz, mac5
ld a,4 ; we set to be 4 as we will decrememt by 1 giving us correct value 3
mac5
dec a
ld (currentorientation),a ;currentorientation not reset to previous value
call setblockshapes
mac6
ld hl, colourlookuptable
ld de,(currentshape)
ld d,0 ;de is 16 bit, but we are actually trying to add an 8 bit to a 16bit so remove any possible extras
add hl,de
ld a,(hl)
ld (blockcolour),a ; now draw block in new position
call showcurrentshape
call showghostshape
ret
; Moves the block clockwise if allowed
moveclockwise
call eraseghostshape ; always try to erase ghost, if not showing this call will not do anything
call erasecurrentshape
ld a,(currentorientation)
or 0
jr nz,mcw1
ld a,4 ; we set to be 4 as we will decrememt by 1 giving us correct value 3
mcw1
dec a
ld (currentorientation),a
call setblockshapes
ld a,(plx)
ld (tmpx),a
ld a,(ply)
ld (tmpy),a
call checkmove
ld a,(allowedmove)
or 0
jr nz,mcw3 ; move is valid
; move is not valid so need to reset blockpointer and blockshapes
ld a,(currentorientation)
inc a
cp 4
jr nz, mcw2
xor a ; we set to be 4 as we will decrememt by 1 giving us correct value 3
mcw2
ld (currentorientation),a ;currentorientation not reset to previous value
call setblockshapes
mcw3
ld hl, colourlookuptable
ld de,(currentshape)
ld d,0 ;de is 16 bit, but we are actually trying to add an 8 bit to a 16bit so remove any possible extras
add hl,de
ld a,(hl)
ld (blockcolour),a ; now draw block in new position
call showcurrentshape
call showghostshape
ret
;setblockshapes uses the currentorientation and currentshape to set the
; value of blockshapes i.e. the exact block to draw
setblockshapes
xor a ;reset a to 0
ld (blockpointer),a
ld a,(currentshape)
or 0
jr z, sbs1
; each shape is 8 bytes so have to increase by eight for each shape
ld hl, blocklookuptable
ld de,(currentshape)
ld d,0 ;de is 16 bit, but we are actually trying to add an 8 bit to a 16bit so remove any possible extras
add hl,de
ld a,(hl)
ld (blockpointer),a
sbs1
ld a,(currentorientation)
or 0
jr z, sbs2
ld b,a
sbsloop1
ld a,(blockpointer)
inc a
inc a
ld (blockpointer),a
djnz sbsloop1
sbs2
ld hl, shapedata
ld de,(blockpointer)
ld d,0 ;blockpointer is always a 8 bit value
add hl,de
ld a,(hl)
ld (blockshapes),a
inc hl
ld a,(hl)
ld (blockshapes+1),a
ret
;this draws the next piece that will be played in the right hand side
; we temporarily set the current piece to be this
drawnextshape
call erasenextshape
ld a,(nextblockx)
ld (tmpx),a
ld a,(nextblocky)
ld (tmpy),a
xor a
ld (currentorientation),a
ld a,(nextshape)
ld (currentshape),a
ld hl, colourlookuptable
ld de,(currentshape)
ld d,0 ;de is 16 bit, but we are actually trying to add an 8 bit to a 16bit so remove any possible extras
add hl,de
ld a,(hl)
ld (drawcolour),a
call setblockshapes
call showshape
ret
; This erases the next shape area. There are three lines here to cope with all shapes
; in orientation 0
erasenextshape
ld a,(nextblockx)
ld (tmpx),a
ld a,(nextblocky)
ld (tmpy),a
ld b,4
ens1
push bc
ld a,(tmpx)
ld b,a
ld a,(tmpy)
ld c,a
call atadd
ld (hl),0
ld a,(tmpy)
inc a
ld (tmpy),a
pop bc
djnz ens1
ld a,(tmpx)
inc a
ld (tmpx),a
ld a,(nextblocky)
ld (tmpy),a
ld b,4
ens2
push bc
ld a,(tmpx)
ld b,a
ld a,(tmpy)
ld c,a
call atadd
ld (hl),0
ld a,(tmpy)
inc a
ld (tmpy),a
pop bc
djnz ens2
ld a,(tmpx)
inc a
ld (tmpx),a
ld a,(nextblocky)
ld (tmpy),a
ld b,4
ens3
push bc
ld a,(tmpx)
ld b,a
ld a,(tmpy)
ld c,a
call atadd
ld (hl),0
ld a,(tmpy)
inc a
ld (tmpy),a
pop bc
djnz ens3
ret
; This is the initial setup of the next shape area. 3 lines to handle
; all shapes in orientation 0
setupnextshape
xor a
ld (blockcolour),a
ld a,(nextblockx)
ld (tmpx),a
ld a,(nextblocky)
ld (tmpy),a
ld b,4
sns1
push bc
call drawblock
ld a,(tmpy)
inc a
ld (tmpy),a
pop bc
djnz sns1
ld a,(tmpx)
inc a
ld (tmpx),a
ld a,(nextblocky)
ld (tmpy),a
ld b,4
sns2
push bc
call drawblock
ld a,(tmpy)
inc a
ld (tmpy),a
pop bc
djnz sns2
ld a,(tmpx)
inc a
ld (tmpx),a
ld a,(nextblocky)
ld (tmpy),a
ld b,4
sns3
push bc
call drawblock
ld a,(tmpy)
inc a
ld (tmpy),a
pop bc
djnz sns3
ret
; This erases the saved shape area
erasesavedshape
ld a,(savedblockx)
ld (tmpx),a
ld a,(savedblocky)
ld (tmpy),a
ld b,4
ess1
push bc
ld a,(tmpx)
ld b,a
ld a,(tmpy)
ld c,a
call atadd
ld (hl),0
ld a,(tmpy)
inc a
ld (tmpy),a
pop bc
djnz ess1
ld a,(tmpx)
inc a
ld (tmpx),a
ld a,(savedblocky)
ld (tmpy),a
ld b,4
ess2
push bc
ld a,(tmpx)
ld b,a
ld a,(tmpy)
ld c,a
call atadd
ld (hl),0
ld a,(tmpy)
inc a
ld (tmpy),a
pop bc
djnz ess2
ld a,(tmpx)
inc a
ld (tmpx),a
ld a,(savedblocky)
ld (tmpy),a
ld b,4
ess3
push bc
ld a,(tmpx)
ld b,a
ld a,(tmpy)
ld c,a
call atadd
ld (hl),0
ld a,(tmpy)
inc a
ld (tmpy),a
pop bc
djnz ess3
ret
; This is the initial setup of the saved shape area
setupsavedshape
xor a
ld (blockcolour),a
ld a,(savedblockx)
ld (tmpx),a
ld a,(savedblocky)
ld (tmpy),a
ld b,4
sss1
push bc
call drawblock
ld a,(tmpy)
inc a
ld (tmpy),a
pop bc
djnz sss1
ld a,(tmpx)
inc a
ld (tmpx),a
ld a,(savedblocky)
ld (tmpy),a
ld b,4
sss2
push bc
call drawblock
ld a,(tmpy)
inc a
ld (tmpy),a
pop bc
djnz sss2
ld a,(tmpx)
inc a
ld (tmpx),a
ld a,(savedblocky)
ld (tmpy),a
ld b,4
sss3
push bc
call drawblock
ld a,(tmpy)
inc a
ld (tmpy),a
pop bc
djnz sss3
ret
;this draws the saved piece that on the left hand side
; we temporarily set the current piece to be this
drawsavedshape
call erasesavedshape
ld a,(savedblockx)
ld (tmpx),a
ld a,(savedblocky)
ld (tmpy),a
xor a
ld (currentorientation),a
ld a,(savedshape)
ld (currentshape),a
ld hl, colourlookuptable
ld de,(currentshape)
ld d,0 ;de is 16 bit, but we are actually trying to add an 8 bit to a 16bit so remove any possible extras
add hl,de
ld a,(hl)
ld (drawcolour),a
call setblockshapes
call showshape
ret
; this routine is used to erase the top line of the play area. We need this code
; as when we move everything down a line after a winning line, we need to clear the top line
erasetopline
ld a,(upsidedown)
cp 1
jp z,etl2
ld a,(playareatoplinex)
ld (tmpx),a
jp eraseline
etl2
ld a,(upsidedownplayareatoplinex) ; different x if upside down
ld (tmpx),a
jp eraseline
; eraseline is used for clearing the playarea at the start of every level and is used
; during process for handling winning lines. tmpx is passed in (line to erase)
eraseline
ld a,(playareatopliney)
ld (tmpy),a
ld b,10 ;10 squares in width of play area
etl1
push bc
ld a,(tmpx)
ld b,a
ld a,(tmpy)
ld c,a
call atadd
ld (hl),0 ; set the attribute at this square to be 0, black
ld a,(tmpy)
inc a
ld (tmpy),a
pop bc
djnz etl1
ret
; this routine detects a winning line in the playarea. It checks the line defined in tmpx
; winningline will be set to 1 in the case of a winning line, otherwise 0
checkwinningline
xor a
ld (winningline),a ; winningline reset to 0
; tmpx is already set, but set initial y value
ld a,(playareatopliney)
ld (tmpy),a
ld b,10 ;10 squares in width of play area
cwl1
push bc
ld a,(tmpx)
ld b,a
ld a,(tmpy)
ld c,a
call atadd
or 0 ; check if it black/black i.e. empty square
jp z, cwl2 ;square is empty, can return with winningline set to 0, not winning line
ld a,(tmpy)
inc a
ld (tmpy),a
pop bc
djnz cwl1
; if get this far then winning line
ld a,1
ld (winningline),a
ret
cwl2
; not a winning line, but need to tidy the stack, then exit
pop bc
ret
; when a winning line is detected, this is the routine that flashes the line, by setting
; the attribute of each of the squares with a flash attribute
; The line to flash will be passed in using tmpx
flashwinningline
; tmpx is already set, but set initial y value
ld a,(playareatopliney)
ld (tmpy),a
ld b,10 ;10 squares in width of play area
fwl1
push bc
ld a,(tmpx)
ld b,a
ld a,(tmpy)
ld c,a
call atadd
ld a,(winninglinecolour)
ld (hl),a ; set the attribute at this square to be winninglinecolour
ld a,(tmpy)
inc a
ld (tmpy),a
pop bc
djnz fwl1
ret
; this is the routine that checks the playarea for all winning lines, adding to
; the players score, flash the lines temporarily and then deleting them and moving
; the playarea down
checkplayarea
xor a
ld (rowscompleted),a
ld b,20
cpa1
push bc ; b will be modified by later calls
ld a,b
ld (tmpx),a
call checkwinningline
ld a,(winningline)
or 0
jr z,cpa2 ; if not a winning line then skip flashwinningline call
call flashwinningline
ld hl,score+4 ; point to tens column.
ld b,5 ; 5 tens = 50.
call uscor ; up the score.
ld hl,score+3 ; point to hundreds column.
ld b,2 ; 2 hundreds = 200.
call uscor ; up the score. - so score increased by 250
call printscore ;print this new score
ld a,(rowscompleted)
inc a
ld (rowscompleted),a
cp 4 ; bonus points for 4 rows together (+1000 score)
jr nz, cpa2
ld hl,score+2 ; point to thousands column.
ld b,1 ; 1 thousands = 1000.
call uscor ; up the score.
call printscore ;print this new score
cpa2
pop bc
djnz cpa1
; now update the lines completed
ld hl,totalrowscompleted+1 ; point to ones column.
ld a,(rowscompleted)
ld b,a
call uscor ; up the lines count
call printlines ;print this new lines tally
ld a,(rowscompleted)
ld b,a
ld a,(totalrowscompletednum)
add a,b
ld (totalrowscompletednum),a
; at this stage we have any winning lines flashing and extra score has been added
; if any winning lines need to now remove
ld a,(rowscompleted)
or 0
ret z ; if no rows completed we can exit this routine
; if there are rows we add a short delay so the player can see the flashing lines i.e.
; they can see their winning lines
ld hl, 50000
cpa3
dec hl
ld a,h
or l
jr nz,cpa3
ld a,(upsidedown)
cp 1
jr z,cpa6
ld b,20
cpa4
push bc ; b will be modified by later calls
ld a,b
ld (tmpx),a
call checkwinningline
ld a,(winningline)
or 0
jr z,cpa5 ; if not a winning line then skip eraseline
call eraseline
call dropplayarea
; we now need to add 1 to b to ensure we delete all winning lines
pop bc
inc b
push bc
cpa5
pop bc
djnz cpa4
call clearedlinenoise
ret
cpa6
ld b,1
cpa7
push bc ; b will be modified by later calls
ld a,b
ld (tmpx),a
call checkwinningline
ld a,(winningline)
or 0
jr z,cpa8
call eraseline
call upsidedowndropplayarea
; we now need to decrement 1 from b to ensure we delete all winning lines
pop bc
dec b
push bc
cpa8
pop bc
inc b
ld a,b
cp 22
jr z,cpa9
jp cpa7
cpa9
call clearedlinenoise
ret
; move playarea down. When we get a winning line, we remove the winning line and this routine
; drops the playarea above that line down
; we pass in tmpx which is the winning line (drop everything above this)
dropplayarea
ld a,(playareatopliney)
ld (tmpy),a
ld a,(tmpx)
ld b,a
dpa1
push bc
ld b,10 ; inner loop
dpa2
push bc
ld a,(tmpx)
dec a ; we drop by 1 as we are copying the line above
ld b,a
ld a,(tmpy)
ld c,a
call atadd
ld (blockcolour),a ; this now contains the colour of the square directly above
ld a,(tmpx)
ld b,a
call atadd
ld a,(blockcolour)
ld (hl),a
ld a,(tmpy) ; next square in the row
inc a
ld (tmpy),a
pop bc
djnz dpa2
; finished inner loop, i.e. that row, drop x by 1 and reset y
ld a,(tmpx)
dec a
ld (tmpx),a
ld a,(playareatopliney)
ld (tmpy),a
pop bc
djnz dpa1
; at this stage we have dropped everything, now just need to erase the top line
jp erasetopline
; move playarea up. When we get a winning line, we remove the winning line and this routine
; drops the playarea above that line up (as this is the routine called when upside down)
; we pass in tmpx which is the winning line (drop everything below this)
upsidedowndropplayarea
ld a,(playareatopliney)
ld (tmpy),a
ld a,(tmpx)
uddpa1
ld b,10 ; inner loop
uddpa2
push bc
ld a,(tmpx)
inc a ; we increase by 1 as we are copying the line below
ld b,a
ld a,(tmpy)
ld c,a
call atadd
ld (blockcolour),a ; this now contains the colour of the square directly above
ld a,(tmpx)
ld b,a
call atadd
ld a,(blockcolour)
ld (hl),a
ld a,(tmpy) ; next square in the row
inc a
ld (tmpy),a
pop bc
djnz uddpa2
; finished inner loop, i.e. that row, increase x by 1 and reset y
ld a,(tmpx)
inc a
ld (tmpx),a
ld a,(playareatopliney)
ld (tmpy),a
ld a,(tmpx)
cp 22
jr nz, uddpa1
; at this stage we have dropped everything, now just need to erase the top line
jp erasetopline
; setupplayarea is used to draw a block (in black so not shown) in each square of the
; playarea
setupplayarea
xor a
ld (blockcolour),a
ld b,21
spa1
push bc ; b will be modified by later calls
ld a,b
ld (tmpx),a
call drawlineofblocks
pop bc
djnz spa1
xor a ; now clear the very top line
ld (tmpx),a
call drawlineofblocks
ret
;drawlineofblocks draws a line of blocks
; passed in tmpx, line at which to draw
drawlineofblocks
ld a,(playareatopliney)
ld (tmpy),a
ld b,10 ;10 squares in width of play area
dlb1
push bc
call drawblock
ld a,(tmpy)
inc a
ld (tmpy),a
pop bc
djnz dlb1
ret
;checkmove. tmpx and tmpy will be set to the desired location
;and the current shape will be removed. This checks if there are
;any existing blocks at the new location
checkmove
ld a,1
ld (allowedmove),a ; default is move allowed
ld a,(tmpx) ; instead of referring to tmpx and tmpy through this routine, we copy the values to d and e registers and use those
ld d,a
ld a,(tmpy)
ld e,a
ld a,(blockshapes)
bit 7,a
jp z, cm1
ld b,d
ld c,e
call atadd
or 0 ; check if it black/black i.e. empty square
jp z, cm1 ;square is empty, can move
xor a
ld (allowedmove),a ; cannot move
ret ; exit as cannot move
cm1
ld a,(blockshapes)
bit 6,a
jp z, cm2
ld b,d
ld a,e
inc a
ld c,a
call atadd
or 0
jp z, cm2
xor a
ld (allowedmove),a ; cannot move
ret ; exit as cannot move
cm2
ld a,(blockshapes)
bit 5,a
jp z, cm3
ld b,d
ld a,e
inc a
inc a
ld c,a
call atadd
or 0
jp z, cm3
xor a
ld (allowedmove),a ; cannot move
ret ; exit as cannot move
cm3
ld a,(blockshapes)
bit 4,a
jp z, cm4
ld b,d
ld a,e
inc a
inc a
inc a
ld c,a
call atadd
or 0
jp z, cm4
xor a
ld (allowedmove),a ; cannot move
ret ; exit as cannot move
cm4
ld a,(blockshapes)
bit 3,a
jp z, cm5
ld a,d
inc a
ld b,a
ld c,e
call atadd
or 0 ; check if it black/black i.e. empty square
jp z, cm5
xor a
ld (allowedmove),a ; cannot move
ret ; exit as cannot move
cm5
ld a,(blockshapes)
bit 2,a
jp z, cm6
ld a,d
inc a
ld b,a
ld a,e
inc a
ld c,a
call atadd
or 0
jp z, cm6
xor a
ld (allowedmove),a ; cannot move
ret ; exit as cannot move
cm6
ld a,(blockshapes)
bit 1,a
jp z, cm7
ld a,d
inc a
ld b,a
ld a,e
inc a
inc a
ld c,a
call atadd
or 0
jp z, cm7
xor a
ld (allowedmove),a ; cannot move
ret ; exit as cannot move
cm7
ld a,(blockshapes)
bit 0,a
jp z, cm8
ld a,d
inc a
ld b,a
ld a,e
inc a
inc a
inc a
ld c,a
call atadd
or 0
jp z, cm8
xor a
ld (allowedmove),a ; cannot move
ret ; exit as cannot move
cm8
ld a,(blockshapes+1)
bit 7,a
jp z, cm9
ld a,d
inc a
inc a
ld b,a
ld c,e
call atadd
or 0 ; check if it black/black i.e. empty square
jp z, cm9
xor a
ld (allowedmove),a ; cannot move
ret ; exit as cannot move
cm9
ld a,(blockshapes+1)
bit 6,a
jp z, cm10
ld a,d
inc a
inc a
ld b,a
ld a,e
inc a
ld c,a
call atadd
or 0
jp z, cm10
xor a
ld (allowedmove),a ; cannot move
ret ; exit as cannot move
cm10
ld a,(blockshapes+1)
bit 5,a
jp z, cm11
ld a,d
inc a
inc a
ld b,a
ld a,e
inc a
inc a
ld c,a
call atadd
or 0
jp z, cm11
xor a
ld (allowedmove),a ; cannot move
ret ; exit as cannot move
cm11
ld a,(blockshapes+1)
bit 4,a
jp z, cm12
ld a,d
inc a
inc a
ld b,a
ld a,e
inc a
inc a
inc a
ld c,a
call atadd
or 0
jp z, cm12
xor a
ld (allowedmove),a ; cannot move
ret ; exit as cannot move
cm12
ld a,(blockshapes+1)
bit 3,a
jp z, cm13
ld a,d
inc a
inc a
inc a
ld b,a
ld c,e
call atadd
or 0 ; check if it black/black i.e. empty square
jp z, cm13
xor a
ld (allowedmove),a ; cannot move
ret ; exit as cannot move
cm13
ld a,(blockshapes+1)
bit 2,a
jp z, cm14
ld a,d
inc a
inc a
inc a
ld b,a
ld a,e
inc a
ld c,a
call atadd
or 0
jp z, cm14
xor a
ld (allowedmove),a ; cannot move
ret ; exit as cannot move
cm14
ld a,(blockshapes+1)
bit 1,a
jp z, cm15
ld a,d
inc a
inc a
inc a
ld b,a
ld a,e
inc a
inc a
ld c,a
call atadd
or 0
jp z, cm15
xor a
ld (allowedmove),a ; cannot move
ret ; exit as cannot move
cm15
ld a,(blockshapes+1)
bit 0,a
jp z, cmend
ld a,d
inc a
inc a
inc a
ld b,a
ld a,e
inc a
inc a
inc a
ld c,a
call atadd
or 0
jp z, cmend
xor a
ld (allowedmove),a ; cannot move
ret ; exit as cannot move
cmend
ret
; Calculate address of attribute for character at (b, c).
atadd
ld a,b ; x position.
rrca ; multiply by 32.
rrca
rrca
ld l,a ; store away in l.
and 3 ; mask bits for high byte.
add a,88 ; 88*256=22528, start of attributes.
ld h,a ; high byte done.
ld a,l ; get x*32 again.
and 224 ; mask low byte.
ld l,a ; put in l.
ld a,c ; get y displacement.
add a,l ; add to low byte.
ld l,a ; hl=address of attributes.
ld a,(hl) ; return attribute in a.
ret
; redefine keys routine written by <NAME>
get_keys:
ld de,0 ; DE will hold the bits for the keys pressed
ld hl,key_music_port ; address of the ports/patterns
ld b,8 ; 8 keys to check
res 0,d
dec hl
gk_loop:
inc hl
rl d
ld a,(hl) ; get the port row
in a,(254) ; check that row
cpl
and 31
inc hl ; point to the key bit pattern
cp (hl) ; check if that key is pressed
jr z,gk_key_is_pressed
;key is not pressed
res 0,d ; indicate key not pressed
djnz gk_loop ; go check next key
jr gk_exit
gk_key_is_pressed:
set 0,d ; indicate key is pressed
djnz gk_loop ; go check next key
; ok, all done, maybe, I hope, ahh pffffffffffffffffft
gk_exit:
ld a,d ; return the bit thingy
ret
; This is where we redefine the keys
do_the_redefine:
call ROM_CLS ; do the clear screen
xor a
ld hl,msg_define
call print_message
call mediumdelay
ld hl,msg_left
call print_message
ld hl,key_left_port
call get_defined_key
ld hl,msg_right
call print_message
ld hl,key_right_port
call get_defined_key
ld hl,msg_anticlockwise
call print_message
ld hl,key_anticlockwise_port
call get_defined_key
ld hl,msg_clockwise
call print_message
ld hl,key_clockwise_port
call get_defined_key
ld hl,msg_drop
call print_message
ld hl,key_drop_port
call get_defined_key
ld hl,msg_ghost
call print_message
ld hl,key_ghost_port
call get_defined_key
ld hl,msg_swap
call print_message
ld hl,key_swap_port
call get_defined_key
ld hl,msg_music
call print_message
ld hl,key_music_port
call get_defined_key
; ok, keys should have been saved, (/me hopes)
ld bc,key_music_port ; return the keys data to calling program
ret
; ----------------------------------------------
; ROUTINE: print_message
;
; prints a string which is terminated with $ff
; On entry, HL = address of message
print_message:
push hl ; save the message address
ld a,2 ; upper screen
call CHAN_OPEN ; get the channel sorted
pop hl ; get the message address back
pm_do_it:
ld a,(hl) ; get the character to print
inc hl ; point to next character
cp 255 ; end of the string
ret z ; so exit
rst 16 ; print the character
jr pm_do_it ; and do it all over again
ret
; ----------------------------------------------
; ROUTINE: get_defined_key
;
; check for key being pressed
; On entry, HL = key_xxx_port where xxx is the direction, eg up/down/left/right/fire/pause/quit
; On exit, the key_xxx_port and key_xxx_pattern will hold the values for the key pressed
;
get_defined_key:
ld de,port_array ; the array of rows
ld b,8 ; number of rows to check
gdk_loop:
ld a,(de) ; get row
in a,(254) ; check for keys on that row
cpl
and 31 ; mask off the 5 bits I want
jr z,gdk_none ; nothing pressed? ok, go to next row
inc hl ; point to the key_xxx_pattern byte
ld (hl),a ; save the pattern byte
dec hl ; go back to the key_xxx_port byte
ld a,(de) ; get the port that the key was found on
ld (hl),a ; save it
; ok, details for the pressed key are saved, lets gtfo here
call delay
ret
gdk_none:
inc de ; next row in array
djnz gdk_loop ; go check next row
; hmm, no key pressed on keyboard, sooooo do it all again
jr get_defined_key
ret ; not executed, but it stops me from getting confused, :)
; -----------------------------------------------
delay:
ld bc,32768
xor a
d_loop:
dec a
out (254),a
dec bc
ld a,b
or c
jr nz,d_loop
ret
; Update score routine by <NAME>
uscor
ld a,(hl) ; current value of digit.
add a,b ; add points to this digit.
ld (hl),a ; place new digit back in string.
cp 58 ; more than ASCII value '9'?
ret c ; no - relax.
sub 10 ; subtract 10.
ld (hl),a ; put new character back in string.
uscor0
dec hl ; previous character in string.
inc (hl) ; up this by one.
ld a,(hl) ; what's the new value?
cp 58 ; gone past ASCII nine?
ret c ; no, scoring done.
sub 10 ; down by ten.
ld (hl),a ; put it back
jr uscor0 ; go round again.
; Print the score
printscore
ld a,CC_INK
rst 16
ld a,7
rst 16
ld a,CC_AT
rst 16
ld a,(scorex)
rst 16
ld a,(scorey)
rst 16
ld hl, score
ld b,6
ps1
ld a,(hl) ; get the character to print
inc hl ; point to next character
rst 16 ; print the character
djnz ps1 ; and do it all over again
ret
; Print the high score
printhighscore
ld a,CC_INK
rst 16
ld a,7
rst 16
ld a,CC_AT
rst 16
ld a,(highscorex)
rst 16
ld a,(highscorey)
rst 16
ld hl, highscore
ld b,6
phs1
ld a,(hl) ; get the character to print
inc hl ; point to next character
rst 16 ; print the character
djnz phs1 ; and do it all over again
ret
gameover
; switch the music to heart and soul
ld bc,heartandsoul
ld (gamemusic),bc
ld a, 11
ld (musicspeed),a
xor a
ld (noteindex),a ; so music plays at start of song
call ROM_CLS ; do the clear screen
;open the upper screen for printing (channel 2)
ld a,2
call 5633
ld hl,gameoverlogo
call printwordswithblocks
ld hl, msg_gameover_score
call print_message
ld a,CC_INK
rst 16
ld a,7
rst 16
ld a,CC_AT
rst 16
ld a,19
rst 16
ld a,12
rst 16
ld hl, score
ld b,6
go1
ld a,(hl) ; get the character to print
inc hl ; point to next character
rst 16 ; print the character
djnz go1 ; and do it all over again
call checkhighscore
ld a,(newhighscore)
cp 0
jr z,go3 ; if equal to 0, no new high score
ld hl, msg_gameover_newhighscore
call print_message
go3
ld b,250 ; time to pause (50 frames a sec, 5 secs wait)
go2
halt ; wait for an interrupt.
djnz go2 ; repeat.
jp BEGIN
; screen that gets called when you win
youwin
; change music to you win music
ld bc,youwinmusic
ld (gamemusic),bc
ld a, 10
ld (musicspeed),a
xor a
ld (noteindex),a ; so music plays at start of song
call ROM_CLS ; do the clear screen
;open the upper screen for printing (channel 2)
ld a,2
call 5633
ld hl,youwinlogo
call printwordswithblocks
ld hl, msg_gameover_score
call print_message
ld a,CC_INK
rst 16
ld a,7
rst 16
ld a,CC_AT
rst 16
ld a,19
rst 16
ld a,12
rst 16
ld hl, score
ld b,6
yw1
ld a,(hl) ; get the character to print
inc hl ; point to next character
rst 16 ; print the character
djnz yw1 ; and do it all over again
call checkhighscore
ld a,(newhighscore)
cp 0
jr z,yw3 ; if equal to 0, no new high score
ld hl, msg_gameover_newhighscore
call print_message
yw3
ld b,250 ; time to pause (50 frames a sec, 5 secs wait)
yw2
halt ; wait for an interrupt.
djnz yw2 ; repeat.
jp BEGIN
; small delay loop used by main loop
smalldelay
ld a,(sensitivity)
cp 0
jr z,sd2
cp 1
jr z,sd3
; else its slow
ld hl, 17500
jr sd1
sd2
; fast
ld hl,5000
jr sd1
sd3
; normal
ld hl,12500
sd1
jr actualdelay
longdelay
ld hl, 17500
jr actualdelay
; medium delay loop used by main menu loop
mediumdelay
ld hl, 12500
jr actualdelay
; very small delay loop used by main menu loop
verysmalldelay
ld hl, 5000
jr actualdelay
actualdelay
dec hl
ld a,h
or l
jr nz,actualdelay
ret
; This draws words onscreen using blocks to make up the parts of the letters
; Each byte represents a colour for the block to draw
; 254 means end of line and 255 means end of data (stop drawing)
; hl is passed in, this is the address of the start of the data to print
printwordswithblocks
xor a
ld (tmpx),a
ld (tmpy),a
pbl1
ld a,(hl)
cp 254
jr z,pbl2
cp 255
ret z ; we return from here if a 255 found
ld (blockcolour),a
call drawblock
ld a,(tmpy)
inc a
ld (tmpy),a
inc hl
jp pbl1
pbl2
; end of line reached, reset y and increment x
ld a,(tmpx)
inc a
ld (tmpx),a
xor a
ld (tmpy),a
inc hl
jp pbl1
; this updates the lines completed area
printlines
ld a,CC_INK
rst 16
ld a,7
rst 16
ld a,CC_AT
rst 16
ld a,(linesx)
rst 16
ld a,(linesy)
rst 16
ld hl, totalrowscompleted
ld b,2
pl1
ld a,(hl) ; get the character to print
inc hl ; point to next character
rst 16 ; print the character
djnz pl1 ; and do it all over again
; now print slash divider
ld a,'/'
rst 16
ld hl, targetlinesforthislevel
ld b,2
pl2
ld a,(hl) ; get the character to print
inc hl ; point to next character
rst 16 ; print the character
djnz pl2 ; and do it all over again
ret
; this determines the target number of lines for this level
calculatelinesforthislevel
ld hl, linesneededperlevel
ld de,(currentlevel)
dec de
ld d,0 ;de is 16 bit, but we are actually trying to add an 8 bit to a 16bit so remove any possible extras
add hl,de
ld a,(hl)
cp 10
jr z,cll1
cp 25
jr z,cll2
ld hl,targetlinesforthislevel+1 ; point to ones column.
ld b,a
call uscor ; up the lines count
ret
cll1
ld hl,targetlinesforthislevel ; point to tens column.
ld b,1
call uscor ; up the lines count
ret
cll2
ld hl,targetlinesforthislevel ; point to tens column.
ld b,2
call uscor ; up the lines count
ld hl,targetlinesforthislevel+1 ; point to ones column.
ld b,5
call uscor ; up the lines count
ret
; routine for printing the name of the level at the bottom of the screen
printlevelname
ld a,1 ; open channel 1
call 5633
ld a,(currentlevel)
cp 1
jr z,pln1
cp 2
jr z,pln2
cp 3
jr z,pln3
cp 4
jr z,pln4
cp 5
jr z,pln5
cp 6
jr z,pln6
cp 7
jr z,pln7
cp 8
jr z,pln8
cp 9
jr z,pln9
cp 10
jr z,pln10
jr pln12 ; no matches found, exit
pln1
ld hl, msg_game_level1
jr pln11
pln2
ld hl, msg_game_level2
jr pln11
pln3
ld hl, msg_game_level3
jr pln11
pln4
ld hl, msg_game_level4
jr pln11
pln5
ld hl, msg_game_level5
jr pln11
pln6
ld hl, msg_game_level6
jr pln11
pln7
ld hl, msg_game_level7
jr pln11
pln8
ld hl, msg_game_level8
jr pln11
pln9
ld hl, msg_game_level9
jr pln11
pln10
ld hl, msg_game_level10
pln11
call pm_do_it ; part of print_message
pln12
ld a,2 ; re-open channel 2
call 5633
ret
; sound effect when clearing lines
clearedlinenoise
ld e,200 ; repeat 200 times.
ld hl,0 ; start pointer in ROM.
noise2
push de
ld b,32 ; length of step.
noise0
push bc
ld a,(hl) ; next "random" number.
inc hl ; pointer.
and 248 ; we want a black border.
out (254),a ; write to speaker.
ld a,e ; as e gets smaller...
cpl ; ...we increase the delay.
noise1
dec a ; decrement loop counter.
jr nz,noise1 ; delay loop.
pop bc
djnz noise0 ; next step.
pop de
ld a,e
sub 24 ; size of step.
cp 30 ; end of range.
ret z
ret c
ld e,a
cpl
noise3
ld b,40 ; silent period.
noise4
djnz noise4
dec a
jr nz,noise3
jr noise2
ret
; this is the noise used when the piece drops one square
autodropnoise
ld hl,300 ; starting pitch.
ld b, 2 ; length of pitch bend.
adn1
push bc
push hl ; store pitch.
ld de,1 ; very short duration.
call 949 ; ROM beeper routine.
pop hl ; restore pitch.
inc hl ; pitch going up.
pop bc
djnz adn1 ; repeat.
ret
; this is the routine that draws the screen
drawscreen
call 3503 ; clear the screen
ld hl, msg_newscreen_level
call print_message
; now print the level
ld a,CC_AT
rst 16
ld a,12 ;x position
rst 16
ld a,18 ;y position
rst 16
ld a,7 ;colour white
ld a,(currentlevel)
cp 10
jr z,ds20
add a,48 ; add ASCII to get correct character
ld c,a
rst 16
jr ds21
ds20
;code for handling level 10
ld a,49 ; ASCII char for '1'
rst 16
ld a,48; ASCII char for '0'
rst 16
ds21
ld b,75 ; time to pause (50 frames a sec, 1.5 secs wait)
ds19
halt ; wait for an interrupt.
djnz ds19 ; repeat.
; to improve performance, we initially draw blocks whereever one of the shapes will be drawn
; we then simply change their attribute colour to show or hide them
call setupnextshape
call setupsavedshape
call setupplayarea
; draw the saved shape
call drawsavedshape
; we call selectnewpiece twice so we have a value for current and next shape
call selectnewpiece
call selectnewpiece
; reset the number of pieces played this level (to skip over the 2 select new piece calls above)
xor a
ld (piecesthislevel),a
ld b,21
dsloop1
ld a,CC_AT
rst 16
ld a,b
rst 16
ld a,11
rst 16
ld a,2 ;wall colour
ld (23695),a ; set our temporary screen colours.
ld a,146 ; ASCII code for User Defined Graphic 'C'.
rst 16
djnz dsloop1
ld b,21
dsloop2
ld a,CC_AT
rst 16
ld a,b
rst 16
ld a,22 ; y co-ordinate
rst 16
ld a,2 ;wall colour
ld (23695),a ; set our temporary screen colours.
ld a,146 ; ASCII code for User Defined Graphic 'C'.
rst 16
djnz dsloop2
ld a,12
ld (wallpos),a
ld d,21 ; default position
ld a,(upsidedown)
cp 1
jr z, ds1
jr ds2
ds1
ld d,0
ds2
ld b,10
dsloop3
ld a,CC_AT
rst 16
ld a,d
rst 16
ld a,(wallpos) ; y co-ordinate
rst 16
ld a,(wallpos)
inc a
ld (wallpos),a
ld a,2 ;wall colour
ld (23695),a ; set our temporary screen colours.
ld a,149 ; ASCII code for User Defined Graphic 'F'.
rst 16
djnz dsloop3
; now we draw the end of the pipes
ld a,(upsidedown)
cp 1
jr z,ds12
ds11
ld b,0 ;end of pipes at top
ld c,147 ; ASCII code for User Defined Graphic 'D'
jr ds13
ds12
ld b,21 ;upside down so end of pipes at bottom
ld c,148 ; ASCII code for User Defined Graphic 'E'
ds13
ld a,CC_AT
rst 16
ld a,b ;x position
rst 16
ld a,11 ;y position
rst 16
ld a,2 ;colour red
ld (23695),a ; set our temporary screen colours.
ld a,c ; graphic
rst 16
ld a,CC_AT
rst 16
ld a,b
rst 16
ld a,22 ;y position
rst 16
ld a,2 ;colour red
ld (23695),a ; set our temporary screen colours.
ld a,c ;graphic
rst 16
ds14
; now we draw the corner pieces
ld a,(upsidedown)
cp 1
jr z,ds16
ds15
ld b,21 ;corner of pipes at bottom
ld c,150 ; ASCII code for User Defined Graphic 'G'
ld d,152 ; ASCII code for User Defined Graphic 'I'
jr ds17
ds16
ld b,0 ;corner of pipes at top
ld c,151 ; ASCII code for User Defined Graphic 'H'
ld d,153 ; ASCII code for User Defined Graphic 'J'
ds17
ld a,CC_AT
rst 16
ld a,b ;x position
rst 16
ld a,11 ;y position
rst 16
ld a,2 ;colour red
ld (23695),a ; set our temporary screen colours.
ld a,c ; graphic
rst 16
ld a,CC_AT
rst 16
ld a,b ;x position
rst 16
ld a,22 ;y position
rst 16
ld a,2 ;colour red
ld (23695),a ; set our temporary screen colours.
ld a,d ; graphic
rst 16
ds18
; now we check for any special cases
ld a,(currentlevel)
cp 4 ; shooting stars
jr z,ds3
cp 5 ; more stars
jr z,ds4
cp 6 ; level letter F
jr z,ds5
cp 7 ; mirror level
jr z,ds6
cp 9
jr z,ds7
jr ds8 ; no matches to special cases
ds3
; draw 2 stars on screen
call shootingstar
call shootingstar
jr ds8
ds4
; draw 2 stars on screen
call shootingstar
call shootingstar
jr ds8
ds5
call drawletterf
jr ds8
ds6
call drawmirror
jr ds8
ds7
; draw 2 stars on screen
call shootingstar
call shootingstar
ds8
; print the score section
ld hl,msg_game_score
call print_message
call printscore
; print the high score section
ld hl,msg_game_highscore
call print_message
call printhighscore
; print ghost section
ld hl, msg_game_ghost
call print_message
ld a,(ghostactive)
cp 1
jr z,ds9
ld hl, msg_game_ghost_inactive
jr ds10
ds9
ld hl, msg_game_ghost_active
ds10
call print_message
; print next shape wording
ld hl, msg_game_nextpiece
call print_message
; print saved shape section
ld hl, msg_game_savedpiece
call print_message
; print lines completed section
ld hl,msg_game_line
call print_message
call printlines
; print the name of the level
call printlevelname
;align shape to correct orientation
call setblockshapes
; now we draw our shape
ld hl, colourlookuptable
ld de,(currentshape)
ld d,0 ;de is 16 bit, but we are actually trying to add an 8 bit to a 16bit so remove any possible extras
add hl,de
ld a,(hl)
ld (blockcolour),a ; now draw block in new position
call showcurrentshape
; final action of setup, set music to 'Hall of the Mountain King'
ld bc,hallofthemountainking
ld (gamemusic),bc
ld a, 6
ld (musicspeed),a
xor a
ld (noteindex),a ; so music plays at start of song
ret
; level 6 is called the letter F. We draw a letter F on-screen
drawletterf
ld c,20 ; starting x position
ld b,5
dlf1
ld a,CC_AT
rst 16
ld a,c
rst 16
ld a,16 ;y position
rst 16
ld a,4 ;colour green
ld (23695),a ; set our temporary screen colours.
ld a,144 ; ASCII code for User Defined Graphic 'A'.
rst 16
dec c ; drop c one square (up the screen)
djnz dlf1
ld a,CC_AT
rst 16
ld a,18
rst 16
ld a,17 ;y position
rst 16
ld a,4 ;colour green
ld (23695),a ; set our temporary screen colours.
ld a,144 ; ASCII code for User Defined Graphic 'A'.
rst 16
ld a,CC_AT
rst 16
ld a,16
rst 16
ld a,17 ;y position
rst 16
ld a,4 ;colour green
ld (23695),a ; set our temporary screen colours.
ld a,144 ; ASCII code for User Defined Graphic 'A'.
rst 16
ld a,CC_AT
rst 16
ld a,16
rst 16
ld a,18 ;y position
rst 16
ld a,4 ;colour green
ld (23695),a ; set our temporary screen colours.
ld a,144 ; ASCII code for User Defined Graphic 'A'.
rst 16
ret
; level 7 is called Mirror, this draws a mirrored F on screen
drawmirror
ld c,20 ; starting x position
ld b,5
dm1
ld a,CC_AT
rst 16
ld a,c
rst 16
ld a,16 ;y position
rst 16
ld a,4 ;colour green
ld (23695),a ; set our temporary screen colours.
ld a,144 ; ASCII code for User Defined Graphic 'A'.
rst 16
dec c ; drop c one square (up the screen)
djnz dm1
ld c,14
ld b,5
dm2
ld a,CC_AT
rst 16
ld a, 16
rst 16
ld a,c
rst 16
ld a,4 ;colour green
ld (23695),a ; set our temporary screen colours.
ld a,144 ; ASCII code for User Defined Graphic 'A'.
rst 16
inc c
djnz dm2
ld c,15
ld b,3
dm3
ld a,CC_AT
rst 16
ld a, 18
rst 16
ld a,c
rst 16
ld a,4 ;colour green
ld (23695),a ; set our temporary screen colours.
ld a,144 ; ASCII code for User Defined Graphic 'A'.
rst 16
inc c
djnz dm3
ret
; this sets up the variables for a new level
setuplevel
xor a
ld (upsidedown),a
ld a,(currentlevel)
cp 3
jr z,sul1
jr sul2
sul1
ld a,1
ld (upsidedown),a
sul2
; reset allowed swap
ld a,1
ld (allowedswap),a
;reset the lines completed
ld hl,totalrowscompleted
ld (hl),'0'
inc hl
ld (hl),'0'
xor a
ld (totalrowscompletednum),a
; reset the number of pieces played this level
xor a
ld (piecesthislevel),a
; calculate the lines required for this level
ld hl,targetlinesforthislevel
ld (hl),'0'
inc hl
ld (hl),'0'
call calculatelinesforthislevel
ld hl, linesneededperlevel
ld de,(currentlevel)
dec de
ld d,0 ;de is 16 bit, but we are actually trying to add an 8 bit to a 16bit so remove any possible extras
add hl,de
ld a,(hl)
ld (targetlinesforthislevelnum),a
; ensure block starts in start position
ld a,(startx)
ld (plx),a
ld a,(starty)
ld (ply),a
; if upside down we need to modify the x position
ld a,(upsidedown)
cp 1
jr z,sul3
jr sul4
sul3
ld a,(upsidedownstartx)
ld (plx),a
sul4
ret
; this setups the variables for a new level and draws the screen
newlevel
; switch off in-game music, music set to silent (will be re-activated later after new screen drawn)
ld bc,silentmusic
ld (gamemusic),bc
xor a
ld (noteindex),a ; so (silent) music plays at start of song
call setuplevel
call drawscreen
ld hl,pretim
ld a,(23672)
ld (hl),a
ret
; this does the level special action
; for example put a random square on the screen or slide a floor level or
; rise the entire board. There are special actions for levels 4,5,8,9 and 10
levelspecialaction
ld a,(currentlevel)
cp 4
jp z,lsa1
cp 5
jp z,lsa2
cp 8
jp z,lsa3
cp 9
jp z,lsa4
cp 10
jp z,lsa5
ret
lsa1
; level 4, needs shooting stars every 5 pieces
ld a,(piecesthislevel)
ld d,a
ld e,5
call getmodulo
; a will be 0 if evenly divisible by 5
cp 0
ret nz
call shootingstar
ret
lsa2
; level 5, needs shooting stars every 5 pieces
ld a,(piecesthislevel)
ld d,a
ld e,5
call getmodulo
; a will be 0 if evenly divisible by 5
cp 0
ret nz
call shootingstar
ret
lsa3
; level 8, sliding floor
; a random level is moved either left or right every 4 pieces
ld a,(piecesthislevel)
ld d,a
ld e,4
call getmodulo
; a will be 0 if evenly divisible by 4
cp 0
ret nz
call slidingfloor
ret
lsa4
; level 9, needs shooting stars every 5 pieces and sliding floor
ld a,(piecesthislevel)
ld d,a
ld e,5
call getmodulo
; a will be 0 if evenly divisible by 5
cp 0
jp nz,lsa6
call shootingstar
lsa6
ld a,(piecesthislevel)
ld d,a
ld e,4
call getmodulo
; a will be 0 if evenly divisible by 4
cp 0
ret nz
call slidingfloor
ret
lsa5
ld a,(piecesthislevel)
ld d,a
ld e,10
call getmodulo
; a will be 0 if evenly divisible by 10
cp 0
ret nz
call risingfloor
ret
; routine for calculating modulo
; Integer divides D by E
; Result in D, remainder in A
; Clobbers F, B
getmodulo
xor a
ld b,8
gm1
sla d
rla
cp e
jr c,gm2
sub e
inc d
gm2
djnz gm1
ret
; shooting star. This puts a random square somewhere on the playarea. It puts it at least 4
; squares down from the top of the screen to give the player a chance
shootingstar
call rnd
and 15 ;bitmask bits 0, 1, 2 and 3
add a,5 ; to ensure we do not put a block directly in starting position
ld (shootingstarx),a
; now that we have picked the row, need to pick the column
; column must be between 12 and 21 (inclusive)
sst1
call rnd
and 15; bitmask 4 bits
cp 10
jp nc,sst1
sst3
; we now have a value between 0 and 9
add a,12
ld c,a
ld (shootingstary),a
; now see if there is already a block at this position
ld a,(shootingstarx)
ld b,a
call atadd
or 0 ; check if it black/black i.e. empty square
jp nz,sst1
; at this stage we have picked a square and it is blank
; lets draw it on-screen
ld a,CC_AT
rst 16
ld a,(shootingstarx)
rst 16
ld a,(shootingstary)
rst 16
ld a,2 ;colour red
ld (23695),a ; set our temporary screen colours.
ld a,144 ; ASCII code for User Defined Graphic 'A'.
rst 16
ret
; finds a row (that has a square already on that row) and slides it one square left or right
slidingfloor
xor a
ld (slidingcounter),a
sf1
call rnd
and 15 ;bitmask bits 0, 1, 2 and 3
add a,5 ; so picking a level safely below start point
ld (slidingrow),a
; now that we have picked a row, need to ensure there is at least one square already on that
; row, otherwise we will need to pick a new row
; set tmpx to the row to check
ld (tmpx),a
ld a,(playareatopliney)
ld (tmpy),a
ld b,10 ;10 squares in width of play area
sf2
push bc
ld a,(tmpx)
ld b,a
ld a,(tmpy)
ld c,a
call atadd
or 0 ; check if it black/black i.e. empty square
jp nz, sf3 ; found a non black square
ld a,(tmpy)
inc a
ld (tmpy),a
pop bc
djnz sf2
; if got here then no squares on the line, pick a new row
ld a,(slidingcounter)
inc a
cp 20
ret z ; if 20 attempts to find a row, give up
ld (slidingcounter),a
jr sf1
sf3
; so we have found a row with at least one block on it, now lets shift it
;pick whether to go left (0) or right (1)
pop bc ; to handle first push within sf2
call rnd
and 15; bitmask 4 bits
ld d,a
ld e,2
call getmodulo
cp 1
jp z,sf4 ; going right
;we are going left so get value at column 12
ld c,12
ld a,(slidingrow)
ld b,a
call atadd
ld (slidingwraparoundcolour),a
ld a,12 ; starting point is column 12
ld (tmpy),a
ld b,9 ; one less than normal
sf5
push bc
ld a,(slidingrow)
ld b,a
ld a,(tmpy)
inc a
ld c,a
call atadd
ld (slidingtempcolour),a ; this now contains the colour of the square directly to the right
ld a,(tmpy)
ld c,a
call atadd
ld a,(slidingtempcolour)
ld (hl),a
ld a,(tmpy) ; next square in the row
inc a
ld (tmpy),a
pop bc
djnz sf5
sf6
; now place the wrap around colour, place at column 21
ld a,(slidingrow)
ld b,a
ld c,21
call atadd
ld a,(slidingwraparoundcolour)
ld (hl),a
ret ;finished
sf4
;get the value at column 21
ld c,21
ld a,(slidingrow)
ld b,a
call atadd
ld (slidingwraparoundcolour),a
ld a,21 ; starting point is column 21
ld (tmpy),a
ld b,9 ; one less than normal
sf7
push bc
ld a,(slidingrow)
ld b,a
ld a,(tmpy)
dec a
ld c,a
call atadd
ld (slidingtempcolour),a ; this now contains the colour of the square directly to the left
ld a,(tmpy)
ld c,a
call atadd
ld a,(slidingtempcolour)
ld (hl),a
ld a,(tmpy) ; next square in the row
dec a
ld (tmpy),a
pop bc
djnz sf7
sf8
; now place the wrap around colour, place at column 12
ld a,(slidingrow)
ld b,a
ld c,12
call atadd
ld a,(slidingwraparoundcolour)
ld (hl),a
ret
; this is the special action for level 10. Every 10 pieces the playarea raises one level
; and random squares are added to that level
risingfloor
ld a,(playareatopliney)
ld (tmpy),a
xor a
ld (tmpx),a
rf1
ld b,10 ; inner loop
rf2
push bc
ld a,(tmpx)
inc a ; we increase by 1 as we are copying the line below
ld b,a
ld a,(tmpy)
ld c,a
call atadd
ld (blockcolour),a ; this now contains the colour of the square directly above
ld a,(tmpx)
ld b,a
call atadd
ld a,(blockcolour)
ld (hl),a
ld a,(tmpy) ; next square in the row
inc a
ld (tmpy),a
pop bc
djnz rf2
; finished inner loop, i.e. that row, increase x by 1 and reset y
ld a,(tmpx)
inc a
ld (tmpx),a
ld a,(playareatopliney)
ld (tmpy),a
ld a,(tmpx)
cp 20 ; at 21 we are at the bottom of the screen, 20 would try to read from the bricks (+1)
jr nz, rf1
; at this stage we have dropped everything, now now erase the bottom line
ld a,20
ld (tmpx),a
call eraseline
; now fill this line with random squares
ld a,(playareatopliney)
ld (tmpy),a
ld b,10 ;10 squares in width of play area
rf3
push bc
call rnd
and 15; bitmask 4 bits
ld d,a
ld e,2
call getmodulo
cp 1
jp z,rf5
rf4
ld a,(tmpx)
ld b,a
ld a,(tmpy)
ld c,a
call atadd
ld (hl),5 ; set the attribute at this square to be 5, cyan
rf5
ld a,(tmpy)
inc a
ld (tmpy),a
pop bc
djnz rf3
ret
; this checks if we have completed the level or won the game
checklevelcomplete
ld a,(targetlinesforthislevelnum)
ld b,a
ld a,(totalrowscompletednum)
cp b
jr nc,clc1
ret ; target for level nor reached, can exit routine
clc1
ld a,(currentlevel)
inc a
ld (currentlevel),a
cp 11
jp nc,youwin
; add delay
ld hl, 50000
clc2
dec hl
ld a,h
or l
jr nz,clc2
jp newlevel
;checks the score against the high score and sets the score to be the high score if larger
checkhighscore
xor a
ld (newhighscore),a
ld hl,highscore
ld c,(hl)
ld hl,score
ld a,(hl)
cp c
jr z,chs2 ;if equal we check next digit
jr nc,chs1 ; accumulator (score) is greater than high score
ret ; otherwise high score is still bettter
chs2
inc hl ; advance score pointer
ld a,(hl)
ld hl,highscore+1
ld c,(hl)
cp c
jr z,chs3
jr nc,chs1
ret
chs3
inc hl ;advance high score pointer
ld c,(hl)
ld hl,score+2
ld a,(hl)
cp c
jr z,chs4
jr nc,chs1
ret
chs4
inc hl ; advance score pointer
ld a,(hl)
ld hl,highscore+3
ld c,(hl)
cp c
jr z,chs5
jr nc,chs1
ret
chs5
inc hl ;advance high score pointer
ld c,(hl)
ld hl,score+4
ld a,(hl)
cp c
jr z,chs6
jr nc,chs1
ret
chs6
inc hl ; advance score pointer
ld a,(hl)
ld hl,highscore+5
ld c,(hl)
cp c
jr nc,chs1
ret ;if reach here score is less than high score
chs1
ld a,1
ld (newhighscore),a ;new high score
ld de,highscore
ld hl,score
ld bc,6
ldir
ret
; this allows the player to switch the music on off
switchmusiconoff
ld a,(gamemusicenabled)
cp 0
jr nz,smo1
; if here then music is currently on, switch off
ld a,1
ld (gamemusicenabled),a
ret
smo1
; if here then music is currently on, we switch off
xor a
ld (gamemusicenabled),a
ret
; the in-game music section
org 40000
gamemusic defb 0,0
musicspeed defb 6
;alternative version 'In the Hall of the Mountain King'
;set musicspeed value to 6 to use
hallofthemountainking
defb 48,48,43,43,40,40,36,36,32,32,40,40,32,32
defb 32,32
defb 34,34,43,43,34,34,34,34,36,36,45,45,36,36,36,36
defb 48,48,43,43,40,40,36,36,32,32,40,40,32,32
defb 24,24,27,27,32,32,40,40,32,32,27,27,27,27,27,27
defb 27,27
defb 128,128,114,114,102,102,96,96,86,86,102,102,86,86
defb 86,86,81,81,102,102,81,81,81,81,86,86,102,102,86,86
defb 86,86
defb 128,128,114,114,102,102,96,96,86,86,102,102,86,86
defb 86,86,81,81,102,102,81,81,81,81,86,86,86,86
defb 86,86,86,86,255
; music played when you win
;set cp value to 10 in playmusic to use
youwinmusic
defb 18,24,23,20,23,24,27,27
defb 23,18,20,23,24,23,20,18
defb 23,27,27,27,24,23,20,17
defb 13,15,17,18,23,18,20,23
defb 24,24,23,20,18,23,27,27
defb 1,18,23,20,24,23,27,28
defb 24,1,18,23,20,24,23,18
defb 13,14,255
; 'If I were a rich man' from Jet Set Willy
ifiwerearichman
defb 86,96,86,96,102,102,128,128,128,128,102,96,86,96,86,96
defb 102,96,86,76,72,76,72,76,86,86,86,86,86,86,86,86
defb 64,64,64,64,68,68,76,76,86,96,102,96,86,86,102,102
defb 81,86,96,86,81,81,96,96,64,64,64,64,64,64,64,64,255
; heart and soul, speed 11
heartandsoul
defb 91,91,91,0,91,96,108,96
defb 91,81,0,72,72,72,0,72
defb 81,91,81,72,68,0,61,0
defb 91,0,54,61,68,72,81,72
defb 81,91,0,0,255
; silent music
silentmusic
defb 0,0,0,255
noteindex defb 0
musicpauseindex defb 0
playmusic
; now see if player wants music
ld a,(gamemusicenabled)
cp 0
ret z
; we do not play a not every interrupt call. This piece of code allows us
; to play a note every X (musicspeed) interrupts
ld a,(musicspeed)
ld d,a
ld a,(musicpauseindex)
inc a
ld (musicpauseindex),a
cp d
jr nc,pm1
ret
pm1
xor a
ld (musicpauseindex),a
jp playnote
; this music routine adapted from manic miner code
; 255 means end of music data, back to beginning of music data
; 0 is a pause, don't play anything
playnote
ld a,(noteindex)
ld e,a
ld d,0
ld hl,(gamemusic)
add hl,de
ld a,(hl)
cp 255 ; end of song
jr z,pn3
cp 0 ; pause/silence
jr z,pn6
; not end of song, increase index
ld a,(noteindex)
inc a
ld (noteindex),a
jr pn4
pn3
xor a
ld (noteindex),a
jr playnote
pn4
xor a ; set border colour to 0
ld e,(hl)
ld bc,3
pn1
out (254),a
dec e
jr nz,pn2
ld e,(hl)
xor 24
pn2
djnz pn1
dec c
jr nz,pn1
ret
; pause routine (0 in music data), increases index, but does not play sound
pn6
ld a,(noteindex)
inc a
ld (noteindex),a
ret
org 51400 ; location of our interrupt routine
Interrupt
di ; disable interrupts
push af ; preserve registers.
push bc
push hl
push de
push ix
; here is where we put the calls to the routines we want to execute during interrupts
; e.g. play music etc.
; we increment the frames counter as this is used to determine the rate of drop of the
; main game piece
ld hl,23672 ; frames counter.
inc (hl) ; move it along.
call playmusic
; end of our routines
pop ix ; restore registers.
pop de
pop hl
pop bc
pop af
ei ; always re-enable interrupts before returning.
reti ; done (return from interrupt)
org 65024
; pointers to interrupt routine.
; 257 instances of '200'
defb 200,200,200,200,200,200,200,200
defb 200,200,200,200,200,200,200,200
defb 200,200,200,200,200,200,200,200
defb 200,200,200,200,200,200,200,200
defb 200,200,200,200,200,200,200,200
defb 200,200,200,200,200,200,200,200
defb 200,200,200,200,200,200,200,200
defb 200,200,200,200,200,200,200,200
defb 200,200,200,200,200,200,200,200
defb 200,200,200,200,200,200,200,200
defb 200,200,200,200,200,200,200,200
defb 200,200,200,200,200,200,200,200
defb 200,200,200,200,200,200,200,200
defb 200,200,200,200,200,200,200,200
defb 200,200,200,200,200,200,200,200
defb 200,200,200,200,200,200,200,200
defb 200,200,200,200,200,200,200,200
defb 200,200,200,200,200,200,200,200
defb 200,200,200,200,200,200,200,200
defb 200,200,200,200,200,200,200,200
defb 200,200,200,200,200,200,200,200
defb 200,200,200,200,200,200,200,200
defb 200,200,200,200,200,200,200,200
defb 200,200,200,200,200,200,200,200
defb 200,200,200,200,200,200,200,200
defb 200,200,200,200,200,200,200,200
defb 200,200,200,200,200,200,200,200
defb 200,200,200,200,200,200,200,200
defb 200,200,200,200,200,200,200,200
defb 200,200,200,200,200,200,200,200
defb 200,200,200,200,200,200,200,200
defb 200,200,200,200,200,200,200,200
defb 200
end 24576 ; assembler directive, says this is the end of the code and where the entry point is
|
src/dnscatcher/network/udp/dnscatcher-network-udp.ads | DNSCatcher/DNSCatcher | 4 | 10338 | <gh_stars>1-10
-- Copyright 2019 <NAME> <<EMAIL>>
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to
-- deal in the Software without restriction, including without limitation the
-- rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-- sell copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in
-- all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-- THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-- DEALINGS IN THE SOFTWARE.
package DNSCatcher.Network.UDP is
end DNSCatcher.Network.UDP;
|
Script/7.asm | Sadman-Alam-Pranto49/CSE331L_Section_7_Summer20_NSU_Final | 0 | 178631 |
.MODEL SMALL
.STACK 100h
.DATA
N1 DB ?
N2 DB ?
.CODE
MOV AX, @DATA
MOV DS, AX
MOV AH, 1
INT 21h
MOV N1, AL
SUB N1, 30h
MOV AH, 1
INT 21h
MOV N2, AL
SUB N2, 30h
MOV BL, N1
MOV BH, N2
SUB BH, BL
CMP BH, 0
JG N2GREATER
JS N2SMALLER
JMP EXIT
N2GREATER:
MOV AH, 2
MOV DL, N1
ADD DL, 30h
INT 21h
JMP EXIT
N2SMALLER:
MOV AH, 2
MOV DL, N2
ADD DL, 30h
INT 21h
JMP EXIT
EXIT:
MOV AH, 4Ch
INT 21h
|
Lab1/Lab1.g4 | pashokred/mini_spreadsheet | 3 | 4332 | <reponame>pashokred/mini_spreadsheet<filename>Lab1/Lab1.g4<gh_stars>1-10
grammar Lab1;
/*
* Parser Rules
*/
compileUnit : expression EOF;
expression :
LPAREN expression RPAREN #ParenthesizedExpr
| expression EXPONENT expression #ExponentialExpr
| expression operatorToken=(MULTIPLY | DIVIDE | MOD | DIV) expression #MultiplicativeExpr
| expression operatorToken=(ADD | SUBTRACT) expression #AdditiveExpr
| expression operatorToken=(GT | GE | LT | LE) expression #RelationalExpr
| expression operatorToken=(EQ | NE) #EqualityExpr
| IDENTIFIER #IdentifierExpr
| NUMBER #NumberExpr
;
/*
* Lexer Rules
*/
NUMBER : INT ('.'INT)?;
IDENTIFIER : [a-zA-Z]+[1-9] | [a-zA-Z]+[0-9]+;
INT : ('0'..'9')+;
EXPONENT : '^';
MULTIPLY : '*';
DIVIDE : '/';
SUBTRACT : '-';
ADD : '+';
LPAREN : '(';
RPAREN : ')';
MOD: 'mod';
DIV: 'div';
GT : '>';
GE : '>=';
LT : '<';
LE : '<=';
EQ : '=';
NE : '<>';
WS : [ \t\r\n] -> channel(HIDDEN); |
Transynther/x86/_processed/US/_zr_/i9-9900K_12_0xca_notsx.log_3877_1873.asm | ljhsiun2/medusa | 9 | 81608 | <reponame>ljhsiun2/medusa<filename>Transynther/x86/_processed/US/_zr_/i9-9900K_12_0xca_notsx.log_3877_1873.asm
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r14
push %r9
push %rcx
push %rdi
push %rsi
lea addresses_UC_ht+0x13a47, %r11
nop
nop
nop
nop
cmp %rsi, %rsi
movl $0x61626364, (%r11)
nop
nop
nop
inc %r9
lea addresses_UC_ht+0x12767, %rsi
lea addresses_WT_ht+0x367, %rdi
clflush (%rdi)
nop
nop
sub %r14, %r14
mov $30, %rcx
rep movsl
sub %rcx, %rcx
pop %rsi
pop %rdi
pop %rcx
pop %r9
pop %r14
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r12
push %r8
push %rbx
push %rcx
push %rdi
push %rsi
// Store
lea addresses_UC+0x1e567, %r10
nop
nop
nop
nop
nop
xor %r12, %r12
movw $0x5152, (%r10)
nop
nop
nop
nop
cmp $11830, %rbx
// Store
lea addresses_A+0xe367, %r10
nop
nop
nop
nop
cmp %rcx, %rcx
mov $0x5152535455565758, %r8
movq %r8, %xmm3
vmovups %ymm3, (%r10)
nop
nop
nop
nop
add %r10, %r10
// Store
lea addresses_PSE+0x1b67, %r10
nop
nop
nop
and $16307, %rcx
movl $0x51525354, (%r10)
nop
nop
sub %r8, %r8
// Store
mov $0xed3890000000bcb, %r12
add $6043, %r8
mov $0x5152535455565758, %rcx
movq %rcx, (%r12)
nop
nop
nop
nop
nop
add $34357, %rdi
// Faulty Load
lea addresses_US+0x1d767, %r8
xor $43502, %rbx
mov (%r8), %di
lea oracles, %r8
and $0xff, %rdi
shlq $12, %rdi
mov (%r8,%rdi,1), %rdi
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %r8
pop %r12
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_US', 'NT': False, 'AVXalign': True, 'size': 4, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_UC', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 9}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_A', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 10}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_PSE', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 9}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_NC', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 2}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_US', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': True, 'size': 4, 'congruent': 5}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 11, 'type': 'addresses_UC_ht'}, 'dst': {'same': False, 'congruent': 9, 'type': 'addresses_WT_ht'}}
{'00': 3877}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
src/test/ref/c64dtv-color.asm | jbrandwood/kickc | 2 | 19292 | // Test C64DTV v2 256-colors and the 16-color redefinable palette
// Commodore 64 PRG executable file
.file [name="c64dtv-color.prg", type="prg", segments="Program"]
.segmentdef Program [segments="Basic, Code, Data"]
.segmentdef Basic [start=$0801]
.segmentdef Code [start=$80d]
.segmentdef Data [startAfter="Code"]
.segment Basic
:BasicUpstart(main)
.const DTV_FEATURE_ENABLE = 1
.const DTV_BORDER_OFF = 2
.const DTV_HIGHCOLOR = 4
.const DTV_BADLINE_OFF = $20
/// $D012 RASTER Raster counter
.label RASTER = $d012
/// $D021 Background Color 0
.label BG_COLOR = $d021
/// Feature enables or disables the extra C64 DTV features
.label DTV_FEATURE = $d03f
/// Controls the graphics modes of the C64 DTV
.label DTV_CONTROL = $d03c
/// Defines colors for the 16 first colors ($00-$0f)
.label DTV_PALETTE = $d200
.segment Code
main: {
// asm
sei
// *DTV_FEATURE = DTV_FEATURE_ENABLE
lda #DTV_FEATURE_ENABLE
sta DTV_FEATURE
// *DTV_CONTROL = DTV_HIGHCOLOR | DTV_BORDER_OFF | DTV_BADLINE_OFF
lda #DTV_HIGHCOLOR|DTV_BORDER_OFF|DTV_BADLINE_OFF
sta DTV_CONTROL
__b1:
// while(*RASTER!=$40)
lda #$40
cmp RASTER
bne __b1
// *BG_COLOR = 0
// Create rasterbars
lda #0
sta BG_COLOR
ldx #$31
__b3:
// asm
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
// (*BG_COLOR)++;
inc BG_COLOR
// for (byte r : $31..$ff)
inx
cpx #0
bne __b3
ldx #0
// Rotate palette
__b4:
// DTV_PALETTE[c] = palette[c]
lda palette,x
sta DTV_PALETTE,x
// palette[c]++;
inc palette,x
// for(byte c : 0..$f)
inx
cpx #$10
bne __b4
jmp __b1
.segment Data
palette: .byte 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, $a, $b, $c, $d, $e, $f
}
|
oeis/082/A082383.asm | neoneye/loda-programs | 11 | 95379 | <filename>oeis/082/A082383.asm<gh_stars>10-100
; A082383: a(0)=1, a(n)=2^n+n-2*a(n-1).
; Submitted by <NAME>
; 1,1,4,3,14,9,52,31,202,117,800,459,3190,1825,12748,7287,50978,29133,203896,116515,815566,466041,3262244,1864143,13048954,7456549,52195792,29826171,208783142,119304657,835132540,477218599,3340530130,1908874365,13362120488,7635497427,53448481918,30541989673,213793927636,122167958655,855175710506,488671834581,3420702841984,1954687338283,13682811367894,7818749353089,54731245471532,31274997412311,218924981886082,125099989649197,875699927544280,500399958596739,3502799710177070,2001599834386905
mov $4,1
lpb $0
sub $0,1
add $2,1
mov $3,$1
mul $4,2
add $2,$4
mov $1,$2
sub $1,$3
mul $1,2
lpe
mov $0,$3
div $0,2
add $0,1
|
oeis/015/A015523.asm | neoneye/loda-programs | 11 | 90057 | <reponame>neoneye/loda-programs<gh_stars>10-100
; A015523: a(n) = 3*a(n-1) + 5*a(n-2), with a(0)=0, a(1)=1.
; Submitted by <NAME>(s3)
; 0,1,3,14,57,241,1008,4229,17727,74326,311613,1306469,5477472,22964761,96281643,403668734,1692414417,7095586921,29748832848,124724433149,522917463687,2192374556806,9191710988853,38537005750589,161569572196032,677393745341041,2840029097003283,11907056017715054,49921313538161577,209299220703060001,877504229799987888,3679008792915263669,15424547527745730447,64668686547813509686,271128797282169181293,1136729824585575092309,4765833460167571183392,19981149503430589011721,83772615811129622952123
lpb $0
sub $0,1
mov $2,$3
mul $2,7
mul $3,2
add $3,$1
add $1,$2
add $3,1
lpe
mov $0,$3
|
levels.asm | duduFreire/hellTakerASM | 0 | 177759 | <gh_stars>0
.data
levels:
.string "000000000000000wp00000wwmww00000wmwm00000ww00000000wbwwbw0000wbwbwwg00"
.string "000000000000wwww000000m0ssww000ws00zzb000ww00wsw000pw00wmw0000000gwm00"
.string "0000gggw000000000t00000wsswwp0000s0s0ww0000wwmss000k0s0s0w000wwwwwmw00"
.string "00000000000p0kwb00000wbszwtw000bwbwbbwg00wbwbwbbw000wbwbw0000000000000"
.string "0000000wg0000000wtbw0000p0awbw0000w0wawa0000m0bbbb0000wwawwa000000000k"
# moves
movesLabel:
.byte 23, 24, 32, 23, 27
.include "resources/mainMenuImage.data"
.include "resources/chapterSelectImage.data"
imagesLabel:
.include "resources/pandemonicaImage.s"
.include "resources/modeusImage.s"
.include "resources/cerberusImage.s"
.include "resources/malinaImage.s"
.include "resources/zdradaImage.s"
correctKeys:
.byte '2', '2', '1', '1', '1'
successImages:
.include "resources/pandemonicaD2.data"
.include "resources/modeusD2.data"
.include "resources/cerberusD2.data"
.include "resources/malinaD2.data"
dialogueImages:
.include "resources/pandemonicaD1.s"
.include "resources/modeusD1.data"
.include "resources/cerberusD1.data"
.include "resources/malinaD1.data"
.include "resources/zdradaD1.data"
.include "resources/victoryScreen.data"
.include "resources/badEndImage.s"
# song length, notes
deathSong:
.word 53
52,577,60,577,52,288,53,288,55,288,59,2596,52,577,60,577,52,288,53,288,55,288,59,2019,43,288,45,288,50,577,48,577,50,577,52,577,55,288,52,288,60,1154,50,288,52,288,50,865,52,144,50,144,48,577,48,288,44,288,43,288,52,577,52,288,60,577,43,288,45,288,50,577,48,577,50,577,52,577,55,288,52,288,60,1154,50,288,52,288,50,865,52,144,50,144,48,577,48,288,44,288,43,577,52,288,52,577
winSong:
.word 71
69,178,69,178,65,178,62,357,62,357,67,357,67,357,67,178,71,178,71,178,72,178,74,178,72,178,72,178,72,178,67,357,65,357,69,357,69,357,69,178,67,178,67,178,69,178,67,178,69,178,69,178,65,178,62,357,62,357,67,357,67,357,67,178,71,178,71,178,72,178,74,178,72,178,72,178,72,178,67,357,65,357,69,357,69,357,69,178,67,178,67,178,69,178,67,178,69,178,69,178,65,178,62,357,62,357,67,357,67,357,67,178,71,178,71,178,72,178,74,178,72,178,72,178,72,178,69,357,65,357,69,357,69,357,69,178,67,178,67,178,67,178
menuSong: .word 115
48,405,52,405,55,405,60,405,62,405,55,405,52,405,62,405,64,405,55,405,52,405,64,405,57,405,53,405,48,405,57,405,55,405,52,405,48,405,52,811,55,405,52,405,48,405,47,405,48,405,48,1216,36,405,43,101,44,304,43,405,36,405,48,405,52,405,55,405,62,405,55,405,52,405,62,405,64,405,55,405,52,405,64,405,57,405,53,405,48,405,57,405,55,405,52,405,48,405,52,811,55,405,52,405,48,405,62,405,64,405,64,1622,36,405,38,405,40,405,43,405,47,405,55,405,57,405,53,405,48,405,57,405,55,405,52,405,48,405,55,405,50,405,48,405,36,405,38,405,52,405,47,405,43,405,52,405,59,405,50,405,47,405,59,405,59,202,57,202,57,405,57,1622,36,405,38,405,40,405,43,405,47,405,52,405,57,405,53,405,48,405,57,405,55,405,52,405,48,405,55,405,50,405,48,405,36,405,38,405,40,405,43,405,47,405,52,405,41,405,48,405,53,405,57,405,71,405,72,405,72,1622
moveSound: .word 1
25, 100
winSound: .word 1
50, 1000,
deathSound: .word 13
69,500,76,500,74,500,76,500,79,600, 76,1000,0,1200,69,500,76,500,74,500,76,500,81,600,76,1000
|
oeis/158/A158887.asm | neoneye/loda-programs | 11 | 81026 | <filename>oeis/158/A158887.asm
; A158887: a(n) = (n+1)^n * n! * binomial(n-1 + 1/(n+1), n).
; 1,1,4,45,1056,43225,2756160,253586025,31872332800,5252921480961,1099886703552000,285322741626047125,89844523369696972800,33764841634845724313625,14930493174337400252809216,7674506578747060126710260625,4537847065835138804393508864000,3058545845772319630432726903506625,2331143669401405032445866254499840000,1994957384162008017750143322269989717821,1904865845327160935040805009115722547200000,2017900292577983473395350887172424075556265625,2359495886042784546184206945130452517788057600000
sub $2,$0
pow $0,2
mov $3,1
lpb $0
mul $3,$0
add $0,$2
sub $0,1
lpe
mov $0,$3
|
grammar/jsgLexer.g4 | hsolbrig/pyjsg | 3 | 5946 | <filename>grammar/jsgLexer.g4<gh_stars>1-10
lexer grammar jsgLexer;
// A LEXER_ID consists of a cap letter followed by one or more caps digits and underscore
LEXER_ID_REF : LEXER_ID_START_CHAR LEXER_ID_CHAR+ ;
fragment LEXER_ID_START_CHAR : [A-Z] ;
fragment LEXER_ID_CHAR : LEXER_ID_START_CHAR | [0-9_] ;
// AN ID must contain at least one ID_CHAR
ID : (ID_START_CHAR ANY_CHAR*) | LEXER_ID_START_CHAR | (LEXER_ID_START_CHAR LEXER_ID_CHAR* ID_CHAR ANY_CHAR*) ;
fragment ID_START_CHAR : [a-z] | [\u00C0-\u00D6] | [\u00D8-\u00F6] | [\u00F8-\u02FF] | [\u0370-\u037D] |
[\u037F-\u1FFF] | [\u200C-\u200D] | [\u2070-\u218F] | [\u2C00-\u2FEF] |
[\u3001-\uD7FF] | [\uF900-\uFDCF] | [\uFDF0-\uFFFD]; // ignores | [\u10000-\uEFFFF] ;
fragment ID_CHAR : ID_START_CHAR | [\u00B7] | [\u0300-\u036F] | [\u203F-\u2040] ;
fragment ANY_CHAR : ID_CHAR | LEXER_ID_CHAR ;
STRING : '"' (~["] | '\\"')+ '"'
| '\'' (~['] | '\u005c\u0039')+ '\'' ;
INT : [0-9]+ ;
ANY : '.' ;
TERMINALS : '@terminals' -> mode(LEXER) ;
TYPE : '.TYPE' ;
IGNORE : '.IGNORE' ;
MAPSTO : '->' ;
JSON_STRING : '@string' ;
JSON_NUMBER : '@number' ;
JSON_INT : '@int' ;
JSON_BOOL : '@bool' ;
JSON_NULL : '@null' ;
JSON_ARRAY : '@array' ;
JSON_OBJECT : '@object' ;
OBRACKET: '[' ;
CBRACKET: ']' ;
SEMI : ';' ;
DASH : '-' ;
OBRACE : '{' ;
CBRACE : '}' ;
COMMA : ',' ;
STAR : '*' ;
QMARK : '?' ;
PLUS : '+' ;
OPREN : '(' ;
CPREN : ')' ;
BAR : '|' ;
COLON : ':' ;
EQUALS : '=' ;
PASS : [ \t\r\n]+ -> skip;
COMMENT : '#' ~[\r\n]* -> skip;
mode LEXER ;
LEXER_ID : LEXER_ID_S_CHAR LEXER_ID_C+ ;
fragment LEXER_ID_S_CHAR : [A-Z] ;
fragment LEXER_ID_C : LEXER_ID_START_CHAR | [0-9_] ;
LEXER_JSON_STRING : '@string' -> type(JSON_STRING);
LEXER_JSON_NUMBER : '@number' -> type(JSON_NUMBER);
LEXER_JSON_INT : '@int' -> type(JSON_INT);
LEXER_JSON_BOOL : '@bool' -> type(JSON_BOOL);
LEXER_JSON_NULL : '@null' -> type(JSON_NULL);
LEXER_JSON_ARRAY : '@array' -> type(JSON_ARRAY);
LEXER_JSON_OBJECT : '@object' -> type(JSON_OBJECT);
LEXER_SEMI : ';' -> type(SEMI);
LEXER_DASH : '-' -> type(DASH);
LEXER_OBRACE : '{' -> type(OBRACE);
LEXER_CBRACE : '}' -> type(CBRACE);
LEXER_COMMA : ',' -> type(COMMA);
LEXER_STAR : '*' -> type(STAR);
LEXER_QMARK : '?' -> type(QMARK);
LEXER_PLUS : '+' -> type(PLUS);
LEXER_OPREN : '(' -> type(OPREN);
LEXER_CPREN : ')' -> type(CPREN);
LEXER_COLON : ':' -> type(COLON);
LEXER_BAR : '|' -> type(BAR);
LEXER_STRING : ('"' (~["] | '\\"')+ '"'
| '\'' (~['] | '\u005c\u0039')+ '\'') -> type(STRING) ;
LEXER_ANY : '.' -> type(ANY);
LEXER_CHAR_SET : '[' (~[\]] | '\\]')+ ']';
LEXER_INT : [0-9]+ -> type(INT);
LEXER_PASS : [ \t\r\n]+ -> skip;
LEXER_COMMENT : '#' ~[\r\n]* -> skip;
|
agda/Avionics/Bool.agda | RPI-WCL/safety-envelopes-sentinels | 0 | 11222 | module Avionics.Bool where
open import Data.Bool using (Bool; true; false; _∧_; T)
open import Data.Unit using (⊤; tt)
open import Data.Product using (_×_; _,_)
open import Relation.Binary.PropositionalEquality using (_≡_; refl; inspect; [_])
--open import Avionics.Product using (_×_; ⟨_,_⟩)
--TODO: Replace with T⇔≡ from standard library
≡→T : ∀ {b : Bool} → b ≡ true → T b
≡→T refl = tt
T→≡ : ∀ {b : Bool} → T b → b ≡ true
T→≡ {true} tt = refl
T∧→× : ∀ {x y} → T (x ∧ y) → (T x) × (T y)
T∧→× {true} {true} tt = tt , tt
--TODO: Find a way to extract the function below from `T-∧` (standard library)
--T∧→× {x} {y} = ? -- Equivalence.to (T-∧ {x} {y})
×→T∧ : ∀ {x y} → (T x) × (T y) → T (x ∧ y)
×→T∧ {true} {true} (tt , tt) = tt
lem∧ : {a b : Bool} → a ∧ b ≡ true → a ≡ true × b ≡ true
lem∧ {true} {true} refl = refl , refl
∧≡true→×≡ : ∀ {A B : Set} {f : A → Bool} {g : B → Bool}
(n : A) (m : B)
→ f n ∧ g m ≡ true
→ f n ≡ true × g m ≡ true
∧≡true→×≡ {f = f} {g = g} n m fn∧gm≡true = lem∧ {f n} {g m} fn∧gm≡true
|
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c3/c35507m.ada | best08618/asylo | 7 | 15017 | -- C35507M.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 THE ATTRIBUTES 'POS' AND 'VAL' YIELD THE CORRECT
-- RESULTS WHEN THE PREFIX IS A CHARACTER TYPE WITH AN ENUMERATION
-- REPRESENTATION CLAUSE.
-- HISTORY:
-- RJW 06/03/86 CREATED ORIGINAL TEST
-- JLH 07/28/87 MODIFIED FUNCTION IDENT.
-- PWB 05/11/89 CHANGED EXTENSION FROM '.DEP' TO '.ADA'.
WITH REPORT; USE REPORT;
PROCEDURE C35507M IS
TYPE CHAR IS ('A', B);
FOR CHAR USE ('A' => 4, B => 5);
TYPE NEWCHAR IS NEW CHAR;
FUNCTION IDENT (CH : CHAR) RETURN CHAR IS
BEGIN
IF EQUAL (3,3) THEN
RETURN CH;
ELSE
RETURN 'A';
END IF;
END IDENT;
FUNCTION IDENT (CH : NEWCHAR) RETURN NEWCHAR IS
BEGIN
IF EQUAL (3,3) THEN
RETURN CH;
ELSE
RETURN 'A';
END IF;
END IDENT;
BEGIN
TEST( "C35507M" , "CHECK THAT THE ATTRIBUTES 'POS' AND " &
"'VAL' YIELD THE CORRECT RESULTS WHEN THE " &
"PREFIX IS A CHARACTER TYPE WITH AN " &
"ENUMERATION REPESENTATION CLAUSE" );
BEGIN
IF CHAR'POS ('A') /= 0 THEN
FAILED ( "INCORRECT VALUE FOR CHAR'POS('A')" );
END IF;
IF CHAR'POS (B) /= 1 THEN
FAILED ( "INCORRECT VALUE FOR CHAR'POS(B)" );
END IF;
IF CHAR'VAL (0) /= 'A' THEN
FAILED ( "INCORRECT VALUE FOR CHAR'VAL(0)" );
END IF;
IF CHAR'VAL (1) /= B THEN
FAILED ( "INCORRECT VALUE FOR CHAR'VAL(1)" );
END IF;
END;
BEGIN
IF NEWCHAR'POS ('A') /= 0 THEN
FAILED ( "INCORRECT VALUE FOR NEWCHAR'POS('A')" );
END IF;
IF NEWCHAR'POS (B) /= 1 THEN
FAILED ( "INCORRECT VALUE FOR NEWCHAR'POS(B)" );
END IF;
IF NEWCHAR'VAL (0) /= 'A' THEN
FAILED ( "INCORRECT VALUE FOR NEWCHAR'VAL(0)" );
END IF;
IF NEWCHAR'VAL (1) /= B THEN
FAILED ( "INCORRECT VALUE FOR NEWCHAR'VAL(1)" );
END IF;
END;
BEGIN
IF CHAR'POS (IDENT ('A')) /= 0 THEN
FAILED ( "INCORRECT VALUE FOR CHAR'POS('A') WITH " &
"IDENT" );
END IF;
IF NEWCHAR'POS (IDENT (B)) /= 1 THEN
FAILED ( "INCORRECT VALUE FOR NEWCHAR'POS(B) WITH " &
"IDENT" );
END IF;
IF IDENT (NEWCHAR'VAL (IDENT_INT(0))) /= 'A' THEN
FAILED ( "INCORRECT VALUE FOR NEWCHAR'VAL(0) WITH " &
"IDENT" );
END IF;
IF IDENT (CHAR'VAL (IDENT_INT(1))) /= B THEN
FAILED ( "INCORRECT VALUE FOR CHAR'VAL(1) WITH IDENT" );
END IF;
END;
BEGIN
IF CHAR'VAL (IDENT_INT(2)) = B THEN
FAILED ( "NO EXCEPTION RAISED FOR " &
"CHAR'VAL (IDENT_INT(2)) - 1" );
ELSE
FAILED ( "NO EXCEPTION RAISED FOR " &
"CHAR'VAL (IDENT_INT(2)) - 2" );
END IF;
EXCEPTION
WHEN CONSTRAINT_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ( "WRONG EXCEPTION RAISED FOR " &
"CHAR'VAL (IDENT_INT(2))" );
END;
BEGIN
IF NEWCHAR'VAL (IDENT_INT (-1)) = 'A' THEN
FAILED ( "NO EXCEPTION RAISED " &
"FOR NEWCHAR'VAL (IDENT_INT (-1)) - 1" );
ELSE
FAILED ( "NO EXCEPTION RAISED " &
"FOR NEWCHAR'VAL (IDENT_INT (-1)) - 2" );
END IF;
EXCEPTION
WHEN CONSTRAINT_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ( "WRONG EXCEPTION RAISED " &
"FOR NEWCHAR'VAL (IDENT_INT (-1))" );
END;
RESULT;
END C35507M;
|
lib/target/pc88/classic/bootstrap.asm | ahjelm/z88dk | 640 | 10488 | ;
; Disk bootstrap for the pc88
;
SECTION BOOTSTRAP
EXTERN __DATA_END_tail
org $f000
di
ld hl,$c000
ld de,$f000
ld bc,512
ldir
jp entry
console_defn:
defb "0,25,0,1",0
entry:
xor a
ld ($e6a7),a ;Disable cursor
call $428b ;Stop cursor blink
ld hl,console_defn ;
call $7071 ; Console entry
call $5f0e ; Text screen area
ld a,%00000001 ; Colour, 80 column text mode
out ($30),a
; --x- ---- graphics hires
; ---x ---- graphic color yes (1) / no (0)
; ---- x--- graphic display yes (1) / no (0)
; ---- -x-- Basic N (1) / N88 (0)
; ---- --x- RAM select yes (1) / no (0)
; ---- ---x VRAM 200 lines (1) / 400 lines (0) in 1bpp mode
ld a,%00111011 ; Hires, 25 row, color graphics mode, graphics on, N88 basic, 64k mode, 200 line resolution
out ($31),a
xor a ;Disable interrupts
out ($E6),a
out ($E4),a
ld hl,CRT_ORG_CODE
ld b, +((__DATA_END_tail - CRT_ORG_CODE) / 256) + 1
ld c,0
ld de,2 ;Start sector 2, track 0
call DISK_Load
jp CRT_ORG_CODE
; hl = address
; b = number of sectors
; c = drive
; d = start track
; e = start sectors
;ディスクからデータをロード
; HL: ロードするアドレス
; B: セクタ数 C: ドライブ D: トラック E: セクタ
DISK_Load:
ld a,$02 ;コマンド 2 Read Data
call DISK_SdCmd
ld a,b ;セクタ数 1<=sec(s)<=16
cp 17
jr c,load2
ld a,17 ;16を超える場合は 17-StartSector だけ読んで次トラックへ
sub e
load2:
call DISK_SdData1
ld a,c ;ドライブ
call DISK_SdData1
ld a,d ;トラック
call DISK_SdData1
ld a,e ;セクタ
call DISK_SdData1
ld a,$12 ;コマンド 18 Fast Send Data
call DISK_SdCmd
loop1:
push bc
ld b,128 ; 128 * 2bytes 受信
loop2:
call DISK_RdData2
djnz loop2 ; セクタ内ループ
inc e
ld a,e
cp 17 ; 17に到達->次のトラックへ移行
jr z,next
pop bc
djnz loop1 ; セクタ数分ループ
ret
;次のトラックへ
next:
inc d ;次のトラックから
ld e,1 ;セクタは1から
pop bc
dec b
jr nz,DISK_Load
ret
; サブシステムにコマンド送信
; a=コマンド番号
DISK_SdCmd:
push af
ld a,%00001111 ;Attention=1
out ($FF),a
wait1:
in a,($FE)
bit 1,a ;Ready for Data?
jr z,wait1
ld a,%00001110 ;Attention=0
out ($FF),a
jr DISK_SdData1sub
;1バイト送信
DISK_SdData1:
push af
wait1_1:
in a,($FE)
bit 1,a ;Ready for Data
jr z,wait1_1
DISK_SdData1sub:
pop af
out ($FD),a ;コマンド
ld a,%00001001 ;Data Valid
out ($FF),a
wait2:
in a,($FE)
bit 2,a ;Data Accepted?
jr z,wait2
ld a,%00001000 ;Data Valid
out ($FF),a
wait3:
in a,($FE)
bit 2,a ;Data Accepted?
jr nz,wait3
ret
;2バイト受信
DISK_RdData2:
ld a,%00001011 ;Ready for Data
out ($FF),a
wait1_3:
in a,($FE)
rrca ;Data Valid?
jr nc,wait1_3
ld a,%00001010 ;Ready for Data=0
out ($FF),a
in a,($FC) ;データ受信
ld (hl),a
inc hl
ld a,%00001101 ;Data Valid=1
out ($FF),a
wait2_1:
in a,($FE)
rrca
jr c,wait2_1
in a,($FC)
ld (hl),a
inc hl
ld a,%00001100 ;Data Accepted
out ($FF),a
ret
|
Transynther/x86/_processed/AVXALIGN/_st_sm_/i7-7700_9_0x48.log_21829_2721.asm | ljhsiun2/medusa | 9 | 241626 | .global s_prepare_buffers
s_prepare_buffers:
push %r13
push %r8
push %rax
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_UC_ht+0x7511, %rsi
lea addresses_normal_ht+0x12d93, %rdi
nop
nop
nop
nop
add $15615, %rax
mov $116, %rcx
rep movsl
nop
nop
inc %rax
lea addresses_WT_ht+0x12593, %r8
sub %rdx, %rdx
mov (%r8), %ecx
nop
nop
cmp $31848, %rdx
lea addresses_D_ht+0x176f3, %r8
clflush (%r8)
nop
nop
nop
dec %r13
mov (%r8), %si
nop
sub %rsi, %rsi
lea addresses_D_ht+0x6093, %rsi
lea addresses_WT_ht+0x8e13, %rdi
nop
nop
nop
nop
add %rbx, %rbx
mov $1, %rcx
rep movsw
nop
cmp %r13, %r13
lea addresses_UC_ht+0xc7b3, %rsi
nop
nop
nop
cmp %rdx, %rdx
mov (%rsi), %r13
nop
xor $59245, %rsi
lea addresses_D_ht+0x1794d, %rsi
lea addresses_A_ht+0x1c393, %rdi
nop
nop
nop
nop
nop
dec %rbx
mov $110, %rcx
rep movsq
nop
nop
nop
nop
nop
add %rcx, %rcx
lea addresses_UC_ht+0xae13, %rsi
lea addresses_WC_ht+0x1e5a3, %rdi
nop
xor $4588, %rdx
mov $110, %rcx
rep movsq
nop
nop
nop
nop
dec %rcx
lea addresses_WT_ht+0x14d03, %rbx
nop
sub %r13, %r13
movb (%rbx), %cl
nop
nop
nop
dec %rsi
lea addresses_WC_ht+0x1e6d3, %r13
nop
nop
nop
nop
sub $27923, %rsi
movb $0x61, (%r13)
nop
nop
nop
sub %r8, %r8
lea addresses_UC_ht+0xabfb, %rsi
lea addresses_UC_ht+0x5b93, %rdi
inc %rax
mov $59, %rcx
rep movsl
nop
nop
nop
cmp $2128, %r13
lea addresses_normal_ht+0xd6b3, %rbx
nop
xor $63113, %r13
and $0xffffffffffffffc0, %rbx
movntdqa (%rbx), %xmm2
vpextrq $1, %xmm2, %rdx
nop
nop
nop
nop
nop
xor $53047, %rcx
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r8
pop %r13
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r14
push %r8
push %r9
push %rbp
push %rdi
push %rsi
// Load
lea addresses_normal+0x12993, %r14
clflush (%r14)
nop
nop
nop
sub %rbp, %rbp
mov (%r14), %r8d
nop
cmp %r8, %r8
// Load
lea addresses_normal+0x1c993, %rdi
nop
xor %r9, %r9
vmovups (%rdi), %ymm4
vextracti128 $1, %ymm4, %xmm4
vpextrq $0, %xmm4, %rbp
nop
nop
nop
nop
nop
add $47540, %r8
// Load
lea addresses_A+0x3393, %r8
cmp %rsi, %rsi
movups (%r8), %xmm2
vpextrq $1, %xmm2, %rbp
nop
sub $2348, %r8
// Store
lea addresses_RW+0x2193, %rbp
add %r9, %r9
mov $0x5152535455565758, %rsi
movq %rsi, (%rbp)
nop
nop
nop
sub %r14, %r14
// Load
lea addresses_UC+0x13c13, %r8
nop
add $40897, %r12
mov (%r8), %r9d
nop
add %rbp, %rbp
// Store
lea addresses_normal+0x12993, %rdi
nop
nop
nop
nop
nop
add %r12, %r12
movl $0x51525354, (%rdi)
nop
inc %r8
// Store
lea addresses_UC+0x7e13, %r8
nop
and %r12, %r12
mov $0x5152535455565758, %r14
movq %r14, %xmm0
vmovups %ymm0, (%r8)
nop
nop
nop
nop
nop
dec %r8
// Faulty Load
lea addresses_normal+0x12993, %r8
nop
nop
nop
add $46783, %r14
movb (%r8), %r12b
lea oracles, %rbp
and $0xff, %r12
shlq $12, %r12
mov (%rbp,%r12,1), %r12
pop %rsi
pop %rdi
pop %rbp
pop %r9
pop %r8
pop %r14
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'AVXalign': False, 'congruent': 0, 'size': 1, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'AVXalign': False, 'congruent': 0, 'size': 4, 'same': True, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'AVXalign': False, 'congruent': 8, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_A', 'AVXalign': False, 'congruent': 7, 'size': 16, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_RW', 'AVXalign': False, 'congruent': 9, 'size': 8, 'same': False, 'NT': True}}
{'OP': 'LOAD', 'src': {'type': 'addresses_UC', 'AVXalign': False, 'congruent': 6, 'size': 4, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal', 'AVXalign': False, 'congruent': 0, 'size': 4, 'same': True, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC', 'AVXalign': False, 'congruent': 4, 'size': 32, 'same': False, 'NT': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'AVXalign': True, 'congruent': 0, 'size': 1, 'same': True, 'NT': False}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 9, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 10, 'size': 4, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'AVXalign': True, 'congruent': 5, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 6, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 3, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 8, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 3, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 3, 'size': 1, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 6, 'size': 1, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 6, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 5, 'size': 16, 'same': False, 'NT': True}}
{'54': 21829}
54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54
*/
|
src/Data/QuadTree/FoldableProofs/FoldableProof.agda | JonathanBrouwer/research-project | 1 | 15188 | -- {-# OPTIONS --show-implicit --show-irrelevant #-}
module Data.QuadTree.FoldableProofs.FoldableProof where
open import Haskell.Prelude renaming (zero to Z; suc to S)
open import Data.Logic
open import Data.QuadTree.Implementation.Definition
open import Data.QuadTree.Implementation.ValidTypes
open import Data.QuadTree.Implementation.QuadrantLenses
open import Data.QuadTree.Implementation.SafeFunctions
open import Data.QuadTree.Implementation.PropDepthRelation
open import Data.QuadTree.Implementation.Foldable
-- All proofs for Foldables
-- foldr f z t = appEndo (foldMap (Endo . f) t ) z
-- foldl f z t = appEndo (getDual (foldMap (Dual . Endo . flip f) t)) z
-- fold = foldMap id
-- length = getSum . foldMap (Sum . const 1)
-- I didn't change the default implementations of foldl/foldr/fold/length, so these laws should all hold
-- However, I will proof that the length of the quadtree is equal to width * height.
-- lengthₑ quadtreeFoldable vqt ≡ size vqt
size : {t : Set} {{eqT : Eq t}} {dep : Nat} -> (vqt : VQuadTree t {dep}) -> Nat
size (CVQuadTree (Wrapper (w , h) x₁)) = w * h
lengthₙ : {t : Set → Set} ⦃ r : Foldable t ⦄ {a : Set} → t a → Nat
lengthₙ {{r}} = foldMap {{r}} {{ MonoidSum }} (const 1)
length-replicateₙ : {t : Set} (n : Nat) (v : t) -> lengthₙ (replicateₙ n v) ≡ n
length-replicateₙ {t} Z v = refl
length-replicateₙ {t} (S n) v =
begin
lengthₙ (replicateₙ (S n) v)
=⟨⟩
S (lengthₙ (replicateₙ n v))
=⟨ cong S (length-replicateₙ n v ) ⟩
S n
end
length-concat-sub : {t : Set} -> (list : List t) (lists : List (List t)) -> lengthₙ (list ++ concat lists) ≡ lengthₙ list + lengthₙ (concat lists)
length-concat-sub {t} [] lists = refl
length-concat-sub {t} (x ∷ xs) lists =
begin
lengthₙ ((x ∷ xs) ++ concat lists)
=⟨⟩
S (lengthₙ (xs ++ concat lists))
=⟨ cong S (length-concat-sub xs lists) ⟩
lengthₙ (x ∷ xs) + lengthₙ (concat lists)
end
length-concat : {t : Set} -> (lists : List (List t)) -> lengthₙ (concat lists) ≡ sum (map lengthₙ lists)
length-concat {t} [] = refl
length-concat {t} (list ∷ lists) =
begin
lengthₙ (concat (list ∷ lists))
=⟨⟩
lengthₙ (list ++ concat lists)
=⟨ length-concat-sub list lists ⟩
lengthₙ list + lengthₙ (concat lists)
=⟨ cong (λ q -> lengthₙ list + q) (length-concat lists) ⟩
lengthₙ list + sum (map lengthₙ lists)
=⟨⟩
sum (map lengthₙ (list ∷ lists))
end
concat-nothing : {t : Set} -> (list : List t) -> list ++ [] ≡ list
concat-nothing [] = refl
concat-nothing (x ∷ list) = cong (λ z → x ∷ z) (concat-nothing list)
diff-n-zero : (n : Nat) -> diff n Z ≡ n
diff-n-zero Z = refl
diff-n-zero (S n) = refl
map-concat : {s t : Set} -> (a b : List s)
-> (f : s -> t)
-> map f (a ++ b) ≡ map f a ++ map f b
map-concat [] b f = refl
map-concat (a ∷ as) b f = cong (λ z → f a ∷ z) (map-concat as b f)
map-concat4 : {s t : Set} -> (a b c d : List s)
-> (f : s -> t)
-> map f (a ++ b ++ c ++ d) ≡ map f a ++ map f b ++ map f c ++ map f d
map-concat4 a b c d f =
begin
map f (a ++ b ++ c ++ d)
=⟨ map-concat a (b ++ c ++ d) f ⟩
map f a ++ map f (b ++ c ++ d)
=⟨ cong (λ q -> map f a ++ q) (map-concat b (c ++ d) f) ⟩
map f a ++ map f b ++ map f (c ++ d)
=⟨ cong (λ q -> map f a ++ map f b ++ q) (map-concat c d f) ⟩
map f a ++ map f b ++ map f c ++ map f d
end
sum-concat : (a b : List Nat) -> sum (a ++ b) ≡ sum a + sum b
sum-concat [] b = refl
sum-concat (a ∷ as) b =
begin
a + sum (as ++ b)
=⟨ cong (λ q -> a + q) (sum-concat as b) ⟩
a + (sum as + sum b)
=⟨ sym $ add-assoc a (sum as) (sum b) ⟩
sum (a ∷ as) + sum b
end
sum-concat4 : (a b c d : List Nat) -> sum (a ++ b ++ c ++ d) ≡ sum a + sum b + sum c + sum d
sum-concat4 a b c d =
begin
sum (a ++ b ++ c ++ d)
=⟨ sum-concat a (b ++ c ++ d) ⟩
sum a + sum (b ++ c ++ d)
=⟨ cong (λ q -> sum a + q) (sum-concat b (c ++ d)) ⟩
sum a + (sum b + sum (c ++ d))
=⟨ cong (λ q -> sum a + (sum b + q)) (sum-concat c d) ⟩
sum a + (sum b + (sum c + sum d))
=⟨ sym $ add-assoc (sum a) (sum b) (sum c + sum d) ⟩
(sum a + sum b) + (sum c + sum d)
=⟨ sym $ add-assoc (sum a + sum b) (sum c) (sum d) ⟩
sum a + sum b + sum c + sum d
end
nat-distributive : (a b c : Nat) -> (a * c) + (b * c) ≡ (a + b) * c
nat-distributive Z b c = refl
nat-distributive (S a) b c =
begin
(S a * c) + (b * c)
=⟨ add-assoc c (a * c) (b * c) ⟩
c + ((a * c) + b * c)
=⟨ cong (_+_ c) (nat-distributive a b c) ⟩
c + ((a + b) * c)
=⟨⟩
(S a + b) * c
end
add-diff : (a b : Nat) -> IsTrue (a <= b) -> a + diff b a ≡ b
add-diff Z Z ab = refl
add-diff Z (S b) ab = refl
add-diff (S a) (S b) ab = cong S (add-diff a b ab)
line-split-left : (x1 xm x2 y : Nat) -> IsTrue (x1 <= xm) -> IsTrue (xm <= x2) -> IsTrue (x1 <= x2)
-> diff xm x1 * y + diff x2 xm * y ≡ diff x2 x1 * y
line-split-left Z Z Z y x1m xm2 x12 = refl
line-split-left Z Z (S x2) y x1m xm2 x12 = refl
line-split-left Z (S xm) (S x2) y x1m xm2 x12 =
begin
(S xm) * y + diff (S x2) (S xm) * y
=⟨ nat-distributive (S xm) (diff (S x2) (S xm)) y ⟩
((S xm) + diff (S x2) (S xm)) * y
=⟨ cong (λ z → y + (z * y)) (add-diff xm x2 xm2) ⟩
(S x2) * y
end
line-split-left (S x1) (S xm) (S x2) y x1m xm2 x12 = line-split-left x1 xm x2 y x1m xm2 x12
line-split-right : (x1 xm x2 y : Nat) -> IsTrue (x1 <= xm) -> IsTrue (xm <= x2) -> IsTrue (x1 <= x2)
-> y * diff xm x1 + y * diff x2 xm ≡ y * diff x2 x1
line-split-right x1 xm x2 y x1m xm2 x12 =
begin
y * diff xm x1 + y * diff x2 xm
=⟨ cong2 _+_ (mul-comm y (diff xm x1)) (mul-comm y (diff x2 xm)) ⟩
diff xm x1 * y + diff x2 xm * y
=⟨ line-split-left x1 xm x2 y x1m xm2 x12 ⟩
diff x2 x1 * y
=⟨ mul-comm (diff x2 x1) y ⟩
y * diff x2 x1
end
square-split : (x1 y1 xm ym x2 y2 : Nat) -> IsTrue (x1 <= xm) -> IsTrue (xm <= x2) -> IsTrue (y1 <= ym) -> IsTrue (ym <= y2)
-> diff xm x1 * diff ym y1 + diff x2 xm * diff ym y1 + diff xm x1 * diff y2 ym + diff x2 xm * diff y2 ym ≡ diff x2 x1 * diff y2 y1
square-split x1 y1 xm ym x2 y2 x1m xm2 y1m ym2 =
begin
diff xm x1 * diff ym y1 + diff x2 xm * diff ym y1 + diff xm x1 * diff y2 ym + diff x2 xm * diff y2 ym
=⟨ add-assoc ((diff xm x1 * diff ym y1) + (diff x2 xm * diff ym y1)) (diff xm x1 * diff y2 ym) (diff x2 xm * diff y2 ym) ⟩
(diff xm x1 * diff ym y1 + diff x2 xm * diff ym y1) + (diff xm x1 * diff y2 ym + diff x2 xm * diff y2 ym)
=⟨ cong2 _+_
(line-split-left x1 xm x2 (diff ym y1) x1m xm2 (lteTransitive x1 xm x2 x1m xm2))
(line-split-left x1 xm x2 (diff y2 ym) x1m xm2 (lteTransitive x1 xm x2 x1m xm2)) ⟩
(diff x2 x1 * diff ym y1) + (diff x2 x1 * diff y2 ym)
=⟨ line-split-right y1 ym y2 (diff x2 x1) y1m ym2 (lteTransitive y1 ym y2 y1m ym2) ⟩
diff x2 x1 * diff y2 y1
end
min-comb : (a b c : Nat) -> IsTrue (a <= b) -> IsTrue (a <= c) -> IsTrue (a <= min b c)
min-comb a b c ab ac = useEq (sym $
begin
a <= min b c
=⟨ sym $ propFnIf {c = c < b} (_<=_ a) ⟩
(if _ then a <= c else a <= b)
=⟨ cong2 (if_then_else_ _) (isTrueToEquiv ac) (isTrueToEquiv ab) ⟩
(if _ then true else true)
=⟨ propIfBranchesSame true ⟩
true
end) IsTrue.itsTrue
min-rel-1 : (x1 mid x2 : Nat) -> IsTrue (x1 <= x2) -> IsTrue (x1 <= min x2 (mid + x1))
min-rel-1 x1 mid x2 x12 = min-comb x1 x2 (mid + x1) x12 (lteSumOne x1 x1 mid (lteSelf x1))
min-rel-2 : (a b : Nat) -> IsTrue (min a b <= a)
min-rel-2 a b = useEq (sym $
begin
min a b <= a
=⟨ sym (propFnIf (λ z → (z <= a))) ⟩
(if b < a then b <= a else a <= a)
=⟨ ifTrueMap {c = b < a} (λ c -> isTrueToEquiv (orFst c)) ⟩
(if b < a then true else a <= a)
=⟨ cong (if_then_else_ (b < a) true) (isTrueToEquiv (lteSelf a)) ⟩
(if b < a then true else true)
=⟨ propIfBranchesSame true ⟩
true
end) IsTrue.itsTrue
length-tilesQd : {t : Set} {{eqT : Eq t}} {dep : Nat} -> (vqd : VQuadrant t {dep})
-> (x1 y1 x2 y2 : Nat) -> IsTrue (x1 <= x2) -> IsTrue (y1 <= y2)
-> sum (map lengthₙ (map expand (tilesQd dep vqd (RegionC (x1 , y1) (x2 , y2))))) ≡ diff x2 x1 * diff y2 y1
length-tilesQd {t} {dep = dep} (CVQuadrant (Leaf v) {p}) x1 y1 x2 y2 _ _ =
begin
sum (map lengthₙ (map expand (tilesQd dep (CVQuadrant (Leaf v) {p}) (RegionC (x1 , y1) (x2 , y2)))))
=⟨⟩
lengthₙ (replicateₙ (diff x2 x1 * diff y2 y1) v) + 0
=⟨ add-comm _ 0 ⟩
lengthₙ (replicateₙ (diff x2 x1 * diff y2 y1) v)
=⟨ length-replicateₙ (diff x2 x1 * diff y2 y1) v ⟩
diff x2 x1 * diff y2 y1
end
length-tilesQd {dep = S dep} (CVQuadrant (Node a b c d) {p}) x1 y1 x2 y2 xp yp =
begin
sum (map lengthₙ (map expand (tilesQd (S dep) (CVQuadrant (Node a b c d) {p}) (RegionC (x1 , y1) (x2 , y2)))))
=⟨⟩
sum (map lengthₙ (map expand (ca ++ cb ++ cc ++ cd)))
=⟨ cong (λ q -> sum (map lengthₙ q)) (map-concat4 ca cb cc cd expand) ⟩
sum (map lengthₙ (map expand ca ++ map expand cb ++ map expand cc ++ map expand cd))
=⟨ cong sum (map-concat4 (map expand ca) (map expand cb) (map expand cc) (map expand cd) lengthₙ) ⟩
sum (map lengthₙ (map expand ca) ++ map lengthₙ (map expand cb) ++ map lengthₙ (map expand cc) ++ map lengthₙ (map expand cd))
=⟨ sum-concat4 (map lengthₙ (map expand ca)) (map lengthₙ (map expand cb)) (map lengthₙ (map expand cc)) (map lengthₙ (map expand cd)) ⟩
sum (map lengthₙ (map expand ca)) + sum (map lengthₙ (map expand cb)) + sum (map lengthₙ (map expand cc)) + sum (map lengthₙ (map expand cd))
=⟨ cong4 (λ a b c d -> a + b + c + d)
(length-tilesQd (CVQuadrant a) x1 y1 (min x2 (mid + x1)) (min y2 (mid + y1)) (min-rel-1 x1 mid x2 xp) (min-rel-1 y1 mid y2 yp))
(length-tilesQd (CVQuadrant b) (min x2 (mid + x1)) y1 x2 (min y2 (mid + y1)) (min-rel-2 x2 (mid + x1)) (min-rel-1 y1 mid y2 yp))
(length-tilesQd (CVQuadrant c) x1 (min y2 (mid + y1)) (min x2 (mid + x1)) y2 (min-rel-1 x1 mid x2 xp) (min-rel-2 y2 (mid + y1)))
(length-tilesQd (CVQuadrant d) (min x2 (mid + x1)) (min y2 (mid + y1)) x2 y2 (min-rel-2 x2 (mid + x1)) (min-rel-2 y2 (mid + y1))) ⟩
diff (min x2 (mid + x1)) x1 * diff (min y2 (mid + y1)) y1
+ diff x2 (min x2 (mid + x1)) * diff (min y2 (mid + y1)) y1
+ diff (min x2 (mid + x1)) x1 * diff y2 (min y2 (mid + y1))
+ diff x2 (min x2 (mid + x1)) * diff y2 (min y2 (mid + y1))
=⟨ square-split x1 y1 (min x2 (mid + x1)) (min y2 (mid + y1)) x2 y2 (min-rel-1 x1 mid x2 xp) (min-rel-2 x2 (mid + x1)) (min-rel-1 y1 mid y2 yp) (min-rel-2 y2 (mid + y1)) ⟩
diff x2 x1 * diff y2 y1
end where
mid = pow 2 dep
ca = tilesQd dep (CVQuadrant a) (RegionC (x1 , y1) (min x2 (mid + x1) , min y2 (mid + y1)) )
cb = tilesQd dep (CVQuadrant b) (RegionC (min x2 (mid + x1) , y1) (x2 , min y2 (mid + y1)) )
cc = tilesQd dep (CVQuadrant c) (RegionC (x1 , min y2 (mid + y1)) (min x2 (mid + x1) , y2) )
cd = tilesQd dep (CVQuadrant d) (RegionC (min x2 (mid + x1) , min y2 (mid + y1)) (x2 , y2) )
proof-length : {t : Set} {{eqT : Eq t}} {dep : Nat} -> (vqt : VQuadTree t {dep}) -> lengthₑ (quadtreeFoldable dep) vqt ≡ size vqt
proof-length {t} ⦃ eqT ⦄ {dep} vqt@(CVQuadTree (Wrapper (w , h) qd) {p1} {p2}) =
begin
lengthₑ (quadtreeFoldable dep) vqt
=⟨⟩
lengthₙ (concat (map expand (tilesQd dep (CVQuadrant qd {p1}) (RegionC (0 , 0) (w , h)))))
=⟨ length-concat (map expand (tilesQd dep (CVQuadrant qd {p1}) (RegionC (0 , 0) (w , h)))) ⟩
sum (map lengthₙ (map expand (tilesQd dep (CVQuadrant qd {p1}) (RegionC (0 , 0) (w , h)))))
=⟨ length-tilesQd {dep = dep} (CVQuadrant qd {p1}) 0 0 w h (zeroLteAny w) (zeroLteAny h) ⟩
w * h
end |
llvm-gcc-4.2-2.9/gcc/ada/a-crbtgk.ads | vidkidz/crossbridge | 1 | 25403 | <filename>llvm-gcc-4.2-2.9/gcc/ada/a-crbtgk.ads
------------------------------------------------------------------------------
-- --
-- GNAT LIBRARY COMPONENTS --
-- --
-- A D A . C O N T A I N E R S . R E D _ B L A C K _ T R E E S . --
-- G E N E R I C _ K E Y S --
-- --
-- S p e c --
-- --
-- This specification is adapted from the Ada Reference Manual for use with --
-- GNAT. In accordance with the copyright of that document, you can freely --
-- copy and modify this specification, provided that if you redistribute a --
-- modified version, any changes that you have made are clearly indicated. --
-- --
------------------------------------------------------------------------------
with Ada.Containers.Red_Black_Trees.Generic_Operations;
generic
with package Tree_Operations is new Generic_Operations (<>);
use Tree_Operations.Tree_Types;
type Key_Type (<>) is limited private;
with function Is_Less_Key_Node
(L : Key_Type;
R : Node_Access) return Boolean;
with function Is_Greater_Key_Node
(L : Key_Type;
R : Node_Access) return Boolean;
package Ada.Containers.Red_Black_Trees.Generic_Keys is
pragma Pure;
generic
with function New_Node return Node_Access;
procedure Generic_Insert_Post
(Tree : in out Tree_Type;
X, Y : Node_Access;
Key : Key_Type;
Z : out Node_Access);
generic
with procedure Insert_Post
(Tree : in out Tree_Type;
X, Y : Node_Access;
Key : Key_Type;
Z : out Node_Access);
procedure Generic_Conditional_Insert
(Tree : in out Tree_Type;
Key : Key_Type;
Node : out Node_Access;
Success : out Boolean);
generic
with procedure Insert_Post
(Tree : in out Tree_Type;
X, Y : Node_Access;
Key : Key_Type;
Z : out Node_Access);
procedure Generic_Unconditional_Insert
(Tree : in out Tree_Type;
Key : Key_Type;
Node : out Node_Access);
generic
with procedure Insert_Post
(Tree : in out Tree_Type;
X, Y : Node_Access;
Key : Key_Type;
Z : out Node_Access);
with procedure Unconditional_Insert_Sans_Hint
(Tree : in out Tree_Type;
Key : Key_Type;
Node : out Node_Access);
procedure Generic_Unconditional_Insert_With_Hint
(Tree : in out Tree_Type;
Hint : Node_Access;
Key : Key_Type;
Node : out Node_Access);
generic
with procedure Insert_Post
(Tree : in out Tree_Type;
X, Y : Node_Access;
Key : Key_Type;
Z : out Node_Access);
with procedure Conditional_Insert_Sans_Hint
(Tree : in out Tree_Type;
Key : Key_Type;
Node : out Node_Access;
Success : out Boolean);
procedure Generic_Conditional_Insert_With_Hint
(Tree : in out Tree_Type;
Position : Node_Access;
Key : Key_Type;
Node : out Node_Access;
Success : out Boolean);
function Find
(Tree : Tree_Type;
Key : Key_Type) return Node_Access;
function Ceiling
(Tree : Tree_Type;
Key : Key_Type) return Node_Access;
function Floor
(Tree : Tree_Type;
Key : Key_Type) return Node_Access;
function Upper_Bound
(Tree : Tree_Type;
Key : Key_Type) return Node_Access;
generic
with procedure Process (Node : Node_Access);
procedure Generic_Iteration
(Tree : Tree_Type;
Key : Key_Type);
generic
with procedure Process (Node : Node_Access);
procedure Generic_Reverse_Iteration
(Tree : Tree_Type;
Key : Key_Type);
end Ada.Containers.Red_Black_Trees.Generic_Keys;
|
other.7z/SFC.7z/SFC/ソースデータ/MarioKart/BGunit_set.asm | prismotizm/gigaleak | 0 | 178319 | <filename>other.7z/SFC.7z/SFC/ソースデータ/MarioKart/BGunit_set.asm
Name: BGunit_set.asm
Type: file
Size: 7024
Last-Modified: '1992-06-28T15:00:00Z'
SHA-1: E5B9074A662A6BA7525481705770B6CB40CF92F9
Description: null
|
Keyboard-Maestro/Collapse-All-[Pause|Type|Execute-Macro]-Actions.applescript | ninjakttty/AppleScripts | 3 | 3626 | <filename>Keyboard-Maestro/Collapse-All-[Pause|Type|Execute-Macro]-Actions.applescript
tell application "Keyboard Maestro"
set m to first macro whose selected is true
set acts to m's actions
repeat with a in acts
if name of a contains "Pause for" or name of a contains "Type the" or name of a contains "Execute Macro" then
if disclosed of a is true then set disclosed of a to false
end if
end repeat
end tell
|
source/oasis/program-elements-constrained_array_types.ads | reznikmm/gela | 0 | 26147 | -- SPDX-FileCopyrightText: 2019 <NAME> <<EMAIL>>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with Program.Elements.Type_Definitions;
with Program.Lexical_Elements;
with Program.Elements.Discrete_Ranges;
with Program.Elements.Component_Definitions;
package Program.Elements.Constrained_Array_Types is
pragma Pure (Program.Elements.Constrained_Array_Types);
type Constrained_Array_Type is
limited interface and Program.Elements.Type_Definitions.Type_Definition;
type Constrained_Array_Type_Access is
access all Constrained_Array_Type'Class with Storage_Size => 0;
not overriding function Index_Subtypes
(Self : Constrained_Array_Type)
return not null Program.Elements.Discrete_Ranges
.Discrete_Range_Vector_Access is abstract;
not overriding function Component_Definition
(Self : Constrained_Array_Type)
return not null Program.Elements.Component_Definitions
.Component_Definition_Access is abstract;
type Constrained_Array_Type_Text is limited interface;
type Constrained_Array_Type_Text_Access is
access all Constrained_Array_Type_Text'Class with Storage_Size => 0;
not overriding function To_Constrained_Array_Type_Text
(Self : in out Constrained_Array_Type)
return Constrained_Array_Type_Text_Access is abstract;
not overriding function Array_Token
(Self : Constrained_Array_Type_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Left_Bracket_Token
(Self : Constrained_Array_Type_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Right_Bracket_Token
(Self : Constrained_Array_Type_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Of_Token
(Self : Constrained_Array_Type_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
end Program.Elements.Constrained_Array_Types;
|
Library/Chart/Utils/utilsUI.asm | steakknife/pcgeos | 504 | 11407 | <reponame>steakknife/pcgeos
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) GeoWorks 1992 -- All Rights Reserved
PROJECT: PC GEOS
MODULE:
FILE: utilsUI.asm
AUTHOR: <NAME>
METHODS:
Name Description
---- -----------
FUNCTIONS:
Scope Name Description
----- ---- -----------
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 1/23/92 Initial version.
DESCRIPTION:
$Id: utilsUI.asm,v 1.1 97/04/04 17:47:48 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
UtilCombineEtype
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Combine an etype in the notification block with the
current object's value
CALLED BY: ChartGroupCombineChartType,
ChartGroupCombineGroupFlags
PASS: ds:si - etype in source object
es:di - etype in notification block
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 1/22/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
UtilCombineEtype proc far
uses ax
.enter
EC_BOUNDS ds si
EC_BOUNDS es di
test es:[CNBH_flags], mask CCF_FOUND
jz firstOne
mov al, es:[di]
cmp al, ds:[si]
je done
mov {byte} es:[di], -1
done:
.leave
ret
firstOne:
mov al, ds:[si]
mov es:[di], al
jmp done
UtilCombineEtype endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
UtilCombineFlags
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Update the notification block based on the current
object's flags -- assume flags are an 8-bit record
CALLED BY: EXTERNAL
PASS: ds:si - flags in source object
es:di - flags in notification block
es:bp - record of "differences"
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 1/22/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
UtilCombineFlags proc far
uses ax
.enter
EC_BOUNDS es bp
EC_BOUNDS es di
test es:[CNBH_flags], mask CCF_FOUND
jz firstOne
mov al, ds:[si]
xor al, es:[di]
or es:[bp], al
done:
.leave
ret
firstOne:
; copy source flags directly to destination
mov al, ds:[si]
mov es:[di], al
mov {byte} es:[bp], 0
jmp done
UtilCombineFlags endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
UtilStartCombine
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Lock the memory block whose handle is in CX,
set ES to the segment, and move handle into BX
CALLED BY: EXTERNAL
PASS: cx - handle of notification block
RETURN: bx - handle of notification block
es - segment of notification block
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 1/23/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
UtilStartCombine proc far
uses ax
.enter
mov bx, cx
call MemLock
mov es, ax
.leave
ret
UtilStartCombine endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
UtilEndCombine
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Set the "Found" flag so that the notification block
will have record of at least one object dealing with
it.
CALLED BY: EXTERNAL
PASS: es:0 - ChartNotifyBlockHeader
bx - handle of notification block at segment ES
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 1/23/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
UtilEndCombine proc far
if ERROR_CHECK
;
; Make sure BX is the handle of the block in ES
;
push ax, bx
mov ax, MGIT_ADDRESS
call MemGetInfo
mov bx, es
cmp ax, bx
ERROR_NE ILLEGAL_SEGMENT
pop ax, bx
endif
ornf es:[CNBH_flags], mask CCF_FOUND
call MemUnlock
ret
UtilEndCombine endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
UtilUpdateUI
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Update the user interface
CALLED BY: EXTERNAL
PASS: cx - UpdateFlags
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 1/23/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
UtilUpdateUI proc far
uses ax
.enter
mov ax, MSG_CHART_BODY_UPDATE_UI
call UtilCallChartBody
.leave
ret
UtilUpdateUI endp
|
grounding.agda | hazelgrove/hazel-palette-agda | 4 | 1559 | open import Prelude
open import core
module grounding where
grounding : ∀{ τ1 τ2} →
τ1 ▸gnd τ2 →
((τ2 ground) × (τ1 ~ τ2) × (τ1 ≠ τ2))
grounding (MGArr x) = GHole , TCArr TCHole1 TCHole1 , x
grounding (MGProd x) = GProd , TCProd TCHole1 TCHole1 , x
|
oeis/187/A187277.asm | neoneye/loda-programs | 11 | 177739 | <gh_stars>10-100
; A187277: Let S denote the palindromes in the language {0,1,2,...,n-1}*; a(n) = number of words of length 4 in the language SS.
; 1,16,57,136,265,456,721,1072,1521,2080,2761,3576,4537,5656,6945,8416,10081,11952,14041,16360,18921,21736,24817,28176,31825,35776,40041,44632,49561,54840,60481,66496,72897,79696,86905,94536,102601,111112,120081,129520,139441,149856,160777,172216,184185,196696,209761,223392,237601,252400,267801,283816,300457,317736,335665,354256,373521,393472,414121,435480,457561,480376,503937,528256,553345,579216,605881,633352,661641,690760,720721,751536,783217,815776,849225,883576,918841,955032,992161,1030240
mov $1,$0
mul $1,2
add $1,4
bin $1,2
mul $0,$1
add $0,1
|
programs/oeis/052/A052254.asm | karttu/loda | 0 | 96346 | ; A052254: Partial sums of A050406.
; 1,17,108,444,1410,3762,8844,18876,37323,69355,122408,206856,336804,531012,813960,1217064,1780053,2552517,3595636,4984100,6808230,9176310,12217140,16082820,20951775,27032031,34564752,43828048,55141064,68868360,85424592,105279504,128963241,157071993,190273980,229315788,275029066,328337594,390264732,461941260,544613619,639652563,748562232,872989656,1014734700,1175760460,1358204120,1564388280,1796832765,2058266925,2351642436,2680146612,3047216238,3456551934,3912133060,4418233172,4979436039,5600652231,6287136288,7044504480,7878753168,8796277776,9803892384,10908849952,12118863185,13442126049,14887335948,16463716572,18181041426,20049658050,22080512940,24285177180,26675872795,29265499835,32067664200,35096706216,38367729972,41896633428,45700139304,49795826760,54202163877,58938540949,64025304596,69483792708,75336370230,81606465798,88318609236,95498469924,103172896047,111369954735,120118973104,129450580208,139396749912,149990844696,161267660400,173263471920,186016079865,199564858185,213950802780,229216581100,245406582746,262566971082,280745735868,299992746924,320359808835,341900716707,364671312984,388729545336,414135525628,440951589980,469242359928,499074804696,530518304589,563644715517,598528434660,635246467284,673878494718,714506943502,757217055716,802096960500,849237746775,898733537175,950681563200,1005182241600,1062339252000,1122259615776,1185053776192,1250835679808,1319722859169,1391836516785,1467301610412,1546246939644,1628805233826,1715113241298,1805311819980,1899546029308,1997965223531,2100723146379,2207978027112,2319892677960,2436634592964,2558376048228,2685294203592,2817571205736,2955394292725,3098955900005,3248453767860,3404091050340,3566076425670,3734624208150,3909954461556,4092293114052,4281872074623,4478929351039,4683709169360,4896462094992,5117445155304,5346921963816,5585162845968,5832444966480,6089052458313,6355276553241,6631415714044,6917775768332,7214670044010,7522419506394,7841352896988,8171806873932,8514126154131,8868663657075,9235780650360,9615846896920,10009240803980,10416349573740,10837569355800,11273305401336,11723972219037,12189993732813,12671803441284,13169844579060,13684570279822,14216443741214,14765938391556,15333538058388,15919737138855,16525040771943,17149965012576,17795037007584,18460795173552,19147789376560,19856581113824,20587743697248,21341862438897,22119534838401,22921370772300,23747992685340,24600035783730,25478148230370,26382991342060,27315239788700,28275581794491,29264719341147,30283368373128,31332259004904,32412135730260,33523757633652,34667898603624,35845347548296,37056908612933,38303401399605,39585661188948,40904539164036,42260902636374,43655635274022,45089637331860,46563825884004,48079135058383,49636516273487,51236938477296,52881388388400,54570870739320,56306408522040,58089043235760,59919835136880,61799863491225,63730226828521,65712043199132,67746450433068,69834606401274,71977689279210,74176897812732,76433451586284,78748591293411,81123579009603,83559698467480,86058255334328,88620577491996,91248015319164,93941941975992,96703753691160,99534870051309,102436734292893,105410813596452,108458599383316,111581607614750,114781379093550,118059479768100,121417501038900,124857060067575,128379800088375
lpb $0,1
mov $2,$0
cal $2,50406 ; Partial sums of A051880.
sub $0,1
add $1,$2
lpe
add $1,1
|
src/offmt_lib.ads | Fabien-Chouteau/offmt-tool | 0 | 28649 | with Ada.Strings.Unbounded;
with Ada.Containers.Indefinite_Doubly_Linked_Lists;
with Ada.Containers.Indefinite_Hashed_Maps;
with Interfaces;
private with System.Storage_Elements;
private with Ada.Containers.Vectors;
package Offmt_Lib is
Log_Root_Pkg : constant Wide_Wide_String := "Offmt";
type Format_Kind is (Decimal, Hexadecimal, Binary);
type Format_Type is (Type_U8, Type_U16, Type_U32);
type Format is record
Expression : Ada.Strings.Unbounded.Unbounded_String;
Kind : Format_Kind;
Typ : Format_Type;
end record;
type Trace_Element_Kind is (Plain_String, Format_String);
type Trace_Element (Kind : Trace_Element_Kind) is record
case Kind is
when Plain_String =>
Str : Ada.Strings.Unbounded.Unbounded_String;
when Format_String =>
Fmt : Format;
end case;
end record;
package Trace_Element_Lists
is new Ada.Containers.Indefinite_Doubly_Linked_Lists (Trace_Element);
type Trace_ID is new Interfaces.Unsigned_16;
type Trace is record
Original : Ada.Strings.Unbounded.Unbounded_String;
Id : Trace_ID;
List : Trace_Element_Lists.List;
end record;
procedure Pretty_Print (T : Trace);
function ID_Hashed (Id : Trace_ID) return Ada.Containers.Hash_Type
is (Ada.Containers.Hash_Type (Id));
package Trace_Maps
is new Ada.Containers.Indefinite_Hashed_Maps (Trace_ID,
Trace,
ID_Hashed,
Equivalent_Keys => "=");
type Trace_Map is new Trace_Maps.Map with null record;
Empty_Map : constant Trace_Map;
type Data_Frame is private;
private
Empty_Map : constant Trace_Map := (Trace_Maps.Empty_Map with null record);
package SE_Vectors
is new Ada.Containers.Vectors (Natural,
System.Storage_Elements.Storage_Element,
System.Storage_Elements."=");
type Data_Frame is record
Data : SE_Vectors.Vector;
Next : Natural := 0;
end record;
function Remaining (Frame : Data_Frame) return Natural;
procedure Clear (Frame : in out Data_Frame)
with Post => Remaining (Frame) = 0;
procedure Push (Frame : in out Data_Frame;
Elt : System.Storage_Elements.Storage_Element);
function Pop (Frame : in out Data_Frame)
return System.Storage_Elements.Storage_Element
with Pre => Remaining (Frame) > 0;
Frame_Error : exception;
end Offmt_Lib;
|
src/Vendor.asm | issalig/amstrad-diagnostics | 0 | 242339 | <filename>src/Vendor.asm
MODULE VENDOR
;; www.cpcwiki.eu/index.php/LK-selectable_Brand_Names
;; www.cpcwiki.eu/index.php/LK_Links
;; LK1,LK2,LK3 are optional links on the CPC mainboard, connected to PPI Port B, Bit1-3.
;; The links select the distributor name (which is displayed by the BIOS in the boot message).
;; www.cpcwiki.eu/index.php/8255#PPI_Port_B
;; LK4 default 50Hz screen refresh
; ALL in UPPERCASE, we do not have lowercase chars in this ROM!!!
@VendorNames:
TxtAmstrad: db "AMSTRAD",0
TxtOrion: db "ORION",0
TxtSchneider: db "SCHNEIDER",0
TxtAwa: db "AWA",0
TxtSolavox: db "SOLAVOX",0
TxtSaisho: db "SAISHO",0
TxtTriumph: db "TRIUMPH",0
TxtIsp: db "ISP",0
@VendorTableOffset:
db 0
db TxtOrion - TxtAmstrad
db TxtSchneider - TxtAmstrad
db TxtAwa - TxtAmstrad
db TxtSolavox - TxtAmstrad
db TxtSaisho - TxtAmstrad
db TxtTriumph - TxtAmstrad
db TxtIsp - TxtAmstrad
@RefreshNames:
Txt50HZ: db "50Hz",0
Txt60HZ: db "60Hz",0
@RefreshTableOffset:
db 0
db Txt60HZ - Txt50HZ
;; OUT: (Vendor) - vendor from LK3-1 configuration
@DetectVendor:
ld b,#f5 ; PPI port B.
in a,(c) ; Addressing, B in top half, C in bottom half (ignored)
cpl ; invert bits
and %00001110 ; Links LK3-LK1 define machine
rrca ; get rid of bit0
ld (VendorName),a
ret
;; OUT: (Frequency) - frequency from LK4 configuration
@DetectFrequency:
ld b,#f5 ; PPI port B input
in a,(c) ;
and %00010000 ; LK4 50/60 Hz &10/&00
ld (RefreshFrequency),a
ret
ENDMODULE
|
assembler/tests/t_mic51/makro1.asm | paulscottrobson/RCA-Cosmac-VIP-III | 0 | 1298 |
; Aufgabe Nr.: Speichermodul fuer uP- Praktikum II
; Autor: <NAME>
; erstellt am : 21.05.1994
; letzte Aenderung am : 01.08.1994
; Bemerkung : Makros
;
; Dateiname : makro1.asm
;
;---------------------------------------------------------------------
; Funktion : Direkter Bitmove- Befehl
; Aufrufparameter : -
; Ruechgabeparameter : -
; Veraenderte Register : PSW
; Stackbedarf :
; Zeitbedarf :
;
MOVB MACRO ZIEL,QUELLE
MOV C,QUELLE
MOV ZIEL,C
ENDM
;---------------------------------------------------------------------
; Funktion : String auf LCD ausgaben.
; Aufrufparameter : -
; Ruechgabeparameter : -
; Veraenderte Register :
; Stackbedarf :
; Zeitbedarf :
;
LCD MACRO POS,STRG
PUSH ACC
PUSH DPH
PUSH DPL
MOV A,#POS
LCALL LCD_SET_DD_RAM_ADDRESS
MOV DPTR,#STR_ADR
LCALL LCD_WRITE_STRING
LJMP WEITER
STR_ADR DB STRG,0
WEITER: POP DPL
POP DPH
POP ACC
ENDM
;---------------------------------------------------------------------
; Funktion : A, B, PSW, DPTR, R0 - R7 auf Stack retten
; Aufrufparameter : PUSH_ALL
; Ruechgabeparameter : -
; Veraenderte Register : -
; Stackbedarf : 2
; Zeitbedarf :
;
PUSH_ALL MACRO
PUSH ACC
PUSH B
PUSH PSW
PUSH_DPTR
PUSH AR0
PUSH AR1
PUSH AR2
PUSH AR3
PUSH AR4
PUSH AR5
PUSH AR6
PUSH AR7
ENDM
;---------------------------------------------------------------------
; Funktion : A, B, PSW, DPTR, R0 - R7 von Stack holen
; Aufrufparameter : POP_ALL
; Ruechgabeparameter : -
; Veraenderte Register : -
; Stackbedarf : 2
; Zeitbedarf :
;
POP_ALL MACRO
POP AR7
POP AR6
POP AR5
POP AR4
POP AR3
POP AR2
POP AR1
POP AR0
POP_DPTR
POP PSW
POP B
POP ACC
ENDM
;---------------------------------------------------------------------
; Funktion : DPTR pushen und popen.
; Aufrufparameter : -
; Ruechgabeparameter : -
; Veraenderte Register :
; Stackbedarf :
; Zeitbedarf :
;
PUSH_DPTR MACRO
PUSH DPL
PUSH DPH
ENDM
POP_DPTR MACRO
POP DPH
POP DPL
ENDM
;---------------------------------------------------------------------
; Funktion : DPTR decreminieren.
; Aufrufparameter : -
; Ruechgabeparameter : -
; Veraenderte Register :
; Stackbedarf :
; Zeitbedarf :
;
ifdef joerg
DEC_DPTR MACRO
INC DPL
DJNZ DPL,DEC_DPTR1
DEC DPH
DEC_DPTR1:
DEC DPL
ENDM
endif
;---------------------------------------------------------------------
; Funktion : Addieren und subtraieren mit DPTR.
; Aufrufparameter : -
; Ruechgabeparameter : -
; Veraenderte Register :
; Stackbedarf :
; Zeitbedarf :
;
ADD_DPTR MACRO WERT
PUSH PSW
PUSH ACC
MOV A,#(WERT#256)
ADD A,DPL
MOV DPL,A
MOV A,#(WERT/256)
ADDC A,DPH
MOV DPH,A
POP ACC
POP PSW
ENDM
SUBB_DPTR MACRO WERT
PUSH PSW
PUSH ACC
MOV A,DPL
CLR C
SUBB A,#(WERT#256)
MOV DPL,A
MOV A,DPH
SUBB A,#(WERT/256)
MOV DPH,A
POP ACC
POP PSW
ENDM
;---------------------------------------------------------------------
; Funktion : Rechnen mit 16- Bit- Werten im ext. RAM (L,H).
; Aufrufparameter : DPTR = Wert
; Ruechgabeparameter : DPTR = Wert
; Veraenderte Register :
; Stackbedarf :
; Zeitbedarf :
;
SET_16 MACRO NAME
PUSH ACC
PUSH_DPTR
PUSH DPH
PUSH DPL
MOV DPTR,#NAME
POP ACC
MOVX @DPTR,A
INC DPTR
POP ACC
MOVX @DPTR,A
POP_DPTR
POP ACC
ENDM
GET_16 MACRO NAME
PUSH ACC
MOV DPTR,#NAME
MOVX A,@DPTR
PUSH ACC
INC DPTR
MOVX A,@DPTR
MOV DPH,A
POP DPL
POP ACC
ENDM
;---------------------------------------------------------------------
; Funktion : Scheduler.
; Aufrufparameter : ACC = Zeichen
; Ruechgabeparameter : -
; Veraenderte Register :
; Stackbedarf :
; Zeitbedarf :
;
IFCALL MACRO CONST,ROUTINE
CJNE A,#CONST,IFCALL1
LCALL ROUTINE
IFCALL1:
ENDM
IFMAKE MACRO CONST,CODE
CJNE A,#CONST,IFMAKE1
CODE
IFMAKE1:
ENDM
;---------------------------------------------------------------------
; Funktion : Warten bis Netzwerk freiund Message senden.
; Aufrufparameter : ACC = Zeichen
; Ruechgabeparameter : -
; Veraenderte Register :
; Stackbedarf :
; Zeitbedarf :
;
SEND_NET MACRO
push acc
SEND_NET1: LCALL READ_STATUS
JB ACC.1,SEND_NET1
pop acc
LCALL SEND_MESSAGE
ENDM
;---------------------------------------------------------------------
; Funktion : Message senden.
; Aufrufparameter : -
; Ruechgabeparameter : -
; Veraenderte Register : -
; Stackbedarf :
; Zeitbedarf :
;
post_Message1 macro Modul,Msg
; if MY_SLAVE_ADR = uC_Modul
; call ADR_Msg ; interne Message
; elseif
PUSH ACC
WAIT_NET: LCALL READ_STATUS
JB ACC.1,WAIT_NET
PUSH DPL
PUSH DPH
MOV DPTR,#ModulNetAdr_Tab
MOV A,#Modul
MOVC A,@A+DPTR
POP DPH
POP DPL
MOV R0,#Modul
MOV R1,#Msg
LCALL SEND_MESSAGE ; Message ins Netz
POP ACC
; endif
endm
;---------------------------------------------------------------------
; Funktion : Message senden, alle Parameter im Mkroaufruf, B automatisch.
; Aufrufparameter : -
; Ruechgabeparameter : -
; Veraenderte Register : R0- R7
; Stackbedarf :
; Zeitbedarf :
;
post_Message2 macro Modul,Msg,PARA1,PARA2,PARA3,PARA4,PARA5,PARA6
Parameteranzahl SET 2 ; min. Modulnr. und Msg.-Nr.
PUSH ACC
PUSH B
IF "PARA1"<>""
MOV R2,PARA1
Parameteranzahl SET Parameteranzahl+1
ENDIF
IF "PARA2"<>""
MOV R3,PARA2
Parameteranzahl SET Parameteranzahl+1
ENDIF
IF "PARA3"<>""
MOV R4,PARA3
Parameteranzahl SET Parameteranzahl+1
ENDIF
IF "PARA4"<>""
MOV R5,PARA4
Parameteranzahl SET Parameteranzahl+1
ENDIF
IF "PARA5"<>""
MOV R6,PARA5
Parameteranzahl SET Parameteranzahl+1
ENDIF
IF "PARA6"<>""
MOV R7,PARA6
Parameteranzahl SET Parameteranzahl+1
ENDIF
PUSH DPL
PUSH DPH
MOV DPTR,#ModulNetAdr_Tab
MOV A,Modul
MOVC A,@A+DPTR
POP DPH
POP DPL
MOV R0,Modul
MOV R1,Msg
MOV B,#Parameteranzahl
PUSH ACC
WAIT_NET: LCALL READ_STATUS
JB ACC.1,WAIT_NET
POP ACC
LCALL SEND_MESSAGE ; Message ins Netz
POP B
POP ACC
endm
;---------------------------------------------------------------------
; Funktion : Message ausgeben
; Aufrufparameter : wie definiert
; Ruechgabeparameter : -
; Veraenderte Register :
; Stackbedarf :
; Zeitbedarf :
;
TEST_MESSAGE_HEX MACRO POS
PUSH ACC
MOV A,#POS
LCALL LCD_SET_DD_RAM_ADDRESS
POP ACC
PUSH ACC
LCALL A_LCD
MOV A,#' '
LCALL LCD_WRITE_CHAR
MOV A,B
LCALL A_LCD
MOV A,#' '
LCALL LCD_WRITE_CHAR
MOV A,R0
LCALL A_LCD
MOV A,#' '
LCALL LCD_WRITE_CHAR
MOV A,R1
LCALL A_LCD
MOV A,#' '
LCALL LCD_WRITE_CHAR
MOV A,R2
LCALL A_LCD
MOV A,#' '
LCALL LCD_WRITE_CHAR
MOV A,R3
LCALL A_LCD
MOV A,#' '
LCALL LCD_WRITE_CHAR
MOV A,R4
LCALL A_LCD
MOV A,#' '
LCALL LCD_WRITE_CHAR
MOV A,R5
LCALL A_LCD
MOV A,#' '
LCALL LCD_WRITE_CHAR
MOV A,R6
LCALL A_LCD
MOV A,#' '
LCALL LCD_WRITE_CHAR
MOV A,R7
LCALL A_LCD
POP ACC
ENDM
;---------------------------------------------------------------------
; Funktion : Fehlerbehandlung
; Aufrufparameter : Fehlernr.
; Ruechgabeparameter : -
; Veraenderte Register :
; Stackbedarf :
; Zeitbedarf :
;
ERROR MACRO NR
ENDM
;---------------------------------------------------------------------
;---------------------------------------------------------------------
TEST_MESSAGE MACRO POS,SCHALTER
IF SCHALTER<=TEST_LEVEL
PUSH ACC
MOV A,#POS
LCALL LCD_SET_DD_RAM_ADDRESS
MOV A,R0
LCALL LCD_WRITE_CHAR
MOV A,R1
LCALL LCD_WRITE_CHAR
MOV A,R2
LCALL LCD_WRITE_CHAR
MOV A,R3
LCALL LCD_WRITE_CHAR
MOV A,R4
LCALL LCD_WRITE_CHAR
MOV A,R5
LCALL LCD_WRITE_CHAR
MOV A,R6
LCALL LCD_WRITE_CHAR
MOV A,R7
LCALL LCD_WRITE_CHAR
POP ACC
ENDIF
ENDM
;---------------------------------------------------------------------
MAKE_MESSAGE MACRO ADR,STRG
IF 0=0
MOV A,#0
MOV DPTR,#STR_ADR
MOVC A,@A+DPTR
MOV R0,A
MOV A,#0
INC DPTR
MOVC A,@A+DPTR
MOV R1,A
MOV A,#0
INC DPTR
MOVC A,@A+DPTR
MOV R2,A
MOV A,#0
INC DPTR
MOVC A,@A+DPTR
MOV R3,A
MOV A,#0
INC DPTR
MOVC A,@A+DPTR
MOV R4,A
MOV A,#0
INC DPTR
MOVC A,@A+DPTR
MOV R5,A
MOV A,#0
INC DPTR
MOVC A,@A+DPTR
MOV R6,A
MOV A,#0
INC DPTR
MOVC A,@A+DPTR
MOV R7,A
MOV A,#ADR
MOV B,#8
LJMP WEITER
STR_ADR DB STRG
WEITER: NOP
ENDIF
ENDM
;---------------------------------------------------------------------
MAKE_MESSAGE_HEX MACRO ADR,L,A0,A1,A2,A3,A4,A5,A6,A7
IF 0=0
MOV R0,#A0
MOV R1,#A1
MOV R2,#A2
MOV R3,#A3
MOV R4,#A4
MOV R5,#A5
MOV R6,#A6
MOV R7,#A7
MOV A,#ADR
MOV B,#L
ENDIF
ENDM
;---------------------------------------------------------------------
|
programs/oeis/023/A023504.asm | neoneye/loda | 22 | 241425 | <reponame>neoneye/loda<gh_stars>10-100
; A023504: Greatest exponent in prime-power factorization of prime(n) - 1.
; 0,1,2,1,1,2,4,2,1,2,1,2,3,1,1,2,1,2,1,1,3,1,1,3,5,2,1,1,3,4,2,1,3,1,2,2,2,4,1,2,1,2,1,6,2,2,1,1,1,2,3,1,4,3,8,1,2,3,2,3,1,2,2,1,3,2,1,4,1,2,5,1,1,2,3,1,2,2,4,3,1,2,1,4,1,1,6,3,2,1,1,1,5,2,1,1,2,3,2,3
seq $0,40976 ; a(n) = prime(n) - 2.
seq $0,51903 ; Maximal exponent in prime factorization of n.
|
programs/oeis/120/A120908.asm | neoneye/loda | 22 | 176377 | ; A120908: Sum of the lengths of the drops in all ternary words of length n on {0,1,2}. The drops of a ternary word on {0,1,2} are the subwords 10,20 and 21, their lengths being the differences 1, 2 and 1, respectively.
; 0,4,24,108,432,1620,5832,20412,69984,236196,787320,2598156,8503056,27634932,89282088,286978140,918330048,2927177028,9298091736,29443957164,92980917360,292889889684,920511081864,2887057484028,9037745167392,28242953648100,88118015382072,274521509459532,854066918318544,2653707924775476,8235645283785960,25530500379736476,79062194724345216,244598664928443012,756032237051551128,2334805437953319660,7204542494255957808,22214006023955869908,68443153695431599176,210732867956986765884,648408824483036202720,1993857135285336323364,6127463391364692115704,18820066130620125783948,57773226261438525662352,177258762393050021918580,543593538005353400550312,1666232366494670206034652,5105052356919840631255104,15634222843067011933218756,47859865846123505918016600,146451189489137928109130796,447968344319716015392635376,1369749360516054739373635092,4186781064218884297708092168,12792942140668813131885837180,39076623266042920111942193568,119323260330238202484680626788,364249952587042933900604018616,1111590372550113781041498470604,3391292662017296281143554656080,10343442619152753657487841701044,31539021756760855414635058301544,96143146968190349570419774499868,293007685998294398690803122285312,892757793276053246011040763213060,2719477585671669887849016478710552,8282045374545540112994732003345772,25216973976228211687327243711679664,76763435486459409107010874239966036,233627847132702549456120052034679240,710896163418080614773622444048381116
mov $1,3
pow $1,$0
mul $1,$0
div $1,3
mul $1,4
mov $0,$1
|
Transynther/x86/_processed/AVXALIGN/_st_sm_/i3-7100_9_0x84_notsx.log_21829_2960.asm | ljhsiun2/medusa | 9 | 4880 | <filename>Transynther/x86/_processed/AVXALIGN/_st_sm_/i3-7100_9_0x84_notsx.log_21829_2960.asm
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r13
push %rax
push %rbp
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_WT_ht+0x6d99, %r13
nop
nop
nop
nop
dec %rbx
movb $0x61, (%r13)
nop
nop
nop
xor %rsi, %rsi
lea addresses_WC_ht+0x3799, %r10
nop
xor %rdi, %rdi
movl $0x61626364, (%r10)
and %r10, %r10
lea addresses_A_ht+0x16231, %rax
xor %rbp, %rbp
movw $0x6162, (%rax)
nop
add $26009, %rbp
lea addresses_UC_ht+0x9999, %rax
clflush (%rax)
nop
nop
nop
nop
nop
sub %rdi, %rdi
mov (%rax), %r13w
nop
nop
nop
nop
cmp $51741, %rsi
lea addresses_normal_ht+0x9db9, %rsi
lea addresses_D_ht+0x10e99, %rdi
clflush (%rdi)
nop
nop
add $12108, %rax
mov $121, %rcx
rep movsl
nop
nop
nop
sub %rcx, %rcx
lea addresses_normal_ht+0x13b8d, %rsi
nop
nop
nop
inc %rbp
movb $0x61, (%rsi)
nop
dec %rcx
lea addresses_WC_ht+0x1b299, %r13
and %rcx, %rcx
movb (%r13), %al
nop
nop
nop
nop
inc %r13
lea addresses_WC_ht+0x16a99, %rcx
nop
nop
nop
nop
add %rdi, %rdi
mov $0x6162636465666768, %rsi
movq %rsi, %xmm5
vmovups %ymm5, (%rcx)
nop
nop
nop
nop
inc %rcx
lea addresses_WT_ht+0x11a5a, %r10
nop
nop
nop
nop
nop
xor $7467, %rax
vmovups (%r10), %ymm5
vextracti128 $0, %ymm5, %xmm5
vpextrq $1, %xmm5, %rcx
nop
nop
nop
nop
nop
cmp %rbp, %rbp
lea addresses_UC_ht+0x3599, %rax
nop
nop
nop
add $36078, %rcx
movl $0x61626364, (%rax)
nop
nop
sub %rcx, %rcx
lea addresses_D_ht+0x12d99, %rcx
nop
nop
nop
nop
nop
dec %rbx
mov (%rcx), %rbp
and $26733, %rsi
lea addresses_A_ht+0x3e99, %rdi
sub $26640, %r10
mov $0x6162636465666768, %rsi
movq %rsi, %xmm5
and $0xffffffffffffffc0, %rdi
vmovntdq %ymm5, (%rdi)
nop
nop
add %rbx, %rbx
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %rax
pop %r13
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r12
push %r14
push %r8
push %rax
push %rbp
push %rdx
// Store
lea addresses_UC+0xed99, %rbp
clflush (%rbp)
nop
xor %r12, %r12
mov $0x5152535455565758, %r11
movq %r11, (%rbp)
add $18041, %r8
// Faulty Load
lea addresses_UC+0xed99, %rax
clflush (%rax)
nop
dec %r14
mov (%rax), %bp
lea oracles, %r14
and $0xff, %rbp
shlq $12, %rbp
mov (%r14,%rbp,1), %rbp
pop %rdx
pop %rbp
pop %rax
pop %r8
pop %r14
pop %r12
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_UC', 'same': False, 'size': 8, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_UC', 'same': True, 'size': 8, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
[Faulty Load]
{'src': {'type': 'addresses_UC', 'same': True, 'size': 2, 'congruent': 0, 'NT': True, 'AVXalign': True}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'dst': {'type': 'addresses_WT_ht', 'same': False, 'size': 1, 'congruent': 11, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_WC_ht', 'same': False, 'size': 4, 'congruent': 9, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_A_ht', 'same': False, 'size': 2, 'congruent': 3, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_UC_ht', 'same': False, 'size': 2, 'congruent': 10, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_normal_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 8, 'same': False}, 'OP': 'REPM'}
{'dst': {'type': 'addresses_normal_ht', 'same': False, 'size': 1, 'congruent': 1, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_WC_ht', 'same': False, 'size': 1, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_WC_ht', 'same': False, 'size': 32, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_WT_ht', 'same': False, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_UC_ht', 'same': False, 'size': 4, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_D_ht', 'same': False, 'size': 8, 'congruent': 10, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_A_ht', 'same': True, 'size': 32, 'congruent': 6, 'NT': True, 'AVXalign': False}, 'OP': 'STOR'}
{'58': 21829}
58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58
*/
|
programs/oeis/156/A156376.asm | karttu/loda | 1 | 101181 | <reponame>karttu/loda
; A156376: a(n) = 30*n + 19.
; 19,49,79,109,139,169,199,229,259,289,319,349,379,409,439,469,499,529,559,589,619,649,679,709,739,769,799,829,859,889,919,949,979,1009,1039,1069,1099,1129,1159,1189,1219,1249,1279,1309,1339,1369,1399,1429,1459,1489,1519,1549,1579,1609,1639,1669,1699,1729,1759,1789,1819,1849,1879,1909,1939,1969,1999,2029,2059,2089,2119,2149,2179,2209,2239,2269,2299,2329,2359,2389,2419,2449,2479,2509,2539,2569,2599,2629,2659,2689,2719,2749,2779,2809,2839,2869,2899,2929,2959,2989,3019,3049,3079,3109,3139,3169,3199,3229,3259,3289,3319,3349,3379,3409,3439,3469,3499,3529,3559,3589,3619,3649,3679,3709,3739,3769,3799,3829,3859,3889,3919,3949,3979,4009,4039,4069,4099,4129,4159,4189,4219,4249,4279,4309,4339,4369,4399,4429,4459,4489,4519,4549,4579,4609,4639,4669,4699,4729,4759,4789,4819,4849,4879,4909,4939,4969,4999,5029,5059,5089,5119,5149,5179,5209,5239,5269,5299,5329,5359,5389,5419,5449,5479,5509,5539,5569,5599,5629,5659,5689,5719,5749,5779,5809,5839,5869,5899,5929,5959,5989,6019,6049,6079,6109,6139,6169,6199,6229,6259,6289,6319,6349,6379,6409,6439,6469,6499,6529,6559,6589,6619,6649,6679,6709,6739,6769,6799,6829,6859,6889,6919,6949,6979,7009,7039,7069,7099,7129,7159,7189,7219,7249,7279,7309,7339,7369,7399,7429,7459,7489
mov $1,$0
mul $1,30
add $1,19
|
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/ce/ce3804c.ada | best08618/asylo | 7 | 23359 | -- CE3804C.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.
--*
-- HISTORY:
-- CHECK THAT GET FOR FLOAT_IO RAISES MODE_ERROR WHEN THE
-- MODE IS NOT IN_FILE.
-- APPLICABILITY CRITERIA:
-- THIS TEST IS ONLY APPLICABLE TO IMPLEMENTATIONS WHICH
-- SUPPORT TEXT FILES.
-- HISTORY:
-- SPS 09/07/82
-- JBG 02/22/84 CHANGED TO .ADA TEST
-- RJW 11/04/86 REVISED TEST TO OUTPUT A NON_APPLICABLE
-- RESULT WHEN FILES ARE NOT SUPPORTED.
-- DWC 09/11/87 SPLIT CASE FOR FIXED_IO INTO CE3804O.ADA
-- AND CORRECTED EXCEPTION HANDLING.
WITH REPORT;
USE REPORT;
WITH TEXT_IO;
USE TEXT_IO;
PROCEDURE CE3804C IS
INCOMPLETE : EXCEPTION;
BEGIN
TEST ("CE3804C", "CHECK THAT GET FOR FLOAT_IO RAISES " &
"MODE_ERROR WHEN THE MODE IS NOT IN_FILE");
DECLARE
FT2 : FILE_TYPE;
BEGIN
BEGIN
CREATE (FT2, OUT_FILE);
EXCEPTION
WHEN USE_ERROR =>
NOT_APPLICABLE ("USE_ERROR RAISED; TEXT CREATE " &
"FOR TEMP FILES WITH OUT_FILE " &
"MODE - 1");
RAISE INCOMPLETE;
END;
DECLARE
PACKAGE FL_IO IS NEW FLOAT_IO (FLOAT);
USE FL_IO;
X : FLOAT;
BEGIN
BEGIN
GET (FT2, X);
FAILED ("MODE_ERROR NOT RAISED - FLOAT " &
"UN-NAMED FILE");
EXCEPTION
WHEN MODE_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ("WRONG EXCEPTION RAISED - " &
"FLOAT UN-NAMED FILE");
END;
BEGIN
GET (STANDARD_OUTPUT, X);
FAILED ("MODE_ERROR NOT RAISED - FLOAT " &
"STANDARD_OUTPUT");
EXCEPTION
WHEN MODE_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ("WRONG EXCEPTION RAISED - " &
"FLOAT STANDARD_OUTPUT");
END;
BEGIN
GET (CURRENT_OUTPUT, X);
FAILED ("MODE_ERROR NOT RAISED - FLOAT " &
"CURRENT_OUTPUT");
EXCEPTION
WHEN MODE_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ("WRONG EXCEPTION RAISED - " &
"FLOAT CURRENT_OUTPUT");
END;
END;
CLOSE (FT2);
EXCEPTION
WHEN INCOMPLETE =>
NULL;
END;
RESULT;
END CE3804C;
|
Transynther/x86/_processed/NONE/_xt_/i7-7700_9_0x48.log_21829_1028.asm | ljhsiun2/medusa | 9 | 1881 | <filename>Transynther/x86/_processed/NONE/_xt_/i7-7700_9_0x48.log_21829_1028.asm
.global s_prepare_buffers
s_prepare_buffers:
push %r15
push %r8
push %rax
push %rbx
push %rcx
push %rdx
lea addresses_WT_ht+0x179fd, %rcx
nop
nop
nop
nop
nop
add %rdx, %rdx
movb $0x61, (%rcx)
nop
nop
nop
nop
nop
inc %rbx
lea addresses_normal_ht+0x1b15d, %r15
nop
nop
nop
nop
nop
add %rdx, %rdx
movb (%r15), %al
nop
nop
inc %r8
lea addresses_WT_ht+0x53dd, %r8
nop
nop
nop
nop
inc %rcx
mov $0x6162636465666768, %rdx
movq %rdx, %xmm4
vmovups %ymm4, (%r8)
nop
nop
nop
nop
cmp $10499, %r8
pop %rdx
pop %rcx
pop %rbx
pop %rax
pop %r8
pop %r15
ret
.global s_faulty_load
s_faulty_load:
push %r13
push %r15
push %r8
push %r9
push %rbp
push %rdi
// Load
lea addresses_WC+0x9c9d, %r8
nop
nop
nop
nop
nop
sub $42727, %r9
movb (%r8), %r15b
nop
nop
nop
nop
inc %rbp
// Faulty Load
lea addresses_D+0x1b5d, %r13
nop
cmp %rdi, %rdi
vmovups (%r13), %ymm6
vextracti128 $0, %ymm6, %xmm6
vpextrq $1, %xmm6, %r8
lea oracles, %r15
and $0xff, %r8
shlq $12, %r8
mov (%r15,%r8,1), %r8
pop %rdi
pop %rbp
pop %r9
pop %r8
pop %r15
pop %r13
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_D', 'AVXalign': False, 'congruent': 0, 'size': 16, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WC', 'AVXalign': False, 'congruent': 5, 'size': 1, 'same': False, 'NT': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_D', 'AVXalign': False, 'congruent': 0, 'size': 32, 'same': True, 'NT': False}}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 4, 'size': 1, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'AVXalign': True, 'congruent': 8, 'size': 1, 'same': False, 'NT': True}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 5, 'size': 32, 'same': False, 'NT': False}}
{'36': 21829}
36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36
*/
|
examples/AIM5/PolyDep/Main.agda | cruhland/agda | 1,989 | 3515 | <filename>examples/AIM5/PolyDep/Main.agda
module Main where
import PolyDepPrelude
import Homogenous.Base
import Homogenous.Equality
import Homogenous.Reflexivity
import Homogenous.Nat
import Tools
import Reflexivity
import EqBase
import TYPE
|
esercizio-17/_main.asm | mattiagualtieri/calcolatori | 0 | 173615 | .586
.model flat
.code
_palindromo proc
push ebp
mov ebp,esp
push ebx
push esi
push edi
mov esi, 0 ; indice
mov ecx, dword ptr [ebp + 8] ; stringa qui
mov edx, 0 ; lunghezza
call len
sub edx, 1
mov esi, 0
call is_palindrome
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret
_palindromo endp
is_palindrome proc
; edx = lunghezza
; esi = 0
; al, bl = esi, bl = edx - esi
pal_loop:
mov eax, 0
mov ebx, 0
mov al, byte ptr [ecx + esi * 1] ; lettera corrente
push edx
sub edx, esi
cmp esi, edx
jge end_pal_loop
mov bl, byte ptr [ecx + edx * 1] ; lettera speculare
pop edx
call to_up
cmp bl, al
jnz end_not_pal_loop
inc esi
jmp pal_loop
end_not_pal_loop:
mov eax, 0
ret
end_pal_loop:
pop edx
mov eax, 1
ret
is_palindrome endp
len proc
keep_going:
cmp byte ptr [ecx + esi * 1], 0
jz endloop
inc edx
inc esi
jmp keep_going
endloop: ret
len endp
to_up proc
cmp bl, 90
jg bl_upper
jmp bl_not_upper
bl_upper: sub bl, 32
bl_not_upper:
cmp al, 90
jg al_upper
jmp al_not_upper
al_upper: sub al, 32
al_not_upper: ret
to_up endp
End |
hw1/main.adb | uiyunkim-private/opl | 0 | 26114 | <filename>hw1/main.adb
-- This code is from Rosettacode.org
-- http://rosettacode.org/wiki/FizzBuzz
-- This program will run fizz buzz 100 times with if-else strategy.
with Ada.Text_IO; use Ada.Text_IO;
procedure Fizzbuzz is
begin
for I in 1..100 loop
if I mod 15 = 0 then
Put_Line("FizzBuzz");
elsif I mod 5 = 0 then
Put_Line("Buzz");
elsif I mod 3 = 0 then
Put_Line("Fizz");
else
Put_Line(Integer'Image(I));
end if;
end loop;
end Fizzbuzz;
|
oeis/075/A075653.asm | neoneye/loda-programs | 11 | 242202 | ; A075653: a(n) = n + sopf(n), where sopf is the sum of the distinct prime factors of n (A008472).
; 1,4,6,6,10,11,14,10,12,17,22,17,26,23,23,18,34,23,38,27,31,35,46,29,30,41,30,37,58,40,62,34,47,53,47,41,74,59,55,47,82,54,86,57,53,71,94,53,56,57,71,67,106,59,71,65,79,89,118,70,122,95,73,66,83,82,134,87,95,84,142,77,146,113,83,97,95,96,158,87,84,125,166,96,107,131,119,101,178,100,111,117,127,143,119,101,194,107,113,107
mov $1,$0
seq $1,8472 ; Sum of the distinct primes dividing n.
add $0,$1
add $0,1
|
projects/batfish/src/main/antlr4/org/batfish/grammar/fortios/Fortios_policy.g4 | pranavbj-amzn/batfish | 763 | 1174 | parser grammar Fortios_policy;
options {
tokenVocab = FortiosLexer;
}
cf_policy: POLICY newline cfp*;
cfp: cfp_clone | cfp_delete | cfp_edit | cfp_move;
cfp_clone: CLONE name = policy_number TO to = policy_number newline;
cfp_delete: DELETE name = policy_number newline;
cfp_move: MOVE name = policy_number after_or_before pivot = policy_number newline;
cfp_edit: EDIT policy_number newline cfpe* NEXT newline;
cfpe: cfp_set | cfp_append | cfp_select;
cfp_set: SET (cfp_set_singletons | cfp_set_lists);
cfp_select: SELECT cfp_set_lists;
cfp_set_singletons
:
cfp_set_action
| cfp_set_comments
| cfp_set_name
| cfp_set_status
| cfp_set_uuid
;
cfp_set_action: ACTION action = policy_action newline;
cfp_set_comments: COMMENTS comments = str newline;
cfp_set_name: NAME name = policy_name newline;
cfp_set_status: STATUS status = policy_status newline;
cfp_set_uuid: UUID id = str newline;
cfp_set_lists
:
cfp_set_dstaddr
| cfp_set_dstintf
| cfp_set_service
| cfp_set_srcaddr
| cfp_set_srcintf
;
cfp_set_dstaddr: DSTADDR addresses = address_names newline;
cfp_set_srcaddr: SRCADDR addresses = address_names newline;
cfp_set_service: SERVICE services = service_names newline;
cfp_set_dstintf: DSTINTF interfaces = interface_or_zone_names newline;
cfp_set_srcintf: SRCINTF interfaces = interface_or_zone_names newline;
cfp_append
:
APPEND (
cfp_append_dstaddr
| cfp_append_dstintf
| cfp_append_service
| cfp_append_srcaddr
| cfp_append_srcintf
)
;
cfp_append_dstaddr: DSTADDR addresses = address_names newline;
cfp_append_srcaddr: SRCADDR addresses = address_names newline;
cfp_append_service: SERVICE services = service_names newline;
cfp_append_dstintf: DSTINTF interfaces = interface_or_zone_names newline;
cfp_append_srcintf: SRCINTF interfaces = interface_or_zone_names newline;
// 1-35
policy_name: str;
policy_status: enable_or_disable;
// 0-4294967294
policy_number: str;
policy_action: ACCEPT | DENY | IPSEC;
address_names: address_name+;
interface_or_zone_names: interface_or_zone_name+;
|
Formalization/LambdaCalculus.agda | Lolirofle/stuff-in-agda | 6 | 4780 | <filename>Formalization/LambdaCalculus.agda
module Formalization.LambdaCalculus where
import Lvl
open import Data
open import Numeral.Natural
open import Numeral.Finite
open import Syntax.Number
open import Type
-- A lambda term (A term in the language of lambda calculus).
-- This is encoded with an abstraction depth which ensures that every term is well-formed.
-- `Term(𝟎)` is the type of closed terms, terms that have no unbound variables.
-- In this representation, it means that there are no occurrences of `Var(_)` in a term.
-- `Term(𝐒(n))` for some `n` is the types of open terms with possibly `n` number of different variables, terms that have unbound variables.
-- In this representation, it means that there can be `Var(i)` for `i < n` in a term.
data Term : ℕ → Type{0} where
-- The term which represents applying the second term on the first term.
-- Representation in function notation:
-- (Apply f(x)) is f(x)
Apply : ∀{d} → Term(d) → Term(d) → Term(d)
-- The term which represents bounding a new variable (introducing a variable).
-- Representation in function notation:
-- (Abstract{n} term) is (xₙ ↦ term)
Abstract : ∀{d} → Term(𝐒(d)) → Term(d)
-- The term which represents a specific variable in scope.
-- Representation in function notation:
-- (Var(n)) is xₙ
Var : ∀{d} → 𝕟(d) → Term(d)
-- An expression in the language of lambda calculus is a closed term.
Expression : Type{0}
Expression = Term(0)
module VarNumeralSyntax where
-- Syntax for writing Var as a numeral.
instance
Term-from-ℕ : ∀{N} → Numeral(Term(N))
Numeral.restriction-ℓ ( Term-from-ℕ {N} ) = Numeral.restriction-ℓ ( 𝕟-from-ℕ {N} )
Numeral.restriction ( Term-from-ℕ {N} ) = Numeral.restriction ( 𝕟-from-ℕ {N} )
num ⦃ Term-from-ℕ {N} ⦄ (n) ⦃ proof ⦄ = Var(num n)
module OperSyntax where
open VarNumeralSyntax public
infixr 100 _↦_
infixl 101 _←_
pattern _↦_ d expr = Term.Abstract{d} expr
pattern _←_ a b = Term.Apply a b
module ExplicitLambdaSyntax where
open VarNumeralSyntax public
infixl 101 _←_
pattern 𝜆 d expr = Term.Abstract{d} expr
pattern _←_ a b = Term.Apply a b
|
Transynther/x86/_processed/NONE/_xt_/i9-9900K_12_0xca.log_21829_1130.asm | ljhsiun2/medusa | 9 | 83076 | .global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r15
push %r8
push %rbp
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_D_ht+0x17f98, %r8
nop
nop
nop
and %r11, %r11
movups (%r8), %xmm5
vpextrq $1, %xmm5, %rbp
nop
nop
cmp $33929, %rbx
lea addresses_UC_ht+0x1d1f8, %r15
nop
nop
xor %rsi, %rsi
mov (%r15), %bp
nop
dec %r15
lea addresses_normal_ht+0x1ef18, %r8
nop
nop
nop
nop
nop
add $62501, %rcx
movw $0x6162, (%r8)
dec %rbp
lea addresses_WT_ht+0x7018, %rsi
lea addresses_D_ht+0x18c78, %rdi
clflush (%rdi)
nop
nop
nop
nop
add $53191, %rbx
mov $19, %rcx
rep movsq
add %rbx, %rbx
lea addresses_normal_ht+0x5ae8, %rcx
nop
nop
nop
nop
nop
add %r8, %r8
mov (%rcx), %r15
nop
nop
nop
nop
nop
and $1444, %r15
lea addresses_normal_ht+0x418, %r11
clflush (%r11)
nop
nop
nop
xor $35075, %r15
mov (%r11), %ebx
nop
nop
nop
nop
and $43409, %rcx
lea addresses_normal_ht+0x13fd0, %r8
nop
nop
nop
cmp $11871, %rbp
mov $0x6162636465666768, %rdi
movq %rdi, %xmm4
movups %xmm4, (%r8)
nop
and $32966, %rdi
lea addresses_A_ht+0xdcb8, %rdi
sub %rsi, %rsi
and $0xffffffffffffffc0, %rdi
vmovaps (%rdi), %ymm2
vextracti128 $0, %ymm2, %xmm2
vpextrq $1, %xmm2, %rcx
nop
and $566, %rdi
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %r8
pop %r15
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r15
push %r8
push %r9
push %rax
push %rdx
push %rsi
// Store
lea addresses_US+0x13e18, %rax
nop
sub $13936, %r15
mov $0x5152535455565758, %rsi
movq %rsi, %xmm4
vmovups %ymm4, (%rax)
nop
nop
dec %r12
// Store
lea addresses_PSE+0xafc0, %rdx
nop
add %r8, %r8
mov $0x5152535455565758, %r15
movq %r15, %xmm2
movntdq %xmm2, (%rdx)
nop
sub $29380, %r12
// Load
lea addresses_A+0xe898, %rdx
clflush (%rdx)
nop
nop
nop
nop
dec %rax
mov (%rdx), %r9
nop
nop
nop
nop
nop
cmp %r12, %r12
// Faulty Load
lea addresses_RW+0x12418, %r9
nop
nop
nop
dec %rdx
movups (%r9), %xmm6
vpextrq $0, %xmm6, %r8
lea oracles, %rsi
and $0xff, %r8
shlq $12, %r8
mov (%rsi,%r8,1), %r8
pop %rsi
pop %rdx
pop %rax
pop %r9
pop %r8
pop %r15
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_RW', 'same': False, 'AVXalign': False, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_US', 'same': False, 'AVXalign': False, 'congruent': 9}}
{'OP': 'STOR', 'dst': {'size': 16, 'NT': True, 'type': 'addresses_PSE', 'same': False, 'AVXalign': False, 'congruent': 3}}
{'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_A', 'same': False, 'AVXalign': False, 'congruent': 3}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_RW', 'same': True, 'AVXalign': False, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_D_ht', 'same': True, 'AVXalign': False, 'congruent': 5}}
{'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 4}}
{'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 7}}
{'OP': 'REPM', 'src': {'same': True, 'type': 'addresses_WT_ht', 'congruent': 7}, 'dst': {'same': False, 'type': 'addresses_D_ht', 'congruent': 1}}
{'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 4}}
{'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 10}}
{'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 2}}
{'OP': 'LOAD', 'src': {'size': 32, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': True, 'congruent': 3}}
{'32': 21829}
32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
*/
|
3-mid/impact/source/3d/collision/shapes/impact-d3-shape-concave.ads | charlie5/lace | 20 | 45 | <filename>3-mid/impact/source/3d/collision/shapes/impact-d3-shape-concave.ads
with impact.d3.Shape;
with impact.d3.triangle_Callback;
package impact.d3.Shape.concave
--
-- The impact.d3.Shape.concave class provides an interface for non-moving (static) concave shapes.
-- It has been implemented by the impact.d3.Shape.concave.static_plane, impact.d3.Shape.concave.triangle_mesh.bvh and impact.d3.Shape.concave.height_field_terrain.
--
is
type Item is abstract new impact.d3.Shape.item with private;
type View is access all Item'Class;
-- /// PHY_ScalarType enumerates possible scalar types.
-- /// See the impact.d3.striding_Mesh or impact.d3.Shape.concave.height_field_terrain for its use
-- typedef enum PHY_ScalarType {
-- PHY_FLOAT,
-- PHY_DOUBLE,
-- PHY_INTEGER,
-- PHY_SHORT,
-- PHY_FIXEDPOINT88,
-- PHY_UCHAR
-- } PHY_ScalarType;
--- Forge
--
procedure define (Self : in out Item);
overriding procedure destruct (Self : in out Item);
--- Attributes
--
overriding procedure setMargin (Self : in out Item; margin : in Real);
overriding function getMargin (Self : in Item) return Real;
procedure processAllTriangles (Self : in Item; callback : access impact.d3.triangle_Callback.Item'Class;
aabbMin, aabbMax : in math.Vector_3)
is abstract;
private
type Item is abstract new impact.d3.Shape.item with
record
m_collisionMargin : math.Real;
end record;
end impact.d3.Shape.concave;
|
obj/gnattest/tests/dg_types-test_data.adb | SMerrony/dgemua | 2 | 22584 | <filename>obj/gnattest/tests/dg_types-test_data.adb
-- This package is intended to set up and tear down the test environment.
-- Once created by GNATtest, this package will never be overwritten
-- automatically. Contents of this package can be modified in any way
-- except for sections surrounded by a 'read only' marker.
package body DG_Types.Test_Data is
procedure Set_Up (Gnattest_T : in out Test) is
pragma Unreferenced (Gnattest_T);
begin
null;
end Set_Up;
procedure Tear_Down (Gnattest_T : in out Test) is
pragma Unreferenced (Gnattest_T);
begin
null;
end Tear_Down;
end DG_Types.Test_Data;
|
programs/oeis/209/A209723.asm | neoneye/loda | 22 | 21448 | <reponame>neoneye/loda<gh_stars>10-100
; A209723: 1/4 the number of (n+1) X 5 0..2 arrays with every 2 X 2 subblock having distinct clockwise edge differences.
; 6,7,8,10,12,16,20,28,36,52,68,100,132,196,260,388,516,772,1028,1540,2052,3076,4100,6148,8196,12292,16388,24580,32772,49156,65540,98308,131076,196612,262148,393220,524292,786436,1048580,1572868,2097156,3145732,4194308,6291460,8388612,12582916,16777220,25165828,33554436,50331652,67108868,100663300,134217732,201326596,268435460,402653188,536870916,805306372,1073741828,1610612740,2147483652,3221225476,4294967300,6442450948,8589934596,12884901892,17179869188,25769803780,34359738372,51539607556,68719476740,103079215108,137438953476,206158430212,274877906948,412316860420,549755813892,824633720836,1099511627780,1649267441668,2199023255556,3298534883332,4398046511108,6597069766660,8796093022212,13194139533316,17592186044420,26388279066628,35184372088836,52776558133252,70368744177668,105553116266500,140737488355332,211106232532996,281474976710660,422212465065988,562949953421316,844424930131972,1125899906842628,1688849860263940
seq $0,164090 ; a(n) = 2*a(n-2) for n > 2; a(1) = 2, a(2) = 3.
add $0,4
|
agda/book/2015-Verified_Functional_programming_in_Agda-Stump/ial/z05-01-bst.agda | haroldcarr/learn-haskell-coq-ml-etc | 36 | 17516 | <gh_stars>10-100
-- binary search trees (not balanced)
open import bool
open import bool-thms2
open import eq
open import maybe
open import product
open import product-thms
open import bool-relations using (transitive ; total)
module z05-01-bst (A : Set) -- type of elements
(_≤A_ : A → A → 𝔹) -- ordering function
(≤A-trans : transitive _≤A_) -- proof of transitivity of given ordering
(≤A-total : total _≤A_) -- proof of totality of given ordering
where
{-
IAL
- relations.agda
- models binary relation on A as functions from A to A to Set
- bool-relations.agda
- models binary realtion on A as functions from A to A to 𝔹
Cannot use A→A→Set relations here because code cannot manipulate types.
But code can pattern match on values of type 𝔹, so boolean relations more useful.
-}
open import bool-relations _≤A_ hiding (transitive ; total)
open import minmax _≤A_ ≤A-trans ≤A-total
-- able to store values in bounds 'l' and 'u'
-- l(ower) bound
-- | u(upper) bound
-- v v
data bst : A → A → Set where
bst-leaf : ∀ {l u : A}
→ l ≤A u ≡ tt
→ bst l u
bst-node : ∀ {l l' u' u : A}
→ (d : A) -- value stored in this node
→ bst l' d -- left subtree of values ≤ stored value
→ bst d u' -- right subtree of values ≥ stored value
→ l ≤A l' ≡ tt
→ u' ≤A u ≡ tt
→ bst l u
------------------------------------------------------------------------------
bst-search : ∀ {l u : A}
→ (d : A) -- find a node that is isomorphic (_=A_) to d
→ bst l u
→ maybe (Σ A (λ d' → d iso𝔹 d' ≡ tt)) -- return that node or nothing
bst-search d (bst-leaf _) = nothing -- could return proof not in tree instead
-- compare given element with stored element
bst-search d (bst-node d' L R _ _) with keep (d ≤A d')
-- compare given element with stored element (other direction)
bst-search d (bst-node d' L R _ _) | tt , p1 with keep (d' ≤A d)
-- both are true implying iso, so return that element and proof
bst-search d (bst-node d' L R _ _) | tt , p1 | tt , p2 = just (d' , iso𝔹-intro p1 p2)
-- if either is false then search the appropriate branch
bst-search d (bst-node d' L R _ _) | tt , p1 | ff , p2 = bst-search d L -- search in left
bst-search d (bst-node d' L R _ _) | ff , p1 = bst-search d R -- search in right
------------------------------------------------------------------------------
-- change the lower bound from l' to l
bst-dec-lb : ∀ {l l' u' : A}
→ bst l' u'
→ l ≤A l' ≡ tt
→ bst l u'
bst-dec-lb (bst-leaf p) q = bst-leaf (≤A-trans q p)
bst-dec-lb (bst-node d L R p1 p2) q = bst-node d L R (≤A-trans q p1) p2
-- change the upper bound from u' to u
bst-inc-ub : ∀ {l' u' u : A}
→ bst l' u'
→ u' ≤A u ≡ tt
→ bst l' u
bst-inc-ub (bst-leaf p) q = bst-leaf (≤A-trans p q)
bst-inc-ub (bst-node d L R p1 p2) q = bst-node d L R p1 (≤A-trans p2 q)
bst-insert : ∀{l u : A}
→ (d : A) -- insert 'd'
→ bst l u -- into this 'bst'
→ bst (min d l) (max d u) -- type might change
bst-insert d (bst-leaf p) =
bst-node d (bst-leaf ≤A-refl) (bst-leaf ≤A-refl) min-≤1 max-≤1
bst-insert d (bst-node d' L R p1 p2) with keep (d ≤A d')
bst-insert d (bst-node d' L R p1 p2) | tt , p with bst-insert d L
bst-insert d (bst-node d' L R p1 p2) | tt , p | L' rewrite p =
bst-node d' L' (bst-inc-ub R (≤A-trans p2 max-≤2))
(min2-mono p1) ≤A-refl
bst-insert d (bst-node d' L R p1 p2) | ff , p with bst-insert d R
bst-insert d (bst-node d' L R p1 p2) | ff , p | R' rewrite p =
bst-node d' (bst-dec-lb L p1) R'
min-≤2 (max2-mono p2)
|
programs/oeis/090/A090617.asm | karttu/loda | 0 | 23156 | <reponame>karttu/loda<gh_stars>0
; A090617: Highest power of 8 dividing n!.
; 0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,5,5,5,5,6,6,6,6,7,7,7,7,8,8,8,8,10,10,10,10,11,11,11,11,12,12,13,13,13,13,14,14,15,15,15,15,16,16,16,16,17,17,18,18,18,18,19,19,21,21,21,21,22,22,22,22,23,23,23,23,24,24,24,24
div $0,2
lpb $0,1
add $1,$0
div $0,2
lpe
div $1,3
|
oeis/037/A037489.asm | neoneye/loda-programs | 11 | 171676 | <reponame>neoneye/loda-programs<filename>oeis/037/A037489.asm
; A037489: Base 4 digits are, in order, the first n terms of the periodic sequence with initial period 2,1.
; 2,9,38,153,614,2457,9830,39321,157286,629145,2516582,10066329,40265318,161061273,644245094,2576980377,10307921510,41231686041,164926744166,659706976665,2638827906662,10555311626649,42221246506598,168884986026393,675539944105574,2702159776422297,10808639105689190,43234556422756761,172938225691027046,691752902764108185,2767011611056432742,11068046444225730969,44272185776902923878,177088743107611695513,708354972430446782054,2833419889721787128217,11333679558887148512870,45334718235548594051481
mov $1,4
pow $1,$0
mul $1,12
div $1,5
mov $0,$1
|
stage2/16/vecs16.asm | tkchia/rebrief | 0 | 9604 | ; Copyright (c) 2021 <NAME>
;
; 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 developer(s) nor the names of its
; contributors may be used to endorse or promote products derived from
; this software without specific prior written permission.
;
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
; IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
; TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
; PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
; HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
; TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
%include "stage2/stage2.inc"
bits 16
; Start a series of interrupt vector entries.
%macro ISR_BEGIN 1
section .rodata
global vecs16_part%1
vecs16_part%1:
%endmacro
; Add an interrupt vector entry for an unimplemented interrupt.
%macro ISR_UNIMPL 1
section .text
isr16_%{1}_unimpl:
mov cl, %1
call isr16_unimpl
section .rodata
dw isr16_%{1}_unimpl
%endmacro
; Add an interrupt vector entry for an interrupt implemented in assembly.
%macro ISR_IMPL 1
section .rodata
dw isr16_%1
%endmacro
; Add an interrupt vector entry for an interrupt implemented in C.
%macro ISR_IMPL_C 1
section .text
extern isr16_%1_impl
isr16_%1:
push gs ; push segment registers
push fs
push es
push ds
push edi ; push registers
push esi
push ebp
push ebx
push edx
push ecx
push eax
mov eax, esp ; preserve esp's top 16 bits, &
and esp, byte -4 ; round esp down to 4-byte boundary
push eax ; also point eax to the saved regs.
xor dx, dx ; set up segment registers: point gs
mov gs, dx ; to linear address 0, fs to our
mov fs, [gs:bda.ebda] ; 16-bit data segment (via the
mov dx, ss ; EBDA), & ds & es to the user stack
mov ds, dx
mov es, dx
push byte 0 ; call out to C routine; stuff a 0 on
call isr16_%1_impl ; stack to make ret. addr. 32-bit
pop esp ; restore esp
pop eax ; restore the other registers
pop ecx
pop edx
pop ebx
pop ebp
pop esi
pop edi
pop ds
pop es
pop fs
pop gs
iret ; return
section .rodata
dw isr16_%1
%endmacro
; Add an interrupt vector entry for an IRQ implemented in assembly.
%macro ISR_IRQ 2
section .rodata
dw irq%2
%endmacro
; Add an interrupt vector entry for an IRQ implemented in C.
%macro ISR_IRQ_C 2
section .text
extern irq%2_impl
irq%2:
push gs ; push segment registers
push fs
push es
push ds
push edx ; push call-used registers
push ecx
push eax
mov eax, esp ; preserve esp's top 16 bits, &
and esp, byte -4 ; round esp down to 4-byte boundary
push eax
xor ax, ax ; set up segment registers: point gs
mov gs, ax ; to linear address 0, fs to our
mov fs, [gs:bda.ebda] ; 16-bit data segment (via the
mov ax, ss ; EBDA), & ds & es to the user stack
mov ds, ax
mov es, ax
push byte 0 ; call out to C routine; stuff a 0 on
call irq%2_impl ; stack to make ret. addr. 32-bit
pop esp ; restore esp
pop eax ; restore the other registers
pop ecx
pop edx
pop ds
pop es
pop fs
pop gs
iret ; return
section .rodata
dw irq%2
%endmacro
; Add an interrupt vector entry for an ISR which just does an `iret'.
%macro ISR_IRET 1
section .rodata
dw iret16
%endmacro
; Wrap up our table of interrupt vectors.
%macro ISR_END 1
section .rodata
global NUM_VECS16_PART%1
NUM_VECS16_PART%1 equ ($-vecs16_part%1)/2
%endmacro
extern irq0, irq8, isr16_0x1a
ISR_BEGIN 1
ISR_UNIMPL 0x00
ISR_IRET 0x01
ISR_UNIMPL 0x02
ISR_IRET 0x03
ISR_IRET 0x04
ISR_UNIMPL 0x05
ISR_UNIMPL 0x06
ISR_UNIMPL 0x07
ISR_IRQ 0x08, 0
ISR_IRQ_C 0x09, 1
ISR_UNIMPL 0x0a
ISR_UNIMPL 0x0b
ISR_UNIMPL 0x0c
ISR_UNIMPL 0x0d
ISR_UNIMPL 0x0e
ISR_UNIMPL 0x0f
ISR_IMPL 0x10
ISR_IMPL 0x11
ISR_IMPL 0x12
ISR_UNIMPL 0x13
ISR_UNIMPL 0x14
ISR_IMPL_C 0x15
ISR_UNIMPL 0x16
ISR_UNIMPL 0x17
ISR_UNIMPL 0x18
ISR_UNIMPL 0x19
ISR_IMPL 0x1a
ISR_IRET 0x1b
ISR_IRET 0x1c
ISR_END 1
ISR_BEGIN 2
ISR_IRQ 0x70, 8
ISR_END 2
section .text
; Stub handler for int 0x10 (video). The system's VGA option ROM is
; expected to fill in an actual int 0x10 implementation.
;
; Before it does, we use a default handler, which mostly just calls
; isr16_unimpl, but has stub implementations of functions ah = 0x03 & ah =
; 0x13 to avoid recursively invoking itself.
isr16_0x10:
cmp ah, 0x03
jz .fn0x03
cmp ah, 0x13
jz .fn0x13
mov cl, 0x10
call isr16_unimpl
.fn0x03:
xor cx, cx
cwd
.fn0x13:
iret
; Handler for int 0x11 (get equipment list).
isr16_0x11:
push ds
xor ax, ax
mov ds, ax
movzx eax, word [bda.eqpt]
pop ds
iret16: iret
; Handler for int 0x12 (get memory size).
isr16_0x12:
push ds
xor ax, ax
mov ds, ax
mov ax, [bda.base_kib]
pop ds
iret
extern _stack16
; Catch-all for unimplemented interrupt service routines.
global isr16_unimpl
isr16_unimpl:
xchg bx, ax ; save our incoming ax
xor ax, ax
mov ds, ax
dec ax ; mask all IRQs --- frob the PICs
out PIC1_DATA, al ; so that even if `int 0x10' uses
out PIC2_DATA, al ; `sti', no IRQs will trigger
mov ax, [bda.ebda] ; switch to our stack
mov ds, ax
mov es, ax
mov ss, ax
mov sp, _stack16
xchg cx, ax ; plug in the intr. vector no. (cl)
call u8_to_hex
mov [msg_unimpl.num], ax
mov al, bh ; plug in the incoming ax
call u8_to_hex
mov [msg_unimpl.ax], ax
xchg bx, ax
call u8_to_hex
mov [msg_unimpl.ax+2], ax
mov al, dh ; plug in the incoming dx
call u8_to_hex
mov [msg_unimpl.dx], ax
xchg dx, ax
call u8_to_hex
mov [msg_unimpl.dx+2], ax
mov ah, 0x03 ; then really panic
xor bh, bh
int 0x10
mov ax, 0x1301
mov bx, 0x0007
mov cx, msg_unimpl.end-msg_unimpl
mov bp, msg_unimpl
int 0x10
cli
hlt
; Convert an 8-bit binary value in al, to its hexadecimal representation in
; ASCII in al:ah.
u8_to_hex:
mov ah, al
shr al, 4
and ah, 0x0f
add al, '0'
cmp al, '9'
jbe .0
add al, 'a'-('9'+1)
.0: add ah, '0'
cmp ah, '9'
jbe .1
add ah, 'a'-('9'+1)
.1: ret
section .data
msg_unimpl:
db 13, 10, "stage2 panic: int 0x"
.num: db "00 unimplemented (with ax = 0x"
.ax: db "0000, dx = 0x"
.dx: db "0000)", 7
.end:
|
programs/oeis/017/A017511.asm | neoneye/loda | 22 | 98675 | <reponame>neoneye/loda
; A017511: a(n) = (11*n + 10)^3.
; 1000,9261,32768,79507,157464,274625,438976,658503,941192,1295029,1728000,2248091,2863288,3581577,4410944,5359375,6434856,7645373,8998912,10503459,12167000,13997521,16003008,18191447,20570824,23149125,25934336,28934443,32157432,35611289,39304000,43243551,47437928,51895117,56623104,61629875,66923416,72511713,78402752,84604519,91125000,97972181,105154048,112678587,120553784,128787625,137388096,146363183,155720872,165469149,175616000,186169411,197137368,208527857,220348864,232608375,245314376,258474853,272097792,286191179,300763000,315821241,331373888,347428927,363994344,381078125,398688256,416832723,435519512,454756609,474552000,494913671,515849608,537367797,559476224,582182875,605495736,629422793,653972032,679151439,704969000,731432701,758550528,786330467,814780504,843908625,873722816,904231063,935441352,967361669,1000000000,1033364331,1067462648,1102302937,1137893184,1174241375,1211355496,1249243533,1287913472,1327373299
mul $0,11
add $0,10
pow $0,3
|
programs/oeis/165/A165776.asm | neoneye/loda | 22 | 28829 | <gh_stars>10-100
; A165776: n + (least square > n), i.e., n + A048761(n+1).
; 1,5,6,7,13,14,15,16,17,25,26,27,28,29,30,31,41,42,43,44,45,46,47,48,49,61,62,63,64,65,66,67,68,69,70,71,85,86,87,88,89,90,91,92,93,94,95,96,97,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,145,146
mov $1,$0
add $0,1
mov $2,3
lpb $1
add $0,$2
trn $1,$2
add $2,2
lpe
|
Source/World.asm | AAKMakes/ASM-projects | 0 | 86937 | ; ASM -- National Computer Camps 2013
; Sample Code for instruction written by <NAME> in 2012
; Setup Notepad++: Press Language > A > Assembly
; Enable Auto Complete: Press Settings > Preferances > Backup/Auto-Completion > Check the auto completion boxes
; === STACK SEGMENT ===
MyStack segment stack
DB 64 dup('12345678') ; This segment will essentially allocate 8 bits (one byte) of memory
MyStack endS ; onto the stack. This should be the same for every assembler program.
; === DATA SEGMENT ===
MyData segment
; --- Declare your variables here ---
helloMsg DB "Hello World$" ; This is the format for declaring a variable, the $ indicates a string.
MyData endS ; Format: varName DB "Value" |OR| varName DB "StringValue$"
; === CODE SEGMENT ===
MyCode segment ; Sets up the segment names for
Assume CS:MyCode,DS:MyData ; the code and data segments.
; === INCLUDE DIRECTIVES ===
; === PROCEDURES ===
Main PROC ; Main procedure
Start: ; This is how you define function names- "FunctionName:", important for later programs
MOV AX, MyData ; Setup data segment, first move vars into a register (AX)
MOV DS, AX ; then move the register value into DS. Mucho Importante!
; --- Insert your program's initial code here ---
; Print "Hello World" to the screen
MOV AH,9 ; DOS-Service Code 9 : Print string DX. Always load svc. codes into AH
LEA DX,helloMsg ; DX -> helloMsg : DX becomes a pointer to var helloMsg
INT 21h ; Invokes the DOS service : Carries out the DOS Svc. Code in AH
;TIP: You can find the DOS service codes here: http://spike.scu.edu.au/~barry/interrupts.html
; ---Stick all this footer code in all of your Assembler programs---
;This section of code closes the program and returns to DOS.
MOV AH, 4Ch ; DOS Service Code 4C: Exit Program (Any service code with a letter must end with "h" for hex value)
XOR AL, AL ; Using XOR with the same register clears the value, a more efficent version of "MOV AL, 0"
INT 21h ; Call the DOS service and return to the DOS prompt
; The following code is essential, it will prevent memory leaks and completely close and terminate your program
Main ENDP
MyCode endS
End Start |
programs/oeis/265/A265724.asm | jmorken/loda | 1 | 19260 | ; A265724: Total number of OFF (white) cells after n iterations of the "Rule 1" elementary cellular automaton starting with a single ON (black) cell.
; 0,3,7,10,18,21,33,36,52,55,75,78,102,105,133,136,168,171,207,210,250,253,297,300,348,351,403,406,462,465,525,528,592,595,663,666,738,741,817,820,900,903,987,990,1078,1081,1173,1176,1272,1275,1375,1378,1482,1485,1593,1596,1708,1711,1827,1830,1950,1953,2077,2080,2208,2211,2343,2346,2482,2485,2625,2628,2772,2775,2923,2926,3078,3081,3237,3240,3400,3403,3567,3570,3738,3741,3913,3916,4092,4095,4275,4278,4462,4465,4653,4656,4848,4851,5047,5050,5250,5253,5457,5460,5668,5671,5883,5886,6102,6105,6325,6328,6552,6555,6783,6786,7018,7021,7257,7260,7500,7503,7747,7750,7998,8001,8253,8256,8512,8515,8775,8778,9042,9045,9313,9316,9588,9591,9867,9870,10150,10153,10437,10440,10728,10731,11023,11026,11322,11325,11625,11628,11932,11935,12243,12246,12558,12561,12877,12880,13200,13203,13527,13530,13858,13861,14193,14196,14532,14535,14875,14878,15222,15225,15573,15576,15928,15931,16287,16290,16650,16653,17017,17020,17388,17391,17763,17766,18142,18145,18525,18528,18912,18915,19303,19306,19698,19701,20097,20100,20500,20503,20907,20910,21318,21321,21733,21736,22152,22155,22575,22578,23002,23005,23433,23436,23868,23871,24307,24310,24750,24753,25197,25200,25648,25651,26103,26106,26562,26565,27025,27028,27492,27495,27963,27966,28438,28441,28917,28920,29400,29403,29887,29890,30378,30381,30873,30876,31372,31375
mov $4,6
lpb $0
add $3,$0
add $1,$3
add $1,2
mov $2,$1
mov $3,0
sub $4,3
mov $1,$4
add $2,6
mov $4,$0
sub $0,1
sub $2,2
add $4,$2
lpe
|
examples/AIM5/PolyDep/Homogenous/Nat.agda | cruhland/agda | 1,989 | 9412 | <filename>examples/AIM5/PolyDep/Homogenous/Nat.agda
module Homogenous.Nat where
import PolyDepPrelude
open PolyDepPrelude using (zero; one; _::_; nil; right; left; pair; unit)
import Homogenous.Base
open Homogenous.Base using (Sig; T; Intro)
-- The code for natural numbers is [0 1]
codeNat : Sig
codeNat = zero :: (one :: nil)
iNat : Set
iNat = T codeNat
-- Short-hand notation for the normal Nat constructors
izero : iNat
izero = Intro (left unit)
isucc : iNat -> iNat
isucc = \(h : iNat) -> Intro (right (left (pair h unit)))
-- the pair with the dummy unit component comes from the 1-tuple
-- representation as A*()
ione : iNat
ione = isucc izero
{-
main : Set
main = {!!}
-}
|
BigNum/Mod/Base/bnDec.asm | FloydZ/Crypto-Hash | 11 | 161694 | .686
.model flat,stdcall
option casemap:none
include .\bnlib.inc
include .\bignum.inc
.code
bnDec proc uses edi bn:DWORD
mov edi,bn
mov eax,1
.if BN_IS_ZERO(edi)
or [edi].BN.bSigned,1
.endif
.if [edi].BN.bSigned
call _bn_adddw_ignoresign
ret
.endif
call _bn_subdw_ignoresign
ret
bnDec endp
end |
src/GUI/date_widget.ads | Fabien-Chouteau/coffee-clock | 7 | 27616 | -------------------------------------------------------------------------------
-- --
-- Coffee Clock --
-- --
-- Copyright (C) 2016-2017 <NAME> --
-- --
-- Coffee Clock is free software: you can redistribute it and/or --
-- modify it under the terms of the GNU General Public License as --
-- published by the Free Software Foundation, either version 3 of the --
-- License, or (at your option) any later version. --
-- --
-- Coffee Clock is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- General Public License for more details. --
-- --
-- You should have received a copy of the GNU General Public License --
-- along with We Noise Maker. If not, see <http://www.gnu.org/licenses/>. --
-- --
-------------------------------------------------------------------------------
with Giza.Widget;
with Giza.Context;
with Giza.Types; use Giza.Types;
with HAL.Real_Time_Clock; use HAL.Real_Time_Clock;
package Date_Widget is
function Next (Day_Of_Week : RTC_Day_Of_Week) return RTC_Day_Of_Week;
function Prev (Day_Of_Week : RTC_Day_Of_Week) return RTC_Day_Of_Week;
function Next (Month : RTC_Month) return RTC_Month;
function Prev (Month : RTC_Month) return RTC_Month;
function Next (Day : RTC_Day) return RTC_Day;
function Prev (Day : RTC_Day) return RTC_Day;
function Next (Year : RTC_Year) return RTC_Year;
function Prev (Year : RTC_Year) return RTC_Year;
subtype Parent is Giza.Widget.Instance;
type Instance (Show_Day_Of_Week : Boolean) is new Parent with private;
subtype Class is Instance'Class;
type Ref is access all Class;
overriding
procedure Draw (This : in out Instance;
Ctx : in out Giza.Context.Class;
Force : Boolean := True);
procedure Set_Date (This : in out Instance;
Date : HAL.Real_Time_Clock.RTC_Date);
function Get_Date (This : Instance)
return HAL.Real_Time_Clock.RTC_Date;
function Required_Size (This : Instance) return Size_T;
private
type Instance (Show_Day_Of_Week : Boolean) is new Parent with record
Date : HAL.Real_Time_Clock.RTC_Date;
end record;
end Date_Widget;
|
dma/hdma_start_3/main.asm | AntonioND/gbc-hw-tests | 6 | 171198 |
INCLUDE "hardware.inc"
INCLUDE "header.inc"
SECTION "var",BSS
ram_ptr: DS 2
SECTION "Main",HOME
;--------------------------------------------------------------------------
;- Main() -
;--------------------------------------------------------------------------
Main:
; -----------------
ld a,$0A
ld [$0000],a ; enable ram
ld hl,$A000
; -----------------
ld a,LCDCF_ON
ld [rLCDC],a
ld b,142
call wait_ly
DMA_COPY 0,$8000,20*16,1
ld b,150
call wait_ly
ld a,[rHDMA5]
ld [hl+],a
ld a,LCDCF_OFF
ld [rLCDC],a
ld a,[rHDMA5]
ld [hl+],a
ld a,LCDCF_ON
ld [rLCDC],a
ld a,[rHDMA5]
ld [hl+],a
.loop1:
ld a,[rHDMA5]
and a,$80
jr z,.loop1
ld a,[rLY]
ld [hl+],a
; -----------------
ld b,150
call wait_ly
ld a,LCDCF_OFF
ld [rLCDC],a
REPETITIONS SET 0
REPT 8
ld b,4
.testagain\@:
ld a,0
ld [rHDMA5],a
ld [rTIMA],a
ld [rTMA],a
ld [rDIV],a
ld a,TACF_STOP|TACF_262KHZ
ld [rTAC],a
ld a,TACF_START|TACF_262KHZ
ld [rTAC],a
xor a,a
ld [rDIV],a
ld [rTIMA],a
ld [rDIV],a
DMA_COPY 0,$8000,1*16,1
REPT REPETITIONS
nop
ENDR
ld a,[rTIMA]
ld [hl+],a
dec b
jr nz,.testagain\@
REPETITIONS SET REPETITIONS+1
ENDR
; -----------------
; continue ptrs GDMA
DMA_COPY 0,$8000,1*16,0
ld a,0
ld [rHDMA5],a ; continue copy
push hl
ld hl,$0000
ld de,$8000
ld b,32
ld c,0
.memcmp:
ld a,[de]
inc de
sub a,[hl]
inc hl
or a,c
ld c,a
dec b
jr nz,.memcmp
ld a,c
pop hl
ld [hl+],a
; -----------------
; continue ptrs HDMA
ld a,LCDCF_ON
ld [rLCDC],a
ld b,2
call wait_ly
DMA_COPY 0,$8000,1*16,1
ld b,5
call wait_ly
ld a,$80
ld [rHDMA5],a ; continue copy
.loop2:
ld a,[rHDMA5]
and a,$80
jr z,.loop2
ld a,[rLY]
ld [hl+],a
ld b,150
call wait_ly
ld a,LCDCF_OFF
ld [rLCDC],a
push hl
ld hl,$0000
ld de,$8000
ld b,32
ld c,0
.memcmp1:
ld a,[de]
inc de
sub a,[hl]
inc hl
or a,c
ld c,a
dec b
jr nz,.memcmp1
ld a,c
pop hl
ld [hl+],a
; -----------------
; continue ptrs HDMA after stop (no wait HBL)
ld a,LCDCF_ON
ld [rLCDC],a
ld b,2
call wait_ly
DMA_COPY 0,$8000,3*16,1
ld b,3
call wait_ly
ld a,0
ld [rHDMA5],a ; stop copy
ld a,[rHDMA5]
ld [hl+],a
ld a,$80
ld [rHDMA5],a ; continue copy
.loop4:
ld a,[rHDMA5]
and a,$80
jr z,.loop4
ld a,[rLY]
ld [hl+],a
ld b,150
call wait_ly
ld a,LCDCF_OFF
ld [rLCDC],a
push hl
ld hl,$0000
ld de,$8000
ld b,32
ld c,0
.memcmp2:
ld a,[de]
inc de
sub a,[hl]
inc hl
or a,c
ld c,a
dec b
jr nz,.memcmp2
ld a,c
pop hl
ld [hl+],a
; -----------------
; continue ptrs HDMA after stop (wait HBL)
ld a,LCDCF_ON
ld [rLCDC],a
ld b,2
call wait_ly
DMA_COPY 0,$8000,3*16,1
ld b,3
call wait_ly
ld a,0
ld [rHDMA5],a ; stop copy
ld b,4
call wait_ly
ld a,$80
ld [rHDMA5],a ; continue copy
.loop5:
ld a,[rHDMA5]
and a,$80
jr z,.loop5
ld a,[rLY]
ld [hl+],a
ld b,150
call wait_ly
ld a,LCDCF_OFF
ld [rLCDC],a
push hl
ld hl,$0000
ld de,$8000
ld b,32
ld c,0
.memcmp3:
ld a,[de]
inc de
sub a,[hl]
inc hl
or a,c
ld c,a
dec b
jr nz,.memcmp3
ld a,c
pop hl
ld [hl+],a
; -----------------
push hl
ld [hl],$12
inc hl
ld [hl],$34
inc hl
ld [hl],$56
inc hl
ld [hl],$78
pop hl
ld a,$00
ld [$0000],a ; disable ram
; -----------------
.end:
halt
jr .end
|
Transynther/x86/_processed/AVXALIGN/_st_zr_un_/i3-7100_9_0x84_notsx.log_21829_3102.asm | ljhsiun2/medusa | 9 | 178291 | <reponame>ljhsiun2/medusa
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r12
push %r13
push %rbp
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_D_ht+0x1290, %rbx
nop
nop
inc %r10
movb $0x61, (%rbx)
nop
nop
nop
nop
and %r10, %r10
lea addresses_normal_ht+0x1895, %r12
nop
dec %rsi
vmovups (%r12), %ymm6
vextracti128 $0, %ymm6, %xmm6
vpextrq $1, %xmm6, %r10
nop
nop
nop
xor %rsi, %rsi
lea addresses_WC_ht+0xf115, %r13
cmp %rbx, %rbx
mov (%r13), %r10d
nop
nop
nop
cmp $28049, %r10
lea addresses_A_ht+0x5095, %r13
nop
nop
and $6032, %r11
mov (%r13), %r12d
add $53024, %rsi
lea addresses_WT_ht+0xe3c5, %r12
xor $27863, %r11
movups (%r12), %xmm3
vpextrq $1, %xmm3, %rbp
sub $51998, %r11
lea addresses_UC_ht+0x18495, %r13
cmp %rbx, %rbx
movb (%r13), %r10b
nop
nop
nop
nop
nop
sub %r13, %r13
lea addresses_WT_ht+0x11b95, %rsi
lea addresses_D_ht+0x9e95, %rdi
sub %r10, %r10
mov $19, %rcx
rep movsb
and %rsi, %rsi
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %r13
pop %r12
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r12
push %r13
push %r15
push %r9
push %rcx
push %rdi
push %rsi
// Store
lea addresses_PSE+0xa95, %rdi
nop
xor %r11, %r11
mov $0x5152535455565758, %r12
movq %r12, %xmm0
vmovups %ymm0, (%rdi)
nop
nop
nop
add %r15, %r15
// REPMOV
lea addresses_WT+0x12a95, %rsi
lea addresses_WC+0x18e55, %rdi
nop
nop
nop
nop
nop
xor %r9, %r9
mov $98, %rcx
rep movsb
cmp $54207, %r12
// Store
mov $0x835, %r12
nop
nop
nop
sub %r15, %r15
movb $0x51, (%r12)
nop
xor $26952, %r12
// Store
lea addresses_D+0x19295, %r11
nop
nop
nop
nop
and %r9, %r9
mov $0x5152535455565758, %r12
movq %r12, (%r11)
and %rdi, %rdi
// Store
lea addresses_RW+0x37d5, %r11
nop
nop
nop
nop
nop
inc %r9
movb $0x51, (%r11)
nop
nop
nop
nop
nop
dec %r15
// Load
lea addresses_US+0x3295, %r12
nop
nop
nop
add $22088, %rdi
mov (%r12), %r15
nop
nop
nop
nop
add $12764, %rsi
// Store
lea addresses_D+0x19295, %r9
nop
xor %r12, %r12
movw $0x5152, (%r9)
nop
nop
nop
nop
sub %rsi, %rsi
// Store
lea addresses_RW+0x157d, %r11
clflush (%r11)
nop
xor $55354, %r15
movb $0x51, (%r11)
nop
sub %r13, %r13
// Store
lea addresses_PSE+0x1495, %rcx
nop
nop
nop
nop
dec %r9
movw $0x5152, (%rcx)
xor $54433, %r12
// Faulty Load
lea addresses_D+0x19295, %rcx
nop
dec %r15
vmovntdqa (%rcx), %ymm3
vextracti128 $1, %ymm3, %xmm3
vpextrq $1, %xmm3, %r11
lea oracles, %rdi
and $0xff, %r11
shlq $12, %r11
mov (%rdi,%r11,1), %r11
pop %rsi
pop %rdi
pop %rcx
pop %r9
pop %r15
pop %r13
pop %r12
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_D', 'same': False, 'size': 1, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_PSE', 'same': False, 'size': 32, 'congruent': 11, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_WT', 'congruent': 10, 'same': False}, 'dst': {'type': 'addresses_WC', 'congruent': 5, 'same': False}, 'OP': 'REPM'}
{'dst': {'type': 'addresses_P', 'same': False, 'size': 1, 'congruent': 5, 'NT': True, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_D', 'same': True, 'size': 8, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_RW', 'same': False, 'size': 1, 'congruent': 1, 'NT': True, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_US', 'same': False, 'size': 8, 'congruent': 9, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_D', 'same': True, 'size': 2, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_RW', 'same': False, 'size': 1, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_PSE', 'same': False, 'size': 2, 'congruent': 9, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
[Faulty Load]
{'src': {'type': 'addresses_D', 'same': True, 'size': 32, 'congruent': 0, 'NT': True, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'dst': {'type': 'addresses_D_ht', 'same': False, 'size': 1, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_normal_ht', 'same': False, 'size': 32, 'congruent': 9, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WC_ht', 'same': False, 'size': 4, 'congruent': 5, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_A_ht', 'same': False, 'size': 4, 'congruent': 9, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WT_ht', 'same': False, 'size': 16, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_UC_ht', 'same': False, 'size': 1, 'congruent': 9, 'NT': True, 'AVXalign': True}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WT_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM'}
{'f8': 7, 'ff': 3, '39': 1, '7d': 1, 'f9': 2, '00': 21811, 'f7': 1, '04': 1, '06': 1, '08': 1}
04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
src/siphash-entropy.ads | jhumphry/SPARK_SipHash | 5 | 621 | <reponame>jhumphry/SPARK_SipHash<filename>src/siphash-entropy.ads
-- SipHash.Entropy
-- A child package that attempts to set the key from an entropy source on the
-- system. There are various different implementations of this that are selected
-- at compile-time.
-- Copyright (c) 2015, <NAME> - see LICENSE file for details
generic
package SipHash.Entropy
with SPARK_Mode => On
is
Entropy_Unavailable : exception;
-- This function indicates whether the program has been compiled with the
-- possibility to set the SipHash key from system entropy. Note that even
-- if this returns true it is still possible for Set_Key_From_System_Entropy
-- to fail, for example if there is an IO error or the system declines to
-- provide enough entropy.
function System_Entropy_Source return Boolean;
-- This procedure will set the SipHash key from a system entropy source,
-- unless System_Entropy_Source is False or the system returns insufficient
-- data, in which case it will raise No_Entropy_Available.
procedure Set_Key_From_System_Entropy
with Global => (Output => Initial_Hash_State);
-- This procedure will set the SipHash key from a system entropy source,
-- returning a boolean to indicate if it was successful. Failure can be
-- caused by having no entropy source compiled into the library, or by an
-- inability to retrieve sufficient data from the system.
-- It would be nice to make this a function, but functions with side effects
-- are not permitted by SPARK.
procedure Set_Key_From_System_Entropy (Success : out Boolean)
with Global => (Output => Initial_Hash_State);
end SipHash.Entropy;
|
asm/lab5proc.asm | metlinskyi/archive | 0 | 89900 |
DATASG SEGMENT PARA 'Data'
mas1 db 6,5,4,3,2,1,0,6
mas2 db 1,3,2,2,1,8,7,3
mas3 db 8 dup (?)
DATASG ENDS
CODESG SEGMENT PARA 'Code'
ASSUME CS:CODESG, DS:DATASG
BEGIN:
first PROC FAR
mov ax,DATASG
mov ds,ax
;xor ax,ax
call second
mov si,0
mov ah,02h
mov cx,8
m1: mov dl,mas3[si]
add dl,30h
int 21h
inc si
loop m1
MOV AH, 04CH
INT 21H
ret
first ENDP
second PROC NEAR
mov si,0
mov cx,8
m3: mov ah,mas1[si]
cmp ah,mas2[si]
jbe m0
cmp mas1[si],2
jb m0
cmp mas1[si],5
ja m0
mov mas3[si],ah
jmp m2
m0: mov mas3[si],0
m2: inc si
loop m3
RET
second ENDP
CODESG ENDS
END BEGIN
|
bb-runtimes/arm/zynqmpr5/s-mpuini.adb | JCGobbi/Nucleo-STM32G474RE | 0 | 28494 | <filename>bb-runtimes/arm/zynqmpr5/s-mpuini.adb
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- Copyright (C) 2016-2021, AdaCore --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Ada.Unchecked_Conversion;
with Interfaces; use Interfaces;
with Interfaces.ARM_V7AR; use Interfaces.ARM_V7AR;
with System; use System;
with System.MPU_Definitions; use System.MPU_Definitions;
with System.Board_Parameters; use System.Board_Parameters;
package body System.MPU_Init is
--------------
-- MPU_Init --
--------------
procedure MPU_Init
is
SCTLR : Unsigned_32;
MPUIR : Unsigned_32;
Num_Rgn : Unsigned_32;
begin
-- Get the number of MPU regions
MPUIR := CP15.Get_MPUIR;
Num_Rgn := Shift_Right (MPUIR and 16#FF00#, 8);
-- Configure memory regions.
for Index in MPU_Config'Range loop
declare
C : MPU_Region_Configuration renames MPU_Config (Index);
begin
CP15.Set_MPU_Region_Number (Index);
CP15.Set_MPU_Region_Base_Address (C.Base_Address);
CP15.Set_MPU_Region_Size_And_Enable (As_W32 (C.Size_And_Enable));
CP15.Set_MPU_Region_Access_Control (As_W32 (C.Access_Control));
end;
end loop;
-- Disable the unused regions
for Index in MPU_Config'Last + 1 .. Num_Rgn loop
CP15.Set_MPU_Region_Number (Index);
CP15.Set_MPU_Region_Base_Address (16#0000_0000#);
CP15.Set_MPU_Region_Size_And_Enable (0);
CP15.Set_MPU_Region_Access_Control (0);
end loop;
-- Enable MPU with background region activated (respectively bits 0 and
-- 17 of SCTLR)
SCTLR := CP15.Get_SCTLR;
SCTLR := SCTLR or 1 or (2 ** 17);
Barriers.DSB;
CP15.Set_SCTLR (SCTLR);
Barriers.ISB;
end MPU_Init;
end System.MPU_Init;
|
agda/calculus-examples.agda | florence/esterel-calculus | 3 | 11330 | <filename>agda/calculus-examples.agda
module calculus-examples where
open import Data.List using (List ; _∷_ ; [] ; _++_)
open import Data.List.Any using (here ; there ; any)
open import Data.List.Any.Properties
open import Data.OrderedListMap
open import Data.Sum using (inj₁ ; inj₂ ; _⊎_)
open import Data.Maybe.Base
open import Data.Empty using (⊥ ; ⊥-elim)
open import Data.Bool.Base using (true ; false)
open import Relation.Nullary using (Dec ; yes ; no ; ¬_)
open import Agda.Builtin.Equality using (refl ; _≡_)
open import Relation.Nullary.Decidable
using (⌊_⌋)
open import Relation.Binary.PropositionalEquality
using (subst ; cong ; sym ; trans)
open import calculus
open import utility
open import Esterel.Environment as Env
open import Esterel.Variable.Signal as Signal
using (Signal ; _ₛ ; unknown ; present ; absent ; _≟ₛₜ_)
open import Esterel.Variable.Shared as SharedVar using (SharedVar)
open import Esterel.Variable.Sequential as SeqVar using (SeqVar)
open import Esterel.Lang
open import Esterel.Lang.CanFunction
open import Esterel.Lang.CanFunction.Properties
open import Esterel.Lang.CanFunction.SetSigMonotonic using (canₛ-set-sig-monotonic)
open import Esterel.Lang.Properties
open import Esterel.Lang.Binding
open import Esterel.Context
open import Esterel.CompletionCode as Code
using () renaming (CompletionCode to Code)
open import context-properties
open import Esterel.Lang.CanFunction.Base using (canₛ-⊆-FV)
open import Data.Nat as Nat
using (ℕ ; zero ; suc ; _+_) renaming (_⊔_ to _⊔ℕ_)
open import Data.Nat.Properties.Simple
using (+-comm)
open import Data.Product
using (Σ-syntax ; Σ ; _,_ ; _,′_ ; proj₁ ; proj₂ ; _×_)
open import eval
{-
This example is not true (and not provable under the current calculus)
{- rewriting a present to the true branch -}
{- cannot prove without the `signal` form -}
ex1 : ∀ S p q -> CB p ->
signl S (emit S >> (present S ∣⇒ p ∣⇒ q)) ≡ₑ
signl S (emit S >> p) # []
ex1 S p q CBp = calc where
θS→unk : Env
θS→unk = Θ SigMap.[ S ↦ Signal.unknown ] [] []
S∈θS→unk : SigMap.∈Dom S (sig θS→unk)
S∈θS→unk = sig-∈-single S Signal.unknown
θS→unk[S]≡unk : sig-stats{S = S} θS→unk S∈θS→unk ≡ Signal.unknown
θS→unk[S]≡unk = sig-stats-1map' S Signal.unknown S∈θS→unk
θS→pre : Env
θS→pre = set-sig{S} θS→unk S∈θS→unk Signal.present
S∈θS→pre : SigMap.∈Dom S (sig θS→pre)
S∈θS→pre = sig-set-mono' {S} {S} {θS→unk} {Signal.present} {S∈θS→unk} S∈θS→unk
θS→pre[S]≡pre : sig-stats{S = S} θS→pre S∈θS→pre ≡ Signal.present
θS→pre[S]≡pre = sig-putget{S} {θS→unk} {Signal.present} S∈θS→unk S∈θS→pre
θS→unk[S]≠absent : ¬ sig-stats{S = S} θS→unk S∈θS→unk ≡ Signal.absent
θS→unk[S]≠absent is rewrite θS→unk[S]≡unk = unknotabs is where
unknotabs : Signal.unknown ≡ Signal.absent → ⊥
unknotabs ()
CBsignalS[emitS>>p] : CB (signl S (emit S >> p))
CBsignalS[emitS>>p]
= CBsig (CBseq (CBemit{S}) CBp ((λ z → λ ()) , (λ z → λ ()) , (λ z → λ ())))
calc : signl S (emit S >> (present S ∣⇒ p ∣⇒ q)) ≡ₑ
signl S (emit S >> p) # []
calc =
≡ₑtran {r = (ρ θS→unk · (emit S >> (present S ∣⇒ p ∣⇒ q)))}
(≡ₑstep [raise-signal])
(≡ₑtran {r = (ρ θS→pre · (nothin >> (present S ∣⇒ p ∣⇒ q)))}
(≡ₑstep ([emit] S∈θS→unk θS→unk[S]≠absent (deseq dehole)))
(≡ₑtran {r = (ρ θS→pre · (present S ∣⇒ p ∣⇒ q))}
(≡ₑctxt (dcenv dchole) (dcenv dchole) (≡ₑstep [seq-done]))
(≡ₑtran {r = (ρ θS→pre · p)}
(≡ₑstep ([is-present] S S∈θS→pre θS→pre[S]≡pre dehole))
(≡ₑsymm CBsignalS[emitS>>p]
(≡ₑtran {r = (ρ θS→unk · (emit S >> p))}
(≡ₑstep [raise-signal])
(≡ₑtran {r = (ρ θS→pre · (nothin >> p))}
(≡ₑstep ([emit] S∈θS→unk θS→unk[S]≠absent (deseq dehole)))
(≡ₑtran {r = ρ θS→pre · p}
(≡ₑctxt (dcenv dchole) (dcenv dchole) (≡ₑstep [seq-done]))
≡ₑrefl)))))))
-}
Canₛpresent-fact : ∀ S p q ->
(Signal.unwrap S) ∈ Canₛ (present S ∣⇒ p ∣⇒ q) (Θ SigMap.[ S ↦ Signal.unknown ] [] []) ->
(Signal.unwrap S ∈ Canₛ p (Θ SigMap.[ S ↦ Signal.unknown ] [] [])) ⊎
(Signal.unwrap S ∈ Canₛ q (Θ SigMap.[ S ↦ Signal.unknown ] [] []))
Canₛpresent-fact S p q S∈Canₛ[presentSpq]
with Env.Sig∈ S (Θ SigMap.[ S ↦ Signal.unknown ] [] [])
Canₛpresent-fact S p q S∈Canₛ[presentSpq] | yes S∈
with ⌊ present ≟ₛₜ (Env.sig-stats{S} (Θ SigMap.[ S ↦ Signal.unknown ] [] []) S∈) ⌋
Canₛpresent-fact S p q S∈Canₛ[presentSpq] | yes S∈ | true
= inj₁ S∈Canₛ[presentSpq]
Canₛpresent-fact S p q S∈Canₛ[presentSpq] | yes S∈ | false
with ⌊ absent ≟ₛₜ Env.sig-stats{S} (Θ SigMap.[ S ↦ Signal.unknown ] [] []) S∈ ⌋
Canₛpresent-fact S p q S∈Canₛ[presentSpq] | yes S∈ | false | true
= inj₂ S∈Canₛ[presentSpq]
Canₛpresent-fact S p q S∈Canₛ[presentSpq] | yes S∈ | false | false
= ++⁻ (Canₛ p (Θ SigMap.[ S ↦ Signal.unknown ] [] [])) S∈Canₛ[presentSpq]
Canₛpresent-fact S p q _ | no ¬p
= ⊥-elim (¬p (SigMap.update-in-keys [] S unknown))
{- rewriting a present to the false branch -}
ex2b : ∀ S p q C -> CB (C ⟦ signl S q ⟧c) ->
Signal.unwrap S ∉ (Canₛ p (Θ SigMap.[ S ↦ unknown ] [] [])) ->
Signal.unwrap S ∉ (Canₛ q (Θ SigMap.[ S ↦ unknown ] [] [])) ->
signl S (present S ∣⇒ p ∣⇒ q) ≡ₑ
signl S q # C
ex2b S p q C CBq s∉Canₛp s∉Canₛq = calc where
θS→unk : Env
θS→unk = Θ SigMap.[ S ↦ Signal.unknown ] [] []
S∈θS→unk : SigMap.∈Dom S (sig θS→unk)
S∈θS→unk = sig-∈-single S Signal.unknown
θS→unk[S]≡unk : sig-stats{S = S} θS→unk S∈θS→unk ≡ Signal.unknown
θS→unk[S]≡unk = sig-stats-1map' S Signal.unknown S∈θS→unk
θS→abs : Env
θS→abs = set-sig{S} θS→unk S∈θS→unk Signal.absent
S∈θS→abs : SigMap.∈Dom S (sig θS→abs)
S∈θS→abs = sig-set-mono' {S} {S} {θS→unk} {Signal.absent} {S∈θS→unk} S∈θS→unk
θS→abs[S]≡abs : sig-stats{S = S} θS→abs S∈θS→abs ≡ Signal.absent
θS→abs[S]≡abs = sig-putget{S} {θS→unk} {Signal.absent} S∈θS→unk S∈θS→abs
S∉Canθₛq : Signal.unwrap S ∉ Canθₛ SigMap.[ S ↦ unknown ] 0 q []env
S∉Canθₛq S∈Canθₛq = s∉Canₛq (Canθₛunknown->Canₛunknown S q S∈Canθₛq)
S∉CanθₛpresentSpq : Signal.unwrap S ∉ Canθₛ SigMap.[ S ↦ unknown ]
0
(present S ∣⇒ p ∣⇒ q)
[]env
S∉CanθₛpresentSpq S∈Canθₛ
with Canθₛunknown->Canₛunknown S (present S ∣⇒ p ∣⇒ q) S∈Canθₛ
... | fact
with Canₛpresent-fact S p q fact
... | inj₁ s∈Canₛp = s∉Canₛp s∈Canₛp
... | inj₂ s∈Canₛq = s∉Canₛq s∈Canₛq
bwd : signl S q ≡ₑ (ρ⟨ θS→abs , WAIT ⟩· q) # C
bwd =
≡ₑtran (≡ₑstep [raise-signal])
(≡ₑtran (≡ₑstep ([absence] S S∈θS→unk θS→unk[S]≡unk S∉Canθₛq))
≡ₑrefl)
fwd : signl S (present S ∣⇒ p ∣⇒ q) ≡ₑ
(ρ⟨ θS→abs , WAIT ⟩· q) # C
fwd =
≡ₑtran (≡ₑstep [raise-signal])
(≡ₑtran (≡ₑstep ([absence] S S∈θS→unk θS→unk[S]≡unk S∉CanθₛpresentSpq))
(≡ₑtran (≡ₑstep ([is-absent] S S∈θS→abs θS→abs[S]≡abs dehole))
≡ₑrefl)) where
calc : signl S (present S ∣⇒ p ∣⇒ q) ≡ₑ
signl S q # C
calc = ≡ₑtran fwd (≡ₑsymm CBq bwd)
ex2 : ∀ S p q C ->
CB (C ⟦ signl S q ⟧c) ->
(∀ status -> Signal.unwrap S ∉ (Canₛ p (Θ SigMap.[ S ↦ status ] [] []))) ->
(∀ status -> Signal.unwrap S ∉ (Canₛ q (Θ SigMap.[ S ↦ status ] [] []))) ->
signl S (present S ∣⇒ p ∣⇒ q) ≡ₑ
signl S q # C
ex2 S p q C CB noSp noSq = ex2b S p q C CB (noSp unknown) (noSq unknown)
{-
Although true, the this example is not provable under the current calculus
{- lifting an emit out of a par -}
ex3 : ∀ S p q -> CB (p ∥ q) ->
signl S ((emit S >> p) ∥ q) ≡ₑ
signl S (emit S >> (p ∥ q)) # []
ex3 S p q CBp∥q = calc where
θS→unk : Env
θS→unk = Θ SigMap.[ S ↦ Signal.unknown ] [] []
S∈θS→unk : SigMap.∈Dom S (sig θS→unk)
S∈θS→unk = sig-∈-single S Signal.unknown
θS→unk[S]≡unk : sig-stats{S = S} θS→unk S∈θS→unk ≡ Signal.unknown
θS→unk[S]≡unk = sig-stats-1map' S Signal.unknown S∈θS→unk
θS→pre : Env
θS→pre = set-sig{S} θS→unk S∈θS→unk Signal.present
θS→unk[S]≠absent : ¬ sig-stats{S = S} θS→unk S∈θS→unk ≡ Signal.absent
θS→unk[S]≠absent is rewrite θS→unk[S]≡unk = unknotabs is where
unknotabs : Signal.unknown ≡ Signal.absent → ⊥
unknotabs ()
calc : signl S ((emit S >> p) ∥ q) ≡ₑ
signl S (emit S >> (p ∥ q)) # []
calc =
≡ₑtran {r = ρ⟨ θS→unk · ((emit S >> p) ∥ q)}
(≡ₑstep [raise-signal])
(≡ₑtran {r = ρ θS→pre · (nothin >> p ∥ q)}
(≡ₑstep ([emit]{S = S} S∈θS→unk θS→unk[S]≠absent (depar₁ (deseq dehole))))
(≡ₑtran {r = ρ θS→pre · (p ∥ q)}
(≡ₑctxt (dcenv (dcpar₁ dchole))
(dcenv (dcpar₁ dchole))
(≡ₑstep [seq-done]))
(≡ₑsymm (CBsig (CBseq CBemit CBp∥q
(((λ z → λ ()) ,
(λ z → λ ()) ,
(λ z → λ ())))))
(≡ₑtran {r = ρ θS→unk · (emit S >> (p ∥ q))}
(≡ₑstep [raise-signal])
(≡ₑtran (≡ₑstep ([emit] S∈θS→unk θS→unk[S]≠absent (deseq dehole)))
(≡ₑctxt (dcenv dchole) (dcenv dchole) (≡ₑstep [seq-done])))))))
-}
{- pushing a trap across a par -}
ex4 : ∀ n p q -> CB p ->
done q -> p ≡ₑ q # [] ->
(trap (exit (suc n) ∥ p)) ≡ₑ (exit n ∥ trap p) # []
ex4 = ex4-split where
basealwaysdistinct : ∀ x -> distinct base x
basealwaysdistinct x = (λ { z () x₂ }) , (λ { z () x₂ }) , (λ { z () x₂})
CBplugrpartrap : ∀ n -> ∀ {r r′ BVp FVp} ->
CorrectBinding r BVp FVp →
r′ ≐ ceval (epar₂ (exit n)) ∷ ceval etrap ∷ [] ⟦ r ⟧c →
CB r′
CBplugrpartrap n {p} {p′} {BVp} {FVp} CBp r′dc
with BVFVcorrect p BVp FVp CBp | unplugc r′dc
... | refl , refl | refl = CBpar CBexit (CBtrap CBp)
(basealwaysdistinct BVp)
(basealwaysdistinct (BVars p))
(basealwaysdistinct (FVars p))
(λ { _ () _ })
CBplugtraprpar : ∀ n -> {r r′ : Term}
{BVp FVp : Σ (List ℕ) (λ x → List ℕ × List ℕ)} →
CorrectBinding r BVp FVp →
r′ ≐ ceval etrap ∷ ceval (epar₂ (exit (suc n))) ∷ [] ⟦ r ⟧c →
CB r′
CBplugtraprpar n {r} {r′} {BVp} {FVp} CBr r′C
with unplugc r′C
... | refl
with BVFVcorrect r BVp FVp CBr
... | refl , refl
= CBtrap (CBpar CBexit CBr
(basealwaysdistinct BVp)
(basealwaysdistinct (BVars r))
(basealwaysdistinct (FVars r))
(λ { _ () _}))
ex4-split : ∀ n p q -> CB p ->
done q -> p ≡ₑ q # [] ->
(trap (exit (suc n) ∥ p)) ≡ₑ (exit n ∥ trap p) # []
ex4-split n p .nothin CBp (dhalted hnothin) p≡ₑnothin =
≡ₑtran {r = trap (exit (suc n) ∥ nothin)}
(≡ₑctxt (dctrap (dcpar₂ dchole))
(dctrap (dcpar₂ dchole))
(≡ₑ-context [] _ (CBplugtraprpar n) p≡ₑnothin))
(≡ₑtran {r = trap (exit (suc n))}
(≡ₑctxt (dctrap dchole)
(dctrap dchole)
(≡ₑtran (≡ₑstep [par-swap])
(≡ₑstep ([par-nothing] (dhalted (hexit (suc n)))))))
(≡ₑtran {r = exit n}
(≡ₑstep ([trap-done] (hexit (suc n))))
(≡ₑsymm (CBpar CBexit (CBtrap CBp)
(basealwaysdistinct (BVars p))
(basealwaysdistinct (BVars p))
(basealwaysdistinct (FVars p))
(λ { _ () _ }))
(≡ₑtran {r = exit n ∥ trap nothin}
(≡ₑctxt (dcpar₂ (dctrap dchole))
(dcpar₂ (dctrap dchole))
(≡ₑ-context [] _ (CBplugrpartrap n) p≡ₑnothin))
(≡ₑtran {r = exit n ∥ nothin}
(≡ₑctxt (dcpar₂ dchole) (dcpar₂ dchole) (≡ₑstep ([trap-done] hnothin)))
(≡ₑtran {r = nothin ∥ exit n}
(≡ₑstep [par-swap])
(≡ₑtran {r = exit n}
(≡ₑstep ([par-nothing] (dhalted (hexit n))))
≡ₑrefl)))))))
ex4-split n p .(exit 0) CBp (dhalted (hexit 0)) p≡ₑexit0 =
≡ₑtran {r = trap (exit (suc n) ∥ exit 0) }
(≡ₑctxt (dctrap (dcpar₂ dchole))
(dctrap (dcpar₂ dchole))
(≡ₑ-context [] _ (CBplugtraprpar n) p≡ₑexit0))
(≡ₑtran {r = trap (exit (suc n))}
(≡ₑctxt (dctrap dchole) (dctrap dchole)
(≡ₑstep ([par-2exit] (suc n) zero)))
(≡ₑtran {r = exit n}
(≡ₑstep ([trap-done] (hexit (suc n))))
(≡ₑsymm (CBpar CBexit (CBtrap CBp)
(basealwaysdistinct (BVars p))
(basealwaysdistinct (BVars p))
(basealwaysdistinct (FVars p))
(λ { _ () _ }))
(≡ₑtran {r = exit n ∥ trap (exit 0)}
(≡ₑctxt (dcpar₂ (dctrap dchole))
(dcpar₂ (dctrap dchole))
(≡ₑ-context [] _ (CBplugrpartrap n) p≡ₑexit0))
(≡ₑtran {r = exit n ∥ nothin }
(≡ₑctxt (dcpar₂ dchole) (dcpar₂ dchole)
(≡ₑstep ([trap-done] (hexit zero))))
(≡ₑtran {r = nothin ∥ exit n}
(≡ₑstep [par-swap])
(≡ₑtran {r = exit n}
(≡ₑstep ([par-nothing] (dhalted (hexit n))))
≡ₑrefl)))))))
ex4-split n p .(exit (suc m)) CBp (dhalted (hexit (suc m))) p≡ₑexitm =
≡ₑtran {r = trap (exit (suc n) ∥ exit (suc m)) }
(≡ₑctxt (dctrap (dcpar₂ dchole))
(dctrap (dcpar₂ dchole))
(≡ₑ-context [] _ (CBplugtraprpar n) p≡ₑexitm))
(≡ₑtran {r = trap (exit (suc n ⊔ℕ (suc m)))}
(≡ₑctxt (dctrap dchole) (dctrap dchole)
(≡ₑstep ([par-2exit] (suc n) (suc m))))
(≡ₑtran {r = ↓_ {p = (exit (suc n ⊔ℕ (suc m)))} (hexit (suc n ⊔ℕ (suc m))) }
(≡ₑstep ([trap-done] (hexit (suc (n ⊔ℕ m)))))
(≡ₑsymm (CBpar CBexit (CBtrap CBp)
(basealwaysdistinct (BVars p))
(basealwaysdistinct (BVars p))
(basealwaysdistinct (FVars p))
(λ { _ () _ }))
(≡ₑtran {r = exit n ∥ trap (exit (suc m))}
(≡ₑctxt (dcpar₂ (dctrap dchole))
(dcpar₂ (dctrap dchole))
(≡ₑ-context [] _ (CBplugrpartrap n) p≡ₑexitm))
(≡ₑtran {r = exit n ∥ ↓_ {p = exit (suc m)} (hexit (suc m))}
(≡ₑctxt (dcpar₂ dchole) (dcpar₂ dchole)
(≡ₑstep ([trap-done] (hexit (suc m)))) )
(≡ₑtran {r = ↓_ {p = (exit (suc n ⊔ℕ (suc m)))} (hexit (suc n ⊔ℕ (suc m))) }
(≡ₑstep ([par-2exit] n m))
≡ₑrefl))))))
ex4-split n p q CBp (dpaused pausedq) p≡ₑq =
≡ₑtran {r = trap (exit (suc n) ∥ q)}
(≡ₑctxt (dctrap (dcpar₂ dchole))
(dctrap (dcpar₂ dchole))
(≡ₑ-context [] _ (CBplugtraprpar n) p≡ₑq))
(≡ₑtran {r = trap (exit (suc n))}
(≡ₑctxt (dctrap dchole) (dctrap dchole)
(≡ₑstep ([par-1exit] (suc n) pausedq)))
(≡ₑtran {r = exit n}
(≡ₑstep ([trap-done] (hexit (suc n))))
(≡ₑsymm (CBpar CBexit (CBtrap CBp)
(basealwaysdistinct (BVars p))
(basealwaysdistinct (BVars p))
(basealwaysdistinct (FVars p))
(λ { _ () _ }))
(≡ₑtran {r = exit n ∥ trap q}
(≡ₑctxt (dcpar₂ (dctrap dchole))
(dcpar₂ (dctrap dchole))
(≡ₑ-context [] _ (CBplugrpartrap n) p≡ₑq))
(≡ₑtran {r = exit n}
(≡ₑstep ([par-1exit] n (ptrap pausedq)))
≡ₑrefl)))))
{- lifting a signal out of an evaluation context -}
ex5 : ∀ S p q r E -> CB r ->
q ≐ E ⟦(signl S p)⟧e ->
r ≐ E ⟦ p ⟧e ->
(ρ⟨ []env , WAIT ⟩· q) ≡ₑ (ρ⟨ []env , WAIT ⟩· (signl S r)) # []
ex5 S p q r E CBr decomp1 decomp2 = calc where
θS→unk : Env
θS→unk = Θ SigMap.[ S ↦ Signal.unknown ] [] []
replugit : q ≐ Data.List.map ceval E ⟦ signl S p ⟧c ->
E ⟦ ρ⟨ θS→unk , WAIT ⟩· p ⟧e ≐ Data.List.map ceval E ⟦ ρ⟨ θS→unk , WAIT ⟩· p ⟧c
replugit x = ⟦⟧e-to-⟦⟧c Erefl
calc : (ρ⟨ []env , WAIT ⟩· q) ≡ₑ (ρ⟨ []env , WAIT ⟩· (signl S r)) # []
calc =
≡ₑtran {r = ρ⟨ []env , WAIT ⟩· (E ⟦ (ρ⟨ θS→unk , WAIT ⟩· p) ⟧e)}
(≡ₑctxt (dcenv (⟦⟧e-to-⟦⟧c decomp1))
(dcenv (replugit (⟦⟧e-to-⟦⟧c decomp1)))
(≡ₑstep [raise-signal]))
(≡ₑtran {r = ρ⟨ θS→unk , WAIT ⟩· (E ⟦ p ⟧e)}
(≡ₑstep ([merge]{E = E} Erefl))
(≡ₑsymm (CBρ (CBsig CBr))
(≡ₑtran {r = ρ⟨ []env , WAIT ⟩· (ρ⟨ θS→unk , WAIT ⟩· r)}
(≡ₑctxt (dcenv dchole) (dcenv dchole) (≡ₑstep [raise-signal]))
(≡ₑstep ([merge] {E = []}
(subst (\ x ->
ρ⟨ θS→unk , WAIT ⟩· x ≐ [] ⟦
ρ⟨ θS→unk , WAIT ⟩· E ⟦ p ⟧e ⟧e)
(unplug decomp2) dehole))))))
{- two specific examples of lifting a signal out of an evaluation context -}
ex6 : ∀ S p q -> CB (p ∥ q) ->
(ρ⟨ []env , WAIT ⟩· ((signl S p) ∥ q)) ≡ₑ (ρ⟨ []env , WAIT ⟩· (signl S (p ∥ q))) # []
ex6 S p q CBp∥q =
ex5 S p (signl S p ∥ q) (p ∥ q) ((epar₁ q) ∷ []) CBp∥q (depar₁ dehole) (depar₁ dehole)
ex7 : ∀ S p q -> CB (p >> q) ->
(ρ⟨ []env , WAIT ⟩· ((signl S p) >> q)) ≡ₑ (ρ⟨ []env , WAIT ⟩· (signl S (p >> q))) # []
ex7 S p q CBp>>q =
ex5 S p (signl S p >> q) (p >> q) ((eseq q) ∷ []) CBp>>q (deseq dehole) (deseq dehole)
{- pushing a seq into a binding form (a signal in this case).
this shows the need for the outer environment ρ [} · _
in order to manipulate the environment.
-}
ex8-worker : ∀ {BV FV} S p q ->
CorrectBinding ((signl S p) >> q) BV FV ->
(ρ⟨ []env , WAIT ⟩· (signl S p) >> q) ≡ₑ
(ρ⟨ []env , WAIT ⟩· signl S (p >> q)) # []
ex8-worker S p q (CBseq {BVp = BVsigS·p} {FVq = FVq} (CBsig {BV = BVp} CBp) CBq BVsigS·p≠FVq) =
≡ₑtran {r = ρ⟨ []env , WAIT ⟩· (ρ⟨ [S]-env S , WAIT ⟩· p) >> q} {C = []}
(≡ₑctxt {C = []} {C′ = cenv []env WAIT ∷ ceval (eseq q) ∷ []}
Crefl Crefl
(≡ₑstep ([raise-signal] {p} {S})))
(≡ₑtran {r = ρ⟨ [S]-env S , WAIT ⟩· p >> q} {C = []}
(≡ₑstep ([merge] (deseq dehole)))
(≡ₑsymm
(CBρ
(CBsig
(CBseq CBp CBq
(⊆-respect-distinct-left (∪ʳ (+S S base) ⊆-refl) BVsigS·p≠FVq))))
(≡ₑtran {r = ρ⟨ []env , WAIT ⟩· (ρ⟨ [S]-env S , WAIT ⟩· p >> q)} {C = []}
(≡ₑctxt {C = []} {C′ = cenv []env WAIT ∷ []}
Crefl Crefl
(≡ₑstep ([raise-signal] {p >> q} {S})))
(≡ₑstep ([merge] dehole)))))
ex8 : ∀ S p q ->
CB ((signl S p) >> q) ->
(ρ⟨ []env , WAIT ⟩· (signl S p) >> q) ≡ₑ
(ρ⟨ []env , WAIT ⟩· signl S (p >> q)) # []
ex8 S p q cb = ex8-worker S p q cb
{- rearranging signal forms -}
ex9 : ∀ S1 S2 p ->
CB p ->
signl S1 (signl S2 p) ≡ₑ signl S2 (signl S1 p) # []
ex9 S1 S2 p CBp =
≡ₑtran {r = ρ⟨ (Θ SigMap.[ S1 ↦ Signal.unknown ] [] []) , WAIT ⟩· (signl S2 p)}
(≡ₑstep [raise-signal])
(≡ₑtran {r = (ρ⟨ Θ SigMap.[ S1 ↦ Signal.unknown ] [] [] , WAIT ⟩·
(ρ⟨ Θ SigMap.[ S2 ↦ Signal.unknown ] [] [] , WAIT ⟩· p))}
(≡ₑctxt (dcenv dchole) (dcenv dchole) (≡ₑstep [raise-signal]))
(≡ₑtran {r = (ρ⟨ (Θ SigMap.[ S1 ↦ Signal.unknown ] [] []) ←
(Θ SigMap.[ S2 ↦ Signal.unknown ] [] []) , A-max WAIT WAIT ⟩·
p)}
(≡ₑstep ([merge] dehole))
(≡ₑsymm (CBsig (CBsig CBp))
(≡ₑtran {r = ρ⟨ (Θ SigMap.[ S2 ↦ Signal.unknown ] [] []) , WAIT ⟩· (signl S1 p)}
(≡ₑstep [raise-signal])
(≡ₑtran {r = (ρ⟨ Θ SigMap.[ S2 ↦ Signal.unknown ] [] [] , WAIT ⟩·
(ρ⟨ Θ SigMap.[ S1 ↦ Signal.unknown ] [] [] , WAIT ⟩· p))}
(≡ₑctxt (dcenv dchole) (dcenv dchole) (≡ₑstep [raise-signal]))
(≡ₑtran {r = (ρ⟨ (Θ SigMap.[ S2 ↦ Signal.unknown ] [] []) ←
(Θ SigMap.[ S1 ↦ Signal.unknown ] [] []) ,
A-max WAIT WAIT ⟩·
p)}
(≡ₑstep ([merge] dehole))
(map-order-irr S1 S2 WAIT p))))))) where
distinct-Ss-env'' : ∀ S1 S2 S3 ->
¬ Signal.unwrap S1 ≡ Signal.unwrap S2 ->
Data.List.Any.Any (_≡_ S3) (Signal.unwrap S1 ∷ []) ->
Data.List.Any.Any (_≡_ S3) (Signal.unwrap S2 ∷ []) ->
⊥
distinct-Ss-env'' S1 S2 S3 S1≠S2 (here S3=S1) (here S3=S2) rewrite S3=S1 = S1≠S2 S3=S2
distinct-Ss-env'' S1 S2 S3 S1≠S2 (here px) (there ())
distinct-Ss-env'' S1 S2 S3 S1≠S2 (there ()) S3∈Domθ2
distinct-Ss-env' : ∀ S1 S2 S3 ->
¬ Signal.unwrap S1 ≡ Signal.unwrap S2 ->
Data.List.Any.Any (_≡_ S3) (Signal.unwrap S1 ∷ []) ->
S3 ∈ proj₁ (Dom (Θ SigMap.[ S2 ↦ Signal.unknown ] [] [])) ->
⊥
distinct-Ss-env' S1 S2 S3 S1≠S2 S3∈Domθ1 S3∈Domθ2
rewrite SigMap.keys-1map S2 Signal.unknown =
distinct-Ss-env'' S1 S2 S3 S1≠S2 S3∈Domθ1 S3∈Domθ2
distinct-Ss-env : ∀ S1 S2 S3 ->
¬ Signal.unwrap S1 ≡ Signal.unwrap S2 ->
S3 ∈ proj₁ (Dom (Θ SigMap.[ S1 ↦ Signal.unknown ] [] [])) ->
S3 ∈ proj₁ (Dom (Θ SigMap.[ S2 ↦ Signal.unknown ] [] [])) ->
⊥
distinct-Ss-env S1 S2 S3 S1≠S2 S3∈Domθ1 S3∈Domθ2
rewrite SigMap.keys-1map S1 Signal.unknown =
distinct-Ss-env' S1 S2 S3 S1≠S2 S3∈Domθ1 S3∈Domθ2
distinct-doms : ∀ S1 S2 ->
¬ (Signal.unwrap S1 ≡ Signal.unwrap S2) ->
distinct (Env.Dom (Θ SigMap.[ S1 ↦ Signal.unknown ] [] []))
(Env.Dom (Θ SigMap.[ S2 ↦ Signal.unknown ] [] []))
distinct-doms S1 S2 S1≠S2 =
(λ {S3 S3∈θ1 S3∈θ2 -> distinct-Ss-env S1 S2 S3 S1≠S2 S3∈θ1 S3∈θ2})
,
(λ x₁ x₂ → λ ())
,
(λ x₁ x₂ → λ ())
map-order-irr' : ∀ S1 S2 ->
(Θ SigMap.[ S1 ↦ Signal.unknown ] [] []) ←
(Θ SigMap.[ S2 ↦ Signal.unknown ] [] [])
≡
(Θ SigMap.[ S2 ↦ Signal.unknown ] [] []) ←
(Θ SigMap.[ S1 ↦ Signal.unknown ] [] [])
map-order-irr' S1 S2 with (Signal.unwrap S1) Nat.≟ (Signal.unwrap S2)
map-order-irr' S1 S2 | yes S1=S2 rewrite S1=S2 = refl
map-order-irr' S1 S2 | no ¬S1=S2 = Env.←-comm
((Θ SigMap.[ S1 ↦ Signal.unknown ] [] []))
((Θ SigMap.[ S2 ↦ Signal.unknown ] [] []))
(distinct-doms S1 S2 ¬S1=S2)
map-order-irr : ∀ S1 S2 A p ->
(ρ⟨
Θ SigMap.[ S2 ↦ Signal.unknown ] [] [] ←
Θ SigMap.[ S1 ↦ Signal.unknown ] [] []
,
A ⟩· p)
≡ₑ
(ρ⟨
Θ SigMap.[ S1 ↦ Signal.unknown ] [] [] ←
Θ SigMap.[ S2 ↦ Signal.unknown ] [] []
,
A ⟩· p) # []
map-order-irr S1 S2 A p rewrite map-order-irr' S1 S2 = ≡ₑrefl
{- dropping a loop whose body is just `exit` -}
ex10 : ∀ C n -> (loop (exit n)) ≡ₑ (exit n) # C
ex10 C n = ≡ₑtran (≡ₑstep [loop-unroll]) (≡ₑstep [loopˢ-exit])
{- (nothin ∥ p) ≡ₑ p, but only if we know that
p goes to something that's done -}
ex11 : ∀ p q ->
CB p -> done q -> p ≡ₑ q # [] ->
(nothin ∥ p) ≡ₑ p # []
ex11 = calc where
ex11-pq : ∀ q C -> done q -> (nothin ∥ q) ≡ₑ q # C
ex11-pq .nothin C (dhalted hnothin) =
≡ₑtran (≡ₑstep [par-swap]) (≡ₑstep ([par-nothing] (dhalted hnothin)))
ex11-pq .(exit n) C (dhalted (hexit n)) =
≡ₑstep ([par-nothing] (dhalted (hexit n)))
ex11-pq q C (dpaused p/paused) =
≡ₑstep ([par-nothing] (dpaused p/paused))
basealwaysdistinct : ∀ x -> distinct base x
basealwaysdistinct x = (λ { z () x₂ }) , (λ { z () x₂ }) , (λ { z () x₂})
CBp->CBnothingp : {r r′ : Term}
{BVp FVp : Σ (List ℕ) (λ x → List ℕ × List ℕ)} →
CorrectBinding r BVp FVp →
r′ ≐ ceval (epar₂ nothin) ∷ [] ⟦ r ⟧c → CB r′
CBp->CBnothingp {r} CBr r′dc
with sym (unplugc r′dc) | BVFVcorrect _ _ _ CBr
... | refl | refl , refl
= CBpar CBnothing CBr
(basealwaysdistinct (BVars r))
(basealwaysdistinct (BVars r))
(basealwaysdistinct (FVars r))
(λ { _ () _ })
calc : ∀ p q ->
CB p -> done q -> p ≡ₑ q # [] ->
(nothin ∥ p) ≡ₑ p # []
calc p q CBp doneq p≡ₑq =
≡ₑtran {r = (nothin ∥ q)}
(≡ₑctxt (dcpar₂ dchole)
(dcpar₂ dchole)
(≡ₑ-context [] _ CBp->CBnothingp p≡ₑq))
(≡ₑtran {r = q} (ex11-pq q [] doneq) (≡ₑsymm CBp p≡ₑq))
{- although true, can no longer prove
{- an emit (first) in sequence is the same as emit in parallel -}
ex12 : ∀ S p q ->
CB p -> done q -> p ≡ₑ q # [] ->
(signl S ((emit S) ∥ p)) ≡ₑ (signl S ((emit S) >> p)) # []
ex12 S p q CBp doneq p≡ₑq = calc where
θS→unk : Env
θS→unk = Θ SigMap.[ S ↦ Signal.unknown ] [] []
S∈θS→unk : SigMap.∈Dom S (sig θS→unk)
S∈θS→unk = sig-∈-single S Signal.unknown
θS→unk[S]≡unk : sig-stats{S = S} θS→unk S∈θS→unk ≡ Signal.unknown
θS→unk[S]≡unk = sig-stats-1map' S Signal.unknown S∈θS→unk
θS→pre : Env
θS→pre = set-sig{S} θS→unk S∈θS→unk Signal.present
θS→unk[S]≠absent : ¬ sig-stats{S = S} θS→unk S∈θS→unk ≡ Signal.absent
θS→unk[S]≠absent is rewrite θS→unk[S]≡unk = unknotabs is where
unknotabs : Signal.unknown ≡ Signal.absent → ⊥
unknotabs ()
CBp->CBρθSp : {r r′ : Term}
{BVp FVp : Σ (List ℕ) (λ x → List ℕ × List ℕ)} →
CorrectBinding r BVp FVp → r′ ≐ cenv θS→pre ∷ [] ⟦ r ⟧c → CB r′
CBp->CBρθSp {r} CBr r′dc
with sym (unplugc r′dc) | BVFVcorrect _ _ _ CBr
... | refl | refl , refl = CBρ CBr
basealwaysdistinct : ∀ x -> distinct base x
basealwaysdistinct x = (λ { z () x₂ }) , (λ { z () x₂ }) , (λ { z () x₂})
CBsiglSemitS>>p : CB (signl S (emit S >> p))
CBsiglSemitS>>p =
CBsig (CBseq CBemit CBp (basealwaysdistinct (FVars p)))
calc : (signl S ((emit S) ∥ p)) ≡ₑ
(signl S ((emit S) >> p)) # []
calc =
≡ₑtran {r = ρ θS→unk · ((emit S) ∥ p)}
(≡ₑstep [raise-signal])
(≡ₑtran {r = ρ θS→pre · (nothin ∥ p)}
(≡ₑstep ([emit] S∈θS→unk θS→unk[S]≠absent (depar₁ dehole)))
(≡ₑtran {r = ρ θS→pre · p}
(≡ₑctxt (dcenv dchole) (dcenv dchole)
(≡ₑ-context [] (cenv _ ∷ [])
CBp->CBρθSp
(ex11 p q CBp doneq p≡ₑq)))
(≡ₑsymm CBsiglSemitS>>p
(≡ₑtran {r = ρ θS→unk · (emit S >> p)}
(≡ₑstep [raise-signal])
(≡ₑtran {r = ρ θS→pre · nothin >> p}
(≡ₑstep ([emit] S∈θS→unk θS→unk[S]≠absent (deseq dehole)))
(≡ₑctxt (dcenv dchole) (dcenv dchole)
(≡ₑstep [seq-done])))))))
-}
|
source/oasis/program-elements-case_expression_paths.ads | reznikmm/gela | 0 | 17437 | -- SPDX-FileCopyrightText: 2019 <NAME> <<EMAIL>>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with Program.Element_Vectors;
with Program.Elements.Paths;
with Program.Lexical_Elements;
with Program.Elements.Expressions;
package Program.Elements.Case_Expression_Paths is
pragma Pure (Program.Elements.Case_Expression_Paths);
type Case_Expression_Path is
limited interface and Program.Elements.Paths.Path;
type Case_Expression_Path_Access is access all Case_Expression_Path'Class
with Storage_Size => 0;
not overriding function Choices
(Self : Case_Expression_Path)
return not null Program.Element_Vectors.Element_Vector_Access
is abstract;
not overriding function Expression
(Self : Case_Expression_Path)
return not null Program.Elements.Expressions.Expression_Access
is abstract;
type Case_Expression_Path_Text is limited interface;
type Case_Expression_Path_Text_Access is
access all Case_Expression_Path_Text'Class with Storage_Size => 0;
not overriding function To_Case_Expression_Path_Text
(Self : in out Case_Expression_Path)
return Case_Expression_Path_Text_Access is abstract;
not overriding function When_Token
(Self : Case_Expression_Path_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Arrow_Token
(Self : Case_Expression_Path_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
type Case_Expression_Path_Vector is
limited interface and Program.Element_Vectors.Element_Vector;
type Case_Expression_Path_Vector_Access is
access all Case_Expression_Path_Vector'Class with Storage_Size => 0;
overriding function Element
(Self : Case_Expression_Path_Vector;
Index : Positive)
return not null Program.Elements.Element_Access is abstract
with Post'Class => Element'Result.Is_Case_Expression_Path;
function To_Case_Expression_Path
(Self : Case_Expression_Path_Vector'Class;
Index : Positive)
return not null Case_Expression_Path_Access
is (Self.Element (Index).To_Case_Expression_Path);
end Program.Elements.Case_Expression_Paths;
|
programs/oeis/006/A006542.asm | jmorken/loda | 1 | 88855 | <reponame>jmorken/loda
; A006542: a(n) = binomial(n,3)*binomial(n-1,3)/4.
; 1,10,50,175,490,1176,2520,4950,9075,15730,26026,41405,63700,95200,138720,197676,276165,379050,512050,681835,896126,1163800,1495000,1901250,2395575,2992626,3708810,4562425,5573800,6765440,8162176,9791320,11682825,13869450
add $0,3
bin $0,2
mov $2,$0
sub $0,1
mov $1,$0
pow $2,2
mul $1,$2
sub $1,18
div $1,18
add $1,1
|
src/core/util-nullables.ads | My-Colaborations/ada-util | 0 | 4693 | <gh_stars>0
-----------------------------------------------------------------------
-- util-nullables -- Basic types that can hold a null value
-- Copyright (C) 2017 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Calendar;
with Ada.Strings.Unbounded;
-- === Nullable types ===
-- Sometimes it is necessary to represent a simple data type with an optional boolean information
-- that indicates whether the value is valid or just null. The concept of nullable type is often
-- used in databases but also in JSON data representation. The <tt>Util.Nullables</tt> package
-- provides several standard type to express the null capability of a value.
--
-- By default a nullable instance is created with the null flag set.
package Util.Nullables is
use type Ada.Strings.Unbounded.Unbounded_String;
use type Ada.Calendar.Time;
DEFAULT_TIME : constant Ada.Calendar.Time;
-- ------------------------------
-- A boolean which can be null.
-- ------------------------------
type Nullable_Boolean is record
Value : Boolean := False;
Is_Null : Boolean := True;
end record;
Null_Boolean : constant Nullable_Boolean;
-- Return True if the two nullable times are identical (both null or both same value).
function "=" (Left, Right : in Nullable_Boolean) return Boolean is
(Left.Is_Null = Right.Is_Null and (Left.Is_Null or else Left.Value = Right.Value));
-- ------------------------------
-- An integer which can be null.
-- ------------------------------
type Nullable_Integer is record
Value : Integer := 0;
Is_Null : Boolean := True;
end record;
Null_Integer : constant Nullable_Integer;
-- Return True if the two nullable times are identical (both null or both same value).
function "=" (Left, Right : in Nullable_Integer) return Boolean is
(Left.Is_Null = Right.Is_Null and (Left.Is_Null or else Left.Value = Right.Value));
-- ------------------------------
-- A long which can be null.
-- ------------------------------
type Nullable_Long is record
Value : Long_Long_Integer := 0;
Is_Null : Boolean := True;
end record;
Null_Long : constant Nullable_Long;
-- Return True if the two nullable times are identical (both null or both same value).
function "=" (Left, Right : in Nullable_Long) return Boolean is
(Left.Is_Null = Right.Is_Null and (Left.Is_Null or else Left.Value = Right.Value));
-- ------------------------------
-- A string which can be null.
-- ------------------------------
type Nullable_String is record
Value : Ada.Strings.Unbounded.Unbounded_String;
Is_Null : Boolean := True;
end record;
Null_String : constant Nullable_String;
-- Return True if the two nullable times are identical (both null or both same value).
function "=" (Left, Right : in Nullable_String) return Boolean is
(Left.Is_Null = Right.Is_Null and (Left.Is_Null or else Left.Value = Right.Value));
-- ------------------------------
-- A date which can be null.
-- ------------------------------
type Nullable_Time is record
Value : Ada.Calendar.Time := DEFAULT_TIME;
Is_Null : Boolean := True;
end record;
Null_Time : constant Nullable_Time;
-- Return True if the two nullable times are identical (both null or both same time).
function "=" (Left, Right : in Nullable_Time) return Boolean is
(Left.Is_Null = Right.Is_Null and (Left.Is_Null or else Left.Value = Right.Value));
private
DEFAULT_TIME : constant Ada.Calendar.Time := Ada.Calendar.Time_Of (Year => 1901,
Month => 1,
Day => 2,
Seconds => 0.0);
Null_Boolean : constant Nullable_Boolean
:= Nullable_Boolean '(Is_Null => True,
Value => False);
Null_Integer : constant Nullable_Integer
:= Nullable_Integer '(Is_Null => True,
Value => 0);
Null_Long : constant Nullable_Long
:= Nullable_Long '(Is_Null => True,
Value => 0);
Null_String : constant Nullable_String
:= Nullable_String '(Is_Null => True,
Value => Ada.Strings.Unbounded.Null_Unbounded_String);
Null_Time : constant Nullable_Time
:= Nullable_Time '(Is_Null => True,
Value => DEFAULT_TIME);
end Util.Nullables;
|
mame/src/lib/cothread/doc/x86.asm | clobber/MAME-OS-X | 15 | 170551 | ; fastcall ABI:
; return = eax
; arguments = ecx,edx
; non-volatile registers = ebp,esi,edi,ebx
co_swap_fastcall(to = ecx, from = edx):
mov [edx],esp
mov esp,[ecx]
pop eax
mov [edx+ 4],ebp
mov [edx+ 8],esi
mov [edx+12],edi
mov [edx+16],ebx
mov ebp,[ecx+ 4]
mov esi,[ecx+ 8]
mov edi,[ecx+12]
mov ebx,[ecx+16]
jmp eax
|
src/test/ref/default-font.asm | jbrandwood/kickc | 2 | 101415 | // Show default font on screen
// Commodore 64 PRG executable file
.file [name="default-font.prg", type="prg", segments="Program"]
.segmentdef Program [segments="Basic, Code, Data"]
.segmentdef Basic [start=$0801]
.segmentdef Code [start=$80d]
.segmentdef Data [startAfter="Code"]
.segment Basic
:BasicUpstart(main)
.label SCREEN = $400
.segment Code
main: {
.label screen = 4
.label ch = 6
.label x = 7
// memset(SCREEN, ' ', 1000)
jsr memset
lda #0
sta.z x
lda #<SCREEN+$28+1
sta.z screen
lda #>SCREEN+$28+1
sta.z screen+1
lda #0
sta.z ch
__b1:
ldx #0
__b2:
// *screen++ = ch++
lda.z ch
ldy #0
sta (screen),y
// *screen++ = ch++;
inc.z screen
bne !+
inc.z screen+1
!:
inc.z ch
// for( byte y: 0..15)
inx
cpx #$10
bne __b2
// screen += (40-16)
lda #$28-$10
clc
adc.z screen
sta.z screen
bcc !+
inc.z screen+1
!:
// for( byte x: 0..15)
inc.z x
lda #$10
cmp.z x
bne __b1
// }
rts
}
// Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
// void * memset(void *str, char c, unsigned int num)
memset: {
.const c = ' '
.const num = $3e8
.label str = SCREEN
.label end = str+num
.label dst = 2
lda #<str
sta.z dst
lda #>str
sta.z dst+1
__b1:
// for(char* dst = str; dst!=end; dst++)
lda.z dst+1
cmp #>end
bne __b2
lda.z dst
cmp #<end
bne __b2
// }
rts
__b2:
// *dst = c
lda #c
ldy #0
sta (dst),y
// for(char* dst = str; dst!=end; dst++)
inc.z dst
bne !+
inc.z dst+1
!:
jmp __b1
}
|
Task/Jump-anywhere/Ada/jump-anywhere.ada | LaudateCorpus1/RosettaCodeData | 1 | 2079 | <gh_stars>1-10
procedure Goto_Test is
begin
Stuff;
goto The_Mother_Ship; -- You can do this if you really must!
Stuff;
if condition then
Stuff;
<<Jail>>
Stuff;
end if;
Stuff;
-- Ada does not permit any of the following
goto Jail;
goto The_Sewer;
goto The_Morgue;
Stuff;
case condition is
when Arm1 =>
Stuff;
goto The_Gutter; -- Cant do this either
Stuff;
when Arm2 =>
Stuff;
<<The_Gutter>>
Stuff;
<<The_Sewer>>
Stuff;
end case;
Stuff;
for I in Something'Range loop
Stuff;
<<The_Morgue>>
if You_Are_In_Trouble then
goto The_Mother_Ship;
-- This is the usual use of a goto.
end if;
Stuff;
end loop;
Stuff;
<<The_Mother_Ship>>
Stuff;
end Goto_Test;
|
libpal/intel_64bit_systemv_nasm/invvpid_checked.asm | mars-research/pal | 26 | 15362 | <reponame>mars-research/pal
bits 64
default rel
section .text
global pal_execute_invvpid_checked
pal_execute_invvpid_checked :
invvpid rdi, [rsi]
jbe pal_execute_invvpid_checked_failure
mov rax, 0x1
ret
pal_execute_invvpid_checked_failure :
mov rax, 0x0
ret
|
grammar/update.g4 | jbreindel/documentclient-mock | 1 | 4911 | grammar update;
update
: updateaction+
;
updateaction
: SET setaction (COMMA setaction)* #setUpdate
| REMOVE removeaction (COMMA removeaction)* #removeUpdate
| ADD addaction (COMMA addaction)* #addUpdate
| DELETE deleteaction (COMMA deleteaction)* #deleteUpdate
;
setaction
: path=OPERAND EQ result=setvalue #setAction
;
removeaction
: path=OPERAND #removeAction
;
addaction
: path=OPERAND value=OPERAND #addAction
;
deleteaction
: path=OPERAND value=OPERAND #deleteAction
;
setvalue
: leftVal=setvalue PLUS rightVal=setvalue #incSetValue
| leftVal=setvalue MINUS rightVal=setvalue #decSetValue
| func=setfunc #setFuncSetValue
| op=OPERAND #valSetValue
;
setfunc
: IF_NOT_EXISTS LPAREN path=OPERAND COMMA val=OPERAND RPAREN #ineSetFunc
| LIST_APPEND LPAREN list1=OPERAND COMMA list2=OPERAND RPAREN #laSetFunc
;
fragment A : [aA]; // match either an 'a' or 'A'
fragment B : [bB];
fragment C : [cC];
fragment D : [dD];
fragment E : [eE];
fragment F : [fF];
fragment G : [gG];
fragment H : [hH];
fragment I : [iI];
fragment J : [jJ];
fragment K : [kK];
fragment L : [lL];
fragment M : [mM];
fragment N : [nN];
fragment O : [oO];
fragment P : [pP];
fragment Q : [qQ];
fragment R : [rR];
fragment S : [sS];
fragment T : [tT];
fragment U : [uU];
fragment V : [vV];
fragment W : [wW];
fragment X : [xX];
fragment Y : [yY];
fragment Z : [zZ];
SET : S E T ;
REMOVE : R E M O V E ;
ADD : A D D ;
DELETE : D E L E T E ;
EQ : '=' ;
PLUS : '+' ;
MINUS : '-' ;
LPAREN : '(' ;
RPAREN : ')' ;
COMMA : ',' ;
LIST_APPEND : L I S T '_' A P P E N D ;
IF_NOT_EXISTS : I F '_' N O T '_' E X I S T S ;
OPERAND : ':'? /[#0-9a-zA-Z.]+/ ;
WS : [ \r\n] -> skip ;
|
programs/oeis/061/A061462.asm | karttu/loda | 0 | 13789 | ; A061462: The exact power of 2 that divides the n-th Bell number (A000110). Has period 12.
; 1,1,2,1,1,4,1,1,4,1,1,2,1,1,2,1,1,4,1,1,4,1,1,2,1,1,2,1,1,4,1,1,4,1,1,2,1,1,2,1,1,4,1,1,4,1,1,2,1,1,2,1,1,4,1,1,4,1,1,2,1,1,2,1,1,4,1,1,4,1,1,2,1,1,2,1,1,4,1,1,4,1,1,2,1,1,2,1,1,4,1,1,4,1,1,2,1,1,2,1,1,4,1,1,4,1,1,2
mov $2,$0
pow $0,2
sub $0,$2
add $0,4
div $0,3
gcd $0,4
add $0,1
mov $1,$0
sub $1,1
|
source/regions/regions-contexts-environments-package_nodes.ads | reznikmm/declarative-regions | 0 | 10767 | -- SPDX-FileCopyrightText: 2022 <NAME> <<EMAIL>>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with Regions.Contexts.Environments.Nodes;
with Regions.Entities.Packages;
with Regions.Shared_Hashed_Maps;
-- with Regions.Shared_Lists;
private
package Regions.Contexts.Environments.Package_Nodes is
pragma Preelaborate;
function Hash
(Value : Regions.Symbols.Symbol) return Ada.Containers.Hash_Type
is (Ada.Containers.Hash_Type'Mod (Value));
type List_Change_Count is mod 2 ** 32;
package Name_List_Maps is new Regions.Shared_Hashed_Maps
(Regions.Symbols.Symbol,
Selected_Entity_Name_Lists.List,
Ada.Containers.Hash_Type,
List_Change_Count,
Hash,
Regions.Symbols."=",
Selected_Entity_Name_Lists."=");
type Package_Node;
function Empty_Map (Self : access Package_Node)
return Name_List_Maps.Map;
type Package_Node is new Nodes.Entity_Node with record
Version : aliased List_Change_Count := 0;
Names : Name_List_Maps.Map :=
Empty_Map (Package_Node'Unchecked_Access);
end record;
type Package_Entity is new Environments.Nodes.Base_Entity
and Regions.Entities.Packages.Package_Entity
with null record;
overriding function Is_Package (Self : Package_Entity) return Boolean
is (True);
overriding function Immediate_Visible_Backward
(Self : Package_Entity;
Symbol : Symbols.Symbol)
return Regions.Entity_Iterator_Interfaces.Forward_Iterator'Class;
overriding function Immediate_Visible
(Self : Package_Entity;
Symbol : Symbols.Symbol)
return Regions.Entity_Iterator_Interfaces.Forward_Iterator'Class;
end Regions.Contexts.Environments.Package_Nodes;
|
verify/output/variable_with_expression.alfy.asm | alexandruradovici/alf-alfy-asm-public | 0 | 24693 | start:
set r2 3
set r3 5
mul r4 r2 r3
set r2 20
add r3 r2 r4
set r2 0
store r2 r3
set r2 0
load r2 r2
writenumber r2
stop
|
data/mapObjects/ViridianForestNorthGate.asm | AmateurPanda92/pokemon-rby-dx | 9 | 168689 | ViridianForestNorthGate_Object:
db $a ; border block
db 4 ; warps
warp 4, 0, 1, -1
warp 5, 0, 1, -1
warp 4, 7, 0, VIRIDIAN_FOREST
warp 5, 7, 0, VIRIDIAN_FOREST
db 0 ; signs
db 2 ; objects
object SPRITE_BLACK_HAIR_BOY_2, 3, 2, STAY, NONE, 1 ; person
object SPRITE_OLD_PERSON, 2, 5, STAY, NONE, 2 ; person
; warp-to
warp_to 4, 0, VIRIDIAN_FOREST_NORTH_GATE_WIDTH
warp_to 5, 0, VIRIDIAN_FOREST_NORTH_GATE_WIDTH
warp_to 4, 7, VIRIDIAN_FOREST_NORTH_GATE_WIDTH ; VIRIDIAN_FOREST
warp_to 5, 7, VIRIDIAN_FOREST_NORTH_GATE_WIDTH ; VIRIDIAN_FOREST
|
Transynther/x86/_processed/NONE/_xt_sm_/i7-7700_9_0x48_notsx.log_21829_72.asm | ljhsiun2/medusa | 9 | 170161 | .global s_prepare_buffers
s_prepare_buffers:
push %r9
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_normal_ht+0x1a81c, %r9
nop
nop
nop
nop
nop
xor $27968, %rdi
movb $0x61, (%r9)
nop
nop
nop
nop
dec %rcx
lea addresses_UC_ht+0x1ad78, %rsi
lea addresses_A_ht+0x1b41c, %rdi
nop
nop
xor %rdx, %rdx
mov $23, %rcx
rep movsl
inc %rdx
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %r9
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r12
push %r15
push %r8
push %rbp
push %rbx
push %rcx
push %rdi
push %rsi
// Store
lea addresses_normal+0x1501c, %r15
nop
nop
nop
xor %r10, %r10
mov $0x5152535455565758, %r8
movq %r8, %xmm5
movups %xmm5, (%r15)
nop
nop
nop
sub %rbx, %rbx
// Load
lea addresses_normal+0x1501c, %r15
nop
nop
nop
cmp %rdi, %rdi
mov (%r15), %r10d
nop
nop
nop
add %rbx, %rbx
// REPMOV
mov $0xd07, %rsi
lea addresses_PSE+0xf2a3, %rdi
nop
nop
and $7501, %rbx
mov $54, %rcx
rep movsb
sub $25263, %rbp
// Faulty Load
lea addresses_normal+0x1501c, %rcx
xor $2392, %r10
mov (%rcx), %r8
lea oracles, %rbp
and $0xff, %r8
shlq $12, %r8
mov (%rbp,%r8,1), %r8
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %r8
pop %r15
pop %r12
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_normal', 'congruent': 0}}
{'dst': {'same': True, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_normal', 'congruent': 0}, 'OP': 'STOR'}
{'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_normal', 'congruent': 0}}
{'dst': {'same': False, 'congruent': 0, 'type': 'addresses_PSE'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 0, 'type': 'addresses_P'}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_normal', 'congruent': 0}}
<gen_prepare_buffer>
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_normal_ht', 'congruent': 10}, 'OP': 'STOR'}
{'dst': {'same': False, 'congruent': 10, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 2, 'type': 'addresses_UC_ht'}}
{'58': 21829}
58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58
*/
|
Transynther/x86/_processed/NONE/_xt_/i7-8650U_0xd2_notsx.log_8792_1794.asm | ljhsiun2/medusa | 9 | 165444 | <filename>Transynther/x86/_processed/NONE/_xt_/i7-8650U_0xd2_notsx.log_8792_1794.asm
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r13
push %r14
push %r15
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_WC_ht+0x91af, %rsi
nop
nop
nop
and $22596, %rcx
mov (%rsi), %r15d
nop
nop
nop
cmp %r10, %r10
lea addresses_A_ht+0x1b0af, %r15
nop
nop
add $10145, %rsi
movl $0x61626364, (%r15)
nop
nop
nop
nop
nop
inc %rsi
lea addresses_normal_ht+0x1422f, %rdi
nop
and %r13, %r13
movw $0x6162, (%rdi)
nop
nop
nop
nop
nop
and %r10, %r10
lea addresses_WT_ht+0x99d9, %rsi
lea addresses_A_ht+0x1b17f, %rdi
clflush (%rsi)
nop
xor %r14, %r14
mov $124, %rcx
rep movsb
nop
nop
nop
sub $15288, %rcx
lea addresses_UC_ht+0x2caf, %r14
xor $3997, %r15
and $0xffffffffffffffc0, %r14
vmovaps (%r14), %ymm0
vextracti128 $0, %ymm0, %xmm0
vpextrq $1, %xmm0, %rbx
nop
nop
and $12225, %rcx
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %r15
pop %r14
pop %r13
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r14
push %r15
push %r9
push %rax
push %rdi
// Faulty Load
lea addresses_UC+0x1e8af, %r9
nop
nop
nop
and $15779, %rdi
movb (%r9), %al
lea oracles, %r15
and $0xff, %rax
shlq $12, %rax
mov (%r15,%rax,1), %rax
pop %rdi
pop %rax
pop %r9
pop %r15
pop %r14
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_UC', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_UC', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'size': 4, 'AVXalign': False, 'NT': True, 'congruent': 5, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 2, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'size': 32, 'AVXalign': True, 'NT': False, 'congruent': 10, 'same': False}}
{'37': 8792}
37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37
*/
|
legend-engine-language-pure-grammar/src/main/antlr4/org/finos/legend/engine/language/pure/grammar/from/antlr4/navigation/NavigationLexerGrammar.g4 | dave-wathen/legend-engine | 32 | 7621 | lexer grammar NavigationLexerGrammar;
import CoreLexerGrammar;
// ----------------------------------- BUILDING BLOCK -----------------------------------
INTEGER: ('+'|'-')? Integer;
FLOAT: ('+'|'-')? Float;
VALID_STRING: ValidString;
VALID_STRING_TYPE: (Letter | Digit | '_' ) (Letter | Digit | '_' | '$' | '<' | '>')*;
|
asm/readTSC.asm | GabrielRavier/Generic-Assembly-Samples | 0 | 91085 | ; RDTSC32.ASM
;
; Original Author: <NAME>
; Date created: 2003
; Last modified: 2018-06-28, by <NAME>
; Description:
;
; Copyright (c) 2018 GNU General Public License www.gnu.org/licenses
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
global _ASM_readTSC
segment .text align=16
; This function returns the value of the time stamp counter, which counts
; clock cycles. To count how many clock cycles a piece of code takes, call
; Rdtsc before and after the code to measure and calculate the difference.
; The number of clock cycles taken by the ReadTSC function itself is approximately:
; Core 2: 730
; Pentium 4: 700
; Pentium II and Pentium III: 225
; AMD Athlon 64, Opteron: 126
; Does not work on 80386 and 80486.
; Note that clock counts may not be fully reproducible on Intel Core and
; Core 2 processors because the clock frequency can change. More reliable
; instruction timings are obtained with the performance monitor counter
; for "core clock cycles". This requires a kernel mode driver as the one
; included with www.agner.org/optimize/testp.zip.
%define loResult eax
%define hiResult edx
_ASM_readTSC:
push ebx ; Modified by cpuid
xor loResult, loResult
cpuid ; Serialize
rdtsc ; Read time stamp counter
push loResult
push hiResult
xor loResult, loResult
cpuid ; Serialize
pop hiResult
pop loResult
pop ebx
ret
|
other.7z/SFC.7z/SFC/ソースデータ/ヨッシーアイランド/ツール/tool/sfxdos/ascii.asm | prismotizm/gigaleak | 0 | 247665 | <gh_stars>0
Name: ascii.asm
Type: file
Size: 12622
Last-Modified: '2016-05-13T04:52:55Z'
SHA-1: C3E7C99A9AA8E3A6AD662A1567522A4BCD8180B3
Description: null
|
test/interaction/Issue2287.agda | cruhland/agda | 1,989 | 16452 |
record R : Set₁ where
field
A : Set
{B} : Set
{{C}} : Set
open R
r : R
r = {!!}
-- C-c C-c produced
-- A r = {!!}
-- B {r} = {!!}
-- C {{r}} = {!!}
|
LC/Confluence.agda | banacorn/bidirectional | 2 | 7145 | module LC.Confluence where
open import LC.Base
open import LC.Subst
open import LC.Reduction
open import Data.Product
open import Relation.Binary.Construct.Closure.ReflexiveTransitive
β→confluent : ∀ {M N O : Term} → (M β→ N) → (M β→ O) → ∃ (λ P → (N β→* P) × (O β→* P))
β→confluent (β-ƛ-∙ {M} {N}) β-ƛ-∙ = M [ N ] , ε , ε
β→confluent (β-ƛ-∙ {M} {N}) (β-∙-l {N = _} (β-ƛ {N = O} M→O)) = (O [ N ]) , cong-[]-l M→O , return β-ƛ-∙
β→confluent (β-ƛ-∙ {M} {N}) (β-∙-r {N = O} N→O) = M [ O ] , cong-[]-r M N→O , return β-ƛ-∙
β→confluent (β-ƛ M→N) (β-ƛ M→O) with β→confluent M→N M→O
... | P , N→P , O→P = ƛ P , cong-ƛ N→P , cong-ƛ O→P
β→confluent (β-∙-l {L} (β-ƛ {N = N} M→N)) β-ƛ-∙ = N [ L ] , return β-ƛ-∙ , cong-[]-l M→N
β→confluent (β-∙-l {L} M→N) (β-∙-l M→O) with β→confluent M→N M→O
... | P , N→P , O→P = P ∙ L , cong-∙-l N→P , cong-∙-l O→P
β→confluent (β-∙-l {N = N} M→N) (β-∙-r {N = O} L→O) = N ∙ O , cong-∙-r (return L→O) , cong-∙-l (return M→N)
β→confluent (β-∙-r {N = N} M→N) (β-ƛ-∙ {O}) = O [ N ] , return β-ƛ-∙ , cong-[]-r O M→N
β→confluent (β-∙-r {N = N} M→N) (β-∙-l {N = O} L→O) = O ∙ N , cong-∙-l (return L→O) , cong-∙-r (return M→N)
β→confluent (β-∙-r {L} {M} {N} M→N) (β-∙-r {N = O} M→O) with β→confluent M→N M→O
... | P , N→P , O→P = L ∙ P , cong-∙-r N→P , cong-∙-r O→P
-- β→*-confluent : ∀ {M N O} → (M β→* N) → (M β→* O) → ∃ (λ P → (N β→* P) × (O β→* P))
-- β→*-confluent {O = O} ε M→O = O , M→O , ε
-- β→*-confluent {N = N} M→N ε = N , ε , M→N
-- β→*-confluent {M} {N} {O} (_◅_ {j = L} M→L L→N) (_◅_ {j = K} M→K K→O) with β→confluent M→L M→K
-- ... | M' , L→M' , K→M' = {! !} |
libsrc/_DEVELOPMENT/fcntl/z80/drivers/terminal/console_01/output/console_01_output_terminal_char/console_01_output_char_proc_reset_scroll_limit.asm | meesokim/z88dk | 0 | 104742 | <reponame>meesokim/z88dk<gh_stars>0
SECTION code_fcntl
PUBLIC console_01_output_char_proc_reset_scroll_limit
console_01_output_char_proc_reset_scroll_limit:
; set scroll limit to window height
ld a,(ix+19) ; a = rect.height
ld (ix+20),a
ret
|
tests/src/trendy_terminal_tests.adb | pyjarrett/archaic_terminal | 3 | 1508 | with Trendy_Test.Reports;
with Trendy_Terminal.Histories.Tests;
with Trendy_Terminal.Lines.Tests;
procedure Trendy_Terminal_Tests is
begin
Trendy_Test.Register (Trendy_Terminal.Histories.Tests.All_Tests);
Trendy_Test.Register (Trendy_Terminal.Lines.Tests.All_Tests);
Trendy_Test.Reports.Print_Basic_Report (Trendy_Test.Run);
end Trendy_Terminal_Tests;
|
savefile/maps/472B_SouthernEncampment.asm | stranck/fools2018-1 | 35 | 105248 | SECTION "Map_472B", ROM0[$B800]
Map_472B_Header:
hdr_tileset 0
hdr_dimensions 9, 11
hdr_pointers_a Map_472B_Blocks, Map_472B_TextPointers
hdr_pointers_b Map_472B_Script, Map_472B_Objects
hdr_pointers_c Map_472B_InitScript, Map_472B_RAMScript
hdr_palette $0A
hdr_music MUSIC_SS_ANNE, AUDIO_1
hdr_connection NORTH, $4530, 6, 16
hdr_connection SOUTH, $482B, 6, 4
hdr_connection WEST, $0000, 0, 0
hdr_connection EAST, $4A34, 1, 8
Map_472B_Objects:
hdr_border $0f
hdr_warp_count 3
hdr_warp 13, 9, 2, 7, $4788
hdr_warp 10, 11, 2, 7, $4787
hdr_warp 9, 5, 2, 7, $4786
hdr_sign_count 1
hdr_signpost 13, 7, $02
hdr_object_count 1
hdr_object SPRITE_LAPRAS_GIVER, 6, 10, STAY, NONE, $01
Map_472B_RAMScript:
rs_write_1 $c6fc, $31
rs_write_1 $c70b, $31
rs_fill_byte $31
rs_fill_3 $c77b
rs_write_3 $c7bf, $7b, $74, $7b
rs_write_3 $c7ce, $74, $7b, $74
rs_end
Map_472B_Blocks:
db $0f,$0f,$31,$0f,$0f,$0f,$0f,$0f,$0f
db $0f,$0f,$31,$0f,$0f,$0f,$0f,$0f,$0f
db $0f,$0f,$31,$0a,$02,$09,$03,$74,$0f
db $0f,$0f,$31,$31,$31,$31,$08,$0a,$0f
db $0f,$0f,$31,$74,$0c,$0e,$02,$03,$0f
db $0f,$0f,$31,$74,$10,$12,$0a,$74,$0f
db $0f,$0f,$31,$31,$31,$31,$31,$31,$31
db $0f,$0f,$1d,$1f,$1e,$0f,$0f,$0f,$0f
db $0f,$0f,$65,$43,$64,$0f,$0f,$0f,$0f
db $0f,$0f,$7b,$74,$7b,$0f,$0f,$0f,$0f
db $0f,$0f,$74,$7b,$74,$0f,$0f,$0f,$0f
Map_472B_TextPointers:
dw Map_472B_TX1
dw Map_472B_TX2
Map_472B_InitScript:
ret
Map_472B_Script:
ret
Map_472B_TX1:
TX_ASM
jp EnhancedTextOnly
text "I see a lot of suspicious"
next "people around these areas."
para "I think there's some"
next "criminal activity here, but"
cont "I can't prove it yet."
done
Map_472B_TX2:
TX_ASM
jp EnhancedTextOnly
text "Want to feel refreshed"
next "and newly born?"
para "Want to experience your"
next "life anew?"
para "Southern Glitchland's"
next "Spirit Relasing Therapy"
para "Refresh your mind and"
next "body, experience a new"
cont "life."
done
|
Part-2 Submission/1512132642_P03.asm | AnikIslam1/CSE331L_Section_7_Summer20_NSU_Midterm_1 | 2 | 16515 |
; You may customize this and other start-up templates;
; The location of this template is c:\emu8086\inc\0_com_template.txt
org 100h
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX
MOV AH, 9
INT 21H
MOV CX, 10
MOV AH, 2
MOV DL, 48
@LOOP:
INT 21H
INC DL
DEC CX
JNZ @LOOP
MOV AH, 4CH
INT 21H
MAIN ENDP
END MAIN
ret
|
data/pokemon/dex_entries/kingdra.asm | Dev727/ancientplatinum | 28 | 172772 | <reponame>Dev727/ancientplatinum
db "DRAGON@" ; species name
dw 511, 3350 ; height, weight
db "It stores energy"
next "by sleeping at"
next "underwater depths"
page "at which no other"
next "life forms can"
next "survive.@"
|
test/Files.agda | L-TChen/agda-prelude | 111 | 2087 | module Files where
open import Prelude
open import System.File
open import System.FilePath
open import Prelude.Equality
fileIsEqual : ∀ {k} → Path k → Path k → IO Unit
fileIsEqual a b = _≟_ <$> readBinaryFile a <*> readBinaryFile b >>= λ x →
if x then return unit else exitWith (Failure 1)
where
-- Move this to Prelude.Equality?
_≟_ : ∀ {a} {A : Set a} → {{eq : Eq A}} → A → A → Bool
x ≟ y = isYes (x == y)
main : IO ⊤
main =
readTextFile fIn >>=
writeTextFile fTxtOut >>
readBinaryFile fIn >>=
writeBinaryFile fBinOut >>
fileIsEqual fIn fTxtOut >>
fileIsEqual fIn fBinOut
where
fIn = relative "Files.agda"
fTxtOut = relative "test_files_txt.out"
fBinOut = relative "test_files_bin.out"
|
dependencies/agar/ada-gui/SYSDEPS/ver_gnat.adb | amvb/GUCEF | 5 | 1395 | <gh_stars>1-10
-- Detect GNAT version
with ada.exceptions;
with ada.strings.fixed;
with ada.strings.bounded;
with ada.strings;
with ada.text_io;
with gnat.compiler_version;
procedure ver_gnat is
package ex renames ada.exceptions;
package io renames ada.text_io;
package str renames ada.strings;
package str_fixed renames ada.strings.fixed;
package version_strings is new ada.strings.bounded.generic_bounded_length (16);
package ver is new gnat.compiler_version;
parse_error : exception;
subtype version_name_t is version_strings.bounded_string;
procedure version_parse
(version_raw : string;
version_name : out version_name_t;
version_major : out integer;
version_minor : out integer;
version_patch : out integer)
is
version_tmp : string := version_raw;
fsf_prefix : constant string := "GNAT Version: ";
gpl_prefix : constant string := "GPL ";
-- does the version string have a non-numeric prefix?
function have_prefix (str : string) return boolean
is
char : constant character := str (str'first);
begin
return (char < '0') or (char > '9');
end have_prefix;
-- find first non numeric character in string
procedure first_non_numeric
(str : string;
position : out positive;
found : out boolean) is
begin
for index in str'range loop
declare
char : constant character := str (index);
begin
if (char < '0') or (char > '9') then
position := index;
found := true;
return;
end if;
end;
end loop;
found := false;
end first_non_numeric;
-- remove GNAT version prefix if necessary
procedure remove_prefix
(version : in out string;
prefix : string;
removed : out boolean) is
begin
if version'length >= prefix'length then
if version (version'first .. prefix'length) = prefix then
str_fixed.delete (version, version'first, prefix'length);
removed := true;
return;
end if;
end if;
removed := false;
end remove_prefix;
-- expects strings of the form "N.N.N"
procedure parse_fsf is
str_tmp : string := version_tmp;
begin
-- consume major
declare
dot : constant integer := str_fixed.index (str_tmp, ".");
begin
version_major := integer'value (str_tmp (str_tmp'first .. dot - 1));
str_fixed.delete (str_tmp, str_tmp'first, dot);
end;
-- consume minor
declare
dot : constant integer := str_fixed.index (str_tmp, ".");
begin
version_minor := integer'value (str_tmp (str_tmp'first .. dot - 1));
str_fixed.delete (str_tmp, str_tmp'first, dot);
end;
-- consume patch
declare
found : boolean;
position : positive;
begin
first_non_numeric (str_tmp, position, found);
if found then
version_patch := integer'value (str_tmp (str_tmp'first .. position - 1));
end if;
end;
exception
when others => raise parse_error with "error parsing FSF version string";
end parse_fsf;
-- expects strings of the form "YYYY (YYYYMMDD)" eg. "2008 (20080521)"
procedure parse_gpl is
year : constant string :=
version_tmp (version_tmp'first .. str_fixed.index (version_tmp, " "));
begin
version_major := integer'value (year);
exception
when others => raise parse_error with "error parsing GPL version string";
end parse_gpl;
removed : boolean;
begin
version_name := version_strings.to_bounded_string ("GNAT");
version_major := 0;
version_minor := 0;
version_patch := 0;
-- FSF GNAT appears to have no prefix on some platforms
if have_prefix (version_tmp) then
remove_prefix (version_tmp, fsf_prefix, removed);
if removed then
version_name := version_strings.to_bounded_string ("GNAT_FSF");
parse_fsf;
return;
end if;
remove_prefix (version_tmp, gpl_prefix, removed);
if removed then
version_name := version_strings.to_bounded_string ("GNAT_GPL");
parse_gpl;
return;
end if;
else
version_name := version_strings.to_bounded_string ("GNAT_FSF");
parse_fsf;
return;
end if;
end version_parse;
function to_string (num : integer) return string is
begin
return str_fixed.trim (integer'image (num), str.left);
end to_string;
-- data
ver_input : constant string := ver.version;
ver_name : version_name_t;
ver_major : integer;
ver_minor : integer;
ver_patch : integer;
begin
-- catch parse errors
begin
version_parse (ver_input, ver_name, ver_major, ver_minor, ver_patch);
exception
when e: parse_error =>
io.put_line (io.current_error, "error: " & ex.exception_message (e));
end;
io.put_line
("SYSDEP_ADA_TYPE_" & version_strings.to_string (ver_name) & " " &
to_string (ver_major) & "." &
to_string (ver_minor) & "." &
to_string (ver_patch));
end ver_gnat;
|
src/MLib/Matrix/SemiTensor.agda | bch29/agda-matrices | 0 | 15233 | <filename>src/MLib/Matrix/SemiTensor.agda
open import MLib.Algebra.PropertyCode
open import MLib.Algebra.PropertyCode.Structures
module MLib.Matrix.SemiTensor {c ℓ} (struct : Struct bimonoidCode c ℓ) where
open import MLib.Matrix.SemiTensor.Core struct using (_⋉_) public
open import MLib.Matrix.SemiTensor.GeneralizesMul struct public
|
lib/target/zx/classic/zx_p3loader.asm | dp304/z88dk | 4 | 11169 | <reponame>dp304/z88dk
EXTERN __DATA_END_tail
EXTERN __BANK_0_END_tail
EXTERN __BANK_1_END_tail
EXTERN __BANK_2_END_tail
EXTERN __BANK_3_END_tail
EXTERN __BANK_4_END_tail
EXTERN __BANK_5_END_tail
EXTERN __BANK_6_END_tail
EXTERN __BANK_7_END_tail
ld hl,(23645)
inc hl
ld a,(hl)
cp 234 ;REM
ret nz
inc hl
;The filename follows
ld de,filen
ld b,16
readf3:
ld a,(hl)
cp 13
jr z,readf4
ld (de),a
inc hl
inc de
cp '.'
jr nz,not_dot
ld (extension),de
not_dot:
djnz readf3
readf4:
ld (23645),hl
ld hl,(extension)
inc hl
ld (hl),255
; We've now read the base of the filename
; Reconfigure +3 memory to allow to read into pages without breaking the cache
ld de,0 ;Disable cache
ld hl,128 ;RAMdisk uses all memory, we don't use it so no problems
ld ix,319
call dodos
; Load FILENAME.BIN
; ld c,0
; ld de,__DATA_END_tail - CRT_ORG_CODE
; ld hl,CRT_ORG_CODE
; call loadfile
; ret nc
ld de,__BANK_0_END_tail - CRT_ORG_BANK_0
ld c,0 ;Bank 0
call loadbank
ret nc
ld de,__BANK_1_END_tail - CRT_ORG_BANK_1
ld c,1 ;Bank 1
call loadbank
ret nc
ld de,__BANK_2_END_tail - CRT_ORG_BANK_2
ld c,2 ;Bank 2
call loadbank
ret nc
ld de,__BANK_3_END_tail - CRT_ORG_BANK_3
ld c,3 ;Bank 3
call loadbank
ret nc
ld de,__BANK_4_END_tail - CRT_ORG_BANK_4
ld c,4 ;Bank 4
call loadbank
ret nc
ld de,__BANK_5_END_tail - CRT_ORG_BANK_5
ld c,5 ;Bank 5
call loadbank
ret nc
ld de,__BANK_6_END_tail - CRT_ORG_BANK_6
ld c,6 ;Bank 6
call loadbank
ret nc
ld de,__BANK_7_END_tail - CRT_ORG_BANK_7
ld c,7 ;Bank 7
call loadbank
ret
loadbank:
ld a,c
add 48
ld hl,(extension)
ld (hl),a
; And fall into...
loadfile:
ld a,d
or e
ccf
ret z
push bc
push de
ld hl,filen
ld bc,1
ld de,1
ld ix,262
call dodos
pop de
pop bc
ret nc
ld hl,49152
ld b,0
ld ix,274
call dodos
ld b,0
ld ix,265
call dodos
scf
ret
dodos:
push af
push bc
di
ld a,7
ld bc,32765
ld (23388),a
out (c),a
ei
pop bc
pop af
call jpix
push af
push bc
di
ld a,16
ld bc,32765
ld (23388),a
out (c),a
ei
pop bc
pop af
ret
jpix:
jp (ix)
; Filename as read from basic
; This contains: FILENAME.BIN initially (padded out)
extension: defw 0
filen: defs 16
|
tier-1/fann/source/thin/fann_c-binding.ads | charlie5/cBound | 2 | 17552 | <gh_stars>1-10
-- This file is generated by SWIG. Please do *not* modify by hand.
--
with fann_c.Pointers;
with fann_c.fann;
with fann_c.fann_callback_type;
with fann_c.fann_connection;
with fann_c.fann_error;
with fann_c.fann_train_data;
with fann_c.user_function;
with interfaces.c;
with interfaces.c.strings;
with swig;
with swig.pointers;
with interfaces.C;
package fann_c.Binding is
procedure fann_set_error_log (errdat : in fann_c.fann_error.Pointer;
log_file : in fann_c.Pointers.FILE_Pointer);
function fann_get_errno (errdat : in fann_c.fann_error.Pointer) return fann_c.fann_errno_enum;
procedure fann_reset_errno (errdat : in fann_c.fann_error.Pointer);
procedure fann_reset_errstr (errdat : in fann_c.fann_error.Pointer);
function fann_get_errstr (errdat : in fann_c.fann_error.Pointer) return interfaces.c.strings.chars_ptr;
procedure fann_print_error (errdat : in fann_c.fann_error.Pointer);
function create_train_from_callback (num_data : in interfaces.c.unsigned;
num_input : in interfaces.c.unsigned;
num_output : in interfaces.c.unsigned;
the_user_function : in fann_c.user_function.Item) return fann_c.fann_train_data.Pointer;
procedure fann_train (ann : in fann_c.fann.Pointer;
input : in fann_c.Pointers.fann_type_Pointer;
desired_output : in fann_c.Pointers.fann_type_Pointer);
function fann_test (ann : in fann_c.fann.Pointer;
input : in fann_c.Pointers.fann_type_Pointer;
desired_output : in fann_c.Pointers.fann_type_Pointer) return fann_c.Pointers.fann_type_Pointer;
function fann_get_MSE (ann : in fann_c.fann.Pointer) return interfaces.c.c_float;
function fann_get_bit_fail (ann : in fann_c.fann.Pointer) return interfaces.c.unsigned;
procedure fann_reset_MSE (ann : in fann_c.fann.Pointer);
procedure fann_train_on_data (ann : in fann_c.fann.Pointer;
data : in fann_c.fann_train_data.Pointer;
max_epochs : in interfaces.c.unsigned;
epochs_between_reports : in interfaces.c.unsigned;
desired_error : in interfaces.c.c_float);
procedure fann_train_on_file (ann : in fann_c.fann.Pointer;
filename : in interfaces.c.strings.chars_ptr;
max_epochs : in interfaces.c.unsigned;
epochs_between_reports : in interfaces.c.unsigned;
desired_error : in interfaces.c.c_float);
function fann_train_epoch (ann : in fann_c.fann.Pointer;
data : in fann_c.fann_train_data.Pointer) return interfaces.c.c_float;
function fann_test_data (ann : in fann_c.fann.Pointer;
data : in fann_c.fann_train_data.Pointer) return interfaces.c.c_float;
function fann_read_train_from_file (filename : in interfaces.c.strings.chars_ptr) return fann_c.fann_train_data.Pointer;
function fann_create_train (num_data : in interfaces.c.unsigned;
num_input : in interfaces.c.unsigned;
num_output : in interfaces.c.unsigned) return fann_c.fann_train_data.Pointer;
procedure fann_destroy_train (train_data : in fann_c.fann_train_data.Pointer);
procedure fann_shuffle_train_data (train_data : in fann_c.fann_train_data.Pointer);
procedure fann_scale_train (ann : in fann_c.fann.Pointer;
data : in fann_c.fann_train_data.Pointer);
procedure fann_descale_train (ann : in fann_c.fann.Pointer;
data : in fann_c.fann_train_data.Pointer);
function fann_set_input_scaling_params (ann : in fann_c.fann.Pointer;
data : in fann_c.fann_train_data.Pointer;
new_input_min : in interfaces.c.c_float;
new_input_max : in interfaces.c.c_float) return interfaces.c.int;
function fann_set_output_scaling_params (ann : in fann_c.fann.Pointer;
data : in fann_c.fann_train_data.Pointer;
new_output_min : in interfaces.c.c_float;
new_output_max : in interfaces.c.c_float) return interfaces.c.int;
function fann_set_scaling_params (ann : in fann_c.fann.Pointer;
data : in fann_c.fann_train_data.Pointer;
new_input_min : in interfaces.c.c_float;
new_input_max : in interfaces.c.c_float;
new_output_min : in interfaces.c.c_float;
new_output_max : in interfaces.c.c_float) return interfaces.c.int;
function fann_clear_scaling_params (ann : in fann_c.fann.Pointer) return interfaces.c.int;
procedure fann_scale_input (ann : in fann_c.fann.Pointer;
input_vector : in fann_c.Pointers.fann_type_Pointer);
procedure fann_scale_output (ann : in fann_c.fann.Pointer;
output_vector : in fann_c.Pointers.fann_type_Pointer);
procedure fann_descale_input (ann : in fann_c.fann.Pointer;
input_vector : in fann_c.Pointers.fann_type_Pointer);
procedure fann_descale_output (ann : in fann_c.fann.Pointer;
output_vector : in fann_c.Pointers.fann_type_Pointer);
procedure fann_scale_input_train_data (train_data : in fann_c.fann_train_data.Pointer;
new_min : in fann_c.fann_type;
new_max : in fann_c.fann_type);
procedure fann_scale_output_train_data (train_data : in fann_c.fann_train_data.Pointer;
new_min : in fann_c.fann_type;
new_max : in fann_c.fann_type);
procedure fann_scale_train_data (train_data : in fann_c.fann_train_data.Pointer;
new_min : in fann_c.fann_type;
new_max : in fann_c.fann_type);
function fann_merge_train_data (data1 : in fann_c.fann_train_data.Pointer;
data2 : in fann_c.fann_train_data.Pointer) return fann_c.fann_train_data.Pointer;
function fann_duplicate_train_data (data : in fann_c.fann_train_data.Pointer) return fann_c.fann_train_data.Pointer;
function fann_subset_train_data (data : in fann_c.fann_train_data.Pointer;
pos : in interfaces.c.unsigned;
length : in interfaces.c.unsigned) return fann_c.fann_train_data.Pointer;
function fann_length_train_data (data : in fann_c.fann_train_data.Pointer) return interfaces.c.unsigned;
function fann_num_input_train_data (data : in fann_c.fann_train_data.Pointer) return interfaces.c.unsigned;
function fann_num_output_train_data (data : in fann_c.fann_train_data.Pointer) return interfaces.c.unsigned;
function fann_save_train (data : in fann_c.fann_train_data.Pointer;
filename : in interfaces.c.strings.chars_ptr) return interfaces.c.int;
function fann_save_train_to_fixed (data : in fann_c.fann_train_data.Pointer;
filename : in interfaces.c.strings.chars_ptr;
decimal_point : in interfaces.c.unsigned) return interfaces.c.int;
function fann_get_training_algorithm (ann : in fann_c.fann.Pointer) return fann_c.fann_train_enum;
procedure fann_set_training_algorithm (ann : in fann_c.fann.Pointer;
training_algorithm : in fann_c.fann_train_enum);
function fann_get_learning_rate (ann : in fann_c.fann.Pointer) return interfaces.c.c_float;
procedure fann_set_learning_rate (ann : in fann_c.fann.Pointer;
learning_rate : in interfaces.c.c_float);
function fann_get_learning_momentum (ann : in fann_c.fann.Pointer) return interfaces.c.c_float;
procedure fann_set_learning_momentum (ann : in fann_c.fann.Pointer;
learning_momentum : in interfaces.c.c_float);
function fann_get_activation_function (ann : in fann_c.fann.Pointer;
layer : in interfaces.c.int;
neuron : in interfaces.c.int) return fann_c.fann_activationfunc_enum;
procedure fann_set_activation_function (ann : in fann_c.fann.Pointer;
activation_function : in fann_c.fann_activationfunc_enum;
layer : in interfaces.c.int;
neuron : in interfaces.c.int);
procedure fann_set_activation_function_layer (ann : in fann_c.fann.Pointer;
activation_function : in fann_c.fann_activationfunc_enum;
layer : in interfaces.c.int);
procedure fann_set_activation_function_hidden (ann : in fann_c.fann.Pointer;
activation_function : in fann_c.fann_activationfunc_enum);
procedure fann_set_activation_function_output (ann : in fann_c.fann.Pointer;
activation_function : in fann_c.fann_activationfunc_enum);
function fann_get_activation_steepness (ann : in fann_c.fann.Pointer;
layer : in interfaces.c.int;
neuron : in interfaces.c.int) return fann_c.fann_type;
procedure fann_set_activation_steepness (ann : in fann_c.fann.Pointer;
steepness : in fann_c.fann_type;
layer : in interfaces.c.int;
neuron : in interfaces.c.int);
procedure fann_set_activation_steepness_layer (ann : in fann_c.fann.Pointer;
steepness : in fann_c.fann_type;
layer : in interfaces.c.int);
procedure fann_set_activation_steepness_hidden (ann : in fann_c.fann.Pointer;
steepness : in fann_c.fann_type);
procedure fann_set_activation_steepness_output (ann : in fann_c.fann.Pointer;
steepness : in fann_c.fann_type);
function fann_get_train_error_function (ann : in fann_c.fann.Pointer) return fann_c.fann_errorfunc_enum;
procedure fann_set_train_error_function (ann : in fann_c.fann.Pointer;
train_error_function : in fann_c.fann_errorfunc_enum);
function fann_get_train_stop_function (ann : in fann_c.fann.Pointer) return fann_c.fann_stopfunc_enum;
procedure fann_set_train_stop_function (ann : in fann_c.fann.Pointer;
train_stop_function : in fann_c.fann_stopfunc_enum);
function fann_get_bit_fail_limit (ann : in fann_c.fann.Pointer) return fann_c.fann_type;
procedure fann_set_bit_fail_limit (ann : in fann_c.fann.Pointer;
bit_fail_limit : in fann_c.fann_type);
procedure fann_set_callback (ann : in fann_c.fann.Pointer;
callback : in fann_c.fann_callback_type.Item);
function fann_get_quickprop_decay (ann : in fann_c.fann.Pointer) return interfaces.c.c_float;
procedure fann_set_quickprop_decay (ann : in fann_c.fann.Pointer;
quickprop_decay : in interfaces.c.c_float);
function fann_get_quickprop_mu (ann : in fann_c.fann.Pointer) return interfaces.c.c_float;
procedure fann_set_quickprop_mu (ann : in fann_c.fann.Pointer;
quickprop_mu : in interfaces.c.c_float);
function fann_get_rprop_increase_factor (ann : in fann_c.fann.Pointer) return interfaces.c.c_float;
procedure fann_set_rprop_increase_factor (ann : in fann_c.fann.Pointer;
rprop_increase_factor : in interfaces.c.c_float);
function fann_get_rprop_decrease_factor (ann : in fann_c.fann.Pointer) return interfaces.c.c_float;
procedure fann_set_rprop_decrease_factor (ann : in fann_c.fann.Pointer;
rprop_decrease_factor : in interfaces.c.c_float);
function fann_get_rprop_delta_min (ann : in fann_c.fann.Pointer) return interfaces.c.c_float;
procedure fann_set_rprop_delta_min (ann : in fann_c.fann.Pointer;
rprop_delta_min : in interfaces.c.c_float);
function fann_get_rprop_delta_max (ann : in fann_c.fann.Pointer) return interfaces.c.c_float;
procedure fann_set_rprop_delta_max (ann : in fann_c.fann.Pointer;
rprop_delta_max : in interfaces.c.c_float);
function fann_get_rprop_delta_zero (ann : in fann_c.fann.Pointer) return interfaces.c.c_float;
procedure fann_set_rprop_delta_zero (ann : in fann_c.fann.Pointer;
rprop_delta_max : in interfaces.c.c_float);
function fann_get_sarprop_weight_decay_shift (ann : in fann_c.fann.Pointer) return interfaces.c.c_float;
procedure fann_set_sarprop_weight_decay_shift (ann : in fann_c.fann.Pointer;
sarprop_weight_decay_shift : in interfaces.c.c_float);
function fann_get_sarprop_step_error_threshold_factor (ann : in fann_c.fann.Pointer) return interfaces.c.c_float;
procedure fann_set_sarprop_step_error_threshold_factor (ann : in fann_c.fann.Pointer;
sarprop_step_error_threshold_factor : in interfaces.c.c_float);
function fann_get_sarprop_step_error_shift (ann : in fann_c.fann.Pointer) return interfaces.c.c_float;
procedure fann_set_sarprop_step_error_shift (ann : in fann_c.fann.Pointer;
sarprop_step_error_shift : in interfaces.c.c_float);
function fann_get_sarprop_temperature (ann : in fann_c.fann.Pointer) return interfaces.c.c_float;
procedure fann_set_sarprop_temperature (ann : in fann_c.fann.Pointer;
sarprop_temperature : in interfaces.c.c_float);
procedure fann_cascadetrain_on_data (ann : in fann_c.fann.Pointer;
data : in fann_c.fann_train_data.Pointer;
max_neurons : in interfaces.c.unsigned;
neurons_between_reports : in interfaces.c.unsigned;
desired_error : in interfaces.c.c_float);
procedure fann_cascadetrain_on_file (ann : in fann_c.fann.Pointer;
filename : in interfaces.c.strings.chars_ptr;
max_neurons : in interfaces.c.unsigned;
neurons_between_reports : in interfaces.c.unsigned;
desired_error : in interfaces.c.c_float);
function fann_get_cascade_output_change_fraction (ann : in fann_c.fann.Pointer) return interfaces.c.c_float;
procedure fann_set_cascade_output_change_fraction (ann : in fann_c.fann.Pointer;
cascade_output_change_fraction : in interfaces.c.c_float);
function fann_get_cascade_output_stagnation_epochs (ann : in fann_c.fann.Pointer) return interfaces.c.unsigned;
procedure fann_set_cascade_output_stagnation_epochs (ann : in fann_c.fann.Pointer;
cascade_output_stagnation_epochs : in interfaces.c.unsigned);
function fann_get_cascade_candidate_change_fraction (ann : in fann_c.fann.Pointer) return interfaces.c.c_float;
procedure fann_set_cascade_candidate_change_fraction (ann : in fann_c.fann.Pointer;
cascade_candidate_change_fraction : in interfaces.c.c_float);
function fann_get_cascade_candidate_stagnation_epochs (ann : in fann_c.fann.Pointer) return interfaces.c.unsigned;
procedure fann_set_cascade_candidate_stagnation_epochs (ann : in fann_c.fann.Pointer;
cascade_candidate_stagnation_epochs : in interfaces.c.unsigned);
function fann_get_cascade_weight_multiplier (ann : in fann_c.fann.Pointer) return fann_c.fann_type;
procedure fann_set_cascade_weight_multiplier (ann : in fann_c.fann.Pointer;
cascade_weight_multiplier : in fann_c.fann_type);
function fann_get_cascade_candidate_limit (ann : in fann_c.fann.Pointer) return fann_c.fann_type;
procedure fann_set_cascade_candidate_limit (ann : in fann_c.fann.Pointer;
cascade_candidate_limit : in fann_c.fann_type);
function fann_get_cascade_max_out_epochs (ann : in fann_c.fann.Pointer) return interfaces.c.unsigned;
procedure fann_set_cascade_max_out_epochs (ann : in fann_c.fann.Pointer;
cascade_max_out_epochs : in interfaces.c.unsigned);
function fann_get_cascade_min_out_epochs (ann : in fann_c.fann.Pointer) return interfaces.c.unsigned;
procedure fann_set_cascade_min_out_epochs (ann : in fann_c.fann.Pointer;
cascade_min_out_epochs : in interfaces.c.unsigned);
function fann_get_cascade_max_cand_epochs (ann : in fann_c.fann.Pointer) return interfaces.c.unsigned;
procedure fann_set_cascade_max_cand_epochs (ann : in fann_c.fann.Pointer;
cascade_max_cand_epochs : in interfaces.c.unsigned);
function fann_get_cascade_min_cand_epochs (ann : in fann_c.fann.Pointer) return interfaces.c.unsigned;
procedure fann_set_cascade_min_cand_epochs (ann : in fann_c.fann.Pointer;
cascade_min_cand_epochs : in interfaces.c.unsigned);
function fann_get_cascade_num_candidates (ann : in fann_c.fann.Pointer) return interfaces.c.unsigned;
function fann_get_cascade_activation_functions_count (ann : in fann_c.fann.Pointer) return interfaces.c.unsigned;
function fann_get_cascade_activation_functions (ann : in fann_c.fann.Pointer) return fann_c.Pointers.fann_activationfunc_enum_Pointer;
procedure fann_set_cascade_activation_functions (ann : in fann_c.fann.Pointer;
cascade_activation_functions : in fann_c.Pointers.fann_activationfunc_enum_Pointer;
cascade_activation_functions_count : in interfaces.c.unsigned);
function fann_get_cascade_activation_steepnesses_count (ann : in fann_c.fann.Pointer) return interfaces.c.unsigned;
function fann_get_cascade_activation_steepnesses (ann : in fann_c.fann.Pointer) return fann_c.Pointers.fann_type_Pointer;
procedure fann_set_cascade_activation_steepnesses (ann : in fann_c.fann.Pointer;
cascade_activation_steepnesses : in fann_c.Pointers.fann_type_Pointer;
cascade_activation_steepnesses_count : in interfaces.c.unsigned);
function fann_get_cascade_num_candidate_groups (ann : in fann_c.fann.Pointer) return interfaces.c.unsigned;
procedure fann_set_cascade_num_candidate_groups (ann : in fann_c.fann.Pointer;
cascade_num_candidate_groups : in interfaces.c.unsigned);
function fann_create_from_file (configuration_file : in interfaces.c.strings.chars_ptr) return fann_c.fann.Pointer;
function fann_save (ann : in fann_c.fann.Pointer;
configuration_file : in interfaces.c.strings.chars_ptr) return interfaces.c.int;
function fann_save_to_fixed (ann : in fann_c.fann.Pointer;
configuration_file : in interfaces.c.strings.chars_ptr) return interfaces.c.int;
function fann_create_standard (num_layers : in interfaces.c.unsigned) return fann_c.fann.Pointer;
function fann_create_standard_array (num_layers : in interfaces.c.unsigned;
layers : in swig.pointers.unsigned_Pointer) return fann_c.fann.Pointer;
function fann_create_sparse (connection_rate : in interfaces.c.c_float;
num_layers : in interfaces.c.unsigned) return fann_c.fann.Pointer;
function fann_create_sparse_array (connection_rate : in interfaces.c.c_float;
num_layers : in interfaces.c.unsigned;
layers : in swig.pointers.unsigned_Pointer) return fann_c.fann.Pointer;
function fann_create_shortcut (num_layers : in interfaces.c.unsigned) return fann_c.fann.Pointer;
function fann_create_shortcut_array (num_layers : in interfaces.c.unsigned;
layers : in swig.pointers.unsigned_Pointer) return fann_c.fann.Pointer;
procedure fann_destroy (ann : in fann_c.fann.Pointer);
function fann_copy (ann : in fann_c.fann.Pointer) return fann_c.fann.Pointer;
function fann_run (ann : in fann_c.fann.Pointer;
input : in fann_c.Pointers.fann_type_Pointer) return fann_c.Pointers.fann_type_Pointer;
procedure fann_randomize_weights (ann : in fann_c.fann.Pointer;
min_weight : in fann_c.fann_type;
max_weight : in fann_c.fann_type);
procedure fann_init_weights (ann : in fann_c.fann.Pointer;
train_data : in fann_c.fann_train_data.Pointer);
procedure fann_print_connections (ann : in fann_c.fann.Pointer);
procedure fann_print_parameters (ann : in fann_c.fann.Pointer);
function fann_get_num_input (ann : in fann_c.fann.Pointer) return interfaces.c.unsigned;
function fann_get_num_output (ann : in fann_c.fann.Pointer) return interfaces.c.unsigned;
function fann_get_total_neurons (ann : in fann_c.fann.Pointer) return interfaces.c.unsigned;
function fann_get_total_connections (ann : in fann_c.fann.Pointer) return interfaces.c.unsigned;
function fann_get_network_type (ann : in fann_c.fann.Pointer) return fann_c.fann_nettype_enum;
function fann_get_connection_rate (ann : in fann_c.fann.Pointer) return interfaces.c.c_float;
function fann_get_num_layers (ann : in fann_c.fann.Pointer) return interfaces.c.unsigned;
procedure fann_get_layer_array (ann : in fann_c.fann.Pointer;
layers : in swig.pointers.unsigned_Pointer);
procedure fann_get_bias_array (ann : in fann_c.fann.Pointer;
bias : in swig.pointers.unsigned_Pointer);
procedure fann_get_connection_array (ann : in fann_c.fann.Pointer;
connections : in fann_c.fann_connection.Pointer);
procedure fann_set_weight_array (ann : in fann_c.fann.Pointer;
connections : in fann_c.fann_connection.Pointer;
num_connections : in interfaces.c.unsigned);
procedure fann_set_weight (ann : in fann_c.fann.Pointer;
from_neuron : in interfaces.c.unsigned;
to_neuron : in interfaces.c.unsigned;
weight : in fann_c.fann_type);
procedure fann_set_user_data (ann : in fann_c.fann.Pointer;
user_data : in swig.void_ptr);
function fann_get_user_data (ann : in fann_c.fann.Pointer) return swig.void_ptr;
private
pragma Import (C, fann_set_error_log, "fann_set_error_log");
pragma Import (C, fann_get_errno, "fann_get_errno");
pragma Import (C, fann_reset_errno, "fann_reset_errno");
pragma Import (C, fann_reset_errstr, "fann_reset_errstr");
pragma Import (C, fann_get_errstr, "fann_get_errstr");
pragma Import (C, fann_print_error, "fann_print_error");
pragma Import (C, create_train_from_callback, "create_train_from_callback");
pragma Import (C, fann_train, "fann_train");
pragma Import (C, fann_test, "fann_test");
pragma Import (C, fann_get_MSE, "fann_get_MSE");
pragma Import (C, fann_get_bit_fail, "fann_get_bit_fail");
pragma Import (C, fann_reset_MSE, "fann_reset_MSE");
pragma Import (C, fann_train_on_data, "fann_train_on_data");
pragma Import (C, fann_train_on_file, "fann_train_on_file");
pragma Import (C, fann_train_epoch, "fann_train_epoch");
pragma Import (C, fann_test_data, "fann_test_data");
pragma Import (C, fann_read_train_from_file, "fann_read_train_from_file");
pragma Import (C, fann_create_train, "fann_create_train");
pragma Import (C, fann_destroy_train, "fann_destroy_train");
pragma Import (C, fann_shuffle_train_data, "fann_shuffle_train_data");
pragma Import (C, fann_scale_train, "fann_scale_train");
pragma Import (C, fann_descale_train, "fann_descale_train");
pragma Import (C, fann_set_input_scaling_params, "fann_set_input_scaling_params");
pragma Import (C, fann_set_output_scaling_params, "fann_set_output_scaling_params");
pragma Import (C, fann_set_scaling_params, "fann_set_scaling_params");
pragma Import (C, fann_clear_scaling_params, "fann_clear_scaling_params");
pragma Import (C, fann_scale_input, "fann_scale_input");
pragma Import (C, fann_scale_output, "fann_scale_output");
pragma Import (C, fann_descale_input, "fann_descale_input");
pragma Import (C, fann_descale_output, "fann_descale_output");
pragma Import (C, fann_scale_input_train_data, "fann_scale_input_train_data");
pragma Import (C, fann_scale_output_train_data, "fann_scale_output_train_data");
pragma Import (C, fann_scale_train_data, "fann_scale_train_data");
pragma Import (C, fann_merge_train_data, "fann_merge_train_data");
pragma Import (C, fann_duplicate_train_data, "fann_duplicate_train_data");
pragma Import (C, fann_subset_train_data, "fann_subset_train_data");
pragma Import (C, fann_length_train_data, "fann_length_train_data");
pragma Import (C, fann_num_input_train_data, "fann_num_input_train_data");
pragma Import (C, fann_num_output_train_data, "fann_num_output_train_data");
pragma Import (C, fann_save_train, "fann_save_train");
pragma Import (C, fann_save_train_to_fixed, "fann_save_train_to_fixed");
pragma Import (C, fann_get_training_algorithm, "fann_get_training_algorithm");
pragma Import (C, fann_set_training_algorithm, "fann_set_training_algorithm");
pragma Import (C, fann_get_learning_rate, "fann_get_learning_rate");
pragma Import (C, fann_set_learning_rate, "fann_set_learning_rate");
pragma Import (C, fann_get_learning_momentum, "fann_get_learning_momentum");
pragma Import (C, fann_set_learning_momentum, "fann_set_learning_momentum");
pragma Import (C, fann_get_activation_function, "fann_get_activation_function");
pragma Import (C, fann_set_activation_function, "fann_set_activation_function");
pragma Import (C, fann_set_activation_function_layer, "fann_set_activation_function_layer");
pragma Import (C, fann_set_activation_function_hidden, "fann_set_activation_function_hidden");
pragma Import (C, fann_set_activation_function_output, "fann_set_activation_function_output");
pragma Import (C, fann_get_activation_steepness, "fann_get_activation_steepness");
pragma Import (C, fann_set_activation_steepness, "fann_set_activation_steepness");
pragma Import (C, fann_set_activation_steepness_layer, "fann_set_activation_steepness_layer");
pragma Import (C, fann_set_activation_steepness_hidden, "fann_set_activation_steepness_hidden");
pragma Import (C, fann_set_activation_steepness_output, "fann_set_activation_steepness_output");
pragma Import (C, fann_get_train_error_function, "fann_get_train_error_function");
pragma Import (C, fann_set_train_error_function, "fann_set_train_error_function");
pragma Import (C, fann_get_train_stop_function, "fann_get_train_stop_function");
pragma Import (C, fann_set_train_stop_function, "fann_set_train_stop_function");
pragma Import (C, fann_get_bit_fail_limit, "fann_get_bit_fail_limit");
pragma Import (C, fann_set_bit_fail_limit, "fann_set_bit_fail_limit");
pragma Import (C, fann_set_callback, "fann_set_callback");
pragma Import (C, fann_get_quickprop_decay, "fann_get_quickprop_decay");
pragma Import (C, fann_set_quickprop_decay, "fann_set_quickprop_decay");
pragma Import (C, fann_get_quickprop_mu, "fann_get_quickprop_mu");
pragma Import (C, fann_set_quickprop_mu, "fann_set_quickprop_mu");
pragma Import (C, fann_get_rprop_increase_factor, "fann_get_rprop_increase_factor");
pragma Import (C, fann_set_rprop_increase_factor, "fann_set_rprop_increase_factor");
pragma Import (C, fann_get_rprop_decrease_factor, "fann_get_rprop_decrease_factor");
pragma Import (C, fann_set_rprop_decrease_factor, "fann_set_rprop_decrease_factor");
pragma Import (C, fann_get_rprop_delta_min, "fann_get_rprop_delta_min");
pragma Import (C, fann_set_rprop_delta_min, "fann_set_rprop_delta_min");
pragma Import (C, fann_get_rprop_delta_max, "fann_get_rprop_delta_max");
pragma Import (C, fann_set_rprop_delta_max, "fann_set_rprop_delta_max");
pragma Import (C, fann_get_rprop_delta_zero, "fann_get_rprop_delta_zero");
pragma Import (C, fann_set_rprop_delta_zero, "fann_set_rprop_delta_zero");
pragma Import (C, fann_get_sarprop_weight_decay_shift, "fann_get_sarprop_weight_decay_shift");
pragma Import (C, fann_set_sarprop_weight_decay_shift, "fann_set_sarprop_weight_decay_shift");
pragma Import (C, fann_get_sarprop_step_error_threshold_factor, "fann_get_sarprop_step_error_threshold_factor");
pragma Import (C, fann_set_sarprop_step_error_threshold_factor, "fann_set_sarprop_step_error_threshold_factor");
pragma Import (C, fann_get_sarprop_step_error_shift, "fann_get_sarprop_step_error_shift");
pragma Import (C, fann_set_sarprop_step_error_shift, "fann_set_sarprop_step_error_shift");
pragma Import (C, fann_get_sarprop_temperature, "fann_get_sarprop_temperature");
pragma Import (C, fann_set_sarprop_temperature, "fann_set_sarprop_temperature");
pragma Import (C, fann_cascadetrain_on_data, "fann_cascadetrain_on_data");
pragma Import (C, fann_cascadetrain_on_file, "fann_cascadetrain_on_file");
pragma Import (C, fann_get_cascade_output_change_fraction, "fann_get_cascade_output_change_fraction");
pragma Import (C, fann_set_cascade_output_change_fraction, "fann_set_cascade_output_change_fraction");
pragma Import (C, fann_get_cascade_output_stagnation_epochs, "fann_get_cascade_output_stagnation_epochs");
pragma Import (C, fann_set_cascade_output_stagnation_epochs, "fann_set_cascade_output_stagnation_epochs");
pragma Import (C, fann_get_cascade_candidate_change_fraction, "fann_get_cascade_candidate_change_fraction");
pragma Import (C, fann_set_cascade_candidate_change_fraction, "fann_set_cascade_candidate_change_fraction");
pragma Import (C, fann_get_cascade_candidate_stagnation_epochs, "fann_get_cascade_candidate_stagnation_epochs");
pragma Import (C, fann_set_cascade_candidate_stagnation_epochs, "fann_set_cascade_candidate_stagnation_epochs");
pragma Import (C, fann_get_cascade_weight_multiplier, "fann_get_cascade_weight_multiplier");
pragma Import (C, fann_set_cascade_weight_multiplier, "fann_set_cascade_weight_multiplier");
pragma Import (C, fann_get_cascade_candidate_limit, "fann_get_cascade_candidate_limit");
pragma Import (C, fann_set_cascade_candidate_limit, "fann_set_cascade_candidate_limit");
pragma Import (C, fann_get_cascade_max_out_epochs, "fann_get_cascade_max_out_epochs");
pragma Import (C, fann_set_cascade_max_out_epochs, "fann_set_cascade_max_out_epochs");
pragma Import (C, fann_get_cascade_min_out_epochs, "fann_get_cascade_min_out_epochs");
pragma Import (C, fann_set_cascade_min_out_epochs, "fann_set_cascade_min_out_epochs");
pragma Import (C, fann_get_cascade_max_cand_epochs, "fann_get_cascade_max_cand_epochs");
pragma Import (C, fann_set_cascade_max_cand_epochs, "fann_set_cascade_max_cand_epochs");
pragma Import (C, fann_get_cascade_min_cand_epochs, "fann_get_cascade_min_cand_epochs");
pragma Import (C, fann_set_cascade_min_cand_epochs, "fann_set_cascade_min_cand_epochs");
pragma Import (C, fann_get_cascade_num_candidates, "fann_get_cascade_num_candidates");
pragma Import (C, fann_get_cascade_activation_functions_count, "fann_get_cascade_activation_functions_count");
pragma Import (C, fann_get_cascade_activation_functions, "fann_get_cascade_activation_functions");
pragma Import (C, fann_set_cascade_activation_functions, "fann_set_cascade_activation_functions");
pragma Import (C, fann_get_cascade_activation_steepnesses_count, "fann_get_cascade_activation_steepnesses_count");
pragma Import (C, fann_get_cascade_activation_steepnesses, "fann_get_cascade_activation_steepnesses");
pragma Import (C, fann_set_cascade_activation_steepnesses, "fann_set_cascade_activation_steepnesses");
pragma Import (C, fann_get_cascade_num_candidate_groups, "fann_get_cascade_num_candidate_groups");
pragma Import (C, fann_set_cascade_num_candidate_groups, "fann_set_cascade_num_candidate_groups");
pragma Import (C, fann_create_from_file, "fann_create_from_file");
pragma Import (C, fann_save, "fann_save");
pragma Import (C, fann_save_to_fixed, "fann_save_to_fixed");
pragma Import (C, fann_create_standard, "fann_create_standard");
pragma Import (C, fann_create_standard_array, "fann_create_standard_array");
pragma Import (C, fann_create_sparse, "fann_create_sparse");
pragma Import (C, fann_create_sparse_array, "fann_create_sparse_array");
pragma Import (C, fann_create_shortcut, "fann_create_shortcut");
pragma Import (C, fann_create_shortcut_array, "fann_create_shortcut_array");
pragma Import (C, fann_destroy, "fann_destroy");
pragma Import (C, fann_copy, "fann_copy");
pragma Import (C, fann_run, "fann_run");
pragma Import (C, fann_randomize_weights, "fann_randomize_weights");
pragma Import (C, fann_init_weights, "fann_init_weights");
pragma Import (C, fann_print_connections, "fann_print_connections");
pragma Import (C, fann_print_parameters, "fann_print_parameters");
pragma Import (C, fann_get_num_input, "fann_get_num_input");
pragma Import (C, fann_get_num_output, "fann_get_num_output");
pragma Import (C, fann_get_total_neurons, "fann_get_total_neurons");
pragma Import (C, fann_get_total_connections, "fann_get_total_connections");
pragma Import (C, fann_get_network_type, "fann_get_network_type");
pragma Import (C, fann_get_connection_rate, "fann_get_connection_rate");
pragma Import (C, fann_get_num_layers, "fann_get_num_layers");
pragma Import (C, fann_get_layer_array, "fann_get_layer_array");
pragma Import (C, fann_get_bias_array, "fann_get_bias_array");
pragma Import (C, fann_get_connection_array, "fann_get_connection_array");
pragma Import (C, fann_set_weight_array, "fann_set_weight_array");
pragma Import (C, fann_set_weight, "fann_set_weight");
pragma Import (C, fann_set_user_data, "fann_set_user_data");
pragma Import (C, fann_get_user_data, "fann_get_user_data");
end fann_c.Binding;
|
Library/Chart/Series/seriesSpider.asm | steakknife/pcgeos | 504 | 243685 | COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) GeoWorks 1993 -- All Rights Reserved
PROJECT: PC/GEOS
MODULE: Chart Library
FILE: seriesSpider.asm
AUTHOR: <NAME>, Aug 5, 1993
ROUTINES:
Name Description
---- -----------
REVISION HISTORY:
Name Date Description
---- ---- -----------
VM 8/ 5/93 Initial revision
DESCRIPTION:
SpiderClass
$Id: seriesSpider.asm,v 1.1 97/04/04 17:47:05 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SpiderRealize
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Realize a series of data
CALLED BY: MSG_CHART_OBJECT_REALIZE
PASS: *ds:si = SpiderClass object
ds:di = SpiderClass instance data
ds:bx = SpiderClass object (same as *ds:si)
es = segment of SpiderClass
ax = message #
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
VM 8/ 5/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SpiderRealize method dynamic SpiderClass,
MSG_CHART_OBJECT_REALIZE
uses ax,cx,dx
locals local SeriesDrawLocalVars
.enter inherit
mov cl, locals.SDLV_seriesNum
mov ax, offset SetPointInDataBlock
mov locals.SDLV_callback, ax
clr locals.SDLV_pointer
clr locals.SDLV_numPoints
; Compute the point for each category.
call SeriesDrawEachCategory
; Add the first point again on the end, so a line is drawn
; from the last point to the first point.
push si
mov cl, locals.SDLV_seriesNum
clr ch
clr dx
mov si, locals.SDLV_valueAxis
mov ax, MSG_AXIS_GET_VALUE_POSITION
call ObjCallInstanceNoLock
pop si
mov bx, ax
mov ax, cx
call SetPointCommon
call LineOrScatterCreateOrUpdatePolyline
inc locals.SDLV_seriesNum
.leave
mov di, offset SpiderClass
GOTO ObjCallSuperNoLock
SpiderRealize endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SpiderGetMaxTextBounds
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Determine the largest bounds of the text objects for
the Spider chart
CALLED BY: MSG_CHART_OBJECT_GET_MAX_TEXT_SIZE
PASS: *ds:si = SpiderClass object
ds:di = SpiderClass instance data
ds:bx = SpiderClass object (same as *ds:si)
es = segment of SpiderClass
ax = message #
cx, dx = current max
bp = series #
RETURN: cx, dx, bp updated
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
VM 8/18/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CALC_TEXT_BOUNDS_FUDGE_FACTOR equ 4
SpiderGetMaxTextBounds method dynamic SpiderClass,
MSG_CHART_OBJECT_GET_MAX_TEXT_SIZE
currentMax local Point push dx, cx
.enter
sub sp, CHART_TEXT_BUFFER_SIZE
mov di, sp
segmov es, ss
call UtilGetChartAttributes
test dx, mask CF_CATEGORY_TITLES
jz nothing
mov ax, MSG_CHART_GROUP_GET_CATEGORY_COUNT
call UtilCallChartGroup
dec cx
; Loop through each category to find the maximum height and
; width of any text.
categoryLoop:
push cx
push bp
mov dx, ss
mov bp, di
mov ax, MSG_CHART_GROUP_GET_CATEGORY_TITLE
call UtilCallChartGroup
pop bp
;
; If there's really no text there, then just return zero (XXX:
; Maybe UtilGetTextSize should do this).
;
cmp {char} es:[di], 0
je continue
call UtilGetTextSize ; cx, dx - width, height
add cx, CALC_TEXT_BOUNDS_FUDGE_FACTOR
add dx, CALC_TEXT_BOUNDS_FUDGE_FACTOR
Max ss:[currentMax].P_x, cx
Max ss:[currentMax].P_y, dx
continue:
pop cx
dec cx
jns categoryLoop
mov cx, ss:[currentMax].P_x
mov dx, ss:[currentMax].P_y
done:
add sp, CHART_TEXT_BUFFER_SIZE
.leave
ret
nothing:
clr cx, dx
jmp done
SpiderGetMaxTextBounds endm
|
solitaire_operations.ads | doug16rogers/solitaire | 1 | 1479 | <reponame>doug16rogers/solitaire<filename>solitaire_operations.ads<gh_stars>1-10
package Solitaire_Operations is
subtype Card_Value is Positive range 1 .. 54;
function Value (Card : Card_Value) return Card_Value; -- B Joker (54) returns 53; all others return value
type Deck_List is array (Card_Value) of Card_Value;
-- Given "Deck : Deck_List;"
-- Deck (Deck_First) is the top card
-- Deck (Deck_Last) is the bottom card
Standard_Deck : constant Deck_List := ( 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9,
10 => 10, 11 => 11, 12 => 12, 13 => 13, 14 => 14, 15 => 15, 16 => 16, 17 => 17, 18 => 18,
19 => 19, 20 => 20, 21 => 21, 22 => 22, 23 => 23, 24 => 24, 25 => 25, 26 => 26, 27 => 27,
28 => 28, 29 => 29, 30 => 30, 31 => 31, 32 => 32, 33 => 33, 34 => 34, 35 => 35, 36 => 36,
37 => 37, 38 => 38, 39 => 39, 40 => 40, 41 => 41, 42 => 42, 43 => 43, 44 => 44, 45 => 45,
46 => 46, 47 => 47, 48 => 48, 49 => 49, 50 => 50, 51 => 51, 52 => 52, 53 => 53, 54 => 54);
procedure Shuffle (Deck : in out Deck_List); -- Randomizes Deck
subtype Character_Value is Positive range 1 .. 26;
procedure Key (Deck : out Deck_List; Passphrase : in String);
-- Keys the deck (creates an initial deck) from a passphrase (method 3 from the web page)
-- Does not use the optional placement of jokers
-- Passphrase should contain at least 80 letters for reasonable security
procedure Generate (Deck : in out Deck_List; Key : out Character_Value); -- Generate next key value from Deck in Key
function Add (Left : Character_Value; Right : Character_Value) return Character_Value;
function Sub (Left : Character_Value; Right : Character_Value) return Character_Value;
-- Modulo 26 addition and subtraction
procedure Encrypt (Deck : in out Deck_List; Plain : in String; Crypto : out String);
procedure Decrypt (Deck : in out Deck_List; Crypto : in String; Plain : out String);
-- Encrypt and decrypt messages
--
-- Precondition: Plain'Length = Crypto'Length raises Constraint_Error if violated
end Solitaire_Operations; |
lab1/assignment_5.asm | 0000Blaze/Microprocess | 0 | 22785 | <reponame>0000Blaze/Microprocess<gh_stars>0
# ORG 8000
LDA 8050
LXI B,2233
LXI D,4455
STA 9000
MOV A,B
STA 9001
MOV A,C
STA 9002
MOV A,D
STA 9003
MOV A,E
STA 9004
HLT
# ORG 8050H
# DB 11H
|
decode/sound.asm | paulscottrobson/dungeon-campaign | 0 | 21138 | ;
; The sound machine code.
;
org $2
$0002 LDA $C030 AD 30 C0 ; toggle speaker
$0005 LDA $00 A5 00 ; get time delay
$0007 JSR $FCA8 20 A8 FC ; wait for (5*(dly*dly)+27*dly+26))*0.5 us defines frequency
$000A LDA $01 A5 01 ; sub counter zero
$000C BNE $04 D0 04 ; no, decrement it and go round again.
$000E DEC $18 C6 18 ; decrement length of note
$0010 BEQ $05 F0 05 ; if zero then exit
$0012 DEC $01 C6 01 ; decrement sub counter.
$0014 JMP $0002 4C 02 00 ; and loop round
$0017 RTS 60
;
; time period = 5.delay^2 + 27.delay + 26 / 2000000 seconds where delay is in [$00]
; one complete cycle is half this.
; frequency is the inverse of this.
; it is played 256 x [$24] times
; |
hw4/str_len_test.asm | Cyfurion/CSE220 | 0 | 2916 | # add test cases to data section
.data
str1: .asciiz "<NAME>"
.text:
main:
la $a0, str1
jal str_len
#write test code
move $a0, $v0
li $v0, 1
syscall
li $v0, 10
syscall
.include "hw4.asm"
|
src/Univalence-axiom/Isomorphism-is-equality/Simple.agda | nad/equality | 3 | 1716 | ------------------------------------------------------------------------
-- A class of algebraic structures, based on non-recursive simple
-- types, satisfies the property that isomorphic instances of a
-- structure are equal (assuming univalence)
------------------------------------------------------------------------
-- In fact, isomorphism and equality are basically the same thing, and
-- the main theorem can be instantiated with several different
-- "universes", not only the one based on simple types.
-- This module has been developed in collaboration with <NAME>.
{-# OPTIONS --without-K --safe #-}
open import Equality
module Univalence-axiom.Isomorphism-is-equality.Simple
{reflexive} (eq : ∀ {a p} → Equality-with-J a p reflexive) where
open import Bijection eq as B using (_↔_)
open Derived-definitions-and-properties eq
renaming (lower-extensionality to lower-ext)
open import Equality.Decidable-UIP eq
open import Equality.Decision-procedures eq
open import Equivalence eq as Eq using (_≃_)
open import Function-universe eq hiding (id) renaming (_∘_ to _⊚_)
open import H-level eq
open import H-level.Closure eq
open import Injection eq using (Injective)
open import Logical-equivalence using (_⇔_; module _⇔_)
open import Nat eq
open import Preimage eq
open import Prelude as P hiding (id)
open import Univalence-axiom eq
------------------------------------------------------------------------
-- Universes with some extra stuff
-- A record type packing up some assumptions.
record Assumptions : Type₃ where
field
-- Univalence at three different levels.
univ : Univalence (# 0)
univ₁ : Univalence (# 1)
univ₂ : Univalence (# 2)
abstract
-- Extensionality.
ext : ∀ {ℓ} → Extensionality ℓ (# 1)
ext = dependent-extensionality univ₂ univ₁
ext₁ : Extensionality (# 1) (# 1)
ext₁ = ext
-- Universes with some extra stuff.
record Universe : Type₃ where
-- Parameters.
field
-- Codes for something.
U : Type₂
-- Interpretation of codes.
El : U → Type₁ → Type₁
-- El a, seen as a predicate, respects equivalences.
resp : ∀ a {B C} → B ≃ C → El a B → El a C
-- The resp function respects identities (assuming univalence).
resp-id : Assumptions → ∀ a {B} (x : El a B) → resp a Eq.id x ≡ x
-- Derived definitions.
-- A predicate that specifies what it means for an equivalence to be
-- an isomorphism between two elements.
Is-isomorphism : ∀ a {B C} → B ≃ C → El a B → El a C → Type₁
Is-isomorphism a eq x y = resp a eq x ≡ y
-- An alternative definition of Is-isomorphism, defined using
-- univalence.
Is-isomorphism′ : Assumptions →
∀ a {B C} → B ≃ C → El a B → El a C → Type₁
Is-isomorphism′ ass a eq x y = subst (El a) (≃⇒≡ univ₁ eq) x ≡ y
where open Assumptions ass
-- Every element is isomorphic to itself, transported along the
-- isomorphism.
isomorphic-to-itself :
(ass : Assumptions) → let open Assumptions ass in
∀ a {B C} (eq : B ≃ C) x →
Is-isomorphism a eq x (subst (El a) (≃⇒≡ univ₁ eq) x)
isomorphic-to-itself ass a eq x =
transport-theorem (El a) (resp a) (resp-id ass a) univ₁ eq x
where open Assumptions ass
-- Is-isomorphism and Is-isomorphism′ are isomorphic (assuming
-- univalence).
isomorphism-definitions-isomorphic :
(ass : Assumptions) →
∀ a {B C} (eq : B ≃ C) {x y} →
Is-isomorphism a eq x y ↔ Is-isomorphism′ ass a eq x y
isomorphism-definitions-isomorphic ass a eq {x} {y} =
Is-isomorphism a eq x y ↝⟨ ≡⇒↝ _ $ cong (λ z → z ≡ y) $ isomorphic-to-itself ass a eq x ⟩□
Is-isomorphism′ ass a eq x y □
------------------------------------------------------------------------
-- A universe-indexed family of classes of structures
module Class (Univ : Universe) where
open Universe Univ
-- Codes for structures.
Code : Type₃
Code =
-- A code.
Σ U λ a →
-- A proposition.
(C : Type₁) → El a C → Σ Type₁ λ P →
-- The proposition should be propositional (assuming
-- univalence).
Assumptions → Is-proposition P
-- Interpretation of the codes. The elements of "Instance c" are
-- instances of the structure encoded by c.
Instance : Code → Type₂
Instance (a , P) =
-- A carrier type.
Σ Type₁ λ C →
-- An element.
Σ (El a C) λ x →
-- The element should satisfy the proposition.
proj₁ (P C x)
-- The carrier type.
Carrier : ∀ c → Instance c → Type₁
Carrier _ X = proj₁ X
-- The "element".
element : ∀ c (X : Instance c) → El (proj₁ c) (Carrier c X)
element _ X = proj₁ (proj₂ X)
abstract
-- One can prove that two instances of a structure are equal by
-- proving that the carrier types and "elements" (suitably
-- transported) are equal (assuming univalence).
equality-pair-lemma :
Assumptions →
∀ c {X Y : Instance c} →
(X ≡ Y) ↔
∃ λ (eq : Carrier c X ≡ Carrier c Y) →
subst (El (proj₁ c)) eq (element c X) ≡ element c Y
equality-pair-lemma ass (a , P) {C , x , p} {D , y , q} =
((C , x , p) ≡ (D , y , q)) ↔⟨ inverse $ Eq.≃-≡ $ Eq.↔⇒≃ Σ-assoc ⟩
(((C , x) , p) ≡ ((D , y) , q)) ↝⟨ inverse $ ignore-propositional-component (proj₂ (P D y) ass) ⟩
((C , x) ≡ (D , y)) ↝⟨ inverse B.Σ-≡,≡↔≡ ⟩□
(∃ λ (eq : C ≡ D) → subst (El a) eq x ≡ y) □
-- Structure isomorphisms.
Isomorphic : ∀ c → Instance c → Instance c → Type₁
Isomorphic (a , _) (C , x , _) (D , y , _) =
Σ (C ≃ D) λ eq → Is-isomorphism a eq x y
-- The type of isomorphisms between two instances of a structure
-- is isomorphic to the type of equalities between the same
-- instances (assuming univalence).
--
-- In short, isomorphism is isomorphic to equality.
isomorphism-is-equality :
Assumptions →
∀ c X Y → Isomorphic c X Y ↔ (X ≡ Y)
isomorphism-is-equality ass (a , P) (C , x , p) (D , y , q) =
(∃ λ (eq : C ≃ D) → resp a eq x ≡ y) ↝⟨ ∃-cong (λ eq → isomorphism-definitions-isomorphic ass a eq) ⟩
(∃ λ (eq : C ≃ D) → subst (El a) (≃⇒≡ univ₁ eq) x ≡ y) ↝⟨ inverse $
Σ-cong (≡≃≃ univ₁) (λ eq → ≡⇒↝ _ $ sym $
cong (λ eq → subst (El a) eq x ≡ y)
(_≃_.left-inverse-of (≡≃≃ univ₁) eq)) ⟩
(∃ λ (eq : C ≡ D) → subst (El a) eq x ≡ y) ↝⟨ inverse $ equality-pair-lemma ass c ⟩□
(X ≡ Y) □
where
open Assumptions ass
c : Code
c = a , P
X : Instance c
X = C , x , p
Y : Instance c
Y = D , y , q
abstract
-- The type of (lifted) isomorphisms between two instances of a
-- structure is equal to the type of equalities between the same
-- instances (assuming univalence).
--
-- In short, isomorphism is equal to equality.
isomorphic≡≡ :
Assumptions →
∀ c {X Y} → ↑ (# 2) (Isomorphic c X Y) ≡ (X ≡ Y)
isomorphic≡≡ ass c {X} {Y} =
≃⇒≡ univ₂ $ Eq.↔⇒≃ (
↑ _ (Isomorphic c X Y) ↝⟨ B.↑↔ ⟩
Isomorphic c X Y ↝⟨ isomorphism-is-equality ass c X Y ⟩□
(X ≡ Y) □)
where open Assumptions ass
-- The "first part" of the from component of
-- isomorphism-is-equality is equal to a simple function.
proj₁-from-isomorphism-is-equality :
∀ ass c X Y →
proj₁ ∘ _↔_.from (isomorphism-is-equality ass c X Y) ≡
elim (λ {X Y} _ → proj₁ X ≃ proj₁ Y) (λ _ → Eq.id)
proj₁-from-isomorphism-is-equality ass _ _ _ = apply-ext ext λ eq →
≡⇒≃ (proj₁ (Σ-≡,≡←≡ (proj₁ (Σ-≡,≡←≡
(cong (λ { (x , (y , z)) → (x , y) , z }) eq))))) ≡⟨ cong (≡⇒≃ ∘ proj₁ ∘ Σ-≡,≡←≡) $ proj₁-Σ-≡,≡←≡ _ ⟩
≡⇒≃ (proj₁ (Σ-≡,≡←≡ (cong proj₁
(cong (λ { (x , (y , z)) → (x , y) , z }) eq)))) ≡⟨ cong (≡⇒≃ ∘ proj₁ ∘ Σ-≡,≡←≡) $
cong-∘ proj₁ (λ { (x , (y , z)) → (x , y) , z }) _ ⟩
≡⇒≃ (proj₁ (Σ-≡,≡←≡ (cong (λ { (x , (y , z)) → x , y }) eq))) ≡⟨ cong ≡⇒≃ $ proj₁-Σ-≡,≡←≡ _ ⟩
≡⇒≃ (cong proj₁ (cong (λ { (x , (y , z)) → x , y }) eq)) ≡⟨ cong ≡⇒≃ $ cong-∘ proj₁ (λ { (x , (y , z)) → x , y }) eq ⟩
≡⇒≃ (cong proj₁ eq) ≡⟨ elim-cong _≃_ proj₁ _ ⟩∎
elim (λ {X Y} _ → proj₁ X ≃ proj₁ Y) (λ _ → Eq.id) eq ∎
where open Assumptions ass
-- In fact, the entire from component of isomorphism-is-equality
-- is equal to a simple function.
--
-- The proof of this lemma is somewhat complicated. A much shorter
-- proof can be constructed if El (proj₁ c) (proj₁ J) is a set
-- (see
-- Structure-identity-principle.from-isomorphism-is-equality′).
from-isomorphism-is-equality :
∀ ass c X Y →
_↔_.from (isomorphism-is-equality ass c X Y) ≡
elim (λ {X Y} _ → Isomorphic c X Y)
(λ { (_ , x , _) → Eq.id , resp-id ass (proj₁ c) x })
from-isomorphism-is-equality ass (a , P) (C , x , p) _ =
apply-ext ext (elim¹
(λ eq → Σ-map ≡⇒≃ f (Σ-≡,≡←≡ (proj₁ (Σ-≡,≡←≡
(cong (λ { (C , (x , p)) → (C , x) , p }) eq)))) ≡
elim (λ {X Y} _ → Isomorphic (a , P) X Y)
(λ { (_ , x , _) → Eq.id , resp-id ass a x })
eq)
(Σ-map ≡⇒≃ f (Σ-≡,≡←≡ (proj₁ (Σ-≡,≡←≡
(cong (_↔_.to Σ-assoc) (refl (C , x , p)))))) ≡⟨ cong (Σ-map ≡⇒≃ f ∘ Σ-≡,≡←≡ ∘ proj₁ ∘ Σ-≡,≡←≡) $ cong-refl _ ⟩
Σ-map ≡⇒≃ f (Σ-≡,≡←≡ (proj₁ (Σ-≡,≡←≡ (refl ((C , x) , p))))) ≡⟨ cong (Σ-map ≡⇒≃ f ∘ Σ-≡,≡←≡ ∘ proj₁) Σ-≡,≡←≡-refl ⟩
Σ-map ≡⇒≃ f (Σ-≡,≡←≡ (refl (C , x))) ≡⟨ cong (Σ-map ≡⇒≃ f) Σ-≡,≡←≡-refl ⟩
(≡⇒≃ (refl C) , f (subst-refl (El a) x)) ≡⟨ Σ-≡,≡→≡ ≡⇒≃-refl lemma₄ ⟩
(Eq.id , resp-id ass a x) ≡⟨ sym $ elim-refl (λ {X Y} _ → Isomorphic (a , P) X Y) _ ⟩∎
elim (λ {X Y} _ → Isomorphic (a , P) X Y)
(λ { (_ , x , _) → Eq.id , resp-id ass a x })
(refl (C , x , p)) ∎))
where
open Assumptions ass
f : ∀ {D} {y : El a D} {eq : C ≡ D} →
subst (El a) eq x ≡ y →
resp a (≡⇒≃ eq) x ≡ y
f {y = y} {eq} eq′ =
_↔_.from (≡⇒↝ _ $ cong (λ z → z ≡ y) $
transport-theorem (El a) (resp a) (resp-id ass a)
univ₁ (≡⇒≃ eq) x)
(_↔_.to (≡⇒↝ _ $ sym $ cong (λ eq → subst (El a) eq x ≡ y)
(_≃_.left-inverse-of (≡≃≃ univ₁) eq)) eq′)
lemma₁ : ∀ {ℓ} {A B C : Type ℓ} {x} (eq₁ : B ≡ A) (eq₂ : C ≡ B) →
_↔_.from (≡⇒↝ _ eq₂) (_↔_.to (≡⇒↝ _ (sym eq₁)) x) ≡
_↔_.to (≡⇒↝ _ (sym (trans eq₂ eq₁))) x
lemma₁ {x = x} eq₁ eq₂ =
_↔_.from (≡⇒↝ _ eq₂) (_↔_.to (≡⇒↝ _ (sym eq₁)) x) ≡⟨ sym $ cong (λ f → f (_↔_.to (≡⇒↝ _ (sym eq₁)) x)) $ ≡⇒↝-sym bijection ⟩
_↔_.to (≡⇒↝ _ (sym eq₂)) (_↔_.to (≡⇒↝ _ (sym eq₁)) x) ≡⟨ sym $ cong (λ f → f x) $ ≡⇒↝-trans bijection ⟩
_↔_.to (≡⇒↝ _ (trans (sym eq₁) (sym eq₂))) x ≡⟨ sym $ cong (λ eq → _↔_.to (≡⇒↝ _ eq) x) $ sym-trans _ _ ⟩∎
_↔_.to (≡⇒↝ _ (sym (trans eq₂ eq₁))) x ∎
lemma₂ : ∀ {a} {A : Type a} {x y z : A}
(x≡y : x ≡ y) (y≡z : y ≡ z) →
_↔_.to (≡⇒↝ _ (cong (λ x → x ≡ z) (sym x≡y))) y≡z ≡
trans x≡y y≡z
lemma₂ {y = y} {z} x≡y y≡z = elim₁
(λ x≡y → _↔_.to (≡⇒↝ _ (cong (λ x → x ≡ z) (sym x≡y))) y≡z ≡
trans x≡y y≡z)
(_↔_.to (≡⇒↝ _ (cong (λ x → x ≡ z) (sym (refl y)))) y≡z ≡⟨ cong (λ eq → _↔_.to (≡⇒↝ _ (cong (λ x → x ≡ z) eq)) y≡z) sym-refl ⟩
_↔_.to (≡⇒↝ _ (cong (λ x → x ≡ z) (refl y))) y≡z ≡⟨ cong (λ eq → _↔_.to (≡⇒↝ _ eq) y≡z) $ cong-refl (λ x → x ≡ z) ⟩
_↔_.to (≡⇒↝ _ (refl (y ≡ z))) y≡z ≡⟨ cong (λ f → _↔_.to f y≡z) ≡⇒↝-refl ⟩
y≡z ≡⟨ sym $ trans-reflˡ _ ⟩∎
trans (refl y) y≡z ∎)
x≡y
lemma₃ :
sym (trans (cong (λ z → z ≡ x) $
transport-theorem (El a) (resp a) (resp-id ass a)
univ₁ (≡⇒≃ (refl C)) x)
(cong (λ eq → subst (El a) eq x ≡ x)
(_≃_.left-inverse-of (≡≃≃ univ₁) (refl C)))) ≡
cong (λ z → z ≡ x) (sym $
trans (trans (cong (λ eq → resp a eq x) ≡⇒≃-refl)
(resp-id ass a x))
(sym $ subst-refl (El a) x))
lemma₃ =
sym (trans (cong (λ z → z ≡ x) _)
(cong (λ eq → subst (El a) eq x ≡ x) _)) ≡⟨ cong (λ eq → sym (trans (cong (λ z → z ≡ x)
(transport-theorem (El a) (resp a) (resp-id ass a)
univ₁ (≡⇒≃ (refl C)) x))
eq)) $ sym $
cong-∘ (λ z → z ≡ x) (λ eq → subst (El a) eq x) _ ⟩
sym (trans (cong (λ z → z ≡ x) _)
(cong (λ z → z ≡ x)
(cong (λ eq → subst (El a) eq x) _))) ≡⟨ cong sym $ sym $ cong-trans (λ z → z ≡ x) _ _ ⟩
sym (cong (λ z → z ≡ x)
(trans _ (cong (λ eq → subst (El a) eq x) _))) ≡⟨ sym $ cong-sym (λ z → z ≡ x) _ ⟩
cong (λ z → z ≡ x) (sym $
trans (transport-theorem (El a) (resp a)
(resp-id ass a) univ₁ (≡⇒≃ (refl C)) x)
(cong (λ eq → subst (El a) eq x) _)) ≡⟨ cong (λ eq → cong (λ z → z ≡ x) (sym $
trans eq (cong (λ eq → subst (El a) eq x)
(_≃_.left-inverse-of (≡≃≃ univ₁) (refl C)))))
(transport-theorem-≡⇒≃-refl (El a) (resp a) (resp-id ass a) univ₁ _) ⟩
cong (λ z → z ≡ x) (sym $
trans (trans (trans (trans (cong (λ eq → resp a eq x)
≡⇒≃-refl)
(resp-id ass a x))
(sym $ subst-refl (El a) x))
(sym $ cong (λ eq → subst (El a) eq x)
(_≃_.left-inverse-of
(≡≃≃ univ₁) (refl C))))
(cong (λ eq → subst (El a) eq x)
(_≃_.left-inverse-of (≡≃≃ univ₁) (refl C)))) ≡⟨ cong (cong (λ z → z ≡ x) ∘ sym) $
trans-[trans-sym]- _ _ ⟩∎
cong (λ z → z ≡ x) (sym $
trans (trans (cong (λ eq → resp a eq x) ≡⇒≃-refl)
(resp-id ass a x))
(sym $ subst-refl (El a) x)) ∎
lemma₄ : subst (λ eq → Is-isomorphism a eq x x) ≡⇒≃-refl
(f (subst-refl (El a) x)) ≡
resp-id ass a x
lemma₄ =
subst (λ eq → Is-isomorphism a eq x x) ≡⇒≃-refl
(f (subst-refl (El a) x)) ≡⟨ cong (subst (λ eq → Is-isomorphism a eq x x) ≡⇒≃-refl) $ lemma₁ _ _ ⟩
subst (λ eq → Is-isomorphism a eq x x) ≡⇒≃-refl
(_↔_.to (≡⇒↝ _ (sym (trans (cong (λ z → z ≡ x) $
transport-theorem (El a)
(resp a) (resp-id ass a)
univ₁ (≡⇒≃ (refl C)) x)
(cong (λ eq → subst (El a) eq x ≡ x)
(_≃_.left-inverse-of
(≡≃≃ univ₁) (refl C))))))
(subst-refl (El a) x)) ≡⟨ cong (λ eq → subst (λ eq → Is-isomorphism a eq x x) ≡⇒≃-refl
(_↔_.to (≡⇒↝ _ eq) (subst-refl (El a) x)))
lemma₃ ⟩
subst (λ eq → Is-isomorphism a eq x x) ≡⇒≃-refl
(_↔_.to (≡⇒↝ _
(cong (λ z → z ≡ x) $ sym
(trans (trans (cong (λ eq → resp a eq x)
≡⇒≃-refl)
(resp-id ass a x))
(sym $ subst-refl (El a) x))))
(subst-refl (El a) x)) ≡⟨ cong (subst (λ eq → Is-isomorphism a eq x x) ≡⇒≃-refl) $ lemma₂ _ _ ⟩
subst (λ eq → Is-isomorphism a eq x x) ≡⇒≃-refl
(trans (trans (trans (cong (λ eq → resp a eq x) ≡⇒≃-refl)
(resp-id ass a x))
(sym $ subst-refl (El a) x))
(subst-refl (El a) x)) ≡⟨ cong (λ eq → subst (λ eq → Is-isomorphism a eq x x) ≡⇒≃-refl eq)
(trans-[trans-sym]- _ _) ⟩
subst (λ eq → resp a eq x ≡ x) ≡⇒≃-refl
(trans (cong (λ eq → resp a eq x) ≡⇒≃-refl)
(resp-id ass a x)) ≡⟨ subst-∘ (λ z → z ≡ x) (λ eq → resp a eq x) _ ⟩
subst (λ z → z ≡ x)
(cong (λ eq → resp a eq x) ≡⇒≃-refl)
(trans (cong (λ eq → resp a eq x) ≡⇒≃-refl)
(resp-id ass a x)) ≡⟨ cong (λ eq → subst (λ z → z ≡ x) eq
(trans (cong (λ eq → resp a eq x) ≡⇒≃-refl)
(resp-id ass a x))) $
sym $ sym-sym _ ⟩
subst (λ z → z ≡ x)
(sym $ sym $ cong (λ eq → resp a eq x) ≡⇒≃-refl)
(trans (cong (λ eq → resp a eq x) ≡⇒≃-refl)
(resp-id ass a x)) ≡⟨ subst-trans (sym $ cong (λ eq → resp a eq x) ≡⇒≃-refl) ⟩
trans (sym $ cong (λ eq → resp a eq x) ≡⇒≃-refl)
(trans (cong (λ eq → resp a eq x) ≡⇒≃-refl)
(resp-id ass a x)) ≡⟨ sym $ trans-assoc _ _ _ ⟩
trans (trans (sym $ cong (λ eq → resp a eq x) ≡⇒≃-refl)
(cong (λ eq → resp a eq x) ≡⇒≃-refl))
(resp-id ass a x) ≡⟨ cong (λ eq → trans eq _) $ trans-symˡ _ ⟩
trans (refl (resp a Eq.id x)) (resp-id ass a x) ≡⟨ trans-reflˡ _ ⟩∎
resp-id ass a x ∎
------------------------------------------------------------------------
-- A universe of non-recursive, simple types
-- Codes for types.
infixr 20 _⊗_
infixr 15 _⊕_
infixr 10 _⇾_
data U : Type₂ where
id type : U
k : Type₁ → U
_⇾_ _⊗_ _⊕_ : U → U → U
-- Interpretation of types.
El : U → Type₁ → Type₁
El id C = C
El type C = Type
El (k A) C = A
El (a ⇾ b) C = El a C → El b C
El (a ⊗ b) C = El a C × El b C
El (a ⊕ b) C = El a C ⊎ El b C
-- El a preserves logical equivalences.
cast : ∀ a {B C} → B ⇔ C → El a B ⇔ El a C
cast id eq = eq
cast type eq = Logical-equivalence.id
cast (k A) eq = Logical-equivalence.id
cast (a ⇾ b) eq = →-cong _ (cast a eq) (cast b eq)
cast (a ⊗ b) eq = cast a eq ×-cong cast b eq
cast (a ⊕ b) eq = cast a eq ⊎-cong cast b eq
-- El a respects equivalences.
resp : ∀ a {B C} → B ≃ C → El a B → El a C
resp a eq = _⇔_.to (cast a (_≃_.logical-equivalence eq))
resp⁻¹ : ∀ a {B C} → B ≃ C → El a C → El a B
resp⁻¹ a eq = _⇔_.from (cast a (_≃_.logical-equivalence eq))
abstract
-- The cast function respects identities (assuming extensionality).
cast-id : Extensionality (# 1) (# 1) →
∀ a {B} → cast a (Logical-equivalence.id {A = B}) ≡
Logical-equivalence.id
cast-id ext id = refl _
cast-id ext type = refl _
cast-id ext (k A) = refl _
cast-id ext (a ⇾ b) = cong₂ (→-cong _) (cast-id ext a) (cast-id ext b)
cast-id ext (a ⊗ b) = cong₂ _×-cong_ (cast-id ext a) (cast-id ext b)
cast-id ext (a ⊕ b) =
cast a Logical-equivalence.id ⊎-cong cast b Logical-equivalence.id ≡⟨ cong₂ _⊎-cong_ (cast-id ext a) (cast-id ext b) ⟩
Logical-equivalence.id ⊎-cong Logical-equivalence.id ≡⟨ cong₂ (λ f g → record { to = f; from = g })
(apply-ext ext [ refl ∘ inj₁ , refl ∘ inj₂ ])
(apply-ext ext [ refl ∘ inj₁ , refl ∘ inj₂ ]) ⟩∎
Logical-equivalence.id ∎
resp-id : Extensionality (# 1) (# 1) →
∀ a {B} x → resp a (Eq.id {A = B}) x ≡ x
resp-id ext a x = cong (λ eq → _⇔_.to eq x) $ cast-id ext a
-- The universe above is a "universe with some extra stuff".
simple : Universe
simple = record
{ U = U
; El = El
; resp = resp
; resp-id = resp-id ∘ Assumptions.ext₁
}
-- Let us use this universe below.
open Universe simple using (Is-isomorphism)
open Class simple
-- An alternative definition of "being an isomorphism".
--
-- This definition is in bijective correspondence with Is-isomorphism
-- (see below).
Is-isomorphism′ : ∀ a {B C} → B ≃ C → El a B → El a C → Type₁
Is-isomorphism′ id eq = λ x y → _≃_.to eq x ≡ y
Is-isomorphism′ type eq = λ X Y → ↑ _ (X ≃ Y)
Is-isomorphism′ (k A) eq = λ x y → x ≡ y
Is-isomorphism′ (a ⇾ b) eq = Is-isomorphism′ a eq →-rel
Is-isomorphism′ b eq
Is-isomorphism′ (a ⊗ b) eq = Is-isomorphism′ a eq ×-rel
Is-isomorphism′ b eq
Is-isomorphism′ (a ⊕ b) eq = Is-isomorphism′ a eq ⊎-rel
Is-isomorphism′ b eq
-- An alternative definition of Isomorphic, using Is-isomorphism′
-- instead of Is-isomorphism.
Isomorphic′ : ∀ c → Instance c → Instance c → Type₁
Isomorphic′ (a , _) (C , x , _) (D , y , _) =
Σ (C ≃ D) λ eq → Is-isomorphism′ a eq x y
-- El a preserves equivalences (assuming extensionality).
--
-- Note that _≃_.logical-equivalence (cast≃ ext a eq) is
-- (definitionally) equal to cast a (_≃_.logical-equivalence eq); this
-- property is used below.
cast≃ : Extensionality (# 1) (# 1) →
∀ a {B C} → B ≃ C → El a B ≃ El a C
cast≃ ext a {B} {C} B≃C = Eq.↔⇒≃ record
{ surjection = record
{ logical-equivalence = cast a B⇔C
; right-inverse-of = to∘from
}
; left-inverse-of = from∘to
}
where
B⇔C = _≃_.logical-equivalence B≃C
cst : ∀ a → El a B ≃ El a C
cst id = B≃C
cst type = Eq.id
cst (k A) = Eq.id
cst (a ⇾ b) = →-cong ext (cst a) (cst b)
cst (a ⊗ b) = cst a ×-cong cst b
cst (a ⊕ b) = cst a ⊎-cong cst b
abstract
-- The projection _≃_.logical-equivalence is homomorphic with
-- respect to cast a/cst a.
casts-related : ∀ a →
cast a (_≃_.logical-equivalence B≃C) ≡
_≃_.logical-equivalence (cst a)
casts-related id = refl _
casts-related type = refl _
casts-related (k A) = refl _
casts-related (a ⇾ b) = cong₂ (→-cong _) (casts-related a)
(casts-related b)
casts-related (a ⊗ b) = cong₂ _×-cong_ (casts-related a)
(casts-related b)
casts-related (a ⊕ b) = cong₂ _⊎-cong_ (casts-related a)
(casts-related b)
to∘from : ∀ x → _⇔_.to (cast a B⇔C) (_⇔_.from (cast a B⇔C) x) ≡ x
to∘from x =
_⇔_.to (cast a B⇔C) (_⇔_.from (cast a B⇔C) x) ≡⟨ cong₂ (λ f g → f (g x)) (cong _⇔_.to $ casts-related a)
(cong _⇔_.from $ casts-related a) ⟩
_≃_.to (cst a) (_≃_.from (cst a) x) ≡⟨ _≃_.right-inverse-of (cst a) x ⟩∎
x ∎
from∘to : ∀ x → _⇔_.from (cast a B⇔C) (_⇔_.to (cast a B⇔C) x) ≡ x
from∘to x =
_⇔_.from (cast a B⇔C) (_⇔_.to (cast a B⇔C) x) ≡⟨ cong₂ (λ f g → f (g x)) (cong _⇔_.from $ casts-related a)
(cong _⇔_.to $ casts-related a) ⟩
_≃_.from (cst a) (_≃_.to (cst a) x) ≡⟨ _≃_.left-inverse-of (cst a) x ⟩∎
x ∎
private
logical-equivalence-cast≃ :
(ext : Extensionality (# 1) (# 1)) →
∀ a {B C} (eq : B ≃ C) →
_≃_.logical-equivalence (cast≃ ext a eq) ≡
cast a (_≃_.logical-equivalence eq)
logical-equivalence-cast≃ _ _ _ = refl _
-- Alternative, shorter definition of cast≃, based on univalence.
--
-- This proof does not (at the time of writing) have the property that
-- _≃_.logical-equivalence (cast≃′ ass a eq) is definitionally equal
-- to cast a (_≃_.logical-equivalence eq).
cast≃′ : Assumptions → ∀ a {B C} → B ≃ C → El a B ≃ El a C
cast≃′ ass a eq =
Eq.⟨ resp a eq
, resp-is-equivalence (El a) (resp a) (resp-id ext₁ a) univ₁ eq
⟩
where open Assumptions ass
abstract
-- The two definitions of "being an isomorphism" are "isomorphic"
-- (in bijective correspondence), assuming univalence.
is-isomorphism-isomorphic :
Assumptions →
∀ a {B C x y} (eq : B ≃ C) →
Is-isomorphism a eq x y ↔ Is-isomorphism′ a eq x y
is-isomorphism-isomorphic ass id {x = x} {y} eq =
(_≃_.to eq x ≡ y) □
is-isomorphism-isomorphic ass type {x = X} {Y} eq =
(X ≡ Y) ↔⟨ ≡≃≃ univ ⟩
(X ≃ Y) ↝⟨ inverse B.↑↔ ⟩□
↑ _ (X ≃ Y) □
where open Assumptions ass
is-isomorphism-isomorphic ass (k A) {x = x} {y} eq =
(x ≡ y) □
is-isomorphism-isomorphic ass (a ⇾ b) {x = f} {g} eq =
(resp b eq ∘ f ∘ resp⁻¹ a eq ≡ g) ↝⟨ ∘from≡↔≡∘to ext₁ (cast≃ ext₁ a eq) ⟩
(resp b eq ∘ f ≡ g ∘ resp a eq) ↔⟨ inverse $ Eq.extensionality-isomorphism ext₁ ⟩
(∀ x → resp b eq (f x) ≡ g (resp a eq x)) ↝⟨ ∀-cong ext₁ (λ x →
∀-intro (λ y _ → resp b eq (f x) ≡ g y) ext₁) ⟩
(∀ x y → resp a eq x ≡ y → resp b eq (f x) ≡ g y) ↝⟨ ∀-cong ext₁ (λ _ → ∀-cong ext₁ λ _ →
→-cong ext₁ (is-isomorphism-isomorphic ass a eq)
(is-isomorphism-isomorphic ass b eq)) ⟩□
(∀ x y → Is-isomorphism′ a eq x y →
Is-isomorphism′ b eq (f x) (g y)) □
where open Assumptions ass
is-isomorphism-isomorphic ass (a ⊗ b) {x = x , u} {y , v} eq =
((resp a eq x , resp b eq u) ≡ (y , v)) ↝⟨ inverse ≡×≡↔≡ ⟩
(resp a eq x ≡ y × resp b eq u ≡ v) ↝⟨ is-isomorphism-isomorphic ass a eq ×-cong
is-isomorphism-isomorphic ass b eq ⟩□
Is-isomorphism′ a eq x y × Is-isomorphism′ b eq u v □
where open Assumptions ass
is-isomorphism-isomorphic ass (a ⊕ b) {x = inj₁ x} {inj₁ y} eq =
(inj₁ (resp a eq x) ≡ inj₁ y) ↝⟨ inverse B.≡↔inj₁≡inj₁ ⟩
(resp a eq x ≡ y) ↝⟨ is-isomorphism-isomorphic ass a eq ⟩□
Is-isomorphism′ a eq x y □
where open Assumptions ass
is-isomorphism-isomorphic ass (a ⊕ b) {x = inj₂ x} {inj₂ y} eq =
(inj₂ (resp b eq x) ≡ inj₂ y) ↝⟨ inverse B.≡↔inj₂≡inj₂ ⟩
(resp b eq x ≡ y) ↝⟨ is-isomorphism-isomorphic ass b eq ⟩□
Is-isomorphism′ b eq x y □
where open Assumptions ass
is-isomorphism-isomorphic ass (a ⊕ b) {x = inj₁ x} {inj₂ y} eq =
(inj₁ _ ≡ inj₂ _) ↝⟨ inverse $ B.⊥↔uninhabited ⊎.inj₁≢inj₂ ⟩□
⊥ □
is-isomorphism-isomorphic ass (a ⊕ b) {x = inj₂ x} {inj₁ y} eq =
(inj₂ _ ≡ inj₁ _) ↝⟨ inverse $ B.⊥↔uninhabited (⊎.inj₁≢inj₂ ∘ sym) ⟩□
⊥ □
-- The two definitions of isomorphism are "isomorphic" (in bijective
-- correspondence), assuming univalence.
isomorphic-isomorphic :
Assumptions →
∀ c X Y →
Isomorphic c X Y ↔ Isomorphic′ c X Y
isomorphic-isomorphic ass (a , _) (C , x , _) (D , y , _) =
Σ (C ≃ D) (λ eq → Is-isomorphism a eq x y) ↝⟨ ∃-cong (λ eq → is-isomorphism-isomorphic ass a eq) ⟩
Σ (C ≃ D) (λ eq → Is-isomorphism′ a eq x y) □
------------------------------------------------------------------------
-- An example: monoids
monoid : Code
monoid =
-- Binary operation.
(id ⇾ id ⇾ id) ⊗
-- Identity.
id ,
λ { C (_∙_ , e) →
-- The carrier type is a set.
(Is-set C ×
-- Left and right identity laws.
(∀ x → (e ∙ x) ≡ x) ×
(∀ x → (x ∙ e) ≡ x) ×
-- Associativity.
(∀ x y z → (x ∙ (y ∙ z)) ≡ ((x ∙ y) ∙ z))) ,
-- The laws are propositional (assuming extensionality).
λ ass → let open Assumptions ass in
[inhabited⇒+]⇒+ 0 λ { (C-set , _) →
×-closure 1 (H-level-propositional ext₁ 2)
(×-closure 1 (Π-closure ext₁ 1 λ _ →
C-set)
(×-closure 1 (Π-closure ext₁ 1 λ _ →
C-set)
(Π-closure ext₁ 1 λ _ →
Π-closure ext₁ 1 λ _ →
Π-closure ext₁ 1 λ _ →
C-set))) }}
-- The interpretation of the code is reasonable.
Instance-monoid :
Instance monoid
≡
Σ Type₁ λ C →
Σ ((C → C → C) × C) λ { (_∙_ , e) →
Is-set C ×
(∀ x → (e ∙ x) ≡ x) ×
(∀ x → (x ∙ e) ≡ x) ×
(∀ x y z → (x ∙ (y ∙ z)) ≡ ((x ∙ y) ∙ z)) }
Instance-monoid = refl _
-- The notion of isomorphism that we get is also reasonable.
Isomorphic-monoid :
∀ {C₁ _∙₁_ e₁ laws₁ C₂ _∙₂_ e₂ laws₂} →
Isomorphic monoid (C₁ , (_∙₁_ , e₁) , laws₁)
(C₂ , (_∙₂_ , e₂) , laws₂)
≡
Σ (C₁ ≃ C₂) λ eq → let open _≃_ eq in
((λ x y → to (from x ∙₁ from y)) , to e₁) ≡ (_∙₂_ , e₂)
Isomorphic-monoid = refl _
-- Note that this definition of isomorphism is isomorphic to a more
-- standard one (assuming extensionality).
Isomorphism-monoid-isomorphic-to-standard :
Extensionality (# 1) (# 1) →
∀ {C₁ _∙₁_ e₁ laws₁ C₂ _∙₂_ e₂ laws₂} →
Isomorphic monoid (C₁ , (_∙₁_ , e₁) , laws₁)
(C₂ , (_∙₂_ , e₂) , laws₂)
↔
Σ (C₁ ↔ C₂) λ eq → let open _↔_ eq in
(∀ x y → to (x ∙₁ y) ≡ (to x ∙₂ to y)) ×
to e₁ ≡ e₂
Isomorphism-monoid-isomorphic-to-standard ext
{C₁} {_∙₁_} {e₁} {laws₁} {C₂} {_∙₂_} {e₂} =
(Σ (C₁ ≃ C₂) λ eq → let open _≃_ eq in
((λ x y → to (from x ∙₁ from y)) , to e₁) ≡ (_∙₂_ , e₂)) ↝⟨ inverse $ Σ-cong (Eq.↔↔≃ ext (proj₁ laws₁)) (λ _ → _ □) ⟩
(Σ (C₁ ↔ C₂) λ eq → let open _↔_ eq in
((λ x y → to (from x ∙₁ from y)) , to e₁) ≡ (_∙₂_ , e₂)) ↝⟨ inverse $ ∃-cong (λ _ → ≡×≡↔≡) ⟩
(Σ (C₁ ↔ C₂) λ eq → let open _↔_ eq in
(λ x y → to (from x ∙₁ from y)) ≡ _∙₂_ ×
to e₁ ≡ e₂) ↔⟨ inverse $ ∃-cong (λ _ → Eq.extensionality-isomorphism ext ×-cong (_ □)) ⟩
(Σ (C₁ ↔ C₂) λ eq → let open _↔_ eq in
(∀ x → (λ y → to (from x ∙₁ from y)) ≡ _∙₂_ x) ×
to e₁ ≡ e₂) ↔⟨ inverse $ ∃-cong (λ _ →
∀-cong ext (λ _ → Eq.extensionality-isomorphism ext)
×-cong
(_ □)) ⟩
(Σ (C₁ ↔ C₂) λ eq → let open _↔_ eq in
(∀ x y → to (from x ∙₁ from y) ≡ (x ∙₂ y)) ×
to e₁ ≡ e₂) ↔⟨ inverse $ ∃-cong (λ eq →
Π-cong ext (Eq.↔⇒≃ eq) (λ x → Π-cong ext (Eq.↔⇒≃ eq) (λ y →
≡⇒≃ $ sym $ cong₂ (λ u v → _↔_.to eq (u ∙₁ v) ≡
(_↔_.to eq x ∙₂ _↔_.to eq y))
(_↔_.left-inverse-of eq x)
(_↔_.left-inverse-of eq y)))
×-cong
(_ □)) ⟩□
(Σ (C₁ ↔ C₂) λ eq → let open _↔_ eq in
(∀ x y → to (x ∙₁ y) ≡ (to x ∙₂ to y)) ×
to e₁ ≡ e₂) □
------------------------------------------------------------------------
-- An example: posets
poset : Code
poset =
-- The ordering relation.
(id ⇾ id ⇾ type) ,
λ C _≤_ →
-- The carrier type is a set.
(Is-set C ×
-- The ordering relation is (pointwise) propositional.
(∀ x y → Is-proposition (x ≤ y)) ×
-- Reflexivity.
(∀ x → x ≤ x) ×
-- Transitivity.
(∀ x y z → x ≤ y → y ≤ z → x ≤ z) ×
-- Antisymmetry.
(∀ x y → x ≤ y → y ≤ x → x ≡ y)) ,
λ ass → let open Assumptions ass in
[inhabited⇒+]⇒+ 0 λ { (C-set , ≤-prop , _) →
×-closure 1 (H-level-propositional ext₁ 2)
(×-closure 1 (Π-closure ext₁ 1 λ _ →
Π-closure (lower-ext (# 0) _ ext₁) 1 λ _ →
H-level-propositional (lower-ext _ _ ext₁) 1)
(×-closure 1 (Π-closure (lower-ext (# 0) _ ext₁) 1 λ _ →
≤-prop _ _)
(×-closure 1 (Π-closure ext₁ 1 λ _ →
Π-closure ext₁ 1 λ _ →
Π-closure (lower-ext (# 0) _ ext₁) 1 λ _ →
Π-closure (lower-ext _ _ ext₁) 1 λ _ →
Π-closure (lower-ext _ _ ext₁) 1 λ _ →
≤-prop _ _)
(Π-closure ext₁ 1 λ _ →
Π-closure ext₁ 1 λ _ →
Π-closure ext 1 λ _ →
Π-closure ext 1 λ _ →
C-set)))) }
-- The interpretation of the code is reasonable. (Except, perhaps,
-- that the carrier type lives in Type₁ but the codomain of the
-- ordering relation is Type. In the corresponding example in
-- Univalence-axiom.Isomorphism-is-equality.Simple.Variant the carrier
-- type lives in Type.)
Instance-poset :
Instance poset
≡
Σ Type₁ λ C →
Σ (C → C → Type) λ _≤_ →
Is-set C ×
(∀ x y → Is-proposition (x ≤ y)) ×
(∀ x → x ≤ x) ×
(∀ x y z → x ≤ y → y ≤ z → x ≤ z) ×
(∀ x y → x ≤ y → y ≤ x → x ≡ y)
Instance-poset = refl _
-- The notion of isomorphism that we get is also reasonable. It is the
-- usual notion of "order isomorphism", with two (main) differences:
--
-- * Equivalences are used instead of bijections. However,
-- equivalences and bijections coincide for sets (assuming
-- extensionality).
--
-- * We use equality, (λ a b → from a ≤₁ from b) ≡ _≤₂_, instead of
-- "iff", ∀ a b → (a ≤₁ b) ⇔ (to a ≤₂ to b). However, the ordering
-- relation is pointwise propositional, so these two expressions are
-- equal (assuming univalence).
Isomorphic-poset :
∀ {C₁ _≤₁_ laws₁ C₂ _≤₂_ laws₂} →
Isomorphic poset (C₁ , _≤₁_ , laws₁) (C₂ , _≤₂_ , laws₂)
≡
Σ (C₁ ≃ C₂) λ eq → let open _≃_ eq in
(λ a b → from a ≤₁ from b) ≡ _≤₂_
Isomorphic-poset = refl _
-- We can prove that this notion of isomorphism is isomorphic to the
-- usual notion of order isomorphism (assuming univalence).
Isomorphism-poset-isomorphic-to-order-isomorphism :
Assumptions →
∀ {C₁ _≤₁_ laws₁ C₂ _≤₂_ laws₂} →
Isomorphic poset (C₁ , _≤₁_ , laws₁) (C₂ , _≤₂_ , laws₂)
↔
Σ (C₁ ↔ C₂) λ eq → let open _↔_ eq in
∀ x y → (x ≤₁ y) ⇔ (to x ≤₂ to y)
Isomorphism-poset-isomorphic-to-order-isomorphism ass
{C₁} {_≤₁_} {laws₁} {C₂} {_≤₂_} {laws₂} =
(Σ (C₁ ≃ C₂) λ eq → let open _≃_ eq in
(λ a b → from a ≤₁ from b) ≡ _≤₂_) ↝⟨ inverse $ Σ-cong (Eq.↔↔≃ ext₁ (proj₁ laws₁)) (λ _ → _ □) ⟩
(Σ (C₁ ↔ C₂) λ eq → let open _↔_ eq in
(λ a b → from a ≤₁ from b) ≡ _≤₂_) ↔⟨ inverse $ ∃-cong (λ _ → Eq.extensionality-isomorphism ext₁) ⟩
(Σ (C₁ ↔ C₂) λ eq → let open _↔_ eq in
(∀ a → (λ b → from a ≤₁ from b) ≡ _≤₂_ a)) ↔⟨ inverse $ ∃-cong (λ _ → ∀-cong ext₁ λ _ → Eq.extensionality-isomorphism ext₁) ⟩
(Σ (C₁ ↔ C₂) λ eq → let open _↔_ eq in
(∀ a b → (from a ≤₁ from b) ≡ (a ≤₂ b))) ↔⟨ inverse $ ∃-cong (λ eq →
Π-cong ext₁ (Eq.↔⇒≃ eq) λ a → Π-cong ext₁ (Eq.↔⇒≃ eq) λ b →
≡⇒≃ $ sym $ cong₂ (λ x y → (x ≤₁ y) ≡ (_↔_.to eq a ≤₂ _↔_.to eq b))
(_↔_.left-inverse-of eq a)
(_↔_.left-inverse-of eq b)) ⟩
(Σ (C₁ ↔ C₂) λ eq → let open _↔_ eq in
(∀ a b → (a ≤₁ b) ≡ (to a ≤₂ to b))) ↔⟨ ∃-cong (λ _ → ∀-cong ext₁ λ _ → ∀-cong ext₁ λ _ → ≡≃≃ univ) ⟩
(Σ (C₁ ↔ C₂) λ eq → let open _↔_ eq in
(∀ a b → (a ≤₁ b) ≃ (to a ≤₂ to b))) ↝⟨ inverse $ ∃-cong (λ _ → ∀-cong ext₁ λ _ → ∀-cong (lower-ext (# 0) _ ext₁) λ _ →
Eq.⇔↔≃ (lower-ext _ _ ext₁) (proj₁ (proj₂ laws₁) _ _)
(proj₁ (proj₂ laws₂) _ _)) ⟩□
(Σ (C₁ ↔ C₂) λ eq → let open _↔_ eq in
(∀ a b → (a ≤₁ b) ⇔ (to a ≤₂ to b))) □
where open Assumptions ass
-- The previous lemma implies that we can prove that the notion of
-- isomorphism that we get is /equal/ to the usual notion of order
-- isomorphism (assuming univalence).
Isomorphism-poset-equal-to-order-isomorphism :
Assumptions →
∀ {C₁ _≤₁_ laws₁ C₂ _≤₂_ laws₂} →
Isomorphic poset (C₁ , _≤₁_ , laws₁) (C₂ , _≤₂_ , laws₂)
≡
Σ (C₁ ↔ C₂) λ eq → let open _↔_ eq in
∀ x y → (x ≤₁ y) ⇔ (to x ≤₂ to y)
Isomorphism-poset-equal-to-order-isomorphism ass
{laws₁ = laws₁} {laws₂ = laws₂} =
≃⇒≡ univ₁ $ Eq.↔⇒≃ $
Isomorphism-poset-isomorphic-to-order-isomorphism ass
{laws₁ = laws₁} {laws₂ = laws₂}
where open Assumptions ass
-- The notion of isomorphism that we get if we use Is-isomorphism′
-- instead of Is-isomorphism is also reasonable.
Isomorphic′-poset :
∀ {C₁ _≤₁_ laws₁ C₂ _≤₂_ laws₂} →
Isomorphic′ poset (C₁ , _≤₁_ , laws₁) (C₂ , _≤₂_ , laws₂)
≡
Σ (C₁ ≃ C₂) λ eq → let open _≃_ eq in
∀ a b → to a ≡ b → ∀ c d → to c ≡ d → ↑ _ ((a ≤₁ c) ≃ (b ≤₂ d))
Isomorphic′-poset = refl _
-- If we had defined isomorphism using Is-isomorphism′ instead of
-- Is-isomorphism, then we could have proved
-- Isomorphism-poset-isomorphic-to-order-isomorphism without assuming
-- univalence, but instead assuming extensionality.
Isomorphism′-poset-isomorphic-to-order-isomorphism :
Extensionality (# 1) (# 1) →
∀ {C₁ _≤₁_ laws₁ C₂ _≤₂_ laws₂} →
Isomorphic′ poset (C₁ , _≤₁_ , laws₁) (C₂ , _≤₂_ , laws₂)
↔
Σ (C₁ ↔ C₂) λ eq → let open _↔_ eq in
∀ x y → (x ≤₁ y) ⇔ (to x ≤₂ to y)
Isomorphism′-poset-isomorphic-to-order-isomorphism ext
{C₁} {_≤₁_} {laws₁} {C₂} {_≤₂_} {laws₂} =
(Σ (C₁ ≃ C₂) λ eq → let open _≃_ eq in
∀ a b → to a ≡ b → ∀ c d → to c ≡ d → ↑ _ ((a ≤₁ c) ≃ (b ≤₂ d))) ↝⟨ inverse $ Σ-cong (Eq.↔↔≃ ext (proj₁ laws₁)) (λ _ → _ □) ⟩
(Σ (C₁ ↔ C₂) λ eq → let open _↔_ eq in
∀ a b → to a ≡ b → ∀ c d → to c ≡ d → ↑ _ ((a ≤₁ c) ≃ (b ≤₂ d))) ↝⟨ inverse $ ∃-cong (λ _ → ∀-cong ext λ _ →
∀-intro (λ _ _ → _) ext) ⟩
(Σ (C₁ ↔ C₂) λ eq → let open _↔_ eq in
∀ a c d → to c ≡ d → ↑ _ ((a ≤₁ c) ≃ (to a ≤₂ d))) ↝⟨ inverse $ ∃-cong (λ _ → ∀-cong ext λ _ → ∀-cong ext λ _ →
∀-intro (λ _ _ → _) ext) ⟩
(Σ (C₁ ↔ C₂) λ eq → let open _↔_ eq in
∀ a c → ↑ _ ((a ≤₁ c) ≃ (to a ≤₂ to c))) ↝⟨ ∃-cong (λ _ → ∀-cong ext λ _ → ∀-cong ext λ _ →
B.↑↔) ⟩
(Σ (C₁ ↔ C₂) λ eq → let open _↔_ eq in
∀ a c → (a ≤₁ c) ≃ (to a ≤₂ to c)) ↝⟨ inverse $ ∃-cong (λ _ →
∀-cong ext λ _ → ∀-cong (lower-ext (# 0) _ ext) λ _ →
Eq.⇔↔≃ (lower-ext _ _ ext) (proj₁ (proj₂ laws₁) _ _)
(proj₁ (proj₂ laws₂) _ _)) ⟩□
(Σ (C₁ ↔ C₂) λ eq → let open _↔_ eq in
∀ a c → (a ≤₁ c) ⇔ (to a ≤₂ to c)) □
------------------------------------------------------------------------
-- An example: discrete fields
private
-- Some lemmas used below.
0* :
{C : Type₁}
(_+_ : C → C → C)
(0# : C)
(_*_ : C → C → C)
(1# : C)
(-_ : C → C) →
(∀ x y z → (x + (y + z)) ≡ ((x + y) + z)) →
(∀ x y → (x + y) ≡ (y + x)) →
(∀ x y → (x * y) ≡ (y * x)) →
(∀ x y z → (x * (y + z)) ≡ ((x * y) + (x * z))) →
(∀ x → (x + 0#) ≡ x) →
(∀ x → (x * 1#) ≡ x) →
(∀ x → (x + (- x)) ≡ 0#) →
∀ x → (0# * x) ≡ 0#
0* _+_ 0# _*_ 1# -_ +-assoc +-comm *-comm *+ +0 *1 +- x =
(0# * x) ≡⟨ sym $ +0 _ ⟩
((0# * x) + 0#) ≡⟨ cong (_+_ _) $ sym $ +- _ ⟩
((0# * x) + (x + (- x))) ≡⟨ +-assoc _ _ _ ⟩
(((0# * x) + x) + (- x)) ≡⟨ cong (λ y → y + _) lemma ⟩
(x + (- x)) ≡⟨ +- x ⟩∎
0# ∎
where
lemma =
((0# * x) + x) ≡⟨ cong (_+_ _) $ sym $ *1 _ ⟩
((0# * x) + (x * 1#)) ≡⟨ cong (λ y → y + (x * 1#)) $ *-comm _ _ ⟩
((x * 0#) + (x * 1#)) ≡⟨ sym $ *+ _ _ _ ⟩
(x * (0# + 1#)) ≡⟨ cong (_*_ _) $ +-comm _ _ ⟩
(x * (1# + 0#)) ≡⟨ cong (_*_ _) $ +0 _ ⟩
(x * 1#) ≡⟨ *1 _ ⟩∎
x ∎
dec-lemma₁ :
{C : Type₁}
(_+_ : C → C → C)
(0# : C)
(-_ : C → C) →
(∀ x y z → (x + (y + z)) ≡ ((x + y) + z)) →
(∀ x y → (x + y) ≡ (y + x)) →
(∀ x → (x + 0#) ≡ x) →
(∀ x → (x + (- x)) ≡ 0#) →
(∀ x → Dec (x ≡ 0#)) →
Decidable (_≡_ {A = C})
dec-lemma₁ _+_ 0# -_ +-assoc +-comm +0 +- dec-0 x y =
⊎-map (λ x-y≡0 → x ≡⟨ sym $ +0 _ ⟩
(x + 0#) ≡⟨ cong (_+_ _) $ sym $ +- _ ⟩
(x + (y + (- y))) ≡⟨ cong (_+_ _) $ +-comm _ _ ⟩
(x + ((- y) + y)) ≡⟨ +-assoc _ _ _ ⟩
((x + (- y)) + y) ≡⟨ cong (λ x → x + _) x-y≡0 ⟩
(0# + y) ≡⟨ +-comm _ _ ⟩
(y + 0#) ≡⟨ +0 _ ⟩∎
y ∎)
(λ x-y≢0 x≡y → x-y≢0 ((x + (- y)) ≡⟨ cong (_+_ _ ∘ -_) $ sym x≡y ⟩
(x + (- x)) ≡⟨ +- _ ⟩∎
0# ∎))
(dec-0 (x + (- y)))
dec-lemma₂ :
{C : Type₁}
(_+_ : C → C → C)
(0# : C)
(_*_ : C → C → C)
(1# : C)
(-_ : C → C) →
(_⁻¹ : C → ↑ (# 1) ⊤ ⊎ C) →
(∀ x y z → (x + (y + z)) ≡ ((x + y) + z)) →
(∀ x y → (x + y) ≡ (y + x)) →
(∀ x y → (x * y) ≡ (y * x)) →
(∀ x y z → (x * (y + z)) ≡ ((x * y) + (x * z))) →
(∀ x → (x + 0#) ≡ x) →
(∀ x → (x * 1#) ≡ x) →
(∀ x → (x + (- x)) ≡ 0#) →
0# ≢ 1# →
(∀ x → (x ⁻¹) ≡ inj₁ (lift tt) → x ≡ 0#) →
(∀ x y → (x ⁻¹) ≡ inj₂ y → (x * y) ≡ 1#) →
Decidable (_≡_ {A = C})
dec-lemma₂ _+_ 0# _*_ 1# -_ _⁻¹ +-assoc +-comm *-comm
*+ +0 *1 +- 0≢1 ⁻¹₁ ⁻¹₂ =
dec-lemma₁ _+_ 0# -_ +-assoc +-comm +0 +- dec-0
where
dec-0 : ∀ z → Dec (z ≡ 0#)
dec-0 z with z ⁻¹ | ⁻¹₁ z | ⁻¹₂ z
... | inj₁ _ | hyp | _ = inj₁ (hyp (refl _))
... | inj₂ z⁻¹ | _ | hyp = inj₂ (λ z≡0 →
0≢1 (0# ≡⟨ sym $ 0* _+_ 0# _*_ 1# -_ +-assoc +-comm *-comm *+ +0 *1 +- _ ⟩
(0# * z⁻¹) ≡⟨ cong (λ x → x * _) $ sym z≡0 ⟩
(z * z⁻¹) ≡⟨ hyp z⁻¹ (refl _) ⟩∎
1# ∎))
dec-lemma₃ :
{C : Type₁}
(_+_ : C → C → C)
(0# : C)
(-_ : C → C) →
(_*_ : C → C → C)
(1# : C) →
(∀ x y z → (x + (y + z)) ≡ ((x + y) + z)) →
(∀ x y z → (x * (y * z)) ≡ ((x * y) * z)) →
(∀ x y → (x + y) ≡ (y + x)) →
(∀ x y → (x * y) ≡ (y * x)) →
(∀ x → (x + 0#) ≡ x) →
(∀ x → (x * 1#) ≡ x) →
(∀ x → (x + (- x)) ≡ 0#) →
(∀ x → (∃ λ y → (x * y) ≡ 1#) Xor (x ≡ 0#)) →
Decidable (_≡_ {A = C})
dec-lemma₃ _+_ 0# -_ _*_ 1# +-assoc *-assoc +-comm *-comm +0 *1 +-
inv-xor =
dec-lemma₁ _+_ 0# -_ +-assoc +-comm +0 +-
(λ x → [ inj₂ ∘ proj₂ , inj₁ ∘ proj₂ ] (inv-xor x))
*-injective :
{C : Type₁}
(_*_ : C → C → C)
(1# : C) →
(∀ x y z → (x * (y * z)) ≡ ((x * y) * z)) →
(∀ x y → (x * y) ≡ (y * x)) →
(∀ x → (x * 1#) ≡ x) →
∀ x → ∃ (λ y → (x * y) ≡ 1#) → Injective (_*_ x)
*-injective _*_ 1# *-assoc *-comm *1 x (x⁻¹ , xx⁻¹≡1)
{y₁} {y₂} xy₁≡xy₂ =
y₁ ≡⟨ lemma y₁ ⟩
(x⁻¹ * (x * y₁)) ≡⟨ cong (_*_ x⁻¹) xy₁≡xy₂ ⟩
(x⁻¹ * (x * y₂)) ≡⟨ sym $ lemma y₂ ⟩∎
y₂ ∎
where
lemma : ∀ y → y ≡ (x⁻¹ * (x * y))
lemma y =
y ≡⟨ sym $ *1 _ ⟩
(y * 1#) ≡⟨ *-comm _ _ ⟩
(1# * y) ≡⟨ cong (λ x → x * y) $ sym xx⁻¹≡1 ⟩
((x * x⁻¹) * y) ≡⟨ cong (λ x → x * y) $ *-comm _ _ ⟩
((x⁻¹ * x) * y) ≡⟨ sym $ *-assoc _ _ _ ⟩∎
(x⁻¹ * (x * y)) ∎
inverse-propositional :
{C : Type₁}
(_*_ : C → C → C)
(1# : C) →
(∀ x y z → (x * (y * z)) ≡ ((x * y) * z)) →
(∀ x y → (x * y) ≡ (y * x)) →
(∀ x → (x * 1#) ≡ x) →
Is-set C →
∀ x → Is-proposition (∃ λ y → (x * y) ≡ 1#)
inverse-propositional _*_ 1# *-assoc *-comm *1 C-set x =
[inhabited⇒+]⇒+ 0 λ { inv →
injection⁻¹-propositional
(record { to = _*_ x
; injective = *-injective _*_ 1# *-assoc *-comm *1 x inv
})
C-set 1# }
proposition-lemma₁ :
Extensionality (# 1) (# 1) →
{C : Type₁}
(0# : C)
(_*_ : C → C → C)
(1# : C) →
(∀ x y z → (x * (y * z)) ≡ ((x * y) * z)) →
(∀ x y → (x * y) ≡ (y * x)) →
(∀ x → (x * 1#) ≡ x) →
Is-proposition (((x y : C) → x ≡ y ⊎ x ≢ y) ×
(∀ x → x ≢ 0# → ∃ λ y → (x * y) ≡ 1#))
proposition-lemma₁ ext 0# _*_ 1# *-assoc *-comm *1 =
[inhabited⇒+]⇒+ 0 λ { (dec , _) →
let C-set = decidable⇒set dec in
×-closure 1 (Π-closure ext 1 λ _ →
Π-closure ext 1 λ _ →
Dec-closure-propositional (lower-ext (# 0) _ ext)
C-set)
(Π-closure ext 1 λ x →
Π-closure ext 1 λ _ →
inverse-propositional _*_ 1# *-assoc *-comm *1
C-set x) }
proposition-lemma₂ :
Extensionality (# 1) (# 1) →
{C : Type₁}
(_+_ : C → C → C)
(0# : C)
(-_ : C → C) →
(_*_ : C → C → C)
(1# : C) →
(∀ x y z → (x + (y + z)) ≡ ((x + y) + z)) →
(∀ x y z → (x * (y * z)) ≡ ((x * y) * z)) →
(∀ x y → (x + y) ≡ (y + x)) →
(∀ x y → (x * y) ≡ (y * x)) →
(∀ x → (x + 0#) ≡ x) →
(∀ x → (x * 1#) ≡ x) →
(∀ x → (x + (- x)) ≡ 0#) →
Is-proposition (∀ x → (∃ λ y → (x * y) ≡ 1#) Xor (x ≡ 0#))
proposition-lemma₂ ext _+_ 0# -_ _*_ 1# +-assoc *-assoc +-comm *-comm
+0 *1 +- =
[inhabited⇒+]⇒+ 0 λ inv-xor →
let C-set = decidable⇒set $
dec-lemma₃ _+_ 0# -_ _*_ 1# +-assoc *-assoc
+-comm *-comm +0 *1 +- inv-xor in
Π-closure ext 1 λ x →
Xor-closure-propositional (lower-ext (# 0) _ ext)
(inverse-propositional _*_ 1# *-assoc *-comm *1 C-set x)
C-set
proposition-lemma₃ :
Extensionality (# 1) (# 1) →
{C : Type₁}
(_+_ : C → C → C)
(0# : C)
(_*_ : C → C → C)
(1# : C) →
(-_ : C → C) →
(∀ x y z → (x + (y + z)) ≡ ((x + y) + z)) →
(∀ x y z → (x * (y * z)) ≡ ((x * y) * z)) →
(∀ x y → (x + y) ≡ (y + x)) →
(∀ x y → (x * y) ≡ (y * x)) →
(∀ x y z → (x * (y + z)) ≡ ((x * y) + (x * z))) →
(∀ x → (x + 0#) ≡ x) →
(∀ x → (x * 1#) ≡ x) →
(∀ x → (x + (- x)) ≡ 0#) →
0# ≢ 1# →
Is-proposition (Σ (C → ↑ _ ⊤ ⊎ C) λ _⁻¹ →
(∀ x → (x ⁻¹) ≡ inj₁ (lift tt) → x ≡ 0#) ×
(∀ x y → (x ⁻¹) ≡ inj₂ y → (x * y) ≡ 1#))
proposition-lemma₃ ext {C} _+_ 0# _*_ 1# -_ +-assoc *-assoc
+-comm *-comm *+ +0 *1 +- 0≢1
(inv , inv₁ , inv₂) (inv′ , inv₁′ , inv₂′) =
_↔_.to (ignore-propositional-component
(×-closure 1 (Π-closure ext 1 λ _ →
Π-closure ext 1 λ _ →
C-set)
(Π-closure ext 1 λ _ →
Π-closure ext 1 λ _ →
Π-closure ext 1 λ _ →
C-set)))
(apply-ext ext inv≡inv′)
where
C-set : Is-set C
C-set = decidable⇒set $
dec-lemma₂ _+_ 0# _*_ 1# -_ inv +-assoc +-comm
*-comm *+ +0 *1 +- 0≢1 inv₁ inv₂
01-lemma : ∀ x y → x ≡ 0# → (x * y) ≡ 1# → ⊥
01-lemma x y x≡0 xy≡1 = 0≢1 (
0# ≡⟨ sym $ 0* _+_ 0# _*_ 1# -_ +-assoc +-comm *-comm *+ +0 *1 +- _ ⟩
(0# * y) ≡⟨ cong (λ x → x * _) $ sym x≡0 ⟩
(x * y) ≡⟨ xy≡1 ⟩∎
1# ∎)
inv≡inv′ : ∀ x → inv x ≡ inv′ x
inv≡inv′ x with inv x | inv₁ x | inv₂ x
| inv′ x | inv₁′ x | inv₂′ x
... | inj₁ _ | _ | _ | inj₁ _ | _ | _ = refl _
... | inj₂ x⁻¹ | _ | hyp | inj₁ _ | hyp′ | _ = ⊥-elim $ 01-lemma x x⁻¹ (hyp′ (refl _)) (hyp x⁻¹ (refl _))
... | inj₁ _ | hyp | _ | inj₂ x⁻¹ | _ | hyp′ = ⊥-elim $ 01-lemma x x⁻¹ (hyp (refl _)) (hyp′ x⁻¹ (refl _))
... | inj₂ x⁻¹ | _ | hyp | inj₂ x⁻¹′ | _ | hyp′ =
cong inj₂ $ *-injective _*_ 1# *-assoc *-comm *1 x
(x⁻¹ , hyp x⁻¹ (refl _))
((x * x⁻¹) ≡⟨ hyp x⁻¹ (refl _) ⟩
1# ≡⟨ sym $ hyp′ x⁻¹′ (refl _) ⟩∎
(x * x⁻¹′) ∎)
-- Discrete fields.
discrete-field : Code
discrete-field =
-- Addition.
(id ⇾ id ⇾ id) ⊗
-- Zero.
id ⊗
-- Multiplication.
(id ⇾ id ⇾ id) ⊗
-- One.
id ⊗
-- Minus.
(id ⇾ id) ⊗
-- Multiplicative inverse (a partial operation).
(id ⇾ k (↑ _ ⊤) ⊕ id) ,
λ { C (_+_ , 0# , _*_ , 1# , -_ , _⁻¹) →
(-- Associativity.
(∀ x y z → (x + (y + z)) ≡ ((x + y) + z)) ×
(∀ x y z → (x * (y * z)) ≡ ((x * y) * z)) ×
-- Commutativity.
(∀ x y → (x + y) ≡ (y + x)) ×
(∀ x y → (x * y) ≡ (y * x)) ×
-- Distributivity.
(∀ x y z → (x * (y + z)) ≡ ((x * y) + (x * z))) ×
-- Identity laws.
(∀ x → (x + 0#) ≡ x) ×
(∀ x → (x * 1#) ≡ x) ×
-- Additive inverse law.
(∀ x → (x + (- x)) ≡ 0#) ×
-- Zero and one are distinct.
0# ≢ 1# ×
-- Multiplicative inverse laws.
(∀ x → (x ⁻¹) ≡ inj₁ (lift tt) → x ≡ 0#) ×
(∀ x y → (x ⁻¹) ≡ inj₂ y → (x * y) ≡ 1#)) ,
λ ass → let open Assumptions ass in
[inhabited⇒+]⇒+ 0 λ { (+-assoc , _ , +-comm , *-comm , *+ , +0 ,
*1 , +- , 0≢1 , ⁻¹₁ , ⁻¹₂) →
let C-set : Is-set C
C-set = decidable⇒set $
dec-lemma₂ _+_ 0# _*_ 1# -_ _⁻¹ +-assoc +-comm
*-comm *+ +0 *1 +- 0≢1 ⁻¹₁ ⁻¹₂
in
×-closure 1 (Π-closure ext₁ 1 λ _ →
Π-closure ext₁ 1 λ _ →
Π-closure ext₁ 1 λ _ →
C-set)
(×-closure 1 (Π-closure ext₁ 1 λ _ →
Π-closure ext₁ 1 λ _ →
Π-closure ext₁ 1 λ _ →
C-set)
(×-closure 1 (Π-closure ext₁ 1 λ _ →
Π-closure ext₁ 1 λ _ →
C-set)
(×-closure 1 (Π-closure ext₁ 1 λ _ →
Π-closure ext₁ 1 λ _ →
C-set)
(×-closure 1 (Π-closure ext₁ 1 λ _ →
Π-closure ext₁ 1 λ _ →
Π-closure ext₁ 1 λ _ →
C-set)
(×-closure 1 (Π-closure ext₁ 1 λ _ →
C-set)
(×-closure 1 (Π-closure ext₁ 1 λ _ →
C-set)
(×-closure 1 (Π-closure ext₁ 1 λ _ →
C-set)
(×-closure 1 (Π-closure (lower-ext (# 0) (# 1) ext₁) 1 λ _ →
⊥-propositional)
(×-closure 1 (Π-closure ext₁ 1 λ _ →
Π-closure ext₁ 1 λ _ →
C-set)
(Π-closure ext₁ 1 λ _ →
Π-closure ext₁ 1 λ _ →
Π-closure ext₁ 1 λ _ →
C-set)))))))))) }}
-- The interpretation of the code is reasonable.
Instance-discrete-field :
Instance discrete-field
≡
Σ Type₁ λ C →
Σ ((C → C → C) × C × (C → C → C) × C × (C → C) × (C → ↑ _ ⊤ ⊎ C))
λ { (_+_ , 0# , _*_ , 1# , -_ , _⁻¹) →
(∀ x y z → (x + (y + z)) ≡ ((x + y) + z)) ×
(∀ x y z → (x * (y * z)) ≡ ((x * y) * z)) ×
(∀ x y → (x + y) ≡ (y + x)) ×
(∀ x y → (x * y) ≡ (y * x)) ×
(∀ x y z → (x * (y + z)) ≡ ((x * y) + (x * z))) ×
(∀ x → (x + 0#) ≡ x) ×
(∀ x → (x * 1#) ≡ x) ×
(∀ x → (x + (- x)) ≡ 0#) ×
0# ≢ 1# ×
(∀ x → (x ⁻¹) ≡ inj₁ (lift tt) → x ≡ 0#) ×
(∀ x y → (x ⁻¹) ≡ inj₂ y → (x * y) ≡ 1#) }
Instance-discrete-field = refl _
-- The notion of isomorphism that we get is reasonable.
Isomorphic-discrete-field :
∀ {C₁ _+₁_ 0₁ _*₁_ 1₁ -₁_ _⁻¹₁ laws₁
C₂ _+₂_ 0₂ _*₂_ 1₂ -₂_ _⁻¹₂ laws₂} →
Isomorphic discrete-field
(C₁ , (_+₁_ , 0₁ , _*₁_ , 1₁ , -₁_ , _⁻¹₁) , laws₁)
(C₂ , (_+₂_ , 0₂ , _*₂_ , 1₂ , -₂_ , _⁻¹₂) , laws₂)
≡
Σ (C₁ ≃ C₂) λ eq → let open _≃_ eq in
((λ x y → to (from x +₁ from y)) ,
to 0₁ ,
(λ x y → to (from x *₁ from y)) ,
to 1₁ ,
(λ x → to (-₁ from x)) ,
(λ x → ⊎-map P.id to (from x ⁻¹₁))) ≡
(_+₂_ , 0₂ , _*₂_ , 1₂ , -₂_ , _⁻¹₂)
Isomorphic-discrete-field = refl _
-- The definitions of discrete field introduced below do not have an
-- inverse operator in their signature, so the derived notion of
-- isomorphism is perhaps not obviously identical to the one above.
-- However, the two notions of isomorphism are isomorphic (assuming
-- extensionality).
Isomorphic-discrete-field-isomorphic-to-one-without-⁻¹ :
Extensionality (# 1) (# 1) →
∀ {C₁ _+₁_ 0₁ _*₁_ 1₁ -₁_ _⁻¹₁ laws₁
C₂ _+₂_ 0₂ _*₂_ 1₂ -₂_ _⁻¹₂ laws₂} →
Isomorphic discrete-field
(C₁ , (_+₁_ , 0₁ , _*₁_ , 1₁ , -₁_ , _⁻¹₁) , laws₁)
(C₂ , (_+₂_ , 0₂ , _*₂_ , 1₂ , -₂_ , _⁻¹₂) , laws₂)
↔
Σ (C₁ ≃ C₂) λ eq → let open _≃_ eq in
((λ x y → to (from x +₁ from y)) ,
to 0₁ ,
(λ x y → to (from x *₁ from y)) ,
to 1₁ ,
(λ x → to (-₁ from x))) ≡
(_+₂_ , 0₂ , _*₂_ , 1₂ , -₂_)
Isomorphic-discrete-field-isomorphic-to-one-without-⁻¹ ext
{C₁} {_+₁_} {0₁} {_*₁_} {1₁} { -₁_} {_⁻¹₁}
{_ , _ , _ , _ , _ , _ , _ , _ , _ , ⁻¹₁₁ , ⁻¹₁₂}
{C₂} {_+₂_} {0₂} {_*₂_} {1₂} { -₂_} {_⁻¹₂}
{+₂-assoc , *₂-assoc , +₂-comm , *₂-comm , *₂+₂ , +₂0₂ , *₂1₂ , +₂-₂ ,
0₂≢1₂ , ⁻¹₂₁ , ⁻¹₂₂} =
∃-cong λ eq → let open _≃_ eq in
(((λ x y → to (from x +₁ from y)) ,
to 0₁ ,
(λ x y → to (from x *₁ from y)) ,
to 1₁ ,
(λ x → to (-₁ from x)) ,
(λ x → ⊎-map P.id to (from x ⁻¹₁))) ≡
(_+₂_ , 0₂ , _*₂_ , 1₂ , -₂_ , _⁻¹₂)) ↝⟨ inverse (≡×≡↔≡ ⊚ ((_ □) ×-cong
≡×≡↔≡ ⊚ ((_ □) ×-cong
≡×≡↔≡ ⊚ ((_ □) ×-cong
≡×≡↔≡ ⊚ ((_ □) ×-cong
≡×≡↔≡))))) ⟩
((λ x y → to (from x +₁ from y)) ≡ _+₂_ ×
to 0₁ ≡ 0₂ ×
(λ x y → to (from x *₁ from y)) ≡ _*₂_ ×
to 1₁ ≡ 1₂ ×
(λ x → to (-₁ from x)) ≡ -₂_ ×
(λ x → ⊎-map P.id to (from x ⁻¹₁)) ≡ _⁻¹₂) ↝⟨ (∃-cong λ _ →
∃-cong λ 0-homo →
∃-cong λ *-homo →
∃-cong λ 1-homo →
∃-cong λ _ →
_⇔_.to contractible⇔↔⊤ $ propositional⇒inhabited⇒contractible
⁻¹-set
(⁻¹-homo eq 0-homo *-homo 1-homo)) ⟩
((λ x y → to (from x +₁ from y)) ≡ _+₂_ ×
to 0₁ ≡ 0₂ ×
(λ x y → to (from x *₁ from y)) ≡ _*₂_ ×
to 1₁ ≡ 1₂ ×
(λ x → to (-₁ from x)) ≡ -₂_ ×
⊤) ↝⟨ (_ □) ×-cong (_ □) ×-cong (_ □) ×-cong (_ □) ×-cong ×-right-identity ⟩
((λ x y → to (from x +₁ from y)) ≡ _+₂_ ×
to 0₁ ≡ 0₂ ×
(λ x y → to (from x *₁ from y)) ≡ _*₂_ ×
to 1₁ ≡ 1₂ ×
(λ x → to (-₁ from x)) ≡ -₂_) ↝⟨ ≡×≡↔≡ ⊚ ((_ □) ×-cong
≡×≡↔≡ ⊚ ((_ □) ×-cong
≡×≡↔≡ ⊚ ((_ □) ×-cong
≡×≡↔≡))) ⟩
(((λ x y → to (from x +₁ from y)) ,
to 0₁ ,
(λ x y → to (from x *₁ from y)) ,
to 1₁ ,
(λ x → to (-₁ from x))) ≡
(_+₂_ , 0₂ , _*₂_ , 1₂ , -₂_)) □
where
⁻¹-set : Is-set (C₂ → ↑ _ ⊤ ⊎ C₂)
⁻¹-set =
Π-closure ext 2 λ _ →
⊎-closure 0 (↑-closure 2 (mono (≤-step (≤-step ≤-refl))
⊤-contractible))
(decidable⇒set $
dec-lemma₂ _+₂_ 0₂ _*₂_ 1₂ -₂_ _⁻¹₂ +₂-assoc +₂-comm
*₂-comm *₂+₂ +₂0₂ *₂1₂ +₂-₂ 0₂≢1₂
⁻¹₂₁ ⁻¹₂₂)
⁻¹-homo :
(eq : C₁ ≃ C₂) → let open _≃_ eq in
to 0₁ ≡ 0₂ →
(λ x y → to (from x *₁ from y)) ≡ _*₂_ →
to 1₁ ≡ 1₂ →
(λ x → ⊎-map P.id to (from x ⁻¹₁)) ≡ _⁻¹₂
⁻¹-homo eq 0-homo *-homo 1-homo = cong proj₁ $
proposition-lemma₃
ext _+₂_ 0₂ _*₂_ 1₂ -₂_
+₂-assoc *₂-assoc +₂-comm *₂-comm
*₂+₂ +₂0₂ *₂1₂ +₂-₂ 0₂≢1₂
( (λ x → ⊎-map P.id to (from x ⁻¹₁))
, (λ x x⁻¹₁≡₁ →
let lemma =
(from x ⁻¹₁) ≡⟨ [_,_] {C = λ z → z ≡ ⊎-map P.id from (⊎-map P.id to z)}
(λ _ → refl _)
(λ _ → cong inj₂ $ sym $ left-inverse-of _)
(from x ⁻¹₁) ⟩
⊎-map P.id from (⊎-map P.id to (from x ⁻¹₁)) ≡⟨ cong (⊎-map P.id from) x⁻¹₁≡₁ ⟩∎
inj₁ (lift tt) ∎
in
x ≡⟨ sym $ right-inverse-of x ⟩
to (from x) ≡⟨ cong to (⁻¹₁₁ (from x) lemma) ⟩
to 0₁ ≡⟨ 0-homo ⟩∎
0₂ ∎)
, (λ x y x⁻¹₁≡y →
let lemma =
(from x ⁻¹₁) ≡⟨ [_,_] {C = λ z → z ≡ ⊎-map P.id from (⊎-map P.id to z)}
(λ _ → refl _)
(λ _ → cong inj₂ $ sym $ left-inverse-of _)
(from x ⁻¹₁) ⟩
⊎-map P.id from (⊎-map P.id to (from x ⁻¹₁)) ≡⟨ cong (⊎-map P.id from) x⁻¹₁≡y ⟩∎
inj₂ (from y) ∎
in
(x *₂ y) ≡⟨ sym $ cong (λ _*_ → x * y) *-homo ⟩
to (from x *₁ from y) ≡⟨ cong to $ ⁻¹₁₂ (from x) (from y) lemma ⟩
to 1₁ ≡⟨ 1-homo ⟩∎
1₂ ∎)
)
(_⁻¹₂ , ⁻¹₂₁ , ⁻¹₂₂)
where open _≃_ eq
-- In "Varieties of Constructive Mathematics" Bridges and Richman
-- define a discrete field as a commutative ring with 1, decidable
-- equality, and satisfying the property that non-zero elements are
-- invertible. What follows is—assuming that I interpreted the
-- informal definition correctly—an encoding of this definition,
-- restricted so that the discrete fields are non-trivial, and using
-- equality as the equality relation, and denial inequality as the
-- inequality relation.
discrete-field-à-la-Bridges-and-Richman : Code
discrete-field-à-la-Bridges-and-Richman =
-- Addition.
(id ⇾ id ⇾ id) ⊗
-- Zero.
id ⊗
-- Multiplication.
(id ⇾ id ⇾ id) ⊗
-- One.
id ⊗
-- Minus.
(id ⇾ id) ,
λ { C (_+_ , 0# , _*_ , 1# , -_) →
(-- Associativity.
(∀ x y z → (x + (y + z)) ≡ ((x + y) + z)) ×
(∀ x y z → (x * (y * z)) ≡ ((x * y) * z)) ×
-- Commutativity.
(∀ x y → (x + y) ≡ (y + x)) ×
(∀ x y → (x * y) ≡ (y * x)) ×
-- Distributivity.
(∀ x y z → (x * (y + z)) ≡ ((x * y) + (x * z))) ×
-- Identity laws.
(∀ x → (x + 0#) ≡ x) ×
(∀ x → (x * 1#) ≡ x) ×
-- Additive inverse law.
(∀ x → (x + (- x)) ≡ 0#) ×
-- Zero and one are distinct.
0# ≢ 1# ×
-- Decidable equality.
((x y : C) → x ≡ y ⊎ x ≢ y) ×
-- Non-zero elements are invertible.
(∀ x → x ≢ 0# → ∃ λ y → (x * y) ≡ 1#)) ,
λ ass → let open Assumptions ass in
[inhabited⇒+]⇒+ 0 λ { (_ , *-assoc , _ , *-comm , _ , _ , *1 ,
_ , _ , dec , _) →
let C-set : Is-set C
C-set = decidable⇒set dec
in
×-closure 1 (Π-closure ext₁ 1 λ _ →
Π-closure ext₁ 1 λ _ →
Π-closure ext₁ 1 λ _ →
C-set)
(×-closure 1 (Π-closure ext₁ 1 λ _ →
Π-closure ext₁ 1 λ _ →
Π-closure ext₁ 1 λ _ →
C-set)
(×-closure 1 (Π-closure ext₁ 1 λ _ →
Π-closure ext₁ 1 λ _ →
C-set)
(×-closure 1 (Π-closure ext₁ 1 λ _ →
Π-closure ext₁ 1 λ _ →
C-set)
(×-closure 1 (Π-closure ext₁ 1 λ _ →
Π-closure ext₁ 1 λ _ →
Π-closure ext₁ 1 λ _ →
C-set)
(×-closure 1 (Π-closure ext₁ 1 λ _ →
C-set)
(×-closure 1 (Π-closure ext₁ 1 λ _ →
C-set)
(×-closure 1 (Π-closure ext₁ 1 λ _ →
C-set)
(×-closure 1 (Π-closure (lower-ext (# 0) (# 1) ext₁) 1 λ _ →
⊥-propositional)
(proposition-lemma₁ ext₁ 0# _*_ 1#
*-assoc *-comm *1))))))))) }}
-- The two discrete field definitions above are isomorphic (assuming
-- extensionality).
Instance-discrete-field-isomorphic-to-Bridges-and-Richman's :
Extensionality (# 1) (# 1) →
Instance discrete-field
↔
Instance discrete-field-à-la-Bridges-and-Richman
Instance-discrete-field-isomorphic-to-Bridges-and-Richman's ext =
∃-cong λ C →
(Σ ((C → C → C) × C × (C → C → C) × C × (C → C) × (C → ↑ _ ⊤ ⊎ C))
λ { (_+_ , 0# , _*_ , 1# , -_ , _⁻¹) →
(∀ x y z → (x + (y + z)) ≡ ((x + y) + z)) ×
(∀ x y z → (x * (y * z)) ≡ ((x * y) * z)) ×
(∀ x y → (x + y) ≡ (y + x)) ×
(∀ x y → (x * y) ≡ (y * x)) ×
(∀ x y z → (x * (y + z)) ≡ ((x * y) + (x * z))) ×
(∀ x → (x + 0#) ≡ x) ×
(∀ x → (x * 1#) ≡ x) ×
(∀ x → (x + (- x)) ≡ 0#) ×
0# ≢ 1# ×
(∀ x → (x ⁻¹) ≡ inj₁ (lift tt) → x ≡ 0#) ×
(∀ x y → (x ⁻¹) ≡ inj₂ y → (x * y) ≡ 1#)}) ↝⟨ lemma₁ _ _ _ _ _ _ _ ⟩
(Σ ((C → C → C) × C × (C → C → C) × C × (C → C))
λ { (_+_ , 0# , _*_ , 1# , -_) →
Σ (C → ↑ _ ⊤ ⊎ C) λ _⁻¹ →
(∀ x y z → (x + (y + z)) ≡ ((x + y) + z)) ×
(∀ x y z → (x * (y * z)) ≡ ((x * y) * z)) ×
(∀ x y → (x + y) ≡ (y + x)) ×
(∀ x y → (x * y) ≡ (y * x)) ×
(∀ x y z → (x * (y + z)) ≡ ((x * y) + (x * z))) ×
(∀ x → (x + 0#) ≡ x) ×
(∀ x → (x * 1#) ≡ x) ×
(∀ x → (x + (- x)) ≡ 0#) ×
0# ≢ 1# ×
(∀ x → (x ⁻¹) ≡ inj₁ (lift tt) → x ≡ 0#) ×
(∀ x y → (x ⁻¹) ≡ inj₂ y → (x * y) ≡ 1#)}) ↝⟨ ∃-cong (λ _ → lemma₂ _ _ _ _ _ _ _ _ _ _ _) ⟩
(Σ (((C → C → C) × C × (C → C → C) × C × (C → C)))
λ { (_+_ , 0# , _*_ , 1# , -_) →
(∀ x y z → (x + (y + z)) ≡ ((x + y) + z)) ×
(∀ x y z → (x * (y * z)) ≡ ((x * y) * z)) ×
(∀ x y → (x + y) ≡ (y + x)) ×
(∀ x y → (x * y) ≡ (y * x)) ×
(∀ x y z → (x * (y + z)) ≡ ((x * y) + (x * z))) ×
(∀ x → (x + 0#) ≡ x) ×
(∀ x → (x * 1#) ≡ x) ×
(∀ x → (x + (- x)) ≡ 0#) ×
0# ≢ 1# ×
Σ (C → ↑ _ ⊤ ⊎ C) λ _⁻¹ →
(∀ x → (x ⁻¹) ≡ inj₁ (lift tt) → x ≡ 0#) ×
(∀ x y → (x ⁻¹) ≡ inj₂ y → (x * y) ≡ 1#) }) ↝⟨ (∃-cong λ { (_+_ , 0# , _*_ , 1# , -_) →
∃-cong λ +-assoc →
∃-cong λ *-assoc →
∃-cong λ +-comm →
∃-cong λ *-comm →
∃-cong λ *+ →
∃-cong λ +0 →
∃-cong λ *1 →
∃-cong λ +- →
∃-cong λ 0≢1 →
main-lemma C _+_ 0# _*_ 1# -_
+-assoc *-assoc +-comm *-comm *+ +0 *1 +- 0≢1 }) ⟩□
(Σ ((C → C → C) × C × (C → C → C) × C × (C → C))
λ { (_+_ , 0# , _*_ , 1# , -_) →
(∀ x y z → (x + (y + z)) ≡ ((x + y) + z)) ×
(∀ x y z → (x * (y * z)) ≡ ((x * y) * z)) ×
(∀ x y → (x + y) ≡ (y + x)) ×
(∀ x y → (x * y) ≡ (y * x)) ×
(∀ x y z → (x * (y + z)) ≡ ((x * y) + (x * z))) ×
(∀ x → (x + 0#) ≡ x) ×
(∀ x → (x * 1#) ≡ x) ×
(∀ x → (x + (- x)) ≡ 0#) ×
0# ≢ 1# ×
((x y : C) → x ≡ y ⊎ x ≢ y) ×
(∀ x → x ≢ 0# → ∃ λ y → (x * y) ≡ 1#) }) □
where
main-lemma :
(C : Type₁)
(_+_ : C → C → C)
(0# : C)
(_*_ : C → C → C)
(1# : C)
(-_ : C → C) →
(∀ x y z → (x + (y + z)) ≡ ((x + y) + z)) →
(∀ x y z → (x * (y * z)) ≡ ((x * y) * z)) →
(∀ x y → (x + y) ≡ (y + x)) →
(∀ x y → (x * y) ≡ (y * x)) →
(∀ x y z → (x * (y + z)) ≡ ((x * y) + (x * z))) →
(∀ x → (x + 0#) ≡ x) →
(∀ x → (x * 1#) ≡ x) →
(∀ x → (x + (- x)) ≡ 0#) →
0# ≢ 1# →
(Σ (C → ↑ _ ⊤ ⊎ C) λ _⁻¹ →
(∀ x → (x ⁻¹) ≡ inj₁ (lift tt) → x ≡ 0#) ×
(∀ x y → (x ⁻¹) ≡ inj₂ y → (x * y) ≡ 1#))
↔
(((x y : C) → x ≡ y ⊎ x ≢ y) ×
(∀ x → x ≢ 0# → ∃ λ y → (x * y) ≡ 1#))
main-lemma C _+_ 0# _*_ 1# -_
+-assoc *-assoc +-comm *-comm *+ +0 *1 +- 0≢1 =
_≃_.bijection $
Eq.⇔→≃
(proposition-lemma₃ ext _+_ 0# _*_ 1# -_
+-assoc *-assoc +-comm *-comm
*+ +0 *1 +- 0≢1)
(proposition-lemma₁ ext 0# _*_ 1# *-assoc *-comm *1)
to
from
where
To = (((x y : C) → x ≡ y ⊎ x ≢ y) ×
(∀ x → x ≢ 0# → ∃ λ y → (x * y) ≡ 1#))
From = Σ (C → ↑ _ ⊤ ⊎ C) λ _⁻¹ →
(∀ x → (x ⁻¹) ≡ inj₁ (lift tt) → x ≡ 0#) ×
(∀ x y → (x ⁻¹) ≡ inj₂ y → (x * y) ≡ 1#)
to : From → To
to (_⁻¹ , ⁻¹₁ , ⁻¹₂) = (dec , inv)
where
dec : Decidable (_≡_ {A = C})
dec = dec-lemma₂ _+_ 0# _*_ 1# -_ _⁻¹ +-assoc +-comm *-comm *+
+0 *1 +- 0≢1 ⁻¹₁ ⁻¹₂
inv : ∀ x → x ≢ 0# → ∃ λ y → (x * y) ≡ 1#
inv x x≢0 with x ⁻¹ | ⁻¹₁ x | ⁻¹₂ x
... | inj₁ _ | hyp | _ = ⊥-elim $ x≢0 (hyp (refl _))
... | inj₂ y | _ | hyp = y , hyp y (refl _)
from : To → From
from (dec , inv) = (_⁻¹ , ⁻¹₁ , ⁻¹₂)
where
_⁻¹ : C → ↑ _ ⊤ ⊎ C
x ⁻¹ = ⊎-map (λ _ → _) (proj₁ ∘ inv x) (dec x 0#)
⁻¹₁ : ∀ x → (x ⁻¹) ≡ inj₁ (lift tt) → x ≡ 0#
⁻¹₁ x x⁻¹≡₁ with dec x 0#
... | inj₁ x≡0 = x≡0
... | inj₂ x≢0 = ⊥-elim $ ⊎.inj₁≢inj₂ (sym x⁻¹≡₁)
⁻¹₂ : ∀ x y → (x ⁻¹) ≡ inj₂ y → (x * y) ≡ 1#
⁻¹₂ x y x⁻¹≡y with dec x 0#
... | inj₁ x≡0 = ⊥-elim $ ⊎.inj₁≢inj₂ x⁻¹≡y
... | inj₂ x≢0 =
(x * y) ≡⟨ cong (_*_ _) $ sym $ ⊎.cancel-inj₂ x⁻¹≡y ⟩
(x * proj₁ (inv x x≢0)) ≡⟨ proj₂ (inv x x≢0) ⟩∎
1# ∎
lemma₁ : (A B C D E F : Type₁) (G : A × B × C × D × E × F → Type₁) →
Σ (A × B × C × D × E × F) G ↔
Σ (A × B × C × D × E) λ { (a , b , c , d , e) →
Σ F λ f → G (a , b , c , d , e , f) }
lemma₁ A B C D E F G =
Σ (A × B × C × D × E × F) G ↝⟨ Σ-cong (×-assoc ⊚ ×-assoc ⊚ ×-assoc ⊚ ×-assoc) (λ _ → _ □) ⟩
(Σ (((((A × B) × C) × D) × E) × F)
λ { (((((a , b) , c) , d) , e) , f) →
G (a , b , c , d , e , f) }) ↝⟨ inverse Σ-assoc ⟩
(Σ ((((A × B) × C) × D) × E)
λ { ((((a , b) , c) , d) , e) →
Σ F λ f → G (a , b , c , d , e , f) }) ↝⟨ Σ-cong (inverse (×-assoc ⊚ ×-assoc ⊚ ×-assoc)) (λ _ → _ □) ⟩□
(Σ (A × B × C × D × E) λ { (a , b , c , d , e) →
Σ F λ f → G (a , b , c , d , e , f) }) □
lemma₂ : (A B C D E F G H I J : Type₁) (K : A → Type₁) →
(Σ A λ x → B × C × D × E × F × G × H × I × J × K x) ↔
(B × C × D × E × F × G × H × I × J × Σ A K)
lemma₂ A B C D E F G H I J K =
(Σ A λ x → B × C × D × E × F × G × H × I × J × K x) ↝⟨ ∃-cong (λ _ → ×-assoc ⊚ ×-assoc ⊚ ×-assoc ⊚ ×-assoc ⊚
×-assoc ⊚ ×-assoc ⊚ ×-assoc ⊚ ×-assoc) ⟩
(Σ A λ x → ((((((((B × C) × D) × E) × F) × G) × H) × I) × J) × K x) ↝⟨ ∃-comm ⟩
(((((((((B × C) × D) × E) × F) × G) × H) × I) × J) × Σ A K) ↝⟨ inverse (×-assoc ⊚ ×-assoc ⊚ ×-assoc ⊚ ×-assoc ⊚
×-assoc ⊚ ×-assoc ⊚ ×-assoc ⊚ ×-assoc) ⟩□
(B × C × D × E × F × G × H × I × J × Σ A K) □
-- nLab defines a discrete field as a commutative ring satisfying the
-- property that "an element is invertible xor it equals zero"
-- (http://ncatlab.org/nlab/show/field). This definition can also be
-- encoded in our framework (assuming that I interpreted the informal
-- definitions correctly).
discrete-field-à-la-nLab : Code
discrete-field-à-la-nLab =
-- Addition.
(id ⇾ id ⇾ id) ⊗
-- Zero.
id ⊗
-- Multiplication.
(id ⇾ id ⇾ id) ⊗
-- One.
id ⊗
-- Minus.
(id ⇾ id) ,
λ { C (_+_ , 0# , _*_ , 1# , -_) →
(-- Associativity.
(∀ x y z → (x + (y + z)) ≡ ((x + y) + z)) ×
(∀ x y z → (x * (y * z)) ≡ ((x * y) * z)) ×
-- Commutativity.
(∀ x y → (x + y) ≡ (y + x)) ×
(∀ x y → (x * y) ≡ (y * x)) ×
-- Distributivity.
(∀ x y z → (x * (y + z)) ≡ ((x * y) + (x * z))) ×
-- Identity laws.
(∀ x → (x + 0#) ≡ x) ×
(∀ x → (x * 1#) ≡ x) ×
-- Additive inverse law.
(∀ x → (x + (- x)) ≡ 0#) ×
-- An element is invertible xor it equals zero.
(∀ x → (∃ λ y → (x * y) ≡ 1#) Xor (x ≡ 0#))) ,
λ ass → let open Assumptions ass in
[inhabited⇒+]⇒+ 0 λ { (+-assoc , *-assoc , +-comm , *-comm , _ ,
+0 , *1 , +- , inv-xor) →
let C-set : Is-set C
C-set = decidable⇒set $
dec-lemma₃ _+_ 0# -_ _*_ 1# +-assoc *-assoc
+-comm *-comm +0 *1 +- inv-xor
in
×-closure 1 (Π-closure ext₁ 1 λ _ →
Π-closure ext₁ 1 λ _ →
Π-closure ext₁ 1 λ _ →
C-set)
(×-closure 1 (Π-closure ext₁ 1 λ _ →
Π-closure ext₁ 1 λ _ →
Π-closure ext₁ 1 λ _ →
C-set)
(×-closure 1 (Π-closure ext₁ 1 λ _ →
Π-closure ext₁ 1 λ _ →
C-set)
(×-closure 1 (Π-closure ext₁ 1 λ _ →
Π-closure ext₁ 1 λ _ →
C-set)
(×-closure 1 (Π-closure ext₁ 1 λ _ →
Π-closure ext₁ 1 λ _ →
Π-closure ext₁ 1 λ _ →
C-set)
(×-closure 1 (Π-closure ext₁ 1 λ _ →
C-set)
(×-closure 1 (Π-closure ext₁ 1 λ _ →
C-set)
(×-closure 1 (Π-closure ext₁ 1 λ _ →
C-set)
(proposition-lemma₂ ext₁ _+_ 0# -_ _*_ 1#
+-assoc *-assoc +-comm *-comm
+0 *1 +-)))))))) }}
-- nLab's definition of discrete fields is isomorphic to the variant
-- of Bridges and Richman's definition given above (assuming
-- extensionality, and assuming that I interpreted the informal
-- definitions correctly).
nLab's-isomorphic-to-Bridges-and-Richman's :
Extensionality (# 1) (# 1) →
Instance discrete-field-à-la-nLab
↔
Instance discrete-field-à-la-Bridges-and-Richman
nLab's-isomorphic-to-Bridges-and-Richman's ext =
∃-cong λ C →
∃-cong λ { (_+_ , 0# , _*_ , 1# , -_) →
∃-cong λ +-assoc →
∃-cong λ *-assoc →
∃-cong λ +-comm →
∃-cong λ *-comm →
∃-cong λ *+ →
∃-cong λ +0 →
∃-cong λ *1 →
∃-cong λ +- →
main-lemma C _+_ 0# _*_ 1# -_
+-assoc *-assoc +-comm *-comm *+ +0 *1 +- }
where
main-lemma :
(C : Type₁)
(_+_ : C → C → C)
(0# : C)
(_*_ : C → C → C)
(1# : C)
(-_ : C → C) →
(∀ x y z → (x + (y + z)) ≡ ((x + y) + z)) →
(∀ x y z → (x * (y * z)) ≡ ((x * y) * z)) →
(∀ x y → (x + y) ≡ (y + x)) →
(∀ x y → (x * y) ≡ (y * x)) →
(∀ x y z → (x * (y + z)) ≡ ((x * y) + (x * z))) →
(∀ x → (x + 0#) ≡ x) →
(∀ x → (x * 1#) ≡ x) →
(∀ x → (x + (- x)) ≡ 0#) →
(∀ x → (∃ λ y → (x * y) ≡ 1#) Xor (x ≡ 0#))
↔
(0# ≢ 1# ×
((x y : C) → x ≡ y ⊎ x ≢ y) ×
(∀ x → x ≢ 0# → ∃ λ y → (x * y) ≡ 1#))
main-lemma C _+_ 0# _*_ 1# -_
+-assoc *-assoc +-comm *-comm *+ +0 *1 +- =
_≃_.bijection $
Eq.⇔→≃
(proposition-lemma₂ ext _+_ 0# -_ _*_ 1#
+-assoc *-assoc +-comm *-comm
+0 *1 +-)
(×-closure 1
(¬-propositional (lower-ext (# 0) _ ext))
(proposition-lemma₁ ext 0# _*_ 1# *-assoc
*-comm *1))
to
from
where
To = 0# ≢ 1# ×
((x y : C) → x ≡ y ⊎ x ≢ y) ×
(∀ x → x ≢ 0# → ∃ λ y → (x * y) ≡ 1#)
From = ∀ x → (∃ λ y → (x * y) ≡ 1#) Xor (x ≡ 0#)
to : From → To
to inv-xor = (0≢1 , dec , inv)
where
0≢1 : 0# ≢ 1#
0≢1 0≡1 =
[ (λ { (_ , 1≢0) → 1≢0 (sym 0≡1) })
, (λ { (∄y[1y≡1] , _) → ∄y[1y≡1] (1# , *1 1#) })
] (inv-xor 1#)
dec : Decidable (_≡_ {A = C})
dec = dec-lemma₃ _+_ 0# -_ _*_ 1# +-assoc *-assoc +-comm *-comm
+0 *1 +- inv-xor
inv : ∀ x → x ≢ 0# → ∃ λ y → (x * y) ≡ 1#
inv x x≢0 =
[ proj₁
, (λ { (_ , x≡0) → ⊥-elim (x≢0 x≡0) })
] (inv-xor x)
from : To → From
from (0≢1 , dec , inv) x =
[ (λ x≡0 → inj₂ ( (λ { (y , xy≡1) → 0≢1 (0# ≡⟨ sym $ 0* _+_ 0# _*_ 1# -_ +-assoc +-comm *-comm *+ +0 *1 +- y ⟩
(0# * y) ≡⟨ cong (λ x → x * y) $ sym x≡0 ⟩
(x * y) ≡⟨ xy≡1 ⟩∎
1# ∎) })
, x≡0
))
, (λ x≢0 → inj₁ (inv x x≢0 , x≢0))
] (dec x 0#)
------------------------------------------------------------------------
-- An example: vector spaces over discrete fields
-- Vector spaces over a particular discrete field.
vector-space : Instance discrete-field → Code
vector-space (F , (_+F_ , _ , _*F_ , 1F , _ , _) , _) =
-- Addition.
(id ⇾ id ⇾ id) ⊗
-- Scalar multiplication.
(k F ⇾ id ⇾ id) ⊗
-- Zero vector.
id ⊗
-- Additive inverse.
(id ⇾ id) ,
λ { V (_+_ , _*_ , 0V , -_) →
-- The carrier type is a set.
(Is-set V ×
-- Associativity.
(∀ u v w → (u + (v + w)) ≡ ((u + v) + w)) ×
(∀ x y v → (x * (y * v)) ≡ ((x *F y) * v)) ×
-- Commutativity.
(∀ u v → (u + v) ≡ (v + u)) ×
-- Distributivity.
(∀ x u v → (x * (u + v)) ≡ ((x * u) + (x * v))) ×
(∀ x y v → ((x +F y) * v) ≡ ((x * v) + (y * v))) ×
-- Identity laws.
(∀ v → (v + 0V) ≡ v) ×
(∀ v → (1F * v) ≡ v) ×
-- Inverse law.
(∀ v → (v + (- v)) ≡ 0V)) ,
λ ass → let open Assumptions ass in
[inhabited⇒+]⇒+ 0 λ { (V-set , _) →
×-closure 1 (H-level-propositional ext₁ 2)
(×-closure 1 (Π-closure ext₁ 1 λ _ →
Π-closure ext₁ 1 λ _ →
Π-closure ext₁ 1 λ _ →
V-set)
(×-closure 1 (Π-closure ext₁ 1 λ _ →
Π-closure ext₁ 1 λ _ →
Π-closure ext₁ 1 λ _ →
V-set)
(×-closure 1 (Π-closure ext₁ 1 λ _ →
Π-closure ext₁ 1 λ _ →
V-set)
(×-closure 1 (Π-closure ext₁ 1 λ _ →
Π-closure ext₁ 1 λ _ →
Π-closure ext₁ 1 λ _ →
V-set)
(×-closure 1 (Π-closure ext₁ 1 λ _ →
Π-closure ext₁ 1 λ _ →
Π-closure ext₁ 1 λ _ →
V-set)
(×-closure 1 (Π-closure ext₁ 1 λ _ →
V-set)
(×-closure 1 (Π-closure ext₁ 1 λ _ →
V-set)
(Π-closure ext₁ 1 λ _ →
V-set)))))))) }}
-- The interpretation of the code is reasonable.
Instance-vector-space :
∀ {F _+F_ 0F _*F_ 1F -F_ _⁻¹F laws} →
Instance (vector-space
(F , (_+F_ , 0F , _*F_ , 1F , -F_ , _⁻¹F) , laws))
≡
Σ Type₁ λ V →
Σ ((V → V → V) × (F → V → V) × V × (V → V))
λ { (_+_ , _*_ , 0V , -_) →
Is-set V ×
(∀ u v w → (u + (v + w)) ≡ ((u + v) + w)) ×
(∀ x y v → (x * (y * v)) ≡ ((x *F y) * v)) ×
(∀ u v → (u + v) ≡ (v + u)) ×
(∀ x u v → (x * (u + v)) ≡ ((x * u) + (x * v))) ×
(∀ x y v → ((x +F y) * v) ≡ ((x * v) + (y * v))) ×
(∀ v → (v + 0V) ≡ v) ×
(∀ v → (1F * v) ≡ v) ×
(∀ v → (v + (- v)) ≡ 0V) }
Instance-vector-space = refl _
-- The notion of isomorphism that we get is also reasonable.
Isomorphic-vector-space :
∀ {F V₁ _+₁_ _*₁_ 0₁ -₁_ laws₁
V₂ _+₂_ _*₂_ 0₂ -₂_ laws₂} →
Isomorphic (vector-space F)
(V₁ , (_+₁_ , _*₁_ , 0₁ , -₁_) , laws₁)
(V₂ , (_+₂_ , _*₂_ , 0₂ , -₂_) , laws₂)
≡
Σ (V₁ ≃ V₂) λ eq → let open _≃_ eq in
((λ u v → to (from u +₁ from v)) ,
(λ x v → to (x *₁ from v)) ,
to 0₁ ,
(λ x → to (-₁ from x))) ≡
(_+₂_ , _*₂_ , 0₂ , -₂_)
Isomorphic-vector-space = refl _
------------------------------------------------------------------------
-- An example: sets equipped with fixpoint operators
set-with-fixpoint-operator : Code
set-with-fixpoint-operator =
(id ⇾ id) ⇾ id ,
λ C fix →
-- The carrier type is a set.
(Is-set C ×
-- The fixpoint operator property.
(∀ f → f (fix f) ≡ fix f)) ,
λ ass → let open Assumptions ass in
[inhabited⇒+]⇒+ 0 λ { (C-set , _) →
×-closure 1 (H-level-propositional ext₁ 2)
(Π-closure ext₁ 1 λ _ →
C-set) }
-- Some unfolding lemmas.
Instance-set-with-fixpoint-operator :
Instance set-with-fixpoint-operator
≡
Σ Type₁ λ C →
Σ ((C → C) → C) λ fix →
Is-set C ×
(∀ f → f (fix f) ≡ fix f)
Instance-set-with-fixpoint-operator = refl _
Isomorphic-set-with-fixpoint-operator :
∀ {C₁ fix₁ laws₁ C₂ fix₂ laws₂} →
Isomorphic set-with-fixpoint-operator
(C₁ , fix₁ , laws₁) (C₂ , fix₂ , laws₂)
≡
Σ (C₁ ≃ C₂) λ eq → let open _≃_ eq in
(λ f → to (fix₁ (λ x → from (f (to x))))) ≡ fix₂
Isomorphic-set-with-fixpoint-operator = refl _
Isomorphic′-set-with-fixpoint-operator :
∀ {C₁ fix₁ laws₁ C₂ fix₂ laws₂} →
Isomorphic′ set-with-fixpoint-operator
(C₁ , fix₁ , laws₁) (C₂ , fix₂ , laws₂)
≡
Σ (C₁ ≃ C₂) λ eq → let open _≃_ eq in
∀ f g →
(∀ x y → to x ≡ y → to (f x) ≡ g y) →
to (fix₁ f) ≡ fix₂ g
Isomorphic′-set-with-fixpoint-operator = refl _
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.